prometeo-design-system 2.4.3 → 2.5.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.
- package/dist/Avatar.es.js +1 -1
- package/dist/{Button-Bc0LYLfg.js → Button-DsbEyjth.js} +1 -1
- package/dist/Button.es.js +1 -1
- package/dist/{CardProfile-BhHJmvqs.js → CardProfile-Fn44kEnM.js} +1 -1
- package/dist/CardProfile.es.js +1 -1
- package/dist/CheckBox.es.js +1 -1
- package/dist/CheckboxFormik.es.js +1 -1
- package/dist/DatePicker.es.js +3 -3
- package/dist/DialogModal.es.js +1 -1
- package/dist/DrawerDesktop.es.js +2 -2
- package/dist/DrawerMobile.es.js +1 -1
- package/dist/DropZone.es.js +1 -1
- package/dist/Header.es.js +1 -1
- package/dist/Icons/Icons.d.ts +1 -0
- package/dist/Icons.es.js +213 -196
- package/dist/Image.es.js +1 -1
- package/dist/{ImageGallery-BeADef_g.js → ImageGallery-DnoRTpCr.js} +2 -2
- package/dist/ImageGallery.es.js +1 -1
- package/dist/Input-Bhd0bmVq.js +270 -0
- package/dist/Input.es.js +2 -236
- package/dist/InputFormik.es.js +1 -1
- package/dist/InputMultiple.es.js +1 -1
- package/dist/{LayoutGeneric-jDE96L2N.js → LayoutGeneric-p4Pll4Cm.js} +1 -1
- package/dist/LayoutGeneric.es.js +1 -1
- package/dist/Logo.es.js +1 -1
- package/dist/Menu.es.js +1 -1
- package/dist/OtpInput.es.js +1 -1
- package/dist/Pagination.es.js +1 -1
- package/dist/ProfilePictureUpload.es.js +1 -1
- package/dist/ProgressBar.es.js +1 -1
- package/dist/SegmentedButton.es.js +1 -1
- package/dist/Select-CxJFcGuQ.js +801 -0
- package/dist/Select.es.js +2 -559
- package/dist/SelectFormik.es.js +28 -14
- package/dist/SelectFormikLegacy.es.js +1 -1
- package/dist/SelectSearch.d.ts +4 -0
- package/dist/SelectSearch.es.js +201 -0
- package/dist/Skeleton.es.js +1 -1
- package/dist/Spinner.es.js +1 -1
- package/dist/Steps.es.js +1 -1
- package/dist/SwipeContainer.es.js +1 -1
- package/dist/Switch.es.js +1 -1
- package/dist/TabLinks.es.js +1 -1
- package/dist/Table.es.js +1 -1
- package/dist/TextArea.es.js +1 -1
- package/dist/Toast.es.js +2 -2
- package/dist/ToastProvider.es.js +1 -1
- package/dist/Tooltip.es.js +1 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +20 -0
- package/dist/components/Autocomplete/useAutocomplete.d.ts +33 -0
- package/dist/components/Input/Input.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +42 -25
- package/dist/components/Select copy/Select.d.ts +71 -0
- package/dist/components/SelectSearch/SelectSearch.d.ts +26 -0
- package/dist/components/Shared/Chip.d.ts +2 -1
- package/dist/exports/Autocomplete.d.ts +1 -0
- package/dist/exports/SelectSearch.d.ts +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/{jsx-runtime-ByW6EXIE.js → jsx-runtime-DKDX3adD.js} +94 -96
- package/dist/lib/utils.d.ts +3 -0
- package/dist/pages/Autocomplete.page.d.ts +2 -0
- package/dist/preview/AutocompletePreview.d.ts +2 -0
- package/dist/prometeo-design-system.css +1 -1
- package/dist/prometeo-design-system.es.js +16 -14
- package/package.json +1 -1
package/dist/Select.es.js
CHANGED
|
@@ -1,561 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Icons as z } from "./Icons.es.js";
|
|
3
|
-
import { c as l } from "./cn-B6yFEsav.js";
|
|
4
|
-
import ie, { useRef as T, useLayoutEffect as Ce, memo as v, useState as de, useMemo as B, useCallback as R, useEffect as se } from "react";
|
|
5
|
-
import Se from "./Spinner.es.js";
|
|
6
|
-
import { createPortal as Ee } from "react-dom";
|
|
7
|
-
import { u as ke } from "./useDragScroll-CHN9OMwn.js";
|
|
8
|
-
import He from "./CheckBox.es.js";
|
|
9
|
-
const Oe = (e) => {
|
|
10
|
-
let t = e;
|
|
11
|
-
for (; t && t !== document.body; ) {
|
|
12
|
-
const s = window.getComputedStyle(t).backgroundColor;
|
|
13
|
-
if (s && s !== "transparent" && s !== "rgba(0, 0, 0, 0)")
|
|
14
|
-
return s;
|
|
15
|
-
t = t.parentElement;
|
|
16
|
-
}
|
|
17
|
-
const a = window.getComputedStyle(document.body).backgroundColor;
|
|
18
|
-
return a && a !== "transparent" && a !== "rgba(0, 0, 0, 0)" ? a : "rgb(255, 255, 255)";
|
|
19
|
-
};
|
|
20
|
-
function Ie() {
|
|
21
|
-
const e = T(null);
|
|
22
|
-
return Ce(() => {
|
|
23
|
-
if (!e.current || !e.current.parentElement) return;
|
|
24
|
-
const t = Oe(e.current.parentElement);
|
|
25
|
-
e.current.style.backgroundColor = t;
|
|
26
|
-
}, []), {
|
|
27
|
-
ref: e
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const fe = (e) => {
|
|
31
|
-
const { variant: t, className: a } = e, u = {
|
|
32
|
-
default: "text-neutral-medium-default pt-[1px]",
|
|
33
|
-
error: "text-error-medium-default pt-[1px]",
|
|
34
|
-
success: "text-success-medium-default"
|
|
35
|
-
}, s = {
|
|
36
|
-
default: /* @__PURE__ */ n.jsx(z.Info, { size: 16, className: "text-neutral-medium-default " }),
|
|
37
|
-
error: /* @__PURE__ */ n.jsx(z.Error, { size: 16, className: "text-error-medium-default" }),
|
|
38
|
-
success: /* @__PURE__ */ n.jsx(z.Check, { size: 16, className: "text-success-medium-default" })
|
|
39
|
-
};
|
|
40
|
-
return /* @__PURE__ */ n.jsx("div", { ref: e.ref, className: l("pl-3", a), children: typeof e.children == "string" ? /* @__PURE__ */ n.jsxs("div", { className: "flex gap-0.5 items-start", children: [
|
|
41
|
-
s[t],
|
|
42
|
-
/* @__PURE__ */ n.jsx("p", { className: l(" prometeo-fonts-body-small", u[t]), children: e.children })
|
|
43
|
-
] }) : e.children });
|
|
44
|
-
};
|
|
45
|
-
fe.displayName = "HelperText";
|
|
46
|
-
const ze = v(fe), Me = {
|
|
47
|
-
default: {
|
|
48
|
-
container: "text-neutral-default-default border-neutral-default-default ",
|
|
49
|
-
icon: ""
|
|
50
|
-
},
|
|
51
|
-
error: {
|
|
52
|
-
container: "",
|
|
53
|
-
icon: ""
|
|
54
|
-
},
|
|
55
|
-
success: {
|
|
56
|
-
container: "",
|
|
57
|
-
icon: ""
|
|
58
|
-
}
|
|
59
|
-
}, ce = {
|
|
60
|
-
icon: " text-neutral-default-disabled",
|
|
61
|
-
container: " border-neutral-strong-default text-neutral-default-disabled"
|
|
62
|
-
}, me = ({ id: e, label: t, onRemove: a, className: u, disabled: s, variant: c = "default" }) => /* @__PURE__ */ n.jsxs(
|
|
63
|
-
"div",
|
|
64
|
-
{
|
|
65
|
-
className: l(
|
|
66
|
-
"inline-flex max-w-[calc(50%-0.25rem)] items-center gap-1 px-2 py-1 bg-inherit text-xs rounded-lg border",
|
|
67
|
-
Me[c].container,
|
|
68
|
-
s && ce.container
|
|
69
|
-
),
|
|
70
|
-
children: [
|
|
71
|
-
/* @__PURE__ */ n.jsx("span", { className: "truncate w-max ", children: t }),
|
|
72
|
-
a && /* @__PURE__ */ n.jsx(
|
|
73
|
-
"button",
|
|
74
|
-
{
|
|
75
|
-
onMouseDown: (x) => {
|
|
76
|
-
s || (x.stopPropagation(), x.preventDefault(), a?.(e));
|
|
77
|
-
},
|
|
78
|
-
className: l(
|
|
79
|
-
"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",
|
|
80
|
-
s && "cursor-default hover:scale-100",
|
|
81
|
-
u
|
|
82
|
-
),
|
|
83
|
-
type: "button",
|
|
84
|
-
tabIndex: -1,
|
|
85
|
-
children: /* @__PURE__ */ n.jsx(z.Close, { size: 18, className: l(s && ce.icon) })
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
me.displayName = "Chip";
|
|
92
|
-
const _e = v(me);
|
|
93
|
-
function g(e, t) {
|
|
94
|
-
if (typeof t == "function")
|
|
95
|
-
return t(e);
|
|
96
|
-
const a = t?.split(".");
|
|
97
|
-
let u = e;
|
|
98
|
-
for (const s of a)
|
|
99
|
-
if (u && typeof u == "object" && s in u)
|
|
100
|
-
u = u[s];
|
|
101
|
-
else
|
|
102
|
-
return;
|
|
103
|
-
return u;
|
|
104
|
-
}
|
|
105
|
-
const re = {
|
|
106
|
-
default: {
|
|
107
|
-
container: "",
|
|
108
|
-
input: l(
|
|
109
|
-
"border-neutral-default-default text-neutral-default-default",
|
|
110
|
-
"focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
|
|
111
|
-
"hover:border-primary-default-default"
|
|
112
|
-
),
|
|
113
|
-
label: l(
|
|
114
|
-
"text-neutral-medium-default",
|
|
115
|
-
"peer-focus:text-primary-default-default"
|
|
116
|
-
),
|
|
117
|
-
icon: l(
|
|
118
|
-
"text-neutral-medium-default",
|
|
119
|
-
"peer-focus:text-primary-default-default"
|
|
120
|
-
)
|
|
121
|
-
},
|
|
122
|
-
error: {
|
|
123
|
-
container: "",
|
|
124
|
-
input: l(
|
|
125
|
-
"border-error-default-default text-neutral-default-default hover:border-error-default-hover",
|
|
126
|
-
"focus:border-error-default focus:border-2",
|
|
127
|
-
"focus:ring-0 focus:ring-error-default/20"
|
|
128
|
-
),
|
|
129
|
-
label: l(
|
|
130
|
-
"text-error-light",
|
|
131
|
-
"peer-focus:text-error-light"
|
|
132
|
-
),
|
|
133
|
-
icon: l(
|
|
134
|
-
"text-error-medium-default",
|
|
135
|
-
"peer-focus:text-error-light"
|
|
136
|
-
)
|
|
137
|
-
},
|
|
138
|
-
success: {
|
|
139
|
-
container: "",
|
|
140
|
-
input: l(
|
|
141
|
-
"border-success-default-default text-neutral-default-default",
|
|
142
|
-
"focus:border-success-default focus:border-2",
|
|
143
|
-
"focus:ring-0 focus:ring-success-default/20"
|
|
144
|
-
),
|
|
145
|
-
label: l(
|
|
146
|
-
"text-success",
|
|
147
|
-
"peer-focus:text-success-light"
|
|
148
|
-
),
|
|
149
|
-
icon: l(
|
|
150
|
-
"text-success-medium-default",
|
|
151
|
-
"peer-focus:text-success-light"
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
}, ne = {
|
|
155
|
-
input: l(
|
|
156
|
-
"border-neutral-strong-default text-neutral-default-default",
|
|
157
|
-
"focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
|
|
158
|
-
"hover:border-primary-default-default"
|
|
159
|
-
),
|
|
160
|
-
label: l(
|
|
161
|
-
"text-neutral-medium-disabled",
|
|
162
|
-
"peer-focus:text-primary-default-default"
|
|
163
|
-
),
|
|
164
|
-
icon: l(
|
|
165
|
-
"text-neutral-medium-disabled",
|
|
166
|
-
"peer-focus:text-primary-default-default"
|
|
167
|
-
)
|
|
168
|
-
}, Le = ({
|
|
169
|
-
label: e,
|
|
170
|
-
onOptionClick: t,
|
|
171
|
-
value: a,
|
|
172
|
-
isLoading: u = !1,
|
|
173
|
-
options: s,
|
|
174
|
-
multiple: c = !1,
|
|
175
|
-
onClear: x,
|
|
176
|
-
onClose: p,
|
|
177
|
-
className: i,
|
|
178
|
-
id: k,
|
|
179
|
-
emptyMessage: G = "No hay opciones disponibles",
|
|
180
|
-
optionValue: m,
|
|
181
|
-
optionLabel: j,
|
|
182
|
-
renderOption: M,
|
|
183
|
-
placeholder: w,
|
|
184
|
-
renderSelection: C,
|
|
185
|
-
containerClassName: le,
|
|
186
|
-
buttonClassName: W,
|
|
187
|
-
dropdownClassName: _,
|
|
188
|
-
displayMode: A = "compact",
|
|
189
|
-
onRemoveOption: L,
|
|
190
|
-
width: P = "100%",
|
|
191
|
-
height: N,
|
|
192
|
-
labelVariant: y = "default",
|
|
193
|
-
attachToParent: f = !1,
|
|
194
|
-
name: o,
|
|
195
|
-
overflow: D = "wrap",
|
|
196
|
-
onChange: h,
|
|
197
|
-
helperComponent: S,
|
|
198
|
-
errorComponent: E,
|
|
199
|
-
disabled: H = !1,
|
|
200
|
-
variant: U = "default"
|
|
201
|
-
}) => {
|
|
202
|
-
const [O, $] = de(!1), q = T(null), J = T(null), ae = T(null), { ref: ge } = Ie(), { bind: I, ref: he } = ke({
|
|
203
|
-
axis: "x",
|
|
204
|
-
cursor: { idle: "default", dragging: "grabbing" }
|
|
205
|
-
}), F = a && a.length > 0, Q = B(() => s?.filter((r) => a?.includes(g(r, m))), [a, m, s]), be = () => y === "static" ? "relative prometeo-fonts-label-large" : O || F ? "absolute top-0 -translate-y-1/2 left-2 scale-90 px-1 prometeo-fonts-body-medium" : "absolute top-1/2 -translate-y-1/2 scale-100 prometeo-fonts-body-large", X = {};
|
|
206
|
-
P && P !== "100%" && (X.width = P), N && (X.height = N);
|
|
207
|
-
const ye = R(() => C ? { height: D === "scroll" ? "48px" : "max-content" } : N ? { height: N } : {}, [N, D, C]);
|
|
208
|
-
se(() => {
|
|
209
|
-
if (!O) return;
|
|
210
|
-
const r = (d) => {
|
|
211
|
-
const b = d.target;
|
|
212
|
-
if (d.type === "mousedown") {
|
|
213
|
-
if (q.current?.contains(b) || J.current?.contains(b))
|
|
214
|
-
return;
|
|
215
|
-
$(!1);
|
|
216
|
-
}
|
|
217
|
-
if (d.type === "scroll") {
|
|
218
|
-
if (J.current?.contains(b))
|
|
219
|
-
return;
|
|
220
|
-
$(!1);
|
|
221
|
-
}
|
|
222
|
-
d.type === "resize" && $(!1);
|
|
223
|
-
};
|
|
224
|
-
return document.addEventListener("mousedown", r), window.addEventListener("scroll", r, !0), window.addEventListener("resize", r, !0), () => {
|
|
225
|
-
document.removeEventListener("mousedown", r), window.removeEventListener("scroll", r, !0), window.removeEventListener("resize", r, !0);
|
|
226
|
-
};
|
|
227
|
-
}, [O]);
|
|
228
|
-
const oe = R(() => {
|
|
229
|
-
$((r) => !r);
|
|
230
|
-
}, []), K = B(() => s.map((r) => ({
|
|
231
|
-
id: g(r, m),
|
|
232
|
-
value: g(r, m),
|
|
233
|
-
label: g(r, j)
|
|
234
|
-
})), [s, m, j]), Y = T(() => {
|
|
235
|
-
});
|
|
236
|
-
Y.current = (r) => {
|
|
237
|
-
if (c) {
|
|
238
|
-
const d = a || [], b = d.includes(r.value), ue = K.filter((te) => d.includes(te.value));
|
|
239
|
-
let ee = [];
|
|
240
|
-
b ? ee = ue.filter((te) => te.value !== r.value) : ee = [...ue, r], h?.(ee, o);
|
|
241
|
-
} else
|
|
242
|
-
h?.([r], o);
|
|
243
|
-
};
|
|
244
|
-
const De = R((r) => {
|
|
245
|
-
t?.(r, o), Y.current?.(r), c || ($(!1), p?.());
|
|
246
|
-
}, [c, t, p, o]), Ne = (r) => {
|
|
247
|
-
r.preventDefault(), r.stopPropagation(), r.target.blur(), x?.(), h?.([], o);
|
|
248
|
-
}, Z = R((r) => {
|
|
249
|
-
c || h?.([], o);
|
|
250
|
-
const d = s.find((b) => g(b, m) === r);
|
|
251
|
-
if (d) {
|
|
252
|
-
const b = {
|
|
253
|
-
id: g(d, m),
|
|
254
|
-
label: g(d, j),
|
|
255
|
-
value: g(d, m)
|
|
256
|
-
};
|
|
257
|
-
t?.(b, o), Y.current?.(b), L?.(d);
|
|
258
|
-
}
|
|
259
|
-
}, [t, L, j, m, s, o, c, h]), ve = R((r) => {
|
|
260
|
-
Z(r);
|
|
261
|
-
}, [Z]), je = B(() => y === "static" && w ? w : "", [y, w]), V = B(
|
|
262
|
-
() => new Set(Q.map((r) => g(r, m))),
|
|
263
|
-
[Q, m]
|
|
264
|
-
), we = B(
|
|
265
|
-
() => K.filter((r) => V.has(r.id)),
|
|
266
|
-
[K, V]
|
|
267
|
-
);
|
|
268
|
-
return /* @__PURE__ */ n.jsxs(
|
|
269
|
-
"div",
|
|
270
|
-
{
|
|
271
|
-
className: l(
|
|
272
|
-
"relative bg-inherit select-none w-full",
|
|
273
|
-
i,
|
|
274
|
-
y === "static" && "mt-2"
|
|
275
|
-
),
|
|
276
|
-
ref: q,
|
|
277
|
-
style: X,
|
|
278
|
-
draggable: !1,
|
|
279
|
-
children: [
|
|
280
|
-
/* @__PURE__ */ n.jsxs("div", { className: l("relative bg-inherit ", le), children: [
|
|
281
|
-
/* @__PURE__ */ n.jsx(
|
|
282
|
-
"label",
|
|
283
|
-
{
|
|
284
|
-
htmlFor: k,
|
|
285
|
-
ref: ge,
|
|
286
|
-
className: l(
|
|
287
|
-
"left-3 pointer-events-none bg-inherit z-10",
|
|
288
|
-
y === "default" && "transition-all duration-200 ease-in-out",
|
|
289
|
-
be(),
|
|
290
|
-
F || O ? re[U].label : "text-neutral-medium-default",
|
|
291
|
-
H && ne.label
|
|
292
|
-
),
|
|
293
|
-
children: e
|
|
294
|
-
}
|
|
295
|
-
),
|
|
296
|
-
/* @__PURE__ */ n.jsxs(
|
|
297
|
-
"div",
|
|
298
|
-
{
|
|
299
|
-
role: "button",
|
|
300
|
-
id: k,
|
|
301
|
-
onClick: (r) => {
|
|
302
|
-
r.preventDefault(), r.stopPropagation(), oe();
|
|
303
|
-
},
|
|
304
|
-
onKeyDown: (r) => {
|
|
305
|
-
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), r.stopPropagation(), oe());
|
|
306
|
-
},
|
|
307
|
-
tabIndex: 0,
|
|
308
|
-
className: l(
|
|
309
|
-
"w-full px-2 text-left border rounded-lg transition-all duration-200 ease-in-out",
|
|
310
|
-
"flex items-center justify-start bg-inherit gap-2 ",
|
|
311
|
-
"focus:outline-none",
|
|
312
|
-
A === "chips" && c && F ? "min-h-12 py-2" : !N && "h-12 min-h-12",
|
|
313
|
-
re[U].input,
|
|
314
|
-
H && ne.input,
|
|
315
|
-
W
|
|
316
|
-
),
|
|
317
|
-
style: ye(),
|
|
318
|
-
children: [
|
|
319
|
-
/* @__PURE__ */ n.jsx(
|
|
320
|
-
"div",
|
|
321
|
-
{
|
|
322
|
-
className: l(
|
|
323
|
-
"flex-1 overflow-x-auto overflow-y-hidden px-1 prometeo-scrollbar-none ",
|
|
324
|
-
C ? " " : ""
|
|
325
|
-
),
|
|
326
|
-
ref: he,
|
|
327
|
-
onPointerDown: I.onPointerDown,
|
|
328
|
-
onPointerMove: I.onPointerMove,
|
|
329
|
-
onPointerUp: I.onPointerUp,
|
|
330
|
-
onPointerLeave: I.onPointerLeave,
|
|
331
|
-
onPointerCancel: I.onPointerCancel,
|
|
332
|
-
onClickCapture: I.onClickCapture,
|
|
333
|
-
children: C ? ie.createElement(v(
|
|
334
|
-
C,
|
|
335
|
-
(r, d) => r.disabled === d.disabled && r.multiple === d.multiple
|
|
336
|
-
), {
|
|
337
|
-
selectedOptions: Q,
|
|
338
|
-
placeholder: w,
|
|
339
|
-
multiple: c,
|
|
340
|
-
onRemoveOption: ve,
|
|
341
|
-
disabled: H
|
|
342
|
-
}) : /* @__PURE__ */ n.jsx(
|
|
343
|
-
xe,
|
|
344
|
-
{
|
|
345
|
-
displayMode: A,
|
|
346
|
-
selectedOptions: we,
|
|
347
|
-
placeholder: je,
|
|
348
|
-
onRemoveOption: Z,
|
|
349
|
-
multiple: c,
|
|
350
|
-
className: l(D === "scroll" ? "flex-nowrap" : "flex-wrap"),
|
|
351
|
-
disabled: H
|
|
352
|
-
}
|
|
353
|
-
)
|
|
354
|
-
}
|
|
355
|
-
),
|
|
356
|
-
/* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
357
|
-
u && /* @__PURE__ */ n.jsx(Se, { size: "small", variant: "clip", className: "mt-2", speedMultiplier: 0.7 }),
|
|
358
|
-
F && x && /* @__PURE__ */ n.jsx(
|
|
359
|
-
"button",
|
|
360
|
-
{
|
|
361
|
-
onMouseDown: (r) => {
|
|
362
|
-
r.preventDefault(), r.stopPropagation(), Ne(r);
|
|
363
|
-
},
|
|
364
|
-
type: "button",
|
|
365
|
-
tabIndex: -1,
|
|
366
|
-
children: /* @__PURE__ */ n.jsx(z.Cancel, { size: 24, className: l(" cursor-pointer transition-all", re[U].icon) })
|
|
367
|
-
}
|
|
368
|
-
),
|
|
369
|
-
/* @__PURE__ */ n.jsx(
|
|
370
|
-
z.ChevronDown,
|
|
371
|
-
{
|
|
372
|
-
size: 20,
|
|
373
|
-
className: l(
|
|
374
|
-
"transition-transform text-neutral-default-default",
|
|
375
|
-
O ? "rotate-180" : "",
|
|
376
|
-
H && ne.icon
|
|
377
|
-
)
|
|
378
|
-
}
|
|
379
|
-
)
|
|
380
|
-
] })
|
|
381
|
-
]
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
] }),
|
|
385
|
-
/* @__PURE__ */ n.jsx(
|
|
386
|
-
$e,
|
|
387
|
-
{
|
|
388
|
-
options: M ? s : K,
|
|
389
|
-
selectedOptionsIds: V,
|
|
390
|
-
onOptionClick: De,
|
|
391
|
-
emptyMessage: G,
|
|
392
|
-
dropdownClassName: _,
|
|
393
|
-
multiple: c,
|
|
394
|
-
attachToParent: f,
|
|
395
|
-
selectRef: q,
|
|
396
|
-
dropdownRef: J,
|
|
397
|
-
isOpen: O,
|
|
398
|
-
renderOption: M,
|
|
399
|
-
optionLabel: j,
|
|
400
|
-
optionValue: m,
|
|
401
|
-
helperComponentRef: ae,
|
|
402
|
-
disabled: H,
|
|
403
|
-
labelVariant: y
|
|
404
|
-
}
|
|
405
|
-
),
|
|
406
|
-
(E || S) && /* @__PURE__ */ n.jsx(
|
|
407
|
-
ze,
|
|
408
|
-
{
|
|
409
|
-
ref: ae,
|
|
410
|
-
variant: U,
|
|
411
|
-
className: "mt-1",
|
|
412
|
-
children: E || S
|
|
413
|
-
}
|
|
414
|
-
)
|
|
415
|
-
]
|
|
416
|
-
}
|
|
417
|
-
);
|
|
418
|
-
}, Ke = v(Le, (e, t) => e.value === t.value && e.options === t.options && e.isLoading === t.isLoading && e.disabled === t.disabled && e.errorComponent === t.errorComponent && e.helperComponent === t.helperComponent && e.variant === t.variant && e.label === t.label && e.id === t.id && e.name === t.name && e.placeholder === t.placeholder);
|
|
419
|
-
function Pe({
|
|
420
|
-
options: e,
|
|
421
|
-
onOptionClick: t,
|
|
422
|
-
dropdownClassName: a,
|
|
423
|
-
emptyMessage: u,
|
|
424
|
-
selectedOptionsIds: s,
|
|
425
|
-
multiple: c,
|
|
426
|
-
attachToParent: x,
|
|
427
|
-
selectRef: p,
|
|
428
|
-
dropdownRef: i,
|
|
429
|
-
isOpen: k,
|
|
430
|
-
renderOption: G,
|
|
431
|
-
optionValue: m,
|
|
432
|
-
optionLabel: j,
|
|
433
|
-
helperComponentRef: M,
|
|
434
|
-
disabled: w,
|
|
435
|
-
labelVariant: C
|
|
436
|
-
}) {
|
|
437
|
-
const W = C === "static" ? -24 : 4, [_, A] = de("down"), L = (f) => {
|
|
438
|
-
if (!i.current || !p.current) return;
|
|
439
|
-
const o = p.current.getBoundingClientRect();
|
|
440
|
-
switch (f || _) {
|
|
441
|
-
case "down":
|
|
442
|
-
i.current.style.top = `${o.top + o.height - (M?.current?.offsetHeight ? M?.current?.offsetHeight + 4 : 0)}px`;
|
|
443
|
-
break;
|
|
444
|
-
case "up":
|
|
445
|
-
i.current.style.top = "auto", i.current.style.bottom = `${window.innerHeight - o.top + W}px`;
|
|
446
|
-
break;
|
|
447
|
-
}
|
|
448
|
-
i.current.style.left = `${o.left}px`, i.current.style.width = `${o.width}px`;
|
|
449
|
-
}, P = () => {
|
|
450
|
-
if (!i.current || !p.current) return _;
|
|
451
|
-
const f = p.current.getBoundingClientRect(), o = f.bottom + 240 < window.innerHeight, D = f.top - 240 - W > 0;
|
|
452
|
-
let h = "down";
|
|
453
|
-
return o ? h = "down" : D && (h = "up"), h;
|
|
454
|
-
}, N = (f) => {
|
|
455
|
-
if (!(!i.current || !p.current)) {
|
|
456
|
-
if (i.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !f) {
|
|
457
|
-
i.current.style.maxHeight = "0", i.current.style.opacity = "0", i.current.style.pointerEvents = "none";
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
if (!x) {
|
|
461
|
-
const o = P();
|
|
462
|
-
A(o), L(o);
|
|
463
|
-
}
|
|
464
|
-
i.current.style.maxHeight = "240px", i.current.style.opacity = "1", i.current.style.pointerEvents = "auto";
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
se(() => {
|
|
468
|
-
x || !p.current || !k || L();
|
|
469
|
-
}, [s]), se(() => {
|
|
470
|
-
N(k);
|
|
471
|
-
}, [k]);
|
|
472
|
-
const y = /* @__PURE__ */ n.jsx(
|
|
473
|
-
"div",
|
|
474
|
-
{
|
|
475
|
-
ref: i,
|
|
476
|
-
style: {
|
|
477
|
-
opacity: "0",
|
|
478
|
-
maxHeight: "0"
|
|
479
|
-
},
|
|
480
|
-
className: l(
|
|
481
|
-
" z-50 w-full mt-1 bg-neutral-default-default border border-neutral-default-default rounded-md shadow-lg",
|
|
482
|
-
"max-h-60 overflow-auto",
|
|
483
|
-
x ? "absolute z-50 " : "fixed z-100 top-0 left-0",
|
|
484
|
-
_ === "up" ? "h-auto" : "min-h-52",
|
|
485
|
-
a
|
|
486
|
-
),
|
|
487
|
-
children: e.length === 0 ? /* @__PURE__ */ n.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: u }) : e.map((f) => {
|
|
488
|
-
const o = typeof f.id < "u" ? f.id : g(f, m), D = s.has(o), h = () => {
|
|
489
|
-
t({
|
|
490
|
-
id: o,
|
|
491
|
-
label: String(g(f, j)),
|
|
492
|
-
value: g(f, m)
|
|
493
|
-
});
|
|
494
|
-
};
|
|
495
|
-
return G ? ie.createElement(v(G, (S, E) => S.isSelected === E.isSelected && S.option === E.option && S.disabled === E.disabled && S.multiple === E.multiple), {
|
|
496
|
-
key: o,
|
|
497
|
-
option: f,
|
|
498
|
-
isSelected: D,
|
|
499
|
-
multiple: c,
|
|
500
|
-
onSelect: h,
|
|
501
|
-
disabled: w
|
|
502
|
-
}) : /* @__PURE__ */ n.jsx(
|
|
503
|
-
pe,
|
|
504
|
-
{
|
|
505
|
-
option: f,
|
|
506
|
-
multiple: c,
|
|
507
|
-
isSelected: D,
|
|
508
|
-
onSelect: t,
|
|
509
|
-
disabled: w
|
|
510
|
-
},
|
|
511
|
-
o
|
|
512
|
-
);
|
|
513
|
-
})
|
|
514
|
-
}
|
|
515
|
-
);
|
|
516
|
-
return x ? y : Ee(y, document.body);
|
|
517
|
-
}
|
|
518
|
-
const $e = v(Pe, (e, t) => e.options === t.options && e.selectedOptionsIds === t.selectedOptionsIds && e.multiple === t.multiple && e.disabled === t.disabled && e.emptyMessage === t.emptyMessage && e.renderOption === t.renderOption && e.isOpen === t.isOpen && e.attachToParent === t.attachToParent && e.optionValue === t.optionValue && e.optionLabel === t.optionLabel), pe = v(({ option: e, isSelected: t, onSelect: a, multiple: u, disabled: s }) => (
|
|
519
|
-
// biome-ignore lint/a11y/noStaticElementInteractions: no keyboard interaction needed
|
|
520
|
-
/* @__PURE__ */ n.jsxs(
|
|
521
|
-
"div",
|
|
522
|
-
{
|
|
523
|
-
onMouseDown: (c) => {
|
|
524
|
-
c.preventDefault(), c.stopPropagation(), !s && a?.(e);
|
|
525
|
-
},
|
|
526
|
-
className: l(
|
|
527
|
-
"px-3 py-2 cursor-pointer flex items-center transition-colors text-neutral-default-default ",
|
|
528
|
-
t ? "bg-neutral-medium-selected text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover",
|
|
529
|
-
s && "text-neutral-default-disabled hover:bg-neutral-default-default"
|
|
530
|
-
),
|
|
531
|
-
children: [
|
|
532
|
-
u && /* @__PURE__ */ n.jsx(
|
|
533
|
-
He,
|
|
534
|
-
{
|
|
535
|
-
checked: t,
|
|
536
|
-
disabled: s
|
|
537
|
-
}
|
|
538
|
-
),
|
|
539
|
-
/* @__PURE__ */ n.jsx("span", { children: e.label })
|
|
540
|
-
]
|
|
541
|
-
}
|
|
542
|
-
)
|
|
543
|
-
), (e, t) => e.isSelected === t.isSelected);
|
|
544
|
-
pe.displayName = "DefaultOptionRenderer";
|
|
545
|
-
const xe = v(({ selectedOptions: e, placeholder: t, onRemoveOption: a, displayMode: u, multiple: s, className: c, disabled: x }) => e?.length === 0 ? t ? /* @__PURE__ */ n.jsx("span", { className: "text-neutral-medium-default opacity-50", children: t }) : null : u === "chips" && s ? /* @__PURE__ */ n.jsx("div", { className: l("flex items-center gap-1 ", c), children: e.map((p) => /* @__PURE__ */ n.jsx(
|
|
546
|
-
_e,
|
|
547
|
-
{
|
|
548
|
-
id: p.id,
|
|
549
|
-
label: p.label,
|
|
550
|
-
onRemove: a,
|
|
551
|
-
disabled: x
|
|
552
|
-
},
|
|
553
|
-
p.id
|
|
554
|
-
)) }) : e?.length === 1 ? /* @__PURE__ */ n.jsx("span", { children: e[0].label }) : /* @__PURE__ */ n.jsxs("span", { children: [
|
|
555
|
-
e?.length,
|
|
556
|
-
" seleccionados"
|
|
557
|
-
] }));
|
|
558
|
-
xe.displayName = "DefaultSelectionDisplay";
|
|
1
|
+
import { S as f } from "./Select-CxJFcGuQ.js";
|
|
559
2
|
export {
|
|
560
|
-
|
|
3
|
+
f as default
|
|
561
4
|
};
|
package/dist/SelectFormik.es.js
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import { j as m } from "./jsx-runtime-
|
|
2
|
-
import { useField as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { j as m } from "./jsx-runtime-DKDX3adD.js";
|
|
2
|
+
import { useField as c } from "formik";
|
|
3
|
+
import { S as f } from "./Select-CxJFcGuQ.js";
|
|
4
|
+
import { useRef as d, useEffect as v } from "react";
|
|
5
|
+
function n(r) {
|
|
6
|
+
return Array.isArray(r) && r.every(
|
|
7
|
+
(e) => typeof e == "string" || typeof e == "number"
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
const S = (r) => {
|
|
11
|
+
const [e, o, a] = c(r.name), t = d(!1);
|
|
12
|
+
v(() => {
|
|
13
|
+
t.current || (t.current = !0, n(e.value) || (console.warn(
|
|
14
|
+
`SelectFormik: El valor del campo "${r.name}" no es un array válido de string | number. Valor recibido:`,
|
|
15
|
+
e.value,
|
|
16
|
+
"Inicializando como array vacío."
|
|
17
|
+
), a.setValue([])));
|
|
18
|
+
}, [e.value, a, r.name]);
|
|
19
|
+
const l = (u) => {
|
|
20
|
+
a.setValue(u.map((s) => s.value));
|
|
21
|
+
}, i = n(e.value) ? e.value : [];
|
|
8
22
|
return /* @__PURE__ */ m.jsx(
|
|
9
|
-
|
|
23
|
+
f,
|
|
10
24
|
{
|
|
11
|
-
...
|
|
12
|
-
value:
|
|
13
|
-
onChange:
|
|
14
|
-
variant:
|
|
15
|
-
errorComponent:
|
|
25
|
+
...r,
|
|
26
|
+
value: i,
|
|
27
|
+
onChange: l,
|
|
28
|
+
variant: o.error ? "error" : "default",
|
|
29
|
+
errorComponent: o.error || void 0
|
|
16
30
|
}
|
|
17
31
|
);
|
|
18
32
|
};
|
|
19
33
|
export {
|
|
20
|
-
|
|
34
|
+
S as default
|
|
21
35
|
};
|