prometeo-design-system 3.1.4 → 3.1.6

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