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