slim-select 3.3.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 A(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;
@@ -113,7 +113,7 @@ class u {
113
113
  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 || {};
114
114
  }
115
115
  }
116
- class g {
116
+ class m {
117
117
  id;
118
118
  label;
119
119
  selectAll;
@@ -140,7 +140,7 @@ class k {
140
140
  return new Error("Data must be an array");
141
141
  for (let t of e)
142
142
  if (t)
143
- if (t instanceof g || "label" in t) {
143
+ if (t instanceof m || "label" in t) {
144
144
  if (!("label" in t))
145
145
  return new Error("Optgroup must have a label");
146
146
  if ("options" in t && t.options)
@@ -165,11 +165,11 @@ class k {
165
165
  let t = [];
166
166
  return e.forEach((s) => {
167
167
  if (s) {
168
- if (s instanceof g || "label" in s) {
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));
172
- }), i.length > 0 && t.push(new g(s));
170
+ "options" in s && s.options && s.options.forEach((n) => {
171
+ i.push(new u(n));
172
+ }), i.length > 0 && t.push(new m(s));
173
173
  }
174
174
  (s instanceof u || "text" in s) && t.push(new u(s));
175
175
  }
@@ -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
- if (o instanceof g) {
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
- if (a instanceof g)
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);
@@ -246,7 +246,7 @@ class k {
246
246
  }
247
247
  getOptgroupByID(e) {
248
248
  for (let t of this.data)
249
- if (t instanceof g && t.id === e)
249
+ if (t instanceof m && t.id === e)
250
250
  return t;
251
251
  return null;
252
252
  }
@@ -260,7 +260,7 @@ class k {
260
260
  getFirstOption() {
261
261
  let e = null;
262
262
  for (let t of this.data)
263
- if (t instanceof g ? e = t.options[0] : t instanceof u && (e = t), e)
263
+ if (t instanceof m ? e = t.options[0] : t instanceof u && (e = t), e)
264
264
  break;
265
265
  return e;
266
266
  }
@@ -273,13 +273,13 @@ class k {
273
273
  filter(e, t) {
274
274
  const s = [];
275
275
  return this.data.forEach((i) => {
276
- if (i instanceof g) {
277
- let l = [];
276
+ if (i instanceof m) {
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) {
281
- let a = new g(i);
282
- a.options = l, s.push(a);
279
+ (!e || e(a)) && (t ? n.push(new u(a)) : s.push(new u(a)));
280
+ }), n.length > 0) {
281
+ let a = new m(i);
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,21 +413,21 @@ 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 {
421
- const d = this.store.getFirstOption(), m = d ? d.id : "";
422
- this.callbacks.setSelected(m, !1);
421
+ const d = this.store.getFirstOption(), g = d ? d.id : "";
422
+ this.callbacks.setSelected(g, !1);
423
423
  }
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 g)
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"))) {
@@ -722,20 +722,20 @@ class N {
722
722
  ));
723
723
  const t = document.createDocumentFragment();
724
724
  for (const s of e) {
725
- if (s instanceof g) {
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;
737
- for (const m of s.options)
738
- if (!m.selected) {
737
+ for (const g of s.options)
738
+ if (!g.selected) {
739
739
  h = !1;
740
740
  break;
741
741
  }
@@ -744,11 +744,11 @@ 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
- d.setAttribute("d", this.classes.optgroupSelectAllCheck), c.appendChild(d), o.addEventListener("click", (m) => {
751
- m.preventDefault(), m.stopPropagation();
750
+ d.setAttribute("d", this.classes.optgroupSelectAllCheck), c.appendChild(d), o.addEventListener("click", (g) => {
751
+ g.preventDefault(), g.stopPropagation();
752
752
  const v = this.store.getSelected();
753
753
  if (h) {
754
754
  const C = v.filter((w) => {
@@ -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
- const d = this.store.getDataOptions(), m = d.findIndex((C) => C.id === this.lastSelectedOption.id), v = d.findIndex((C) => C.id === e.id);
815
- if (m >= 0 && v >= 0) {
816
- const C = Math.min(m, v), w = Math.max(m, v), E = d.slice(C, w + 1).filter((x) => !h.find((T) => T.id === x.id));
817
- h.length + E.length <= this.settings.maxSelected ? r = h.concat(E) : r = h;
814
+ const d = this.store.getDataOptions(), g = d.findIndex((C) => C.id === this.lastSelectedOption.id), v = d.findIndex((C) => C.id === e.id);
815
+ if (g >= 0 && v >= 0) {
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,14 +836,14 @@ 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
- h.split(r).forEach((d, m) => {
846
+ h.split(r).forEach((d, g) => {
847
847
  if (d && r.test(d)) {
848
848
  const v = document.createElement("mark");
849
849
  v.className = s, v.textContent = d, c.appendChild(v);
@@ -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
  }
@@ -867,13 +867,24 @@ class N {
867
867
  return;
868
868
  const e = this.main.main.getBoundingClientRect();
869
869
  let t, s;
870
- if (this.settings.contentPosition === "fixed")
871
- t = e.top + e.height, s = e.left;
872
- else {
873
- const i = this.content.main.offsetParent, l = i ? i.getBoundingClientRect() : { top: 0, left: 0 };
874
- t = e.top - l.top + e.height - (i?.clientTop || 0), s = e.left - l.left - (i?.clientLeft || 0);
875
- }
876
- this.content.main.style.top = t + "px", this.content.main.style.left = s + "px", this.content.main.style.width = e.width + "px";
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
+ const i = this.settings.contentWidth;
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
+ });
877
888
  }
878
889
  moveContentAbove() {
879
890
  this.setContentDirection("above"), this.setContentPosition();
@@ -882,8 +893,8 @@ class N {
882
893
  this.setContentDirection("below"), this.setContentPosition();
883
894
  }
884
895
  ensureElementInView(e, t) {
885
- const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, l = t.offsetTop, n = l + t.clientHeight;
886
- 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);
887
898
  }
888
899
  putContent() {
889
900
  const e = this.main.main.offsetHeight, t = this.main.main.getBoundingClientRect(), s = this.content.main.offsetHeight;
@@ -893,11 +904,11 @@ class N {
893
904
  updateDeselectAll() {
894
905
  if (!this.store || !this.settings)
895
906
  return;
896
- 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;
897
- 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);
898
909
  }
899
910
  }
900
- class P {
911
+ class M {
901
912
  select;
902
913
  // Mutation observer fields
903
914
  onValueChange;
@@ -956,30 +967,30 @@ class P {
956
967
  observeCall(e) {
957
968
  if (!this.listen)
958
969
  return;
959
- let t = !1, s = !1, i = !1, l = !1;
960
- for (const n of e) {
961
- if (n.target === this.select && (n.attributeName === "disabled" && (s = !0), n.attributeName === "class" && (t = !0), n.type === "childList")) {
962
- 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))
963
974
  if (a.nodeName === "OPTION" && a.value === this.select.value) {
964
- l = !0;
975
+ n = !0;
965
976
  break;
966
977
  }
967
978
  i = !0;
968
979
  }
969
- (n.target.nodeName === "OPTGROUP" || n.target.nodeName === "OPTION") && (i = !0);
980
+ (l.target.nodeName === "OPTGROUP" || l.target.nodeName === "OPTION") && (i = !0);
970
981
  }
971
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) {
972
983
  if (this.isUpdating) {
973
984
  if (this.select.options.length > 0) {
974
- const n = this.getData();
975
- n.length > 0 && (this.pendingOptionsChange = n);
985
+ const l = this.getData();
986
+ l.length > 0 && (this.pendingOptionsChange = l);
976
987
  }
977
- l && this.select.dispatchEvent(new Event("change"));
988
+ n && this.select.dispatchEvent(new Event("change"));
978
989
  return;
979
990
  }
980
991
  this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
981
992
  }
982
- l && this.select.dispatchEvent(new Event("change"));
993
+ n && this.select.dispatchEvent(new Event("change"));
983
994
  }
984
995
  // From the select element pull optgroup and options into data
985
996
  getData() {
@@ -1027,10 +1038,10 @@ class P {
1027
1038
  for (const s of t) {
1028
1039
  if (s.nodeName === "OPTGROUP") {
1029
1040
  const i = s.childNodes;
1030
- for (const l of i)
1031
- if (l.nodeName === "OPTION") {
1032
- const n = l;
1033
- 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));
1034
1045
  }
1035
1046
  }
1036
1047
  if (s.nodeName === "OPTION") {
@@ -1048,10 +1059,10 @@ class P {
1048
1059
  const t = this.select.childNodes;
1049
1060
  for (const s of t) {
1050
1061
  if (s.nodeName === "OPTGROUP") {
1051
- const l = s.childNodes;
1052
- for (const n of l)
1053
- if (n.nodeName === "OPTION") {
1054
- const a = n;
1062
+ const n = s.childNodes;
1063
+ for (const l of n)
1064
+ if (l.nodeName === "OPTION") {
1065
+ const a = l;
1055
1066
  a.selected = e.includes(a.id);
1056
1067
  }
1057
1068
  }
@@ -1071,10 +1082,10 @@ class P {
1071
1082
  const t = this.select.childNodes;
1072
1083
  for (const s of t) {
1073
1084
  if (s.nodeName === "OPTGROUP") {
1074
- const l = s.childNodes;
1075
- for (const n of l)
1076
- if (n.nodeName === "OPTION") {
1077
- const a = n;
1085
+ const n = s.childNodes;
1086
+ for (const l of n)
1087
+ if (l.nodeName === "OPTION") {
1088
+ const a = l;
1078
1089
  a.selected = e.includes(a.value);
1079
1090
  }
1080
1091
  }
@@ -1094,7 +1105,7 @@ class P {
1094
1105
  if (!(!e || e.length === 0)) {
1095
1106
  this.isUpdating = !0, this.pendingOptionsChange = null, this.changeListen(!1), this.select.innerHTML = "";
1096
1107
  for (const t of e)
1097
- t instanceof g && this.select.appendChild(this.createOptgroup(t)), t instanceof u && this.select.appendChild(this.createOption(t));
1108
+ t instanceof m && this.select.appendChild(this.createOptgroup(t)), t instanceof u && this.select.appendChild(this.createOption(t));
1098
1109
  if (this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0), this.isUpdating = !1, this.pendingOptionsChange !== null) {
1099
1110
  const t = this.pendingOptionsChange;
1100
1111
  t.length > 0 && this.onOptionsChange ? (this.pendingOptionsChange = null, this.changeListen(!1), this.onOptionsChange(t), this.changeListen(!0)) : this.pendingOptionsChange = null;
@@ -1119,7 +1130,7 @@ class P {
1119
1130
  // Find and handle labels associated with this select
1120
1131
  setupLabelHandlers() {
1121
1132
  const e = [], t = this.select.id;
1122
- t && document.querySelectorAll(`label[for="${t}"]`).forEach((n) => e.push(n));
1133
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((l) => e.push(l));
1123
1134
  let s = this.select.parentElement;
1124
1135
  for (; s && s !== document.body; ) {
1125
1136
  if (s.tagName === "LABEL") {
@@ -1128,20 +1139,20 @@ class P {
1128
1139
  }
1129
1140
  s = s.parentElement;
1130
1141
  }
1131
- Array.from(new Set(e)).forEach((l) => {
1132
- if (l.__slimSelectLabelHandler)
1142
+ Array.from(new Set(e)).forEach((n) => {
1143
+ if (n.__slimSelectLabelHandler)
1133
1144
  return;
1134
- const n = (a) => {
1135
- const o = a.target, h = A(o, this.select.dataset.id);
1145
+ const l = (a) => {
1146
+ const o = a.target, h = E(o, this.select.dataset.id);
1136
1147
  a.preventDefault(), !h && this.onLabelClick && this.onLabelClick();
1137
1148
  };
1138
- l.__slimSelectLabelHandler = n, l.addEventListener("click", n, { capture: !0, passive: !1 });
1149
+ n.__slimSelectLabelHandler = l, n.addEventListener("click", l, { capture: !0, passive: !1 });
1139
1150
  });
1140
1151
  }
1141
1152
  // Remove label handlers
1142
1153
  removeLabelHandlers() {
1143
1154
  const e = [], t = this.select.id;
1144
- t && document.querySelectorAll(`label[for="${t}"]`).forEach((n) => e.push(n));
1155
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((l) => e.push(l));
1145
1156
  let s = this.select.parentElement;
1146
1157
  for (; s && s !== document.body; ) {
1147
1158
  if (s.tagName === "LABEL") {
@@ -1150,16 +1161,16 @@ class P {
1150
1161
  }
1151
1162
  s = s.parentElement;
1152
1163
  }
1153
- Array.from(new Set(e)).forEach((l) => {
1154
- const n = l.__slimSelectLabelHandler;
1155
- 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);
1156
1167
  });
1157
1168
  }
1158
1169
  destroy() {
1159
1170
  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();
1160
1171
  }
1161
1172
  }
1162
- class M {
1173
+ class P {
1163
1174
  id = "";
1164
1175
  // Primary ID for the select
1165
1176
  style = "";
@@ -1185,6 +1196,7 @@ class M {
1185
1196
  closeOnSelect;
1186
1197
  contentLocation;
1187
1198
  contentPosition;
1199
+ contentWidth;
1188
1200
  openPosition;
1189
1201
  placeholderText;
1190
1202
  allowDeselect;
@@ -1198,7 +1210,7 @@ class M {
1198
1210
  maxValuesMessage;
1199
1211
  addableText;
1200
1212
  constructor(e) {
1201
- e || (e = {}), this.id = "ss-" + y(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.alwaysOpen = e.alwaysOpen !== void 0 ? e.alwaysOpen : !1, this.showSearch = e.showSearch !== void 0 ? e.showSearch : !0, this.focusSearch = e.focusSearch !== void 0 ? e.focusSearch : !0, this.keepSearch = e.keepSearch !== void 0 ? e.keepSearch : !1, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.searchHighlight = e.searchHighlight !== void 0 ? e.searchHighlight : !1, this.closeOnSelect = e.closeOnSelect !== void 0 ? e.closeOnSelect : !0, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || 'Press "Enter" to add {value}';
1213
+ 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}';
1202
1214
  }
1203
1215
  }
1204
1216
  class F {
@@ -1233,11 +1245,11 @@ class F {
1233
1245
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1234
1246
  return;
1235
1247
  }
1236
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new M(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);
1237
1249
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1238
1250
  for (const a in e.events)
1239
1251
  e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = S(e.events[a], 100) : this.events[a] = e.events[a]);
1240
- 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 P(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) => {
1252
+ 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 M(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) => {
1241
1253
  this.setSelected(a.map((o) => o.id));
1242
1254
  }, this.select.onClassChange = (a) => {
1243
1255
  this.settings.class = a, this.render.updateClassStyles();
@@ -1261,8 +1273,8 @@ class F {
1261
1273
  afterChange: this.events.afterChange
1262
1274
  };
1263
1275
  this.render = new N(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1264
- const l = this.selectEl.getAttribute("aria-label"), n = this.selectEl.getAttribute("aria-labelledby");
1265
- 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;
1266
1278
  }
1267
1279
  // Set to enabled and remove disabled classes
1268
1280
  enable() {
@@ -1293,18 +1305,18 @@ class F {
1293
1305
  setSelected(e, t = !0) {
1294
1306
  const s = this.store.getSelected(), i = this.store.getDataOptions();
1295
1307
  e = Array.isArray(e) ? e : [e];
1296
- const l = [];
1308
+ const n = [];
1297
1309
  for (const a of e) {
1298
1310
  if (i.find((o) => o.id == a)) {
1299
- l.push(a);
1311
+ n.push(a);
1300
1312
  continue;
1301
1313
  }
1302
1314
  for (const o of i.filter((h) => h.value == a))
1303
- l.push(o.id);
1315
+ n.push(o.id);
1304
1316
  }
1305
- this.store.setSelectedBy("id", l);
1306
- const n = this.store.getData();
1307
- 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());
1308
1320
  }
1309
1321
  addOption(e) {
1310
1322
  const t = this.store.getSelected();
@@ -1356,7 +1368,7 @@ class F {
1356
1368
  });
1357
1369
  // Event listener for document click
1358
1370
  documentClick = (e) => {
1359
- this.settings.isOpen && e.target && !A(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);
1360
1372
  };
1361
1373
  // Event Listener for window visibility change
1362
1374
  windowVisibilityChange = () => {
@@ -1364,9 +1376,9 @@ class F {
1364
1376
  };
1365
1377
  }
1366
1378
  export {
1367
- g as Optgroup,
1379
+ m as Optgroup,
1368
1380
  u as Option,
1369
- M as Settings,
1381
+ P as Settings,
1370
1382
  F as default
1371
1383
  };
1372
1384
  //# sourceMappingURL=slimselect.es.js.map