monobill-mintui 0.6.708 → 0.6.710
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.
- package/bin/component-dependencies.json +4 -3
- package/dist/components/chunks/{date-picker-Bqre6M4g.js → date-picker-C0U4312C.js} +24 -6
- package/dist/components/chunks/date-picker-MT1QYTbL.js +1 -0
- package/dist/components/chunks/{input-j6FCwb-x.js → input-BTRS6ggP.js} +89 -11
- package/dist/components/chunks/input-D9FDLgwb.js +1 -0
- package/dist/components/chunks/{popover-C1qiTAvR.js → popover-D5-jzS7p.js} +10 -2
- package/dist/components/chunks/{popover-6cborap6.js → popover-DFxM40QK.js} +1 -1
- package/dist/components/chunks/select-B1T9k1wp.js +615 -0
- package/dist/components/chunks/select-DYbwUtkq.js +1 -0
- package/dist/components/chunks/{time-picker-DY5emLWw.js → time-picker-BJY2sFyL.js} +22 -7
- package/dist/components/chunks/time-picker-DA-kUn8C.js +1 -0
- package/dist/components/date-picker/DatePicker.d.ts +6 -0
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/date-picker/browser.js +1 -1
- package/dist/components/date-picker/index.cjs +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/datetime-picker/DateTimePicker.d.ts +4 -0
- package/dist/components/datetime-picker/DateTimePicker.d.ts.map +1 -1
- package/dist/components/datetime-picker/browser.js +21 -6
- package/dist/components/datetime-picker/index.cjs +1 -1
- package/dist/components/datetime-picker/index.js +21 -6
- package/dist/components/input/Input.d.ts +3 -0
- package/dist/components/input/Input.d.ts.map +1 -1
- package/dist/components/input/browser.js +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +1 -1
- package/dist/components/navigation/browser.js +1 -1
- package/dist/components/navigation/index.cjs +1 -1
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/off-canvas/OffCanvas.d.ts +2 -0
- package/dist/components/off-canvas/OffCanvas.d.ts.map +1 -1
- package/dist/components/off-canvas/browser.js +17 -12
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +17 -12
- package/dist/components/page/browser.js +1 -1
- package/dist/components/page/index.cjs +1 -1
- package/dist/components/page/index.js +1 -1
- package/dist/components/popover/Popover.d.ts.map +1 -1
- package/dist/components/popover/browser.js +1 -1
- package/dist/components/popover/index.cjs +1 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/resource-table/ResourceTable.d.ts +7 -0
- package/dist/components/resource-table/ResourceTable.d.ts.map +1 -1
- package/dist/components/resource-table/browser.js +40 -14
- package/dist/components/resource-table/index.cjs +2 -2
- package/dist/components/resource-table/index.js +40 -14
- package/dist/components/search/browser.js +1 -1
- package/dist/components/search/index.cjs +1 -1
- package/dist/components/search/index.js +1 -1
- package/dist/components/select/NativeSelect.d.ts +4 -0
- package/dist/components/select/NativeSelect.d.ts.map +1 -1
- package/dist/components/select/Select.d.ts +4 -0
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/select/browser.js +2 -578
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +2 -578
- package/dist/components/side-navigation/browser.js +1 -1
- package/dist/components/side-navigation/index.cjs +1 -1
- package/dist/components/side-navigation/index.js +1 -1
- package/dist/components/sortable/browser.js +1 -1
- package/dist/components/sortable/index.cjs +1 -1
- package/dist/components/sortable/index.js +1 -1
- package/dist/components/tags/browser.js +1 -1
- package/dist/components/tags/index.cjs +1 -1
- package/dist/components/tags/index.js +1 -1
- package/dist/components/time-picker/TimePicker.d.ts +4 -0
- package/dist/components/time-picker/TimePicker.d.ts.map +1 -1
- package/dist/components/time-picker/browser.js +1 -1
- package/dist/components/time-picker/index.cjs +1 -1
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/tree/browser.js +2 -2
- package/dist/components/tree/index.cjs +1 -1
- package/dist/components/tree/index.js +2 -2
- package/dist/date-picker.css +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.css +5 -5
- package/dist/index.js +2469 -2269
- package/dist/input.css +1 -1
- package/dist/off-canvas.css +1 -1
- package/dist/resource-table.css +1 -1
- package/dist/select.css +1 -1
- package/package.json +1 -1
- package/dist/components/chunks/date-picker-CBucQNne.js +0 -1
- package/dist/components/chunks/input-Br2qLesW.js +0 -1
- package/dist/components/chunks/time-picker-CxdBZbER.js +0 -1
- /package/dist/components/chunks/{sortable-Dgk6LvmB.js → sortable-BSw58wy_.js} +0 -0
- /package/dist/components/chunks/{sortable-BAL3k9Se.js → sortable-D3et5wXB.js} +0 -0
|
@@ -15,581 +15,5 @@ __mintLoadStyle('icon', '../../icon.css')
|
|
|
15
15
|
__mintLoadStyle('popover', '../../popover.css')
|
|
16
16
|
__mintLoadStyle('stack', '../../stack.css')
|
|
17
17
|
__mintLoadStyle('select', '../../select.css')
|
|
18
|
-
import "../chunks/
|
|
19
|
-
|
|
20
|
-
import "../chunks/icon-l34kRIZg.js";
|
|
21
|
-
import "../chunks/popover-C1qiTAvR.js";
|
|
22
|
-
//#region src/components/select/NativeSelect.ts
|
|
23
|
-
var t = "data-mint-native-select-part", n = class extends HTMLElement {
|
|
24
|
-
static get observedAttributes() {
|
|
25
|
-
return [
|
|
26
|
-
"name",
|
|
27
|
-
"value",
|
|
28
|
-
"disabled",
|
|
29
|
-
"id",
|
|
30
|
-
"required",
|
|
31
|
-
"label",
|
|
32
|
-
"info",
|
|
33
|
-
"error",
|
|
34
|
-
"error-message",
|
|
35
|
-
"multiple",
|
|
36
|
-
"loading",
|
|
37
|
-
"aria-label",
|
|
38
|
-
"aria-labelledby",
|
|
39
|
-
"aria-describedby"
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
constructor() {
|
|
43
|
-
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)}`;
|
|
44
|
-
}
|
|
45
|
-
connectedCallback() {
|
|
46
|
-
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) => {
|
|
47
|
-
if (e.some((e) => {
|
|
48
|
-
let t = e.target;
|
|
49
|
-
if (this._select && (t === this._select || this._select.contains(t))) return !1;
|
|
50
|
-
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");
|
|
51
|
-
return n || r;
|
|
52
|
-
})) {
|
|
53
|
-
if (this._hostOptionsObserverRaf !== null) return;
|
|
54
|
-
this._hostOptionsObserverRaf = requestAnimationFrame(() => {
|
|
55
|
-
this._hostOptionsObserverRaf = null, this.isConnected && this.render();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}), this._childrenObserver.observe(this, {
|
|
59
|
-
childList: !0,
|
|
60
|
-
subtree: !0,
|
|
61
|
-
attributes: !0,
|
|
62
|
-
attributeFilter: [
|
|
63
|
-
"value",
|
|
64
|
-
"selected",
|
|
65
|
-
"disabled"
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
disconnectedCallback() {
|
|
70
|
-
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);
|
|
71
|
-
}
|
|
72
|
-
isLoading() {
|
|
73
|
-
let e = this.getAttribute("loading");
|
|
74
|
-
return e !== null && e !== "false";
|
|
75
|
-
}
|
|
76
|
-
attributeChangedCallback(e, t, n) {
|
|
77
|
-
if (t !== n) {
|
|
78
|
-
if (e === "error" || e === "error-message") {
|
|
79
|
-
this._renderErrorState(), this._select && (this._select.className = this.getSelectClasses(), this._select.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._syncSelectAccessibility());
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (e === "loading") {
|
|
83
|
-
this.render();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (e === "value") {
|
|
87
|
-
if (this._select) if (this.isMultiple()) {
|
|
88
|
-
let e = [];
|
|
89
|
-
try {
|
|
90
|
-
let t = n ? JSON.parse(n) : [];
|
|
91
|
-
e = Array.isArray(t) ? t.map((e) => String(e)) : [];
|
|
92
|
-
} catch {
|
|
93
|
-
e = n ? [String(n)] : [];
|
|
94
|
-
}
|
|
95
|
-
Array.from(this._select.options).forEach((t) => {
|
|
96
|
-
t.selected = e.includes(t.value);
|
|
97
|
-
});
|
|
98
|
-
} else this._select.value = n || "";
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
this.render();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
getName() {
|
|
105
|
-
return this.getAttribute("name") || "";
|
|
106
|
-
}
|
|
107
|
-
getValue() {
|
|
108
|
-
if (this.isMultiple() && this._select) {
|
|
109
|
-
let e = Array.from(this._select.selectedOptions).map((e) => e.value);
|
|
110
|
-
return JSON.stringify(e);
|
|
111
|
-
}
|
|
112
|
-
return this.hasAttribute("value") ? this.getAttribute("value") || "" : this._select ? this._select.value : "";
|
|
113
|
-
}
|
|
114
|
-
setValue(e) {
|
|
115
|
-
if (this.isMultiple()) {
|
|
116
|
-
let t = Array.isArray(e) ? e.map((e) => String(e)) : e == null || e === "" ? [] : [String(e)];
|
|
117
|
-
this.setAttribute("value", JSON.stringify(t)), this._select && Array.from(this._select.options).forEach((e) => {
|
|
118
|
-
e.selected = t.includes(e.value);
|
|
119
|
-
});
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
let t = e == null ? "" : String(e);
|
|
123
|
-
this.setAttribute("value", t), this._select && (this._select.value = t);
|
|
124
|
-
}
|
|
125
|
-
get value() {
|
|
126
|
-
try {
|
|
127
|
-
return this.getValue() || "";
|
|
128
|
-
} catch {
|
|
129
|
-
return "";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
set value(e) {
|
|
133
|
-
try {
|
|
134
|
-
if (this.isMultiple()) {
|
|
135
|
-
this.setValue(e);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
let t = e || "";
|
|
139
|
-
(this.getAttribute("value") || "") !== t && this.setAttribute("value", t), this._select && requestAnimationFrame(() => {
|
|
140
|
-
this._select && (t === "" || Array.from(this._select.options).some((e) => e.value === t)) && this._select.value !== t && (this._select.value = t);
|
|
141
|
-
});
|
|
142
|
-
} catch {}
|
|
143
|
-
}
|
|
144
|
-
isDisabled() {
|
|
145
|
-
let e = this.getAttribute("disabled");
|
|
146
|
-
return e !== null && e !== "false";
|
|
147
|
-
}
|
|
148
|
-
isMultiple() {
|
|
149
|
-
let e = this.getAttribute("multiple");
|
|
150
|
-
return e !== null && e !== "false";
|
|
151
|
-
}
|
|
152
|
-
isRequired() {
|
|
153
|
-
let e = this.getAttribute("required");
|
|
154
|
-
return e !== null && e !== "false";
|
|
155
|
-
}
|
|
156
|
-
hasError() {
|
|
157
|
-
return this.getAttribute("error") === "true";
|
|
158
|
-
}
|
|
159
|
-
getErrorMessage() {
|
|
160
|
-
return this.getAttribute("error-message") || "";
|
|
161
|
-
}
|
|
162
|
-
getId() {
|
|
163
|
-
return this.getAttribute("id") || "";
|
|
164
|
-
}
|
|
165
|
-
getLabel() {
|
|
166
|
-
return this.getAttribute("label") || "";
|
|
167
|
-
}
|
|
168
|
-
getInfo() {
|
|
169
|
-
return this.getAttribute("info") || "";
|
|
170
|
-
}
|
|
171
|
-
getSelectClasses() {
|
|
172
|
-
return [
|
|
173
|
-
"mint-native-select-control",
|
|
174
|
-
this.isMultiple() ? "is-multiple" : "",
|
|
175
|
-
this.hasError() ? "has-error" : ""
|
|
176
|
-
].filter(Boolean).join(" ");
|
|
177
|
-
}
|
|
178
|
-
render() {
|
|
179
|
-
this._hostOptionsObserverRaf !== null && (cancelAnimationFrame(this._hostOptionsObserverRaf), this._hostOptionsObserverRaf = null);
|
|
180
|
-
let e = this.isLoading(), n = this.isMultiple(), r = this.getValue(), i = [];
|
|
181
|
-
this._select && Array.from(this._select.children).forEach((e) => {
|
|
182
|
-
(e.tagName === "OPTION" || e.tagName === "OPTGROUP") && i.push(e.cloneNode(!0));
|
|
183
|
-
}), Array.from(this.children).forEach((e) => {
|
|
184
|
-
e instanceof HTMLElement && e.hasAttribute(t) && e.remove();
|
|
185
|
-
}), this._wrapper = null, this._select = null;
|
|
186
|
-
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();
|
|
187
|
-
if (o) {
|
|
188
|
-
let e = document.createElement("label");
|
|
189
|
-
e.setAttribute(t, "label"), e.className = "mint-native-select-label", c && e.setAttribute("for", c);
|
|
190
|
-
let n = document.createTextNode(o);
|
|
191
|
-
e.appendChild(n), this.appendChild(e);
|
|
192
|
-
}
|
|
193
|
-
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");
|
|
194
|
-
let f = this.getAttribute("aria-label")?.trim(), p = this.getAttribute("aria-labelledby")?.trim();
|
|
195
|
-
p ? this._select.setAttribute("aria-labelledby", p) : o ? this._select.removeAttribute("aria-label") : this._select.setAttribute("aria-label", f || "Select an option");
|
|
196
|
-
let m = a.length > 0 ? a : i;
|
|
197
|
-
if (m.length > 0 && m.forEach((e) => {
|
|
198
|
-
this._select.appendChild(e);
|
|
199
|
-
}), this._select.options.length === 0) {
|
|
200
|
-
let e = document.createElement("option");
|
|
201
|
-
e.value = "", e.textContent = "Select an option", e.disabled = !0, e.selected = !0, this._select.appendChild(e);
|
|
202
|
-
}
|
|
203
|
-
if (n) {
|
|
204
|
-
let e = [];
|
|
205
|
-
try {
|
|
206
|
-
let t = r ? JSON.parse(r) : [];
|
|
207
|
-
e = Array.isArray(t) ? t.map((e) => String(e)) : [];
|
|
208
|
-
} catch {
|
|
209
|
-
e = r ? [String(r)] : [];
|
|
210
|
-
}
|
|
211
|
-
Array.from(this._select.options).forEach((t) => {
|
|
212
|
-
t.selected = e.includes(t.value);
|
|
213
|
-
});
|
|
214
|
-
} else this._select.value = r || "";
|
|
215
|
-
if (this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (e) => {
|
|
216
|
-
let t = e.target, r = n ? Array.from(t.selectedOptions).map((e) => e.value) : t.value, i = n ? JSON.stringify(r) : String(r || "");
|
|
217
|
-
(this.getAttribute("value") || "") !== i && (i ? this.setAttribute("value", i) : this.removeAttribute("value"));
|
|
218
|
-
let a = new Event("input", {
|
|
219
|
-
bubbles: !0,
|
|
220
|
-
cancelable: !0,
|
|
221
|
-
composed: !0
|
|
222
|
-
});
|
|
223
|
-
this.dispatchEvent(a), this.dispatchEvent(new CustomEvent("input", {
|
|
224
|
-
detail: { value: r },
|
|
225
|
-
bubbles: !0,
|
|
226
|
-
cancelable: !0,
|
|
227
|
-
composed: !0
|
|
228
|
-
})), this.dispatchEvent(new CustomEvent("change", {
|
|
229
|
-
detail: { value: r },
|
|
230
|
-
bubbles: !0,
|
|
231
|
-
cancelable: !0,
|
|
232
|
-
composed: !0
|
|
233
|
-
}));
|
|
234
|
-
}, this._select.addEventListener("change", this._changeHandler), this._optionObserver && this._optionObserver.disconnect(), this._optionObserver = new MutationObserver(() => {
|
|
235
|
-
let e = this.getAttribute("value") || this.value || "";
|
|
236
|
-
this._select && e && requestAnimationFrame(() => {
|
|
237
|
-
if (this._select) if (n) {
|
|
238
|
-
let t = [];
|
|
239
|
-
try {
|
|
240
|
-
let n = JSON.parse(e);
|
|
241
|
-
t = Array.isArray(n) ? n.map((e) => String(e)) : [];
|
|
242
|
-
} catch {
|
|
243
|
-
t = [String(e)];
|
|
244
|
-
}
|
|
245
|
-
Array.from(this._select.options).forEach((e) => {
|
|
246
|
-
e.selected = t.includes(e.value);
|
|
247
|
-
});
|
|
248
|
-
} else Array.from(this._select.options).some((t) => t.value === e) && this._select.value !== e && (this._select.value = e);
|
|
249
|
-
});
|
|
250
|
-
}), this._optionObserver.observe(this._select, {
|
|
251
|
-
childList: !0,
|
|
252
|
-
subtree: !0
|
|
253
|
-
}), this._wrapper.appendChild(this._select), n) this._caretUpIcon = null, this._caretDownIcon = null;
|
|
254
|
-
else {
|
|
255
|
-
let e = document.createElement("div");
|
|
256
|
-
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);
|
|
257
|
-
}
|
|
258
|
-
if (s) {
|
|
259
|
-
let e = document.createElement("div");
|
|
260
|
-
e.setAttribute(t, "info"), e.className = "mint-native-select-info", e.textContent = s, this.appendChild(e);
|
|
261
|
-
}
|
|
262
|
-
this._renderErrorState(), this._syncSelectAccessibility(), this._renderSkeleton(e);
|
|
263
|
-
}
|
|
264
|
-
_renderSkeleton(e) {
|
|
265
|
-
let t = this.querySelector(".mint-native-select-skeleton-container"), n = this._wrapper;
|
|
266
|
-
if (e) {
|
|
267
|
-
t || (t = document.createElement("div"), t.className = "mint-native-select-skeleton-container", t.setAttribute("aria-hidden", "true"), n ? n.appendChild(t) : this.appendChild(t));
|
|
268
|
-
let e = t.querySelector(".mint-native-select-skeleton");
|
|
269
|
-
e || (e = document.createElement("div"), t.appendChild(e));
|
|
270
|
-
let r = this.isMultiple();
|
|
271
|
-
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"));
|
|
272
|
-
} else t && (t.style.display = "none"), this._select && (this._select.style.opacity = "1", this._select.style.pointerEvents = "auto", this._select.removeAttribute("aria-busy"));
|
|
273
|
-
}
|
|
274
|
-
_renderErrorState() {
|
|
275
|
-
let e = this.hasError(), n = this.getErrorMessage(), r = this.querySelector(".mint-native-select-error");
|
|
276
|
-
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();
|
|
277
|
-
}
|
|
278
|
-
_syncSelectAccessibility() {
|
|
279
|
-
if (!this._select) return;
|
|
280
|
-
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");
|
|
281
|
-
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");
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
customElements.get("mint-native-select") || e("mint-native-select", n);
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region src/components/select/Select.ts
|
|
287
|
-
var r = "data-mint-select-part", i = class extends HTMLElement {
|
|
288
|
-
constructor(...e) {
|
|
289
|
-
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._pointerSelectedOption = null, this._id = `mint-select-${Math.random().toString(36).slice(2, 10)}`;
|
|
290
|
-
}
|
|
291
|
-
static get observedAttributes() {
|
|
292
|
-
return [
|
|
293
|
-
"name",
|
|
294
|
-
"value",
|
|
295
|
-
"values",
|
|
296
|
-
"multiple",
|
|
297
|
-
"disabled",
|
|
298
|
-
"id",
|
|
299
|
-
"required",
|
|
300
|
-
"label",
|
|
301
|
-
"info",
|
|
302
|
-
"error",
|
|
303
|
-
"error-message",
|
|
304
|
-
"loading",
|
|
305
|
-
"placeholder",
|
|
306
|
-
"aria-label",
|
|
307
|
-
"aria-labelledby",
|
|
308
|
-
"aria-describedby",
|
|
309
|
-
"form"
|
|
310
|
-
];
|
|
311
|
-
}
|
|
312
|
-
connectedCallback() {
|
|
313
|
-
this.classList.add("mint-select-host"), this.render(), this._observer?.disconnect(), this._observer = new MutationObserver((e) => {
|
|
314
|
-
this._syncing || e.some((e) => {
|
|
315
|
-
let t = e.target instanceof Element ? e.target : e.target.parentElement;
|
|
316
|
-
return t === this || t?.closest(`[${r}]`) ? !1 : e.type === "attributes" ? [
|
|
317
|
-
"value",
|
|
318
|
-
"label",
|
|
319
|
-
"disabled",
|
|
320
|
-
"selected"
|
|
321
|
-
].includes(e.attributeName) : t instanceof HTMLOptionElement || t instanceof HTMLOptGroupElement || [...e.addedNodes, ...e.removedNodes].some((e) => e instanceof HTMLOptionElement || e instanceof HTMLOptGroupElement);
|
|
322
|
-
}) && this.render();
|
|
323
|
-
}), this._observer.observe(this, {
|
|
324
|
-
childList: !0,
|
|
325
|
-
subtree: !0,
|
|
326
|
-
attributes: !0,
|
|
327
|
-
attributeFilter: [
|
|
328
|
-
"value",
|
|
329
|
-
"label",
|
|
330
|
-
"disabled",
|
|
331
|
-
"selected"
|
|
332
|
-
]
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
disconnectedCallback() {
|
|
336
|
-
this._observer?.disconnect(), this._observer = null, this._typeaheadTimer !== null && window.clearTimeout(this._typeaheadTimer);
|
|
337
|
-
}
|
|
338
|
-
attributeChangedCallback(e, t, n) {
|
|
339
|
-
if (!(t === n || !this.isConnected)) {
|
|
340
|
-
if (e === "values" && this._native && this.isMultiple()) {
|
|
341
|
-
this._applyValues(this.parseValues(n)), this.updateDisplay();
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
if (e === "multiple" && this._native) {
|
|
345
|
-
this.render();
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
if (e === "value" && this._native) {
|
|
349
|
-
this.isMultiple() ? this._applyValues(n ? [n] : []) : this._native.value = n || "", this.updateDisplay();
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
this.render();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
get value() {
|
|
356
|
-
return this.isMultiple() ? this.values : this._native?.value || this.getAttribute("value") || "";
|
|
357
|
-
}
|
|
358
|
-
set value(e) {
|
|
359
|
-
this.setValue(e);
|
|
360
|
-
}
|
|
361
|
-
get values() {
|
|
362
|
-
return this._native && this.isMultiple() ? Array.from(this._native.selectedOptions, (e) => e.value) : this.parseValues(this.getAttribute("values"));
|
|
363
|
-
}
|
|
364
|
-
set values(e) {
|
|
365
|
-
this.setValue(e);
|
|
366
|
-
}
|
|
367
|
-
getValue() {
|
|
368
|
-
return this.value;
|
|
369
|
-
}
|
|
370
|
-
setValue(e) {
|
|
371
|
-
if (this.isMultiple()) {
|
|
372
|
-
let t = Array.isArray(e) ? e.map(String) : e == null || e === "" ? [] : [String(e)];
|
|
373
|
-
this.setAttribute("values", JSON.stringify(t)), this._applyValues(t);
|
|
374
|
-
} else {
|
|
375
|
-
let t = e == null ? "" : String(e);
|
|
376
|
-
this.setAttribute("value", t), this._native && (this._native.value = t);
|
|
377
|
-
}
|
|
378
|
-
this.updateDisplay();
|
|
379
|
-
}
|
|
380
|
-
isDisabled() {
|
|
381
|
-
return this.hasAttribute("disabled") && this.getAttribute("disabled") !== "false";
|
|
382
|
-
}
|
|
383
|
-
isLoading() {
|
|
384
|
-
let e = this.getAttribute("loading");
|
|
385
|
-
return e !== null && e !== "false";
|
|
386
|
-
}
|
|
387
|
-
isRequired() {
|
|
388
|
-
return this.hasAttribute("required") && this.getAttribute("required") !== "false";
|
|
389
|
-
}
|
|
390
|
-
isMultiple() {
|
|
391
|
-
return this.hasAttribute("multiple") && this.getAttribute("multiple") !== "false";
|
|
392
|
-
}
|
|
393
|
-
hasError() {
|
|
394
|
-
return this.getAttribute("error") === "true";
|
|
395
|
-
}
|
|
396
|
-
parseValues(e) {
|
|
397
|
-
if (!e) return [];
|
|
398
|
-
try {
|
|
399
|
-
let t = JSON.parse(e);
|
|
400
|
-
if (Array.isArray(t)) {
|
|
401
|
-
if (t.length === 1 && typeof t[0] == "string" && t[0].trim().startsWith("[")) try {
|
|
402
|
-
let e = JSON.parse(t[0]);
|
|
403
|
-
if (Array.isArray(e)) return e.map(String);
|
|
404
|
-
} catch {}
|
|
405
|
-
return t.map(String);
|
|
406
|
-
}
|
|
407
|
-
} catch {}
|
|
408
|
-
return [e];
|
|
409
|
-
}
|
|
410
|
-
_applyValues(e) {
|
|
411
|
-
if (!this._native) return;
|
|
412
|
-
let t = new Set(e);
|
|
413
|
-
Array.from(this._native.options).forEach((e) => {
|
|
414
|
-
e.selected = t.has(e.value);
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
options() {
|
|
418
|
-
return Array.from(this.querySelectorAll(":scope > option, :scope > optgroup > option"));
|
|
419
|
-
}
|
|
420
|
-
selectedOption() {
|
|
421
|
-
return this._native?.selectedOptions[0] || this.options().find((e) => e.value === this.value);
|
|
422
|
-
}
|
|
423
|
-
render() {
|
|
424
|
-
let e = this._native?.value || this.getAttribute("value") || "", t = this._native?.multiple ? Array.from(this._native.selectedOptions, (e) => e.value) : [], n = t.length ? t : this.parseValues(this.getAttribute("values"));
|
|
425
|
-
this._syncing = !0, Array.from(this.children).forEach((e) => {
|
|
426
|
-
e.hasAttribute(r) && e.remove();
|
|
427
|
-
});
|
|
428
|
-
let i = this.getAttribute("label")?.trim() || "", a = this.getAttribute("id") || this._id;
|
|
429
|
-
if (i) {
|
|
430
|
-
let e = document.createElement("label");
|
|
431
|
-
e.setAttribute(r, "label"), e.className = "mint-select-label", e.htmlFor = `${a}-trigger`, e.textContent = i, this.append(e);
|
|
432
|
-
}
|
|
433
|
-
let o = document.createElement("div");
|
|
434
|
-
o.setAttribute(r, "wrap"), o.className = "mint-select-control-wrap", o.style.position = "relative", this.append(o);
|
|
435
|
-
let s = document.createElement("button");
|
|
436
|
-
s.type = "button", s.id = `${a}-trigger`, s.className = "mint-select-trigger", s.disabled = this.isDisabled() || this.isLoading(), s.setAttribute("role", "combobox"), s.setAttribute("aria-busy", String(this.isLoading())), s.setAttribute("aria-haspopup", "listbox"), s.setAttribute("aria-expanded", "false"), s.setAttribute("aria-required", String(this.isRequired())), s.setAttribute("aria-invalid", String(this.hasError()));
|
|
437
|
-
let c = this.getAttribute("aria-labelledby"), l = this.getAttribute("aria-label")?.trim();
|
|
438
|
-
if (c ? s.setAttribute("aria-labelledby", c) : !i && l ? s.setAttribute("aria-label", l) : i && s.setAttribute("aria-labelledby", `${a}-label`), i) {
|
|
439
|
-
let e = this.querySelector(`[${r}="label"]`);
|
|
440
|
-
e && (e.id = `${a}-label`);
|
|
441
|
-
}
|
|
442
|
-
let u = document.createElement("span");
|
|
443
|
-
u.className = "mint-select-value", s.append(u);
|
|
444
|
-
let d = document.createElement("span");
|
|
445
|
-
d.className = "mint-select-caret", d.setAttribute("aria-hidden", "true"), d.innerHTML = "<mint-icon name=\"caret-up\"></mint-icon><mint-icon name=\"caret-down\"></mint-icon>", s.append(d), o.append(s);
|
|
446
|
-
let f = null;
|
|
447
|
-
this.isLoading() ? (f = document.createElement("div"), f.className = "mint-select-skeleton", f.setAttribute("aria-hidden", "true"), f.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;", o.append(f), s.style.visibility = "hidden", this.setAttribute("aria-busy", "true")) : this.removeAttribute("aria-busy");
|
|
448
|
-
let p = document.createElement("select");
|
|
449
|
-
p.setAttribute(r, "native"), p.className = "mint-select-native-control", p.id = `${a}-native`, p.name = this.getAttribute("name") || "", p.multiple = this.isMultiple(), this.hasAttribute("form") && p.setAttribute("form", this.getAttribute("form") || ""), p.required = this.isRequired(), p.disabled = this.isDisabled(), p.tabIndex = -1, p.setAttribute("aria-hidden", "true"), p.setAttribute("aria-invalid", String(this.hasError()));
|
|
450
|
-
let m = [
|
|
451
|
-
this.getAttribute("aria-describedby"),
|
|
452
|
-
i ? `${a}-label` : "",
|
|
453
|
-
this.getAttribute("info") ? `${a}-info` : "",
|
|
454
|
-
this.getAttribute("error-message") ? `${a}-error` : ""
|
|
455
|
-
].filter(Boolean).join(" ");
|
|
456
|
-
if (m && p.setAttribute("aria-describedby", m), this.options().forEach((e) => p.append(e.cloneNode(!0))), !p.options.length) {
|
|
457
|
-
let e = document.createElement("option");
|
|
458
|
-
e.value = "", e.textContent = this.getAttribute("placeholder") || "Select an option", e.disabled = !0, p.append(e);
|
|
459
|
-
}
|
|
460
|
-
if (p.multiple) {
|
|
461
|
-
let t = n.length ? n : this.parseValues(this.getAttribute("values")).length ? this.parseValues(this.getAttribute("values")) : e ? [e] : [];
|
|
462
|
-
t.length && Array.from(p.options).forEach((e) => {
|
|
463
|
-
e.selected = t.includes(e.value);
|
|
464
|
-
});
|
|
465
|
-
} else p.value = e;
|
|
466
|
-
o.append(p), this._native = p, this._trigger = s;
|
|
467
|
-
let h = document.createElement("mint-popover");
|
|
468
|
-
h.className = "mint-select-popover", h.setAttribute(r, "popover"), h.setAttribute("trigger-id", s.id), h.setAttribute("trigger-toggle", "false"), h.setAttribute("direction", "down"), h.setAttribute("trigger-align", "start"), h.setAttribute("align-selected", "true"), h.setAttribute("distance", "4"), h.setAttribute("padding", "0"), h.setAttribute("aria-label", i ? `${i} options` : "Select options");
|
|
469
|
-
let g = document.createElement("div");
|
|
470
|
-
g.className = "mint-select-options", g.id = `${a}-listbox`, g.setAttribute("role", "listbox"), g.setAttribute("aria-multiselectable", String(this.isMultiple())), s.setAttribute("aria-controls", g.id), h.append(g), this.append(h), this._popover = h, this._list = g, this.renderOptions(), this.updateDisplay(), this.bindEvents();
|
|
471
|
-
let _ = this.getAttribute("info");
|
|
472
|
-
if (_) {
|
|
473
|
-
let e = document.createElement("div");
|
|
474
|
-
e.setAttribute(r, "info"), e.className = "mint-select-info", e.id = `${a}-info`, e.textContent = _, this.append(e);
|
|
475
|
-
}
|
|
476
|
-
let v = this.getAttribute("error-message");
|
|
477
|
-
if (this.hasError() && v) {
|
|
478
|
-
let e = document.createElement("div");
|
|
479
|
-
e.setAttribute(r, "error"), e.className = "mint-select-error", e.id = `${a}-error`, e.textContent = v, this.append(e);
|
|
480
|
-
}
|
|
481
|
-
this._syncing = !1;
|
|
482
|
-
}
|
|
483
|
-
renderOptions() {
|
|
484
|
-
this._list && (this._list.replaceChildren(), Array.from(this.children).filter((e) => e.tagName === "OPTION" || e.tagName === "OPTGROUP").forEach((e) => {
|
|
485
|
-
if (e instanceof HTMLOptGroupElement) {
|
|
486
|
-
let t = document.createElement("div");
|
|
487
|
-
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));
|
|
488
|
-
} else this.addOption(e, !1);
|
|
489
|
-
}));
|
|
490
|
-
}
|
|
491
|
-
addOption(e, t) {
|
|
492
|
-
if (!this._list) return;
|
|
493
|
-
let n = document.createElement("button");
|
|
494
|
-
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;
|
|
495
|
-
let r = document.createElement("span");
|
|
496
|
-
r.textContent = e.label || e.textContent || "", n.append(r);
|
|
497
|
-
let i = document.createElement("mint-icon");
|
|
498
|
-
i.setAttribute("name", "check"), i.setAttribute("aria-hidden", "true"), i.className = "mint-select-option-check", n.append(i), this._list.append(n);
|
|
499
|
-
}
|
|
500
|
-
updateDisplay() {
|
|
501
|
-
if (!this._native || !this._trigger) return;
|
|
502
|
-
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");
|
|
503
|
-
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)));
|
|
504
|
-
}
|
|
505
|
-
bindEvents() {
|
|
506
|
-
!this._trigger || !this._popover || !this._native || !this._list || (this._trigger.onclick = () => {
|
|
507
|
-
this._popover.style.setProperty("--mint-select-popover-width", `${this._trigger.getBoundingClientRect().width}px`), this._popover.hasAttribute("open") ? this._popover.close() : this.openPopover();
|
|
508
|
-
}, this._trigger.onkeydown = (e) => {
|
|
509
|
-
let t = Array.from(this._list.querySelectorAll("[role=\"option\"]:not(:disabled)"));
|
|
510
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
511
|
-
e.preventDefault(), this._popover.hasAttribute("open") || this.openPopover();
|
|
512
|
-
let n = t.findIndex((e) => e.dataset.value === (this.isMultiple() ? this.values[0] : this._native.value));
|
|
513
|
-
t[e.key === "ArrowDown" ? Math.min(t.length - 1, n + 1) : Math.max(0, n <= 0 ? 0 : n - 1)]?.focus();
|
|
514
|
-
} else if (e.key === "Enter" || e.key === " ") if (this._popover.hasAttribute("open")) {
|
|
515
|
-
e.preventDefault();
|
|
516
|
-
let t = this._list.querySelector("[role=\"option\"]:focus");
|
|
517
|
-
t ? this.selectOption(t.dataset.value || "") : this.openPopover();
|
|
518
|
-
} else e.key === " " && (e.preventDefault(), this.openPopover());
|
|
519
|
-
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);
|
|
520
|
-
}, this._list.onpointerdown = (e) => {
|
|
521
|
-
let t = e.target.closest("[role=\"option\"]");
|
|
522
|
-
if (!t || t.disabled) return;
|
|
523
|
-
e.preventDefault();
|
|
524
|
-
let n = t.dataset.value || "";
|
|
525
|
-
this._pointerSelectedOption = {
|
|
526
|
-
value: n,
|
|
527
|
-
time: Date.now()
|
|
528
|
-
}, this.selectOption(n);
|
|
529
|
-
}, this._list.onclick = (e) => {
|
|
530
|
-
let t = e.target.closest("[role=\"option\"]");
|
|
531
|
-
if (!t || t.disabled) return;
|
|
532
|
-
let n = t.dataset.value || "", r = this._pointerSelectedOption?.value === n && Date.now() - this._pointerSelectedOption.time < 1e3;
|
|
533
|
-
this._pointerSelectedOption = null, r || this.selectOption(n);
|
|
534
|
-
}, this._list.onkeydown = (e) => {
|
|
535
|
-
let t = Array.from(this._list.querySelectorAll("[role=\"option\"]:not(:disabled)")), n = t.indexOf(e.target), r = n;
|
|
536
|
-
if (e.key === "ArrowDown") r = Math.min(t.length - 1, n + 1);
|
|
537
|
-
else if (e.key === "ArrowUp") r = Math.max(0, n - 1);
|
|
538
|
-
else if (e.key === "Home") r = 0;
|
|
539
|
-
else if (e.key === "End") r = t.length - 1;
|
|
540
|
-
else if (e.key === "Escape") {
|
|
541
|
-
e.preventDefault(), this._popover.close(), this._trigger.focus();
|
|
542
|
-
return;
|
|
543
|
-
} else if (e.key === "Enter" || e.key === " ") {
|
|
544
|
-
e.preventDefault(), this.selectOption(e.target.dataset.value || "");
|
|
545
|
-
return;
|
|
546
|
-
} else if (e.key.length === 1) {
|
|
547
|
-
this.typeahead(e.key);
|
|
548
|
-
return;
|
|
549
|
-
} else return;
|
|
550
|
-
e.preventDefault(), t[r]?.focus();
|
|
551
|
-
}, this._native.onchange = () => {
|
|
552
|
-
this.isMultiple() ? this.setAttribute("values", JSON.stringify(this.values)) : this.setAttribute("value", this._native.value), this.updateDisplay(), this.dispatchSelectionEvents();
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
openPopover() {
|
|
556
|
-
this._popover && this._popover.open();
|
|
557
|
-
}
|
|
558
|
-
selectOption(e) {
|
|
559
|
-
if (this._native) {
|
|
560
|
-
if (this.isMultiple()) {
|
|
561
|
-
let t = new Set(this.values);
|
|
562
|
-
t.has(e) ? t.delete(e) : t.add(e);
|
|
563
|
-
let n = [...t];
|
|
564
|
-
this._applyValues(n), this.setAttribute("values", JSON.stringify(n)), this.updateDisplay(), this.dispatchSelectionEvents();
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
this._native.value = e, this.setAttribute("value", e), this.updateDisplay(), this._popover?.close(), this._trigger?.focus(), this.dispatchSelectionEvents();
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
dispatchSelectionEvents() {
|
|
571
|
-
let e = this.isMultiple() ? this.values : this._native?.value || "", t = this.isMultiple() ? {
|
|
572
|
-
value: e,
|
|
573
|
-
values: e
|
|
574
|
-
} : { value: e };
|
|
575
|
-
this.dispatchEvent(new CustomEvent("input", {
|
|
576
|
-
bubbles: !0,
|
|
577
|
-
composed: !0,
|
|
578
|
-
detail: t
|
|
579
|
-
})), this.dispatchEvent(new CustomEvent("change", {
|
|
580
|
-
bubbles: !0,
|
|
581
|
-
composed: !0,
|
|
582
|
-
detail: t
|
|
583
|
-
}));
|
|
584
|
-
}
|
|
585
|
-
typeahead(e) {
|
|
586
|
-
this._typeahead += e.toLocaleLowerCase(), this._typeaheadTimer !== null && window.clearTimeout(this._typeaheadTimer), this._typeaheadTimer = window.setTimeout(() => {
|
|
587
|
-
this._typeahead = "";
|
|
588
|
-
}, 700);
|
|
589
|
-
let t = Array.from(this._list?.querySelectorAll("[role=\"option\"]:not(:disabled)") || []).find((e) => e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));
|
|
590
|
-
t && (this._popover?.hasAttribute("open") || this.openPopover(), t.focus());
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
customElements.get("mint-select") || e("mint-select", i);
|
|
594
|
-
//#endregion
|
|
595
|
-
export { n as NativeSelect, i as default };
|
|
18
|
+
import { n as e, t } from "../chunks/select-B1T9k1wp.js";
|
|
19
|
+
export { e as NativeSelect, t as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-CWOP4Com.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-D6C1XGp2.js`),require(`../chunks/popover-6cborap6.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._pointerSelectedOption=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?.multiple?Array.from(this._native.selectedOptions,e=>e.value):[],n=t.length?t:this.parseValues(this.getAttribute(`values`));this._syncing=!0,Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let i=this.getAttribute(`label`)?.trim()||``,a=this.getAttribute(`id`)||this._id;if(i){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${a}-trigger`,e.textContent=i,this.append(e)}let o=document.createElement(`div`);o.setAttribute(r,`wrap`),o.className=`mint-select-control-wrap`,o.style.position=`relative`,this.append(o);let s=document.createElement(`button`);s.type=`button`,s.id=`${a}-trigger`,s.className=`mint-select-trigger`,s.disabled=this.isDisabled()||this.isLoading(),s.setAttribute(`role`,`combobox`),s.setAttribute(`aria-busy`,String(this.isLoading())),s.setAttribute(`aria-haspopup`,`listbox`),s.setAttribute(`aria-expanded`,`false`),s.setAttribute(`aria-required`,String(this.isRequired())),s.setAttribute(`aria-invalid`,String(this.hasError()));let c=this.getAttribute(`aria-labelledby`),l=this.getAttribute(`aria-label`)?.trim();if(c?s.setAttribute(`aria-labelledby`,c):!i&&l?s.setAttribute(`aria-label`,l):i&&s.setAttribute(`aria-labelledby`,`${a}-label`),i){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${a}-label`)}let u=document.createElement(`span`);u.className=`mint-select-value`,s.append(u);let d=document.createElement(`span`);d.className=`mint-select-caret`,d.setAttribute(`aria-hidden`,`true`),d.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,s.append(d),o.append(s);let f=null;this.isLoading()?(f=document.createElement(`div`),f.className=`mint-select-skeleton`,f.setAttribute(`aria-hidden`,`true`),f.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;`,o.append(f),s.style.visibility=`hidden`,this.setAttribute(`aria-busy`,`true`)):this.removeAttribute(`aria-busy`);let p=document.createElement(`select`);p.setAttribute(r,`native`),p.className=`mint-select-native-control`,p.id=`${a}-native`,p.name=this.getAttribute(`name`)||``,p.multiple=this.isMultiple(),this.hasAttribute(`form`)&&p.setAttribute(`form`,this.getAttribute(`form`)||``),p.required=this.isRequired(),p.disabled=this.isDisabled(),p.tabIndex=-1,p.setAttribute(`aria-hidden`,`true`),p.setAttribute(`aria-invalid`,String(this.hasError()));let m=[this.getAttribute(`aria-describedby`),i?`${a}-label`:``,this.getAttribute(`info`)?`${a}-info`:``,this.getAttribute(`error-message`)?`${a}-error`:``].filter(Boolean).join(` `);if(m&&p.setAttribute(`aria-describedby`,m),this.options().forEach(e=>p.append(e.cloneNode(!0))),!p.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,p.append(e)}if(p.multiple){let t=n.length?n:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];t.length&&Array.from(p.options).forEach(e=>{e.selected=t.includes(e.value)})}else p.value=e;o.append(p),this._native=p,this._trigger=s;let h=document.createElement(`mint-popover`);h.className=`mint-select-popover`,h.setAttribute(r,`popover`),h.setAttribute(`trigger-id`,s.id),h.setAttribute(`trigger-toggle`,`false`),h.setAttribute(`direction`,`down`),h.setAttribute(`trigger-align`,`start`),h.setAttribute(`align-selected`,`true`),h.setAttribute(`distance`,`4`),h.setAttribute(`padding`,`0`),h.setAttribute(`aria-label`,i?`${i} options`:`Select options`);let g=document.createElement(`div`);g.className=`mint-select-options`,g.id=`${a}-listbox`,g.setAttribute(`role`,`listbox`),g.setAttribute(`aria-multiselectable`,String(this.isMultiple())),s.setAttribute(`aria-controls`,g.id),h.append(g),this.append(h),this._popover=h,this._list=g,this.renderOptions(),this.updateDisplay(),this.bindEvents();let _=this.getAttribute(`info`);if(_){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${a}-info`,e.textContent=_,this.append(e)}let v=this.getAttribute(`error-message`);if(this.hasError()&&v){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${a}-error`,e.textContent=v,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.onpointerdown=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;e.preventDefault();let n=t.dataset.value||``;this._pointerSelectedOption={value:n,time:Date.now()},this.selectOption(n)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;let n=t.dataset.value||``,r=this._pointerSelectedOption?.value===n&&Date.now()-this._pointerSelectedOption.time<1e3;this._pointerSelectedOption=null,r||this.selectOption(n)},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`}});const e=require(`../chunks/select-DYbwUtkq.js`);exports.NativeSelect=e.n,exports.default=e.t;
|