prometeo-design-system 2.5.0 → 2.5.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.
package/dist/Select.es.js
CHANGED
package/dist/SelectFormik.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as m } from "./jsx-runtime-DKDX3adD.js";
|
|
2
2
|
import { useField as c } from "formik";
|
|
3
|
-
import { S as f } from "./Select-
|
|
3
|
+
import { S as f } from "./Select-B32JqJIS.js";
|
|
4
4
|
import { useRef as d, useEffect as v } from "react";
|
|
5
5
|
function n(r) {
|
|
6
6
|
return Array.isArray(r) && r.every(
|
package/dist/SelectSearch.es.js
CHANGED
|
@@ -1,146 +1,140 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { g as
|
|
3
|
-
import { useState as
|
|
4
|
-
function
|
|
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";
|
|
4
|
+
function te(e) {
|
|
5
5
|
const {
|
|
6
|
-
options:
|
|
6
|
+
options: f,
|
|
7
7
|
multiple: l = !1,
|
|
8
|
-
fetcher:
|
|
9
|
-
asyncMode:
|
|
10
|
-
disabled:
|
|
11
|
-
debounceDelay:
|
|
12
|
-
minCharacters:
|
|
13
|
-
optionLabel:
|
|
14
|
-
optionValue:
|
|
15
|
-
controlledValue:
|
|
16
|
-
isOpen:
|
|
17
|
-
inputRef:
|
|
18
|
-
name:
|
|
19
|
-
} = e || {}, [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
|
|
8
|
+
fetcher: C,
|
|
9
|
+
asyncMode: g = "fetch_in_open",
|
|
10
|
+
disabled: v = !1,
|
|
11
|
+
debounceDelay: p = 500,
|
|
12
|
+
minCharacters: S = 3,
|
|
13
|
+
optionLabel: m,
|
|
14
|
+
optionValue: d,
|
|
15
|
+
controlledValue: u,
|
|
16
|
+
isOpen: j,
|
|
17
|
+
inputRef: L,
|
|
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([]);
|
|
20
|
+
a(() => {
|
|
21
|
+
x.current = C;
|
|
22
|
+
}, [C]), a(() => {
|
|
23
|
+
u !== void 0 && A(u);
|
|
24
|
+
}, [u]), a(() => {
|
|
25
|
+
F.current = u !== void 0 ? u : h;
|
|
26
|
+
}, [u, h]), a(() => {
|
|
27
|
+
e?.options && (_(e.options), w(e.options));
|
|
26
28
|
}, [e?.options]);
|
|
27
|
-
const
|
|
28
|
-
R.current && clearTimeout(R.current), R.current = setTimeout(() =>
|
|
29
|
-
}), [
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
c = [n];
|
|
41
|
-
t || M(c), e?.onChange?.(c, x);
|
|
42
|
-
}, K = (n) => (e?.onFetchingStart?.(), F.current?.(n) || Promise.resolve([])), B = G((n, t) => n.length === 0 ? t : a ? t.filter((o) => !n.some((c) => s(c, a) === s(o, a))) : t.filter((o) => !n.some((c) => s(c, "id") === s(o, "id"))), [a]);
|
|
43
|
-
f(() => {
|
|
44
|
-
const n = e?.subscribeOpenChange;
|
|
45
|
-
if (!n) return;
|
|
46
|
-
const t = n((o) => {
|
|
47
|
-
N(o);
|
|
29
|
+
const K = G(() => (t, n) => new Promise((r, o) => {
|
|
30
|
+
R.current && clearTimeout(R.current), R.current = setTimeout(() => t(c).then(r).catch(o), n);
|
|
31
|
+
}), [c]), X = (t) => {
|
|
32
|
+
const n = u !== void 0, r = F.current;
|
|
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]);
|
|
37
|
+
a(() => {
|
|
38
|
+
const t = e?.subscribeOpenChange;
|
|
39
|
+
if (!t) return;
|
|
40
|
+
const n = t((r) => {
|
|
41
|
+
Q(r);
|
|
48
42
|
});
|
|
49
43
|
return () => {
|
|
50
|
-
|
|
44
|
+
n && n();
|
|
51
45
|
};
|
|
52
46
|
}, [e?.subscribeOpenChange]);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (!
|
|
56
|
-
if (!
|
|
47
|
+
const W = j !== void 0 ? j : N;
|
|
48
|
+
a(() => {
|
|
49
|
+
if (!v && x.current && g === "fetch_on_type") {
|
|
50
|
+
if (!c || c === "" || c.length < S) {
|
|
57
51
|
R.current && clearTimeout(R.current), I(!1);
|
|
58
52
|
return;
|
|
59
53
|
}
|
|
60
|
-
const
|
|
61
|
-
I(!0),
|
|
62
|
-
|
|
54
|
+
const t = K(B, p);
|
|
55
|
+
I(!0), t.then((n) => {
|
|
56
|
+
_(n);
|
|
63
57
|
}).finally(() => {
|
|
64
58
|
I(!1), e?.onFetchingEnd?.();
|
|
65
59
|
});
|
|
66
60
|
}
|
|
67
|
-
}, [
|
|
68
|
-
if (
|
|
69
|
-
if (e?.onOpen?.(),
|
|
70
|
-
if (!
|
|
61
|
+
}, [g, c, v, p, K, S]), a(() => {
|
|
62
|
+
if (W) {
|
|
63
|
+
if (e?.onOpen?.(), g === "fetch_in_open") {
|
|
64
|
+
if (!x.current)
|
|
71
65
|
return;
|
|
72
|
-
I(!0),
|
|
73
|
-
|
|
66
|
+
I(!0), B().then((t) => {
|
|
67
|
+
_(() => h.length > 0 ? [...U(h, t), ...h] : t);
|
|
74
68
|
}).finally(() => {
|
|
75
69
|
I(!1), e?.onFetchingEnd?.();
|
|
76
70
|
});
|
|
77
71
|
}
|
|
78
72
|
} else
|
|
79
73
|
e?.onClose?.();
|
|
80
|
-
}, [
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
84
|
-
switch (typeof
|
|
74
|
+
}, [W, g]);
|
|
75
|
+
const Y = (t, n) => t.filter((r) => {
|
|
76
|
+
if (m)
|
|
77
|
+
return i(r, m).toLowerCase().includes(n.toLowerCase());
|
|
78
|
+
switch (typeof r) {
|
|
85
79
|
case "string":
|
|
86
|
-
return
|
|
80
|
+
return r.toLowerCase().includes(n.toLowerCase());
|
|
87
81
|
case "number":
|
|
88
|
-
return
|
|
82
|
+
return r.toString().includes(n);
|
|
89
83
|
case "object":
|
|
90
|
-
return Object.values(
|
|
84
|
+
return Object.values(r).some((s) => s.toString().toLowerCase().includes(n.toLowerCase()));
|
|
91
85
|
default:
|
|
92
86
|
return !1;
|
|
93
87
|
}
|
|
94
|
-
}),
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
88
|
+
}), Z = (t) => t.sort((n, r) => {
|
|
89
|
+
if (m)
|
|
90
|
+
return i(n, m) < i(r, m) ? -1 : 1;
|
|
97
91
|
{
|
|
98
|
-
const
|
|
99
|
-
switch (typeof
|
|
92
|
+
const s = ["label", "name", "value"].find((b) => typeof n == "object" && Object.keys(n).includes(b));
|
|
93
|
+
switch (typeof n) {
|
|
100
94
|
case "string":
|
|
101
|
-
return
|
|
95
|
+
return n < r ? -1 : 1;
|
|
102
96
|
case "number":
|
|
103
|
-
return
|
|
97
|
+
return n < r ? -1 : 1;
|
|
104
98
|
case "object":
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
return
|
|
99
|
+
if (s) {
|
|
100
|
+
const b = i(n, s), $ = i(r, s);
|
|
101
|
+
return b < $ ? -1 : 1;
|
|
108
102
|
} else
|
|
109
103
|
return 1;
|
|
110
104
|
default:
|
|
111
105
|
return 1;
|
|
112
106
|
}
|
|
113
107
|
}
|
|
114
|
-
}),
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
108
|
+
}), q = (t) => {
|
|
109
|
+
const n = typeof L == "function" ? L() : L;
|
|
110
|
+
t.target === n?.current && (D.current && clearTimeout(D.current), J.current || (J.current = !0, e?.onTypeStart?.()), D.current = setTimeout(() => {
|
|
111
|
+
J.current = !1;
|
|
112
|
+
}, p));
|
|
119
113
|
};
|
|
120
|
-
return
|
|
121
|
-
if (
|
|
122
|
-
|
|
114
|
+
return a(() => {
|
|
115
|
+
if (c === "")
|
|
116
|
+
w(Z(V));
|
|
123
117
|
else {
|
|
124
|
-
const
|
|
125
|
-
|
|
118
|
+
const t = U(h, V);
|
|
119
|
+
w([...Y(t, c), ...h]);
|
|
126
120
|
}
|
|
127
|
-
}, [
|
|
128
|
-
document.removeEventListener("keydown",
|
|
121
|
+
}, [V]), a(() => (document.addEventListener("keydown", q), () => {
|
|
122
|
+
document.removeEventListener("keydown", q);
|
|
129
123
|
}), []), {
|
|
130
|
-
inputValue:
|
|
131
|
-
setInputValue:
|
|
124
|
+
inputValue: c,
|
|
125
|
+
setInputValue: T,
|
|
132
126
|
cleanInputValue: () => {
|
|
133
|
-
|
|
127
|
+
T("");
|
|
134
128
|
},
|
|
135
|
-
filteredOptions:
|
|
136
|
-
isLoading:
|
|
137
|
-
value:
|
|
138
|
-
setValue:
|
|
139
|
-
onOptionClick:
|
|
129
|
+
filteredOptions: P,
|
|
130
|
+
isLoading: M,
|
|
131
|
+
value: h,
|
|
132
|
+
setValue: A,
|
|
133
|
+
onOptionClick: X
|
|
140
134
|
};
|
|
141
135
|
}
|
|
142
|
-
const
|
|
143
|
-
const
|
|
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({
|
|
144
138
|
options: e.options,
|
|
145
139
|
fetcher: e.fetcher,
|
|
146
140
|
asyncMode: l,
|
|
@@ -151,51 +145,50 @@ const ce = (e) => {
|
|
|
151
145
|
optionValue: e.optionValue,
|
|
152
146
|
optionLabel: e.optionLabel,
|
|
153
147
|
onFetchingStart: () => {
|
|
154
|
-
l === "fetch_on_type" &&
|
|
148
|
+
l === "fetch_on_type" && f.current?.open();
|
|
155
149
|
},
|
|
156
150
|
onTypeStart: () => {
|
|
157
|
-
!e?.fetcher &&
|
|
151
|
+
!e?.fetcher && f.current?.open();
|
|
158
152
|
},
|
|
159
|
-
inputRef: () =>
|
|
153
|
+
inputRef: () => f.current?.searchInputRef,
|
|
160
154
|
//estado controlado
|
|
161
155
|
controlledValue: e.value,
|
|
162
|
-
subscribeOpenChange:
|
|
156
|
+
subscribeOpenChange: f.current?.subscribeOpenChange,
|
|
163
157
|
onChange: e.onChange,
|
|
164
158
|
name: e.name
|
|
165
|
-
}),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
onSearchClear: l === "fetch_on_type" ? a : void 0,
|
|
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);
|
|
162
|
+
}, { displayMode: k = "chips", dropdownOptions: V, overflow: _ = "scroll", ...P } = e.selectComponentProps || {}, w = {
|
|
163
|
+
controledSearchValue: C,
|
|
164
|
+
onSearchValueChange: l === "fetch_on_type" ? g : void 0,
|
|
165
|
+
onSearchClear: l === "fetch_on_type" ? d : void 0,
|
|
173
166
|
inputSearchPlaceholder: e.inputSearchPlaceholder,
|
|
174
|
-
isLoading:
|
|
175
|
-
...
|
|
167
|
+
isLoading: j(),
|
|
168
|
+
...V || {}
|
|
176
169
|
};
|
|
177
|
-
return /* @__PURE__ */
|
|
178
|
-
|
|
170
|
+
return /* @__PURE__ */ z.jsx("div", { children: /* @__PURE__ */ z.jsx(
|
|
171
|
+
ee,
|
|
179
172
|
{
|
|
180
173
|
name: e.name,
|
|
181
|
-
overflow:
|
|
182
|
-
...
|
|
174
|
+
overflow: _,
|
|
175
|
+
...P,
|
|
183
176
|
label: e.label || "",
|
|
184
|
-
value:
|
|
185
|
-
options:
|
|
177
|
+
value: u,
|
|
178
|
+
options: v,
|
|
186
179
|
optionValue: e.optionValue,
|
|
187
180
|
optionLabel: e.optionLabel,
|
|
188
181
|
renderOption: e.renderOption,
|
|
189
|
-
onOptionClick:
|
|
182
|
+
onOptionClick: L,
|
|
190
183
|
multiple: e.multiple,
|
|
191
|
-
displayMode:
|
|
192
|
-
controls:
|
|
184
|
+
displayMode: k,
|
|
185
|
+
controls: f,
|
|
193
186
|
emptyMessage: "Use el buscador para obtener las opciones disponibles",
|
|
194
|
-
dropdownOptions:
|
|
195
|
-
isLoading: l === "fetch_in_open" ?
|
|
187
|
+
dropdownOptions: w,
|
|
188
|
+
isLoading: l === "fetch_in_open" ? p : !1
|
|
196
189
|
}
|
|
197
190
|
) });
|
|
198
191
|
};
|
|
199
192
|
export {
|
|
200
|
-
|
|
193
|
+
ie as default
|
|
201
194
|
};
|