import { Host, h } from '@stencil/core';
import { getHostAttrsWithId } from '../../utils';
import { v4 as createId } from 'uuid';
/**
 * @docsPage
 */
export class BsTextareaField {
  constructor() {
    /** Native attributes to pass through to the input element. */
    this.attrs = {};
    this.charMax = undefined;
    this.disabled = false;
    this.error = undefined;
    this.hints = undefined;
    this.label = undefined;
    this.placeholder = undefined;
    this.required = undefined;
    this.value = '';
    this.passAttrs = '';
    this.hintId = null;
  }
  get charCount() {
    var _a;
    return ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
  }
  componentWillLoad() {
    this.hintId = this.hints ? createId() : null;
    this.attrs = getHostAttrsWithId(this.hostEl, [
      'autocomplete',
      'maxlength',
      'minlength',
      'name',
      ...this.passAttrs.split(',')
    ]);
  }
  render() {
    return (h(Host, null, h("bs-field-layout", { disabled: this.disabled, error: this.error, hints: this.hints, label: this.label, labelFor: this.attrs.id, required: this.required, charCount: this.charCount, charMax: this.charMax, hintId: this.hintId }, h("bs-textarea", Object.assign({ disabled: this.disabled, error: this.error, placeholder: this.placeholder, required: this.required, value: this.value, hintId: this.hintId }, this.attrs)))));
  }
  static get is() { return "bs-textarea-field"; }
  static get originalStyleUrls() {
    return {
      "$": ["bs-textarea-field.scss"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["bs-textarea-field.css"]
    };
  }
  static get properties() {
    return {
      "charMax": {
        "type": "number",
        "mutable": false,
        "complexType": {
          "original": "number",
          "resolved": "number",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Sets the maximum value this textarea will allow. Will also display character count if present. This does not set maxlength, so users are able to enter text that is longer and edit it down. Enforcement of length must be by the developer."
        },
        "attribute": "char-max",
        "reflect": false
      },
      "disabled": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Sets the disabled state on textarea, disabled styles on label."
        },
        "attribute": "disabled",
        "reflect": false,
        "defaultValue": "false"
      },
      "error": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Applies error styles to the input."
        },
        "attribute": "error",
        "reflect": false
      },
      "hints": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string | string[]",
          "resolved": "string | string[]",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Pass single helper/error text or array of text."
        },
        "attribute": "hints",
        "reflect": false
      },
      "label": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Pass label text."
        },
        "attribute": "label",
        "reflect": false
      },
      "placeholder": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Placeholder attribute - same as native attribute."
        },
        "attribute": "placeholder",
        "reflect": false
      },
      "required": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Sets the required state on the textarea, append required* indicator to label."
        },
        "attribute": "required",
        "reflect": false
      },
      "value": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Sets the textarea value."
        },
        "attribute": "value",
        "reflect": false,
        "defaultValue": "''"
      },
      "passAttrs": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "List additional attributes by name (comma-separated) to pass through to <input>."
        },
        "attribute": "pass-attrs",
        "reflect": false,
        "defaultValue": "''"
      }
    };
  }
  static get states() {
    return {
      "hintId": {}
    };
  }
  static get elementRef() { return "hostEl"; }
}
//# sourceMappingURL=bs-textarea-field.js.map
