slim-select 3.1.4 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineComponent as E, createElementBlock as T, openBlock as D, renderSlot as k } from "vue";
2
- class N {
1
+ import { defineComponent as L, createElementBlock as D, openBlock as k, renderSlot as N } from "vue";
2
+ class M {
3
3
  main;
4
4
  // Placeholder
5
5
  placeholder;
@@ -60,36 +60,41 @@ class N {
60
60
  disabled;
61
61
  hide;
62
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";
63
+ e || (e = {});
64
+ let t = (s = "", i = "") => `${s} ${i}`.trim();
65
+ this.main = t("ss-main", e.main), this.placeholder = t("ss-placeholder", e.placeholder), this.values = t("ss-values", e.values), this.single = t("ss-single", e.single), this.max = t("ss-max", e.max), this.value = t("ss-value", e.value), this.valueText = t("ss-value-text", e.valueText), this.valueDelete = t("ss-value-delete", e.valueDelete), this.valueOut = t("ss-value-out", e.valueOut), this.deselect = t("ss-deselect", e.deselect), this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = t("ss-arrow", e.arrow), this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = t("ss-content", e.content), this.contentOpen = t("ss-open", e.contentOpen), this.dirAbove = t("ss-dir-above", e.dirAbove), this.dirBelow = t("ss-dir-below", e.dirBelow), this.search = t("ss-search", e.search), this.searchHighlighter = t("ss-search-highlight", e.searchHighlighter), this.searching = t("ss-searching", e.searching), this.addable = t("ss-addable", e.addable), this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = t("ss-list", e.list), this.optgroup = t("ss-optgroup", e.optgroup), this.optgroupLabel = t("ss-optgroup-label", e.optgroupLabel), this.optgroupLabelText = t("ss-optgroup-label-text", e.optgroupLabelText), this.optgroupActions = t("ss-optgroup-actions", e.optgroupActions), this.optgroupSelectAll = t("ss-selectall", e.optgroupSelectAll), 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 = t("ss-closable", e.optgroupClosable), this.option = t("ss-option", e.option), this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = t("ss-highlighted", e.highlighted), this.mainOpen = t("ss-open", e.mainOpen), this.close = t("ss-close", e.close), this.selected = t("ss-selected", e.selected), this.error = t("ss-error", e.error), this.disabled = t("ss-disabled", e.disabled), this.hide = t("ss-hide", e.hide);
66
+ }
67
+ getFirst(e) {
68
+ return this[e].split(" ")[0];
64
69
  }
65
70
  }
66
- function C() {
71
+ function y() {
67
72
  return Math.random().toString(36).substring(2, 10);
68
73
  }
69
- function M(h, e) {
74
+ function E(c, e) {
70
75
  function t(i, l) {
71
76
  return l && i && i.classList && i.classList.contains(l) || l && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
72
77
  }
73
78
  function s(i, l) {
74
79
  return !i || i === document ? null : t(i, l) ? i : s(i.parentNode, l);
75
80
  }
76
- return t(h, e) || s(h, e);
81
+ return t(c, e) || s(c, e);
77
82
  }
78
- function O(h, e = 50, t = !1) {
83
+ function w(c, e = 50, t = !1) {
79
84
  let s;
80
85
  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);
86
+ const l = self, n = () => {
87
+ s = null, t || c.apply(l, i);
88
+ }, a = t && !s;
89
+ clearTimeout(s), s = setTimeout(n, e), a && c.apply(l, i);
85
90
  };
86
91
  }
87
- function y(h, e) {
88
- return JSON.stringify(h) === JSON.stringify(e);
92
+ function O(c, e) {
93
+ return JSON.stringify(c) === JSON.stringify(e);
89
94
  }
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;
95
+ function P(c) {
96
+ const e = c.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
97
+ return c[0] === c[0].toUpperCase() ? e.substring(1) : e;
93
98
  }
94
99
  class p {
95
100
  id;
@@ -106,10 +111,10 @@ class p {
106
111
  data;
107
112
  mandatory;
108
113
  constructor(e) {
109
- this.id = !e.id || e.id === "" ? C() : 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 || {};
114
+ 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
115
  }
111
116
  }
112
- class g {
117
+ class m {
113
118
  id;
114
119
  label;
115
120
  selectAll;
@@ -117,7 +122,7 @@ class g {
117
122
  closable;
118
123
  options;
119
124
  constructor(e) {
120
- if (this.id = !e.id || e.id === "" ? C() : 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)
125
+ 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
126
  for (const t of e.options)
122
127
  this.options.push(new p(t));
123
128
  }
@@ -136,7 +141,7 @@ class V {
136
141
  return new Error("Data must be an array");
137
142
  for (let t of e)
138
143
  if (t)
139
- if (t instanceof g || "label" in t) {
144
+ if (t instanceof m || "label" in t) {
140
145
  if (!("label" in t))
141
146
  return new Error("Optgroup must have a label");
142
147
  if ("options" in t && t.options)
@@ -161,11 +166,11 @@ class V {
161
166
  let t = [];
162
167
  return e.forEach((s) => {
163
168
  if (s) {
164
- if (s instanceof g || "label" in s) {
169
+ if (s instanceof m || "label" in s) {
165
170
  let i = [];
166
171
  "options" in s && s.options && s.options.forEach((l) => {
167
172
  i.push(new p(l));
168
- }), i.length > 0 && t.push(new g(s));
173
+ }), i.length > 0 && t.push(new m(s));
169
174
  }
170
175
  (s instanceof p || "text" in s) && t.push(new p(s));
171
176
  }
@@ -175,22 +180,22 @@ class V {
175
180
  const s = this.partialToFullData(e);
176
181
  if (t) {
177
182
  const i = this.getSelectedOptions(), l = [];
178
- i.forEach((a) => {
179
- let n = !1;
183
+ i.forEach((n) => {
184
+ let a = !1;
180
185
  for (const o of s) {
181
- if (o instanceof p && o.id === a.id) {
182
- n = !0;
186
+ if (o instanceof p && o.id === n.id) {
187
+ a = !0;
183
188
  break;
184
189
  }
185
- if (o instanceof g) {
186
- for (const c of o.options)
187
- if (c.id === a.id) {
188
- n = !0;
190
+ if (o instanceof m) {
191
+ for (const h of o.options)
192
+ if (h.id === n.id) {
193
+ a = !0;
189
194
  break;
190
195
  }
191
196
  }
192
197
  }
193
- n || l.push(a);
198
+ a || l.push(n);
194
199
  }), this.data = [...l, ...s];
195
200
  } else
196
201
  this.data = s;
@@ -218,18 +223,18 @@ class V {
218
223
  setSelectedBy(e, t) {
219
224
  let s = null, i = !1;
220
225
  const l = [];
221
- for (let n of this.data) {
222
- if (n instanceof g)
223
- for (let o of n.options) {
226
+ for (let a of this.data) {
227
+ if (a instanceof m)
228
+ for (let o of a.options) {
224
229
  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));
230
+ let h = o[e] || "";
231
+ o.selected = i ? !1 : t.includes(h), o.selected && (l.push(o), this.selectType === "single" && (i = !0));
227
232
  }
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)));
233
+ a instanceof p && (s || (s = a), a.selected = i ? !1 : t.includes(a[e]), a.selected && (l.push(a), this.selectType === "single" && (i = !0)));
229
234
  }
230
235
  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;
236
+ const n = t.map((a) => l.find((o) => o[e] === a)?.id || "");
237
+ this.selectedOrder = n;
233
238
  }
234
239
  getSelected() {
235
240
  return this.getSelectedOptions().map((e) => e.id);
@@ -242,7 +247,7 @@ class V {
242
247
  }
243
248
  getOptgroupByID(e) {
244
249
  for (let t of this.data)
245
- if (t instanceof g && t.id === e)
250
+ if (t instanceof m && t.id === e)
246
251
  return t;
247
252
  return null;
248
253
  }
@@ -256,7 +261,7 @@ class V {
256
261
  getFirstOption() {
257
262
  let e = null;
258
263
  for (let t of this.data)
259
- if (t instanceof g ? e = t.options[0] : t instanceof p && (e = t), e)
264
+ if (t instanceof m ? e = t.options[0] : t instanceof p && (e = t), e)
260
265
  break;
261
266
  return e;
262
267
  }
@@ -269,13 +274,13 @@ class V {
269
274
  filter(e, t) {
270
275
  const s = [];
271
276
  return this.data.forEach((i) => {
272
- if (i instanceof g) {
277
+ if (i instanceof m) {
273
278
  let l = [];
274
- if (i.options.forEach((n) => {
275
- (!e || e(n)) && (t ? l.push(new p(n)) : s.push(new p(n)));
279
+ if (i.options.forEach((a) => {
280
+ (!e || e(a)) && (t ? l.push(new p(a)) : s.push(new p(a)));
276
281
  }), l.length > 0) {
277
- let n = new g(i);
278
- n.options = l, s.push(n);
282
+ let a = new m(i);
283
+ a.options = l, s.push(a);
279
284
  }
280
285
  }
281
286
  i instanceof p && (!e || e(i)) && s.push(new p(i));
@@ -298,12 +303,14 @@ class V {
298
303
  }), t;
299
304
  }
300
305
  }
301
- class B {
306
+ class F {
302
307
  settings;
303
308
  store;
304
309
  callbacks;
305
310
  // Used to compute the range selection
306
311
  lastSelectedOption;
312
+ // Timeout tracking for cleanup
313
+ closeAnimationTimeout = null;
307
314
  // Elements
308
315
  main;
309
316
  content;
@@ -312,18 +319,35 @@ class B {
312
319
  constructor(e, t, s, i) {
313
320
  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.contentPosition !== "relative" && (this.content.main.style.top = "-9999px", this.content.main.style.left = "-9999px", this.content.main.style.margin = "0", this.content.main.style.width = "auto"), this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main);
314
321
  }
322
+ // Helper method to add classes that may contain spaces
323
+ // Splits by spaces and adds each class individually to avoid DOMException
324
+ addClasses(e, t) {
325
+ if (!t || t.trim() === "")
326
+ return;
327
+ const s = t.split(" ").filter((i) => i.trim() !== "");
328
+ for (const i of s)
329
+ e.classList.add(i.trim());
330
+ }
331
+ // Helper method to remove classes that may contain spaces
332
+ removeClasses(e, t) {
333
+ if (!t || t.trim() === "")
334
+ return;
335
+ const s = t.split(" ").filter((i) => i.trim() !== "");
336
+ for (const i of s)
337
+ e.classList.remove(i.trim());
338
+ }
315
339
  // Remove disabled classes
316
340
  enable() {
317
- this.main.main.classList.remove(this.classes.disabled), this.main.main.setAttribute("aria-disabled", "false"), this.content.search.input.disabled = !1;
341
+ this.removeClasses(this.main.main, this.classes.disabled), this.main.main.setAttribute("aria-disabled", "false"), this.content.search.input.disabled = !1;
318
342
  }
319
343
  // Set disabled classes
320
344
  disable() {
321
- this.main.main.classList.add(this.classes.disabled), this.main.main.setAttribute("aria-disabled", "true"), this.content.search.input.disabled = !0;
345
+ this.addClasses(this.main.main, this.classes.disabled), this.main.main.setAttribute("aria-disabled", "true"), this.content.search.input.disabled = !0;
322
346
  }
323
347
  open() {
324
- this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true");
348
+ this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true"), this.closeAnimationTimeout && (clearTimeout(this.closeAnimationTimeout), this.closeAnimationTimeout = null);
325
349
  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();
350
+ this.addClasses(this.main.main, t), this.addClasses(this.content.main, t), this.addClasses(this.content.main, this.classes.contentOpen), this.content.search.input.removeAttribute("aria-hidden"), this.moveContent();
327
351
  const s = this.store.getSelectedOptions();
328
352
  if (s.length) {
329
353
  const i = s[s.length - 1].id, l = this.content.list.querySelector('[data-id="' + i + '"]');
@@ -331,12 +355,24 @@ class B {
331
355
  }
332
356
  }
333
357
  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"), setTimeout(() => {
335
- this.main.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow);
336
- }, 100);
358
+ this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.removeClasses(this.content.main, this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
359
+ const e = this.getAnimationTiming();
360
+ this.closeAnimationTimeout = setTimeout(() => {
361
+ this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow), this.removeClasses(this.content.main, this.classes.dirAbove), this.removeClasses(this.content.main, this.classes.dirBelow), this.closeAnimationTimeout = null;
362
+ }, e);
363
+ }
364
+ getAnimationTiming() {
365
+ const t = getComputedStyle(this.content.main).getPropertyValue("--ss-animation-timing").trim();
366
+ if (t) {
367
+ if (t.endsWith("ms"))
368
+ return parseFloat(t);
369
+ if (t.endsWith("s"))
370
+ return parseFloat(t) * 1e3;
371
+ }
372
+ return 200;
337
373
  }
338
374
  updateClassStyles() {
339
- 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)
375
+ if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.addClasses(this.main.main, this.classes.main), this.addClasses(this.content.main, 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)
340
376
  for (const e of this.settings.class)
341
377
  e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
342
378
  (this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
@@ -347,33 +383,35 @@ class B {
347
383
  }
348
384
  mainDiv() {
349
385
  const e = document.createElement("div");
350
- e.dataset.id = this.settings.id, e.setAttribute("aria-label", this.settings.ariaLabel), e.tabIndex = 0, e.onkeydown = (c) => {
351
- switch (c.key) {
386
+ e.dataset.id = this.settings.id, e.setAttribute("aria-label", this.settings.ariaLabel), e.tabIndex = 0, e.onkeydown = (h) => {
387
+ switch (h.key) {
352
388
  case "ArrowUp":
353
389
  case "ArrowDown":
354
- return this.callbacks.open(), c.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
390
+ return this.callbacks.open(), h.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
355
391
  case "Tab":
356
392
  return this.callbacks.close(), !0;
357
393
  // Continue doing normal tabbing
358
394
  case "Enter":
359
395
  case " ":
360
396
  this.callbacks.open();
361
- const r = this.content.list.querySelector("." + this.classes.highlighted);
397
+ const r = this.content.list.querySelector(
398
+ "." + this.classes.getFirst("highlighted")
399
+ );
362
400
  return r && r.click(), !1;
363
401
  case "Escape":
364
402
  return this.callbacks.close(), !1;
365
403
  }
366
- return c.key.length === 1 && this.callbacks.open(), !0;
367
- }, e.onclick = (c) => {
404
+ return h.key.length === 1 && this.callbacks.open(), !0;
405
+ }, e.onclick = (h) => {
368
406
  this.settings.disabled || (this.settings.isOpen ? this.callbacks.close() : this.callbacks.open());
369
407
  };
370
408
  const t = document.createElement("div");
371
- t.classList.add(this.classes.values), e.appendChild(t);
409
+ this.addClasses(t, this.classes.values), e.appendChild(t);
372
410
  const s = document.createElement("div");
373
- s.classList.add(this.classes.deselect);
411
+ this.addClasses(s, this.classes.deselect);
374
412
  const i = this.store?.getSelectedOptions();
375
- !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) => {
376
- if (c.stopPropagation(), this.settings.disabled)
413
+ !this.settings.allowDeselect || this.settings.isMultiple && i && i.length <= 0 ? this.addClasses(s, this.classes.hide) : this.removeClasses(s, this.classes.hide), s.onclick = (h) => {
414
+ if (h.stopPropagation(), this.settings.disabled)
377
415
  return;
378
416
  let r = !0;
379
417
  const d = this.store.getSelectedOptions(), f = [];
@@ -381,29 +419,29 @@ class B {
381
419
  if (this.settings.isMultiple)
382
420
  this.callbacks.setSelected([], !1), this.updateDeselectAll();
383
421
  else {
384
- const u = this.store.getFirstOption(), m = u ? u.id : "";
385
- this.callbacks.setSelected(m, !1);
422
+ const u = this.store.getFirstOption(), g = u ? u.id : "";
423
+ this.callbacks.setSelected(g, !1);
386
424
  }
387
425
  this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
388
426
  }
389
427
  };
390
428
  const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
391
429
  l.setAttribute("viewBox", "0 0 100 100");
392
- const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
393
- a.setAttribute("d", this.classes.deselectPath), l.appendChild(a), s.appendChild(l), e.appendChild(s);
394
- const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
395
- n.classList.add(this.classes.arrow), n.setAttribute("viewBox", "0 0 100 100");
430
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
431
+ n.setAttribute("d", this.classes.deselectPath), l.appendChild(n), s.appendChild(l), e.appendChild(s);
432
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
433
+ this.addClasses(a, this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
396
434
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
397
- return o.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && n.classList.add(this.classes.hide), n.appendChild(o), e.appendChild(n), {
435
+ return o.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && this.addClasses(a, this.classes.hide), a.appendChild(o), e.appendChild(a), {
398
436
  main: e,
399
437
  values: t,
400
438
  deselect: {
401
439
  main: s,
402
440
  svg: l,
403
- path: a
441
+ path: n
404
442
  },
405
443
  arrow: {
406
- main: n,
444
+ main: a,
407
445
  path: o
408
446
  }
409
447
  };
@@ -416,7 +454,7 @@ class B {
416
454
  let t = this.settings.placeholderText;
417
455
  e.length && (e[0].html !== "" ? t = e[0].html : e[0].text !== "" && (t = e[0].text));
418
456
  const s = document.createElement("div");
419
- return s.classList.add(this.classes.placeholder), s.innerHTML = t, s;
457
+ return this.addClasses(s, this.classes.placeholder), s.innerHTML = t, s;
420
458
  }
421
459
  // Get selected values and append to multiSelected values container
422
460
  // and remove those who shouldnt exist
@@ -433,9 +471,9 @@ class B {
433
471
  this.main.values.innerHTML = this.placeholder().outerHTML;
434
472
  else {
435
473
  const s = document.createElement("div");
436
- s.classList.add(this.classes.single), t.html ? s.innerHTML = t.html : s.innerText = t.text, this.main.values.innerHTML = s.outerHTML;
474
+ this.addClasses(s, this.classes.single), t.html ? s.innerHTML = t.html : s.innerText = t.text, this.main.values.innerHTML = s.outerHTML;
437
475
  }
438
- !this.settings.allowDeselect || !e.length ? this.main.deselect.main.classList.add(this.classes.hide) : this.main.deselect.main.classList.remove(this.classes.hide);
476
+ !this.settings.allowDeselect || !e.length ? this.addClasses(this.main.deselect.main, this.classes.hide) : this.removeClasses(this.main.deselect.main, this.classes.hide);
439
477
  }
440
478
  renderMultipleValues() {
441
479
  let e = this.main.values.childNodes, t = this.store.filter((i) => i.selected && i.display, !1);
@@ -443,50 +481,50 @@ class B {
443
481
  this.main.values.innerHTML = this.placeholder().outerHTML;
444
482
  return;
445
483
  } else {
446
- const i = this.main.values.querySelector("." + this.classes.placeholder);
484
+ const i = this.main.values.querySelector("." + this.classes.getFirst("placeholder"));
447
485
  i && i.remove();
448
486
  }
449
487
  if (t.length > this.settings.maxValuesShown) {
450
488
  const i = document.createElement("div");
451
- i.classList.add(this.classes.max), i.textContent = this.settings.maxValuesMessage.replace("{number}", t.length.toString()), this.main.values.innerHTML = i.outerHTML;
489
+ this.addClasses(i, this.classes.max), i.textContent = this.settings.maxValuesMessage.replace("{number}", t.length.toString()), this.main.values.innerHTML = i.outerHTML;
452
490
  return;
453
491
  } else {
454
- const i = this.main.values.querySelector("." + this.classes.max);
492
+ const i = this.main.values.querySelector("." + this.classes.getFirst("max"));
455
493
  i && i.remove();
456
494
  }
457
495
  this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
458
496
  let s = [];
459
497
  for (let i = 0; i < e.length; i++) {
460
- const l = e[i], a = l.getAttribute("data-id");
461
- a && (t.filter((o) => o.id === a, !1).length || s.push(l));
498
+ const l = e[i], n = l.getAttribute("data-id");
499
+ n && (t.filter((o) => o.id === n, !1).length || s.push(l));
462
500
  }
463
501
  for (const i of s)
464
- i.classList.add(this.classes.valueOut), setTimeout(() => {
502
+ this.addClasses(i, this.classes.valueOut), setTimeout(() => {
465
503
  this.main.values.hasChildNodes() && this.main.values.contains(i) && this.main.values.removeChild(i);
466
504
  }, 100);
467
505
  e = this.main.values.childNodes;
468
506
  for (let i = 0; i < t.length; i++) {
469
507
  let l = !0;
470
- for (let a = 0; a < e.length; a++)
471
- t[i].id === String(e[a].dataset.id) && (l = !1);
508
+ for (let n = 0; n < e.length; n++)
509
+ t[i].id === String(e[n].dataset.id) && (l = !1);
472
510
  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])));
473
511
  }
474
512
  }
475
513
  multipleValue(e) {
476
514
  const t = document.createElement("div");
477
- t.classList.add(this.classes.value), t.dataset.id = e.id;
515
+ this.addClasses(t, this.classes.value), t.dataset.id = e.id;
478
516
  const s = document.createElement("div");
479
- if (s.classList.add(this.classes.valueText), s.textContent = e.text, t.appendChild(s), !e.mandatory) {
517
+ if (this.addClasses(s, this.classes.valueText), s.textContent = e.text, t.appendChild(s), !e.mandatory) {
480
518
  const i = document.createElement("div");
481
- i.classList.add(this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (n) => {
482
- if (n.preventDefault(), n.stopPropagation(), this.settings.disabled)
519
+ this.addClasses(i, this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (a) => {
520
+ if (a.preventDefault(), a.stopPropagation(), this.settings.disabled)
483
521
  return;
484
522
  let o = !0;
485
- const c = this.store.getSelectedOptions(), r = c.filter((d) => d.selected && d.id !== e.id, !0);
486
- if (!(this.settings.minSelected && r.length < this.settings.minSelected) && (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(r, c) === !0), o)) {
523
+ const h = this.store.getSelectedOptions(), r = h.filter((d) => d.selected && d.id !== e.id, !0);
524
+ if (!(this.settings.minSelected && r.length < this.settings.minSelected) && (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(r, h) === !0), o)) {
487
525
  let d = [];
488
526
  for (const f of r) {
489
- if (f instanceof g)
527
+ if (f instanceof m)
490
528
  for (const u of f.options)
491
529
  u.id && d.push(u.id);
492
530
  f instanceof p && d.push(f.id);
@@ -496,9 +534,9 @@ class B {
496
534
  };
497
535
  const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
498
536
  l.setAttribute("viewBox", "0 0 100 100");
499
- const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
500
- a.setAttribute("d", this.classes.optionDelete), l.appendChild(a), i.appendChild(l), t.appendChild(i), i.onkeydown = (n) => {
501
- n.key === "Enter" && i.click();
537
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
538
+ n.setAttribute("d", this.classes.optionDelete), l.appendChild(n), i.appendChild(l), t.appendChild(i), i.onkeydown = (a) => {
539
+ a.key === "Enter" && i.click();
502
540
  };
503
541
  }
504
542
  return t;
@@ -531,12 +569,12 @@ class B {
531
569
  }
532
570
  searchDiv() {
533
571
  const e = document.createElement("div"), t = document.createElement("input"), s = document.createElement("div");
534
- e.classList.add(this.classes.search);
572
+ this.addClasses(e, this.classes.search);
535
573
  const i = {
536
574
  main: e,
537
575
  input: t
538
576
  };
539
- 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 = O((l) => {
577
+ if (this.settings.showSearch || (this.addClasses(e, 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 = w((l) => {
540
578
  this.callbacks.search(l.target.value);
541
579
  }, 100), t.onkeydown = (l) => {
542
580
  switch (l.key) {
@@ -549,27 +587,31 @@ class B {
549
587
  case "Escape":
550
588
  return this.callbacks.close(), !1;
551
589
  case " ":
552
- const a = this.content.list.querySelector("." + this.classes.highlighted);
553
- return a ? (a.click(), !1) : !0;
590
+ const n = this.content.list.querySelector(
591
+ "." + this.classes.getFirst("highlighted")
592
+ );
593
+ return n ? (n.click(), !1) : !0;
554
594
  case "Enter":
555
- const n = this.content.list.querySelector("." + this.classes.highlighted);
556
- return n ? (n.click(), !1) : this.callbacks.addable ? (s.click(), !1) : !0;
595
+ const a = this.content.list.querySelector(
596
+ "." + this.classes.getFirst("highlighted")
597
+ );
598
+ return a ? (a.click(), !1) : this.callbacks.addable ? (s.click(), !1) : !0;
557
599
  }
558
600
  return !0;
559
601
  }, e.appendChild(t), this.callbacks.addable) {
560
- s.classList.add(this.classes.addable);
602
+ this.addClasses(s, this.classes.addable);
561
603
  const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
562
604
  l.setAttribute("viewBox", "0 0 100 100");
563
- const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
564
- a.setAttribute("d", this.classes.addablePath), l.appendChild(a), s.appendChild(l), s.onclick = (n) => {
565
- if (n.preventDefault(), n.stopPropagation(), !this.callbacks.addable)
605
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
606
+ n.setAttribute("d", this.classes.addablePath), l.appendChild(n), s.appendChild(l), s.onclick = (a) => {
607
+ if (a.preventDefault(), a.stopPropagation(), !this.callbacks.addable)
566
608
  return;
567
609
  const o = this.content.search.input.value.trim();
568
610
  if (o === "") {
569
611
  this.content.search.input.focus();
570
612
  return;
571
613
  }
572
- const c = (d) => {
614
+ const h = (d) => {
573
615
  let f = new p(d);
574
616
  if (this.callbacks.addOption(f), this.settings.isMultiple) {
575
617
  let u = this.store.getSelected();
@@ -581,91 +623,93 @@ class B {
581
623
  }, 100);
582
624
  }, r = this.callbacks.addable(o);
583
625
  r === !1 || r === void 0 || r === null || (r instanceof Promise ? r.then((d) => {
584
- typeof d == "string" ? c({
626
+ typeof d == "string" ? h({
585
627
  text: d,
586
628
  value: d
587
- }) : r instanceof Error ? this.renderError(r.message) : c(d);
588
- }) : typeof r == "string" ? c({
629
+ }) : r instanceof Error ? this.renderError(r.message) : h(d);
630
+ }) : typeof r == "string" ? h({
589
631
  text: r,
590
632
  value: r
591
- }) : r instanceof Error ? this.renderError(r.message) : c(r));
633
+ }) : r instanceof Error ? this.renderError(r.message) : h(r));
592
634
  }, e.appendChild(s), i.addable = {
593
635
  main: s,
594
636
  svg: l,
595
- path: a
637
+ path: n
596
638
  };
597
639
  }
598
640
  return i;
599
641
  }
600
642
  searchFocus() {
601
- this.content.search.input.focus();
643
+ this.content.search.input.focus({ preventScroll: !0 });
602
644
  }
603
645
  getOptions(e = !1, t = !1, s = !1) {
604
- let i = "." + this.classes.option;
605
- 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));
646
+ let i = "." + this.classes.getFirst("option");
647
+ return e && (i += ":not(." + this.classes.getFirst("placeholder") + ")"), t && (i += ":not(." + this.classes.getFirst("disabled") + ")"), s && (i += ":not(." + this.classes.getFirst("hide") + ")"), Array.from(this.content.list.querySelectorAll(i));
606
648
  }
607
649
  // highlightUp is used to highlight the previous option in the list
608
650
  highlight(e) {
609
651
  const t = this.getOptions(!0, !0, !0);
610
652
  if (t.length === 0)
611
653
  return;
612
- if (t.length === 1 && !t[0].classList.contains(this.classes.highlighted)) {
613
- t[0].classList.add(this.classes.highlighted);
654
+ if (t.length === 1 && !t[0].classList.contains(this.classes.getFirst("highlighted"))) {
655
+ this.addClasses(t[0], this.classes.highlighted);
614
656
  return;
615
657
  }
616
658
  let s = !1;
617
659
  for (const l of t)
618
- l.classList.contains(this.classes.highlighted) && (s = !0);
660
+ l.classList.contains(this.classes.getFirst("highlighted")) && (s = !0);
619
661
  if (!s) {
620
662
  for (const l of t)
621
- if (l.classList.contains(this.classes.selected)) {
622
- l.classList.add(this.classes.highlighted);
663
+ if (l.classList.contains(this.classes.getFirst("selected"))) {
664
+ this.addClasses(l, this.classes.highlighted);
623
665
  break;
624
666
  }
625
667
  }
626
668
  for (let l = 0; l < t.length; l++)
627
- if (t[l].classList.contains(this.classes.highlighted)) {
628
- const a = t[l];
629
- a.classList.remove(this.classes.highlighted);
630
- const n = a.parentElement;
631
- if (n && n.classList.contains(this.classes.mainOpen)) {
632
- const r = n.querySelector("." + this.classes.optgroupLabel);
669
+ if (t[l].classList.contains(this.classes.getFirst("highlighted"))) {
670
+ const n = t[l];
671
+ this.removeClasses(n, this.classes.highlighted);
672
+ const a = n.parentElement;
673
+ if (a && a.classList.contains(this.classes.getFirst("mainOpen"))) {
674
+ const r = a.querySelector("." + this.classes.getFirst("optgroupLabel"));
633
675
  r && r.click();
634
676
  }
635
677
  let o = t[e === "down" ? l + 1 < t.length ? l + 1 : 0 : l - 1 >= 0 ? l - 1 : t.length - 1];
636
- o.classList.add(this.classes.highlighted), this.ensureElementInView(this.content.list, o), o.id && this.main.main.setAttribute("aria-activedescendant", o.id);
637
- const c = o.parentElement;
638
- if (c && c.classList.contains(this.classes.close)) {
639
- const r = c.querySelector("." + this.classes.optgroupLabel);
678
+ this.addClasses(o, this.classes.highlighted), this.ensureElementInView(this.content.list, o), o.id && this.main.main.setAttribute("aria-activedescendant", o.id);
679
+ const h = o.parentElement;
680
+ if (h && h.classList.contains(this.classes.getFirst("close"))) {
681
+ const r = h.querySelector(
682
+ "." + this.classes.getFirst("optgroupLabel")
683
+ );
640
684
  r && r.click();
641
685
  }
642
686
  return;
643
687
  }
644
688
  const i = t[e === "down" ? 0 : t.length - 1];
645
- i.classList.add(this.classes.highlighted), i.id && this.main.main.setAttribute("aria-activedescendant", i.id), this.ensureElementInView(this.content.list, i);
689
+ this.addClasses(i, this.classes.highlighted), i.id && this.main.main.setAttribute("aria-activedescendant", i.id), this.ensureElementInView(this.content.list, i);
646
690
  }
647
691
  // Create main container that options will reside
648
692
  listDiv() {
649
693
  const e = document.createElement("div");
650
- e.classList.add(this.classes.list);
694
+ this.addClasses(e, this.classes.list);
651
695
  const t = this.settings.id + "-list";
652
696
  return e.id = t, e.dataset.id = t, e;
653
697
  }
654
698
  renderError(e) {
655
699
  this.content.list.innerHTML = "";
656
700
  const t = document.createElement("div");
657
- t.classList.add(this.classes.error), t.textContent = e, this.content.list.appendChild(t);
701
+ this.addClasses(t, this.classes.error), t.textContent = e, this.content.list.appendChild(t);
658
702
  }
659
703
  renderSearching() {
660
704
  this.content.list.innerHTML = "";
661
705
  const e = document.createElement("div");
662
- e.classList.add(this.classes.searching), e.textContent = this.settings.searchingText, this.content.list.appendChild(e);
706
+ this.addClasses(e, this.classes.searching), e.textContent = this.settings.searchingText, this.content.list.appendChild(e);
663
707
  }
664
708
  // Take in data and add options to
665
709
  renderOptions(e) {
666
710
  if (this.content.list.innerHTML = "", e.length === 0) {
667
711
  const s = document.createElement("div");
668
- 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);
712
+ this.addClasses(s, 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);
669
713
  return;
670
714
  }
671
715
  this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((i) => i.placeholder, !1).length || this.store.addOption(
@@ -679,24 +723,24 @@ class B {
679
723
  ));
680
724
  const t = document.createDocumentFragment();
681
725
  for (const s of e) {
682
- if (s instanceof g) {
726
+ if (s instanceof m) {
683
727
  const i = document.createElement("div");
684
- i.classList.add(this.classes.optgroup);
728
+ this.addClasses(i, this.classes.optgroup);
685
729
  const l = document.createElement("div");
686
- l.classList.add(this.classes.optgroupLabel), i.appendChild(l);
687
- const a = document.createElement("div");
688
- a.classList.add(this.classes.optgroupLabelText), a.textContent = s.label, l.appendChild(a);
730
+ this.addClasses(l, this.classes.optgroupLabel), i.appendChild(l);
689
731
  const n = document.createElement("div");
690
- if (n.classList.add(this.classes.optgroupActions), l.appendChild(n), this.settings.isMultiple && s.selectAll) {
732
+ this.addClasses(n, this.classes.optgroupLabelText), n.textContent = s.label, l.appendChild(n);
733
+ const a = document.createElement("div");
734
+ if (this.addClasses(a, this.classes.optgroupActions), l.appendChild(a), this.settings.isMultiple && s.selectAll) {
691
735
  const o = document.createElement("div");
692
- o.classList.add(this.classes.optgroupSelectAll);
693
- let c = !0;
694
- for (const m of s.options)
695
- if (!m.selected) {
696
- c = !1;
736
+ this.addClasses(o, this.classes.optgroupSelectAll);
737
+ let h = !0;
738
+ for (const g of s.options)
739
+ if (!g.selected) {
740
+ h = !1;
697
741
  break;
698
742
  }
699
- c && o.classList.add(this.classes.selected);
743
+ h && this.addClasses(o, this.classes.selected);
700
744
  const r = document.createElement("span");
701
745
  r.textContent = s.selectAllText, o.appendChild(r);
702
746
  const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@@ -704,37 +748,37 @@ class B {
704
748
  const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
705
749
  f.setAttribute("d", this.classes.optgroupSelectAllBox), d.appendChild(f);
706
750
  const u = document.createElementNS("http://www.w3.org/2000/svg", "path");
707
- u.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(u), o.addEventListener("click", (m) => {
708
- m.preventDefault(), m.stopPropagation();
751
+ u.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(u), o.addEventListener("click", (g) => {
752
+ g.preventDefault(), g.stopPropagation();
709
753
  const v = this.store.getSelected();
710
- if (c) {
711
- const w = v.filter((S) => {
754
+ if (h) {
755
+ const C = v.filter((S) => {
712
756
  for (const b of s.options)
713
757
  if (S === b.id)
714
758
  return !1;
715
759
  return !0;
716
760
  });
717
- this.callbacks.setSelected(w, !0);
761
+ this.callbacks.setSelected(C, !0);
718
762
  return;
719
763
  } else {
720
- let w = s.options.map((b) => b.id).filter((b) => b !== void 0);
721
- const S = v.concat(w);
764
+ let C = s.options.map((b) => b.id).filter((b) => b !== void 0);
765
+ const S = v.concat(C);
722
766
  for (const b of s.options)
723
767
  b.id && !this.store.getOptionByID(b.id) && this.callbacks.addOption(new p(b));
724
768
  this.callbacks.setSelected(S, !0);
725
769
  return;
726
770
  }
727
- }), n.appendChild(o);
771
+ }), a.appendChild(o);
728
772
  }
729
773
  if (s.closable !== "off") {
730
774
  const o = document.createElement("div");
731
- o.classList.add(this.classes.optgroupClosable);
732
- const c = document.createElementNS("http://www.w3.org/2000/svg", "svg");
733
- c.setAttribute("viewBox", "0 0 100 100"), c.classList.add(this.classes.arrow), o.appendChild(c);
775
+ this.addClasses(o, this.classes.optgroupClosable);
776
+ const h = document.createElementNS("http://www.w3.org/2000/svg", "svg");
777
+ h.setAttribute("viewBox", "0 0 100 100"), this.addClasses(h, this.classes.arrow), o.appendChild(h);
734
778
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
735
- 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) => {
736
- 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));
737
- }), n.appendChild(o);
779
+ h.appendChild(r), s.options.some((d) => d.selected) || this.content.search.input.value.trim() !== "" ? (this.addClasses(o, this.classes.mainOpen), r.setAttribute("d", this.classes.arrowOpen)) : s.closable === "open" ? (this.addClasses(i, this.classes.mainOpen), r.setAttribute("d", this.classes.arrowOpen)) : s.closable === "close" && (this.addClasses(i, this.classes.close), r.setAttribute("d", this.classes.arrowClose)), l.addEventListener("click", (d) => {
780
+ d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.getFirst("close")) ? (this.removeClasses(i, this.classes.close), this.addClasses(i, this.classes.mainOpen), r.setAttribute("d", this.classes.arrowOpen)) : (this.removeClasses(i, this.classes.mainOpen), this.addClasses(i, this.classes.close), r.setAttribute("d", this.classes.arrowClose));
781
+ }), a.appendChild(o);
738
782
  }
739
783
  i.appendChild(l);
740
784
  for (const o of s.options)
@@ -748,36 +792,36 @@ class B {
748
792
  option(e) {
749
793
  if (e.placeholder) {
750
794
  const s = document.createElement("div");
751
- return s.classList.add(this.classes.option), s.classList.add(this.classes.hide), s;
795
+ return this.addClasses(s, this.classes.option), this.addClasses(s, this.classes.hide), s;
752
796
  }
753
797
  const t = document.createElement("div");
754
- 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) => {
798
+ return t.dataset.id = e.id, t.id = this.settings.id + "-" + e.id, this.addClasses(t, this.classes.option), t.setAttribute("role", "option"), e.class && e.class.split(" ").forEach((s) => {
755
799
  t.classList.add(s);
756
800
  }), e.style && (t.style.cssText = e.style), this.settings.searchHighlight && this.content.search.input.value.trim() !== "" ? t.innerHTML = this.highlightText(
757
801
  e.html !== "" ? e.html : e.text,
758
802
  this.content.search.input.value,
759
803
  this.classes.searchHighlighter
760
- ) : 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) => {
804
+ ) : e.html !== "" ? t.innerHTML = e.html : t.textContent = e.text, this.settings.showOptionTooltips && t.textContent && t.setAttribute("title", t.textContent), e.display || this.addClasses(t, this.classes.hide), e.disabled && this.addClasses(t, this.classes.disabled), e.selected && this.settings.hideSelected && this.addClasses(t, this.classes.hide), e.selected ? (this.addClasses(t, this.classes.selected), t.setAttribute("aria-selected", "true"), this.main.main.setAttribute("aria-activedescendant", t.id)) : (this.removeClasses(t, this.classes.selected), t.setAttribute("aria-selected", "false")), t.addEventListener("click", (s) => {
761
805
  s.preventDefault(), s.stopPropagation();
762
- const i = this.store.getSelected(), l = s.currentTarget, a = String(l.dataset.id), n = s.ctrlKey || s.metaKey;
763
- if (e.disabled || !this.settings.isMultiple && e.selected && !this.settings.allowDeselect || e.selected && e.mandatory || this.settings.isMultiple && this.settings.maxSelected <= i.length && !e.selected || this.settings.isMultiple && this.settings.minSelected >= i.length && e.selected && !n)
806
+ const i = this.store.getSelected(), l = s.currentTarget, n = String(l.dataset.id), a = s.ctrlKey || s.metaKey;
807
+ if (e.disabled || !this.settings.isMultiple && e.selected && !this.settings.allowDeselect || e.selected && e.mandatory || this.settings.isMultiple && this.settings.maxSelected <= i.length && !e.selected || this.settings.isMultiple && this.settings.minSelected >= i.length && e.selected && !a)
764
808
  return;
765
809
  let o = !1;
766
- const c = this.store.getSelectedOptions();
810
+ const h = this.store.getSelectedOptions();
767
811
  let r = [];
768
812
  if (this.settings.isMultiple) {
769
- const d = c.some((u) => u.id === a);
813
+ const d = h.some((u) => u.id === n);
770
814
  if (s.shiftKey && this.lastSelectedOption) {
771
- const u = this.store.getDataOptions(), m = u.findIndex((w) => w.id === this.lastSelectedOption.id), v = u.findIndex((w) => w.id === e.id);
772
- if (m >= 0 && v >= 0) {
773
- const w = Math.min(m, v), S = Math.max(m, v), L = u.slice(w, S + 1).filter((A) => !c.find((x) => x.id === A.id));
774
- c.length + L.length <= this.settings.maxSelected ? r = c.concat(L) : r = c;
815
+ const u = this.store.getDataOptions(), g = u.findIndex((C) => C.id === this.lastSelectedOption.id), v = u.findIndex((C) => C.id === e.id);
816
+ if (g >= 0 && v >= 0) {
817
+ const C = Math.min(g, v), S = Math.max(g, v), A = u.slice(C, S + 1).filter((x) => !h.find((T) => T.id === x.id));
818
+ h.length + A.length <= this.settings.maxSelected ? r = h.concat(A) : r = h;
775
819
  } else
776
- r = c;
777
- } 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);
820
+ r = h;
821
+ } else a ? (d ? r = h.filter((u) => u.id !== n) : r = h.concat(e), this.lastSelectedOption = e) : (d ? r = h.filter((u) => u.id !== n) : r = h.concat(e), this.lastSelectedOption = e);
778
822
  }
779
- 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) {
780
- this.store.getOptionByID(a) || this.callbacks.addOption(e), this.callbacks.setSelected(
823
+ if (this.settings.isMultiple || (e.selected ? r = [] : r = [e]), this.callbacks.beforeChange || (o = !0), this.callbacks.beforeChange && (this.callbacks.beforeChange(r, h) === !1 ? o = !1 : o = !0), o) {
824
+ this.store.getOptionByID(n) || this.callbacks.addOption(e), this.callbacks.setSelected(
781
825
  r.map((u) => u.id),
782
826
  !1
783
827
  );
@@ -787,44 +831,60 @@ class B {
787
831
  }), t;
788
832
  }
789
833
  destroy() {
790
- this.main.main.remove(), this.content.main.remove();
834
+ this.closeAnimationTimeout && (clearTimeout(this.closeAnimationTimeout), this.closeAnimationTimeout = null), this.main.main.remove(), this.content.main.remove();
791
835
  }
792
836
  highlightText(e, t, s) {
793
837
  const i = t.trim();
794
838
  if (i === "")
795
839
  return e;
796
- const l = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = document.createElement("div");
797
- a.innerHTML = e;
798
- const n = (o) => {
840
+ const l = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), n = document.createElement("div");
841
+ n.innerHTML = e;
842
+ const a = (o) => {
799
843
  if (o.nodeType === Node.TEXT_NODE) {
800
- const c = o.textContent || "", r = new RegExp("(" + l + ")", "i");
801
- if (r.test(c)) {
844
+ const h = o.textContent || "", r = new RegExp("(" + l + ")", "i");
845
+ if (r.test(h)) {
802
846
  const d = document.createElement("span");
803
- c.split(r).forEach((u, m) => {
847
+ h.split(r).forEach((u, g) => {
804
848
  if (u && r.test(u)) {
805
849
  const v = document.createElement("mark");
806
850
  v.className = s, v.textContent = u, d.appendChild(v);
807
851
  } else u && d.appendChild(document.createTextNode(u));
808
852
  }), o.parentNode?.replaceChild(d, o);
809
853
  }
810
- } else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((c) => n(c));
854
+ } else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((h) => a(h));
811
855
  };
812
- return Array.from(a.childNodes).forEach((o) => n(o)), a.innerHTML;
856
+ return Array.from(n.childNodes).forEach((o) => a(o)), n.innerHTML;
857
+ }
858
+ setContentDirection(e) {
859
+ const t = e === "above", s = t ? this.classes.dirAbove : this.classes.dirBelow, i = t ? this.classes.dirBelow : this.classes.dirAbove;
860
+ if (this.removeClasses(this.main.main, i), this.addClasses(this.main.main, s), this.removeClasses(this.content.main, i), this.addClasses(this.content.main, s), t) {
861
+ const l = this.main.main.offsetHeight, n = this.content.main.offsetHeight;
862
+ this.content.main.style.margin = "-" + (l + n - 1) + "px 0px 0px 0px";
863
+ } else
864
+ this.content.main.style.margin = "-1px 0px 0px 0px";
865
+ }
866
+ setContentPosition() {
867
+ if (this.settings.contentPosition === "relative")
868
+ return;
869
+ const e = this.main.main.getBoundingClientRect();
870
+ let t, s;
871
+ if (this.settings.contentPosition === "fixed")
872
+ t = e.top + e.height, s = e.left;
873
+ else {
874
+ const i = this.content.main.offsetParent, l = i ? i.getBoundingClientRect() : { top: 0, left: 0 };
875
+ t = e.top - l.top + e.height - (i?.clientTop || 0), s = e.left - l.left - (i?.clientLeft || 0);
876
+ }
877
+ this.content.main.style.top = t + "px", this.content.main.style.left = s + "px", this.content.main.style.width = e.width + "px";
813
878
  }
814
879
  moveContentAbove() {
815
- const e = this.main.main.offsetHeight, t = this.content.main.offsetHeight;
816
- 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);
817
- const s = this.main.main.getBoundingClientRect();
818
- 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";
880
+ this.setContentDirection("above"), this.setContentPosition();
819
881
  }
820
882
  moveContentBelow() {
821
- 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);
822
- const e = this.main.main.getBoundingClientRect();
823
- 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");
883
+ this.setContentDirection("below"), this.setContentPosition();
824
884
  }
825
885
  ensureElementInView(e, t) {
826
- const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, l = t.offsetTop, a = l + t.clientHeight;
827
- l < s ? e.scrollTop -= s - l : a > i && (e.scrollTop += a - i);
886
+ const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, l = t.offsetTop, n = l + t.clientHeight;
887
+ l < s ? e.scrollTop -= s - l : n > i && (e.scrollTop += n - i);
828
888
  }
829
889
  putContent() {
830
890
  const e = this.main.main.offsetHeight, t = this.main.main.getBoundingClientRect(), s = this.content.main.offsetHeight;
@@ -834,11 +894,11 @@ class B {
834
894
  updateDeselectAll() {
835
895
  if (!this.store || !this.settings)
836
896
  return;
837
- 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;
838
- i && !(s && !t) ? l.classList.remove(a) : l.classList.add(a);
897
+ const e = this.store.getSelectedOptions(), t = e && e.length > 0, s = this.settings.isMultiple, i = this.settings.allowDeselect, l = this.main.deselect.main, n = this.classes.hide;
898
+ i && !(s && !t) ? this.removeClasses(l, n) : this.addClasses(l, n);
839
899
  }
840
900
  }
841
- class I {
901
+ class B {
842
902
  select;
843
903
  // Mutation observer fields
844
904
  onValueChange;
@@ -897,28 +957,30 @@ class I {
897
957
  observeCall(e) {
898
958
  if (!this.listen)
899
959
  return;
900
- let t = !1, s = !1, i = !1;
901
- for (const l of e) {
902
- if (l.target === this.select && (l.attributeName === "disabled" && (s = !0), l.attributeName === "class" && (t = !0), l.type === "childList")) {
903
- for (const a of Array.from(l.addedNodes))
960
+ let t = !1, s = !1, i = !1, l = !1;
961
+ for (const n of e) {
962
+ if (n.target === this.select && (n.attributeName === "disabled" && (s = !0), n.attributeName === "class" && (t = !0), n.type === "childList")) {
963
+ for (const a of Array.from(n.addedNodes))
904
964
  if (a.nodeName === "OPTION" && a.value === this.select.value) {
905
- this.select.dispatchEvent(new Event("change"));
965
+ l = !0;
906
966
  break;
907
967
  }
908
968
  i = !0;
909
969
  }
910
- (l.target.nodeName === "OPTGROUP" || l.target.nodeName === "OPTION") && (i = !0);
970
+ (n.target.nodeName === "OPTGROUP" || n.target.nodeName === "OPTION") && (i = !0);
911
971
  }
912
972
  if (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) {
913
973
  if (this.isUpdating) {
914
974
  if (this.select.options.length > 0) {
915
- const l = this.getData();
916
- l.length > 0 && (this.pendingOptionsChange = l);
975
+ const n = this.getData();
976
+ n.length > 0 && (this.pendingOptionsChange = n);
917
977
  }
978
+ l && this.select.dispatchEvent(new Event("change"));
918
979
  return;
919
980
  }
920
981
  this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
921
982
  }
983
+ l && this.select.dispatchEvent(new Event("change"));
922
984
  }
923
985
  // From the select element pull optgroup and options into data
924
986
  getData() {
@@ -968,8 +1030,8 @@ class I {
968
1030
  const i = s.childNodes;
969
1031
  for (const l of i)
970
1032
  if (l.nodeName === "OPTION") {
971
- const a = l;
972
- a.selected && e.push(this.getDataFromOption(a));
1033
+ const n = l;
1034
+ n.selected && e.push(this.getDataFromOption(n));
973
1035
  }
974
1036
  }
975
1037
  if (s.nodeName === "OPTION") {
@@ -988,10 +1050,10 @@ class I {
988
1050
  for (const s of t) {
989
1051
  if (s.nodeName === "OPTGROUP") {
990
1052
  const l = s.childNodes;
991
- for (const a of l)
992
- if (a.nodeName === "OPTION") {
993
- const n = a;
994
- n.selected = e.includes(n.id);
1053
+ for (const n of l)
1054
+ if (n.nodeName === "OPTION") {
1055
+ const a = n;
1056
+ a.selected = e.includes(a.id);
995
1057
  }
996
1058
  }
997
1059
  if (s.nodeName === "OPTION") {
@@ -1011,10 +1073,10 @@ class I {
1011
1073
  for (const s of t) {
1012
1074
  if (s.nodeName === "OPTGROUP") {
1013
1075
  const l = s.childNodes;
1014
- for (const a of l)
1015
- if (a.nodeName === "OPTION") {
1016
- const n = a;
1017
- n.selected = e.includes(n.value);
1076
+ for (const n of l)
1077
+ if (n.nodeName === "OPTION") {
1078
+ const a = n;
1079
+ a.selected = e.includes(a.value);
1018
1080
  }
1019
1081
  }
1020
1082
  if (s.nodeName === "OPTION") {
@@ -1033,7 +1095,7 @@ class I {
1033
1095
  if (!(!e || e.length === 0)) {
1034
1096
  this.isUpdating = !0, this.pendingOptionsChange = null, this.changeListen(!1), this.select.innerHTML = "";
1035
1097
  for (const t of e)
1036
- t instanceof g && this.select.appendChild(this.createOptgroup(t)), t instanceof p && this.select.appendChild(this.createOption(t));
1098
+ t instanceof m && this.select.appendChild(this.createOptgroup(t)), t instanceof p && this.select.appendChild(this.createOption(t));
1037
1099
  if (this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0), this.isUpdating = !1, this.pendingOptionsChange !== null) {
1038
1100
  const t = this.pendingOptionsChange;
1039
1101
  t.length > 0 && this.onOptionsChange ? (this.pendingOptionsChange = null, this.changeListen(!1), this.onOptionsChange(t), this.changeListen(!0)) : this.pendingOptionsChange = null;
@@ -1058,7 +1120,7 @@ class I {
1058
1120
  // Find and handle labels associated with this select
1059
1121
  setupLabelHandlers() {
1060
1122
  const e = [], t = this.select.id;
1061
- t && document.querySelectorAll(`label[for="${t}"]`).forEach((a) => e.push(a));
1123
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((n) => e.push(n));
1062
1124
  let s = this.select.parentElement;
1063
1125
  for (; s && s !== document.body; ) {
1064
1126
  if (s.tagName === "LABEL") {
@@ -1070,16 +1132,17 @@ class I {
1070
1132
  Array.from(new Set(e)).forEach((l) => {
1071
1133
  if (l.__slimSelectLabelHandler)
1072
1134
  return;
1073
- const a = (n) => {
1074
- n.target === l && (n.preventDefault(), this.onLabelClick && this.onLabelClick());
1135
+ const n = (a) => {
1136
+ const o = a.target, h = E(o, this.select.dataset.id);
1137
+ a.preventDefault(), !h && this.onLabelClick && this.onLabelClick();
1075
1138
  };
1076
- l.__slimSelectLabelHandler = a, l.addEventListener("click", a, { capture: !0, passive: !1 });
1139
+ l.__slimSelectLabelHandler = n, l.addEventListener("click", n, { capture: !0, passive: !1 });
1077
1140
  });
1078
1141
  }
1079
1142
  // Remove label handlers
1080
1143
  removeLabelHandlers() {
1081
1144
  const e = [], t = this.select.id;
1082
- t && document.querySelectorAll(`label[for="${t}"]`).forEach((a) => e.push(a));
1145
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((n) => e.push(n));
1083
1146
  let s = this.select.parentElement;
1084
1147
  for (; s && s !== document.body; ) {
1085
1148
  if (s.tagName === "LABEL") {
@@ -1089,15 +1152,15 @@ class I {
1089
1152
  s = s.parentElement;
1090
1153
  }
1091
1154
  Array.from(new Set(e)).forEach((l) => {
1092
- const a = l.__slimSelectLabelHandler;
1093
- a && (l.removeEventListener("click", a, { capture: !0 }), delete l.__slimSelectLabelHandler);
1155
+ const n = l.__slimSelectLabelHandler;
1156
+ n && (l.removeEventListener("click", n, { capture: !0 }), delete l.__slimSelectLabelHandler);
1094
1157
  });
1095
1158
  }
1096
1159
  destroy() {
1097
1160
  this.changeListen(!1), this.select.removeEventListener("change", this.valueChange), this.preventNativeSelect && (this.select.removeEventListener("click", this.preventNativeSelect, { capture: !0 }), this.preventNativeSelect = null), this.preventNativeSelectMousedown && (this.select.removeEventListener("mousedown", this.preventNativeSelectMousedown, { capture: !0 }), this.preventNativeSelectMousedown = null), this.preventNativeSelectFocus && (this.select.removeEventListener("focus", this.preventNativeSelectFocus, { capture: !0 }), this.preventNativeSelectFocus = null), this.observer && (this.observer.disconnect(), this.observer = null), this.removeLabelHandlers(), delete this.select.dataset.id, this.showUI();
1098
1161
  }
1099
1162
  }
1100
- class H {
1163
+ class I {
1101
1164
  id = "";
1102
1165
  // Primary ID for the select
1103
1166
  style = "";
@@ -1114,6 +1177,7 @@ class H {
1114
1177
  alwaysOpen;
1115
1178
  showSearch;
1116
1179
  focusSearch;
1180
+ keepSearch;
1117
1181
  ariaLabel;
1118
1182
  searchPlaceholder;
1119
1183
  searchText;
@@ -1135,10 +1199,10 @@ class H {
1135
1199
  maxValuesMessage;
1136
1200
  addableText;
1137
1201
  constructor(e) {
1138
- e || (e = {}), this.id = "ss-" + C(), 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}';
1202
+ 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.keepSearch = e.keepSearch !== void 0 ? e.keepSearch : !1, 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}';
1139
1203
  }
1140
1204
  }
1141
- let F = class {
1205
+ let H = class {
1142
1206
  selectEl;
1143
1207
  // Classes
1144
1208
  settings;
@@ -1170,18 +1234,18 @@ let F = class {
1170
1234
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1171
1235
  return;
1172
1236
  }
1173
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new H(e.settings), this.cssClasses = new N(e.cssClasses);
1237
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new I(e.settings), this.cssClasses = new M(e.cssClasses);
1174
1238
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1175
- for (const n in e.events)
1176
- e.events.hasOwnProperty(n) && (t.indexOf(n) !== -1 ? this.events[n] = O(e.events[n], 100) : this.events[n] = e.events[n]);
1177
- 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.selectEl.id || (this.selectEl.id = this.settings.id), this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class), this.select.hideUI(), this.select.onValueChange = (n) => {
1178
- this.setSelected(n.map((o) => o.id));
1179
- }, this.select.onClassChange = (n) => {
1180
- this.settings.class = n, this.render.updateClassStyles();
1181
- }, this.select.onDisabledChange = (n) => {
1182
- n ? this.disable() : this.enable();
1183
- }, this.select.onOptionsChange = (n) => {
1184
- this.setData(n || []);
1239
+ for (const a in e.events)
1240
+ e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = w(e.events[a], 100) : this.events[a] = e.events[a]);
1241
+ 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 B(this.selectEl), this.selectEl.id || (this.selectEl.id = this.settings.id), this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class), this.select.hideUI(), this.select.onValueChange = (a) => {
1242
+ this.setSelected(a.map((o) => o.id));
1243
+ }, this.select.onClassChange = (a) => {
1244
+ this.settings.class = a, this.render.updateClassStyles();
1245
+ }, this.select.onDisabledChange = (a) => {
1246
+ a ? this.disable() : this.enable();
1247
+ }, this.select.onOptionsChange = (a) => {
1248
+ this.setData(a || []);
1185
1249
  }, this.select.onLabelClick = () => {
1186
1250
  this.settings.disabled || (this.settings.isOpen ? this.close() : this.open());
1187
1251
  };
@@ -1197,9 +1261,9 @@ let F = class {
1197
1261
  beforeChange: this.events.beforeChange,
1198
1262
  afterChange: this.events.afterChange
1199
1263
  };
1200
- this.render = new B(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1201
- const l = this.selectEl.getAttribute("aria-label"), a = this.selectEl.getAttribute("aria-labelledby");
1202
- 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.select.setupLabelHandlers(), this.selectEl.slim = this;
1264
+ this.render = new F(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1265
+ const l = this.selectEl.getAttribute("aria-label"), n = this.selectEl.getAttribute("aria-labelledby");
1266
+ l ? this.render.main.main.setAttribute("aria-label", l) : n && this.render.main.main.setAttribute("aria-labelledby", n), 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.select.setupLabelHandlers(), this.selectEl.slim = this;
1203
1267
  }
1204
1268
  // Set to enabled and remove disabled classes
1205
1269
  enable() {
@@ -1220,7 +1284,7 @@ let F = class {
1220
1284
  }
1221
1285
  this.store.setData(e);
1222
1286
  const i = this.store.getData();
1223
- this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !y(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1287
+ this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !O(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1224
1288
  }
1225
1289
  getSelected() {
1226
1290
  let e = this.store.getSelectedOptions();
@@ -1231,31 +1295,31 @@ let F = class {
1231
1295
  const s = this.store.getSelected(), i = this.store.getDataOptions();
1232
1296
  e = Array.isArray(e) ? e : [e];
1233
1297
  const l = [];
1234
- for (const n of e) {
1235
- if (i.find((o) => o.id == n)) {
1236
- l.push(n);
1298
+ for (const a of e) {
1299
+ if (i.find((o) => o.id == a)) {
1300
+ l.push(a);
1237
1301
  continue;
1238
1302
  }
1239
- for (const o of i.filter((c) => c.value == n))
1303
+ for (const o of i.filter((h) => h.value == a))
1240
1304
  l.push(o.id);
1241
1305
  }
1242
1306
  this.store.setSelectedBy("id", l);
1243
- const a = this.store.getData();
1244
- 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 && !y(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1307
+ const n = this.store.getData();
1308
+ this.select.updateOptions(n), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(n), t && this.events.afterChange && !O(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1245
1309
  }
1246
1310
  addOption(e) {
1247
1311
  const t = this.store.getSelected();
1248
1312
  this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1249
1313
  const s = this.store.getData();
1250
- this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !y(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1314
+ this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !O(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1251
1315
  }
1252
1316
  open() {
1253
- 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(() => {
1317
+ this.settings.disabled || this.settings.isOpen || (this.closeTimeout && (clearTimeout(this.closeTimeout), this.closeTimeout = null), 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(() => {
1254
1318
  this.events.afterOpen && this.events.afterOpen(), this.settings.isOpen && (this.settings.isFullOpen = !0), document.addEventListener("click", this.documentClick);
1255
1319
  }, 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)));
1256
1320
  }
1257
1321
  close(e = null) {
1258
- !this.settings.isOpen || this.settings.alwaysOpen || (this.events.beforeClose && this.events.beforeClose(), this.render.close(), this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
1322
+ !this.settings.isOpen || this.settings.alwaysOpen || (this.openTimeout && (clearTimeout(this.openTimeout), this.openTimeout = null), this.events.beforeClose && this.events.beforeClose(), this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
1259
1323
  this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
1260
1324
  }, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
1261
1325
  }
@@ -1284,23 +1348,23 @@ let F = class {
1284
1348
  destroy() {
1285
1349
  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();
1286
1350
  }
1287
- windowResize = O(() => {
1351
+ windowResize = w(() => {
1288
1352
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1289
1353
  });
1290
1354
  // Event listener for window scrolling
1291
- windowScroll = O(() => {
1355
+ windowScroll = w(() => {
1292
1356
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1293
1357
  });
1294
1358
  // Event listener for document click
1295
1359
  documentClick = (e) => {
1296
- this.settings.isOpen && e.target && !M(e.target, this.settings.id) && this.close(e.type);
1360
+ this.settings.isOpen && e.target && !E(e.target, this.settings.id) && this.close(e.type);
1297
1361
  };
1298
1362
  // Event Listener for window visibility change
1299
1363
  windowVisibilityChange = () => {
1300
1364
  document.hidden && this.close();
1301
1365
  };
1302
1366
  };
1303
- const R = E({
1367
+ const R = L({
1304
1368
  name: "SlimSelect",
1305
1369
  props: {
1306
1370
  modelValue: {
@@ -1341,12 +1405,12 @@ const R = E({
1341
1405
  afterChange: (s) => {
1342
1406
  this.handleAfterChange(s, t);
1343
1407
  }
1344
- }, this.slim = new F(e), this.syncModelValueToSlimSelect(!1);
1408
+ }, this.slim = new H(e), this.syncModelValueToSlimSelect(!1);
1345
1409
  },
1346
1410
  updated() {
1347
1411
  if (this.slim && !this.data) {
1348
- const h = this.slim.getSelected(), e = Array.isArray(this.value) ? this.value : [this.value];
1349
- JSON.stringify(h.sort()) !== JSON.stringify(e.sort()) && this.syncModelValueToSlimSelect(!1);
1412
+ const c = this.slim.getSelected(), e = Array.isArray(this.value) ? this.value : [this.value];
1413
+ JSON.stringify(c.sort()) !== JSON.stringify(e.sort()) && this.syncModelValueToSlimSelect(!1);
1350
1414
  }
1351
1415
  },
1352
1416
  beforeUnmount() {
@@ -1354,13 +1418,13 @@ const R = E({
1354
1418
  },
1355
1419
  watch: {
1356
1420
  modelValue: {
1357
- handler: function(h) {
1421
+ handler: function(c) {
1358
1422
  this.slim && this.syncModelValueToSlimSelect(!1);
1359
1423
  }
1360
1424
  },
1361
1425
  data: {
1362
- handler: function(h) {
1363
- this.slim && this.slim.setData(h);
1426
+ handler: function(c) {
1427
+ this.slim && this.slim.setData(c);
1364
1428
  },
1365
1429
  deep: !0
1366
1430
  }
@@ -1370,8 +1434,8 @@ const R = E({
1370
1434
  get() {
1371
1435
  return this.getCleanValue(this.$props.modelValue);
1372
1436
  },
1373
- set(h) {
1374
- this.$emit("update:modelValue", h);
1437
+ set(c) {
1438
+ this.$emit("update:modelValue", c);
1375
1439
  }
1376
1440
  }
1377
1441
  },
@@ -1380,48 +1444,48 @@ const R = E({
1380
1444
  getSlimSelect() {
1381
1445
  return this.slim;
1382
1446
  },
1383
- handleAfterChange(h, e) {
1447
+ handleAfterChange(c, e) {
1384
1448
  if (!this.slim) return;
1385
- const t = this.multiple ? h.map((o) => o.value) : h.length > 0 ? h[0].value : "", s = this.getCleanValue(this.$props.modelValue), i = this.slim.store.getDataOptions(), l = Array.isArray(s) ? s.length > 0 && s.every((o) => i.some((c) => c.value === o)) : s !== "" && i.some((o) => o.value === s), a = Array.isArray(t) ? t.length > 0 && t.every((o) => i.some((c) => c.value === o)) : t !== "" && i.some((o) => o.value === t);
1386
- (Array.isArray(t) && Array.isArray(this.value) ? JSON.stringify(t.sort()) !== JSON.stringify(this.value.sort()) : this.value !== t) && (l || a) && (this.value = t), e && e(h);
1449
+ const t = this.multiple ? c.map((o) => o.value) : c.length > 0 ? c[0].value : "", s = this.getCleanValue(this.$props.modelValue), i = this.slim.store.getDataOptions(), l = Array.isArray(s) ? s.length > 0 && s.every((o) => i.some((h) => h.value === o)) : s !== "" && i.some((o) => o.value === s), n = Array.isArray(t) ? t.length > 0 && t.every((o) => i.some((h) => h.value === o)) : t !== "" && i.some((o) => o.value === t);
1450
+ (Array.isArray(t) && Array.isArray(this.value) ? JSON.stringify(t.sort()) !== JSON.stringify(this.value.sort()) : this.value !== t) && (l || n) && (this.value = t), e && e(c);
1387
1451
  },
1388
- getCleanValue(h) {
1452
+ getCleanValue(c) {
1389
1453
  const e = this.$props.multiple;
1390
- return typeof h == "string" ? e ? [h] : h : Array.isArray(h) ? e ? h : h[0] : e ? [] : "";
1454
+ return typeof c == "string" ? e ? [c] : c : Array.isArray(c) ? e ? c : c[0] : e ? [] : "";
1391
1455
  },
1392
- syncModelValueToSlimSelect(h = !1) {
1456
+ syncModelValueToSlimSelect(c = !1) {
1393
1457
  if (!this.slim || this.$props.modelValue === void 0)
1394
1458
  return;
1395
1459
  const e = this.getCleanValue(this.$props.modelValue), s = this.slim.getData().flatMap((l) => "label" in l ? l.options : [l]);
1396
- if (!(Array.isArray(e) ? e.length > 0 && e.every((l) => s.some((a) => a.value === l)) : e !== "" && s.some((l) => l.value === e)) && !Array.isArray(e) && !s.some((a) => a.placeholder)) {
1397
- const a = this.slim.getData(), n = {
1460
+ if (!(Array.isArray(e) ? e.length > 0 && e.every((l) => s.some((n) => n.value === l)) : e !== "" && s.some((l) => l.value === e)) && !Array.isArray(e) && !s.some((n) => n.placeholder)) {
1461
+ const n = this.slim.getData(), a = {
1398
1462
  value: "",
1399
1463
  text: "",
1400
1464
  placeholder: !0
1401
1465
  };
1402
- this.slim.setData([n].concat(a));
1466
+ this.slim.setData([a].concat(n));
1403
1467
  }
1404
- this.slim.setSelected(e, h);
1468
+ this.slim.setSelected(e, c);
1405
1469
  }
1406
1470
  }
1407
- }), _ = (h, e) => {
1408
- const t = h.__vccOpts || h;
1471
+ }), $ = (c, e) => {
1472
+ const t = c.__vccOpts || c;
1409
1473
  for (const [s, i] of e)
1410
1474
  t[s] = i;
1411
1475
  return t;
1412
- }, $ = ["multiple"];
1413
- function q(h, e, t, s, i, l) {
1414
- return D(), T("select", {
1415
- multiple: h.multiple,
1476
+ }, _ = ["multiple"];
1477
+ function q(c, e, t, s, i, l) {
1478
+ return k(), D("select", {
1479
+ multiple: c.multiple,
1416
1480
  ref: "slim"
1417
1481
  }, [
1418
- k(h.$slots, "default")
1419
- ], 8, $);
1482
+ N(c.$slots, "default")
1483
+ ], 8, _);
1420
1484
  }
1421
- const z = /* @__PURE__ */ _(R, [["render", q]]);
1485
+ const z = /* @__PURE__ */ $(R, [["render", q]]);
1422
1486
  export {
1423
- g as Optgroup,
1487
+ m as Optgroup,
1424
1488
  p as Option,
1425
- H as Settings,
1489
+ I as Settings,
1426
1490
  z as default
1427
1491
  };