prometeo-design-system 2.6.1 → 2.6.3

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