import { r as registerInstance, h, H as Host, g as getElement } from './index-92f6d7ee.js';
import { g as genId, a as getHostAttrs } from './index-7c9378a9.js';
import './v4-23648a96.js';

const bsSelectFieldCss = ":where(bs-select-field){display:block;width:100%}bs-label+bs-select select{margin-top:0.25rem}:where(.box) bs-select :where(input,textarea,select):focus{--offset-color:var(--bs-bg-subtle)}:where(.box[data-invert]) bs-select :where(input,textarea,select):focus{--offset-color:var(--bs-bg-invert)}";

const BsSelectField = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    /** Native attributes to pass through to the select element. */
    this.attrs = {};
    this.disabled = false;
    this.error = undefined;
    this.errorMsg = undefined;
    this.inputId = undefined;
    this.label = undefined;
    this.hint = undefined;
    this.hints = undefined;
    this.placeholder = '';
    this.required = undefined;
    this.value = undefined;
    this.passAttrs = '';
    this.data = [];
    this.hintId = null;
  }
  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 || genId();
    this.hintId = this.hintMsg ? genId() : null;
    this.attrs = getHostAttrs(this.hostEl, [
      'autocomplete',
      'max',
      'min',
      'maxlength',
      'minlength',
      'name',
      'placeholder',
      ...this.passAttrs.split(',')
    ]);
  }
  get validValue() {
    return this.value;
  }
  render() {
    return (h(Host, null, this.label && (h("bs-label", { for: this.inputIdAttr, disabled: this.disabled, required: this.required }, this.label)), h("bs-select", Object.assign({ disabled: this.disabled, error: this.error, "hint-id": this.hintId, "input-id": this.inputIdAttr, "pass-attrs": this.passAttrs, required: this.required, value: this.validValue }, this.attrs), h("option", { selected: !this.validValue, disabled: false }, this.placeholder), this.data.map(option => (h("option", { value: option.value, selected: this.validValue === option.value, disabled: option.disabled }, option.label)))), this.hintMsg && (h("bs-field-details", { error: this.error, "error-msg": this.errorMsg, hint: this.hint || this.hintDeprecated, "hint-id": this.hintId }))));
  }
  get hostEl() { return getElement(this); }
};
BsSelectField.style = bsSelectFieldCss;

export { BsSelectField as bs_select_field };

//# sourceMappingURL=bs-select-field.entry.js.map