@vellira-ui/react 2.19.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1096 @@
1
+ import { createContext as e, forwardRef as t, useCallback as n, useContext as r, useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
2
+ import l from "clsx";
3
+ import { createPortal as u } from "react-dom";
4
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
+ import { FloatingPortal as m, arrow as h, autoUpdate as g, flip as _, offset as v, shift as y, size as b, useFloating as x, useFocus as S, useHover as C, useInteractions as w } from "@floating-ui/react";
6
+ import { useControllableState as T, useKeyboardNavigation as E, useTabsKeyboard as D } from "@vellira-ui/core";
7
+ import { Check as O, ChevronDown as k, Close as A } from "@vellira-ui/icons";
8
+ import j from "focus-trap-react";
9
+ //#region src/utils/cn.ts
10
+ var M = (...e) => l(e), N = ({ children: e }) => {
11
+ let [t, n] = c(!1);
12
+ if (i(() => {
13
+ n(!0);
14
+ }, []), !t) return null;
15
+ let r = document.getElementById("overlay-root") ?? document.body;
16
+ return r ? u(e, r) : null;
17
+ }, P = {
18
+ dropdown: "_dropdown_6pgxt_1",
19
+ dropdownIn: "_dropdownIn_6pgxt_1"
20
+ }, F = t(({ children: e, floatingStyles: t, menuId: n, labelledById: r, label: i, activeDescendantId: a, onKeyDown: o, className: s }, c) => /* @__PURE__ */ f(N, { children: /* @__PURE__ */ f("ul", {
21
+ ref: c,
22
+ id: n,
23
+ role: "menu",
24
+ tabIndex: -1,
25
+ "aria-labelledby": r,
26
+ "aria-label": r ? void 0 : i,
27
+ "aria-activedescendant": a,
28
+ onKeyDown: o,
29
+ style: t,
30
+ className: M(P.dropdown, s),
31
+ children: e
32
+ }) }));
33
+ F.displayName = "DropdownContent";
34
+ //#endregion
35
+ //#region src/hooks/useFloatingPosition.ts
36
+ var I = (e) => {
37
+ let [t, n] = c(() => typeof window > "u" || typeof window.matchMedia != "function" || !e ? !1 : window.matchMedia(`(max-width: ${e}px)`).matches);
38
+ return i(() => {
39
+ if (typeof window > "u" || typeof window.matchMedia != "function" || !e) return;
40
+ let t = window.matchMedia(`(max-width: ${e}px)`), r = () => n(t.matches);
41
+ return r(), t.addEventListener("change", r), () => {
42
+ t.removeEventListener("change", r);
43
+ };
44
+ }, [e]), t;
45
+ }, ee = ({ open: e, onOpenChange: t, placement: n = "bottom-start", strategy: r = "fixed", matchTriggerWidth: a = !1, mobileSheetBreakpoint: s, middleware: c = [] } = {}) => {
46
+ let l = I(s), { refs: u, floatingStyles: d, update: f, context: p, middlewareData: m, placement: h } = x({
47
+ open: e,
48
+ onOpenChange: t,
49
+ placement: n,
50
+ strategy: r,
51
+ transform: !1,
52
+ middleware: o(() => [
53
+ v(6),
54
+ _(),
55
+ b({ apply({ rects: e, elements: t }) {
56
+ !a || l || Object.assign(t.floating.style, { width: `${e.reference.width}px` });
57
+ } }),
58
+ y({ padding: 8 }),
59
+ ...c
60
+ ], [
61
+ c,
62
+ l,
63
+ a
64
+ ]),
65
+ whileElementsMounted: g
66
+ });
67
+ return i(() => {
68
+ l && u.floating.current?.style.removeProperty("width");
69
+ }, [l, u.floating]), {
70
+ context: p,
71
+ placement: h,
72
+ middlewareData: m,
73
+ floatingStyles: l ? {} : d,
74
+ isMobileSheet: l,
75
+ setRef: u.setReference,
76
+ setFloatingRef: u.setFloating,
77
+ updatePosition: f
78
+ };
79
+ }, te = (e, t, n = !0) => {
80
+ let r = s(e);
81
+ r.current = e;
82
+ let a = s(t);
83
+ a.current = t, i(() => {
84
+ if (!n) return;
85
+ let e = (e) => {
86
+ let t = e.target;
87
+ r.current.every((e) => e.current && !e.current.contains(t)) && a.current();
88
+ };
89
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
90
+ }, [n]);
91
+ }, L = { group: "_group_1yomt_1" }, ne = ({ label: e }) => /* @__PURE__ */ f("li", {
92
+ role: "presentation",
93
+ className: L.group,
94
+ children: e
95
+ }), R = {
96
+ item: "_item_t87eq_1",
97
+ disabled: "_disabled_t87eq_18",
98
+ active: "_active_t87eq_28",
99
+ danger: "_danger_t87eq_37",
100
+ itemIcon: "_itemIcon_t87eq_61",
101
+ itemShortcut: "_itemShortcut_t87eq_62",
102
+ itemText: "_itemText_t87eq_68",
103
+ "itemText--truncate": "_itemText--truncate_t87eq_74",
104
+ "itemText--wrap": "_itemText--wrap_t87eq_79",
105
+ "itemText--nowrap": "_itemText--nowrap_t87eq_83"
106
+ }, z = ({ id: e, children: t, label: n, icon: r, danger: i, disabled: a, active: o, onClick: s, onMouseEnter: c, shortcut: l, textWrap: u = "truncate", className: d }) => {
107
+ let m = t || n;
108
+ return /* @__PURE__ */ p("li", {
109
+ id: e,
110
+ role: "menuitem",
111
+ tabIndex: -1,
112
+ "aria-disabled": a || void 0,
113
+ "data-active": o || void 0,
114
+ "data-danger": i || void 0,
115
+ onClick: a ? void 0 : s,
116
+ onMouseEnter: a ? void 0 : c,
117
+ className: M(R.item, {
118
+ [R.active]: o,
119
+ [R.disabled]: a,
120
+ [R.danger]: i
121
+ }, d),
122
+ children: [
123
+ r && /* @__PURE__ */ f("span", {
124
+ "aria-hidden": "true",
125
+ className: R.itemIcon,
126
+ children: r
127
+ }),
128
+ m && /* @__PURE__ */ f("span", {
129
+ className: M(R.itemText, R[`itemText--${u}`]),
130
+ children: m
131
+ }),
132
+ l && /* @__PURE__ */ f("span", {
133
+ className: R.itemShortcut,
134
+ children: l
135
+ })
136
+ ]
137
+ });
138
+ }, B = { group: "_group_ts4nb_1" }, re = () => /* @__PURE__ */ f("li", {
139
+ role: "separator",
140
+ className: B.separator,
141
+ "aria-hidden": "true"
142
+ }), V = {
143
+ button: "_button_ii6sx_1",
144
+ disabled: "_disabled_ii6sx_16",
145
+ iconLeft: "_iconLeft_ii6sx_27",
146
+ arrow: "_arrow_ii6sx_39",
147
+ iconOnly: "_iconOnly_ii6sx_42",
148
+ open: "_open_ii6sx_75"
149
+ }, ie = t(({ children: e, isOpen: t, icon: n, arrowIcon: r, showArrow: i = !0, rotateAngle: a = 90, label: o, className: s, ...c }, l) => {
150
+ let u = !!n, d = !!e, m = u && !d, h = i && d, g = r ?? /* @__PURE__ */ f(k, {}), _ = m ? o ?? "Open menu" : void 0;
151
+ return /* @__PURE__ */ p("button", {
152
+ ...c,
153
+ ref: l,
154
+ type: "button",
155
+ className: M(V.button, {
156
+ [V.disabled]: c.disabled,
157
+ [V.iconOnly]: m
158
+ }, s),
159
+ "aria-label": _,
160
+ "aria-expanded": t,
161
+ "aria-haspopup": "menu",
162
+ style: { "--dropdown-rotate-angle": `${a}deg` },
163
+ children: [
164
+ u && /* @__PURE__ */ f("span", {
165
+ "aria-hidden": "true",
166
+ className: V.iconLeft,
167
+ children: n
168
+ }),
169
+ e,
170
+ h && /* @__PURE__ */ f("span", {
171
+ "aria-hidden": "true",
172
+ className: M(V.arrow, { [V.open]: t }),
173
+ children: g
174
+ })
175
+ ]
176
+ });
177
+ });
178
+ ie.displayName = "DropdownTrigger";
179
+ //#endregion
180
+ //#region src/components/Dropdown/types.ts
181
+ var ae = (e) => e.type !== "group" && e.type !== "separator", oe = (e) => e.type === "group", se = (e) => e.type === "separator", ce = { wrapper: "_wrapper_14ue8_1" }, le = ({ label: e, icon: t, trigger: n, items: r, onSelect: i, className: o, disabled: l, rotateAngle: u = 90, placement: d, matchTriggerWidth: m, textWrap: h, showArrow: g = !0, arrowIcon: _ }) => {
182
+ let [v, y] = c(!1), [b, x] = c(-1), S = s(null), C = s(null), w = a(), T = `${w}-trigger`, { floatingStyles: D, setRef: O, setFloatingRef: k } = ee({
183
+ placement: d,
184
+ matchTriggerWidth: m,
185
+ mobileSheetBreakpoint: 640
186
+ }), A = r.filter(ae), j = v && b >= 0 ? `${w}-item-${b}` : void 0, N = () => A.findIndex((e) => !e.disabled), P = () => {
187
+ l || y((e) => {
188
+ let t = !e;
189
+ return x(t ? N() : -1), t;
190
+ });
191
+ }, I = () => {
192
+ y(!1), x(-1);
193
+ }, L = () => {
194
+ I(), S.current?.focus();
195
+ }, { onKeyDown: R } = E({
196
+ activeIndex: b,
197
+ setActiveIndex: x,
198
+ items: A,
199
+ isOpen: v,
200
+ onOpen: P,
201
+ onSelect: () => {
202
+ let e = A[b];
203
+ !e || e.disabled || (i?.(e.value), L());
204
+ },
205
+ onClose: L
206
+ });
207
+ te([S, C], () => I(), v);
208
+ let B = (e) => {
209
+ S.current = e, O(e);
210
+ }, V = (e) => {
211
+ C.current = e, k(e), e?.focus();
212
+ };
213
+ return /* @__PURE__ */ p("div", {
214
+ className: M(ce.wrapper, o),
215
+ children: [/* @__PURE__ */ f(ie, {
216
+ ref: B,
217
+ id: T,
218
+ isOpen: v,
219
+ disabled: l,
220
+ icon: t,
221
+ label: e,
222
+ showArrow: g,
223
+ arrowIcon: _,
224
+ rotateAngle: u,
225
+ onClick: P,
226
+ onKeyDown: R,
227
+ "aria-expanded": v,
228
+ "aria-haspopup": "menu",
229
+ ...v && { "aria-controls": w },
230
+ children: n
231
+ }), v && /* @__PURE__ */ f(F, {
232
+ ref: V,
233
+ floatingStyles: D,
234
+ menuId: w,
235
+ labelledById: n ? T : void 0,
236
+ label: n ? void 0 : e,
237
+ activeDescendantId: j,
238
+ onKeyDown: R,
239
+ children: r.map((e, t) => {
240
+ if (oe(e)) return /* @__PURE__ */ f(ne, { label: e.label }, `group-${e.label}`);
241
+ if (se(e)) return /* @__PURE__ */ f(re, {}, `separator-${t}`);
242
+ if (ae(e)) {
243
+ let t = A.findIndex((t) => t === e);
244
+ return /* @__PURE__ */ f(z, {
245
+ id: `${w}-item-${t}`,
246
+ ...e,
247
+ active: b === t,
248
+ textWrap: e.textWrap || h,
249
+ onClick: () => {
250
+ e.disabled || (i?.(e.value), L());
251
+ },
252
+ onMouseEnter: () => {
253
+ t < 0 || e.disabled || x(t);
254
+ },
255
+ children: e.label
256
+ }, e.value);
257
+ }
258
+ })
259
+ })]
260
+ });
261
+ }, ue = e(void 0), de = () => {
262
+ let e = r(ue);
263
+ if (e === void 0) throw Error("Modal compound components must be used inside Modal");
264
+ return e;
265
+ };
266
+ ue.displayName = "ModalContext";
267
+ var fe = { modalBody: "_modalBody_iv33a_1" }, pe = ({ children: e }) => {
268
+ let { descriptionId: t } = de();
269
+ return /* @__PURE__ */ f("div", {
270
+ id: t,
271
+ className: fe.modalBody,
272
+ children: e
273
+ });
274
+ };
275
+ pe.displayName = "ModalBody";
276
+ var me = { content: "_content_avpai_1" }, he = ({ children: e }) => /* @__PURE__ */ f("div", {
277
+ className: me.content,
278
+ children: e
279
+ });
280
+ he.displayName = "ModalContent";
281
+ var ge = { modalFooter: "_modalFooter_ezys6_1" }, _e = ({ children: e }) => /* @__PURE__ */ f("div", {
282
+ className: ge.modalFooter,
283
+ children: e
284
+ });
285
+ _e.displayName = "ModalFooter";
286
+ var ve = {
287
+ modalHeader: "_modalHeader_155d7_1",
288
+ modalHeaderTitle: "_modalHeaderTitle_155d7_8",
289
+ modalHeaderCloseButton: "_modalHeaderCloseButton_155d7_15"
290
+ }, ye = ({ children: e }) => {
291
+ let { onClose: t, titleId: n } = de();
292
+ return /* @__PURE__ */ p("div", {
293
+ className: ve.modalHeader,
294
+ children: [/* @__PURE__ */ f("h2", {
295
+ id: n,
296
+ className: ve.modalHeaderTitle,
297
+ children: e
298
+ }), t && /* @__PURE__ */ f("button", {
299
+ type: "button",
300
+ className: ve.modalHeaderCloseButton,
301
+ onClick: t,
302
+ "aria-label": "Close modal",
303
+ children: /* @__PURE__ */ f(A, { size: 16 })
304
+ })]
305
+ });
306
+ };
307
+ ye.displayName = "ModalHeader";
308
+ //#endregion
309
+ //#region src/hooks/useModalKeyboard.ts
310
+ var be = ({ isOpen: e, onClose: t }) => {
311
+ let r = n((n) => {
312
+ e && n.key === "Escape" && (n.preventDefault(), t?.());
313
+ }, [e, t]);
314
+ i(() => (document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r)), [r]);
315
+ }, H = {
316
+ overlay: "_overlay_1xotg_1",
317
+ "overlay--open": "_overlay--open_1xotg_13",
318
+ "overlay--animated": "_overlay--animated_1xotg_17",
319
+ modal: "_modal_1xotg_21"
320
+ }, U = 0, xe = "", Se = ({ children: e, onClose: t, isOpen: r, className: a, closeOnBackdrop: o, closeOnClick: c, closeOnEsc: l = !0, zIndex: u = 1e3, animated: d = !0 }) => {
321
+ let p = o ?? c ?? !0, m = s(null), { titleId: h, descriptionId: g } = de(), _ = n((e) => {
322
+ p && e.target === e.currentTarget && t?.();
323
+ }, [p, t]);
324
+ return be({
325
+ isOpen: r,
326
+ onClose: l ? t : void 0
327
+ }), i(() => {
328
+ if (r) return U === 0 && (xe = document.body.style.overflow), U += 1, document.body.style.overflow = "hidden", () => {
329
+ U = Math.max(0, U - 1), U === 0 && (document.body.style.overflow = xe);
330
+ };
331
+ }, [r]), !r && !d ? null : /* @__PURE__ */ f(N, { children: /* @__PURE__ */ f("div", {
332
+ className: M(H.overlay, r && H["overlay--open"], d && H["overlay--animated"], a),
333
+ onClick: _,
334
+ tabIndex: -1,
335
+ role: "presentation",
336
+ "aria-hidden": !r,
337
+ style: { zIndex: u },
338
+ children: /* @__PURE__ */ f(j, {
339
+ active: r,
340
+ focusTrapOptions: {
341
+ fallbackFocus: () => m.current,
342
+ returnFocusOnDeactivate: !0,
343
+ allowOutsideClick: !0
344
+ },
345
+ children: /* @__PURE__ */ f("div", {
346
+ ref: m,
347
+ tabIndex: -1,
348
+ className: H.modal,
349
+ role: "dialog",
350
+ "aria-modal": "true",
351
+ "aria-labelledby": h,
352
+ "aria-describedby": g,
353
+ children: e
354
+ })
355
+ })
356
+ }) });
357
+ };
358
+ Se.displayName = "ModalOverlay";
359
+ //#endregion
360
+ //#region src/components/Modal/Modal.tsx
361
+ var Ce = ({ isOpen: e, children: t, onClose: n, closeOnBackdrop: r, closeOnClick: i, closeOnEsc: o = !0 }) => {
362
+ let s = a(), c = a();
363
+ return e ? /* @__PURE__ */ f(ue.Provider, {
364
+ value: {
365
+ onClose: n,
366
+ titleId: s,
367
+ descriptionId: c
368
+ },
369
+ children: /* @__PURE__ */ f(Se, {
370
+ isOpen: e,
371
+ onClose: n,
372
+ closeOnBackdrop: r ?? i,
373
+ closeOnEsc: o,
374
+ children: /* @__PURE__ */ f(he, { children: t })
375
+ })
376
+ }) : null;
377
+ };
378
+ Ce.displayName = "Modal";
379
+ //#endregion
380
+ //#region src/components/Modal/index.ts
381
+ var we = Object.assign(Ce, {
382
+ Header: ye,
383
+ Body: pe,
384
+ Content: he,
385
+ Footer: _e
386
+ }), W = {
387
+ wrapper: "_wrapper_14t1p_1",
388
+ label: "_label_14t1p_9",
389
+ required: "_required_14t1p_20",
390
+ description: "_description_14t1p_25",
391
+ control: "_control_14t1p_32",
392
+ errorText: "_errorText_14t1p_38",
393
+ disabled: "_disabled_14t1p_45"
394
+ }, G = ({ id: e, label: t, description: n, error: r, required: i = !1, disabled: o = !1, children: s, className: c }) => {
395
+ let l = a(), u = e ?? l, d = n ? `${u}-description` : void 0, m = r ? `${u}-error` : void 0;
396
+ return /* @__PURE__ */ p("div", {
397
+ className: M(W.wrapper, { [W.disabled]: o }, c),
398
+ "data-disabled": o || void 0,
399
+ "data-invalid": !!r || void 0,
400
+ children: [
401
+ t && /* @__PURE__ */ p("label", {
402
+ className: W.label,
403
+ htmlFor: u,
404
+ children: [t, i && /* @__PURE__ */ f("span", {
405
+ className: W.required,
406
+ "aria-hidden": "true",
407
+ children: "*"
408
+ })]
409
+ }),
410
+ n && /* @__PURE__ */ f("span", {
411
+ className: W.description,
412
+ id: d,
413
+ children: n
414
+ }),
415
+ /* @__PURE__ */ f("div", {
416
+ className: W.control,
417
+ children: s
418
+ }),
419
+ r && /* @__PURE__ */ f("span", {
420
+ className: W.errorText,
421
+ id: m,
422
+ role: "alert",
423
+ children: r
424
+ })
425
+ ]
426
+ });
427
+ }, K = {
428
+ group: "_group_rncsx_1",
429
+ vertical: "_vertical_rncsx_7",
430
+ horizontal: "_horizontal_rncsx_11",
431
+ option: "_option_rncsx_16",
432
+ disabled: "_disabled_rncsx_27",
433
+ customRadio: "_customRadio_rncsx_30",
434
+ input: "_input_rncsx_35",
435
+ label: "_label_rncsx_86"
436
+ }, Te = ({ label: e, description: t, value: n, defaultValue: r, onChange: i, options: o, name: s, required: c = !1, disabled: l = !1, error: u, className: d, orientation: m = "vertical" }) => {
437
+ let h = a(), g = `${h}-group`, _ = [t ? `${h}-description` : void 0, u ? `${h}-error` : void 0].filter(Boolean).join(" ") || void 0, [v, y] = T({
438
+ value: n,
439
+ defaultValue: r ?? "",
440
+ onChange: i
441
+ });
442
+ return /* @__PURE__ */ f(G, {
443
+ id: h,
444
+ label: e,
445
+ description: t,
446
+ required: c,
447
+ disabled: l,
448
+ error: u,
449
+ children: /* @__PURE__ */ f("div", {
450
+ id: g,
451
+ className: M(K.group, K[m], d),
452
+ role: "radiogroup",
453
+ "aria-required": c || void 0,
454
+ "aria-invalid": !!u || void 0,
455
+ "aria-describedby": _,
456
+ children: o.map((e) => {
457
+ let t = `${h}-${e.value}`, n = l || e.disabled;
458
+ return /* @__PURE__ */ p("label", {
459
+ htmlFor: t,
460
+ className: M(K.option, { [K.disabled]: n }),
461
+ children: [
462
+ /* @__PURE__ */ f("input", {
463
+ id: t,
464
+ type: "radio",
465
+ name: s,
466
+ value: e.value,
467
+ checked: v === e.value,
468
+ required: c,
469
+ disabled: n,
470
+ onChange: () => {
471
+ n || y(e.value);
472
+ },
473
+ className: K.input
474
+ }),
475
+ /* @__PURE__ */ f("span", {
476
+ className: K.customRadio,
477
+ "aria-hidden": "true"
478
+ }),
479
+ /* @__PURE__ */ f("span", {
480
+ className: K.label,
481
+ children: e.label
482
+ })
483
+ ]
484
+ }, e.value);
485
+ })
486
+ })
487
+ });
488
+ };
489
+ Te.displayName = "RadioGroup";
490
+ var q = {
491
+ option: "_option_1qm3g_1",
492
+ selected: "_selected_1qm3g_10",
493
+ disabled: "_disabled_1qm3g_10",
494
+ active: "_active_1qm3g_21"
495
+ }, Ee = ({ option: e, isSelected: t, isActive: n, optionId: r, onSelect: i, onMouseEnter: a }) => {
496
+ let o = !!e.disabled;
497
+ return /* @__PURE__ */ f("li", {
498
+ id: r,
499
+ role: "option",
500
+ "aria-selected": t,
501
+ "aria-disabled": o || void 0,
502
+ className: M(q.option, {
503
+ [q.selected]: t,
504
+ [q.active]: n,
505
+ [q.disabled]: o
506
+ }),
507
+ onClick: () => {
508
+ o || i(e.value);
509
+ },
510
+ onMouseEnter: () => {
511
+ o || a();
512
+ },
513
+ children: e.label
514
+ });
515
+ };
516
+ Ee.displayName = "SelectOption";
517
+ var De = {
518
+ dropdown: "_dropdown_1vrjb_1",
519
+ dropdownIn: "_dropdownIn_1vrjb_1"
520
+ }, Oe = ({ isOpen: e, listboxId: t, labelledById: n, setDropdownRef: r, style: i, options: a, selectedValue: o, activeIndex: s, onSelect: c, onMouseEnter: l }) => e ? /* @__PURE__ */ f(N, { children: /* @__PURE__ */ f("ul", {
521
+ ref: r,
522
+ id: t,
523
+ role: "listbox",
524
+ "aria-labelledby": n,
525
+ className: De.dropdown,
526
+ style: i,
527
+ children: a.map((e, n) => /* @__PURE__ */ f(Ee, {
528
+ option: e,
529
+ isSelected: e.value === o,
530
+ isActive: n === s,
531
+ optionId: `${t}-option-${n}`,
532
+ onSelect: c,
533
+ onMouseEnter: () => l(n)
534
+ }, e.value))
535
+ }) }) : null;
536
+ Oe.displayName = "SelectDropdown";
537
+ var J = {
538
+ control: "_control_mmsxg_1",
539
+ disabled: "_disabled_mmsxg_19",
540
+ arrow: "_arrow_mmsxg_24",
541
+ value: "_value_mmsxg_34",
542
+ placeholder: "_placeholder_mmsxg_42",
543
+ error: "_error_mmsxg_46",
544
+ open: "_open_mmsxg_87"
545
+ }, ke = ({ id: e, errorId: t, isOpen: n, disabled: r, required: i, listboxId: a, activeIndex: o, ariaLabel: s, error: c, displayText: l, isPlaceholder: u, buttonRef: d, onClick: m, onKeyDown: h }) => /* @__PURE__ */ p("button", {
546
+ id: e,
547
+ ref: d,
548
+ type: "button",
549
+ role: "combobox",
550
+ disabled: r,
551
+ "aria-disabled": r || void 0,
552
+ "aria-required": i || void 0,
553
+ "aria-expanded": n,
554
+ "aria-haspopup": "listbox",
555
+ "aria-label": s,
556
+ "aria-controls": n ? a : void 0,
557
+ "aria-describedby": t,
558
+ "aria-activedescendant": n && o >= 0 ? `${a}-option-${o}` : void 0,
559
+ className: M(J.control, {
560
+ [J.error]: !!c,
561
+ [J.disabled]: r
562
+ }),
563
+ onClick: m,
564
+ onKeyDown: h,
565
+ children: [/* @__PURE__ */ f("span", {
566
+ className: M(J.value, { [J.placeholder]: u }),
567
+ children: l
568
+ }), /* @__PURE__ */ f("span", {
569
+ className: M(J.arrow, { [J.open]: n }),
570
+ "aria-hidden": "true",
571
+ children: /* @__PURE__ */ f(k, {})
572
+ })]
573
+ });
574
+ ke.displayName = "SelectTrigger";
575
+ //#endregion
576
+ //#region src/components/Select/Select.tsx
577
+ var Ae = ({ label: e, description: t, id: r, name: i, value: l, defaultValue: u, onChange: d, options: m, placeholder: h = "Select...", required: g = !1, disabled: _ = !1, error: v, className: y }) => {
578
+ let b = a(), x = r ?? b, S = `${x}-listbox`, C = v ? `${x}-error` : void 0, w = s(null), D = s(null), [O, k] = T({
579
+ value: l,
580
+ defaultValue: u ?? "",
581
+ onChange: d
582
+ }), [A, j] = c(!1), [M, N] = c(-1), P = o(() => m.find((e) => e.value === O), [m, O]), F = !!P, { floatingStyles: I, setRef: L, setFloatingRef: ne } = ee({
583
+ open: A,
584
+ matchTriggerWidth: !0,
585
+ mobileSheetBreakpoint: 640
586
+ }), R = n(() => {
587
+ let e = m.findIndex((e) => e.value === O && !e.disabled);
588
+ return e >= 0 ? e : m.findIndex((e) => !e.disabled);
589
+ }, [m, O]), z = n(() => {
590
+ _ || (N(R()), j(!0));
591
+ }, [_, R]), B = n(() => {
592
+ j(!1);
593
+ }, []), re = n(() => {
594
+ if (!_) {
595
+ if (A) {
596
+ B();
597
+ return;
598
+ }
599
+ z();
600
+ }
601
+ }, [
602
+ B,
603
+ _,
604
+ A,
605
+ z
606
+ ]), V = n((e) => {
607
+ k(e), B(), w.current?.focus();
608
+ }, [B, k]), { onKeyDown: ie } = E({
609
+ activeIndex: M,
610
+ setActiveIndex: N,
611
+ items: m,
612
+ isOpen: A,
613
+ onOpen: z,
614
+ onClose: B,
615
+ onSelect: () => {
616
+ let e = m[M];
617
+ !e || e.disabled || V(e.value);
618
+ }
619
+ });
620
+ te([w, D], B, A);
621
+ let ae = n((e) => {
622
+ w.current = e, L(e);
623
+ }, [L]), oe = n((e) => {
624
+ D.current = e, ne(e);
625
+ }, [ne]);
626
+ return /* @__PURE__ */ p(G, {
627
+ id: x,
628
+ label: e,
629
+ description: t,
630
+ error: v,
631
+ required: g,
632
+ disabled: _,
633
+ className: y,
634
+ children: [
635
+ /* @__PURE__ */ f(ke, {
636
+ id: x,
637
+ errorId: C,
638
+ isOpen: A,
639
+ disabled: _,
640
+ required: g,
641
+ listboxId: S,
642
+ activeIndex: M,
643
+ ariaLabel: e ? void 0 : P?.label || h,
644
+ error: v,
645
+ displayText: P?.label ?? h,
646
+ isPlaceholder: !F,
647
+ buttonRef: ae,
648
+ onClick: re,
649
+ onKeyDown: ie
650
+ }),
651
+ i && /* @__PURE__ */ f("input", {
652
+ type: "hidden",
653
+ name: i,
654
+ value: O,
655
+ disabled: _
656
+ }),
657
+ /* @__PURE__ */ f(Oe, {
658
+ isOpen: A,
659
+ listboxId: S,
660
+ labelledById: x,
661
+ style: I,
662
+ options: m,
663
+ selectedValue: O,
664
+ activeIndex: M,
665
+ setDropdownRef: oe,
666
+ onSelect: V,
667
+ onMouseEnter: N
668
+ })
669
+ ]
670
+ });
671
+ };
672
+ Ae.displayName = "Select";
673
+ //#endregion
674
+ //#region src/components/Tabs/TabsContext.tsx
675
+ var je = e(null), Me = () => {
676
+ let e = r(je);
677
+ if (!e) throw Error("Tabs components must be used inside Tabs");
678
+ return e;
679
+ }, Y = {
680
+ list: "_list_astty_1",
681
+ vertical: "_vertical_astty_8"
682
+ }, Ne = ({ children: e, className: t, ...n }) => {
683
+ let { orientation: r, appearance: i } = Me();
684
+ return /* @__PURE__ */ f("div", {
685
+ ...n,
686
+ role: "tablist",
687
+ "aria-orientation": r,
688
+ className: M(Y.list, r === "vertical" && Y.vertical, i === "underline" && Y.underline, i === "pills" && Y.pills, t),
689
+ children: e
690
+ });
691
+ };
692
+ Ne.displayName = "TabsList";
693
+ var Pe = {
694
+ panel: "_panel_1e9ds_1",
695
+ visible: "_visible_1e9ds_10",
696
+ vertical: "_vertical_1e9ds_15"
697
+ }, Fe = ({ index: e, children: t, className: n }) => {
698
+ let { activeIndex: r, orientation: a } = Me(), [o, s] = c(!1), l = r === e;
699
+ return i(() => {
700
+ if (!l) {
701
+ s(!1);
702
+ return;
703
+ }
704
+ let e = setTimeout(() => s(!0), 10);
705
+ return () => clearTimeout(e);
706
+ }, [l]), /* @__PURE__ */ f("div", {
707
+ role: "tabpanel",
708
+ id: `tab-panel-${e}`,
709
+ "aria-labelledby": `tab-${e}`,
710
+ hidden: !l,
711
+ tabIndex: 0,
712
+ className: M(Pe.panel, o && Pe.visible, a === "vertical" && Pe.vertical, n),
713
+ children: t
714
+ });
715
+ };
716
+ Fe.displayName = "TabsPanel";
717
+ var X = {
718
+ tab: "_tab_160gh_1",
719
+ iconOnly: "_iconOnly_160gh_19",
720
+ tabIcon: "_tabIcon_160gh_27",
721
+ label: "_label_160gh_41",
722
+ default: "_default_160gh_46",
723
+ underline: "_underline_160gh_53",
724
+ pills: "_pills_160gh_81",
725
+ vertical: "_vertical_160gh_93"
726
+ }, Ie = t(({ index: e, children: t, className: r, disabled: i = !1, icon: a, onClick: o, onKeyDown: s, ...c }, l) => {
727
+ let { activeIndex: u, setActiveIndex: d, orientation: m, appearance: h = "default", registerTab: g, onTabKeyDown: _ } = Me(), v = u === e, y = !!a, b = y && t == null;
728
+ return /* @__PURE__ */ p("button", {
729
+ type: "button",
730
+ ref: n((t) => {
731
+ g(e, t), typeof l == "function" ? l(t) : l && (l.current = t);
732
+ }, [
733
+ g,
734
+ e,
735
+ l
736
+ ]),
737
+ role: "tab",
738
+ "aria-selected": v,
739
+ "aria-controls": `tab-panel-${e}`,
740
+ id: `tab-${e}`,
741
+ disabled: i,
742
+ tabIndex: v ? 0 : -1,
743
+ className: M(X.tab, X[h], m === "vertical" && X.vertical, y && X.withIcon, b && X.iconOnly, r),
744
+ onClick: (t) => {
745
+ i || (d(e), o?.(t));
746
+ },
747
+ onKeyDown: (e) => {
748
+ _(e), s?.(e);
749
+ },
750
+ ...c,
751
+ children: [y && /* @__PURE__ */ f("span", {
752
+ className: X.tabIcon,
753
+ "aria-hidden": "true",
754
+ children: a
755
+ }), t != null && /* @__PURE__ */ f("span", {
756
+ className: X.label,
757
+ children: t
758
+ })]
759
+ });
760
+ });
761
+ Ie.displayName = "Tab";
762
+ var Le = {
763
+ tabs: "_tabs_15a7w_1",
764
+ vertical: "_vertical_15a7w_4"
765
+ }, Re = ({ children: e, activeIndex: t, defaultActiveIndex: r = 0, onChange: i, orientation: a = "horizontal", appearance: o = "default", className: l }) => {
766
+ let [u, d] = c(r), p = t !== void 0, m = p ? t : u, h = n((e) => {
767
+ p || d(e), i?.(e);
768
+ }, [p, i]), g = s([]), _ = n((e, t) => {
769
+ g.current[e] = t;
770
+ }, []), { onKeyDown: v } = D({
771
+ activeIndex: m,
772
+ setActiveIndex: h,
773
+ tabRefs: g,
774
+ orientation: a
775
+ }), y = {
776
+ activeIndex: m,
777
+ setActiveIndex: h,
778
+ orientation: a,
779
+ appearance: o,
780
+ registerTab: _,
781
+ onTabKeyDown: v
782
+ };
783
+ return /* @__PURE__ */ f(je.Provider, {
784
+ value: y,
785
+ children: /* @__PURE__ */ f("div", {
786
+ className: M(Le.tabs, a === "vertical" && Le.vertical, l),
787
+ children: e
788
+ })
789
+ });
790
+ };
791
+ Re.displayName = "Tabs";
792
+ //#endregion
793
+ //#region src/components/Tabs/index.ts
794
+ var ze = Object.assign(Re, {
795
+ List: Ne,
796
+ Tab: Ie,
797
+ Panel: Fe
798
+ }), Be = {
799
+ tooltip: "_tooltip_frlq7_1",
800
+ arrow: "_arrow_frlq7_22"
801
+ }, Ve = t(({ content: e, placement: t = "top", arrowRef: n, arrowX: r, arrowY: i, className: a, style: o, ...s }, c) => {
802
+ let l = {
803
+ top: "bottom",
804
+ right: "left",
805
+ bottom: "top",
806
+ left: "right"
807
+ }[t.split("-")[0]], u = {
808
+ position: "absolute",
809
+ pointerEvents: "none",
810
+ left: r == null ? "" : `${r}px`,
811
+ top: i == null ? "" : `${i}px`,
812
+ [l]: "-5px"
813
+ };
814
+ return /* @__PURE__ */ p("div", {
815
+ ref: c,
816
+ className: M(Be.tooltip, a),
817
+ "data-placement": t,
818
+ "data-state": "open",
819
+ style: o,
820
+ ...s,
821
+ children: [e, /* @__PURE__ */ f("div", {
822
+ ref: n,
823
+ className: Be.arrow,
824
+ style: u
825
+ })]
826
+ });
827
+ });
828
+ Ve.displayName = "TooltipContent";
829
+ //#endregion
830
+ //#region src/components/Tooltip/Tooltip.tsx
831
+ var He = ({ children: e, placement: t = "top", content: n, disabled: r = !1, delay: i = {
832
+ open: 300,
833
+ close: 100
834
+ }, maxWidth: o = 250, className: l, onOpenChange: u }) => {
835
+ let [g, _] = c(!1), v = s(null), y = a(), { context: b, floatingStyles: x, middlewareData: T, setRef: E, setFloatingRef: D, placement: O } = ee({
836
+ open: g,
837
+ onOpenChange: (e) => {
838
+ r || (_(e), u?.(e));
839
+ },
840
+ placement: t,
841
+ middleware: [h({ element: v })]
842
+ }), k = T.arrow?.x, A = T.arrow?.y, { getReferenceProps: j, getFloatingProps: M } = w([C(b, { delay: {
843
+ open: i.open,
844
+ close: i.close
845
+ } }), S(b)]);
846
+ return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
847
+ ref: E,
848
+ style: { display: "inline-flex" },
849
+ "aria-describedby": g ? y : void 0,
850
+ ...j(),
851
+ children: e
852
+ }), /* @__PURE__ */ f(m, { children: g && n && /* @__PURE__ */ f(Ve, {
853
+ id: y,
854
+ ref: D,
855
+ content: n,
856
+ arrowRef: v,
857
+ arrowX: k,
858
+ arrowY: A,
859
+ role: "tooltip",
860
+ style: {
861
+ ...x,
862
+ maxWidth: typeof o == "number" ? `${o}px` : o
863
+ },
864
+ placement: O,
865
+ className: l,
866
+ ...M()
867
+ }) })] });
868
+ };
869
+ He.displayName = "Tooltip";
870
+ var Z = {
871
+ button: "_button_1nc1z_1",
872
+ primary: "_primary_1nc1z_22",
873
+ secondary: "_secondary_1nc1z_38",
874
+ danger: "_danger_1nc1z_54",
875
+ sm: "_sm_1nc1z_80",
876
+ md: "_md_1nc1z_87",
877
+ lg: "_lg_1nc1z_94",
878
+ iconOnly: "_iconOnly_1nc1z_100",
879
+ fullWidth: "_fullWidth_1nc1z_105",
880
+ label: "_label_1nc1z_121",
881
+ icon: "_icon_1nc1z_100"
882
+ }, Ue = t(({ children: e, variant: t = "primary", size: n = "md", disabled: r = !1, leftIcon: i, rightIcon: a, fullWidth: o = !1, className: s, onClick: c, ariaLabel: l }, u) => {
883
+ let d = !e && (i || a);
884
+ return d && !l && process.env.NODE_ENV !== "production" && console.warn("Button: icon-only buttons must provide ariaLabel."), /* @__PURE__ */ p("button", {
885
+ ref: u,
886
+ type: "button",
887
+ disabled: r,
888
+ onClick: c,
889
+ "aria-label": l || void 0,
890
+ className: M(Z.button, Z[t], Z[n], s, {
891
+ [Z.disabled]: r,
892
+ [Z.fullWidth]: o,
893
+ [Z.iconOnly]: d
894
+ }),
895
+ children: [
896
+ i && /* @__PURE__ */ f("span", {
897
+ className: Z.icon,
898
+ children: i
899
+ }),
900
+ e && /* @__PURE__ */ f("span", {
901
+ className: Z.label,
902
+ children: e
903
+ }),
904
+ a && /* @__PURE__ */ f("span", {
905
+ className: Z.icon,
906
+ children: a
907
+ })
908
+ ]
909
+ });
910
+ });
911
+ Ue.displayName = "Button";
912
+ var Q = {
913
+ wrapper: "_wrapper_36r4m_1",
914
+ input: "_input_36r4m_9",
915
+ customCheckbox: "_customCheckbox_36r4m_21",
916
+ checkmark: "_checkmark_36r4m_38",
917
+ container: "_container_36r4m_54",
918
+ label: "_label_36r4m_60",
919
+ error: "_error_36r4m_65",
920
+ errorText: "_errorText_36r4m_69",
921
+ disabled: "_disabled_36r4m_115"
922
+ }, We = t(({ label: e, checked: t, defaultChecked: n = !1, disabled: r = !1, className: i, onCheckedChange: o, error: s }, c) => {
923
+ let l = a(), u = !!s, [d, m] = T({
924
+ value: t,
925
+ defaultValue: n,
926
+ onChange: o
927
+ });
928
+ return /* @__PURE__ */ p("div", {
929
+ className: Q.container,
930
+ children: [/* @__PURE__ */ p("label", {
931
+ htmlFor: l,
932
+ className: M(Q.wrapper, r && Q.disabled, i),
933
+ children: [
934
+ /* @__PURE__ */ f("input", {
935
+ ref: c,
936
+ id: l,
937
+ type: "checkbox",
938
+ checked: d,
939
+ disabled: r,
940
+ onChange: (e) => {
941
+ m(e.target.checked);
942
+ },
943
+ className: Q.input,
944
+ "aria-invalid": u || void 0,
945
+ "aria-describedby": u ? `${l}-error` : void 0,
946
+ "aria-label": e ? void 0 : "Checkbox"
947
+ }),
948
+ /* @__PURE__ */ f("span", {
949
+ className: M(Q.customCheckbox, u && Q.error),
950
+ "aria-hidden": "true",
951
+ children: d && /* @__PURE__ */ f("span", {
952
+ className: Q.checkmark,
953
+ children: /* @__PURE__ */ f(O, {})
954
+ })
955
+ }),
956
+ e && /* @__PURE__ */ f("span", {
957
+ className: Q.label,
958
+ children: e
959
+ })
960
+ ]
961
+ }), u && /* @__PURE__ */ f("span", {
962
+ id: `${l}-error`,
963
+ className: Q.errorText,
964
+ children: s
965
+ })]
966
+ });
967
+ });
968
+ We.displayName = "Checkbox";
969
+ var $ = {
970
+ inputWrapper: "_inputWrapper_kfk5j_1",
971
+ input: "_input_kfk5j_1",
972
+ error: "_error_kfk5j_36",
973
+ withEllipsis: "_withEllipsis_kfk5j_43",
974
+ sm: "_sm_kfk5j_48",
975
+ md: "_md_kfk5j_52",
976
+ lg: "_lg_kfk5j_56",
977
+ tooltip: "_tooltip_kfk5j_63",
978
+ fadeIn: "_fadeIn_kfk5j_1"
979
+ }, Ge = t(({ id: e, label: t, placeholder: r, value: o, onChange: l, size: u = "md", error: d, disabled: m = !1, required: h = !1, className: g, autoComplete: _, type: v = "text", showOverflowTooltip: y = !1 }, b) => {
980
+ let x = a(), S = e ?? x, C = s(null), [w, T] = c(!1), [E, D] = c(!1), O = o != null && o !== "", k = n(() => {
981
+ let e = C.current;
982
+ if (!e) {
983
+ T(!1);
984
+ return;
985
+ }
986
+ T(e.scrollWidth > e.clientWidth);
987
+ }, []);
988
+ i(() => {
989
+ if (!y) return;
990
+ if (k(), typeof ResizeObserver > "u") return window.addEventListener("resize", k), () => {
991
+ window.removeEventListener("resize", k);
992
+ };
993
+ let e = new ResizeObserver(k);
994
+ return C.current && e.observe(C.current), window.addEventListener("resize", k), () => {
995
+ e.disconnect(), window.removeEventListener("resize", k);
996
+ };
997
+ }, [k, y]), i(() => {
998
+ y && k();
999
+ }, [
1000
+ o,
1001
+ k,
1002
+ y
1003
+ ]);
1004
+ let A = n((e) => {
1005
+ if (C.current = e, typeof b == "function") {
1006
+ b(e);
1007
+ return;
1008
+ }
1009
+ b && (b.current = e);
1010
+ }, [b]), j = n((e) => {
1011
+ l?.(e.target.value);
1012
+ }, [l]), N = n(() => {
1013
+ y && w && O && D(!0);
1014
+ }, [
1015
+ O,
1016
+ w,
1017
+ y
1018
+ ]), P = n(() => {
1019
+ D(!1);
1020
+ }, []);
1021
+ return /* @__PURE__ */ f(G, {
1022
+ id: S,
1023
+ label: t,
1024
+ error: d,
1025
+ required: h,
1026
+ disabled: m,
1027
+ children: /* @__PURE__ */ p("div", {
1028
+ className: $.inputWrapper,
1029
+ children: [/* @__PURE__ */ f("input", {
1030
+ ref: A,
1031
+ id: S,
1032
+ type: v,
1033
+ autoComplete: _,
1034
+ className: M($.input, $[u], {
1035
+ [$.error]: !!d,
1036
+ [$.withEllipsis]: y
1037
+ }, g),
1038
+ value: o,
1039
+ onChange: j,
1040
+ placeholder: r,
1041
+ disabled: m,
1042
+ required: h,
1043
+ "aria-invalid": !!d,
1044
+ "aria-describedby": d ? `${S}-error` : void 0,
1045
+ onMouseEnter: N,
1046
+ onMouseLeave: P
1047
+ }), y && E && w && O && /* @__PURE__ */ f("div", {
1048
+ className: $.tooltip,
1049
+ role: "tooltip",
1050
+ children: o
1051
+ })]
1052
+ })
1053
+ });
1054
+ });
1055
+ Ge.displayName = "Input";
1056
+ //#endregion
1057
+ //#region src/theme/ThemeContext.ts
1058
+ var Ke = e(null), qe = (e) => e === "highContrast" ? "high-contrast" : e, Je = ({ theme: e, defaultTheme: t = "light", onThemeChange: n, children: r }) => {
1059
+ let [a, s] = T({
1060
+ value: e,
1061
+ defaultValue: t,
1062
+ onChange: n
1063
+ }), c = qe(a);
1064
+ i(() => {
1065
+ if (typeof document > "u") return;
1066
+ let { documentElement: e } = document, t = e.dataset.velliraTheme;
1067
+ return e.dataset.velliraTheme = c, () => {
1068
+ if (t === void 0) {
1069
+ delete e.dataset.velliraTheme;
1070
+ return;
1071
+ }
1072
+ e.dataset.velliraTheme = t;
1073
+ };
1074
+ }, [c]);
1075
+ let l = o(() => ({
1076
+ theme: a,
1077
+ setTheme: s
1078
+ }), [a, s]);
1079
+ return /* @__PURE__ */ f(Ke.Provider, {
1080
+ value: l,
1081
+ children: /* @__PURE__ */ f("div", {
1082
+ "data-vellira-theme": c,
1083
+ children: r
1084
+ })
1085
+ });
1086
+ };
1087
+ Je.displayName = "ThemeProvider";
1088
+ //#endregion
1089
+ //#region src/theme/useTheme.ts
1090
+ function Ye() {
1091
+ let e = r(Ke);
1092
+ if (!e) throw Error("useTheme must be used within ThemeProvider.");
1093
+ return e;
1094
+ }
1095
+ //#endregion
1096
+ export { Ue as Button, We as Checkbox, le as Dropdown, G as FormField, Ge as Input, we as Modal, Te as RadioGroup, Ae as Select, ze as Tabs, Je as ThemeProvider, He as Tooltip, Ye as useTheme };