slim-select 3.1.4 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -140,6 +140,7 @@ new SlimSelect({
140
140
  alwaysOpen: false, // Keep dropdown always open
141
141
  showSearch: true, // Show search input
142
142
  focusSearch: true, // Auto focus search on open
143
+ keepSearch: false, // Keep search input value when dropdown closes
143
144
  ariaLabel: 'Combobox', // ARIA label for accessibility
144
145
  searchPlaceholder: 'Search', // Search input placeholder
145
146
  searchText: 'No Results', // Text when no results found
package/dist/index.d.ts CHANGED
@@ -138,6 +138,7 @@ declare class Render {
138
138
  disable(): void;
139
139
  open(): void;
140
140
  close(): void;
141
+ private getAnimationTiming;
141
142
  updateClassStyles(): void;
142
143
  updateAriaAttributes(): void;
143
144
  mainDiv(): Main;
@@ -227,6 +228,7 @@ export declare class Settings {
227
228
  alwaysOpen: boolean;
228
229
  showSearch: boolean;
229
230
  focusSearch: boolean;
231
+ keepSearch: boolean;
230
232
  ariaLabel: string;
231
233
  searchPlaceholder: string;
232
234
  searchText: string;
@@ -138,6 +138,7 @@ declare class Render {
138
138
  disable(): void;
139
139
  open(): void;
140
140
  close(): void;
141
+ private getAnimationTiming;
141
142
  updateClassStyles(): void;
142
143
  updateAriaAttributes(): void;
143
144
  mainDiv(): Main;
@@ -227,6 +228,7 @@ export declare class Settings {
227
228
  alwaysOpen: boolean;
228
229
  showSearch: boolean;
229
230
  focusSearch: boolean;
231
+ keepSearch: boolean;
230
232
  ariaLabel: string;
231
233
  searchPlaceholder: string;
232
234
  searchText: string;
@@ -1,10 +1,10 @@
1
1
  import ae, { forwardRef as re, useRef as V, useImperativeHandle as oe, useEffect as $ } from "react";
2
- var B = { exports: {} }, R = {};
2
+ var F = { exports: {} }, R = {};
3
3
  var ee;
4
4
  function ce() {
5
5
  if (ee) return R;
6
6
  ee = 1;
7
- var p = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
7
+ var f = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
8
8
  function t(s, i, n) {
9
9
  var r = null;
10
10
  if (n !== void 0 && (r = "" + n), i.key !== void 0 && (r = "" + i.key), "key" in i) {
@@ -13,7 +13,7 @@ function ce() {
13
13
  a !== "key" && (n[a] = i[a]);
14
14
  } else n = i;
15
15
  return i = n.ref, {
16
- $$typeof: p,
16
+ $$typeof: f,
17
17
  type: s,
18
18
  key: r,
19
19
  ref: i !== void 0 ? i : null,
@@ -26,7 +26,7 @@ var _ = {};
26
26
  var te;
27
27
  function he() {
28
28
  return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
29
- function p(l) {
29
+ function f(l) {
30
30
  if (l == null) return null;
31
31
  if (typeof l == "function")
32
32
  return l.$$typeof === ie ? null : l.displayName || l.name || null;
@@ -58,12 +58,12 @@ function he() {
58
58
  case b:
59
59
  var u = l.render;
60
60
  return l = l.displayName, l || (l = u.displayName || u.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
61
- case F:
62
- return u = l.displayName || null, u !== null ? u : p(l.type) || "Memo";
61
+ case H:
62
+ return u = l.displayName || null, u !== null ? u : f(l.type) || "Memo";
63
63
  case A:
64
64
  u = l._payload, l = l._init;
65
65
  try {
66
- return p(l(u));
66
+ return f(l(u));
67
67
  } catch {
68
68
  }
69
69
  }
@@ -94,7 +94,7 @@ function he() {
94
94
  if (typeof l == "object" && l !== null && l.$$typeof === A)
95
95
  return "<...>";
96
96
  try {
97
- var u = p(l);
97
+ var u = f(l);
98
98
  return u ? "<" + u + ">" : "<...>";
99
99
  } catch {
100
100
  return "<...>";
@@ -127,7 +127,7 @@ function he() {
127
127
  });
128
128
  }
129
129
  function c() {
130
- var l = p(this.type);
130
+ var l = f(this.type);
131
131
  return X[l] || (X[l] = !0, console.error(
132
132
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
133
  )), l = this.props.ref, l !== void 0 ? l : null;
@@ -179,7 +179,7 @@ function he() {
179
179
  );
180
180
  else d(E);
181
181
  if (J.call(u, "key")) {
182
- E = p(l);
182
+ E = f(l);
183
183
  var N = Object.keys(u).filter(function(le) {
184
184
  return le !== "key";
185
185
  });
@@ -219,16 +219,16 @@ React keys must be passed directly to JSX without using spread:
219
219
  function g(l) {
220
220
  return typeof l == "object" && l !== null && l.$$typeof === C;
221
221
  }
222
- var f = ae, C = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), k = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"), F = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), j = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ne = Array.isArray, U = console.createTask ? console.createTask : function() {
222
+ var p = ae, C = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), k = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), j = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ne = Array.isArray, U = console.createTask ? console.createTask : function() {
223
223
  return null;
224
224
  };
225
- f = {
225
+ p = {
226
226
  react_stack_bottom_frame: function(l) {
227
227
  return l();
228
228
  }
229
229
  };
230
- var G, X = {}, K = f.react_stack_bottom_frame.bind(
231
- f,
230
+ var G, X = {}, K = p.react_stack_bottom_frame.bind(
231
+ p,
232
232
  n
233
233
  )(), Z = U(s(n)), Q = {};
234
234
  _.Fragment = L, _.jsx = function(l, u, w) {
@@ -256,10 +256,10 @@ React keys must be passed directly to JSX without using spread:
256
256
  }
257
257
  var se;
258
258
  function de() {
259
- return se || (se = 1, process.env.NODE_ENV === "production" ? B.exports = ce() : B.exports = he()), B.exports;
259
+ return se || (se = 1, process.env.NODE_ENV === "production" ? F.exports = ce() : F.exports = he()), F.exports;
260
260
  }
261
261
  var ue = de();
262
- class fe {
262
+ class pe {
263
263
  main;
264
264
  // Placeholder
265
265
  placeholder;
@@ -323,33 +323,33 @@ class fe {
323
323
  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";
324
324
  }
325
325
  }
326
- function W() {
326
+ function z() {
327
327
  return Math.random().toString(36).substring(2, 10);
328
328
  }
329
- function pe(p, e) {
329
+ function fe(f, e) {
330
330
  function t(i, n) {
331
331
  return n && i && i.classList && i.classList.contains(n) || n && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
332
332
  }
333
333
  function s(i, n) {
334
334
  return !i || i === document ? null : t(i, n) ? i : s(i.parentNode, n);
335
335
  }
336
- return t(p, e) || s(p, e);
336
+ return t(f, e) || s(f, e);
337
337
  }
338
- function H(p, e = 50, t = !1) {
338
+ function B(f, e = 50, t = !1) {
339
339
  let s;
340
340
  return function(...i) {
341
341
  const n = self, r = () => {
342
- s = null, t || p.apply(n, i);
342
+ s = null, t || f.apply(n, i);
343
343
  }, a = t && !s;
344
- clearTimeout(s), s = setTimeout(r, e), a && p.apply(n, i);
344
+ clearTimeout(s), s = setTimeout(r, e), a && f.apply(n, i);
345
345
  };
346
346
  }
347
- function z(p, e) {
348
- return JSON.stringify(p) === JSON.stringify(e);
347
+ function W(f, e) {
348
+ return JSON.stringify(f) === JSON.stringify(e);
349
349
  }
350
- function me(p) {
351
- const e = p.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
352
- return p[0] === p[0].toUpperCase() ? e.substring(1) : e;
350
+ function me(f) {
351
+ const e = f.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
352
+ return f[0] === f[0].toUpperCase() ? e.substring(1) : e;
353
353
  }
354
354
  class S {
355
355
  id;
@@ -366,7 +366,7 @@ class S {
366
366
  data;
367
367
  mandatory;
368
368
  constructor(e) {
369
- this.id = !e.id || e.id === "" ? W() : 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 || {};
369
+ this.id = !e.id || e.id === "" ? z() : 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 || {};
370
370
  }
371
371
  }
372
372
  class x {
@@ -377,7 +377,7 @@ class x {
377
377
  closable;
378
378
  options;
379
379
  constructor(e) {
380
- if (this.id = !e.id || e.id === "" ? W() : 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)
380
+ if (this.id = !e.id || e.id === "" ? z() : 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)
381
381
  for (const t of e.options)
382
382
  this.options.push(new S(t));
383
383
  }
@@ -591,9 +591,21 @@ class ve {
591
591
  }
592
592
  }
593
593
  close() {
594
- this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.content.main.classList.remove(this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant"), setTimeout(() => {
594
+ this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.content.main.classList.remove(this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
595
+ const e = this.getAnimationTiming();
596
+ setTimeout(() => {
595
597
  this.main.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow);
596
- }, 100);
598
+ }, e);
599
+ }
600
+ getAnimationTiming() {
601
+ const t = getComputedStyle(this.content.main).getPropertyValue("--ss-animation-timing").trim();
602
+ if (t) {
603
+ if (t.endsWith("ms"))
604
+ return parseFloat(t);
605
+ if (t.endsWith("s"))
606
+ return parseFloat(t) * 1e3;
607
+ }
608
+ return 200;
597
609
  }
598
610
  updateClassStyles() {
599
611
  if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.main.main.classList.add(this.classes.main), this.content.main.classList.add(this.classes.content), this.settings.style !== "" && (this.main.main.style.cssText = this.settings.style, this.content.main.style.cssText = this.settings.style), this.settings.class.length)
@@ -641,7 +653,7 @@ class ve {
641
653
  if (this.settings.isMultiple)
642
654
  this.callbacks.setSelected([], !1), this.updateDeselectAll();
643
655
  else {
644
- const f = this.store.getFirstOption(), C = f ? f.id : "";
656
+ const p = this.store.getFirstOption(), C = p ? p.id : "";
645
657
  this.callbacks.setSelected(C, !1);
646
658
  }
647
659
  this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
@@ -747,8 +759,8 @@ class ve {
747
759
  let d = [];
748
760
  for (const g of o) {
749
761
  if (g instanceof x)
750
- for (const f of g.options)
751
- f.id && d.push(f.id);
762
+ for (const p of g.options)
763
+ p.id && d.push(p.id);
752
764
  g instanceof S && d.push(g.id);
753
765
  }
754
766
  this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(o), this.updateDeselectAll();
@@ -796,7 +808,7 @@ class ve {
796
808
  main: e,
797
809
  input: t
798
810
  };
799
- 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 = H((n) => {
811
+ 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 = B((n) => {
800
812
  this.callbacks.search(n.target.value);
801
813
  }, 100), t.onkeydown = (n) => {
802
814
  switch (n.key) {
@@ -832,8 +844,8 @@ class ve {
832
844
  const h = (d) => {
833
845
  let g = new S(d);
834
846
  if (this.callbacks.addOption(g), this.settings.isMultiple) {
835
- let f = this.store.getSelected();
836
- f.push(g.id), this.callbacks.setSelected(f, !0);
847
+ let p = this.store.getSelected();
848
+ p.push(g.id), this.callbacks.setSelected(p, !0);
837
849
  } else
838
850
  this.callbacks.setSelected([g.id], !0);
839
851
  this.callbacks.search(""), this.settings.closeOnSelect && setTimeout(() => {
@@ -858,7 +870,7 @@ class ve {
858
870
  return i;
859
871
  }
860
872
  searchFocus() {
861
- this.content.search.input.focus();
873
+ this.content.search.input.focus({ preventScroll: !0 });
862
874
  }
863
875
  getOptions(e = !1, t = !1, s = !1) {
864
876
  let i = "." + this.classes.option;
@@ -963,8 +975,8 @@ class ve {
963
975
  d.setAttribute("viewBox", "0 0 100 100"), c.appendChild(d);
964
976
  const g = document.createElementNS("http://www.w3.org/2000/svg", "path");
965
977
  g.setAttribute("d", this.classes.optgroupSelectAllBox), d.appendChild(g);
966
- const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
967
- f.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(f), c.addEventListener("click", (C) => {
978
+ const p = document.createElementNS("http://www.w3.org/2000/svg", "path");
979
+ p.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(p), c.addEventListener("click", (C) => {
968
980
  C.preventDefault(), C.stopPropagation();
969
981
  const m = this.store.getSelected();
970
982
  if (h) {
@@ -1026,19 +1038,19 @@ class ve {
1026
1038
  const h = this.store.getSelectedOptions();
1027
1039
  let o = [];
1028
1040
  if (this.settings.isMultiple) {
1029
- const d = h.some((f) => f.id === r);
1041
+ const d = h.some((p) => p.id === r);
1030
1042
  if (s.shiftKey && this.lastSelectedOption) {
1031
- const f = this.store.getDataOptions(), C = f.findIndex((L) => L.id === this.lastSelectedOption.id), m = f.findIndex((L) => L.id === e.id);
1043
+ const p = this.store.getDataOptions(), C = p.findIndex((L) => L.id === this.lastSelectedOption.id), m = p.findIndex((L) => L.id === e.id);
1032
1044
  if (C >= 0 && m >= 0) {
1033
- const L = Math.min(C, m), O = Math.max(C, m), T = f.slice(L, O + 1).filter((k) => !h.find((b) => b.id === k.id));
1045
+ const L = Math.min(C, m), O = Math.max(C, m), T = p.slice(L, O + 1).filter((k) => !h.find((b) => b.id === k.id));
1034
1046
  h.length + T.length <= this.settings.maxSelected ? o = h.concat(T) : o = h;
1035
1047
  } else
1036
1048
  o = h;
1037
- } else a ? (d ? o = h.filter((f) => f.id !== r) : o = h.concat(e), this.lastSelectedOption = e) : (d ? o = h.filter((f) => f.id !== r) : o = h.concat(e), this.lastSelectedOption = e);
1049
+ } else a ? (d ? o = h.filter((p) => p.id !== r) : o = h.concat(e), this.lastSelectedOption = e) : (d ? o = h.filter((p) => p.id !== r) : o = h.concat(e), this.lastSelectedOption = e);
1038
1050
  }
1039
1051
  if (this.settings.isMultiple || (e.selected ? o = [] : o = [e]), this.callbacks.beforeChange || (c = !0), this.callbacks.beforeChange && (this.callbacks.beforeChange(o, h) === !1 ? c = !1 : c = !0), c) {
1040
1052
  this.store.getOptionByID(r) || this.callbacks.addOption(e), this.callbacks.setSelected(
1041
- o.map((f) => f.id),
1053
+ o.map((p) => p.id),
1042
1054
  !1
1043
1055
  );
1044
1056
  const d = s.ctrlKey || s.metaKey || s.shiftKey;
@@ -1060,11 +1072,11 @@ class ve {
1060
1072
  const h = c.textContent || "", o = new RegExp("(" + n + ")", "i");
1061
1073
  if (o.test(h)) {
1062
1074
  const d = document.createElement("span");
1063
- h.split(o).forEach((f, C) => {
1064
- if (f && o.test(f)) {
1075
+ h.split(o).forEach((p, C) => {
1076
+ if (p && o.test(p)) {
1065
1077
  const m = document.createElement("mark");
1066
- m.className = s, m.textContent = f, d.appendChild(m);
1067
- } else f && d.appendChild(document.createTextNode(f));
1078
+ m.className = s, m.textContent = p, d.appendChild(m);
1079
+ } else p && d.appendChild(document.createTextNode(p));
1068
1080
  }), c.parentNode?.replaceChild(d, c);
1069
1081
  }
1070
1082
  } else c.nodeType === Node.ELEMENT_NODE && Array.from(c.childNodes).forEach((h) => a(h));
@@ -1157,28 +1169,30 @@ class be {
1157
1169
  observeCall(e) {
1158
1170
  if (!this.listen)
1159
1171
  return;
1160
- let t = !1, s = !1, i = !1;
1161
- for (const n of e) {
1162
- if (n.target === this.select && (n.attributeName === "disabled" && (s = !0), n.attributeName === "class" && (t = !0), n.type === "childList")) {
1163
- for (const r of Array.from(n.addedNodes))
1164
- if (r.nodeName === "OPTION" && r.value === this.select.value) {
1165
- this.select.dispatchEvent(new Event("change"));
1172
+ let t = !1, s = !1, i = !1, n = !1;
1173
+ for (const r of e) {
1174
+ if (r.target === this.select && (r.attributeName === "disabled" && (s = !0), r.attributeName === "class" && (t = !0), r.type === "childList")) {
1175
+ for (const a of Array.from(r.addedNodes))
1176
+ if (a.nodeName === "OPTION" && a.value === this.select.value) {
1177
+ n = !0;
1166
1178
  break;
1167
1179
  }
1168
1180
  i = !0;
1169
1181
  }
1170
- (n.target.nodeName === "OPTGROUP" || n.target.nodeName === "OPTION") && (i = !0);
1182
+ (r.target.nodeName === "OPTGROUP" || r.target.nodeName === "OPTION") && (i = !0);
1171
1183
  }
1172
1184
  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) {
1173
1185
  if (this.isUpdating) {
1174
1186
  if (this.select.options.length > 0) {
1175
- const n = this.getData();
1176
- n.length > 0 && (this.pendingOptionsChange = n);
1187
+ const r = this.getData();
1188
+ r.length > 0 && (this.pendingOptionsChange = r);
1177
1189
  }
1190
+ n && this.select.dispatchEvent(new Event("change"));
1178
1191
  return;
1179
1192
  }
1180
1193
  this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
1181
1194
  }
1195
+ n && this.select.dispatchEvent(new Event("change"));
1182
1196
  }
1183
1197
  // From the select element pull optgroup and options into data
1184
1198
  getData() {
@@ -1331,7 +1345,8 @@ class be {
1331
1345
  if (n.__slimSelectLabelHandler)
1332
1346
  return;
1333
1347
  const r = (a) => {
1334
- a.target === n && (a.preventDefault(), this.onLabelClick && this.onLabelClick());
1348
+ const c = a.target;
1349
+ a.preventDefault(), c === n && this.onLabelClick && this.onLabelClick();
1335
1350
  };
1336
1351
  n.__slimSelectLabelHandler = r, n.addEventListener("click", r, { capture: !0, passive: !1 });
1337
1352
  });
@@ -1374,6 +1389,7 @@ class we {
1374
1389
  alwaysOpen;
1375
1390
  showSearch;
1376
1391
  focusSearch;
1392
+ keepSearch;
1377
1393
  ariaLabel;
1378
1394
  searchPlaceholder;
1379
1395
  searchText;
@@ -1395,7 +1411,7 @@ class we {
1395
1411
  maxValuesMessage;
1396
1412
  addableText;
1397
1413
  constructor(e) {
1398
- e || (e = {}), this.id = "ss-" + W(), 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}';
1414
+ e || (e = {}), this.id = "ss-" + z(), 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}';
1399
1415
  }
1400
1416
  }
1401
1417
  let Se = class {
@@ -1430,10 +1446,10 @@ let Se = class {
1430
1446
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1431
1447
  return;
1432
1448
  }
1433
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new we(e.settings), this.cssClasses = new fe(e.cssClasses);
1449
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new we(e.settings), this.cssClasses = new pe(e.cssClasses);
1434
1450
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1435
1451
  for (const a in e.events)
1436
- e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = H(e.events[a], 100) : this.events[a] = e.events[a]);
1452
+ e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = B(e.events[a], 100) : this.events[a] = e.events[a]);
1437
1453
  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 be(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) => {
1438
1454
  this.setSelected(a.map((c) => c.id));
1439
1455
  }, this.select.onClassChange = (a) => {
@@ -1480,7 +1496,7 @@ let Se = class {
1480
1496
  }
1481
1497
  this.store.setData(e);
1482
1498
  const i = this.store.getData();
1483
- this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !z(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1499
+ this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !W(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1484
1500
  }
1485
1501
  getSelected() {
1486
1502
  let e = this.store.getSelectedOptions();
@@ -1501,13 +1517,13 @@ let Se = class {
1501
1517
  }
1502
1518
  this.store.setSelectedBy("id", n);
1503
1519
  const r = this.store.getData();
1504
- this.select.updateOptions(r), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(r), t && this.events.afterChange && !z(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1520
+ this.select.updateOptions(r), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(r), t && this.events.afterChange && !W(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1505
1521
  }
1506
1522
  addOption(e) {
1507
1523
  const t = this.store.getSelected();
1508
1524
  this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1509
1525
  const s = this.store.getData();
1510
- this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !z(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1526
+ this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !W(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1511
1527
  }
1512
1528
  open() {
1513
1529
  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(() => {
@@ -1515,7 +1531,7 @@ let Se = class {
1515
1531
  }, this.settings.timeoutDelay), this.settings.contentPosition === "absolute" && (this.settings.intervalMove && clearInterval(this.settings.intervalMove), this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500)));
1516
1532
  }
1517
1533
  close(e = null) {
1518
- !this.settings.isOpen || this.settings.alwaysOpen || (this.events.beforeClose && this.events.beforeClose(), this.render.close(), this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
1534
+ !this.settings.isOpen || this.settings.alwaysOpen || (this.events.beforeClose && this.events.beforeClose(), this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
1519
1535
  this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
1520
1536
  }, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
1521
1537
  }
@@ -1544,16 +1560,16 @@ let Se = class {
1544
1560
  destroy() {
1545
1561
  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();
1546
1562
  }
1547
- windowResize = H(() => {
1563
+ windowResize = B(() => {
1548
1564
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1549
1565
  });
1550
1566
  // Event listener for window scrolling
1551
- windowScroll = H(() => {
1567
+ windowScroll = B(() => {
1552
1568
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1553
1569
  });
1554
1570
  // Event listener for document click
1555
1571
  documentClick = (e) => {
1556
- this.settings.isOpen && e.target && !pe(e.target, this.settings.id) && this.close(e.type);
1572
+ this.settings.isOpen && e.target && !fe(e.target, this.settings.id) && this.close(e.type);
1557
1573
  };
1558
1574
  // Event Listener for window visibility change
1559
1575
  windowVisibilityChange = () => {
@@ -1561,15 +1577,15 @@ let Se = class {
1561
1577
  };
1562
1578
  };
1563
1579
  const Oe = re(
1564
- ({ data: p, settings: e, events: t, cssClasses: s, value: i, onChange: n, children: r, multiple: a }, c) => {
1580
+ ({ data: f, settings: e, events: t, cssClasses: s, value: i, onChange: n, children: r, multiple: a }, c) => {
1565
1581
  const h = V(null), o = V(null), d = V(!0), g = V(i);
1566
1582
  oe(c, () => ({
1567
1583
  slimSelect: o.current
1568
1584
  }));
1569
- const f = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", C = (m, L = !1) => {
1585
+ const p = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", C = (m, L = !1) => {
1570
1586
  if (!o.current || m === void 0)
1571
1587
  return;
1572
- const O = f(m), T = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
1588
+ const O = p(m), T = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
1573
1589
  if (!(Array.isArray(O) ? O.length > 0 && O.every((b) => T.some((D) => D.value === b)) : O !== "" && T.some((b) => b.value === O)) && !Array.isArray(O) && !T.some((D) => D.placeholder)) {
1574
1590
  const D = o.current.getData(), P = {
1575
1591
  value: "",
@@ -1585,7 +1601,7 @@ const Oe = re(
1585
1601
  const m = {
1586
1602
  select: h.current
1587
1603
  };
1588
- p && (m.data = p), e && (m.settings = e), s && (m.cssClasses = s);
1604
+ f && (m.data = f), e && (m.settings = e), s && (m.cssClasses = s);
1589
1605
  const L = t?.afterChange;
1590
1606
  return m.events = {
1591
1607
  ...t,
@@ -1593,8 +1609,8 @@ const Oe = re(
1593
1609
  if (!o.current) return;
1594
1610
  const v = a ? O.map((A) => A.value) : O[0]?.value ?? "", k = o.current.getData().flatMap(
1595
1611
  (A) => "label" in A ? A.options : [A]
1596
- ), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((A) => k.some((M) => M.value === A)) : b !== "" && k.some((A) => A.value === b), P = Array.isArray(v) ? v.length > 0 && v.every((A) => k.some((M) => M.value === A)) : v !== "" && k.some((A) => A.value === v), F = Array.isArray(v) && Array.isArray(b) ? JSON.stringify(v.sort()) !== JSON.stringify(b.sort()) : b !== v;
1597
- n && F && (D || P) && (n(v), g.current = v), L && L(O);
1612
+ ), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((A) => k.some((M) => M.value === A)) : b !== "" && k.some((A) => A.value === b), P = Array.isArray(v) ? v.length > 0 && v.every((A) => k.some((M) => M.value === A)) : v !== "" && k.some((A) => A.value === v), H = Array.isArray(v) && Array.isArray(b) ? JSON.stringify(v.sort()) !== JSON.stringify(b.sort()) : b !== v;
1613
+ n && H && (D || P) && (n(v), g.current = v), L && L(O);
1598
1614
  }
1599
1615
  }, o.current = new Se(m), i !== void 0 && C(i, !1), () => {
1600
1616
  o.current && (o.current.destroy(), o.current = null);
@@ -1606,8 +1622,8 @@ const Oe = re(
1606
1622
  }
1607
1623
  o.current && i !== void 0 && (g.current = i, C(i, !1));
1608
1624
  }, [i]), $(() => {
1609
- o.current && p && !d.current && (o.current.setData(p), i !== void 0 && C(i, !1));
1610
- }, [p]), /* @__PURE__ */ ue.jsx("select", { ref: h, multiple: a, children: r });
1625
+ o.current && f && !d.current && (o.current.setData(f), i !== void 0 && C(i, !1));
1626
+ }, [f]), /* @__PURE__ */ ue.jsx("select", { ref: h, multiple: a, children: r });
1611
1627
  }
1612
1628
  );
1613
1629
  Oe.displayName = "SlimSelect";