/*!
 * (C) Gasco https://gasco-web-component.herokuapp.com/ - MIT License
 */
import { Component, h, Element, State, Prop, Event } from '@stencil/core';
import { ellipsisVertical } from 'ionicons/icons';
export class GascoTableCol {
  constructor() {
    this.showList = false;
  }
  componentWillLoad() {
    this.getRowHeader();
  }
  getRowHeader() {
    const parent = this.el.parentElement.className;
    this.isColHeader = parent.includes('table-row-header');
  }
  render() {
    const { action, typeAction } = this;
    return (h("span", { part: "native", class: {
        'table-col': true,
        [`table-col-header`]: this.isColHeader
      } },
      h("slot", null),
      action && (h("button", { onFocus: () => this.showList = true, onBlur: () => setTimeout(() => this.showList = false, 200) },
        h("ion-icon", { icon: ellipsisVertical, lazy: false }))),
      this.showList && (h("gasco-list", null,
        h("gasco-item", { class: "table-action", onClick: () => this.gascoTableTypeAction.emit({ action: 'edit', data: typeAction }) }, "Editar"),
        h("gasco-item", { class: "table-action", onClick: () => this.gascoTableTypeAction.emit({ action: 'delete', data: typeAction }) }, "Eliminar")))));
  }
  static get is() { return "gasco-table-col"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["gasco-table-col.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["gasco-table-col.css"]
  }; }
  static get properties() { return {
    "action": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "action",
      "reflect": true
    },
    "typeAction": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "type-action",
      "reflect": true
    }
  }; }
  static get states() { return {
    "isColHeader": {},
    "showList": {}
  }; }
  static get events() { return [{
      "method": "gascoTableTypeAction",
      "name": "gascoTableTypeAction",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "ITableColTypeAction",
        "resolved": "ITableColTypeAction",
        "references": {
          "ITableColTypeAction": {
            "location": "import",
            "path": "../../interface"
          }
        }
      }
    }]; }
  static get elementRef() { return "el"; }
}
