monobill-mintui 0.6.675 → 0.6.677

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,8 @@ var t = class extends HTMLElement {
12
12
  "id",
13
13
  "name",
14
14
  "value",
15
- "required"
15
+ "required",
16
+ "loading"
16
17
  ];
17
18
  }
18
19
  constructor() {
@@ -43,7 +44,7 @@ var t = class extends HTMLElement {
43
44
  e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._checked = !!e, this._radio && (this._radio.checked = this._checked), this.updateVisualState();
44
45
  }
45
46
  isDisabled() {
46
- return this.hasAttribute("disabled");
47
+ return this.hasAttribute("disabled") || this.getAttribute("loading") === "true";
47
48
  }
48
49
  getLabel() {
49
50
  return this.getAttribute("label") || "";
@@ -78,13 +79,63 @@ var t = class extends HTMLElement {
78
79
  }), t ? this.setAttribute("value", t) : this.removeAttribute("value");
79
80
  }
80
81
  renderGroup() {
81
- this.classList.add("mint-choice-group"), this.setAttribute("role", "radiogroup");
82
- let e = this.getAttribute("label") || "", t = this.querySelector(":scope > .mint-choice-group-label");
83
- e && !t && (t = document.createElement("div"), t.className = "mint-choice-group-label", this.insertBefore(t, this.firstChild)), t && (e ? t.textContent = e : t.remove());
84
- let n = this.querySelector(":scope > .mint-choice-options");
85
- n || (n = document.createElement("div"), n.className = "mint-choice-options", t?.parentElement === this ? this.insertBefore(n, t.nextSibling) : this.insertBefore(n, this.firstChild)), Array.from(this.children).filter((e) => e.tagName === "MINT-CHOICE-OPTION" && e.parentElement !== n).forEach((e) => n.appendChild(e)), this.querySelectorAll("mint-choice-option").forEach((e) => e.render());
86
- let r = this.getAttribute("value");
87
- r && this.setValue(r);
82
+ let e = this.getAttribute("loading") === "true";
83
+ this.toggleAttribute("aria-busy", e), this.classList.add("mint-choice-group"), this.setAttribute("role", "radiogroup");
84
+ let t = this.getAttribute("label") || "", n = this.querySelector(":scope > .mint-choice-group-label");
85
+ t && !n && (n = document.createElement("div"), n.className = "mint-choice-group-label", this.insertBefore(n, this.firstChild)), n && (t ? n.textContent = t : n.remove());
86
+ let r = this.querySelector(":scope > .mint-choice-options");
87
+ r || (r = document.createElement("div"), r.className = "mint-choice-options", n?.parentElement === this ? this.insertBefore(r, n.nextSibling) : this.insertBefore(r, this.firstChild)), Array.from(this.children).filter((e) => e.tagName === "MINT-CHOICE-OPTION" && e.parentElement !== r).forEach((e) => r.appendChild(e)), this.querySelectorAll("mint-choice-option").forEach((t) => {
88
+ t.toggleAttribute("loading", e), t.render();
89
+ });
90
+ let i = this.getAttribute("value");
91
+ i && this.setValue(i);
92
+ let a = r.querySelector(":scope > .mint-choice-loading-skeleton");
93
+ if (e) {
94
+ r.style.position = "relative", a || (a = document.createElement("div"), a.className = "mint-choice-loading-skeleton", a.setAttribute("aria-hidden", "true"), Object.assign(a.style, {
95
+ position: "absolute",
96
+ inset: "0",
97
+ display: "flex",
98
+ flexDirection: "column",
99
+ pointerEvents: "none",
100
+ zIndex: "20"
101
+ }), r.appendChild(a)), a.style.gap = r.querySelector(":scope > mint-choice-option[info]") ? "0.75rem" : "0.55rem";
102
+ let e = r.querySelectorAll(":scope > mint-choice-option").length, t = Array.from(a.children);
103
+ for (; t.length > e;) t.pop()?.remove();
104
+ for (; t.length < e;) {
105
+ let e = t.length, n = document.createElement("div");
106
+ Object.assign(n.style, {
107
+ display: "flex",
108
+ alignItems: "center",
109
+ gap: "0.55rem",
110
+ minHeight: "1.25rem",
111
+ flex: "none"
112
+ });
113
+ let r = document.createElement("span");
114
+ Object.assign(r.style, {
115
+ display: "block",
116
+ width: "1.1rem",
117
+ height: "1.1rem",
118
+ flex: "none",
119
+ borderRadius: "50%",
120
+ background: "var(--mint-color-surface-control, #e8eee9)",
121
+ animation: "mint-choice-skeleton-pulse 1.4s ease-in-out infinite"
122
+ });
123
+ let i = document.createElement("span");
124
+ Object.assign(i.style, {
125
+ display: "block",
126
+ width: `${e % 2 ? "5rem" : "6rem"}`,
127
+ height: "1rem",
128
+ borderRadius: "0.35rem",
129
+ background: "var(--mint-color-surface-control, #e8eee9)",
130
+ animation: "mint-choice-skeleton-pulse 1.4s ease-in-out infinite"
131
+ }), n.append(r, i), a.appendChild(n), t.push(n);
132
+ }
133
+ a.style.display = "flex", r.querySelectorAll(":scope > mint-choice-option").forEach((e) => {
134
+ e.style.visibility = "hidden";
135
+ });
136
+ } else a && (a.style.display = "none"), r.style.position = "", r.querySelectorAll(":scope > mint-choice-option").forEach((e) => {
137
+ e.style.visibility = "";
138
+ });
88
139
  }
89
140
  _activateGroupModeIfNeeded() {
90
141
  this._groupMode || !this.querySelector("mint-choice-option") || (this._groupMode = !0, this.removeEventListeners(), this.querySelector(".mint-choice-wrapper")?.remove(), this.querySelector(".mint-choice-label-container")?.remove(), this._radio = null, this._groupChangeHandler = (e) => {
@@ -226,7 +277,8 @@ var t = class extends HTMLElement {
226
277
  return [
227
278
  "value",
228
279
  "checked",
229
- "disabled"
280
+ "disabled",
281
+ "loading"
230
282
  ];
231
283
  }
232
284
  constructor() {
@@ -250,7 +302,7 @@ var t = class extends HTMLElement {
250
302
  },
251
303
  bubbles: !1
252
304
  })));
253
- }, this._radio.addEventListener("change", this._changeHandler)), this._radio.name = e?.getAttribute("name") || "", this._radio.value = this.getAttribute("value") || "", this._radio.disabled = this.hasAttribute("disabled") || e?.hasAttribute("disabled") || !1, this._radio.required = e?.hasAttribute("required") || !1, this._radio.checked = this.hasAttribute("checked") || e?.getAttribute("value") === this._radio.value;
305
+ }, this._radio.addEventListener("change", this._changeHandler)), this._radio.name = e?.getAttribute("name") || "", this._radio.value = this.getAttribute("value") || "", this._radio.disabled = this.hasAttribute("disabled") || this.hasAttribute("loading") || e?.hasAttribute("disabled") || e?.hasAttribute("loading") || !1, this._radio.required = e?.hasAttribute("required") || !1, this._radio.checked = this.hasAttribute("checked") || e?.getAttribute("value") === this._radio.value;
254
306
  let r = n.querySelector(".mint-choice-option-label");
