import { Component, Element, Event, h, Host, Listen, Prop, State } from '@stencil/core';
export class DvnTableCell {
  constructor() {
    this.focused = false;
    this.isValueChanged = false;
  }
  onCellFormSubmit(event) {
    event.stopPropagation();
    this.cellValueChange.emit(event.detail);
    this.focused = false;
  }
  onCellFormCancel(event) {
    event.stopPropagation();
    this.focused = false;
  }
  render() {
    var _a, _b;
    const { focused, weight, width } = this;
    const style = {};
    if (weight) {
      style['--cell-weight'] = `${weight} 0 ${width || 100}px`;
      style['--cell-width'] = `0px`;
    }
    else {
      style['--cell-weight'] = `0 0 ${width}px`;
      style['--cell-width'] = `${width}px`;
    }
    return (h(Host, { class: { focused }, style: style, onClick: () => {
        if (!this.editable)
          return;
        this.focused = true;
      } },
      focused ? (_a = this.renderEdit) === null || _a === void 0 ? void 0 : _a.call(this) : (_b = this.renderDisplay) === null || _b === void 0 ? void 0 : _b.call(this),
      h("slot", null)));
  }
  static get is() { return "dvn-table-cell"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["dvn-table-cell.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-table-cell.css"]
  }; }
  static get properties() { return {
    "renderDisplay": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "render-display",
      "reflect": false
    },
    "renderEdit": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "render-edit",
      "reflect": false
    },
    "weight": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "weight",
      "reflect": false
    },
    "width": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "width",
      "reflect": false
    },
    "editable": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "editable",
      "reflect": false
    }
  }; }
  static get states() { return {
    "focused": {},
    "modifiedValue": {},
    "isValueChanged": {}
  }; }
  static get events() { return [{
      "method": "cellValueChange",
      "name": "cellValueChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
  static get elementRef() { return "el"; }
  static get listeners() { return [{
      "name": "cellFormSubmit",
      "method": "onCellFormSubmit",
      "target": undefined,
      "capture": false,
      "passive": false
    }, {
      "name": "cellFormCancel",
      "method": "onCellFormCancel",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
