import { h } from "@stencil/core";
import { States } from "src/utils/utils";
import "@maggioli-design-system/mds-text/dist/mds-text/mds-text";
export class SwInputText {
  constructor() {
    this.status = States.create;
    this.type = "text";
    this.maxLength = 100;
    this.value = undefined;
    this.typography = "h6";
    this.placeholderText = undefined;
  }
  render() {
    switch (this.status) {
      case States.create:
      case States.edit:
      default:
        return (h("div", null, h("input", { onClick: (ev) => {
            ev.preventDefault();
            ev.stopPropagation();
          }, class: "w-full", type: this.type, placeholder: this.placeholderText, maxLength: this.maxLength, value: this.value, onInput: (event) => this.handleChange(event) })));
      case States.view:
        return h("mds-text", { typography: this.typography }, this.value);
    }
  }
  handleChange(event) {
    this.value = event.target.value;
    this.updateText.emit(this.value);
  }
  static get is() { return "sw-input-text"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() {
    return {
      "$": ["sw-input-text.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["sw-input-text.css"]
    };
  }
  static get properties() {
    return {
      "status": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "States",
          "resolved": "States.create | States.edit | States.view",
          "references": {
            "States": {
              "location": "import",
              "path": "src/utils/utils"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "status",
        "reflect": false,
        "defaultValue": "States.create"
      },
      "type": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "type",
        "reflect": false,
        "defaultValue": "\"text\""
      },
      "maxLength": {
        "type": "number",
        "mutable": true,
        "complexType": {
          "original": "number",
          "resolved": "number",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "max-length",
        "reflect": false,
        "defaultValue": "100"
      },
      "value": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "value",
        "reflect": false
      },
      "typography": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "typography",
        "reflect": false,
        "defaultValue": "\"h6\""
      },
      "placeholderText": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "placeholder-text",
        "reflect": false
      }
    };
  }
  static get events() {
    return [{
        "method": "updateText",
        "name": "updateText",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        }
      }];
  }
}
