@mateosuarezdev/react-ui 1.0.5 → 1.0.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/index.js CHANGED
@@ -1,153 +1,486 @@
1
- import { clsx as B } from "clsx";
2
- import { twMerge as T } from "tailwind-merge";
3
- import { jsx as c, jsxs as k } from "react/jsx-runtime";
4
- import { useSyncExternalStore as I, useEffect as x, useRef as v, useCallback as O, forwardRef as $, useState as C, memo as X, useContext as P, createContext as N } from "react";
5
- import { createPortal as z } from "react-dom";
6
- import { atom as F } from "@mateosuarezdev/atoms";
7
- const f = (...e) => T(B(e));
8
- function U(e, r = 100) {
9
- let t = null, o = null;
10
- return function(...s) {
11
- const a = Date.now();
12
- t === null || a - t >= r ? (e.apply(this, s), t = a) : (o && clearTimeout(o), o = setTimeout(() => {
13
- e.apply(this, s), t = Date.now();
14
- }, r - (a - t)));
1
+ import { jsx as f, jsxs as w, Fragment as Te } from "react/jsx-runtime";
2
+ import { useRef as N, useEffect as j, useState as L, useSyncExternalStore as Ke, useCallback as K, useId as ve, forwardRef as H, memo as Be, useContext as xe, createContext as we } from "react";
3
+ import { createPortal as ye } from "react-dom";
4
+ import { clsx as Ve } from "clsx";
5
+ import { twMerge as Xe } from "tailwind-merge";
6
+ import { atom as Ue } from "@mateosuarezdev/atoms";
7
+ import { appendErrors as ke, FormProvider as Ze, useForm as Pe, useFormContext as W, Controller as R } from "react-hook-form";
8
+ import { validateFieldsNatively as me, toNestErrors as be } from "@hookform/resolvers";
9
+ import { Check as Ne, Minus as Ye, DollarSign as qe, CheckIcon as J, EyeOffIcon as Ge, Eye as Je, XIcon as Qe, ChevronDownIcon as He, X as We, Plus as Re } from "lucide-react";
10
+ import { AnimatePresence as et, motion as tt } from "framer-motion";
11
+ const p = (...e) => Xe(Ve(e));
12
+ function ae(e, n = 100) {
13
+ let r = null, t = null;
14
+ return function(...i) {
15
+ const l = Date.now();
16
+ r === null || l - r >= n ? (e.apply(this, i), r = l) : (t && clearTimeout(t), t = setTimeout(() => {
17
+ e.apply(this, i), r = Date.now();
18
+ }, n - (l - r)));
15
19
  };
16
20
  }
17
- function fe(e, r = 500) {
18
- let t = null;
19
- return function(...o) {
20
- t && clearTimeout(t), t = setTimeout(() => {
21
- e.apply(this, o), t = null;
22
- }, r);
21
+ function er(e, n = 500) {
22
+ let r = null;
23
+ return function(...t) {
24
+ r && clearTimeout(r), r = setTimeout(() => {
25
+ e.apply(this, t), r = null;
26
+ }, n);
23
27
  };
24
28
  }
25
- function Y(e) {
29
+ function rt(e) {
26
30
  if (!e) return "";
27
- const t = e.trim().replace(/\s+/g, " ").split(" ");
28
- return t.length === 0 || t[0] === "" ? "" : t.length === 1 ? t[0].charAt(0).toUpperCase() : (t[0].charAt(0) + t[1].charAt(0)).toUpperCase();
31
+ const r = e.trim().replace(/\s+/g, " ").split(" ");
32
+ return r.length === 0 || r[0] === "" ? "" : r.length === 1 ? r[0].charAt(0).toUpperCase() : (r[0].charAt(0) + r[1].charAt(0)).toUpperCase();
29
33
  }
30
- const w = {
34
+ function nt(e) {
35
+ e.focus();
36
+ const n = e.value.length;
37
+ e.setSelectionRange(n, n);
38
+ }
39
+ function st(e) {
40
+ return e.replace(/\s/g, "");
41
+ }
42
+ function tr(e) {
43
+ return e.toLowerCase().split(" ").map((i) => {
44
+ if (i.length === 0) return i;
45
+ const l = [...i][0], s = i.slice(l.length);
46
+ return l.toUpperCase() + s;
47
+ }).join(" ");
48
+ }
49
+ function Ce(e) {
50
+ return e === null ? "" : e;
51
+ }
52
+ function oe(e) {
53
+ return st(e) === "" ? null : e;
54
+ }
55
+ function rr(e, n, r = {}) {
56
+ const t = { ...r };
57
+ return Object.keys(n).forEach((i) => {
58
+ if (n[i] === !0 && i in e) {
59
+ const l = i;
60
+ t[l] = e[l];
61
+ }
62
+ }), t;
63
+ }
64
+ class nr {
65
+ constructor() {
66
+ this.container = null, this.previouslyFocusedElement = null;
67
+ }
68
+ enable() {
69
+ this.container && (this.previouslyFocusedElement = document.activeElement, this.container.addEventListener("keydown", this.trapFocus.bind(this)), document.addEventListener("click", this.handleClickOutside.bind(this)));
70
+ }
71
+ disable() {
72
+ this.container && (this.container.removeEventListener("keydown", this.trapFocus.bind(this)), document.removeEventListener("click", this.handleClickOutside.bind(this)), this.previouslyFocusedElement && this.previouslyFocusedElement.focus && this.previouslyFocusedElement.focus());
73
+ }
74
+ setContainer(n) {
75
+ this.disable(), this.container = n, this.enable();
76
+ }
77
+ trapFocus(n) {
78
+ const r = this.container?.querySelectorAll(
79
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
80
+ );
81
+ if (!r) return;
82
+ const t = r[0], i = r[r.length - 1];
83
+ n.key === "Tab" && (n.shiftKey && document.activeElement === t ? (n.preventDefault(), i.focus()) : !n.shiftKey && document.activeElement === i && (n.preventDefault(), t.focus()));
84
+ }
85
+ handleClickOutside(n) {
86
+ this.container && !this.container.contains(n.target) && (n.preventDefault(), this.previouslyFocusedElement && this.previouslyFocusedElement.focus && this.previouslyFocusedElement.focus());
87
+ }
88
+ }
89
+ const Q = (e) => {
90
+ const n = e.scrollWidth > e.clientWidth, r = e.scrollHeight > e.clientHeight, t = Math.max(0, e.scrollWidth - e.clientWidth), i = Math.max(0, e.scrollHeight - e.clientHeight);
91
+ return {
92
+ horizontal: n,
93
+ vertical: r,
94
+ scrollWidth: e.scrollWidth,
95
+ clientWidth: e.clientWidth,
96
+ scrollHeight: e.scrollHeight,
97
+ clientHeight: e.clientHeight,
98
+ scrollLeft: e.scrollLeft,
99
+ scrollTop: e.scrollTop,
100
+ // Scroll capabilities (require current scroll position)
101
+ canScrollLeft: e.scrollLeft > 10,
102
+ canScrollRight: e.scrollLeft < t - 10,
103
+ canScrollUp: e.scrollTop > 0,
104
+ canScrollDown: e.scrollTop < i,
105
+ // Scroll percentages
106
+ scrollPercentageX: n && t > 0 ? e.scrollLeft / t * 100 : 0,
107
+ scrollPercentageY: r && i > 0 ? e.scrollTop / i * 100 : 0
108
+ };
109
+ }, sr = ({
110
+ onOverflow: e,
111
+ trackScroll: n = !1,
112
+ // New option to enable scroll tracking
113
+ withObserver: r = !1,
114
+ enabled: t = !0,
115
+ deps: i = []
116
+ } = {}) => {
117
+ const l = N(null);
118
+ return j(() => {
119
+ if (!l.current || !t) return;
120
+ let s = !1;
121
+ const a = ae(() => {
122
+ if (l.current) {
123
+ const b = Q(l.current);
124
+ e?.(b);
125
+ }
126
+ }), c = Q(l.current);
127
+ s = c.horizontal || c.vertical, e?.(c), window.addEventListener("resize", a);
128
+ let u = null;
129
+ r && (u = new ResizeObserver(a), l.current && u.observe(l.current));
130
+ let d = null;
131
+ return n && s && (d = l.current, d.addEventListener("scroll", a)), () => {
132
+ window.removeEventListener("resize", a), u && u.disconnect(), d && s && d.removeEventListener("scroll", a);
133
+ };
134
+ }, [t, ...i]), { ref: l };
135
+ }, or = ({
136
+ trackScroll: e = !1,
137
+ withObserver: n = !1,
138
+ enabled: r = !0,
139
+ deps: t = []
140
+ } = {}) => {
141
+ const i = N(null), [l, s] = L(null);
142
+ return j(() => {
143
+ if (!i.current || !r) return;
144
+ let o = !1;
145
+ const c = ae(() => {
146
+ if (i.current) {
147
+ const m = Q(i.current);
148
+ s(m);
149
+ }
150
+ }), u = Q(i.current);
151
+ o = u.horizontal || u.vertical, s(u), window.addEventListener("resize", c);
152
+ let d = null;
153
+ n && (d = new ResizeObserver(c), i.current && d.observe(i.current));
154
+ let b = null;
155
+ return e && o && (b = i.current, b.addEventListener("scroll", c)), () => {
156
+ window.removeEventListener("resize", c), d && d.disconnect(), b && o && b.removeEventListener("scroll", c);
157
+ };
158
+ }, [r, ...t]), { ref: i, overflowInfo: l };
159
+ }, ne = {
31
160
  xs: "w-8 h-8",
32
161
  sm: "w-10 h-10 text-lg",
33
162
  md: "w-14 h-14 text-xl",
34
163
  lg: "h-20 w-20 text-2xl",
35
164
  xl: "h-24 w-24 text-2xl"
36
- }, me = ({
165
+ }, lr = ({
37
166
  src: e,
38
- name: r,
39
- size: t = "md",
40
- className: o
41
- }) => e ? /* @__PURE__ */ c(
167
+ name: n,
168
+ size: r = "md",
169
+ className: t
170
+ }) => e ? /* @__PURE__ */ f(
42
171
  "img",
43
172
  {
44
173
  alt: "avatar",
45
174
  src: e,
46
- className: f("rounded-full bg-base-3", w[t])
175
+ className: p("rounded-full bg-base-3", ne[r])
47
176
  }
48
- ) : r ? /* @__PURE__ */ c(
177
+ ) : n ? /* @__PURE__ */ f(
49
178
  "p",
50
179
  {
51
- className: f(
180
+ className: p(
52
181
  "rounded-full font-medium dark-theme:bg-base-3 border border-base-6 dark-theme:border-base-4 flex items-center justify-center",
53
- w[t],
54
- o
182
+ ne[r],
183
+ t
55
184
  ),
56
- children: Y(r)
185
+ children: rt(n)
57
186
  }
58
- ) : /* @__PURE__ */ c(
187
+ ) : /* @__PURE__ */ f(
59
188
  "div",
60
189
  {
61
- className: f(
190
+ className: p(
62
191
  "rounded-full text-2xl font-medium flex items-center justify-center",
63
192
  "bg-base-2 dark-theme:bg-base-3 border border-base-4",
64
193
  "lg:hover:bg-base-3 max-lg:active:bg-base-4 transition-colors",
65
- w[t],
66
- o
194
+ ne[r],
195
+ t
67
196
  ),
68
- children: /* @__PURE__ */ k(
69
- oe,
197
+ children: /* @__PURE__ */ w(
198
+ xt,
70
199
  {
71
- size: t === "xs" ? 16 : t === "sm" ? 20 : 24,
200
+ size: r === "xs" ? 16 : r === "sm" ? 20 : 24,
72
201
  fill: "none",
73
202
  stroke: "currentColor",
74
203
  strokeWidth: 2,
75
204
  strokeLinecap: "round",
76
205
  strokeLinejoin: "round",
77
206
  children: [
78
- /* @__PURE__ */ c("path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }),
79
- /* @__PURE__ */ c("circle", { cx: "12", cy: "7", r: "4" })
207
+ /* @__PURE__ */ f("path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }),
208
+ /* @__PURE__ */ f("circle", { cx: "12", cy: "7", r: "4" })
80
209
  ]
81
210
  }
82
211
  )
83
212
  }
84
213
  );
85
- function he({
214
+ function ir({
86
215
  className: e,
87
- children: r,
88
- animate: t = !1,
89
- ...o
216
+ children: n,
217
+ animate: r = !1,
218
+ ...t
90
219
  }) {
91
- return /* @__PURE__ */ c(
220
+ return /* @__PURE__ */ f(
92
221
  "div",
93
222
  {
94
- className: f("flex -space-x-3 rtl:space-x-reverse", e),
95
- ...o,
96
- children: r
223
+ className: p("flex -space-x-3 rtl:space-x-reverse", e),
224
+ ...t,
225
+ children: n
97
226
  }
98
227
  );
99
228
  }
100
- function G(e) {
101
- return I(
102
- (r) => e.subscribe(r),
229
+ function ot(e) {
230
+ return Ke(
231
+ (n) => e.subscribe(n),
103
232
  () => e.get(),
104
233
  () => e.get()
105
234
  );
106
235
  }
107
- const A = F(!0);
108
- let y = !1;
109
- const S = U(() => {
110
- A.set(window.innerWidth > 1024);
236
+ const le = Ue(!0);
237
+ let se = !1;
238
+ const pe = ae(() => {
239
+ le.set(window.innerWidth > 1024);
111
240
  });
112
- typeof window < "u" && (y && (window.removeEventListener("resize", S), y = !1), window.addEventListener("resize", S), y = !0);
113
- const H = () => (x(() => {
114
- A.set(window.innerWidth > 1024);
115
- }, []), G(A));
116
- function _(...e) {
117
- return (r) => {
118
- e.forEach((t) => {
119
- typeof t == "function" ? t(r) : t != null && (t.current = r);
241
+ typeof window < "u" && (se && (window.removeEventListener("resize", pe), se = !1), window.addEventListener("resize", pe), se = !0);
242
+ const lt = () => (j(() => {
243
+ le.set(window.innerWidth > 1024);
244
+ }, []), ot(le));
245
+ function it(...e) {
246
+ return (n) => {
247
+ e.forEach((r) => {
248
+ typeof r == "function" ? r(n) : r != null && (r.current = n);
120
249
  });
121
250
  };
122
251
  }
123
- const q = (e = !0, r) => {
124
- const t = H(), o = v(null), s = O(
125
- (a) => {
126
- if (!e || t) return;
127
- const b = o.current;
128
- if (!b) return;
129
- const n = b.getBoundingClientRect(), l = Math.max(n.width, n.height), i = a.clientX - n.left - l / 2, u = a.clientY - n.top - l / 2, d = document.createElement("span");
252
+ const at = (e = !0, n) => {
253
+ const r = lt(), t = N(null), i = K(
254
+ (l) => {
255
+ if (!e || r) return;
256
+ const s = t.current;
257
+ if (!s) return;
258
+ const o = s.getBoundingClientRect(), a = Math.max(o.width, o.height), c = l.clientX - o.left - a / 2, u = l.clientY - o.top - a / 2, d = document.createElement("span");
130
259
  d.classList.add("ripple-wrapper");
131
- const p = document.createElement("span");
132
- p.classList.add("ripple"), p.style.backgroundColor = r ? "var(--ripple-contrast)" : "var(--ripple-main)", p.style.width = `${l}px`, p.style.height = `${l}px`, p.style.left = `${i}px`, p.style.top = `${u}px`, d.appendChild(p);
133
- const g = b.getElementsByClassName("ripple-wrapper");
134
- if (g?.length)
135
- for (const m of g)
136
- m.remove();
137
- b.appendChild(d), setTimeout(() => {
260
+ const b = document.createElement("span");
261
+ b.classList.add("ripple"), b.style.backgroundColor = n ? "var(--ripple-contrast)" : "var(--ripple-main)", b.style.width = `${a}px`, b.style.height = `${a}px`, b.style.left = `${c}px`, b.style.top = `${u}px`, d.appendChild(b);
262
+ const m = s.getElementsByClassName("ripple-wrapper");
263
+ if (m?.length)
264
+ for (const g of m)
265
+ g.remove();
266
+ s.appendChild(d), setTimeout(() => {
138
267
  d.remove();
139
268
  }, 700);
140
269
  },
141
- [e, t, r]
270
+ [e, r, n]
142
271
  );
143
272
  return {
144
- ref: o,
145
- ripple: s,
273
+ ref: t,
274
+ ripple: i,
146
275
  styles: {
147
276
  position: "relative"
148
277
  }
149
278
  };
150
- }, J = "relative shrink-0 select-none transition outline-none duration-200 ease-out focus:ring-border-brand-light flex items-center justify-center cursor-pointer", Q = {
279
+ }, ct = ({
280
+ // routerMode = "outlet",
281
+ scrollerId: e,
282
+ // useScrollerSuffix,
283
+ align: n = "start",
284
+ side: r = "bottom",
285
+ offset: t = 8,
286
+ collisionPadding: i = 8,
287
+ avoidCollisions: l = !0,
288
+ closeOnScroll: s = !0,
289
+ // observeResize = false,
290
+ onOpen: o,
291
+ onClose: a
292
+ } = {}) => {
293
+ const [c, u] = L(!1), [d, b] = L({
294
+ width: 192,
295
+ height: 300
296
+ }), m = N(null), g = N(null), v = N({
297
+ left: 0,
298
+ right: 0,
299
+ top: 0,
300
+ bottom: 0,
301
+ x: 0,
302
+ y: 0,
303
+ width: 0,
304
+ height: 0
305
+ }), x = N(null), A = ve(), F = K(
306
+ (E) => {
307
+ const z = E ?? v.current;
308
+ if (!z) return { x: 0, top: 0, bottom: void 0 };
309
+ const _ = d.width, B = d.height;
310
+ return ut({
311
+ triggerRect: z,
312
+ popoverWidth: _,
313
+ popoverHeight: B,
314
+ align: n,
315
+ side: r,
316
+ offset: t,
317
+ collisionPadding: i,
318
+ avoidCollisions: l
319
+ });
320
+ },
321
+ [v.current, d, n, r]
322
+ );
323
+ j(() => {
324
+ if (!c || !e || (x.current = document.getElementById(e), !x.current)) return;
325
+ c && O();
326
+ const E = () => {
327
+ x.current && (u(!1), o?.(), x.current.removeEventListener("scroll", E));
328
+ };
329
+ return s && x.current.addEventListener("scroll", E, {
330
+ passive: !0
331
+ }), () => {
332
+ x.current && x.current.removeEventListener("scroll", E);
333
+ };
334
+ }, [c, e]);
335
+ const O = () => {
336
+ g.current && b({
337
+ width: g.current.offsetWidth,
338
+ height: g.current.offsetHeight
339
+ });
340
+ }, S = K(() => {
341
+ if (!m.current) return;
342
+ const E = m.current.getBoundingClientRect();
343
+ v.current = {
344
+ left: E.left,
345
+ right: E.right,
346
+ top: E.top,
347
+ bottom: E.bottom,
348
+ x: E.x,
349
+ y: E.y,
350
+ width: E.width,
351
+ height: E.height
352
+ }, u((z) => (z ? a?.() : o?.(), !z));
353
+ }, []), $ = K(() => {
354
+ u(!1), a?.();
355
+ }, []);
356
+ return {
357
+ triggerRef: m,
358
+ triggerProps: {
359
+ id: A,
360
+ "aria-expanded": c,
361
+ "aria-haspopup": !0
362
+ },
363
+ popoverRef: g,
364
+ // popoverPosition,
365
+ /**
366
+ * Call this sync before rendering the popover
367
+ */
368
+ getPopoverPosition: F,
369
+ open: c,
370
+ toggle: S,
371
+ close: $
372
+ };
373
+ }, ut = ({
374
+ triggerRect: e,
375
+ popoverWidth: n,
376
+ popoverHeight: r,
377
+ align: t = "start",
378
+ side: i = "bottom",
379
+ offset: l = 4,
380
+ collisionPadding: s = 8,
381
+ avoidCollisions: o = !0
382
+ }) => {
383
+ const a = {
384
+ width: window.innerWidth,
385
+ height: window.innerHeight
386
+ };
387
+ let c = 0, u = 0;
388
+ if (o) {
389
+ if (i === "right") {
390
+ const m = e.right + l, g = e.left - n - l, v = Math.max(
391
+ 0,
392
+ m + n - (a.width - s)
393
+ ), x = Math.max(0, s - g);
394
+ v <= x ? (c = m, v > 0 && (c = a.width - n - s)) : (c = g, x > 0 && (c = s)), u = e.top, u + r > a.height - s && (u = a.height - r - s), u < s && (u = s);
395
+ } else if (i === "left") {
396
+ const m = e.left - n - l, g = e.right + l, v = Math.max(0, s - m), x = Math.max(
397
+ 0,
398
+ g + n - (a.width - s)
399
+ );
400
+ v <= x ? (c = m, v > 0 && (c = s)) : (c = g, x > 0 && (c = a.width - n - s)), u = e.top, u + r > a.height - s && (u = a.height - r - s), u < s && (u = s);
401
+ } else if (i === "bottom") {
402
+ const m = a.height - e.bottom, g = e.top;
403
+ m >= r + l ? u = e.bottom + l : g >= r + l ? u = e.top - r - l : (u = e.bottom + l, u = Math.min(u, a.height - r - s));
404
+ const v = a.width - e.left, x = e.right;
405
+ if (t === "start")
406
+ c = e.left, c + n > a.width - s && (x >= n ? c = e.right - n : c = a.width - n - s);
407
+ else if (t === "end")
408
+ c = e.right - n, c < s && (v >= n ? c = e.left : c = s);
409
+ else {
410
+ const A = e.left + e.width / 2 - n / 2;
411
+ A >= s && A + n <= a.width - s ? c = A : A < s ? c = s : c = a.width - n - s;
412
+ }
413
+ } else {
414
+ const m = e.top, g = a.height - e.bottom;
415
+ m >= r + l ? u = e.top - r - l : g >= r + l ? u = e.bottom + l : (u = e.top - r - l, u = Math.max(s, u));
416
+ const v = a.width - e.left, x = e.right;
417
+ if (t === "start")
418
+ c = e.left, c + n > a.width - s && (x >= n ? c = e.right - n : c = a.width - n - s);
419
+ else if (t === "end")
420
+ c = e.right - n, c < s && (v >= n ? c = e.left : c = s);
421
+ else {
422
+ const A = e.left + e.width / 2 - n / 2;
423
+ A >= s && A + n <= a.width - s ? c = A : A < s ? c = s : c = a.width - n - s;
424
+ }
425
+ }
426
+ c = Math.max(
427
+ s,
428
+ Math.min(c, a.width - n - s)
429
+ ), u = Math.max(
430
+ s,
431
+ Math.min(u, a.height - r - s)
432
+ );
433
+ } else
434
+ i === "right" ? (c = e.right + l, u = e.top) : i === "left" ? (c = e.left - n - l, u = e.top) : i === "bottom" ? u = e.bottom + l : u = e.top - r - l, (i === "top" || i === "bottom") && (t === "start" ? c = e.left : t === "end" ? c = e.right - n : c = e.left + e.width / 2 - n / 2);
435
+ let d, b;
436
+ return u + r <= e.top ? b = window.innerHeight - (u + r) : d = u, { x: c, top: d, bottom: b };
437
+ };
438
+ function ar(e) {
439
+ const n = N(null);
440
+ return j(() => {
441
+ const r = (t) => {
442
+ n.current && !n.current.contains(t.target) && e();
443
+ };
444
+ return document.addEventListener("mousedown", r), () => {
445
+ document.removeEventListener("mousedown", r);
446
+ };
447
+ }, [e]), n;
448
+ }
449
+ function cr(e, n = {}) {
450
+ const {
451
+ enabled: r = !0,
452
+ events: t = ["mousedown", "touchstart"],
453
+ excludeRefs: i = []
454
+ } = n, l = N(null);
455
+ return j(() => {
456
+ if (!r) return;
457
+ const s = (o) => {
458
+ const a = o.target;
459
+ l.current?.contains(a) || i.some(
460
+ (u) => u.current?.contains(a)
461
+ ) || e();
462
+ };
463
+ return t.forEach((o) => {
464
+ document.addEventListener(o, s);
465
+ }), () => {
466
+ t.forEach((o) => {
467
+ document.removeEventListener(o, s);
468
+ });
469
+ };
470
+ }, [e, r, t, i]), l;
471
+ }
472
+ function ft(e, n, r = !0) {
473
+ j(() => {
474
+ if (!r) return;
475
+ const t = (i) => {
476
+ e.current && !e.current.contains(i.target) && n(i);
477
+ };
478
+ return document.addEventListener("mousedown", t), () => {
479
+ document.removeEventListener("mousedown", t);
480
+ };
481
+ }, [e, n, r]);
482
+ }
483
+ const dt = "relative shrink-0 select-none transition outline-none duration-200 ease-out focus:ring-border-brand-light flex items-center justify-center cursor-pointer", ht = {
151
484
  xs: "text-xs px-1 gap-x-0.5 py-1",
152
485
  sm: "text-sm px-2.5 gap-x-1 py-1.5",
153
486
  mdsm: "text-sm px-3 gap-x-1.5 py-2.5",
@@ -158,18 +491,18 @@ const q = (e = !0, r) => {
158
491
  iconSm: "text-sm p-2",
159
492
  iconMd: "text-base p-3",
160
493
  iconLg: "text-base p-4"
161
- }, V = {
494
+ }, mt = {
162
495
  all: "focus:ring-1",
163
496
  desktop: "lg:focus:ring-1",
164
497
  mobile: "focus:ring-1 lg:focus-ring-0",
165
498
  none: ""
166
- }, Z = {
499
+ }, bt = {
167
500
  light: "font-light",
168
501
  normal: "font-normal",
169
502
  medium: "font-medium",
170
503
  semibold: "font-semibold",
171
504
  bold: "font-bold"
172
- }, ee = {
505
+ }, pt = {
173
506
  none: "rounded-none",
174
507
  1: "rounded-1",
175
508
  2: "rounded-2",
@@ -184,7 +517,7 @@ const q = (e = !0, r) => {
184
517
  11: "rounded-11",
185
518
  12: "rounded-12",
186
519
  full: "rounded-full"
187
- }, te = {
520
+ }, gt = {
188
521
  transparent: "text-base-12 lg:hover:bg-base-4 focus:ring-base-6",
189
522
  transparentinactive: "text-base-11 lg:hover:bg-base-4",
190
523
  brand: "bg-brand text-brand-text lg:hover:bg-brand-hover focus:ring-base-6 border border-transparent",
@@ -199,144 +532,1444 @@ const q = (e = !0, r) => {
199
532
  danger: "bg-red-4 text-red-9 lg:hover:bg-red-5 focus:ring-red-9 border border-transparent",
200
533
  dangersolid: "bg-red-9 text-base-1 dark-theme:text-base-12 lg:hover:bg-red-8 focus:ring-base-6 border border-transparent",
201
534
  disabled: "bg-base-3 text-base-11 border border-transparent"
202
- }, re = {
535
+ }, vt = {
203
536
  enabled: "",
204
537
  disabled: "opacity-75",
205
538
  loading: ""
206
- }, ne = $(
539
+ }, ie = H(
207
540
  ({
208
541
  color: e = "transparent",
209
- size: r = "mdsm",
210
- fontWeight: t = "normal",
211
- rounded: o = "6",
212
- state: s = "enabled",
213
- onClick: a,
214
- className: b,
215
- children: n,
216
- withRipple: l = !0,
217
- contrastRipple: i,
542
+ size: n = "mdsm",
543
+ fontWeight: r = "normal",
544
+ rounded: t = "6",
545
+ state: i = "enabled",
546
+ onClick: l,
547
+ className: s,
548
+ children: o,
549
+ withRipple: a = !0,
550
+ contrastRipple: c,
218
551
  showFocus: u = "desktop",
219
552
  withDisabledDelay: d = !1,
220
- type: p = "button",
221
- ...g
222
- }, m) => {
223
- const [K, E] = C(!1), L = (h) => {
224
- s === "enabled" && (d ? (E(!0), a && a(h), setTimeout(() => E(!1), 1e3)) : a && a(h));
225
- }, { ref: j, ripple: D } = q(
226
- l,
227
- e === "contrast" || i
228
- ), W = _(j, m);
229
- return /* @__PURE__ */ c(
553
+ type: b = "button",
554
+ ...m
555
+ }, g) => {
556
+ const [v, x] = L(!1), A = ($) => {
557
+ i === "enabled" && (d ? (x(!0), l && l($), setTimeout(() => x(!1), 1e3)) : l && l($));
558
+ }, { ref: F, ripple: O } = at(
559
+ a,
560
+ e === "contrast" || c
561
+ ), S = it(F, g);
562
+ return /* @__PURE__ */ f(
230
563
  "button",
231
564
  {
232
- ref: W,
233
- type: p,
234
- disabled: g.disabled ? g.disabled : s === "disabled" || s === "loading",
235
- onMouseDown: D,
236
- onClick: (h) => K ? null : L(h),
237
- className: f(
238
- J,
239
- Q[r],
240
- Z[t],
241
- ee[o],
242
- V[u],
243
- te[e],
244
- re[s],
245
- g.disabled && "opacity-50",
246
- b
565
+ ref: S,
566
+ type: b,
567
+ disabled: m.disabled ? m.disabled : i === "disabled" || i === "loading",
568
+ onMouseDown: O,
569
+ onClick: ($) => v ? null : A($),
570
+ className: p(
571
+ dt,
572
+ ht[n],
573
+ bt[r],
574
+ pt[t],
575
+ mt[u],
576
+ gt[e],
577
+ vt[i],
578
+ m.disabled && "opacity-50",
579
+ s
247
580
  ),
248
- ...g,
249
- children: n
581
+ ...m,
582
+ children: o
250
583
  }
251
584
  );
252
585
  }
253
586
  );
254
- ne.displayName = "Button";
255
- const xe = ({ className: e }) => /* @__PURE__ */ c("div", { className: f("w-full h-px bg-base-4", e) }), oe = ({
587
+ ie.displayName = "Button";
588
+ const ur = ({ className: e }) => /* @__PURE__ */ f("div", { className: p("w-full h-px bg-base-4", e) }), xt = ({
256
589
  children: e,
257
- size: r = 24,
258
- strokeWidth: t = 2,
259
- viewBox: o = "0 0 24 24",
260
- className: s,
261
- ...a
262
- }) => /* @__PURE__ */ c(
590
+ size: n = 24,
591
+ strokeWidth: r = 2,
592
+ viewBox: t = "0 0 24 24",
593
+ className: i,
594
+ ...l
595
+ }) => /* @__PURE__ */ f(
263
596
  "svg",
264
597
  {
265
598
  xmlns: "http://www.w3.org/2000/svg",
266
- width: r,
267
- height: r,
268
- viewBox: o,
269
- className: s,
270
- ...a,
599
+ width: n,
600
+ height: n,
601
+ viewBox: t,
602
+ className: i,
603
+ ...l,
271
604
  children: e
272
605
  }
273
- ), M = N(null), se = ({
606
+ ), wt = ({
607
+ loading: e = !0,
608
+ wrapperClassName: n,
609
+ spinnerClassName: r
610
+ }) => /* @__PURE__ */ f("div", { className: p("flex justify-center", n), children: /* @__PURE__ */ f(
611
+ "svg",
612
+ {
613
+ xmlns: "http://www.w3.org/2000/svg",
614
+ width: "20",
615
+ height: "20",
616
+ viewBox: "0 0 20 20",
617
+ className: p({ "animate-spin": e }, r),
618
+ children: /* @__PURE__ */ f(
619
+ "path",
620
+ {
621
+ fill: "currentColor",
622
+ d: "M10 3a7 7 0 0 0-7 7a.5.5 0 0 1-1 0a8 8 0 1 1 8 8a.5.5 0 0 1 0-1a7 7 0 1 0 0-14Z"
623
+ }
624
+ )
625
+ }
626
+ ) }), yt = ({ children: e, node: n }) => ye(e, n ?? document.body);
627
+ function Ee(e, n, r) {
628
+ function t(o, a) {
629
+ var c;
630
+ Object.defineProperty(o, "_zod", {
631
+ value: o._zod ?? {},
632
+ enumerable: !1
633
+ }), (c = o._zod).traits ?? (c.traits = /* @__PURE__ */ new Set()), o._zod.traits.add(e), n(o, a);
634
+ for (const u in s.prototype)
635
+ u in o || Object.defineProperty(o, u, { value: s.prototype[u].bind(o) });
636
+ o._zod.constr = s, o._zod.def = a;
637
+ }
638
+ const i = r?.Parent ?? Object;
639
+ class l extends i {
640
+ }
641
+ Object.defineProperty(l, "name", { value: e });
642
+ function s(o) {
643
+ var a;
644
+ const c = r?.Parent ? new l() : this;
645
+ t(c, o), (a = c._zod).deferred ?? (a.deferred = []);
646
+ for (const u of c._zod.deferred)
647
+ u();
648
+ return c;
649
+ }
650
+ return Object.defineProperty(s, "init", { value: t }), Object.defineProperty(s, Symbol.hasInstance, {
651
+ value: (o) => r?.Parent && o instanceof r.Parent ? !0 : o?._zod?.traits?.has(e)
652
+ }), Object.defineProperty(s, "name", { value: e }), s;
653
+ }
654
+ class kt extends Error {
655
+ constructor() {
656
+ super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
657
+ }
658
+ }
659
+ const Nt = {};
660
+ function Ae(e) {
661
+ return Nt;
662
+ }
663
+ function Ct(e, n) {
664
+ return typeof n == "bigint" ? n.toString() : n;
665
+ }
666
+ const Fe = Error.captureStackTrace ? Error.captureStackTrace : (...e) => {
667
+ };
668
+ function q(e) {
669
+ return typeof e == "string" ? e : e?.message;
670
+ }
671
+ function Se(e, n, r) {
672
+ const t = { ...e, path: e.path ?? [] };
673
+ if (!e.message) {
674
+ const i = q(e.inst?._zod.def?.error?.(e)) ?? q(n?.error?.(e)) ?? q(r.customError?.(e)) ?? q(r.localeError?.(e)) ?? "Invalid input";
675
+ t.message = i;
676
+ }
677
+ return delete t.inst, delete t.continue, n?.reportInput || delete t.input, t;
678
+ }
679
+ const $e = (e, n) => {
680
+ e.name = "$ZodError", Object.defineProperty(e, "_zod", {
681
+ value: e._zod,
682
+ enumerable: !1
683
+ }), Object.defineProperty(e, "issues", {
684
+ value: n,
685
+ enumerable: !1
686
+ }), Object.defineProperty(e, "message", {
687
+ get() {
688
+ return JSON.stringify(n, Ct, 2);
689
+ },
690
+ enumerable: !0
691
+ // configurable: false,
692
+ }), Object.defineProperty(e, "toString", {
693
+ value: () => e.message,
694
+ enumerable: !1
695
+ });
696
+ }, Et = Ee("$ZodError", $e), Oe = Ee("$ZodError", $e, { Parent: Error }), At = (e) => (n, r, t, i) => {
697
+ const l = t ? Object.assign(t, { async: !1 }) : { async: !1 }, s = n._zod.run({ value: r, issues: [] }, l);
698
+ if (s instanceof Promise)
699
+ throw new kt();
700
+ if (s.issues.length) {
701
+ const o = new (i?.Err ?? e)(s.issues.map((a) => Se(a, l, Ae())));
702
+ throw Fe(o, i?.callee), o;
703
+ }
704
+ return s.value;
705
+ }, Ft = /* @__PURE__ */ At(Oe), St = (e) => async (n, r, t, i) => {
706
+ const l = t ? Object.assign(t, { async: !0 }) : { async: !0 };
707
+ let s = n._zod.run({ value: r, issues: [] }, l);
708
+ if (s instanceof Promise && (s = await s), s.issues.length) {
709
+ const o = new (i?.Err ?? e)(s.issues.map((a) => Se(a, l, Ae())));
710
+ throw Fe(o, i?.callee), o;
711
+ }
712
+ return s.value;
713
+ }, $t = /* @__PURE__ */ St(Oe);
714
+ function ge(e, n) {
715
+ try {
716
+ var r = e();
717
+ } catch (t) {
718
+ return n(t);
719
+ }
720
+ return r && r.then ? r.then(void 0, n) : r;
721
+ }
722
+ function Ot(e, n) {
723
+ for (var r = {}; e.length; ) {
724
+ var t = e[0], i = t.code, l = t.message, s = t.path.join(".");
725
+ if (!r[s]) if ("unionErrors" in t) {
726
+ var o = t.unionErrors[0].errors[0];
727
+ r[s] = { message: o.message, type: o.code };
728
+ } else r[s] = { message: l, type: i };
729
+ if ("unionErrors" in t && t.unionErrors.forEach(function(u) {
730
+ return u.errors.forEach(function(d) {
731
+ return e.push(d);
732
+ });
733
+ }), n) {
734
+ var a = r[s].types, c = a && a[t.code];
735
+ r[s] = ke(s, n, r, i, c ? [].concat(c, t.message) : t.message);
736
+ }
737
+ e.shift();
738
+ }
739
+ return r;
740
+ }
741
+ function zt(e, n) {
742
+ for (var r = {}; e.length; ) {
743
+ var t = e[0], i = t.code, l = t.message, s = t.path.join(".");
744
+ if (!r[s]) if (t.code === "invalid_union" && t.errors.length > 0) {
745
+ var o = t.errors[0][0];
746
+ r[s] = { message: o.message, type: o.code };
747
+ } else r[s] = { message: l, type: i };
748
+ if (t.code === "invalid_union" && t.errors.forEach(function(u) {
749
+ return u.forEach(function(d) {
750
+ return e.push(d);
751
+ });
752
+ }), n) {
753
+ var a = r[s].types, c = a && a[t.code];
754
+ r[s] = ke(s, n, r, i, c ? [].concat(c, t.message) : t.message);
755
+ }
756
+ e.shift();
757
+ }
758
+ return r;
759
+ }
760
+ function Dt(e, n, r) {
761
+ if (r === void 0 && (r = {}), (function(t) {
762
+ return "_def" in t && typeof t._def == "object" && "typeName" in t._def;
763
+ })(e)) return function(t, i, l) {
764
+ try {
765
+ return Promise.resolve(ge(function() {
766
+ return Promise.resolve(e[r.mode === "sync" ? "parse" : "parseAsync"](t, n)).then(function(s) {
767
+ return l.shouldUseNativeValidation && me({}, l), { errors: {}, values: r.raw ? Object.assign({}, t) : s };
768
+ });
769
+ }, function(s) {
770
+ if ((function(o) {
771
+ return Array.isArray(o?.issues);
772
+ })(s)) return { values: {}, errors: be(Ot(s.errors, !l.shouldUseNativeValidation && l.criteriaMode === "all"), l) };
773
+ throw s;
774
+ }));
775
+ } catch (s) {
776
+ return Promise.reject(s);
777
+ }
778
+ };
779
+ if ((function(t) {
780
+ return "_zod" in t && typeof t._zod == "object";
781
+ })(e)) return function(t, i, l) {
782
+ try {
783
+ return Promise.resolve(ge(function() {
784
+ return Promise.resolve((r.mode === "sync" ? Ft : $t)(e, t, n)).then(function(s) {
785
+ return l.shouldUseNativeValidation && me({}, l), { errors: {}, values: r.raw ? Object.assign({}, t) : s };
786
+ });
787
+ }, function(s) {
788
+ if ((function(o) {
789
+ return o instanceof Et;
790
+ })(s)) return { values: {}, errors: be(zt(s.issues, !l.shouldUseNativeValidation && l.criteriaMode === "all"), l) };
791
+ throw s;
792
+ }));
793
+ } catch (s) {
794
+ return Promise.reject(s);
795
+ }
796
+ };
797
+ throw new Error("Invalid input: not a Zod schema");
798
+ }
799
+ function fr({
800
+ methods: e,
801
+ onSubmit: n,
802
+ onError: r,
803
+ children: t,
804
+ logErrors: i,
805
+ className: l
806
+ }) {
807
+ return /* @__PURE__ */ f(Ze, { ...e, children: /* @__PURE__ */ f(
808
+ "form",
809
+ {
810
+ className: p(
811
+ "mt-4 lg:mt-8 grid grid-cols-1 lg:grid-cols-2 gap-4 lg:gap-8 relative",
812
+ l
813
+ ),
814
+ onSubmit: e.handleSubmit(
815
+ (s) => n(s),
816
+ (s) => {
817
+ i && console.log(s), r?.(s);
818
+ }
819
+ ),
820
+ children: t
821
+ }
822
+ ) });
823
+ }
824
+ function dr(e, n) {
825
+ return Pe({
826
+ resolver: Dt(e),
827
+ defaultValues: n
828
+ });
829
+ }
830
+ const G = {
831
+ unchecked: "bg-base-3 lg:hover:bg-base-4",
832
+ checked: "bg-brand lg:hover:bg-brand-hover text-brand-text",
833
+ uncheckedDisabled: "bg-base-3 border-base-4",
834
+ checkedDisabled: "bg-base-3 border-base-4 text-base-10"
835
+ }, Lt = H(
836
+ ({
837
+ checked: e = !1,
838
+ onCheckedChange: n,
839
+ disabled: r = !1,
840
+ required: t = !1,
841
+ name: i,
842
+ value: l,
843
+ id: s,
844
+ className: o = "",
845
+ size: a = "sm",
846
+ ...c
847
+ }, u) => {
848
+ const d = () => {
849
+ r || n?.(e === "indeterminate" ? !0 : !e);
850
+ }, b = (v) => {
851
+ (v.key === " " || v.key === "Enter") && (v.preventDefault(), d());
852
+ }, m = {
853
+ xs: "h-3.5 w-3.5",
854
+ sm: "h-4 w-4",
855
+ md: "h-5 w-5",
856
+ lg: "h-6 w-6"
857
+ }, g = {
858
+ xs: 24,
859
+ sm: 12,
860
+ md: 14,
861
+ lg: 16
862
+ };
863
+ return /* @__PURE__ */ w(Te, { children: [
864
+ /* @__PURE__ */ w(
865
+ "button",
866
+ {
867
+ ref: u,
868
+ type: "button",
869
+ role: "checkbox",
870
+ "aria-checked": e === "indeterminate" ? "mixed" : e,
871
+ "aria-required": t,
872
+ disabled: r,
873
+ onClick: d,
874
+ onKeyDown: b,
875
+ className: p(
876
+ // Base styles
877
+ "inline-flex items-center justify-center rounded-2 border border-base-4 transition-all duration-200 ease-in-out",
878
+ "focus:outline-none focus:ring-2 focus:ring-base-5",
879
+ // Size
880
+ m[a],
881
+ // Disabled state
882
+ r && "cursor-not-allowed opacity-75",
883
+ !r && "cursor-pointer",
884
+ // Checked states
885
+ e ? r ? G.checkedDisabled : G.checked : r ? G.uncheckedDisabled : G.unchecked,
886
+ // Custom classes
887
+ typeof o == "function" ? o(e) : o
888
+ ),
889
+ ...c,
890
+ children: [
891
+ e === !0 && /* @__PURE__ */ f(
892
+ Ne,
893
+ {
894
+ size: g[a],
895
+ className: "stroke-current"
896
+ }
897
+ ),
898
+ e === "indeterminate" && /* @__PURE__ */ f(
899
+ Ye,
900
+ {
901
+ size: g[a],
902
+ className: "stroke-current"
903
+ }
904
+ )
905
+ ]
906
+ }
907
+ ),
908
+ /* @__PURE__ */ f(
909
+ "input",
910
+ {
911
+ type: "checkbox",
912
+ name: i,
913
+ value: l,
914
+ checked: e === !0,
915
+ onChange: () => {
916
+ },
917
+ disabled: r,
918
+ required: t,
919
+ id: s,
920
+ className: "sr-only",
921
+ tabIndex: -1
922
+ }
923
+ )
924
+ ] });
925
+ }
926
+ );
927
+ Lt.displayName = "Checkbox";
928
+ const Mt = {
929
+ solid: "bg-base-3 border border-base-4 drop-shadow-sm dark-theme:drop-shadow-none",
930
+ outline: "border border-base-6"
931
+ }, It = {
932
+ brand: "ring-1 ring-brand",
933
+ solid: "ring-1 ring-base-6"
934
+ }, ze = H(
935
+ ({
936
+ label: e,
937
+ description: n,
938
+ labelPosition: r = "default",
939
+ color: t = "solid",
940
+ focusColor: i = "brand",
941
+ placeholder: l,
942
+ valid: s,
943
+ error: o,
944
+ errorMessage: a,
945
+ isPrice: c,
946
+ prefix: u,
947
+ wrapperClassName: d,
948
+ containerClassName: b,
949
+ className: m,
950
+ type: g = "text",
951
+ value: v,
952
+ ...x
953
+ }, A) => {
954
+ const F = N(null), O = N(!1), [S, $] = L(!1), [E, z] = L(!1), _ = g === "password", B = _ && S ? "text" : c ? "number" : g, U = v !== "" && v !== null && v !== void 0;
955
+ return j(() => {
956
+ if (!O.current) {
957
+ O.current = !0;
958
+ return;
959
+ }
960
+ F.current && nt(F.current);
961
+ }, [S, F]), /* @__PURE__ */ w("div", { className: p("relative", d), children: [
962
+ e && r === "default" && /* @__PURE__ */ f(
963
+ "label",
964
+ {
965
+ className: p("font-medium ml-0.5 text-xs", o && "text-red-9"),
966
+ children: e
967
+ }
968
+ ),
969
+ /* @__PURE__ */ w(
970
+ "div",
971
+ {
972
+ className: p(
973
+ "rounded-6 transition cursor-text relative",
974
+ Mt[t],
975
+ {
976
+ "pt-[22px] pb-1.5": r === "floating",
977
+ [It[i]]: !o && E,
978
+ "bg-red-4 text-red-9": !!o,
979
+ "ring-1 ring-red-9": !!o && E
980
+ },
981
+ b
982
+ ),
983
+ children: [
984
+ e && r === "floating" && /* @__PURE__ */ f(
985
+ "label",
986
+ {
987
+ className: p(
988
+ "absolute transition-all duration-200 pointer-events-none",
989
+ "text-sm top-[18px] font-semibold left-3",
990
+ {
991
+ "text-xs top-2.5": E || U || l,
992
+ "text-red-9": !!o
993
+ }
994
+ ),
995
+ children: e
996
+ }
997
+ ),
998
+ c && /* @__PURE__ */ f(
999
+ qe,
1000
+ {
1001
+ size: 16,
1002
+ className: p(
1003
+ "absolute top-1/2 -translate-y-1/2 left-3",
1004
+ o ? "text-red-9" : "text-base-11"
1005
+ )
1006
+ }
1007
+ ),
1008
+ u && /* @__PURE__ */ f("p", { className: "text-sm text-base-11 absolute top-1/2 -translate-y-1/2 left-3", children: u }),
1009
+ /* @__PURE__ */ f(
1010
+ "input",
1011
+ {
1012
+ ref: (V) => {
1013
+ A && (typeof A == "function" ? A(V) : A.current = V), F.current = V;
1014
+ },
1015
+ type: B,
1016
+ className: p(
1017
+ "w-full bg-transparent focus:outline-none",
1018
+ "placeholder:text-sm text-sm placeholder:text-base-11",
1019
+ c || u ? "pl-9" : "pl-3",
1020
+ {
1021
+ "py-2.5": r === "default",
1022
+ "mt-1.5": r === "floating",
1023
+ "pr-10": s,
1024
+ "text-red-9 placeholder:text-red-9": !!o
1025
+ },
1026
+ m
1027
+ ),
1028
+ value: v,
1029
+ placeholder: l,
1030
+ onFocus: () => z(!0),
1031
+ onBlur: () => z(!1),
1032
+ ...x
1033
+ }
1034
+ )
1035
+ ]
1036
+ }
1037
+ ),
1038
+ s ? /* @__PURE__ */ f(
1039
+ J,
1040
+ {
1041
+ size: 20,
1042
+ className: `absolute top-1/2 -translate-y-1/2 text-green-500 ${_ ? "right-10" : "right-3"}`
1043
+ }
1044
+ ) : null,
1045
+ _ && /* @__PURE__ */ f(
1046
+ "button",
1047
+ {
1048
+ type: "button",
1049
+ className: p(
1050
+ r === "floating" ? "absolute right-3 top-1/2 -translate-y-1/2" : "absolute right-3 top-10"
1051
+ ),
1052
+ onClick: () => {
1053
+ $(!S);
1054
+ },
1055
+ children: S ? /* @__PURE__ */ f(
1056
+ Ge,
1057
+ {
1058
+ size: 20,
1059
+ className: p(o ? "text-red-9" : "text-base-11")
1060
+ }
1061
+ ) : /* @__PURE__ */ f(
1062
+ Je,
1063
+ {
1064
+ size: 20,
1065
+ className: p(o ? "text-red-9" : "text-base-11")
1066
+ }
1067
+ )
1068
+ }
1069
+ ),
1070
+ a ? /* @__PURE__ */ f("span", { role: "alert", className: "text-red-9 text-sm mt-1 ml-0.5", children: a }) : n ? /* @__PURE__ */ f("p", { className: "text-xs text-base-11 mt-1 ml-0.5", children: n }) : null
1071
+ ] });
1072
+ }
1073
+ );
1074
+ ze.displayName = "Input";
1075
+ const hr = ({
1076
+ name: e,
1077
+ customRead: n,
1078
+ customSet: r,
1079
+ withNullSet: t = !0,
1080
+ ...i
1081
+ }) => {
1082
+ const { control: l } = W(), s = K(
1083
+ (a) => n ? n(a) : a === null ? Ce(a) : a,
1084
+ [n]
1085
+ ), o = K(
1086
+ (a) => r ? t && a === null ? oe(a) : r(a) : a === null ? oe(a) : a,
1087
+ [r]
1088
+ );
1089
+ return l ? /* @__PURE__ */ f(
1090
+ R,
1091
+ {
1092
+ name: e,
1093
+ control: l,
1094
+ render: ({ field: a, fieldState: c }) => /* @__PURE__ */ f(
1095
+ ze,
1096
+ {
1097
+ value: s(a.value),
1098
+ onChange: (u) => a.onChange(o(u.target.value)),
1099
+ error: !!c.error,
1100
+ errorMessage: c.error?.message,
1101
+ ref: a.ref,
1102
+ ...i
1103
+ }
1104
+ )
1105
+ }
1106
+ ) : (console.error(`Form control is missing for field: ${e}`), /* @__PURE__ */ w("p", { children: [
1107
+ "Form control missing for field: ",
1108
+ e
1109
+ ] }));
1110
+ }, jt = {
1111
+ brand: "ring-1 ring-brand",
1112
+ solid: "ring-1 ring-base-6"
1113
+ }, De = H(
1114
+ ({
1115
+ label: e,
1116
+ labelPosition: n = "default",
1117
+ placeholder: r,
1118
+ error: t,
1119
+ focusColor: i = "brand",
1120
+ className: l,
1121
+ value: s,
1122
+ rows: o = 3,
1123
+ ...a
1124
+ }, c) => {
1125
+ const [u, d] = L(!1), b = s !== "" && s !== null && s !== void 0;
1126
+ return /* @__PURE__ */ w("div", { className: "relative", children: [
1127
+ n === "default" ? /* @__PURE__ */ f(
1128
+ "label",
1129
+ {
1130
+ className: p(
1131
+ "top-[18px] font-medium ml-0.5 text-xs",
1132
+ t && "text-red-9"
1133
+ ),
1134
+ children: e
1135
+ }
1136
+ ) : null,
1137
+ /* @__PURE__ */ w(
1138
+ "div",
1139
+ {
1140
+ className: p(n === "default" ? "p-0" : "pt-5 pb-2", {
1141
+ "bg-red-4 text-red-9": !!t
1142
+ }),
1143
+ children: [
1144
+ n === "floating" && /* @__PURE__ */ f(
1145
+ "label",
1146
+ {
1147
+ className: p(
1148
+ "absolute transition-all duration-200 pointer-events-none",
1149
+ "text-sm top-2.5 font-semibold left-2.5",
1150
+ {
1151
+ "text-xs top-2.5": u || b || r,
1152
+ "text-red-9": !!t
1153
+ }
1154
+ ),
1155
+ children: e
1156
+ }
1157
+ ),
1158
+ /* @__PURE__ */ f(
1159
+ "textarea",
1160
+ {
1161
+ ref: c,
1162
+ className: p(
1163
+ !t && u && jt[i],
1164
+ "bg-base-3 border border-base-4 light-theme:drop-shadow-sm rounded-6 w-full focus:outline-none customscrollbarnohide",
1165
+ "placeholder:text-base-11 text-sm",
1166
+ "resize-none",
1167
+ // Prevent manual resizing since we're auto-resizing
1168
+ n === "default" ? "p-3" : "mt-1",
1169
+ {
1170
+ // "pr-10": valid,
1171
+ "text-red-9 placeholder:text-red-9": !!t
1172
+ },
1173
+ l
1174
+ ),
1175
+ value: s,
1176
+ placeholder: r,
1177
+ onFocus: () => d(!0),
1178
+ onBlur: () => d(!1),
1179
+ rows: o,
1180
+ ...a
1181
+ }
1182
+ )
1183
+ ]
1184
+ }
1185
+ )
1186
+ ] });
1187
+ }
1188
+ );
1189
+ De.displayName = "TextArea";
1190
+ const mr = ({
1191
+ name: e,
1192
+ customRead: n,
1193
+ customSet: r,
1194
+ ...t
1195
+ }) => {
1196
+ const { control: i } = W(), l = K(
1197
+ (o) => n ? n(o) : o === null ? Ce(o) : o,
1198
+ [n]
1199
+ ), s = K(
1200
+ (o) => r ? r(o) : o === null ? oe(o) : o,
1201
+ [r]
1202
+ );
1203
+ return i ? /* @__PURE__ */ f(
1204
+ R,
1205
+ {
1206
+ name: e,
1207
+ control: i,
1208
+ render: ({ field: o, fieldState: a }) => /* @__PURE__ */ w("div", { children: [
1209
+ /* @__PURE__ */ f(
1210
+ De,
1211
+ {
1212
+ value: l(o.value),
1213
+ onChange: (c) => o.onChange(s(c.target.value)),
1214
+ error: !!a.error,
1215
+ ref: o.ref,
1216
+ ...t
1217
+ }
1218
+ ),
1219
+ a.error ? /* @__PURE__ */ f("span", { role: "alert", className: "text-red-9 text-sm mt-1 ml-0.5", children: a.error.message }) : null
1220
+ ] })
1221
+ }
1222
+ ) : (console.error(`Form control is missing for field: ${e}`), /* @__PURE__ */ w("p", { children: [
1223
+ "Form control missing for field: ",
1224
+ e
1225
+ ] }));
1226
+ }, _t = ({
1227
+ label: e,
1228
+ variant: n = "default",
1229
+ color: r = "solid",
1230
+ tags: t,
1231
+ onChange: i,
1232
+ valid: l,
1233
+ error: s,
1234
+ placeholder: o = "Add a tag...",
1235
+ maxTags: a,
1236
+ validateTag: c
1237
+ }) => {
1238
+ const [u, d] = L(""), [b, m] = L(!1), [g, v] = L(null), x = N(null), A = N(null), F = N([]), O = t.length > 0, S = N(
1239
+ `taginput-${Math.random().toString(36).substr(2, 9)}`
1240
+ ).current, $ = N(
1241
+ `label-${Math.random().toString(36).substr(2, 9)}`
1242
+ ).current, E = N(
1243
+ `error-${Math.random().toString(36).substr(2, 9)}`
1244
+ ).current;
1245
+ j(() => {
1246
+ F.current = F.current.slice(0, t.length);
1247
+ }, [t.length]);
1248
+ const z = (k) => {
1249
+ if (k.key === "Enter" && u.trim()) {
1250
+ k.preventDefault();
1251
+ const C = u.trim();
1252
+ if (a && t.length >= a) {
1253
+ v(`Maximum of ${a} tags allowed`);
1254
+ return;
1255
+ }
1256
+ if (t.includes(C)) {
1257
+ v("Tag already exists");
1258
+ return;
1259
+ }
1260
+ if (c) {
1261
+ const I = c(C);
1262
+ if (typeof I == "string") {
1263
+ v(I);
1264
+ return;
1265
+ } else if (I === !1) {
1266
+ v("Invalid tag");
1267
+ return;
1268
+ }
1269
+ }
1270
+ i([...t, C]), d(""), v(null), M(`Added tag ${C}`);
1271
+ } else if (k.key === "Backspace" && !u && t.length > 0) {
1272
+ const C = t[t.length - 1];
1273
+ i(t.slice(0, -1)), M(`Removed tag ${C}`);
1274
+ } else k.key === "ArrowLeft" && u === "" && t.length > 0 && F.current[t.length - 1] && F.current[t.length - 1]?.focus();
1275
+ }, _ = (k, C) => {
1276
+ if (k.key === "Backspace" || k.key === "Delete") {
1277
+ k.preventDefault();
1278
+ const I = t[C], Z = [...t];
1279
+ Z.splice(C, 1), i(Z), setTimeout(() => {
1280
+ x.current && x.current.focus();
1281
+ }, 0), M(`Removed tag ${I}`);
1282
+ } else k.key === "ArrowRight" ? (k.preventDefault(), C < t.length - 1 ? F.current[C + 1]?.focus() : x.current?.focus()) : k.key === "ArrowLeft" && (k.preventDefault(), C > 0 && F.current[C - 1]?.focus());
1283
+ }, B = (k, C) => {
1284
+ i(t.filter((I) => I !== k)), setTimeout(() => {
1285
+ C < t.length - 1 ? F.current[C]?.focus() : C > 0 ? F.current[C - 1]?.focus() : x.current?.focus();
1286
+ }, 0), M(`Removed tag ${k}`);
1287
+ }, U = (k) => {
1288
+ d(k.target.value), v(null);
1289
+ }, V = () => {
1290
+ x.current && x.current.focus();
1291
+ }, M = (k) => {
1292
+ console.log(`Accessibility announcement: ${k}`);
1293
+ };
1294
+ return /* @__PURE__ */ w("div", { children: [
1295
+ /* @__PURE__ */ w("div", { className: "relative", ref: A, children: [
1296
+ n === "default" ? /* @__PURE__ */ w(
1297
+ "label",
1298
+ {
1299
+ id: $,
1300
+ htmlFor: S,
1301
+ className: p("text-base top-4 font-semibold left-3", {
1302
+ "text-sm top-2 left-2": b || O || o,
1303
+ "text-red-9": !!s
1304
+ }),
1305
+ children: [
1306
+ e,
1307
+ " ",
1308
+ a && `(${t.length}/${a})`
1309
+ ]
1310
+ }
1311
+ ) : null,
1312
+ /* @__PURE__ */ w(
1313
+ "div",
1314
+ {
1315
+ className: p("rounded-6 px-2 transition cursor-text pr-10", {
1316
+ "bg-base-3": r === "solid",
1317
+ "border border-uielborder focus:border-transparent": r === "outline",
1318
+ "py-3": n === "default",
1319
+ "pt-5 pb-2": n === "floating",
1320
+ "ring-2 ring-branduielborder": b,
1321
+ "text-red-9": s || g,
1322
+ "ring-2 ring-red-6": (s || g) && b
1323
+ }),
1324
+ onClick: V,
1325
+ role: "group",
1326
+ "aria-labelledby": $,
1327
+ "aria-describedby": s || g ? E : void 0,
1328
+ children: [
1329
+ n === "floating" ? /* @__PURE__ */ w(
1330
+ "label",
1331
+ {
1332
+ id: $,
1333
+ htmlFor: S,
1334
+ className: p(
1335
+ "absolute transition-all duration-200 pointer-events-none",
1336
+ "text-base top-4 font-semibold left-3",
1337
+ {
1338
+ "text-sm top-2 left-2": b || O || o,
1339
+ "text-red-9": !!s
1340
+ }
1341
+ ),
1342
+ children: [
1343
+ e,
1344
+ " ",
1345
+ a && `(${t.length}/${a})`
1346
+ ]
1347
+ }
1348
+ ) : null,
1349
+ /* @__PURE__ */ w(
1350
+ "div",
1351
+ {
1352
+ className: p("flex flex-wrap gap-1 items-center", {
1353
+ "mt-2.5": n === "floating"
1354
+ }),
1355
+ children: [
1356
+ t.map((k, C) => /* @__PURE__ */ w(
1357
+ "div",
1358
+ {
1359
+ ref: (I) => {
1360
+ F.current[C] = I;
1361
+ },
1362
+ className: p(
1363
+ "line-clamp-1 text-brand rounded-full px-2 text-sm flex items-center",
1364
+ {
1365
+ "bg-brandfadedbg text-brand": !s && !g,
1366
+ "bg-red-4 text-red-9": s || g
1367
+ }
1368
+ ),
1369
+ tabIndex: 0,
1370
+ role: "button",
1371
+ "aria-label": `${k}, press delete or backspace to remove`,
1372
+ onKeyDown: (I) => _(I, C),
1373
+ children: [
1374
+ k,
1375
+ /* @__PURE__ */ f(
1376
+ "button",
1377
+ {
1378
+ type: "button",
1379
+ className: "ml-1 text-brand hover:text-brandhover shrink-0",
1380
+ onClick: () => B(k, C),
1381
+ "aria-label": `Remove ${k} tag`,
1382
+ children: "x"
1383
+ }
1384
+ )
1385
+ ]
1386
+ },
1387
+ `${k}-${C}`
1388
+ )),
1389
+ /* @__PURE__ */ f(
1390
+ "input",
1391
+ {
1392
+ id: S,
1393
+ ref: x,
1394
+ type: "text",
1395
+ className: "flex-grow min-w-[60px] bg-transparent outline-none placeholder:text-sm placeholder:text-secondarytext",
1396
+ value: u,
1397
+ onChange: U,
1398
+ onKeyDown: z,
1399
+ onFocus: () => m(!0),
1400
+ onBlur: () => m(!1),
1401
+ enterKeyHint: "enter",
1402
+ autoComplete: "off",
1403
+ placeholder: t.length > 0 ? "" : o,
1404
+ style: { width: `${Math.max(60, u.length * 8)}px` },
1405
+ "aria-describedby": s || g ? E : void 0,
1406
+ "aria-invalid": !!(s || g)
1407
+ }
1408
+ )
1409
+ ]
1410
+ }
1411
+ )
1412
+ ]
1413
+ }
1414
+ ),
1415
+ l && /* @__PURE__ */ f("span", { className: "absolute right-3 top-1/2 transform -translate-y-1/2", children: /* @__PURE__ */ f(J, {}) })
1416
+ ] }),
1417
+ (s || g) && /* @__PURE__ */ f(
1418
+ "p",
1419
+ {
1420
+ id: E,
1421
+ className: "text-red-500 text-xs mt-1",
1422
+ "aria-live": "assertive",
1423
+ children: s || g
1424
+ }
1425
+ ),
1426
+ /* @__PURE__ */ f("div", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true", children: t.length > 0 ? `Current tags: ${t.join(", ")}` : "No tags added yet" })
1427
+ ] });
1428
+ }, br = ({ name: e, ...n }) => {
1429
+ const { control: r } = W();
1430
+ return r ? /* @__PURE__ */ f(
1431
+ R,
1432
+ {
1433
+ name: e,
1434
+ control: r,
1435
+ render: ({ field: t, fieldState: i }) => /* @__PURE__ */ f(
1436
+ _t,
1437
+ {
1438
+ tags: t.value,
1439
+ onChange: (l) => t.onChange(l),
1440
+ error: i.error?.message,
1441
+ ...n
1442
+ }
1443
+ )
1444
+ }
1445
+ ) : (console.error(`Form control is missing for field: ${e}`), /* @__PURE__ */ w("p", { children: [
1446
+ "Form control missing for field: ",
1447
+ e
1448
+ ] }));
1449
+ }, Tt = ({
1450
+ label: e,
1451
+ labelPosition: n = "default",
1452
+ options: r,
1453
+ selectedValues: t,
1454
+ onChange: i,
1455
+ idExtractor: l,
1456
+ labelExtractor: s,
1457
+ customSetter: o,
1458
+ valid: a,
1459
+ error: c,
1460
+ placeholder: u = "Select options...",
1461
+ maxSelections: d,
1462
+ searchable: b = !1,
1463
+ disabled: m = !1,
1464
+ className: g
1465
+ }) => {
1466
+ const [v, x] = L(""), [A, F] = L(!1), [O, S] = L(-1), $ = N(null), E = N(null), z = N([]), {
1467
+ triggerRef: _,
1468
+ triggerProps: B,
1469
+ popoverRef: U,
1470
+ getPopoverPosition: V,
1471
+ open: M,
1472
+ toggle: k,
1473
+ close: C
1474
+ } = ct({
1475
+ align: "start",
1476
+ side: "top",
1477
+ avoidCollisions: !1,
1478
+ onOpen: () => {
1479
+ F(!0), b && $.current && setTimeout(() => $.current?.focus(), 10);
1480
+ },
1481
+ onClose: () => {
1482
+ F(!1), x(""), S(-1);
1483
+ }
1484
+ }), I = N(
1485
+ `multiselect-${Math.random().toString(36).substr(2, 9)}`
1486
+ ).current, Z = N(
1487
+ `label-${Math.random().toString(36).substr(2, 9)}`
1488
+ ).current, ce = N(
1489
+ `error-${Math.random().toString(36).substr(2, 9)}`
1490
+ ).current, ee = N(
1491
+ `listbox-${Math.random().toString(36).substr(2, 9)}`
1492
+ ).current, T = o ? t.map((h) => r.find(
1493
+ (D) => l(D) === h || l(D) === l(h)
1494
+ )).filter(Boolean) : t, te = T.length > 0, X = b ? r.filter(
1495
+ (h) => s(h).toLowerCase().includes(v.toLowerCase())
1496
+ ) : r;
1497
+ j(() => {
1498
+ z.current = z.current.slice(0, X.length);
1499
+ }, [X.length]);
1500
+ const ue = (h) => o ? t.some(
1501
+ (y) => y === l(h) || l(y) === l(h)
1502
+ ) : t.some(
1503
+ (y) => l(y) === l(h)
1504
+ ), fe = (h) => {
1505
+ if (!m)
1506
+ if (ue(h)) {
1507
+ let y;
1508
+ if (o) {
1509
+ const D = l(h);
1510
+ y = t.filter(
1511
+ (P) => P !== D && l(P) !== D
1512
+ );
1513
+ } else
1514
+ y = t.filter(
1515
+ (D) => l(D) !== l(h)
1516
+ );
1517
+ i(y), Y(`Removed ${s(h)}`);
1518
+ } else {
1519
+ if (d && T.length >= d) {
1520
+ Y(`Maximum of ${d} selections allowed`);
1521
+ return;
1522
+ }
1523
+ let y;
1524
+ o ? y = [...t, o(h)] : y = [...t, h], i(y), Y(`Added ${s(h)}`);
1525
+ }
1526
+ }, de = (h) => {
1527
+ if (m) return;
1528
+ let y;
1529
+ if (o) {
1530
+ const D = l(h);
1531
+ y = t.filter(
1532
+ (P) => P !== D && l(P) !== D
1533
+ );
1534
+ } else
1535
+ y = t.filter(
1536
+ (D) => l(D) !== l(h)
1537
+ );
1538
+ i(y), Y(`Removed ${s(h)}`);
1539
+ }, he = (h) => {
1540
+ if (!m)
1541
+ switch (h.key) {
1542
+ case "Enter":
1543
+ h.preventDefault(), M ? O >= 0 && fe(X[O]) : k();
1544
+ break;
1545
+ case "Escape":
1546
+ h.preventDefault(), C();
1547
+ break;
1548
+ case "ArrowDown":
1549
+ if (h.preventDefault(), !M)
1550
+ k();
1551
+ else {
1552
+ const y = O >= X.length - 1 ? 0 : O + 1;
1553
+ S(y), z.current[y]?.scrollIntoView({ block: "nearest" });
1554
+ }
1555
+ break;
1556
+ case "ArrowUp":
1557
+ if (h.preventDefault(), M) {
1558
+ const y = O <= 0 ? X.length - 1 : O - 1;
1559
+ S(y), z.current[y]?.scrollIntoView({ block: "nearest" });
1560
+ }
1561
+ break;
1562
+ case "Backspace":
1563
+ if (b && v === "" && T.length > 0) {
1564
+ const y = T[T.length - 1];
1565
+ de(y);
1566
+ }
1567
+ break;
1568
+ }
1569
+ }, Ie = (h) => {
1570
+ x(h.target.value), S(-1);
1571
+ }, je = () => {
1572
+ m || (b && $.current && $.current.focus(), k());
1573
+ }, Y = (h) => {
1574
+ console.log(`Accessibility announcement: ${h}`);
1575
+ };
1576
+ ft(U, (h) => {
1577
+ !_.current || !M || !h.target || _.current.contains(h.target) || C();
1578
+ });
1579
+ const re = V();
1580
+ return /* @__PURE__ */ w("div", { className: p("relative", g), children: [
1581
+ /* @__PURE__ */ w("div", { className: "relative", ref: E, children: [
1582
+ n === "default" && /* @__PURE__ */ f(
1583
+ "label",
1584
+ {
1585
+ className: p(
1586
+ "top-[18px] font-medium ml-0.5 text-xs",
1587
+ c && "text-red-9"
1588
+ ),
1589
+ children: e
1590
+ }
1591
+ ),
1592
+ /* @__PURE__ */ w(
1593
+ "div",
1594
+ {
1595
+ ref: _,
1596
+ ...B,
1597
+ className: p(
1598
+ "relative rounded-6 px-2 transition cursor-pointer pr-10 min-h-[48px]",
1599
+ "border border-base-4 light-theme:drop-shadow-sm dark-theme:bg-base-3",
1600
+ {
1601
+ "py-3": n === "default",
1602
+ "pt-5 pb-2": n === "floating",
1603
+ "ring-1 ring-brand": M || A,
1604
+ "text-red-9": c,
1605
+ "ring-2 ring-red-6": c && (M || A),
1606
+ "opacity-60 cursor-not-allowed": m
1607
+ }
1608
+ ),
1609
+ onClick: je,
1610
+ role: "combobox",
1611
+ "aria-expanded": M,
1612
+ "aria-haspopup": "listbox",
1613
+ "aria-owns": ee,
1614
+ "aria-labelledby": Z,
1615
+ "aria-describedby": c ? ce : void 0,
1616
+ onKeyDown: he,
1617
+ tabIndex: m ? -1 : 0,
1618
+ children: [
1619
+ n === "floating" && /* @__PURE__ */ w(
1620
+ "label",
1621
+ {
1622
+ id: Z,
1623
+ htmlFor: I,
1624
+ className: p(
1625
+ "absolute transition-all duration-200 pointer-events-none",
1626
+ "text-base top-4 font-semibold left-3",
1627
+ {
1628
+ "text-sm top-2 left-2": A || te,
1629
+ "text-red-9": !!c
1630
+ }
1631
+ ),
1632
+ children: [
1633
+ e,
1634
+ " ",
1635
+ d && `(${t.length}/${d})`
1636
+ ]
1637
+ }
1638
+ ),
1639
+ /* @__PURE__ */ w(
1640
+ "div",
1641
+ {
1642
+ className: p("flex flex-wrap gap-2 items-center", {
1643
+ "mt-2.5": n === "floating"
1644
+ }),
1645
+ children: [
1646
+ T.map((h) => /* @__PURE__ */ w(
1647
+ "div",
1648
+ {
1649
+ className: p(
1650
+ "border border-base-4 dark-theme:border-base-5 dark-theme:bg-base-4 rounded-full px-2 py-1 text-sm flex items-center gap-1",
1651
+ {
1652
+ "bg-red-4 text-red-9": c
1653
+ }
1654
+ ),
1655
+ children: [
1656
+ /* @__PURE__ */ f("span", { className: "line-clamp-1", children: s(h) }),
1657
+ !m && /* @__PURE__ */ f(
1658
+ "button",
1659
+ {
1660
+ type: "button",
1661
+ className: "hover:bg-brand/20 rounded-full p-0.5 transition-colors",
1662
+ onClick: (y) => {
1663
+ y.stopPropagation(), de(h);
1664
+ },
1665
+ "aria-label": `Remove ${s(h)}`,
1666
+ children: /* @__PURE__ */ f(Qe, { size: 12 })
1667
+ }
1668
+ )
1669
+ ]
1670
+ },
1671
+ l(h)
1672
+ )),
1673
+ b && /* @__PURE__ */ f(
1674
+ "input",
1675
+ {
1676
+ ref: $,
1677
+ id: I,
1678
+ type: "text",
1679
+ className: "flex-grow min-w-[60px] bg-transparent outline-none placeholder:text-sm",
1680
+ value: v,
1681
+ onChange: Ie,
1682
+ onKeyDown: he,
1683
+ placeholder: te ? "" : u,
1684
+ disabled: m,
1685
+ "aria-autocomplete": "list",
1686
+ "aria-controls": ee,
1687
+ autoComplete: "off"
1688
+ }
1689
+ ),
1690
+ !b && !te && /* @__PURE__ */ f("span", { className: "text-secondarytext text-sm flex-grow", children: u })
1691
+ ]
1692
+ }
1693
+ ),
1694
+ /* @__PURE__ */ w("div", { className: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2", children: [
1695
+ a && /* @__PURE__ */ f(J, { size: 16, className: "text-green-600" }),
1696
+ /* @__PURE__ */ f(
1697
+ He,
1698
+ {
1699
+ size: 16,
1700
+ className: p("transition-transform text-base-11", {
1701
+ "rotate-180": M
1702
+ })
1703
+ }
1704
+ )
1705
+ ] })
1706
+ ]
1707
+ }
1708
+ )
1709
+ ] }),
1710
+ /* @__PURE__ */ f(et, { children: M && /* @__PURE__ */ f(yt, { children: /* @__PURE__ */ f(
1711
+ tt.div,
1712
+ {
1713
+ initial: { opacity: 0, y: -10 },
1714
+ animate: { opacity: 1, y: 0 },
1715
+ exit: { opacity: 0, y: -10 },
1716
+ transition: { duration: 0.15 },
1717
+ ref: U,
1718
+ style: {
1719
+ position: "fixed",
1720
+ left: re.x,
1721
+ top: re.top,
1722
+ bottom: re.bottom,
1723
+ width: E.current?.offsetWidth ?? 200
1724
+ },
1725
+ className: p(
1726
+ "bg-base-1 dark-theme:bg-base-3 border border-base-4",
1727
+ "rounded-6 shadow-lg max-h-[300px] overflow-y-auto z-50",
1728
+ "customscrollbarnohide"
1729
+ ),
1730
+ role: "listbox",
1731
+ id: ee,
1732
+ "aria-labelledby": Z,
1733
+ children: X.length === 0 ? /* @__PURE__ */ f("div", { className: "px-3 py-2 text-sm text-secondarytext", children: v ? "No results found" : "No options available" }) : X.map((h, y) => {
1734
+ const D = ue(h);
1735
+ return /* @__PURE__ */ w(
1736
+ "div",
1737
+ {
1738
+ ref: (_e) => {
1739
+ z.current[y] = _e;
1740
+ },
1741
+ className: p(
1742
+ "px-3 py-2 text-sm cursor-pointer flex items-center justify-between",
1743
+ // gap-x-2
1744
+ "first:rounded-t-6 last:rounded-b-6",
1745
+ // !selected && "pl-9",
1746
+ {
1747
+ "bg-base-3 dark-theme:bg-base-4": y === O,
1748
+ "bg-brandfadedbg text-brand": D
1749
+ }
1750
+ ),
1751
+ onClick: () => fe(h),
1752
+ role: "option",
1753
+ "aria-selected": D,
1754
+ onMouseEnter: () => S(y),
1755
+ children: [
1756
+ /* @__PURE__ */ f("span", { children: s(h) }),
1757
+ D && /* @__PURE__ */ f(J, { size: 16 })
1758
+ ]
1759
+ },
1760
+ l(h)
1761
+ );
1762
+ })
1763
+ }
1764
+ ) }) }),
1765
+ c && /* @__PURE__ */ f(
1766
+ "p",
1767
+ {
1768
+ id: ce,
1769
+ className: "text-red-9 text-xs mt-1",
1770
+ "aria-live": "assertive",
1771
+ children: c
1772
+ }
1773
+ ),
1774
+ /* @__PURE__ */ f("div", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true", children: T.length > 0 ? `Selected: ${T.map(s).join(", ")}` : "No selections" })
1775
+ ] });
1776
+ }, pr = ({
1777
+ name: e,
1778
+ ...n
1779
+ }) => {
1780
+ const { control: r } = W();
1781
+ return r ? /* @__PURE__ */ f(
1782
+ R,
1783
+ {
1784
+ name: e,
1785
+ control: r,
1786
+ render: ({ field: t, fieldState: i }) => /* @__PURE__ */ f(
1787
+ Tt,
1788
+ {
1789
+ selectedValues: t.value || [],
1790
+ onChange: (l) => t.onChange(l),
1791
+ error: i.error?.message,
1792
+ ...n
1793
+ }
1794
+ )
1795
+ }
1796
+ ) : (console.error(`Form control is missing for field: ${e}`), /* @__PURE__ */ w("p", { children: [
1797
+ "Form control missing for field: ",
1798
+ e
1799
+ ] }));
1800
+ }, gr = ({
1801
+ isEditable: e,
1802
+ isDeletable: n = !0,
1803
+ createUpdateLoading: r,
1804
+ deleteLoading: t,
1805
+ onDelete: i,
1806
+ onDeleteConfirm: l,
1807
+ addText: s = "Añadir",
1808
+ updateText: o = "Actualizar",
1809
+ deleteText: a = "Eliminar",
1810
+ className: c
1811
+ }) => {
1812
+ const [u, d] = L(!1);
1813
+ return /* @__PURE__ */ w("div", { className: `w-full grid grid-cols-2 gap-4 col-span-full ${c}`, children: [
1814
+ e && n ? /* @__PURE__ */ w(
1815
+ ie,
1816
+ {
1817
+ color: "dangersolid",
1818
+ state: t ? "loading" : r ? "disabled" : "enabled",
1819
+ onClick: () => {
1820
+ l ? u ? i?.() : d(!0) : i?.();
1821
+ },
1822
+ children: [
1823
+ /* @__PURE__ */ f(We, { size: 18 }),
1824
+ l && u ? "Confirmar" : a
1825
+ ]
1826
+ }
1827
+ ) : null,
1828
+ /* @__PURE__ */ w(
1829
+ ie,
1830
+ {
1831
+ color: "brand",
1832
+ className: p(e && n ? "" : "col-span-2"),
1833
+ state: r ? "loading" : t ? "disabled" : "enabled",
1834
+ type: "submit",
1835
+ children: [
1836
+ r ? /* @__PURE__ */ f(wt, {}) : e ? /* @__PURE__ */ f(Ne, { size: 18 }) : /* @__PURE__ */ f(Re, { size: 18 }),
1837
+ e ? o : s
1838
+ ]
1839
+ }
1840
+ )
1841
+ ] });
1842
+ };
1843
+ function vr({
1844
+ checked: e,
1845
+ onCheckedChange: n,
1846
+ disabled: r = !1,
1847
+ name: t,
1848
+ required: i,
1849
+ className: l = ""
1850
+ }) {
1851
+ const s = ve();
1852
+ return /* @__PURE__ */ w(
1853
+ "button",
1854
+ {
1855
+ id: s,
1856
+ type: "button",
1857
+ role: "switch",
1858
+ "aria-checked": e,
1859
+ "aria-required": i,
1860
+ "data-state": e ? "checked" : "unchecked",
1861
+ disabled: r,
1862
+ onClick: () => {
1863
+ r || n(!e);
1864
+ },
1865
+ className: p(
1866
+ `
1867
+ relative inline-flex h-6 w-11 items-center rounded-full
1868
+ transition-colors duration-200 ease-in-out
1869
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2
1870
+ focus-visible:ring-blue-500`,
1871
+ e ? "bg-blue-600" : "bg-gray-200",
1872
+ r ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
1873
+ l
1874
+ ),
1875
+ children: [
1876
+ /* @__PURE__ */ f(
1877
+ "span",
1878
+ {
1879
+ className: p(
1880
+ `inline-block h-5 w-5 transform rounded-full bg-white
1881
+ transition-transform duration-200 ease-in-out
1882
+ shadow-lg`,
1883
+ e ? "translate-x-6" : "translate-x-0.5"
1884
+ )
1885
+ }
1886
+ ),
1887
+ t && /* @__PURE__ */ f(
1888
+ "input",
1889
+ {
1890
+ type: "checkbox",
1891
+ name: t,
1892
+ checked: e,
1893
+ required: i,
1894
+ disabled: r,
1895
+ onChange: () => {
1896
+ },
1897
+ tabIndex: -1,
1898
+ "aria-hidden": "true",
1899
+ className: "sr-only"
1900
+ }
1901
+ )
1902
+ ]
1903
+ }
1904
+ );
1905
+ }
1906
+ const Le = we(null), Kt = ({
274
1907
  children: e,
275
- value: r
276
- }) => /* @__PURE__ */ c(M.Provider, { value: r, children: e }), le = () => {
277
- const e = P(M);
1908
+ value: n
1909
+ }) => /* @__PURE__ */ f(Le.Provider, { value: n, children: e }), Bt = () => {
1910
+ const e = xe(Le);
278
1911
  if (!e)
279
1912
  throw new Error("useAliveScope must be wrapped within AliveScopeProvider");
280
1913
  return e;
281
- }, ve = ({ children: e }) => {
282
- const [r, t] = C({}), o = v(
1914
+ }, xr = ({ children: e }) => {
1915
+ const [n, r] = L({}), t = N(
283
1916
  {}
284
- ), s = v(
1917
+ ), i = N(
285
1918
  {}
286
1919
  );
287
- return /* @__PURE__ */ k(
288
- se,
1920
+ return /* @__PURE__ */ w(
1921
+ Kt,
289
1922
  {
290
1923
  value: {
291
- getPortalElement: (n, l, i) => {
292
- if (!r[n]) {
1924
+ getPortalElement: (o, a, c) => {
1925
+ if (!n[o]) {
293
1926
  const u = document.createElement("div");
294
- return n && (u.id = n), i && (u.className = i), t((d) => ({
1927
+ return o && (u.id = o), c && (u.className = c), r((d) => ({
295
1928
  ...d,
296
- [n]: { children: l, element: u }
297
- })), o.current[n] = [], s.current[n] = [], o.current && o.current[n] && o.current[n].forEach((d) => d(n)), u;
1929
+ [o]: { children: a, element: u }
1930
+ })), t.current[o] = [], i.current[o] = [], t.current && t.current[o] && t.current[o].forEach((d) => d(o)), u;
298
1931
  }
299
- return o.current && o.current[n] && o.current[n].forEach((u) => u(n)), r[n].element;
1932
+ return t.current && t.current[o] && t.current[o].forEach((u) => u(o)), n[o].element;
300
1933
  },
301
- dropPortalElement: (n) => {
302
- t((l) => {
303
- const i = { ...l };
304
- return delete i[n], i;
305
- }), s.current && s.current[n] && s.current[n].forEach((l) => l(n));
1934
+ dropPortalElement: (o) => {
1935
+ r((a) => {
1936
+ const c = { ...a };
1937
+ return delete c[o], c;
1938
+ }), i.current && i.current[o] && i.current[o].forEach((a) => a(o));
306
1939
  }
307
1940
  },
308
1941
  children: [
309
1942
  e,
310
- Object.entries(r).map(([n, { children: l, element: i }]) => /* @__PURE__ */ c(
311
- ie,
1943
+ Object.entries(n).map(([o, { children: a, element: c }]) => /* @__PURE__ */ f(
1944
+ Xt,
312
1945
  {
313
- id: n,
314
- onMountCallbacks: o,
315
- onDropCallbacks: s,
316
- children: l,
317
- element: i
1946
+ id: o,
1947
+ onMountCallbacks: t,
1948
+ onDropCallbacks: i,
1949
+ children: a,
1950
+ element: c
318
1951
  },
319
- n
1952
+ o
320
1953
  ))
321
1954
  ]
322
1955
  }
323
1956
  );
324
- }, R = N(
1957
+ }, Me = we(
325
1958
  null
326
- ), ae = ({
1959
+ ), Vt = ({
327
1960
  children: e,
328
- value: r
329
- }) => /* @__PURE__ */ c(R.Provider, { value: r, children: e }), ie = X(({ id: e, onMountCallbacks: r, onDropCallbacks: t, children: o, element: s }) => /* @__PURE__ */ c(
330
- ae,
1961
+ value: n
1962
+ }) => /* @__PURE__ */ f(Me.Provider, { value: n, children: e }), Xt = Be(({ id: e, onMountCallbacks: n, onDropCallbacks: r, children: t, element: i }) => /* @__PURE__ */ f(
1963
+ Vt,
331
1964
  {
332
- value: { keepAliveId: e, onKeepAliveMount: (n, l = { runOnFirstMount: !1 }) => {
333
- x(() => {
334
- const i = () => {
1965
+ value: { keepAliveId: e, onKeepAliveMount: (o, a = { runOnFirstMount: !1 }) => {
1966
+ j(() => {
1967
+ const c = () => {
335
1968
  if (document.getElementById(e))
336
- n(e);
1969
+ o(e);
337
1970
  else {
338
- const d = new MutationObserver((p, g) => {
339
- document.getElementById(e) && (n(e), g.disconnect());
1971
+ const d = new MutationObserver((b, m) => {
1972
+ document.getElementById(e) && (o(e), m.disconnect());
340
1973
  });
341
1974
  return d.observe(document.body, {
342
1975
  childList: !0,
@@ -344,54 +1977,84 @@ const xe = ({ className: e }) => /* @__PURE__ */ c("div", { className: f("w-full
344
1977
  }), () => d.disconnect();
345
1978
  }
346
1979
  };
347
- return l?.runOnFirstMount && i(), r.current[e].push(i), () => {
348
- r.current[e] = r.current[e].filter(
349
- (u) => u !== i
1980
+ return a?.runOnFirstMount && c(), n.current[e].push(c), () => {
1981
+ n.current[e] = n.current[e].filter(
1982
+ (u) => u !== c
350
1983
  );
351
1984
  };
352
1985
  }, []);
353
- }, onKeepAliveDrop: (n) => {
354
- x(() => (t.current[e].push(n), () => {
355
- t.current[e] = t.current[e].filter(
356
- (l) => l !== n
1986
+ }, onKeepAliveDrop: (o) => {
1987
+ j(() => (r.current[e].push(o), () => {
1988
+ r.current[e] = r.current[e].filter(
1989
+ (a) => a !== o
357
1990
  );
358
1991
  }), []);
359
1992
  } },
360
- children: z(o, s, e)
1993
+ children: ye(t, i, e)
361
1994
  }
362
- )), we = () => {
363
- const e = P(R);
1995
+ )), wr = () => {
1996
+ const e = xe(Me);
364
1997
  if (!e)
365
1998
  throw new Error("useKeepAlive must be used within KeepAliveProvider");
366
1999
  return e;
367
- }, ye = ({
2000
+ }, yr = ({
368
2001
  aliveKey: e,
369
- children: r,
370
- enabled: t = !0,
371
- ...o
2002
+ children: n,
2003
+ enabled: r = !0,
2004
+ ...t
372
2005
  }) => {
373
- const s = v(null), { getPortalElement: a } = le();
374
- return x(() => {
375
- const b = a(e, r, o.className);
376
- return t && s.current && s.current.replaceWith(b), () => {
2006
+ const i = N(null), { getPortalElement: l } = Bt();
2007
+ return j(() => {
2008
+ const s = l(e, n, t.className);
2009
+ return r && i.current && i.current.replaceWith(s), () => {
377
2010
  };
378
- }, [e, r, t, o]), /* @__PURE__ */ c("div", { ...o, ref: s });
2011
+ }, [e, n, r, t]), /* @__PURE__ */ f("div", { ...t, ref: i, children: n });
379
2012
  };
380
2013
  export {
381
- ve as AliveScope,
382
- me as Avatar,
383
- he as AvatarsGroup,
384
- ne as Button,
385
- oe as Icon,
386
- ye as KeepAlive,
387
- xe as Separator,
388
- f as cn,
389
- fe as debounce,
390
- Y as generateInitials,
391
- U as throttle,
392
- we as useKeepAlive,
393
- H as useLargeScreen,
394
- _ as useMergedRef,
395
- q as useRipple
2014
+ xr as AliveScope,
2015
+ lr as Avatar,
2016
+ ir as AvatarsGroup,
2017
+ ie as Button,
2018
+ Lt as Checkbox,
2019
+ nr as FocusTrap,
2020
+ fr as Form,
2021
+ hr as FormInput,
2022
+ pr as FormMultiSelect,
2023
+ gr as FormSubmit,
2024
+ br as FormTags,
2025
+ mr as FormTextArea,
2026
+ xt as Icon,
2027
+ ze as Input,
2028
+ yr as KeepAlive,
2029
+ Tt as MultiSelect,
2030
+ yt as Portal,
2031
+ ur as Separator,
2032
+ wt as Spinner,
2033
+ vr as Switch,
2034
+ _t as Tags,
2035
+ De as TextArea,
2036
+ ut as calculatePopoverPosition,
2037
+ Q as checkOverflow,
2038
+ p as cn,
2039
+ er as debounce,
2040
+ rr as extractDirtyData,
2041
+ rt as generateInitials,
2042
+ Ce as nullRead,
2043
+ oe as nullSet,
2044
+ st as removeWhitespaces,
2045
+ nt as setFocusEnd,
2046
+ ae as throttle,
2047
+ tr as toTitleCase,
2048
+ ar as useClickAway,
2049
+ cr as useClickAwayAdvanced,
2050
+ ft as useClickAwayWithRef,
2051
+ wr as useKeepAlive,
2052
+ lt as useLargeScreen,
2053
+ it as useMergedRef,
2054
+ dr as useMethods,
2055
+ sr as useOverflow,
2056
+ or as useOverflowState,
2057
+ ct as usePopover,
2058
+ at as useRipple
396
2059
  };
397
2060
  //# sourceMappingURL=index.js.map