slim-select 3.2.0 → 3.4.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, openBlock as D, createElementBlock 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
86
  const l = self, n = () => {
82
- s = null, t || h.apply(l, i);
87
+ s = null, t || c.apply(l, i);
83
88
  }, a = t && !s;
84
- clearTimeout(s), s = setTimeout(n, e), a && h.apply(l, i);
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,7 +111,7 @@ 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
117
  class m {
@@ -117,7 +122,7 @@ class m {
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
  }
@@ -183,8 +188,8 @@ class V {
183
188
  break;
184
189
  }
185
190
  if (o instanceof m) {
186
- for (const c of o.options)
187
- if (c.id === n.id) {
191
+ for (const h of o.options)
192
+ if (h.id === n.id) {
188
193
  a = !0;
189
194
  break;
190
195
  }
@@ -222,8 +227,8 @@ class V {
222
227
  if (a instanceof m)
223
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
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
  }
@@ -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,10 +355,10 @@ 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");
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");
335
359
  const e = this.getAnimationTiming();
336
- setTimeout(() => {
337
- this.main.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow);
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;
338
362
  }, e);
339
363
  }
340
364
  getAnimationTiming() {
@@ -348,7 +372,7 @@ class B {
348
372
  return 200;
349
373
  }
350
374
  updateClassStyles() {
351
- 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)
352
376
  for (const e of this.settings.class)
353
377
  e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
354
378
  (this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
@@ -359,33 +383,35 @@ class B {
359
383
  }
360
384
  mainDiv() {
361
385
  const e = document.createElement("div");
362
- e.dataset.id = this.settings.id, e.setAttribute("aria-label", this.settings.ariaLabel), e.tabIndex = 0, e.onkeydown = (c) => {
363
- 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) {
364
388
  case "ArrowUp":
365
389
  case "ArrowDown":
366
- 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;
367
391
  case "Tab":
368
392
  return this.callbacks.close(), !0;
369
393
  // Continue doing normal tabbing
370
394
  case "Enter":
371
395
  case " ":
372
396
  this.callbacks.open();
373
- const r = this.content.list.querySelector("." + this.classes.highlighted);
397
+ const r = this.content.list.querySelector(
398
+ "." + this.classes.getFirst("highlighted")
399
+ );
374
400
  return r && r.click(), !1;
375
401
  case "Escape":
376
402
  return this.callbacks.close(), !1;
377
403
  }
378
- return c.key.length === 1 && this.callbacks.open(), !0;
379
- }, e.onclick = (c) => {
404
+ return h.key.length === 1 && this.callbacks.open(), !0;
405
+ }, e.onclick = (h) => {
380
406
  this.settings.disabled || (this.settings.isOpen ? this.callbacks.close() : this.callbacks.open());
381
407
  };
382
408
  const t = document.createElement("div");
383
- t.classList.add(this.classes.values), e.appendChild(t);
409
+ this.addClasses(t, this.classes.values), e.appendChild(t);
384
410
  const s = document.createElement("div");
385
- s.classList.add(this.classes.deselect);
411
+ this.addClasses(s, this.classes.deselect);
386
412
  const i = this.store?.getSelectedOptions();
387
- !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) => {
388
- 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)
389
415
  return;
390
416
  let r = !0;
391
417
  const d = this.store.getSelectedOptions(), f = [];
@@ -404,9 +430,9 @@ class B {
404
430
  const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
405
431
  n.setAttribute("d", this.classes.deselectPath), l.appendChild(n), s.appendChild(l), e.appendChild(s);
406
432
  const a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
407
- a.classList.add(this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
433
+ this.addClasses(a, this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
408
434
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
409
- return o.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && a.classList.add(this.classes.hide), a.appendChild(o), e.appendChild(a), {
435
+ return o.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && this.addClasses(a, this.classes.hide), a.appendChild(o), e.appendChild(a), {
410
436
  main: e,
411
437
  values: t,
412
438
  deselect: {
@@ -428,7 +454,7 @@ class B {
428
454
  let t = this.settings.placeholderText;
429
455
  e.length && (e[0].html !== "" ? t = e[0].html : e[0].text !== "" && (t = e[0].text));
430
456
  const s = document.createElement("div");
431
- return s.classList.add(this.classes.placeholder), s.innerHTML = t, s;
457
+ return this.addClasses(s, this.classes.placeholder), s.innerHTML = t, s;
432
458
  }
433
459
  // Get selected values and append to multiSelected values container
434
460
  // and remove those who shouldnt exist
@@ -445,9 +471,9 @@ class B {
445
471
  this.main.values.innerHTML = this.placeholder().outerHTML;
446
472
  else {
447
473
  const s = document.createElement("div");
448
- 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;
449
475
  }
450
- !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);
451
477
  }
452
478
  renderMultipleValues() {
453
479
  let e = this.main.values.childNodes, t = this.store.filter((i) => i.selected && i.display, !1);
@@ -455,15 +481,15 @@ class B {
455
481
  this.main.values.innerHTML = this.placeholder().outerHTML;
456
482
  return;
457
483
  } else {
458
- const i = this.main.values.querySelector("." + this.classes.placeholder);
484
+ const i = this.main.values.querySelector("." + this.classes.getFirst("placeholder"));
459
485
  i && i.remove();
460
486
  }
461
487
  if (t.length > this.settings.maxValuesShown) {
462
488
  const i = document.createElement("div");
463
- 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;
464
490
  return;
465
491
  } else {
466
- const i = this.main.values.querySelector("." + this.classes.max);
492
+ const i = this.main.values.querySelector("." + this.classes.getFirst("max"));
467
493
  i && i.remove();
468
494
  }
469
495
  this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
@@ -473,7 +499,7 @@ class B {
473
499
  n && (t.filter((o) => o.id === n, !1).length || s.push(l));
474
500
  }
475
501
  for (const i of s)
476
- i.classList.add(this.classes.valueOut), setTimeout(() => {
502
+ this.addClasses(i, this.classes.valueOut), setTimeout(() => {
477
503
  this.main.values.hasChildNodes() && this.main.values.contains(i) && this.main.values.removeChild(i);
478
504
  }, 100);
479
505
  e = this.main.values.childNodes;
@@ -486,16 +512,16 @@ class B {
486
512
  }
487
513
  multipleValue(e) {
488
514
  const t = document.createElement("div");
489
- t.classList.add(this.classes.value), t.dataset.id = e.id;
515
+ this.addClasses(t, this.classes.value), t.dataset.id = e.id;
490
516
  const s = document.createElement("div");
491
- 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) {
492
518
  const i = document.createElement("div");
493
- i.classList.add(this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (a) => {
519
+ this.addClasses(i, this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (a) => {
494
520
  if (a.preventDefault(), a.stopPropagation(), this.settings.disabled)
495
521
  return;
496
522
  let o = !0;
497
- const c = this.store.getSelectedOptions(), r = c.filter((d) => d.selected && d.id !== e.id, !0);
498
- 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)) {
499
525
  let d = [];
500
526
  for (const f of r) {
501
527
  if (f instanceof m)
@@ -543,12 +569,12 @@ class B {
543
569
  }
544
570
  searchDiv() {
545
571
  const e = document.createElement("div"), t = document.createElement("input"), s = document.createElement("div");
546
- e.classList.add(this.classes.search);
572
+ this.addClasses(e, this.classes.search);
547
573
  const i = {
548
574
  main: e,
549
575
  input: t
550
576
  };
551
- 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) => {
552
578
  this.callbacks.search(l.target.value);
553
579
  }, 100), t.onkeydown = (l) => {
554
580
  switch (l.key) {
@@ -561,15 +587,19 @@ class B {
561
587
  case "Escape":
562
588
  return this.callbacks.close(), !1;
563
589
  case " ":
564
- const n = this.content.list.querySelector("." + this.classes.highlighted);
590
+ const n = this.content.list.querySelector(
591
+ "." + this.classes.getFirst("highlighted")
592
+ );
565
593
  return n ? (n.click(), !1) : !0;
566
594
  case "Enter":
567
- const a = this.content.list.querySelector("." + this.classes.highlighted);
595
+ const a = this.content.list.querySelector(
596
+ "." + this.classes.getFirst("highlighted")
597
+ );
568
598
  return a ? (a.click(), !1) : this.callbacks.addable ? (s.click(), !1) : !0;
569
599
  }
570
600
  return !0;
571
601
  }, e.appendChild(t), this.callbacks.addable) {
572
- s.classList.add(this.classes.addable);
602
+ this.addClasses(s, this.classes.addable);
573
603
  const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
574
604
  l.setAttribute("viewBox", "0 0 100 100");
575
605
  const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
@@ -581,7 +611,7 @@ class B {
581
611
  this.content.search.input.focus();
582
612
  return;
583
613
  }
584
- const c = (d) => {
614
+ const h = (d) => {
585
615
  let f = new p(d);
586
616
  if (this.callbacks.addOption(f), this.settings.isMultiple) {
587
617
  let u = this.store.getSelected();
@@ -593,14 +623,14 @@ class B {
593
623
  }, 100);
594
624
  }, r = this.callbacks.addable(o);
595
625
  r === !1 || r === void 0 || r === null || (r instanceof Promise ? r.then((d) => {
596
- typeof d == "string" ? c({
626
+ typeof d == "string" ? h({
597
627
  text: d,
598
628
  value: d
599
- }) : r instanceof Error ? this.renderError(r.message) : c(d);
600
- }) : typeof r == "string" ? c({
629
+ }) : r instanceof Error ? this.renderError(r.message) : h(d);
630
+ }) : typeof r == "string" ? h({
601
631
  text: r,
602
632
  value: r
603
- }) : r instanceof Error ? this.renderError(r.message) : c(r));
633
+ }) : r instanceof Error ? this.renderError(r.message) : h(r));
604
634
  }, e.appendChild(s), i.addable = {
605
635
  main: s,
606
636
  svg: l,
@@ -613,71 +643,73 @@ class B {
613
643
  this.content.search.input.focus({ preventScroll: !0 });
614
644
  }
615
645
  getOptions(e = !1, t = !1, s = !1) {
616
- let i = "." + this.classes.option;
617
- 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));
618
648
  }
619
649
  // highlightUp is used to highlight the previous option in the list
620
650
  highlight(e) {
621
651
  const t = this.getOptions(!0, !0, !0);
622
652
  if (t.length === 0)
623
653
  return;
624
- if (t.length === 1 && !t[0].classList.contains(this.classes.highlighted)) {
625
- 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);
626
656
  return;
627
657
  }
628
658
  let s = !1;
629
659
  for (const l of t)
630
- l.classList.contains(this.classes.highlighted) && (s = !0);
660
+ l.classList.contains(this.classes.getFirst("highlighted")) && (s = !0);
631
661
  if (!s) {
632
662
  for (const l of t)
633
- if (l.classList.contains(this.classes.selected)) {
634
- l.classList.add(this.classes.highlighted);
663
+ if (l.classList.contains(this.classes.getFirst("selected"))) {
664
+ this.addClasses(l, this.classes.highlighted);
635
665
  break;
636
666
  }
637
667
  }
638
668
  for (let l = 0; l < t.length; l++)
639
- if (t[l].classList.contains(this.classes.highlighted)) {
669
+ if (t[l].classList.contains(this.classes.getFirst("highlighted"))) {
640
670
  const n = t[l];
641
- n.classList.remove(this.classes.highlighted);
671
+ this.removeClasses(n, this.classes.highlighted);
642
672
  const a = n.parentElement;
643
- if (a && a.classList.contains(this.classes.mainOpen)) {
644
- const r = a.querySelector("." + this.classes.optgroupLabel);
673
+ if (a && a.classList.contains(this.classes.getFirst("mainOpen"))) {
674
+ const r = a.querySelector("." + this.classes.getFirst("optgroupLabel"));
645
675
  r && r.click();
646
676
  }
647
677
  let o = t[e === "down" ? l + 1 < t.length ? l + 1 : 0 : l - 1 >= 0 ? l - 1 : t.length - 1];
648
- o.classList.add(this.classes.highlighted), this.ensureElementInView(this.content.list, o), o.id && this.main.main.setAttribute("aria-activedescendant", o.id);
649
- const c = o.parentElement;
650
- if (c && c.classList.contains(this.classes.close)) {
651
- 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
+ );
652
684
  r && r.click();
653
685
  }
654
686
  return;
655
687
  }
656
688
  const i = t[e === "down" ? 0 : t.length - 1];
657
- 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);
658
690
  }
659
691
  // Create main container that options will reside
660
692
  listDiv() {
661
693
  const e = document.createElement("div");
662
- e.classList.add(this.classes.list);
694
+ this.addClasses(e, this.classes.list);
663
695
  const t = this.settings.id + "-list";
664
696
  return e.id = t, e.dataset.id = t, e;
665
697
  }
666
698
  renderError(e) {
667
699
  this.content.list.innerHTML = "";
668
700
  const t = document.createElement("div");
669
- 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);
670
702
  }
671
703
  renderSearching() {
672
704
  this.content.list.innerHTML = "";
673
705
  const e = document.createElement("div");
674
- 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);
675
707
  }
676
708
  // Take in data and add options to
677
709
  renderOptions(e) {
678
710
  if (this.content.list.innerHTML = "", e.length === 0) {
679
711
  const s = document.createElement("div");
680
- 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);
681
713
  return;
682
714
  }
683
715
  this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((i) => i.placeholder, !1).length || this.store.addOption(
@@ -693,22 +725,22 @@ class B {
693
725
  for (const s of e) {
694
726
  if (s instanceof m) {
695
727
  const i = document.createElement("div");
696
- i.classList.add(this.classes.optgroup);
728
+ this.addClasses(i, this.classes.optgroup);
697
729
  const l = document.createElement("div");
698
- l.classList.add(this.classes.optgroupLabel), i.appendChild(l);
730
+ this.addClasses(l, this.classes.optgroupLabel), i.appendChild(l);
699
731
  const n = document.createElement("div");
700
- n.classList.add(this.classes.optgroupLabelText), n.textContent = s.label, l.appendChild(n);
732
+ this.addClasses(n, this.classes.optgroupLabelText), n.textContent = s.label, l.appendChild(n);
701
733
  const a = document.createElement("div");
702
- if (a.classList.add(this.classes.optgroupActions), l.appendChild(a), this.settings.isMultiple && s.selectAll) {
734
+ if (this.addClasses(a, this.classes.optgroupActions), l.appendChild(a), this.settings.isMultiple && s.selectAll) {
703
735
  const o = document.createElement("div");
704
- o.classList.add(this.classes.optgroupSelectAll);
705
- let c = !0;
736
+ this.addClasses(o, this.classes.optgroupSelectAll);
737
+ let h = !0;
706
738
  for (const g of s.options)
707
739
  if (!g.selected) {
708
- c = !1;
740
+ h = !1;
709
741
  break;
710
742
  }
711
- c && o.classList.add(this.classes.selected);
743
+ h && this.addClasses(o, this.classes.selected);
712
744
  const r = document.createElement("span");
713
745
  r.textContent = s.selectAllText, o.appendChild(r);
714
746
  const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@@ -719,18 +751,18 @@ class B {
719
751
  u.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(u), o.addEventListener("click", (g) => {
720
752
  g.preventDefault(), g.stopPropagation();
721
753
  const v = this.store.getSelected();
722
- if (c) {
723
- const w = v.filter((S) => {
754
+ if (h) {
755
+ const C = v.filter((S) => {
724
756
  for (const b of s.options)
725
757
  if (S === b.id)
726
758
  return !1;
727
759
  return !0;
728
760
  });
729
- this.callbacks.setSelected(w, !0);
761
+ this.callbacks.setSelected(C, !0);
730
762
  return;
731
763
  } else {
732
- let w = s.options.map((b) => b.id).filter((b) => b !== void 0);
733
- 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);
734
766
  for (const b of s.options)
735
767
  b.id && !this.store.getOptionByID(b.id) && this.callbacks.addOption(new p(b));
736
768
  this.callbacks.setSelected(S, !0);
@@ -740,12 +772,12 @@ class B {
740
772
  }
741
773
  if (s.closable !== "off") {
742
774
  const o = document.createElement("div");
743
- o.classList.add(this.classes.optgroupClosable);
744
- const c = document.createElementNS("http://www.w3.org/2000/svg", "svg");
745
- 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);
746
778
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
747
- 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) => {
748
- 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));
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));
749
781
  }), a.appendChild(o);
750
782
  }
751
783
  i.appendChild(l);
@@ -760,35 +792,35 @@ class B {
760
792
  option(e) {
761
793
  if (e.placeholder) {
762
794
  const s = document.createElement("div");
763
- 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;
764
796
  }
765
797
  const t = document.createElement("div");
766
- 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) => {
767
799
  t.classList.add(s);
768
800
  }), e.style && (t.style.cssText = e.style), this.settings.searchHighlight && this.content.search.input.value.trim() !== "" ? t.innerHTML = this.highlightText(
769
801
  e.html !== "" ? e.html : e.text,
770
802
  this.content.search.input.value,
771
803
  this.classes.searchHighlighter
772
- ) : 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) => {
773
805
  s.preventDefault(), s.stopPropagation();
774
806
  const i = this.store.getSelected(), l = s.currentTarget, n = String(l.dataset.id), a = s.ctrlKey || s.metaKey;
775
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)
776
808
  return;
777
809
  let o = !1;
778
- const c = this.store.getSelectedOptions();
810
+ const h = this.store.getSelectedOptions();
779
811
  let r = [];
780
812
  if (this.settings.isMultiple) {
781
- const d = c.some((u) => u.id === n);
813
+ const d = h.some((u) => u.id === n);
782
814
  if (s.shiftKey && this.lastSelectedOption) {
783
- const u = this.store.getDataOptions(), g = u.findIndex((w) => w.id === this.lastSelectedOption.id), v = u.findIndex((w) => w.id === e.id);
815
+ const u = this.store.getDataOptions(), g = u.findIndex((C) => C.id === this.lastSelectedOption.id), v = u.findIndex((C) => C.id === e.id);
784
816
  if (g >= 0 && v >= 0) {
785
- const w = Math.min(g, v), S = Math.max(g, v), L = u.slice(w, S + 1).filter((A) => !c.find((x) => x.id === A.id));
786
- c.length + L.length <= this.settings.maxSelected ? r = c.concat(L) : r = c;
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;
787
819
  } else
788
- r = c;
789
- } else a ? (d ? r = c.filter((u) => u.id !== n) : r = c.concat(e), this.lastSelectedOption = e) : (d ? r = c.filter((u) => u.id !== n) : 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);
790
822
  }
791
- 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) {
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) {
792
824
  this.store.getOptionByID(n) || this.callbacks.addOption(e), this.callbacks.setSelected(
793
825
  r.map((u) => u.id),
794
826
  !1
@@ -799,7 +831,7 @@ class B {
799
831
  }), t;
800
832
  }
801
833
  destroy() {
802
- 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();
803
835
  }
804
836
  highlightText(e, t, s) {
805
837
  const i = t.trim();
@@ -809,30 +841,42 @@ class B {
809
841
  n.innerHTML = e;
810
842
  const a = (o) => {
811
843
  if (o.nodeType === Node.TEXT_NODE) {
812
- const c = o.textContent || "", r = new RegExp("(" + l + ")", "i");
813
- if (r.test(c)) {
844
+ const h = o.textContent || "", r = new RegExp("(" + l + ")", "i");
845
+ if (r.test(h)) {
814
846
  const d = document.createElement("span");
815
- c.split(r).forEach((u, g) => {
847
+ h.split(r).forEach((u, g) => {
816
848
  if (u && r.test(u)) {
817
849
  const v = document.createElement("mark");
818
850
  v.className = s, v.textContent = u, d.appendChild(v);
819
851
  } else u && d.appendChild(document.createTextNode(u));
820
852
  }), o.parentNode?.replaceChild(d, o);
821
853
  }
822
- } else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((c) => a(c));
854
+ } else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((h) => a(h));
823
855
  };
824
856
  return Array.from(n.childNodes).forEach((o) => a(o)), n.innerHTML;
825
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
+ this.settings.contentPosition === "fixed" ? (t = e.top + e.height, s = e.left) : (t = e.top + window.scrollY + e.height, s = e.left + window.scrollX), this.content.main.style.top = t + "px", this.content.main.style.left = s + "px";
872
+ const i = this.settings.contentWidth;
873
+ this.content.main.style.width = "", this.content.main.style.minWidth = "", this.content.main.style.maxWidth = "", i ? i.startsWith(">") ? this.content.main.style.minWidth = i.slice(1) : i.startsWith("<") ? this.content.main.style.maxWidth = i.slice(1) : this.content.main.style.width = i : this.content.main.style.width = e.width + "px";
874
+ }
826
875
  moveContentAbove() {
827
- const e = this.main.main.offsetHeight, t = this.content.main.offsetHeight;
828
- 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);
829
- const s = this.main.main.getBoundingClientRect();
830
- 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";
876
+ this.setContentDirection("above"), this.setContentPosition();
831
877
  }
832
878
  moveContentBelow() {
833
- 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);
834
- const e = this.main.main.getBoundingClientRect();
835
- 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");
879
+ this.setContentDirection("below"), this.setContentPosition();
836
880
  }
837
881
  ensureElementInView(e, t) {
838
882
  const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, l = t.offsetTop, n = l + t.clientHeight;
@@ -847,7 +891,7 @@ class B {
847
891
  if (!this.store || !this.settings)
848
892
  return;
849
893
  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;
850
- i && !(s && !t) ? l.classList.remove(n) : l.classList.add(n);
894
+ i && !(s && !t) ? this.removeClasses(l, n) : this.addClasses(l, n);
851
895
  }
852
896
  }
853
897
  class I {
@@ -1085,8 +1129,8 @@ class I {
1085
1129
  if (l.__slimSelectLabelHandler)
1086
1130
  return;
1087
1131
  const n = (a) => {
1088
- const o = a.target;
1089
- a.preventDefault(), o === l && this.onLabelClick && this.onLabelClick();
1132
+ const o = a.target, h = E(o, this.select.dataset.id);
1133
+ a.preventDefault(), !h && this.onLabelClick && this.onLabelClick();
1090
1134
  };
1091
1135
  l.__slimSelectLabelHandler = n, l.addEventListener("click", n, { capture: !0, passive: !1 });
1092
1136
  });
@@ -1112,7 +1156,7 @@ class I {
1112
1156
  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();
1113
1157
  }
1114
1158
  }
1115
- class H {
1159
+ class B {
1116
1160
  id = "";
1117
1161
  // Primary ID for the select
1118
1162
  style = "";
@@ -1138,6 +1182,7 @@ class H {
1138
1182
  closeOnSelect;
1139
1183
  contentLocation;
1140
1184
  contentPosition;
1185
+ contentWidth;
1141
1186
  openPosition;
1142
1187
  placeholderText;
1143
1188
  allowDeselect;
@@ -1151,10 +1196,10 @@ class H {
1151
1196
  maxValuesMessage;
1152
1197
  addableText;
1153
1198
  constructor(e) {
1154
- 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.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}';
1199
+ 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.contentWidth = e.contentWidth || "", 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}';
1155
1200
  }
1156
1201
  }
1157
- let F = class {
1202
+ let H = class {
1158
1203
  selectEl;
1159
1204
  // Classes
1160
1205
  settings;
@@ -1186,10 +1231,10 @@ let F = class {
1186
1231
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1187
1232
  return;
1188
1233
  }
1189
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new H(e.settings), this.cssClasses = new N(e.cssClasses);
1234
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new B(e.settings), this.cssClasses = new M(e.cssClasses);
1190
1235
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1191
1236
  for (const a in e.events)
1192
- e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = O(e.events[a], 100) : this.events[a] = e.events[a]);
1237
+ e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = w(e.events[a], 100) : this.events[a] = e.events[a]);
1193
1238
  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 = (a) => {
1194
1239
  this.setSelected(a.map((o) => o.id));
1195
1240
  }, this.select.onClassChange = (a) => {
@@ -1213,7 +1258,7 @@ let F = class {
1213
1258
  beforeChange: this.events.beforeChange,
1214
1259
  afterChange: this.events.afterChange
1215
1260
  };
1216
- this.render = new B(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1261
+ this.render = new F(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1217
1262
  const l = this.selectEl.getAttribute("aria-label"), n = this.selectEl.getAttribute("aria-labelledby");
1218
1263
  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;
1219
1264
  }
@@ -1236,7 +1281,7 @@ let F = class {
1236
1281
  }
1237
1282
  this.store.setData(e);
1238
1283
  const i = this.store.getData();
1239
- 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());
1284
+ 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());
1240
1285
  }
1241
1286
  getSelected() {
1242
1287
  let e = this.store.getSelectedOptions();
@@ -1252,26 +1297,26 @@ let F = class {
1252
1297
  l.push(a);
1253
1298
  continue;
1254
1299
  }
1255
- for (const o of i.filter((c) => c.value == a))
1300
+ for (const o of i.filter((h) => h.value == a))
1256
1301
  l.push(o.id);
1257
1302
  }
1258
1303
  this.store.setSelectedBy("id", l);
1259
1304
  const n = this.store.getData();
1260
- 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 && !y(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1305
+ 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());
1261
1306
  }
1262
1307
  addOption(e) {
1263
1308
  const t = this.store.getSelected();
1264
1309
  this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1265
1310
  const s = this.store.getData();
1266
- 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());
1311
+ 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());
1267
1312
  }
1268
1313
  open() {
1269
- 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(() => {
1314
+ 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(() => {
1270
1315
  this.events.afterOpen && this.events.afterOpen(), this.settings.isOpen && (this.settings.isFullOpen = !0), document.addEventListener("click", this.documentClick);
1271
1316
  }, 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)));
1272
1317
  }
1273
1318
  close(e = null) {
1274
- !this.settings.isOpen || this.settings.alwaysOpen || (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(() => {
1319
+ !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(() => {
1275
1320
  this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
1276
1321
  }, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
1277
1322
  }
@@ -1300,23 +1345,23 @@ let F = class {
1300
1345
  destroy() {
1301
1346
  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();
1302
1347
  }
1303
- windowResize = O(() => {
1348
+ windowResize = w(() => {
1304
1349
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1305
1350
  });
1306
1351
  // Event listener for window scrolling
1307
- windowScroll = O(() => {
1352
+ windowScroll = w(() => {
1308
1353
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1309
1354
  });
1310
1355
  // Event listener for document click
1311
1356
  documentClick = (e) => {
1312
- this.settings.isOpen && e.target && !M(e.target, this.settings.id) && this.close(e.type);
1357
+ this.settings.isOpen && e.target && !E(e.target, this.settings.id) && this.close(e.type);
1313
1358
  };
1314
1359
  // Event Listener for window visibility change
1315
1360
  windowVisibilityChange = () => {
1316
1361
  document.hidden && this.close();
1317
1362
  };
1318
1363
  };
1319
- const R = E({
1364
+ const $ = L({
1320
1365
  name: "SlimSelect",
1321
1366
  props: {
1322
1367
  modelValue: {
@@ -1357,12 +1402,12 @@ const R = E({
1357
1402
  afterChange: (s) => {
1358
1403
  this.handleAfterChange(s, t);
1359
1404
  }
1360
- }, this.slim = new F(e), this.syncModelValueToSlimSelect(!1);
1405
+ }, this.slim = new H(e), this.syncModelValueToSlimSelect(!1);
1361
1406
  },
1362
1407
  updated() {
1363
1408
  if (this.slim && !this.data) {
1364
- const h = this.slim.getSelected(), e = Array.isArray(this.value) ? this.value : [this.value];
1365
- JSON.stringify(h.sort()) !== JSON.stringify(e.sort()) && this.syncModelValueToSlimSelect(!1);
1409
+ const c = this.slim.getSelected(), e = Array.isArray(this.value) ? this.value : [this.value];
1410
+ JSON.stringify(c.sort()) !== JSON.stringify(e.sort()) && this.syncModelValueToSlimSelect(!1);
1366
1411
  }
1367
1412
  },
1368
1413
  beforeUnmount() {
@@ -1370,13 +1415,13 @@ const R = E({
1370
1415
  },
1371
1416
  watch: {
1372
1417
  modelValue: {
1373
- handler: function(h) {
1418
+ handler: function(c) {
1374
1419
  this.slim && this.syncModelValueToSlimSelect(!1);
1375
1420
  }
1376
1421
  },
1377
1422
  data: {
1378
- handler: function(h) {
1379
- this.slim && this.slim.setData(h);
1423
+ handler: function(c) {
1424
+ this.slim && this.slim.setData(c);
1380
1425
  },
1381
1426
  deep: !0
1382
1427
  }
@@ -1386,8 +1431,8 @@ const R = E({
1386
1431
  get() {
1387
1432
  return this.getCleanValue(this.$props.modelValue);
1388
1433
  },
1389
- set(h) {
1390
- this.$emit("update:modelValue", h);
1434
+ set(c) {
1435
+ this.$emit("update:modelValue", c);
1391
1436
  }
1392
1437
  }
1393
1438
  },
@@ -1396,16 +1441,16 @@ const R = E({
1396
1441
  getSlimSelect() {
1397
1442
  return this.slim;
1398
1443
  },
1399
- handleAfterChange(h, e) {
1444
+ handleAfterChange(c, e) {
1400
1445
  if (!this.slim) return;
1401
- 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), n = Array.isArray(t) ? t.length > 0 && t.every((o) => i.some((c) => c.value === o)) : t !== "" && i.some((o) => o.value === t);
1402
- (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(h);
1446
+ 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);
1447
+ (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);
1403
1448
  },
1404
- getCleanValue(h) {
1449
+ getCleanValue(c) {
1405
1450
  const e = this.$props.multiple;
1406
- return typeof h == "string" ? e ? [h] : h : Array.isArray(h) ? e ? h : h[0] : e ? [] : "";
1451
+ return typeof c == "string" ? e ? [c] : c : Array.isArray(c) ? e ? c : c[0] : e ? [] : "";
1407
1452
  },
1408
- syncModelValueToSlimSelect(h = !1) {
1453
+ syncModelValueToSlimSelect(c = !1) {
1409
1454
  if (!this.slim || this.$props.modelValue === void 0)
1410
1455
  return;
1411
1456
  const e = this.getCleanValue(this.$props.modelValue), s = this.slim.getData().flatMap((l) => "label" in l ? l.options : [l]);
@@ -1417,27 +1462,27 @@ const R = E({
1417
1462
  };
1418
1463
  this.slim.setData([a].concat(n));
1419
1464
  }
1420
- this.slim.setSelected(e, h);
1465
+ this.slim.setSelected(e, c);
1421
1466
  }
1422
1467
  }
1423
- }), _ = (h, e) => {
1424
- const t = h.__vccOpts || h;
1468
+ }), _ = (c, e) => {
1469
+ const t = c.__vccOpts || c;
1425
1470
  for (const [s, i] of e)
1426
1471
  t[s] = i;
1427
1472
  return t;
1428
- }, $ = ["multiple"];
1429
- function q(h, e, t, s, i, l) {
1430
- return D(), T("select", {
1431
- multiple: h.multiple,
1473
+ }, R = ["multiple"];
1474
+ function q(c, e, t, s, i, l) {
1475
+ return D(), k("select", {
1476
+ multiple: c.multiple,
1432
1477
  ref: "slim"
1433
1478
  }, [
1434
- k(h.$slots, "default")
1435
- ], 8, $);
1479
+ N(c.$slots, "default")
1480
+ ], 8, R);
1436
1481
  }
1437
- const z = /* @__PURE__ */ _(R, [["render", q]]);
1482
+ const K = /* @__PURE__ */ _($, [["render", q]]);
1438
1483
  export {
1439
1484
  m as Optgroup,
1440
1485
  p as Option,
1441
- H as Settings,
1442
- z as default
1486
+ B as Settings,
1487
+ K as default
1443
1488
  };