import { ElementIDUtils } from '@sankhyalabs/core';
import { h } from '@stencil/core';
export class SnkFilterText {
  constructor() {
    this.config = undefined;
    this.value = undefined;
    this.errorMessage = undefined;
  }
  /**
   * Emitido quando acontece a alteração de valor do componente snk-filter-text.
   */
  ezChangeListener(evt) {
    this.errorMessage = undefined;
    this.value = evt.detail;
    this.valueChanged.emit(this.value);
  }
  /**
   * Define o foco no componente snk-filter-text.
   */
  async setFocus() {
    this._textInputElement.setFocus();
  }
  /**
   * Limpa o valor do componente restaurando o valor original da configuração.
   */
  async clearValue() {
    this.value = this.config.value;
    if (this._textInputElement) {
      this._textInputElement.value = this.config.value;
    }
  }
  componentDidLoad() {
    if (this._element) {
      ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
    }
  }
  render() {
    var _a;
    if (!this.config) {
      return undefined;
    }
    return (h("ez-tooltip", { active: this.config.enabled === false, message: this.config.disabledMessage, type: 'warning' }, h("ez-text-input", { id: this.config.id, label: this.config.label, ref: ref => this._textInputElement = ref, value: this.config.value, mask: (_a = this.config) === null || _a === void 0 ? void 0 : _a.mask, enabled: this.config.enabled, cleanValueMask: true, errorMessage: this.errorMessage })));
  }
  static get is() { return "snk-filter-text"; }
  static get properties() {
    return {
      "config": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "SnkFilterItemConfig",
          "resolved": "SnkFilterItemConfig",
          "references": {
            "SnkFilterItemConfig": {
              "location": "import",
              "path": "../snk-filter-item"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define as configura\u00E7\u00F5es do componente snk-filter-text."
        }
      },
      "value": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o valor do componente snk-filter-text."
        },
        "attribute": "value",
        "reflect": false
      },
      "errorMessage": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Usado para exibir mensagens de erro."
        },
        "attribute": "error-message",
        "reflect": true
      }
    };
  }
  static get events() {
    return [{
        "method": "valueChanged",
        "name": "valueChanged",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Emitido quando o valor do filtro \u00E9 alterado."
        },
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        }
      }];
  }
  static get methods() {
    return {
      "setFocus": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Define o foco no componente snk-filter-text.",
          "tags": []
        }
      },
      "clearValue": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Limpa o valor do componente restaurando o valor original da configura\u00E7\u00E3o.",
          "tags": []
        }
      }
    };
  }
  static get elementRef() { return "_element"; }
  static get listeners() {
    return [{
        "name": "ezChange",
        "method": "ezChangeListener",
        "target": undefined,
        "capture": false,
        "passive": false
      }];
  }
}
