import { r as registerInstance, h, H as Host, g as getElement } from './index-7e09edea.js';
import { v as v4, a as getHostAttrsWithId } from './index-ed2d325c.js';

const bsSelectFieldCss = "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.required = undefined;
    this.label = undefined;
    this.hints = undefined;
    this.placeholder = '';
    this.value = undefined;
    this.passAttrs = '';
    this.data = [];
    this.hintId = null;
  }
  componentWillLoad() {
    this.hintId = this.hints ? v4() : null;
    this.attrs = getHostAttrsWithId(this.hostEl, [
      'autocomplete',
      'max',
      'min',
      'maxlength',
      'minlength',
      'name',
      'placeholder',
      ...this.passAttrs.split(',')
    ]);
  }
  get validValue() {
    return this.value;
  }
  render() {
    return (h(Host, null, h("bs-field-layout", { disabled: this.disabled, error: this.error, hints: this.hints, label: this.label, "label-for": this.attrs.id, required: this.required, hintId: this.hintId }, h("bs-select", Object.assign({ disabled: this.disabled, error: this.error, required: this.required, value: this.validValue, hintId: this.hintId }, 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)))))));
  }
  get hostEl() { return getElement(this); }
};
BsSelectField.style = bsSelectFieldCss;

export { BsSelectField as bs_select_field };

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