prometeo-design-system 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/dist/RecurrentDatePicker.es.js +1 -1
- package/dist/{Select-mdLPyy7g.js → Select-DW30oGym.js} +122 -115
- package/dist/Select.es.js +1 -1
- package/dist/SelectSearch.es.js +137 -124
- package/dist/components/Autocomplete/useAutocomplete.d.ts +2 -0
- package/dist/prometeo-design-system.es.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as r } from "./jsx-runtime-DKDX3adD.js";
|
|
2
2
|
import O, { useMemo as D, memo as b, useRef as M, useCallback as g, useState as L, useEffect as W } from "react";
|
|
3
3
|
import { D as I } from "./DatePicker-D1EwMGIN.js";
|
|
4
|
-
import { S as f } from "./Select-
|
|
4
|
+
import { S as f } from "./Select-DW30oGym.js";
|
|
5
5
|
import { I as R } from "./Input-EkMrxcNX.js";
|
|
6
6
|
import _ from "./CheckBox.es.js";
|
|
7
7
|
import { c as p } from "./cn-B6yFEsav.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as a } from "./jsx-runtime-DKDX3adD.js";
|
|
2
2
|
import { c as f } from "./cn-B6yFEsav.js";
|
|
3
3
|
import Ne, { memo as Z, useState as je, useRef as ce, useMemo as oe, useCallback as U, useEffect as ve, useImperativeHandle as Qe } from "react";
|
|
4
4
|
import Xe from "./Spinner.es.js";
|
|
@@ -28,7 +28,7 @@ const at = {
|
|
|
28
28
|
}, Fe = {
|
|
29
29
|
icon: " text-neutral-default-disabled",
|
|
30
30
|
container: " border-neutral-strong-default text-neutral-default-disabled"
|
|
31
|
-
}, Ve = ({ id: e, label: n, onRemove: m, className: i, disabled: u, variant: y = "default", tabIndex: p }) => /* @__PURE__ */
|
|
31
|
+
}, Ve = ({ id: e, label: n, onRemove: m, className: i, disabled: u, variant: y = "default", tabIndex: p }) => /* @__PURE__ */ a.jsxs(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
34
|
tabIndex: p,
|
|
@@ -38,8 +38,8 @@ const at = {
|
|
|
38
38
|
u && Fe.container
|
|
39
39
|
),
|
|
40
40
|
children: [
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
m && /* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ a.jsx("span", { className: "truncate w-max ", children: n }),
|
|
42
|
+
m && /* @__PURE__ */ a.jsx(
|
|
43
43
|
"button",
|
|
44
44
|
{
|
|
45
45
|
onMouseDown: (D) => {
|
|
@@ -52,7 +52,7 @@ const at = {
|
|
|
52
52
|
),
|
|
53
53
|
type: "button",
|
|
54
54
|
tabIndex: p,
|
|
55
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ a.jsx(rt, { size: 18, className: f(u && Fe.icon) })
|
|
56
56
|
}
|
|
57
57
|
)
|
|
58
58
|
]
|
|
@@ -88,8 +88,8 @@ const qe = (e, n) => {
|
|
|
88
88
|
if (u.length > i.length) return !1;
|
|
89
89
|
const D = Math.floor(u.length * m);
|
|
90
90
|
if (D <= 0) return !1;
|
|
91
|
-
const g = (b,
|
|
92
|
-
const I = b.length, W =
|
|
91
|
+
const g = (b, E) => {
|
|
92
|
+
const I = b.length, W = E.length;
|
|
93
93
|
if (I === 0) return W;
|
|
94
94
|
if (W === 0) return I;
|
|
95
95
|
const A = new Array(W + 1);
|
|
@@ -98,15 +98,15 @@ const qe = (e, n) => {
|
|
|
98
98
|
let S = v - 1;
|
|
99
99
|
A[0] = v;
|
|
100
100
|
for (let z = 1; z <= W; z++) {
|
|
101
|
-
const se = A[z], K = b.charCodeAt(v - 1) ===
|
|
101
|
+
const se = A[z], K = b.charCodeAt(v - 1) === E.charCodeAt(z - 1) ? 0 : 1, V = A[z] + 1, M = A[z - 1] + 1, N = S + K;
|
|
102
102
|
A[z] = V < M ? V < N ? V : N : M < N ? M : N, S = se;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
return A[W];
|
|
106
106
|
};
|
|
107
107
|
for (let b = 0; b <= i.length - u.length; b++) {
|
|
108
|
-
const
|
|
109
|
-
if (g(
|
|
108
|
+
const E = i.slice(b, b + u.length);
|
|
109
|
+
if (g(E, u) <= D) return !0;
|
|
110
110
|
}
|
|
111
111
|
return !1;
|
|
112
112
|
}, ut = (e) => {
|
|
@@ -170,7 +170,7 @@ const qe = (e, n) => {
|
|
|
170
170
|
)
|
|
171
171
|
};
|
|
172
172
|
function ct(e) {
|
|
173
|
-
const [n, m] = je(!1), [i, u] = je([]), [y, p] = je(""), D = ce(null), g = ce(null), b = ce(null),
|
|
173
|
+
const [n, m] = je(!1), [i, u] = je([]), [y, p] = je(""), D = ce(null), g = ce(null), b = ce(null), E = ce(null), I = ce(
|
|
174
174
|
() => {
|
|
175
175
|
}
|
|
176
176
|
), W = ce(null), A = ce(/* @__PURE__ */ new Set()), {
|
|
@@ -182,7 +182,7 @@ function ct(e) {
|
|
|
182
182
|
controls: V,
|
|
183
183
|
className: M,
|
|
184
184
|
placeholder: N,
|
|
185
|
-
optionValue:
|
|
185
|
+
optionValue: k,
|
|
186
186
|
optionLabel: de,
|
|
187
187
|
renderOption: J,
|
|
188
188
|
renderOptionGroupHeader: fe,
|
|
@@ -194,7 +194,7 @@ function ct(e) {
|
|
|
194
194
|
dropdownOptions: O,
|
|
195
195
|
helperComponent: ee,
|
|
196
196
|
errorComponent: Ce,
|
|
197
|
-
onRemoveOption:
|
|
197
|
+
onRemoveOption: ke,
|
|
198
198
|
onOptionClick: X,
|
|
199
199
|
onClose: Se,
|
|
200
200
|
onClear: me,
|
|
@@ -206,7 +206,7 @@ function ct(e) {
|
|
|
206
206
|
displayMode: we = "compact",
|
|
207
207
|
labelVariant: ie = "default",
|
|
208
208
|
disableOpenOnFocus: ze = !1,
|
|
209
|
-
emptyMessage:
|
|
209
|
+
emptyMessage: Ee = "No hay opciones disponibles"
|
|
210
210
|
} = e, { ref: Oe } = et(), { bind: ne, ref: Me } = Ze({
|
|
211
211
|
axis: "x",
|
|
212
212
|
cursor: { idle: "default", dragging: "grabbing" }
|
|
@@ -223,35 +223,35 @@ function ct(e) {
|
|
|
223
223
|
active: "absolute top-0 -translate-y-1/2 left-3 px-1 prometeo-fonts-body-small",
|
|
224
224
|
default: "absolute top-1/2 -translate-y-1/2 "
|
|
225
225
|
}
|
|
226
|
-
},
|
|
227
|
-
return t[ie][
|
|
226
|
+
}, s = n || pe ? "active" : "default";
|
|
227
|
+
return t[ie][s];
|
|
228
228
|
}, T = U(
|
|
229
229
|
(t) => ({
|
|
230
|
-
id: G(t,
|
|
231
|
-
value: G(t,
|
|
230
|
+
id: G(t, k),
|
|
231
|
+
value: G(t, k),
|
|
232
232
|
label: G(t, de)
|
|
233
233
|
}),
|
|
234
|
-
[
|
|
234
|
+
[k, de]
|
|
235
235
|
), Y = oe(() => ut(K), [K]), ge = oe(
|
|
236
236
|
() => Y.map(T),
|
|
237
237
|
[Y, T]
|
|
238
238
|
), r = oe(() => {
|
|
239
239
|
const t = [];
|
|
240
240
|
if (e.multiple)
|
|
241
|
-
e.value?.forEach((
|
|
241
|
+
e.value?.forEach((s) => {
|
|
242
242
|
const l = Y?.find(
|
|
243
|
-
(h) => G(h,
|
|
243
|
+
(h) => G(h, k) === s
|
|
244
244
|
);
|
|
245
245
|
l && t.push(l);
|
|
246
246
|
});
|
|
247
247
|
else {
|
|
248
|
-
const
|
|
249
|
-
(l) => G(l,
|
|
248
|
+
const s = Y?.find(
|
|
249
|
+
(l) => G(l, k) === e.value
|
|
250
250
|
);
|
|
251
|
-
|
|
251
|
+
s && t.push(s);
|
|
252
252
|
}
|
|
253
253
|
return t;
|
|
254
|
-
}, [e.value,
|
|
254
|
+
}, [e.value, k, Y, e.multiple]), o = oe(
|
|
255
255
|
() => r.map(T),
|
|
256
256
|
[r, T]
|
|
257
257
|
), c = oe(
|
|
@@ -259,16 +259,16 @@ function ct(e) {
|
|
|
259
259
|
[o]
|
|
260
260
|
), d = oe(() => {
|
|
261
261
|
const t = [];
|
|
262
|
-
return K.forEach((
|
|
263
|
-
const h =
|
|
262
|
+
return K.forEach((s, l) => {
|
|
263
|
+
const h = s, H = typeof h == "object" ? h?.options : [];
|
|
264
264
|
if (Array.isArray(H) && H.length > 0) {
|
|
265
|
-
const $ = h.label, P = G(
|
|
265
|
+
const $ = h.label, P = G(s, k), le = `__group-${String(P ?? l)}`, xe = {
|
|
266
266
|
id: le,
|
|
267
267
|
value: le,
|
|
268
268
|
label: typeof $ == "string" ? $ : String(P ?? `Grupo ${l + 1}`),
|
|
269
269
|
isGroupHeader: !0,
|
|
270
270
|
groupLabelNode: $,
|
|
271
|
-
originalOption:
|
|
271
|
+
originalOption: s,
|
|
272
272
|
groupData: {
|
|
273
273
|
groupOptions: H
|
|
274
274
|
}
|
|
@@ -277,10 +277,10 @@ function ct(e) {
|
|
|
277
277
|
J ? t.push(ye) : t.push(T(ye));
|
|
278
278
|
});
|
|
279
279
|
} else
|
|
280
|
-
J ? t.push(
|
|
280
|
+
J ? t.push(s) : t.push(T(s));
|
|
281
281
|
}), t;
|
|
282
|
-
}, [K,
|
|
283
|
-
(t,
|
|
282
|
+
}, [K, k, J, T]), w = U(
|
|
283
|
+
(t, s) => {
|
|
284
284
|
if (!t || t.length === 0) return;
|
|
285
285
|
const l = t.map(
|
|
286
286
|
(C) => T(C)
|
|
@@ -288,7 +288,7 @@ function ct(e) {
|
|
|
288
288
|
if (!e.multiple) {
|
|
289
289
|
const C = l[0];
|
|
290
290
|
if (!C) return;
|
|
291
|
-
const j = c.has(C.id), B =
|
|
291
|
+
const j = c.has(C.id), B = s ?? "toggle";
|
|
292
292
|
let Pe;
|
|
293
293
|
B === "select" || B === "toggle" && !j ? Pe = C : Pe = void 0, e.onChange?.(Pe, S);
|
|
294
294
|
return;
|
|
@@ -300,7 +300,7 @@ function ct(e) {
|
|
|
300
300
|
});
|
|
301
301
|
const $ = new Set(H.map((C) => C.id)), P = new Set(l.map((C) => C.id)), le = l.every(
|
|
302
302
|
(C) => $.has(C.id)
|
|
303
|
-
), xe =
|
|
303
|
+
), xe = s ?? "toggle", ye = xe === "select" || xe === "toggle" && !le;
|
|
304
304
|
let _;
|
|
305
305
|
if (!ye)
|
|
306
306
|
_ = H.filter((C) => !P.has(C.id));
|
|
@@ -330,8 +330,8 @@ function ct(e) {
|
|
|
330
330
|
if (!e.multiple)
|
|
331
331
|
e.onChange?.(t, S);
|
|
332
332
|
else {
|
|
333
|
-
const
|
|
334
|
-
|
|
333
|
+
const s = e.value || [], l = [], h = s.includes(t.value);
|
|
334
|
+
s.forEach(($) => {
|
|
335
335
|
const P = ge.find(
|
|
336
336
|
(le) => le.value === $
|
|
337
337
|
);
|
|
@@ -342,31 +342,37 @@ function ct(e) {
|
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
344
|
const x = U(
|
|
345
|
-
(t,
|
|
346
|
-
X?.(t, S), I.current?.(t),
|
|
345
|
+
(t, s = !1) => {
|
|
346
|
+
X?.(t, S), I.current?.(t), s && (m(!1), Se?.());
|
|
347
347
|
},
|
|
348
348
|
[X, Se, S]
|
|
349
349
|
), R = (t) => {
|
|
350
|
-
t.preventDefault(), t.stopPropagation(), t.target.blur(), me?.(), e.multiple
|
|
350
|
+
if (t.preventDefault(), t.stopPropagation(), t.target.blur(), me?.(), e.multiple) {
|
|
351
|
+
const s = e.onChange;
|
|
352
|
+
s?.([], S);
|
|
353
|
+
} else {
|
|
354
|
+
const s = e.onChange;
|
|
355
|
+
s?.(void 0, S);
|
|
356
|
+
}
|
|
351
357
|
}, q = U(
|
|
352
358
|
(t) => {
|
|
353
359
|
e.multiple || e.onChange?.(void 0, S);
|
|
354
|
-
const
|
|
355
|
-
(h) => G(h,
|
|
360
|
+
const s = Y.find(
|
|
361
|
+
(h) => G(h, k) === t
|
|
356
362
|
);
|
|
357
|
-
if (!
|
|
358
|
-
const l = T(
|
|
359
|
-
X?.(l, S), I.current?.(l),
|
|
363
|
+
if (!s) return;
|
|
364
|
+
const l = T(s);
|
|
365
|
+
X?.(l, S), I.current?.(l), ke?.(s);
|
|
360
366
|
},
|
|
361
367
|
[
|
|
362
368
|
X,
|
|
363
|
-
|
|
369
|
+
ke,
|
|
364
370
|
Y,
|
|
365
371
|
S,
|
|
366
372
|
e.multiple,
|
|
367
373
|
e.onChange,
|
|
368
374
|
T,
|
|
369
|
-
|
|
375
|
+
k
|
|
370
376
|
]
|
|
371
377
|
), re = U(
|
|
372
378
|
(t) => {
|
|
@@ -376,17 +382,17 @@ function ct(e) {
|
|
|
376
382
|
);
|
|
377
383
|
ve(() => {
|
|
378
384
|
if (!n) return;
|
|
379
|
-
const t = (
|
|
380
|
-
const l =
|
|
381
|
-
if (
|
|
385
|
+
const t = (s) => {
|
|
386
|
+
const l = s.target;
|
|
387
|
+
if (s.type === "mousedown") {
|
|
382
388
|
if (D.current?.contains(l) || g.current?.contains(l)) return;
|
|
383
389
|
m(!1);
|
|
384
390
|
}
|
|
385
|
-
if (
|
|
391
|
+
if (s.type === "scroll") {
|
|
386
392
|
if (g.current?.contains(l)) return;
|
|
387
393
|
m(!1);
|
|
388
394
|
}
|
|
389
|
-
|
|
395
|
+
s.type === "resize" && m(!1);
|
|
390
396
|
};
|
|
391
397
|
return document.addEventListener("mousedown", t), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t, !0), () => {
|
|
392
398
|
document.removeEventListener("mousedown", t), window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t, !0);
|
|
@@ -425,7 +431,7 @@ function ct(e) {
|
|
|
425
431
|
b.current?.focus();
|
|
426
432
|
}, 10));
|
|
427
433
|
};
|
|
428
|
-
return /* @__PURE__ */
|
|
434
|
+
return /* @__PURE__ */ a.jsxs(
|
|
429
435
|
"div",
|
|
430
436
|
{
|
|
431
437
|
className: f("relative bg-inherit select-none w-full", M),
|
|
@@ -433,8 +439,8 @@ function ct(e) {
|
|
|
433
439
|
draggable: !1,
|
|
434
440
|
style: Le,
|
|
435
441
|
children: [
|
|
436
|
-
/* @__PURE__ */
|
|
437
|
-
/* @__PURE__ */
|
|
442
|
+
/* @__PURE__ */ a.jsxs("div", { className: f("relative bg-inherit ", Q), children: [
|
|
443
|
+
/* @__PURE__ */ a.jsx(
|
|
438
444
|
"label",
|
|
439
445
|
{
|
|
440
446
|
htmlFor: v,
|
|
@@ -449,13 +455,13 @@ function ct(e) {
|
|
|
449
455
|
children: z
|
|
450
456
|
}
|
|
451
457
|
),
|
|
452
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ a.jsxs(
|
|
453
459
|
"div",
|
|
454
460
|
{
|
|
455
461
|
id: v,
|
|
456
462
|
tabIndex: 0,
|
|
457
463
|
role: "button",
|
|
458
|
-
ref:
|
|
464
|
+
ref: E,
|
|
459
465
|
onFocus: be,
|
|
460
466
|
onKeyDown: ue,
|
|
461
467
|
onClick: (t) => {
|
|
@@ -471,7 +477,7 @@ function ct(e) {
|
|
|
471
477
|
He
|
|
472
478
|
),
|
|
473
479
|
children: [
|
|
474
|
-
/* @__PURE__ */
|
|
480
|
+
/* @__PURE__ */ a.jsx(
|
|
475
481
|
"div",
|
|
476
482
|
{
|
|
477
483
|
className: f(
|
|
@@ -487,7 +493,7 @@ function ct(e) {
|
|
|
487
493
|
children: De ? Ne.createElement(
|
|
488
494
|
Z(
|
|
489
495
|
De,
|
|
490
|
-
(t,
|
|
496
|
+
(t, s) => t.disabled === s.disabled && t.multiple === s.multiple
|
|
491
497
|
),
|
|
492
498
|
{
|
|
493
499
|
disabled: te,
|
|
@@ -496,7 +502,7 @@ function ct(e) {
|
|
|
496
502
|
selectedOptions: r,
|
|
497
503
|
onRemoveOption: re
|
|
498
504
|
}
|
|
499
|
-
) : /* @__PURE__ */
|
|
505
|
+
) : /* @__PURE__ */ a.jsx(
|
|
500
506
|
Je,
|
|
501
507
|
{
|
|
502
508
|
displayMode: we,
|
|
@@ -512,8 +518,8 @@ function ct(e) {
|
|
|
512
518
|
)
|
|
513
519
|
}
|
|
514
520
|
),
|
|
515
|
-
/* @__PURE__ */
|
|
516
|
-
he && /* @__PURE__ */
|
|
521
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
522
|
+
he && /* @__PURE__ */ a.jsx(
|
|
517
523
|
Xe,
|
|
518
524
|
{
|
|
519
525
|
size: "small",
|
|
@@ -521,15 +527,16 @@ function ct(e) {
|
|
|
521
527
|
className: " opacity-90"
|
|
522
528
|
}
|
|
523
529
|
),
|
|
524
|
-
pe && me && /* @__PURE__ */
|
|
530
|
+
pe && me && /* @__PURE__ */ a.jsx(
|
|
525
531
|
"button",
|
|
526
532
|
{
|
|
527
|
-
|
|
533
|
+
className: "z-100",
|
|
534
|
+
onClick: (t) => {
|
|
528
535
|
t.preventDefault(), t.stopPropagation(), R(t);
|
|
529
536
|
},
|
|
530
537
|
type: "button",
|
|
531
538
|
tabIndex: -1,
|
|
532
|
-
children: /* @__PURE__ */
|
|
539
|
+
children: /* @__PURE__ */ a.jsx(
|
|
533
540
|
ot,
|
|
534
541
|
{
|
|
535
542
|
size: 20,
|
|
@@ -541,7 +548,7 @@ function ct(e) {
|
|
|
541
548
|
)
|
|
542
549
|
}
|
|
543
550
|
),
|
|
544
|
-
/* @__PURE__ */
|
|
551
|
+
/* @__PURE__ */ a.jsx(
|
|
545
552
|
Ue,
|
|
546
553
|
{
|
|
547
554
|
size: 20,
|
|
@@ -557,15 +564,15 @@ function ct(e) {
|
|
|
557
564
|
}
|
|
558
565
|
)
|
|
559
566
|
] }),
|
|
560
|
-
n && /* @__PURE__ */
|
|
567
|
+
n && /* @__PURE__ */ a.jsx(
|
|
561
568
|
mt,
|
|
562
569
|
{
|
|
563
570
|
label: z,
|
|
564
571
|
isOpen: n,
|
|
565
572
|
disabled: te,
|
|
566
|
-
optionValue:
|
|
573
|
+
optionValue: k,
|
|
567
574
|
optionLabel: de,
|
|
568
|
-
emptyMessage:
|
|
575
|
+
emptyMessage: Ee,
|
|
569
576
|
labelVariant: ie,
|
|
570
577
|
renderOption: J,
|
|
571
578
|
renderOptionGroupHeader: fe,
|
|
@@ -579,7 +586,7 @@ function ct(e) {
|
|
|
579
586
|
options: d,
|
|
580
587
|
selectRef: D,
|
|
581
588
|
dropdownRef: g,
|
|
582
|
-
selectButtonRef:
|
|
589
|
+
selectButtonRef: E,
|
|
583
590
|
helperComponentRef: W,
|
|
584
591
|
onOptionClick: x,
|
|
585
592
|
onCloseDropdown: () => m(!1),
|
|
@@ -599,7 +606,7 @@ function ct(e) {
|
|
|
599
606
|
onGroupSelectChange: w
|
|
600
607
|
}
|
|
601
608
|
),
|
|
602
|
-
(Ce || ee) && /* @__PURE__ */
|
|
609
|
+
(Ce || ee) && /* @__PURE__ */ a.jsx("div", { className: "min-h-6", children: /* @__PURE__ */ a.jsx(
|
|
603
610
|
nt,
|
|
604
611
|
{
|
|
605
612
|
ref: W,
|
|
@@ -612,7 +619,7 @@ function ct(e) {
|
|
|
612
619
|
}
|
|
613
620
|
);
|
|
614
621
|
}
|
|
615
|
-
const dt = Z(ct, (e, n) => e.value === n.value && e.options === n.options && e.isLoading === n.isLoading && e.disabled === n.disabled && e.errorComponent === n.errorComponent && e.helperComponent === n.helperComponent && e.variant === n.variant && e.label === n.label && e.id === n.id && e.name === n.name && e.placeholder === n.placeholder && e.renderOptionContext === n.renderOptionContext && e.dropdownOptions?.controledSearchValue === n.dropdownOptions?.controledSearchValue && e.dropdownOptions?.isLoading === n.dropdownOptions?.isLoading),
|
|
622
|
+
const dt = Z(ct, (e, n) => e.value === n.value && e.options === n.options && e.isLoading === n.isLoading && e.disabled === n.disabled && e.errorComponent === n.errorComponent && e.helperComponent === n.helperComponent && e.variant === n.variant && e.label === n.label && e.id === n.id && e.name === n.name && e.placeholder === n.placeholder && e.renderOptionContext === n.renderOptionContext && e.dropdownOptions?.controledSearchValue === n.dropdownOptions?.controledSearchValue && e.dropdownOptions?.isLoading === n.dropdownOptions?.isLoading), kt = dt;
|
|
616
623
|
function ft({
|
|
617
624
|
footer: e,
|
|
618
625
|
isOpen: n,
|
|
@@ -624,7 +631,7 @@ function ft({
|
|
|
624
631
|
inputProps: D,
|
|
625
632
|
dropdownRef: g,
|
|
626
633
|
optionLabel: b,
|
|
627
|
-
optionValue:
|
|
634
|
+
optionValue: E,
|
|
628
635
|
searchValue: I,
|
|
629
636
|
labelVariant: W,
|
|
630
637
|
emptyMessage: A,
|
|
@@ -636,7 +643,7 @@ function ft({
|
|
|
636
643
|
searchInputRef: V,
|
|
637
644
|
setSearchValue: M,
|
|
638
645
|
dropdownHeight: N,
|
|
639
|
-
attachToParent:
|
|
646
|
+
attachToParent: k,
|
|
640
647
|
filteredOptions: de,
|
|
641
648
|
selectButtonRef: J,
|
|
642
649
|
onCloseDropdown: fe,
|
|
@@ -648,7 +655,7 @@ function ft({
|
|
|
648
655
|
onSearchValueChange: O,
|
|
649
656
|
isLoading: ee = !1,
|
|
650
657
|
hideSearchBar: Ce = !1,
|
|
651
|
-
inputSearchPlaceholder:
|
|
658
|
+
inputSearchPlaceholder: ke = "Buscar opciones",
|
|
652
659
|
enableGroupToggle: X = !0,
|
|
653
660
|
onGroupSelectChange: Se
|
|
654
661
|
}) {
|
|
@@ -660,7 +667,7 @@ function ft({
|
|
|
660
667
|
), ze = U(
|
|
661
668
|
(r) => !we.has(r),
|
|
662
669
|
[we]
|
|
663
|
-
),
|
|
670
|
+
), Ee = U(
|
|
664
671
|
(r, o) => {
|
|
665
672
|
ie((c) => {
|
|
666
673
|
const d = new Set(c), w = d.has(r);
|
|
@@ -693,7 +700,7 @@ function ft({
|
|
|
693
700
|
g.current.style.maxHeight = "0", g.current.style.opacity = "0", g.current.style.pointerEvents = "none";
|
|
694
701
|
return;
|
|
695
702
|
}
|
|
696
|
-
if (!
|
|
703
|
+
if (!k) {
|
|
697
704
|
const o = Me();
|
|
698
705
|
Ae(o), Oe(o.direction), ne(o.height);
|
|
699
706
|
}
|
|
@@ -701,7 +708,7 @@ function ft({
|
|
|
701
708
|
}
|
|
702
709
|
};
|
|
703
710
|
ve(() => {
|
|
704
|
-
|
|
711
|
+
k || !p.current || !n || Oe();
|
|
705
712
|
}, [ae]), ve(() => {
|
|
706
713
|
pe(n);
|
|
707
714
|
}, [n]), ve(() => {
|
|
@@ -725,11 +732,11 @@ function ft({
|
|
|
725
732
|
re(), R = ue;
|
|
726
733
|
return;
|
|
727
734
|
}
|
|
728
|
-
const
|
|
729
|
-
|
|
735
|
+
const s = be, l = G(
|
|
736
|
+
s,
|
|
730
737
|
b
|
|
731
738
|
), h = qe(String(l ?? ""), o);
|
|
732
|
-
R ? h && q.push(
|
|
739
|
+
R ? h && q.push(s) : h && x.push(s);
|
|
733
740
|
}), re(), x;
|
|
734
741
|
}
|
|
735
742
|
const c = [];
|
|
@@ -761,7 +768,7 @@ function ft({
|
|
|
761
768
|
if (K) {
|
|
762
769
|
K(), Q(
|
|
763
770
|
i.filter((r) => {
|
|
764
|
-
const o = v ? G(r,
|
|
771
|
+
const o = v ? G(r, E) : r.id;
|
|
765
772
|
return ae.has(o);
|
|
766
773
|
})
|
|
767
774
|
);
|
|
@@ -771,7 +778,7 @@ function ft({
|
|
|
771
778
|
}, [
|
|
772
779
|
i,
|
|
773
780
|
ae,
|
|
774
|
-
|
|
781
|
+
E,
|
|
775
782
|
K,
|
|
776
783
|
Q,
|
|
777
784
|
M,
|
|
@@ -821,7 +828,7 @@ function ft({
|
|
|
821
828
|
isLoading: !0,
|
|
822
829
|
renderContext: S
|
|
823
830
|
}
|
|
824
|
-
) : /* @__PURE__ */
|
|
831
|
+
) : /* @__PURE__ */ a.jsx(
|
|
825
832
|
Be,
|
|
826
833
|
{
|
|
827
834
|
multiple: !1,
|
|
@@ -834,7 +841,7 @@ function ft({
|
|
|
834
841
|
`skeleton-option-${// biome-ignore lint/suspicious/noArrayIndexKey: <>
|
|
835
842
|
o}`
|
|
836
843
|
)
|
|
837
|
-
), ge = /* @__PURE__ */
|
|
844
|
+
), ge = /* @__PURE__ */ a.jsx(
|
|
838
845
|
"div",
|
|
839
846
|
{
|
|
840
847
|
tabIndex: 0,
|
|
@@ -843,11 +850,11 @@ function ft({
|
|
|
843
850
|
className: f(
|
|
844
851
|
" z-100! w-full mt-1 bg-neutral-default-default border border-neutral-default-default rounded-lg shadow-lg",
|
|
845
852
|
" overflow-hidden focus-visible:bg-neutral-default-hover ",
|
|
846
|
-
|
|
853
|
+
k ? "absolute z-50 " : "fixed z-100 top-0 left-0",
|
|
847
854
|
he.direction === "up" ? "h-auto" : " h-max",
|
|
848
855
|
Ie
|
|
849
856
|
),
|
|
850
|
-
children: /* @__PURE__ */
|
|
857
|
+
children: /* @__PURE__ */ a.jsxs(
|
|
851
858
|
"div",
|
|
852
859
|
{
|
|
853
860
|
className: f(
|
|
@@ -859,7 +866,7 @@ function ft({
|
|
|
859
866
|
maxHeight: he.height
|
|
860
867
|
},
|
|
861
868
|
children: [
|
|
862
|
-
!Ce && /* @__PURE__ */
|
|
869
|
+
!Ce && /* @__PURE__ */ a.jsx(
|
|
863
870
|
tt,
|
|
864
871
|
{
|
|
865
872
|
name: "",
|
|
@@ -870,23 +877,23 @@ function ft({
|
|
|
870
877
|
disabled: y,
|
|
871
878
|
ref: V,
|
|
872
879
|
labelVariant: "static",
|
|
873
|
-
icon: /* @__PURE__ */
|
|
880
|
+
icon: /* @__PURE__ */ a.jsx(st, { size: 22 }),
|
|
874
881
|
isFetching: ee,
|
|
875
882
|
onKeyDown: $e,
|
|
876
883
|
onClear: Ge,
|
|
877
884
|
onChange: (r) => Te(r.target.value),
|
|
878
|
-
placeholder:
|
|
885
|
+
placeholder: ke,
|
|
879
886
|
className: " bg-neutral-medium-pressed",
|
|
880
887
|
...D
|
|
881
888
|
}
|
|
882
889
|
),
|
|
883
|
-
/* @__PURE__ */
|
|
890
|
+
/* @__PURE__ */ a.jsx("div", { className: " overflow-y-auto flex-1 max-h-max ", children: de.length === 0 ? ee ? /* @__PURE__ */ a.jsx("div", { className: "flex flex-col gap-1 overflow-hidden w-full", children: De || Y }) : /* @__PURE__ */ a.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: I ? `No se encontraron resultados para "${I}"` : A }) : (() => {
|
|
884
891
|
let r = !0;
|
|
885
892
|
return de.map((o) => {
|
|
886
|
-
const c = o, d = !!(c || {}).isGroupHeader, w = v && !d ? G(o,
|
|
893
|
+
const c = o, d = !!(c || {}).isGroupHeader, w = v && !d ? G(o, E) : c.id, L = ae.has(w), x = (l) => !v || d ? l : {
|
|
887
894
|
id: w,
|
|
888
895
|
label: String(G(l, b)),
|
|
889
|
-
value: G(l,
|
|
896
|
+
value: G(l, E)
|
|
890
897
|
}, R = (l) => {
|
|
891
898
|
d || se(
|
|
892
899
|
x(o),
|
|
@@ -901,7 +908,7 @@ function ft({
|
|
|
901
908
|
const H = !!(h || {}).isGroupHeader;
|
|
902
909
|
return (
|
|
903
910
|
// biome-ignore lint/a11y/useSemanticElements: <>
|
|
904
|
-
/* @__PURE__ */
|
|
911
|
+
/* @__PURE__ */ a.jsx(
|
|
905
912
|
"div",
|
|
906
913
|
{
|
|
907
914
|
tabIndex: 0,
|
|
@@ -922,12 +929,12 @@ function ft({
|
|
|
922
929
|
const l = c.groupLabelNode ?? c.label, h = String(c.id), H = X === !1 ? !0 : ze(h);
|
|
923
930
|
r = H;
|
|
924
931
|
const $ = c.originalOption, P = c.groupData?.groupOptions ?? [], le = (_) => {
|
|
925
|
-
X &&
|
|
932
|
+
X && Ee(h, _);
|
|
926
933
|
}, xe = (_) => {
|
|
927
934
|
!P || P.length === 0 || Se && Se(P, _);
|
|
928
935
|
}, ye = P.filter(
|
|
929
|
-
(_) => ae.has(G(_,
|
|
930
|
-
).map((_) => String(G(_,
|
|
936
|
+
(_) => ae.has(G(_, E))
|
|
937
|
+
).map((_) => String(G(_, E)));
|
|
931
938
|
if (z) {
|
|
932
939
|
const _ = Z(
|
|
933
940
|
z,
|
|
@@ -947,14 +954,14 @@ function ft({
|
|
|
947
954
|
return re(C, c);
|
|
948
955
|
}
|
|
949
956
|
return re(
|
|
950
|
-
/* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
952
|
-
X && /* @__PURE__ */
|
|
957
|
+
/* @__PURE__ */ a.jsxs("div", { className: "px-3 py-2 text-neutral-medium-default font-medium text-sm w-full flex justify-between", children: [
|
|
958
|
+
/* @__PURE__ */ a.jsx("div", { children: l }),
|
|
959
|
+
X && /* @__PURE__ */ a.jsx(
|
|
953
960
|
"div",
|
|
954
961
|
{
|
|
955
962
|
className: "cursor-pointer",
|
|
956
|
-
onClick: () =>
|
|
957
|
-
children: /* @__PURE__ */
|
|
963
|
+
onClick: () => Ee(h),
|
|
964
|
+
children: /* @__PURE__ */ a.jsx(
|
|
958
965
|
Ue,
|
|
959
966
|
{
|
|
960
967
|
className: f(
|
|
@@ -984,7 +991,7 @@ function ft({
|
|
|
984
991
|
isLoading: ee,
|
|
985
992
|
renderContext: S
|
|
986
993
|
}
|
|
987
|
-
) : /* @__PURE__ */
|
|
994
|
+
) : /* @__PURE__ */ a.jsx(
|
|
988
995
|
Be,
|
|
989
996
|
{
|
|
990
997
|
disabled: y,
|
|
@@ -1001,10 +1008,10 @@ function ft({
|
|
|
1001
1008
|
);
|
|
1002
1009
|
if (!X)
|
|
1003
1010
|
return ue;
|
|
1004
|
-
const t = !r,
|
|
1005
|
-
return Ne.cloneElement(
|
|
1011
|
+
const t = !r, s = ue;
|
|
1012
|
+
return Ne.cloneElement(s, {
|
|
1006
1013
|
className: f(
|
|
1007
|
-
|
|
1014
|
+
s.props.className,
|
|
1008
1015
|
"overflow-hidden transition-[max-height] duration-300 ease-out",
|
|
1009
1016
|
t ? "max-h-0" : "max-h-[999px]"
|
|
1010
1017
|
)
|
|
@@ -1017,7 +1024,7 @@ function ft({
|
|
|
1017
1024
|
)
|
|
1018
1025
|
}
|
|
1019
1026
|
);
|
|
1020
|
-
return
|
|
1027
|
+
return k ? ge : Ye(ge, document.body);
|
|
1021
1028
|
}
|
|
1022
1029
|
const mt = Z(
|
|
1023
1030
|
ft,
|
|
@@ -1033,13 +1040,13 @@ const mt = Z(
|
|
|
1033
1040
|
}) => {
|
|
1034
1041
|
const p = (e || {})?.isGroupHeader;
|
|
1035
1042
|
if (y)
|
|
1036
|
-
return /* @__PURE__ */
|
|
1043
|
+
return /* @__PURE__ */ a.jsxs(
|
|
1037
1044
|
"div",
|
|
1038
1045
|
{
|
|
1039
1046
|
className: "flex gap-2 w-full px-3 py-2 cursor-wait",
|
|
1040
1047
|
children: [
|
|
1041
|
-
/* @__PURE__ */
|
|
1042
|
-
/* @__PURE__ */
|
|
1048
|
+
/* @__PURE__ */ a.jsx(Ke, { className: "size-6 aspect-square" }),
|
|
1049
|
+
/* @__PURE__ */ a.jsx(Ke, { className: "flex-1 h-6" })
|
|
1043
1050
|
]
|
|
1044
1051
|
},
|
|
1045
1052
|
e.id
|
|
@@ -1049,7 +1056,7 @@ const mt = Z(
|
|
|
1049
1056
|
}, g = p && e.groupLabelNode ? e.groupLabelNode : e.label;
|
|
1050
1057
|
return (
|
|
1051
1058
|
// biome-ignore lint/a11y/noStaticElementInteractions: no keyboard interaction needed
|
|
1052
|
-
/* @__PURE__ */
|
|
1059
|
+
/* @__PURE__ */ a.jsxs(
|
|
1053
1060
|
"div",
|
|
1054
1061
|
{
|
|
1055
1062
|
onMouseDown: D,
|
|
@@ -1060,8 +1067,8 @@ const mt = Z(
|
|
|
1060
1067
|
u && !p && "text-neutral-default-disabled hover:bg-neutral-default-default"
|
|
1061
1068
|
),
|
|
1062
1069
|
children: [
|
|
1063
|
-
i && !p && /* @__PURE__ */
|
|
1064
|
-
/* @__PURE__ */
|
|
1070
|
+
i && !p && /* @__PURE__ */ a.jsx(lt, { checked: n, disabled: u }),
|
|
1071
|
+
/* @__PURE__ */ a.jsx("span", { children: g })
|
|
1065
1072
|
]
|
|
1066
1073
|
},
|
|
1067
1074
|
e.id
|
|
@@ -1080,7 +1087,7 @@ const Je = Z(
|
|
|
1080
1087
|
multiple: u,
|
|
1081
1088
|
className: y,
|
|
1082
1089
|
disabled: p
|
|
1083
|
-
}) => e?.length === 0 ? n ? /* @__PURE__ */
|
|
1090
|
+
}) => e?.length === 0 ? n ? /* @__PURE__ */ a.jsx("span", { className: "text-neutral-medium-default opacity-50", children: n }) : null : i === "chips" && u ? /* @__PURE__ */ a.jsx("div", { className: f("flex items-center gap-1 ", y), children: e.map((D) => /* @__PURE__ */ a.jsx(
|
|
1084
1091
|
it,
|
|
1085
1092
|
{
|
|
1086
1093
|
tabIndex: -1,
|
|
@@ -1090,7 +1097,7 @@ const Je = Z(
|
|
|
1090
1097
|
disabled: p
|
|
1091
1098
|
},
|
|
1092
1099
|
D.id
|
|
1093
|
-
)) }) : e?.length === 1 ? /* @__PURE__ */
|
|
1100
|
+
)) }) : e?.length === 1 ? /* @__PURE__ */ a.jsx("span", { children: e[0].label }) : /* @__PURE__ */ a.jsxs("span", { children: [
|
|
1094
1101
|
e?.length,
|
|
1095
1102
|
" seleccionados"
|
|
1096
1103
|
] }),
|
|
@@ -1098,6 +1105,6 @@ const Je = Z(
|
|
|
1098
1105
|
);
|
|
1099
1106
|
Je.displayName = "DefaultSelectionDisplay";
|
|
1100
1107
|
export {
|
|
1101
|
-
|
|
1108
|
+
kt as S,
|
|
1102
1109
|
G as g
|
|
1103
1110
|
};
|
package/dist/Select.es.js
CHANGED
package/dist/SelectSearch.es.js
CHANGED
|
@@ -1,97 +1,98 @@
|
|
|
1
1
|
import { j as X } from "./jsx-runtime-DKDX3adD.js";
|
|
2
|
-
import { g as i, S as Y } from "./Select-
|
|
3
|
-
import { useState as
|
|
4
|
-
function
|
|
2
|
+
import { g as i, S as Y } from "./Select-DW30oGym.js";
|
|
3
|
+
import { useState as x, useRef as A, useEffect as b, useMemo as Z, useCallback as ee } from "react";
|
|
4
|
+
function le(e) {
|
|
5
5
|
const {
|
|
6
|
-
options:
|
|
7
|
-
fetcher:
|
|
8
|
-
asyncMode:
|
|
9
|
-
disabled:
|
|
10
|
-
debounceDelay:
|
|
11
|
-
minCharacters:
|
|
12
|
-
optionLabel:
|
|
6
|
+
options: O,
|
|
7
|
+
fetcher: u,
|
|
8
|
+
asyncMode: S = "fetch_in_open",
|
|
9
|
+
disabled: _ = !1,
|
|
10
|
+
debounceDelay: E = 500,
|
|
11
|
+
minCharacters: w = 3,
|
|
12
|
+
optionLabel: h,
|
|
13
13
|
optionValue: s,
|
|
14
|
-
controlledValue:
|
|
14
|
+
controlledValue: d,
|
|
15
15
|
isOpen: F,
|
|
16
|
-
inputRef:
|
|
17
|
-
name:
|
|
18
|
-
} = e || {},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
if (
|
|
23
|
-
const t =
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
inputRef: P,
|
|
17
|
+
name: T
|
|
18
|
+
} = e || {}, M = O ? O.filter((t) => t != null) : [], [p, y] = x(M || []), [D, I] = x(M || []), [c, N] = x(""), [W, C] = x(!1), [J, U] = x(!1), l = A(null), g = A(null), m = A(!1), V = A(u), L = e?.multiple === !0 || !1, k = A(L ? [] : void 0), [f, v] = x(L ? [] : void 0);
|
|
19
|
+
b(() => {
|
|
20
|
+
V.current = u;
|
|
21
|
+
}, [u]), b(() => {
|
|
22
|
+
if (L) {
|
|
23
|
+
const t = z(d, "value");
|
|
24
|
+
v(t);
|
|
25
|
+
} else
|
|
26
|
+
d != null ? v(d) : v(void 0);
|
|
27
|
+
}, [d]), b(() => {
|
|
28
|
+
k.current = d !== void 0 ? d : f;
|
|
29
|
+
}, [d, f]), b(() => {
|
|
29
30
|
if (e?.options) {
|
|
30
31
|
const t = e.options.filter((n) => n != null);
|
|
31
|
-
|
|
32
|
+
y(t), I(t);
|
|
32
33
|
}
|
|
33
34
|
}, [e?.options]);
|
|
34
35
|
const B = Z(() => (t, n) => new Promise((o, r) => {
|
|
35
|
-
|
|
36
|
+
l.current && clearTimeout(l.current), l.current = setTimeout(() => t(c).then(o).catch(r), n);
|
|
36
37
|
}), [c]), te = (t) => {
|
|
37
|
-
const n =
|
|
38
|
+
const n = d !== void 0, o = (r) => s ? i(r, s) : i(r, "id");
|
|
38
39
|
if (e?.multiple === !0) {
|
|
39
|
-
const r =
|
|
40
|
-
let
|
|
41
|
-
r.some((
|
|
40
|
+
const r = k.current || [];
|
|
41
|
+
let a;
|
|
42
|
+
r.some((R) => o(R) === o(t)) ? a = r.filter((R) => o(R) !== o(t)) : a = [...r, t], n ? (k.current = a, e?.onChange?.(a, T)) : (k.current = a, v(a), e?.onChange?.(a, T));
|
|
42
43
|
} else
|
|
43
|
-
n ? (
|
|
44
|
-
}, q = (t) => (e?.onFetchingStart?.(),
|
|
45
|
-
|
|
44
|
+
n ? (k.current = t, e?.onChange?.(t, T)) : (k.current = t, v(t), e?.onChange?.(t, T));
|
|
45
|
+
}, q = (t) => (e?.onFetchingStart?.(), V.current?.(t) || Promise.resolve([])), z = (t, n) => Array.isArray(t) ? (t.some((o) => typeof o != "object" || o === null) && console.debug(`El valor del ${n || "resultado del fetcher"} contiene elementos no válidos (null,undefined, no-object)`, t), t?.filter((o) => o != null) || []) : (console.debug(`El valor del ${n || "resultado del fetcher"} no es un Array (tipo de dato obtenido: ${typeof t})`), []), $ = ee((t, n) => t.length === 0 ? n : s ? n.filter((o) => !t.some((r) => i(r, s) === i(o, s))) : n.filter((o) => !t.some((r) => i(r, "id") === i(o, "id"))), [s]);
|
|
46
|
+
b(() => {
|
|
46
47
|
const t = e?.subscribeOpenChange;
|
|
47
48
|
if (!t) return;
|
|
48
49
|
const n = t((o) => {
|
|
49
|
-
|
|
50
|
+
U(o);
|
|
50
51
|
});
|
|
51
52
|
return () => {
|
|
52
53
|
n && n();
|
|
53
54
|
};
|
|
54
55
|
}, [e?.subscribeOpenChange]);
|
|
55
|
-
const G = F !== void 0 ? F :
|
|
56
|
-
|
|
57
|
-
if (!
|
|
58
|
-
if (!c || c === "" || c.length <
|
|
59
|
-
|
|
56
|
+
const G = F !== void 0 ? F : J;
|
|
57
|
+
b(() => {
|
|
58
|
+
if (!_ && V.current && S === "fetch_on_type") {
|
|
59
|
+
if (!c || c === "" || c.length < w) {
|
|
60
|
+
l.current && clearTimeout(l.current), C(!1);
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
|
-
const t = B(q,
|
|
63
|
-
|
|
64
|
-
const o =
|
|
65
|
-
|
|
63
|
+
const t = B(q, E);
|
|
64
|
+
C(!0), t.then((n) => {
|
|
65
|
+
const o = z(n);
|
|
66
|
+
y(o);
|
|
66
67
|
}).finally(() => {
|
|
67
|
-
|
|
68
|
+
C(!1), e?.onFetchingEnd?.();
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
}, [
|
|
71
|
-
if (!
|
|
71
|
+
}, [S, c, _, E, B, w]), b(() => {
|
|
72
|
+
if (!_)
|
|
72
73
|
if (G) {
|
|
73
|
-
if (e?.onOpen?.(),
|
|
74
|
-
if (!
|
|
74
|
+
if (e?.onOpen?.(), S === "fetch_in_open") {
|
|
75
|
+
if (!V.current)
|
|
75
76
|
return;
|
|
76
|
-
|
|
77
|
-
const n =
|
|
78
|
-
|
|
77
|
+
C(!0), q().then((t) => {
|
|
78
|
+
const n = z(t);
|
|
79
|
+
y(() => {
|
|
79
80
|
const o = n.filter((r) => {
|
|
80
81
|
if (s)
|
|
81
82
|
return i(r, s) !== void 0;
|
|
82
83
|
});
|
|
83
|
-
return
|
|
84
|
+
return L && f.length > 0 ? [...$(f, o), ...f] : o;
|
|
84
85
|
});
|
|
85
86
|
}).finally(() => {
|
|
86
|
-
|
|
87
|
+
C(!1), e?.onFetchingEnd?.();
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
} else
|
|
90
91
|
e?.onClose?.();
|
|
91
|
-
}, [G,
|
|
92
|
+
}, [G, S, _]);
|
|
92
93
|
const H = (t, n) => t?.filter((o) => {
|
|
93
|
-
if (
|
|
94
|
-
return i(o,
|
|
94
|
+
if (h)
|
|
95
|
+
return i(o, h)?.toLowerCase().includes(n.toLowerCase());
|
|
95
96
|
{
|
|
96
97
|
const r = o;
|
|
97
98
|
switch (typeof r) {
|
|
@@ -100,25 +101,25 @@ function re(e) {
|
|
|
100
101
|
case "number":
|
|
101
102
|
return r.toString().includes(n);
|
|
102
103
|
case "object":
|
|
103
|
-
return Object.values(r).some((
|
|
104
|
+
return Object.values(r).some((j) => j.toString()?.toLowerCase().includes(n.toLowerCase()));
|
|
104
105
|
default:
|
|
105
106
|
return !1;
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
}) || [], ne = (t) => t?.sort((n, o) => {
|
|
109
|
-
if (
|
|
110
|
-
return i(n,
|
|
110
|
+
if (h)
|
|
111
|
+
return i(n, h) < i(o, h) ? -1 : 1;
|
|
111
112
|
{
|
|
112
|
-
const
|
|
113
|
-
switch (typeof
|
|
113
|
+
const a = ["label", "name", "value"].find((K) => typeof n == "object" && Object.keys(n).includes(K)), j = n, R = o;
|
|
114
|
+
switch (typeof j) {
|
|
114
115
|
case "string":
|
|
115
|
-
return
|
|
116
|
+
return j < R ? -1 : 1;
|
|
116
117
|
case "number":
|
|
117
|
-
return
|
|
118
|
+
return j < R ? -1 : 1;
|
|
118
119
|
case "object":
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
return
|
|
120
|
+
if (a) {
|
|
121
|
+
const K = i(n, a), oe = i(o, a);
|
|
122
|
+
return K < oe ? -1 : 1;
|
|
122
123
|
} else
|
|
123
124
|
return 1;
|
|
124
125
|
default:
|
|
@@ -126,82 +127,92 @@ function re(e) {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}) || [], Q = (t) => {
|
|
129
|
-
const n = typeof
|
|
130
|
-
t.target === n?.current && (
|
|
131
|
-
|
|
132
|
-
},
|
|
130
|
+
const n = typeof P == "function" ? P() : P;
|
|
131
|
+
t.target === n?.current && (g.current && clearTimeout(g.current), m.current || (m.current = !0, e?.onTypeStart?.()), g.current = setTimeout(() => {
|
|
132
|
+
m.current = !1;
|
|
133
|
+
}, E));
|
|
133
134
|
};
|
|
134
|
-
return
|
|
135
|
+
return b(() => {
|
|
135
136
|
if (c === "")
|
|
136
|
-
|
|
137
|
-
else if (
|
|
138
|
-
const t =
|
|
139
|
-
|
|
137
|
+
I(ne(p));
|
|
138
|
+
else if (L) {
|
|
139
|
+
const t = $(f, p);
|
|
140
|
+
I([...H(t, c), ...f]);
|
|
140
141
|
} else {
|
|
141
|
-
const t =
|
|
142
|
-
|
|
142
|
+
const t = $([f], p);
|
|
143
|
+
I([...H(t, c), f]);
|
|
143
144
|
}
|
|
144
|
-
}, [
|
|
145
|
+
}, [p]), b(() => (document.addEventListener("keydown", Q), () => {
|
|
145
146
|
document.removeEventListener("keydown", Q);
|
|
146
147
|
}), []), {
|
|
147
148
|
inputValue: c,
|
|
148
|
-
setInputValue:
|
|
149
|
+
setInputValue: N,
|
|
149
150
|
cleanInputValue: () => {
|
|
150
|
-
|
|
151
|
+
N("");
|
|
152
|
+
},
|
|
153
|
+
cleanOptions: () => {
|
|
154
|
+
L && y(f);
|
|
155
|
+
},
|
|
156
|
+
clearValue: () => {
|
|
157
|
+
v(L ? [] : void 0);
|
|
151
158
|
},
|
|
152
|
-
filteredOptions:
|
|
153
|
-
isLoading:
|
|
154
|
-
value:
|
|
155
|
-
setValue:
|
|
159
|
+
filteredOptions: D,
|
|
160
|
+
isLoading: W,
|
|
161
|
+
value: f,
|
|
162
|
+
setValue: v,
|
|
156
163
|
onOptionClick: te
|
|
157
164
|
};
|
|
158
165
|
}
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
e.controls && (e.controls.current =
|
|
166
|
+
const fe = (e) => {
|
|
167
|
+
const O = A(null);
|
|
168
|
+
b(() => {
|
|
169
|
+
e.controls && (e.controls.current = O.current);
|
|
163
170
|
}, [e.controls]);
|
|
164
|
-
const { asyncMode:
|
|
165
|
-
const
|
|
171
|
+
const { asyncMode: u = "fetch_in_open" } = e, S = (l, g, m) => {
|
|
172
|
+
const V = {
|
|
166
173
|
options: l.options,
|
|
167
174
|
fetcher: l.fetcher,
|
|
168
|
-
asyncMode:
|
|
175
|
+
asyncMode: g,
|
|
169
176
|
debounceDelay: l.debounceDelay,
|
|
170
177
|
minCharacters: l.minCharacters,
|
|
171
178
|
disabled: l.disabled,
|
|
172
179
|
optionValue: l.optionValue,
|
|
173
180
|
optionLabel: l.optionLabel,
|
|
174
181
|
onFetchingStart: () => {
|
|
175
|
-
|
|
182
|
+
g === "fetch_on_type" && m.current?.open();
|
|
176
183
|
},
|
|
177
184
|
onTypeStart: () => {
|
|
178
|
-
!l?.fetcher &&
|
|
185
|
+
!l?.fetcher && m.current?.open();
|
|
179
186
|
},
|
|
180
|
-
inputRef: () =>
|
|
181
|
-
subscribeOpenChange:
|
|
187
|
+
inputRef: () => m.current?.searchInputRef,
|
|
188
|
+
subscribeOpenChange: m.current?.subscribeOpenChange,
|
|
182
189
|
name: l.name
|
|
183
190
|
};
|
|
184
191
|
return l.multiple ? {
|
|
185
|
-
...
|
|
192
|
+
...V,
|
|
186
193
|
multiple: !0,
|
|
187
194
|
controlledValue: l.value,
|
|
188
195
|
onChange: l.onChange
|
|
189
196
|
} : {
|
|
190
|
-
...
|
|
197
|
+
...V,
|
|
191
198
|
multiple: !1,
|
|
192
199
|
controlledValue: l.value,
|
|
193
200
|
onChange: l.onChange
|
|
194
201
|
};
|
|
195
|
-
}, { inputValue:
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
}, { displayMode:
|
|
199
|
-
controledSearchValue:
|
|
200
|
-
onSearchValueChange:
|
|
201
|
-
onSearchClear:
|
|
202
|
+
}, { inputValue: _, setInputValue: E, filteredOptions: w, isLoading: h, value: s, onOptionClick: d, cleanInputValue: F, cleanOptions: P, clearValue: T } = le(S(e, u, O)), M = ee(() => u === "fetch_on_type" ? h : !1, [u, h]), p = Z(() => e.multiple ? s.map((l) => i(l, e.optionValue)) : s ? i(s, e.optionValue) : void 0, [s, e.optionValue, e.multiple]), y = (l) => {
|
|
203
|
+
const g = w.find((m) => i(m, e.optionValue) === l.id);
|
|
204
|
+
g && d(g);
|
|
205
|
+
}, { displayMode: D = e.multiple ? "chips" : "compact", dropdownOptions: I, overflow: c = "scroll", onChange: N, onClear: W, ...C } = e.selectComponentProps || {}, J = {
|
|
206
|
+
controledSearchValue: _,
|
|
207
|
+
onSearchValueChange: u === "fetch_on_type" ? E : void 0,
|
|
208
|
+
onSearchClear: u === "fetch_on_type" ? () => {
|
|
209
|
+
F(), P();
|
|
210
|
+
} : void 0,
|
|
202
211
|
inputSearchPlaceholder: e.inputSearchPlaceholder,
|
|
203
|
-
isLoading:
|
|
204
|
-
...
|
|
212
|
+
isLoading: M(),
|
|
213
|
+
...I || {}
|
|
214
|
+
}, U = () => {
|
|
215
|
+
T(), e?.selectComponentProps?.onClear?.();
|
|
205
216
|
};
|
|
206
217
|
return e.multiple ? /* @__PURE__ */ X.jsx(
|
|
207
218
|
Y,
|
|
@@ -209,46 +220,48 @@ const ae = (e) => {
|
|
|
209
220
|
disabled: e.disabled,
|
|
210
221
|
className: e.className,
|
|
211
222
|
name: e.name,
|
|
212
|
-
overflow:
|
|
213
|
-
...
|
|
223
|
+
overflow: c,
|
|
224
|
+
...C,
|
|
225
|
+
onClear: e?.selectComponentProps?.onClear && U,
|
|
214
226
|
multiple: !0,
|
|
215
|
-
value:
|
|
227
|
+
value: p,
|
|
216
228
|
label: e.label || "",
|
|
217
|
-
options:
|
|
229
|
+
options: w,
|
|
218
230
|
optionValue: e.optionValue,
|
|
219
231
|
optionLabel: e.optionLabel,
|
|
220
232
|
renderOption: e.renderOption,
|
|
221
|
-
onOptionClick:
|
|
222
|
-
displayMode:
|
|
223
|
-
controls:
|
|
233
|
+
onOptionClick: y,
|
|
234
|
+
displayMode: D,
|
|
235
|
+
controls: O,
|
|
224
236
|
emptyMessage: "Use el buscador para obtener las opciones disponibles",
|
|
225
|
-
dropdownOptions:
|
|
226
|
-
isLoading:
|
|
237
|
+
dropdownOptions: J,
|
|
238
|
+
isLoading: u === "fetch_in_open" ? h : !1
|
|
227
239
|
}
|
|
228
240
|
) : /* @__PURE__ */ X.jsx(
|
|
229
241
|
Y,
|
|
230
242
|
{
|
|
231
243
|
disabled: e.disabled,
|
|
232
|
-
...
|
|
244
|
+
...C,
|
|
245
|
+
onClear: U,
|
|
233
246
|
className: e.className,
|
|
234
|
-
overflow:
|
|
247
|
+
overflow: c,
|
|
235
248
|
name: e.name,
|
|
236
249
|
multiple: !1,
|
|
237
|
-
value:
|
|
250
|
+
value: p,
|
|
238
251
|
label: e.label || "",
|
|
239
|
-
options:
|
|
252
|
+
options: w,
|
|
240
253
|
optionValue: e.optionValue,
|
|
241
254
|
optionLabel: e.optionLabel,
|
|
242
255
|
renderOption: e.renderOption,
|
|
243
|
-
onOptionClick:
|
|
256
|
+
onOptionClick: y,
|
|
244
257
|
displayMode: "compact",
|
|
245
|
-
controls:
|
|
258
|
+
controls: O,
|
|
246
259
|
emptyMessage: "Use el buscador para obtener las opciones disponibles",
|
|
247
|
-
dropdownOptions:
|
|
248
|
-
isLoading:
|
|
260
|
+
dropdownOptions: J,
|
|
261
|
+
isLoading: u === "fetch_in_open" ? h : !1
|
|
249
262
|
}
|
|
250
263
|
);
|
|
251
264
|
};
|
|
252
265
|
export {
|
|
253
|
-
|
|
266
|
+
fe as default
|
|
254
267
|
};
|
|
@@ -33,6 +33,8 @@ export declare function useAutocomplete<T extends object>(options?: UseAutocompl
|
|
|
33
33
|
inputValue: string;
|
|
34
34
|
setInputValue: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
35
35
|
cleanInputValue: () => void;
|
|
36
|
+
cleanOptions: () => void;
|
|
37
|
+
clearValue: () => void;
|
|
36
38
|
filteredOptions: T[];
|
|
37
39
|
isLoading: boolean;
|
|
38
40
|
value: T | T[] | undefined;
|
|
@@ -13,7 +13,7 @@ import { default as Ke } from "./Menu.es.js";
|
|
|
13
13
|
import { default as Ye } from "./Pagination.es.js";
|
|
14
14
|
import { default as tt } from "./ProfilePictureUpload.es.js";
|
|
15
15
|
import { default as rt } from "./ProgressBar.es.js";
|
|
16
|
-
import { S as nt } from "./Select-
|
|
16
|
+
import { S as nt } from "./Select-DW30oGym.js";
|
|
17
17
|
import { default as it } from "./Spinner.es.js";
|
|
18
18
|
import { default as ct } from "./Steps.es.js";
|
|
19
19
|
import { default as dt } from "./SwipeContainer.es.js";
|