prometeo-design-system 2.5.0 → 2.5.2

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