slim-select 2.13.1 → 3.0.1

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 (60) hide show
  1. package/README.md +185 -44
  2. package/dist/index.d.ts +304 -52
  3. package/dist/react/index.d.ts +304 -0
  4. package/dist/react/index.js +1549 -0
  5. package/dist/react/index.umd.js +22 -0
  6. package/dist/slimselect.cjs.js +2 -2030
  7. package/dist/slimselect.cjs.js.map +1 -0
  8. package/dist/slimselect.css +1 -1
  9. package/dist/slimselect.css.map +1 -1
  10. package/dist/slimselect.es.js +1225 -2012
  11. package/dist/slimselect.es.js.map +1 -0
  12. package/dist/slimselect.iife.js +2 -0
  13. package/dist/slimselect.iife.js.map +1 -0
  14. package/dist/slimselect.js +2 -2036
  15. package/dist/slimselect.js.map +1 -0
  16. package/dist/vue/index.d.ts +304 -0
  17. package/dist/vue/index.js +1341 -0
  18. package/dist/vue/index.umd.js +1 -0
  19. package/index.html +1 -0
  20. package/package.json +63 -40
  21. package/release.js +0 -7
  22. package/src/slim-select/accessibility.test.ts +782 -0
  23. package/src/slim-select/classes.test.ts +7 -6
  24. package/src/slim-select/classes.ts +8 -6
  25. package/src/slim-select/helpers.test.ts +10 -8
  26. package/src/slim-select/index.test.ts +509 -14
  27. package/src/slim-select/index.ts +58 -31
  28. package/src/slim-select/react/index.tsx +9 -0
  29. package/src/slim-select/react/react.tsx +112 -0
  30. package/src/slim-select/render.test.ts +479 -119
  31. package/src/slim-select/render.ts +213 -91
  32. package/src/slim-select/select.test.ts +28 -10
  33. package/src/slim-select/select.ts +35 -12
  34. package/src/slim-select/settings.test.ts +19 -8
  35. package/src/slim-select/settings.ts +2 -4
  36. package/src/slim-select/slimselect.scss +30 -15
  37. package/src/slim-select/store.test.ts +13 -16
  38. package/src/slim-select/store.ts +97 -86
  39. package/src/slim-select/vue/index.ts +9 -0
  40. package/src/slim-select/vue/vue.test.ts +832 -0
  41. package/src/slim-select/{vue.vue → vue/vue.vue} +45 -23
  42. package/tsconfig.json +6 -4
  43. package/{vite.config.mts → vite.config.docs.mts} +10 -0
  44. package/vite.config.lib.mts +48 -0
  45. package/vite.config.react.mts +40 -0
  46. package/vite.config.vue.mts +39 -0
  47. package/vitest.config.ts +29 -0
  48. package/dist/classes.d.ts +0 -43
  49. package/dist/helpers.d.ts +0 -5
  50. package/dist/render.d.ts +0 -81
  51. package/dist/select.d.ts +0 -30
  52. package/dist/settings.d.ts +0 -35
  53. package/dist/slimselect.global.js +0 -2033
  54. package/dist/slimselect.min.js +0 -1
  55. package/dist/slimselect.umd.js +0 -2036
  56. package/dist/slimselect.umd.min.js +0 -1
  57. package/dist/store.d.ts +0 -84
  58. package/jest.config.js +0 -14
  59. package/src/slim-select/rollup.config.mjs +0 -127
  60. package/src/slim-select/tsconfig.json +0 -14
