prometeo-design-system 2.6.8 → 2.7.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.
Files changed (40) hide show
  1. package/dist/{Button-DsbEyjth.js → Button-CvBWH1HX.js} +8 -8
  2. package/dist/Button.es.js +1 -1
  3. package/dist/ButtonV2.es.js +12 -12
  4. package/dist/CheckboxFormik.es.js +10 -10
  5. package/dist/DatePicker.es.js +2 -2
  6. package/dist/DrawerDesktop.es.js +1 -1
  7. package/dist/DropZone.es.js +5 -5
  8. package/dist/FAButton.es.js +1 -1
  9. package/dist/{ImageGallery-DnoRTpCr.js → ImageGallery-DKzJg3un.js} +1 -1
  10. package/dist/ImageGallery.es.js +1 -1
  11. package/dist/Input-BTsR-vNF.js +281 -0
  12. package/dist/Input.es.js +1 -1
  13. package/dist/InputFormikV2.es.js +1 -1
  14. package/dist/Pagination.es.js +8 -8
  15. package/dist/ProfilePictureUpload.es.js +3 -3
  16. package/dist/Select-BQMdfu1n.js +1003 -0
  17. package/dist/Select.es.js +1 -1
  18. package/dist/SelectFormik.es.js +1 -1
  19. package/dist/SelectFormikLegacy.es.js +14 -14
  20. package/dist/SelectSearch.es.js +66 -63
  21. package/dist/TabLinks.es.js +8 -8
  22. package/dist/TextArea.es.js +28 -26
  23. package/dist/Toast.es.js +1 -1
  24. package/dist/components/RecurrentDatePicker/CustomFrequencySettings.d.ts +29 -3
  25. package/dist/components/RecurrentDatePicker/FrequencySettings.d.ts +2 -1
  26. package/dist/components/RecurrentDatePicker/MonthlyFrequencySettings.d.ts +9 -3
  27. package/dist/components/RecurrentDatePicker/RecurrentDatePicker.d.ts +28 -1
  28. package/dist/components/RecurrentDatePicker/WeekdaysSelector.d.ts +1 -0
  29. package/dist/components/RecurrentDatePicker/WeeklyFrequencySetting.d.ts +2 -1
  30. package/dist/components/RecurrentDatePicker/YearlyFrequencySettings.d.ts +13 -2
  31. package/dist/components/RecurrentDatePicker/recurrentDatePicker.validations.d.ts +69 -0
  32. package/dist/components/Select/Select.d.ts +18 -0
  33. package/dist/components/TextArea/TextArea.d.ts +2 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/preview/SelectPreview/SelectGroupedOptionsPreview.d.ts +2 -0
  36. package/dist/prometeo-design-system.css +1 -1
  37. package/dist/prometeo-design-system.es.js +4 -4
  38. package/package.json +1 -1
  39. package/dist/Input-R52CsX56.js +0 -280
  40. package/dist/Select-CMjYSSZB.js +0 -812
