import { withHooks } from "@saasquatch/stencil-hooks";
import { Component, h, Host, Method, Prop } from "@stencil/core";
import { useRequestRerender } from "../../../tables/re-render";
/**
 * @uiName Reward Table Date Column
 * @validParents ["sqm-rewards-table"]
 * @exampleGroup Rewards
 * @example Date Column - <sqm-rewards-table-date-column column-title="Date received" date-shown="dateGiven"></sqm-rewards-table-date-column>
 */
export class RewardTableDateColumn {
  constructor() {
    /**
     * @uiName Date column title
     */
    this.columnTitle = "Date received";
    /**
     * @uiName Date displayed
     * @uiType string
     * @uiEnum ["dateGiven",
     * "dateExpires",
     * "dateCancelled",
     * "dateRedeemed",
     * "dateScheduledFor"]
     * @uiEnumNames ["Date Given", "Date Expires", "Date Cancelled", "Date Redeemed", "Date Scheduled For"]
     */
    this.dateShown = "dateGiven";
    withHooks(this);
  }
  disconnectedCallback() { }
  async renderCell(data, options) {
    return (h("sqm-rewards-table-date-cell", { date: data[this.dateShown], locale: options === null || options === void 0 ? void 0 : options.locale }));
  }
  async renderLabel() {
    return this.columnTitle;
  }
  render() {
    useRequestRerender([this.dateShown, this.columnTitle]);
    return h(Host, { style: { display: "none" } });
  }
  static get is() { return "sqm-rewards-table-date-column"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "columnTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Date column title",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "column-title",
      "reflect": false,
      "defaultValue": "\"Date received\""
    },
    "dateShown": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Date displayed",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "[\"dateGiven\",\n\"dateExpires\",\n\"dateCancelled\",\n\"dateRedeemed\",\n\"dateScheduledFor\"]",
            "name": "uiEnum"
          }, {
            "text": "[\"Date Given\", \"Date Expires\", \"Date Cancelled\", \"Date Redeemed\", \"Date Scheduled For\"]",
            "name": "uiEnumNames"
          }],
        "text": ""
      },
      "attribute": "date-shown",
      "reflect": false,
      "defaultValue": "\"dateGiven\""
    }
  }; }
  static get methods() { return {
    "renderCell": {
      "complexType": {
        "signature": "(data: Reward, options?: { locale: string; }) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }, {
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Reward": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        },
        "return": "Promise<any>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    },
    "renderLabel": {
      "complexType": {
        "signature": "() => Promise<string>",
        "parameters": [],
        "references": {
          "Promise": {
            "location": "global"
          }
        },
        "return": "Promise<string>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    }
  }; }
}
