slim-select 3.1.4 → 3.3.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,7 +1,7 @@
1
- import ae, { forwardRef as re, useRef as V, useImperativeHandle as oe, useEffect as $ } from "react";
2
- var B = { exports: {} }, R = {};
1
+ import re, { forwardRef as oe, useRef as I, useImperativeHandle as ce, useEffect as Y } from "react";
2
+ var V = { exports: {} }, R = {};
3
3
  var ee;
4
- function ce() {
4
+ function he() {
5
5
  if (ee) return R;
6
6
  ee = 1;
7
7
  var p = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
@@ -24,19 +24,19 @@ function ce() {
24
24
  }
25
25
  var _ = {};
26
26
  var te;
27
- function he() {
27
+ function de() {
28
28
  return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
29
29
  function p(l) {
30
30
  if (l == null) return null;
31
31
  if (typeof l == "function")
32
- return l.$$typeof === ie ? null : l.displayName || l.name || null;
32
+ return l.$$typeof === ne ? null : l.displayName || l.name || null;
33
33
  if (typeof l == "string") return l;
34
34
  switch (l) {
35
- case L:
35
+ case A:
36
36
  return "Fragment";
37
37
  case v:
38
38
  return "Profiler";
39
- case O:
39
+ case S:
40
40
  return "StrictMode";
41
41
  case D:
42
42
  return "Suspense";
@@ -51,16 +51,16 @@ function he() {
51
51
  ), l.$$typeof) {
52
52
  case m:
53
53
  return "Portal";
54
- case k:
54
+ case L:
55
55
  return l.displayName || "Context";
56
- case T:
56
+ case k:
57
57
  return (l._context.displayName || "Context") + ".Consumer";
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:
61
+ case B:
62
62
  return u = l.displayName || null, u !== null ? u : p(l.type) || "Memo";
63
- case A:
63
+ case T:
64
64
  u = l._payload, l = l._init;
65
65
  try {
66
66
  return p(l(u));
@@ -81,17 +81,17 @@ function he() {
81
81
  }
82
82
  if (u) {
83
83
  u = console;
84
- var w = u.error, y = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
85
- return w.call(
84
+ var C = u.error, O = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
85
+ return C.call(
86
86
  u,
87
87
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
- y
88
+ O
89
89
  ), e(l);
90
90
  }
91
91
  }
92
92
  function s(l) {
93
- if (l === L) return "<>";
94
- if (typeof l == "object" && l !== null && l.$$typeof === A)
93
+ if (l === A) return "<>";
94
+ if (typeof l == "object" && l !== null && l.$$typeof === T)
95
95
  return "<...>";
96
96
  try {
97
97
  var u = p(l);
@@ -115,14 +115,14 @@ function he() {
115
115
  return l.key !== void 0;
116
116
  }
117
117
  function a(l, u) {
118
- function w() {
118
+ function C() {
119
119
  G || (G = !0, console.error(
120
120
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
121
  u
122
122
  ));
123
123
  }
124
- w.isReactWarning = !0, Object.defineProperty(l, "key", {
125
- get: w,
124
+ C.isReactWarning = !0, Object.defineProperty(l, "key", {
125
+ get: C,
126
126
  configurable: !0
127
127
  });
128
128
  }
@@ -132,15 +132,15 @@ function he() {
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;
134
134
  }
135
- function h(l, u, w, y, I, q) {
136
- var E = w.ref;
135
+ function h(l, u, C, O, F, q) {
136
+ var y = C.ref;
137
137
  return l = {
138
- $$typeof: C,
138
+ $$typeof: E,
139
139
  type: l,
140
140
  key: u,
141
- props: w,
142
- _owner: y
143
- }, (E !== void 0 ? E : null) !== null ? Object.defineProperty(l, "ref", {
141
+ props: C,
142
+ _owner: O
143
+ }, (y !== void 0 ? y : null) !== null ? Object.defineProperty(l, "ref", {
144
144
  enumerable: !1,
145
145
  get: c
146
146
  }) : Object.defineProperty(l, "ref", { enumerable: !1, value: null }), l._store = {}, Object.defineProperty(l._store, "validated", {
@@ -157,7 +157,7 @@ function he() {
157
157
  configurable: !1,
158
158
  enumerable: !1,
159
159
  writable: !0,
160
- value: I
160
+ value: F
161
161
  }), Object.defineProperty(l, "_debugTask", {
162
162
  configurable: !1,
163
163
  enumerable: !1,
@@ -165,61 +165,61 @@ function he() {
165
165
  value: q
166
166
  }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
167
167
  }
168
- function o(l, u, w, y, I, q) {
169
- var E = u.children;
170
- if (E !== void 0)
171
- if (y)
172
- if (ne(E)) {
173
- for (y = 0; y < E.length; y++)
174
- d(E[y]);
175
- Object.freeze && Object.freeze(E);
168
+ function o(l, u, C, O, F, q) {
169
+ var y = u.children;
170
+ if (y !== void 0)
171
+ if (O)
172
+ if (le(y)) {
173
+ for (O = 0; O < y.length; O++)
174
+ d(y[O]);
175
+ Object.freeze && Object.freeze(y);
176
176
  } else
177
177
  console.error(
178
178
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
179
  );
180
- else d(E);
180
+ else d(y);
181
181
  if (J.call(u, "key")) {
182
- E = p(l);
183
- var N = Object.keys(u).filter(function(le) {
184
- return le !== "key";
182
+ y = p(l);
183
+ var N = Object.keys(u).filter(function(ae) {
184
+ return ae !== "key";
185
185
  });
186
- y = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", Q[E + y] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
186
+ O = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", Q[y + O] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
187
187
  `A props object containing a "key" prop is being spread into JSX:
188
188
  let props = %s;
189
189
  <%s {...props} />
190
190
  React keys must be passed directly to JSX without using spread:
191
191
  let props = %s;
192
192
  <%s key={someKey} {...props} />`,
193
+ O,
193
194
  y,
194
- E,
195
195
  N,
196
- E
197
- ), Q[E + y] = !0);
196
+ y
197
+ ), Q[y + O] = !0);
198
198
  }
199
- if (E = null, w !== void 0 && (t(w), E = "" + w), r(u) && (t(u.key), E = "" + u.key), "key" in u) {
200
- w = {};
201
- for (var Y in u)
202
- Y !== "key" && (w[Y] = u[Y]);
203
- } else w = u;
204
- return E && a(
205
- w,
199
+ if (y = null, C !== void 0 && (t(C), y = "" + C), r(u) && (t(u.key), y = "" + u.key), "key" in u) {
200
+ C = {};
201
+ for (var $ in u)
202
+ $ !== "key" && (C[$] = u[$]);
203
+ } else C = u;
204
+ return y && a(
205
+ C,
206
206
  typeof l == "function" ? l.displayName || l.name || "Unknown" : l
207
207
  ), h(
208
208
  l,
209
- E,
210
- w,
209
+ y,
210
+ C,
211
211
  i(),
212
- I,
212
+ F,
213
213
  q
214
214
  );
215
215
  }
216
216
  function d(l) {
217
- g(l) ? l._store && (l._store.validated = 1) : typeof l == "object" && l !== null && l.$$typeof === A && (l._payload.status === "fulfilled" ? g(l._payload.value) && l._payload.value._store && (l._payload.value._store.validated = 1) : l._store && (l._store.validated = 1));
217
+ g(l) ? l._store && (l._store.validated = 1) : typeof l == "object" && l !== null && l.$$typeof === T && (l._payload.status === "fulfilled" ? g(l._payload.value) && l._payload.value._store && (l._payload.value._store.validated = 1) : l._store && (l._store.validated = 1));
218
218
  }
219
219
  function g(l) {
220
- return typeof l == "object" && l !== null && l.$$typeof === C;
220
+ return typeof l == "object" && l !== null && l.$$typeof === E;
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 f = re, E = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), L = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ne = Symbol.for("react.client.reference"), j = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, le = Array.isArray, U = console.createTask ? console.createTask : function() {
223
223
  return null;
224
224
  };
225
225
  f = {
@@ -231,35 +231,35 @@ React keys must be passed directly to JSX without using spread:
231
231
  f,
232
232
  n
233
233
  )(), Z = U(s(n)), Q = {};
234
- _.Fragment = L, _.jsx = function(l, u, w) {
235
- var y = 1e4 > j.recentlyCreatedOwnerStacks++;
234
+ _.Fragment = A, _.jsx = function(l, u, C) {
235
+ var O = 1e4 > j.recentlyCreatedOwnerStacks++;
236
236
  return o(
237
237
  l,
238
238
  u,
239
- w,
239
+ C,
240
240
  !1,
241
- y ? Error("react-stack-top-frame") : K,
242
- y ? U(s(l)) : Z
241
+ O ? Error("react-stack-top-frame") : K,
242
+ O ? U(s(l)) : Z
243
243
  );
244
- }, _.jsxs = function(l, u, w) {
245
- var y = 1e4 > j.recentlyCreatedOwnerStacks++;
244
+ }, _.jsxs = function(l, u, C) {
245
+ var O = 1e4 > j.recentlyCreatedOwnerStacks++;
246
246
  return o(
247
247
  l,
248
248
  u,
249
- w,
249
+ C,
250
250
  !0,
251
- y ? Error("react-stack-top-frame") : K,
252
- y ? U(s(l)) : Z
251
+ O ? Error("react-stack-top-frame") : K,
252
+ O ? U(s(l)) : Z
253
253
  );
254
254
  };
255
255
  }()), _;
256
256
  }
257
257
  var se;
258
- function de() {
259
- return se || (se = 1, process.env.NODE_ENV === "production" ? B.exports = ce() : B.exports = he()), B.exports;
258
+ function ue() {
259
+ return se || (se = 1, process.env.NODE_ENV === "production" ? V.exports = he() : V.exports = de()), V.exports;
260
260
  }
261
- var ue = de();
262
- class fe {
261
+ var fe = ue();
262
+ class pe {
263
263
  main;
264
264
  // Placeholder
265
265
  placeholder;
@@ -320,13 +320,18 @@ class fe {
320
320
  disabled;
321
321
  hide;
322
322
  constructor(e) {
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";
323
+ e || (e = {});
324
+ let t = (s = "", i = "") => `${s} ${i}`.trim();
325
+ this.main = t("ss-main", e.main), this.placeholder = t("ss-placeholder", e.placeholder), this.values = t("ss-values", e.values), this.single = t("ss-single", e.single), this.max = t("ss-max", e.max), this.value = t("ss-value", e.value), this.valueText = t("ss-value-text", e.valueText), this.valueDelete = t("ss-value-delete", e.valueDelete), this.valueOut = t("ss-value-out", e.valueOut), this.deselect = t("ss-deselect", e.deselect), this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = t("ss-arrow", e.arrow), this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = t("ss-content", e.content), this.contentOpen = t("ss-open", e.contentOpen), this.dirAbove = t("ss-dir-above", e.dirAbove), this.dirBelow = t("ss-dir-below", e.dirBelow), this.search = t("ss-search", e.search), this.searchHighlighter = t("ss-search-highlight", e.searchHighlighter), this.searching = t("ss-searching", e.searching), this.addable = t("ss-addable", e.addable), this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = t("ss-list", e.list), this.optgroup = t("ss-optgroup", e.optgroup), this.optgroupLabel = t("ss-optgroup-label", e.optgroupLabel), this.optgroupLabelText = t("ss-optgroup-label-text", e.optgroupLabelText), this.optgroupActions = t("ss-optgroup-actions", e.optgroupActions), this.optgroupSelectAll = t("ss-selectall", e.optgroupSelectAll), this.optgroupSelectAllBox = e.optgroupSelectAllBox || "M60,10 L10,10 L10,90 L90,90 L90,50", this.optgroupSelectAllCheck = e.optgroupSelectAllCheck || "M30,45 L50,70 L90,10", this.optgroupClosable = t("ss-closable", e.optgroupClosable), this.option = t("ss-option", e.option), this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = t("ss-highlighted", e.highlighted), this.mainOpen = t("ss-open", e.mainOpen), this.close = t("ss-close", e.close), this.selected = t("ss-selected", e.selected), this.error = t("ss-error", e.error), this.disabled = t("ss-disabled", e.disabled), this.hide = t("ss-hide", e.hide);
326
+ }
327
+ getFirst(e) {
328
+ return this[e].split(" ")[0];
324
329
  }
325
330
  }
326
- function W() {
331
+ function z() {
327
332
  return Math.random().toString(36).substring(2, 10);
328
333
  }
329
- function pe(p, e) {
334
+ function ie(p, e) {
330
335
  function t(i, n) {
331
336
  return n && i && i.classList && i.classList.contains(n) || n && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
332
337
  }
@@ -344,14 +349,14 @@ function H(p, e = 50, t = !1) {
344
349
  clearTimeout(s), s = setTimeout(r, e), a && p.apply(n, i);
345
350
  };
346
351
  }
347
- function z(p, e) {
352
+ function W(p, e) {
348
353
  return JSON.stringify(p) === JSON.stringify(e);
349
354
  }
350
355
  function me(p) {
351
356
  const e = p.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
352
357
  return p[0] === p[0].toUpperCase() ? e.substring(1) : e;
353
358
  }
354
- class S {
359
+ class w {
355
360
  id;
356
361
  value;
357
362
  text;
@@ -366,7 +371,7 @@ class S {
366
371
  data;
367
372
  mandatory;
368
373
  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 || {};
374
+ 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
375
  }
371
376
  }
372
377
  class x {
@@ -377,9 +382,9 @@ class x {
377
382
  closable;
378
383
  options;
379
384
  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)
385
+ 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
386
  for (const t of e.options)
382
- this.options.push(new S(t));
387
+ this.options.push(new w(t));
383
388
  }
384
389
  }
385
390
  class ge {
@@ -405,7 +410,7 @@ class ge {
405
410
  if (i)
406
411
  return i;
407
412
  }
408
- } else if (t instanceof S || "text" in t) {
413
+ } else if (t instanceof w || "text" in t) {
409
414
  const s = this.validateOption(t);
410
415
  if (s)
411
416
  return s;
@@ -424,10 +429,10 @@ class ge {
424
429
  if (s instanceof x || "label" in s) {
425
430
  let i = [];
426
431
  "options" in s && s.options && s.options.forEach((n) => {
427
- i.push(new S(n));
432
+ i.push(new w(n));
428
433
  }), i.length > 0 && t.push(new x(s));
429
434
  }
430
- (s instanceof S || "text" in s) && t.push(new S(s));
435
+ (s instanceof w || "text" in s) && t.push(new w(s));
431
436
  }
432
437
  }), t;
433
438
  }
@@ -438,7 +443,7 @@ class ge {
438
443
  i.forEach((r) => {
439
444
  let a = !1;
440
445
  for (const c of s) {
441
- if (c instanceof S && c.id === r.id) {
446
+ if (c instanceof w && c.id === r.id) {
442
447
  a = !0;
443
448
  break;
444
449
  }
@@ -467,10 +472,10 @@ class ge {
467
472
  }
468
473
  addOption(e, t = !1) {
469
474
  if (t) {
470
- let s = [new S(e)];
475
+ let s = [new w(e)];
471
476
  this.setData(s.concat(this.getData()));
472
477
  } else
473
- this.setData(this.getData().concat(new S(e)));
478
+ this.setData(this.getData().concat(new w(e)));
474
479
  }
475
480
  // Pass in an array of id that will loop through
476
481
  // each option and set the selected property to true
@@ -485,7 +490,7 @@ class ge {
485
490
  let h = c[e] || "";
486
491
  c.selected = i ? !1 : t.includes(h), c.selected && (n.push(c), this.selectType === "single" && (i = !0));
487
492
  }
488
- a instanceof S && (s || (s = a), a.selected = i ? !1 : t.includes(a[e]), a.selected && (n.push(a), this.selectType === "single" && (i = !0)));
493
+ a instanceof w && (s || (s = a), a.selected = i ? !1 : t.includes(a[e]), a.selected && (n.push(a), this.selectType === "single" && (i = !0)));
489
494
  }
490
495
  this.selectType === "single" && s && !i && (s.selected = !0, n.push(s));
491
496
  const r = t.map((a) => n.find((c) => c[e] === a)?.id || "");
@@ -516,7 +521,7 @@ class ge {
516
521
  getFirstOption() {
517
522
  let e = null;
518
523
  for (let t of this.data)
519
- if (t instanceof x ? e = t.options[0] : t instanceof S && (e = t), e)
524
+ if (t instanceof x ? e = t.options[0] : t instanceof w && (e = t), e)
520
525
  break;
521
526
  return e;
522
527
  }
@@ -532,13 +537,13 @@ class ge {
532
537
  if (i instanceof x) {
533
538
  let n = [];
534
539
  if (i.options.forEach((a) => {
535
- (!e || e(a)) && (t ? n.push(new S(a)) : s.push(new S(a)));
540
+ (!e || e(a)) && (t ? n.push(new w(a)) : s.push(new w(a)));
536
541
  }), n.length > 0) {
537
542
  let a = new x(i);
538
543
  a.options = n, s.push(a);
539
544
  }
540
545
  }
541
- i instanceof S && (!e || e(i)) && s.push(new S(i));
546
+ i instanceof w && (!e || e(i)) && s.push(new w(i));
542
547
  }), s;
543
548
  }
544
549
  // Take in an array of options and reoder them based upon the selected order
@@ -564,6 +569,8 @@ class ve {
564
569
  callbacks;
565
570
  // Used to compute the range selection
566
571
  lastSelectedOption;
572
+ // Timeout tracking for cleanup
573
+ closeAnimationTimeout = null;
567
574
  // Elements
568
575
  main;
569
576
  content;
@@ -572,18 +579,35 @@ class ve {
572
579
  constructor(e, t, s, i) {
573
580
  this.store = s, this.settings = e, this.classes = t, this.callbacks = i, this.lastSelectedOption = null, this.main = this.mainDiv(), this.content = this.contentDiv(), this.updateClassStyles(), this.updateAriaAttributes(), this.settings.contentPosition !== "relative" && (this.content.main.style.top = "-9999px", this.content.main.style.left = "-9999px", this.content.main.style.margin = "0", this.content.main.style.width = "auto"), this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main);
574
581
  }
582
+ // Helper method to add classes that may contain spaces
583
+ // Splits by spaces and adds each class individually to avoid DOMException
584
+ addClasses(e, t) {
585
+ if (!t || t.trim() === "")
586
+ return;
587
+ const s = t.split(" ").filter((i) => i.trim() !== "");
588
+ for (const i of s)
589
+ e.classList.add(i.trim());
590
+ }
591
+ // Helper method to remove classes that may contain spaces
592
+ removeClasses(e, t) {
593
+ if (!t || t.trim() === "")
594
+ return;
595
+ const s = t.split(" ").filter((i) => i.trim() !== "");
596
+ for (const i of s)
597
+ e.classList.remove(i.trim());
598
+ }
575
599
  // Remove disabled classes
576
600
  enable() {
577
- this.main.main.classList.remove(this.classes.disabled), this.main.main.setAttribute("aria-disabled", "false"), this.content.search.input.disabled = !1;
601
+ this.removeClasses(this.main.main, this.classes.disabled), this.main.main.setAttribute("aria-disabled", "false"), this.content.search.input.disabled = !1;
578
602
  }
579
603
  // Set disabled classes
580
604
  disable() {
581
- this.main.main.classList.add(this.classes.disabled), this.main.main.setAttribute("aria-disabled", "true"), this.content.search.input.disabled = !0;
605
+ this.addClasses(this.main.main, this.classes.disabled), this.main.main.setAttribute("aria-disabled", "true"), this.content.search.input.disabled = !0;
582
606
  }
583
607
  open() {
584
- this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true");
608
+ this.main.arrow.path.setAttribute("d", this.classes.arrowOpen), this.main.main.setAttribute("aria-expanded", "true"), this.closeAnimationTimeout && (clearTimeout(this.closeAnimationTimeout), this.closeAnimationTimeout = null);
585
609
  const t = this.settings.openPosition === "up" ? this.classes.dirAbove : this.classes.dirBelow;
586
- this.main.main.classList.add(t), this.content.main.classList.add(t), this.content.main.classList.add(this.classes.contentOpen), this.content.search.input.removeAttribute("aria-hidden"), this.moveContent();
610
+ 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();
587
611
  const s = this.store.getSelectedOptions();
588
612
  if (s.length) {
589
613
  const i = s[s.length - 1].id, n = this.content.list.querySelector('[data-id="' + i + '"]');
@@ -591,12 +615,24 @@ class ve {
591
615
  }
592
616
  }
593
617
  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(() => {
595
- this.main.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow);
596
- }, 100);
618
+ this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.removeClasses(this.content.main, this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
619
+ const e = this.getAnimationTiming();
620
+ this.closeAnimationTimeout = setTimeout(() => {
621
+ this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow), this.removeClasses(this.content.main, this.classes.dirAbove), this.removeClasses(this.content.main, this.classes.dirBelow), this.closeAnimationTimeout = null;
622
+ }, e);
623
+ }
624
+ getAnimationTiming() {
625
+ const t = getComputedStyle(this.content.main).getPropertyValue("--ss-animation-timing").trim();
626
+ if (t) {
627
+ if (t.endsWith("ms"))
628
+ return parseFloat(t);
629
+ if (t.endsWith("s"))
630
+ return parseFloat(t) * 1e3;
631
+ }
632
+ return 200;
597
633
  }
598
634
  updateClassStyles() {
599
- 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)
635
+ if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.addClasses(this.main.main, this.classes.main), this.addClasses(this.content.main, this.classes.content), this.settings.style !== "" && (this.main.main.style.cssText = this.settings.style, this.content.main.style.cssText = this.settings.style), this.settings.class.length)
600
636
  for (const e of this.settings.class)
601
637
  e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
602
638
  (this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
@@ -618,7 +654,9 @@ class ve {
618
654
  case "Enter":
619
655
  case " ":
620
656
  this.callbacks.open();
621
- const o = this.content.list.querySelector("." + this.classes.highlighted);
657
+ const o = this.content.list.querySelector(
658
+ "." + this.classes.getFirst("highlighted")
659
+ );
622
660
  return o && o.click(), !1;
623
661
  case "Escape":
624
662
  return this.callbacks.close(), !1;
@@ -628,11 +666,11 @@ class ve {
628
666
  this.settings.disabled || (this.settings.isOpen ? this.callbacks.close() : this.callbacks.open());
629
667
  };
630
668
  const t = document.createElement("div");
631
- t.classList.add(this.classes.values), e.appendChild(t);
669
+ this.addClasses(t, this.classes.values), e.appendChild(t);
632
670
  const s = document.createElement("div");
633
- s.classList.add(this.classes.deselect);
671
+ this.addClasses(s, this.classes.deselect);
634
672
  const i = this.store?.getSelectedOptions();
635
- !this.settings.allowDeselect || this.settings.isMultiple && i && i.length <= 0 ? s.classList.add(this.classes.hide) : s.classList.remove(this.classes.hide), s.onclick = (h) => {
673
+ !this.settings.allowDeselect || this.settings.isMultiple && i && i.length <= 0 ? this.addClasses(s, this.classes.hide) : this.removeClasses(s, this.classes.hide), s.onclick = (h) => {
636
674
  if (h.stopPropagation(), this.settings.disabled)
637
675
  return;
638
676
  let o = !0;
@@ -641,8 +679,8 @@ class ve {
641
679
  if (this.settings.isMultiple)
642
680
  this.callbacks.setSelected([], !1), this.updateDeselectAll();
643
681
  else {
644
- const f = this.store.getFirstOption(), C = f ? f.id : "";
645
- this.callbacks.setSelected(C, !1);
682
+ const f = this.store.getFirstOption(), E = f ? f.id : "";
683
+ this.callbacks.setSelected(E, !1);
646
684
  }
647
685
  this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
648
686
  }
@@ -652,9 +690,9 @@ class ve {
652
690
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
653
691
  r.setAttribute("d", this.classes.deselectPath), n.appendChild(r), s.appendChild(n), e.appendChild(s);
654
692
  const a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
655
- a.classList.add(this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
693
+ this.addClasses(a, this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
656
694
  const c = document.createElementNS("http://www.w3.org/2000/svg", "path");
657
- return c.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && a.classList.add(this.classes.hide), a.appendChild(c), e.appendChild(a), {
695
+ return c.setAttribute("d", this.classes.arrowClose), this.settings.alwaysOpen && this.addClasses(a, this.classes.hide), a.appendChild(c), e.appendChild(a), {
658
696
  main: e,
659
697
  values: t,
660
698
  deselect: {
@@ -676,7 +714,7 @@ class ve {
676
714
  let t = this.settings.placeholderText;
677
715
  e.length && (e[0].html !== "" ? t = e[0].html : e[0].text !== "" && (t = e[0].text));
678
716
  const s = document.createElement("div");
679
- return s.classList.add(this.classes.placeholder), s.innerHTML = t, s;
717
+ return this.addClasses(s, this.classes.placeholder), s.innerHTML = t, s;
680
718
  }
681
719
  // Get selected values and append to multiSelected values container
682
720
  // and remove those who shouldnt exist
@@ -693,9 +731,9 @@ class ve {
693
731
  this.main.values.innerHTML = this.placeholder().outerHTML;
694
732
  else {
695
733
  const s = document.createElement("div");
696
- s.classList.add(this.classes.single), t.html ? s.innerHTML = t.html : s.innerText = t.text, this.main.values.innerHTML = s.outerHTML;
734
+ this.addClasses(s, this.classes.single), t.html ? s.innerHTML = t.html : s.innerText = t.text, this.main.values.innerHTML = s.outerHTML;
697
735
  }
698
- !this.settings.allowDeselect || !e.length ? this.main.deselect.main.classList.add(this.classes.hide) : this.main.deselect.main.classList.remove(this.classes.hide);
736
+ !this.settings.allowDeselect || !e.length ? this.addClasses(this.main.deselect.main, this.classes.hide) : this.removeClasses(this.main.deselect.main, this.classes.hide);
699
737
  }
700
738
  renderMultipleValues() {
701
739
  let e = this.main.values.childNodes, t = this.store.filter((i) => i.selected && i.display, !1);
@@ -703,15 +741,15 @@ class ve {
703
741
  this.main.values.innerHTML = this.placeholder().outerHTML;
704
742
  return;
705
743
  } else {
706
- const i = this.main.values.querySelector("." + this.classes.placeholder);
744
+ const i = this.main.values.querySelector("." + this.classes.getFirst("placeholder"));
707
745
  i && i.remove();
708
746
  }
709
747
  if (t.length > this.settings.maxValuesShown) {
710
748
  const i = document.createElement("div");
711
- i.classList.add(this.classes.max), i.textContent = this.settings.maxValuesMessage.replace("{number}", t.length.toString()), this.main.values.innerHTML = i.outerHTML;
749
+ this.addClasses(i, this.classes.max), i.textContent = this.settings.maxValuesMessage.replace("{number}", t.length.toString()), this.main.values.innerHTML = i.outerHTML;
712
750
  return;
713
751
  } else {
714
- const i = this.main.values.querySelector("." + this.classes.max);
752
+ const i = this.main.values.querySelector("." + this.classes.getFirst("max"));
715
753
  i && i.remove();
716
754
  }
717
755
  this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
@@ -721,7 +759,7 @@ class ve {
721
759
  r && (t.filter((c) => c.id === r, !1).length || s.push(n));
722
760
  }
723
761
  for (const i of s)
724
- i.classList.add(this.classes.valueOut), setTimeout(() => {
762
+ this.addClasses(i, this.classes.valueOut), setTimeout(() => {
725
763
  this.main.values.hasChildNodes() && this.main.values.contains(i) && this.main.values.removeChild(i);
726
764
  }, 100);
727
765
  e = this.main.values.childNodes;
@@ -734,11 +772,11 @@ class ve {
734
772
  }
735
773
  multipleValue(e) {
736
774
  const t = document.createElement("div");
737
- t.classList.add(this.classes.value), t.dataset.id = e.id;
775
+ this.addClasses(t, this.classes.value), t.dataset.id = e.id;
738
776
  const s = document.createElement("div");
739
- if (s.classList.add(this.classes.valueText), s.textContent = e.text, t.appendChild(s), !e.mandatory) {
777
+ if (this.addClasses(s, this.classes.valueText), s.textContent = e.text, t.appendChild(s), !e.mandatory) {
740
778
  const i = document.createElement("div");
741
- i.classList.add(this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (a) => {
779
+ this.addClasses(i, this.classes.valueDelete), i.setAttribute("tabindex", "0"), i.onclick = (a) => {
742
780
  if (a.preventDefault(), a.stopPropagation(), this.settings.disabled)
743
781
  return;
744
782
  let c = !0;
@@ -749,7 +787,7 @@ class ve {
749
787
  if (g instanceof x)
750
788
  for (const f of g.options)
751
789
  f.id && d.push(f.id);
752
- g instanceof S && d.push(g.id);
790
+ g instanceof w && d.push(g.id);
753
791
  }
754
792
  this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(o), this.updateDeselectAll();
755
793
  }
@@ -791,12 +829,12 @@ class ve {
791
829
  }
792
830
  searchDiv() {
793
831
  const e = document.createElement("div"), t = document.createElement("input"), s = document.createElement("div");
794
- e.classList.add(this.classes.search);
832
+ this.addClasses(e, this.classes.search);
795
833
  const i = {
796
834
  main: e,
797
835
  input: t
798
836
  };
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) => {
837
+ 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 = H((n) => {
800
838
  this.callbacks.search(n.target.value);
801
839
  }, 100), t.onkeydown = (n) => {
802
840
  switch (n.key) {
@@ -809,15 +847,19 @@ class ve {
809
847
  case "Escape":
810
848
  return this.callbacks.close(), !1;
811
849
  case " ":
812
- const r = this.content.list.querySelector("." + this.classes.highlighted);
850
+ const r = this.content.list.querySelector(
851
+ "." + this.classes.getFirst("highlighted")
852
+ );
813
853
  return r ? (r.click(), !1) : !0;
814
854
  case "Enter":
815
- const a = this.content.list.querySelector("." + this.classes.highlighted);
855
+ const a = this.content.list.querySelector(
856
+ "." + this.classes.getFirst("highlighted")
857
+ );
816
858
  return a ? (a.click(), !1) : this.callbacks.addable ? (s.click(), !1) : !0;
817
859
  }
818
860
  return !0;
819
861
  }, e.appendChild(t), this.callbacks.addable) {
820
- s.classList.add(this.classes.addable);
862
+ this.addClasses(s, this.classes.addable);
821
863
  const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
822
864
  n.setAttribute("viewBox", "0 0 100 100");
823
865
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
@@ -830,7 +872,7 @@ class ve {
830
872
  return;
831
873
  }
832
874
  const h = (d) => {
833
- let g = new S(d);
875
+ let g = new w(d);
834
876
  if (this.callbacks.addOption(g), this.settings.isMultiple) {
835
877
  let f = this.store.getSelected();
836
878
  f.push(g.id), this.callbacks.setSelected(f, !0);
@@ -858,78 +900,80 @@ class ve {
858
900
  return i;
859
901
  }
860
902
  searchFocus() {
861
- this.content.search.input.focus();
903
+ this.content.search.input.focus({ preventScroll: !0 });
862
904
  }
863
905
  getOptions(e = !1, t = !1, s = !1) {
864
- let i = "." + this.classes.option;
865
- return e && (i += ":not(." + this.classes.placeholder + ")"), t && (i += ":not(." + this.classes.disabled + ")"), s && (i += ":not(." + this.classes.hide + ")"), Array.from(this.content.list.querySelectorAll(i));
906
+ let i = "." + this.classes.getFirst("option");
907
+ return e && (i += ":not(." + this.classes.getFirst("placeholder") + ")"), t && (i += ":not(." + this.classes.getFirst("disabled") + ")"), s && (i += ":not(." + this.classes.getFirst("hide") + ")"), Array.from(this.content.list.querySelectorAll(i));
866
908
  }
867
909
  // highlightUp is used to highlight the previous option in the list
868
910
  highlight(e) {
869
911
  const t = this.getOptions(!0, !0, !0);
870
912
  if (t.length === 0)
871
913
  return;
872
- if (t.length === 1 && !t[0].classList.contains(this.classes.highlighted)) {
873
- t[0].classList.add(this.classes.highlighted);
914
+ if (t.length === 1 && !t[0].classList.contains(this.classes.getFirst("highlighted"))) {
915
+ this.addClasses(t[0], this.classes.highlighted);
874
916
  return;
875
917
  }
876
918
  let s = !1;
877
919
  for (const n of t)
878
- n.classList.contains(this.classes.highlighted) && (s = !0);
920
+ n.classList.contains(this.classes.getFirst("highlighted")) && (s = !0);
879
921
  if (!s) {
880
922
  for (const n of t)
881
- if (n.classList.contains(this.classes.selected)) {
882
- n.classList.add(this.classes.highlighted);
923
+ if (n.classList.contains(this.classes.getFirst("selected"))) {
924
+ this.addClasses(n, this.classes.highlighted);
883
925
  break;
884
926
  }
885
927
  }
886
928
  for (let n = 0; n < t.length; n++)
887
- if (t[n].classList.contains(this.classes.highlighted)) {
929
+ if (t[n].classList.contains(this.classes.getFirst("highlighted"))) {
888
930
  const r = t[n];
889
- r.classList.remove(this.classes.highlighted);
931
+ this.removeClasses(r, this.classes.highlighted);
890
932
  const a = r.parentElement;
891
- if (a && a.classList.contains(this.classes.mainOpen)) {
892
- const o = a.querySelector("." + this.classes.optgroupLabel);
933
+ if (a && a.classList.contains(this.classes.getFirst("mainOpen"))) {
934
+ const o = a.querySelector("." + this.classes.getFirst("optgroupLabel"));
893
935
  o && o.click();
894
936
  }
895
937
  let c = t[e === "down" ? n + 1 < t.length ? n + 1 : 0 : n - 1 >= 0 ? n - 1 : t.length - 1];
896
- c.classList.add(this.classes.highlighted), this.ensureElementInView(this.content.list, c), c.id && this.main.main.setAttribute("aria-activedescendant", c.id);
938
+ this.addClasses(c, this.classes.highlighted), this.ensureElementInView(this.content.list, c), c.id && this.main.main.setAttribute("aria-activedescendant", c.id);
897
939
  const h = c.parentElement;
898
- if (h && h.classList.contains(this.classes.close)) {
899
- const o = h.querySelector("." + this.classes.optgroupLabel);
940
+ if (h && h.classList.contains(this.classes.getFirst("close"))) {
941
+ const o = h.querySelector(
942
+ "." + this.classes.getFirst("optgroupLabel")
943
+ );
900
944
  o && o.click();
901
945
  }
902
946
  return;
903
947
  }
904
948
  const i = t[e === "down" ? 0 : t.length - 1];
905
- i.classList.add(this.classes.highlighted), i.id && this.main.main.setAttribute("aria-activedescendant", i.id), this.ensureElementInView(this.content.list, i);
949
+ this.addClasses(i, this.classes.highlighted), i.id && this.main.main.setAttribute("aria-activedescendant", i.id), this.ensureElementInView(this.content.list, i);
906
950
  }
907
951
  // Create main container that options will reside
908
952
  listDiv() {
909
953
  const e = document.createElement("div");
910
- e.classList.add(this.classes.list);
954
+ this.addClasses(e, this.classes.list);
911
955
  const t = this.settings.id + "-list";
912
956
  return e.id = t, e.dataset.id = t, e;
913
957
  }
914
958
  renderError(e) {
915
959
  this.content.list.innerHTML = "";
916
960
  const t = document.createElement("div");
917
- t.classList.add(this.classes.error), t.textContent = e, this.content.list.appendChild(t);
961
+ this.addClasses(t, this.classes.error), t.textContent = e, this.content.list.appendChild(t);
918
962
  }
919
963
  renderSearching() {
920
964
  this.content.list.innerHTML = "";
921
965
  const e = document.createElement("div");
922
- e.classList.add(this.classes.searching), e.textContent = this.settings.searchingText, this.content.list.appendChild(e);
966
+ this.addClasses(e, this.classes.searching), e.textContent = this.settings.searchingText, this.content.list.appendChild(e);
923
967
  }
924
968
  // Take in data and add options to
925
969
  renderOptions(e) {
926
970
  if (this.content.list.innerHTML = "", e.length === 0) {
927
971
  const s = document.createElement("div");
928
- s.classList.add(this.classes.search), this.callbacks.addable ? s.innerHTML = this.settings.addableText.replace("{value}", this.content.search.input.value) : s.innerHTML = this.settings.searchText, this.content.list.appendChild(s);
972
+ this.addClasses(s, this.classes.search), this.callbacks.addable ? s.innerHTML = this.settings.addableText.replace("{value}", this.content.search.input.value) : s.innerHTML = this.settings.searchText, this.content.list.appendChild(s);
929
973
  return;
930
974
  }
931
975
  this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((i) => i.placeholder, !1).length || this.store.addOption(
932
- new S({
976
+ new w({
933
977
  text: "",
934
978
  value: "",
935
979
  selected: !1,
@@ -941,22 +985,22 @@ class ve {
941
985
  for (const s of e) {
942
986
  if (s instanceof x) {
943
987
  const i = document.createElement("div");
944
- i.classList.add(this.classes.optgroup);
988
+ this.addClasses(i, this.classes.optgroup);
945
989
  const n = document.createElement("div");
946
- n.classList.add(this.classes.optgroupLabel), i.appendChild(n);
990
+ this.addClasses(n, this.classes.optgroupLabel), i.appendChild(n);
947
991
  const r = document.createElement("div");
948
- r.classList.add(this.classes.optgroupLabelText), r.textContent = s.label, n.appendChild(r);
992
+ this.addClasses(r, this.classes.optgroupLabelText), r.textContent = s.label, n.appendChild(r);
949
993
  const a = document.createElement("div");
950
- if (a.classList.add(this.classes.optgroupActions), n.appendChild(a), this.settings.isMultiple && s.selectAll) {
994
+ if (this.addClasses(a, this.classes.optgroupActions), n.appendChild(a), this.settings.isMultiple && s.selectAll) {
951
995
  const c = document.createElement("div");
952
- c.classList.add(this.classes.optgroupSelectAll);
996
+ this.addClasses(c, this.classes.optgroupSelectAll);
953
997
  let h = !0;
954
- for (const C of s.options)
955
- if (!C.selected) {
998
+ for (const E of s.options)
999
+ if (!E.selected) {
956
1000
  h = !1;
957
1001
  break;
958
1002
  }
959
- h && c.classList.add(this.classes.selected);
1003
+ h && this.addClasses(c, this.classes.selected);
960
1004
  const o = document.createElement("span");
961
1005
  o.textContent = s.selectAllText, c.appendChild(o);
962
1006
  const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@@ -964,43 +1008,43 @@ class ve {
964
1008
  const g = document.createElementNS("http://www.w3.org/2000/svg", "path");
965
1009
  g.setAttribute("d", this.classes.optgroupSelectAllBox), d.appendChild(g);
966
1010
  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) => {
968
- C.preventDefault(), C.stopPropagation();
1011
+ f.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(f), c.addEventListener("click", (E) => {
1012
+ E.preventDefault(), E.stopPropagation();
969
1013
  const m = this.store.getSelected();
970
1014
  if (h) {
971
- const L = m.filter((O) => {
1015
+ const A = m.filter((S) => {
972
1016
  for (const v of s.options)
973
- if (O === v.id)
1017
+ if (S === v.id)
974
1018
  return !1;
975
1019
  return !0;
976
1020
  });
977
- this.callbacks.setSelected(L, !0);
1021
+ this.callbacks.setSelected(A, !0);
978
1022
  return;
979
1023
  } else {
980
- let L = s.options.map((v) => v.id).filter((v) => v !== void 0);
981
- const O = m.concat(L);
1024
+ let A = s.options.map((v) => v.id).filter((v) => v !== void 0);
1025
+ const S = m.concat(A);
982
1026
  for (const v of s.options)
983
- v.id && !this.store.getOptionByID(v.id) && this.callbacks.addOption(new S(v));
984
- this.callbacks.setSelected(O, !0);
1027
+ v.id && !this.store.getOptionByID(v.id) && this.callbacks.addOption(new w(v));
1028
+ this.callbacks.setSelected(S, !0);
985
1029
  return;
986
1030
  }
987
1031
  }), a.appendChild(c);
988
1032
  }
989
1033
  if (s.closable !== "off") {
990
1034
  const c = document.createElement("div");
991
- c.classList.add(this.classes.optgroupClosable);
1035
+ this.addClasses(c, this.classes.optgroupClosable);
992
1036
  const h = document.createElementNS("http://www.w3.org/2000/svg", "svg");
993
- h.setAttribute("viewBox", "0 0 100 100"), h.classList.add(this.classes.arrow), c.appendChild(h);
1037
+ h.setAttribute("viewBox", "0 0 100 100"), this.addClasses(h, this.classes.arrow), c.appendChild(h);
994
1038
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
995
- h.appendChild(o), s.options.some((d) => d.selected) || this.content.search.input.value.trim() !== "" ? (c.classList.add(this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : s.closable === "open" ? (i.classList.add(this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : s.closable === "close" && (i.classList.add(this.classes.close), o.setAttribute("d", this.classes.arrowClose)), n.addEventListener("click", (d) => {
996
- d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.close) ? (i.classList.remove(this.classes.close), i.classList.add(this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : (i.classList.remove(this.classes.mainOpen), i.classList.add(this.classes.close), o.setAttribute("d", this.classes.arrowClose));
1039
+ h.appendChild(o), s.options.some((d) => d.selected) || this.content.search.input.value.trim() !== "" ? (this.addClasses(c, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : s.closable === "open" ? (this.addClasses(i, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : s.closable === "close" && (this.addClasses(i, this.classes.close), o.setAttribute("d", this.classes.arrowClose)), n.addEventListener("click", (d) => {
1040
+ d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.getFirst("close")) ? (this.removeClasses(i, this.classes.close), this.addClasses(i, this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : (this.removeClasses(i, this.classes.mainOpen), this.addClasses(i, this.classes.close), o.setAttribute("d", this.classes.arrowClose));
997
1041
  }), a.appendChild(c);
998
1042
  }
999
1043
  i.appendChild(n);
1000
1044
  for (const c of s.options)
1001
- i.appendChild(this.option(new S(c))), t.appendChild(i);
1045
+ i.appendChild(this.option(new w(c))), t.appendChild(i);
1002
1046
  }
1003
- s instanceof S && t.appendChild(this.option(s));
1047
+ s instanceof w && t.appendChild(this.option(s));
1004
1048
  }
1005
1049
  this.content.list.appendChild(t);
1006
1050
  }
@@ -1008,16 +1052,16 @@ class ve {
1008
1052
  option(e) {
1009
1053
  if (e.placeholder) {
1010
1054
  const s = document.createElement("div");
1011
- return s.classList.add(this.classes.option), s.classList.add(this.classes.hide), s;
1055
+ return this.addClasses(s, this.classes.option), this.addClasses(s, this.classes.hide), s;
1012
1056
  }
1013
1057
  const t = document.createElement("div");
1014
- return t.dataset.id = e.id, t.id = this.settings.id + "-" + e.id, t.classList.add(this.classes.option), t.setAttribute("role", "option"), e.class && e.class.split(" ").forEach((s) => {
1058
+ return t.dataset.id = e.id, t.id = this.settings.id + "-" + e.id, this.addClasses(t, this.classes.option), t.setAttribute("role", "option"), e.class && e.class.split(" ").forEach((s) => {
1015
1059
  t.classList.add(s);
1016
1060
  }), e.style && (t.style.cssText = e.style), this.settings.searchHighlight && this.content.search.input.value.trim() !== "" ? t.innerHTML = this.highlightText(
1017
1061
  e.html !== "" ? e.html : e.text,
1018
1062
  this.content.search.input.value,
1019
1063
  this.classes.searchHighlighter
1020
- ) : e.html !== "" ? t.innerHTML = e.html : t.textContent = e.text, this.settings.showOptionTooltips && t.textContent && t.setAttribute("title", t.textContent), e.display || t.classList.add(this.classes.hide), e.disabled && t.classList.add(this.classes.disabled), e.selected && this.settings.hideSelected && t.classList.add(this.classes.hide), e.selected ? (t.classList.add(this.classes.selected), t.setAttribute("aria-selected", "true"), this.main.main.setAttribute("aria-activedescendant", t.id)) : (t.classList.remove(this.classes.selected), t.setAttribute("aria-selected", "false")), t.addEventListener("click", (s) => {
1064
+ ) : 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) => {
1021
1065
  s.preventDefault(), s.stopPropagation();
1022
1066
  const i = this.store.getSelected(), n = s.currentTarget, r = String(n.dataset.id), a = s.ctrlKey || s.metaKey;
1023
1067
  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)
@@ -1028,10 +1072,10 @@ class ve {
1028
1072
  if (this.settings.isMultiple) {
1029
1073
  const d = h.some((f) => f.id === r);
1030
1074
  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);
1032
- 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));
1034
- h.length + T.length <= this.settings.maxSelected ? o = h.concat(T) : o = h;
1075
+ const f = this.store.getDataOptions(), E = f.findIndex((A) => A.id === this.lastSelectedOption.id), m = f.findIndex((A) => A.id === e.id);
1076
+ if (E >= 0 && m >= 0) {
1077
+ const A = Math.min(E, m), S = Math.max(E, m), k = f.slice(A, S + 1).filter((L) => !h.find((b) => b.id === L.id));
1078
+ h.length + k.length <= this.settings.maxSelected ? o = h.concat(k) : o = h;
1035
1079
  } else
1036
1080
  o = h;
1037
1081
  } 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);
@@ -1047,7 +1091,7 @@ class ve {
1047
1091
  }), t;
1048
1092
  }
1049
1093
  destroy() {
1050
- this.main.main.remove(), this.content.main.remove();
1094
+ this.closeAnimationTimeout && (clearTimeout(this.closeAnimationTimeout), this.closeAnimationTimeout = null), this.main.main.remove(), this.content.main.remove();
1051
1095
  }
1052
1096
  highlightText(e, t, s) {
1053
1097
  const i = t.trim();
@@ -1060,7 +1104,7 @@ class ve {
1060
1104
  const h = c.textContent || "", o = new RegExp("(" + n + ")", "i");
1061
1105
  if (o.test(h)) {
1062
1106
  const d = document.createElement("span");
1063
- h.split(o).forEach((f, C) => {
1107
+ h.split(o).forEach((f, E) => {
1064
1108
  if (f && o.test(f)) {
1065
1109
  const m = document.createElement("mark");
1066
1110
  m.className = s, m.textContent = f, d.appendChild(m);
@@ -1071,16 +1115,32 @@ class ve {
1071
1115
  };
1072
1116
  return Array.from(r.childNodes).forEach((c) => a(c)), r.innerHTML;
1073
1117
  }
1118
+ setContentDirection(e) {
1119
+ const t = e === "above", s = t ? this.classes.dirAbove : this.classes.dirBelow, i = t ? this.classes.dirBelow : this.classes.dirAbove;
1120
+ 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) {
1121
+ const n = this.main.main.offsetHeight, r = this.content.main.offsetHeight;
1122
+ this.content.main.style.margin = "-" + (n + r - 1) + "px 0px 0px 0px";
1123
+ } else
1124
+ this.content.main.style.margin = "-1px 0px 0px 0px";
1125
+ }
1126
+ setContentPosition() {
1127
+ if (this.settings.contentPosition === "relative")
1128
+ return;
1129
+ const e = this.main.main.getBoundingClientRect();
1130
+ let t, s;
1131
+ if (this.settings.contentPosition === "fixed")
1132
+ t = e.top + e.height, s = e.left;
1133
+ else {
1134
+ const i = this.content.main.offsetParent, n = i ? i.getBoundingClientRect() : { top: 0, left: 0 };
1135
+ t = e.top - n.top + e.height - (i?.clientTop || 0), s = e.left - n.left - (i?.clientLeft || 0);
1136
+ }
1137
+ this.content.main.style.top = t + "px", this.content.main.style.left = s + "px", this.content.main.style.width = e.width + "px";
1138
+ }
1074
1139
  moveContentAbove() {
1075
- const e = this.main.main.offsetHeight, t = this.content.main.offsetHeight;
1076
- this.main.main.classList.remove(this.classes.dirBelow), this.main.main.classList.add(this.classes.dirAbove), this.content.main.classList.remove(this.classes.dirBelow), this.content.main.classList.add(this.classes.dirAbove);
1077
- const s = this.main.main.getBoundingClientRect();
1078
- this.content.main.style.margin = "-" + (e + t - 1) + "px 0px 0px 0px", this.content.main.style.top = s.top + s.height + (this.settings.contentPosition === "fixed" ? 0 : window.scrollY) + "px", this.content.main.style.left = s.left + (this.settings.contentPosition === "fixed" ? 0 : window.scrollX) + "px", this.content.main.style.width = s.width + "px";
1140
+ this.setContentDirection("above"), this.setContentPosition();
1079
1141
  }
1080
1142
  moveContentBelow() {
1081
- this.main.main.classList.remove(this.classes.dirAbove), this.main.main.classList.add(this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove), this.content.main.classList.add(this.classes.dirBelow);
1082
- const e = this.main.main.getBoundingClientRect();
1083
- this.content.main.style.margin = "-1px 0px 0px 0px", this.settings.contentPosition !== "relative" && (this.content.main.style.top = e.top + e.height + (this.settings.contentPosition === "fixed" ? 0 : window.scrollY) + "px", this.content.main.style.left = e.left + (this.settings.contentPosition === "fixed" ? 0 : window.scrollX) + "px", this.content.main.style.width = e.width + "px");
1143
+ this.setContentDirection("below"), this.setContentPosition();
1084
1144
  }
1085
1145
  ensureElementInView(e, t) {
1086
1146
  const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, n = t.offsetTop, r = n + t.clientHeight;
@@ -1095,7 +1155,7 @@ class ve {
1095
1155
  if (!this.store || !this.settings)
1096
1156
  return;
1097
1157
  const e = this.store.getSelectedOptions(), t = e && e.length > 0, s = this.settings.isMultiple, i = this.settings.allowDeselect, n = this.main.deselect.main, r = this.classes.hide;
1098
- i && !(s && !t) ? n.classList.remove(r) : n.classList.add(r);
1158
+ i && !(s && !t) ? this.removeClasses(n, r) : this.addClasses(n, r);
1099
1159
  }
1100
1160
  }
1101
1161
  class be {
@@ -1157,28 +1217,30 @@ class be {
1157
1217
  observeCall(e) {
1158
1218
  if (!this.listen)
1159
1219
  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"));
1220
+ let t = !1, s = !1, i = !1, n = !1;
1221
+ for (const r of e) {
1222
+ if (r.target === this.select && (r.attributeName === "disabled" && (s = !0), r.attributeName === "class" && (t = !0), r.type === "childList")) {
1223
+ for (const a of Array.from(r.addedNodes))
1224
+ if (a.nodeName === "OPTION" && a.value === this.select.value) {
1225
+ n = !0;
1166
1226
  break;
1167
1227
  }
1168
1228
  i = !0;
1169
1229
  }
1170
- (n.target.nodeName === "OPTGROUP" || n.target.nodeName === "OPTION") && (i = !0);
1230
+ (r.target.nodeName === "OPTGROUP" || r.target.nodeName === "OPTION") && (i = !0);
1171
1231
  }
1172
1232
  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
1233
  if (this.isUpdating) {
1174
1234
  if (this.select.options.length > 0) {
1175
- const n = this.getData();
1176
- n.length > 0 && (this.pendingOptionsChange = n);
1235
+ const r = this.getData();
1236
+ r.length > 0 && (this.pendingOptionsChange = r);
1177
1237
  }
1238
+ n && this.select.dispatchEvent(new Event("change"));
1178
1239
  return;
1179
1240
  }
1180
1241
  this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
1181
1242
  }
1243
+ n && this.select.dispatchEvent(new Event("change"));
1182
1244
  }
1183
1245
  // From the select element pull optgroup and options into data
1184
1246
  getData() {
@@ -1293,7 +1355,7 @@ class be {
1293
1355
  if (!(!e || e.length === 0)) {
1294
1356
  this.isUpdating = !0, this.pendingOptionsChange = null, this.changeListen(!1), this.select.innerHTML = "";
1295
1357
  for (const t of e)
1296
- t instanceof x && this.select.appendChild(this.createOptgroup(t)), t instanceof S && this.select.appendChild(this.createOption(t));
1358
+ t instanceof x && this.select.appendChild(this.createOptgroup(t)), t instanceof w && this.select.appendChild(this.createOption(t));
1297
1359
  if (this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0), this.isUpdating = !1, this.pendingOptionsChange !== null) {
1298
1360
  const t = this.pendingOptionsChange;
1299
1361
  t.length > 0 && this.onOptionsChange ? (this.pendingOptionsChange = null, this.changeListen(!1), this.onOptionsChange(t), this.changeListen(!0)) : this.pendingOptionsChange = null;
@@ -1331,7 +1393,8 @@ class be {
1331
1393
  if (n.__slimSelectLabelHandler)
1332
1394
  return;
1333
1395
  const r = (a) => {
1334
- a.target === n && (a.preventDefault(), this.onLabelClick && this.onLabelClick());
1396
+ const c = a.target, h = ie(c, this.select.dataset.id);
1397
+ a.preventDefault(), !h && this.onLabelClick && this.onLabelClick();
1335
1398
  };
1336
1399
  n.__slimSelectLabelHandler = r, n.addEventListener("click", r, { capture: !0, passive: !1 });
1337
1400
  });
@@ -1357,7 +1420,7 @@ class be {
1357
1420
  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();
1358
1421
  }
1359
1422
  }
1360
- class we {
1423
+ class Ce {
1361
1424
  id = "";
1362
1425
  // Primary ID for the select
1363
1426
  style = "";
@@ -1374,6 +1437,7 @@ class we {
1374
1437
  alwaysOpen;
1375
1438
  showSearch;
1376
1439
  focusSearch;
1440
+ keepSearch;
1377
1441
  ariaLabel;
1378
1442
  searchPlaceholder;
1379
1443
  searchText;
@@ -1395,10 +1459,10 @@ class we {
1395
1459
  maxValuesMessage;
1396
1460
  addableText;
1397
1461
  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}';
1462
+ 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
1463
  }
1400
1464
  }
1401
- let Se = class {
1465
+ let we = class {
1402
1466
  selectEl;
1403
1467
  // Classes
1404
1468
  settings;
@@ -1430,7 +1494,7 @@ let Se = class {
1430
1494
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1431
1495
  return;
1432
1496
  }
1433
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new we(e.settings), this.cssClasses = new fe(e.cssClasses);
1497
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new Ce(e.settings), this.cssClasses = new pe(e.cssClasses);
1434
1498
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1435
1499
  for (const a in e.events)
1436
1500
  e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = H(e.events[a], 100) : this.events[a] = e.events[a]);
@@ -1480,7 +1544,7 @@ let Se = class {
1480
1544
  }
1481
1545
  this.store.setData(e);
1482
1546
  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());
1547
+ 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
1548
  }
1485
1549
  getSelected() {
1486
1550
  let e = this.store.getSelectedOptions();
@@ -1501,21 +1565,21 @@ let Se = class {
1501
1565
  }
1502
1566
  this.store.setSelectedBy("id", n);
1503
1567
  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());
1568
+ 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
1569
  }
1506
1570
  addOption(e) {
1507
1571
  const t = this.store.getSelected();
1508
1572
  this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1509
1573
  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());
1574
+ 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
1575
  }
1512
1576
  open() {
1513
- 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(() => {
1577
+ this.settings.disabled || this.settings.isOpen || (this.closeTimeout && (clearTimeout(this.closeTimeout), this.closeTimeout = null), this.events.beforeOpen && this.events.beforeOpen(), this.render.open(), this.settings.showSearch && this.settings.focusSearch && this.render.searchFocus(), this.settings.isOpen = !0, this.openTimeout = setTimeout(() => {
1514
1578
  this.events.afterOpen && this.events.afterOpen(), this.settings.isOpen && (this.settings.isFullOpen = !0), document.addEventListener("click", this.documentClick);
1515
1579
  }, 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
1580
  }
1517
1581
  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(() => {
1582
+ !this.settings.isOpen || this.settings.alwaysOpen || (this.openTimeout && (clearTimeout(this.openTimeout), this.openTimeout = null), this.events.beforeClose && this.events.beforeClose(), this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
1519
1583
  this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
1520
1584
  }, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
1521
1585
  }
@@ -1553,24 +1617,24 @@ let Se = class {
1553
1617
  });
1554
1618
  // Event listener for document click
1555
1619
  documentClick = (e) => {
1556
- this.settings.isOpen && e.target && !pe(e.target, this.settings.id) && this.close(e.type);
1620
+ this.settings.isOpen && e.target && !ie(e.target, this.settings.id) && this.close(e.type);
1557
1621
  };
1558
1622
  // Event Listener for window visibility change
1559
1623
  windowVisibilityChange = () => {
1560
1624
  document.hidden && this.close();
1561
1625
  };
1562
1626
  };
1563
- const Oe = re(
1627
+ const Se = oe(
1564
1628
  ({ data: p, settings: e, events: t, cssClasses: s, value: i, onChange: n, children: r, multiple: a }, c) => {
1565
- const h = V(null), o = V(null), d = V(!0), g = V(i);
1566
- oe(c, () => ({
1629
+ const h = I(null), o = I(null), d = I(!0), g = I(i);
1630
+ ce(c, () => ({
1567
1631
  slimSelect: o.current
1568
1632
  }));
1569
- const f = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", C = (m, L = !1) => {
1633
+ const f = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", E = (m, A = !1) => {
1570
1634
  if (!o.current || m === void 0)
1571
1635
  return;
1572
- const O = f(m), T = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
1573
- 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)) {
1636
+ const S = f(m), k = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
1637
+ if (!(Array.isArray(S) ? S.length > 0 && S.every((b) => k.some((D) => D.value === b)) : S !== "" && k.some((b) => b.value === S)) && !Array.isArray(S) && !k.some((D) => D.placeholder)) {
1574
1638
  const D = o.current.getData(), P = {
1575
1639
  value: "",
1576
1640
  text: "",
@@ -1578,42 +1642,42 @@ const Oe = re(
1578
1642
  };
1579
1643
  o.current.setData([P].concat(D));
1580
1644
  }
1581
- o.current.setSelected(O, L);
1645
+ o.current.setSelected(S, A);
1582
1646
  };
1583
- return $(() => {
1647
+ return Y(() => {
1584
1648
  if (!h.current) return;
1585
1649
  const m = {
1586
1650
  select: h.current
1587
1651
  };
1588
1652
  p && (m.data = p), e && (m.settings = e), s && (m.cssClasses = s);
1589
- const L = t?.afterChange;
1653
+ const A = t?.afterChange;
1590
1654
  return m.events = {
1591
1655
  ...t,
1592
- afterChange: (O) => {
1656
+ afterChange: (S) => {
1593
1657
  if (!o.current) return;
1594
- const v = a ? O.map((A) => A.value) : O[0]?.value ?? "", k = o.current.getData().flatMap(
1595
- (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);
1658
+ const v = a ? S.map((T) => T.value) : S[0]?.value ?? "", L = o.current.getData().flatMap(
1659
+ (T) => "label" in T ? T.options : [T]
1660
+ ), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((T) => L.some((M) => M.value === T)) : b !== "" && L.some((T) => T.value === b), P = Array.isArray(v) ? v.length > 0 && v.every((T) => L.some((M) => M.value === T)) : v !== "" && L.some((T) => T.value === v), B = Array.isArray(v) && Array.isArray(b) ? JSON.stringify(v.sort()) !== JSON.stringify(b.sort()) : b !== v;
1661
+ n && B && (D || P) && (n(v), g.current = v), A && A(S);
1598
1662
  }
1599
- }, o.current = new Se(m), i !== void 0 && C(i, !1), () => {
1663
+ }, o.current = new we(m), i !== void 0 && E(i, !1), () => {
1600
1664
  o.current && (o.current.destroy(), o.current = null);
1601
1665
  };
1602
- }, []), $(() => {
1666
+ }, []), Y(() => {
1603
1667
  if (d.current) {
1604
1668
  d.current = !1, g.current = i;
1605
1669
  return;
1606
1670
  }
1607
- o.current && i !== void 0 && (g.current = i, C(i, !1));
1608
- }, [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 });
1671
+ o.current && i !== void 0 && (g.current = i, E(i, !1));
1672
+ }, [i]), Y(() => {
1673
+ o.current && p && !d.current && (o.current.setData(p), i !== void 0 && E(i, !1));
1674
+ }, [p]), /* @__PURE__ */ fe.jsx("select", { ref: h, multiple: a, children: r });
1611
1675
  }
1612
1676
  );
1613
- Oe.displayName = "SlimSelect";
1677
+ Se.displayName = "SlimSelect";
1614
1678
  export {
1615
1679
  x as Optgroup,
1616
- S as Option,
1617
- we as Settings,
1618
- Oe as default
1680
+ w as Option,
1681
+ Ce as Settings,
1682
+ Se as default
1619
1683
  };