@@ -0,0 +1,1003 @@
1
+ import { j as s } from "./jsx-runtime-DKDX3adD.js";
2
+ import { Icons as je } from "./Icons.es.js";
3
+ import { c as f } from "./cn-B6yFEsav.js";
4
+ import Ne, { memo as Z, useState as De, useRef as ce, useMemo as oe, useCallback as U, useEffect as ve, useImperativeHandle as Qe } from "react";
5
+ import Xe from "./Spinner.es.js";
6
+ import { createPortal as Ye } from "react-dom";
7
+ import { u as Ze } from "./useDragScroll-CHN9OMwn.js";
8
+ import { u as et, I as tt } from "./Input-BTsR-vNF.js";
9
+ import { H as nt } from "./HelperComponent-U6mPwuDH.js";
10
+ import rt from "./CheckBox.es.js";
11
+ import { Skeleton as Fe } from "./Skeleton.es.js";
12
+ const lt = {
13
+ default: {
14
+ container: "text-neutral-default-default border-neutral-default-default ",
15
+ icon: ""
16
+ },
17
+ error: {
18
+ container: "",
19
+ icon: ""
20
+ },
21
+ success: {
22
+ container: "",
23
+ icon: ""
24
+ }
25
+ }, qe = {
26
+ icon: " text-neutral-default-disabled",
27
+ container: " border-neutral-strong-default text-neutral-default-disabled"
28
+ }, Ve = ({ id: e, label: n, onRemove: m, className: i, disabled: u, variant: v = "default", tabIndex: h }) => /* @__PURE__ */ s.jsxs(
29
+ "div",
30
+ {
31
+ tabIndex: h,
32
+ className: f(
33
+ "inline-flex max-w-[calc(50%-0.25rem)] items-center gap-1 px-2 py-1 bg-inherit text-xs rounded-lg border h-[30px]",
34
+ lt[v].container,
35
+ u && qe.container
36
+ ),
37
+ children: [
38
+ /* @__PURE__ */ s.jsx("span", { className: "truncate w-max ", children: n }),
39
+ m && /* @__PURE__ */ s.jsx(
40
+ "button",
41
+ {
42
+ onMouseDown: (j) => {
43
+ u || (j.stopPropagation(), j.preventDefault(), m?.(e));
44
+ },
45
+ className: f(
46
+ "shrink-0 p-0.5 transition-all duration-200 hover:text-neutral-default-hover cursor-pointer z-50 text-neutral-default-default hover:scale-105",
47
+ u && "cursor-default hover:scale-100",
48
+ i
49
+ ),
50
+ type: "button",
51
+ tabIndex: h,
52
+ children: /* @__PURE__ */ s.jsx(je.Close, { size: 18, className: f(u && qe.icon) })
53
+ }
54
+ )
55
+ ]
56
+ }
57
+ );
58
+ Ve.displayName = "Chip";
59
+ const ot = Z(Ve);
60
+ function G(e, n) {
61
+ if (typeof n == "function")
62
+ return n(e);
63
+ const m = n?.split(".");
64
+ let i = e;
65
+ for (const u of m)
66
+ if (i && typeof i == "object" && u in i)
67
+ i = i[u];
68
+ else
69
+ return;
70
+ return i;
71
+ }
72
+ const Ue = (e, n) => {
73
+ if (!n) return !0;
74
+ const m = 0.1, i = String(e).toLowerCase(), u = String(n).toLowerCase().trim();
75
+ if (i.includes(u)) return !0;
76
+ const v = u.split(/\s+/).filter(Boolean), h = v.filter((b) => /^\d+$/.test(b));
77
+ if (v.length > 1 || h.length > 0) {
78
+ for (const b of h)
79
+ if (!new RegExp(`(^|\\D)${b}(\\D|$)`).test(i)) return !1;
80
+ for (const b of v)
81
+ if (!/^\d+$/.test(b) && !i.includes(b))
82
+ return !1;
83
+ return !0;
84
+ }
85
+ if (u.length > i.length) return !1;
86
+ const j = Math.floor(u.length * m);
87
+ if (j <= 0) return !1;
88
+ const p = (b, k) => {
89
+ const I = b.length, W = k.length;
90
+ if (I === 0) return W;
91
+ if (W === 0) return I;
92
+ const A = new Array(W + 1);
93
+ for (let x = 0; x <= W; x++) A[x] = x;
94
+ for (let x = 1; x <= I; x++) {
95
+ let S = x - 1;
96
+ A[0] = x;
97
+ for (let M = 1; M <= W; M++) {
98
+ const se = A[M], K = b.charCodeAt(x - 1) === k.charCodeAt(M - 1) ? 0 : 1, V = A[M] + 1, z = A[M - 1] + 1, N = S + K;
99
+ A[M] = V < z ? V < N ? V : N : z < N ? z : N, S = se;
100
+ }
101
+ }
102
+ return A[W];
103
+ };
104
+ for (let b = 0; b <= i.length - u.length; b++) {
105
+ const k = i.slice(b, b + u.length);
106
+ if (p(k, u) <= j) return !0;
107
+ }
108
+ return !1;
109
+ }, st = (e) => {
110
+ const n = [], m = (i) => {
111
+ i.forEach((u) => {
112
+ const h = u.options;
113
+ Array.isArray(h) && h.length > 0 ? m(h) : n.push(u);
114
+ });
115
+ };
116
+ return m(e), n;
117
+ }, Re = {
118
+ default: {
119
+ container: "",
120
+ input: f(
121
+ "border-neutral-default-default text-neutral-default-default",
122
+ "focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
123
+ "hover:border-primary-default-default"
124
+ ),
125
+ label: f(
126
+ "text-neutral-medium-default",
127
+ "peer-focus:text-primary-default-default"
128
+ ),
129
+ icon: f(
130
+ "text-neutral-medium-default",
131
+ "peer-focus:text-primary-default-default"
132
+ )
133
+ },
134
+ error: {
135
+ container: "",
136
+ input: f(
137
+ "border-error-default-default text-neutral-default-default hover:border-error-default-hover",
138
+ "focus:border-error-default focus:border-2",
139
+ "focus:ring-0 focus:ring-error-default/20"
140
+ ),
141
+ label: f(
142
+ "text-error-light",
143
+ "peer-focus:text-error-light"
144
+ ),
145
+ icon: f(
146
+ "text-error-medium-default",
147
+ "peer-focus:text-error-light"
148
+ )
149
+ },
150
+ success: {
151
+ container: "",
152
+ input: f(
153
+ "border-success-default-default text-neutral-default-default",
154
+ "focus:border-success-default focus:border-2",
155
+ "focus:ring-0 focus:ring-success-default/20"
156
+ ),
157
+ label: f(
158
+ "text-success",
159
+ "peer-focus:text-success-light"
160
+ ),
161
+ icon: f(
162
+ "text-success-medium-default",
163
+ "peer-focus:text-success-light"
164
+ )
165
+ }
166
+ }, Be = {
167
+ input: f(
168
+ "border-neutral-strong-default text-neutral-default-default",
169
+ "focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
170
+ "hover:border-primary-default-default"
171
+ ),
172
+ label: f(
173
+ "text-neutral-medium-disabled",
174
+ "peer-focus:text-primary-default-default"
175
+ ),
176
+ icon: f(
177
+ "text-neutral-medium-disabled",
178
+ "peer-focus:text-primary-default-default"
179
+ )
180
+ };
181
+ function at(e) {
182
+ const [n, m] = De(!1), [i, u] = De([]), [v, h] = De(""), j = ce(null), p = ce(null), b = ce(null), k = ce(null), I = ce(() => {
183
+ }), W = ce(null), A = ce(/* @__PURE__ */ new Set()), {
184
+ id: x,
185
+ name: S,
186
+ label: M,
187
+ height: se,
188
+ options: K,
189
+ controls: V,
190
+ className: z,
191
+ placeholder: N,
192
+ optionValue: E,
193
+ optionLabel: de,
194
+ renderOption: J,
195
+ renderOptionGroupHeader: fe,
196
+ renderSelection: He,
197
+ renderOptionContext: Ae,
198
+ buttonClassName: Ee,
199
+ dropdownClassName: ae,
200
+ containerClassName: Q,
201
+ dropdownOptions: O,
202
+ helperComponent: ee,
203
+ errorComponent: Ce,
204
+ onRemoveOption: ke,
205
+ onOptionClick: X,
206
+ onClose: Se,
207
+ onClear: me,
208
+ disabled: te = !1,
209
+ overflow: Ke = "wrap",
210
+ variant: F = "default",
211
+ isLoading: he = !1,
212
+ attachToParent: Me = !1,
213
+ displayMode: we = "compact",
214
+ labelVariant: ie = "default",
215
+ disableOpenOnFocus: ze = !1,
216
+ emptyMessage: Oe = "No hay opciones disponibles"
217
+ } = e, { ref: Le } = et(), { bind: ne, ref: Te } = Ze({
218
+ axis: "x",
219
+ cursor: { idle: "default", dragging: "grabbing" }
220
+ }), pe = e.multiple ? Array.isArray(e.value) && e.value.length > 0 : e.value !== void 0 && e.value !== null && e.value !== "", Ge = {}, $e = oe(() => ie === "static" && N ? N : "", [ie, N]), Ie = oe(
221
+ () => O?.controledSearchValue || v,
222
+ [O?.controledSearchValue, v]
223
+ ), Pe = () => {
224
+ const t = {
225
+ static: {
226
+ active: "relative prometeo-fonts-label-large",
227
+ default: "relative prometeo-fonts-label-large"
228
+ },
229
+ default: {
230
+ active: "absolute top-0 -translate-y-1/2 left-3 px-1 prometeo-fonts-body-small",
231
+ default: "absolute top-1/2 -translate-y-1/2 "
232
+ }
233
+ }, a = n || pe ? "active" : "default";
234
+ return t[ie][a];
235
+ }, T = U((t) => ({
236
+ id: G(t, E),
237
+ value: G(t, E),
238
+ label: G(t, de)
239
+ }), [E, de]), Y = oe(
240
+ () => st(K),
241
+ [K]
242
+ ), ge = oe(
243
+ () => Y.map(T),
244
+ [Y, T]
245
+ ), r = oe(
246
+ () => {
247
+ const t = [];
248
+ if (e.multiple)
249
+ e.value?.forEach((a) => {
250
+ const l = Y?.find((g) => G(g, E) === a);
251
+ l && t.push(l);
252
+ });
253
+ else {
254
+ const a = Y?.find((l) => G(l, E) === e.value);
255
+ a && t.push(a);
256
+ }
257
+ return t;
258
+ },
259
+ [e.value, E, Y, e.multiple]
260
+ ), o = oe(
261
+ () => r.map(T),
262
+ [r, T]
263
+ ), c = oe(
264
+ () => new Set(o.map((t) => t.id)),
265
+ [o]
266
+ ), d = oe(() => {
267
+ const t = [];
268
+ return K.forEach((a, l) => {
269
+ const g = a, H = g.options;
270
+ if (Array.isArray(H) && H.length > 0) {
271
+ const $ = g.label, P = G(a, E), le = `__group-${String(P ?? l)}`, xe = {
272
+ id: le,
273
+ value: le,
274
+ label: typeof $ == "string" ? $ : String(P ?? `Grupo ${l + 1}`),
275
+ isGroupHeader: !0,
276
+ groupLabelNode: $,
277
+ originalOption: a,
278
+ groupData: {
279
+ groupOptions: H
280
+ }
281
+ };
282
+ t.push(xe), H.forEach((ye) => {
283
+ J ? t.push(ye) : t.push(T(ye));
284
+ });
285
+ } else
286
+ J ? t.push(a) : t.push(T(a));
287
+ }), t;
288
+ }, [K, E, J, T]), w = U(
289
+ (t, a) => {
290
+ if (!t || t.length === 0) return;
291
+ const l = t.map((C) => T(C));
292
+ if (!e.multiple) {
293
+ const C = l[0];
294
+ if (!C) return;
295
+ const D = c.has(C.id), B = a ?? "toggle";
296
+ let _e;
297
+ B === "select" || B === "toggle" && !D ? _e = C : _e = void 0, e.onChange?.(_e, S);
298
+ return;
299
+ }
300
+ const g = e.value || [], H = [];
301
+ g.forEach((C) => {
302
+ const D = ge.find((B) => B.value === C);
303
+ D && H.push(D);
304
+ });
305
+ const $ = new Set(H.map((C) => C.id)), P = new Set(l.map((C) => C.id)), le = l.every((C) => $.has(C.id)), xe = a ?? "toggle", ye = xe === "select" || xe === "toggle" && !le;
306
+ let _;
307
+ if (!ye)
308
+ _ = H.filter((C) => !P.has(C.id));
309
+ else {
310
+ const C = new Map(H.map((D) => [D.id, D]));
311
+ l.forEach((D) => {
312
+ C.set(D.id, D);
313
+ }), _ = Array.from(C.values());
314
+ }
315
+ e.onChange?.(_, S);
316
+ },
317
+ [
318
+ e.multiple,
319
+ e.value,
320
+ e.onChange,
321
+ ge,
322
+ c,
323
+ T,
324
+ S
325
+ ]
326
+ ), L = U(() => {
327
+ m((t) => !t);
328
+ }, []);
329
+ I.current = (t) => {
330
+ if (!e.multiple)
331
+ e.onChange?.(t, S);
332
+ else {
333
+ const a = e.value || [], l = [], g = a.includes(t.value);
334
+ a.forEach(($) => {
335
+ const P = ge.find((le) => le.value === $);
336
+ P && l.push(P);
337
+ });
338
+ const H = g ? l.filter(($) => $.value !== t.value) : [...l, t];
339
+ e.onChange?.(H, S);
340
+ }
341
+ };
342
+ const y = U((t, a = !1) => {
343
+ X?.(t, S), I.current?.(t), a && (m(!1), Se?.());
344
+ }, [X, Se, S]), R = (t) => {
345
+ t.preventDefault(), t.stopPropagation(), t.target.blur(), me?.(), e.multiple ? e.onChange?.([], S) : e.onChange?.(void 0, S);
346
+ }, q = U((t) => {
347
+ e.multiple || e.onChange?.(void 0, S);
348
+ const a = Y.find((g) => G(g, E) === t);
349
+ if (!a) return;
350
+ const l = T(a);
351
+ X?.(l, S), I.current?.(l), ke?.(a);
352
+ }, [X, ke, Y, S, e.multiple, e.onChange, T, E]), re = U((t) => {
353
+ q(t);
354
+ }, [q]);
355
+ ve(() => {
356
+ if (!n) return;
357
+ const t = (a) => {
358
+ const l = a.target;
359
+ if (a.type === "mousedown") {
360
+ if (j.current?.contains(l) || p.current?.contains(l)) return;
361
+ m(!1);
362
+ }
363
+ if (a.type === "scroll") {
364
+ if (p.current?.contains(l)) return;
365
+ m(!1);
366
+ }
367
+ a.type === "resize" && m(!1);
368
+ };
369
+ return document.addEventListener("mousedown", t), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t, !0), () => {
370
+ document.removeEventListener("mousedown", t), window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t, !0);
371
+ };
372
+ }, [n]), ve(() => {
373
+ A.current.forEach((t) => {
374
+ try {
375
+ t(n);
376
+ } catch {
377
+ }
378
+ });
379
+ }, [n]), Qe(V, () => ({
380
+ open: () => {
381
+ !n && m(!0);
382
+ },
383
+ close: () => {
384
+ n && m(!1);
385
+ },
386
+ toggle: () => m((t) => !t),
387
+ handleOptionSelect: y,
388
+ subscribeOpenChange: (t) => (A.current.add(t), () => {
389
+ A.current.delete(t);
390
+ }),
391
+ searchInputRef: b
392
+ }), [n, y]);
393
+ const be = (t) => {
394
+ t.preventDefault(), t.stopPropagation(), t.target.matches(":focus-visible") && !ze && !n && (m(!0), setTimeout(() => {
395
+ b.current?.focus();
396
+ }, 10));
397
+ }, ue = (t) => {
398
+ t.key === "Tab" && n && m(!1), (t.keyCode === 32 || t.key === "ArrowDown") && (m(!0), setTimeout(() => {
399
+ b.current?.focus();
400
+ }, 10));
401
+ };
402
+ return /* @__PURE__ */ s.jsxs(
403
+ "div",
404
+ {
405
+ className: f(
406
+ "relative bg-inherit select-none w-full",
407
+ z
408
+ ),
409
+ ref: j,
410
+ draggable: !1,
411
+ style: Ge,
412
+ children: [
413
+ /* @__PURE__ */ s.jsxs("div", { className: f("relative bg-inherit ", Q), children: [
414
+ /* @__PURE__ */ s.jsx(
415
+ "label",
416
+ {
417
+ htmlFor: x,
418
+ ref: Le,
419
+ className: f(
420
+ "left-3 pointer-events-none bg-inherit z-10",
421
+ ie === "default" && "transition-all duration-200 ease-in-out",
422
+ Pe(),
423
+ pe || n ? Re[F].label : "text-neutral-medium-default",
424
+ te && Be.label
425
+ ),
426
+ children: M
427
+ }
428
+ ),
429
+ /* @__PURE__ */ s.jsxs(
430
+ "div",
431
+ {
432
+ id: x,
433
+ tabIndex: 0,
434
+ role: "button",
435
+ ref: k,
436
+ onFocus: be,
437
+ onKeyDown: ue,
438
+ onClick: (t) => {
439
+ t.preventDefault(), t.stopPropagation(), L();
440
+ },
441
+ className: f(
442
+ "w-full px-2 text-left border rounded-lg transition-all duration-200 ease-in-out",
443
+ "flex items-center justify-start bg-inherit ",
444
+ "focus:outline-none",
445
+ we === "chips" && e.multiple && pe ? "min-h-12 py-2 " : !se && "h-12 min-h-12",
446
+ Re[F].input,
447
+ te && Be.input,
448
+ Ee
449
+ ),
450
+ children: [
451
+ /* @__PURE__ */ s.jsx(
452
+ "div",
453
+ {
454
+ className: f("flex-1 overflow-x-auto overflow-y-hidden px-1 prometeo-scrollbar-none "),
455
+ ref: Te,
456
+ onPointerUp: ne.onPointerUp,
457
+ onPointerDown: ne.onPointerDown,
458
+ onPointerMove: ne.onPointerMove,
459
+ onPointerLeave: ne.onPointerLeave,
460
+ onPointerCancel: ne.onPointerCancel,
461
+ onClickCapture: ne.onClickCapture,
462
+ children: He ? Ne.createElement(
463
+ Z(
464
+ He,
465
+ (t, a) => t.disabled === a.disabled && t.multiple === a.multiple
466
+ ),
467
+ {
468
+ disabled: te,
469
+ multiple: e.multiple || !1,
470
+ placeholder: N,
471
+ selectedOptions: r,
472
+ onRemoveOption: re
473
+ }
474
+ ) : /* @__PURE__ */ s.jsx(
475
+ Je,
476
+ {
477
+ displayMode: we,
478
+ selectedOptions: o,
479
+ placeholder: $e,
480
+ onRemoveOption: q,
481
+ multiple: e.multiple || !1,
482
+ className: f(Ke === "scroll" ? "flex-nowrap" : "flex-wrap"),
483
+ disabled: te
484
+ }
485
+ )
486
+ }
487
+ ),
488
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-2", children: [
489
+ he && /* @__PURE__ */ s.jsx(Xe, { size: "small", variant: "clip", className: " translate-y-1", speedMultiplier: 0.7 }),
490
+ pe && me && /* @__PURE__ */ s.jsx(
491
+ "button",
492
+ {
493
+ onMouseDown: (t) => {
494
+ t.preventDefault(), t.stopPropagation(), R(t);
495
+ },
496
+ type: "button",
497
+ tabIndex: -1,
498
+ children: /* @__PURE__ */ s.jsx(je.Cancel, { size: 20, className: f(" cursor-pointer transition-all", Re[F].icon) })
499
+ }
500
+ ),
501
+ /* @__PURE__ */ s.jsx(
502
+ je.ChevronDown,
503
+ {
504
+ size: 20,
505
+ className: f(
506
+ "transition-transform text-neutral-default-default",
507
+ n ? "rotate-180" : "",
508
+ te && Be.icon
509
+ )
510
+ }
511
+ )
512
+ ] })
513
+ ]
514
+ }
515
+ )
516
+ ] }),
517
+ n && /* @__PURE__ */ s.jsx(
518
+ ct,
519
+ {
520
+ label: M,
521
+ isOpen: n,
522
+ disabled: te,
523
+ optionValue: E,
524
+ optionLabel: de,
525
+ emptyMessage: Oe,
526
+ labelVariant: ie,
527
+ renderOption: J,
528
+ renderOptionGroupHeader: fe,
529
+ attachToParent: Me,
530
+ filteredOptions: i,
531
+ multiple: e.multiple || !1,
532
+ dropdownClassName: ae,
533
+ selectedOptionsIds: c,
534
+ setFilteredOptions: u,
535
+ renderOptionContext: Ae,
536
+ options: d,
537
+ selectRef: j,
538
+ dropdownRef: p,
539
+ selectButtonRef: k,
540
+ helperComponentRef: W,
541
+ onOptionClick: y,
542
+ onCloseDropdown: () => m(!1),
543
+ searchValue: Ie,
544
+ setSearchValue: h,
545
+ searchInputRef: b,
546
+ isLoading: O?.isLoading,
547
+ onSearchClear: O?.onSearchClear,
548
+ hideSearchBar: O?.hideSearchBar,
549
+ dropdownHeight: O?.dropdownHeight,
550
+ onSearchValueChange: O?.onSearchValueChange,
551
+ inputSearchPlaceholder: O?.inputSearchPlaceholder,
552
+ footer: O?.footer,
553
+ loadingComponent: O?.loadingComponent,
554
+ inputProps: O?.inputProps,
555
+ enableGroupToggle: O?.enableGroupToggle,
556
+ onGroupSelectChange: w
557
+ }
558
+ ),
559
+ (Ce || ee) && /* @__PURE__ */ s.jsx("div", { className: "min-h-6", children: /* @__PURE__ */ s.jsx(
560
+ nt,
561
+ {
562
+ ref: W,
563
+ variant: F,
564
+ className: "absolute bottom-0 h-5 overflow-visible ",
565
+ children: Ce || ee
566
+ }
567
+ ) })
568
+ ]
569
+ }
570
+ );
571
+ }
572
+ const it = Z(at, (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), St = it;
573
+ function ut({
574
+ footer: e,
575
+ isOpen: n,
576
+ label: m,
577
+ options: i,
578
+ multiple: u,
579
+ disabled: v,
580
+ selectRef: h,
581
+ inputProps: j,
582
+ dropdownRef: p,
583
+ optionLabel: b,
584
+ optionValue: k,
585
+ searchValue: I,
586
+ labelVariant: W,
587
+ emptyMessage: A,
588
+ renderOption: x,
589
+ renderOptionContext: S,
590
+ renderOptionGroupHeader: M,
591
+ onOptionClick: se,
592
+ onSearchClear: K,
593
+ searchInputRef: V,
594
+ setSearchValue: z,
595
+ dropdownHeight: N,
596
+ attachToParent: E,
597
+ filteredOptions: de,
598
+ selectButtonRef: J,
599
+ onCloseDropdown: fe,
600
+ loadingComponent: He,
601
+ dropdownClassName: Ae,
602
+ helperComponentRef: Ee,
603
+ selectedOptionsIds: ae,
604
+ setFilteredOptions: Q,
605
+ onSearchValueChange: O,
606
+ isLoading: ee = !1,
607
+ hideSearchBar: Ce = !1,
608
+ inputSearchPlaceholder: ke = "Buscar opciones",
609
+ enableGroupToggle: X = !0,
610
+ onGroupSelectChange: Se
611
+ }) {
612
+ const me = e ? 380 : 320, te = W === "static" ? m !== "" ? -20 : 4 : 7, F = U(() => N ? N.endsWith("px") ? Number(N.replace("px", "")) : N.endsWith("vh") ? window.innerHeight * Number(N.replace("vh", "")) / 100 : N.endsWith("%") ? window.innerHeight * Number(N.replace("%", "")) / 100 : me : me, [N, me])(), [he, Me] = De({ direction: "down", height: F }), [we, ie] = De(() => /* @__PURE__ */ new Set()), ze = U((r) => !we.has(r), [we]), Oe = U((r, o) => {
613
+ ie((c) => {
614
+ const d = new Set(c), w = d.has(r);
615
+ return (o === void 0 ? !w : !o) ? d.add(r) : d.delete(r), d;
616
+ });
617
+ }, []), Le = (r) => {
618
+ if (!p.current || !h.current) return;
619
+ const o = h.current.getBoundingClientRect();
620
+ switch (r || he.direction) {
621
+ case "down":
622
+ p.current.style.top = `${o.top + o.height - (Ee?.current?.offsetHeight ? Ee?.current?.offsetHeight + 4 : 0)}px`;
623
+ break;
624
+ case "up":
625
+ p.current.style.top = "auto", p.current.style.bottom = `${window.innerHeight - o.top + te}px`;
626
+ break;
627
+ }
628
+ p.current.style.left = `${o.left}px`, p.current.style.width = `${o.width}px`;
629
+ }, ne = (r) => {
630
+ p.current && (p.current.style.maxHeight = `${r}px`);
631
+ }, Te = () => {
632
+ if (!p.current || !h.current) return he;
633
+ const r = h.current.getBoundingClientRect(), o = window.innerHeight - (window.innerHeight - r.top), c = window.innerHeight - r.bottom, d = c >= F, w = o >= F;
634
+ let L = "down", y;
635
+ return d ? (L = "down", y = F) : w ? (L = "up", y = F) : c > o ? (L = "down", y = c - 16) : (L = "up", y = o - 16), { direction: L, height: y };
636
+ }, pe = (r) => {
637
+ if (!(!p.current || !h.current)) {
638
+ if (p.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !r) {
639
+ p.current.style.maxHeight = "0", p.current.style.opacity = "0", p.current.style.pointerEvents = "none";
640
+ return;
641
+ }
642
+ if (!E) {
643
+ const o = Te();
644
+ Me(o), Le(o.direction), ne(o.height);
645
+ }
646
+ p.current.style.opacity = "1", p.current.style.pointerEvents = "auto";
647
+ }
648
+ };
649
+ ve(() => {
650
+ E || !h.current || !n || Le();
651
+ }, [ae]), ve(() => {
652
+ pe(n);
653
+ }, [n]), ve(() => {
654
+ i && Q(i);
655
+ }, [i]), ve(() => {
656
+ if (ee || !I) return;
657
+ const r = Ge(i, I);
658
+ Q(r);
659
+ }, [i]);
660
+ const Ge = (r, o) => {
661
+ if (!o) return r;
662
+ if (x) {
663
+ const y = [];
664
+ let R = null, q = [];
665
+ const re = () => {
666
+ R && q.length > 0 && y.push(R, ...q), R = null, q = [];
667
+ };
668
+ return r.forEach((be) => {
669
+ const ue = be;
670
+ if (!!ue.isGroupHeader) {
671
+ re(), R = ue;
672
+ return;
673
+ }
674
+ const a = be, l = G(a, b), g = Ue(String(l ?? ""), o);
675
+ R ? g && q.push(a) : g && y.push(a);
676
+ }), re(), y;
677
+ }
678
+ const c = [];
679
+ let d = null, w = [];
680
+ const L = () => {
681
+ d && w.length > 0 && c.push(d, ...w), d = null, w = [];
682
+ };
683
+ return r.forEach((y) => {
684
+ if (y.isGroupHeader) {
685
+ L(), d = y;
686
+ return;
687
+ }
688
+ const R = Ue(y.label, o);
689
+ d ? R && w.push(y) : R && c.push(y);
690
+ }), L(), c;
691
+ }, $e = (r) => {
692
+ const o = Ge(i, r);
693
+ if (Q(o), O) {
694
+ if (r === "") {
695
+ Ie();
696
+ return;
697
+ }
698
+ O(r);
699
+ return;
700
+ }
701
+ z && i && z(r);
702
+ }, Ie = U(() => {
703
+ if (K) {
704
+ K(), Q(
705
+ i.filter((r) => {
706
+ const o = x ? G(r, k) : r.id;
707
+ return ae.has(o);
708
+ })
709
+ );
710
+ return;
711
+ }
712
+ z && (z(""), Q(i));
713
+ }, [i, ae, k, K, Q, z, x]), Pe = (r) => {
714
+ r.key === "ArrowDown" ? (r.preventDefault(), p.current?.querySelector("[role=listitem]")?.focus()) : (r.key === "Tab" || r.key === "Escape") && setTimeout(() => {
715
+ J.current?.focus(), fe();
716
+ }, 10);
717
+ }, T = (r, o) => {
718
+ const c = Array.from(p.current?.querySelectorAll("[role=listitem]") || []), d = c.indexOf(r.currentTarget);
719
+ if (r.key === "ArrowDown") {
720
+ r.preventDefault();
721
+ const w = d < c.length - 1 ? d + 1 : d;
722
+ c[w]?.focus();
723
+ } else if (r.key === "ArrowUp")
724
+ if (r.preventDefault(), d === 0)
725
+ V && V.current?.focus();
726
+ else {
727
+ const w = d - 1;
728
+ c[w]?.focus();
729
+ }
730
+ else if (r.key === "Enter" || r.key === " ") {
731
+ if (r.preventDefault(), o.isGroupHeader || v) return;
732
+ se(o, !u), u || setTimeout(() => {
733
+ J.current?.focus(), fe();
734
+ }, 10);
735
+ } else r.key === "Escape" ? (r.preventDefault(), setTimeout(() => {
736
+ J.current?.focus(), fe();
737
+ }, 10)) : r.key === "Tab" && setTimeout(() => {
738
+ J.current?.focus(), fe();
739
+ }, 10);
740
+ }, Y = Array.from({ length: 5 }).map((r, o) => x ? Ne.createElement(
741
+ Z(
742
+ x,
743
+ (c, d) => c.isSelected === d.isSelected && c.option === d.option && c.disabled === d.disabled && c.multiple === d.multiple && c.renderContext === d.renderContext
744
+ ),
745
+ {
746
+ key: `skeleton-option-${o}`,
747
+ option: { id: o, label: "", value: "" },
748
+ isSelected: !1,
749
+ multiple: !1,
750
+ onSelect: () => {
751
+ },
752
+ disabled: !1,
753
+ isLoading: !0,
754
+ renderContext: S
755
+ }
756
+ ) : /* @__PURE__ */ s.jsx(
757
+ We,
758
+ {
759
+ multiple: !1,
760
+ isLoading: !0,
761
+ onSelect: () => {
762
+ },
763
+ isSelected: !1,
764
+ option: { id: o, label: "", value: "" }
765
+ },
766
+ `skeleton-option-${// biome-ignore lint/suspicious/noArrayIndexKey: <>
767
+ o}`
768
+ )), ge = /* @__PURE__ */ s.jsx(
769
+ "div",
770
+ {
771
+ tabIndex: 0,
772
+ ref: p,
773
+ style: { opacity: "0" },
774
+ className: f(
775
+ " z-100! w-full mt-1 bg-neutral-default-default border border-neutral-default-default rounded-lg shadow-lg",
776
+ " overflow-hidden focus-visible:bg-neutral-default-hover ",
777
+ E ? "absolute z-50 " : "fixed z-100 top-0 left-0",
778
+ he.direction === "up" ? "h-auto" : " h-max",
779
+ Ae
780
+ ),
781
+ children: /* @__PURE__ */ s.jsxs(
782
+ "div",
783
+ {
784
+ className: f(
785
+ "flex flex-col ",
786
+ Ce ? "p-0" : "p-2 pt-0 gap-2"
787
+ ),
788
+ style: {
789
+ height: "auto",
790
+ maxHeight: he.height
791
+ },
792
+ children: [
793
+ !Ce && /* @__PURE__ */ s.jsx(
794
+ tt,
795
+ {
796
+ name: "",
797
+ label: "",
798
+ size: "small",
799
+ tabIndex: 0,
800
+ value: I,
801
+ disabled: v,
802
+ ref: V,
803
+ labelVariant: "static",
804
+ icon: /* @__PURE__ */ s.jsx(je.Search, {}),
805
+ isFetching: ee,
806
+ onKeyDown: Pe,
807
+ onClear: Ie,
808
+ onChange: $e,
809
+ placeholder: ke,
810
+ className: " bg-neutral-medium-pressed",
811
+ ...j
812
+ }
813
+ ),
814
+ /* @__PURE__ */ s.jsx("div", { className: " overflow-y-auto flex-1 max-h-max ", children: de.length === 0 ? ee ? /* @__PURE__ */ s.jsx("div", { className: "flex flex-col gap-1 overflow-hidden w-full", children: He || Y }) : /* @__PURE__ */ s.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: I ? `No se encontraron resultados para "${I}"` : A }) : (() => {
815
+ let r = !0;
816
+ return de.map((o) => {
817
+ const c = o, d = !!c.isGroupHeader, w = x && !d ? G(o, k) : c.id, L = ae.has(w), y = (l) => !x || d ? l : {
818
+ id: w,
819
+ label: String(G(l, b)),
820
+ value: G(l, k)
821
+ }, R = (l) => {
822
+ d || se(y(o), l === void 0 ? !u : l);
823
+ }, q = (l) => {
824
+ if (se(l, !u), !u) {
825
+ if (!z) return;
826
+ z(""), Q(i);
827
+ }
828
+ }, re = (l, g) => {
829
+ const H = !!g.isGroupHeader;
830
+ return (
831
+ // biome-ignore lint/a11y/useSemanticElements: <>
832
+ /* @__PURE__ */ s.jsx(
833
+ "div",
834
+ {
835
+ tabIndex: 0,
836
+ role: "listitem",
837
+ onKeyDown: ($) => T($, g),
838
+ className: f(
839
+ !H && !v && "focus-visible:bg-neutral-medium-hover outline-none hover:bg-neutral-medium-hover",
840
+ L && "bg-neutral-medium-selected",
841
+ v && "cursor-default pointer-events-none"
842
+ ),
843
+ children: l
844
+ },
845
+ g.id
846
+ )
847
+ );
848
+ };
849
+ if (d) {
850
+ const l = c.groupLabelNode ?? c.label, g = String(c.id), H = X === !1 ? !0 : ze(g);
851
+ r = H;
852
+ const $ = c.originalOption, P = c.groupData?.groupOptions ?? [], le = (_) => {
853
+ X && Oe(g, _);
854
+ }, xe = (_) => {
855
+ !P || P.length === 0 || Se && Se(P, _);
856
+ }, ye = P.filter((_) => ae.has(G(_, k))).map((_) => String(G(_, k)));
857
+ if (M) {
858
+ const _ = Z(
859
+ M,
860
+ (D, B) => D.label === B.label && D.group === B.group && D.groupOptions === B.groupOptions && D.disabled === B.disabled && D.multiple === B.multiple && D.expanded === B.expanded && D.renderContext === B.renderContext
861
+ ), C = Ne.createElement(_, {
862
+ group: $,
863
+ label: l,
864
+ groupOptions: P,
865
+ multiple: u,
866
+ disabled: v,
867
+ expanded: H,
868
+ toggleGroup: le,
869
+ selectGroup: xe,
870
+ renderContext: S,
871
+ groupSelectedIds: ye
872
+ });
873
+ return re(C, c);
874
+ }
875
+ return re(
876
+ /* @__PURE__ */ s.jsxs(
877
+ "div",
878
+ {
879
+ className: "px-3 py-2 text-neutral-medium-default font-medium text-sm w-full flex justify-between",
880
+ children: [
881
+ /* @__PURE__ */ s.jsx("div", { children: l }),
882
+ X && /* @__PURE__ */ s.jsx("div", { className: "cursor-pointer", onClick: () => Oe(g), children: /* @__PURE__ */ s.jsx(
883
+ je.ChevronDown,
884
+ {
885
+ className: f(
886
+ "transition-transform duration-300 ease-out",
887
+ H ? "rotate-180" : "rotate-0"
888
+ )
889
+ }
890
+ ) })
891
+ ]
892
+ }
893
+ ),
894
+ c
895
+ );
896
+ }
897
+ const be = x ? Ne.createElement(
898
+ Z(
899
+ x,
900
+ (l, g) => l.isSelected === g.isSelected && l.option === g.option && l.disabled === g.disabled && l.multiple === g.multiple && l.renderContext === g.renderContext
901
+ ),
902
+ {
903
+ key: w,
904
+ option: o,
905
+ isSelected: L,
906
+ multiple: u,
907
+ onSelect: R,
908
+ disabled: v,
909
+ isLoading: ee,
910
+ renderContext: S
911
+ }
912
+ ) : /* @__PURE__ */ s.jsx(
913
+ We,
914
+ {
915
+ disabled: v,
916
+ multiple: u,
917
+ isLoading: ee,
918
+ isSelected: L,
919
+ onSelect: q,
920
+ option: o
921
+ },
922
+ w
923
+ ), ue = re(be, y(o));
924
+ if (!X)
925
+ return ue;
926
+ const t = !r, a = ue;
927
+ return Ne.cloneElement(
928
+ a,
929
+ {
930
+ className: f(
931
+ a.props.className,
932
+ "overflow-hidden transition-[max-height] duration-300 ease-out",
933
+ t ? "max-h-0" : "max-h-[999px]"
934
+ )
935
+ }
936
+ );
937
+ });
938
+ })() }),
939
+ e && /* @__PURE__ */ s.jsx("div", { className: "border-t border-neutral-strong-default p-2", children: e })
940
+ ]
941
+ }
942
+ )
943
+ }
944
+ );
945
+ return E ? ge : Ye(ge, document.body);
946
+ }
947
+ const ct = Z(ut, (e, n) => e.options === n.options && e.selectedOptionsIds === n.selectedOptionsIds && e.multiple === n.multiple && e.disabled === n.disabled && e.emptyMessage === n.emptyMessage && e.renderOption === n.renderOption && e.renderOptionContext === n.renderOptionContext && e.isOpen === n.isOpen && e.attachToParent === n.attachToParent && e.optionValue === n.optionValue && e.optionLabel === n.optionLabel && e.filteredOptions === n.filteredOptions && e.isLoading === n.isLoading), We = Z(({ option: e, isSelected: n, onSelect: m, multiple: i, disabled: u, isLoading: v }) => {
948
+ const h = e.isGroupHeader;
949
+ if (v)
950
+ return /* @__PURE__ */ s.jsxs("div", { className: "flex gap-2 w-full px-3 py-2 cursor-wait", children: [
951
+ /* @__PURE__ */ s.jsx(Fe, { className: "size-6 aspect-square" }),
952
+ /* @__PURE__ */ s.jsx(Fe, { className: "flex-1 h-6" })
953
+ ] }, e.id);
954
+ const j = (b) => {
955
+ b.preventDefault(), b.stopPropagation(), !(u || h) && m?.(e);
956
+ }, p = h && e.groupLabelNode ? e.groupLabelNode : e.label;
957
+ return (
958
+ // biome-ignore lint/a11y/noStaticElementInteractions: no keyboard interaction needed
959
+ /* @__PURE__ */ s.jsxs(
960
+ "div",
961
+ {
962
+ onMouseDown: j,
963
+ className: f(
964
+ "px-3 py-2 flex items-center transition-colors text-neutral-default-default ",
965
+ h ? "cursor-default text-neutral-medium-default" : "cursor-pointer",
966
+ !h && (n ? " text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover"),
967
+ u && !h && "text-neutral-default-disabled hover:bg-neutral-default-default"
968
+ ),
969
+ children: [
970
+ i && !h && /* @__PURE__ */ s.jsx(
971
+ rt,
972
+ {
973
+ checked: n,
974
+ disabled: u
975
+ }
976
+ ),
977
+ /* @__PURE__ */ s.jsx("span", { children: p })
978
+ ]
979
+ },
980
+ e.id
981
+ )
982
+ );
983
+ }, (e, n) => e.isSelected === n.isSelected && e.disabled === n.disabled);
984
+ We.displayName = "DefaultOptionRenderer";
985
+ const Je = Z(({ selectedOptions: e, placeholder: n, onRemoveOption: m, displayMode: i, multiple: u, className: v, disabled: h }) => e?.length === 0 ? n ? /* @__PURE__ */ s.jsx("span", { className: "text-neutral-medium-default opacity-50", children: n }) : null : i === "chips" && u ? /* @__PURE__ */ s.jsx("div", { className: f("flex items-center gap-1 ", v), children: e.map((j) => /* @__PURE__ */ s.jsx(
986
+ ot,
987
+ {
988
+ tabIndex: -1,
989
+ id: j.id,
990
+ label: j.label,
991
+ onRemove: m,
992
+ disabled: h
993
+ },
994
+ j.id
995
+ )) }) : e?.length === 1 ? /* @__PURE__ */ s.jsx("span", { children: e[0].label }) : /* @__PURE__ */ s.jsxs("span", { children: [
996
+ e?.length,
997
+ " seleccionados"
998
+ ] }), (e, n) => e.selectedOptions === n.selectedOptions && e.disabled === n.disabled);
999
+ Je.displayName = "DefaultSelectionDisplay";
1000
+ export {
1001
+ St as S,
1002
+ G as g
1003
+ };