import { Component, Event, h, Listen, Prop } from "@stencil/core";
import { isDefined } from "../model";
export class IntergiroTableRow {
  constructor() {
    this.opened = "";
    this.selected = false;
  }
  handleColumnClick(column) {
    this.opened = column;
    this.columnClicked.emit({ index: this.index, column });
  }
  handleSelected(event) {
    this.valueSelected.emit({ id: this.identifier, value: this.value, checked: event.detail.selected });
    event.stopPropagation();
  }
  render() {
    return [
      this.selectable && (h("td", { class: "checkbox" },
        h("smoothly-checkbox", { selected: this.selected }))),
      this.row.filter(isDefined).map((v, index) => (h("td", { class: v.align == "right" ? "right" : "" },
        h("section", { class: v.openable ? "openable" + (this.opened == index.toString() ? " opened" : "") : "", onClick: () => v.openable && this.handleColumnClick(index.toString()) }, v.column)))),
    ];
  }
  static get is() { return "ig-table-row"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "row": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "({ column: any; openable?: boolean; align?: \"right\" | \"left\" } | undefined)[]",
        "resolved": "({ column: any; openable?: boolean | undefined; align?: \"right\" | \"left\" | undefined; } | undefined)[]",
        "references": {}
      },
      "required": true,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "opened": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "opened",
      "reflect": false,
      "defaultValue": "\"\""
    },
    "index": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "index",
      "reflect": false
    },
    "identifier": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "identifier",
      "reflect": false
    },
    "value": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "value",
      "reflect": false
    },
    "selectable": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "selectable",
      "reflect": false
    },
    "selected": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "selected",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get events() { return [{
      "method": "columnClicked",
      "name": "columnClicked",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "valueSelected",
      "name": "valueSelected",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "{ id: string; value: any; checked: boolean }",
        "resolved": "{ id: string; value: any; checked: boolean; }",
        "references": {}
      }
    }]; }
  static get listeners() { return [{
      "name": "checked",
      "method": "handleSelected",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
