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