slim-select 3.2.0 → 3.4.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,10 +1,10 @@
1
- import ae, { forwardRef as re, useRef as V, useImperativeHandle as oe, useEffect as $ } from "react";
2
- var F = { exports: {} }, R = {};
1
+ import re, { forwardRef as oe, useRef as I, useImperativeHandle as ce, useEffect as $ } 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
- var f = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
7
+ var p = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ 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: f,
16
+ $$typeof: p,
17
17
  type: s,
18
18
  key: r,
19
19
  ref: i !== void 0 ? i : null,
@@ -24,19 +24,19 @@ function ce() {
24
24
  }
25
25
  var _ = {};
26
26
  var te;
27
- function he() {
28
- return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
29
- function f(l) {
27
+ function de() {
28
+ return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
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,19 +51,19 @@ 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 H:
62
- return u = l.displayName || null, u !== null ? u : f(l.type) || "Memo";
63
- case A:
61
+ case B:
62
+ return u = l.displayName || null, u !== null ? u : p(l.type) || "Memo";
63
+ case T:
64
64
  u = l._payload, l = l._init;
65
65
  try {
66
- return f(l(u));
66
+ return p(l(u));
67
67
  } catch {
68
68
  }
69
69
  }
@@ -81,20 +81,20 @@ 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
- var u = f(l);
97
+ var u = p(l);
98
98
  return u ? "<" + u + ">" : "<...>";
99
99
  } catch {
100
100
  return "<...>";
@@ -115,32 +115,32 @@ 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
  }
129
129
  function c() {
130
- var l = f(this.type);
130
+ var l = p(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;
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,100 +165,100 @@ 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 = f(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 W in u)
202
+ W !== "key" && (C[W] = u[W]);
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 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() {
222
+ var f = re, E = /* @__PURE__ */ Symbol.for("react.transitional.element"), m = /* @__PURE__ */ Symbol.for("react.portal"), A = /* @__PURE__ */ Symbol.for("react.fragment"), S = /* @__PURE__ */ Symbol.for("react.strict_mode"), v = /* @__PURE__ */ Symbol.for("react.profiler"), k = /* @__PURE__ */ Symbol.for("react.consumer"), L = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), D = /* @__PURE__ */ Symbol.for("react.suspense"), P = /* @__PURE__ */ Symbol.for("react.suspense_list"), B = /* @__PURE__ */ Symbol.for("react.memo"), T = /* @__PURE__ */ Symbol.for("react.lazy"), M = /* @__PURE__ */ Symbol.for("react.activity"), ne = /* @__PURE__ */ 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
- p = {
225
+ f = {
226
226
  react_stack_bottom_frame: function(l) {
227
227
  return l();
228
228
  }
229
229
  };
230
- var G, X = {}, K = p.react_stack_bottom_frame.bind(
231
- p,
230
+ var G, X = {}, K = f.react_stack_bottom_frame.bind(
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" ? F.exports = ce() : F.exports = he()), F.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();
261
+ var fe = ue();
262
262
  class pe {
263
263
  main;
264
264
  // Placeholder
@@ -320,38 +320,43 @@ class pe {
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
331
  function z() {
327
332
  return Math.random().toString(36).substring(2, 10);
328
333
  }
329
- function fe(f, 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
  }
333
338
  function s(i, n) {
334
339
  return !i || i === document ? null : t(i, n) ? i : s(i.parentNode, n);
335
340
  }
336
- return t(f, e) || s(f, e);
341
+ return t(p, e) || s(p, e);
337
342
  }
338
- function B(f, e = 50, t = !1) {
343
+ function H(p, e = 50, t = !1) {
339
344
  let s;
340
345
  return function(...i) {
341
346
  const n = self, r = () => {
342
- s = null, t || f.apply(n, i);
347
+ s = null, t || p.apply(n, i);
343
348
  }, a = t && !s;
344
- clearTimeout(s), s = setTimeout(r, e), a && f.apply(n, i);
349
+ clearTimeout(s), s = setTimeout(r, e), a && p.apply(n, i);
345
350
  };
346
351
  }
347
- function W(f, e) {
348
- return JSON.stringify(f) === JSON.stringify(e);
352
+ function Y(p, e) {
353
+ return JSON.stringify(p) === JSON.stringify(e);
349
354
  }
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;
355
+ function me(p) {
356
+ const e = p.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
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;
@@ -379,7 +384,7 @@ class x {
379
384
  constructor(e) {
380
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,10 +615,10 @@ 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");
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");
595
619
  const e = this.getAnimationTiming();
596
- setTimeout(() => {
597
- this.main.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow);
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;
598
622
  }, e);
599
623
  }
600
624
  getAnimationTiming() {
@@ -608,7 +632,7 @@ class ve {
608
632
  return 200;
609
633
  }
610
634
  updateClassStyles() {
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)
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)
612
636
  for (const e of this.settings.class)
613
637
  e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
614
638
  (this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
@@ -630,7 +654,9 @@ class ve {
630
654
  case "Enter":
631
655
  case " ":
632
656
  this.callbacks.open();
633
- const o = this.content.list.querySelector("." + this.classes.highlighted);
657
+ const o = this.content.list.querySelector(
658
+ "." + this.classes.getFirst("highlighted")
659
+ );
634
660
  return o && o.click(), !1;
635
661
  case "Escape":
636
662
  return this.callbacks.close(), !1;
@@ -640,11 +666,11 @@ class ve {
640
666
  this.settings.disabled || (this.settings.isOpen ? this.callbacks.close() : this.callbacks.open());
641
667
  };
642
668
  const t = document.createElement("div");
643
- t.classList.add(this.classes.values), e.appendChild(t);
669
+ this.addClasses(t, this.classes.values), e.appendChild(t);
644
670
  const s = document.createElement("div");
645
- s.classList.add(this.classes.deselect);
671
+ this.addClasses(s, this.classes.deselect);
646
672
  const i = this.store?.getSelectedOptions();
647
- !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) => {
648
674
  if (h.stopPropagation(), this.settings.disabled)
649
675
  return;
650
676
  let o = !0;
@@ -653,8 +679,8 @@ class ve {
653
679
  if (this.settings.isMultiple)
654
680
  this.callbacks.setSelected([], !1), this.updateDeselectAll();
655
681
  else {
656
- const p = this.store.getFirstOption(), C = p ? p.id : "";
657
- this.callbacks.setSelected(C, !1);
682
+ const f = this.store.getFirstOption(), E = f ? f.id : "";
683
+ this.callbacks.setSelected(E, !1);
658
684
  }
659
685
  this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
660
686
  }
@@ -664,9 +690,9 @@ class ve {
664
690
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
665
691
  r.setAttribute("d", this.classes.deselectPath), n.appendChild(r), s.appendChild(n), e.appendChild(s);
666
692
  const a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
667
- 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");
668
694
  const c = document.createElementNS("http://www.w3.org/2000/svg", "path");
669
- 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), {
670
696
  main: e,
671
697
  values: t,
672
698
  deselect: {
@@ -688,7 +714,7 @@ class ve {
688
714
  let t = this.settings.placeholderText;
689
715
  e.length && (e[0].html !== "" ? t = e[0].html : e[0].text !== "" && (t = e[0].text));
690
716
  const s = document.createElement("div");
691
- return s.classList.add(this.classes.placeholder), s.innerHTML = t, s;
717
+ return this.addClasses(s, this.classes.placeholder), s.innerHTML = t, s;
692
718
  }
693
719
  // Get selected values and append to multiSelected values container
694
720
  // and remove those who shouldnt exist
@@ -705,9 +731,9 @@ class ve {
705
731
  this.main.values.innerHTML = this.placeholder().outerHTML;
706
732
  else {
707
733
  const s = document.createElement("div");
708
- 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;
709
735
  }
710
- !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);
711
737
  }
712
738
  renderMultipleValues() {
713
739
  let e = this.main.values.childNodes, t = this.store.filter((i) => i.selected && i.display, !1);
@@ -715,15 +741,15 @@ class ve {
715
741
  this.main.values.innerHTML = this.placeholder().outerHTML;
716
742
  return;
717
743
  } else {
718
- const i = this.main.values.querySelector("." + this.classes.placeholder);
744
+ const i = this.main.values.querySelector("." + this.classes.getFirst("placeholder"));
719
745
  i && i.remove();
720
746
  }
721
747
  if (t.length > this.settings.maxValuesShown) {
722
748
  const i = document.createElement("div");
723
- 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;
724
750
  return;
725
751
  } else {
726
- const i = this.main.values.querySelector("." + this.classes.max);
752
+ const i = this.main.values.querySelector("." + this.classes.getFirst("max"));
727
753
  i && i.remove();
728
754
  }
729
755
  this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
@@ -733,7 +759,7 @@ class ve {
733
759
  r && (t.filter((c) => c.id === r, !1).length || s.push(n));
734
760
  }
735
761
  for (const i of s)
736
- i.classList.add(this.classes.valueOut), setTimeout(() => {
762
+ this.addClasses(i, this.classes.valueOut), setTimeout(() => {
737
763
  this.main.values.hasChildNodes() && this.main.values.contains(i) && this.main.values.removeChild(i);
738
764
  }, 100);
739
765
  e = this.main.values.childNodes;
@@ -746,11 +772,11 @@ class ve {
746
772
  }
747
773
  multipleValue(e) {
748
774
  const t = document.createElement("div");
749
- t.classList.add(this.classes.value), t.dataset.id = e.id;
775
+ this.addClasses(t, this.classes.value), t.dataset.id = e.id;
750
776
  const s = document.createElement("div");
751
- 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) {
752
778
  const i = document.createElement("div");
753
- 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) => {
754
780
  if (a.preventDefault(), a.stopPropagation(), this.settings.disabled)
755
781
  return;
756
782
  let c = !0;
@@ -759,9 +785,9 @@ class ve {
759
785
  let d = [];
760
786
  for (const g of o) {
761
787
  if (g instanceof x)
762
- for (const p of g.options)
763
- p.id && d.push(p.id);
764
- g instanceof S && d.push(g.id);
788
+ for (const f of g.options)
789
+ f.id && d.push(f.id);
790
+ g instanceof w && d.push(g.id);
765
791
  }
766
792
  this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(o), this.updateDeselectAll();
767
793
  }
@@ -803,12 +829,12 @@ class ve {
803
829
  }
804
830
  searchDiv() {
805
831
  const e = document.createElement("div"), t = document.createElement("input"), s = document.createElement("div");
806
- e.classList.add(this.classes.search);
832
+ this.addClasses(e, this.classes.search);
807
833
  const i = {
808
834
  main: e,
809
835
  input: t
810
836
  };
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) => {
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) => {
812
838
  this.callbacks.search(n.target.value);
813
839
  }, 100), t.onkeydown = (n) => {
814
840
  switch (n.key) {
@@ -821,15 +847,19 @@ class ve {
821
847
  case "Escape":
822
848
  return this.callbacks.close(), !1;
823
849
  case " ":
824
- const r = this.content.list.querySelector("." + this.classes.highlighted);
850
+ const r = this.content.list.querySelector(
851
+ "." + this.classes.getFirst("highlighted")
852
+ );
825
853
  return r ? (r.click(), !1) : !0;
826
854
  case "Enter":
827
- const a = this.content.list.querySelector("." + this.classes.highlighted);
855
+ const a = this.content.list.querySelector(
856
+ "." + this.classes.getFirst("highlighted")
857
+ );
828
858
  return a ? (a.click(), !1) : this.callbacks.addable ? (s.click(), !1) : !0;
829
859
  }
830
860
  return !0;
831
861
  }, e.appendChild(t), this.callbacks.addable) {
832
- s.classList.add(this.classes.addable);
862
+ this.addClasses(s, this.classes.addable);
833
863
  const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
834
864
  n.setAttribute("viewBox", "0 0 100 100");
835
865
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
@@ -842,10 +872,10 @@ class ve {
842
872
  return;
843
873
  }
844
874
  const h = (d) => {
845
- let g = new S(d);
875
+ let g = new w(d);
846
876
  if (this.callbacks.addOption(g), this.settings.isMultiple) {
847
- let p = this.store.getSelected();
848
- p.push(g.id), this.callbacks.setSelected(p, !0);
877
+ let f = this.store.getSelected();
878
+ f.push(g.id), this.callbacks.setSelected(f, !0);
849
879
  } else
850
880
  this.callbacks.setSelected([g.id], !0);
851
881
  this.callbacks.search(""), this.settings.closeOnSelect && setTimeout(() => {
@@ -873,75 +903,77 @@ class ve {
873
903
  this.content.search.input.focus({ preventScroll: !0 });
874
904
  }
875
905
  getOptions(e = !1, t = !1, s = !1) {
876
- let i = "." + this.classes.option;
877
- 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));
878
908
  }
879
909
  // highlightUp is used to highlight the previous option in the list
880
910
  highlight(e) {
881
911
  const t = this.getOptions(!0, !0, !0);
882
912
  if (t.length === 0)
883
913
  return;
884
- if (t.length === 1 && !t[0].classList.contains(this.classes.highlighted)) {
885
- 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);
886
916
  return;
887
917
  }
888
918
  let s = !1;
889
919
  for (const n of t)
890
- n.classList.contains(this.classes.highlighted) && (s = !0);
920
+ n.classList.contains(this.classes.getFirst("highlighted")) && (s = !0);
891
921
  if (!s) {
892
922
  for (const n of t)
893
- if (n.classList.contains(this.classes.selected)) {
894
- n.classList.add(this.classes.highlighted);
923
+ if (n.classList.contains(this.classes.getFirst("selected"))) {
924
+ this.addClasses(n, this.classes.highlighted);
895
925
  break;
896
926
  }
897
927
  }
898
928
  for (let n = 0; n < t.length; n++)
899
- if (t[n].classList.contains(this.classes.highlighted)) {
929
+ if (t[n].classList.contains(this.classes.getFirst("highlighted"))) {
900
930
  const r = t[n];
901
- r.classList.remove(this.classes.highlighted);
931
+ this.removeClasses(r, this.classes.highlighted);
902
932
  const a = r.parentElement;
903
- if (a && a.classList.contains(this.classes.mainOpen)) {
904
- 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"));
905
935
  o && o.click();
906
936
  }
907
937
  let c = t[e === "down" ? n + 1 < t.length ? n + 1 : 0 : n - 1 >= 0 ? n - 1 : t.length - 1];
908
- 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);
909
939
  const h = c.parentElement;
910
- if (h && h.classList.contains(this.classes.close)) {
911
- 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
+ );
912
944
  o && o.click();
913
945
  }
914
946
  return;
915
947
  }
916
948
  const i = t[e === "down" ? 0 : t.length - 1];
917
- 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);
918
950
  }
919
951
  // Create main container that options will reside
920
952
  listDiv() {
921
953
  const e = document.createElement("div");
922
- e.classList.add(this.classes.list);
954
+ this.addClasses(e, this.classes.list);
923
955
  const t = this.settings.id + "-list";
924
956
  return e.id = t, e.dataset.id = t, e;
925
957
  }
926
958
  renderError(e) {
927
959
  this.content.list.innerHTML = "";
928
960
  const t = document.createElement("div");
929
- 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);
930
962
  }
931
963
  renderSearching() {
932
964
  this.content.list.innerHTML = "";
933
965
  const e = document.createElement("div");
934
- 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);
935
967
  }
936
968
  // Take in data and add options to
937
969
  renderOptions(e) {
938
970
  if (this.content.list.innerHTML = "", e.length === 0) {
939
971
  const s = document.createElement("div");
940
- 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);
941
973
  return;
942
974
  }
943
975
  this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((i) => i.placeholder, !1).length || this.store.addOption(
944
- new S({
976
+ new w({
945
977
  text: "",
946
978
  value: "",
947
979
  selected: !1,
@@ -953,66 +985,66 @@ class ve {
953
985
  for (const s of e) {
954
986
  if (s instanceof x) {
955
987
  const i = document.createElement("div");
956
- i.classList.add(this.classes.optgroup);
988
+ this.addClasses(i, this.classes.optgroup);
957
989
  const n = document.createElement("div");
958
- n.classList.add(this.classes.optgroupLabel), i.appendChild(n);
990
+ this.addClasses(n, this.classes.optgroupLabel), i.appendChild(n);
959
991
  const r = document.createElement("div");
960
- 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);
961
993
  const a = document.createElement("div");
962
- 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) {
963
995
  const c = document.createElement("div");
964
- c.classList.add(this.classes.optgroupSelectAll);
996
+ this.addClasses(c, this.classes.optgroupSelectAll);
965
997
  let h = !0;
966
- for (const C of s.options)
967
- if (!C.selected) {
998
+ for (const E of s.options)
999
+ if (!E.selected) {
968
1000
  h = !1;
969
1001
  break;
970
1002
  }
971
- h && c.classList.add(this.classes.selected);
1003
+ h && this.addClasses(c, this.classes.selected);
972
1004
  const o = document.createElement("span");
973
1005
  o.textContent = s.selectAllText, c.appendChild(o);
974
1006
  const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
975
1007
  d.setAttribute("viewBox", "0 0 100 100"), c.appendChild(d);
976
1008
  const g = document.createElementNS("http://www.w3.org/2000/svg", "path");
977
1009
  g.setAttribute("d", this.classes.optgroupSelectAllBox), d.appendChild(g);
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) => {
980
- C.preventDefault(), C.stopPropagation();
1010
+ const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
1011
+ f.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(f), c.addEventListener("click", (E) => {
1012
+ E.preventDefault(), E.stopPropagation();
981
1013
  const m = this.store.getSelected();
982
1014
  if (h) {
983
- const L = m.filter((O) => {
1015
+ const A = m.filter((S) => {
984
1016
  for (const v of s.options)
985
- if (O === v.id)
1017
+ if (S === v.id)
986
1018
  return !1;
987
1019
  return !0;
988
1020
  });
989
- this.callbacks.setSelected(L, !0);
1021
+ this.callbacks.setSelected(A, !0);
990
1022
  return;
991
1023
  } else {
992
- let L = s.options.map((v) => v.id).filter((v) => v !== void 0);
993
- 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);
994
1026
  for (const v of s.options)
995
- v.id && !this.store.getOptionByID(v.id) && this.callbacks.addOption(new S(v));
996
- 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);
997
1029
  return;
998
1030
  }
999
1031
  }), a.appendChild(c);
1000
1032
  }
1001
1033
  if (s.closable !== "off") {
1002
1034
  const c = document.createElement("div");
1003
- c.classList.add(this.classes.optgroupClosable);
1035
+ this.addClasses(c, this.classes.optgroupClosable);
1004
1036
  const h = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1005
- 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);
1006
1038
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
1007
- 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) => {
1008
- 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));
1009
1041
  }), a.appendChild(c);
1010
1042
  }
1011
1043
  i.appendChild(n);
1012
1044
  for (const c of s.options)
1013
- i.appendChild(this.option(new S(c))), t.appendChild(i);
1045
+ i.appendChild(this.option(new w(c))), t.appendChild(i);
1014
1046
  }
1015
- s instanceof S && t.appendChild(this.option(s));
1047
+ s instanceof w && t.appendChild(this.option(s));
1016
1048
  }
1017
1049
  this.content.list.appendChild(t);
1018
1050
  }
@@ -1020,16 +1052,16 @@ class ve {
1020
1052
  option(e) {
1021
1053
  if (e.placeholder) {
1022
1054
  const s = document.createElement("div");
1023
- 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;
1024
1056
  }
1025
1057
  const t = document.createElement("div");
1026
- 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) => {
1027
1059
  t.classList.add(s);
1028
1060
  }), e.style && (t.style.cssText = e.style), this.settings.searchHighlight && this.content.search.input.value.trim() !== "" ? t.innerHTML = this.highlightText(
1029
1061
  e.html !== "" ? e.html : e.text,
1030
1062
  this.content.search.input.value,
1031
1063
  this.classes.searchHighlighter
1032
- ) : 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) => {
1033
1065
  s.preventDefault(), s.stopPropagation();
1034
1066
  const i = this.store.getSelected(), n = s.currentTarget, r = String(n.dataset.id), a = s.ctrlKey || s.metaKey;
1035
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)
@@ -1038,19 +1070,19 @@ class ve {
1038
1070
  const h = this.store.getSelectedOptions();
1039
1071
  let o = [];
1040
1072
  if (this.settings.isMultiple) {
1041
- const d = h.some((p) => p.id === r);
1073
+ const d = h.some((f) => f.id === r);
1042
1074
  if (s.shiftKey && this.lastSelectedOption) {
1043
- const p = this.store.getDataOptions(), C = p.findIndex((L) => L.id === this.lastSelectedOption.id), m = p.findIndex((L) => L.id === e.id);
1044
- if (C >= 0 && m >= 0) {
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));
1046
- 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;
1047
1079
  } else
1048
1080
  o = h;
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);
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);
1050
1082
  }
1051
1083
  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) {
1052
1084
  this.store.getOptionByID(r) || this.callbacks.addOption(e), this.callbacks.setSelected(
1053
- o.map((p) => p.id),
1085
+ o.map((f) => f.id),
1054
1086
  !1
1055
1087
  );
1056
1088
  const d = s.ctrlKey || s.metaKey || s.shiftKey;
@@ -1059,7 +1091,7 @@ class ve {
1059
1091
  }), t;
1060
1092
  }
1061
1093
  destroy() {
1062
- 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();
1063
1095
  }
1064
1096
  highlightText(e, t, s) {
1065
1097
  const i = t.trim();
@@ -1072,27 +1104,39 @@ class ve {
1072
1104
  const h = c.textContent || "", o = new RegExp("(" + n + ")", "i");
1073
1105
  if (o.test(h)) {
1074
1106
  const d = document.createElement("span");
1075
- h.split(o).forEach((p, C) => {
1076
- if (p && o.test(p)) {
1107
+ h.split(o).forEach((f, E) => {
1108
+ if (f && o.test(f)) {
1077
1109
  const m = document.createElement("mark");
1078
- m.className = s, m.textContent = p, d.appendChild(m);
1079
- } else p && d.appendChild(document.createTextNode(p));
1110
+ m.className = s, m.textContent = f, d.appendChild(m);
1111
+ } else f && d.appendChild(document.createTextNode(f));
1080
1112
  }), c.parentNode?.replaceChild(d, c);
1081
1113
  }
1082
1114
  } else c.nodeType === Node.ELEMENT_NODE && Array.from(c.childNodes).forEach((h) => a(h));
1083
1115
  };
1084
1116
  return Array.from(r.childNodes).forEach((c) => a(c)), r.innerHTML;
1085
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
+ this.settings.contentPosition === "fixed" ? (t = e.top + e.height, s = e.left) : (t = e.top + window.scrollY + e.height, s = e.left + window.scrollX), this.content.main.style.top = t + "px", this.content.main.style.left = s + "px";
1132
+ const i = this.settings.contentWidth;
1133
+ this.content.main.style.width = "", this.content.main.style.minWidth = "", this.content.main.style.maxWidth = "", i ? i.startsWith(">") ? this.content.main.style.minWidth = i.slice(1) : i.startsWith("<") ? this.content.main.style.maxWidth = i.slice(1) : this.content.main.style.width = i : this.content.main.style.width = e.width + "px";
1134
+ }
1086
1135
  moveContentAbove() {
1087
- const e = this.main.main.offsetHeight, t = this.content.main.offsetHeight;
1088
- 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);
1089
- const s = this.main.main.getBoundingClientRect();
1090
- 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";
1136
+ this.setContentDirection("above"), this.setContentPosition();
1091
1137
  }
1092
1138
  moveContentBelow() {
1093
- 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);
1094
- const e = this.main.main.getBoundingClientRect();
1095
- 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");
1139
+ this.setContentDirection("below"), this.setContentPosition();
1096
1140
  }
1097
1141
  ensureElementInView(e, t) {
1098
1142
  const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, n = t.offsetTop, r = n + t.clientHeight;
@@ -1107,7 +1151,7 @@ class ve {
1107
1151
  if (!this.store || !this.settings)
1108
1152
  return;
1109
1153
  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;
1110
- i && !(s && !t) ? n.classList.remove(r) : n.classList.add(r);
1154
+ i && !(s && !t) ? this.removeClasses(n, r) : this.addClasses(n, r);
1111
1155
  }
1112
1156
  }
1113
1157
  class be {
@@ -1307,7 +1351,7 @@ class be {
1307
1351
  if (!(!e || e.length === 0)) {
1308
1352
  this.isUpdating = !0, this.pendingOptionsChange = null, this.changeListen(!1), this.select.innerHTML = "";
1309
1353
  for (const t of e)
1310
- t instanceof x && this.select.appendChild(this.createOptgroup(t)), t instanceof S && this.select.appendChild(this.createOption(t));
1354
+ t instanceof x && this.select.appendChild(this.createOptgroup(t)), t instanceof w && this.select.appendChild(this.createOption(t));
1311
1355
  if (this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0), this.isUpdating = !1, this.pendingOptionsChange !== null) {
1312
1356
  const t = this.pendingOptionsChange;
1313
1357
  t.length > 0 && this.onOptionsChange ? (this.pendingOptionsChange = null, this.changeListen(!1), this.onOptionsChange(t), this.changeListen(!0)) : this.pendingOptionsChange = null;
@@ -1345,8 +1389,8 @@ class be {
1345
1389
  if (n.__slimSelectLabelHandler)
1346
1390
  return;
1347
1391
  const r = (a) => {
1348
- const c = a.target;
1349
- a.preventDefault(), c === n && this.onLabelClick && this.onLabelClick();
1392
+ const c = a.target, h = ie(c, this.select.dataset.id);
1393
+ a.preventDefault(), !h && this.onLabelClick && this.onLabelClick();
1350
1394
  };
1351
1395
  n.__slimSelectLabelHandler = r, n.addEventListener("click", r, { capture: !0, passive: !1 });
1352
1396
  });
@@ -1372,7 +1416,7 @@ class be {
1372
1416
  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();
1373
1417
  }
1374
1418
  }
1375
- class we {
1419
+ class Ce {
1376
1420
  id = "";
1377
1421
  // Primary ID for the select
1378
1422
  style = "";
@@ -1398,6 +1442,7 @@ class we {
1398
1442
  closeOnSelect;
1399
1443
  contentLocation;
1400
1444
  contentPosition;
1445
+ contentWidth;
1401
1446
  openPosition;
1402
1447
  placeholderText;
1403
1448
  allowDeselect;
@@ -1411,10 +1456,10 @@ class we {
1411
1456
  maxValuesMessage;
1412
1457
  addableText;
1413
1458
  constructor(e) {
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}';
1459
+ 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.contentWidth = e.contentWidth || "", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || 'Press "Enter" to add {value}';
1415
1460
  }
1416
1461
  }
1417
- let Se = class {
1462
+ let we = class {
1418
1463
  selectEl;
1419
1464
  // Classes
1420
1465
  settings;
@@ -1446,10 +1491,10 @@ let Se = class {
1446
1491
  e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
1447
1492
  return;
1448
1493
  }
1449
- this.selectEl.dataset.ssid && this.destroy(), this.settings = new we(e.settings), this.cssClasses = new pe(e.cssClasses);
1494
+ this.selectEl.dataset.ssid && this.destroy(), this.settings = new Ce(e.settings), this.cssClasses = new pe(e.cssClasses);
1450
1495
  const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
1451
1496
  for (const a in e.events)
1452
- e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = B(e.events[a], 100) : this.events[a] = e.events[a]);
1497
+ e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = H(e.events[a], 100) : this.events[a] = e.events[a]);
1453
1498
  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) => {
1454
1499
  this.setSelected(a.map((c) => c.id));
1455
1500
  }, this.select.onClassChange = (a) => {
@@ -1496,7 +1541,7 @@ let Se = class {
1496
1541
  }
1497
1542
  this.store.setData(e);
1498
1543
  const i = this.store.getData();
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());
1544
+ this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !Y(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1500
1545
  }
1501
1546
  getSelected() {
1502
1547
  let e = this.store.getSelectedOptions();
@@ -1517,21 +1562,21 @@ let Se = class {
1517
1562
  }
1518
1563
  this.store.setSelectedBy("id", n);
1519
1564
  const r = this.store.getData();
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());
1565
+ 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 && !Y(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1521
1566
  }
1522
1567
  addOption(e) {
1523
1568
  const t = this.store.getSelected();
1524
1569
  this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
1525
1570
  const s = this.store.getData();
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());
1571
+ this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !Y(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
1527
1572
  }
1528
1573
  open() {
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(() => {
1574
+ 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(() => {
1530
1575
  this.events.afterOpen && this.events.afterOpen(), this.settings.isOpen && (this.settings.isFullOpen = !0), document.addEventListener("click", this.documentClick);
1531
1576
  }, 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)));
1532
1577
  }
1533
1578
  close(e = null) {
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(() => {
1579
+ !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(() => {
1535
1580
  this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
1536
1581
  }, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
1537
1582
  }
@@ -1560,33 +1605,33 @@ let Se = class {
1560
1605
  destroy() {
1561
1606
  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();
1562
1607
  }
1563
- windowResize = B(() => {
1608
+ windowResize = H(() => {
1564
1609
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1565
1610
  });
1566
1611
  // Event listener for window scrolling
1567
- windowScroll = B(() => {
1612
+ windowScroll = H(() => {
1568
1613
  !this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
1569
1614
  });
1570
1615
  // Event listener for document click
1571
1616
  documentClick = (e) => {
1572
- this.settings.isOpen && e.target && !fe(e.target, this.settings.id) && this.close(e.type);
1617
+ this.settings.isOpen && e.target && !ie(e.target, this.settings.id) && this.close(e.type);
1573
1618
  };
1574
1619
  // Event Listener for window visibility change
1575
1620
  windowVisibilityChange = () => {
1576
1621
  document.hidden && this.close();
1577
1622
  };
1578
1623
  };
1579
- const Oe = re(
1580
- ({ data: f, settings: e, events: t, cssClasses: s, value: i, onChange: n, children: r, multiple: a }, c) => {
1581
- const h = V(null), o = V(null), d = V(!0), g = V(i);
1582
- oe(c, () => ({
1624
+ const Se = oe(
1625
+ ({ data: p, settings: e, events: t, cssClasses: s, value: i, onChange: n, children: r, multiple: a }, c) => {
1626
+ const h = I(null), o = I(null), d = I(!0), g = I(i);
1627
+ ce(c, () => ({
1583
1628
  slimSelect: o.current
1584
1629
  }));
1585
- const p = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", C = (m, L = !1) => {
1630
+ const f = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", E = (m, A = !1) => {
1586
1631
  if (!o.current || m === void 0)
1587
1632
  return;
1588
- const O = p(m), T = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
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)) {
1633
+ const S = f(m), k = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
1634
+ 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)) {
1590
1635
  const D = o.current.getData(), P = {
1591
1636
  value: "",
1592
1637
  text: "",
@@ -1594,25 +1639,25 @@ const Oe = re(
1594
1639
  };
1595
1640
  o.current.setData([P].concat(D));
1596
1641
  }
1597
- o.current.setSelected(O, L);
1642
+ o.current.setSelected(S, A);
1598
1643
  };
1599
1644
  return $(() => {
1600
1645
  if (!h.current) return;
1601
1646
  const m = {
1602
1647
  select: h.current
1603
1648
  };
1604
- f && (m.data = f), e && (m.settings = e), s && (m.cssClasses = s);
1605
- const L = t?.afterChange;
1649
+ p && (m.data = p), e && (m.settings = e), s && (m.cssClasses = s);
1650
+ const A = t?.afterChange;
1606
1651
  return m.events = {
1607
1652
  ...t,
1608
- afterChange: (O) => {
1653
+ afterChange: (S) => {
1609
1654
  if (!o.current) return;
1610
- const v = a ? O.map((A) => A.value) : O[0]?.value ?? "", k = o.current.getData().flatMap(
1611
- (A) => "label" in A ? A.options : [A]
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);
1655
+ const v = a ? S.map((T) => T.value) : S[0]?.value ?? "", L = o.current.getData().flatMap(
1656
+ (T) => "label" in T ? T.options : [T]
1657
+ ), 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;
1658
+ n && B && (D || P) && (n(v), g.current = v), A && A(S);
1614
1659
  }
1615
- }, o.current = new Se(m), i !== void 0 && C(i, !1), () => {
1660
+ }, o.current = new we(m), i !== void 0 && E(i, !1), () => {
1616
1661
  o.current && (o.current.destroy(), o.current = null);
1617
1662
  };
1618
1663
  }, []), $(() => {
@@ -1620,16 +1665,16 @@ const Oe = re(
1620
1665
  d.current = !1, g.current = i;
1621
1666
  return;
1622
1667
  }
1623
- o.current && i !== void 0 && (g.current = i, C(i, !1));
1668
+ o.current && i !== void 0 && (g.current = i, E(i, !1));
1624
1669
  }, [i]), $(() => {
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 });
1670
+ o.current && p && !d.current && (o.current.setData(p), i !== void 0 && E(i, !1));
1671
+ }, [p]), /* @__PURE__ */ fe.jsx("select", { ref: h, multiple: a, children: r });
1627
1672
  }
1628
1673
  );
1629
- Oe.displayName = "SlimSelect";
1674
+ Se.displayName = "SlimSelect";
1630
1675
  export {
1631
1676
  x as Optgroup,
1632
- S as Option,
1633
- we as Settings,
1634
- Oe as default
1677
+ w as Option,
1678
+ Ce as Settings,
1679
+ Se as default
1635
1680
  };