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.
- package/README.md +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +291 -246
- package/dist/react/index.umd.js +2 -2
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.css +1 -1
- package/dist/slimselect.css.map +1 -1
- package/dist/slimselect.es.js +308 -263
- package/dist/slimselect.es.js.map +1 -1
- package/dist/slimselect.iife.js +1 -1
- package/dist/slimselect.iife.js.map +1 -1
- package/dist/slimselect.js +1 -1
- package/dist/slimselect.js.map +1 -1
- package/dist/vue/index.d.ts +7 -0
- package/dist/vue/index.js +214 -169
- package/dist/vue/index.umd.js +1 -1
- package/package.json +24 -23
- package/sitemap.js +21 -2
- package/src/slim-select/classes.test.ts +3 -3
- package/src/slim-select/classes.ts +40 -34
- package/src/slim-select/index.test.ts +26 -5
- package/src/slim-select/index.ts +12 -0
- package/src/slim-select/render.test.ts +216 -0
- package/src/slim-select/render.ts +204 -115
- package/src/slim-select/select.ts +11 -7
- package/src/slim-select/settings.test.ts +2 -1
- package/src/slim-select/settings.ts +2 -0
- package/src/slim-select/slimselect.scss +5 -0
package/dist/react/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
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
|
|
4
|
+
function he() {
|
|
5
5
|
if (ee) return R;
|
|
6
6
|
ee = 1;
|
|
7
|
-
var
|
|
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:
|
|
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
|
|
28
|
-
return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
29
|
-
function
|
|
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 ===
|
|
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
|
|
35
|
+
case A:
|
|
36
36
|
return "Fragment";
|
|
37
37
|
case v:
|
|
38
38
|
return "Profiler";
|
|
39
|
-
case
|
|
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
|
|
54
|
+
case L:
|
|
55
55
|
return l.displayName || "Context";
|
|
56
|
-
case
|
|
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
|
|
62
|
-
return u = l.displayName || null, u !== null ? u :
|
|
63
|
-
case
|
|
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
|
|
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
|
|
85
|
-
return
|
|
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
|
-
|
|
88
|
+
O
|
|
89
89
|
), e(l);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function s(l) {
|
|
93
|
-
if (l ===
|
|
94
|
-
if (typeof l == "object" && l !== null && l.$$typeof ===
|
|
93
|
+
if (l === A) return "<>";
|
|
94
|
+
if (typeof l == "object" && l !== null && l.$$typeof === T)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var u =
|
|
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
|
|
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
|
-
|
|
125
|
-
get:
|
|
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 =
|
|
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,
|
|
136
|
-
var
|
|
135
|
+
function h(l, u, C, O, F, q) {
|
|
136
|
+
var y = C.ref;
|
|
137
137
|
return l = {
|
|
138
|
-
$$typeof:
|
|
138
|
+
$$typeof: E,
|
|
139
139
|
type: l,
|
|
140
140
|
key: u,
|
|
141
|
-
props:
|
|
142
|
-
_owner:
|
|
143
|
-
}, (
|
|
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:
|
|
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,
|
|
169
|
-
var
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
for (
|
|
174
|
-
d(
|
|
175
|
-
Object.freeze && Object.freeze(
|
|
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(
|
|
180
|
+
else d(y);
|
|
181
181
|
if (J.call(u, "key")) {
|
|
182
|
-
|
|
183
|
-
var N = Object.keys(u).filter(function(
|
|
184
|
-
return
|
|
182
|
+
y = p(l);
|
|
183
|
+
var N = Object.keys(u).filter(function(ae) {
|
|
184
|
+
return ae !== "key";
|
|
185
185
|
});
|
|
186
|
-
|
|
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
|
-
|
|
197
|
-
), Q[
|
|
196
|
+
y
|
|
197
|
+
), Q[y + O] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
for (var
|
|
202
|
-
|
|
203
|
-
} else
|
|
204
|
-
return
|
|
205
|
-
|
|
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
|
-
|
|
210
|
-
|
|
209
|
+
y,
|
|
210
|
+
C,
|
|
211
211
|
i(),
|
|
212
|
-
|
|
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 ===
|
|
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 ===
|
|
220
|
+
return typeof l == "object" && l !== null && l.$$typeof === E;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
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
|
-
|
|
225
|
+
f = {
|
|
226
226
|
react_stack_bottom_frame: function(l) {
|
|
227
227
|
return l();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var G, X = {}, K =
|
|
231
|
-
|
|
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 =
|
|
235
|
-
var
|
|
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
|
-
|
|
239
|
+
C,
|
|
240
240
|
!1,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
O ? Error("react-stack-top-frame") : K,
|
|
242
|
+
O ? U(s(l)) : Z
|
|
243
243
|
);
|
|
244
|
-
}, _.jsxs = function(l, u,
|
|
245
|
-
var
|
|
244
|
+
}, _.jsxs = function(l, u, C) {
|
|
245
|
+
var O = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return o(
|
|
247
247
|
l,
|
|
248
248
|
u,
|
|
249
|
-
|
|
249
|
+
C,
|
|
250
250
|
!0,
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
259
|
-
return se || (se = 1, process.env.NODE_ENV === "production" ?
|
|
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
|
|
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 = {})
|
|
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
|
|
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(
|
|
341
|
+
return t(p, e) || s(p, e);
|
|
337
342
|
}
|
|
338
|
-
function
|
|
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 ||
|
|
347
|
+
s = null, t || p.apply(n, i);
|
|
343
348
|
}, a = t && !s;
|
|
344
|
-
clearTimeout(s), s = setTimeout(r, e), a &&
|
|
349
|
+
clearTimeout(s), s = setTimeout(r, e), a && p.apply(n, i);
|
|
345
350
|
};
|
|
346
351
|
}
|
|
347
|
-
function
|
|
348
|
-
return JSON.stringify(
|
|
352
|
+
function Y(p, e) {
|
|
353
|
+
return JSON.stringify(p) === JSON.stringify(e);
|
|
349
354
|
}
|
|
350
|
-
function me(
|
|
351
|
-
const e =
|
|
352
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
432
|
+
i.push(new w(n));
|
|
428
433
|
}), i.length > 0 && t.push(new x(s));
|
|
429
434
|
}
|
|
430
|
-
(s instanceof
|
|
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
|
|
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
|
|
475
|
+
let s = [new w(e)];
|
|
471
476
|
this.setData(s.concat(this.getData()));
|
|
472
477
|
} else
|
|
473
|
-
this.setData(this.getData().concat(new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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(
|
|
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
|
-
|
|
669
|
+
this.addClasses(t, this.classes.values), e.appendChild(t);
|
|
644
670
|
const s = document.createElement("div");
|
|
645
|
-
|
|
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 ?
|
|
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
|
|
657
|
-
this.callbacks.setSelected(
|
|
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
|
-
|
|
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 &&
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
775
|
+
this.addClasses(t, this.classes.value), t.dataset.id = e.id;
|
|
750
776
|
const s = document.createElement("div");
|
|
751
|
-
if (
|
|
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
|
-
|
|
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
|
|
763
|
-
|
|
764
|
-
g instanceof
|
|
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
|
-
|
|
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 || (
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
|
875
|
+
let g = new w(d);
|
|
846
876
|
if (this.callbacks.addOption(g), this.settings.isMultiple) {
|
|
847
|
-
let
|
|
848
|
-
|
|
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]
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
988
|
+
this.addClasses(i, this.classes.optgroup);
|
|
957
989
|
const n = document.createElement("div");
|
|
958
|
-
|
|
990
|
+
this.addClasses(n, this.classes.optgroupLabel), i.appendChild(n);
|
|
959
991
|
const r = document.createElement("div");
|
|
960
|
-
|
|
992
|
+
this.addClasses(r, this.classes.optgroupLabelText), r.textContent = s.label, n.appendChild(r);
|
|
961
993
|
const a = document.createElement("div");
|
|
962
|
-
if (
|
|
994
|
+
if (this.addClasses(a, this.classes.optgroupActions), n.appendChild(a), this.settings.isMultiple && s.selectAll) {
|
|
963
995
|
const c = document.createElement("div");
|
|
964
|
-
|
|
996
|
+
this.addClasses(c, this.classes.optgroupSelectAll);
|
|
965
997
|
let h = !0;
|
|
966
|
-
for (const
|
|
967
|
-
if (!
|
|
998
|
+
for (const E of s.options)
|
|
999
|
+
if (!E.selected) {
|
|
968
1000
|
h = !1;
|
|
969
1001
|
break;
|
|
970
1002
|
}
|
|
971
|
-
h &&
|
|
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
|
|
979
|
-
|
|
980
|
-
|
|
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
|
|
1015
|
+
const A = m.filter((S) => {
|
|
984
1016
|
for (const v of s.options)
|
|
985
|
-
if (
|
|
1017
|
+
if (S === v.id)
|
|
986
1018
|
return !1;
|
|
987
1019
|
return !0;
|
|
988
1020
|
});
|
|
989
|
-
this.callbacks.setSelected(
|
|
1021
|
+
this.callbacks.setSelected(A, !0);
|
|
990
1022
|
return;
|
|
991
1023
|
} else {
|
|
992
|
-
let
|
|
993
|
-
const
|
|
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
|
|
996
|
-
this.callbacks.setSelected(
|
|
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
|
-
|
|
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"),
|
|
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() !== "" ? (
|
|
1008
|
-
d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.close) ? (
|
|
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
|
|
1045
|
+
i.appendChild(this.option(new w(c))), t.appendChild(i);
|
|
1014
1046
|
}
|
|
1015
|
-
s instanceof
|
|
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
|
|
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,
|
|
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 ||
|
|
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((
|
|
1073
|
+
const d = h.some((f) => f.id === r);
|
|
1042
1074
|
if (s.shiftKey && this.lastSelectedOption) {
|
|
1043
|
-
const
|
|
1044
|
-
if (
|
|
1045
|
-
const
|
|
1046
|
-
h.length +
|
|
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((
|
|
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((
|
|
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((
|
|
1076
|
-
if (
|
|
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 =
|
|
1079
|
-
} else
|
|
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
|
-
|
|
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.
|
|
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) ?
|
|
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
|
|
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(),
|
|
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
|
|
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
|
|
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
|
|
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] =
|
|
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 && !
|
|
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 && !
|
|
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 && !
|
|
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 =
|
|
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 =
|
|
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 && !
|
|
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
|
|
1580
|
-
({ data:
|
|
1581
|
-
const h =
|
|
1582
|
-
|
|
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
|
|
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
|
|
1589
|
-
if (!(Array.isArray(
|
|
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(
|
|
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
|
-
|
|
1605
|
-
const
|
|
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: (
|
|
1653
|
+
afterChange: (S) => {
|
|
1609
1654
|
if (!o.current) return;
|
|
1610
|
-
const v = a ?
|
|
1611
|
-
(
|
|
1612
|
-
), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((
|
|
1613
|
-
n &&
|
|
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
|
|
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,
|
|
1668
|
+
o.current && i !== void 0 && (g.current = i, E(i, !1));
|
|
1624
1669
|
}, [i]), $(() => {
|
|
1625
|
-
o.current &&
|
|
1626
|
-
}, [
|
|
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
|
-
|
|
1674
|
+
Se.displayName = "SlimSelect";
|
|
1630
1675
|
export {
|
|
1631
1676
|
x as Optgroup,
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1677
|
+
w as Option,
|
|
1678
|
+
Ce as Settings,
|
|
1679
|
+
Se as default
|
|
1635
1680
|
};
|