255
307
  r || (r = document.createElement("span"), r.className = "mint-choice-option-label", n.appendChild(r)), r.textContent = this._labelText;
256
308
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,0BAA0B,CAAA;AACjC,OAAO,kBAAkB,CAAA;AAIzB,cAAM,UAAW,SAAQ,WAAW;IAClC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,GAAG,CAA2D;IAEtE,iBAAiB,IAAI,IAAI;IAiBzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAoB9F,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,EAAE,CAG7B;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAA0B;IAC5D,IAAI,MAAM,IAAI,MAAM,EAAE,CAGrB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAA2B;IACtD,QAAQ,IAAI,MAAM,GAAG,MAAM,EAAE;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAa9B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IAEtB,OAAO,CAAC,MAAM;IAuId,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,UAAU;IAsDlB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,SAAS;CAUlB;AAGD,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,0BAA0B,CAAA;AACjC,OAAO,kBAAkB,CAAA;AAIzB,cAAM,UAAW,SAAQ,WAAW;IAClC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,GAAG,CAA2D;IAEtE,iBAAiB,IAAI,IAAI;IAiBzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAoB9F,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,EAAE,CAG7B;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAA0B;IAC5D,IAAI,MAAM,IAAI,MAAM,EAAE,CAGrB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAA2B;IACtD,QAAQ,IAAI,MAAM,GAAG,MAAM,EAAE;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAa9B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IAEtB,OAAO,CAAC,MAAM;IAqJd,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,UAAU;IAsDlB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,SAAS;CAUlB;AAGD,eAAe,UAAU,CAAA"}
@@ -431,7 +431,7 @@ var r = "data-mint-select-part", i = class extends HTMLElement {
431
431
  e.setAttribute(r, "label"), e.className = "mint-select-label", e.htmlFor = `${i}-trigger`, e.textContent = n, this.append(e);
432
432
  }
433
433
  let a = document.createElement("div");
434
- a.setAttribute(r, "wrap"), a.className = "mint-select-control-wrap", this.append(a);
434
+ a.setAttribute(r, "wrap"), a.className = "mint-select-control-wrap", a.style.position = "relative", this.append(a);
435
435
  let o = document.createElement("button");
436
436
  o.type = "button", o.id = `${i}-trigger`, o.className = "mint-select-trigger", o.disabled = this.isDisabled() || this.isLoading(), o.setAttribute("role", "combobox"), o.setAttribute("aria-busy", String(this.isLoading())), o.setAttribute("aria-haspopup", "listbox"), o.setAttribute("aria-expanded", "false"), o.setAttribute("aria-required", String(this.isRequired())), o.setAttribute("aria-invalid", String(this.hasError()));
437
437
  let s = this.getAttribute("aria-labelledby"), c = this.getAttribute("aria-label")?.trim();
