dropdowns-js 1.1.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1039 +1,204 @@
1
- import { jsxs as Q, jsx as L } from "react/jsx-runtime";
2
- import { useId as ce, useState as ee, useMemo as re, useEffect as Pe } from "react";
3
- function _e(n) {
4
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
1
+ import { jsxs as v, jsx as l } from "react/jsx-runtime";
2
+ import { useId as Q, useState as j, useMemo as E, useEffect as W } from "react";
3
+ function G(t) {
4
+ return t === null || typeof t != "object" || Object.prototype.toString.call(t) !== "[object Object]" ? !1 : t.constructor === Object;
5
5
  }
6
- var se = { exports: {} }, ae = { exports: {} }, F = {};
7
- var me;
8
- function Ie() {
9
- if (me) return F;
10
- me = 1;
11
- var n = typeof Symbol == "function" && Symbol.for, j = n ? /* @__PURE__ */ Symbol.for("react.element") : 60103, M = n ? /* @__PURE__ */ Symbol.for("react.portal") : 60106, b = n ? /* @__PURE__ */ Symbol.for("react.fragment") : 60107, T = n ? /* @__PURE__ */ Symbol.for("react.strict_mode") : 60108, p = n ? /* @__PURE__ */ Symbol.for("react.profiler") : 60114, w = n ? /* @__PURE__ */ Symbol.for("react.provider") : 60109, m = n ? /* @__PURE__ */ Symbol.for("react.context") : 60110, g = n ? /* @__PURE__ */ Symbol.for("react.async_mode") : 60111, x = n ? /* @__PURE__ */ Symbol.for("react.concurrent_mode") : 60111, y = n ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112, C = n ? /* @__PURE__ */ Symbol.for("react.suspense") : 60113, E = n ? /* @__PURE__ */ Symbol.for("react.suspense_list") : 60120, P = n ? /* @__PURE__ */ Symbol.for("react.memo") : 60115, Y = n ? /* @__PURE__ */ Symbol.for("react.lazy") : 60116, q = n ? /* @__PURE__ */ Symbol.for("react.block") : 60121, _ = n ? /* @__PURE__ */ Symbol.for("react.fundamental") : 60117, U = n ? /* @__PURE__ */ Symbol.for("react.responder") : 60118, X = n ? /* @__PURE__ */ Symbol.for("react.scope") : 60119;
12
- function D(s) {
13
- if (typeof s == "object" && s !== null) {
14
- var B = s.$$typeof;
15
- switch (B) {
16
- case j:
17
- switch (s = s.type, s) {
18
- case g:
19
- case x:
20
- case b:
21
- case p:
22
- case T:
23
- case C:
24
- return s;
25
- default:
26
- switch (s = s && s.$$typeof, s) {
27
- case m:
28
- case y:
29
- case Y:
30
- case P:
31
- case w:
32
- return s;
33
- default:
34
- return B;
35
- }
36
- }
37
- case M:
38
- return B;
6
+ function X(t) {
7
+ if (!G(t))
8
+ return [];
9
+ const r = [{ value: t }];
10
+ let u = 0;
11
+ for (; u < r.length; ) {
12
+ const d = r[u];
13
+ if (G(d.value)) {
14
+ for (const c in d.value) {
15
+ let s = d.path ? d.path + "." + c : c;
16
+ r.push(
17
+ { value: d.value[c], path: s }
18
+ );
39
19
  }
20
+ d.remove = !0;
40
21
  }
22
+ u++;
41
23
  }
42
- function $(s) {
43
- return D(s) === x;
44
- }
45
- return F.AsyncMode = g, F.ConcurrentMode = x, F.ContextConsumer = m, F.ContextProvider = w, F.Element = j, F.ForwardRef = y, F.Fragment = b, F.Lazy = Y, F.Memo = P, F.Portal = M, F.Profiler = p, F.StrictMode = T, F.Suspense = C, F.isAsyncMode = function(s) {
46
- return $(s) || D(s) === g;
47
- }, F.isConcurrentMode = $, F.isContextConsumer = function(s) {
48
- return D(s) === m;
49
- }, F.isContextProvider = function(s) {
50
- return D(s) === w;
51
- }, F.isElement = function(s) {
52
- return typeof s == "object" && s !== null && s.$$typeof === j;
53
- }, F.isForwardRef = function(s) {
54
- return D(s) === y;
55
- }, F.isFragment = function(s) {
56
- return D(s) === b;
57
- }, F.isLazy = function(s) {
58
- return D(s) === Y;
59
- }, F.isMemo = function(s) {
60
- return D(s) === P;
61
- }, F.isPortal = function(s) {
62
- return D(s) === M;
63
- }, F.isProfiler = function(s) {
64
- return D(s) === p;
65
- }, F.isStrictMode = function(s) {
66
- return D(s) === T;
67
- }, F.isSuspense = function(s) {
68
- return D(s) === C;
69
- }, F.isValidElementType = function(s) {
70
- return typeof s == "string" || typeof s == "function" || s === b || s === x || s === p || s === T || s === C || s === E || typeof s == "object" && s !== null && (s.$$typeof === Y || s.$$typeof === P || s.$$typeof === w || s.$$typeof === m || s.$$typeof === y || s.$$typeof === _ || s.$$typeof === U || s.$$typeof === X || s.$$typeof === q);
71
- }, F.typeOf = D, F;
24
+ return r.filter((d) => !d.remove).map((d) => d.path);
72
25
  }
73
- var V = {};
74
- var ve;
75
- function De() {
76
- return ve || (ve = 1, process.env.NODE_ENV !== "production" && (function() {
77
- var n = typeof Symbol == "function" && Symbol.for, j = n ? /* @__PURE__ */ Symbol.for("react.element") : 60103, M = n ? /* @__PURE__ */ Symbol.for("react.portal") : 60106, b = n ? /* @__PURE__ */ Symbol.for("react.fragment") : 60107, T = n ? /* @__PURE__ */ Symbol.for("react.strict_mode") : 60108, p = n ? /* @__PURE__ */ Symbol.for("react.profiler") : 60114, w = n ? /* @__PURE__ */ Symbol.for("react.provider") : 60109, m = n ? /* @__PURE__ */ Symbol.for("react.context") : 60110, g = n ? /* @__PURE__ */ Symbol.for("react.async_mode") : 60111, x = n ? /* @__PURE__ */ Symbol.for("react.concurrent_mode") : 60111, y = n ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112, C = n ? /* @__PURE__ */ Symbol.for("react.suspense") : 60113, E = n ? /* @__PURE__ */ Symbol.for("react.suspense_list") : 60120, P = n ? /* @__PURE__ */ Symbol.for("react.memo") : 60115, Y = n ? /* @__PURE__ */ Symbol.for("react.lazy") : 60116, q = n ? /* @__PURE__ */ Symbol.for("react.block") : 60121, _ = n ? /* @__PURE__ */ Symbol.for("react.fundamental") : 60117, U = n ? /* @__PURE__ */ Symbol.for("react.responder") : 60118, X = n ? /* @__PURE__ */ Symbol.for("react.scope") : 60119;
78
- function D(d) {
79
- return typeof d == "string" || typeof d == "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
80
- d === b || d === x || d === p || d === T || d === C || d === E || typeof d == "object" && d !== null && (d.$$typeof === Y || d.$$typeof === P || d.$$typeof === w || d.$$typeof === m || d.$$typeof === y || d.$$typeof === _ || d.$$typeof === U || d.$$typeof === X || d.$$typeof === q);
81
- }
82
- function $(d) {
83
- if (typeof d == "object" && d !== null) {
84
- var oe = d.$$typeof;
85
- switch (oe) {
86
- case j:
87
- var ie = d.type;
88
- switch (ie) {
89
- case g:
90
- case x:
91
- case b:
92
- case p:
93
- case T:
94
- case C:
95
- return ie;
96
- default:
97
- var ge = ie && ie.$$typeof;
98
- switch (ge) {
99
- case m:
100
- case y:
101
- case Y:
102
- case P:
103
- case w:
104
- return ge;
105
- default:
106
- return oe;
107
- }
108
- }
109
- case M:
110
- return oe;
111
- }
112
- }
113
- }
114
- var s = g, B = x, G = m, Z = w, t = j, o = y, u = b, r = Y, i = P, f = M, c = p, v = T, h = C, H = !1;
115
- function K(d) {
116
- return H || (H = !0, console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")), e(d) || $(d) === g;
117
- }
118
- function e(d) {
119
- return $(d) === x;
120
- }
121
- function a(d) {
122
- return $(d) === m;
123
- }
124
- function S(d) {
125
- return $(d) === w;
126
- }
127
- function O(d) {
128
- return typeof d == "object" && d !== null && d.$$typeof === j;
129
- }
130
- function R(d) {
131
- return $(d) === y;
132
- }
133
- function A(d) {
134
- return $(d) === b;
135
- }
136
- function I(d) {
137
- return $(d) === Y;
138
- }
139
- function k(d) {
140
- return $(d) === P;
141
- }
142
- function z(d) {
143
- return $(d) === M;
144
- }
145
- function W(d) {
146
- return $(d) === p;
147
- }
148
- function N(d) {
149
- return $(d) === T;
150
- }
151
- function te(d) {
152
- return $(d) === C;
153
- }
154
- V.AsyncMode = s, V.ConcurrentMode = B, V.ContextConsumer = G, V.ContextProvider = Z, V.Element = t, V.ForwardRef = o, V.Fragment = u, V.Lazy = r, V.Memo = i, V.Portal = f, V.Profiler = c, V.StrictMode = v, V.Suspense = h, V.isAsyncMode = K, V.isConcurrentMode = e, V.isContextConsumer = a, V.isContextProvider = S, V.isElement = O, V.isForwardRef = R, V.isFragment = A, V.isLazy = I, V.isMemo = k, V.isPortal = z, V.isProfiler = W, V.isStrictMode = N, V.isSuspense = te, V.isValidElementType = D, V.typeOf = $;
155
- })()), V;
26
+ function J(t, r, u = void 0) {
27
+ if (!G(t))
28
+ return;
29
+ let d = r.split("."), c = t;
30
+ for (let s = 0; s < d.length; s++) {
31
+ let a = d[s];
32
+ if (!(a in c) || (c = c[a], c === void 0))
33
+ return u;
34
+ }
35
+ return d.length === 0 ? u : c;
156
36
  }
157
- var be;
158
- function Re() {
159
- return be || (be = 1, process.env.NODE_ENV === "production" ? ae.exports = Ie() : ae.exports = De()), ae.exports;
37
+ function Y(t, r, u = "asc") {
38
+ if (!["asc", "desc"].includes(u))
39
+ throw new Error(`sortDir must be one of ${u}`);
40
+ const d = u === "desc" ? -1 : 1;
41
+ return t > r ? d : t < r ? -d : 0;
160
42
  }
161
- var le, we;
162
- function ke() {
163
- if (we) return le;
164
- we = 1;
165
- var n = Object.getOwnPropertySymbols, j = Object.prototype.hasOwnProperty, M = Object.prototype.propertyIsEnumerable;
166
- function b(p) {
167
- if (p == null)
168
- throw new TypeError("Object.assign cannot be called with null or undefined");
169
- return Object(p);
170
- }
171
- function T() {
172
- try {
173
- if (!Object.assign)
174
- return !1;
175
- var p = new String("abc");
176
- if (p[5] = "de", Object.getOwnPropertyNames(p)[0] === "5")
177
- return !1;
178
- for (var w = {}, m = 0; m < 10; m++)
179
- w["_" + String.fromCharCode(m)] = m;
180
- var g = Object.getOwnPropertyNames(w).map(function(y) {
181
- return w[y];
182
- });
183
- if (g.join("") !== "0123456789")
184
- return !1;
185
- var x = {};
186
- return "abcdefghijklmnopqrst".split("").forEach(function(y) {
187
- x[y] = y;
188
- }), Object.keys(Object.assign({}, x)).join("") === "abcdefghijklmnopqrst";
189
- } catch {
190
- return !1;
191
- }
192
- }
193
- return le = T() ? Object.assign : function(p, w) {
194
- for (var m, g = b(p), x, y = 1; y < arguments.length; y++) {
195
- m = Object(arguments[y]);
196
- for (var C in m)
197
- j.call(m, C) && (g[C] = m[C]);
198
- if (n) {
199
- x = n(m);
200
- for (var E = 0; E < x.length; E++)
201
- M.call(m, x[E]) && (g[x[E]] = m[x[E]]);
202
- }
203
- }
204
- return g;
205
- }, le;
206
- }
207
- var ue, Se;
208
- function ye() {
209
- if (Se) return ue;
210
- Se = 1;
211
- var n = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
212
- return ue = n, ue;
213
- }
214
- var de, Ce;
215
- function $e() {
216
- return Ce || (Ce = 1, de = Function.call.bind(Object.prototype.hasOwnProperty)), de;
217
- }
218
- var fe, xe;
219
- function qe() {
220
- if (xe) return fe;
221
- xe = 1;
222
- var n = function() {
223
- };
224
- if (process.env.NODE_ENV !== "production") {
225
- var j = /* @__PURE__ */ ye(), M = {}, b = /* @__PURE__ */ $e();
226
- n = function(p) {
227
- var w = "Warning: " + p;
228
- typeof console < "u" && console.error(w);
229
- try {
230
- throw new Error(w);
231
- } catch {
232
- }
233
- };
234
- }
235
- function T(p, w, m, g, x) {
236
- if (process.env.NODE_ENV !== "production") {
237
- for (var y in p)
238
- if (b(p, y)) {
239
- var C;
240
- try {
241
- if (typeof p[y] != "function") {
242
- var E = Error(
243
- (g || "React class") + ": " + m + " type `" + y + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof p[y] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
244
- );
245
- throw E.name = "Invariant Violation", E;
246
- }
247
- C = p[y](w, y, g, m, null, j);
248
- } catch (Y) {
249
- C = Y;
250
- }
251
- if (C && !(C instanceof Error) && n(
252
- (g || "React class") + ": type specification of " + m + " `" + y + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof C + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
253
- ), C instanceof Error && !(C.message in M)) {
254
- M[C.message] = !0;
255
- var P = x ? x() : "";
256
- n(
257
- "Failed " + m + " type: " + C.message + (P ?? "")
258
- );
259
- }
260
- }
261
- }
262
- }
263
- return T.resetWarningCache = function() {
264
- process.env.NODE_ENV !== "production" && (M = {});
265
- }, fe = T, fe;
266
- }
267
- var pe, Te;
268
- function Me() {
269
- if (Te) return pe;
270
- Te = 1;
271
- var n = Re(), j = ke(), M = /* @__PURE__ */ ye(), b = /* @__PURE__ */ $e(), T = /* @__PURE__ */ qe(), p = function() {
272
- };
273
- process.env.NODE_ENV !== "production" && (p = function(m) {
274
- var g = "Warning: " + m;
275
- typeof console < "u" && console.error(g);
276
- try {
277
- throw new Error(g);
278
- } catch {
279
- }
280
- });
281
- function w() {
282
- return null;
283
- }
284
- return pe = function(m, g) {
285
- var x = typeof Symbol == "function" && Symbol.iterator, y = "@@iterator";
286
- function C(e) {
287
- var a = e && (x && e[x] || e[y]);
288
- if (typeof a == "function")
289
- return a;
290
- }
291
- var E = "<<anonymous>>", P = {
292
- array: U("array"),
293
- bigint: U("bigint"),
294
- bool: U("boolean"),
295
- func: U("function"),
296
- number: U("number"),
297
- object: U("object"),
298
- string: U("string"),
299
- symbol: U("symbol"),
300
- any: X(),
301
- arrayOf: D,
302
- element: $(),
303
- elementType: s(),
304
- instanceOf: B,
305
- node: o(),
306
- objectOf: Z,
307
- oneOf: G,
308
- oneOfType: t,
309
- shape: r,
310
- exact: i
311
- };
312
- function Y(e, a) {
313
- return e === a ? e !== 0 || 1 / e === 1 / a : e !== e && a !== a;
314
- }
315
- function q(e, a) {
316
- this.message = e, this.data = a && typeof a == "object" ? a : {}, this.stack = "";
317
- }
318
- q.prototype = Error.prototype;
319
- function _(e) {
320
- if (process.env.NODE_ENV !== "production")
321
- var a = {}, S = 0;
322
- function O(A, I, k, z, W, N, te) {
323
- if (z = z || E, N = N || k, te !== M) {
324
- if (g) {
325
- var d = new Error(
326
- "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
327
- );
328
- throw d.name = "Invariant Violation", d;
329
- } else if (process.env.NODE_ENV !== "production" && typeof console < "u") {
330
- var oe = z + ":" + k;
331
- !a[oe] && // Avoid spamming the console because they are often not actionable except for lib authors
332
- S < 3 && (p(
333
- "You are manually calling a React.PropTypes validation function for the `" + N + "` prop on `" + z + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."
334
- ), a[oe] = !0, S++);
335
- }
336
- }
337
- return I[k] == null ? A ? I[k] === null ? new q("The " + W + " `" + N + "` is marked as required " + ("in `" + z + "`, but its value is `null`.")) : new q("The " + W + " `" + N + "` is marked as required in " + ("`" + z + "`, but its value is `undefined`.")) : null : e(I, k, z, W, N);
338
- }
339
- var R = O.bind(null, !1);
340
- return R.isRequired = O.bind(null, !0), R;
341
- }
342
- function U(e) {
343
- function a(S, O, R, A, I, k) {
344
- var z = S[O], W = v(z);
345
- if (W !== e) {
346
- var N = h(z);
347
- return new q(
348
- "Invalid " + A + " `" + I + "` of type " + ("`" + N + "` supplied to `" + R + "`, expected ") + ("`" + e + "`."),
349
- { expectedType: e }
350
- );
351
- }
352
- return null;
353
- }
354
- return _(a);
355
- }
356
- function X() {
357
- return _(w);
358
- }
359
- function D(e) {
360
- function a(S, O, R, A, I) {
361
- if (typeof e != "function")
362
- return new q("Property `" + I + "` of component `" + R + "` has invalid PropType notation inside arrayOf.");
363
- var k = S[O];
364
- if (!Array.isArray(k)) {
365
- var z = v(k);
366
- return new q("Invalid " + A + " `" + I + "` of type " + ("`" + z + "` supplied to `" + R + "`, expected an array."));
367
- }
368
- for (var W = 0; W < k.length; W++) {
369
- var N = e(k, W, R, A, I + "[" + W + "]", M);
370
- if (N instanceof Error)
371
- return N;
372
- }
373
- return null;
374
- }
375
- return _(a);
376
- }
377
- function $() {
378
- function e(a, S, O, R, A) {
379
- var I = a[S];
380
- if (!m(I)) {
381
- var k = v(I);
382
- return new q("Invalid " + R + " `" + A + "` of type " + ("`" + k + "` supplied to `" + O + "`, expected a single ReactElement."));
383
- }
384
- return null;
385
- }
386
- return _(e);
387
- }
388
- function s() {
389
- function e(a, S, O, R, A) {
390
- var I = a[S];
391
- if (!n.isValidElementType(I)) {
392
- var k = v(I);
393
- return new q("Invalid " + R + " `" + A + "` of type " + ("`" + k + "` supplied to `" + O + "`, expected a single ReactElement type."));
394
- }
395
- return null;
396
- }
397
- return _(e);
398
- }
399
- function B(e) {
400
- function a(S, O, R, A, I) {
401
- if (!(S[O] instanceof e)) {
402
- var k = e.name || E, z = K(S[O]);
403
- return new q("Invalid " + A + " `" + I + "` of type " + ("`" + z + "` supplied to `" + R + "`, expected ") + ("instance of `" + k + "`."));
404
- }
405
- return null;
406
- }
407
- return _(a);
408
- }
409
- function G(e) {
410
- if (!Array.isArray(e))
411
- return process.env.NODE_ENV !== "production" && (arguments.length > 1 ? p(
412
- "Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."
413
- ) : p("Invalid argument supplied to oneOf, expected an array.")), w;
414
- function a(S, O, R, A, I) {
415
- for (var k = S[O], z = 0; z < e.length; z++)
416
- if (Y(k, e[z]))
417
- return null;
418
- var W = JSON.stringify(e, function(te, d) {
419
- var oe = h(d);
420
- return oe === "symbol" ? String(d) : d;
421
- });
422
- return new q("Invalid " + A + " `" + I + "` of value `" + String(k) + "` " + ("supplied to `" + R + "`, expected one of " + W + "."));
423
- }
424
- return _(a);
425
- }
426
- function Z(e) {
427
- function a(S, O, R, A, I) {
428
- if (typeof e != "function")
429
- return new q("Property `" + I + "` of component `" + R + "` has invalid PropType notation inside objectOf.");
430
- var k = S[O], z = v(k);
431
- if (z !== "object")
432
- return new q("Invalid " + A + " `" + I + "` of type " + ("`" + z + "` supplied to `" + R + "`, expected an object."));
433
- for (var W in k)
434
- if (b(k, W)) {
435
- var N = e(k, W, R, A, I + "." + W, M);
436
- if (N instanceof Error)
437
- return N;
438
- }
439
- return null;
440
- }
441
- return _(a);
442
- }
443
- function t(e) {
444
- if (!Array.isArray(e))
445
- return process.env.NODE_ENV !== "production" && p("Invalid argument supplied to oneOfType, expected an instance of array."), w;
446
- for (var a = 0; a < e.length; a++) {
447
- var S = e[a];
448
- if (typeof S != "function")
449
- return p(
450
- "Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + H(S) + " at index " + a + "."
451
- ), w;
452
- }
453
- function O(R, A, I, k, z) {
454
- for (var W = [], N = 0; N < e.length; N++) {
455
- var te = e[N], d = te(R, A, I, k, z, M);
456
- if (d == null)
457
- return null;
458
- d.data && b(d.data, "expectedType") && W.push(d.data.expectedType);
459
- }
460
- var oe = W.length > 0 ? ", expected one of type [" + W.join(", ") + "]" : "";
461
- return new q("Invalid " + k + " `" + z + "` supplied to " + ("`" + I + "`" + oe + "."));
462
- }
463
- return _(O);
464
- }
465
- function o() {
466
- function e(a, S, O, R, A) {
467
- return f(a[S]) ? null : new q("Invalid " + R + " `" + A + "` supplied to " + ("`" + O + "`, expected a ReactNode."));
468
- }
469
- return _(e);
470
- }
471
- function u(e, a, S, O, R) {
472
- return new q(
473
- (e || "React class") + ": " + a + " type `" + S + "." + O + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + R + "`."
474
- );
475
- }
476
- function r(e) {
477
- function a(S, O, R, A, I) {
478
- var k = S[O], z = v(k);
479
- if (z !== "object")
480
- return new q("Invalid " + A + " `" + I + "` of type `" + z + "` " + ("supplied to `" + R + "`, expected `object`."));
481
- for (var W in e) {
482
- var N = e[W];
483
- if (typeof N != "function")
484
- return u(R, A, I, W, h(N));
485
- var te = N(k, W, R, A, I + "." + W, M);
486
- if (te)
487
- return te;
488
- }
489
- return null;
490
- }
491
- return _(a);
492
- }
493
- function i(e) {
494
- function a(S, O, R, A, I) {
495
- var k = S[O], z = v(k);
496
- if (z !== "object")
497
- return new q("Invalid " + A + " `" + I + "` of type `" + z + "` " + ("supplied to `" + R + "`, expected `object`."));
498
- var W = j({}, S[O], e);
499
- for (var N in W) {
500
- var te = e[N];
501
- if (b(e, N) && typeof te != "function")
502
- return u(R, A, I, N, h(te));
503
- if (!te)
504
- return new q(
505
- "Invalid " + A + " `" + I + "` key `" + N + "` supplied to `" + R + "`.\nBad object: " + JSON.stringify(S[O], null, " ") + `
506
- Valid keys: ` + JSON.stringify(Object.keys(e), null, " ")
507
- );
508
- var d = te(k, N, R, A, I + "." + N, M);
509
- if (d)
510
- return d;
511
- }
512
- return null;
513
- }
514
- return _(a);
515
- }
516
- function f(e) {
517
- switch (typeof e) {
518
- case "number":
519
- case "string":
520
- case "undefined":
521
- return !0;
522
- case "boolean":
523
- return !e;
524
- case "object":
525
- if (Array.isArray(e))
526
- return e.every(f);
527
- if (e === null || m(e))
528
- return !0;
529
- var a = C(e);
530
- if (a) {
531
- var S = a.call(e), O;
532
- if (a !== e.entries) {
533
- for (; !(O = S.next()).done; )
534
- if (!f(O.value))
535
- return !1;
536
- } else
537
- for (; !(O = S.next()).done; ) {
538
- var R = O.value;
539
- if (R && !f(R[1]))
540
- return !1;
541
- }
542
- } else
543
- return !1;
544
- return !0;
545
- default:
546
- return !1;
547
- }
548
- }
549
- function c(e, a) {
550
- return e === "symbol" ? !0 : a ? a["@@toStringTag"] === "Symbol" || typeof Symbol == "function" && a instanceof Symbol : !1;
551
- }
552
- function v(e) {
553
- var a = typeof e;
554
- return Array.isArray(e) ? "array" : e instanceof RegExp ? "object" : c(a, e) ? "symbol" : a;
555
- }
556
- function h(e) {
557
- if (typeof e > "u" || e === null)
558
- return "" + e;
559
- var a = v(e);
560
- if (a === "object") {
561
- if (e instanceof Date)
562
- return "date";
563
- if (e instanceof RegExp)
564
- return "regexp";
565
- }
566
- return a;
567
- }
568
- function H(e) {
569
- var a = h(e);
570
- switch (a) {
571
- case "array":
572
- case "object":
573
- return "an " + a;
574
- case "boolean":
575
- case "date":
576
- case "regexp":
577
- return "a " + a;
578
- default:
579
- return a;
580
- }
581
- }
582
- function K(e) {
583
- return !e.constructor || !e.constructor.name ? E : e.constructor.name;
584
- }
585
- return P.checkPropTypes = T, P.resetWarningCache = T.resetWarningCache, P.PropTypes = P, P;
586
- }, pe;
587
- }
588
- var he, Ee;
589
- function Ae() {
590
- if (Ee) return he;
591
- Ee = 1;
592
- var n = /* @__PURE__ */ ye();
593
- function j() {
594
- }
595
- function M() {
596
- }
597
- return M.resetWarningCache = j, he = function() {
598
- function b(w, m, g, x, y, C) {
599
- if (C !== n) {
600
- var E = new Error(
601
- "Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
602
- );
603
- throw E.name = "Invariant Violation", E;
604
- }
605
- }
606
- b.isRequired = b;
607
- function T() {
43
+ function M(t, r, ...u) {
44
+ if (!u || !u.length)
45
+ throw new Error("comparisonFields not supplied!");
46
+ if (!G(t) || !G(r))
47
+ throw new Error("Both obj1 and obj2 must be plain objects.");
48
+ const d = ["", "asc", "desc"];
49
+ for (let c = 0; c < u.length; c++) {
50
+ const s = u[c].split(" "), a = s[0];
51
+ let h = "";
52
+ if (s.length > 2)
53
+ throw new Error("Each comparison field must be of the form 'fieldName sortDirection' or 'fieldName'.");
54
+ if (s.length === 2 && (h = s[1]), !d.includes(h))
55
+ throw new Error("Sort direction must be one of " + d.toString());
56
+ const C = J(t, a), m = J(r, a), w = ["string", "number", "bigint", "boolean"];
57
+ if (!(w.includes(typeof C) || w.includes(typeof m) || C instanceof Date || m instanceof Date))
58
+ throw new Error("Comparison values must be primitive type or Date instance");
59
+ if (typeof C != typeof m)
60
+ throw new Error("Comparison values must be of the same type");
61
+ const b = h === "desc" ? -1 : 1;
62
+ if (C > m)
608
63
  return b;
609
- }
610
- var p = {
611
- array: b,
612
- bigint: b,
613
- bool: b,
614
- func: b,
615
- number: b,
616
- object: b,
617
- string: b,
618
- symbol: b,
619
- any: b,
620
- arrayOf: T,
621
- element: b,
622
- elementType: b,
623
- instanceOf: T,
624
- node: b,
625
- objectOf: T,
626
- oneOf: T,
627
- oneOfType: T,
628
- shape: T,
629
- exact: T,
630
- checkPropTypes: M,
631
- resetWarningCache: j
632
- };
633
- return p.PropTypes = p, p;
634
- }, he;
635
- }
636
- var je;
637
- function ze() {
638
- if (je) return se.exports;
639
- if (je = 1, process.env.NODE_ENV !== "production") {
640
- var n = Re(), j = !0;
641
- se.exports = /* @__PURE__ */ Me()(n.isElement, j);
642
- } else
643
- se.exports = /* @__PURE__ */ Ae()();
644
- return se.exports;
645
- }
646
- var Ne = /* @__PURE__ */ ze();
647
- const l = /* @__PURE__ */ _e(Ne);
648
- var J = {}, Oe;
649
- function Le() {
650
- if (Oe) return J;
651
- Oe = 1;
652
- function n(t) {
653
- return t ? /^[a-zA-Z][a-zA-Z0-9_-]{2,50}$/.test(t) : !1;
654
- }
655
- J.isValidUserName = n;
656
- function j(t) {
657
- return t ? /^[A-Za-z' -]{2,50}$/.test(t) : !1;
658
- }
659
- J.isValidName = j;
660
- function M(t) {
661
- return t ? /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t) : !1;
662
- }
663
- J.isValidEmail = M;
664
- function b(t) {
665
- return t ? /^[0-9]{10,15}$/g.test(t) : !1;
666
- }
667
- J.isValidPhoneNum = b;
668
- function T(t) {
669
- return t ? /^[a-zA-Z0-9.\-\(\) ]{2,}$/.test(t) : !1;
670
- }
671
- J.isValidOrganisationName = T;
672
- function p(t) {
673
- return !(!t || t.length < 6 || /[A-Z]/.test(t) === !1 || /[a-z]/.test(t) === !1 || /[0-9]/.test(t) === !1 || /[\s]/.test(t) || /[\][!"#$%&'()*+,./:;<=>?@^\\_`{|}~-]/.test(t) === !1);
674
- }
675
- J.isValidPassword = p;
676
- function w(t) {
677
- let o = t.getFullYear(), u = t.getMonth() + 1;
678
- u = g(u, 2);
679
- let r = t.getDate();
680
- return r = g(r, 2), `${o}-${u}-${r}`;
681
- }
682
- J.timeStampYyyyMmDd = w;
683
- function m(t) {
684
- let o = g(t.getHours(), 2), u = g(t.getMinutes(), 2), r = g(t.getSeconds(), 2), i = g(t.getMilliseconds(), 3);
685
- return `${w(t)}T${o}:${u}:${r}.${i}`;
686
- }
687
- J.timeStampString = m;
688
- function g(t, o) {
689
- let u = t + "";
690
- const r = o - u.length;
691
- for (let i = 1; i <= r; i++)
692
- u = "0" + u;
693
- return u;
694
- }
695
- J.addLeadingZeros = g;
696
- function x(t) {
697
- return new Intl.NumberFormat("en-US", { style: "currency", currency: "ZAR" }).format(t).replace(/ZAR/gi, "R");
698
- }
699
- J.toZarCurrencyFormat = x;
700
- function y(t) {
701
- if (Object.prototype.toString.call(t) !== "[object Object]") return t instanceof Date ? new Date(t) : (["string", "number", "boolean"].includes(typeof t), t);
702
- const o = [{ ...t }];
703
- let u = 0;
704
- for (; u < o.length; ) {
705
- let r = o[u];
706
- if (Object.prototype.toString.call(r) === "[object Object]")
707
- for (let i in r)
708
- r[i] instanceof Date ? r[i] = new Date(r[i]) : Object.prototype.toString.call(r[i]) === "[object Object]" && (r[i] = { ...r[i] }), o.push(r[i]);
709
- u++;
710
- }
711
- return o[0];
712
- }
713
- J.deepClone = y;
714
- function C(t) {
715
- const o = [{ value: t }];
716
- let u = 0;
717
- for (; u < o.length; ) {
718
- const r = o[u];
719
- if (Object.prototype.toString.call(r.value) === "[object Object]") {
720
- for (const i in r.value) {
721
- let f = r.path ? r.path + "." + i : i;
722
- o.push(
723
- { value: r.value[i], path: f }
724
- );
725
- }
726
- r.remove = !0;
727
- }
728
- u++;
729
- }
730
- return o.filter((r) => !r.remove).map((r) => r.path);
731
- }
732
- J.getPaths = C;
733
- function E(t) {
734
- let o = y(t), u = 0;
735
- const r = C(o).toSorted();
736
- sortedObj = {};
737
- for (u in r) {
738
- const i = r[u], f = P(o, i);
739
- Y(sortedObj, i, f);
740
- }
741
- return sortedObj;
742
- }
743
- J.getSortedObject = E;
744
- function P(t, o, u = void 0) {
745
- let r = o.split("."), i = t;
746
- for (let f in r) {
747
- let c = r[f];
748
- if (i[c] === void 0 || (i = i[c], i === void 0))
749
- return u;
750
- }
751
- return i;
64
+ if (C < m)
65
+ return -b;
752
66
  }
753
- J.get = P;
754
- function Y(t, o, u) {
755
- let r = t, i = o.split(".");
756
- for (let f in i) {
757
- let c = i[f];
758
- f < i.length - 1 ? (c in r || (r[c] = {}), r = r[c]) : r[c] = u;
759
- }
760
- }
761
- J.set = Y;
762
- function q(t, o) {
763
- let u = o.split("."), r = t;
764
- for (let i in u) {
765
- let f = u[i];
766
- if (Object.prototype.toString.call(r) !== "[object Object]" || r[f] === void 0)
767
- return;
768
- i < u.length - 1 ? r = r[f] : delete r[f];
769
- }
770
- }
771
- J.unset = q;
772
- function _(t, ...o) {
773
- if (!o || !o.length)
774
- throw new Error("fields must be specified");
775
- const u = C(t);
776
- let r = 0;
777
- for (const i in u) {
778
- const f = u[i];
779
- if (o.includes(f))
780
- r++;
781
- else
782
- return !1;
783
- }
784
- return r > 0;
785
- }
786
- J.hasOnly = _;
787
- function U(t, ...o) {
788
- if (!o || !o.length)
789
- throw new Error("fields must be specified");
790
- const u = C(t);
791
- let r = 0;
792
- for (const i in o) {
793
- const f = o[i];
794
- if (u.includes(f))
795
- r++;
796
- else
797
- return !1;
798
- }
799
- return r === o.length;
800
- }
801
- J.hasAll = U;
802
- function X(t, ...o) {
803
- return _(t, ...o) && U(t, ...o);
804
- }
805
- J.hasOnlyAll = X;
806
- function D(t, o, u = 0, r = "asc") {
807
- const i = ["asc", "desc"];
808
- if (!["asc", "desc"].includes(r))
809
- throw new Error(`arraySortDir must be one of ${i}`);
810
- if (t.length === 0)
811
- return -1;
812
- let f = u, c = t.length - 1;
813
- for (; f < c; ) {
814
- if ($(t[f], o) === 0)
815
- return f;
816
- if ($(t[c], o) === 0)
817
- return c;
818
- const v = Math.trunc((f + c) / 2), h = $(t[v], o, r);
819
- if (h < 0)
820
- f = v + 1;
821
- else if (h > 0)
822
- c = v - 1;
823
- else
824
- return v;
825
- }
826
- return f;
827
- }
828
- J.binarySearch = D;
829
- function $(t, o, u = "asc") {
830
- if (!["asc", "desc"].includes(u))
831
- throw new Error(`sortDir must be one of ${u}`);
832
- const r = u === "desc" ? -1 : 1;
833
- return t > o ? r : t < o ? -r : 0;
834
- }
835
- J.compare = $;
836
- function s(t, o, u = 0, ...r) {
837
- if (t.length === 0)
838
- return -1;
839
- let i = u, f = t.length - 1;
840
- for (; i < f; ) {
841
- if (Z(t[i], o, ...r) === 0)
842
- return i;
843
- if (Z(t[f], o, ...r) === 0)
844
- return f;
845
- let c = Math.trunc((i + f) / 2);
846
- if (Z(t[c], o, ...r) < 0)
847
- i = c + 1;
848
- else if (Z(t[c], o, ...r) > 0)
849
- f = c - 1;
850
- else
851
- return c;
852
- }
853
- return i;
854
- }
855
- J.binarySearchObj = s;
856
- function B(t, o, u, ...r) {
857
- let i = u, f = t.length - 1;
858
- if (i >= t.length)
859
- throw new Error("startFrom is outside the bounds of the array.");
860
- if (Z(o, t[i], ...r) > 0)
861
- throw new Error("targetObj is to the right ('greater than') objArray[startFrom].");
862
- for (; i < f; ) {
863
- let c = Math.trunc((i + f) / 2);
864
- Z(o, t[c], ...r) === 0 ? i = c + 1 : Z(o, t[c], ...r) < 0 && (f = c);
865
- }
866
- return Z(o, t[i], ...r) === 0 ? -1 : i;
867
- }
868
- J.getNextDifferent = B;
869
- function G(t, o, ...u) {
870
- if (t.length <= 1)
871
- return [...t];
872
- if (typeof o != "boolean")
873
- throw new Error("firstOfDuplicates must be boolean true or false.");
874
- const r = [];
875
- let i = 0;
876
- for (; i < t.length - 1 && (o && r.push(t[i]), i = B(t, t[i], i + 1, ...u), !(i < 0)); ) {
877
- let f = i - 1;
878
- o || r.push(t[f]);
879
- }
880
- return r.length === 0 ? o ? r.push(t[0]) : r.push(t[t.length - 1]) : Z(r[r.length - 1], t[t.length - 1], ...u) !== 0 && r.push(t[t.length - 1]), r;
881
- }
882
- J.getObjArrayWithNoDuplicates = G;
883
- function Z(t, o, ...u) {
884
- if (u.length === 0)
885
- throw new Error("comparisonFields not supplied!");
886
- const r = ["", "asc", "desc"];
887
- for (const i in u) {
888
- const f = u[i].split(" "), c = f[0];
889
- let v = "";
890
- if (f.length === 2 && (v = f[1]), !r.includes(v))
891
- throw new Error("Sort direction must be one of " + r.toString());
892
- const h = P(t, c), H = P(o, c), K = v === "desc" ? -1 : 1;
893
- if (h > H)
894
- return K;
895
- if (h < H)
896
- return -K;
897
- }
898
- return 0;
899
- }
900
- return J.objCompare = Z, J;
67
+ return 0;
901
68
  }
902
- var ne = Le();
903
- function Ye({
904
- label: n,
69
+ function R({
70
+ label: t,
905
71
  // label with which to describe the dropdown.
906
- data: j,
72
+ data: r,
907
73
  // Primitive type array.
908
- sortOrder: M = "asc",
909
- onItemSelected: b = null,
74
+ sortOrder: u = "asc",
75
+ onItemSelected: d,
910
76
  // Function to pass on the value of the selected item to the parent component
911
- selected: T = null,
77
+ selected: c,
912
78
  // Initial selected item.
913
- dropdownStyle: p,
79
+ selReset: s = !1,
80
+ // If true, selected item via parent component.
81
+ dropdownStyle: a,
914
82
  // Styling object with fields {color, backgroundColor, borderColor (optional), fontSize}.
915
- isDisabled: w = !1
83
+ isDisabled: h = !1
916
84
  }) {
917
- const m = ce(), [g, x] = ee(!1), [y, C] = ee(""), E = re(() => j.toSorted(s), [j]), P = re(() => {
918
- if (y.length === 0)
919
- return [];
920
- const r = y.toUpperCase();
921
- return E.filter((i) => i.toUpperCase().includes(r));
922
- }, [E, y]), Y = re(() => y.length === 0 ? E : P, [E, y]), [q, _] = ee(""), [U, X] = ee(null);
923
- re(() => {
924
- let r = "";
925
- if (U)
926
- r = U;
927
- else if (T) {
928
- const i = j.findIndex((f) => f === T);
929
- i >= 0 && (r = j[i]);
930
- }
931
- return _(r), r;
932
- }, [T, U]);
933
- const D = (() => {
934
- const r = {
935
- backgroundColor: p?.backgroundColor,
936
- color: p?.color
85
+ const C = ["number", "string", "boolean", "bigint"];
86
+ if (r.length > 0 && r.some((i) => i === null || !C.includes(typeof i)))
87
+ throw new Error(`Dropdown items must be one of ${C}`);
88
+ const m = Q(), [w, b] = j(!1), [S, y] = j(""), D = E(() => r.toSorted(I), [r]), $ = E(() => {
89
+ if (S.length === 0)
90
+ return D;
91
+ const i = S.toUpperCase();
92
+ return D.filter((p) => p.toUpperCase().includes(i));
93
+ }, [D, S]), [z, k] = j(""), [x, L] = j(), V = E(() => {
94
+ let i, p = -1;
95
+ return x && s === !1 ? (p = r.findIndex((e) => e === x), p >= 0 && (i = r[p])) : c && (p = r.findIndex((e) => e === c), p >= 0 && (i = r[p])), p >= 0 ? k(i) : k(""), i;
96
+ }, [s, c, x]), [T, U] = j(0);
97
+ W(() => {
98
+ T > 0 && x && d && d(V);
99
+ }, [T]);
100
+ const g = (() => {
101
+ const i = {
102
+ backgroundColor: a?.backgroundColor,
103
+ color: a?.color
937
104
  };
938
- return p?.fontSize && (r.fontSize = p?.fontSize), r;
939
- })(), $ = p?.borderColor;
940
- function s(r, i) {
941
- return ne.compare(r, i, M);
105
+ return a?.fontSize && (i.fontSize = a.fontSize), i;
106
+ })(), K = a?.borderColor;
107
+ function I(i, p) {
108
+ return Y(i, p, u);
942
109
  }
943
- function B(r) {
944
- C(r.target.value), _(r.target.value), P.length === 0 ? t() : o();
110
+ function F(i) {
111
+ y(i.target.value), k(i.target.value), P();
945
112
  }
946
- async function G(r) {
947
- _(r), C(""), X(r), b !== null && b(r), t();
113
+ async function q(i) {
114
+ s || (k(i), y(""), L(i), A(), U((p) => p + 1));
948
115
  }
949
- function Z() {
950
- g ? t() : o();
116
+ function B() {
117
+ h || (w ? A() : P());
951
118
  }
952
- function t() {
953
- x(!1);
119
+ function A() {
120
+ b(!1);
954
121
  }
955
- function o() {
956
- Y.length > 0 && x(!0);
122
+ function P() {
123
+ $.length > 0 && b(!0);
957
124
  }
958
- const u = {
125
+ const N = {
959
126
  dropdownSearch: `dropdownSearch-${m}`,
960
127
  dropdown: `dropdown-${m}`
961
128
  };
962
- return /* @__PURE__ */ Q(
129
+ return /* @__PURE__ */ v(
963
130
  "div",
964
131
  {
965
132
  className: `dropdown-js dropdown-js-rounded
966
- ${$ && `dropdown-js-border ${$}`}`,
967
- style: { ...w ? { pointerEvents: "none" } : {} },
133
+ ${K && `dropdown-js-border ${K}`}`,
134
+ style: { ...h ? { pointerEvents: "none" } : {} },
968
135
  children: [
969
- /* @__PURE__ */ Q("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: D, children: [
970
- /* @__PURE__ */ L(
136
+ /* @__PURE__ */ v("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: g, children: [
137
+ /* @__PURE__ */ l(
971
138
  "input",
972
139
  {
973
- id: u.dropdownSearch,
140
+ id: N.dropdownSearch,
974
141
  name: "dropdownSearch",
975
142
  className: "dropdown-js-input dropdown-js-rounded",
976
143
  autoComplete: "off",
977
144
  type: "text",
978
- style: D,
145
+ style: g,
979
146
  role: "combobox",
980
- "aria-placeholder": `Type to Search for ${n}`,
147
+ "aria-placeholder": `Type to Search for ${t}`,
981
148
  "aria-required": !0,
982
- "aria-controls": u.dropdown,
149
+ "aria-controls": N.dropdown,
983
150
  "aria-autocomplete": "list",
984
151
  "aria-haspopup": "listbox",
985
- "aria-expanded": g,
986
- onChange: (r) => B(r),
987
- disabled: w,
988
- placeholder: `Type to Search for ${n}`,
989
- value: q
152
+ "aria-expanded": w,
153
+ onChange: (i) => F(i),
154
+ disabled: h,
155
+ placeholder: `Type to Search for ${t}`,
156
+ value: z
990
157
  }
991
158
  ),
992
- /* @__PURE__ */ L(
159
+ /* @__PURE__ */ l(
993
160
  "div",
994
161
  {
995
162
  className: "dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded",
996
- "aria-expanded": g,
163
+ "aria-expanded": w,
997
164
  "aria-controls": "multiSelectionDropdown",
998
- "aria-label": `${n} options`,
999
- onClick: (r) => Z(),
1000
- children: /* @__PURE__ */ L(
165
+ "aria-label": `${t} options`,
166
+ onClick: () => B(),
167
+ children: /* @__PURE__ */ l(
1001
168
  "span",
1002
169
  {
1003
170
  className: "dropdown-js-arrow dropdown-js-padding",
1004
- "aria-label": `${n} options`,
1005
- "aria-expanded": g,
1006
- children: g ? "-" : "+"
171
+ "aria-label": `${t} options`,
172
+ "aria-expanded": w,
173
+ children: w ? "-" : "+"
1007
174
  }
1008
175
  )
1009
176
  }
1010
177
  )
1011
178
  ] }),
1012
- /* @__PURE__ */ L(
1013
- "div",
179
+ /* @__PURE__ */ l(
180
+ "ul",
1014
181
  {
1015
- className: `dropdown-js-padding dropdown-js-menu ${!g && "dropdown-js-hide"}`,
1016
- id: u.dropdown,
1017
- name: "dropDown",
182
+ className: `dropdown-js-padding dropdown-js-menu ${!w && "dropdown-js-hide"}`,
183
+ id: N.dropdown,
1018
184
  role: "listbox",
1019
- "aria-expanded": g,
1020
- disabled: w,
1021
- "aria-label": n,
1022
- style: { ...D, marginTop: "3.5px" },
1023
- children: Y.map((r, i) => /* @__PURE__ */ Q(
1024
- "div",
185
+ "aria-expanded": w,
186
+ "aria-disabled": h,
187
+ "aria-label": t,
188
+ style: { ...g, marginTop: "3.5px" },
189
+ children: $.map((i, p) => /* @__PURE__ */ v(
190
+ "li",
1025
191
  {
1026
- name: r,
1027
192
  role: "option",
1028
- "aria-label": r,
193
+ "aria-label": i,
1029
194
  style: { cursor: "pointer" },
1030
- onClick: (f) => G(r),
195
+ onClick: () => q(i),
1031
196
  children: [
1032
- r,
1033
- i < Y.length - 1 && /* @__PURE__ */ L("hr", { style: { borderColor: D.color } })
197
+ i,
198
+ p < $.length - 1 && /* @__PURE__ */ l("hr", { style: { borderColor: g.color } })
1034
199
  ]
1035
200
  },
1036
- `${i}#${r}`
201
+ `${p}#${i}`
1037
202
  ))
1038
203
  }
1039
204
  )
@@ -1041,154 +206,138 @@ function Ye({
1041
206
  }
1042
207
  );
1043
208
  }
1044
- Ye.propTypes = {
1045
- label: l.string.isRequired,
1046
- data: l.array.isRequired,
1047
- sortOrder: l.string,
1048
- selected: l.any,
1049
- isDisabled: l.bool,
1050
- onItemSelected: l.func,
1051
- dropdownStyle: l.shape({
1052
- color: l.string.isRequired,
1053
- // text color
1054
- backgroundColor: l.string.isRequired,
1055
- fontSize: l.string,
1056
- borderColor: l.string
1057
- }),
1058
- buttonStyle: l.shape({
1059
- color: l.string.isRequired,
1060
- // text color
1061
- backgroundColor: l.string.isRequired,
1062
- fontSize: l.string,
1063
- borderColor: l.string
1064
- })
1065
- };
1066
- function Ue({
1067
- label: n,
209
+ function ee({
210
+ label: t,
1068
211
  // label with which to describe the dropdown.
1069
- data: j,
1070
- sortFields: M,
1071
- selected: b = null,
1072
- displayName: T,
212
+ data: r,
213
+ sortFields: u,
214
+ selected: d = null,
215
+ selReset: c = !1,
216
+ displayName: s,
1073
217
  // the name of the field that will be used for displaying the list items to the user.
1074
- valueName: p,
218
+ valueName: a,
1075
219
  // the name of the field that will be used as the underlying unique value of each list item.
1076
- isDisabled: w = !1,
1077
- onItemSelected: m = null,
1078
- dropdownStyle: g
220
+ isDisabled: h = !1,
221
+ onItemSelected: C,
222
+ dropdownStyle: m
1079
223
  }) {
1080
- const x = ce(), [y, C] = ee(null), [E, P] = ee(""), [Y, q] = ee(""), _ = re(() => j.toSorted(o), [j]), U = re(() => {
1081
- if (Y.length === 0)
1082
- return [];
1083
- const h = Y.toUpperCase();
1084
- return _.filter((H) => H[T].toUpperCase().toUpperCase().includes(h));
1085
- }, [Y]), [X, D] = ee(""), [$, s] = ee(null);
1086
- re(() => {
1087
- let h;
1088
- if ($)
1089
- h = { ...$ };
1090
- else if (b) {
1091
- const H = u(), K = j.findIndex((e) => ne.get(e, ...H) === ne.get(b, ...H));
1092
- K >= 0 && (h = j[K]);
1093
- }
1094
- return h && D(h[T]), h;
1095
- }, [b, $]);
1096
- const B = re(() => Y.length > 0 ? U : _, [Y, _]), G = (() => {
1097
- const h = {
1098
- backgroundColor: g?.backgroundColor,
1099
- color: g?.color
224
+ j(
225
+ () => (r.forEach((e) => {
226
+ if (!G(e))
227
+ throw new Error("[Dropdowns-js] Non plain object found");
228
+ const n = Object.keys(e);
229
+ if (!n.includes(s))
230
+ throw new Error(`[Dropdowns-js] displayName field ${s} not found`);
231
+ if (!n.includes(a))
232
+ throw new Error(`[Dropdowns-js] valueName field ${a} not found`);
233
+ }), !0)
234
+ );
235
+ const w = Q(), [b, S] = j(!1), [y, D] = j(""), $ = E(() => r.length > 0 ? X(r[0]) : [], [r]), z = E(() => r.toSorted(B), [r]), k = E(() => {
236
+ if (y.length === 0)
237
+ return z;
238
+ const e = y.toUpperCase();
239
+ return z.filter((n) => n[s].toUpperCase().includes(e));
240
+ }, [y, z]), [x, L] = j(0);
241
+ W(() => {
242
+ x > 0 && U && C && C(K);
243
+ }, [x]);
244
+ const [V, T] = j(""), [U, g] = j(null), K = E(() => {
245
+ let e = null, n = -1;
246
+ return U && c === !1 ? (n = r.findIndex(
247
+ (o) => M(o, U, ...$) === 0
248
+ ), n >= 0 && (e = r[n])) : d && (n = r.findIndex(
249
+ (o) => M(o, d, ...$) === 0
250
+ ), n >= 0 && (e = r[n])), n >= 0 ? T(e[s]) : T(""), e;
251
+ }, [d, U]), I = (() => {
252
+ const e = {
253
+ backgroundColor: m?.backgroundColor,
254
+ color: m?.color
1100
255
  };
1101
- return g?.fontSize && (h.fontSize = g?.fontSize), h;
1102
- })(), Z = g?.borderColor;
1103
- async function t(h) {
1104
- q((H) => h.target.value), D((H) => h.target.value), U.length > 0 ? c() : f();
256
+ return m?.fontSize && (e.fontSize = m?.fontSize), e;
257
+ })(), F = m?.borderColor;
258
+ async function q(e) {
259
+ D(e.target.value), T(e.target.value), i();
1105
260
  }
1106
- function o(h, H) {
1107
- return ne.objCompare(h, H, ...M);
261
+ function B(e, n) {
262
+ return M(e, n, ...u);
1108
263
  }
1109
- function u() {
1110
- let h = E;
1111
- return h || (j.length > 0 && (h = ne.getPaths(j[0])), P(h)), h;
264
+ function A(e) {
265
+ c || (g({ ...e }), D(""), N(), L((n) => n + 1));
1112
266
  }
1113
- function r(h) {
1114
- s(h), m !== null && m(h), f();
1115
- }
1116
- function i() {
1117
- y ? f() : c();
267
+ function P() {
268
+ b ? N() : i();
1118
269
  }
1119
- function f() {
1120
- C(!1);
270
+ function N() {
271
+ S(!1);
1121
272
  }
1122
- function c() {
1123
- B.length > 0 && C(!0);
273
+ function i() {
274
+ k.length > 0 && S(!0);
1124
275
  }
1125
- const v = {
1126
- dropdownSearch: `dropdownObjSearch-${x}`,
1127
- dropdownObj: `dropdownObj-${x}`
276
+ const p = {
277
+ dropdownSearch: `dropdownObjSearch-${w}`,
278
+ dropdownObj: `dropdownObj-${w}`
1128
279
  };
1129
- return /* @__PURE__ */ Q(
280
+ return /* @__PURE__ */ v(
1130
281
  "div",
1131
282
  {
1132
283
  className: `dropdown-js dropdown-js-rounded
1133
- ${Z && `dropdown-js-border ${Z}`}`,
1134
- style: { ...w ? { pointerEvents: "none" } : {} },
284
+ ${F && `dropdown-js-border ${F}`}`,
285
+ style: { ...h ? { pointerEvents: "none" } : {} },
1135
286
  children: [
1136
- /* @__PURE__ */ Q("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: G, children: [
1137
- /* @__PURE__ */ L(
287
+ /* @__PURE__ */ v("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: I, children: [
288
+ /* @__PURE__ */ l(
1138
289
  "input",
1139
290
  {
1140
- id: v.dropdownSearch,
291
+ id: p.dropdownSearch,
1141
292
  name: "dropdownObjSearch",
1142
293
  className: "dropdown-js-input dropdown-js-rounded",
1143
- style: G,
294
+ style: I,
1144
295
  type: "text",
1145
296
  autoComplete: "off",
1146
297
  role: "combobox",
1147
298
  "aria-autocomplete": "list",
1148
- "aria-controls": v.dropdownObj,
1149
- "aria-expanded": y,
1150
- "aria-placeholder": `Type to Search for ${n}`,
299
+ "aria-controls": p.dropdownObj,
300
+ "aria-expanded": b,
301
+ "aria-placeholder": `Type to Search for ${t}`,
1151
302
  "aria-required": !0,
1152
- onChange: (h) => t(h),
1153
- disabled: w,
1154
- placeholder: `Type to Search for ${n}`,
1155
- value: X
303
+ onChange: (e) => q(e),
304
+ disabled: h,
305
+ placeholder: `Type to Search for ${t}`,
306
+ value: V
1156
307
  }
1157
308
  ),
1158
- /* @__PURE__ */ L(
309
+ /* @__PURE__ */ l(
1159
310
  "div",
1160
311
  {
1161
312
  className: "dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded",
1162
- "aria-label": `${n} options`,
1163
- "aria-expanded": y,
1164
- onClick: (h) => i(),
1165
- children: /* @__PURE__ */ L("span", { className: "dropdown-js-arrow dropdown-js-padding", children: y ? "-" : "+" })
313
+ "aria-label": `${t} options`,
314
+ "aria-expanded": b,
315
+ onClick: () => P(),
316
+ children: /* @__PURE__ */ l("span", { className: "dropdown-js-arrow dropdown-js-padding", children: b ? "-" : "+" })
1166
317
  }
1167
318
  )
1168
319
  ] }),
1169
- /* @__PURE__ */ L(
320
+ /* @__PURE__ */ l(
1170
321
  "div",
1171
322
  {
1172
- className: `dropdown-js-padding dropdown-js-menu ${!y && "dropdown-js-hide"}`,
1173
- id: v.dropdownObj,
1174
- name: "dropDownObj",
323
+ className: `dropdown-js-padding dropdown-js-menu ${!b && "dropdown-js-hide"}`,
324
+ id: p.dropdownObj,
1175
325
  role: "listbox",
1176
- "aria-expanded": y,
1177
- style: { ...G, marginTop: "3.5px" },
1178
- children: B.map((h, H) => /* @__PURE__ */ Q(
326
+ "aria-expanded": b,
327
+ style: { ...I, marginTop: "3.5px" },
328
+ children: k.map((e, n) => /* @__PURE__ */ v(
1179
329
  "div",
1180
330
  {
1181
- name: h[T],
1182
331
  role: "option",
1183
- "aria-label": h[T],
332
+ "aria-label": J(e, s),
1184
333
  style: { cursor: "pointer" },
1185
- onClick: (K) => r(h),
334
+ onClick: () => A(e),
1186
335
  children: [
1187
- h[T],
1188
- H < B.length - 1 && /* @__PURE__ */ L("hr", { style: { borderColor: G.color } })
336
+ J(e, s),
337
+ n < k.length - 1 && /* @__PURE__ */ l("hr", { style: { borderColor: I.color } })
1189
338
  ]
1190
339
  },
1191
- `${h[p]}${H}`
340
+ `${J(e, a)}${n}`
1192
341
  ))
1193
342
  }
1194
343
  )
@@ -1196,213 +345,204 @@ function Ue({
1196
345
  }
1197
346
  );
1198
347
  }
1199
- Ue.propTypes = {
1200
- label: l.string.isRequired,
1201
- data: l.arrayOf(l.object).isRequired,
1202
- sortFields: l.arrayOf(l.string).isRequired,
1203
- selected: l.object,
1204
- displayName: l.string.isRequired,
1205
- valueName: l.string.isRequired,
1206
- isDisabled: l.bool,
1207
- onItemSelected: l.func,
1208
- dropdownStyle: l.shape({
1209
- color: l.string.isRequired,
1210
- // text color
1211
- backgroundColor: l.string.isRequired,
1212
- fontSize: l.string,
1213
- borderColor: l.string
1214
- })
1215
- };
1216
- function Fe({
1217
- label: n,
348
+ function oe({
349
+ label: t,
1218
350
  // label with which to describe the dropdown.
1219
- data: j,
1220
- sortFields: M,
1221
- selectedData: b = [],
1222
- maxNumSelections: T = null,
1223
- displayName: p,
351
+ data: r,
352
+ sortFields: u,
353
+ selectedData: d = [],
354
+ selReset: c = !1,
355
+ maxNumSelections: s,
356
+ displayName: a,
1224
357
  // the name of the field that will be used for displaying the list items to the user.
1225
- valueName: w,
358
+ valueName: h,
1226
359
  // the name of the field that will be used as the underlying unique value of each list item.
1227
- isDisabled: m = !1,
1228
- onItemsSelected: g = null,
1229
- dropdownStyle: x,
1230
- buttonStyle: y
360
+ isDisabled: C,
361
+ onItemsSelected: m,
362
+ dropdownStyle: w,
363
+ buttonStyle: b
1231
364
  }) {
1232
- const C = ce(), [E, P] = ee(!1), [Y, q] = ee(""), [_, U] = ee(""), X = re(() => j.toSorted(u), [j]), [D, $] = ee([]), s = re(() => D.length > 0 ? D.filter((e) => X.findIndex((a) => {
1233
- const S = o();
1234
- return ne.objCompare(e, a, ...S) === 0;
1235
- }) >= 0).toSorted(u) : b.filter((e) => X.findIndex((a) => {
1236
- const S = o();
1237
- return ne.objCompare(e, a, ...S) === 0;
1238
- }) >= 0).toSorted(u), [X, b, D]), B = re(() => {
1239
- if (_.length === 0)
1240
- return [];
1241
- const e = _.toUpperCase();
1242
- return X.filter((a) => a[p].toUpperCase().includes(e));
1243
- }, [_]), G = re(() => _.length > 0 ? B : X, [_, X]), Z = (() => {
1244
- const e = {
1245
- backgroundColor: x?.backgroundColor,
1246
- color: x?.color
365
+ j(
366
+ () => (r.forEach((o) => {
367
+ if (!G(o))
368
+ throw new Error("[Dropdowns-js] Non plain object found");
369
+ const f = Object.keys(o);
370
+ if (!f.includes(a))
371
+ throw new Error(`[Dropdowns-js] displayName field ${a} not found`);
372
+ if (!f.includes(h))
373
+ throw new Error(`[Dropdowns-js] valueName field ${h} not found`);
374
+ }), !0)
375
+ );
376
+ const S = Q(), [y, D] = j(!1), $ = E(() => r.length > 0 ? X(r[0]) : [], [r]), [z, k] = j(""), x = E(() => r.toSorted(q), [r]), [L, V] = j(0), [T, U] = j([]), g = E(() => {
377
+ let o = c === !1 && T ? [...T] : [...d];
378
+ return o = o.filter((f) => x.some(
379
+ (O) => M(f, O, ...$) === 0
380
+ )), s && o.length > s && (o = o.slice(0, s - 1)), o.toSorted(q);
381
+ }, [x, d, T]);
382
+ W(() => {
383
+ L > 0 && T && m && m([...g]);
384
+ }, [L]);
385
+ const K = E(() => {
386
+ const o = z.toUpperCase();
387
+ return o.length === 0 ? x : x.filter((f) => f[a].toUpperCase().includes(o));
388
+ }, [z, x]), I = (() => {
389
+ const o = {
390
+ backgroundColor: w?.backgroundColor,
391
+ color: w?.color
1247
392
  };
1248
- return x?.fontSize && (e.fontSize = x?.fontSize), e;
1249
- })(), t = x?.borderColor;
1250
- Pe(() => {
1251
- if (!p)
1252
- throw new Error("displayName must be provided");
1253
- if (!w)
1254
- throw new Error("valueName must be provided");
1255
- }, []);
1256
- function o() {
1257
- let e = Y;
1258
- return e || (j.length > 0 && (e = ne.getPaths(j[0])), q(e)), e;
1259
- }
1260
- function u(e, a) {
1261
- return ne.objCompare(e, a, ...M);
1262
- }
1263
- function r(e) {
1264
- U(e.target.value), B.length > 0 ? H() : h();
1265
- }
1266
- function i(e) {
1267
- let a = [...s];
1268
- if (f(e))
1269
- a = a.filter((S) => {
1270
- const O = o();
1271
- return ne.objCompare(S, e, ...O) !== 0;
1272
- });
1273
- else {
1274
- if (T !== null && s.length >= T)
1275
- return;
1276
- a.push(e);
1277
- }
1278
- $(a);
393
+ return w?.fontSize && (o.fontSize = w?.fontSize), o;
394
+ })(), F = w?.borderColor;
395
+ function q(o, f) {
396
+ return M(o, f, ...u);
397
+ }
398
+ function B(o) {
399
+ k(o.target.value), e();
400
+ }
401
+ function A(o) {
402
+ c || U((f) => {
403
+ let O = f ? [...f] : [...g];
404
+ return O.some(
405
+ (H) => (
406
+ // clicked item not found in the list of selected items.
407
+ M(H, o, ...$) === 0
408
+ )
409
+ ) ? O = O.filter((H) => M(H, o, ...$) !== 0) : (s === null || s && O.length < s) && O.push(o), O;
410
+ });
1279
411
  }
1280
- function f(e) {
1281
- const a = o();
1282
- return s.findIndex((S) => ne.objCompare(S, e, ...a) === 0) >= 0;
412
+ function P(o) {
413
+ return g.some((f) => M(f, o, ...$) === 0);
1283
414
  }
1284
- function c(e) {
1285
- const a = o(), S = s.filter((O) => ne.objCompare(O, e, ...a) !== 0);
1286
- $(S), g !== null && g(S);
415
+ function N(o) {
416
+ c || (U((f) => {
417
+ let O = f ? [...f] : [...g];
418
+ return O = O.filter((H) => M(H, o, ...$) !== 0), O;
419
+ }), V((f) => f + 1));
1287
420
  }
1288
- function v() {
1289
- E ? h() : H();
421
+ function i() {
422
+ y ? p() : e();
1290
423
  }
1291
- function h() {
1292
- P(!1), g !== null && g(s);
424
+ function p() {
425
+ D(!1), V((o) => o + 1);
1293
426
  }
1294
- function H() {
1295
- G.length > 0 && P(!0);
427
+ function e() {
428
+ K.length > 0 && D(!0);
1296
429
  }
1297
- const K = {
1298
- multiSelectionDropdownObjSearch: `multiSelectionDropdownSearch-${C}`,
1299
- multiSelectionDropdownObj: `multiSelectionDropdown-${C}`,
1300
- selectedItems: `selectedItems-${C}`
430
+ const n = {
431
+ multiSelectionDropdownObjSearch: `multiSelectionDropdownSearch-${S}`,
432
+ multiSelectionDropdownObj: `multiSelectionDropdown-${S}`,
433
+ selectedItems: `selectedItems-${S}`
1301
434
  };
1302
- return /* @__PURE__ */ Q(
435
+ return /* @__PURE__ */ v(
1303
436
  "div",
1304
437
  {
1305
438
  className: `dropdown-js dropdown-js-rounded
1306
- ${t && `dropdown-js-border ${t}`}`,
1307
- style: { ...m ? { pointerEvents: "none" } : {} },
439
+ ${F && `dropdown-js-border ${F}`}`,
440
+ style: { ...C ? { pointerEvents: "none" } : {} },
1308
441
  children: [
1309
- /* @__PURE__ */ Q("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: Z, children: [
1310
- /* @__PURE__ */ L("div", { children: /* @__PURE__ */ L(
442
+ /* @__PURE__ */ v("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: I, children: [
443
+ /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(
1311
444
  "input",
1312
445
  {
1313
- id: K.multiSelectionDropdownObjSearch,
446
+ id: n.multiSelectionDropdownObjSearch,
1314
447
  name: "multiSelectionDropdownObjSearch",
1315
448
  className: "dropdown-js-input dropdown-js-rounded",
1316
- style: Z,
1317
- "aria-label": n,
449
+ style: I,
450
+ "aria-label": t,
1318
451
  "aria-autocomplete": "list",
1319
- "aria-controls": K.multiSelectionDropdownObj,
452
+ "aria-controls": n.multiSelectionDropdownObj,
1320
453
  role: "combobox",
1321
- "aria-expanded": E,
454
+ "aria-expanded": y,
1322
455
  "aria-haspopup": "listbox",
1323
456
  type: "text",
1324
457
  autoComplete: "off",
1325
- "aria-placeholder": `Type to Search for ${n}`,
1326
- onChange: (e) => r(e),
1327
- placeholder: `Type to Search for ${n}`,
1328
- value: _
458
+ "aria-placeholder": `Type to Search for ${t}`,
459
+ onChange: (o) => B(o),
460
+ placeholder: `Type to Search for ${t}`,
461
+ value: z
1329
462
  }
1330
463
  ) }),
1331
- /* @__PURE__ */ L(
464
+ /* @__PURE__ */ l(
1332
465
  "div",
1333
466
  {
1334
467
  className: "dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded",
1335
- "aria-expanded": E,
468
+ "aria-expanded": y,
1336
469
  "aria-controls": "multiSelectionDropdownObj",
1337
- "aria-label": `${n} options`,
1338
- onClick: (e) => v(),
1339
- children: /* @__PURE__ */ L("span", { className: "dropdown-js-arrow dropdown-js-padding", children: E ? "-" : "+" })
470
+ "aria-label": `${t} options`,
471
+ onClick: () => i(),
472
+ children: /* @__PURE__ */ l("span", { className: "dropdown-js-arrow dropdown-js-padding", children: y ? "-" : "+" })
1340
473
  }
1341
474
  )
1342
475
  ] }),
1343
- /* @__PURE__ */ L("div", { className: "dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container", children: /* @__PURE__ */ L(
476
+ /* @__PURE__ */ l("div", { className: "dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container", children: /* @__PURE__ */ l(
1344
477
  "div",
1345
478
  {
1346
- id: K.selectedItems,
479
+ id: n.selectedItems,
1347
480
  className: "dropdown-js-selected-items",
1348
- "aria-label": `Selected ${n} options`,
481
+ "aria-label": `Selected ${t} options`,
1349
482
  "aria-multiselectable": !0,
1350
483
  "aria-live": "polite",
1351
- children: s.map((e) => /* @__PURE__ */ Q(
484
+ children: g.map((o) => /* @__PURE__ */ v(
1352
485
  "span",
1353
486
  {
1354
487
  className: "dropdown-js-padding dropdown-js-rounded",
1355
- "aria-label": `${e[p]}`,
1356
- style: { ...Z, margin: "3.5px", marginRight: "0px" },
488
+ "aria-label": `${o[a]}`,
489
+ style: { ...I, margin: "3.5px", marginRight: "0px" },
1357
490
  children: [
1358
- e[p],
491
+ o[a],
1359
492
  " ",
1360
- /* @__PURE__ */ L("span", { className: "dropdown-js-padding", style: { cursor: "pointer" }, "aria-label": `Remove ${e[p]}`, onClick: (a) => c(e), children: "×" })
493
+ /* @__PURE__ */ l(
494
+ "span",
495
+ {
496
+ className: "dropdown-js-padding",
497
+ style: { cursor: "pointer" },
498
+ "aria-label": `Remove ${o[a]}`,
499
+ onClick: () => N(o),
500
+ children: "×"
501
+ }
502
+ )
1361
503
  ]
1362
504
  },
1363
- `${e[w]}${e[p]}`
505
+ `${o[h]}${o[a]}`
1364
506
  ))
1365
507
  }
1366
508
  ) }),
1367
- /* @__PURE__ */ Q(
509
+ /* @__PURE__ */ v(
1368
510
  "div",
1369
511
  {
1370
- className: `dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!E && "dropdown-js-hide"}`,
1371
- style: Z,
1372
- id: K.multiSelectionDropdownObj,
1373
- name: "multiSelectionDropdownObj",
512
+ className: `dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!y && "dropdown-js-hide"}`,
513
+ style: I,
514
+ id: n.multiSelectionDropdownObj,
1374
515
  role: "listbox",
1375
516
  "aria-multiselectable": !0,
1376
- "aria-expanded": E,
517
+ "aria-expanded": y,
1377
518
  children: [
1378
- G.map((e) => /* @__PURE__ */ Q("div", { children: [
1379
- /* @__PURE__ */ L(
519
+ K.map((o) => /* @__PURE__ */ v("div", { children: [
520
+ /* @__PURE__ */ l(
1380
521
  "input",
1381
522
  {
1382
- id: `${e[w]}Checkbox`,
523
+ id: `${o[h]}Checkbox`,
1383
524
  type: "checkbox",
1384
- name: `${e[p]}Checkbox`,
525
+ name: `${o[a]}Checkbox`,
1385
526
  role: "option",
1386
- "aria-label": `${e[p]}`,
1387
- "aria-checked": f(e),
527
+ "aria-label": `${o[a]}`,
528
+ "aria-checked": P(o),
1388
529
  style: { cursor: "pointer" },
1389
- checked: f(e),
1390
- onChange: (a) => i(e),
1391
- value: e[w]
530
+ checked: P(o),
531
+ onChange: () => A(o),
532
+ value: o[h]
1392
533
  }
1393
534
  ),
1394
- /* @__PURE__ */ L("label", { style: { marginLeft: "5px" }, htmlFor: `${e[w]}`, children: e[p] }),
1395
- /* @__PURE__ */ L("hr", { style: { backgroundColor: Z.color, border: "none", height: "0.5px" } })
1396
- ] }, `${e[w]}${e[p]}`)),
1397
- /* @__PURE__ */ L(
535
+ /* @__PURE__ */ l("label", { style: { marginLeft: "5px" }, htmlFor: `${o[h]}`, children: o[a] }),
536
+ /* @__PURE__ */ l("hr", { style: { backgroundColor: I.color, border: "none", height: "0.5px" } })
537
+ ] }, `${o[h]}${o[a]}`)),
538
+ /* @__PURE__ */ l(
1398
539
  "button",
1399
540
  {
1400
541
  className: "dropdown-js-padding dropdown-js-round",
1401
- style: y,
542
+ style: b,
1402
543
  title: "Done",
1403
- disabled: G.length === 0,
1404
- "aria-label": `Close ${n} options`,
1405
- onClick: (e) => h(),
544
+ "aria-label": `Close ${t} options`,
545
+ onClick: () => p(),
1406
546
  type: "button",
1407
547
  children: "Done"
1408
548
  }
@@ -1414,198 +554,173 @@ function Fe({
1414
554
  }
1415
555
  );
1416
556
  }
1417
- Fe.propTypes = {
1418
- label: l.string.isRequired,
1419
- data: l.arrayOf(l.object).isRequired,
1420
- sortFields: l.arrayOf(l.string).isRequired,
1421
- selectedData: l.arrayOf(l.object),
1422
- maxNumSelections: l.number,
1423
- displayName: l.string.isRequired,
1424
- valueName: l.string.isRequired,
1425
- isDisabled: l.bool,
1426
- onItemsSelected: l.func,
1427
- dropdownStyle: l.shape({
1428
- color: l.string.isRequired,
1429
- // text color
1430
- backgroundColor: l.string.isRequired,
1431
- fontSize: l.string,
1432
- borderColor: l.string
1433
- }),
1434
- buttonStyle: l.shape({
1435
- color: l.string.isRequired,
1436
- // text color
1437
- backgroundColor: l.string.isRequired,
1438
- fontSize: l.string,
1439
- borderColor: l.string
1440
- })
1441
- };
1442
- function Ve({
1443
- label: n,
557
+ function re({
558
+ label: t,
1444
559
  // label with which to describe the dropdown.
1445
- data: j,
1446
- sortOrder: M = "asc",
1447
- selectedData: b = [],
1448
- maxNumSelections: T = null,
1449
- isDisabled: p = !1,
1450
- onItemsSelected: w = null,
1451
- dropdownStyle: m,
560
+ data: r,
561
+ sortOrder: u = "asc",
562
+ selectedData: d = [],
563
+ selReset: c = !1,
564
+ maxNumSelections: s,
565
+ isDisabled: a = !1,
566
+ onItemsSelected: h,
567
+ dropdownStyle: C,
1452
568
  // Styling object with fields {color, backgroundColor, borderColor (optional), fontSize}.
1453
- buttonStyle: g
569
+ buttonStyle: m
1454
570
  // Styling for the DONE button
1455
571
  }) {
1456
- const x = ce(), [y, C] = ee(!1), E = re(() => j.toSorted(B), [j]), [P, Y] = ee(""), [q, _] = ee([]), U = re(() => q.length > 0 ? q.filter((c) => E.findIndex((v) => v === c) >= 0).toSorted(B) : b.filter((c) => E.findIndex((v) => v === c) >= 0).toSorted(B), [E, b, q]), X = re(() => {
1457
- if (P.length === 0)
1458
- return [];
1459
- const c = P.toUpperCase();
1460
- return E.filter((v) => v.toUpperCase().includes(c));
1461
- }, [P]), D = re(() => P.length > 0 ? X : E, [P, E]), $ = (() => {
1462
- const c = {
1463
- backgroundColor: m?.backgroundColor,
1464
- color: m?.color
1465
- };
1466
- return m?.fontSize && (c.fontSize = m?.fontSize), c;
1467
- })(), s = m?.borderColor;
1468
- function B(c, v) {
1469
- return ne.compare(c, v, M);
1470
- }
1471
- function G(c) {
1472
- const v = c.target.value;
1473
- Y(v), D.length > 0 ? i() : r();
1474
- }
1475
- function Z(c) {
1476
- let v = [...U];
1477
- if (t(c))
1478
- v = v.filter((h) => h !== c);
1479
- else {
1480
- if (T !== null && v.length >= T)
1481
- return;
1482
- v.push(c);
1483
- }
1484
- _(v);
1485
- }
1486
- function t(c) {
1487
- return U.findIndex((v) => v === c) >= 0;
1488
- }
1489
- function o(c) {
1490
- const v = U.filter((h) => h !== c);
1491
- _((h) => v), w !== null && w(v);
1492
- }
1493
- function u() {
1494
- y ? r() : i();
1495
- }
1496
- function r() {
1497
- C(!1), w !== null && w(U);
572
+ const w = ["number", "string", "boolean", "bigint"];
573
+ if (r.length > 0 && r.some((e) => e === null && !w.includes(typeof e)))
574
+ throw new Error(`Dropdown items must be one of ${w}`);
575
+ const b = Q(), [S, y] = j(!1), D = E(() => r.toSorted(I), [r]), [$, z] = j(""), [k, x] = j([]), L = E(() => {
576
+ let e = [];
577
+ return c === !1 && k ? e = [...k] : e = [...d], e = e.filter(
578
+ (n) => D.some((o) => o === n)
579
+ ), s && e.length > s && (e = e.slice(0, s - 1)), e.toSorted(I);
580
+ }, [c, D, d, k]), [V, T] = j(0);
581
+ W(() => {
582
+ V > 0 && h && k !== null && h([...L]);
583
+ }, [V]);
584
+ const U = E(() => $.length === 0 ? D : D.filter(
585
+ (e) => e.toUpperCase().includes($.toUpperCase())
586
+ ), [$, D]), g = C, K = C?.borderColor;
587
+ function I(e, n) {
588
+ return Y(e, n, u);
589
+ }
590
+ function F(e) {
591
+ const n = e.target.value;
592
+ z(n), i();
593
+ }
594
+ function q(e) {
595
+ c || x((n) => {
596
+ let o = n ? [...n] : [...L];
597
+ return o.some((f) => f === e) ? o = o.filter(
598
+ (f) => f !== e
599
+ ) : (s === null || s && o.length < s) && o.push(e), o;
600
+ });
601
+ }
602
+ function B(e) {
603
+ return L.some((n) => n === e);
604
+ }
605
+ function A(e) {
606
+ c || (x(
607
+ (n) => (n ? [...n] : [...L]).filter((f) => f !== e)
608
+ ), T((n) => n + 1));
609
+ }
610
+ function P() {
611
+ S ? N() : i();
612
+ }
613
+ function N() {
614
+ y(!1), T((e) => e + 1);
1498
615
  }
1499
616
  function i() {
1500
- D.length > 0 && C(!0);
617
+ U.length > 0 && y(!0);
1501
618
  }
1502
- const f = {
1503
- multiSelectionDropdownSearch: `multiSelectionDropdown-${x}`,
1504
- multiSelectionDropdown: `multiSelectionDropdown-${x}`,
1505
- selectedItems: `selectedItems-${x}`
619
+ const p = {
620
+ multiSelectionDropdownSearch: `multiSelectionDropdown-${b}`,
621
+ multiSelectionDropdown: `multiSelectionDropdown-${b}`,
622
+ selectedItems: `selectedItems-${b}`
1506
623
  };
1507
- return /* @__PURE__ */ Q(
624
+ return /* @__PURE__ */ v(
1508
625
  "div",
1509
626
  {
1510
627
  className: `dropdown-js dropdown-js-rounded
1511
- ${s && `dropdown-js-border ${s}`}`,
1512
- style: { ...p ? { pointerEvents: "none" } : {} },
628
+ ${K && `dropdown-js-border ${K}`}`,
629
+ style: { ...a ? { pointerEvents: "none" } : {} },
1513
630
  children: [
1514
- /* @__PURE__ */ Q("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: $, children: [
1515
- /* @__PURE__ */ L("div", { children: /* @__PURE__ */ L(
631
+ /* @__PURE__ */ v("div", { className: "dropdown-js-input-wrapper dropdown-js-rounded", style: g, children: [
632
+ /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(
1516
633
  "input",
1517
634
  {
1518
635
  className: "dropdown-js-input dropdown-js-rounded",
1519
- id: f.multiSelectionDropdownSearch,
636
+ id: p.multiSelectionDropdownSearch,
1520
637
  name: "multiselectionDropdownSearch",
1521
- style: $,
638
+ style: g,
1522
639
  type: "text",
1523
640
  autoComplete: "off",
1524
641
  role: "combobox",
1525
- "aria-label": n,
1526
- "aria-placeholder": `Type to search for ${n}`,
642
+ "aria-label": t,
643
+ "aria-placeholder": `Type to search for ${t}`,
1527
644
  "aria-autocomplete": "list",
1528
- "aria-controls": f.multiSelectionDropdown,
1529
- "aria-expanded": y,
645
+ "aria-controls": p.multiSelectionDropdown,
646
+ "aria-expanded": S,
1530
647
  "aria-haspopup": "listbox",
1531
- onChange: (c) => G(c),
1532
- placeholder: `Type to Search for ${n}`,
1533
- value: P
648
+ onChange: F,
649
+ placeholder: `Type to Search for ${t}`,
650
+ value: $
1534
651
  }
1535
652
  ) }),
1536
- /* @__PURE__ */ L(
653
+ /* @__PURE__ */ l(
1537
654
  "div",
1538
655
  {
1539
656
  className: "dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded",
1540
- "aria-expanded": y,
657
+ "aria-expanded": S,
1541
658
  "aria-controls": "multiSelectionDropdown",
1542
- "aria-label": `${n} options`,
1543
- onClick: (c) => u(),
1544
- children: /* @__PURE__ */ L("span", { className: "dropdown-js-arrow dropdown-js-padding", children: y ? "-" : "+" })
659
+ "aria-label": `${t} options`,
660
+ onClick: () => P(),
661
+ children: /* @__PURE__ */ l("span", { className: "dropdown-js-arrow dropdown-js-padding", children: S ? "-" : "+" })
1545
662
  }
1546
663
  )
1547
664
  ] }),
1548
- /* @__PURE__ */ L("div", { className: "dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container", children: /* @__PURE__ */ L(
665
+ /* @__PURE__ */ l("div", { className: "dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container", children: /* @__PURE__ */ l(
1549
666
  "div",
1550
667
  {
1551
- id: f.selectedItems,
668
+ id: p.selectedItems,
1552
669
  className: "dropdown-js-selected-items",
1553
- "aria-label": `Selected ${n} options`,
670
+ "aria-label": `Selected ${t} options`,
1554
671
  "aria-live": "polite",
1555
- children: U.map((c) => /* @__PURE__ */ Q(
672
+ children: L.map((e) => /* @__PURE__ */ v(
1556
673
  "span",
1557
674
  {
1558
675
  className: "dropdown-js-padding dropdown-js-rounded",
1559
- "aria-label": `${c}`,
1560
- style: { ...$, margin: "3.5px", marginRight: "0px" },
676
+ "aria-label": `${e}`,
677
+ style: { ...g, margin: "3.5px", marginRight: "0px" },
1561
678
  children: [
1562
- c,
679
+ e,
1563
680
  " ",
1564
- /* @__PURE__ */ L("span", { style: { cursor: "pointer" }, "aria-label": `Remove ${c}`, onClick: (v) => o(c), children: "×" })
681
+ /* @__PURE__ */ l("span", { style: { cursor: "pointer" }, "aria-label": `Remove ${e}`, onClick: () => A(e), children: "×" })
1565
682
  ]
1566
683
  },
1567
- `${c}`
684
+ `${e}`
1568
685
  ))
1569
686
  }
1570
687
  ) }),
1571
- /* @__PURE__ */ Q(
688
+ /* @__PURE__ */ v(
1572
689
  "div",
1573
690
  {
1574
- className: `dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!y && "dropdown-js-hide"}`,
1575
- style: $,
1576
- id: f.multiSelectionDropdown,
1577
- name: "multiSelectionDropdown",
691
+ className: `dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!S && "dropdown-js-hide"}`,
692
+ style: g,
693
+ id: p.multiSelectionDropdown,
1578
694
  role: "listbox",
1579
695
  "aria-multiselectable": !0,
1580
- "aria-expanded": y,
696
+ "aria-expanded": S,
1581
697
  children: [
1582
- D.map((c, v) => /* @__PURE__ */ Q("div", { children: [
1583
- /* @__PURE__ */ L(
698
+ U.map((e, n) => /* @__PURE__ */ v("div", { children: [
699
+ /* @__PURE__ */ l(
1584
700
  "input",
1585
701
  {
1586
702
  type: "checkbox",
1587
- name: `${c}Checkbox`,
703
+ name: `${e}Checkbox`,
1588
704
  role: "option",
1589
- "aria-label": c,
1590
- "aria-checked": t(c),
705
+ "aria-label": e,
706
+ "aria-checked": B(e),
1591
707
  style: { cursor: "pointer" },
1592
- checked: t(c),
1593
- onChange: (h) => Z(c),
1594
- value: c
708
+ checked: B(e),
709
+ onChange: () => q(e),
710
+ value: e
1595
711
  }
1596
712
  ),
1597
- /* @__PURE__ */ L("label", { style: { marginLeft: "5px" }, htmlFor: `${c}`, children: c }),
1598
- /* @__PURE__ */ L("hr", { style: { backgroundColor: $.color, border: "none", height: "0.5px" } })
1599
- ] }, `${v}#${c}`)),
1600
- /* @__PURE__ */ L(
713
+ /* @__PURE__ */ l("label", { style: { marginLeft: "5px" }, htmlFor: `${e}`, children: e }),
714
+ /* @__PURE__ */ l("hr", { style: { backgroundColor: g.color, border: "none", height: "0.5px" } })
715
+ ] }, `${n}#${e}`)),
716
+ /* @__PURE__ */ l(
1601
717
  "button",
1602
718
  {
1603
719
  className: "dropdown-js-padding dropdown-js-round",
1604
- style: g,
1605
- "aria-label": `Click to collapse ${n} options`,
720
+ style: m,
721
+ "aria-label": `Click to collapse ${t} options`,
1606
722
  title: "Done",
1607
- disabled: D.length === 0,
1608
- onClick: (c) => r(),
723
+ onClick: () => N(),
1609
724
  type: "button",
1610
725
  children: "Done"
1611
726
  }
@@ -1617,32 +732,9 @@ function Ve({
1617
732
  }
1618
733
  );
1619
734
  }
1620
- Ve.propTypes = {
1621
- label: l.string.isRequired,
1622
- data: l.array.isRequired,
1623
- sortOrder: l.string,
1624
- selectedData: l.array,
1625
- maxNumSelections: l.number,
1626
- isDisabled: l.bool,
1627
- onItemsSelected: l.func,
1628
- dropdownStyle: l.shape({
1629
- color: l.string.isRequired,
1630
- // text color
1631
- backgroundColor: l.string.isRequired,
1632
- fontSize: l.string,
1633
- borderColor: l.string
1634
- }),
1635
- buttonStyle: l.shape({
1636
- color: l.string.isRequired,
1637
- // text color
1638
- backgroundColor: l.string.isRequired,
1639
- fontSize: l.string,
1640
- borderColor: l.string
1641
- })
1642
- };
1643
735
  export {
1644
- Ye as Dropdown,
1645
- Ue as DropdownObj,
1646
- Ve as MultiSelectionDropdown,
1647
- Fe as MultiSelectionDropdownObj
736
+ R as Dropdown,
737
+ ee as DropdownObj,
738
+ re as MultiSelectionDropdown,
739
+ oe as MultiSelectionDropdownObj
1648
740
  };