'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-305226cb.js');
const index$1 = require('./index-f92a5850.js');
require('./v4-c23234d2.js');

const bsTextareaFieldCss = "bs-textarea-field{display:block;width:100%}";

const BsTextareaField = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    /** Native attributes to pass through to the input element. */
    this.attrs = {};
    this.charMax = undefined;
    this.disabled = false;
    this.error = undefined;
    this.errorMsg = undefined;
    this.hint = undefined;
    this.hints = undefined;
    this.inputId = undefined;
    this.label = undefined;
    this.placeholder = undefined;
    this.required = undefined;
    this.rows = 6;
    this.value = '';
    this.passAttrs = '';
    this.hintId = null;
  }
  get charCount() {
    var _a;
    return ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
  }
  get hintMsg() {
    return this.errorMsg || this.hint || this.hintDeprecated || undefined;
  }
  // Temporary holdover; removing this very soon
  get hintDeprecated() {
    var _a, _b;
    return ((_b = (_a = this.hints) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '\n')) || this.hints;
  }
  get inputIdAttr() {
    return this.inputId || this.inputIdGen;
  }
  componentWillLoad() {
    this.inputIdGen = this.inputId || index$1.genId();
    this.hintId = this.hintMsg ? index$1.genId() : null;
    this.attrs = index$1.getHostAttrs(this.hostEl, [
      'autocomplete',
      'cols',
      'maxlength',
      'minlength',
      'name',
      ...this.passAttrs.split(',')
    ]);
  }
  render() {
    return (index.h(index.Host, null, this.label && (index.h("bs-label", { for: this.inputIdAttr, disabled: this.disabled, required: this.required }, this.label)), index.h("bs-textarea", Object.assign({ disabled: this.disabled, error: this.error, "hint-id": this.hintId, "input-id": this.inputIdAttr, "pass-attrs": this.passAttrs, placeholder: this.placeholder, required: this.required, rows: this.rows, value: this.value }, this.attrs)), (this.hintMsg || this.charMax) && (index.h("bs-field-details", { "char-count": this.charCount, "char-max": this.charMax, error: this.error, "error-msg": this.errorMsg, hint: this.hint || this.hintDeprecated, "hint-id": this.hintId }))));
  }
  get hostEl() { return index.getElement(this); }
};
BsTextareaField.style = bsTextareaFieldCss;

exports.bs_textarea_field = BsTextareaField;

//# sourceMappingURL=bs-textarea-field.cjs.entry.js.map