prometeo-design-system 2.5.2 → 2.5.4

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,6 +1,6 @@
1
- import { j as z } from "./jsx-runtime-DKDX3adD.js";
2
- import { g as i, S as ee } from "./Select-B32JqJIS.js";
3
- import { useState as y, useRef as O, useEffect as a, useMemo as G, useCallback as H } from "react";
1
+ import { j as $ } from "./jsx-runtime-DKDX3adD.js";
2
+ import { g as s, S as ee } from "./Select-C-aLaiJu.js";
3
+ import { useState as y, useRef as O, useEffect as a, useMemo as q, useCallback as z } from "react";
4
4
  function te(e) {
5
5
  const {
6
6
  options: f,
@@ -8,15 +8,15 @@ function te(e) {
8
8
  fetcher: C,
9
9
  asyncMode: g = "fetch_in_open",
10
10
  disabled: v = !1,
11
- debounceDelay: p = 500,
11
+ debounceDelay: m = 500,
12
12
  minCharacters: S = 3,
13
- optionLabel: m,
13
+ optionLabel: p,
14
14
  optionValue: d,
15
15
  controlledValue: u,
16
16
  isOpen: j,
17
17
  inputRef: L,
18
18
  name: k
19
- } = e || {}, [V, _] = y(f || []), [P, w] = y(f || []), [c, T] = y(""), [M, I] = y(!1), [h, A] = y([]), [N, Q] = y(!1), R = O(null), D = O(null), J = O(!1), x = O(C), F = O([]);
19
+ } = e || {}, [V, _] = y(f || []), [P, w] = y(f || []), [c, T] = y(""), [M, I] = y(!1), [h, A] = y([]), [G, H] = y(!1), R = O(null), D = O(null), J = O(!1), x = O(C), F = O([]);
20
20
  a(() => {
21
21
  x.current = C;
22
22
  }, [C]), a(() => {
@@ -26,100 +26,100 @@ function te(e) {
26
26
  }, [u, h]), a(() => {
27
27
  e?.options && (_(e.options), w(e.options));
28
28
  }, [e?.options]);
29
- const K = G(() => (t, n) => new Promise((r, o) => {
29
+ const K = q(() => (t, n) => new Promise((r, o) => {
30
30
  R.current && clearTimeout(R.current), R.current = setTimeout(() => t(c).then(r).catch(o), n);
31
- }), [c]), X = (t) => {
31
+ }), [c]), Q = (t) => {
32
32
  const n = u !== void 0, r = F.current;
33
33
  let o;
34
- const s = (E) => d ? i(E, d) : i(E, "id");
35
- l ? r.some((b) => s(b) === s(t)) ? o = r.filter((b) => s(b) !== s(t)) : o = [...r, t] : o = [t], n ? (F.current = o, e?.onChange?.(o, k)) : (F.current = o, A(o), e?.onChange?.(o, k));
36
- }, B = (t) => (e?.onFetchingStart?.(), x.current?.(t) || Promise.resolve([])), U = H((t, n) => t.length === 0 ? n : d ? n.filter((r) => !t.some((o) => i(o, d) === i(r, d))) : n.filter((r) => !t.some((o) => i(o, "id") === i(r, "id"))), [d]);
34
+ const i = (E) => d ? s(E, d) : s(E, "id");
35
+ l ? r.some((b) => i(b) === i(t)) ? o = r.filter((b) => i(b) !== i(t)) : o = [...r, t] : o = [t], n ? (F.current = o, e?.onChange?.(o, k)) : (F.current = o, A(o), e?.onChange?.(o, k));
36
+ }, N = (t) => (e?.onFetchingStart?.(), x.current?.(t) || Promise.resolve([])), B = z((t, n) => t.length === 0 ? n : d ? n.filter((r) => !t.some((o) => s(o, d) === s(r, d))) : n.filter((r) => !t.some((o) => s(o, "id") === s(r, "id"))), [d]);
37
37
  a(() => {
38
38
  const t = e?.subscribeOpenChange;
39
39
  if (!t) return;
40
40
  const n = t((r) => {
41
- Q(r);
41
+ H(r);
42
42
  });
43
43
  return () => {
44
44
  n && n();
45
45
  };
46
46
  }, [e?.subscribeOpenChange]);
47
- const W = j !== void 0 ? j : N;
47
+ const U = j !== void 0 ? j : G;
48
48
  a(() => {
49
49
  if (!v && x.current && g === "fetch_on_type") {
50
50
  if (!c || c === "" || c.length < S) {
51
51
  R.current && clearTimeout(R.current), I(!1);
52
52
  return;
53
53
  }
54
- const t = K(B, p);
54
+ const t = K(N, m);
55
55
  I(!0), t.then((n) => {
56
56
  _(n);
57
57
  }).finally(() => {
58
58
  I(!1), e?.onFetchingEnd?.();
59
59
  });
60
60
  }
61
- }, [g, c, v, p, K, S]), a(() => {
62
- if (W) {
61
+ }, [g, c, v, m, K, S]), a(() => {
62
+ if (U) {
63
63
  if (e?.onOpen?.(), g === "fetch_in_open") {
64
64
  if (!x.current)
65
65
  return;
66
- I(!0), B().then((t) => {
67
- _(() => h.length > 0 ? [...U(h, t), ...h] : t);
66
+ I(!0), N().then((t) => {
67
+ _(() => h.length > 0 ? [...B(h, t), ...h] : t);
68
68
  }).finally(() => {
69
69
  I(!1), e?.onFetchingEnd?.();
70
70
  });
71
71
  }
72
72
  } else
73
73
  e?.onClose?.();
74
- }, [W, g]);
75
- const Y = (t, n) => t.filter((r) => {
76
- if (m)
77
- return i(r, m).toLowerCase().includes(n.toLowerCase());
74
+ }, [U, g]);
75
+ const X = (t, n) => t.filter((r) => {
76
+ if (p)
77
+ return s(r, p).toLowerCase().includes(n.toLowerCase());
78
78
  switch (typeof r) {
79
79
  case "string":
80
80
  return r.toLowerCase().includes(n.toLowerCase());
81
81
  case "number":
82
82
  return r.toString().includes(n);
83
83
  case "object":
84
- return Object.values(r).some((s) => s.toString().toLowerCase().includes(n.toLowerCase()));
84
+ return Object.values(r).some((i) => i.toString().toLowerCase().includes(n.toLowerCase()));
85
85
  default:
86
86
  return !1;
87
87
  }
88
- }), Z = (t) => t.sort((n, r) => {
89
- if (m)
90
- return i(n, m) < i(r, m) ? -1 : 1;
88
+ }), Y = (t) => t.sort((n, r) => {
89
+ if (p)
90
+ return s(n, p) < s(r, p) ? -1 : 1;
91
91
  {
92
- const s = ["label", "name", "value"].find((b) => typeof n == "object" && Object.keys(n).includes(b));
92
+ const i = ["label", "name", "value"].find((b) => typeof n == "object" && Object.keys(n).includes(b));
93
93
  switch (typeof n) {
94
94
  case "string":
95
95
  return n < r ? -1 : 1;
96
96
  case "number":
97
97
  return n < r ? -1 : 1;
98
98
  case "object":
99
- if (s) {
100
- const b = i(n, s), $ = i(r, s);
101
- return b < $ ? -1 : 1;
99
+ if (i) {
100
+ const b = s(n, i), Z = s(r, i);
101
+ return b < Z ? -1 : 1;
102
102
  } else
103
103
  return 1;
104
104
  default:
105
105
  return 1;
106
106
  }
107
107
  }
108
- }), q = (t) => {
108
+ }), W = (t) => {
109
109
  const n = typeof L == "function" ? L() : L;
110
110
  t.target === n?.current && (D.current && clearTimeout(D.current), J.current || (J.current = !0, e?.onTypeStart?.()), D.current = setTimeout(() => {
111
111
  J.current = !1;
112
- }, p));
112
+ }, m));
113
113
  };
114
114
  return a(() => {
115
115
  if (c === "")
116
- w(Z(V));
116
+ w(Y(V));
117
117
  else {
118
- const t = U(h, V);
119
- w([...Y(t, c), ...h]);
118
+ const t = B(h, V);
119
+ w([...X(t, c), ...h]);
120
120
  }
121
- }, [V]), a(() => (document.addEventListener("keydown", q), () => {
122
- document.removeEventListener("keydown", q);
121
+ }, [V]), a(() => (document.addEventListener("keydown", W), () => {
122
+ document.removeEventListener("keydown", W);
123
123
  }), []), {
124
124
  inputValue: c,
125
125
  setInputValue: T,
@@ -130,11 +130,11 @@ function te(e) {
130
130
  isLoading: M,
131
131
  value: h,
132
132
  setValue: A,
133
- onOptionClick: X
133
+ onOptionClick: Q
134
134
  };
135
135
  }
136
- const ie = (e) => {
137
- const f = O(null), { asyncMode: l = "fetch_in_open" } = e, { inputValue: C, setInputValue: g, filteredOptions: v, isLoading: p, value: S, onOptionClick: m, cleanInputValue: d } = te({
136
+ const se = (e) => {
137
+ const f = O(null), { asyncMode: l = "fetch_in_open" } = e, { inputValue: C, setInputValue: g, filteredOptions: v, isLoading: m, value: S, onOptionClick: p, cleanInputValue: d } = te({
138
138
  options: e.options,
139
139
  fetcher: e.fetcher,
140
140
  asyncMode: l,
@@ -156,9 +156,9 @@ const ie = (e) => {
156
156
  subscribeOpenChange: f.current?.subscribeOpenChange,
157
157
  onChange: e.onChange,
158
158
  name: e.name
159
- }), u = G(() => S.map((c) => i(c, e.optionValue)), [S, e.optionValue]), j = H(() => l === "fetch_on_type" ? p : !1, [l, p]), L = (c) => {
160
- const T = v.find((M) => i(M, e.optionValue) === c.id);
161
- T && m(T);
159
+ }), u = q(() => S.map((c) => s(c, e.optionValue)), [S, e.optionValue]), j = z(() => l === "fetch_on_type" ? m : !1, [l, m]), L = (c) => {
160
+ const T = v.find((M) => s(M, e.optionValue) === c.id);
161
+ T && p(T);
162
162
  }, { displayMode: k = "chips", dropdownOptions: V, overflow: _ = "scroll", ...P } = e.selectComponentProps || {}, w = {
163
163
  controledSearchValue: C,
164
164
  onSearchValueChange: l === "fetch_on_type" ? g : void 0,
@@ -167,9 +167,10 @@ const ie = (e) => {
167
167
  isLoading: j(),
168
168
  ...V || {}
169
169
  };
170
- return /* @__PURE__ */ z.jsx("div", { children: /* @__PURE__ */ z.jsx(
170
+ return /* @__PURE__ */ $.jsx(
171
171
  ee,
172
172
  {
173
+ className: e.className,
173
174
  name: e.name,
174
175
  overflow: _,
175
176
  ...P,
@@ -185,10 +186,10 @@ const ie = (e) => {
185
186
  controls: f,
186
187
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
187
188
  dropdownOptions: w,
188
- isLoading: l === "fetch_in_open" ? p : !1
189
+ isLoading: l === "fetch_in_open" ? m : !1
189
190
  }
190
- ) });
191
+ );
191
192
  };
192
193
  export {
193
- ie as default
194
+ se as default
194
195
  };
@@ -1,8 +1,8 @@
1
1
  import { default as React } from 'react';
2
- export interface DrawerMobileProps {
3
- children?: React.ReactNode;
2
+ export interface DrawerMobileProps<TContext = unknown> {
3
+ children?: React.ReactNode | ((context: TContext | null) => React.ReactNode);
4
4
  defaultOpen?: boolean;
5
- onClose?: () => void;
5
+ onClose?: (context: TContext | null) => void;
6
6
  snap?: string | number | null;
7
7
  snapPoints?: (string | number)[];
8
8
  setSnap?: (snap: string | number) => void;
@@ -12,10 +12,11 @@ export interface DrawerMobileProps {
12
12
  modal?: boolean;
13
13
  closeOnOverlayClick?: boolean;
14
14
  }
15
- export interface DrawerMobileHandle {
16
- open: (snap?: string | number) => void;
15
+ export interface DrawerMobileHandle<TContext = unknown> {
16
+ open: (snap?: string | number, context?: TContext) => void;
17
17
  close: () => void;
18
18
  isOpen: boolean;
19
+ getContext: () => TContext | null;
19
20
  }
20
- declare const DrawerMobile: React.ForwardRefExoticComponent<DrawerMobileProps & React.RefAttributes<DrawerMobileHandle>>;
21
+ declare const DrawerMobile: React.ForwardRefExoticComponent<DrawerMobileProps<any> & React.RefAttributes<DrawerMobileHandle<any>>>;
21
22
  export default DrawerMobile;
@@ -1,7 +1,8 @@
1
1
  import { DrawerMobileHandle } from './DrawerMobile';
2
- export declare const useDrawerMobile: () => {
2
+ export declare const useDrawerMobile: <TContext = unknown>() => {
3
3
  isOpen: () => boolean;
4
- open: (snap?: string | number) => void;
4
+ open: (snap?: string | number, context?: TContext) => void;
5
5
  close: () => void;
6
- drawerRef: import('react').RefObject<DrawerMobileHandle | null>;
6
+ drawerRef: import('react').RefObject<DrawerMobileHandle<TContext> | null>;
7
+ getContext: () => NonNullable<TContext> | null;
7
8
  };
@@ -16,6 +16,7 @@ export interface SelectSearchProps<T> {
16
16
  inputSearchPlaceholder?: string;
17
17
  labelVariant?: 'static' | 'default';
18
18
  disabled?: boolean;
19
+ className?: string;
19
20
  renderOption?: ComponentType<CustomSelectOptionRendererProps<T>>;
20
21
  renderSelection?: ComponentType<CustomSelectionDisplayProps<T>>;
21
22
  selectComponentProps?: Partial<SelectProps<T>>;