@@ -443,38 +443,40 @@ var r = "data-mint-select-part", i = class extends HTMLElement {
443
443
  l.className = "mint-select-value", o.append(l);
444
444
  let u = document.createElement("span");
445
445
  u.className = "mint-select-caret", u.setAttribute("aria-hidden", "true"), u.innerHTML = "<mint-icon name=\"caret-up\"></mint-icon><mint-icon name=\"caret-down\"></mint-icon>", o.append(u), a.append(o);
446
- let d = document.createElement("select");
447
- d.setAttribute(r, "native"), d.className = "mint-select-native-control", d.id = `${i}-native`, d.name = this.getAttribute("name") || "", d.multiple = this.isMultiple(), this.hasAttribute("form") && d.setAttribute("form", this.getAttribute("form") || ""), d.required = this.isRequired(), d.disabled = this.isDisabled(), d.tabIndex = -1, d.setAttribute("aria-hidden", "true"), d.setAttribute("aria-invalid", String(this.hasError()));
448
- let f = [
446
+ let d = null;
447
+ this.isLoading() ? (d = document.createElement("div"), d.className = "mint-select-skeleton", d.setAttribute("aria-hidden", "true"), d.style.cssText = "position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;", a.append(d), o.style.visibility = "hidden", this.setAttribute("aria-busy", "true")) : this.removeAttribute("aria-busy");
448
+ let f = document.createElement("select");
449
+ f.setAttribute(r, "native"), f.className = "mint-select-native-control", f.id = `${i}-native`, f.name = this.getAttribute("name") || "", f.multiple = this.isMultiple(), this.hasAttribute("form") && f.setAttribute("form", this.getAttribute("form") || ""), f.required = this.isRequired(), f.disabled = this.isDisabled(), f.tabIndex = -1, f.setAttribute("aria-hidden", "true"), f.setAttribute("aria-invalid", String(this.hasError()));
450
+ let p = [
449
451
  this.getAttribute("aria-describedby"),
450
452
  n ? `${i}-label` : "",
451
453
  this.getAttribute("info") ? `${i}-info` : "",
452
454
  this.getAttribute("error-message") ? `${i}-error` : ""
453
455
  ].filter(Boolean).join(" ");
454
- if (f && d.setAttribute("aria-describedby", f), this.options().forEach((e) => d.append(e.cloneNode(!0))), !d.options.length) {
456
+ if (p && f.setAttribute("aria-describedby", p), this.options().forEach((e) => f.append(e.cloneNode(!0))), !f.options.length) {
455
457
  let e = document.createElement("option");
456
- e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0, d.append(e);
458
+ e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0, f.append(e);
457
459
  }
458
- if (d.multiple) {
460
+ if (f.multiple) {
459
461
  let n = t.length ? t : this.parseValues(this.getAttribute("values")).length ? this.parseValues(this.getAttribute("values")) : e ? [e] : [];
460
- n.length && Array.from(d.options).forEach((e) => {
462
+ n.length && Array.from(f.options).forEach((e) => {
461
463
  e.selected = n.includes(e.value);
462
464
  });
463
- } else d.value = e;
464
- a.append(d), this._native = d, this._trigger = o;
465
- let p = document.createElement("mint-popover");
466
- p.className = "mint-select-popover", p.setAttribute(r, "popover"), p.setAttribute("trigger-id", o.id), p.setAttribute("trigger-toggle", "false"), p.setAttribute("direction", "down"), p.setAttribute("trigger-align", "start"), p.setAttribute("align-selected", "true"), p.setAttribute("distance", "4"), p.setAttribute("padding", "0"), p.setAttribute("aria-label", n ? `${n} options` : "Select options");
467
- let m = document.createElement("div");
468
- m.className = "mint-select-options", m.id = `${i}-listbox`, m.setAttribute("role", "listbox"), m.setAttribute("aria-multiselectable", String(this.isMultiple())), o.setAttribute("aria-controls", m.id), p.append(m), this.append(p), this._popover = p, this._list = m, this.renderOptions(), this.updateDisplay(), this.bindEvents();
469
- let h = this.getAttribute("info");
470
- if (h) {
465
+ } else f.value = e;
466
+ a.append(f), this._native = f, this._trigger = o;
467
+ let m = document.createElement("mint-popover");
468
+ m.className = "mint-select-popover", m.setAttribute(r, "popover"), m.setAttribute("trigger-id", o.id), m.setAttribute("trigger-toggle", "false"), m.setAttribute("direction", "down"), m.setAttribute("trigger-align", "start"), m.setAttribute("align-selected", "true"), m.setAttribute("distance", "4"), m.setAttribute("padding", "0"), m.setAttribute("aria-label", n ? `${n} options` : "Select options");
469
+ let h = document.createElement("div");
470
+ h.className = "mint-select-options", h.id = `${i}-listbox`, h.setAttribute("role", "listbox"), h.setAttribute("aria-multiselectable", String(this.isMultiple())), o.setAttribute("aria-controls", h.id), m.append(h), this.append(m), this._popover = m, this._list = h, this.renderOptions(), this.updateDisplay(), this.bindEvents();
471
+ let g = this.getAttribute("info");
472
+ if (g) {
471
473
  let e = document.createElement("div");
472
- e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${i}-info`, e.textContent = h, this.append(e);
474
+ e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${i}-info`, e.textContent = g, this.append(e);
473
475
  }
474
- let g = this.getAttribute("error-message");
475
- if (this.hasError() && g) {
476
+ let _ = this.getAttribute("error-message");
477
+ if (this.hasError() && _) {
476
478
  let e = document.createElement("div");
477
- e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${i}-error`, e.textContent = g, this.append(e);
479
+ e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${i}-error`, e.textContent = _, this.append(e);
478
480
  }
479
481
  this._syncing = !1;
480
482
  }
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-CGXHKbMq.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-Cfhjb8tV.js`),require(`../chunks/popover-eTECdkG7.js`);var t=`data-mint-native-select-part`,n=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null,this._hostOptionsObserverRaf=null,this._generatedControlId=`mint-native-select-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-native-select-host`),this.getLabel()||console.error(`mint-native-select: The "label" attribute is required. Please provide a label for the select.`),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{if(e.some(e=>{let t=e.target;if(this._select&&(t===this._select||this._select.contains(t)))return!1;let n=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),r=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return n||r})){if(this._hostOptionsObserverRaf!==null)return;this._hostOptionsObserverRaf=requestAnimationFrame(()=>{this._hostOptionsObserverRaf=null,this.isConnected&&this.render()})}}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null),this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null)}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._syncSelectAccessibility());return}if(e===`loading`){this.render();return}if(e===`value`){if(this._select)if(this.isMultiple()){let e=[];try{let t=n?JSON.parse(n):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=n?[String(n)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=n||``;return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){if(this.isMultiple()&&this._select){let e=Array.from(this._select.selectedOptions).map(e=>e.value);return JSON.stringify(e)}return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(e=>String(e)):e==null||e===``?[]:[String(e)];this.setAttribute(`value`,JSON.stringify(t)),this._select&&Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)});return}let t=e==null?``:String(e);this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{if(this.isMultiple()){this.setValue(e);return}let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){let e=this.getAttribute(`disabled`);return e!==null&&e!==`false`}isMultiple(){let e=this.getAttribute(`multiple`);return e!==null&&e!==`false`}isRequired(){let e=this.getAttribute(`required`);return e!==null&&e!==`false`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){return[`mint-native-select-control`,this.isMultiple()?`is-multiple`:``,this.hasError()?`has-error`:``].filter(Boolean).join(` `)}render(){this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null);let e=this.isLoading(),n=this.isMultiple(),r=this.getValue(),i=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&i.push(e.cloneNode(!0))}),Array.from(this.children).forEach(e=>{e instanceof HTMLElement&&e.hasAttribute(t)&&e.remove()}),this._wrapper=null,this._select=null;let a=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0)),o=this.getLabel(),s=this.getInfo(),c=this.getId()||this._generatedControlId,l=this.getName(),u=this.isDisabled(),d=this.hasError();if(o){let e=document.createElement(`label`);e.setAttribute(t,`label`),e.className=`mint-native-select-label`,c&&e.setAttribute(`for`,c);let n=document.createTextNode(o);e.appendChild(n),this.appendChild(e)}this._wrapper=document.createElement(`div`),this._wrapper.setAttribute(t,`wrapper`),this._wrapper.className=`mint-native-select-control-wrap`,this.appendChild(this._wrapper),this._select=document.createElement(`select`),this._select.className=this.getSelectClasses(),c&&(this._select.id=c),l&&(this._select.name=l),u&&(this._select.disabled=!0),this._select.required=this.isRequired(),n&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,d?`true`:`false`);let f=this.getAttribute(`aria-label`)?.trim(),p=this.getAttribute(`aria-labelledby`)?.trim();p?this._select.setAttribute(`aria-labelledby`,p):o?this._select.removeAttribute(`aria-label`):this._select.setAttribute(`aria-label`,f||`Select an option`);let m=a.length>0?a:i;if(m.length>0&&m.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(n){let e=[];try{let t=r?JSON.parse(r):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=r?[String(r)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=r||``;if(this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target,r=n?Array.from(t.selectedOptions).map(e=>e.value):t.value,i=n?JSON.stringify(r):String(r||``);(this.getAttribute(`value`)||``)!==i&&(i?this.setAttribute(`value`,i):this.removeAttribute(`value`));let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{if(this._select)if(n){let t=[];try{let n=JSON.parse(e);t=Array.isArray(n)?n.map(e=>String(e)):[]}catch{t=[String(e)]}Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)})}else Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),n)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.className=`mint-native-select-caret`,this._caretUpIcon=document.createElement(`mint-icon`),this._caretUpIcon.setAttribute(`name`,`caret-up`),this._caretUpIcon.className=`mint-native-select-caret-up`,this._caretUpIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement(`mint-icon`),this._caretDownIcon.setAttribute(`name`,`caret-down`),this._caretDownIcon.className=`mint-native-select-caret-down`,this._caretDownIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(s){let e=document.createElement(`div`);e.setAttribute(t,`info`),e.className=`mint-native-select-info`,e.textContent=s,this.appendChild(e)}this._renderErrorState(),this._syncSelectAccessibility(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-native-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-native-select-skeleton-container`,t.setAttribute(`aria-hidden`,`true`),n?n.appendChild(t):this.appendChild(t));let e=t.querySelector(`.mint-native-select-skeleton`);e||(e=document.createElement(`div`),t.appendChild(e));let r=this.isMultiple();e.classList.toggle(`is-multiple`,r),e.style.height=r?`5rem`:`2rem`,t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`,this._select.setAttribute(`aria-busy`,`true`))}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`,this._select.removeAttribute(`aria-busy`))}_renderErrorState(){let e=this.hasError(),n=this.getErrorMessage(),r=this.querySelector(`.mint-native-select-error`);e&&n?(r?r.hasAttribute(t)||r.setAttribute(t,`error`):(r=document.createElement(`div`),r.setAttribute(t,`error`),r.className=`mint-native-select-error`,this.appendChild(r)),r.textContent=n):r&&r.remove()}_syncSelectAccessibility(){if(!this._select)return;let e=this._select.id||this._generatedControlId,n=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),r=this.querySelector(`[${t}="info"]`),i=this.querySelector(`.mint-native-select-error`);r&&(r.id=`${e}-info`,n.push(r.id)),i&&(i.id=`${e}-error`,n.push(i.id)),n.length?this._select.setAttribute(`aria-describedby`,Array.from(new Set(n)).join(` `)):this._select.removeAttribute(`aria-describedby`)}};customElements.get(`mint-native-select`)||e.t(`mint-native-select`,n);var r=`data-mint-select-part`,i=class extends HTMLElement{constructor(...e){super(...e),this._native=null,this._trigger=null,this._popover=null,this._list=null,this._observer=null,this._syncing=!1,this._typeahead=``,this._typeaheadTimer=null,this._id=`mint-select-${Math.random().toString(36).slice(2,10)}`}static get observedAttributes(){return[`name`,`value`,`values`,`multiple`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`loading`,`placeholder`,`aria-label`,`aria-labelledby`,`aria-describedby`,`form`]}connectedCallback(){this.classList.add(`mint-select-host`),this.render(),this._observer?.disconnect(),this._observer=new MutationObserver(e=>{this._syncing||e.some(e=>{let t=e.target instanceof Element?e.target:e.target.parentElement;return t===this||t?.closest(`[${r}]`)?!1:e.type===`attributes`?[`value`,`label`,`disabled`,`selected`].includes(e.attributeName):t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement||[...e.addedNodes,...e.removedNodes].some(e=>e instanceof HTMLOptionElement||e instanceof HTMLOptGroupElement)})&&this.render()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`label`,`disabled`,`selected`]})}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer)}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`values`&&this._native&&this.isMultiple()){this._applyValues(this.parseValues(n)),this.updateDisplay();return}if(e===`multiple`&&this._native){this.render();return}if(e===`value`&&this._native){this.isMultiple()?this._applyValues(n?[n]:[]):this._native.value=n||``,this.updateDisplay();return}this.render()}}get value(){return this.isMultiple()?this.values:this._native?.value||this.getAttribute(`value`)||``}set value(e){this.setValue(e)}get values(){return this._native&&this.isMultiple()?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`))}set values(e){this.setValue(e)}getValue(){return this.value}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)];this.setAttribute(`values`,JSON.stringify(t)),this._applyValues(t)}else{let t=e==null?``:String(e);this.setAttribute(`value`,t),this._native&&(this._native.value=t)}this.updateDisplay()}isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}isRequired(){return this.hasAttribute(`required`)&&this.getAttribute(`required`)!==`false`}isMultiple(){return this.hasAttribute(`multiple`)&&this.getAttribute(`multiple`)!==`false`}hasError(){return this.getAttribute(`error`)===`true`}parseValues(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){if(t.length===1&&typeof t[0]==`string`&&t[0].trim().startsWith(`[`))try{let e=JSON.parse(t[0]);if(Array.isArray(e))return e.map(String)}catch{}return t.map(String)}}catch{}return[e]}_applyValues(e){if(!this._native)return;let t=new Set(e);Array.from(this._native.options).forEach(e=>{e.selected=t.has(e.value)})}options(){return Array.from(this.querySelectorAll(`:scope > option, :scope > optgroup > option`))}selectedOption(){return this._native?.selectedOptions[0]||this.options().find(e=>e.value===this.value)}render(){let e=this._native?.value??this.getAttribute(`value`)??``,t=this._native&&this._native.multiple?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`));this._syncing=!0,Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let n=this.getAttribute(`label`)?.trim()||``,i=this.getAttribute(`id`)||this._id;if(n){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${i}-trigger`,e.textContent=n,this.append(e)}let a=document.createElement(`div`);a.setAttribute(r,`wrap`),a.className=`mint-select-control-wrap`,this.append(a);let o=document.createElement(`button`);o.type=`button`,o.id=`${i}-trigger`,o.className=`mint-select-trigger`,o.disabled=this.isDisabled()||this.isLoading(),o.setAttribute(`role`,`combobox`),o.setAttribute(`aria-busy`,String(this.isLoading())),o.setAttribute(`aria-haspopup`,`listbox`),o.setAttribute(`aria-expanded`,`false`),o.setAttribute(`aria-required`,String(this.isRequired())),o.setAttribute(`aria-invalid`,String(this.hasError()));let s=this.getAttribute(`aria-labelledby`),c=this.getAttribute(`aria-label`)?.trim();if(s?o.setAttribute(`aria-labelledby`,s):!n&&c?o.setAttribute(`aria-label`,c):n&&o.setAttribute(`aria-labelledby`,`${i}-label`),n){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${i}-label`)}let l=document.createElement(`span`);l.className=`mint-select-value`,o.append(l);let u=document.createElement(`span`);u.className=`mint-select-caret`,u.setAttribute(`aria-hidden`,`true`),u.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,o.append(u),a.append(o);let d=document.createElement(`select`);d.setAttribute(r,`native`),d.className=`mint-select-native-control`,d.id=`${i}-native`,d.name=this.getAttribute(`name`)||``,d.multiple=this.isMultiple(),this.hasAttribute(`form`)&&d.setAttribute(`form`,this.getAttribute(`form`)||``),d.required=this.isRequired(),d.disabled=this.isDisabled(),d.tabIndex=-1,d.setAttribute(`aria-hidden`,`true`),d.setAttribute(`aria-invalid`,String(this.hasError()));let f=[this.getAttribute(`aria-describedby`),n?`${i}-label`:``,this.getAttribute(`info`)?`${i}-info`:``,this.getAttribute(`error-message`)?`${i}-error`:``].filter(Boolean).join(` `);if(f&&d.setAttribute(`aria-describedby`,f),this.options().forEach(e=>d.append(e.cloneNode(!0))),!d.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,d.append(e)}if(d.multiple){let n=t.length?t:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];n.length&&Array.from(d.options).forEach(e=>{e.selected=n.includes(e.value)})}else d.value=e;a.append(d),this._native=d,this._trigger=o;let p=document.createElement(`mint-popover`);p.className=`mint-select-popover`,p.setAttribute(r,`popover`),p.setAttribute(`trigger-id`,o.id),p.setAttribute(`trigger-toggle`,`false`),p.setAttribute(`direction`,`down`),p.setAttribute(`trigger-align`,`start`),p.setAttribute(`align-selected`,`true`),p.setAttribute(`distance`,`4`),p.setAttribute(`padding`,`0`),p.setAttribute(`aria-label`,n?`${n} options`:`Select options`);let m=document.createElement(`div`);m.className=`mint-select-options`,m.id=`${i}-listbox`,m.setAttribute(`role`,`listbox`),m.setAttribute(`aria-multiselectable`,String(this.isMultiple())),o.setAttribute(`aria-controls`,m.id),p.append(m),this.append(p),this._popover=p,this._list=m,this.renderOptions(),this.updateDisplay(),this.bindEvents();let h=this.getAttribute(`info`);if(h){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${i}-info`,e.textContent=h,this.append(e)}let g=this.getAttribute(`error-message`);if(this.hasError()&&g){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${i}-error`,e.textContent=g,this.append(e)}this._syncing=!1}renderOptions(){this._list&&(this._list.replaceChildren(),Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).forEach(e=>{if(e instanceof HTMLOptGroupElement){let t=document.createElement(`div`);t.className=`mint-select-group-label`,t.setAttribute(`role`,`presentation`),t.textContent=e.label,this._list.append(t),Array.from(e.children).forEach(t=>this.addOption(t,e.disabled))}else this.addOption(e,!1)}))}addOption(e,t){if(!this._list)return;let n=document.createElement(`button`);n.type=`button`,n.className=`mint-select-option`,n.dataset.value=e.value,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(this.isMultiple()?this.values.includes(e.value):e.value===this.value)),n.disabled=e.disabled||t||this.isDisabled(),n.tabIndex=-1;let r=document.createElement(`span`);r.textContent=e.label||e.textContent||``,n.append(r);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`check`),i.setAttribute(`aria-hidden`,`true`),i.className=`mint-select-option-check`,n.append(i),this._list.append(n)}updateDisplay(){if(!this._native||!this._trigger)return;let e=this.selectedOption(),t=this.values,n=this.isMultiple()?t.map(e=>this.options().find(t=>t.value===e)?.label||e):[],r=this._trigger.querySelector(`.mint-select-value`);r&&(r.textContent=this.isMultiple()?n.join(`, `)||this.getAttribute(`placeholder`)||`Select an option`:e?.label||e?.textContent?.trim()||this.getAttribute(`placeholder`)||`Select an option`,r.classList.toggle(`is-placeholder`,this.isMultiple()?t.length===0:!e||e.value===``)),this._trigger.setAttribute(`aria-invalid`,String(this.hasError())),this._trigger.setAttribute(`aria-haspopup`,`listbox`),this._list?.setAttribute(`aria-multiselectable`,String(this.isMultiple())),this._list?.querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,String(this.isMultiple()?t.includes(e.dataset.value||``):e.dataset.value===this._native.value)))}bindEvents(){!this._trigger||!this._popover||!this._native||!this._list||(this._trigger.onclick=()=>{this._popover.style.setProperty(`--mint-select-popover-width`,`${this._trigger.getBoundingClientRect().width}px`),this._popover.hasAttribute(`open`)?this._popover.close():this.openPopover()},this._trigger.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),this._popover.hasAttribute(`open`)||this.openPopover();let n=t.findIndex(e=>e.dataset.value===(this.isMultiple()?this.values[0]:this._native.value));t[e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n<=0?0:n-1)]?.focus()}else if(e.key===`Enter`||e.key===` `)if(this._popover.hasAttribute(`open`)){e.preventDefault();let t=this._list.querySelector(`[role="option"]:focus`);t?this.selectOption(t.dataset.value||``):this.openPopover()}else e.key===` `&&(e.preventDefault(),this.openPopover());else e.key===`Escape`&&this._popover.hasAttribute(`open`)?(e.preventDefault(),this._popover.close(),this._trigger.focus()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.typeahead(e.key)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);t&&!t.disabled&&this.selectOption(t.dataset.value||``)},this._list.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`)),n=t.indexOf(e.target),r=n;if(e.key===`ArrowDown`)r=Math.min(t.length-1,n+1);else if(e.key===`ArrowUp`)r=Math.max(0,n-1);else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),this._popover.close(),this._trigger.focus();return}else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.selectOption(e.target.dataset.value||``);return}else if(e.key.length===1){this.typeahead(e.key);return}else return;e.preventDefault(),t[r]?.focus()},this._native.onchange=()=>{this.isMultiple()?this.setAttribute(`values`,JSON.stringify(this.values)):this.setAttribute(`value`,this._native.value),this.updateDisplay(),this.dispatchSelectionEvents()})}openPopover(){this._popover&&this._popover.open()}selectOption(e){if(this._native){if(this.isMultiple()){let t=new Set(this.values);t.has(e)?t.delete(e):t.add(e);let n=[...t];this._applyValues(n),this.setAttribute(`values`,JSON.stringify(n)),this.updateDisplay(),this.dispatchSelectionEvents();return}this._native.value=e,this.setAttribute(`value`,e),this.updateDisplay(),this._popover?.close(),this._trigger?.focus(),this.dispatchSelectionEvents()}}dispatchSelectionEvents(){let e=this.isMultiple()?this.values:this._native?.value||``,t=this.isMultiple()?{value:e,values:e}:{value:e};this.dispatchEvent(new CustomEvent(`input`,{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,composed:!0,detail:t}))}typeahead(e){this._typeahead+=e.toLocaleLowerCase(),this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``},700);let t=Array.from(this._list?.querySelectorAll(`[role="option"]:not(:disabled)`)||[]).find(e=>e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));t&&(this._popover?.hasAttribute(`open`)||this.openPopover(),t.focus())}};customElements.get(`mint-select`)||e.t(`mint-select`,i),exports.NativeSelect=n,exports.default=i;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-CGXHKbMq.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-Cfhjb8tV.js`),require(`../chunks/popover-eTECdkG7.js`);var t=`data-mint-native-select-part`,n=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null,this._hostOptionsObserverRaf=null,this._generatedControlId=`mint-native-select-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-native-select-host`),this.getLabel()||console.error(`mint-native-select: The "label" attribute is required. Please provide a label for the select.`),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{if(e.some(e=>{let t=e.target;if(this._select&&(t===this._select||this._select.contains(t)))return!1;let n=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),r=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return n||r})){if(this._hostOptionsObserverRaf!==null)return;this._hostOptionsObserverRaf=requestAnimationFrame(()=>{this._hostOptionsObserverRaf=null,this.isConnected&&this.render()})}}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null),this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null)}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._syncSelectAccessibility());return}if(e===`loading`){this.render();return}if(e===`value`){if(this._select)if(this.isMultiple()){let e=[];try{let t=n?JSON.parse(n):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=n?[String(n)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=n||``;return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){if(this.isMultiple()&&this._select){let e=Array.from(this._select.selectedOptions).map(e=>e.value);return JSON.stringify(e)}return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(e=>String(e)):e==null||e===``?[]:[String(e)];this.setAttribute(`value`,JSON.stringify(t)),this._select&&Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)});return}let t=e==null?``:String(e);this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{if(this.isMultiple()){this.setValue(e);return}let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){let e=this.getAttribute(`disabled`);return e!==null&&e!==`false`}isMultiple(){let e=this.getAttribute(`multiple`);return e!==null&&e!==`false`}isRequired(){let e=this.getAttribute(`required`);return e!==null&&e!==`false`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){return[`mint-native-select-control`,this.isMultiple()?`is-multiple`:``,this.hasError()?`has-error`:``].filter(Boolean).join(` `)}render(){this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null);let e=this.isLoading(),n=this.isMultiple(),r=this.getValue(),i=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&i.push(e.cloneNode(!0))}),Array.from(this.children).forEach(e=>{e instanceof HTMLElement&&e.hasAttribute(t)&&e.remove()}),this._wrapper=null,this._select=null;let a=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0)),o=this.getLabel(),s=this.getInfo(),c=this.getId()||this._generatedControlId,l=this.getName(),u=this.isDisabled(),d=this.hasError();if(o){let e=document.createElement(`label`);e.setAttribute(t,`label`),e.className=`mint-native-select-label`,c&&e.setAttribute(`for`,c);let n=document.createTextNode(o);e.appendChild(n),this.appendChild(e)}this._wrapper=document.createElement(`div`),this._wrapper.setAttribute(t,`wrapper`),this._wrapper.className=`mint-native-select-control-wrap`,this.appendChild(this._wrapper),this._select=document.createElement(`select`),this._select.className=this.getSelectClasses(),c&&(this._select.id=c),l&&(this._select.name=l),u&&(this._select.disabled=!0),this._select.required=this.isRequired(),n&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,d?`true`:`false`);let f=this.getAttribute(`aria-label`)?.trim(),p=this.getAttribute(`aria-labelledby`)?.trim();p?this._select.setAttribute(`aria-labelledby`,p):o?this._select.removeAttribute(`aria-label`):this._select.setAttribute(`aria-label`,f||`Select an option`);let m=a.length>0?a:i;if(m.length>0&&m.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(n){let e=[];try{let t=r?JSON.parse(r):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=r?[String(r)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=r||``;if(this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target,r=n?Array.from(t.selectedOptions).map(e=>e.value):t.value,i=n?JSON.stringify(r):String(r||``);(this.getAttribute(`value`)||``)!==i&&(i?this.setAttribute(`value`,i):this.removeAttribute(`value`));let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{if(this._select)if(n){let t=[];try{let n=JSON.parse(e);t=Array.isArray(n)?n.map(e=>String(e)):[]}catch{t=[String(e)]}Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)})}else Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),n)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.className=`mint-native-select-caret`,this._caretUpIcon=document.createElement(`mint-icon`),this._caretUpIcon.setAttribute(`name`,`caret-up`),this._caretUpIcon.className=`mint-native-select-caret-up`,this._caretUpIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement(`mint-icon`),this._caretDownIcon.setAttribute(`name`,`caret-down`),this._caretDownIcon.className=`mint-native-select-caret-down`,this._caretDownIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(s){let e=document.createElement(`div`);e.setAttribute(t,`info`),e.className=`mint-native-select-info`,e.textContent=s,this.appendChild(e)}this._renderErrorState(),this._syncSelectAccessibility(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-native-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-native-select-skeleton-container`,t.setAttribute(`aria-hidden`,`true`),n?n.appendChild(t):this.appendChild(t));let e=t.querySelector(`.mint-native-select-skeleton`);e||(e=document.createElement(`div`),t.appendChild(e));let r=this.isMultiple();e.classList.toggle(`is-multiple`,r),e.style.height=r?`5rem`:`2rem`,t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`,this._select.setAttribute(`aria-busy`,`true`))}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`,this._select.removeAttribute(`aria-busy`))}_renderErrorState(){let e=this.hasError(),n=this.getErrorMessage(),r=this.querySelector(`.mint-native-select-error`);e&&n?(r?r.hasAttribute(t)||r.setAttribute(t,`error`):(r=document.createElement(`div`),r.setAttribute(t,`error`),r.className=`mint-native-select-error`,this.appendChild(r)),r.textContent=n):r&&r.remove()}_syncSelectAccessibility(){if(!this._select)return;let e=this._select.id||this._generatedControlId,n=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),r=this.querySelector(`[${t}="info"]`),i=this.querySelector(`.mint-native-select-error`);r&&(r.id=`${e}-info`,n.push(r.id)),i&&(i.id=`${e}-error`,n.push(i.id)),n.length?this._select.setAttribute(`aria-describedby`,Array.from(new Set(n)).join(` `)):this._select.removeAttribute(`aria-describedby`)}};customElements.get(`mint-native-select`)||e.t(`mint-native-select`,n);var r=`data-mint-select-part`,i=class extends HTMLElement{constructor(...e){super(...e),this._native=null,this._trigger=null,this._popover=null,this._list=null,this._observer=null,this._syncing=!1,this._typeahead=``,this._typeaheadTimer=null,this._id=`mint-select-${Math.random().toString(36).slice(2,10)}`}static get observedAttributes(){return[`name`,`value`,`values`,`multiple`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`loading`,`placeholder`,`aria-label`,`aria-labelledby`,`aria-describedby`,`form`]}connectedCallback(){this.classList.add(`mint-select-host`),this.render(),this._observer?.disconnect(),this._observer=new MutationObserver(e=>{this._syncing||e.some(e=>{let t=e.target instanceof Element?e.target:e.target.parentElement;return t===this||t?.closest(`[${r}]`)?!1:e.type===`attributes`?[`value`,`label`,`disabled`,`selected`].includes(e.attributeName):t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement||[...e.addedNodes,...e.removedNodes].some(e=>e instanceof HTMLOptionElement||e instanceof HTMLOptGroupElement)})&&this.render()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`label`,`disabled`,`selected`]})}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer)}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`values`&&this._native&&this.isMultiple()){this._applyValues(this.parseValues(n)),this.updateDisplay();return}if(e===`multiple`&&this._native){this.render();return}if(e===`value`&&this._native){this.isMultiple()?this._applyValues(n?[n]:[]):this._native.value=n||``,this.updateDisplay();return}this.render()}}get value(){return this.isMultiple()?this.values:this._native?.value||this.getAttribute(`value`)||``}set value(e){this.setValue(e)}get values(){return this._native&&this.isMultiple()?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`))}set values(e){this.setValue(e)}getValue(){return this.value}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)];this.setAttribute(`values`,JSON.stringify(t)),this._applyValues(t)}else{let t=e==null?``:String(e);this.setAttribute(`value`,t),this._native&&(this._native.value=t)}this.updateDisplay()}isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}isRequired(){return this.hasAttribute(`required`)&&this.getAttribute(`required`)!==`false`}isMultiple(){return this.hasAttribute(`multiple`)&&this.getAttribute(`multiple`)!==`false`}hasError(){return this.getAttribute(`error`)===`true`}parseValues(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){if(t.length===1&&typeof t[0]==`string`&&t[0].trim().startsWith(`[`))try{let e=JSON.parse(t[0]);if(Array.isArray(e))return e.map(String)}catch{}return t.map(String)}}catch{}return[e]}_applyValues(e){if(!this._native)return;let t=new Set(e);Array.from(this._native.options).forEach(e=>{e.selected=t.has(e.value)})}options(){return Array.from(this.querySelectorAll(`:scope > option, :scope > optgroup > option`))}selectedOption(){return this._native?.selectedOptions[0]||this.options().find(e=>e.value===this.value)}render(){let e=this._native?.value??this.getAttribute(`value`)??``,t=this._native&&this._native.multiple?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`));this._syncing=!0,Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let n=this.getAttribute(`label`)?.trim()||``,i=this.getAttribute(`id`)||this._id;if(n){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${i}-trigger`,e.textContent=n,this.append(e)}let a=document.createElement(`div`);a.setAttribute(r,`wrap`),a.className=`mint-select-control-wrap`,a.style.position=`relative`,this.append(a);let o=document.createElement(`button`);o.type=`button`,o.id=`${i}-trigger`,o.className=`mint-select-trigger`,o.disabled=this.isDisabled()||this.isLoading(),o.setAttribute(`role`,`combobox`),o.setAttribute(`aria-busy`,String(this.isLoading())),o.setAttribute(`aria-haspopup`,`listbox`),o.setAttribute(`aria-expanded`,`false`),o.setAttribute(`aria-required`,String(this.isRequired())),o.setAttribute(`aria-invalid`,String(this.hasError()));let s=this.getAttribute(`aria-labelledby`),c=this.getAttribute(`aria-label`)?.trim();if(s?o.setAttribute(`aria-labelledby`,s):!n&&c?o.setAttribute(`aria-label`,c):n&&o.setAttribute(`aria-labelledby`,`${i}-label`),n){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${i}-label`)}let l=document.createElement(`span`);l.className=`mint-select-value`,o.append(l);let u=document.createElement(`span`);u.className=`mint-select-caret`,u.setAttribute(`aria-hidden`,`true`),u.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,o.append(u),a.append(o);let d=null;this.isLoading()?(d=document.createElement(`div`),d.className=`mint-select-skeleton`,d.setAttribute(`aria-hidden`,`true`),d.style.cssText=`position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;`,a.append(d),o.style.visibility=`hidden`,this.setAttribute(`aria-busy`,`true`)):this.removeAttribute(`aria-busy`);let f=document.createElement(`select`);f.setAttribute(r,`native`),f.className=`mint-select-native-control`,f.id=`${i}-native`,f.name=this.getAttribute(`name`)||``,f.multiple=this.isMultiple(),this.hasAttribute(`form`)&&f.setAttribute(`form`,this.getAttribute(`form`)||``),f.required=this.isRequired(),f.disabled=this.isDisabled(),f.tabIndex=-1,f.setAttribute(`aria-hidden`,`true`),f.setAttribute(`aria-invalid`,String(this.hasError()));let p=[this.getAttribute(`aria-describedby`),n?`${i}-label`:``,this.getAttribute(`info`)?`${i}-info`:``,this.getAttribute(`error-message`)?`${i}-error`:``].filter(Boolean).join(` `);if(p&&f.setAttribute(`aria-describedby`,p),this.options().forEach(e=>f.append(e.cloneNode(!0))),!f.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,f.append(e)}if(f.multiple){let n=t.length?t:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];n.length&&Array.from(f.options).forEach(e=>{e.selected=n.includes(e.value)})}else f.value=e;a.append(f),this._native=f,this._trigger=o;let m=document.createElement(`mint-popover`);m.className=`mint-select-popover`,m.setAttribute(r,`popover`),m.setAttribute(`trigger-id`,o.id),m.setAttribute(`trigger-toggle`,`false`),m.setAttribute(`direction`,`down`),m.setAttribute(`trigger-align`,`start`),m.setAttribute(`align-selected`,`true`),m.setAttribute(`distance`,`4`),m.setAttribute(`padding`,`0`),m.setAttribute(`aria-label`,n?`${n} options`:`Select options`);let h=document.createElement(`div`);h.className=`mint-select-options`,h.id=`${i}-listbox`,h.setAttribute(`role`,`listbox`),h.setAttribute(`aria-multiselectable`,String(this.isMultiple())),o.setAttribute(`aria-controls`,h.id),m.append(h),this.append(m),this._popover=m,this._list=h,this.renderOptions(),this.updateDisplay(),this.bindEvents();let g=this.getAttribute(`info`);if(g){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${i}-info`,e.textContent=g,this.append(e)}let _=this.getAttribute(`error-message`);if(this.hasError()&&_){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${i}-error`,e.textContent=_,this.append(e)}this._syncing=!1}renderOptions(){this._list&&(this._list.replaceChildren(),Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).forEach(e=>{if(e instanceof HTMLOptGroupElement){let t=document.createElement(`div`);t.className=`mint-select-group-label`,t.setAttribute(`role`,`presentation`),t.textContent=e.label,this._list.append(t),Array.from(e.children).forEach(t=>this.addOption(t,e.disabled))}else this.addOption(e,!1)}))}addOption(e,t){if(!this._list)return;let n=document.createElement(`button`);n.type=`button`,n.className=`mint-select-option`,n.dataset.value=e.value,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(this.isMultiple()?this.values.includes(e.value):e.value===this.value)),n.disabled=e.disabled||t||this.isDisabled(),n.tabIndex=-1;let r=document.createElement(`span`);r.textContent=e.label||e.textContent||``,n.append(r);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`check`),i.setAttribute(`aria-hidden`,`true`),i.className=`mint-select-option-check`,n.append(i),this._list.append(n)}updateDisplay(){if(!this._native||!this._trigger)return;let e=this.selectedOption(),t=this.values,n=this.isMultiple()?t.map(e=>this.options().find(t=>t.value===e)?.label||e):[],r=this._trigger.querySelector(`.mint-select-value`);r&&(r.textContent=this.isMultiple()?n.join(`, `)||this.getAttribute(`placeholder`)||`Select an option`:e?.label||e?.textContent?.trim()||this.getAttribute(`placeholder`)||`Select an option`,r.classList.toggle(`is-placeholder`,this.isMultiple()?t.length===0:!e||e.value===``)),this._trigger.setAttribute(`aria-invalid`,String(this.hasError())),this._trigger.setAttribute(`aria-haspopup`,`listbox`),this._list?.setAttribute(`aria-multiselectable`,String(this.isMultiple())),this._list?.querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,String(this.isMultiple()?t.includes(e.dataset.value||``):e.dataset.value===this._native.value)))}bindEvents(){!this._trigger||!this._popover||!this._native||!this._list||(this._trigger.onclick=()=>{this._popover.style.setProperty(`--mint-select-popover-width`,`${this._trigger.getBoundingClientRect().width}px`),this._popover.hasAttribute(`open`)?this._popover.close():this.openPopover()},this._trigger.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),this._popover.hasAttribute(`open`)||this.openPopover();let n=t.findIndex(e=>e.dataset.value===(this.isMultiple()?this.values[0]:this._native.value));t[e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n<=0?0:n-1)]?.focus()}else if(e.key===`Enter`||e.key===` `)if(this._popover.hasAttribute(`open`)){e.preventDefault();let t=this._list.querySelector(`[role="option"]:focus`);t?this.selectOption(t.dataset.value||``):this.openPopover()}else e.key===` `&&(e.preventDefault(),this.openPopover());else e.key===`Escape`&&this._popover.hasAttribute(`open`)?(e.preventDefault(),this._popover.close(),this._trigger.focus()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.typeahead(e.key)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);t&&!t.disabled&&this.selectOption(t.dataset.value||``)},this._list.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`)),n=t.indexOf(e.target),r=n;if(e.key===`ArrowDown`)r=Math.min(t.length-1,n+1);else if(e.key===`ArrowUp`)r=Math.max(0,n-1);else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),this._popover.close(),this._trigger.focus();return}else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.selectOption(e.target.dataset.value||``);return}else if(e.key.length===1){this.typeahead(e.key);return}else return;e.preventDefault(),t[r]?.focus()},this._native.onchange=()=>{this.isMultiple()?this.setAttribute(`values`,JSON.stringify(this.values)):this.setAttribute(`value`,this._native.value),this.updateDisplay(),this.dispatchSelectionEvents()})}openPopover(){this._popover&&this._popover.open()}selectOption(e){if(this._native){if(this.isMultiple()){let t=new Set(this.values);t.has(e)?t.delete(e):t.add(e);let n=[...t];this._applyValues(n),this.setAttribute(`values`,JSON.stringify(n)),this.updateDisplay(),this.dispatchSelectionEvents();return}this._native.value=e,this.setAttribute(`value`,e),this.updateDisplay(),this._popover?.close(),this._trigger?.focus(),this.dispatchSelectionEvents()}}dispatchSelectionEvents(){let e=this.isMultiple()?this.values:this._native?.value||``,t=this.isMultiple()?{value:e,values:e}:{value:e};this.dispatchEvent(new CustomEvent(`input`,{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,composed:!0,detail:t}))}typeahead(e){this._typeahead+=e.toLocaleLowerCase(),this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``},700);let t=Array.from(this._list?.querySelectorAll(`[role="option"]:not(:disabled)`)||[]).find(e=>e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));t&&(this._popover?.hasAttribute(`open`)||this.openPopover(),t.focus())}};customElements.get(`mint-select`)||e.t(`mint-select`,i),exports.NativeSelect=n,exports.default=i;
@@ -419,7 +419,7 @@ var r = "data-mint-select-part", i = class extends HTMLElement {
419
419
  e.setAttribute(r, "label"), e.className = "mint-select-label", e.htmlFor = `${i}-trigger`, e.textContent = n, this.append(e);
420
420
  }
