prometeo-design-system 3.0.8 → 3.1.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.
@@ -1,7 +1,7 @@
1
1
  import { j as r } from "./jsx-runtime-DKDX3adD.js";
2
2
  import O, { useMemo as D, memo as b, useRef as M, useCallback as g, useState as L, useEffect as W } from "react";
3
3
  import { D as I } from "./DatePicker-D1EwMGIN.js";
4
- import { S as f } from "./Select-CRFOzYc6.js";
4
+ import { S as f } from "./Select-mdLPyy7g.js";
5
5
  import { I as R } from "./Input-EkMrxcNX.js";
6
6
  import _ from "./CheckBox.es.js";
7
7
  import { c as p } from "./cn-B6yFEsav.js";
@@ -1,6 +1,6 @@
1
1
  import { j as s } from "./jsx-runtime-DKDX3adD.js";
2
2
  import { c as f } from "./cn-B6yFEsav.js";
3
- import Ne, { memo as Z, useState as De, useRef as ce, useMemo as oe, useCallback as U, useEffect as ve, useImperativeHandle as Qe } from "react";
3
+ import Ne, { memo as Z, useState as je, useRef as ce, useMemo as oe, useCallback as U, useEffect as ve, useImperativeHandle as Qe } from "react";
4
4
  import Xe from "./Spinner.es.js";
5
5
  import { createPortal as Ye } from "react-dom";
6
6
  import { u as Ze } from "./useDragScroll-CHN9OMwn.js";
