slim-select 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- class L {
1
+ class T {
2
2
  main;
3
3
  // Placeholder
4
4
  placeholder;
@@ -70,30 +70,30 @@ class L {
70
70
  function y() {
71
71
  return Math.random().toString(36).substring(2, 10);
72
72
  }
73
- function x(p, e) {
74
- function t(i, l) {
75
- return l && i && i.classList && i.classList.contains(l) || l && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
73
+ function E(f, e) {
74
+ function t(i, n) {
75
+ return n && i && i.classList && i.classList.contains(n) || n && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
76
76
  }
77
- function s(i, l) {
78
- return !i || i === document ? null : t(i, l) ? i : s(i.parentNode, l);
77
+ function s(i, n) {
78
+ return !i || i === document ? null : t(i, n) ? i : s(i.parentNode, n);
79
79
  }
80
- return t(p, e) || s(p, e);
80
+ return t(f, e) || s(f, e);
81
81
  }
82
- function S(p, e = 50, t = !1) {
82
+ function S(f, e = 50, t = !1) {
83
83
  let s;
84
84
  return function(...i) {
85
- const l = self, n = () => {
86
- s = null, t || p.apply(l, i);
85
+ const n = self, l = () => {
86
+ s = null, t || f.apply(n, i);
87
87
  }, a = t && !s;
88
- clearTimeout(s), s = setTimeout(n, e), a && p.apply(l, i);
88
+ clearTimeout(s), s = setTimeout(l, e), a && f.apply(n, i);
89
89
  };
90
90
  }
91
- function O(p, e) {
92
- return JSON.stringify(p) === JSON.stringify(e);
91
+ function O(f, e) {
92
+ return JSON.stringify(f) === JSON.stringify(e);
93
93
  }
94
- function D(p) {
95
- const e = p.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
96
- return p[0] === p[0].toUpperCase() ? e.substring(1) : e;
94
+ function D(f) {
95
+ const e = f.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
96
+ return f[0] === f[0].toUpperCase() ? e.substring(1) : e;
97
97
  }
98
98
  class u {
99
99
  id;
@@ -167,8 +167,8 @@ class k {
167
167
  if (s) {
168
168
  if (s instanceof m || "label" in s) {
169
169
  let i = [];
170
- "options" in s && s.options && s.options.forEach((l) => {
171
- i.push(new u(l));
170
+ "options" in s && s.options && s.options.forEach((n) => {
171
+ i.push(new u(n));
172
172
  }), i.length > 0 && t.push(new m(s));
173
173
  }
174
174
  (s instanceof u || "text" in s) && t.push(new u(s));
@@ -178,24 +178,24 @@ class k {
178
178
  setData(e, t = !1) {
179
179
  const s = this.partialToFullData(e);
180
180
  if (t) {
181
- const i = this.getSelectedOptions(), l = [];
182
- i.forEach((n) => {
181
+ const i = this.getSelectedOptions(), n = [];
182
+ i.forEach((l) => {
183
183
  let a = !1;
184
184
  for (const o of s) {
185
- if (o instanceof u && o.id === n.id) {
185
+ if (o instanceof u && o.id === l.id) {
186
186
  a = !0;
187
187
  break;
188
188
  }
189
189
  if (o instanceof m) {
190
190
  for (const h of o.options)
191
- if (h.id === n.id) {
191
+ if (h.id === l.id) {
192
192
  a = !0;
193
193
  break;
194
194
  }
195
195
  }
196
196
  }
197
- a || l.push(n);
198
- }), this.data = [...l, ...s];
197
+ a || n.push(l);
198
+ }), this.data = [...n, ...s];
199
199
  } else
200
200
  this.data = s;
201
201
  this.selectType === "single" && this.setSelectedBy("id", this.getSelected());
@@ -221,19 +221,19 @@ class k {
221
221
  // but also clean selected by determining selectType
222
222
  setSelectedBy(e, t) {
223
223
  let s = null, i = !1;
224
- const l = [];
224
+ const n = [];
225
225
  for (let a of this.data) {
226
226
  if (a instanceof m)
227
227
  for (let o of a.options) {
228
228
  s || (s = o);
229
229
  let h = o[e] || "";
230
- o.selected = i ? !1 : t.includes(h), o.selected && (l.push(o), this.selectType === "single" && (i = !0));
230
+ o.selected = i ? !1 : t.includes(h), o.selected && (n.push(o), this.selectType === "single" && (i = !0));
231
231
  }
232
- a instanceof u && (s || (s = a), a.selected = i ? !1 : t.includes(a[e]), a.selected && (l.push(a), this.selectType === "single" && (i = !0)));
232
+ a instanceof u && (s || (s = a), a.selected = i ? !1 : t.includes(a[e]), a.selected && (n.push(a), this.selectType === "single" && (i = !0)));
233
233
  }
234
- this.selectType === "single" && s && !i && (s.selected = !0, l.push(s));
235
- const n = t.map((a) => l.find((o) => o[e] === a)?.id || "");
236
- this.selectedOrder = n;
234
+ this.selectType === "single" && s && !i && (s.selected = !0, n.push(s));
235
+ const l = t.map((a) => n.find((o) => o[e] === a)?.id || "");
236
+ this.selectedOrder = l;
237
237
  }
238
238
  getSelected() {
239
239
  return this.getSelectedOptions().map((e) => e.id);
@@ -274,12 +274,12 @@ class k {
274
274
  const s = [];
275
275
  return this.data.forEach((i) => {
276
276
  if (i instanceof m) {
277
- let l = [];
277
+ let n = [];
278
278
  if (i.options.forEach((a) => {
279
- (!e || e(a)) && (t ? l.push(new u(a)) : s.push(new u(a)));
280
- }), l.length > 0) {
279
+ (!e || e(a)) && (t ? n.push(new u(a)) : s.push(new u(a)));
280
+ }), n.length > 0) {
281
281
  let a = new m(i);
282
- a.options = l, s.push(a);
282
+ a.options = n, s.push(a);
283
283
  }
284
284
  }
285
285
  i instanceof u && (!e || e(i)) && s.push(new u(i));
@@ -289,12 +289,12 @@ class k {
289
289
  selectedOrderOptions(e) {
290
290
  const t = [];
291
291
  return this.selectedOrder.forEach((s) => {
292
- const i = e.find((l) => l.id === s);
292
+ const i = e.find((n) => n.id === s);
293
293
  i && t.push(i);
294
294
  }), e.forEach((s) => {
295
295
  let i = !1;
296
- t.forEach((l) => {
297
- if (s.id === l.id) {
296
+ t.forEach((n) => {
297
+ if (s.id === n.id) {
298
298
  i = !0;
299
299
  return;
300
300
  }
@@ -349,8 +349,8 @@ class N {
349
349
  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();
350
350
  const s = this.store.getSelectedOptions();
351
351
  if (s.length) {
352
- const i = s[s.length - 1].id, l = this.content.list.querySelector('[data-id="' + i + '"]');
353
- l && this.ensureElementInView(this.content.list, l);
352
+ const i = s[s.length - 1].id, n = this.content.list.querySelector('[data-id="' + i + '"]');
353
+ n && this.ensureElementInView(this.content.list, n);
354
354
  }
355
355
  }
356
356
  close() {
@@ -413,8 +413,8 @@ class N {
413
413
  if (h.stopPropagation(), this.settings.disabled)
414
414
  return;
415
415
  let r = !0;
416
- const c = this.store.getSelectedOptions(), f = [];
417
- if (this.callbacks.beforeChange && (r = this.callbacks.beforeChange(f, c) === !0), r) {
416
+ const c = this.store.getSelectedOptions(), p = [];
417
+ if (this.callbacks.beforeChange && (r = this.callbacks.beforeChange(p, c) === !0), r) {
418
418
  if (this.settings.isMultiple)
419
419
  this.callbacks.setSelected([], !1), this.updateDeselectAll();
420
420
  else {
@@ -424,10 +424,10 @@ class N {
424
424
  this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
425
425
  }
426
426
  };
427
- const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
428
- l.setAttribute("viewBox", "0 0 100 100");
429
- const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
430
- n.setAttribute("d", this.classes.deselectPath), l.appendChild(n), s.appendChild(l), e.appendChild(s);
427
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
428
+ n.setAttribute("viewBox", "0 0 100 100");
429
+ const l = document.createElementNS("http://www.w3.org/2000/svg", "path");
430
+ l.setAttribute("d", this.classes.deselectPath), n.appendChild(l), s.appendChild(n), e.appendChild(s);
431
431
  const a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
432
432
  this.addClasses(a, this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
433
433
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
@@ -436,8 +436,8 @@ class N {
436
436
  values: t,
437
437
  deselect: {
438
438
  main: s,
439
- svg: l,
440
- path: n
439
+ svg: n,
440
+ path: l
441
441
  },
442
442
  arrow: {
443
443
  main: a,
@@ -494,8 +494,8 @@ class N {
494
494
  this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
495
495
  let s = [];
496
496
  for (let i = 0; i < e.length; i++) {
497
- const l = e[i], n = l.getAttribute("data-id");
498
- n && (t.filter((o) => o.id === n, !1).length || s.push(l));
497
+ const n = e[i], l = n.getAttribute("data-id");
498
+ l && (t.filter((o) => o.id === l, !1).length || s.push(n));
499
499
  }
500
500
  for (const i of s)
501
501
  this.addClasses(i, this.classes.valueOut), setTimeout(() => {
@@ -503,10 +503,10 @@ class N {
503
503
  }, 100);
504
504
  e = this.main.values.childNodes;
505
505
  for (let i = 0; i < t.length; i++) {
506
- let l = !0;
507
- for (let n = 0; n < e.length; n++)
508
- t[i].id === String(e[n].dataset.id) && (l = !1);
509
- 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])));
506
+ let n = !0;
507
+ for (let l = 0; l < e.length; l++)
508
+ t[i].id === String(e[l].dataset.id) && (n = !1);
509
+ n && (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])));
510
510
  }
511
511
  }
512
512
  multipleValue(e) {
@@ -522,19 +522,19 @@ class N {
522
522
  const h = this.store.getSelectedOptions(), r = h.filter((c) => c.selected && c.id !== e.id, !0);
523
523
  if (!(this.settings.minSelected && r.length < this.settings.minSelected) && (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(r, h) === !0), o)) {
524
524
  let c = [];
525
- for (const f of r) {
526
- if (f instanceof m)
527
- for (const d of f.options)
525
+ for (const p of r) {
526
+ if (p instanceof m)
527
+ for (const d of p.options)
528
528
  d.id && c.push(d.id);
529
- f instanceof u && c.push(f.id);
529
+ p instanceof u && c.push(p.id);
530
530
  }
531
531
  this.callbacks.setSelected(c, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(r), this.updateDeselectAll();
532
532
  }
533
533
  };
534
- const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
535
- l.setAttribute("viewBox", "0 0 100 100");
536
- const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
537
- n.setAttribute("d", this.classes.optionDelete), l.appendChild(n), i.appendChild(l), t.appendChild(i), i.onkeydown = (a) => {
534
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
535
+ n.setAttribute("viewBox", "0 0 100 100");
536
+ const l = document.createElementNS("http://www.w3.org/2000/svg", "path");
537
+ l.setAttribute("d", this.classes.optionDelete), n.appendChild(l), i.appendChild(n), t.appendChild(i), i.onkeydown = (a) => {
538
538
  a.key === "Enter" && i.click();
539
539
  };
540
540
  }
@@ -573,23 +573,23 @@ class N {
573
573
  main: e,
574
574
  input: t
575
575
  };
576
- 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 = S((l) => {
577
- this.callbacks.search(l.target.value);
578
- }, 100), t.onkeydown = (l) => {
579
- switch (l.key) {
576
+ 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 = S((n) => {
577
+ this.callbacks.search(n.target.value);
578
+ }, 100), t.onkeydown = (n) => {
579
+ switch (n.key) {
580
580
  case "ArrowUp":
581
581
  case "ArrowDown":
582
- return l.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
582
+ return n.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
583
583
  case "Tab":
584
584
  return this.callbacks.close(), !0;
585
585
  // Continue doing normal tabbing
586
586
  case "Escape":
587
587
  return this.callbacks.close(), !1;
588
588
  case " ":
589
- const n = this.content.list.querySelector(
589
+ const l = this.content.list.querySelector(
590
590
  "." + this.classes.getFirst("highlighted")
591
591
  );
592
- return n ? (n.click(), !1) : !0;
592
+ return l ? (l.click(), !1) : !0;
593
593
  case "Enter":
594
594
  const a = this.content.list.querySelector(
595
595
  "." + this.classes.getFirst("highlighted")
@@ -599,10 +599,10 @@ class N {
599
599
  return !0;
600
600
  }, e.appendChild(t), this.callbacks.addable) {
601
601
  this.addClasses(s, this.classes.addable);
602
- const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
603
- l.setAttribute("viewBox", "0 0 100 100");
604
- const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
605
- n.setAttribute("d", this.classes.addablePath), l.appendChild(n), s.appendChild(l), s.onclick = (a) => {
602
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
603
+ n.setAttribute("viewBox", "0 0 100 100");
604
+ const l = document.createElementNS("http://www.w3.org/2000/svg", "path");
605
+ l.setAttribute("d", this.classes.addablePath), n.appendChild(l), s.appendChild(n), s.onclick = (a) => {
606
606
  if (a.preventDefault(), a.stopPropagation(), !this.callbacks.addable)
607
607
  return;
608
608
  const o = this.content.search.input.value.trim();
@@ -611,12 +611,12 @@ class N {
611
611
  return;
612
612
  }
613
613
  const h = (c) => {
614
- let f = new u(c);
615
- if (this.callbacks.addOption(f), this.settings.isMultiple) {
614
+ let p = new u(c);
615
+ if (this.callbacks.addOption(p), this.settings.isMultiple) {
616
616
  let d = this.store.getSelected();
617
- d.push(f.id), this.callbacks.setSelected(d, !0);
617
+ d.push(p.id), this.callbacks.setSelected(d, !0);
618
618
  } else
619
- this.callbacks.setSelected([f.id], !0);
619
+ this.callbacks.setSelected([p.id], !0);
620
620
  this.callbacks.search(""), this.settings.closeOnSelect && setTimeout(() => {
621
621
  this.callbacks.close();
622
622
  }, 100);
@@ -632,8 +632,8 @@ class N {
632
632
  }) : r instanceof Error ? this.renderError(r.message) : h(r));
633
633
  }, e.appendChild(s), i.addable = {
634
634
  main: s,
635
- svg: l,
636
- path: n
635
+ svg: n,
636
+ path: l
637
637
  };
638
638
  }
639
639
  return i;
@@ -655,25 +655,25 @@ class N {
655
655
  return;
656
656
  }
657
657
  let s = !1;
658
- for (const l of t)
659
- l.classList.contains(this.classes.getFirst("highlighted")) && (s = !0);
658
+ for (const n of t)
659
+ n.classList.contains(this.classes.getFirst("highlighted")) && (s = !0);
660
660
  if (!s) {
661
- for (const l of t)
662
- if (l.classList.contains(this.classes.getFirst("selected"))) {
663
- this.addClasses(l, this.classes.highlighted);
661
+ for (const n of t)
662
+ if (n.classList.contains(this.classes.getFirst("selected"))) {
663
+ this.addClasses(n, this.classes.highlighted);
664
664
  break;
665
665
  }
666
666
  }
667
- for (let l = 0; l < t.length; l++)
668
- if (t[l].classList.contains(this.classes.getFirst("highlighted"))) {
669
- const n = t[l];
670
- this.removeClasses(n, this.classes.highlighted);
671
- const a = n.parentElement;
667
+ for (let n = 0; n < t.length; n++)
668
+ if (t[n].classList.contains(this.classes.getFirst("highlighted"))) {
669
+ const l = t[n];
670
+ this.removeClasses(l, this.classes.highlighted);
671
+ const a = l.parentElement;
672
672
  if (a && a.classList.contains(this.classes.getFirst("mainOpen"))) {
673
673
  const r = a.querySelector("." + this.classes.getFirst("optgroupLabel"));
674
674
  r && r.click();
675
675
  }
676
- let o = t[e === "down" ? l + 1 < t.length ? l + 1 : 0 : l - 1 >= 0 ? l - 1 : t.length - 1];
676
+ let o = t[e === "down" ? n + 1 < t.length ? n + 1 : 0 : n - 1 >= 0 ? n - 1 : t.length - 1];
677
677
  this.addClasses(o, this.classes.highlighted), this.ensureElementInView(this.content.list, o), o.id && this.main.main.setAttribute("aria-activedescendant", o.id);
678
678
  const h = o.parentElement;
679
679
  if (h && h.classList.contains(this.classes.getFirst("close"))) {
@@ -725,12 +725,12 @@ class N {
725
725
  if (s instanceof m) {
726
726
  const i = document.createElement("div");
727
727
  this.addClasses(i, this.classes.optgroup);
728
- const l = document.createElement("div");
729
- this.addClasses(l, this.classes.optgroupLabel), i.appendChild(l);
730
728
  const n = document.createElement("div");
731
- this.addClasses(n, this.classes.optgroupLabelText), n.textContent = s.label, l.appendChild(n);
729
+ this.addClasses(n, this.classes.optgroupLabel), i.appendChild(n);
730
+ const l = document.createElement("div");
731
+ this.addClasses(l, this.classes.optgroupLabelText), l.textContent = s.label, n.appendChild(l);
732
732
  const a = document.createElement("div");
733
- if (this.addClasses(a, this.classes.optgroupActions), l.appendChild(a), this.settings.isMultiple && s.selectAll) {
733
+ if (this.addClasses(a, this.classes.optgroupActions), n.appendChild(a), this.settings.isMultiple && s.selectAll) {
734
734
  const o = document.createElement("div");
735
735
  this.addClasses(o, this.classes.optgroupSelectAll);
736
736
  let h = !0;
@@ -744,8 +744,8 @@ class N {
744
744
  r.textContent = s.selectAllText, o.appendChild(r);
745
745
  const c = document.createElementNS("http://www.w3.org/2000/svg", "svg");
746
746
  c.setAttribute("viewBox", "0 0 100 100"), o.appendChild(c);
747
- const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
748
- f.setAttribute("d", this.classes.optgroupSelectAllBox), c.appendChild(f);
747
+ const p = document.createElementNS("http://www.w3.org/2000/svg", "path");
748
+ p.setAttribute("d", this.classes.optgroupSelectAllBox), c.appendChild(p);
749
749
  const d = document.createElementNS("http://www.w3.org/2000/svg", "path");
750
750
  d.setAttribute("d", this.classes.optgroupSelectAllCheck), c.appendChild(d), o.addEventListener("click", (g) => {
751
751
  g.preventDefault(), g.stopPropagation();
@@ -775,11 +775,11 @@ class N {
775
775
  const h = document.createElementNS("http://www.w3.org/2000/svg", "svg");
776
776
  h.setAttribute("viewBox", "0 0 100 100"), this.addClasses(h, this.classes.arrow), o.appendChild(h);
777
777
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
778
- h.appendChild(r), s.options.some((c) => c.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", (c) => {
778
+ h.appendChild(r), s.options.some((c) => c.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)), n.addEventListener("click", (c) => {
779
779
  c.preventDefault(), c.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));
780
780
  }), a.appendChild(o);
781
781
  }
782
- i.appendChild(l);
782
+ i.appendChild(n);
783
783
  for (const o of s.options)
784
784
  i.appendChild(this.option(new u(o))), t.appendChild(i);
785
785
  }
@@ -802,25 +802,25 @@ class N {
802
802
  this.classes.searchHighlighter
803
803
  ) : 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) => {
804
804
  s.preventDefault(), s.stopPropagation();
805
- const i = this.store.getSelected(), l = s.currentTarget, n = String(l.dataset.id), a = s.ctrlKey || s.metaKey;
805
+ const i = this.store.getSelected(), n = s.currentTarget, l = String(n.dataset.id), a = s.ctrlKey || s.metaKey;
806
806
  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)
807
807
  return;
808
808
  let o = !1;
809
809
  const h = this.store.getSelectedOptions();
810
810
  let r = [];
811
811
  if (this.settings.isMultiple) {
812
- const c = h.some((d) => d.id === n);
812
+ const c = h.some((d) => d.id === l);
813
813
  if (s.shiftKey && this.lastSelectedOption) {
814
814
  const d = this.store.getDataOptions(), g = d.findIndex((C) => C.id === this.lastSelectedOption.id), v = d.findIndex((C) => C.id === e.id);
815
815
  if (g >= 0 && v >= 0) {
816
- const C = Math.min(g, v), w = Math.max(g, v), E = d.slice(C, w + 1).filter((A) => !h.find((T) => T.id === A.id));
817
- h.length + E.length <= this.settings.maxSelected ? r = h.concat(E) : r = h;
816
+ const C = Math.min(g, v), w = Math.max(g, v), x = d.slice(C, w + 1).filter((A) => !h.find((L) => L.id === A.id));
817
+ h.length + x.length <= this.settings.maxSelected ? r = h.concat(x) : r = h;
818
818
  } else
819
819
  r = h;
820
- } else a ? (c ? r = h.filter((d) => d.id !== n) : r = h.concat(e), this.lastSelectedOption = e) : (c ? r = h.filter((d) => d.id !== n) : r = h.concat(e), this.lastSelectedOption = e);
820
+ } else a ? (c ? r = h.filter((d) => d.id !== l) : r = h.concat(e), this.lastSelectedOption = e) : (c ? r = h.filter((d) => d.id !== l) : r = h.concat(e), this.lastSelectedOption = e);
821
821
  }
822
822
  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) {
823
- this.store.getOptionByID(n) || this.callbacks.addOption(e), this.callbacks.setSelected(
823
+ this.store.getOptionByID(l) || this.callbacks.addOption(e), this.callbacks.setSelected(
824
824
  r.map((d) => d.id),
825
825
  !1
826
826
  );
@@ -836,11 +836,11 @@ class N {
836
836
  const i = t.trim();
837
837
  if (i === "")
838
838
  return e;
839
- const l = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), n = document.createElement("div");
840
- n.innerHTML = e;
839
+ const n = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = document.createElement("div");
840
+ l.innerHTML = e;
841
841
  const a = (o) => {
842
842
  if (o.nodeType === Node.TEXT_NODE) {
843
- const h = o.textContent || "", r = new RegExp("(" + l + ")", "i");
843
+ const h = o.textContent || "", r = new RegExp("(" + n + ")", "i");
844
844
  if (r.test(h)) {
845
845
  const c = document.createElement("span");
846
846
  h.split(r).forEach((d, g) => {
@@ -852,13 +852,13 @@ class N {
852
852
  }
853
853
  } else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((h) => a(h));
854
854
  };
855
- return Array.from(n.childNodes).forEach((o) => a(o)), n.innerHTML;
855
+ return Array.from(l.childNodes).forEach((o) => a(o)), l.innerHTML;
856
856
  }
857
857
  setContentDirection(e) {
858
858
  const t = e === "above", s = t ? this.classes.dirAbove : this.classes.dirBelow, i = t ? this.classes.dirBelow : this.classes.dirAbove;
859
859
  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) {
860
- const l = this.main.main.offsetHeight, n = this.content.main.offsetHeight;
861
- this.content.main.style.margin = "-" + (l + n - 1) + "px 0px 0px 0px";
860
+ const n = this.main.main.offsetHeight, l = this.content.main.offsetHeight;
861
+ this.content.main.style.margin = "-" + (n + l - 1) + "px 0px 0px 0px";
862
862
  } else
863
863
  this.content.main.style.margin = "-1px 0px 0px 0px";
864
864
  }
@@ -870,6 +870,21 @@ class N {
870
870
  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";
871
871
  const i = this.settings.contentWidth;
872
872
  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";
873
+ const n = 20, l = window.innerWidth - n, a = () => {
874
+ const h = this.content.main.getBoundingClientRect().right;
875
+ if (h <= l) return;
876
+ const r = h - l, c = parseFloat(this.content.main.style.left) || 0;
877
+ if (this.settings.contentPosition === "fixed") {
878
+ const p = Math.max(n, c - r);
879
+ this.content.main.style.left = p + "px";
880
+ } else {
881
+ const p = Math.max(window.scrollX + n, c - r);
882
+ this.content.main.style.left = p + "px";
883
+ }
884
+ };
885
+ requestAnimationFrame(() => {
886
+ a(), requestAnimationFrame(a);
887
+ });
873
888
  }
874
889
  moveContentAbove() {
875
890
  this.setContentDirection("above"), this.setContentPosition();
@@ -878,8 +893,8 @@ class N {
878
893
  this.setContentDirection("below"), this.setContentPosition();
879
894
  }
880
895
  ensureElementInView(e, t) {
881
- const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, l = t.offsetTop, n = l + t.clientHeight;
882
- l < s ? e.scrollTop -= s - l : n > i && (e.scrollTop += n - i);
896
+ const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, n = t.offsetTop, l = n + t.clientHeight;
897
+ n < s ? e.scrollTop -= s - n : l > i && (e.scrollTop += l - i);
883
898
  }
884
899
  putContent() {
885
900
  const e = this.main.main.offsetHeight, t = this.main.main.getBoundingClientRect(), s = this.content.main.offsetHeight;
@@ -889,8 +904,8 @@ class N {
889
904
  updateDeselectAll() {
890
905
  if (!this.store || !this.settings)
891
906
  return;
892
- 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;
893
- i && !(s && !t) ? this.removeClasses(l, n) : this.addClasses(l, n);
907
+ const e = this.store.getSelectedOptions(), t = e && e.length > 0, s = this.settings.isMultiple, i = this.settings.allowDeselect, n = this.main.deselect.main, l = this.classes.hide;
908
+ i && !(s && !t) ? this.removeClasses(n, l) : this.addClasses(n, l);
894
909
  }
895
910
  }
896
911
  class M {
@@ -952,30 +967,30 @@ class M {
952
967
  observeCall(e) {
953
968
  if (!this.listen)
954
969
  return;
955
- let t = !1, s = !1, i = !1, l = !1;
956
- for (const n of e) {
957
- if (n.target === this.select && (n.attributeName === "disabled" && (s = !0), n.attributeName === "class" && (t = !0), n.type === "childList")) {
958
- for (const a of Array.from(n.addedNodes))
970
+ let t = !1, s = !1, i = !1, n = !1;
971
+ for (const l of e) {
972
+ if (l.target === this.select && (l.attributeName === "disabled" && (s = !0), l.attributeName === "class" && (t = !0), l.type === "childList")) {
973
+ for (const a of Array.from(l.addedNodes))
959
974
  if (a.nodeName === "OPTION" && a.value === this.select.value) {
960
- l = !0;
975
+ n = !0;
961
976
  break;
962
977
  }
963
978
  i = !0;
964
979
  }
965
- (n.target.nodeName === "OPTGROUP" || n.target.nodeName === "OPTION") && (i = !0);
980
+ (l.target.nodeName === "OPTGROUP" || l.target.nodeName === "OPTION") && (i = !0);
966
981
  }
967
982
  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) {
968
983
  if (this.isUpdating) {
969
984
  if (this.select.options.length > 0) {
970
- const n = this.getData();
971
- n.length > 0 && (this.pendingOptionsChange = n);
985
+ const l = this.getData();
986
+ l.length > 0 && (this.pendingOptionsChange = l);
972
987
  }
973
- l && this.select.dispatchEvent(new Event("change"));
988
+ n && this.select.dispatchEvent(new Event("change"));
974
989
  return;
975
990
  }
976
991
  this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
977
992
  }
978
- l && this.select.dispatchEvent(new Event("change"));
993
+ n && this.select.dispatchEvent(new Event("change"));
979
994
  }
980
995
  // From the select element pull optgroup and options into data
981
996
  getData() {
@@ -1023,10 +1038,10 @@ class M {
1023
1038
  for (const s of t) {
1024
1039
  if (s.nodeName === "OPTGROUP") {
1025
1040
  const i = s.childNodes;
1026
- for (const l of i)
1027
- if (l.nodeName === "OPTION") {
1028
- const n = l;
1029
- n.selected && e.push(this.getDataFromOption(n));
1041
+ for (const n of i)
1042
+ if (n.nodeName === "OPTION") {
1043
+ const l = n;
1044
+ l.selected && e.push(this.getDataFromOption(l));
1030
1045
  }
1031
1046
  }
1032
1047
  if (s.nodeName === "OPTION") {
@@ -1044,10 +1059,10 @@ class M {
1044
1059
  const t = this.select.childNodes;
1045
1060
  for (const s of t) {
1046
1061
  if (s.nodeName === "OPTGROUP") {
1047
- const l = s.childNodes;
1048
- for (const n of l)
1049
- if (n.nodeName === "OPTION") {
1050
- const a = n;
1062
+ const n = s.childNodes;
1063
+ for (const l of n)
1064
+ if (l.nodeName === "OPTION") {
1065
+ const a = l;
1051
1066
  a.selected = e.includes(a.id);
1052
1067
  }
1053
1068
  }
@@ -1067,10 +1082,10 @@ class M {
1067
1082
  const t = this.select.childNodes;
1068
1083
  for (const s of t) {
1069
1084
  if (s.nodeName === "OPTGROUP") {
1070
- const l = s.childNodes;
1071
- for (const n of l)
1072
- if (n.nodeName === "OPTION") {
1073
- const a = n;
1085
+ const n = s.childNodes;
1086
+ for (const l of n)
1087
+ if (l.nodeName === "OPTION") {
1088
+ const a = l;
1074
1089
  a.selected = e.includes(a.value);
1075
1090
  }
1076
1091
  }
@@ -1115,7 +1130,7 @@ class M {
1115
1130
  // Find and handle labels associated with this select
1116
1131
  setupLabelHandlers() {
1117
1132
  const e = [], t = this.select.id;
1118
- t && document.querySelectorAll(`label[for="${t}"]`).forEach((n) => e.push(n));
1133
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((l) => e.push(l));
1119
1134
  let s = this.select.parentElement;
1120
1135
  for (; s && s !== document.body; ) {
1121
1136
  if (s.tagName === "LABEL") {
@@ -1124,20 +1139,20 @@ class M {
1124
1139
  }
1125
1140
  s = s.parentElement;
1126
1141
  }
1127
- Array.from(new Set(e)).forEach((l) => {
1128
- if (l.__slimSelectLabelHandler)
1142
+ Array.from(new Set(e)).forEach((n) => {
1143
+ if (n.__slimSelectLabelHandler)
1129
1144
  return;
1130
- const n = (a) => {
1131
- const o = a.target, h = x(o, this.select.dataset.id);
1145
+ const l = (a) => {
1146
+ const o = a.target, h = E(o, this.select.dataset.id);
1132
1147
  a.preventDefault(), !h && this.onLabelClick && this.onLabelClick();
1133
1148
  };
1134
- l.__slimSelectLabelHandler = n, l.addEventListener("click", n, { capture: !0, passive: !1 });
1149
+ n.__slimSelectLabelHandler = l, n.addEventListener("click", l, { capture: !0, passive: !1 });
1135
1150
  });
1136
1151
  }
1137
1152
  // Remove label handlers
1138
1153
  removeLabelHandlers() {
1139
1154
  const e = [], t = this.select.id;
1140
- t && document.querySelectorAll(`label[for="${t}"]`).forEach((n) => e.push(n));
1155
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((l) => e.push(l));
1141
1156
  let s = this.select.parentElement;
1142
1157
  for (; s && s !== document.body; ) {
1143
1158
  if (s.tagName === "LABEL") {
@@ -1146,9 +1161,9 @@ class M {
1146
1161
  }
1147
1162
  s = s.parentElement;
1148
1163
  }
1149
- Array.from(new Set(e)).forEach((l) => {
1150
- const n = l.__slimSelectLabelHandler;
1151
- n && (l.removeEventListener("click", n, { capture: !0 }), delete l.__slimSelectLabelHandler);
1164
+ Array.from(new Set(e)).forEach((n) => {
1165
+ const l = n.__slimSelectLabelHandler;
1166
+ l && (n.removeEventListener("click", l, { capture: !0 }), delete n.__slimSelectLabelHandler);
1152
1167
  });
1153
1168
  }
1154
1169
  destroy() {
@@ -1230,7 +1245,7 @@ class F {
1230
1245
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1231
1246
  return;
1232
1247
  }
1233
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new P(e.settings), this.cssClasses = new L(e.cssClasses);
1248
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new P(e.settings), this.cssClasses = new T(e.cssClasses);
1234
1249
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1235
1250
  for (const a in e.events)
1236
1251
  e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = S(e.events[a], 100) : this.events[a] = e.events[a]);
@@ -1258,8 +1273,8 @@ class F {
1258
1273
  afterChange: this.events.afterChange
1259
1274
  };
1260
1275
  this.render = new N(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1261
- const l = this.selectEl.getAttribute("aria-label"), n = this.selectEl.getAttribute("aria-labelledby");
1262
- 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;
1276
+ const n = this.selectEl.getAttribute("aria-label"), l = this.selectEl.getAttribute("aria-labelledby");
1277
+ n ? this.render.main.main.setAttribute("aria-label", n) : l && this.render.main.main.setAttribute("aria-labelledby", l), 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;
1263
1278
  }
1264
1279
  // Set to enabled and remove disabled classes
1265
1280
  enable() {
@@ -1290,18 +1305,18 @@ class F {
1290
1305
  setSelected(e, t = !0) {
1291
1306
  const s = this.store.getSelected(), i = this.store.getDataOptions();
1292
1307
  e = Array.isArray(e) ? e : [e];
1293
- const l = [];
1308
+ const n = [];
1294
1309
  for (const a of e) {
1295
1310
  if (i.find((o) => o.id == a)) {
1296
- l.push(a);
1311
+ n.push(a);
1297
1312
  continue;
1298
1313
  }
1299
1314
  for (const o of i.filter((h) => h.value == a))
1300
- l.push(o.id);
1315
+ n.push(o.id);
1301
1316
  }
1302
- this.store.setSelectedBy("id", l);
1303
- const n = this.store.getData();
1304
- 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());
1317
+ this.store.setSelectedBy("id", n);
1318
+ const l = this.store.getData();
1319
+ this.select.updateOptions(l), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(l), t && this.events.afterChange && !O(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1305
1320
  }
1306
1321
  addOption(e) {
1307
1322
  const t = this.store.getSelected();
@@ -1353,7 +1368,7 @@ class F {
1353
1368
  });
1354
1369
  // Event listener for document click
1355
1370
  documentClick = (e) => {
1356
- this.settings.isOpen && e.target && !x(e.target, this.settings.id) && this.close(e.type);
1371
+ this.settings.isOpen && e.target && !E(e.target, this.settings.id) && this.close(e.type);
1357
1372
  };
1358
1373
  // Event Listener for window visibility change
1359
1374
  windowVisibilityChange = () => {