421
421
  let a = document.createElement("div");
422
- a.setAttribute(r, "wrap"), a.className = "mint-select-control-wrap", this.append(a);
422
+ a.setAttribute(r, "wrap"), a.className = "mint-select-control-wrap", a.style.position = "relative", this.append(a);
423
423
  let o = document.createElement("button");
424
424
  o.type = "button", o.id = `${i}-trigger`, o.className = "mint-select-trigger", o.disabled = this.isDisabled() || this.isLoading(), o.setAttribute("role", "combobox"), o.setAttribute("aria-busy", String(this.isLoading())), o.setAttribute("aria-haspopup", "listbox"), o.setAttribute("aria-expanded", "false"), o.setAttribute("aria-required", String(this.isRequired())), o.setAttribute("aria-invalid", String(this.hasError()));
425
425
  let s = this.getAttribute("aria-labelledby"), c = this.getAttribute("aria-label")?.trim();
@@ -431,38 +431,40 @@ var r = "data-mint-select-part", i = class extends HTMLElement {
431
431
  l.className = "mint-select-value", o.append(l);
432
432
  let u = document.createElement("span");
433
433
  u.className = "mint-select-caret", u.setAttribute("aria-hidden", "true"), u.innerHTML = "<mint-icon name=\"caret-up\"></mint-icon><mint-icon name=\"caret-down\"></mint-icon>", o.append(u), a.append(o);
434
- let d = document.createElement("select");
435
- d.setAttribute(r, "native"), d.className = "mint-select-native-control", d.id = `${i}-native`, d.name = this.getAttribute("name") || "", d.multiple = this.isMultiple(), this.hasAttribute("form") && d.setAttribute("form", this.getAttribute("form") || ""), d.required = this.isRequired(), d.disabled = this.isDisabled(), d.tabIndex = -1, d.setAttribute("aria-hidden", "true"), d.setAttribute("aria-invalid", String(this.hasError()));
436
- let f = [
434
+ let d = null;
435
+ this.isLoading() ? (d = document.createElement("div"), d.className = "mint-select-skeleton", d.setAttribute("aria-hidden", "true"), d.style.cssText = "position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;", a.append(d), o.style.visibility = "hidden", this.setAttribute("aria-busy", "true")) : this.removeAttribute("aria-busy");
436
+ let f = document.createElement("select");
437
+ f.setAttribute(r, "native"), f.className = "mint-select-native-control", f.id = `${i}-native`, f.name = this.getAttribute("name") || "", f.multiple = this.isMultiple(), this.hasAttribute("form") && f.setAttribute("form", this.getAttribute("form") || ""), f.required = this.isRequired(), f.disabled = this.isDisabled(), f.tabIndex = -1, f.setAttribute("aria-hidden", "true"), f.setAttribute("aria-invalid", String(this.hasError()));
438
+ let p = [
437
439
  this.getAttribute("aria-describedby"),
438
440
  n ? `${i}-label` : "",
439
441
  this.getAttribute("info") ? `${i}-info` : "",
440
442
  this.getAttribute("error-message") ? `${i}-error` : ""
441
443
  ].filter(Boolean).join(" ");
442
- if (f && d.setAttribute("aria-describedby", f), this.options().forEach((e) => d.append(e.cloneNode(!0))), !d.options.length) {
444
+ if (p && f.setAttribute("aria-describedby", p), this.options().forEach((e) => f.append(e.cloneNode(!0))), !f.options.length) {
443
445
  let e = document.createElement("option");
444
- e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0, d.append(e);
446
+ e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0, f.append(e);
445
447
  }
446
- if (d.multiple) {
448
+ if (f.multiple) {
447
449
  let n = t.length ? t : this.parseValues(this.getAttribute("values")).length ? this.parseValues(this.getAttribute("values")) : e ? [e] : [];
448
- n.length && Array.from(d.options).forEach((e) => {
450
+ n.length && Array.from(f.options).forEach((e) => {
449
451
  e.selected = n.includes(e.value);
450
452
  });
451
- } else d.value = e;
452
- a.append(d), this._native = d, this._trigger = o;
453
- let p = document.createElement("mint-popover");
454
- p.className = "mint-select-popover", p.setAttribute(r, "popover"), p.setAttribute("trigger-id", o.id), p.setAttribute("trigger-toggle", "false"), p.setAttribute("direction", "down"), p.setAttribute("trigger-align", "start"), p.setAttribute("align-selected", "true"), p.setAttribute("distance", "4"), p.setAttribute("padding", "0"), p.setAttribute("aria-label", n ? `${n} options` : "Select options");
455
- let m = document.createElement("div");
456
- m.className = "mint-select-options", m.id = `${i}-listbox`, m.setAttribute("role", "listbox"), m.setAttribute("aria-multiselectable", String(this.isMultiple())), o.setAttribute("aria-controls", m.id), p.append(m), this.append(p), this._popover = p, this._list = m, this.renderOptions(), this.updateDisplay(), this.bindEvents();
457
- let h = this.getAttribute("info");
458
- if (h) {
453
+ } else f.value = e;
454
+ a.append(f), this._native = f, this._trigger = o;
455
+ let m = document.createElement("mint-popover");
456
+ m.className = "mint-select-popover", m.setAttribute(r, "popover"), m.setAttribute("trigger-id", o.id), m.setAttribute("trigger-toggle", "false"), m.setAttribute("direction", "down"), m.setAttribute("trigger-align", "start"), m.setAttribute("align-selected", "true"), m.setAttribute("distance", "4"), m.setAttribute("padding", "0"), m.setAttribute("aria-label", n ? `${n} options` : "Select options");
457
+ let h = document.createElement("div");
458
+ h.className = "mint-select-options", h.id = `${i}-listbox`, h.setAttribute("role", "listbox"), h.setAttribute("aria-multiselectable", String(this.isMultiple())), o.setAttribute("aria-controls", h.id), m.append(h), this.append(m), this._popover = m, this._list = h, this.renderOptions(), this.updateDisplay(), this.bindEvents();
459
+ let g = this.getAttribute("info");
460
+ if (g) {
459
461
  let e = document.createElement("div");
460
- e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${i}-info`, e.textContent = h, this.append(e);
462
+ e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${i}-info`, e.textContent = g, this.append(e);
461
463
  }
462
- let g = this.getAttribute("error-message");
463
- if (this.hasError() && g) {
464
+ let _ = this.getAttribute("error-message");
465
+ if (this.hasError() && _) {
464
466
  let e = document.createElement("div");
465
- e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${i}-error`, e.textContent = g, this.append(e);
467
+ e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${i}-error`, e.textContent = _, this.append(e);
466
468
  }
467
469
  this._syncing = !1;
468
470
  }