@@ -28,13 +28,13 @@ const at = {
28
28
  }, Fe = {
29
29
  icon: " text-neutral-default-disabled",
30
30
  container: " border-neutral-strong-default text-neutral-default-disabled"
31
- }, Ve = ({ id: e, label: n, onRemove: m, className: i, disabled: u, variant: v = "default", tabIndex: h }) => /* @__PURE__ */ s.jsxs(
31
+ }, Ve = ({ id: e, label: n, onRemove: m, className: i, disabled: u, variant: y = "default", tabIndex: p }) => /* @__PURE__ */ s.jsxs(
32
32
  "div",
33
33
  {
34
- tabIndex: h,
34
+ tabIndex: p,
35
35
  className: f(
36
36
  "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]",
37
- at[v].container,
37
+ at[y].container,
38
38
  u && Fe.container
39
39
  ),
40
40
  children: [
@@ -42,8 +42,8 @@ const at = {
42
42
  m && /* @__PURE__ */ s.jsx(
43
43
  "button",
44
44
  {
45
- onMouseDown: (j) => {
46
- u || (j.stopPropagation(), j.preventDefault(), m?.(e));
45
+ onMouseDown: (D) => {
46
+ u || (D.stopPropagation(), D.preventDefault(), m?.(e));
47
47
  },
48
48
  className: f(
49
49
  "shrink-0 p-0.5 transition-all duration-200 hover:text-neutral-default-hover cursor-pointer z-50 text-neutral-default-default hover:scale-105",
@@ -51,7 +51,7 @@ const at = {
51
51
  i
52
52
  ),
53
53
  type: "button",
54
- tabIndex: h,
54
+ tabIndex: p,
55
55
  children: /* @__PURE__ */ s.jsx(rt, { size: 18, className: f(u && Fe.icon) })
56
56
  }
57
57
  )
@@ -76,29 +76,29 @@ const qe = (e, n) => {
76
76
  if (!n) return !0;
77
77
  const m = 0.1, i = String(e).toLowerCase(), u = String(n).toLowerCase().trim();
78
78
  if (i.includes(u)) return !0;
79
- const v = u.split(/\s+/).filter(Boolean), h = v.filter((b) => /^\d+$/.test(b));
80
- if (v.length > 1 || h.length > 0) {
81
- for (const b of h)
79
+ const y = u.split(/\s+/).filter(Boolean), p = y.filter((b) => /^\d+$/.test(b));
80
+ if (y.length > 1 || p.length > 0) {
81
+ for (const b of p)
82
82
  if (!new RegExp(`(^|\\D)${b}(\\D|$)`).test(i)) return !1;
83
- for (const b of v)
83
+ for (const b of y)
84
84
  if (!/^\d+$/.test(b) && !i.includes(b))
85
85
  return !1;
86
86
  return !0;
87
87
  }
88
88
  if (u.length > i.length) return !1;
89
- const j = Math.floor(u.length * m);
90
- if (j <= 0) return !1;
91
- const p = (b, k) => {
89
+ const D = Math.floor(u.length * m);
90
+ if (D <= 0) return !1;
91
+ const g = (b, k) => {
92
92
  const I = b.length, W = k.length;
93
93
  if (I === 0) return W;
94
94
  if (W === 0) return I;
95
95
  const A = new Array(W + 1);
96
- for (let x = 0; x <= W; x++) A[x] = x;
97
- for (let x = 1; x <= I; x++) {
98
- let S = x - 1;
99
- A[0] = x;
96
+ for (let v = 0; v <= W; v++) A[v] = v;
97
+ for (let v = 1; v <= I; v++) {
98
+ let S = v - 1;
99
+ A[0] = v;
100
100
  for (let z = 1; z <= W; z++) {
101
- const se = A[z], K = b.charCodeAt(x - 1) === k.charCodeAt(z - 1) ? 0 : 1, V = A[z] + 1, M = A[z - 1] + 1, N = S + K;
101
+ const se = A[z], K = b.charCodeAt(v - 1) === k.charCodeAt(z - 1) ? 0 : 1, V = A[z] + 1, M = A[z - 1] + 1, N = S + K;
102
102
  A[z] = V < M ? V < N ? V : N : M < N ? M : N, S = se;
103
103
  }
104
104
  }
@@ -106,14 +106,14 @@ const qe = (e, n) => {
106
106
  };
107
107
  for (let b = 0; b <= i.length - u.length; b++) {
108
108
  const k = i.slice(b, b + u.length);
109
- if (p(k, u) <= j) return !0;
109
+ if (g(k, u) <= D) return !0;
110
110
  }
111
111
  return !1;
112
112
  }, ut = (e) => {
113
113
  const n = [], m = (i) => {
114
114
  i.forEach((u) => {
115
- const h = u.options;
116
- Array.isArray(h) && h.length > 0 ? m(h) : n.push(u);
115
+ const y = u, p = typeof y == "object" ? y?.options : [];
116
+ Array.isArray(p) && p.length > 0 ? m(p) : n.push(u);
117
117
  });
118
118
  };
119
119
  return m(e), n;
@@ -170,11 +170,11 @@ const qe = (e, n) => {
170
170
  )
171
171
  };
172
172
  function ct(e) {
173
- const [n, m] = De(!1), [i, u] = De([]), [v, h] = De(""), j = ce(null), p = ce(null), b = ce(null), k = ce(null), I = ce(
173
+ const [n, m] = je(!1), [i, u] = je([]), [y, p] = je(""), D = ce(null), g = ce(null), b = ce(null), k = ce(null), I = ce(
174
174
  () => {
175
175
  }
176
176
  ), W = ce(null), A = ce(/* @__PURE__ */ new Set()), {
177
- id: x,
177
+ id: v,
178
178
  name: S,
179
179
  label: z,
180
180
  height: se,
@@ -186,7 +186,7 @@ function ct(e) {
186
186
  optionLabel: de,
187
187
  renderOption: J,
188
188
  renderOptionGroupHeader: fe,
189
- renderSelection: je,
189
+ renderSelection: De,
190
190
  renderOptionContext: Ie,
191
191
  buttonClassName: He,
192
192
  dropdownClassName: ae,
@@ -210,9 +210,9 @@ function ct(e) {
210
210
  } = e, { ref: Oe } = et(), { bind: ne, ref: Me } = Ze({
211
211
  axis: "x",
212
212
  cursor: { idle: "default", dragging: "grabbing" }
213
- }), pe = e.multiple ? Array.isArray(e.value) && e.value.length > 0 : e.value !== void 0 && e.value !== null && e.value !== "", Le = {}, Te = oe(() => ie === "static" && N ? N : "", [ie, N]), Ge = oe(
214
- () => O?.controledSearchValue || v,
215
- [O?.controledSearchValue, v]
213
+ }), pe = e.multiple ? Array.isArray(e.value) && e.value.length > 0 && e.value.every((t) => t != null && t !== "") : e.value !== void 0 && e.value !== null && e.value !== "", Le = {}, Te = oe(() => ie === "static" && N ? N : "", [ie, N]), Ge = oe(
214
+ () => O?.controledSearchValue || y,
215
+ [O?.controledSearchValue, y]
216
216
  ), $e = () => {
217
217
  const t = {
218
218
  static: {
@@ -240,7 +240,7 @@ function ct(e) {
240
240
  if (e.multiple)
241
241
  e.value?.forEach((a) => {
242
242
  const l = Y?.find(
243
- (g) => G(g, E) === a
243
+ (h) => G(h, E) === a
244
244
  );
245
245
  l && t.push(l);
246
246
  });
@@ -260,9 +260,9 @@ function ct(e) {
260
260
  ), d = oe(() => {
261
261
  const t = [];
262
262
  return K.forEach((a, l) => {
263
- const g = a, H = g.options;
263
+ const h = a, H = typeof h == "object" ? h?.options : [];
264
264
  if (Array.isArray(H) && H.length > 0) {
265
- const $ = g.label, P = G(a, E), le = `__group-${String(P ?? l)}`, xe = {
265
+ const $ = h.label, P = G(a, E), le = `__group-${String(P ?? l)}`, xe = {
266
266
  id: le,
267
267
  value: le,
268
268
  label: typeof $ == "string" ? $ : String(P ?? `Grupo ${l + 1}`),
@@ -288,15 +288,15 @@ function ct(e) {
288
288
  if (!e.multiple) {
289
289
  const C = l[0];
290
290
  if (!C) return;
291
- const D = c.has(C.id), B = a ?? "toggle";
291
+ const j = c.has(C.id), B = a ?? "toggle";
292
292
  let Pe;
293
- B === "select" || B === "toggle" && !D ? Pe = C : Pe = void 0, e.onChange?.(Pe, S);
293
+ B === "select" || B === "toggle" && !j ? Pe = C : Pe = void 0, e.onChange?.(Pe, S);
294
294
  return;
295
295
  }
296
- const g = e.value || [], H = [];
297
- g.forEach((C) => {
298
- const D = ge.find((B) => B.value === C);
299
- D && H.push(D);
296
+ const h = e.value || [], H = [];
297
+ h.forEach((C) => {
298
+ const j = ge.find((B) => B.value === C);
299
+ j && H.push(j);
300
300
  });
301
301
  const $ = new Set(H.map((C) => C.id)), P = new Set(l.map((C) => C.id)), le = l.every(
302
302
  (C) => $.has(C.id)
@@ -306,10 +306,10 @@ function ct(e) {
306
306
  _ = H.filter((C) => !P.has(C.id));
307
307
  else {
308
308
  const C = new Map(
309
- H.map((D) => [D.id, D])
309
+ H.map((j) => [j.id, j])
310
310
  );
311
- l.forEach((D) => {
312
- C.set(D.id, D);
311
+ l.forEach((j) => {
312
+ C.set(j.id, j);
313
313
  }), _ = Array.from(C.values());
314
314
  }
315
315
  e.onChange?.(_, S);
@@ -330,18 +330,18 @@ function ct(e) {
330
330
  if (!e.multiple)
331
331
  e.onChange?.(t, S);
332
332
  else {
333
- const a = e.value || [], l = [], g = a.includes(t.value);
333
+ const a = e.value || [], l = [], h = a.includes(t.value);
334
334
  a.forEach(($) => {
335
335
  const P = ge.find(
336
336
  (le) => le.value === $
337
337
  );
338
338
  P && l.push(P);
339
339
  });
340
- const H = g ? l.filter(($) => $.value !== t.value) : [...l, t];
340
+ const H = h ? l.filter(($) => $.value !== t.value) : [...l, t];
341
341
  e.onChange?.(H, S);
342
342
  }
343
343
  };
344
- const y = U(
344
+ const x = U(
345
345
  (t, a = !1) => {
346
346
  X?.(t, S), I.current?.(t), a && (m(!1), Se?.());
347
347
  },
@@ -352,7 +352,7 @@ function ct(e) {
352
352
  (t) => {
353
353
  e.multiple || e.onChange?.(void 0, S);
354
354
  const a = Y.find(
355
- (g) => G(g, E) === t
355
+ (h) => G(h, E) === t
356
356
  );
357
357
  if (!a) return;
358
358
  const l = T(a);
@@ -379,11 +379,11 @@ function ct(e) {
379
379
  const t = (a) => {
380
380
  const l = a.target;
381
381
  if (a.type === "mousedown") {
382
- if (j.current?.contains(l) || p.current?.contains(l)) return;
382
+ if (D.current?.contains(l) || g.current?.contains(l)) return;
383
383
  m(!1);
384
384
  }
385
385
  if (a.type === "scroll") {
386
- if (p.current?.contains(l)) return;
386
+ if (g.current?.contains(l)) return;
387
387
  m(!1);
388
388
  }
389
389
  a.type === "resize" && m(!1);
@@ -408,13 +408,13 @@ function ct(e) {
408
408
  n && m(!1);
409
409
  },
410
410
  toggle: () => m((t) => !t),
411
- handleOptionSelect: y,
411
+ handleOptionSelect: x,
412
412
  subscribeOpenChange: (t) => (A.current.add(t), () => {
413
413
  A.current.delete(t);
414
414
  }),
415
415
  searchInputRef: b
416
416
  }),
417
- [n, y]
417
+ [n, x]
418
418
  );
419
419
  const be = (t) => {
420
420
  t.preventDefault(), t.stopPropagation(), t.target.matches(":focus-visible") && !ze && !n && (m(!0), setTimeout(() => {
@@ -429,7 +429,7 @@ function ct(e) {
429
429
  "div",
430
430
  {
431
431
  className: f("relative bg-inherit select-none w-full", M),
432
- ref: j,
432
+ ref: D,
433
433
  draggable: !1,
434
434
  style: Le,
435
435
  children: [
@@ -437,7 +437,7 @@ function ct(e) {
437
437
  /* @__PURE__ */ s.jsx(
438
438
  "label",
439
439
  {
440
- htmlFor: x,
440
+ htmlFor: v,
441
441
  ref: Oe,
442
442
  className: f(
443
443
  "left-3 pointer-events-none bg-inherit z-10",
@@ -452,7 +452,7 @@ function ct(e) {
452
452
  /* @__PURE__ */ s.jsxs(
453
453
  "div",
454
454
  {
455
- id: x,
455
+ id: v,
456
456
  tabIndex: 0,
457
457
  role: "button",
458
458
  ref: k,
@@ -484,9 +484,9 @@ function ct(e) {
484
484
  onPointerLeave: ne.onPointerLeave,
485
485
  onPointerCancel: ne.onPointerCancel,
486
486
  onClickCapture: ne.onClickCapture,
487
- children: je ? Ne.createElement(
487
+ children: De ? Ne.createElement(
488
488
  Z(
489
- je,
489
+ De,
490
490
  (t, a) => t.disabled === a.disabled && t.multiple === a.multiple
491
491
  ),
492
492
  {
@@ -577,14 +577,14 @@ function ct(e) {
577
577
  setFilteredOptions: u,
578
578
  renderOptionContext: Ie,
579
579
  options: d,
580
- selectRef: j,
581
- dropdownRef: p,
580
+ selectRef: D,
581
+ dropdownRef: g,
582
582
  selectButtonRef: k,
583
583
  helperComponentRef: W,
584
- onOptionClick: y,
584
+ onOptionClick: x,
585
585
  onCloseDropdown: () => m(!1),
586
586
  searchValue: Ge,
587
- setSearchValue: h,
587
+ setSearchValue: p,
588
588
  searchInputRef: b,
589
589
  isLoading: O?.isLoading,
590
590
  onSearchClear: O?.onSearchClear,
@@ -619,16 +619,16 @@ function ft({
619
619
  label: m,
620
620
  options: i,
621
621
  multiple: u,
622
- disabled: v,
623
- selectRef: h,
624
- inputProps: j,
625
- dropdownRef: p,
622
+ disabled: y,
623
+ selectRef: p,
624
+ inputProps: D,
625
+ dropdownRef: g,
626
626
  optionLabel: b,
627
627
  optionValue: k,
628
628
  searchValue: I,
629
629
  labelVariant: W,
630
630
  emptyMessage: A,
631
- renderOption: x,
631
+ renderOption: v,
632
632
  renderOptionContext: S,
633
633
  renderOptionGroupHeader: z,
634
634
  onOptionClick: se,
@@ -640,7 +640,7 @@ function ft({
640
640
  filteredOptions: de,
641
641
  selectButtonRef: J,
642
642
  onCloseDropdown: fe,
643
- loadingComponent: je,
643
+ loadingComponent: De,
644
644
  dropdownClassName: Ie,
645
645
  helperComponentRef: He,
646
646
  selectedOptionsIds: ae,
@@ -652,10 +652,10 @@ function ft({
652
652
  enableGroupToggle: X = !0,
653
653
  onGroupSelectChange: Se
654
654
  }) {
655
- const me = e ? 380 : 320, te = W === "static" ? m !== "" ? -20 : 4 : 7, F = U(() => N ? N.endsWith("px") ? Number(N.replace("px", "")) : N.endsWith("vh") ? window.innerHeight * Number(N.replace("vh", "")) / 100 : N.endsWith("%") ? window.innerHeight * Number(N.replace("%", "")) / 100 : me : me, [N, me])(), [he, Ae] = De({
655
+ const me = e ? 380 : 320, te = W === "static" ? m !== "" ? -20 : 4 : 7, F = U(() => N ? N.endsWith("px") ? Number(N.replace("px", "")) : N.endsWith("vh") ? window.innerHeight * Number(N.replace("vh", "")) / 100 : N.endsWith("%") ? window.innerHeight * Number(N.replace("%", "")) / 100 : me : me, [N, me])(), [he, Ae] = je({
656
656
  direction: "down",
657
657
  height: F
658
- }), [we, ie] = De(
658
+ }), [we, ie] = je(
659
659
  () => /* @__PURE__ */ new Set()
660
660
  ), ze = U(
661
661
  (r) => !we.has(r),
@@ -669,39 +669,39 @@ function ft({
669
669
  },
670
670
  []
671
671
  ), Oe = (r) => {
672
- if (!p.current || !h.current) return;
673
- const o = h.current.getBoundingClientRect();
672
+ if (!g.current || !p.current) return;
673
+ const o = p.current.getBoundingClientRect();
674
674
  switch (r || he.direction) {
675
675
  case "down":
676
- p.current.style.top = `${o.top + o.height - (He?.current?.offsetHeight ? He?.current?.offsetHeight + 4 : 0)}px`;
676
+ g.current.style.top = `${o.top + o.height - (He?.current?.offsetHeight ? He?.current?.offsetHeight + 4 : 0)}px`;
677
677
  break;
678
678
  case "up":
679
- p.current.style.top = "auto", p.current.style.bottom = `${window.innerHeight - o.top + te}px`;
679
+ g.current.style.top = "auto", g.current.style.bottom = `${window.innerHeight - o.top + te}px`;
680
680
  break;
681
681
  }
682
- p.current.style.left = `${o.left}px`, p.current.style.width = `${o.width}px`;
682
+ g.current.style.left = `${o.left}px`, g.current.style.width = `${o.width}px`;
683
683
  }, ne = (r) => {
684
- p.current && (p.current.style.maxHeight = `${r}px`);
684
+ g.current && (g.current.style.maxHeight = `${r}px`);
685
685
  }, Me = () => {
686
- if (!p.current || !h.current) return he;
687
- const r = h.current.getBoundingClientRect(), o = window.innerHeight - (window.innerHeight - r.top), c = window.innerHeight - r.bottom, d = c >= F, w = o >= F;
688
- let L = "down", y;
689
- return d ? (L = "down", y = F) : w ? (L = "up", y = F) : c > o ? (L = "down", y = c - 16) : (L = "up", y = o - 16), { direction: L, height: y };
686
+ if (!g.current || !p.current) return he;
687
+ const r = p.current.getBoundingClientRect(), o = window.innerHeight - (window.innerHeight - r.top), c = window.innerHeight - r.bottom, d = c >= F, w = o >= F;
688
+ let L = "down", x;
689
+ return d ? (L = "down", x = F) : w ? (L = "up", x = F) : c > o ? (L = "down", x = c - 16) : (L = "up", x = o - 16), { direction: L, height: x };
690
690
  }, pe = (r) => {
691
- if (!(!p.current || !h.current)) {
692
- if (p.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !r) {
693
- p.current.style.maxHeight = "0", p.current.style.opacity = "0", p.current.style.pointerEvents = "none";
691
+ if (!(!g.current || !p.current)) {
692
+ if (g.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !r) {
693
+ g.current.style.maxHeight = "0", g.current.style.opacity = "0", g.current.style.pointerEvents = "none";
694
694
  return;
695
695
  }
696
696
  if (!E) {
697
697
  const o = Me();
698
698
  Ae(o), Oe(o.direction), ne(o.height);
699
699
  }
700
- p.current.style.opacity = "1", p.current.style.pointerEvents = "auto";
700
+ g.current.style.opacity = "1", g.current.style.pointerEvents = "auto";
701
701
  }
702
702
  };
703
703
  ve(() => {
704
- E || !h.current || !n || Oe();
704
+ E || !p.current || !n || Oe();
705
705
  }, [ae]), ve(() => {
706
706
  pe(n);
707
707
  }, [n]), ve(() => {
@@ -713,37 +713,38 @@ function ft({
713
713
  }, [i]);
714
714
  const Le = (r, o) => {
715
715
  if (!o) return r;
716
- if (x) {
717
- const y = [];
716
+ if (v) {
717
+ const x = [];
718
718
  let R = null, q = [];
719
719
  const re = () => {
720
- R && q.length > 0 && y.push(R, ...q), R = null, q = [];
720
+ R && q.length > 0 && x.push(R, ...q), R = null, q = [];
721
721
  };
722
722
  return r.forEach((be) => {
723
723
  const ue = be;
724
- if (!!ue.isGroupHeader) {
724
+ if (!!(ue || {})?.isGroupHeader) {
725
725
  re(), R = ue;
726
726
  return;
727
727
  }
728
728
  const a = be, l = G(
729
729
  a,
730
730
  b
731
- ), g = qe(String(l ?? ""), o);
732
- R ? g && q.push(a) : g && y.push(a);
733
- }), re(), y;
731
+ ), h = qe(String(l ?? ""), o);
732
+ R ? h && q.push(a) : h && x.push(a);
733
+ }), re(), x;
734
734
  }
735
735
  const c = [];
736
736
  let d = null, w = [];
737
737
  const L = () => {
738
738
  d && w.length > 0 && c.push(d, ...w), d = null, w = [];
739
739
  };
740
- return r.forEach((y) => {
741
- if (y.isGroupHeader) {
742
- L(), d = y;
740
+ return r.forEach((x) => {
741
+ if (typeof x != "object" || x === null) return;
742
+ if ((x || {})?.isGroupHeader) {
743
+ L(), d = x;
743
744
  return;
744
745
  }
745
- const R = qe(y.label, o);
746
- d ? R && w.push(y) : R && c.push(y);
746
+ const R = qe(x.label, o);
747
+ d ? R && w.push(x) : R && c.push(x);
747
748
  }), L(), c;
748
749
  }, Te = (r) => {
749
750
  const o = Le(i, r);
@@ -760,7 +761,7 @@ function ft({
760
761
  if (K) {
761
762
  K(), Q(
762
763
  i.filter((r) => {
763
- const o = x ? G(r, k) : r.id;
764
+ const o = v ? G(r, k) : r.id;
764
765
  return ae.has(o);
765
766
  })
766
767
  );
@@ -774,16 +775,16 @@ function ft({
774
775
  K,
775
776
  Q,
776
777
  M,
777
- x
778
+ v
778
779
  ]), $e = (r) => {
779
- r.key === "ArrowDown" ? (r.preventDefault(), p.current?.querySelector(
780
+ r.key === "ArrowDown" ? (r.preventDefault(), g.current?.querySelector(
780
781
  "[role=listitem]"
781
782
  )?.focus()) : (r.key === "Tab" || r.key === "Escape") && setTimeout(() => {
782
783
  J.current?.focus(), fe();
783
784
  }, 10);
784
785
  }, T = (r, o) => {
785
786
  const c = Array.from(
786
- p.current?.querySelectorAll("[role=listitem]") || []
787
+ g.current?.querySelectorAll("[role=listitem]") || []
787
788
  ), d = c.indexOf(r.currentTarget);
788
789
  if (r.key === "ArrowDown") {
789
790
  r.preventDefault();
@@ -797,7 +798,7 @@ function ft({
797
798
  c[w]?.focus();
798
799
  }
799
800
  else if (r.key === "Enter" || r.key === " ") {
800
- if (r.preventDefault(), o.isGroupHeader || v) return;
801
+ if (r.preventDefault(), (o || {})?.isGroupHeader || y) return;
801
802
  se(o, !u), u || setTimeout(() => {
802
803
  J.current?.focus(), fe();
803
804
  }, 10);
@@ -807,8 +808,8 @@ function ft({
807
808
  J.current?.focus(), fe();
808
809
  }, 10);
809
810
  }, Y = Array.from({ length: 5 }).map(
810
- (r, o) => x ? Ne.createElement(
811
- Z(x, (c, d) => c.isSelected === d.isSelected && c.option === d.option && c.disabled === d.disabled && c.multiple === d.multiple && c.renderContext === d.renderContext),
811
+ (r, o) => v ? Ne.createElement(
812
+ Z(v, (c, d) => c.isSelected === d.isSelected && c.option === d.option && c.disabled === d.disabled && c.multiple === d.multiple && c.renderContext === d.renderContext),
812
813
  {
813
814
  key: `skeleton-option-${o}`,
814
815
  option: { id: o, label: "", value: "" },
@@ -837,7 +838,7 @@ function ft({
837
838
  "div",
838
839
  {
839
840
  tabIndex: 0,
840
- ref: p,
841
+ ref: g,
841
842
  style: { opacity: "0" },
842
843
  className: f(
843
844
  " z-100! w-full mt-1 bg-neutral-default-default border border-neutral-default-default rounded-lg shadow-lg",
@@ -866,7 +867,7 @@ function ft({
866
867
  size: "small",
867
868
  tabIndex: 0,
868
869
  value: I,
869
- disabled: v,
870
+ disabled: y,
870
871
  ref: V,
871
872
  labelVariant: "static",
872
873
  icon: /* @__PURE__ */ s.jsx(st, { size: 22 }),
@@ -876,19 +877,19 @@ function ft({
876
877
  onChange: (r) => Te(r.target.value),
877
878
  placeholder: Ee,
878
879
  className: " bg-neutral-medium-pressed",
879
- ...j
880
+ ...D
880
881
  }
881
882
  ),
882
- /* @__PURE__ */ s.jsx("div", { className: " overflow-y-auto flex-1 max-h-max ", children: de.length === 0 ? ee ? /* @__PURE__ */ s.jsx("div", { className: "flex flex-col gap-1 overflow-hidden w-full", children: je || Y }) : /* @__PURE__ */ s.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: I ? `No se encontraron resultados para "${I}"` : A }) : (() => {
883
+ /* @__PURE__ */ s.jsx("div", { className: " overflow-y-auto flex-1 max-h-max ", children: de.length === 0 ? ee ? /* @__PURE__ */ s.jsx("div", { className: "flex flex-col gap-1 overflow-hidden w-full", children: De || Y }) : /* @__PURE__ */ s.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: I ? `No se encontraron resultados para "${I}"` : A }) : (() => {
883
884
  let r = !0;
884
885
  return de.map((o) => {
885
- const c = o, d = !!c.isGroupHeader, w = x && !d ? G(o, k) : c.id, L = ae.has(w), y = (l) => !x || d ? l : {
886
+ const c = o, d = !!(c || {}).isGroupHeader, w = v && !d ? G(o, k) : c.id, L = ae.has(w), x = (l) => !v || d ? l : {
886
887
  id: w,
887
888
  label: String(G(l, b)),
888
889
  value: G(l, k)
889
890
  }, R = (l) => {
890
891
  d || se(
891
- y(o),
892
+ x(o),
892
893
  l === void 0 ? !u : l
893
894
  );
894
895
  }, q = (l) => {
@@ -896,8 +897,8 @@ function ft({
896
897
  if (!M) return;
897
898
  M(""), Q(i);
898
899
  }
899
- }, re = (l, g) => {
900
- const H = !!g.isGroupHeader;
900
+ }, re = (l, h) => {
901
+ const H = !!(h || {}).isGroupHeader;
901
902
  return (
902
903
  // biome-ignore lint/a11y/useSemanticElements: <>
903
904
  /* @__PURE__ */ s.jsx(
@@ -905,23 +906,23 @@ function ft({
905
906
  {
906
907
  tabIndex: 0,
907
908
  role: "listitem",
908
- onKeyDown: ($) => T($, g),
909
+ onKeyDown: ($) => T($, h),
909
910
  className: f(
910
- !H && !v && "focus-visible:bg-neutral-medium-hover outline-none hover:bg-neutral-medium-hover",
911
+ !H && !y && "focus-visible:bg-neutral-medium-hover outline-none hover:bg-neutral-medium-hover",
911
912
  L && "bg-neutral-medium-selected",
912
- v && "cursor-default pointer-events-none"
913
+ y && "cursor-default pointer-events-none"
913
914
  ),
914
915
  children: l
915
916
  },
916
- g.id
917
+ h.id
917
918
  )
918
919
  );
919
920
  };
920
921
  if (d) {
921
- const l = c.groupLabelNode ?? c.label, g = String(c.id), H = X === !1 ? !0 : ze(g);
922
+ const l = c.groupLabelNode ?? c.label, h = String(c.id), H = X === !1 ? !0 : ze(h);
922
923
  r = H;
923
924
  const $ = c.originalOption, P = c.groupData?.groupOptions ?? [], le = (_) => {
924
- X && ke(g, _);
925
+ X && ke(h, _);
925
926
  }, xe = (_) => {
926
927
  !P || P.length === 0 || Se && Se(P, _);
927
928
  }, ye = P.filter(
@@ -930,13 +931,13 @@ function ft({
930
931
  if (z) {
931
932
  const _ = Z(
932
933
  z,
933
- (D, B) => D.label === B.label && D.group === B.group && D.groupOptions === B.groupOptions && D.disabled === B.disabled && D.multiple === B.multiple && D.expanded === B.expanded && D.renderContext === B.renderContext
934
+ (j, B) => j.label === B.label && j.group === B.group && j.groupOptions === B.groupOptions && j.disabled === B.disabled && j.multiple === B.multiple && j.expanded === B.expanded && j.renderContext === B.renderContext
934
935
  ), C = Ne.createElement(_, {
935
936
  group: $,
936
937
  label: l,
937
938
  groupOptions: P,
938
939
  multiple: u,
939
- disabled: v,
940
+ disabled: y,
940
941
  expanded: H,
941
942
  toggleGroup: le,
942
943
  selectGroup: xe,
@@ -952,7 +953,7 @@ function ft({
952
953
  "div",
953
954
  {
954
955
  className: "cursor-pointer",
955
- onClick: () => ke(g),
956
+ onClick: () => ke(h),
956
957
  children: /* @__PURE__ */ s.jsx(
957
958
  Ue,
958
959
  {
@@ -968,10 +969,10 @@ function ft({
968
969
  c
969
970
  );
970
971
  }
971
- const be = x ? Ne.createElement(
972
+ const be = v ? Ne.createElement(
972
973
  Z(
973
- x,
974
- (l, g) => l.isSelected === g.isSelected && l.option === g.option && l.disabled === g.disabled && l.multiple === g.multiple && l.renderContext === g.renderContext
974
+ v,
975
+ (l, h) => l.isSelected === h.isSelected && l.option === h.option && l.disabled === h.disabled && l.multiple === h.multiple && l.renderContext === h.renderContext
975
976
  ),
976
977
  {
977
978
  key: w,
@@ -979,14 +980,14 @@ function ft({
979
980
  isSelected: L,
980
981
  multiple: u,
981
982
  onSelect: R,
982
- disabled: v,
983
+ disabled: y,
983
984
  isLoading: ee,
984
985
  renderContext: S
985
986
  }
986
987
  ) : /* @__PURE__ */ s.jsx(
987
988
  Be,
988
989
  {
989
- disabled: v,
990
+ disabled: y,
990
991
  multiple: u,
991
992
  isLoading: ee,
992
993
  isSelected: L,
@@ -996,7 +997,7 @@ function ft({
996
997
  w
997
998
  ), ue = re(
998
999
  be,
999
- y(o)
1000
+ x(o)
1000
1001
  );
1001
1002
  if (!X)
1002
1003
  return ue;
@@ -1010,7 +1011,7 @@ function ft({
1010
1011
  });
1011
1012
  });
1012
1013
  })() }),
1013
- e && /* @__PURE__ */ s.jsx("div", { className: "border-t border-neutral-strong-default p-2", children: e })
1014
+ e && e
1014
1015
  ]
1015
1016
  }
1016
1017
  )
@@ -1028,10 +1029,10 @@ const mt = Z(
1028
1029
  onSelect: m,
1029
1030
  multiple: i,
1030
1031
  disabled: u,
1031
- isLoading: v
1032
+ isLoading: y
1032
1033
  }) => {
1033
- const h = e.isGroupHeader;
1034
- if (v)
1034
+ const p = (e || {})?.isGroupHeader;
1035
+ if (y)
1035
1036
  return /* @__PURE__ */ s.jsxs(
1036
1037
  "div",
1037
1038
  {
@@ -1043,24 +1044,24 @@ const mt = Z(
1043
1044
  },
1044
1045
  e.id
1045
1046
  );
1046
- const j = (b) => {
1047
- b.preventDefault(), b.stopPropagation(), !(u || h) && m?.(e);
1048
- }, p = h && e.groupLabelNode ? e.groupLabelNode : e.label;
1047
+ const D = (b) => {
1048
+ b.preventDefault(), b.stopPropagation(), !(u || p) && m?.(e);
1049
+ }, g = p && e.groupLabelNode ? e.groupLabelNode : e.label;
1049
1050
  return (
1050
1051
  // biome-ignore lint/a11y/noStaticElementInteractions: no keyboard interaction needed
1051
1052
  /* @__PURE__ */ s.jsxs(
1052
1053
  "div",
1053
1054
  {
1054
- onMouseDown: j,
1055
+ onMouseDown: D,
1055
1056
  className: f(
1056
1057
  "px-3 py-2 flex items-center transition-colors text-neutral-default-default ",
1057
- h ? "cursor-default text-neutral-medium-default" : "cursor-pointer",
1058
- !h && (n ? " text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover"),
1059
- u && !h && "text-neutral-default-disabled hover:bg-neutral-default-default"
1058
+ p ? "cursor-default text-neutral-medium-default" : "cursor-pointer",
1059
+ !p && (n ? " text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover"),
1060
+ u && !p && "text-neutral-default-disabled hover:bg-neutral-default-default"
1060
1061
  ),
1061
1062
  children: [
1062
- i && !h && /* @__PURE__ */ s.jsx(lt, { checked: n, disabled: u }),
1063
- /* @__PURE__ */ s.jsx("span", { children: p })
1063
+ i && !p && /* @__PURE__ */ s.jsx(lt, { checked: n, disabled: u }),
1064
+ /* @__PURE__ */ s.jsx("span", { children: g })
1064
1065
  ]
1065
1066
  },
1066
1067
  e.id
@@ -1077,18 +1078,18 @@ const Je = Z(
1077
1078
  onRemoveOption: m,
1078
1079
  displayMode: i,
1079
1080
  multiple: u,
1080
- className: v,
1081
- disabled: h
1082
- }) => e?.length === 0 ? n ? /* @__PURE__ */ s.jsx("span", { className: "text-neutral-medium-default opacity-50", children: n }) : null : i === "chips" && u ? /* @__PURE__ */ s.jsx("div", { className: f("flex items-center gap-1 ", v), children: e.map((j) => /* @__PURE__ */ s.jsx(
1081
+ className: y,
1082
+ disabled: p
1083
+ }) => e?.length === 0 ? n ? /* @__PURE__ */ s.jsx("span", { className: "text-neutral-medium-default opacity-50", children: n }) : null : i === "chips" && u ? /* @__PURE__ */ s.jsx("div", { className: f("flex items-center gap-1 ", y), children: e.map((D) => /* @__PURE__ */ s.jsx(
1083
1084
  it,
1084
1085
  {
1085
1086
  tabIndex: -1,
1086
- id: j.id,
1087
- label: j.label,
1087
+ id: D.id,
1088
+ label: D.label,
1088
1089
  onRemove: m,
1089
- disabled: h
1090
+ disabled: p
1090
1091
  },
1091
- j.id
1092
+ D.id
1092
1093
  )) }) : e?.length === 1 ? /* @__PURE__ */ s.jsx("span", { children: e[0].label }) : /* @__PURE__ */ s.jsxs("span", { children: [
1093
1094
  e?.length,
1094
1095
  " seleccionados"
package/dist/Select.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as f } from "./Select-CRFOzYc6.js";
1
+ import { S as f } from "./Select-mdLPyy7g.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,247 +1,254 @@
1
- import { j as q } from "./jsx-runtime-DKDX3adD.js";
2
- import { g as l, S as G } from "./Select-CRFOzYc6.js";
3
- import { useState as T, useRef as I, useEffect as h, useMemo as H, useCallback as Q } from "react";
4
- function te(e) {
1
+ import { j as X } from "./jsx-runtime-DKDX3adD.js";
2
+ import { g as i, S as Y } from "./Select-mdLPyy7g.js";
3
+ import { useState as w, useRef as T, useEffect as m, useMemo as Z, useCallback as ee } from "react";
4
+ function re(e) {
5
5
  const {
6
6
  options: y,
7
- fetcher: u,
8
- asyncMode: V = "fetch_in_open",
9
- disabled: S = !1,
10
- debounceDelay: A = 500,
11
- minCharacters: _ = 3,
12
- optionLabel: d,
13
- optionValue: c,
14
- controlledValue: m,
15
- isOpen: x,
16
- inputRef: R,
17
- name: p
18
- } = e || {}, [O, j] = T(y || []), [J, C] = T(y || []), [a, k] = T(""), [E, o] = T(!1), [v, b] = T(!1), g = I(null), D = I(null), N = I(!1), F = I(u), M = e?.multiple === !0 || !1, w = I(M ? [] : void 0), [f, P] = T(M ? [] : void 0);
19
- h(() => {
20
- F.current = u;
21
- }, [u]), h(() => {
22
- m !== void 0 && P(m);
23
- }, [m]), h(() => {
24
- w.current = m !== void 0 ? m : f;
25
- }, [m, f]), h(() => {
26
- e?.options && (j(e.options), C(e.options));
7
+ fetcher: a,
8
+ asyncMode: p = "fetch_in_open",
9
+ disabled: O = !1,
10
+ debounceDelay: I = 500,
11
+ minCharacters: C = 3,
12
+ optionLabel: f,
13
+ optionValue: s,
14
+ controlledValue: b,
15
+ isOpen: F,
16
+ inputRef: k,
17
+ name: v
18
+ } = e || {}, j = y ? y.filter((t) => t != null) : [], [V, R] = w(j || []), [M, x] = w(j || []), [c, A] = w(""), [l, d] = w(!1), [g, P] = w(!1), E = T(null), N = T(null), z = T(!1), J = T(a), U = e?.multiple === !0 || !1, L = T(U ? [] : void 0), [h, D] = w(U ? [] : void 0);
19
+ m(() => {
20
+ J.current = a;
21
+ }, [a]), m(() => {
22
+ if (b !== void 0) {
23
+ const t = $(b, "value");
24
+ D(t);
25
+ }
26
+ }, [b]), m(() => {
27
+ L.current = b !== void 0 ? b : h;
28
+ }, [b, h]), m(() => {
29
+ if (e?.options) {
30
+ const t = e.options.filter((n) => n != null);
31
+ R(t), x(t);
32
+ }
27
33
  }, [e?.options]);
28
- const U = H(() => (t, n) => new Promise((r, i) => {
29
- g.current && clearTimeout(g.current), g.current = setTimeout(() => t(a).then(r).catch(i), n);
30
- }), [a]), X = (t) => {
31
- const n = m !== void 0, r = (i) => c ? l(i, c) : l(i, "id");
34
+ const B = Z(() => (t, n) => new Promise((o, r) => {
35
+ E.current && clearTimeout(E.current), E.current = setTimeout(() => t(c).then(o).catch(r), n);
36
+ }), [c]), te = (t) => {
37
+ const n = b !== void 0, o = (r) => s ? i(r, s) : i(r, "id");
32
38
  if (e?.multiple === !0) {
33
- const i = w.current || [];
34
- let s;
35
- i.some((L) => r(L) === r(t)) ? s = i.filter((L) => r(L) !== r(t)) : s = [...i, t], n ? (w.current = s, e?.onChange?.(s, p)) : (w.current = s, P(s), e?.onChange?.(s, p));
39
+ const r = L.current || [];
40
+ let u;
41
+ r.some((_) => o(_) === o(t)) ? u = r.filter((_) => o(_) !== o(t)) : u = [...r, t], n ? (L.current = u, e?.onChange?.(u, v)) : (L.current = u, D(u), e?.onChange?.(u, v));
36
42
  } else
37
- n ? (w.current = t, e?.onChange?.(t, p)) : (w.current = t, P(t), e?.onChange?.(t, p));
38
- }, W = (t) => (e?.onFetchingStart?.(), F.current?.(t) || Promise.resolve([])), K = Q((t, n) => t.length === 0 ? n : c ? n.filter((r) => !t.some((i) => l(i, c) === l(r, c))) : n.filter((r) => !t.some((i) => l(i, "id") === l(r, "id"))), [c]);
39
- h(() => {
43
+ n ? (L.current = t, e?.onChange?.(t, v)) : (L.current = t, D(t), e?.onChange?.(t, v));
44
+ }, q = (t) => (e?.onFetchingStart?.(), J.current?.(t) || Promise.resolve([])), $ = (t, n) => Array.isArray(t) ? (t.some((o) => typeof o != "object" || o === null) && console.debug(`El valor del ${n || "resultado del fetcher"} contiene elementos no válidos (null,undefined, no-object)`, t), t?.filter((o) => o != null) || []) : (console.debug(`El valor del ${n || "resultado del fetcher"} no es un Array (tipo de dato obtenido: ${typeof t})`), []), K = ee((t, n) => t.length === 0 ? n : s ? n.filter((o) => !t.some((r) => i(r, s) === i(o, s))) : n.filter((o) => !t.some((r) => i(r, "id") === i(o, "id"))), [s]);
45
+ m(() => {
40
46
  const t = e?.subscribeOpenChange;
41
47
  if (!t) return;
42
- const n = t((r) => {
43
- b(r);
48
+ const n = t((o) => {
49
+ P(o);
44
50
  });
45
51
  return () => {
46
52
  n && n();
47
53
  };
48
54
  }, [e?.subscribeOpenChange]);
49
- const $ = x !== void 0 ? x : v;
50
- h(() => {
51
- if (!S && F.current && V === "fetch_on_type") {
52
- if (!a || a === "" || a.length < _) {
53
- g.current && clearTimeout(g.current), o(!1);
55
+ const G = F !== void 0 ? F : g;
56
+ m(() => {
57
+ if (!O && J.current && p === "fetch_on_type") {
58
+ if (!c || c === "" || c.length < C) {
59
+ E.current && clearTimeout(E.current), d(!1);
54
60
  return;
55
61
  }
56
- const t = U(W, A);
57
- o(!0), t.then((n) => {
58
- if (!Array.isArray(n))
59
- return console.debug(`El resultado del fetcher no es un Array (tipo de resultado obtenido: ${typeof n})`), [];
60
- j(n);
62
+ const t = B(q, I);
63
+ d(!0), t.then((n) => {
64
+ const o = $(n);
65
+ R(o);
61
66
  }).finally(() => {
62
- o(!1), e?.onFetchingEnd?.();
67
+ d(!1), e?.onFetchingEnd?.();
63
68
  });
64
69
  }
65
- }, [V, a, S, A, U, _]), h(() => {
66
- if (!S)
67
- if ($) {
68
- if (e?.onOpen?.(), V === "fetch_in_open") {
69
- if (!F.current)
70
+ }, [p, c, O, I, B, C]), m(() => {
71
+ if (!O)
72
+ if (G) {
73
+ if (e?.onOpen?.(), p === "fetch_in_open") {
74
+ if (!J.current)
70
75
  return;
71
- o(!0), W().then((t) => {
72
- if (!Array.isArray(t))
73
- return console.debug(`El resultado del fetcher no es un Array (tipo de resultado obtenido: ${typeof t})`), [];
74
- j(() => {
75
- const n = t.filter((r) => {
76
- if (c)
77
- return l(r, c) !== void 0;
76
+ d(!0), q().then((t) => {
77
+ const n = $(t);
78
+ R(() => {
79
+ const o = n.filter((r) => {
80
+ if (s)
81
+ return i(r, s) !== void 0;
78
82
  });
79
- return M && f.length > 0 ? [...K(f, n), ...f] : n;
83
+ return U && h.length > 0 ? [...K(h, o), ...h] : o;
80
84
  });
81
85
  }).finally(() => {
82
- o(!1), e?.onFetchingEnd?.();
86
+ d(!1), e?.onFetchingEnd?.();
83
87
  });
84
88
  }
85
89
  } else
86
90
  e?.onClose?.();
87
- }, [$, V, S]);
88
- const z = (t, n) => t?.filter((r) => {
89
- if (d)
90
- return l(r, d)?.toLowerCase().includes(n.toLowerCase());
91
- switch (typeof r) {
92
- case "string":
93
- return r?.toLowerCase().includes(n.toLowerCase());
94
- case "number":
95
- return r.toString().includes(n);
96
- case "object":
97
- return Object.values(r).some((s) => s.toString()?.toLowerCase().includes(n.toLowerCase()));
98
- default:
99
- return !1;
91
+ }, [G, p, O]);
92
+ const H = (t, n) => t?.filter((o) => {
93
+ if (f)
94
+ return i(o, f)?.toLowerCase().includes(n.toLowerCase());
95
+ {
96
+ const r = o;
97
+ switch (typeof r) {
98
+ case "string":
99
+ return r?.toLowerCase().includes(n.toLowerCase());
100
+ case "number":
101
+ return r.toString().includes(n);
102
+ case "object":
103
+ return Object.values(r).some((S) => S.toString()?.toLowerCase().includes(n.toLowerCase()));
104
+ default:
105
+ return !1;
106
+ }
100
107
  }
101
- }) || [], Y = (t) => t?.sort((n, r) => {
102
- if (d)
103
- return l(n, d) < l(r, d) ? -1 : 1;
108
+ }) || [], ne = (t) => t?.sort((n, o) => {
109
+ if (f)
110
+ return i(n, f) < i(o, f) ? -1 : 1;
104
111
  {
105
- const s = ["label", "name", "value"].find((L) => typeof n == "object" && Object.keys(n).includes(L));
106
- switch (typeof n) {
112
+ const u = ["label", "name", "value"].find((W) => typeof n == "object" && Object.keys(n).includes(W)), S = n, _ = o;
113
+ switch (typeof S) {
107
114
  case "string":
108
- return n < r ? -1 : 1;
115
+ return S < _ ? -1 : 1;
109
116
  case "number":
110
- return n < r ? -1 : 1;
117
+ return S < _ ? -1 : 1;
111
118
  case "object":
112
- if (s) {
113
- const L = l(n, s), ee = l(r, s);
114
- return L < ee ? -1 : 1;
119
+ if (u) {
120
+ const W = i(n, u), oe = i(o, u);
121
+ return W < oe ? -1 : 1;
115
122
  } else
116
123
  return 1;
117
124
  default:
118
125
  return 1;
119
126
  }
120
127
  }
121
- }) || [], B = (t) => {
122
- const n = typeof R == "function" ? R() : R;
123
- t.target === n?.current && (D.current && clearTimeout(D.current), N.current || (N.current = !0, e?.onTypeStart?.()), D.current = setTimeout(() => {
124
- N.current = !1;
125
- }, A));
128
+ }) || [], Q = (t) => {
129
+ const n = typeof k == "function" ? k() : k;
130
+ t.target === n?.current && (N.current && clearTimeout(N.current), z.current || (z.current = !0, e?.onTypeStart?.()), N.current = setTimeout(() => {
131
+ z.current = !1;
132
+ }, I));
126
133
  };
127
- return h(() => {
128
- if (a === "")
129
- C(Y(O));
130
- else if (M) {
131
- const t = K(f, O);
132
- C([...z(t, a), ...f]);
134
+ return m(() => {
135
+ if (c === "")
136
+ x(ne(V));
137
+ else if (U) {
138
+ const t = K(h, V);
139
+ x([...H(t, c), ...h]);
133
140
  } else {
134
- const t = K([f], O);
135
- C([...z(t, a), f]);
141
+ const t = K([h], V);
142
+ x([...H(t, c), h]);
136
143
  }
137
- }, [O]), h(() => (document.addEventListener("keydown", B), () => {
138
- document.removeEventListener("keydown", B);
144
+ }, [V]), m(() => (document.addEventListener("keydown", Q), () => {
145
+ document.removeEventListener("keydown", Q);
139
146
  }), []), {
140
- inputValue: a,
141
- setInputValue: k,
147
+ inputValue: c,
148
+ setInputValue: A,
142
149
  cleanInputValue: () => {
143
- k("");
150
+ A("");
144
151
  },
145
- filteredOptions: J,
146
- isLoading: E,
147
- value: f,
148
- setValue: P,
149
- onOptionClick: X
152
+ filteredOptions: M,
153
+ isLoading: l,
154
+ value: h,
155
+ setValue: D,
156
+ onOptionClick: te
150
157
  };
151
158
  }
152
- const ie = (e) => {
153
- const y = I(null);
154
- h(() => {
159
+ const ae = (e) => {
160
+ const y = T(null);
161
+ m(() => {
155
162
  e.controls && (e.controls.current = y.current);
156
163
  }, [e.controls]);
157
- const { asyncMode: u = "fetch_in_open" } = e, V = (o, v, b) => {
158
- const g = {
159
- options: o.options,
160
- fetcher: o.fetcher,
161
- asyncMode: v,
162
- debounceDelay: o.debounceDelay,
163
- minCharacters: o.minCharacters,
164
- disabled: o.disabled,
165
- optionValue: o.optionValue,
166
- optionLabel: o.optionLabel,
164
+ const { asyncMode: a = "fetch_in_open" } = e, p = (l, d, g) => {
165
+ const P = {
166
+ options: l.options,
167
+ fetcher: l.fetcher,
168
+ asyncMode: d,
169
+ debounceDelay: l.debounceDelay,
170
+ minCharacters: l.minCharacters,
171
+ disabled: l.disabled,
172
+ optionValue: l.optionValue,
173
+ optionLabel: l.optionLabel,
167
174
  onFetchingStart: () => {
168
- v === "fetch_on_type" && b.current?.open();
175
+ d === "fetch_on_type" && g.current?.open();
169
176
  },
170
177
  onTypeStart: () => {
171
- !o?.fetcher && b.current?.open();
178
+ !l?.fetcher && g.current?.open();
172
179
  },
173
- inputRef: () => b.current?.searchInputRef,
174
- subscribeOpenChange: b.current?.subscribeOpenChange,
175
- name: o.name
180
+ inputRef: () => g.current?.searchInputRef,
181
+ subscribeOpenChange: g.current?.subscribeOpenChange,
182
+ name: l.name
176
183
  };
177
- return o.multiple ? {
178
- ...g,
184
+ return l.multiple ? {
185
+ ...P,
179
186
  multiple: !0,
180
- controlledValue: o.value,
181
- onChange: o.onChange
187
+ controlledValue: l.value,
188
+ onChange: l.onChange
182
189
  } : {
183
- ...g,
190
+ ...P,
184
191
  multiple: !1,
185
- controlledValue: o.value,
186
- onChange: o.onChange
192
+ controlledValue: l.value,
193
+ onChange: l.onChange
187
194
  };
188
- }, { inputValue: S, setInputValue: A, filteredOptions: _, isLoading: d, value: c, onOptionClick: m, cleanInputValue: x } = te(V(e, u, y)), R = Q(() => u === "fetch_on_type" ? d : !1, [u, d]), p = H(() => e.multiple ? c.map((o) => l(o, e.optionValue)) : c ? l(c, e.optionValue) : void 0, [c, e.optionValue, e.multiple]), O = (o) => {
189
- const v = _.find((b) => l(b, e.optionValue) === o.id);
190
- v && m(v);
191
- }, { displayMode: j = e.multiple ? "chips" : "compact", dropdownOptions: J, overflow: C = "scroll", onChange: a, ...k } = e.selectComponentProps || {}, E = {
192
- controledSearchValue: S,
193
- onSearchValueChange: u === "fetch_on_type" ? A : void 0,
194
- onSearchClear: u === "fetch_on_type" ? x : void 0,
195
+ }, { inputValue: O, setInputValue: I, filteredOptions: C, isLoading: f, value: s, onOptionClick: b, cleanInputValue: F } = re(p(e, a, y)), k = ee(() => a === "fetch_on_type" ? f : !1, [a, f]), v = Z(() => e.multiple ? s.map((l) => i(l, e.optionValue)) : s ? i(s, e.optionValue) : void 0, [s, e.optionValue, e.multiple]), j = (l) => {
196
+ const d = C.find((g) => i(g, e.optionValue) === l.id);
197
+ d && b(d);
198
+ }, { displayMode: V = e.multiple ? "chips" : "compact", dropdownOptions: R, overflow: M = "scroll", onChange: x, ...c } = e.selectComponentProps || {}, A = {
199
+ controledSearchValue: O,
200
+ onSearchValueChange: a === "fetch_on_type" ? I : void 0,
201
+ onSearchClear: a === "fetch_on_type" ? F : void 0,
195
202
  inputSearchPlaceholder: e.inputSearchPlaceholder,
196
- isLoading: R(),
197
- ...J || {}
203
+ isLoading: k(),
204
+ ...R || {}
198
205
  };
199
- return e.multiple ? /* @__PURE__ */ q.jsx(
200
- G,
206
+ return e.multiple ? /* @__PURE__ */ X.jsx(
207
+ Y,
201
208
  {
202
209
  disabled: e.disabled,
203
210
  className: e.className,
204
211
  name: e.name,
205
- overflow: C,
206
- ...k,
212
+ overflow: M,
213
+ ...c,
207
214
  multiple: !0,
208
- value: p,
215
+ value: v,
209
216
  label: e.label || "",
210
- options: _,
217
+ options: C,
211
218
  optionValue: e.optionValue,
212
219
  optionLabel: e.optionLabel,
213
220
  renderOption: e.renderOption,
214
- onOptionClick: O,
215
- displayMode: j,
221
+ onOptionClick: j,
222
+ displayMode: V,
216
223
  controls: y,
217
224
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
218
- dropdownOptions: E,
219
- isLoading: u === "fetch_in_open" ? d : !1
225
+ dropdownOptions: A,
226
+ isLoading: a === "fetch_in_open" ? f : !1
220
227
  }
221
- ) : /* @__PURE__ */ q.jsx(
222
- G,
228
+ ) : /* @__PURE__ */ X.jsx(
229
+ Y,
223
230
  {
224
231
  disabled: e.disabled,
225
- ...k,
232
+ ...c,
226
233
  className: e.className,
227
- overflow: C,
234
+ overflow: M,
228
235
  name: e.name,
229
236
  multiple: !1,
230
- value: p,
237
+ value: v,
231
238
  label: e.label || "",
232
- options: _,
239
+ options: C,
233
240
  optionValue: e.optionValue,
234
241
  optionLabel: e.optionLabel,
235
242
  renderOption: e.renderOption,
236
- onOptionClick: O,
243
+ onOptionClick: j,
237
244
  displayMode: "compact",
238
245
  controls: y,
239
246
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
240
- dropdownOptions: E,
241
- isLoading: u === "fetch_in_open" ? d : !1
247
+ dropdownOptions: A,
248
+ isLoading: a === "fetch_in_open" ? f : !1
242
249
  }
243
250
  );
244
251
  };
245
252
  export {
246
- ie as default
253
+ ae as default
247
254
  };
@@ -16,5 +16,5 @@ export interface AutocompleteProps<T> {
16
16
  disabled?: boolean;
17
17
  renderOption?: ComponentType<CustomSelectOptionRendererProps<T>>;
18
18
  }
19
- declare const Autocomplete: <T>(props: AutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
19
+ declare const Autocomplete: <T extends object>(props: AutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
20
20
  export default Autocomplete;
@@ -1,16 +1,16 @@
1
1
  import { OptionAccessor } from '../Shared/types';
2
- export interface UseAutocompleteOptionsMultiple<T> extends UseAutocompleteBaseOptions<T> {
2
+ export interface UseAutocompleteOptionsMultiple<T extends object> extends UseAutocompleteBaseOptions<T> {
3
3
  multiple: true;
4
4
  controlledValue?: T[];
5
5
  onChange?: (newValue: T[], name?: string) => void;
6
6
  }
7
- export interface UseAutocompleteOptionsSingle<T> extends UseAutocompleteBaseOptions<T> {
7
+ export interface UseAutocompleteOptionsSingle<T extends object> extends UseAutocompleteBaseOptions<T> {
8
8
  multiple?: false;
9
9
  controlledValue?: T;
10
10
  onChange?: (newValue: T, name?: string) => void;
11
11
  }
12
- export interface UseAutocompleteBaseOptions<T> {
13
- options?: T[];
12
+ export interface UseAutocompleteBaseOptions<T extends object> {
13
+ options?: (T | undefined | null)[];
14
14
  fetcher?: (input?: string) => Promise<T[]>;
15
15
  asyncMode?: 'fetch_in_open' | 'fetch_on_type';
16
16
  disabled?: boolean;
@@ -28,8 +28,8 @@ export interface UseAutocompleteBaseOptions<T> {
28
28
  subscribeOpenChange?: (cb: (open: boolean) => void) => (() => void) | undefined;
29
29
  name?: string;
30
30
  }
31
- export type UseAutocompleteOptions<T> = UseAutocompleteOptionsMultiple<T> | UseAutocompleteOptionsSingle<T>;
32
- export declare function useAutocomplete<T>(options?: UseAutocompleteOptions<T>): {
31
+ export type UseAutocompleteOptions<T extends object> = UseAutocompleteOptionsMultiple<T> | UseAutocompleteOptionsSingle<T>;
32
+ export declare function useAutocomplete<T extends object>(options?: UseAutocompleteOptions<T>): {
33
33
  inputValue: string;
34
34
  setInputValue: import('react').Dispatch<import('react').SetStateAction<string>>;
35
35
  cleanInputValue: () => void;
@@ -1,17 +1,17 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { CustomSelectionDisplayProps, CustomSelectOptionRendererProps, SelectControlsHandler, SelectProps } from '../Select/Select';
3
3
  import { OptionAccessor } from '../Shared/types';
4
- interface SimpleSelectSearchProps<T> extends BaseSelectSearchProps<T> {
4
+ interface SimpleSelectSearchProps<T extends object> extends BaseSelectSearchProps<T> {
5
5
  multiple?: false;
6
6
  value?: T | undefined;
7
7
  onChange?: (newValue: T, name?: string) => void;
8
8
  }
9
- interface MultipleSelectSearchProps<T> extends BaseSelectSearchProps<T> {
9
+ interface MultipleSelectSearchProps<T extends object> extends BaseSelectSearchProps<T> {
10
10
  multiple: true;
11
11
  value?: T[];
12
12
  onChange?: (newValue: T[], name?: string) => void;
13
13
  }
14
- export interface BaseSelectSearchProps<T> {
14
+ export interface BaseSelectSearchProps<T extends object> {
15
15
  label?: string;
16
16
  placeholder?: string;
17
17
  name?: string;
@@ -31,6 +31,6 @@ export interface BaseSelectSearchProps<T> {
31
31
  controls?: React.RefObject<SelectControlsHandler | null>;
32
32
  selectComponentProps?: Partial<Omit<SelectProps<T>, 'controls'>>;
33
33
  }
34
- export type SelectSearchProps<T> = SimpleSelectSearchProps<T> | MultipleSelectSearchProps<T>;
35
- declare const SelectSearch: <T>(props: SelectSearchProps<T>) => import("react/jsx-runtime").JSX.Element;
34
+ export type SelectSearchProps<T extends object> = SimpleSelectSearchProps<T> | MultipleSelectSearchProps<T>;
35
+ declare const SelectSearch: <T extends object>(props: SelectSearchProps<T>) => import("react/jsx-runtime").JSX.Element;
36
36
  export default SelectSearch;
@@ -13,7 +13,7 @@ import { default as Ke } from "./Menu.es.js";
13
13
  import { default as Ye } from "./Pagination.es.js";
14
14
  import { default as tt } from "./ProfilePictureUpload.es.js";
15
15
  import { default as rt } from "./ProgressBar.es.js";
16
- import { S as nt } from "./Select-CRFOzYc6.js";
16
+ import { S as nt } from "./Select-mdLPyy7g.js";
17
17
  import { default as it } from "./Spinner.es.js";
18
18
  import { default as ct } from "./Steps.es.js";
19
19
  import { default as dt } from "./SwipeContainer.es.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prometeo-design-system",
3
3
  "private": false,
4
- "version": "3.0.8",
4
+ "version": "3.1.0",
5
5
  "type": "module",
6
6
  "description": "design kit system",
7
7
  "main": "dist/prometeo-design-system.umd.js",