prometeo-design-system 2.5.2 → 2.5.3
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.
- package/dist/DatePicker.es.js +1 -1
- package/dist/DrawerMobile.es.js +102 -100
- package/dist/Icons/Icons.d.ts +1 -0
- package/dist/Icons.es.js +43 -26
- package/dist/{Input-Bhd0bmVq.js → Input-PNwH7rb6.js} +1 -1
- package/dist/Input.es.js +1 -1
- package/dist/OtpInput.es.js +1 -1
- package/dist/{Select-B32JqJIS.js → Select-C-aLaiJu.js} +1 -1
- package/dist/Select.es.js +1 -1
- package/dist/SelectFormik.es.js +1 -1
- package/dist/SelectSearch.es.js +48 -47
- package/dist/components/Drawer/DrawerMobile.d.ts +6 -5
- package/dist/components/Drawer/useDrawerMobile.d.ts +4 -3
- package/dist/components/SelectSearch/SelectSearch.d.ts +1 -0
- package/dist/prometeo-design-system.css +1 -1
- package/dist/prometeo-design-system.es.js +2 -2
- package/package.json +1 -1
package/dist/SelectSearch.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { g as
|
|
3
|
-
import { useState as y, useRef as O, useEffect as a, useMemo as
|
|
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:
|
|
11
|
+
debounceDelay: m = 500,
|
|
12
12
|
minCharacters: S = 3,
|
|
13
|
-
optionLabel:
|
|
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([]), [
|
|
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 =
|
|
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]),
|
|
31
|
+
}), [c]), Q = (t) => {
|
|
32
32
|
const n = u !== void 0, r = F.current;
|
|
33
33
|
let o;
|
|
34
|
-
const
|
|
35
|
-
l ? r.some((b) =>
|
|
36
|
-
},
|
|
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
|
-
|
|
41
|
+
H(r);
|
|
42
42
|
});
|
|
43
43
|
return () => {
|
|
44
44
|
n && n();
|
|
45
45
|
};
|
|
46
46
|
}, [e?.subscribeOpenChange]);
|
|
47
|
-
const
|
|
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(
|
|
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,
|
|
62
|
-
if (
|
|
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),
|
|
67
|
-
_(() => h.length > 0 ? [...
|
|
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
|
-
}, [
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
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((
|
|
84
|
+
return Object.values(r).some((i) => i.toString().toLowerCase().includes(n.toLowerCase()));
|
|
85
85
|
default:
|
|
86
86
|
return !1;
|
|
87
87
|
}
|
|
88
|
-
}),
|
|
89
|
-
if (
|
|
90
|
-
return
|
|
88
|
+
}), Y = (t) => t.sort((n, r) => {
|
|
89
|
+
if (p)
|
|
90
|
+
return s(n, p) < s(r, p) ? -1 : 1;
|
|
91
91
|
{
|
|
92
|
-
const
|
|
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 (
|
|
100
|
-
const b =
|
|
101
|
-
return b <
|
|
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
|
-
}),
|
|
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
|
-
},
|
|
112
|
+
}, m));
|
|
113
113
|
};
|
|
114
114
|
return a(() => {
|
|
115
115
|
if (c === "")
|
|
116
|
-
w(
|
|
116
|
+
w(Y(V));
|
|
117
117
|
else {
|
|
118
|
-
const t =
|
|
119
|
-
w([...
|
|
118
|
+
const t = B(h, V);
|
|
119
|
+
w([...X(t, c), ...h]);
|
|
120
120
|
}
|
|
121
|
-
}, [V]), a(() => (document.addEventListener("keydown",
|
|
122
|
-
document.removeEventListener("keydown",
|
|
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:
|
|
133
|
+
onOptionClick: Q
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
const f = O(null), { asyncMode: l = "fetch_in_open" } = e, { inputValue: C, setInputValue: g, filteredOptions: v, isLoading:
|
|
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 =
|
|
160
|
-
const T = v.find((M) =>
|
|
161
|
-
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__ */
|
|
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" ?
|
|
189
|
+
isLoading: l === "fetch_in_open" ? m : !1
|
|
189
190
|
}
|
|
190
|
-
)
|
|
191
|
+
);
|
|
191
192
|
};
|
|
192
193
|
export {
|
|
193
|
-
|
|
194
|
+
se as default
|
|
194
195
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
export interface DrawerMobileProps {
|
|
2
|
+
export interface DrawerMobileProps<TContext = unknown> {
|
|
3
3
|
children?: 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>>;
|