slim-select 3.0.6 → 3.1.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.
@@ -1,4 +1,4 @@
1
- class E {
1
+ class A {
2
2
  main;
3
3
  // Placeholder
4
4
  placeholder;
@@ -62,7 +62,7 @@ class E {
62
62
  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
63
  }
64
64
  }
65
- function L() {
65
+ function C() {
66
66
  return Math.random().toString(36).substring(2, 10);
67
67
  }
68
68
  function T(p, e) {
@@ -74,7 +74,7 @@ function T(p, e) {
74
74
  }
75
75
  return t(p, e) || s(p, e);
76
76
  }
77
- function C(p, e = 50, t = !1) {
77
+ function O(p, e = 50, t = !1) {
78
78
  let s;
79
79
  return function(...i) {
80
80
  const l = self, a = () => {
@@ -83,7 +83,7 @@ function C(p, e = 50, t = !1) {
83
83
  clearTimeout(s), s = setTimeout(a, e), n && p.apply(l, i);
84
84
  };
85
85
  }
86
- function S(p, e) {
86
+ function L(p, e) {
87
87
  return JSON.stringify(p) === JSON.stringify(e);
88
88
  }
89
89
  function D(p) {
@@ -105,10 +105,10 @@ class u {
105
105
  data;
106
106
  mandatory;
107
107
  constructor(e) {
108
- this.id = !e.id || e.id === "" ? L() : 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 || {};
108
+ 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 || {};
109
109
  }
110
110
  }
111
- class g {
111
+ class m {
112
112
  id;
113
113
  label;
114
114
  selectAll;
@@ -116,7 +116,7 @@ class g {
116
116
  closable;
117
117
  options;
118
118
  constructor(e) {
119
- if (this.id = !e.id || e.id === "" ? L() : 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)
119
+ 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)
120
120
  for (const t of e.options)
121
121
  this.options.push(new u(t));
122
122
  }
@@ -135,7 +135,7 @@ class k {
135
135
  return new Error("Data must be an array");
136
136
  for (let t of e)
137
137
  if (t)
138
- if (t instanceof g || "label" in t) {
138
+ if (t instanceof m || "label" in t) {
139
139
  if (!("label" in t))
140
140
  return new Error("Optgroup must have a label");
141
141
  if ("options" in t && t.options)
@@ -160,11 +160,11 @@ class k {
160
160
  let t = [];
161
161
  return e.forEach((s) => {
162
162
  if (s) {
163
- if (s instanceof g || "label" in s) {
163
+ if (s instanceof m || "label" in s) {
164
164
  let i = [];
165
165
  "options" in s && s.options && s.options.forEach((l) => {
166
166
  i.push(new u(l));
167
- }), i.length > 0 && t.push(new g(s));
167
+ }), i.length > 0 && t.push(new m(s));
168
168
  }
169
169
  (s instanceof u || "text" in s) && t.push(new u(s));
170
170
  }
@@ -181,7 +181,7 @@ class k {
181
181
  n = !0;
182
182
  break;
183
183
  }
184
- if (o instanceof g) {
184
+ if (o instanceof m) {
185
185
  for (const c of o.options)
186
186
  if (c.id === a.id) {
187
187
  n = !0;
@@ -218,7 +218,7 @@ class k {
218
218
  let s = null, i = !1;
219
219
  const l = [];
220
220
  for (let n of this.data) {
221
- if (n instanceof g)
221
+ if (n instanceof m)
222
222
  for (let o of n.options) {
223
223
  s || (s = o);
224
224
  let c = o[e] || "";
@@ -241,7 +241,7 @@ class k {
241
241
  }
242
242
  getOptgroupByID(e) {
243
243
  for (let t of this.data)
244
- if (t instanceof g && t.id === e)
244
+ if (t instanceof m && t.id === e)
245
245
  return t;
246
246
  return null;
247
247
  }
@@ -255,7 +255,7 @@ class k {
255
255
  getFirstOption() {
256
256
  let e = null;
257
257
  for (let t of this.data)
258
- if (t instanceof g ? e = t.options[0] : t instanceof u && (e = t), e)
258
+ if (t instanceof m ? e = t.options[0] : t instanceof u && (e = t), e)
259
259
  break;
260
260
  return e;
261
261
  }
@@ -268,12 +268,12 @@ class k {
268
268
  filter(e, t) {
269
269
  const s = [];
270
270
  return this.data.forEach((i) => {
271
- if (i instanceof g) {
271
+ if (i instanceof m) {
272
272
  let l = [];
273
273
  if (i.options.forEach((n) => {
274
274
  (!e || e(n)) && (t ? l.push(new u(n)) : s.push(new u(n)));
275
275
  }), l.length > 0) {
276
- let n = new g(i);
276
+ let n = new m(i);
277
277
  n.options = l, s.push(n);
278
278
  }
279
279
  }
@@ -380,8 +380,8 @@ class N {
380
380
  if (this.settings.isMultiple)
381
381
  this.callbacks.setSelected([], !1), this.updateDeselectAll();
382
382
  else {
383
- const d = this.store.getFirstOption(), m = d ? d.id : "";
384
- this.callbacks.setSelected(m, !1);
383
+ const d = this.store.getFirstOption(), g = d ? d.id : "";
384
+ this.callbacks.setSelected(g, !1);
385
385
  }
386
386
  this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
387
387
  }
@@ -485,7 +485,7 @@ class N {
485
485
  if (!(this.settings.minSelected && r.length < this.settings.minSelected) && (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(r, c) === !0), o)) {
486
486
  let h = [];
487
487
  for (const f of r) {
488
- if (f instanceof g)
488
+ if (f instanceof m)
489
489
  for (const d of f.options)
490
490
  d.id && h.push(d.id);
491
491
  f instanceof u && h.push(f.id);
@@ -535,7 +535,7 @@ class N {
535
535
  main: e,
536
536
  input: t
537
537
  };
538
- 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 = C((l) => {
538
+ 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) => {
539
539
  this.callbacks.search(l.target.value);
540
540
  }, 100), t.onkeydown = (l) => {
541
541
  switch (l.key) {
@@ -678,7 +678,7 @@ class N {
678
678
  ));
679
679
  const t = document.createDocumentFragment();
680
680
  for (const s of e) {
681
- if (s instanceof g) {
681
+ if (s instanceof m) {
682
682
  const i = document.createElement("div");
683
683
  i.classList.add(this.classes.optgroup);
684
684
  const l = document.createElement("div");
@@ -690,8 +690,8 @@ class N {
690
690
  const o = document.createElement("div");
691
691
  o.classList.add(this.classes.optgroupSelectAll);
692
692
  let c = !0;
693
- for (const m of s.options)
694
- if (!m.selected) {
693
+ for (const g of s.options)
694
+ if (!g.selected) {
695
695
  c = !1;
696
696
  break;
697
697
  }
@@ -703,24 +703,24 @@ class N {
703
703
  const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
704
704
  f.setAttribute("d", this.classes.optgroupSelectAllBox), h.appendChild(f);
705
705
  const d = document.createElementNS("http://www.w3.org/2000/svg", "path");
706
- d.setAttribute("d", this.classes.optgroupSelectAllCheck), h.appendChild(d), o.addEventListener("click", (m) => {
707
- m.preventDefault(), m.stopPropagation();
708
- const b = this.store.getSelected();
706
+ d.setAttribute("d", this.classes.optgroupSelectAllCheck), h.appendChild(d), o.addEventListener("click", (g) => {
707
+ g.preventDefault(), g.stopPropagation();
708
+ const v = this.store.getSelected();
709
709
  if (c) {
710
- const w = b.filter((O) => {
711
- for (const v of s.options)
712
- if (O === v.id)
710
+ const w = v.filter((S) => {
711
+ for (const b of s.options)
712
+ if (S === b.id)
713
713
  return !1;
714
714
  return !0;
715
715
  });
716
716
  this.callbacks.setSelected(w, !0);
717
717
  return;
718
718
  } else {
719
- let w = s.options.map((v) => v.id).filter((v) => v !== void 0);
720
- const O = b.concat(w);
721
- for (const v of s.options)
722
- v.id && !this.store.getOptionByID(v.id) && this.callbacks.addOption(new u(v));
723
- this.callbacks.setSelected(O, !0);
719
+ let w = s.options.map((b) => b.id).filter((b) => b !== void 0);
720
+ const S = v.concat(w);
721
+ for (const b of s.options)
722
+ b.id && !this.store.getOptionByID(b.id) && this.callbacks.addOption(new u(b));
723
+ this.callbacks.setSelected(S, !0);
724
724
  return;
725
725
  }
726
726
  }), n.appendChild(o);
@@ -767,9 +767,9 @@ class N {
767
767
  if (this.settings.isMultiple) {
768
768
  const h = c.some((d) => d.id === a);
769
769
  if (s.shiftKey && this.lastSelectedOption) {
770
- const d = this.store.getDataOptions(), m = d.findIndex((w) => w.id === this.lastSelectedOption.id), b = d.findIndex((w) => w.id === e.id);
771
- if (m >= 0 && b >= 0) {
772
- const w = Math.min(m, b), O = Math.max(m, b), y = d.slice(w, O + 1).filter((x) => !c.find((A) => A.id === x.id));
770
+ const d = this.store.getDataOptions(), g = d.findIndex((w) => w.id === this.lastSelectedOption.id), v = d.findIndex((w) => w.id === e.id);
771
+ if (g >= 0 && v >= 0) {
772
+ const w = Math.min(g, v), S = Math.max(g, v), y = d.slice(w, S + 1).filter((x) => !c.find((E) => E.id === x.id));
773
773
  c.length + y.length <= this.settings.maxSelected ? r = c.concat(y) : r = c;
774
774
  } else
775
775
  r = c;
@@ -799,10 +799,10 @@ class N {
799
799
  const c = o.textContent || "", r = new RegExp("(" + l + ")", "i");
800
800
  if (r.test(c)) {
801
801
  const h = document.createElement("span");
802
- c.split(r).forEach((d, m) => {
802
+ c.split(r).forEach((d, g) => {
803
803
  if (d && r.test(d)) {
804
- const b = document.createElement("mark");
805
- b.className = s, b.textContent = d, h.appendChild(b);
804
+ const v = document.createElement("mark");
805
+ v.className = s, v.textContent = d, h.appendChild(v);
806
806
  } else d && h.appendChild(document.createTextNode(d));
807
807
  }), o.parentNode?.replaceChild(h, o);
808
808
  }
@@ -844,9 +844,14 @@ class M {
844
844
  onClassChange;
845
845
  onDisabledChange;
846
846
  onOptionsChange;
847
+ onLabelClick;
847
848
  // Change observers
848
849
  listen = !1;
849
850
  observer = null;
851
+ // Event handlers for preventing native select behavior (especially on iOS Safari)
852
+ preventNativeSelect = null;
853
+ preventNativeSelectMousedown = null;
854
+ preventNativeSelectFocus = null;
850
855
  constructor(e) {
851
856
  this.select = e, this.valueChange = this.valueChange.bind(this), this.select.addEventListener("change", this.valueChange, {
852
857
  // allow bubbling of event
@@ -860,10 +865,16 @@ class M {
860
865
  this.select.disabled = !0;
861
866
  }
862
867
  hideUI() {
863
- this.select.tabIndex = -1, this.select.style.position = "absolute", this.select.style.width = "1px", this.select.style.height = "1px", this.select.style.opacity = "0", this.select.style.overflow = "hidden", this.select.style.pointerEvents = "none", this.select.style.margin = "0", this.select.style.padding = "0", this.select.style.borderWidth = "0", this.select.style.clip = "rect(0 0 0 0)", this.select.setAttribute("aria-hidden", "true");
868
+ this.select.tabIndex = -1, this.select.style.position = "absolute", this.select.style.width = "1px", this.select.style.height = "1px", this.select.style.opacity = "0", this.select.style.overflow = "hidden", this.select.style.pointerEvents = "none", this.select.style.margin = "0", this.select.style.padding = "0", this.select.style.borderWidth = "0", this.select.style.clip = "rect(0 0 0 0)", this.select.setAttribute("aria-hidden", "true"), this.preventNativeSelect || (this.preventNativeSelect = (e) => {
869
+ e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
870
+ }, this.preventNativeSelectMousedown = (e) => {
871
+ e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
872
+ }, this.preventNativeSelectFocus = (e) => {
873
+ e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
874
+ }, this.select.addEventListener("click", this.preventNativeSelect, { capture: !0, passive: !1 }), this.select.addEventListener("mousedown", this.preventNativeSelectMousedown, { capture: !0, passive: !1 }), this.select.addEventListener("focus", this.preventNativeSelectFocus, { capture: !0, passive: !1 }));
864
875
  }
865
876
  showUI() {
866
- this.select.removeAttribute("tabindex"), this.select.style.position = "", this.select.style.width = "", this.select.style.height = "", this.select.style.opacity = "", this.select.style.overflow = "", this.select.style.pointerEvents = "", this.select.style.margin = "", this.select.style.padding = "", this.select.style.borderWidth = "", this.select.style.clip = "", this.select.removeAttribute("aria-hidden");
877
+ this.select.removeAttribute("tabindex"), this.select.style.position = "", this.select.style.width = "", this.select.style.height = "", this.select.style.opacity = "", this.select.style.overflow = "", this.select.style.pointerEvents = "", this.select.style.margin = "", this.select.style.padding = "", this.select.style.borderWidth = "", this.select.style.clip = "", this.select.removeAttribute("aria-hidden"), 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);
867
878
  }
868
879
  changeListen(e) {
869
880
  this.listen = e, e && this.observer && this.observer.observe(this.select, {
@@ -1009,7 +1020,7 @@ class M {
1009
1020
  updateOptions(e) {
1010
1021
  this.changeListen(!1), this.select.innerHTML = "";
1011
1022
  for (const t of e)
1012
- t instanceof g && this.select.appendChild(this.createOptgroup(t)), t instanceof u && this.select.appendChild(this.createOption(t));
1023
+ t instanceof m && this.select.appendChild(this.createOptgroup(t)), t instanceof u && this.select.appendChild(this.createOption(t));
1013
1024
  this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0);
1014
1025
  }
1015
1026
  createOptgroup(e) {
@@ -1027,8 +1038,48 @@ class M {
1027
1038
  t.setAttribute("data-" + D(s), e.data[s]);
1028
1039
  }), t;
1029
1040
  }
1041
+ // Find and handle labels associated with this select
1042
+ setupLabelHandlers() {
1043
+ const e = [], t = this.select.id;
1044
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((a) => e.push(a));
1045
+ let s = this.select.parentElement;
1046
+ for (; s && s !== document.body; ) {
1047
+ if (s.tagName === "LABEL") {
1048
+ e.push(s);
1049
+ break;
1050
+ }
1051
+ s = s.parentElement;
1052
+ }
1053
+ Array.from(new Set(e)).forEach((l) => {
1054
+ if (l.__slimSelectLabelHandler)
1055
+ return;
1056
+ const a = (n) => {
1057
+ n.preventDefault(), n.stopPropagation(), this.onLabelClick && setTimeout(() => {
1058
+ this.onLabelClick();
1059
+ }, 0);
1060
+ };
1061
+ l.__slimSelectLabelHandler = a, l.addEventListener("click", a, { capture: !0, passive: !1 });
1062
+ });
1063
+ }
1064
+ // Remove label handlers
1065
+ removeLabelHandlers() {
1066
+ const e = [], t = this.select.id;
1067
+ t && document.querySelectorAll(`label[for="${t}"]`).forEach((a) => e.push(a));
1068
+ let s = this.select.parentElement;
1069
+ for (; s && s !== document.body; ) {
1070
+ if (s.tagName === "LABEL") {
1071
+ e.push(s);
1072
+ break;
1073
+ }
1074
+ s = s.parentElement;
1075
+ }
1076
+ Array.from(new Set(e)).forEach((l) => {
1077
+ const a = l.__slimSelectLabelHandler;
1078
+ a && (l.removeEventListener("click", a, { capture: !0 }), delete l.__slimSelectLabelHandler);
1079
+ });
1080
+ }
1030
1081
  destroy() {
1031
- this.changeListen(!1), this.select.removeEventListener("change", this.valueChange), this.observer && (this.observer.disconnect(), this.observer = null), delete this.select.dataset.id, this.showUI();
1082
+ 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();
1032
1083
  }
1033
1084
  }
1034
1085
  class P {
@@ -1069,7 +1120,7 @@ class P {
1069
1120
  maxValuesMessage;
1070
1121
  addableText;
1071
1122
  constructor(e) {
1072
- e || (e = {}), this.id = "ss-" + L(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.alwaysOpen = e.alwaysOpen !== void 0 ? e.alwaysOpen : !1, this.showSearch = e.showSearch !== void 0 ? e.showSearch : !0, this.focusSearch = e.focusSearch !== void 0 ? e.focusSearch : !0, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.searchHighlight = e.searchHighlight !== void 0 ? e.searchHighlight : !1, this.closeOnSelect = e.closeOnSelect !== void 0 ? e.closeOnSelect : !0, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || 'Press "Enter" to add {value}';
1123
+ e || (e = {}), this.id = "ss-" + C(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.alwaysOpen = e.alwaysOpen !== void 0 ? e.alwaysOpen : !1, this.showSearch = e.showSearch !== void 0 ? e.showSearch : !0, this.focusSearch = e.focusSearch !== void 0 ? e.focusSearch : !0, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.searchHighlight = e.searchHighlight !== void 0 ? e.searchHighlight : !1, this.closeOnSelect = e.closeOnSelect !== void 0 ? e.closeOnSelect : !0, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || 'Press "Enter" to add {value}';
1073
1124
  }
1074
1125
  }
1075
1126
  class I {
@@ -1104,11 +1155,11 @@ class I {
1104
1155
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1105
1156
  return;
1106
1157
  }
1107
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new P(e.settings), this.cssClasses = new E(e.cssClasses);
1158
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new P(e.settings), this.cssClasses = new A(e.cssClasses);
1108
1159
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1109
1160
  for (const n in e.events)
1110
- e.events.hasOwnProperty(n) && (t.indexOf(n) !== -1 ? this.events[n] = C(e.events[n], 100) : this.events[n] = e.events[n]);
1111
- 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.select.updateSelect(this.settings.id, this.settings.style, this.settings.class), this.select.hideUI(), this.select.onValueChange = (n) => {
1161
+ e.events.hasOwnProperty(n) && (t.indexOf(n) !== -1 ? this.events[n] = O(e.events[n], 100) : this.events[n] = e.events[n]);
1162
+ 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 = (n) => {
1112
1163
  this.setSelected(n.map((o) => o.id));
1113
1164
  }, this.select.onClassChange = (n) => {
1114
1165
  this.settings.class = n, this.render.updateClassStyles();
@@ -1116,6 +1167,8 @@ class I {
1116
1167
  n ? this.disable() : this.enable();
1117
1168
  }, this.select.onOptionsChange = (n) => {
1118
1169
  this.setData(n);
1170
+ }, this.select.onLabelClick = () => {
1171
+ this.settings.disabled || this.open();
1119
1172
  };
1120
1173
  const s = e.data ? e.data : this.select.getData();
1121
1174
  this.store = new k(this.settings.isMultiple ? "multiple" : "single", s), e.data && this.select.updateOptions(this.store.getData());
@@ -1131,7 +1184,7 @@ class I {
1131
1184
  };
1132
1185
  this.render = new N(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
1133
1186
  const l = this.selectEl.getAttribute("aria-label"), a = this.selectEl.getAttribute("aria-labelledby");
1134
- l ? this.render.main.main.setAttribute("aria-label", l) : a && this.render.main.main.setAttribute("aria-labelledby", a), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), window.addEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.addEventListener("scroll", this.windowScroll, !1), document.addEventListener("visibilitychange", this.windowVisibilityChange), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.selectEl.slim = this;
1187
+ l ? this.render.main.main.setAttribute("aria-label", l) : a && this.render.main.main.setAttribute("aria-labelledby", a), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), window.addEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.addEventListener("scroll", this.windowScroll, !1), document.addEventListener("visibilitychange", this.windowVisibilityChange), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.select.setupLabelHandlers(), this.selectEl.slim = this;
1135
1188
  }
1136
1189
  // Set to enabled and remove disabled classes
1137
1190
  enable() {
@@ -1152,7 +1205,7 @@ class I {
1152
1205
  }
1153
1206
  this.store.setData(e);
1154
1207
  const i = this.store.getData();
1155
- this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !S(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1208
+ this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !L(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1156
1209
  }
1157
1210
  getSelected() {
1158
1211
  let e = this.store.getSelectedOptions();
@@ -1173,13 +1226,13 @@ class I {
1173
1226
  }
1174
1227
  this.store.setSelectedBy("id", l);
1175
1228
  const a = this.store.getData();
1176
- this.select.updateOptions(a), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(a), t && this.events.afterChange && !S(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1229
+ this.select.updateOptions(a), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(a), t && this.events.afterChange && !L(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1177
1230
  }
1178
1231
  addOption(e) {
1179
1232
  const t = this.store.getSelected();
1180
1233
  this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1181
1234
  const s = this.store.getData();
1182
- this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !S(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1235
+ this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !L(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1183
1236
  }
1184
1237
  open() {
1185
1238
  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(() => {
@@ -1216,11 +1269,11 @@ class I {
1216
1269
  destroy() {
1217
1270
  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();
1218
1271
  }
1219
- windowResize = C(() => {
1272
+ windowResize = O(() => {
1220
1273
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1221
1274
  });
1222
1275
  // Event listener for window scrolling
1223
- windowScroll = C(() => {
1276
+ windowScroll = O(() => {
1224
1277
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1225
1278
  });
1226
1279
  // Event listener for document click
@@ -1233,7 +1286,7 @@ class I {
1233
1286
  };
1234
1287
  }
1235
1288
  export {
1236
- g as Optgroup,
1289
+ m as Optgroup,
1237
1290
  u as Option,
1238
1291
  P as Settings,
1239
1292
  I as default