'use strict';

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

const index = require('./index-128c5169.js');
const index$1 = require('./index-06cbe7f9.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) {
    index.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 ? index$1.v4() : null;
    this.attrs = index$1.getHostAttrsWithId(this.hostEl, [
      'autocomplete',
      'max',
      'min',
      'maxlength',
      'minlength',
      'name',
      'placeholder',
      ...this.passAttrs.split(',')
    ]);
  }
  get validValue() {
    return this.value;
  }
  render() {
    return (index.h(index.Host, null, index.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 }, index.h("bs-select", Object.assign({ disabled: this.disabled, error: this.error, required: this.required, value: this.validValue, hintId: this.hintId }, this.attrs), index.h("option", { selected: !this.validValue, disabled: false }, this.placeholder), this.data.map(option => (index.h("option", { value: option.value, selected: this.validValue === option.value, disabled: option.disabled }, option.label)))))));
  }
  get hostEl() { return index.getElement(this); }
};
BsSelectField.style = bsSelectFieldCss;

exports.bs_select_field = BsSelectField;

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