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