prometeo-design-system 3.0.9 → 3.1.1

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-DYuTa7Cm.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";
@@ -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: x = "default", tabIndex: p }) => /* @__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
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[x].container,
37
+ at[y].container,
38
38
  u && Fe.container
39
39
  ),
40
40
  children: [
@@ -76,11 +76,11 @@ 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 x = u.split(/\s+/).filter(Boolean), p = x.filter((b) => /^\d+$/.test(b));
80
- if (x.length > 1 || p.length > 0) {
79
+ const y = u.split(/\s+/).filter(Boolean), p = y.filter((b) => /^\d+$/.test(b));
80
+ if (y.length > 1 || p.length > 0) {
81
81
  for (const b of p)
82
82
  if (!new RegExp(`(^|\\D)${b}(\\D|$)`).test(i)) return !1;
83
- for (const b of x)
83
+ for (const b of y)
84
84
  if (!/^\d+$/.test(b) && !i.includes(b))
85
85
  return !1;
86
86
  return !0;
@@ -93,12 +93,12 @@ const qe = (e, n) => {
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 y = 0; y <= W; y++) A[y] = y;
97
- for (let y = 1; y <= I; y++) {
98
- let S = y - 1;
99
- A[0] = y;
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(y - 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
  }
@@ -112,7 +112,7 @@ const qe = (e, n) => {
112
112
  }, ut = (e) => {
113
113
  const n = [], m = (i) => {
114
114
  i.forEach((u) => {
115
- const x = u, p = typeof x == "object" ? x?.options : [];
115
+ const y = u, p = typeof y == "object" ? y?.options : [];
116
116
  Array.isArray(p) && p.length > 0 ? m(p) : n.push(u);
117
117
  });
118
118
  };
@@ -170,11 +170,11 @@ const qe = (e, n) => {
170
170
  )
171
171
  };
172
172
  function ct(e) {
173
- const [n, m] = je(!1), [i, u] = je([]), [x, p] = je(""), D = ce(null), g = 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: y,
177
+ id: v,
178
178
  name: S,
179
179
  label: z,
180
180
  height: se,
@@ -211,8 +211,8 @@ function ct(e) {
211
211
  axis: "x",
212
212
  cursor: { idle: "default", dragging: "grabbing" }
213
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 || x,
215
- [O?.controledSearchValue, x]
214
+ () => O?.controledSearchValue || y,
215
+ [O?.controledSearchValue, y]
216
216
  ), $e = () => {
217
217
  const t = {
218
218
  static: {
@@ -341,7 +341,7 @@ function ct(e) {
341
341
  e.onChange?.(H, S);
342
342
  }
343
343
  };
344
- const v = U(
344
+ const x = U(
345
345
  (t, a = !1) => {
346
346
  X?.(t, S), I.current?.(t), a && (m(!1), Se?.());
347
347
  },
@@ -408,13 +408,13 @@ function ct(e) {
408
408
  n && m(!1);
409
409
  },
410
410
  toggle: () => m((t) => !t),
411
- handleOptionSelect: v,
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, v]
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(() => {
@@ -437,7 +437,7 @@ function ct(e) {
437
437
  /* @__PURE__ */ s.jsx(
438
438
  "label",
439
439
  {
440
- htmlFor: y,
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: y,
455
+ id: v,
456
456
  tabIndex: 0,
457
457
  role: "button",
458
458
  ref: k,
@@ -581,7 +581,7 @@ function ct(e) {
581
581
  dropdownRef: g,
582
582
  selectButtonRef: k,
583
583
  helperComponentRef: W,
584
- onOptionClick: v,
584
+ onOptionClick: x,
585
585
  onCloseDropdown: () => m(!1),
586
586
  searchValue: Ge,
587
587
  setSearchValue: p,
@@ -619,7 +619,7 @@ function ft({
619
619
  label: m,
620
620
  options: i,
621
621
  multiple: u,
622
- disabled: x,
622
+ disabled: y,
623
623
  selectRef: p,
624
624
  inputProps: D,
625
625
  dropdownRef: g,
@@ -628,7 +628,7 @@ function ft({
628
628
  searchValue: I,
629
629
  labelVariant: W,
630
630
  emptyMessage: A,
631
- renderOption: y,
631
+ renderOption: v,
632
632
  renderOptionContext: S,
633
633
  renderOptionGroupHeader: z,
634
634
  onOptionClick: se,
@@ -685,8 +685,8 @@ function ft({
685
685
  }, Me = () => {
686
686
  if (!g.current || !p.current) return he;
687
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", v;
689
- return d ? (L = "down", v = F) : w ? (L = "up", v = F) : c > o ? (L = "down", v = c - 16) : (L = "up", v = o - 16), { direction: L, height: v };
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
691
  if (!(!g.current || !p.current)) {
692
692
  if (g.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !r) {
@@ -713,15 +713,15 @@ function ft({
713
713
  }, [i]);
714
714
  const Le = (r, o) => {
715
715
  if (!o) return r;
716
- if (y) {
717
- const v = [];
716
+ if (v) {
717
+ const x = [];
718
718
  let R = null, q = [];
719
719
  const re = () => {
720
- R && q.length > 0 && v.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
  }
@@ -729,21 +729,22 @@ function ft({
729
729
  a,
730
730
  b
731
731
  ), h = qe(String(l ?? ""), o);
732
- R ? h && q.push(a) : h && v.push(a);
733
- }), re(), v;
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((v) => {
741
- if (v.isGroupHeader) {
742
- L(), d = v;
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(v.label, o);
746
- d ? R && w.push(v) : R && c.push(v);
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 = y ? 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,7 +775,7 @@ function ft({
774
775
  K,
775
776
  Q,
776
777
  M,
777
- y
778
+ v
778
779
  ]), $e = (r) => {
779
780
  r.key === "ArrowDown" ? (r.preventDefault(), g.current?.querySelector(
780
781
  "[role=listitem]"
@@ -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 || x) 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) => y ? Ne.createElement(
811
- Z(y, (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: "" },
@@ -866,7 +867,7 @@ function ft({
866
867
  size: "small",
867
868
  tabIndex: 0,
868
869
  value: I,
869
- disabled: x,
870
+ disabled: y,
870
871
  ref: V,
871
872
  labelVariant: "static",
872
873
  icon: /* @__PURE__ */ s.jsx(st, { size: 22 }),
@@ -882,13 +883,13 @@ function ft({
882
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 = y && !d ? G(o, k) : c.id, L = ae.has(w), v = (l) => !y || 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
- v(o),
892
+ x(o),
892
893
  l === void 0 ? !u : l
893
894
  );
894
895
  }, q = (l) => {
@@ -897,7 +898,7 @@ function ft({
897
898
  M(""), Q(i);
898
899
  }
899
900
  }, re = (l, h) => {
900
- const H = !!h.isGroupHeader;
901
+ const H = !!(h || {}).isGroupHeader;
901
902
  return (
902
903
  // biome-ignore lint/a11y/useSemanticElements: <>
903
904
  /* @__PURE__ */ s.jsx(
@@ -907,9 +908,9 @@ function ft({
907
908
  role: "listitem",
908
909
  onKeyDown: ($) => T($, h),
909
910
  className: f(
910
- !H && !x && "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
- x && "cursor-default pointer-events-none"
913
+ y && "cursor-default pointer-events-none"
913
914
  ),
914
915
  children: l
915
916
  },
@@ -936,7 +937,7 @@ function ft({
936
937
  label: l,
937
938
  groupOptions: P,
938
939
  multiple: u,
939
- disabled: x,
940
+ disabled: y,
940
941
  expanded: H,
941
942
  toggleGroup: le,
942
943
  selectGroup: xe,
@@ -968,9 +969,9 @@ function ft({
968
969
  c
969
970
  );
970
971
  }
971
- const be = y ? Ne.createElement(
972
+ const be = v ? Ne.createElement(
972
973
  Z(
973
- y,
974
+ v,
974
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
  {
@@ -979,14 +980,14 @@ function ft({
979
980
  isSelected: L,
980
981
  multiple: u,
981
982
  onSelect: R,
982
- disabled: x,
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: x,
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
- v(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: x
1032
+ isLoading: y
1032
1033
  }) => {
1033
- const p = e.isGroupHeader;
1034
- if (x)
1034
+ const p = (e || {})?.isGroupHeader;
1035
+ if (y)
1035
1036
  return /* @__PURE__ */ s.jsxs(
1036
1037
  "div",
1037
1038
  {
@@ -1077,9 +1078,9 @@ const Je = Z(
1077
1078
  onRemoveOption: m,
1078
1079
  displayMode: i,
1079
1080
  multiple: u,
1080
- className: x,
1081
+ className: y,
1081
1082
  disabled: p
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 ", x), children: e.map((D) => /* @__PURE__ */ s.jsx(
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,
package/dist/Select.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as f } from "./Select-DYuTa7Cm.js";
1
+ import { S as f } from "./Select-mdLPyy7g.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,247 +1,261 @@
1
- import { j as q } from "./jsx-runtime-DKDX3adD.js";
2
- import { g as l, S as G } from "./Select-DYuTa7Cm.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 k, useRef as j, useEffect as m, useMemo as Z, useCallback as ee } from "react";
4
+ function le(e) {
5
5
  const {
6
- options: y,
6
+ options: p,
7
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));
8
+ asyncMode: C = "fetch_in_open",
9
+ disabled: V = !1,
10
+ debounceDelay: R = 500,
11
+ minCharacters: L = 3,
12
+ optionLabel: h,
13
+ optionValue: s,
14
+ controlledValue: c,
15
+ isOpen: P,
16
+ inputRef: x,
17
+ name: S
18
+ } = e || {}, A = p ? p.filter((t) => t != null) : [], [v, _] = k(A || []), [D, y] = k(A || []), [d, E] = k(""), [J, l] = k(!1), [O, b] = k(!1), g = j(null), N = j(null), z = j(!1), U = j(u), F = e?.multiple === !0 || !1, w = j(F ? [] : void 0), [f, M] = k(F ? [] : void 0);
19
+ m(() => {
20
+ U.current = u;
21
+ }, [u]), m(() => {
22
+ if (c !== void 0)
23
+ if (F) {
24
+ const t = $(c, "value");
25
+ M(t);
26
+ } else
27
+ c != null && M(c);
28
+ }, [c]), m(() => {
29
+ w.current = c !== void 0 ? c : f;
30
+ }, [c, f]), m(() => {
31
+ if (e?.options) {
32
+ const t = e.options.filter((n) => n != null);
33
+ _(t), y(t);
34
+ }
27
35
  }, [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");
36
+ const B = Z(() => (t, n) => new Promise((o, r) => {
37
+ g.current && clearTimeout(g.current), g.current = setTimeout(() => t(d).then(o).catch(r), n);
38
+ }), [d]), te = (t) => {
39
+ const n = c !== void 0, o = (r) => s ? i(r, s) : i(r, "id");
32
40
  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));
41
+ const r = w.current || [];
42
+ let a;
43
+ r.some((I) => o(I) === o(t)) ? a = r.filter((I) => o(I) !== o(t)) : a = [...r, t], n ? (w.current = a, e?.onChange?.(a, S)) : (w.current = a, M(a), e?.onChange?.(a, S));
36
44
  } 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(() => {
45
+ n ? (w.current = t, e?.onChange?.(t, S)) : (w.current = t, M(t), e?.onChange?.(t, S));
46
+ }, q = (t) => (e?.onFetchingStart?.(), U.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]);
47
+ m(() => {
40
48
  const t = e?.subscribeOpenChange;
41
49
  if (!t) return;
42
- const n = t((r) => {
43
- b(r);
50
+ const n = t((o) => {
51
+ b(o);
44
52
  });
45
53
  return () => {
46
54
  n && n();
47
55
  };
48
56
  }, [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);
57
+ const G = P !== void 0 ? P : O;
58
+ m(() => {
59
+ if (!V && U.current && C === "fetch_on_type") {
60
+ if (!d || d === "" || d.length < L) {
61
+ g.current && clearTimeout(g.current), l(!1);
54
62
  return;
55
63
  }
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);
64
+ const t = B(q, R);
65
+ l(!0), t.then((n) => {
66
+ const o = $(n);
67
+ _(o);
61
68
  }).finally(() => {
62
- o(!1), e?.onFetchingEnd?.();
69
+ l(!1), e?.onFetchingEnd?.();
63
70
  });
64
71
  }
65
- }, [V, a, S, A, U, _]), h(() => {
66
- if (!S)
67
- if ($) {
68
- if (e?.onOpen?.(), V === "fetch_in_open") {
69
- if (!F.current)
72
+ }, [C, d, V, R, B, L]), m(() => {
73
+ if (!V)
74
+ if (G) {
75
+ if (e?.onOpen?.(), C === "fetch_in_open") {
76
+ if (!U.current)
70
77
  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;
78
+ l(!0), q().then((t) => {
79
+ const n = $(t);
80
+ _(() => {
81
+ const o = n.filter((r) => {
82
+ if (s)
83
+ return i(r, s) !== void 0;
78
84
  });
79
- return M && f.length > 0 ? [...K(f, n), ...f] : n;
85
+ return F && f.length > 0 ? [...K(f, o), ...f] : o;
80
86
  });
81
87
  }).finally(() => {
82
- o(!1), e?.onFetchingEnd?.();
88
+ l(!1), e?.onFetchingEnd?.();
83
89
  });
84
90
  }
85
91
  } else
86
92
  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;
93
+ }, [G, C, V]);
94
+ const H = (t, n) => t?.filter((o) => {
95
+ if (h)
96
+ return i(o, h)?.toLowerCase().includes(n.toLowerCase());
97
+ {
98
+ const r = o;
99
+ switch (typeof r) {
100
+ case "string":
101
+ return r?.toLowerCase().includes(n.toLowerCase());
102
+ case "number":
103
+ return r.toString().includes(n);
104
+ case "object":
105
+ return Object.values(r).some((T) => T.toString()?.toLowerCase().includes(n.toLowerCase()));
106
+ default:
107
+ return !1;
108
+ }
100
109
  }
101
- }) || [], Y = (t) => t?.sort((n, r) => {
102
- if (d)
103
- return l(n, d) < l(r, d) ? -1 : 1;
110
+ }) || [], ne = (t) => t?.sort((n, o) => {
111
+ if (h)
112
+ return i(n, h) < i(o, h) ? -1 : 1;
104
113
  {
105
- const s = ["label", "name", "value"].find((L) => typeof n == "object" && Object.keys(n).includes(L));
106
- switch (typeof n) {
114
+ const a = ["label", "name", "value"].find((W) => typeof n == "object" && Object.keys(n).includes(W)), T = n, I = o;
115
+ switch (typeof T) {
107
116
  case "string":
108
- return n < r ? -1 : 1;
117
+ return T < I ? -1 : 1;
109
118
  case "number":
110
- return n < r ? -1 : 1;
119
+ return T < I ? -1 : 1;
111
120
  case "object":
112
- if (s) {
113
- const L = l(n, s), ee = l(r, s);
114
- return L < ee ? -1 : 1;
121
+ if (a) {
122
+ const W = i(n, a), oe = i(o, a);
123
+ return W < oe ? -1 : 1;
115
124
  } else
116
125
  return 1;
117
126
  default:
118
127
  return 1;
119
128
  }
120
129
  }
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));
130
+ }) || [], Q = (t) => {
131
+ const n = typeof x == "function" ? x() : x;
132
+ t.target === n?.current && (N.current && clearTimeout(N.current), z.current || (z.current = !0, e?.onTypeStart?.()), N.current = setTimeout(() => {
133
+ z.current = !1;
134
+ }, R));
126
135
  };
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]);
136
+ return m(() => {
137
+ if (d === "")
138
+ y(ne(v));
139
+ else if (F) {
140
+ const t = K(f, v);
141
+ y([...H(t, d), ...f]);
133
142
  } else {
134
- const t = K([f], O);
135
- C([...z(t, a), f]);
143
+ const t = K([f], v);
144
+ y([...H(t, d), f]);
136
145
  }
137
- }, [O]), h(() => (document.addEventListener("keydown", B), () => {
138
- document.removeEventListener("keydown", B);
146
+ }, [v]), m(() => (document.addEventListener("keydown", Q), () => {
147
+ document.removeEventListener("keydown", Q);
139
148
  }), []), {
140
- inputValue: a,
141
- setInputValue: k,
149
+ inputValue: d,
150
+ setInputValue: E,
142
151
  cleanInputValue: () => {
143
- k("");
152
+ E("");
153
+ },
154
+ cleanOptions: () => {
155
+ _(f);
144
156
  },
145
- filteredOptions: J,
146
- isLoading: E,
157
+ filteredOptions: D,
158
+ isLoading: J,
147
159
  value: f,
148
- setValue: P,
149
- onOptionClick: X
160
+ setValue: M,
161
+ onOptionClick: te
150
162
  };
151
163
  }
152
- const ie = (e) => {
153
- const y = I(null);
154
- h(() => {
155
- e.controls && (e.controls.current = y.current);
164
+ const de = (e) => {
165
+ const p = j(null);
166
+ m(() => {
167
+ e.controls && (e.controls.current = p.current);
156
168
  }, [e.controls]);
157
- const { asyncMode: u = "fetch_in_open" } = e, V = (o, v, b) => {
169
+ const { asyncMode: u = "fetch_in_open" } = e, C = (l, O, b) => {
158
170
  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,
171
+ options: l.options,
172
+ fetcher: l.fetcher,
173
+ asyncMode: O,
174
+ debounceDelay: l.debounceDelay,
175
+ minCharacters: l.minCharacters,
176
+ disabled: l.disabled,
177
+ optionValue: l.optionValue,
178
+ optionLabel: l.optionLabel,
167
179
  onFetchingStart: () => {
168
- v === "fetch_on_type" && b.current?.open();
180
+ O === "fetch_on_type" && b.current?.open();
169
181
  },
170
182
  onTypeStart: () => {
171
- !o?.fetcher && b.current?.open();
183
+ !l?.fetcher && b.current?.open();
172
184
  },
173
185
  inputRef: () => b.current?.searchInputRef,
174
186
  subscribeOpenChange: b.current?.subscribeOpenChange,
175
- name: o.name
187
+ name: l.name
176
188
  };
177
- return o.multiple ? {
189
+ return l.multiple ? {
178
190
  ...g,
179
191
  multiple: !0,
180
- controlledValue: o.value,
181
- onChange: o.onChange
192
+ controlledValue: l.value,
193
+ onChange: l.onChange
182
194
  } : {
183
195
  ...g,
184
196
  multiple: !1,
185
- controlledValue: o.value,
186
- onChange: o.onChange
197
+ controlledValue: l.value,
198
+ onChange: l.onChange
187
199
  };
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,
200
+ }, { inputValue: V, setInputValue: R, filteredOptions: L, isLoading: h, value: s, onOptionClick: c, cleanInputValue: P, cleanOptions: x } = le(C(e, u, p)), S = ee(() => u === "fetch_on_type" ? h : !1, [u, h]), A = Z(() => e.multiple ? s.map((l) => i(l, e.optionValue)) : s ? i(s, e.optionValue) : void 0, [s, e.optionValue, e.multiple]), v = (l) => {
201
+ const O = L.find((b) => i(b, e.optionValue) === l.id);
202
+ O && c(O);
203
+ }, { displayMode: _ = e.multiple ? "chips" : "compact", dropdownOptions: D, overflow: y = "scroll", onChange: d, ...E } = e.selectComponentProps || {}, J = {
204
+ controledSearchValue: V,
205
+ onSearchValueChange: u === "fetch_on_type" ? R : void 0,
206
+ onSearchClear: u === "fetch_on_type" ? () => {
207
+ P(), x();
208
+ } : void 0,
195
209
  inputSearchPlaceholder: e.inputSearchPlaceholder,
196
- isLoading: R(),
197
- ...J || {}
210
+ isLoading: S(),
211
+ ...D || {}
198
212
  };
199
- return e.multiple ? /* @__PURE__ */ q.jsx(
200
- G,
213
+ return e.multiple ? /* @__PURE__ */ X.jsx(
214
+ Y,
201
215
  {
202
216
  disabled: e.disabled,
203
217
  className: e.className,
204
218
  name: e.name,
205
- overflow: C,
206
- ...k,
219
+ overflow: y,
220
+ ...E,
207
221
  multiple: !0,
208
- value: p,
222
+ value: A,
209
223
  label: e.label || "",
210
- options: _,
224
+ options: L,
211
225
  optionValue: e.optionValue,
212
226
  optionLabel: e.optionLabel,
213
227
  renderOption: e.renderOption,
214
- onOptionClick: O,
215
- displayMode: j,
216
- controls: y,
228
+ onOptionClick: v,
229
+ displayMode: _,
230
+ controls: p,
217
231
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
218
- dropdownOptions: E,
219
- isLoading: u === "fetch_in_open" ? d : !1
232
+ dropdownOptions: J,
233
+ isLoading: u === "fetch_in_open" ? h : !1
220
234
  }
221
- ) : /* @__PURE__ */ q.jsx(
222
- G,
235
+ ) : /* @__PURE__ */ X.jsx(
236
+ Y,
223
237
  {
224
238
  disabled: e.disabled,
225
- ...k,
239
+ ...E,
226
240
  className: e.className,
227
- overflow: C,
241
+ overflow: y,
228
242
  name: e.name,
229
243
  multiple: !1,
230
- value: p,
244
+ value: A,
231
245
  label: e.label || "",
232
- options: _,
246
+ options: L,
233
247
  optionValue: e.optionValue,
234
248
  optionLabel: e.optionLabel,
235
249
  renderOption: e.renderOption,
236
- onOptionClick: O,
250
+ onOptionClick: v,
237
251
  displayMode: "compact",
238
- controls: y,
252
+ controls: p,
239
253
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
240
- dropdownOptions: E,
241
- isLoading: u === "fetch_in_open" ? d : !1
254
+ dropdownOptions: J,
255
+ isLoading: u === "fetch_in_open" ? h : !1
242
256
  }
243
257
  );
244
258
  };
245
259
  export {
246
- ie as default
260
+ de as default
247
261
  };
@@ -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,11 +28,12 @@ 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;
36
+ cleanOptions: () => void;
36
37
  filteredOptions: T[];
37
38
  isLoading: boolean;
38
39
  value: T | T[] | undefined;
@@ -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-DYuTa7Cm.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.9",
4
+ "version": "3.1.1",
5
5
  "type": "module",
6
6
  "description": "design kit system",
7
7
  "main": "dist/prometeo-design-system.umd.js",