prometeo-design-system 2.3.5 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Select.es.js CHANGED
@@ -1,45 +1,45 @@
1
1
  import { j as t } from "./jsx-runtime-ByW6EXIE.js";
2
2
  import { Icons as k } from "./Icons.es.js";
3
3
  import { c as a } from "./cn-B6yFEsav.js";
4
- import ce, { useRef as F, useLayoutEffect as De, memo as z, useState as ie, useMemo as U, useCallback as P, useEffect as Z } from "react";
4
+ import ce, { useRef as F, useLayoutEffect as we, memo as z, useState as ie, useMemo as U, useCallback as P, useEffect as Z } from "react";
5
5
  import Ne from "./Spinner.es.js";
6
6
  import { createPortal as je } from "react-dom";
7
7
  import { u as Ce } from "./useDragScroll-CHN9OMwn.js";
8
8
  import Ee from "./CheckBox.es.js";
9
9
  const He = (r) => {
10
- let s = r;
11
- for (; s && s !== document.body; ) {
12
- const n = window.getComputedStyle(s).backgroundColor;
13
- if (n && n !== "transparent" && n !== "rgba(0, 0, 0, 0)")
14
- return n;
15
- s = s.parentElement;
10
+ let n = r;
11
+ for (; n && n !== document.body; ) {
12
+ const s = window.getComputedStyle(n).backgroundColor;
13
+ if (s && s !== "transparent" && s !== "rgba(0, 0, 0, 0)")
14
+ return s;
15
+ n = n.parentElement;
16
16
  }
17
17
  const u = window.getComputedStyle(document.body).backgroundColor;
18
18
  return u && u !== "transparent" && u !== "rgba(0, 0, 0, 0)" ? u : "rgb(255, 255, 255)";
19
19
  };
20
20
  function Pe() {
21
21
  const r = F(null);
22
- return De(() => {
22
+ return we(() => {
23
23
  if (!r.current || !r.current.parentElement) return;
24
- const s = He(r.current.parentElement);
25
- r.current.style.backgroundColor = s;
24
+ const n = He(r.current.parentElement);
25
+ r.current.style.backgroundColor = n;
26
26
  }, []), {
27
27
  ref: r
28
28
  };
29
29
  }
30
30
  const de = (r) => {
31
- const { variant: s, className: u } = r, c = {
31
+ const { variant: n, className: u } = r, c = {
32
32
  default: "text-neutral-medium-default pt-[1px]",
33
33
  error: "text-error-medium-default pt-[1px]",
34
34
  success: "text-success-medium-default"
35
- }, n = {
35
+ }, s = {
36
36
  default: /* @__PURE__ */ t.jsx(k.Info, { size: 16, className: "text-neutral-medium-default " }),
37
37
  error: /* @__PURE__ */ t.jsx(k.Error, { size: 16, className: "text-error-medium-default" }),
38
38
  success: /* @__PURE__ */ t.jsx(k.Check, { size: 16, className: "text-success-medium-default" })
39
39
  };
40
40
  return /* @__PURE__ */ t.jsx("div", { ref: r.ref, className: a("pl-3", u), children: typeof r.children == "string" ? /* @__PURE__ */ t.jsxs("div", { className: "flex gap-0.5 items-start", children: [
41
- n[s],
42
- /* @__PURE__ */ t.jsx("p", { className: a(" prometeo-fonts-body-small", c[s]), children: r.children })
41
+ s[n],
42
+ /* @__PURE__ */ t.jsx("p", { className: a(" prometeo-fonts-body-small", c[n]), children: r.children })
43
43
  ] }) : r.children });
44
44
  };
45
45
  de.displayName = "HelperText";
@@ -59,30 +59,30 @@ const ke = z(de), ze = {
59
59
  }, oe = {
60
60
  icon: " text-neutral-default-disabled",
61
61
  container: " border-neutral-strong-default text-neutral-default-disabled"
62
- }, fe = ({ id: r, label: s, onRemove: u, className: c, disabled: n, variant: o = "default" }) => /* @__PURE__ */ t.jsxs(
62
+ }, fe = ({ id: r, label: n, onRemove: u, className: c, disabled: s, variant: o = "default" }) => /* @__PURE__ */ t.jsxs(
63
63
  "div",
64
64
  {
65
65
  className: a(
66
66
  "inline-flex max-w-[calc(50%-0.25rem)] items-center gap-1 px-2 py-1 bg-inherit text-xs rounded-lg border",
67
67
  ze[o].container,
68
- n && oe.container
68
+ s && oe.container
69
69
  ),
70
70
  children: [
71
- /* @__PURE__ */ t.jsx("span", { className: "truncate w-max ", children: s }),
71
+ /* @__PURE__ */ t.jsx("span", { className: "truncate w-max ", children: n }),
72
72
  u && /* @__PURE__ */ t.jsx(
73
73
  "button",
74
74
  {
75
75
  onMouseDown: (p) => {
76
- n || (p.stopPropagation(), p.preventDefault(), u?.(r));
76
+ s || (p.stopPropagation(), p.preventDefault(), u?.(r));
77
77
  },
78
78
  className: a(
79
79
  "shrink-0 p-0.5 transition-all duration-200 hover:text-neutral-default-hover cursor-pointer z-50 text-neutral-default-default hover:scale-105",
80
- n && "cursor-default hover:scale-100",
80
+ s && "cursor-default hover:scale-100",
81
81
  c
82
82
  ),
83
83
  type: "button",
84
84
  tabIndex: -1,
85
- children: /* @__PURE__ */ t.jsx(k.Close, { size: 18, className: a(n && oe.icon) })
85
+ children: /* @__PURE__ */ t.jsx(k.Close, { size: 18, className: a(s && oe.icon) })
86
86
  }
87
87
  )
88
88
  ]
@@ -90,14 +90,14 @@ const ke = z(de), ze = {
90
90
  );
91
91
  fe.displayName = "Chip";
92
92
  const Ie = z(fe);
93
- function h(r, s) {
94
- if (typeof s == "function")
95
- return s(r);
96
- const u = s?.split(".");
93
+ function h(r, n) {
94
+ if (typeof n == "function")
95
+ return n(r);
96
+ const u = n?.split(".");
97
97
  let c = r;
98
- for (const n of u)
99
- if (c && typeof c == "object" && n in c)
100
- c = c[n];
98
+ for (const s of u)
99
+ if (c && typeof c == "object" && s in c)
100
+ c = c[s];
101
101
  else
102
102
  return;
103
103
  return c;
@@ -167,14 +167,14 @@ const X = {
167
167
  )
168
168
  }, Se = ({
169
169
  label: r,
170
- onOptionClick: s,
170
+ onOptionClick: n,
171
171
  value: u,
172
172
  isLoading: c = !1,
173
- options: n,
173
+ options: s,
174
174
  multiple: o = !1,
175
175
  onClear: p,
176
176
  onClose: m,
177
- className: d,
177
+ className: i,
178
178
  id: C,
179
179
  emptyMessage: O = "No hay opciones disponibles",
180
180
  optionValue: f,
@@ -188,9 +188,9 @@ const X = {
188
188
  displayMode: B = "compact",
189
189
  onRemoveOption: _,
190
190
  width: M = "100%",
191
- height: w,
191
+ height: D,
192
192
  labelVariant: b = "default",
193
- attachToParent: i = !1,
193
+ attachToParent: d = !1,
194
194
  name: l,
195
195
  overflow: y = "wrap",
196
196
  onChange: g,
@@ -199,20 +199,20 @@ const X = {
199
199
  disabled: E = !1,
200
200
  variant: L = "default"
201
201
  }) => {
202
- const [G, K] = ie(!1), R = F(null), re = F(null), ne = F(null), { ref: pe } = Pe(), { bind: H, ref: ge } = Ce({
202
+ const [G, K] = ie(!1), W = F(null), re = F(null), ne = F(null), { ref: pe } = Pe(), { bind: H, ref: ge } = Ce({
203
203
  axis: "x",
204
204
  cursor: { idle: "default", dragging: "grabbing" }
205
- }), W = u && u.length > 0, q = U(() => n?.filter((e) => u?.includes(h(e, f))), [n, u, f]), he = () => b === "static" ? "relative prometeo-fonts-label-large" : G || W ? "absolute top-0 -translate-y-1/2 left-2 scale-90 px-1 prometeo-fonts-body-medium" : "absolute top-1/2 -translate-y-1/2 scale-100 prometeo-fonts-body-large", J = {}, A = U(() => n.map((e) => ({
205
+ }), A = u && u.length > 0, q = U(() => s?.filter((e) => u?.includes(h(e, f))), [s, u, f]), he = () => b === "static" ? "relative prometeo-fonts-label-large" : G || A ? "absolute top-0 -translate-y-1/2 left-2 scale-90 px-1 prometeo-fonts-body-medium" : "absolute top-1/2 -translate-y-1/2 scale-100 prometeo-fonts-body-large", J = {}, T = U(() => s.map((e) => ({
206
206
  id: h(e, f),
207
207
  value: h(e, f),
208
208
  label: h(e, v)
209
- })), [n, f, v]);
210
- M && M !== "100%" && (J.width = M), w && (J.height = w);
211
- const be = P(() => j ? { height: y === "scroll" ? "48px" : "max-content" } : w ? { height: w } : {}, [w, y, j]);
209
+ })), [s, f, v]);
210
+ M && M !== "100%" && (J.width = M), D && (J.height = D);
211
+ const be = P(() => j ? { height: y === "scroll" ? "48px" : "max-content" } : D ? { height: D } : {}, [D, y, j]);
212
212
  Z(() => {
213
213
  const e = (x) => {
214
- if (R.current) {
215
- if (x.type === "mousedown" && R.current.contains(x.target) || x.type === "scroll" && re.current?.contains(x.target))
214
+ if (W.current) {
215
+ if (x.type === "mousedown" && W.current.contains(x.target) || x.type === "scroll" && re.current?.contains(x.target))
216
216
  return;
217
217
  K(!1);
218
218
  }
@@ -223,30 +223,30 @@ const X = {
223
223
  }, []);
224
224
  const se = P(() => {
225
225
  K((e) => !e);
226
- }, []), T = P((e) => {
226
+ }, []), R = P((e) => {
227
227
  if (o) {
228
- const x = u.includes(e.id);
229
- let D = [];
230
- const ue = A.filter((Q) => u.includes(Q.id));
231
- x ? D = ue.filter((Q) => Q.id !== e.id) : D = [...ue, e], g?.(D, l);
228
+ const x = u?.includes(e.id);
229
+ let w = [];
230
+ const ue = T.filter((Q) => u?.includes(Q.id));
231
+ x ? w = ue.filter((Q) => Q.id !== e.id) : w = [...ue, e], g?.(w, l);
232
232
  } else
233
233
  g?.([e], l);
234
- }, [o, g, l, A, u]), ye = P((e) => {
235
- s?.(e, l), T(e), o || (K(!1), m?.());
236
- }, [o, s, m, l, T]), ve = (e) => {
234
+ }, [o, g, l, T, u]), ye = P((e) => {
235
+ n?.(e, l), R(e), o || (K(!1), m?.());
236
+ }, [o, n, m, l, R]), ve = (e) => {
237
237
  e.preventDefault(), e.stopPropagation(), e.target.blur(), p?.(), g?.([], l);
238
238
  }, ae = P((e) => {
239
239
  o || g?.([], l);
240
- const x = n.find((D) => h(D, f) === e);
240
+ const x = s.find((w) => h(w, f) === e);
241
241
  if (x) {
242
- const D = {
242
+ const w = {
243
243
  id: h(x, f),
244
244
  label: h(x, v),
245
245
  value: h(x, f)
246
246
  };
247
- s?.(D, l), T(D), _?.(x);
247
+ n?.(w, l), R(w), _?.(x);
248
248
  }
249
- }, [s, _, v, f, n, l, o, g, T]), we = U(() => b === "static" && N ? N : "", [b, N]), le = U(
249
+ }, [n, _, v, f, s, l, o, g, R]), De = U(() => b === "static" && N ? N : "", [b, N]), le = U(
250
250
  () => new Set(q.map((e) => h(e, f))),
251
251
  [q, f]
252
252
  );
@@ -255,10 +255,10 @@ const X = {
255
255
  {
256
256
  className: a(
257
257
  "relative bg-inherit select-none w-full",
258
- d,
258
+ i,
259
259
  b === "static" && "mt-2"
260
260
  ),
261
- ref: R,
261
+ ref: W,
262
262
  style: J,
263
263
  draggable: !1,
264
264
  children: [
@@ -272,7 +272,7 @@ const X = {
272
272
  "left-3 pointer-events-none bg-inherit z-10",
273
273
  b === "default" && "transition-all duration-200 ease-in-out",
274
274
  he(),
275
- W || G ? X[L].label : "text-neutral-medium-default",
275
+ A || G ? X[L].label : "text-neutral-medium-default",
276
276
  E && Y.label
277
277
  ),
278
278
  children: r
@@ -294,7 +294,7 @@ const X = {
294
294
  "w-full px-2 text-left border rounded-lg transition-all duration-200 ease-in-out",
295
295
  "flex items-center justify-start bg-inherit gap-2 ",
296
296
  "focus:outline-none",
297
- B === "chips" && o && W ? "min-h-12 py-2" : !w && "h-12 min-h-12",
297
+ B === "chips" && o && A ? "min-h-12 py-2" : !D && "h-12 min-h-12",
298
298
  X[L].input,
299
299
  E && Y.input,
300
300
  $
@@ -327,8 +327,8 @@ const X = {
327
327
  xe,
328
328
  {
329
329
  displayMode: B,
330
- selectedOptions: A.filter((e) => le.has(e.id)),
331
- placeholder: we,
330
+ selectedOptions: T.filter((e) => le.has(e.id)),
331
+ placeholder: De,
332
332
  onRemoveOption: ae,
333
333
  multiple: o,
334
334
  className: a(y === "scroll" ? "flex-nowrap" : "flex-wrap"),
@@ -339,7 +339,7 @@ const X = {
339
339
  ),
340
340
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
341
341
  c && /* @__PURE__ */ t.jsx(Ne, { size: "small", variant: "clip", className: "mt-2", speedMultiplier: 0.7 }),
342
- W && p && /* @__PURE__ */ t.jsx(
342
+ A && p && /* @__PURE__ */ t.jsx(
343
343
  "button",
344
344
  {
345
345
  onMouseDown: (e) => {
@@ -369,14 +369,14 @@ const X = {
369
369
  /* @__PURE__ */ t.jsx(
370
370
  Me,
371
371
  {
372
- options: I ? n : A,
372
+ options: I ? s : T,
373
373
  selectedOptionsIds: le,
374
374
  onOptionClick: ye,
375
375
  emptyMessage: O,
376
376
  dropdownClassName: S,
377
377
  multiple: o,
378
- attachToParent: i,
379
- selectRef: R,
378
+ attachToParent: d,
379
+ selectRef: W,
380
380
  dropdownRef: re,
381
381
  isOpen: G,
382
382
  renderOption: I,
@@ -399,17 +399,17 @@ const X = {
399
399
  ]
400
400
  }
401
401
  );
402
- }, Te = z(Se);
402
+ }, Re = z(Se);
403
403
  function _e({
404
404
  options: r,
405
- onOptionClick: s,
405
+ onOptionClick: n,
406
406
  dropdownClassName: u,
407
407
  emptyMessage: c,
408
- selectedOptionsIds: n,
408
+ selectedOptionsIds: s,
409
409
  multiple: o,
410
410
  attachToParent: p,
411
411
  selectRef: m,
412
- dropdownRef: d,
412
+ dropdownRef: i,
413
413
  isOpen: C,
414
414
  renderOption: O,
415
415
  optionValue: f,
@@ -418,45 +418,45 @@ function _e({
418
418
  disabled: N,
419
419
  labelVariant: j
420
420
  }) {
421
- const $ = j === "static" ? -24 : 4, [S, B] = ie("down"), _ = (i) => {
422
- if (!d.current || !m.current) return;
421
+ const $ = j === "static" ? -24 : 4, [S, B] = ie("down"), _ = (d) => {
422
+ if (!i.current || !m.current) return;
423
423
  const l = m.current.getBoundingClientRect();
424
- switch (i || S) {
424
+ switch (d || S) {
425
425
  case "down":
426
- d.current.style.top = `${l.top + l.height - (I?.current?.offsetHeight ? I?.current?.offsetHeight + 4 : 0)}px`;
426
+ i.current.style.top = `${l.top + l.height - (I?.current?.offsetHeight ? I?.current?.offsetHeight + 4 : 0)}px`;
427
427
  break;
428
428
  case "up":
429
- d.current.style.top = "auto", d.current.style.bottom = `${window.innerHeight - l.top + $}px`;
429
+ i.current.style.top = "auto", i.current.style.bottom = `${window.innerHeight - l.top + $}px`;
430
430
  break;
431
431
  }
432
- d.current.style.left = `${l.left}px`, d.current.style.width = `${l.width}px`;
432
+ i.current.style.left = `${l.left}px`, i.current.style.width = `${l.width}px`;
433
433
  }, M = () => {
434
- if (!d.current || !m.current) return S;
435
- const i = m.current.getBoundingClientRect(), l = i.bottom + 240 < window.innerHeight, y = i.top - 240 - $ > 0;
434
+ if (!i.current || !m.current) return S;
435
+ const d = m.current.getBoundingClientRect(), l = d.bottom + 240 < window.innerHeight, y = d.top - 240 - $ > 0;
436
436
  let g = "down";
437
437
  return l ? g = "down" : y && (g = "up"), g;
438
- }, w = (i) => {
439
- if (!(!d.current || !m.current)) {
440
- if (d.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !i) {
441
- d.current.style.maxHeight = "0", d.current.style.opacity = "0";
438
+ }, D = (d) => {
439
+ if (!(!i.current || !m.current)) {
440
+ if (i.current.style.transition = "max-height 0.2s ease,opacity 0.2s ease", !d) {
441
+ i.current.style.maxHeight = "0", i.current.style.opacity = "0", i.current.style.pointerEvents = "none";
442
442
  return;
443
443
  }
444
444
  if (!p) {
445
445
  const l = M();
446
446
  B(l), _(l);
447
447
  }
448
- d.current.style.maxHeight = "240px", d.current.style.opacity = "1";
448
+ i.current.style.maxHeight = "240px", i.current.style.opacity = "1", i.current.style.pointerEvents = "auto";
449
449
  }
450
450
  };
451
451
  Z(() => {
452
- console.log("mutated selectedOptionsIds", n), !(p || !m.current || !C) && _();
453
- }, [n]), Z(() => {
454
- w(C);
452
+ p || !m.current || !C || _();
453
+ }, [s]), Z(() => {
454
+ D(C);
455
455
  }, [C]);
456
456
  const b = /* @__PURE__ */ t.jsx(
457
457
  "div",
458
458
  {
459
- ref: d,
459
+ ref: i,
460
460
  style: {
461
461
  opacity: "0",
462
462
  maxHeight: "0"
@@ -468,17 +468,17 @@ function _e({
468
468
  S === "up" ? "h-auto" : "min-h-52",
469
469
  u
470
470
  ),
471
- children: r.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: c }) : r.map((i) => {
472
- const l = typeof i.id < "u" ? i.id : h(i, f), y = n.has(l), g = P(() => {
473
- s({
471
+ children: r.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: c }) : r.map((d) => {
472
+ const l = typeof d.id < "u" ? d.id : h(d, f), y = s.has(l), g = P(() => {
473
+ n({
474
474
  id: l,
475
- label: String(h(i, v)),
476
- value: h(i, f)
475
+ label: String(h(d, v)),
476
+ value: h(d, f)
477
477
  });
478
- }, [s, l, v, f, i]);
478
+ }, [n, l, v, f, d]);
479
479
  return O ? ce.createElement(O, {
480
480
  key: l,
481
- option: i,
481
+ option: d,
482
482
  isSelected: y,
483
483
  multiple: o,
484
484
  onSelect: g,
@@ -486,10 +486,10 @@ function _e({
486
486
  }) : /* @__PURE__ */ t.jsx(
487
487
  me,
488
488
  {
489
- option: i,
489
+ option: d,
490
490
  multiple: o,
491
491
  isSelected: y,
492
- onSelect: s,
492
+ onSelect: n,
493
493
  disabled: N
494
494
  },
495
495
  l
@@ -499,25 +499,25 @@ function _e({
499
499
  );
500
500
  return p ? b : je(b, document.body);
501
501
  }
502
- const Me = z(_e), me = z(({ option: r, isSelected: s, onSelect: u, multiple: c, disabled: n }) => (
502
+ const Me = z(_e), me = z(({ option: r, isSelected: n, onSelect: u, multiple: c, disabled: s }) => (
503
503
  // biome-ignore lint/a11y/noStaticElementInteractions: no keyboard interaction needed
504
504
  /* @__PURE__ */ t.jsxs(
505
505
  "div",
506
506
  {
507
507
  onMouseDown: (o) => {
508
- o.preventDefault(), o.stopPropagation(), !n && u?.(r);
508
+ o.preventDefault(), o.stopPropagation(), !s && u?.(r);
509
509
  },
510
510
  className: a(
511
511
  "px-3 py-2 cursor-pointer flex items-center transition-colors text-neutral-default-default ",
512
- s ? "bg-neutral-medium-selected text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover",
513
- n && "text-neutral-default-disabled hover:bg-neutral-default-default"
512
+ n ? "bg-neutral-medium-selected text-primary-default-default" : "hover:bg-neutral-medium-hover text-neutral-default-hover",
513
+ s && "text-neutral-default-disabled hover:bg-neutral-default-default"
514
514
  ),
515
515
  children: [
516
516
  c && /* @__PURE__ */ t.jsx(
517
517
  Ee,
518
518
  {
519
- checked: s,
520
- disabled: n
519
+ checked: n,
520
+ disabled: s
521
521
  }
522
522
  ),
523
523
  /* @__PURE__ */ t.jsx("span", { children: r.label })
@@ -526,7 +526,7 @@ const Me = z(_e), me = z(({ option: r, isSelected: s, onSelect: u, multiple: c,
526
526
  )
527
527
  ));
528
528
  me.displayName = "DefaultOptionRenderer";
529
- const xe = z(({ selectedOptions: r, placeholder: s, onRemoveOption: u, displayMode: c, multiple: n, className: o, disabled: p }) => r?.length === 0 ? s ? /* @__PURE__ */ t.jsx("span", { className: "text-neutral-medium-default opacity-50", children: s }) : null : c === "chips" && n ? /* @__PURE__ */ t.jsx("div", { className: a("flex items-center gap-1 ", o), children: r.map((m) => /* @__PURE__ */ t.jsx(
529
+ const xe = z(({ selectedOptions: r, placeholder: n, onRemoveOption: u, displayMode: c, multiple: s, className: o, disabled: p }) => r?.length === 0 ? n ? /* @__PURE__ */ t.jsx("span", { className: "text-neutral-medium-default opacity-50", children: n }) : null : c === "chips" && s ? /* @__PURE__ */ t.jsx("div", { className: a("flex items-center gap-1 ", o), children: r.map((m) => /* @__PURE__ */ t.jsx(
530
530
  Ie,
531
531
  {
532
532
  id: m.id,
@@ -541,5 +541,5 @@ const xe = z(({ selectedOptions: r, placeholder: s, onRemoveOption: u, displayMo
541
541
  ] }));
542
542
  xe.displayName = "DefaultSelectionDisplay";
543
543
  export {
544
- Te as default
544
+ Re as default
545
545
  };
@@ -1,194 +1,21 @@
1
- import { j as t } from "./jsx-runtime-ByW6EXIE.js";
2
- import { Icons as g } from "./Icons.es.js";
3
- import { c as d } from "./cn-B6yFEsav.js";
4
- import { useField as $, ErrorMessage as q } from "formik";
5
- import { memo as G, useState as k, useRef as H, useEffect as J } from "react";
6
- import K from "./Spinner.es.js";
7
- const Q = ({
8
- label: C,
9
- name: I,
10
- placeholder: b = "",
11
- disabled: j,
12
- containerClassName: S,
13
- className: D,
14
- options: c = [],
15
- multiple: i = !1,
16
- emptyMessage: z = "No hay opciones disponibles",
17
- labelVariant: w = "default",
18
- isFetching: E = !1,
19
- returnFullObject: m = !1
20
- // Por defecto false para mantener compatibilidad
21
- }) => {
22
- const [r, N, o] = $(I), [l, x] = k(!1), [p, A] = k(!1), h = H(null), v = N.touched && N.error, u = (e) => e ? typeof e == "object" && e.id !== void 0 ? e.id : e : null, V = () => r.value ? Array.isArray(r.value) ? r.value.map(u) : u(r.value) : i ? [] : null, f = r.value && (Array.isArray(r.value) ? r.value.length > 0 : typeof r.value == "object" ? r.value.id : r.value?.toString().length > 0), O = () => w === "static" || f || l || p ? "-top-3 left-2 scale-90" : "top-1/2 -translate-y-1/2 scale-100", P = () => {
23
- if (!r.value) return [];
24
- const e = V();
25
- return Array.isArray(e) ? c.filter((a) => e.includes(a.id)) : c.filter((a) => a.id === e);
26
- }, F = (e) => {
27
- if (i) {
28
- const a = Array.isArray(r.value) ? r.value.map(u) : [], s = a.includes(e.id);
29
- if (m) {
30
- const n = Array.isArray(r.value) ? r.value : [], y = s ? n.filter((B) => u(B) !== e.id) : [...n, e];
31
- o.setValue(y);
32
- } else {
33
- const n = s ? a.filter((y) => y !== e.id) : [...a, e.id];
34
- o.setValue(n);
35
- }
36
- } else
37
- o.setValue(m ? e : e.id), x(!1);
38
- }, M = (e) => {
39
- e.stopPropagation(), o.setValue(i ? [] : "");
40
- }, R = (e, a) => {
41
- if (a?.stopPropagation(), i && Array.isArray(r.value))
42
- if (m) {
43
- const s = r.value.filter(
44
- (n) => u(n) !== e
45
- );
46
- o.setValue(s);
47
- } else {
48
- const s = r.value.filter(
49
- (n) => n !== e
50
- );
51
- o.setValue(s);
52
- }
1
+ import { j as m } from "./jsx-runtime-ByW6EXIE.js";
2
+ import { useField as s } from "formik";
3
+ import i from "./Select.es.js";
4
+ const p = (e) => {
5
+ const [o, r, t] = s(e.name), a = (n) => {
6
+ t.setValue(n.map((l) => l.value));
53
7
  };
54
- J(() => {
55
- const e = (a) => {
56
- h.current && !h.current.contains(a.target) && x(!1);
57
- };
58
- return l && document.addEventListener("mousedown", e), () => {
59
- document.removeEventListener("mousedown", e);
60
- };
61
- }, [l]);
62
- const L = () => {
63
- const e = P();
64
- return e.length === 0 ? b ? /* @__PURE__ */ t.jsx("span", { className: "text-neutral-medium-default opacity-50", children: b }) : null : i ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center gap-1 flex-wrap py-1", children: e.map((a) => /* @__PURE__ */ t.jsxs(
65
- "div",
66
- {
67
- className: "inline-flex items-center gap-1 px-2 py-1 bg-primary-default-default text-white text-xs rounded-md",
68
- children: [
69
- /* @__PURE__ */ t.jsx("span", { className: "truncate max-w-20", children: a.label }),
70
- /* @__PURE__ */ t.jsx(
71
- "button",
72
- {
73
- onMouseDown: (s) => {
74
- s.preventDefault(), R(a.id, s);
75
- },
76
- className: "flex-shrink-0 hover:bg-primary-strong-default rounded-sm p-0.5 transition-colors",
77
- type: "button",
78
- tabIndex: -1,
79
- children: /* @__PURE__ */ t.jsx(g.Close, { size: 12, className: "" })
80
- }
81
- )
82
- ]
83
- },
84
- a.id
85
- )) }) : /* @__PURE__ */ t.jsx("span", { children: e[0]?.label });
86
- };
87
- return /* @__PURE__ */ t.jsxs(
88
- "div",
8
+ return /* @__PURE__ */ m.jsx(
9
+ i,
89
10
  {
90
- className: d("relative w-full bg-inherit", S),
91
- ref: h,
92
- children: [
93
- /* @__PURE__ */ t.jsxs("div", { className: "relative bg-inherit", children: [
94
- /* @__PURE__ */ t.jsxs(
95
- "div",
96
- {
97
- onClick: () => !j && x(!l),
98
- onFocus: () => A(!0),
99
- onBlur: () => A(!1),
100
- className: d(
101
- "w-full px-3 h-12 text-left border-1 rounded-lg transition-all duration-300 ease-in-out text-neutral-default-default",
102
- "flex items-center justify-between bg-transparent focus:outline-none",
103
- f || l || p ? " border-primary-default-focused ring-primary-default-focused ring-[2px]" : v ? "ring-error-default-default ring-[2px]" : "border-neutral-default-default hover:border-primary-default-hover",
104
- j && "opacity-50 cursor-not-allowed pointer-events-none",
105
- D
106
- ),
107
- children: [
108
- /* @__PURE__ */ t.jsx(
109
- "label",
110
- {
111
- className: d(
112
- "absolute pointer-events-none bg-inherit px-1 z-10",
113
- w === "default" && "transition-all duration-200 ease-in-out",
114
- "text-md",
115
- O(),
116
- f || l || p ? "text-primary-default-default" : v ? "text-red-500" : "text-neutral-medium-default",
117
- "left-3"
118
- ),
119
- children: C
120
- }
121
- ),
122
- /* @__PURE__ */ t.jsx("div", { className: "flex-1 min-w-0", children: L() }),
123
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2 ml-2", children: [
124
- f && /* @__PURE__ */ t.jsx(
125
- "button",
126
- {
127
- onMouseDown: (e) => {
128
- e.preventDefault(), e.stopPropagation(), M(e);
129
- },
130
- className: "text-neutral-medium-default hover:text-neutral-default-default transition-colors",
131
- type: "button",
132
- tabIndex: -1,
133
- children: /* @__PURE__ */ t.jsx(g.Close, { size: 16, className: "" })
134
- }
135
- ),
136
- E ? /* @__PURE__ */ t.jsx(K, { size: 20, variant: "clip" }) : /* @__PURE__ */ t.jsx(
137
- g.ChevronDown,
138
- {
139
- size: 20,
140
- className: d(
141
- "transition-transform text-neutral-default-default",
142
- l ? "rotate-180" : ""
143
- )
144
- }
145
- )
146
- ] })
147
- ]
148
- }
149
- ),
150
- l && /* @__PURE__ */ t.jsx("div", { className: "absolute z-50 w-full mt-1 bg-neutral-default-default border border-neutral-default-default rounded-md shadow-lg max-h-60 overflow-auto", children: c.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "px-3 py-2 text-neutral-medium-default", children: z }) : c.map((e) => {
151
- const a = V(), s = i ? Array.isArray(a) && a.includes(e.id) : a === e.id;
152
- return /* @__PURE__ */ t.jsxs(
153
- "div",
154
- {
155
- onMouseDown: (n) => {
156
- n.preventDefault(), F(e), n.stopPropagation();
157
- },
158
- className: d(
159
- "px-3 py-2 cursor-pointer flex items-center transition-colors",
160
- s ? "bg-primary-default-default text-white" : "hover:bg-neutral-medium-selected text-neutral-default-default"
161
- ),
162
- children: [
163
- i && /* @__PURE__ */ t.jsx(
164
- "input",
165
- {
166
- type: "checkbox",
167
- checked: s,
168
- onChange: () => {
169
- },
170
- className: "mr-2 pointer-events-none"
171
- }
172
- ),
173
- /* @__PURE__ */ t.jsx("span", { children: e.label })
174
- ]
175
- },
176
- e.id
177
- );
178
- }) })
179
- ] }),
180
- v && /* @__PURE__ */ t.jsx(
181
- q,
182
- {
183
- name: r.name,
184
- component: "span",
185
- className: "block text-error-default-default text-xs mt-1"
186
- }
187
- )
188
- ]
11
+ ...e,
12
+ value: o.value,
13
+ onChange: a,
14
+ variant: r.error ? "error" : "default",
15
+ errorComponent: r.error || void 0
189
16
  }
190
17
  );
191
- }, _ = G(Q);
18
+ };
192
19
  export {
193
- _ as default
20
+ p as default
194
21
  };