export class TableColumn {
  constructor() {
    this.attribute = undefined;
    this.cellClassAttribute = undefined;
    this.component = undefined;
    this.componentProps = undefined;
    this.csv = true;
    this.format = undefined;
    this.label = undefined;
    this.pdf = true;
    this.sortable = true;
    this.visible = true;
  }
  componentWillLoad() {
    this.updateFormat();
  }
  componentDidLoad() {
    this.change();
  }
  componentDidUpdate() {
    this.change();
  }
  disconnectedCallback() {
    this.change();
  }
  updateFormat() {
    if (typeof this.format === "string") {
      let format;
      try {
        format = JSON.parse(this.format);
      }
      catch (e) {
        if (/SyntaxError/.test(e)) {
          if (["currency", "decimal", "percent"].indexOf(this.format) !== -1) {
            format = {
              style: this.format,
            };
            if (this.format === "currency")
              format["currency"] = "USD";
          }
        }
        else {
          throw e;
        }
      }
      this.format = format;
    }
  }
  change() {
    this.glTableColumnChanged.emit(this);
  }
  static get is() { return "gl-table-column"; }
  static get properties() {
    return {
      "attribute": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "What attribute in the data this specific column represents"
        },
        "attribute": "attribute",
        "reflect": false
      },
      "cellClassAttribute": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "The name of the attribute which holds the css class name for the cells of this column."
        },
        "attribute": "cell-class-attribute",
        "reflect": false
      },
      "component": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "The name of the JSX component which is used to render this cell, if any"
        },
        "attribute": "component",
        "reflect": false
      },
      "componentProps": {
        "type": "any",
        "mutable": false,
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Additional properties passed to a JSX component used to render this cell"
        },
        "attribute": "component-props",
        "reflect": false
      },
      "csv": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Whether or not this column will be exported if the user exports the table as a csv document.\nIn effect setting this option to false is a way to exclude this column from csv exports."
        },
        "attribute": "csv",
        "reflect": false,
        "defaultValue": "true"
      },
      "format": {
        "type": "any",
        "mutable": true,
        "complexType": {
          "original": "string | any",
          "resolved": "any",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "If the contents of this column are text based, the format of that text.\nThis could either be the strings \"currency\", \"decimal\", \"percent\", or an object that represents the options sent to a toLocaleString call.\n\nE.g. format=\"currency\" or format={style:\"decimal\", notation:\"scientific\"}"
        },
        "attribute": "format",
        "reflect": false
      },
      "label": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "A label for this column, used in the toggle-visibility button and when choosing ascending or descending sort order."
        },
        "attribute": "label",
        "reflect": false
      },
      "pdf": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Whether or not this column will be exported if the user exports the table as a pdf document.\nIn effect setting this option to false is a way to exclude this column from pdf exports."
        },
        "attribute": "pdf",
        "reflect": false,
        "defaultValue": "true"
      },
      "sortable": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Whether or not the data can be sorted by the contents of this column."
        },
        "attribute": "sortable",
        "reflect": false,
        "defaultValue": "true"
      },
      "visible": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Whether or not this column is rendered and visible to the user."
        },
        "attribute": "visible",
        "reflect": false,
        "defaultValue": "true"
      }
    };
  }
  static get events() {
    return [{
        "method": "glTableColumnChanged",
        "name": "glTableColumnChanged",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "An event emitted when the column updates for any reason, including when it is disconnected"
        },
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        }
      }];
  }
  static get watchers() {
    return [{
        "propName": "format",
        "methodName": "updateFormat"
      }];
  }
}
//# sourceMappingURL=table-column.js.map
