slim-select 3.1.0 → 3.1.2
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 +4 -3
- package/dist/index.d.ts +2 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +358 -342
- package/dist/react/index.umd.js +2 -18
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.es.js +54 -38
- 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 +2 -0
- package/dist/vue/index.js +67 -35
- package/dist/vue/index.umd.js +1 -1
- package/package.json +20 -19
- package/src/slim-select/index.test.ts +367 -4
- package/src/slim-select/index.ts +4 -2
- package/src/slim-select/react/react.test.tsx +498 -0
- package/src/slim-select/react/react.tsx +102 -5
- package/src/slim-select/render.test.ts +14 -15
- package/src/slim-select/select.test.ts +242 -1
- package/src/slim-select/select.ts +45 -0
- package/src/slim-select/vue/vue.test.ts +259 -0
- package/src/slim-select/vue/vue.vue +85 -25
- package/vitest.config.ts +3 -2
package/dist/react/index.js
CHANGED
|
@@ -1,280 +1,262 @@
|
|
|
1
|
-
import ae, { forwardRef as re, useRef as V, useImperativeHandle as oe, useEffect as
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
* @license React
|
|
5
|
-
* react-jsx-runtime.production.js
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
var X;
|
|
1
|
+
import ae, { forwardRef as re, useRef as V, useImperativeHandle as oe, useEffect as $ } from "react";
|
|
2
|
+
var B = { exports: {} }, R = {};
|
|
3
|
+
var ee;
|
|
13
4
|
function ce() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
5
|
+
if (ee) return R;
|
|
6
|
+
ee = 1;
|
|
16
7
|
var p = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
17
|
-
function t(s, i,
|
|
8
|
+
function t(s, i, n) {
|
|
18
9
|
var r = null;
|
|
19
|
-
if (
|
|
20
|
-
|
|
10
|
+
if (n !== void 0 && (r = "" + n), i.key !== void 0 && (r = "" + i.key), "key" in i) {
|
|
11
|
+
n = {};
|
|
21
12
|
for (var a in i)
|
|
22
|
-
a !== "key" && (
|
|
23
|
-
} else
|
|
24
|
-
return i =
|
|
13
|
+
a !== "key" && (n[a] = i[a]);
|
|
14
|
+
} else n = i;
|
|
15
|
+
return i = n.ref, {
|
|
25
16
|
$$typeof: p,
|
|
26
17
|
type: s,
|
|
27
18
|
key: r,
|
|
28
19
|
ref: i !== void 0 ? i : null,
|
|
29
|
-
props:
|
|
20
|
+
props: n
|
|
30
21
|
};
|
|
31
22
|
}
|
|
32
|
-
return
|
|
23
|
+
return R.Fragment = e, R.jsx = t, R.jsxs = t, R;
|
|
33
24
|
}
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
* @license React
|
|
37
|
-
* react-jsx-runtime.development.js
|
|
38
|
-
*
|
|
39
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
-
*
|
|
41
|
-
* This source code is licensed under the MIT license found in the
|
|
42
|
-
* LICENSE file in the root directory of this source tree.
|
|
43
|
-
*/
|
|
44
|
-
var K;
|
|
25
|
+
var _ = {};
|
|
26
|
+
var te;
|
|
45
27
|
function he() {
|
|
46
|
-
return
|
|
47
|
-
function p(
|
|
48
|
-
if (
|
|
49
|
-
if (typeof
|
|
50
|
-
return
|
|
51
|
-
if (typeof
|
|
52
|
-
switch (
|
|
53
|
-
case
|
|
28
|
+
return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
29
|
+
function p(l) {
|
|
30
|
+
if (l == null) return null;
|
|
31
|
+
if (typeof l == "function")
|
|
32
|
+
return l.$$typeof === ie ? null : l.displayName || l.name || null;
|
|
33
|
+
if (typeof l == "string") return l;
|
|
34
|
+
switch (l) {
|
|
35
|
+
case L:
|
|
54
36
|
return "Fragment";
|
|
55
|
-
case
|
|
37
|
+
case v:
|
|
56
38
|
return "Profiler";
|
|
57
|
-
case
|
|
39
|
+
case O:
|
|
58
40
|
return "StrictMode";
|
|
59
|
-
case
|
|
41
|
+
case D:
|
|
60
42
|
return "Suspense";
|
|
61
|
-
case
|
|
43
|
+
case P:
|
|
62
44
|
return "SuspenseList";
|
|
63
|
-
case
|
|
45
|
+
case M:
|
|
64
46
|
return "Activity";
|
|
65
47
|
}
|
|
66
|
-
if (typeof
|
|
67
|
-
switch (typeof
|
|
48
|
+
if (typeof l == "object")
|
|
49
|
+
switch (typeof l.tag == "number" && console.error(
|
|
68
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
-
),
|
|
70
|
-
case
|
|
51
|
+
), l.$$typeof) {
|
|
52
|
+
case m:
|
|
71
53
|
return "Portal";
|
|
72
|
-
case R:
|
|
73
|
-
return n.displayName || "Context";
|
|
74
54
|
case k:
|
|
75
|
-
return
|
|
76
|
-
case
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return
|
|
81
|
-
case
|
|
82
|
-
u =
|
|
55
|
+
return l.displayName || "Context";
|
|
56
|
+
case T:
|
|
57
|
+
return (l._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case b:
|
|
59
|
+
var u = l.render;
|
|
60
|
+
return l = l.displayName, l || (l = u.displayName || u.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
|
|
61
|
+
case F:
|
|
62
|
+
return u = l.displayName || null, u !== null ? u : p(l.type) || "Memo";
|
|
63
|
+
case A:
|
|
64
|
+
u = l._payload, l = l._init;
|
|
83
65
|
try {
|
|
84
|
-
return p(
|
|
66
|
+
return p(l(u));
|
|
85
67
|
} catch {
|
|
86
68
|
}
|
|
87
69
|
}
|
|
88
70
|
return null;
|
|
89
71
|
}
|
|
90
|
-
function e(
|
|
91
|
-
return "" +
|
|
72
|
+
function e(l) {
|
|
73
|
+
return "" + l;
|
|
92
74
|
}
|
|
93
|
-
function t(
|
|
75
|
+
function t(l) {
|
|
94
76
|
try {
|
|
95
|
-
e(
|
|
77
|
+
e(l);
|
|
96
78
|
var u = !1;
|
|
97
79
|
} catch {
|
|
98
80
|
u = !0;
|
|
99
81
|
}
|
|
100
82
|
if (u) {
|
|
101
83
|
u = console;
|
|
102
|
-
var
|
|
103
|
-
return
|
|
84
|
+
var w = u.error, y = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
|
|
85
|
+
return w.call(
|
|
104
86
|
u,
|
|
105
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
107
|
-
), e(
|
|
88
|
+
y
|
|
89
|
+
), e(l);
|
|
108
90
|
}
|
|
109
91
|
}
|
|
110
|
-
function s(
|
|
111
|
-
if (
|
|
112
|
-
if (typeof
|
|
92
|
+
function s(l) {
|
|
93
|
+
if (l === L) return "<>";
|
|
94
|
+
if (typeof l == "object" && l !== null && l.$$typeof === A)
|
|
113
95
|
return "<...>";
|
|
114
96
|
try {
|
|
115
|
-
var u = p(
|
|
97
|
+
var u = p(l);
|
|
116
98
|
return u ? "<" + u + ">" : "<...>";
|
|
117
99
|
} catch {
|
|
118
100
|
return "<...>";
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
103
|
function i() {
|
|
122
|
-
var
|
|
123
|
-
return
|
|
104
|
+
var l = j.A;
|
|
105
|
+
return l === null ? null : l.getOwner();
|
|
124
106
|
}
|
|
125
|
-
function
|
|
107
|
+
function n() {
|
|
126
108
|
return Error("react-stack-top-frame");
|
|
127
109
|
}
|
|
128
|
-
function r(
|
|
129
|
-
if (
|
|
130
|
-
var u = Object.getOwnPropertyDescriptor(
|
|
110
|
+
function r(l) {
|
|
111
|
+
if (J.call(l, "key")) {
|
|
112
|
+
var u = Object.getOwnPropertyDescriptor(l, "key").get;
|
|
131
113
|
if (u && u.isReactWarning) return !1;
|
|
132
114
|
}
|
|
133
|
-
return
|
|
115
|
+
return l.key !== void 0;
|
|
134
116
|
}
|
|
135
|
-
function a(
|
|
136
|
-
function
|
|
137
|
-
|
|
117
|
+
function a(l, u) {
|
|
118
|
+
function w() {
|
|
119
|
+
G || (G = !0, console.error(
|
|
138
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)",
|
|
139
121
|
u
|
|
140
122
|
));
|
|
141
123
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
124
|
+
w.isReactWarning = !0, Object.defineProperty(l, "key", {
|
|
125
|
+
get: w,
|
|
144
126
|
configurable: !0
|
|
145
127
|
});
|
|
146
128
|
}
|
|
147
129
|
function c() {
|
|
148
|
-
var
|
|
149
|
-
return
|
|
130
|
+
var l = p(this.type);
|
|
131
|
+
return X[l] || (X[l] = !0, console.error(
|
|
150
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."
|
|
151
|
-
)),
|
|
133
|
+
)), l = this.props.ref, l !== void 0 ? l : null;
|
|
152
134
|
}
|
|
153
|
-
function h(
|
|
154
|
-
var
|
|
155
|
-
return
|
|
156
|
-
$$typeof:
|
|
157
|
-
type:
|
|
135
|
+
function h(l, u, w, y, I, q) {
|
|
136
|
+
var E = w.ref;
|
|
137
|
+
return l = {
|
|
138
|
+
$$typeof: C,
|
|
139
|
+
type: l,
|
|
158
140
|
key: u,
|
|
159
|
-
props:
|
|
160
|
-
_owner:
|
|
161
|
-
}, (
|
|
141
|
+
props: w,
|
|
142
|
+
_owner: y
|
|
143
|
+
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(l, "ref", {
|
|
162
144
|
enumerable: !1,
|
|
163
145
|
get: c
|
|
164
|
-
}) : Object.defineProperty(
|
|
146
|
+
}) : Object.defineProperty(l, "ref", { enumerable: !1, value: null }), l._store = {}, Object.defineProperty(l._store, "validated", {
|
|
165
147
|
configurable: !1,
|
|
166
148
|
enumerable: !1,
|
|
167
149
|
writable: !0,
|
|
168
150
|
value: 0
|
|
169
|
-
}), Object.defineProperty(
|
|
151
|
+
}), Object.defineProperty(l, "_debugInfo", {
|
|
170
152
|
configurable: !1,
|
|
171
153
|
enumerable: !1,
|
|
172
154
|
writable: !0,
|
|
173
155
|
value: null
|
|
174
|
-
}), Object.defineProperty(
|
|
156
|
+
}), Object.defineProperty(l, "_debugStack", {
|
|
175
157
|
configurable: !1,
|
|
176
158
|
enumerable: !1,
|
|
177
159
|
writable: !0,
|
|
178
|
-
value:
|
|
179
|
-
}), Object.defineProperty(
|
|
160
|
+
value: I
|
|
161
|
+
}), Object.defineProperty(l, "_debugTask", {
|
|
180
162
|
configurable: !1,
|
|
181
163
|
enumerable: !1,
|
|
182
164
|
writable: !0,
|
|
183
|
-
value:
|
|
184
|
-
}), Object.freeze && (Object.freeze(
|
|
165
|
+
value: q
|
|
166
|
+
}), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
|
|
185
167
|
}
|
|
186
|
-
function o(
|
|
187
|
-
var
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
for (
|
|
192
|
-
d(
|
|
193
|
-
Object.freeze && Object.freeze(
|
|
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);
|
|
194
176
|
} else
|
|
195
177
|
console.error(
|
|
196
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."
|
|
197
179
|
);
|
|
198
|
-
else d(
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
var
|
|
202
|
-
return
|
|
180
|
+
else d(E);
|
|
181
|
+
if (J.call(u, "key")) {
|
|
182
|
+
E = p(l);
|
|
183
|
+
var N = Object.keys(u).filter(function(le) {
|
|
184
|
+
return le !== "key";
|
|
203
185
|
});
|
|
204
|
-
|
|
186
|
+
y = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", Q[E + y] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
206
188
|
let props = %s;
|
|
207
189
|
<%s {...props} />
|
|
208
190
|
React keys must be passed directly to JSX without using spread:
|
|
209
191
|
let props = %s;
|
|
210
192
|
<%s key={someKey} {...props} />`,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
),
|
|
193
|
+
y,
|
|
194
|
+
E,
|
|
195
|
+
N,
|
|
196
|
+
E
|
|
197
|
+
), Q[E + y] = !0);
|
|
216
198
|
}
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
for (var
|
|
220
|
-
|
|
221
|
-
} else
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
typeof
|
|
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,
|
|
206
|
+
typeof l == "function" ? l.displayName || l.name || "Unknown" : l
|
|
225
207
|
), h(
|
|
226
|
-
|
|
208
|
+
l,
|
|
209
|
+
E,
|
|
227
210
|
w,
|
|
228
|
-
g,
|
|
229
211
|
i(),
|
|
230
|
-
|
|
231
|
-
|
|
212
|
+
I,
|
|
213
|
+
q
|
|
232
214
|
);
|
|
233
215
|
}
|
|
234
|
-
function d(
|
|
235
|
-
|
|
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));
|
|
236
218
|
}
|
|
237
|
-
function
|
|
238
|
-
return typeof
|
|
219
|
+
function g(l) {
|
|
220
|
+
return typeof l == "object" && l !== null && l.$$typeof === C;
|
|
239
221
|
}
|
|
240
|
-
var f = ae,
|
|
222
|
+
var f = ae, C = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), k = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"), F = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), j = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ne = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
241
223
|
return null;
|
|
242
224
|
};
|
|
243
225
|
f = {
|
|
244
|
-
react_stack_bottom_frame: function(
|
|
245
|
-
return
|
|
226
|
+
react_stack_bottom_frame: function(l) {
|
|
227
|
+
return l();
|
|
246
228
|
}
|
|
247
229
|
};
|
|
248
|
-
var
|
|
230
|
+
var G, X = {}, K = f.react_stack_bottom_frame.bind(
|
|
249
231
|
f,
|
|
250
|
-
|
|
251
|
-
)(),
|
|
252
|
-
|
|
253
|
-
var
|
|
232
|
+
n
|
|
233
|
+
)(), Z = U(s(n)), Q = {};
|
|
234
|
+
_.Fragment = L, _.jsx = function(l, u, w) {
|
|
235
|
+
var y = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
254
236
|
return o(
|
|
255
|
-
|
|
237
|
+
l,
|
|
256
238
|
u,
|
|
257
|
-
|
|
239
|
+
w,
|
|
258
240
|
!1,
|
|
259
|
-
|
|
260
|
-
|
|
241
|
+
y ? Error("react-stack-top-frame") : K,
|
|
242
|
+
y ? U(s(l)) : Z
|
|
261
243
|
);
|
|
262
|
-
},
|
|
263
|
-
var
|
|
244
|
+
}, _.jsxs = function(l, u, w) {
|
|
245
|
+
var y = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
264
246
|
return o(
|
|
265
|
-
|
|
247
|
+
l,
|
|
266
248
|
u,
|
|
267
|
-
|
|
249
|
+
w,
|
|
268
250
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
251
|
+
y ? Error("react-stack-top-frame") : K,
|
|
252
|
+
y ? U(s(l)) : Z
|
|
271
253
|
);
|
|
272
254
|
};
|
|
273
|
-
}()),
|
|
255
|
+
}()), _;
|
|
274
256
|
}
|
|
275
|
-
var
|
|
257
|
+
var se;
|
|
276
258
|
function de() {
|
|
277
|
-
return
|
|
259
|
+
return se || (se = 1, process.env.NODE_ENV === "production" ? B.exports = ce() : B.exports = he()), B.exports;
|
|
278
260
|
}
|
|
279
261
|
var ue = de();
|
|
280
262
|
class fe {
|
|
@@ -341,35 +323,35 @@ class fe {
|
|
|
341
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";
|
|
342
324
|
}
|
|
343
325
|
}
|
|
344
|
-
function
|
|
326
|
+
function W() {
|
|
345
327
|
return Math.random().toString(36).substring(2, 10);
|
|
346
328
|
}
|
|
347
329
|
function pe(p, e) {
|
|
348
|
-
function t(i,
|
|
349
|
-
return
|
|
330
|
+
function t(i, n) {
|
|
331
|
+
return n && i && i.classList && i.classList.contains(n) || n && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
|
|
350
332
|
}
|
|
351
|
-
function s(i,
|
|
352
|
-
return !i || i === document ? null : t(i,
|
|
333
|
+
function s(i, n) {
|
|
334
|
+
return !i || i === document ? null : t(i, n) ? i : s(i.parentNode, n);
|
|
353
335
|
}
|
|
354
336
|
return t(p, e) || s(p, e);
|
|
355
337
|
}
|
|
356
|
-
function
|
|
338
|
+
function H(p, e = 50, t = !1) {
|
|
357
339
|
let s;
|
|
358
340
|
return function(...i) {
|
|
359
|
-
const
|
|
360
|
-
s = null, t || p.apply(
|
|
341
|
+
const n = self, r = () => {
|
|
342
|
+
s = null, t || p.apply(n, i);
|
|
361
343
|
}, a = t && !s;
|
|
362
|
-
clearTimeout(s), s = setTimeout(r, e), a && p.apply(
|
|
344
|
+
clearTimeout(s), s = setTimeout(r, e), a && p.apply(n, i);
|
|
363
345
|
};
|
|
364
346
|
}
|
|
365
|
-
function
|
|
347
|
+
function z(p, e) {
|
|
366
348
|
return JSON.stringify(p) === JSON.stringify(e);
|
|
367
349
|
}
|
|
368
350
|
function me(p) {
|
|
369
351
|
const e = p.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, (t) => "-" + t.toLowerCase());
|
|
370
352
|
return p[0] === p[0].toUpperCase() ? e.substring(1) : e;
|
|
371
353
|
}
|
|
372
|
-
class
|
|
354
|
+
class S {
|
|
373
355
|
id;
|
|
374
356
|
value;
|
|
375
357
|
text;
|
|
@@ -384,10 +366,10 @@ class v {
|
|
|
384
366
|
data;
|
|
385
367
|
mandatory;
|
|
386
368
|
constructor(e) {
|
|
387
|
-
this.id = !e.id || e.id === "" ?
|
|
369
|
+
this.id = !e.id || e.id === "" ? W() : e.id, this.value = e.value === void 0 ? e.text || "" : e.value || "", this.text = e.text || "", this.html = e.html || "", this.defaultSelected = e.defaultSelected !== void 0 ? e.defaultSelected : !1, this.selected = e.selected !== void 0 ? e.selected : !1, this.display = e.display !== void 0 ? e.display : !0, this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.mandatory = e.mandatory !== void 0 ? e.mandatory : !1, this.placeholder = e.placeholder !== void 0 ? e.placeholder : !1, this.class = e.class || "", this.style = e.style || "", this.data = e.data || {};
|
|
388
370
|
}
|
|
389
371
|
}
|
|
390
|
-
class
|
|
372
|
+
class x {
|
|
391
373
|
id;
|
|
392
374
|
label;
|
|
393
375
|
selectAll;
|
|
@@ -395,9 +377,9 @@ class L {
|
|
|
395
377
|
closable;
|
|
396
378
|
options;
|
|
397
379
|
constructor(e) {
|
|
398
|
-
if (this.id = !e.id || e.id === "" ?
|
|
380
|
+
if (this.id = !e.id || e.id === "" ? W() : e.id, this.label = e.label || "", this.selectAll = e.selectAll === void 0 ? !1 : e.selectAll, this.selectAllText = e.selectAllText || "Select All", this.closable = e.closable || "off", this.options = [], e.options)
|
|
399
381
|
for (const t of e.options)
|
|
400
|
-
this.options.push(new
|
|
382
|
+
this.options.push(new S(t));
|
|
401
383
|
}
|
|
402
384
|
}
|
|
403
385
|
class ge {
|
|
@@ -414,7 +396,7 @@ class ge {
|
|
|
414
396
|
return new Error("Data must be an array");
|
|
415
397
|
for (let t of e)
|
|
416
398
|
if (t)
|
|
417
|
-
if (t instanceof
|
|
399
|
+
if (t instanceof x || "label" in t) {
|
|
418
400
|
if (!("label" in t))
|
|
419
401
|
return new Error("Optgroup must have a label");
|
|
420
402
|
if ("options" in t && t.options)
|
|
@@ -423,7 +405,7 @@ class ge {
|
|
|
423
405
|
if (i)
|
|
424
406
|
return i;
|
|
425
407
|
}
|
|
426
|
-
} else if (t instanceof
|
|
408
|
+
} else if (t instanceof S || "text" in t) {
|
|
427
409
|
const s = this.validateOption(t);
|
|
428
410
|
if (s)
|
|
429
411
|
return s;
|
|
@@ -439,28 +421,28 @@ class ge {
|
|
|
439
421
|
let t = [];
|
|
440
422
|
return e.forEach((s) => {
|
|
441
423
|
if (s) {
|
|
442
|
-
if (s instanceof
|
|
424
|
+
if (s instanceof x || "label" in s) {
|
|
443
425
|
let i = [];
|
|
444
|
-
"options" in s && s.options && s.options.forEach((
|
|
445
|
-
i.push(new
|
|
446
|
-
}), i.length > 0 && t.push(new
|
|
426
|
+
"options" in s && s.options && s.options.forEach((n) => {
|
|
427
|
+
i.push(new S(n));
|
|
428
|
+
}), i.length > 0 && t.push(new x(s));
|
|
447
429
|
}
|
|
448
|
-
(s instanceof
|
|
430
|
+
(s instanceof S || "text" in s) && t.push(new S(s));
|
|
449
431
|
}
|
|
450
432
|
}), t;
|
|
451
433
|
}
|
|
452
434
|
setData(e, t = !1) {
|
|
453
435
|
const s = this.partialToFullData(e);
|
|
454
436
|
if (t) {
|
|
455
|
-
const i = this.getSelectedOptions(),
|
|
437
|
+
const i = this.getSelectedOptions(), n = [];
|
|
456
438
|
i.forEach((r) => {
|
|
457
439
|
let a = !1;
|
|
458
440
|
for (const c of s) {
|
|
459
|
-
if (c instanceof
|
|
441
|
+
if (c instanceof S && c.id === r.id) {
|
|
460
442
|
a = !0;
|
|
461
443
|
break;
|
|
462
444
|
}
|
|
463
|
-
if (c instanceof
|
|
445
|
+
if (c instanceof x) {
|
|
464
446
|
for (const h of c.options)
|
|
465
447
|
if (h.id === r.id) {
|
|
466
448
|
a = !0;
|
|
@@ -468,8 +450,8 @@ class ge {
|
|
|
468
450
|
}
|
|
469
451
|
}
|
|
470
452
|
}
|
|
471
|
-
a ||
|
|
472
|
-
}), this.data = [...
|
|
453
|
+
a || n.push(r);
|
|
454
|
+
}), this.data = [...n, ...s];
|
|
473
455
|
} else
|
|
474
456
|
this.data = s;
|
|
475
457
|
this.selectType === "single" && this.setSelectedBy("id", this.getSelected());
|
|
@@ -485,28 +467,28 @@ class ge {
|
|
|
485
467
|
}
|
|
486
468
|
addOption(e, t = !1) {
|
|
487
469
|
if (t) {
|
|
488
|
-
let s = [new
|
|
470
|
+
let s = [new S(e)];
|
|
489
471
|
this.setData(s.concat(this.getData()));
|
|
490
472
|
} else
|
|
491
|
-
this.setData(this.getData().concat(new
|
|
473
|
+
this.setData(this.getData().concat(new S(e)));
|
|
492
474
|
}
|
|
493
475
|
// Pass in an array of id that will loop through
|
|
494
476
|
// each option and set the selected property to true
|
|
495
477
|
// but also clean selected by determining selectType
|
|
496
478
|
setSelectedBy(e, t) {
|
|
497
479
|
let s = null, i = !1;
|
|
498
|
-
const
|
|
480
|
+
const n = [];
|
|
499
481
|
for (let a of this.data) {
|
|
500
|
-
if (a instanceof
|
|
482
|
+
if (a instanceof x)
|
|
501
483
|
for (let c of a.options) {
|
|
502
484
|
s || (s = c);
|
|
503
485
|
let h = c[e] || "";
|
|
504
|
-
c.selected = i ? !1 : t.includes(h), c.selected && (
|
|
486
|
+
c.selected = i ? !1 : t.includes(h), c.selected && (n.push(c), this.selectType === "single" && (i = !0));
|
|
505
487
|
}
|
|
506
|
-
a instanceof
|
|
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)));
|
|
507
489
|
}
|
|
508
|
-
this.selectType === "single" && s && !i && (s.selected = !0,
|
|
509
|
-
const r = t.map((a) =>
|
|
490
|
+
this.selectType === "single" && s && !i && (s.selected = !0, n.push(s));
|
|
491
|
+
const r = t.map((a) => n.find((c) => c[e] === a)?.id || "");
|
|
510
492
|
this.selectedOrder = r;
|
|
511
493
|
}
|
|
512
494
|
getSelected() {
|
|
@@ -520,7 +502,7 @@ class ge {
|
|
|
520
502
|
}
|
|
521
503
|
getOptgroupByID(e) {
|
|
522
504
|
for (let t of this.data)
|
|
523
|
-
if (t instanceof
|
|
505
|
+
if (t instanceof x && t.id === e)
|
|
524
506
|
return t;
|
|
525
507
|
return null;
|
|
526
508
|
}
|
|
@@ -534,7 +516,7 @@ class ge {
|
|
|
534
516
|
getFirstOption() {
|
|
535
517
|
let e = null;
|
|
536
518
|
for (let t of this.data)
|
|
537
|
-
if (t instanceof
|
|
519
|
+
if (t instanceof x ? e = t.options[0] : t instanceof S && (e = t), e)
|
|
538
520
|
break;
|
|
539
521
|
return e;
|
|
540
522
|
}
|
|
@@ -547,28 +529,28 @@ class ge {
|
|
|
547
529
|
filter(e, t) {
|
|
548
530
|
const s = [];
|
|
549
531
|
return this.data.forEach((i) => {
|
|
550
|
-
if (i instanceof
|
|
551
|
-
let
|
|
532
|
+
if (i instanceof x) {
|
|
533
|
+
let n = [];
|
|
552
534
|
if (i.options.forEach((a) => {
|
|
553
|
-
(!e || e(a)) && (t ?
|
|
554
|
-
}),
|
|
555
|
-
let a = new
|
|
556
|
-
a.options =
|
|
535
|
+
(!e || e(a)) && (t ? n.push(new S(a)) : s.push(new S(a)));
|
|
536
|
+
}), n.length > 0) {
|
|
537
|
+
let a = new x(i);
|
|
538
|
+
a.options = n, s.push(a);
|
|
557
539
|
}
|
|
558
540
|
}
|
|
559
|
-
i instanceof
|
|
541
|
+
i instanceof S && (!e || e(i)) && s.push(new S(i));
|
|
560
542
|
}), s;
|
|
561
543
|
}
|
|
562
544
|
// Take in an array of options and reoder them based upon the selected order
|
|
563
545
|
selectedOrderOptions(e) {
|
|
564
546
|
const t = [];
|
|
565
547
|
return this.selectedOrder.forEach((s) => {
|
|
566
|
-
const i = e.find((
|
|
548
|
+
const i = e.find((n) => n.id === s);
|
|
567
549
|
i && t.push(i);
|
|
568
550
|
}), e.forEach((s) => {
|
|
569
551
|
let i = !1;
|
|
570
|
-
t.forEach((
|
|
571
|
-
if (s.id ===
|
|
552
|
+
t.forEach((n) => {
|
|
553
|
+
if (s.id === n.id) {
|
|
572
554
|
i = !0;
|
|
573
555
|
return;
|
|
574
556
|
}
|
|
@@ -604,8 +586,8 @@ class ve {
|
|
|
604
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();
|
|
605
587
|
const s = this.store.getSelectedOptions();
|
|
606
588
|
if (s.length) {
|
|
607
|
-
const i = s[s.length - 1].id,
|
|
608
|
-
|
|
589
|
+
const i = s[s.length - 1].id, n = this.content.list.querySelector('[data-id="' + i + '"]');
|
|
590
|
+
n && this.ensureElementInView(this.content.list, n);
|
|
609
591
|
}
|
|
610
592
|
}
|
|
611
593
|
close() {
|
|
@@ -654,21 +636,21 @@ class ve {
|
|
|
654
636
|
if (h.stopPropagation(), this.settings.disabled)
|
|
655
637
|
return;
|
|
656
638
|
let o = !0;
|
|
657
|
-
const d = this.store.getSelectedOptions(),
|
|
658
|
-
if (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(
|
|
639
|
+
const d = this.store.getSelectedOptions(), g = [];
|
|
640
|
+
if (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(g, d) === !0), o) {
|
|
659
641
|
if (this.settings.isMultiple)
|
|
660
642
|
this.callbacks.setSelected([], !1), this.updateDeselectAll();
|
|
661
643
|
else {
|
|
662
|
-
const f = this.store.getFirstOption(),
|
|
663
|
-
this.callbacks.setSelected(
|
|
644
|
+
const f = this.store.getFirstOption(), C = f ? f.id : "";
|
|
645
|
+
this.callbacks.setSelected(C, !1);
|
|
664
646
|
}
|
|
665
647
|
this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
|
|
666
648
|
}
|
|
667
649
|
};
|
|
668
|
-
const
|
|
669
|
-
|
|
650
|
+
const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
651
|
+
n.setAttribute("viewBox", "0 0 100 100");
|
|
670
652
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
671
|
-
r.setAttribute("d", this.classes.deselectPath),
|
|
653
|
+
r.setAttribute("d", this.classes.deselectPath), n.appendChild(r), s.appendChild(n), e.appendChild(s);
|
|
672
654
|
const a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
673
655
|
a.classList.add(this.classes.arrow), a.setAttribute("viewBox", "0 0 100 100");
|
|
674
656
|
const c = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
@@ -677,7 +659,7 @@ class ve {
|
|
|
677
659
|
values: t,
|
|
678
660
|
deselect: {
|
|
679
661
|
main: s,
|
|
680
|
-
svg:
|
|
662
|
+
svg: n,
|
|
681
663
|
path: r
|
|
682
664
|
},
|
|
683
665
|
arrow: {
|
|
@@ -735,8 +717,8 @@ class ve {
|
|
|
735
717
|
this.settings.keepOrder && (t = this.store.selectedOrderOptions(t));
|
|
736
718
|
let s = [];
|
|
737
719
|
for (let i = 0; i < e.length; i++) {
|
|
738
|
-
const
|
|
739
|
-
r && (t.filter((c) => c.id === r, !1).length || s.push(
|
|
720
|
+
const n = e[i], r = n.getAttribute("data-id");
|
|
721
|
+
r && (t.filter((c) => c.id === r, !1).length || s.push(n));
|
|
740
722
|
}
|
|
741
723
|
for (const i of s)
|
|
742
724
|
i.classList.add(this.classes.valueOut), setTimeout(() => {
|
|
@@ -744,10 +726,10 @@ class ve {
|
|
|
744
726
|
}, 100);
|
|
745
727
|
e = this.main.values.childNodes;
|
|
746
728
|
for (let i = 0; i < t.length; i++) {
|
|
747
|
-
let
|
|
729
|
+
let n = !0;
|
|
748
730
|
for (let r = 0; r < e.length; r++)
|
|
749
|
-
t[i].id === String(e[r].dataset.id) && (
|
|
750
|
-
|
|
731
|
+
t[i].id === String(e[r].dataset.id) && (n = !1);
|
|
732
|
+
n && (this.settings.keepOrder ? this.main.values.appendChild(this.multipleValue(t[i])) : e.length === 0 ? this.main.values.appendChild(this.multipleValue(t[i])) : i === 0 ? this.main.values.insertBefore(this.multipleValue(t[i]), e[i]) : e[i - 1].insertAdjacentElement("afterend", this.multipleValue(t[i])));
|
|
751
733
|
}
|
|
752
734
|
}
|
|
753
735
|
multipleValue(e) {
|
|
@@ -763,19 +745,19 @@ class ve {
|
|
|
763
745
|
const h = this.store.getSelectedOptions(), o = h.filter((d) => d.selected && d.id !== e.id, !0);
|
|
764
746
|
if (!(this.settings.minSelected && o.length < this.settings.minSelected) && (this.callbacks.beforeChange && (c = this.callbacks.beforeChange(o, h) === !0), c)) {
|
|
765
747
|
let d = [];
|
|
766
|
-
for (const
|
|
767
|
-
if (
|
|
768
|
-
for (const f of
|
|
748
|
+
for (const g of o) {
|
|
749
|
+
if (g instanceof x)
|
|
750
|
+
for (const f of g.options)
|
|
769
751
|
f.id && d.push(f.id);
|
|
770
|
-
|
|
752
|
+
g instanceof S && d.push(g.id);
|
|
771
753
|
}
|
|
772
754
|
this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(o), this.updateDeselectAll();
|
|
773
755
|
}
|
|
774
756
|
};
|
|
775
|
-
const
|
|
776
|
-
|
|
757
|
+
const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
758
|
+
n.setAttribute("viewBox", "0 0 100 100");
|
|
777
759
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
778
|
-
r.setAttribute("d", this.classes.optionDelete),
|
|
760
|
+
r.setAttribute("d", this.classes.optionDelete), n.appendChild(r), i.appendChild(n), t.appendChild(i), i.onkeydown = (a) => {
|
|
779
761
|
a.key === "Enter" && i.click();
|
|
780
762
|
};
|
|
781
763
|
}
|
|
@@ -814,13 +796,13 @@ class ve {
|
|
|
814
796
|
main: e,
|
|
815
797
|
input: t
|
|
816
798
|
};
|
|
817
|
-
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 =
|
|
818
|
-
this.callbacks.search(
|
|
819
|
-
}, 100), t.onkeydown = (
|
|
820
|
-
switch (
|
|
799
|
+
if (this.settings.showSearch || (e.classList.add(this.classes.hide), t.readOnly = !0), t.type = "search", t.placeholder = this.settings.searchPlaceholder, t.tabIndex = -1, t.setAttribute("aria-label", this.settings.searchPlaceholder), t.setAttribute("aria-autocomplete", "list"), t.setAttribute("autocapitalize", "off"), t.setAttribute("autocomplete", "off"), t.setAttribute("autocorrect", "off"), t.setAttribute("aria-hidden", "true"), t.oninput = H((n) => {
|
|
800
|
+
this.callbacks.search(n.target.value);
|
|
801
|
+
}, 100), t.onkeydown = (n) => {
|
|
802
|
+
switch (n.key) {
|
|
821
803
|
case "ArrowUp":
|
|
822
804
|
case "ArrowDown":
|
|
823
|
-
return
|
|
805
|
+
return n.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
|
|
824
806
|
case "Tab":
|
|
825
807
|
return this.callbacks.close(), !0;
|
|
826
808
|
// Continue doing normal tabbing
|
|
@@ -836,10 +818,10 @@ class ve {
|
|
|
836
818
|
return !0;
|
|
837
819
|
}, e.appendChild(t), this.callbacks.addable) {
|
|
838
820
|
s.classList.add(this.classes.addable);
|
|
839
|
-
const
|
|
840
|
-
|
|
821
|
+
const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
822
|
+
n.setAttribute("viewBox", "0 0 100 100");
|
|
841
823
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
842
|
-
r.setAttribute("d", this.classes.addablePath),
|
|
824
|
+
r.setAttribute("d", this.classes.addablePath), n.appendChild(r), s.appendChild(n), s.onclick = (a) => {
|
|
843
825
|
if (a.preventDefault(), a.stopPropagation(), !this.callbacks.addable)
|
|
844
826
|
return;
|
|
845
827
|
const c = this.content.search.input.value.trim();
|
|
@@ -848,12 +830,12 @@ class ve {
|
|
|
848
830
|
return;
|
|
849
831
|
}
|
|
850
832
|
const h = (d) => {
|
|
851
|
-
let
|
|
852
|
-
if (this.callbacks.addOption(
|
|
833
|
+
let g = new S(d);
|
|
834
|
+
if (this.callbacks.addOption(g), this.settings.isMultiple) {
|
|
853
835
|
let f = this.store.getSelected();
|
|
854
|
-
f.push(
|
|
836
|
+
f.push(g.id), this.callbacks.setSelected(f, !0);
|
|
855
837
|
} else
|
|
856
|
-
this.callbacks.setSelected([
|
|
838
|
+
this.callbacks.setSelected([g.id], !0);
|
|
857
839
|
this.callbacks.search(""), this.settings.closeOnSelect && setTimeout(() => {
|
|
858
840
|
this.callbacks.close();
|
|
859
841
|
}, 100);
|
|
@@ -869,7 +851,7 @@ class ve {
|
|
|
869
851
|
}) : o instanceof Error ? this.renderError(o.message) : h(o));
|
|
870
852
|
}, e.appendChild(s), i.addable = {
|
|
871
853
|
main: s,
|
|
872
|
-
svg:
|
|
854
|
+
svg: n,
|
|
873
855
|
path: r
|
|
874
856
|
};
|
|
875
857
|
}
|
|
@@ -892,25 +874,25 @@ class ve {
|
|
|
892
874
|
return;
|
|
893
875
|
}
|
|
894
876
|
let s = !1;
|
|
895
|
-
for (const
|
|
896
|
-
|
|
877
|
+
for (const n of t)
|
|
878
|
+
n.classList.contains(this.classes.highlighted) && (s = !0);
|
|
897
879
|
if (!s) {
|
|
898
|
-
for (const
|
|
899
|
-
if (
|
|
900
|
-
|
|
880
|
+
for (const n of t)
|
|
881
|
+
if (n.classList.contains(this.classes.selected)) {
|
|
882
|
+
n.classList.add(this.classes.highlighted);
|
|
901
883
|
break;
|
|
902
884
|
}
|
|
903
885
|
}
|
|
904
|
-
for (let
|
|
905
|
-
if (t[
|
|
906
|
-
const r = t[
|
|
886
|
+
for (let n = 0; n < t.length; n++)
|
|
887
|
+
if (t[n].classList.contains(this.classes.highlighted)) {
|
|
888
|
+
const r = t[n];
|
|
907
889
|
r.classList.remove(this.classes.highlighted);
|
|
908
890
|
const a = r.parentElement;
|
|
909
891
|
if (a && a.classList.contains(this.classes.mainOpen)) {
|
|
910
892
|
const o = a.querySelector("." + this.classes.optgroupLabel);
|
|
911
893
|
o && o.click();
|
|
912
894
|
}
|
|
913
|
-
let c = t[e === "down" ?
|
|
895
|
+
let c = t[e === "down" ? n + 1 < t.length ? n + 1 : 0 : n - 1 >= 0 ? n - 1 : t.length - 1];
|
|
914
896
|
c.classList.add(this.classes.highlighted), this.ensureElementInView(this.content.list, c), c.id && this.main.main.setAttribute("aria-activedescendant", c.id);
|
|
915
897
|
const h = c.parentElement;
|
|
916
898
|
if (h && h.classList.contains(this.classes.close)) {
|
|
@@ -947,7 +929,7 @@ class ve {
|
|
|
947
929
|
return;
|
|
948
930
|
}
|
|
949
931
|
this.settings.allowDeselect && !this.settings.isMultiple && (this.store.filter((i) => i.placeholder, !1).length || this.store.addOption(
|
|
950
|
-
new
|
|
932
|
+
new S({
|
|
951
933
|
text: "",
|
|
952
934
|
value: "",
|
|
953
935
|
selected: !1,
|
|
@@ -957,20 +939,20 @@ class ve {
|
|
|
957
939
|
));
|
|
958
940
|
const t = document.createDocumentFragment();
|
|
959
941
|
for (const s of e) {
|
|
960
|
-
if (s instanceof
|
|
942
|
+
if (s instanceof x) {
|
|
961
943
|
const i = document.createElement("div");
|
|
962
944
|
i.classList.add(this.classes.optgroup);
|
|
963
|
-
const
|
|
964
|
-
|
|
945
|
+
const n = document.createElement("div");
|
|
946
|
+
n.classList.add(this.classes.optgroupLabel), i.appendChild(n);
|
|
965
947
|
const r = document.createElement("div");
|
|
966
|
-
r.classList.add(this.classes.optgroupLabelText), r.textContent = s.label,
|
|
948
|
+
r.classList.add(this.classes.optgroupLabelText), r.textContent = s.label, n.appendChild(r);
|
|
967
949
|
const a = document.createElement("div");
|
|
968
|
-
if (a.classList.add(this.classes.optgroupActions),
|
|
950
|
+
if (a.classList.add(this.classes.optgroupActions), n.appendChild(a), this.settings.isMultiple && s.selectAll) {
|
|
969
951
|
const c = document.createElement("div");
|
|
970
952
|
c.classList.add(this.classes.optgroupSelectAll);
|
|
971
953
|
let h = !0;
|
|
972
|
-
for (const
|
|
973
|
-
if (!
|
|
954
|
+
for (const C of s.options)
|
|
955
|
+
if (!C.selected) {
|
|
974
956
|
h = !1;
|
|
975
957
|
break;
|
|
976
958
|
}
|
|
@@ -979,27 +961,27 @@ class ve {
|
|
|
979
961
|
o.textContent = s.selectAllText, c.appendChild(o);
|
|
980
962
|
const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
981
963
|
d.setAttribute("viewBox", "0 0 100 100"), c.appendChild(d);
|
|
982
|
-
const
|
|
983
|
-
|
|
964
|
+
const g = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
965
|
+
g.setAttribute("d", this.classes.optgroupSelectAllBox), d.appendChild(g);
|
|
984
966
|
const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
985
|
-
f.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(f), c.addEventListener("click", (
|
|
986
|
-
|
|
987
|
-
const
|
|
967
|
+
f.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(f), c.addEventListener("click", (C) => {
|
|
968
|
+
C.preventDefault(), C.stopPropagation();
|
|
969
|
+
const m = this.store.getSelected();
|
|
988
970
|
if (h) {
|
|
989
|
-
const
|
|
990
|
-
for (const
|
|
991
|
-
if (
|
|
971
|
+
const L = m.filter((O) => {
|
|
972
|
+
for (const v of s.options)
|
|
973
|
+
if (O === v.id)
|
|
992
974
|
return !1;
|
|
993
975
|
return !0;
|
|
994
976
|
});
|
|
995
|
-
this.callbacks.setSelected(
|
|
977
|
+
this.callbacks.setSelected(L, !0);
|
|
996
978
|
return;
|
|
997
979
|
} else {
|
|
998
|
-
let
|
|
999
|
-
const
|
|
1000
|
-
for (const
|
|
1001
|
-
|
|
1002
|
-
this.callbacks.setSelected(
|
|
980
|
+
let L = s.options.map((v) => v.id).filter((v) => v !== void 0);
|
|
981
|
+
const O = m.concat(L);
|
|
982
|
+
for (const v of s.options)
|
|
983
|
+
v.id && !this.store.getOptionByID(v.id) && this.callbacks.addOption(new S(v));
|
|
984
|
+
this.callbacks.setSelected(O, !0);
|
|
1003
985
|
return;
|
|
1004
986
|
}
|
|
1005
987
|
}), a.appendChild(c);
|
|
@@ -1010,15 +992,15 @@ class ve {
|
|
|
1010
992
|
const h = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1011
993
|
h.setAttribute("viewBox", "0 0 100 100"), h.classList.add(this.classes.arrow), c.appendChild(h);
|
|
1012
994
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1013
|
-
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)),
|
|
995
|
+
h.appendChild(o), s.options.some((d) => d.selected) || this.content.search.input.value.trim() !== "" ? (c.classList.add(this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : s.closable === "open" ? (i.classList.add(this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : s.closable === "close" && (i.classList.add(this.classes.close), o.setAttribute("d", this.classes.arrowClose)), n.addEventListener("click", (d) => {
|
|
1014
996
|
d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.close) ? (i.classList.remove(this.classes.close), i.classList.add(this.classes.mainOpen), o.setAttribute("d", this.classes.arrowOpen)) : (i.classList.remove(this.classes.mainOpen), i.classList.add(this.classes.close), o.setAttribute("d", this.classes.arrowClose));
|
|
1015
997
|
}), a.appendChild(c);
|
|
1016
998
|
}
|
|
1017
|
-
i.appendChild(
|
|
999
|
+
i.appendChild(n);
|
|
1018
1000
|
for (const c of s.options)
|
|
1019
|
-
i.appendChild(this.option(new
|
|
1001
|
+
i.appendChild(this.option(new S(c))), t.appendChild(i);
|
|
1020
1002
|
}
|
|
1021
|
-
s instanceof
|
|
1003
|
+
s instanceof S && t.appendChild(this.option(s));
|
|
1022
1004
|
}
|
|
1023
1005
|
this.content.list.appendChild(t);
|
|
1024
1006
|
}
|
|
@@ -1037,7 +1019,7 @@ class ve {
|
|
|
1037
1019
|
this.classes.searchHighlighter
|
|
1038
1020
|
) : e.html !== "" ? t.innerHTML = e.html : t.textContent = e.text, this.settings.showOptionTooltips && t.textContent && t.setAttribute("title", t.textContent), e.display || t.classList.add(this.classes.hide), e.disabled && t.classList.add(this.classes.disabled), e.selected && this.settings.hideSelected && t.classList.add(this.classes.hide), e.selected ? (t.classList.add(this.classes.selected), t.setAttribute("aria-selected", "true"), this.main.main.setAttribute("aria-activedescendant", t.id)) : (t.classList.remove(this.classes.selected), t.setAttribute("aria-selected", "false")), t.addEventListener("click", (s) => {
|
|
1039
1021
|
s.preventDefault(), s.stopPropagation();
|
|
1040
|
-
const i = this.store.getSelected(),
|
|
1022
|
+
const i = this.store.getSelected(), n = s.currentTarget, r = String(n.dataset.id), a = s.ctrlKey || s.metaKey;
|
|
1041
1023
|
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)
|
|
1042
1024
|
return;
|
|
1043
1025
|
let c = !1;
|
|
@@ -1046,10 +1028,10 @@ class ve {
|
|
|
1046
1028
|
if (this.settings.isMultiple) {
|
|
1047
1029
|
const d = h.some((f) => f.id === r);
|
|
1048
1030
|
if (s.shiftKey && this.lastSelectedOption) {
|
|
1049
|
-
const f = this.store.getDataOptions(),
|
|
1050
|
-
if (
|
|
1051
|
-
const
|
|
1052
|
-
h.length +
|
|
1031
|
+
const f = this.store.getDataOptions(), C = f.findIndex((L) => L.id === this.lastSelectedOption.id), m = f.findIndex((L) => L.id === e.id);
|
|
1032
|
+
if (C >= 0 && m >= 0) {
|
|
1033
|
+
const L = Math.min(C, m), O = Math.max(C, m), T = f.slice(L, O + 1).filter((k) => !h.find((b) => b.id === k.id));
|
|
1034
|
+
h.length + T.length <= this.settings.maxSelected ? o = h.concat(T) : o = h;
|
|
1053
1035
|
} else
|
|
1054
1036
|
o = h;
|
|
1055
1037
|
} else a ? (d ? o = h.filter((f) => f.id !== r) : o = h.concat(e), this.lastSelectedOption = e) : (d ? o = h.filter((f) => f.id !== r) : o = h.concat(e), this.lastSelectedOption = e);
|
|
@@ -1071,17 +1053,17 @@ class ve {
|
|
|
1071
1053
|
const i = t.trim();
|
|
1072
1054
|
if (i === "")
|
|
1073
1055
|
return e;
|
|
1074
|
-
const
|
|
1056
|
+
const n = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), r = document.createElement("div");
|
|
1075
1057
|
r.innerHTML = e;
|
|
1076
1058
|
const a = (c) => {
|
|
1077
1059
|
if (c.nodeType === Node.TEXT_NODE) {
|
|
1078
|
-
const h = c.textContent || "", o = new RegExp("(" +
|
|
1060
|
+
const h = c.textContent || "", o = new RegExp("(" + n + ")", "i");
|
|
1079
1061
|
if (o.test(h)) {
|
|
1080
1062
|
const d = document.createElement("span");
|
|
1081
|
-
h.split(o).forEach((f,
|
|
1063
|
+
h.split(o).forEach((f, C) => {
|
|
1082
1064
|
if (f && o.test(f)) {
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1065
|
+
const m = document.createElement("mark");
|
|
1066
|
+
m.className = s, m.textContent = f, d.appendChild(m);
|
|
1085
1067
|
} else f && d.appendChild(document.createTextNode(f));
|
|
1086
1068
|
}), c.parentNode?.replaceChild(d, c);
|
|
1087
1069
|
}
|
|
@@ -1101,8 +1083,8 @@ class ve {
|
|
|
1101
1083
|
this.content.main.style.margin = "-1px 0px 0px 0px", this.settings.contentPosition !== "relative" && (this.content.main.style.top = e.top + e.height + (this.settings.contentPosition === "fixed" ? 0 : window.scrollY) + "px", this.content.main.style.left = e.left + (this.settings.contentPosition === "fixed" ? 0 : window.scrollX) + "px", this.content.main.style.width = e.width + "px");
|
|
1102
1084
|
}
|
|
1103
1085
|
ensureElementInView(e, t) {
|
|
1104
|
-
const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight,
|
|
1105
|
-
|
|
1086
|
+
const s = e.scrollTop + e.offsetTop, i = s + e.clientHeight, n = t.offsetTop, r = n + t.clientHeight;
|
|
1087
|
+
n < s ? e.scrollTop -= s - n : r > i && (e.scrollTop += r - i);
|
|
1106
1088
|
}
|
|
1107
1089
|
putContent() {
|
|
1108
1090
|
const e = this.main.main.offsetHeight, t = this.main.main.getBoundingClientRect(), s = this.content.main.offsetHeight;
|
|
@@ -1112,8 +1094,8 @@ class ve {
|
|
|
1112
1094
|
updateDeselectAll() {
|
|
1113
1095
|
if (!this.store || !this.settings)
|
|
1114
1096
|
return;
|
|
1115
|
-
const e = this.store.getSelectedOptions(), t = e && e.length > 0, s = this.settings.isMultiple, i = this.settings.allowDeselect,
|
|
1116
|
-
i && !(s && !t) ?
|
|
1097
|
+
const e = this.store.getSelectedOptions(), t = e && e.length > 0, s = this.settings.isMultiple, i = this.settings.allowDeselect, n = this.main.deselect.main, r = this.classes.hide;
|
|
1098
|
+
i && !(s && !t) ? n.classList.remove(r) : n.classList.add(r);
|
|
1117
1099
|
}
|
|
1118
1100
|
}
|
|
1119
1101
|
class be {
|
|
@@ -1127,6 +1109,8 @@ class be {
|
|
|
1127
1109
|
// Change observers
|
|
1128
1110
|
listen = !1;
|
|
1129
1111
|
observer = null;
|
|
1112
|
+
isUpdating = !1;
|
|
1113
|
+
pendingOptionsChange = null;
|
|
1130
1114
|
// Event handlers for preventing native select behavior (especially on iOS Safari)
|
|
1131
1115
|
preventNativeSelect = null;
|
|
1132
1116
|
preventNativeSelectMousedown = null;
|
|
@@ -1174,18 +1158,27 @@ class be {
|
|
|
1174
1158
|
if (!this.listen)
|
|
1175
1159
|
return;
|
|
1176
1160
|
let t = !1, s = !1, i = !1;
|
|
1177
|
-
for (const
|
|
1178
|
-
if (
|
|
1179
|
-
for (const r of Array.from(
|
|
1161
|
+
for (const n of e) {
|
|
1162
|
+
if (n.target === this.select && (n.attributeName === "disabled" && (s = !0), n.attributeName === "class" && (t = !0), n.type === "childList")) {
|
|
1163
|
+
for (const r of Array.from(n.addedNodes))
|
|
1180
1164
|
if (r.nodeName === "OPTION" && r.value === this.select.value) {
|
|
1181
1165
|
this.select.dispatchEvent(new Event("change"));
|
|
1182
1166
|
break;
|
|
1183
1167
|
}
|
|
1184
1168
|
i = !0;
|
|
1185
1169
|
}
|
|
1186
|
-
(
|
|
1170
|
+
(n.target.nodeName === "OPTGROUP" || n.target.nodeName === "OPTION") && (i = !0);
|
|
1171
|
+
}
|
|
1172
|
+
if (t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), s && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)), i && this.onOptionsChange) {
|
|
1173
|
+
if (this.isUpdating) {
|
|
1174
|
+
if (this.select.options.length > 0) {
|
|
1175
|
+
const n = this.getData();
|
|
1176
|
+
n.length > 0 && (this.pendingOptionsChange = n);
|
|
1177
|
+
}
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
|
|
1187
1181
|
}
|
|
1188
|
-
t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), s && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)), i && this.onOptionsChange && (this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0));
|
|
1189
1182
|
}
|
|
1190
1183
|
// From the select element pull optgroup and options into data
|
|
1191
1184
|
getData() {
|
|
@@ -1233,9 +1226,9 @@ class be {
|
|
|
1233
1226
|
for (const s of t) {
|
|
1234
1227
|
if (s.nodeName === "OPTGROUP") {
|
|
1235
1228
|
const i = s.childNodes;
|
|
1236
|
-
for (const
|
|
1237
|
-
if (
|
|
1238
|
-
const r =
|
|
1229
|
+
for (const n of i)
|
|
1230
|
+
if (n.nodeName === "OPTION") {
|
|
1231
|
+
const r = n;
|
|
1239
1232
|
r.selected && e.push(this.getDataFromOption(r));
|
|
1240
1233
|
}
|
|
1241
1234
|
}
|
|
@@ -1254,8 +1247,8 @@ class be {
|
|
|
1254
1247
|
const t = this.select.childNodes;
|
|
1255
1248
|
for (const s of t) {
|
|
1256
1249
|
if (s.nodeName === "OPTGROUP") {
|
|
1257
|
-
const
|
|
1258
|
-
for (const r of
|
|
1250
|
+
const n = s.childNodes;
|
|
1251
|
+
for (const r of n)
|
|
1259
1252
|
if (r.nodeName === "OPTION") {
|
|
1260
1253
|
const a = r;
|
|
1261
1254
|
a.selected = e.includes(a.id);
|
|
@@ -1277,8 +1270,8 @@ class be {
|
|
|
1277
1270
|
const t = this.select.childNodes;
|
|
1278
1271
|
for (const s of t) {
|
|
1279
1272
|
if (s.nodeName === "OPTGROUP") {
|
|
1280
|
-
const
|
|
1281
|
-
for (const r of
|
|
1273
|
+
const n = s.childNodes;
|
|
1274
|
+
for (const r of n)
|
|
1282
1275
|
if (r.nodeName === "OPTION") {
|
|
1283
1276
|
const a = r;
|
|
1284
1277
|
a.selected = e.includes(a.value);
|
|
@@ -1297,10 +1290,15 @@ class be {
|
|
|
1297
1290
|
})), this.changeListen(!0);
|
|
1298
1291
|
}
|
|
1299
1292
|
updateOptions(e) {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1293
|
+
if (!(!e || e.length === 0)) {
|
|
1294
|
+
this.isUpdating = !0, this.pendingOptionsChange = null, this.changeListen(!1), this.select.innerHTML = "";
|
|
1295
|
+
for (const t of e)
|
|
1296
|
+
t instanceof x && this.select.appendChild(this.createOptgroup(t)), t instanceof S && this.select.appendChild(this.createOption(t));
|
|
1297
|
+
if (this.select.dispatchEvent(new Event("change", { bubbles: !0 })), this.changeListen(!0), this.isUpdating = !1, this.pendingOptionsChange !== null) {
|
|
1298
|
+
const t = this.pendingOptionsChange;
|
|
1299
|
+
t.length > 0 && this.onOptionsChange ? (this.pendingOptionsChange = null, this.changeListen(!1), this.onOptionsChange(t), this.changeListen(!0)) : this.pendingOptionsChange = null;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1304
1302
|
}
|
|
1305
1303
|
createOptgroup(e) {
|
|
1306
1304
|
const t = document.createElement("optgroup");
|
|
@@ -1329,15 +1327,15 @@ class be {
|
|
|
1329
1327
|
}
|
|
1330
1328
|
s = s.parentElement;
|
|
1331
1329
|
}
|
|
1332
|
-
Array.from(new Set(e)).forEach((
|
|
1333
|
-
if (
|
|
1330
|
+
Array.from(new Set(e)).forEach((n) => {
|
|
1331
|
+
if (n.__slimSelectLabelHandler)
|
|
1334
1332
|
return;
|
|
1335
1333
|
const r = (a) => {
|
|
1336
1334
|
a.preventDefault(), a.stopPropagation(), this.onLabelClick && setTimeout(() => {
|
|
1337
1335
|
this.onLabelClick();
|
|
1338
1336
|
}, 0);
|
|
1339
1337
|
};
|
|
1340
|
-
|
|
1338
|
+
n.__slimSelectLabelHandler = r, n.addEventListener("click", r, { capture: !0, passive: !1 });
|
|
1341
1339
|
});
|
|
1342
1340
|
}
|
|
1343
1341
|
// Remove label handlers
|
|
@@ -1352,9 +1350,9 @@ class be {
|
|
|
1352
1350
|
}
|
|
1353
1351
|
s = s.parentElement;
|
|
1354
1352
|
}
|
|
1355
|
-
Array.from(new Set(e)).forEach((
|
|
1356
|
-
const r =
|
|
1357
|
-
r && (
|
|
1353
|
+
Array.from(new Set(e)).forEach((n) => {
|
|
1354
|
+
const r = n.__slimSelectLabelHandler;
|
|
1355
|
+
r && (n.removeEventListener("click", r, { capture: !0 }), delete n.__slimSelectLabelHandler);
|
|
1358
1356
|
});
|
|
1359
1357
|
}
|
|
1360
1358
|
destroy() {
|
|
@@ -1399,7 +1397,7 @@ class we {
|
|
|
1399
1397
|
maxValuesMessage;
|
|
1400
1398
|
addableText;
|
|
1401
1399
|
constructor(e) {
|
|
1402
|
-
e || (e = {}), this.id = "ss-" +
|
|
1400
|
+
e || (e = {}), this.id = "ss-" + W(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.alwaysOpen = e.alwaysOpen !== void 0 ? e.alwaysOpen : !1, this.showSearch = e.showSearch !== void 0 ? e.showSearch : !0, this.focusSearch = e.focusSearch !== void 0 ? e.focusSearch : !0, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.searchHighlight = e.searchHighlight !== void 0 ? e.searchHighlight : !1, this.closeOnSelect = e.closeOnSelect !== void 0 ? e.closeOnSelect : !0, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || 'Press "Enter" to add {value}';
|
|
1403
1401
|
}
|
|
1404
1402
|
}
|
|
1405
1403
|
let Se = class {
|
|
@@ -1437,7 +1435,7 @@ let Se = class {
|
|
|
1437
1435
|
this.selectEl.dataset.ssid && this.destroy(), this.settings = new we(e.settings), this.cssClasses = new fe(e.cssClasses);
|
|
1438
1436
|
const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
|
|
1439
1437
|
for (const a in e.events)
|
|
1440
|
-
e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] =
|
|
1438
|
+
e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = H(e.events[a], 100) : this.events[a] = e.events[a]);
|
|
1441
1439
|
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) => {
|
|
1442
1440
|
this.setSelected(a.map((c) => c.id));
|
|
1443
1441
|
}, this.select.onClassChange = (a) => {
|
|
@@ -1445,7 +1443,7 @@ let Se = class {
|
|
|
1445
1443
|
}, this.select.onDisabledChange = (a) => {
|
|
1446
1444
|
a ? this.disable() : this.enable();
|
|
1447
1445
|
}, this.select.onOptionsChange = (a) => {
|
|
1448
|
-
this.setData(a);
|
|
1446
|
+
this.setData(a || []);
|
|
1449
1447
|
}, this.select.onLabelClick = () => {
|
|
1450
1448
|
this.settings.disabled || this.open();
|
|
1451
1449
|
};
|
|
@@ -1462,8 +1460,8 @@ let Se = class {
|
|
|
1462
1460
|
afterChange: this.events.afterChange
|
|
1463
1461
|
};
|
|
1464
1462
|
this.render = new ve(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1463
|
+
const n = this.selectEl.getAttribute("aria-label"), r = this.selectEl.getAttribute("aria-labelledby");
|
|
1464
|
+
n ? this.render.main.main.setAttribute("aria-label", n) : r && this.render.main.main.setAttribute("aria-labelledby", r), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), window.addEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.addEventListener("scroll", this.windowScroll, !1), document.addEventListener("visibilitychange", this.windowVisibilityChange), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.select.setupLabelHandlers(), this.selectEl.slim = this;
|
|
1467
1465
|
}
|
|
1468
1466
|
// Set to enabled and remove disabled classes
|
|
1469
1467
|
enable() {
|
|
@@ -1484,7 +1482,7 @@ let Se = class {
|
|
|
1484
1482
|
}
|
|
1485
1483
|
this.store.setData(e);
|
|
1486
1484
|
const i = this.store.getData();
|
|
1487
|
-
this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !
|
|
1485
|
+
this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !z(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1488
1486
|
}
|
|
1489
1487
|
getSelected() {
|
|
1490
1488
|
let e = this.store.getSelectedOptions();
|
|
@@ -1494,24 +1492,24 @@ let Se = class {
|
|
|
1494
1492
|
setSelected(e, t = !0) {
|
|
1495
1493
|
const s = this.store.getSelected(), i = this.store.getDataOptions();
|
|
1496
1494
|
e = Array.isArray(e) ? e : [e];
|
|
1497
|
-
const
|
|
1495
|
+
const n = [];
|
|
1498
1496
|
for (const a of e) {
|
|
1499
1497
|
if (i.find((c) => c.id == a)) {
|
|
1500
|
-
|
|
1498
|
+
n.push(a);
|
|
1501
1499
|
continue;
|
|
1502
1500
|
}
|
|
1503
1501
|
for (const c of i.filter((h) => h.value == a))
|
|
1504
|
-
|
|
1502
|
+
n.push(c.id);
|
|
1505
1503
|
}
|
|
1506
|
-
this.store.setSelectedBy("id",
|
|
1504
|
+
this.store.setSelectedBy("id", n);
|
|
1507
1505
|
const r = this.store.getData();
|
|
1508
|
-
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 && !
|
|
1506
|
+
this.select.updateOptions(r), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(r), t && this.events.afterChange && !z(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1509
1507
|
}
|
|
1510
1508
|
addOption(e) {
|
|
1511
1509
|
const t = this.store.getSelected();
|
|
1512
1510
|
this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
|
|
1513
1511
|
const s = this.store.getData();
|
|
1514
|
-
this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !
|
|
1512
|
+
this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !z(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1515
1513
|
}
|
|
1516
1514
|
open() {
|
|
1517
1515
|
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(() => {
|
|
@@ -1548,11 +1546,11 @@ let Se = class {
|
|
|
1548
1546
|
destroy() {
|
|
1549
1547
|
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();
|
|
1550
1548
|
}
|
|
1551
|
-
windowResize =
|
|
1549
|
+
windowResize = H(() => {
|
|
1552
1550
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1553
1551
|
});
|
|
1554
1552
|
// Event listener for window scrolling
|
|
1555
|
-
windowScroll =
|
|
1553
|
+
windowScroll = H(() => {
|
|
1556
1554
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1557
1555
|
});
|
|
1558
1556
|
// Event listener for document click
|
|
@@ -1565,41 +1563,59 @@ let Se = class {
|
|
|
1565
1563
|
};
|
|
1566
1564
|
};
|
|
1567
1565
|
const Oe = re(
|
|
1568
|
-
({ data: p, settings: e, events: t, cssClasses: s, value: i, onChange:
|
|
1569
|
-
const h = V(null), o = V(null), d = V(!0);
|
|
1570
|
-
|
|
1566
|
+
({ data: p, settings: e, events: t, cssClasses: s, value: i, onChange: n, children: r, multiple: a }, c) => {
|
|
1567
|
+
const h = V(null), o = V(null), d = V(!0), g = V(i);
|
|
1568
|
+
oe(c, () => ({
|
|
1571
1569
|
slimSelect: o.current
|
|
1572
|
-
}))
|
|
1570
|
+
}));
|
|
1571
|
+
const f = (m) => typeof m == "string" ? a ? [m] : m : Array.isArray(m) ? a ? m : m[0] : a ? [] : "", C = (m, L = !1) => {
|
|
1572
|
+
if (!o.current || m === void 0)
|
|
1573
|
+
return;
|
|
1574
|
+
const O = f(m), T = o.current.getData().flatMap((b) => "label" in b ? b.options : [b]);
|
|
1575
|
+
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)) {
|
|
1576
|
+
const D = o.current.getData(), P = {
|
|
1577
|
+
value: "",
|
|
1578
|
+
text: "",
|
|
1579
|
+
placeholder: !0
|
|
1580
|
+
};
|
|
1581
|
+
o.current.setData([P].concat(D));
|
|
1582
|
+
}
|
|
1583
|
+
o.current.setSelected(O, L);
|
|
1584
|
+
};
|
|
1585
|
+
return $(() => {
|
|
1573
1586
|
if (!h.current) return;
|
|
1574
1587
|
const m = {
|
|
1575
1588
|
select: h.current
|
|
1576
1589
|
};
|
|
1577
1590
|
p && (m.data = p), e && (m.settings = e), s && (m.cssClasses = s);
|
|
1578
|
-
const
|
|
1591
|
+
const L = t?.afterChange;
|
|
1579
1592
|
return m.events = {
|
|
1580
1593
|
...t,
|
|
1581
|
-
afterChange: (
|
|
1582
|
-
|
|
1583
|
-
|
|
1594
|
+
afterChange: (O) => {
|
|
1595
|
+
if (!o.current) return;
|
|
1596
|
+
const v = a ? O.map((A) => A.value) : O[0]?.value ?? "", k = o.current.getData().flatMap(
|
|
1597
|
+
(A) => "label" in A ? A.options : [A]
|
|
1598
|
+
), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((A) => k.some((M) => M.value === A)) : b !== "" && k.some((A) => A.value === b), P = Array.isArray(v) ? v.length > 0 && v.every((A) => k.some((M) => M.value === A)) : v !== "" && k.some((A) => A.value === v), F = Array.isArray(v) && Array.isArray(b) ? JSON.stringify(v.sort()) !== JSON.stringify(b.sort()) : b !== v;
|
|
1599
|
+
n && F && (D || P) && (n(v), g.current = v), L && L(O);
|
|
1584
1600
|
}
|
|
1585
|
-
}, o.current = new Se(m), i !== void 0 &&
|
|
1601
|
+
}, o.current = new Se(m), i !== void 0 && C(i, !1), () => {
|
|
1586
1602
|
o.current && (o.current.destroy(), o.current = null);
|
|
1587
1603
|
};
|
|
1588
|
-
}, []),
|
|
1604
|
+
}, []), $(() => {
|
|
1589
1605
|
if (d.current) {
|
|
1590
|
-
d.current = !1;
|
|
1606
|
+
d.current = !1, g.current = i;
|
|
1591
1607
|
return;
|
|
1592
1608
|
}
|
|
1593
|
-
o.current && i !== void 0 &&
|
|
1594
|
-
}, [i]),
|
|
1595
|
-
o.current && p && !d.current && o.current.setData(p);
|
|
1609
|
+
o.current && i !== void 0 && (g.current = i, C(i, !1));
|
|
1610
|
+
}, [i]), $(() => {
|
|
1611
|
+
o.current && p && !d.current && (o.current.setData(p), i !== void 0 && C(i, !1));
|
|
1596
1612
|
}, [p]), /* @__PURE__ */ ue.jsx("select", { ref: h, multiple: a, children: r });
|
|
1597
1613
|
}
|
|
1598
1614
|
);
|
|
1599
1615
|
Oe.displayName = "SlimSelect";
|
|
1600
1616
|
export {
|
|
1601
|
-
|
|
1602
|
-
|
|
1617
|
+
x as Optgroup,
|
|
1618
|
+
S as Option,
|
|
1603
1619
|
we as Settings,
|
|
1604
1620
|
Oe as default
|
|
1605
1621
|
};
|