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