import { withHooks } from "@saasquatch/stencil-hooks";
import { Component, h, Host, Method, Prop } from "@stencil/core";
import { useRequestRerender } from "../../../tables/re-render";
/**
 * @uiName Referral Table Date Column
 * @validParents ["sqm-referral-table"]
 * @exampleGroup Referrals
 * @example Referral Table Date Column - <sqm-referral-table-date-column column-title="Date converted" date-shown="dateConverted"></sqm-referral-table-date-column>
 */
export class ReferralTableDateColumn {
  constructor() {
    /**
     * @uiName Date column title
     */
    this.columnTitle = "Date converted";
    /**
     * @uiName Date displayed
     * @uiType string
     * @uiEnum ["dateConverted",
     * "dateReferralStarted",
     * "dateFraudChecksCompleted",
     * "dateModerated",
     * "dateModified",
     * "dateReferralEnded",
     * "dateReferralPaid",
     * "dateUserModified"]
     * @uiEnumNames ["Date Converted",
     * "Date Referral Started",
     * "Date Fraud Checks Completed",
     * "Date Moderated",
     * "Date Modified",
     * "Date Referral Ended",
     * "Date Referral Paid",
     * "Date User Modified"]
     */
    this.dateShown = "dateConverted";
    withHooks(this);
  }
  disconnectedCallback() { }
  async renderCell(data, options) {
    // TODO - Validate `dateShown` against a set of known values
    return (h("sqm-referral-table-date-cell", { date: data[this.dateShown], locale: options === null || options === void 0 ? void 0 : options.locale }));
  }
  async renderLabel() {
    return this.columnTitle;
  }
  async renderReferrerCell(data) {
    // TODO - Validate `dateShown` against a set of known values
    return (h("sqm-referral-table-date-cell", { date: data[this.dateShown] }));
  }
  render() {
    useRequestRerender([this.dateShown, this.columnTitle]);
    return h(Host, { style: { display: "none" } });
  }
  static get is() { return "sqm-referral-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 converted\""
    },
    "dateShown": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "ReferralDates",
        "resolved": "\"dateConverted\" | \"dateFraudChecksCompleted\" | \"dateModerated\" | \"dateModified\" | \"dateReferralEnded\" | \"dateReferralPaid\" | \"dateReferralStarted\" | \"dateUserModified\"",
        "references": {
          "ReferralDates": {
            "location": "import",
            "path": "../useReferralTable"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Date displayed",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }, {
            "text": "[\"dateConverted\",\n\"dateReferralStarted\",\n\"dateFraudChecksCompleted\",\n\"dateModerated\",\n\"dateModified\",\n\"dateReferralEnded\",\n\"dateReferralPaid\",\n\"dateUserModified\"]",
            "name": "uiEnum"
          }, {
            "text": "[\"Date Converted\",\n\"Date Referral Started\",\n\"Date Fraud Checks Completed\",\n\"Date Moderated\",\n\"Date Modified\",\n\"Date Referral Ended\",\n\"Date Referral Paid\",\n\"Date User Modified\"]",
            "name": "uiEnumNames"
          }],
        "text": ""
      },
      "attribute": "date-shown",
      "reflect": false,
      "defaultValue": "\"dateConverted\""
    }
  }; }
  static get methods() { return {
    "renderCell": {
      "complexType": {
        "signature": "(data: Referral, options?: { locale: string; }) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }, {
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Referral": {
            "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": []
      }
    },
    "renderReferrerCell": {
      "complexType": {
        "signature": "(data: Referrer) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Referrer": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        },
        "return": "Promise<any>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    }
  }; }
}
