import { h } from "@stencil/core";
import { findOrCreateOnReady } from "../utils";
export class TableExportButton {
  constructor() {
    this.buttonClicked = () => this.clickHandler();
    this.author = undefined;
    this.filename = undefined;
    this.format = "csv";
    this.pageOrientation = undefined;
    this.pageSubtitle = undefined;
    this.pageTitle = undefined;
    this.tableId = undefined;
    this.url = undefined;
    this.customButton = false;
    this.exportCtrl = undefined;
  }
  async clickHandler() {
    if (this.exportCtrl == undefined) {
      this.exportCtrl = await findOrCreateOnReady("gl-table-export-controller");
    }
    this.exportCtrl.create(this);
  }
  render() {
    return (h("ion-button", { "ion-button": true, onClick: this.buttonClicked }, this.customButton ? h("slot", null) : this.format.toUpperCase()));
  }
  static get is() { return "gl-table-export-button"; }
  static get properties() {
    return {
      "author": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "If this is for a pdf export, the author variable of the pdf document."
        },
        "attribute": "author",
        "reflect": false
      },
      "filename": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "When the document is exported, what file name it should be saved as."
        },
        "attribute": "filename",
        "reflect": false
      },
      "format": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "\"csv\" | \"pdf\"",
          "resolved": "\"csv\" | \"pdf\"",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "The format in which the document should be exported, either csv or pdf."
        },
        "attribute": "format",
        "reflect": false,
        "defaultValue": "\"csv\""
      },
      "pageOrientation": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "\"landscape\" | \"portrait\"",
          "resolved": "\"landscape\" | \"portrait\"",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "The orientation of the exported document"
        },
        "attribute": "page-orientation",
        "reflect": false
      },
      "pageSubtitle": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "The subtitle of the document if the document is exported as a pdf"
        },
        "attribute": "page-subtitle",
        "reflect": false
      },
      "pageTitle": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "The title of the document if the document is exported as a pdf."
        },
        "attribute": "page-title",
        "reflect": false
      },
      "tableId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "The id of the [table]{@link ../table} this export button is for."
        },
        "attribute": "table-id",
        "reflect": false
      },
      "url": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "If this value is defined the application will attempt to send the contents of the pdf in a POST request to the specified\nurl when the export button is clicked, in addition to presenting it to the user for download."
        },
        "attribute": "url",
        "reflect": false
      },
      "customButton": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "If true the JSX component for the table-export-button will expose a <slot /> for a custom button whereas otherwise it is this.format.toUpperCase()\naka CSV or PDF"
        },
        "attribute": "custom-button",
        "reflect": false,
        "defaultValue": "false"
      }
    };
  }
  static get states() {
    return {
      "exportCtrl": {}
    };
  }
}
//# sourceMappingURL=table-export-button.js.map