@@ -0,0 +1,1341 @@
1
+ import { defineComponent as E, createElementBlock as T, openBlock as D, renderSlot as k } from "vue";
2
+ class N {
3
+ main;
4
+ // Placeholder
5
+ placeholder;
6
+ // Values
7
+ values;
8
+ single;
9
+ max;
10
+ value;
11
+ valueText;
12
+ valueDelete;
13
+ valueOut;
14
+ // Deselect
15
+ deselect;
16
+ deselectPath;
17
+ // Not a class but whatever
18
+ // Arrow
19
+ arrow;
20
+ arrowClose;
21
+ // Not a class but whatever
22
+ arrowOpen;
23
+ // Not a class but whatever
24
+ // Content
25
+ content;
26
+ contentOpen;
27
+ dirAbove;
28
+ dirBelow;
29
+ // Search
30
+ search;
31
+ searchHighlighter;
32
+ searching;
33
+ addable;
34
+ addablePath;
35
+ // Not a class but whatever
36
+ // List optgroups/options
37
+ list;
38
+ // Optgroup
39
+ optgroup;
40
+ optgroupLabel;
41
+ optgroupLabelText;
42
+ optgroupActions;
43
+ optgroupSelectAll;
44
+ // optgroup select all
45
+ optgroupSelectAllBox;
46
+ // Not a class but whatever
47
+ optgroupSelectAllCheck;
48
+ // Not a class but whatever
49
+ optgroupClosable;
50
+ // Option
51
+ option;
52
+ optionDelete;
53
+ // Not a class but whatever
54
+ highlighted;
55
+ // Misc
56
+ mainOpen;
57
+ close;
58
+ selected;
59
+ error;
60
+ disabled;
61
+ hide;
62
+ constructor(e) {
63
+ e || (e = {}), this.main = e.main || "ss-main", this.placeholder = e.placeholder || "ss-placeholder", this.values = e.values || "ss-values", this.single = e.single || "ss-single", this.max = e.max || "ss-max", this.value = e.value || "ss-value", this.valueText = e.valueText || "ss-value-text", this.valueDelete = e.valueDelete || "ss-value-delete", this.valueOut = e.valueOut || "ss-value-out", this.deselect = e.deselect || "ss-deselect", this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = e.arrow || "ss-arrow", this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = e.content || "ss-content", this.contentOpen = e.contentOpen || "ss-open", this.dirAbove = e.dirAbove || "ss-dir-above", this.dirBelow = e.dirBelow || "ss-dir-below", this.search = e.search || "ss-search", this.searchHighlighter = e.searchHighlighter || "ss-search-highlight", this.searching = e.searching || "ss-searching", this.addable = e.addable || "ss-addable", this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = e.list || "ss-list", this.optgroup = e.optgroup || "ss-optgroup", this.optgroupLabel = e.optgroupLabel || "ss-optgroup-label", this.optgroupLabelText = e.optgroupLabelText || "ss-optgroup-label-text", this.optgroupActions = e.optgroupActions || "ss-optgroup-actions", this.optgroupSelectAll = e.optgroupSelectAll || "ss-selectall", this.optgroupSelectAllBox = e.optgroupSelectAllBox || "M60,10 L10,10 L10,90 L90,90 L90,50", this.optgroupSelectAllCheck = e.optgroupSelectAllCheck || "M30,45 L50,70 L90,10", this.optgroupClosable = e.optgroupClosable || "ss-closable", this.option = e.option || "ss-option", this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = e.highlighted || "ss-highlighted", this.mainOpen = e.mainOpen || "ss-open", this.close = e.close || "ss-close", this.selected = e.selected || "ss-selected", this.error = e.error || "ss-error", this.disabled = e.disabled || "ss-disabled", this.hide = e.hide || "ss-hide";
64
+ }
65
+ }
66
+ function y() {
67
+ return Math.random().toString(36).substring(2, 10);
68
+ }
69
+ function M(h, e) {
70
+ function t(i, l) {
71
+ return l && i && i.classList && i.classList.contains(l) || l && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
72
+ }
73
+ function s(i, l) {
74
+ return !i || i === document ? null : t(i, l) ? i : s(i.parentNode, l);
75
+ }
76
+ return t(h, e) || s(h, e);
77
+ }
78
+ function S(h, e = 50, t = !1) {
79
+ let s;
80
+ return function(...i) {
81
+ const l = self, a = () => {
82
+ s = null, t || h.apply(l, i);
83
+ }, n = t && !s;
84
+ clearTimeout(s), s = setTimeout(a, e), n && h.apply(l, i);
85
+ };
86
+ }
87
+ function C(h, e) {
88
+ return JSON.stringify(h) === JSON.stringify(e);
89
+ }
90
+ function P(h) {
91
+ const e = h.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
92
+ return h[0] === h[0].toUpperCase() ? e.substring(1) : e;
93
+ }
94
+ class p {
95
+ id;
96
+ value;
97
+ text;
98
+ html;
99
+ defaultSelected;
100
+ selected;
101
+ display;
102
+ disabled;
103
+ placeholder;
104
+ class;
105
+ style;
106
+ data;
107
+ mandatory;
108
+ constructor(e) {
109
+ this.id = !e.id || e.id === "" ? y() : e.id, this.value = e.value === void 0 ? e.text || "" : e.value || "", this.text = e.text || "", this.html = e.html || "", this.defaultSelected = e.defaultSelected !== void 0 ? e.defaultSelected : !1, this.selected = e.selected !== void 0 ? e.selected : !1, this.display = e.display !== void 0 ? e.display : !0, this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.mandatory = e.mandatory !== void 0 ? e.mandatory : !1, this.placeholder = e.placeholder !== void 0 ? e.placeholder : !1, this.class = e.class || "", this.style = e.style || "", this.data = e.data || {};
110
+ }
111
+ }
112
+ class g {
113
+ id;
114
+ label;
115
+ selectAll;
116
+ selectAllText;
117
+ closable;
118
+ options;
119
+ constructor(e) {
120
+ if (this.id = !e.id || e.id === "" ? y() : e.id, this.label = e.label || "", this.selectAll = e.selectAll === void 0 ? !1 : e.selectAll, this.selectAllText = e.selectAllText || "Select All", this.closable = e.closable || "off", this.options = [], e.options)
121
+ for (const t of e.options)
122
+ this.options.push(new p(t));
123
+ }
124
+ }
125
+ class V {
126
+ selectType = "single";
127
+ // Main data set, never null
128
+ data = [];
129
+ selectedOrder = [];
130
+ constructor(e, t) {
131
+ this.selectType = e, this.setData(t);
132
+ }
133
+ // Validate DataArrayPartial
134
+ validateDataArray(e) {
135
+ if (!Array.isArray(e))
136
+ return new Error("Data must be an array");
137
+ for (let t of e)
138
+ if (t)
139
+ if (t instanceof g || "label" in t) {
140
+ if (!("label" in t))
141
+ return new Error("Optgroup must have a label");
142
+ if ("options" in t && t.options)
143
+ for (let s of t.options) {
144
+ const i = this.validateOption(s);
145
+ if (i)
146
+ return i;
147
+ }
148
+ } else if (t instanceof p || "text" in t) {
149
+ const s = this.validateOption(t);
150
+ if (s)
151
+ return s;
152
+ } else
153
+ return new Error("Data object must be a valid optgroup or option");
154
+ return null;
155
+ }
156
+ // Validate Option
157
+ validateOption(e) {
158
+ return "text" in e ? null : new Error("Option must have a text");
159
+ }
160
+ partialToFullData(e) {
161
+ let t = [];
162
+ return e.forEach((s) => {
163
+ if (s) {
164
+ if (s instanceof g || "label" in s) {
165
+ let i = [];
166
+ "options" in s && s.options && s.options.forEach((l) => {
167
+ i.push(new p(l));
168
+ }), i.length > 0 && t.push(new g(s));
169
+ }
170
+ (s instanceof p || "text" in s) && t.push(new p(s));
171
+ }
172
+ }), t;
173
+ }
174
+ setData(e, t = !1) {
175
+ const s = this.partialToFullData(e);
176
+ if (t) {
177
+ const i = this.getSelectedOptions(), l = [];
178
+ i.forEach((a) => {
179
+ let n = !1;
180
+ for (const o of s) {
181
+ if (o instanceof p && o.id === a.id) {
182
+ n = !0;
183
+ break;
184
+ }
185
+ if (o instanceof g) {
186
+ for (const c of o.options)
187
+ if (c.id === a.id) {
188
+ n = !0;
189
+ break;
190
+ }
191
+ }
192
+ }
193
+ n || l.push(a);
194
+ }), this.data = [...l, ...s];
195
+ } else
196
+ this.data = s;
197
+ this.selectType === "single" && this.setSelectedBy("id", this.getSelected());
198
+ }
199
+ // Get data will return all the data
200
+ getData() {
201
+ return this.filter(null, !0);
202
+ }
203
+ // Get data options will return the data as a
204
+ // flat array of just options
205
+ getDataOptions() {
206
+ return this.filter(null, !1);
207
+ }
208
+ addOption(e, t = !1) {
209
+ if (t) {
210
+ let s = [new p(e)];
211
+ this.setData(s.concat(this.getData()));
212
+ } else
213
+ this.setData(this.getData().concat(new p(e)));
214
+ }
215
+ // Pass in an array of id that will loop through
216
+ // each option and set the selected property to true
217
+ // but also clean selected by determining selectType
218
+ setSelectedBy(e, t) {
219
+ let s = null, i = !1;
220
+ const l = [];
221
+ for (let n of this.data) {
222
+ if (n instanceof g)
223
+ for (let o of n.options) {
224
+ s || (s = o);
225
+ let c = o[e] || "";
226
+ o.selected = i ? !1 : t.includes(c), o.selected && (l.push(o), this.selectType === "single" && (i = !0));
227
+ }
228
+ n instanceof p && (s || (s = n), n.selected = i ? !1 : t.includes(n[e]), n.selected && (l.push(n), this.selectType === "single" && (i = !0)));
229
+ }
230
+ this.selectType === "single" && s && !i && (s.selected = !0, l.push(s));
231
+ const a = t.map((n) => l.find((o) => o[e] === n)?.id || "");
232
+ this.selectedOrder = a;
233
+ }
234
+ getSelected() {
235
+ return this.getSelectedOptions().map((e) => e.id);
236
+ }
237
+ getSelectedValues() {
238
+ return this.getSelectedOptions().map((e) => e.value);
239
+ }
240
+ getSelectedOptions() {
241
+ return this.filter((e) => e.selected, !1);
242
+ }
243
+ getOptgroupByID(e) {
244
+ for (let t of this.data)
245
+ if (t instanceof g && t.id === e)
246
+ return t;
247
+ return null;
248
+ }
249
+ getOptionByID(e) {
250
+ let t = this.filter((s) => s.id === e, !1);
251
+ return t.length ? t[0] : null;
252
+ }
253
+ getSelectType() {
254
+ return this.selectType;
255
+ }
256
+ getFirstOption() {
257
+ let e = null;
258
+ for (let t of this.data)
259
+ if (t instanceof g ? e = t.options[0] : t instanceof p && (e = t), e)
260
+ break;
261
+ return e;
262
+ }
263
+ // Take in search string and return filtered list of values
264
+ search(e, t) {
265
+ return e = e.trim(), e === "" ? this.getData() : this.filter((s) => t(s, e), !0);
266
+ }
267
+ // Filter takes in a function that will be used to filter the data
268
+ // This will also keep optgroups of sub options meet the filter requirements
269
+ filter(e, t) {
270
+ const s = [];
271
+ return this.data.forEach((i) => {
272
+ if (i instanceof g) {
273
+ let l = [];
274
+ if (i.options.forEach((n) => {
275
+ (!e || e(n)) && (t ? l.push(new p(n)) : s.push(new p(n)));
276
+ }), l.length > 0) {
277
+ let n = new g(i);
278
+ n.options = l, s.push(n);
279
+ }
280
+ }
281
+ i instanceof p && (!e || e(i)) && s.push(new p(i));
282
+ }), s;
283
+ }
284
+ // Take in an array of options and reoder them based upon the selected order
285
+ selectedOrderOptions(e) {
286
+ const t = [];
287
+ return this.selectedOrder.forEach((s) => {
288
+ const i = e.find((l) => l.id === s);
289
+ i && t.push(i);
290
+ }), e.forEach((s) => {
291
+ let i = !1;
292
+ t.forEach((l) => {
293
+ if (s.id === l.id) {
294
+ i = !0;
295
+ return;
296
+ }
297
+ }), i || t.push(s);
298
+ }), t;
299
+ }
300
+ }
301
+ class B {
302
+ settings;
303
+ store;
304
+ callbacks;
305
+ // Used to compute the range selection
306
+ lastSelectedOption;
307
+ // Elements
308
+ main;
309
+ content;
310
+ // Classes
311
+ classes;
312
+ constructor(e, t, s, i) {
313
+ this.store = s, this.settings = e, this.classes = t, this.callbacks = i, this.lastSelectedOption = null, this.main = this.mainDiv(), this.content = this.contentDiv(), this.updateClassStyles(), this.updateAriaAttributes(), this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main);
314
+ }
315
+ // Remove disabled classes
316
+ enable() {
317
+ this.main.main.classList.remove(this.classes.disabled), this.main.main.setAttribute("aria-disabled", "false"), this.content.search.input.disabled = !1;
318
+ }
319
+ // Set disabled classes
320
+ disable() {
321
+ this.main.main.classList.add(this.classes.disabled), this.main.main.setAttribute("aria-disabled", "true"), this.content.search.input.disabled = !0;
322
+ }
323
+ open() {
324
+ this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true");
325
+ const t = this.settings.openPosition === "up" ? this.classes.dirAbove : this.classes.dirBelow;
326
+ this.main.main.classList.add(t), this.content.main.classList.add(t), this.content.main.classList.add(this.classes.contentOpen), this.content.search.input.removeAttribute("aria-hidden"), this.moveContent();
327
+ const s = this.store.getSelectedOptions();
328
+ if (s.length) {
329
+ const i = s[s.length - 1].id, l = this.content.list.querySelector('[data-id="' + i + '"]');
330
+ l && this.ensureElementInView(this.content.list, l);
331
+ }
332
+ }
333
+ close() {
334
+ this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.content.main.classList.remove(this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
335
+ }
336
+ updateClassStyles() {
337
+ if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.main.main.classList.add(this.classes.main), this.content.main.classList.add(this.classes.content), this.settings.style !== "" && (this.main.main.style.cssText = this.settings.style, this.content.main.style.cssText = this.settings.style), this.settings.class.length)
338
+ for (const e of this.settings.class)
339
+ e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
340
+ (this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
341
+ }
342
+ updateAriaAttributes() {
343
+ const e = this.content.list.id;
344
+ this.main.main.role = "combobox", this.main.main.setAttribute("aria-haspopup", "listbox"), this.main.main.setAttribute("aria-controls", e), this.main.main.setAttribute("aria-expanded", "false"), this.content.list.setAttribute("role", "listbox"), this.content.list.setAttribute("aria-label", this.settings.ariaLabel + " listbox"), this.settings.isMultiple && this.content.list.setAttribute("aria-multiselectable", "true"), this.content.search.input.setAttribute("aria-controls", e);
345
+ }
346
+ mainDiv() {
347
+ const e = document.createElement("div");
348
+ e.dataset.id = this.settings.id, e.setAttribute("aria-label", this.settings.ariaLabel), e.tabIndex = 0, e.onkeydown = (c) => {
349
+ switch (c.key) {
350
+ case "ArrowUp":
351
+ case "ArrowDown":
352
+ return this.callbacks.open(), c.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
353
+ case "Tab":
354
+ return this.callbacks.close(), !0;
355
+ // Continue doing normal tabbing
356
+ case "Enter":
357
+ case " ":
358
+ this.callbacks.open();
359
+ const r = this.content.list.querySelector("." + this.classes.highlighted);
360
+ return r && r.click(), !1;
361
+ case "Escape":
362
+ return this.callbacks.close(), !1;
363
+ }
364
+ return c.key.length === 1 && this.callbacks.open(), !0;
365
+ }, e.onclick = (c) => {
366
+ this.settings.disabled || (this.settings.isOpen ? this.callbacks.close() : this.callbacks.open());
367
+ };
368
+ const t = document.createElement("div");
369
+ t.classList.add(this.classes.values), e.appendChild(t);
370
+ const s = document.createElement("div");
371
+ s.classList.add(this.classes.deselect);
372
+ const i = this.store?.getSelectedOptions();
373
+ !this.settings.allowDeselect || this.settings.isMultiple && i && i.length <= 0 ? s.classList.add(this.classes.hide) : s.classList.remove(this.classes.hide), s.onclick = (c) => {
374
+ if (c.stopPropagation(), this.settings.disabled)
375
+ return;
376
+ let r = !0;
377
+ const d = this.store.getSelectedOptions(), f = [];
378
+ if (this.callbacks.beforeChange && (r = this.callbacks.beforeChange(f, d) === !0), r) {
379
+ if (this.settings.isMultiple)
380
+ this.callbacks.setSelected([], !1), this.updateDeselectAll();
381
+ else {
382
+ const u = this.store.getFirstOption(), m = u ? u.id : "";
383
+ this.callbacks.setSelected(m, !1);
384
+ }
385
+ this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
386
+ }
387
+ };
388
+ const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
389
+ l.setAttribute("viewBox", "0 0 100 100");
390
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
391
+ a.setAttribute("d", this.classes.deselectPath), l.appendChild(a), s.appendChild(l), e.appendChild(s);
392
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
393
+ n.classList.add(this.classes.arrow), n.setAttribute("viewBox", "0 0 100 100");
394
+ const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
395
+ return o.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && n.classList.add(this.classes.hide), n.appendChild(o), e.appendChild(n), {
396
+ main: e,
397
+ values: t,
398
+ deselect: {
399
+ main: s,
400
+ svg: l,
401
+ path: a
402
+ },
403
+ arrow: {
404
+ main: n,
405
+ path: o
406
+ }
407
+ };
408
+ }
409
+ mainFocus(e) {
410
+ e !== "click" && this.main.main.focus({ preventScroll: !0 });
411
+ }
412
+ placeholder() {
413
+ const e = this.store.filter((i) => i.placeholder, !1);
414
+ let t = this.settings.placeholderText;
415
+ e.length && (e[0].html !== "" ? t = e[0].html : e[0].text !== "" && (t = e[0].text));
416
+ const s = document.createElement("div");
417
+ return s.classList.add(this.classes.placeholder), s.innerHTML = t, s;
418
+ }
419
+ // Get selected values and append to multiSelected values container
420
+ // and remove those who shouldnt exist
421
+ renderValues() {
422
+ if (!this.settings.isMultiple) {
423
+ this.renderSingleValue();
424
+ return;
425
+ }
426
+ this.renderMultipleValues(), this.updateDeselectAll();
427
+ }
428
+ renderSingleValue() {
429
+ const e = this.store.filter((s) => s.selected && !s.placeholder, !1), t = e.length > 0 ? e[0] : null;
430
+ if (!t)
431
+ this.main.values.innerHTML = this.placeholder().outerHTML;
432
+ else {
433
+ const s = document.createElement("div");
434
+ s.classList.add(this.classes.single), t.html ? s.innerHTML = t.html : s.innerText = t.text, this.main.values.innerHTML = s.outerHTML;
435
+ }
436
+ !this.settings.allowDeselect || !e.length ? this.main.deselect.main.classList.add(this.classes.hide) : this.main.deselect.main.classList.remove(this.classes.hide);
437
+ }
438
+ renderMultipleValues() {
439
+ let e = this.main.values.childNodes, t = this.store.filter((i) => i.selected && i.display, !1);
440
+ if (t.length === 0) {
441
+ this.main.values.innerHTML = this.placeholder().outerHTML;
442
+ return;
443
+ } else {
444
+ const i = this.main.values.querySelector("." + this.classes.placeholder);
445
+ i && i.remove();
446
+ }
447
+ if (t.length > this.settings.maxValuesShown) {
448
+ const i = document.createElement("div");
449
+ i.classList.add(this.classes.max), i.textContent = this.settings.maxValuesMessage.replace("{number}", t.length.toString()), this.main.values.innerHTML = i.outerHTML;
450
+ return;
451
+ } else {
452
+ const i = this.main.values.querySelector("." + this.classes.max);
453
+ i && i.remove();
454
+ }
455
+ this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
456
+ let s = [];
457
+ for (let i = 0; i < e.length; i++) {
458
+ const l = e[i], a = l.getAttribute("data-id");
459
+ a && (t.filter((o) => o.id === a, !1).length || s.push(l));
460
+ }
461
+ for (const i of s)
462
+ i.classList.add(this.classes.valueOut), setTimeout(() => {
463
+ this.main.values.hasChildNodes() && this.main.values.contains(i) && this.main.values.removeChild(i);
464
+ }, 100);
465
+ e = this.main.values.childNodes;
466
+ for (let i = 0; i < t.length; i++) {
467
+ let l = !0;
468
+ for (let a = 0; a < e.length; a++)
469
+ t[i].id === String(e[a].dataset.id) && (l = !1);
470
+ l && (this.settings.keepOrder ? this.main.values.appendChild(this.multipleValue(t[i])) : e.length === 0 ? this.main.values.appendChild(this.multipleValue(t[i])) : i === 0 ? this.main.values.insertBefore(this.multipleValue(t[i]), e[i]) : e[i - 1].insertAdjacentElement("afterend", this.multipleValue(t[i])));
471
+ }
472
+ }
473
+ multipleValue(e) {
474
+ const t = document.createElement("div");
475
+ t.classList.add(this.classes.value), t.dataset.id = e.id;
476
+ const s = document.createElement("div");
477
+ if (s.classList.add(this.classes.valueText), s.textContent = e.text, t.appendChild(s), !e.mandatory) {
478
+ const i = document.createElement("div");
479
+ i.classList.add(this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (n) => {
480
+ if (n.preventDefault(), n.stopPropagation(), this.settings.disabled)
481
+ return;
482
+ let o = !0;
483
+ const c = this.store.getSelectedOptions(), r = c.filter((d) => d.selected && d.id !== e.id, !0);
484
+ if (!(this.settings.minSelected && r.length < this.settings.minSelected) && (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(r, c) === !0), o)) {
485
+ let d = [];
486
+ for (const f of r) {
487
+ if (f instanceof g)
488
+ for (const u of f.options)
489
+ u.id && d.push(u.id);
490
+ f instanceof p && d.push(f.id);
491
+ }
492
+ this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(r), this.updateDeselectAll();
493
+ }
494
+ };
495
+ const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
496
+ l.setAttribute("viewBox", "0 0 100 100");
497
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
498
+ a.setAttribute("d", this.classes.optionDelete), l.appendChild(a), i.appendChild(l), t.appendChild(i), i.onkeydown = (n) => {
499
+ n.key === "Enter" && i.click();
500
+ };
501
+ }
502
+ return t;
503
+ }
504
+ contentDiv() {
505
+ const e = document.createElement("div");
506
+ e.dataset.id = this.settings.id;
507
+ const t = this.searchDiv();
508
+ e.appendChild(t.main);
509
+ const s = this.listDiv();
510
+ return e.appendChild(s), {
511
+ main: e,
512
+ search: t,
513
+ list: s
514
+ };
515
+ }
516
+ moveContent() {
517
+ if (this.settings.contentPosition === "relative") {
518
+ this.moveContentBelow();
519
+ return;
520
+ }
521
+ if (this.settings.openPosition === "down") {
522
+ this.moveContentBelow();
523
+ return;
524
+ } else if (this.settings.openPosition === "up") {
525
+ this.moveContentAbove();
526
+ return;
527
+ }
528
+ this.putContent() === "up" ? this.moveContentAbove() : this.moveContentBelow();
529
+ }
530
+ searchDiv() {
531
+ const e = document.createElement("div"), t = document.createElement("input"), s = document.createElement("div");
532
+ e.classList.add(this.classes.search);
533
+ const i = {
534
+ main: e,
535
+ input: t
536
+ };
537
+ if (this.settings.showSearch || (e.classList.add(this.classes.hide), t.readOnly = !0), t.type = "search", t.placeholder = this.settings.searchPlaceholder, t.tabIndex = -1, t.setAttribute("aria-label", this.settings.searchPlaceholder), t.setAttribute("aria-autocomplete", "list"), t.setAttribute("autocapitalize", "off"), t.setAttribute("autocomplete", "off"), t.setAttribute("autocorrect", "off"), t.setAttribute("aria-hidden", "true"), t.oninput = S((l) => {
538
+ this.callbacks.search(l.target.value);
539
+ }, 100), t.onkeydown = (l) => {
540
+ switch (l.key) {
541
+ case "ArrowUp":
542
+ case "ArrowDown":
543
+ return l.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
544
+ case "Tab":
545
+ return this.callbacks.close(), !0;
546
+ // Continue doing normal tabbing
547
+ case "Escape":
548
+ return this.callbacks.close(), !1;
549
+ case " ":
550
+ const a = this.content.list.querySelector("." + this.classes.highlighted);
551
+ return a ? (a.click(), !1) : !0;
552
+ case "Enter":
553
+ const n = this.content.list.querySelector("." + this.classes.highlighted);
554
+ return n ? (n.click(), !1) : this.callbacks.addable ? (s.click(), !1) : !0;
555
+ }
556
+ return !0;
557
+ }, e.appendChild(t), this.callbacks.addable) {
558
+ s.classList.add(this.classes.addable);
559
+ const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
560
+ l.setAttribute("viewBox", "0 0 100 100");
561
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
562
+ a.setAttribute("d", this.classes.addablePath), l.appendChild(a), s.appendChild(l), s.onclick = (n) => {
563
+ if (n.preventDefault(), n.stopPropagation(), !this.callbacks.addable)
564
+ return;
565
+ const o = this.content.search.input.value.trim();
566
+ if (o === "") {
567
+ this.content.search.input.focus();
568
+ return;
569
+ }
570
+ const c = (d) => {
571
+ let f = new p(d);
572
+ if (this.callbacks.addOption(f), this.settings.isMultiple) {
573
+ let u = this.store.getSelected();
574
+ u.push(f.id), this.callbacks.setSelected(u, !0);
575
+ } else
576
+ this.callbacks.setSelected([f.id], !0);
577
+ this.callbacks.search(""), this.settings.closeOnSelect && setTimeout(() => {
578
+ this.callbacks.close();
579
+ }, 100);
580
+ }, r = this.callbacks.addable(o);
581
+ r === !1 || r === void 0 || r === null || (r instanceof Promise ? r.then((d) => {
582
+ typeof d == "string" ? c({
583
+ text: d,
584
+ value: d
585
+ }) : r instanceof Error ? this.renderError(r.message) : c(d);
586
+ }) : typeof r == "string" ? c({
587
+ text: r,
588
+ value: r
589
+ }) : r instanceof Error ? this.renderError(r.message) : c(r));
590
+ }, e.appendChild(s), i.addable = {
591
+ main: s,
592
+ svg: l,
593
+ path: a
594
+ };
595
+ }
596
+ return i;
597
+ }
598
+ searchFocus() {
599
+ this.content.search.input.focus();
600
+ }
601
+ clearSearch() {
602
+ this.content.search.input.value = "";
603
+ }
604
+ getOptions(e = !1, t = !1, s = !1) {
605
+ let i = "." + this.classes.option;
606
+ return e && (i += ":not(." + this.classes.placeholder + ")"), t && (i += ":not(." + this.classes.disabled + ")"), s && (i += ":not(." + this.classes.hide + ")"), Array.from(this.content.list.querySelectorAll(i));
607
+ }
608
+ // highlightUp is used to highlight the previous option in the list
609
+ highlight(e) {
610
+ const t = this.getOptions(!0, !0, !0);
611
+ if (t.length === 0)
612
+ return;
613
+ if (t.length === 1 && !t[0].classList.contains(this.classes.highlighted)) {
614
+ t[0].classList.add(this.classes.highlighted);
615
+ return;
616
+ }
617
+ let s = !1;
618
+ for (const l of t)
619
+ l.classList.contains(this.classes.highlighted) && (s = !0);
620
+ if (!s) {
621
+ for (const l of t)
622
+ if (l.classList.contains(this.classes.selected)) {
623
+ l.classList.add(this.classes.highlighted);
624
+ break;
625
+ }
626
+ }
627
+ for (let l = 0; l < t.length; l++)
628
+ if (t[l].classList.contains(this.classes.highlighted)) {
629
+ const a = t[l];
630
+ a.classList.remove(this.classes.highlighted);
631
+ const n = a.parentElement;
632
+ if (n && n.classList.contains(this.classes.mainOpen)) {
633
+ const r = n.querySelector("." + this.classes.optgroupLabel);
634
+ r && r.click();
635
+ }
636
+ let o = t[e === "down" ? l + 1 < t.length ? l + 1 : 0 : l - 1 >= 0 ? l - 1 : t.length - 1];
637
+ o.classList.add(this.classes.highlighted), this.ensureElementInView(this.content.list, o), o.id && this.main.main.setAttribute("aria-activedescendant", o.id);
638
+ const c = o.parentElement;
639
+ if (c && c.classList.contains(this.classes.close)) {
640
+ const r = c.querySelector("." + this.classes.optgroupLabel);
641
+ r && r.click();
642
+ }
643
+ return;
644
+ }
645
+ const i = t[e === "down" ? 0 : t.length - 1];
646
+ i.classList.add(this.classes.highlighted), i.id && this.main.main.setAttribute("aria-activedescendant", i.id), this.ensureElementInView(this.content.list, i);
647
+ }
648
+ // Create main container that options will reside
649
+ listDiv() {
650
+ const e = document.createElement("div");
651
+ e.classList.add(this.classes.list);
652
+ const t = this.settings.id + "-list";
653
+ return e.id = t, e.dataset.id = t, e;
654
+ }
655
+ renderError(e) {
656
+ this.content.list.innerHTML = "";
657
+ const t = document.createElement("div");
658
+ t.classList.add(this.classes.error), t.textContent = e, this.content.list.appendChild(t);
659
+ }
660
+ renderSearching() {
661
+ this.content.list.innerHTML = "";
662
+ const e = document.createElement("div");
663
+ e.classList.add(this.classes.searching), e.textContent = this.settings.searchingText, this.content.list.appendChild(e);
664
+ }
665
+ // Take in data and add options to
666
+ renderOptions(e) {
667
+ if (this.content.list.innerHTML = "", e.length === 0) {
668
+ const s = document.createElement("div");
669
+ s.classList.add(this.classes.search), this.callbacks.addable ? s.innerHTML = this.settings.addableText.replace("{value}", this.content.search.input.value) : s.innerHTML = this.settings.searchText, this.content.list.appendChild(s);
670
+ return;
671
+ }
672
+ this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((i) => i.placeholder, !1).length || this.store.addOption(
673
+ new p({
674
+ text: "",
675
+ value: "",
676
+ selected: !1,
677
+ placeholder: !0
678
+ }),
679
+ !0
680
+ ));
681
+ const t = document.createDocumentFragment();
682
+ for (const s of e) {
683
+ if (s instanceof g) {
684
+ const i = document.createElement("div");
685
+ i.classList.add(this.classes.optgroup);
686
+ const l = document.createElement("div");
687
+ l.classList.add(this.classes.optgroupLabel), i.appendChild(l);
688
+ const a = document.createElement("div");
689
+ a.classList.add(this.classes.optgroupLabelText), a.textContent = s.label, l.appendChild(a);
690
+ const n = document.createElement("div");
691
+ if (n.classList.add(this.classes.optgroupActions), l.appendChild(n), this.settings.isMultiple && s.selectAll) {
692
+ const o = document.createElement("div");
693
+ o.classList.add(this.classes.optgroupSelectAll);
694
+ let c = !0;
695
+ for (const m of s.options)
696
+ if (!m.selected) {
697
+ c = !1;
698
+ break;
699
+ }
700
+ c && o.classList.add(this.classes.selected);
701
+ const r = document.createElement("span");
702
+ r.textContent = s.selectAllText, o.appendChild(r);
703
+ const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
704
+ d.setAttribute("viewBox", "0 0 100 100"), o.appendChild(d);
705
+ const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
706
+ f.setAttribute("d", this.classes.optgroupSelectAllBox), d.appendChild(f);
707
+ const u = document.createElementNS("http://www.w3.org/2000/svg", "path");
708
+ u.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(u), o.addEventListener("click", (m) => {
709
+ m.preventDefault(), m.stopPropagation();
710
+ const b = this.store.getSelected();
711
+ if (c) {
712
+ const w = b.filter((O) => {
713
+ for (const v of s.options)
714
+ if (O === v.id)
715
+ return !1;
716
+ return !0;
717
+ });
718
+ this.callbacks.setSelected(w, !0);
719
+ return;
720
+ } else {
721
+ let w = s.options.map((v) => v.id).filter((v) => v !== void 0);
722
+ const O = b.concat(w);
723
+ for (const v of s.options)
724
+ v.id && !this.store.getOptionByID(v.id) && this.callbacks.addOption(new p(v));
725
+ this.callbacks.setSelected(O, !0);
726
+ return;
727
+ }
728
+ }), n.appendChild(o);
729
+ }
730
+ if (s.closable !== "off") {
731
+ const o = document.createElement("div");
732
+ o.classList.add(this.classes.optgroupClosable);
733
+ const c = document.createElementNS("http://www.w3.org/2000/svg", "svg");
734
+ c.setAttribute("viewBox", "0 0 100 100"), c.classList.add(this.classes.arrow), o.appendChild(c);
735
+ const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
736
+ c.appendChild(r), s.options.some((d) => d.selected) || this.content.search.input.value.trim() !== "" ? (o.classList.add(this.classes.mainOpen), r.setAttribute("d", this.classes.arrowOpen)) : s.closable === "open" ? (i.classList.add(this.classes.mainOpen), r.setAttribute("d", this.classes.arrowOpen)) : s.closable === "close" && (i.classList.add(this.classes.close), r.setAttribute("d", this.classes.arrowClose)), l.addEventListener("click", (d) => {
737
+ d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.close) ? (i.classList.remove(this.classes.close), i.classList.add(this.classes.mainOpen), r.setAttribute("d", this.classes.arrowOpen)) : (i.classList.remove(this.classes.mainOpen), i.classList.add(this.classes.close), r.setAttribute("d", this.classes.arrowClose));
738
+ }), n.appendChild(o);
739
+ }
740
+ i.appendChild(l);
741
+ for (const o of s.options)
742
+ i.appendChild(this.option(new p(o))), t.appendChild(i);
743
+ }
744
+ s instanceof p && t.appendChild(this.option(s));
745
+ }
746
+ this.content.list.appendChild(t);
747
+ }
748
+ // Create option div element
749
+ option(e) {
750
+ if (e.placeholder) {
751
+ const s = document.createElement("div");
752
+ return s.classList.add(this.classes.option), s.classList.add(this.classes.hide), s;
753
+ }
754
+ const t = document.createElement("div");
755
+ return t.dataset.id = e.id, t.id = this.settings.id + "-" + e.id, t.classList.add(this.classes.option), t.setAttribute("role", "option"), e.class && e.class.split(" ").forEach((s) => {
756
+ t.classList.add(s);
757
+ }), e.style && (t.style.cssText = e.style), this.settings.searchHighlight && this.content.search.input.value.trim() !== "" ? t.innerHTML = this.highlightText(
758
+ e.html !== "" ? e.html : e.text,
759
+ this.content.search.input.value,
760
+ this.classes.searchHighlighter
761
+ ) : e.html !== "" ? t.innerHTML = e.html : t.textContent = e.text, this.settings.showOptionTooltips && t.textContent && t.setAttribute("title", t.textContent), e.display || t.classList.add(this.classes.hide), e.disabled && t.classList.add(this.classes.disabled), e.selected && this.settings.hideSelected && t.classList.add(this.classes.hide), e.selected ? (t.classList.add(this.classes.selected), t.setAttribute("aria-selected", "true"), this.main.main.setAttribute("aria-activedescendant", t.id)) : (t.classList.remove(this.classes.selected), t.setAttribute("aria-selected", "false")), t.addEventListener("click", (s) => {
762
+ s.preventDefault(), s.stopPropagation();
763
+ const i = this.store.getSelected(), l = s.currentTarget, a = String(l.dataset.id), n = s.ctrlKey || s.metaKey;
764
+ if (e.disabled || !this.settings.isMultiple && e.selected && !this.settings.allowDeselect || this.settings.isMultiple && this.settings.maxSelected <= i.length && !e.selected || this.settings.isMultiple && this.settings.minSelected >= i.length && e.selected && !n)
765
+ return;
766
+ let o = !1;
767
+ const c = this.store.getSelectedOptions();
768
+ let r = [];
769
+ if (this.settings.isMultiple) {
770
+ const d = c.some((u) => u.id === a);
771
+ if (s.shiftKey && this.lastSelectedOption) {
772
+ const u = this.store.getDataOptions(), m = u.findIndex((w) => w.id === this.lastSelectedOption.id), b = u.findIndex((w) => w.id === e.id);
773
+ if (m >= 0 && b >= 0) {
774
+ const w = Math.min(m, b), O = Math.max(m, b), L = u.slice(w, O + 1).filter((x) => !c.find((A) => A.id === x.id));
775
+ c.length + L.length <= this.settings.maxSelected ? r = c.concat(L) : r = c;
776
+ } else
777
+ r = c;
778
+ } else n ? (d ? r = c.filter((u) => u.id !== a) : r = c.concat(e), this.lastSelectedOption = e) : (d ? r = c.filter((u) => u.id !== a) : r = c.concat(e), this.lastSelectedOption = e);
779
+ }
780
+ if (this.settings.isMultiple || (e.selected ? r = [] : r = [e]), this.callbacks.beforeChange || (o = !0), this.callbacks.beforeChange && (this.callbacks.beforeChange(r, c) === !1 ? o = !1 : o = !0), o) {
781
+ this.store.getOptionByID(a) || this.callbacks.addOption(e), this.callbacks.setSelected(
782
+ r.map((u) => u.id),
783
+ !1
784
+ );
785
+ const d = s.ctrlKey || s.metaKey || s.shiftKey;
786
+ this.settings.closeOnSelect && !(this.settings.isMultiple && d) && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(r);
787
+ }
788
+ }), t;
789
+ }
790
+ destroy() {
791
+ this.main.main.remove(), this.content.main.remove();
792
+ }
793
+ highlightText(e, t, s) {
794
+ const i = t.trim();
795
+ if (i === "")
796
+ return e;
797
+ const l = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = document.createElement("div");
798
+ a.innerHTML = e;
799
+ const n = (o) => {
800
+ if (o.nodeType === Node.TEXT_NODE) {
801
+ const c = o.textContent || "", r = new RegExp("(" + l + ")", "i");
802
+ if (r.test(c)) {
803
+ const d = document.createElement("span");
804
+ c.split(r).forEach((u, m) => {
805
+ if (u && r.test(u)) {
806
+ const b = document.createElement("mark");
807
+ b.className = s, b.textContent = u, d.appendChild(b);
808
+ } else u && d.appendChild(document.createTextNode(u));
809
+ }), o.parentNode?.replaceChild(d, o);
810
+ }
811
+ } else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((c) => n(c));
812
+ };
813
+ return Array.from(a.childNodes).forEach((o) => n(o)), a.innerHTML;
814
+ }
815
+ moveContentAbove() {
816
+ const e = this.main.main.offsetHeight, t = this.content.main.offsetHeight;
817
+ this.main.main.classList.remove(this.classes.dirBelow), this.main.main.classList.add(this.classes.dirAbove), this.content.main.classList.remove(this.classes.dirBelow), this.content.main.classList.add(this.classes.dirAbove);
818
+ const s = this.main.main.getBoundingClientRect();
819
+ this.content.main.style.margin = "-" + (e + t - 1) + "px 0px 0px 0px", this.content.main.style.top = s.top + s.height + (this.settings.contentPosition === "fixed" ? 0 : window.scrollY) + "px", this.content.main.style.left = s.left + (this.settings.contentPosition === "fixed" ? 0 : window.scrollX) + "px", this.content.main.style.width = s.width + "px";
820
+ }
821
+ moveContentBelow() {
822
+ this.main.main.classList.remove(this.classes.dirAbove), this.main.main.classList.add(this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove), this.content.main.classList.add(this.classes.dirBelow);
823
+ const e = this.main.main.getBoundingClientRect();
824
+ this.content.main.style.margin = "-1px 0px 0px 0px", this.settings.contentPosition !== "relative" && (this.content.main.style.top = e.top + e.height + (this.settings.contentPosition === "fixed" ? 0 : window.scrollY) + "px", this.content.main.style.left = e.left + (this.settings.contentPosition === "fixed" ? 0 : window.scrollX) + "px", this.content.main.style.width = e.width + "px");
825
+ }
826
+ ensureElementInView(e, t) {
827
+ const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, l = t.offsetTop, a = l + t.clientHeight;
828
+ l < s ? e.scrollTop -= s - l : a > i && (e.scrollTop += a - i);
829
+ }
830
+ putContent() {
831
+ const e = this.main.main.offsetHeight, t = this.main.main.getBoundingClientRect(), s = this.content.main.offsetHeight;
832
+ return window.innerHeight - (t.top + e) <= s && t.top > s ? "up" : "down";
833
+ }
834
+ // Updates deselect based on item count and allowDeselect setting
835
+ updateDeselectAll() {
836
+ if (!this.store || !this.settings)
837
+ return;
838
+ const e = this.store.getSelectedOptions(), t = e && e.length > 0, s = this.settings.isMultiple, i = this.settings.allowDeselect, l = this.main.deselect.main, a = this.classes.hide;
839
+ i && !(s && !t) ? l.classList.remove(a) : l.classList.add(a);
840
+ }
841
+ }
842
+ class I {
843
+ select;
844
+ // Mutation observer fields
845
+ onValueChange;
846
+ onClassChange;
847
+ onDisabledChange;
848
+ onOptionsChange;
849
+ // Change observers
850
+ listen = !1;
851
+ observer = null;
852
+ constructor(e) {
853
+ this.select = e, this.valueChange = this.valueChange.bind(this), this.select.addEventListener("change", this.valueChange, {
854
+ // allow bubbling of event
855
+ passive: !0
856
+ }), this.observer = new MutationObserver(this.observeCall.bind(this)), this.changeListen(!0);
857
+ }
858
+ enable() {
859
+ this.select.disabled = !1;
860
+ }
861
+ disable() {
862
+ this.select.disabled = !0;
863
+ }
864
+ hideUI() {
865
+ this.select.tabIndex = -1, this.select.style.position = "absolute", this.select.style.width = "1px", this.select.style.height = "1px", this.select.style.opacity = "0", this.select.style.overflow = "hidden", this.select.style.pointerEvents = "none", this.select.style.margin = "0", this.select.style.padding = "0", this.select.style.borderWidth = "0", this.select.style.clip = "rect(0 0 0 0)", this.select.setAttribute("aria-hidden", "true");
866
+ }
867
+ showUI() {
868
+ this.select.removeAttribute("tabindex"), this.select.style.position = "", this.select.style.width = "", this.select.style.height = "", this.select.style.opacity = "", this.select.style.overflow = "", this.select.style.pointerEvents = "", this.select.style.margin = "", this.select.style.padding = "", this.select.style.borderWidth = "", this.select.style.clip = "", this.select.removeAttribute("aria-hidden");
869
+ }
870
+ changeListen(e) {
871
+ this.listen = e, e && this.observer && this.observer.observe(this.select, {
872
+ subtree: !0,
873
+ // subtree for optgroups options
874
+ childList: !0,
875
+ // children changes
876
+ attributes: !0
877
+ // attributes changes
878
+ }), e || this.observer && this.observer.disconnect();
879
+ }
880
+ // This function get triggers when the select value changes
881
+ // and will call the onValueChange function if it exists
882
+ valueChange(e) {
883
+ return this.listen && this.onValueChange && this.onValueChange(this.getSelectedOptions()), !0;
884
+ }
885
+ observeCall(e) {
886
+ if (!this.listen)
887
+ return;
888
+ let t = !1, s = !1, i = !1;
889
+ for (const l of e) {
890
+ if (l.target === this.select && (l.attributeName === "disabled" && (s = !0), l.attributeName === "class" && (t = !0), l.type === "childList")) {
891
+ for (const a of Array.from(l.addedNodes))
892
+ if (a.nodeName === "OPTION" && a.value === this.select.value) {
893
+ this.select.dispatchEvent(new Event("change"));
894
+ break;
895
+ }
896
+ i = !0;
897
+ }
898
+ (l.target.nodeName === "OPTGROUP" || l.target.nodeName === "OPTION") && (i = !0);
899
+ }
900
+ t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), s && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)), i && this.onOptionsChange && (this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0));
901
+ }
902
+ // From the select element pull optgroup and options into data
903
+ getData() {
904
+ let e = [];
905
+ const t = this.select.childNodes;
906
+ for (const s of t)
907
+ s.nodeName === "OPTGROUP" && e.push(this.getDataFromOptgroup(s)), s.nodeName === "OPTION" && e.push(this.getDataFromOption(s));
908
+ return e;
909
+ }
910
+ getDataFromOptgroup(e) {
911
+ let t = {
912
+ id: e.id,
913
+ label: e.label,
914
+ selectAll: e.dataset ? e.dataset.selectall === "true" : !1,
915
+ selectAllText: e.dataset ? e.dataset.selectalltext : "Select all",
916
+ closable: e.dataset ? e.dataset.closable : "off",
917
+ options: []
918
+ };
919
+ const s = e.childNodes;
920
+ for (const i of s)
921
+ i.nodeName === "OPTION" && t.options.push(this.getDataFromOption(i));
922
+ return t;
923
+ }
924
+ // From passed in option pull pieces of usable information
925
+ getDataFromOption(e) {
926
+ return {
927
+ id: e.id,
928
+ value: e.value,
929
+ text: e.text,
930
+ html: e.dataset && e.dataset.html ? e.dataset.html : "",
931
+ defaultSelected: e.defaultSelected,
932
+ selected: e.selected,
933
+ display: e.style.display !== "none",
934
+ disabled: e.disabled,
935
+ mandatory: e.dataset ? e.dataset.mandatory === "true" : !1,
936
+ placeholder: e.dataset.placeholder === "true",
937
+ class: e.className,
938
+ style: e.style.cssText,
939
+ data: e.dataset
940
+ };
941
+ }
942
+ getSelectedOptions() {
943
+ let e = [];
944
+ const t = this.select.childNodes;
945
+ for (const s of t) {
946
+ if (s.nodeName === "OPTGROUP") {
947
+ const i = s.childNodes;
948
+ for (const l of i)
949
+ if (l.nodeName === "OPTION") {
950
+ const a = l;
951
+ a.selected && e.push(this.getDataFromOption(a));
952
+ }
953
+ }
954
+ if (s.nodeName === "OPTION") {
955
+ const i = s;
956
+ i.selected && e.push(this.getDataFromOption(i));
957
+ }
958
+ }
959
+ return e;
960
+ }
961
+ getSelectedValues() {
962
+ return this.getSelectedOptions().map((e) => e.value);
963
+ }
964
+ setSelected(e) {
965
+ this.changeListen(!1);
966
+ const t = this.select.childNodes;
967
+ for (const s of t) {
968
+ if (s.nodeName === "OPTGROUP") {
969
+ const l = s.childNodes;
970
+ for (const a of l)
971
+ if (a.nodeName === "OPTION") {
972
+ const n = a;
973
+ n.selected = e.includes(n.id);
974
+ }
975
+ }
976
+ if (s.nodeName === "OPTION") {
977
+ const i = s;
978
+ i.selected = e.includes(i.id);
979
+ }
980
+ }
981
+ this.changeListen(!0);
982
+ }
983
+ // Set selected options by value instead of id
984
+ // This is useful when the id is not known
985
+ // and only the value is known
986
+ // but the value is not unique and can be duplicated
987
+ setSelectedByValue(e) {
988
+ this.changeListen(!1);
989
+ const t = this.select.childNodes;
990
+ for (const s of t) {
991
+ if (s.nodeName === "OPTGROUP") {
992
+ const l = s.childNodes;
993
+ for (const a of l)
994
+ if (a.nodeName === "OPTION") {
995
+ const n = a;
996
+ n.selected = e.includes(n.value);
997
+ }
998
+ }
999
+ if (s.nodeName === "OPTION") {
1000
+ const i = s;
1001
+ i.selected = e.includes(i.value);
1002
+ }
1003
+ }
1004
+ this.changeListen(!0);
1005
+ }
1006
+ updateSelect(e, t, s) {
1007
+ this.changeListen(!1), e && (this.select.dataset.id = e), t && (this.select.style.cssText = t), s && (this.select.className = "", s.forEach((i) => {
1008
+ i.trim() !== "" && this.select.classList.add(i.trim());
1009
+ })), this.changeListen(!0);
1010
+ }
1011
+ updateOptions(e) {
1012
+ this.changeListen(!1), this.select.innerHTML = "";
1013
+ for (const t of e)
1014
+ t instanceof g && this.select.appendChild(this.createOptgroup(t)), t instanceof p && this.select.appendChild(this.createOption(t));
1015
+ this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0);
1016
+ }
1017
+ createOptgroup(e) {
1018
+ const t = document.createElement("optgroup");
1019
+ if (t.id = e.id, t.label = e.label, e.selectAll && (t.dataset.selectAll = "true"), e.closable !== "off" && (t.dataset.closable = e.closable), e.options)
1020
+ for (const s of e.options)
1021
+ t.appendChild(this.createOption(s));
1022
+ return t;
1023
+ }
1024
+ createOption(e) {
1025
+ const t = document.createElement("option");
1026
+ return t.id = e.id, t.value = e.value, t.textContent = e.text, e.html !== "" && t.setAttribute("data-html", e.html), t.defaultSelected = e.defaultSelected, t.selected = e.selected, e.disabled && (t.disabled = !0), e.display || (t.style.display = "none"), e.placeholder && t.setAttribute("data-placeholder", "true"), e.mandatory && t.setAttribute("data-mandatory", "true"), e.class && e.class.split(" ").forEach((s) => {
1027
+ t.classList.add(s);
1028
+ }), e.data && typeof e.data == "object" && Object.keys(e.data).forEach((s) => {
1029
+ t.setAttribute("data-" + P(s), e.data[s]);
1030
+ }), t;
1031
+ }
1032
+ destroy() {
1033
+ this.changeListen(!1), this.select.removeEventListener("change", this.valueChange), this.observer && (this.observer.disconnect(), this.observer = null), delete this.select.dataset.id, this.showUI();
1034
+ }
1035
+ }
1036
+ class H {
1037
+ id = "";
1038
+ // Primary ID for the select
1039
+ style = "";
1040
+ // Style attribute from the select element
1041
+ class = [];
1042
+ // Class attribute from the select element
1043
+ // Dynamic settings
1044
+ isMultiple = !1;
1045
+ isOpen = !1;
1046
+ isFullOpen = !1;
1047
+ intervalMove = null;
1048
+ // Fields set from constructor
1049
+ disabled;
1050
+ alwaysOpen;
1051
+ showSearch;
1052
+ focusSearch;
1053
+ ariaLabel;
1054
+ searchPlaceholder;
1055
+ searchText;
1056
+ searchingText;
1057
+ searchHighlight;
1058
+ closeOnSelect;
1059
+ contentLocation;
1060
+ contentPosition;
1061
+ openPosition;
1062
+ placeholderText;
1063
+ allowDeselect;
1064
+ hideSelected;
1065
+ keepOrder;
1066
+ showOptionTooltips;
1067
+ minSelected;
1068
+ maxSelected;
1069
+ timeoutDelay;
1070
+ maxValuesShown;
1071
+ maxValuesMessage;
1072
+ addableText;
1073
+ constructor(e) {
1074
+ e || (e = {}), this.id = "ss-" + y(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.alwaysOpen = e.alwaysOpen !== void 0 ? e.alwaysOpen : !1, this.showSearch = e.showSearch !== void 0 ? e.showSearch : !0, this.focusSearch = e.focusSearch !== void 0 ? e.focusSearch : !0, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.searchHighlight = e.searchHighlight !== void 0 ? e.searchHighlight : !1, this.closeOnSelect = e.closeOnSelect !== void 0 ? e.closeOnSelect : !0, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || 'Press "Enter" to add {value}';
1075
+ }
1076
+ }
1077
+ let F = class {
1078
+ selectEl;
1079
+ // Classes
1080
+ settings;
1081
+ cssClasses;
1082
+ select;
1083
+ store;
1084
+ render;
1085
+ // Timeout tracking for cleanup
1086
+ openTimeout = null;
1087
+ closeTimeout = null;
1088
+ // Events
1089
+ events = {
1090
+ search: void 0,
1091
+ searchFilter: (e, t) => e.text.toLowerCase().indexOf(t.toLowerCase()) !== -1,
1092
+ addable: void 0,
1093
+ beforeChange: void 0,
1094
+ afterChange: void 0,
1095
+ beforeOpen: void 0,
1096
+ afterOpen: void 0,
1097
+ beforeClose: void 0,
1098
+ afterClose: void 0
1099
+ };
1100
+ constructor(e) {
1101
+ if (this.selectEl = typeof e.select == "string" ? document.querySelector(e.select) : e.select, !this.selectEl) {
1102
+ e.events && e.events.error && e.events.error(new Error("Could not find select element"));
1103
+ return;
1104
+ }
1105
+ if (this.selectEl.tagName !== "SELECT") {
1106
+ e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1107
+ return;
1108
+ }
1109
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new H(e.settings), this.cssClasses = new N(e.cssClasses);
1110
+ const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1111
+ for (const n in e.events)
1112
+ e.events.hasOwnProperty(n) && (t.indexOf(n) !== -1 ? this.events[n] = S(e.events[n], 100) : this.events[n] = e.events[n]);
1113
+ this.settings.disabled = e.settings?.disabled ? e.settings.disabled : this.selectEl.disabled, this.settings.isMultiple = this.selectEl.multiple, this.settings.style = this.selectEl.style.cssText, this.settings.class = this.selectEl.className.split(" "), this.select = new I(this.selectEl), this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class), this.select.hideUI(), this.select.onValueChange = (n) => {
1114
+ this.setSelected(n.map((o) => o.id));
1115
+ }, this.select.onClassChange = (n) => {
1116
+ this.settings.class = n, this.render.updateClassStyles();
1117
+ }, this.select.onDisabledChange = (n) => {
1118
+ n ? this.disable() : this.enable();
1119
+ }, this.select.onOptionsChange = (n) => {
1120
+ this.setData(n);
1121
+ };
1122
+ const s = e.data ? e.data : this.select.getData();
1123
+ this.store = new V(this.settings.isMultiple ? "multiple" : "single", s), e.data && this.select.updateOptions(this.store.getData());
1124
+ const i = {
1125
+ open: this.open.bind(this),
1126
+ close: this.close.bind(this),
1127
+ addable: this.events.addable ? this.events.addable : void 0,
1128
+ setSelected: this.setSelected.bind(this),
1129
+ addOption: this.addOption.bind(this),
1130
+ search: this.search.bind(this),
1131
+ beforeChange: this.events.beforeChange,
1132
+ afterChange: this.events.afterChange
1133
+ };
1134
+ this.render = new B(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1135
+ const l = this.selectEl.getAttribute("aria-label"), a = this.selectEl.getAttribute("aria-labelledby");
1136
+ l ? this.render.main.main.setAttribute("aria-label", l) : a && this.render.main.main.setAttribute("aria-labelledby", a), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), window.addEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.addEventListener("scroll", this.windowScroll, !1), document.addEventListener("visibilitychange", this.windowVisibilityChange), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.selectEl.slim = this;
1137
+ }
1138
+ // Set to enabled and remove disabled classes
1139
+ enable() {
1140
+ this.settings.disabled = !1, this.select.enable(), this.render.enable();
1141
+ }
1142
+ // Set to disabled and add disabled classes
1143
+ disable() {
1144
+ this.settings.disabled = !0, this.select.disable(), this.render.disable();
1145
+ }
1146
+ getData() {
1147
+ return this.store.getData();
1148
+ }
1149
+ setData(e) {
1150
+ const t = this.store.getSelected(), s = this.store.validateDataArray(e);
1151
+ if (s) {
1152
+ this.events.error && this.events.error(s);
1153
+ return;
1154
+ }
1155
+ this.store.setData(e);
1156
+ const i = this.store.getData();
1157
+ this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !C(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1158
+ }
1159
+ getSelected() {
1160
+ let e = this.store.getSelectedOptions();
1161
+ return this.settings.keepOrder && (e = this.store.selectedOrderOptions(e)), e.map((t) => t.value);
1162
+ }
1163
+ // Will take in a string or array of strings and set the selected by either the id or value
1164
+ setSelected(e, t = !0) {
1165
+ const s = this.store.getSelected(), i = this.store.getDataOptions();
1166
+ e = Array.isArray(e) ? e : [e];
1167
+ const l = [];
1168
+ for (const n of e) {
1169
+ if (i.find((o) => o.id == n)) {
1170
+ l.push(n);
1171
+ continue;
1172
+ }
1173
+ for (const o of i.filter((c) => c.value == n))
1174
+ l.push(o.id);
1175
+ }
1176
+ this.store.setSelectedBy("id", l);
1177
+ const a = this.store.getData();
1178
+ this.select.updateOptions(a), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(a), t && this.events.afterChange && !C(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1179
+ }
1180
+ addOption(e) {
1181
+ const t = this.store.getSelected();
1182
+ this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1183
+ const s = this.store.getData();
1184
+ this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !C(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1185
+ }
1186
+ open() {
1187
+ this.settings.disabled || this.settings.isOpen || (this.events.beforeOpen && this.events.beforeOpen(), this.render.open(), this.settings.showSearch && this.settings.focusSearch && this.render.searchFocus(), this.settings.isOpen = !0, this.openTimeout = setTimeout(() => {
1188
+ this.events.afterOpen && this.events.afterOpen(), this.settings.isOpen && (this.settings.isFullOpen = !0), document.addEventListener("click", this.documentClick);
1189
+ }, this.settings.timeoutDelay), this.settings.contentPosition === "absolute" && (this.settings.intervalMove && clearInterval(this.settings.intervalMove), this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500)));
1190
+ }
1191
+ close(e = null) {
1192
+ !this.settings.isOpen || this.settings.alwaysOpen || (this.events.beforeClose && this.events.beforeClose(), this.render.close(), this.render.clearSearch(), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
1193
+ this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
1194
+ }, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
1195
+ }
1196
+ // Take in string value and search current options
1197
+ search(e) {
1198
+ if (this.render.content.search.input.value !== e && (this.render.content.search.input.value = e), !this.events.search) {
1199
+ const s = e === "" ? this.store.getData() : this.store.search(e, this.events.searchFilter);
1200
+ this.render.renderOptions(s);
1201
+ return;
1202
+ }
1203
+ this.render.renderSearching();
1204
+ const t = this.events.search(e, this.store.getSelectedOptions());
1205
+ if (t instanceof Promise) {
1206
+ t.then((s) => {
1207
+ this.store.setData(s, !0), this.select.updateOptions(this.store.getData()), this.render.renderOptions(this.store.getData());
1208
+ }).catch((s) => {
1209
+ this.render.renderError(typeof s == "string" ? s : s.message);
1210
+ });
1211
+ return;
1212
+ } else Array.isArray(t) ? (this.store.setData(t, !0), this.select.updateOptions(this.store.getData()), this.render.renderOptions(this.store.getData())) : this.render.renderError("Search event must return a promise or an array of data");
1213
+ }
1214
+ destroy() {
1215
+ this.openTimeout && (clearTimeout(this.openTimeout), this.openTimeout = null), this.closeTimeout && (clearTimeout(this.closeTimeout), this.closeTimeout = null), this.settings.intervalMove && (clearInterval(this.settings.intervalMove), this.settings.intervalMove = null), document.removeEventListener("click", this.documentClick), window.removeEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.removeEventListener("scroll", this.windowScroll, !1), document.removeEventListener("visibilitychange", this.windowVisibilityChange), this.store.setData([]), this.render.destroy(), this.select.destroy();
1216
+ }
1217
+ windowResize = S(() => {
1218
+ !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1219
+ });
1220
+ // Event listener for window scrolling
1221
+ windowScroll = S(() => {
1222
+ !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1223
+ });
1224
+ // Event listener for document click
1225
+ documentClick = (e) => {
1226
+ this.settings.isOpen && e.target && !M(e.target, this.settings.id) && this.close(e.type);
1227
+ };
1228
+ // Event Listener for window visibility change
1229
+ windowVisibilityChange = () => {
1230
+ document.hidden && this.close();
1231
+ };
1232
+ };
1233
+ const R = E({
1234
+ name: "SlimSelect",
1235
+ props: {
1236
+ modelValue: {
1237
+ type: [String, Array, void 0]
1238
+ },
1239
+ multiple: {
1240
+ type: Boolean,
1241
+ default: !1
1242
+ },
1243
+ data: {
1244
+ type: Array
1245
+ },
1246
+ settings: {
1247
+ type: Object
1248
+ },
1249
+ events: {
1250
+ type: Object,
1251
+ default: () => ({})
1252
+ }
1253
+ },
1254
+ emits: ["update:modelValue"],
1255
+ data() {
1256
+ return {
1257
+ slim: null
1258
+ };
1259
+ },
1260
+ mounted() {
1261
+ this.$slots.default && this.$slots.default().length > 0 && this.data && console.warn(
1262
+ "[SlimSelect Vue] Both slot content and data prop are provided. Data prop will take precedence and slot content will be ignored."
1263
+ );
1264
+ let e = {
1265
+ select: this.$refs.slim
1266
+ };
1267
+ this.data && (e.data = this.data), this.settings && (e.settings = this.settings);
1268
+ const t = this.events?.afterChange;
1269
+ e.events = {
1270
+ ...this.events,
1271
+ afterChange: (i) => {
1272
+ const l = this.multiple ? i.map((a) => a.value) : i.length > 0 ? i[0].value : "";
1273
+ this.value !== l && (this.value = l), t && t(i);
1274
+ }
1275
+ }, this.slim = new F(e);
1276
+ let s = this.$props.multiple ? this.slim.getSelected() : this.slim.getSelected()[0];
1277
+ this.value !== s && this.slim.setSelected(this.value, !1);
1278
+ },
1279
+ updated() {
1280
+ if (this.slim && !this.data) {
1281
+ const h = this.slim.getSelected(), e = Array.isArray(this.value) ? this.value : [this.value];
1282
+ JSON.stringify(h.sort()) !== JSON.stringify(e.sort()) && this.slim.setSelected(this.value, !1);
1283
+ }
1284
+ },
1285
+ beforeUnmount() {
1286
+ this.slim && this.slim.destroy();
1287
+ },
1288
+ watch: {
1289
+ modelValue: {
1290
+ handler: function(h) {
1291
+ this.slim && this.slim.setSelected(this.getCleanValue(h), !1);
1292
+ }
1293
+ },
1294
+ data: {
1295
+ handler: function(h) {
1296
+ this.slim && this.slim.setData(h);
1297
+ },
1298
+ deep: !0
1299
+ }
1300
+ },
1301
+ computed: {
1302
+ value: {
1303
+ get() {
1304
+ return this.getCleanValue(this.$props.modelValue);
1305
+ },
1306
+ set(h) {
1307
+ this.$emit("update:modelValue", h);
1308
+ }
1309
+ }
1310
+ },
1311
+ methods: {
1312
+ // This allows via a ref to call the SlimSelect methods
1313
+ getSlimSelect() {
1314
+ return this.slim;
1315
+ },
1316
+ getCleanValue(h) {
1317
+ const e = this.$props.multiple;
1318
+ return typeof h == "string" ? e ? [h] : h : Array.isArray(h) ? e ? h : h[0] : e ? [] : "";
1319
+ }
1320
+ }
1321
+ }), $ = (h, e) => {
1322
+ const t = h.__vccOpts || h;
1323
+ for (const [s, i] of e)
1324
+ t[s] = i;
1325
+ return t;
1326
+ }, U = ["multiple"];
1327
+ function q(h, e, t, s, i, l) {
1328
+ return D(), T("select", {
1329
+ multiple: h.multiple,
1330
+ ref: "slim"
1331
+ }, [
1332
+ k(h.$slots, "default")
1333
+ ], 8, U);
1334
+ }
1335
+ const z = /* @__PURE__ */ $(R, [["render", q]]);
1336
+ export {
1337
+ g as Optgroup,
1338
+ p as Option,
1339
+ H as Settings,
1340
+ z as default
1341
+ };