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
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
import { j as s } from "./jsx-runtime-DKDX3adD.js";
|
|
2
|
+
import { Icons as J } from "./Icons.es.js";
|
|
3
|
+
import { c as i } from "./cn-B6yFEsav.js";
|
|
4
|
+
import De, { memo as R, useState as fe, useRef as G, useMemo as V, useCallback as ee, useEffect as te, useImperativeHandle as We } from "react";
|
|
5
|
+
import Be from "./Spinner.es.js";
|
|
6
|
+
import { createPortal as Ke } from "react-dom";
|
|
7
|
+
import { u as Ue } from "./useDragScroll-CHN9OMwn.js";
|
|
8
|
+
import { u as qe, I as Fe } from "./Input-Bhd0bmVq.js";
|
|
9
|
+
import Ge from "./CheckBox.es.js";
|
|
10
|
+
import { Skeleton as Ce } from "./Skeleton.es.js";
|
|
11
|
+
const He = (r) => {
|
|
12
|
+
const { variant: e, className: f } = r, c = {
|
|
13
|
+
default: "text-neutral-medium-default pt-[1px]",
|
|
14
|
+
error: "text-error-medium-default pt-[1px]",
|
|
15
|
+
success: "text-success-medium-default"
|
|
16
|
+
}, o = {
|
|
17
|
+
default: /* @__PURE__ */ s.jsx(J.Info, { size: 16, className: "text-neutral-medium-default " }),
|
|
18
|
+
error: /* @__PURE__ */ s.jsx(J.Error, { size: 16, className: "text-error-medium-default" }),
|
|
19
|
+
success: /* @__PURE__ */ s.jsx(J.Check, { size: 16, className: "text-success-medium-default" })
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ s.jsx("div", { ref: r.ref, className: i("pl-3", f), children: typeof r.children == "string" ? /* @__PURE__ */ s.jsxs("div", { className: "flex gap-0.5 items-start", children: [
|
|
22
|
+
o[e],
|
|
23
|
+
/* @__PURE__ */ s.jsx("p", { className: i(" prometeo-fonts-body-small", c[e]), children: r.children })
|
|
24
|
+
] }) : r.children });
|
|
25
|
+
};
|
|
26
|
+
He.displayName = "HelperText";
|
|
27
|
+
const Je = R(He), Qe = {
|
|
28
|
+
default: {
|
|
29
|
+
container: "text-neutral-default-default border-neutral-default-default ",
|
|
30
|
+
icon: ""
|
|
31
|
+
},
|
|
32
|
+
error: {
|
|
33
|
+
container: "",
|
|
34
|
+
icon: ""
|
|
35
|
+
},
|
|
36
|
+
success: {
|
|
37
|
+
container: "",
|
|
38
|
+
icon: ""
|
|
39
|
+
}
|
|
40
|
+
}, ke = {
|
|
41
|
+
icon: " text-neutral-default-disabled",
|
|
42
|
+
container: " border-neutral-strong-default text-neutral-default-disabled"
|
|
43
|
+
}, Ie = ({ id: r, label: e, onRemove: f, className: c, disabled: o, variant: a = "default", tabIndex: y }) => /* @__PURE__ */ s.jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
tabIndex: y,
|
|
47
|
+
className: i(
|
|
48
|
+
"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]",
|
|
49
|
+
Qe[a].container,
|
|
50
|
+
o && ke.container
|
|
51
|
+
),
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ s.jsx("span", { className: "truncate w-max ", children: e }),
|
|
54
|
+
f && /* @__PURE__ */ s.jsx(
|
|
55
|
+
"button",
|
|
56
|
+
{
|
|
57
|
+
onMouseDown: (p) => {
|
|
58
|
+
o || (p.stopPropagation(), p.preventDefault(), f?.(r));
|
|
59
|
+
},
|
|
60
|
+
className: i(
|
|
61
|
+
"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",
|
|
62
|
+
o && "cursor-default hover:scale-100",
|
|
63
|
+
c
|
|
64
|
+
),
|
|
65
|
+
type: "button",
|
|
66
|
+
tabIndex: y,
|
|
67
|
+
children: /* @__PURE__ */ s.jsx(J.Close, { size: 18, className: i(o && ke.icon) })
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
Ie.displayName = "Chip";
|
|
74
|
+
const Xe = R(Ie);
|
|
75
|
+
function $(r, e) {
|
|
76
|
+
if (typeof e == "function")
|
|
77
|
+
return e(r);
|
|
78
|
+
const f = e?.split(".");
|
|
79
|
+
let c = r;
|
|
80
|
+
for (const o of f)
|
|
81
|
+
if (c && typeof c == "object" && o in c)
|
|
82
|
+
c = c[o];
|
|
83
|
+
else
|
|
84
|
+
return;
|
|
85
|
+
return c;
|
|
86
|
+
}
|
|
87
|
+
const Ee = (r, e) => {
|
|
88
|
+
if (!e) return !0;
|
|
89
|
+
const f = 0.1, c = String(r).toLowerCase(), o = String(e).toLowerCase().trim();
|
|
90
|
+
if (c.includes(o)) return !0;
|
|
91
|
+
const a = o.split(/\s+/).filter(Boolean), y = a.filter((m) => /^\d+$/.test(m));
|
|
92
|
+
if (a.length > 1 || y.length > 0) {
|
|
93
|
+
for (const m of y)
|
|
94
|
+
if (!new RegExp(`(^|\\D)${m}(\\D|$)`).test(c)) return !1;
|
|
95
|
+
for (const m of a)
|
|
96
|
+
if (!/^\d+$/.test(m) && !c.includes(m))
|
|
97
|
+
return !1;
|
|
98
|
+
return !0;
|
|
99
|
+
}
|
|
100
|
+
if (o.length > c.length) return !1;
|
|
101
|
+
const p = Math.floor(o.length * f);
|
|
102
|
+
if (p <= 0) return !1;
|
|
103
|
+
const C = (m, T) => {
|
|
104
|
+
const v = m.length, w = T.length;
|
|
105
|
+
if (v === 0) return w;
|
|
106
|
+
if (w === 0) return v;
|
|
107
|
+
const N = new Array(w + 1);
|
|
108
|
+
for (let x = 0; x <= w; x++) N[x] = x;
|
|
109
|
+
for (let x = 1; x <= v; x++) {
|
|
110
|
+
let k = x - 1;
|
|
111
|
+
N[0] = x;
|
|
112
|
+
for (let u = 1; u <= w; u++) {
|
|
113
|
+
const O = N[u], B = m.charCodeAt(x - 1) === T.charCodeAt(u - 1) ? 0 : 1, L = N[u] + 1, S = N[u - 1] + 1, z = k + B;
|
|
114
|
+
N[u] = L < S ? L < z ? L : z : S < z ? S : z, k = O;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return N[w];
|
|
118
|
+
};
|
|
119
|
+
for (let m = 0; m <= c.length - o.length; m++) {
|
|
120
|
+
const T = c.slice(m, m + o.length);
|
|
121
|
+
if (C(T, o) <= p) return !0;
|
|
122
|
+
}
|
|
123
|
+
return !1;
|
|
124
|
+
}, ye = {
|
|
125
|
+
default: {
|
|
126
|
+
container: "",
|
|
127
|
+
input: i(
|
|
128
|
+
"border-neutral-default-default text-neutral-default-default",
|
|
129
|
+
"focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
|
|
130
|
+
"hover:border-primary-default-default"
|
|
131
|
+
),
|
|
132
|
+
label: i(
|
|
133
|
+
"text-neutral-medium-default",
|
|
134
|
+
"peer-focus:text-primary-default-default"
|
|
135
|
+
),
|
|
136
|
+
icon: i(
|
|
137
|
+
"text-neutral-medium-default",
|
|
138
|
+
"peer-focus:text-primary-default-default"
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
error: {
|
|
142
|
+
container: "",
|
|
143
|
+
input: i(
|
|
144
|
+
"border-error-default-default text-neutral-default-default hover:border-error-default-hover",
|
|
145
|
+
"focus:border-error-default focus:border-2",
|
|
146
|
+
"focus:ring-0 focus:ring-error-default/20"
|
|
147
|
+
),
|
|
148
|
+
label: i(
|
|
149
|
+
"text-error-light",
|
|
150
|
+
"peer-focus:text-error-light"
|
|
151
|
+
),
|
|
152
|
+
icon: i(
|
|
153
|
+
"text-error-medium-default",
|
|
154
|
+
"peer-focus:text-error-light"
|
|
155
|
+
)
|
|
156
|
+
},
|
|
157
|
+
success: {
|
|
158
|
+
container: "",
|
|
159
|
+
input: i(
|
|
160
|
+
"border-success-default-default text-neutral-default-default",
|
|
161
|
+
"focus:border-success-default focus:border-2",
|
|
162
|
+
"focus:ring-0 focus:ring-success-default/20"
|
|
163
|
+
),
|
|
164
|
+
label: i(
|
|
165
|
+
"text-success",
|
|
166
|
+
"peer-focus:text-success-light"
|
|
167
|
+
),
|
|
168
|
+
icon: i(
|
|
169
|
+
"text-success-medium-default",
|
|
170
|
+
"peer-focus:text-success-light"
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
}, ve = {
|
|
174
|
+
input: i(
|
|
175
|
+
"border-neutral-strong-default text-neutral-default-default",
|
|
176
|
+
"focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
|
|
177
|
+
"hover:border-primary-default-default"
|
|
178
|
+
),
|
|
179
|
+
label: i(
|
|
180
|
+
"text-neutral-medium-disabled",
|
|
181
|
+
"peer-focus:text-primary-default-default"
|
|
182
|
+
),
|
|
183
|
+
icon: i(
|
|
184
|
+
"text-neutral-medium-disabled",
|
|
185
|
+
"peer-focus:text-primary-default-default"
|
|
186
|
+
)
|
|
187
|
+
}, Ye = ({
|
|
188
|
+
id: r,
|
|
189
|
+
name: e,
|
|
190
|
+
value: f,
|
|
191
|
+
label: c,
|
|
192
|
+
height: o,
|
|
193
|
+
options: a,
|
|
194
|
+
controls: y,
|
|
195
|
+
className: p,
|
|
196
|
+
placeholder: C,
|
|
197
|
+
optionValue: m,
|
|
198
|
+
optionLabel: T,
|
|
199
|
+
renderOption: v,
|
|
200
|
+
renderSelection: w,
|
|
201
|
+
buttonClassName: N,
|
|
202
|
+
dropdownClassName: x,
|
|
203
|
+
containerClassName: k,
|
|
204
|
+
dropdownOptions: u,
|
|
205
|
+
helperComponent: O,
|
|
206
|
+
errorComponent: B,
|
|
207
|
+
onRemoveOption: L,
|
|
208
|
+
onOptionClick: S,
|
|
209
|
+
onChange: z,
|
|
210
|
+
onClose: re,
|
|
211
|
+
onClear: K,
|
|
212
|
+
disabled: j = !1,
|
|
213
|
+
overflow: ae = "wrap",
|
|
214
|
+
variant: A = "default",
|
|
215
|
+
multiple: E = !1,
|
|
216
|
+
isLoading: de = !1,
|
|
217
|
+
attachToParent: we = !1,
|
|
218
|
+
displayMode: ne = "compact",
|
|
219
|
+
labelVariant: U = "default",
|
|
220
|
+
disableOpenOnFocus: q = !1,
|
|
221
|
+
emptyMessage: Q = "No hay opciones disponibles"
|
|
222
|
+
}) => {
|
|
223
|
+
const [b, D] = fe(!1), [me, he] = fe([]), [oe, ie] = fe(""), se = G(null), X = G(null), Y = G(null), ce = G(null), le = G(() => {
|
|
224
|
+
}), ue = G(null), Z = G(/* @__PURE__ */ new Set()), { ref: n } = qe(), { bind: l, ref: d } = Ue({
|
|
225
|
+
axis: "x",
|
|
226
|
+
cursor: { idle: "default", dragging: "grabbing" }
|
|
227
|
+
}), h = f && f.length > 0, P = {}, _ = V(() => U === "static" && C ? C : "", [U, C]), M = V(
|
|
228
|
+
() => u?.controledSearchValue || oe,
|
|
229
|
+
[u?.controledSearchValue, oe]
|
|
230
|
+
), H = () => {
|
|
231
|
+
const t = {
|
|
232
|
+
static: {
|
|
233
|
+
active: "relative prometeo-fonts-label-large",
|
|
234
|
+
default: "relative prometeo-fonts-label-large"
|
|
235
|
+
},
|
|
236
|
+
default: {
|
|
237
|
+
active: "absolute top-0 -translate-y-1/2 left-3 px-1 prometeo-fonts-body-small",
|
|
238
|
+
default: "absolute top-1/2 -translate-y-1/2 "
|
|
239
|
+
}
|
|
240
|
+
}, g = b || h ? "active" : "default";
|
|
241
|
+
return t[U][g];
|
|
242
|
+
}, W = (t) => ({
|
|
243
|
+
id: $(t, m),
|
|
244
|
+
value: $(t, m),
|
|
245
|
+
label: $(t, T)
|
|
246
|
+
}), Ne = V(
|
|
247
|
+
() => a.map(W),
|
|
248
|
+
[a]
|
|
249
|
+
), ge = V(
|
|
250
|
+
() => {
|
|
251
|
+
const t = [];
|
|
252
|
+
return f?.forEach((g) => {
|
|
253
|
+
const I = a?.find((F) => $(F, m) === g);
|
|
254
|
+
I && t.push(I);
|
|
255
|
+
}), t;
|
|
256
|
+
},
|
|
257
|
+
[f, m, a]
|
|
258
|
+
), pe = V(
|
|
259
|
+
() => ge.map(W),
|
|
260
|
+
[ge]
|
|
261
|
+
), ze = V(
|
|
262
|
+
() => new Set(pe.map((t) => t.id)),
|
|
263
|
+
[pe]
|
|
264
|
+
), Te = ee(() => {
|
|
265
|
+
D((t) => !t);
|
|
266
|
+
}, []);
|
|
267
|
+
le.current = (t) => {
|
|
268
|
+
let g;
|
|
269
|
+
if (!E)
|
|
270
|
+
g = [t];
|
|
271
|
+
else {
|
|
272
|
+
const I = f || [], F = [], Me = I.includes(t.value);
|
|
273
|
+
I.forEach((be) => {
|
|
274
|
+
const Se = Ne.find((Re) => Re.value === be);
|
|
275
|
+
Se && F.push(Se);
|
|
276
|
+
}), g = Me ? F.filter((be) => be.value !== t.value) : [...F, t];
|
|
277
|
+
}
|
|
278
|
+
z?.(g, e);
|
|
279
|
+
};
|
|
280
|
+
const Ae = ee((t) => {
|
|
281
|
+
S?.(t, e), le.current?.(t), E || (D(!1), re?.());
|
|
282
|
+
}, [E, S, re, e]), $e = (t) => {
|
|
283
|
+
t.preventDefault(), t.stopPropagation(), t.target.blur(), K?.(), z?.([], e);
|
|
284
|
+
}, xe = ee((t) => {
|
|
285
|
+
E || z?.([], e);
|
|
286
|
+
const g = a.find((F) => $(F, m) === t);
|
|
287
|
+
if (!g) return;
|
|
288
|
+
const I = W(g);
|
|
289
|
+
S?.(I, e), le.current?.(I), L?.(g);
|
|
290
|
+
}, [S, L, a, e, E, z]), Oe = ee((t) => {
|
|
291
|
+
xe(t);
|
|
292
|
+
}, [xe]);
|
|
293
|
+
te(() => {
|
|
294
|
+
if (!b) return;
|
|
295
|
+
const t = (g) => {
|
|
296
|
+
const I = g.target;
|
|
297
|
+
if (g.type === "mousedown") {
|
|
298
|
+
if (se.current?.contains(I) || X.current?.contains(I)) return;
|
|
299
|
+
D(!1);
|
|
300
|
+
}
|
|
301
|
+
if (g.type === "scroll") {
|
|
302
|
+
if (X.current?.contains(I)) return;
|
|
303
|
+
D(!1);
|
|
304
|
+
}
|
|
305
|
+
g.type === "resize" && D(!1);
|
|
306
|
+
};
|
|
307
|
+
return document.addEventListener("mousedown", t), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t, !0), () => {
|
|
308
|
+
document.removeEventListener("mousedown", t), window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t, !0);
|
|
309
|
+
};
|
|
310
|
+
}, [b]), te(() => {
|
|
311
|
+
Z.current.forEach((t) => {
|
|
312
|
+
try {
|
|
313
|
+
t(b);
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}, [b]), We(y, () => ({
|
|
318
|
+
open: () => {
|
|
319
|
+
!b && D(!0);
|
|
320
|
+
},
|
|
321
|
+
close: () => {
|
|
322
|
+
b && D(!1);
|
|
323
|
+
},
|
|
324
|
+
toggle: () => D((t) => !t),
|
|
325
|
+
subscribeOpenChange: (t) => (Z.current.add(t), () => {
|
|
326
|
+
Z.current.delete(t);
|
|
327
|
+
}),
|
|
328
|
+
searchInputRef: Y
|
|
329
|
+
}), [b]);
|
|
330
|
+
const Pe = (t) => {
|
|
331
|
+
t.preventDefault(), t.stopPropagation(), t.target.matches(":focus-visible") && !q && !b && (D(!0), setTimeout(() => {
|
|
332
|
+
Y.current?.focus();
|
|
333
|
+
}, 10));
|
|
334
|
+
}, _e = (t) => {
|
|
335
|
+
t.key === "Tab" && b && D(!1), (t.keyCode === 32 || t.key === "ArrowDown") && (D(!0), setTimeout(() => {
|
|
336
|
+
Y.current?.focus();
|
|
337
|
+
}, 10));
|
|
338
|
+
};
|
|
339
|
+
return /* @__PURE__ */ s.jsxs(
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
className: i(
|
|
343
|
+
"relative bg-inherit select-none w-full",
|
|
344
|
+
p,
|
|
345
|
+
U === "static" && "mt-2"
|
|
346
|
+
),
|
|
347
|
+
ref: se,
|
|
348
|
+
draggable: !1,
|
|
349
|
+
style: P,
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ s.jsxs("div", { className: i("relative bg-inherit ", k), children: [
|
|
352
|
+
/* @__PURE__ */ s.jsx(
|
|
353
|
+
"label",
|
|
354
|
+
{
|
|
355
|
+
htmlFor: r,
|
|
356
|
+
ref: n,
|
|
357
|
+
className: i(
|
|
358
|
+
"left-3 pointer-events-none bg-inherit z-10",
|
|
359
|
+
U === "default" && "transition-all duration-200 ease-in-out",
|
|
360
|
+
H(),
|
|
361
|
+
h || b ? ye[A].label : "text-neutral-medium-default",
|
|
362
|
+
j && ve.label
|
|
363
|
+
),
|
|
364
|
+
children: c
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ s.jsxs(
|
|
368
|
+
"div",
|
|
369
|
+
{
|
|
370
|
+
id: r,
|
|
371
|
+
tabIndex: 0,
|
|
372
|
+
role: "button",
|
|
373
|
+
ref: ce,
|
|
374
|
+
onFocus: Pe,
|
|
375
|
+
onKeyDown: _e,
|
|
376
|
+
onClick: (t) => {
|
|
377
|
+
t.preventDefault(), t.stopPropagation(), Te();
|
|
378
|
+
},
|
|
379
|
+
className: i(
|
|
380
|
+
"w-full px-2 text-left border rounded-lg transition-all duration-200 ease-in-out",
|
|
381
|
+
"flex items-center justify-start bg-inherit ",
|
|
382
|
+
"focus:outline-none",
|
|
383
|
+
ne === "chips" && "mt-1.5",
|
|
384
|
+
ne === "chips" && E && h ? "min-h-14 py-3 " : !o && "h-14 min-h-14",
|
|
385
|
+
ye[A].input,
|
|
386
|
+
j && ve.input,
|
|
387
|
+
N
|
|
388
|
+
),
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ s.jsx(
|
|
391
|
+
"div",
|
|
392
|
+
{
|
|
393
|
+
className: i("flex-1 overflow-x-auto overflow-y-hidden px-1 prometeo-scrollbar-none "),
|
|
394
|
+
ref: d,
|
|
395
|
+
onPointerUp: l.onPointerUp,
|
|
396
|
+
onPointerDown: l.onPointerDown,
|
|
397
|
+
onPointerMove: l.onPointerMove,
|
|
398
|
+
onPointerLeave: l.onPointerLeave,
|
|
399
|
+
onPointerCancel: l.onPointerCancel,
|
|
400
|
+
onClickCapture: l.onClickCapture,
|
|
401
|
+
children: w ? De.createElement(
|
|
402
|
+
R(
|
|
403
|
+
w,
|
|
404
|
+
(t, g) => t.disabled === g.disabled && t.multiple === g.multiple
|
|
405
|
+
),
|
|
406
|
+
{
|
|
407
|
+
disabled: j,
|
|
408
|
+
multiple: E,
|
|
409
|
+
placeholder: C,
|
|
410
|
+
selectedOptions: ge,
|
|
411
|
+
onRemoveOption: Oe
|
|
412
|
+
}
|
|
413
|
+
) : /* @__PURE__ */ s.jsx(
|
|
414
|
+
Le,
|
|
415
|
+
{
|
|
416
|
+
displayMode: ne,
|
|
417
|
+
selectedOptions: pe,
|
|
418
|
+
placeholder: _,
|
|
419
|
+
onRemoveOption: xe,
|
|
420
|
+
multiple: E,
|
|
421
|
+
className: i(ae === "scroll" ? "flex-nowrap" : "flex-wrap"),
|
|
422
|
+
disabled: j
|
|
423
|
+
}
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
),
|
|
427
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
428
|
+
de && /* @__PURE__ */ s.jsx(Be, { size: "small", variant: "clip", className: " translate-y-1", speedMultiplier: 0.7 }),
|
|
429
|
+
h && K && /* @__PURE__ */ s.jsx(
|
|
430
|
+
"button",
|
|
431
|
+
{
|
|
432
|
+
onMouseDown: (t) => {
|
|
433
|
+
t.preventDefault(), t.stopPropagation(), $e(t);
|
|
434
|
+
},
|
|
435
|
+
type: "button",
|
|
436
|
+
tabIndex: -1,
|
|
437
|
+
children: /* @__PURE__ */ s.jsx(J.Cancel, { size: 20, className: i(" cursor-pointer transition-all", ye[A].icon) })
|
|
438
|
+
}
|
|
439
|
+
),
|
|
440
|
+
/* @__PURE__ */ s.jsx(
|
|
441
|
+
J.ChevronDown,
|
|
442
|
+
{
|
|
443
|
+
size: 20,
|
|
444
|
+
className: i(
|
|
445
|
+
"transition-transform text-neutral-default-default",
|
|
446
|
+
b ? "rotate-180" : "",
|
|
447
|
+
j && ve.icon
|
|
448
|
+
)
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
] })
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
)
|
|
455
|
+
] }),
|
|
456
|
+
b && /* @__PURE__ */ s.jsx(
|
|
457
|
+
Ve,
|
|
458
|
+
{
|
|
459
|
+
isOpen: b,
|
|
460
|
+
multiple: E,
|
|
461
|
+
disabled: j,
|
|
462
|
+
optionLabel: T,
|
|
463
|
+
optionValue: m,
|
|
464
|
+
labelVariant: U,
|
|
465
|
+
renderOption: v,
|
|
466
|
+
emptyMessage: Q,
|
|
467
|
+
attachToParent: we,
|
|
468
|
+
filteredOptions: me,
|
|
469
|
+
dropdownClassName: x,
|
|
470
|
+
setFilteredOptions: he,
|
|
471
|
+
selectedOptionsIds: ze,
|
|
472
|
+
options: v ? a : Ne,
|
|
473
|
+
selectRef: se,
|
|
474
|
+
dropdownRef: X,
|
|
475
|
+
selectButtonRef: ce,
|
|
476
|
+
helperComponentRef: ue,
|
|
477
|
+
onOptionClick: Ae,
|
|
478
|
+
onCloseDropdown: () => D(!1),
|
|
479
|
+
searchValue: M,
|
|
480
|
+
setSearchValue: ie,
|
|
481
|
+
searchInputRef: Y,
|
|
482
|
+
isLoading: u?.isLoading,
|
|
483
|
+
onSearchClear: u?.onSearchClear,
|
|
484
|
+
hideSearchBar: u?.hideSearchBar,
|
|
485
|
+
dropdownHeight: u?.dropdownHeight,
|
|
486
|
+
onSearchValueChange: u?.onSearchValueChange,
|
|
487
|
+
inputSearchPlaceholder: u?.inputSearchPlaceholder
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
(B || O) && /* @__PURE__ */ s.jsx(
|
|
491
|
+
Je,
|
|
492
|
+
{
|
|
493
|
+
ref: ue,
|
|
494
|
+
variant: A,
|
|
495
|
+
className: "mt-1",
|
|
496
|
+
children: B || O
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
}, ut = R(Ye, (r, e) => r.value === e.value && r.options === e.options && r.isLoading === e.isLoading && r.disabled === e.disabled && r.errorComponent === e.errorComponent && r.helperComponent === e.helperComponent && r.variant === e.variant && r.label === e.label && r.id === e.id && r.name === e.name && r.placeholder === e.placeholder && r.dropdownOptions?.controledSearchValue === e.dropdownOptions?.controledSearchValue && r.dropdownOptions?.isLoading === e.dropdownOptions?.isLoading);
|
|
503
|
+
function Ze({
|
|
504
|
+
isOpen: r,
|
|
505
|
+
options: e,
|
|
506
|
+
multiple: f,
|
|
507
|
+
disabled: c,
|
|
508
|
+
selectRef: o,
|
|
509
|
+
dropdownRef: a,
|
|
510
|
+
optionLabel: y,
|
|
511
|
+
optionValue: p,
|
|
512
|
+
searchValue: C,
|
|
513
|
+
labelVariant: m,
|
|
514
|
+
emptyMessage: T,
|
|
515
|
+
renderOption: v,
|
|
516
|
+
onOptionClick: w,
|
|
517
|
+
onSearchClear: N,
|
|
518
|
+
searchInputRef: x,
|
|
519
|
+
setSearchValue: k,
|
|
520
|
+
dropdownHeight: u,
|
|
521
|
+
attachToParent: O,
|
|
522
|
+
filteredOptions: B,
|
|
523
|
+
selectButtonRef: L,
|
|
524
|
+
onCloseDropdown: S,
|
|
525
|
+
dropdownClassName: z,
|
|
526
|
+
helperComponentRef: re,
|
|
527
|
+
selectedOptionsIds: K,
|
|
528
|
+
setFilteredOptions: j,
|
|
529
|
+
onSearchValueChange: ae,
|
|
530
|
+
isLoading: A = !1,
|
|
531
|
+
hideSearchBar: E = !1,
|
|
532
|
+
inputSearchPlaceholder: de = "Buscar opciones"
|
|
533
|
+
}) {
|
|
534
|
+
const ne = m === "static" ? -20 : 7, q = ee(() => u ? u.endsWith("px") ? Number(u.replace("px", "")) : u.endsWith("vh") ? window.innerHeight * Number(u.replace("vh", "")) / 100 : u.endsWith("%") ? window.innerHeight * Number(u.replace("%", "")) / 100 : 320 : 320, [u])(), [Q, b] = fe({ direction: "down", height: q }), D = (n) => {
|
|
535
|
+
if (!a.current || !o.current) return;
|
|
536
|
+
const l = o.current.getBoundingClientRect();
|
|
537
|
+
switch (n || Q.direction) {
|
|
538
|
+
case "down":
|
|
539
|
+
a.current.style.top = `${l.top + l.height - (re?.current?.offsetHeight ? re?.current?.offsetHeight + 4 : 0)}px`;
|
|
540
|
+
break;
|
|
541
|
+
case "up":
|
|
542
|
+
a.current.style.top = "auto", a.current.style.bottom = `${window.innerHeight - l.top + ne}px`;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
a.current.style.left = `${l.left}px`, a.current.style.width = `${l.width}px`;
|
|
546
|
+
}, me = (n) => {
|
|
547
|
+
a.current && (a.current.style.maxHeight = `${n}px`);
|
|
548
|
+
}, he = () => {
|
|
549
|
+
if (!a.current || !o.current) return Q;
|
|
550
|
+
const n = o.current.getBoundingClientRect(), l = window.innerHeight - (window.innerHeight - n.top), d = window.innerHeight - n.bottom, h = d >= q, P = l >= q;
|
|
551
|
+
let _ = "down", M;
|
|
552
|
+
return h ? (_ = "down", M = q) : P ? (_ = "up", M = q) : d > l ? (_ = "down", M = d - 16) : (_ = "up", M = l - 16), { direction: _, height: M };
|
|
553
|
+
}, oe = (n) => {
|
|
554
|
+
if (!(!a.current || !o.current)) {
|
|
555
|
+
if (a.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !n) {
|
|
556
|
+
a.current.style.maxHeight = "0", a.current.style.opacity = "0", a.current.style.pointerEvents = "none";
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (!O) {
|
|
560
|
+
const l = he();
|
|
561
|
+
b(l), D(l.direction), me(l.height);
|
|
562
|
+
}
|
|
563
|
+
a.current.style.opacity = "1", a.current.style.pointerEvents = "auto";
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
te(() => {
|
|
567
|
+
O || !o.current || !r || D();
|
|
568
|
+
}, [K]), te(() => {
|
|
569
|
+
oe(r);
|
|
570
|
+
}, [r]), te(() => {
|
|
571
|
+
e && j(e);
|
|
572
|
+
}, [e]), te(() => {
|
|
573
|
+
if (A || !C) return;
|
|
574
|
+
const n = ie(e, C);
|
|
575
|
+
j(n);
|
|
576
|
+
}, [e]);
|
|
577
|
+
const ie = (n, l) => n.filter((d) => Ee(v ? $(d, y) : d.label, l)), se = (n) => {
|
|
578
|
+
const l = ie(e, n);
|
|
579
|
+
if (j(l), ae) {
|
|
580
|
+
if (n === "") {
|
|
581
|
+
X();
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
ae(n);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
k && e && k(n);
|
|
588
|
+
}, X = ee(() => {
|
|
589
|
+
if (N) {
|
|
590
|
+
N(), j(
|
|
591
|
+
e.filter((n) => {
|
|
592
|
+
const l = v ? $(n, p) : n.id;
|
|
593
|
+
return K.has(l);
|
|
594
|
+
})
|
|
595
|
+
);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
k && (k(""), j(e));
|
|
599
|
+
}, [e, K, p, N, j, k]), Y = (n) => {
|
|
600
|
+
n.key === "ArrowDown" ? (n.preventDefault(), a.current?.querySelector("[role=listitem]")?.focus()) : (n.key === "Tab" || n.key === "Escape") && setTimeout(() => {
|
|
601
|
+
L.current?.focus(), S();
|
|
602
|
+
}, 10);
|
|
603
|
+
}, ce = (n, l) => {
|
|
604
|
+
const d = Array.from(a.current?.querySelectorAll("[role=listitem]") || []), h = d.indexOf(n.currentTarget);
|
|
605
|
+
if (n.key === "ArrowDown") {
|
|
606
|
+
n.preventDefault();
|
|
607
|
+
const P = h < d.length - 1 ? h + 1 : h;
|
|
608
|
+
d[P]?.focus();
|
|
609
|
+
} else if (n.key === "ArrowUp")
|
|
610
|
+
if (n.preventDefault(), h === 0)
|
|
611
|
+
x && x.current?.focus();
|
|
612
|
+
else {
|
|
613
|
+
const P = h - 1;
|
|
614
|
+
d[P]?.focus();
|
|
615
|
+
}
|
|
616
|
+
else if (n.key === "Enter" || n.key === " ") {
|
|
617
|
+
if (n.preventDefault(), c) return;
|
|
618
|
+
console.log("enter option", l), w(l), f || setTimeout(() => {
|
|
619
|
+
L.current?.focus(), S();
|
|
620
|
+
}, 10);
|
|
621
|
+
} else n.key === "Escape" ? (n.preventDefault(), setTimeout(() => {
|
|
622
|
+
L.current?.focus(), S();
|
|
623
|
+
}, 10)) : n.key === "Tab" && setTimeout(() => {
|
|
624
|
+
L.current?.focus(), S();
|
|
625
|
+
}, 10);
|
|
626
|
+
}, le = Array.from({ length: 5 }).map((n, l) => v ? De.createElement(
|
|
627
|
+
R(
|
|
628
|
+
v,
|
|
629
|
+
(d, h) => d.isSelected === h.isSelected && d.option === h.option && d.disabled === h.disabled && d.multiple === h.multiple
|
|
630
|
+
),
|
|
631
|
+
{
|
|
632
|
+
key: `skeleton-option-${l}`,
|
|
633
|
+
option: { id: l, label: "", value: "" },
|
|
634
|
+
isSelected: !1,
|
|
635
|
+
multiple: !1,
|
|
636
|
+
onSelect: () => {
|
|
637
|
+
},
|
|
638
|
+
disabled: !1,
|
|
639
|
+
isLoading: !0
|
|
640
|
+
}
|
|
641
|
+
) : /* @__PURE__ */ s.jsx(
|
|
642
|
+
je,
|
|
643
|
+
{
|
|
644
|
+
multiple: !1,
|
|
645
|
+
isLoading: !0,
|
|
646
|
+
onSelect: () => {
|
|
647
|
+
},
|
|
648
|
+
isSelected: !1,
|
|
649
|
+
option: { id: l, label: "", value: "" }
|
|
650
|
+
},
|
|
651
|
+
`skeleton-option-${l}`
|
|
652
|
+
)), ue = (n, l) => /* @__PURE__ */ s.jsx(
|
|
653
|
+
"div",
|
|
654
|
+
{
|
|
655
|
+
tabIndex: 0,
|
|
656
|
+
role: "listitem",
|
|
657
|
+
onKeyDown: (d) => ce(d, l),
|
|
658
|
+
className: "focus-visible:bg-neutral-default-hover outline-none",
|
|
659
|
+
children: n
|
|
660
|
+
}
|
|
661
|
+
), Z = /* @__PURE__ */ s.jsx(
|
|
662
|
+
"div",
|
|
663
|
+
{
|
|
664
|
+
tabIndex: 0,
|
|
665
|
+
ref: a,
|
|
666
|
+
style: { opacity: "0" },
|
|
667
|
+
className: i(
|
|
668
|
+
" z-50 w-full mt-1 bg-neutral-default-default border border-neutral-default-default rounded-lg shadow-lg",
|
|
669
|
+
" overflow-hidden focus-visible:bg-neutral-default-hover ",
|
|
670
|
+
O ? "absolute z-50 " : "fixed z-100 top-0 left-0",
|
|
671
|
+
Q.direction === "up" ? "h-auto" : " h-max",
|
|
672
|
+
z
|
|
673
|
+
),
|
|
674
|
+
children: /* @__PURE__ */ s.jsxs(
|
|
675
|
+
"div",
|
|
676
|
+
{
|
|
677
|
+
className: i(
|
|
678
|
+
"flex flex-col ",
|
|
679
|
+
E ? "p-0" : "p-2 pt-0 gap-2"
|
|
680
|
+
),
|
|
681
|
+
style: {
|
|
682
|
+
height: "auto",
|
|
683
|
+
maxHeight: Q.height
|
|
684
|
+
},
|
|
685
|
+
children: [
|
|
686
|
+
!E && /* @__PURE__ */ s.jsx(
|
|
687
|
+
Fe,
|
|
688
|
+
{
|
|
689
|
+
name: "",
|
|
690
|
+
label: "",
|
|
691
|
+
size: "small",
|
|
692
|
+
tabIndex: 0,
|
|
693
|
+
value: C,
|
|
694
|
+
disabled: c,
|
|
695
|
+
ref: x,
|
|
696
|
+
labelVariant: "static",
|
|
697
|
+
icon: /* @__PURE__ */ s.jsx(J.Search, {}),
|
|
698
|
+
isFetching: A,
|
|
699
|
+
onKeyDown: Y,
|
|
700
|
+
onClear: X,
|
|
701
|
+
onChange: se,
|
|
702
|
+
placeholder: de,
|
|
703
|
+
className: " bg-neutral-medium-pressed"
|
|
704
|
+
}
|
|
705
|
+
),
|
|
706
|
+
/* @__PURE__ */ s.jsx("div", { className: " overflow-y-auto flex-1 max-h-max ", children: B.length === 0 ? A ? /* @__PURE__ */ s.jsx("div", { className: "flex flex-col gap-1 overflow-hidden w-full", children: le }) : /* @__PURE__ */ s.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: C ? `No se encontraron resultados para "${C}"` : T }) : B.map((n) => {
|
|
707
|
+
const l = v ? $(n, p) : n.id, d = K.has(l), h = (H) => v ? {
|
|
708
|
+
id: l,
|
|
709
|
+
label: String($(H, y)),
|
|
710
|
+
value: $(H, p)
|
|
711
|
+
} : H, P = () => {
|
|
712
|
+
w(h(n));
|
|
713
|
+
}, _ = (H) => {
|
|
714
|
+
if (w(H), !f) {
|
|
715
|
+
if (!k) return;
|
|
716
|
+
k(""), j(e);
|
|
717
|
+
}
|
|
718
|
+
}, M = v ? De.createElement(
|
|
719
|
+
R(
|
|
720
|
+
v,
|
|
721
|
+
(H, W) => H.isSelected === W.isSelected && H.option === W.option && H.disabled === W.disabled && H.multiple === W.multiple
|
|
722
|
+
),
|
|
723
|
+
{
|
|
724
|
+
key: l,
|
|
725
|
+
option: n,
|
|
726
|
+
isSelected: d,
|
|
727
|
+
multiple: f,
|
|
728
|
+
onSelect: P,
|
|
729
|
+
disabled: c,
|
|
730
|
+
isLoading: A
|
|
731
|
+
}
|
|
732
|
+
) : /* @__PURE__ */ s.jsx(
|
|
733
|
+
je,
|
|
734
|
+
{
|
|
735
|
+
disabled: c,
|
|
736
|
+
multiple: f,
|
|
737
|
+
isLoading: A,
|
|
738
|
+
isSelected: d,
|
|
739
|
+
onSelect: _,
|
|
740
|
+
option: n
|
|
741
|
+
},
|
|
742
|
+
l
|
|
743
|
+
);
|
|
744
|
+
return ue(M, h(n));
|
|
745
|
+
}) })
|
|
746
|
+
]
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
return O ? Z : Ke(Z, document.body);
|
|
752
|
+
}
|
|
753
|
+
const Ve = R(Ze, (r, e) => r.options === e.options && r.selectedOptionsIds === e.selectedOptionsIds && r.multiple === e.multiple && r.disabled === e.disabled && r.emptyMessage === e.emptyMessage && r.renderOption === e.renderOption && r.isOpen === e.isOpen && r.attachToParent === e.attachToParent && r.optionValue === e.optionValue && r.optionLabel === e.optionLabel && r.filteredOptions === e.filteredOptions && r.isLoading === e.isLoading), je = R(({ option: r, isSelected: e, onSelect: f, multiple: c, disabled: o, isLoading: a }) => a ? /* @__PURE__ */ s.jsxs("div", { className: "flex gap-2 w-full px-3 py-2 cursor-wait", children: [
|
|
754
|
+
/* @__PURE__ */ s.jsx(Ce, { className: "size-6 aspect-square" }),
|
|
755
|
+
/* @__PURE__ */ s.jsx(Ce, { className: "flex-1 h-6" })
|
|
756
|
+
] }) : (
|
|
757
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: no keyboard interaction needed
|
|
758
|
+
/* @__PURE__ */ s.jsxs(
|
|
759
|
+
"div",
|
|
760
|
+
{
|
|
761
|
+
onMouseDown: (y) => {
|
|
762
|
+
y.preventDefault(), y.stopPropagation(), !o && f?.(r);
|
|
763
|
+
},
|
|
764
|
+
className: i(
|
|
765
|
+
"px-3 py-2 cursor-pointer flex items-center transition-colors text-neutral-default-default ",
|
|
766
|
+
e ? "bg-neutral-medium-selected text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover",
|
|
767
|
+
o && "text-neutral-default-disabled hover:bg-neutral-default-default"
|
|
768
|
+
),
|
|
769
|
+
children: [
|
|
770
|
+
c && /* @__PURE__ */ s.jsx(
|
|
771
|
+
Ge,
|
|
772
|
+
{
|
|
773
|
+
checked: e,
|
|
774
|
+
disabled: o
|
|
775
|
+
}
|
|
776
|
+
),
|
|
777
|
+
/* @__PURE__ */ s.jsx("span", { children: r.label })
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
)
|
|
781
|
+
), (r, e) => r.isSelected === e.isSelected);
|
|
782
|
+
je.displayName = "DefaultOptionRenderer";
|
|
783
|
+
const Le = R(({ selectedOptions: r, placeholder: e, onRemoveOption: f, displayMode: c, multiple: o, className: a, disabled: y }) => r?.length === 0 ? e ? /* @__PURE__ */ s.jsx("span", { className: "text-neutral-medium-default opacity-50", children: e }) : null : c === "chips" && o ? /* @__PURE__ */ s.jsx("div", { className: i("flex items-center gap-1 ", a), children: r.map((p) => /* @__PURE__ */ s.jsx(
|
|
784
|
+
Xe,
|
|
785
|
+
{
|
|
786
|
+
tabIndex: -1,
|
|
787
|
+
id: p.id,
|
|
788
|
+
label: p.label,
|
|
789
|
+
onRemove: f,
|
|
790
|
+
disabled: y
|
|
791
|
+
},
|
|
792
|
+
p.id
|
|
793
|
+
)) }) : r?.length === 1 ? /* @__PURE__ */ s.jsx("span", { children: r[0].label }) : /* @__PURE__ */ s.jsxs("span", { children: [
|
|
794
|
+
r?.length,
|
|
795
|
+
" seleccionados"
|
|
796
|
+
] }), (r, e) => r.selectedOptions === e.selectedOptions);
|
|
797
|
+
Le.displayName = "DefaultSelectionDisplay";
|
|
798
|
+
export {
|
|
799
|
+
ut as S,
|
|
800
|
+
$ as g
|
|
801
|
+
};
|