@vesture/react 0.1.0

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,1349 @@
1
+ // src/components/Button/Button.tsx
2
+ import { forwardRef } from "react";
3
+
4
+ // src/components/Button/Button.css.ts
5
+ var button = "Button_button__w1yuq20";
6
+ var variant = { primary: "Button_variant_primary__w1yuq21", secondary: "Button_variant_secondary__w1yuq22", ghost: "Button_variant_ghost__w1yuq23" };
7
+
8
+ // src/components/Button/Button.tsx
9
+ import { jsx } from "react/jsx-runtime";
10
+ var Button = forwardRef(
11
+ function Button2({ variant: variantProp = "primary", className, ...rest }, ref) {
12
+ const classes = [button, variant[variantProp], className].filter(Boolean).join(" ");
13
+ return /* @__PURE__ */ jsx("button", { ref, className: classes, ...rest });
14
+ }
15
+ );
16
+
17
+ // src/components/Label/Label.tsx
18
+ import { forwardRef as forwardRef2 } from "react";
19
+
20
+ // src/components/Label/Label.css.ts
21
+ var label = "Label_label__7kn8v10";
22
+ var requiredMark = "Label_requiredMark__7kn8v11";
23
+
24
+ // src/components/Label/Label.tsx
25
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
26
+ var Label = forwardRef2(function Label2({ required, disabled, className, children, ...rest }, ref) {
27
+ const classes = [label, className].filter(Boolean).join(" ");
28
+ return /* @__PURE__ */ jsxs("label", { ref, className: classes, "data-disabled": disabled || void 0, ...rest, children: [
29
+ children,
30
+ required ? /* @__PURE__ */ jsx2("span", { className: requiredMark, "aria-hidden": "true", children: "*" }) : null
31
+ ] });
32
+ });
33
+
34
+ // src/components/Input/Input.tsx
35
+ import { forwardRef as forwardRef3 } from "react";
36
+
37
+ // src/components/Input/Input.css.ts
38
+ var input = "Input_input__baytuv0";
39
+
40
+ // src/components/Input/Input.tsx
41
+ import { jsx as jsx3 } from "react/jsx-runtime";
42
+ var Input = forwardRef3(function Input2({ invalid, className, ...rest }, ref) {
43
+ const classes = [input, className].filter(Boolean).join(" ");
44
+ return /* @__PURE__ */ jsx3("input", { ref, className: classes, "aria-invalid": invalid || void 0, ...rest });
45
+ });
46
+
47
+ // src/components/Textarea/Textarea.tsx
48
+ import { forwardRef as forwardRef4 } from "react";
49
+
50
+ // src/components/Textarea/Textarea.css.ts
51
+ var textarea = "Textarea_textarea__1ucrsbx0";
52
+
53
+ // src/components/Textarea/Textarea.tsx
54
+ import { jsx as jsx4 } from "react/jsx-runtime";
55
+ var Textarea = forwardRef4(function Textarea2({ invalid, className, ...rest }, ref) {
56
+ const classes = [textarea, className].filter(Boolean).join(" ");
57
+ return /* @__PURE__ */ jsx4("textarea", { ref, className: classes, "aria-invalid": invalid || void 0, ...rest });
58
+ });
59
+
60
+ // src/components/Select/Select.tsx
61
+ import { forwardRef as forwardRef5 } from "react";
62
+
63
+ // src/components/Select/Select.css.ts
64
+ var chevron = "Select_chevron__1ciea9l2";
65
+ var select = "Select_select__1ciea9l1";
66
+ var wrapper = "Select_wrapper__1ciea9l0";
67
+
68
+ // src/components/Select/Select.tsx
69
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
70
+ var Select = forwardRef5(function Select2({ invalid, className, children, ...rest }, ref) {
71
+ const classes = [select, className].filter(Boolean).join(" ");
72
+ return /* @__PURE__ */ jsxs2("span", { className: wrapper, children: [
73
+ /* @__PURE__ */ jsx5("select", { ref, className: classes, "aria-invalid": invalid || void 0, ...rest, children }),
74
+ /* @__PURE__ */ jsx5("span", { className: chevron, "aria-hidden": "true" })
75
+ ] });
76
+ });
77
+
78
+ // src/components/Checkbox/Checkbox.tsx
79
+ import { forwardRef as forwardRef6 } from "react";
80
+
81
+ // src/components/Checkbox/Checkbox.css.ts
82
+ var box = "Checkbox_box__7029a22";
83
+ var hiddenInput = "Checkbox_hiddenInput__7029a21";
84
+ var wrapper2 = "Checkbox_wrapper__7029a20";
85
+
86
+ // src/components/Checkbox/Checkbox.tsx
87
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
88
+ var Checkbox = forwardRef6(function Checkbox2({ label: label3, className, ...rest }, ref) {
89
+ return /* @__PURE__ */ jsxs3("label", { className: [wrapper2, className].filter(Boolean).join(" "), children: [
90
+ /* @__PURE__ */ jsx6("input", { ref, type: "checkbox", className: hiddenInput, ...rest }),
91
+ /* @__PURE__ */ jsx6("span", { className: box, "aria-hidden": "true" }),
92
+ label3
93
+ ] });
94
+ });
95
+
96
+ // src/components/Radio/Radio.tsx
97
+ import { forwardRef as forwardRef7 } from "react";
98
+
99
+ // src/components/Radio/Radio.css.ts
100
+ var circle = "Radio_circle__gzk3vv2";
101
+ var hiddenInput2 = "Radio_hiddenInput__gzk3vv1";
102
+ var wrapper3 = "Radio_wrapper__gzk3vv0";
103
+
104
+ // src/components/Radio/Radio.tsx
105
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
106
+ var Radio = forwardRef7(function Radio2({ label: label3, className, ...rest }, ref) {
107
+ return /* @__PURE__ */ jsxs4("label", { className: [wrapper3, className].filter(Boolean).join(" "), children: [
108
+ /* @__PURE__ */ jsx7("input", { ref, type: "radio", className: hiddenInput2, ...rest }),
109
+ /* @__PURE__ */ jsx7("span", { className: circle, "aria-hidden": "true" }),
110
+ label3
111
+ ] });
112
+ });
113
+
114
+ // src/components/Switch/Switch.tsx
115
+ import { forwardRef as forwardRef8 } from "react";
116
+
117
+ // src/components/Switch/Switch.css.ts
118
+ var hiddenInput3 = "Switch_hiddenInput__1yxysfy1";
119
+ var track = "Switch_track__1yxysfy2";
120
+ var wrapper4 = "Switch_wrapper__1yxysfy0";
121
+
122
+ // src/components/Switch/Switch.tsx
123
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
124
+ var Switch = forwardRef8(function Switch2({ label: label3, className, ...rest }, ref) {
125
+ return /* @__PURE__ */ jsxs5("label", { className: [wrapper4, className].filter(Boolean).join(" "), children: [
126
+ /* @__PURE__ */ jsx8("input", { ref, type: "checkbox", role: "switch", className: hiddenInput3, ...rest }),
127
+ /* @__PURE__ */ jsx8("span", { className: track, "aria-hidden": "true" }),
128
+ label3
129
+ ] });
130
+ });
131
+
132
+ // src/components/Card/Card.tsx
133
+ import { forwardRef as forwardRef9 } from "react";
134
+
135
+ // src/components/Card/Card.css.ts
136
+ var card = "Card_card__mv7u2g0";
137
+ var elevation = { flat: "Card_elevation_flat__mv7u2g1", raised: "Card_elevation_raised__mv7u2g2", overlay: "Card_elevation_overlay__mv7u2g3" };
138
+
139
+ // src/components/Card/Card.tsx
140
+ import { jsx as jsx9 } from "react/jsx-runtime";
141
+ var Card = forwardRef9(function Card2({ elevation: elevationProp = "flat", className, ...rest }, ref) {
142
+ const classes = [card, elevation[elevationProp], className].filter(Boolean).join(" ");
143
+ return /* @__PURE__ */ jsx9("div", { ref, className: classes, ...rest });
144
+ });
145
+
146
+ // src/components/Stack/Stack.tsx
147
+ import { forwardRef as forwardRef10 } from "react";
148
+
149
+ // src/components/Stack/Stack.css.ts
150
+ var align = { start: "Stack_align_start__yit1113", center: "Stack_align_center__yit1114", end: "Stack_align_end__yit1115", stretch: "Stack_align_stretch__yit1116" };
151
+ var direction = { row: "Stack_direction_row__yit1111", column: "Stack_direction_column__yit1112" };
152
+ var gap = { xs: "Stack_gap_xs__yit111b", sm: "Stack_gap_sm__yit111c", md: "Stack_gap_md__yit111d", lg: "Stack_gap_lg__yit111e", xl: "Stack_gap_xl__yit111f", "2xl": "Stack_gap_2xl__yit111g" };
153
+ var justify = { start: "Stack_justify_start__yit1117", center: "Stack_justify_center__yit1118", end: "Stack_justify_end__yit1119", between: "Stack_justify_between__yit111a" };
154
+ var stack = "Stack_stack__yit1110";
155
+ var wrapStyle = "Stack_wrapStyle__yit111h";
156
+
157
+ // src/components/Stack/Stack.tsx
158
+ import { jsx as jsx10 } from "react/jsx-runtime";
159
+ var Stack = forwardRef10(function Stack2({
160
+ direction: directionProp = "column",
161
+ align: alignProp = "stretch",
162
+ justify: justifyProp = "start",
163
+ gap: gapProp = "md",
164
+ wrap = false,
165
+ className,
166
+ ...rest
167
+ }, ref) {
168
+ const classes = [
169
+ stack,
170
+ direction[directionProp],
171
+ align[alignProp],
172
+ justify[justifyProp],
173
+ gap[gapProp],
174
+ wrap ? wrapStyle : null,
175
+ className
176
+ ].filter(Boolean).join(" ");
177
+ return /* @__PURE__ */ jsx10("div", { ref, className: classes, ...rest });
178
+ });
179
+
180
+ // src/components/Divider/Divider.tsx
181
+ import { forwardRef as forwardRef11 } from "react";
182
+
183
+ // src/components/Divider/Divider.css.ts
184
+ var base = "Divider_base__1qjfac50";
185
+ var orientation = { horizontal: "Divider_orientation_horizontal__1qjfac51", vertical: "Divider_orientation_vertical__1qjfac52" };
186
+
187
+ // src/components/Divider/Divider.tsx
188
+ import { jsx as jsx11 } from "react/jsx-runtime";
189
+ var Divider = forwardRef11(function Divider2({ orientation: orientationProp = "horizontal", className, ...rest }, ref) {
190
+ const classes = [base, orientation[orientationProp], className].filter(Boolean).join(" ");
191
+ return /* @__PURE__ */ jsx11(
192
+ "hr",
193
+ {
194
+ ref,
195
+ className: classes,
196
+ "aria-orientation": orientationProp,
197
+ ...rest
198
+ }
199
+ );
200
+ });
201
+
202
+ // src/components/Tooltip/Tooltip.tsx
203
+ import { cloneElement, isValidElement, useRef, useState } from "react";
204
+ import {
205
+ FloatingArrow,
206
+ FloatingPortal,
207
+ arrow,
208
+ autoUpdate,
209
+ flip,
210
+ offset,
211
+ shift,
212
+ useDismiss,
213
+ useFloating,
214
+ useFocus,
215
+ useHover,
216
+ useInteractions,
217
+ useMergeRefs,
218
+ useRole
219
+ } from "@floating-ui/react";
220
+ import { vars } from "@vesture/tokens";
221
+
222
+ // src/components/Tooltip/Tooltip.css.ts
223
+ var tooltip = "Tooltip_tooltip__foawl10";
224
+
225
+ // src/components/Tooltip/Tooltip.tsx
226
+ import { Fragment, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
227
+ function Tooltip({ content, placement = "top", children }) {
228
+ const [open, setOpen] = useState(false);
229
+ const arrowRef = useRef(null);
230
+ const { refs, floatingStyles, context } = useFloating({
231
+ open,
232
+ onOpenChange: setOpen,
233
+ placement,
234
+ whileElementsMounted: autoUpdate,
235
+ middleware: [offset(8), flip(), shift({ padding: 8 }), arrow({ element: arrowRef })]
236
+ });
237
+ const { getReferenceProps, getFloatingProps } = useInteractions([
238
+ useHover(context, { move: false }),
239
+ useFocus(context),
240
+ useRole(context, { role: "tooltip" }),
241
+ useDismiss(context)
242
+ ]);
243
+ const childRef = useMergeRefs([
244
+ refs.setReference,
245
+ children.ref ?? null
246
+ ]);
247
+ if (!isValidElement(children)) {
248
+ return children;
249
+ }
250
+ return /* @__PURE__ */ jsxs6(Fragment, { children: [
251
+ cloneElement(children, getReferenceProps({ ref: childRef, ...children.props })),
252
+ open ? /* @__PURE__ */ jsx12(FloatingPortal, { children: /* @__PURE__ */ jsxs6(
253
+ "div",
254
+ {
255
+ ref: refs.setFloating,
256
+ className: tooltip,
257
+ style: floatingStyles,
258
+ ...getFloatingProps(),
259
+ children: [
260
+ content,
261
+ /* @__PURE__ */ jsx12(FloatingArrow, { ref: arrowRef, context, fill: vars.color.text })
262
+ ]
263
+ }
264
+ ) }) : null
265
+ ] });
266
+ }
267
+
268
+ // src/components/Popover/Popover.tsx
269
+ import { cloneElement as cloneElement2, isValidElement as isValidElement2, useState as useState2 } from "react";
270
+ import {
271
+ FloatingFocusManager,
272
+ FloatingPortal as FloatingPortal2,
273
+ autoUpdate as autoUpdate2,
274
+ flip as flip2,
275
+ offset as offset2,
276
+ shift as shift2,
277
+ useClick,
278
+ useDismiss as useDismiss2,
279
+ useFloating as useFloating2,
280
+ useInteractions as useInteractions2,
281
+ useMergeRefs as useMergeRefs2,
282
+ useRole as useRole2
283
+ } from "@floating-ui/react";
284
+
285
+ // src/components/Popover/Popover.css.ts
286
+ var popover = "Popover_popover__ke5el70";
287
+
288
+ // src/components/Popover/Popover.tsx
289
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
290
+ function Popover({
291
+ content,
292
+ placement = "bottom-start",
293
+ open: controlledOpen,
294
+ onOpenChange,
295
+ children
296
+ }) {
297
+ const [uncontrolledOpen, setUncontrolledOpen] = useState2(false);
298
+ const open = controlledOpen ?? uncontrolledOpen;
299
+ const setOpen = onOpenChange ?? setUncontrolledOpen;
300
+ const { refs, floatingStyles, context } = useFloating2({
301
+ open,
302
+ onOpenChange: setOpen,
303
+ placement,
304
+ whileElementsMounted: autoUpdate2,
305
+ middleware: [offset2(8), flip2(), shift2({ padding: 8 })]
306
+ });
307
+ const { getReferenceProps, getFloatingProps } = useInteractions2([
308
+ useClick(context),
309
+ useDismiss2(context),
310
+ useRole2(context, { role: "dialog" })
311
+ ]);
312
+ const childRef = useMergeRefs2([
313
+ refs.setReference,
314
+ children.ref ?? null
315
+ ]);
316
+ if (!isValidElement2(children)) {
317
+ return children;
318
+ }
319
+ return /* @__PURE__ */ jsxs7(Fragment2, { children: [
320
+ cloneElement2(children, getReferenceProps({ ref: childRef, ...children.props })),
321
+ open ? /* @__PURE__ */ jsx13(FloatingPortal2, { children: /* @__PURE__ */ jsx13(FloatingFocusManager, { context, modal: false, children: /* @__PURE__ */ jsx13("div", { ref: refs.setFloating, className: popover, style: floatingStyles, ...getFloatingProps(), children: content }) }) }) : null
322
+ ] });
323
+ }
324
+
325
+ // src/components/Modal/Modal.tsx
326
+ import { useId } from "react";
327
+ import {
328
+ FloatingFocusManager as FloatingFocusManager2,
329
+ FloatingOverlay,
330
+ FloatingPortal as FloatingPortal3,
331
+ useDismiss as useDismiss3,
332
+ useFloating as useFloating3,
333
+ useInteractions as useInteractions3,
334
+ useRole as useRole3
335
+ } from "@floating-ui/react";
336
+
337
+ // src/components/Modal/Modal.css.ts
338
+ var closeButton = "Modal_closeButton__1eq75ae3";
339
+ var heading = "Modal_heading__1eq75ae2";
340
+ var modal = "Modal_modal__1eq75ae1";
341
+ var overlay = "Modal_overlay__1eq75ae0";
342
+
343
+ // src/components/Modal/Modal.tsx
344
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
345
+ function Modal({ open, onOpenChange, title: title3, children }) {
346
+ const { refs, context } = useFloating3({ open, onOpenChange });
347
+ const { getFloatingProps } = useInteractions3([useDismiss3(context), useRole3(context)]);
348
+ const titleId = useId();
349
+ if (!open) {
350
+ return null;
351
+ }
352
+ return /* @__PURE__ */ jsx14(FloatingPortal3, { children: /* @__PURE__ */ jsx14(FloatingOverlay, { className: overlay, lockScroll: true, children: /* @__PURE__ */ jsx14(FloatingFocusManager2, { context, children: /* @__PURE__ */ jsxs8(
353
+ "div",
354
+ {
355
+ ref: refs.setFloating,
356
+ className: modal,
357
+ "aria-labelledby": title3 ? titleId : void 0,
358
+ ...getFloatingProps(),
359
+ children: [
360
+ /* @__PURE__ */ jsx14(
361
+ "button",
362
+ {
363
+ type: "button",
364
+ className: closeButton,
365
+ "aria-label": "Close",
366
+ onClick: () => onOpenChange(false),
367
+ children: "\u2715"
368
+ }
369
+ ),
370
+ title3 ? /* @__PURE__ */ jsx14("h2", { id: titleId, className: heading, children: title3 }) : null,
371
+ children
372
+ ]
373
+ }
374
+ ) }) }) });
375
+ }
376
+
377
+ // src/components/Toast/ToastProvider.tsx
378
+ import { createContext, useCallback, useMemo, useState as useState3 } from "react";
379
+ import { createPortal } from "react-dom";
380
+
381
+ // src/components/Toast/Toast.css.ts
382
+ var accent = { "default": "Toast_accent_default__xnm1xa2", success: "Toast_accent_success__xnm1xa3", warning: "Toast_accent_warning__xnm1xa4", danger: "Toast_accent_danger__xnm1xa5" };
383
+ var body = "Toast_body__xnm1xa8";
384
+ var closeButton2 = "Toast_closeButton__xnm1xa9";
385
+ var description = "Toast_description__xnm1xa7";
386
+ var title = "Toast_title__xnm1xa6";
387
+ var toast = "Toast_toast__xnm1xa1";
388
+ var viewport = "Toast_viewport__xnm1xa0";
389
+
390
+ // src/components/Toast/ToastProvider.tsx
391
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
392
+ var ToastContext = createContext(null);
393
+ var DEFAULT_DURATION = 5e3;
394
+ function ToastProvider({ children }) {
395
+ const [toasts, setToasts] = useState3([]);
396
+ const dismiss = useCallback((id) => {
397
+ setToasts((current2) => current2.filter((item4) => item4.id !== id));
398
+ }, []);
399
+ const pushToast = useCallback(
400
+ (options) => {
401
+ const id = Date.now() + Math.random();
402
+ setToasts((current2) => [...current2, { id, ...options }]);
403
+ const duration = options.duration ?? DEFAULT_DURATION;
404
+ if (duration > 0) {
405
+ setTimeout(() => dismiss(id), duration);
406
+ }
407
+ return id;
408
+ },
409
+ [dismiss]
410
+ );
411
+ const value = useMemo(() => ({ toast: pushToast, dismiss }), [pushToast, dismiss]);
412
+ return /* @__PURE__ */ jsxs9(ToastContext.Provider, { value, children: [
413
+ children,
414
+ createPortal(
415
+ /* @__PURE__ */ jsx15("div", { className: viewport, role: "region", "aria-label": "Notifications", children: toasts.map((item4) => /* @__PURE__ */ jsxs9("div", { className: `${toast} ${accent[item4.variant ?? "default"]}`, role: "status", children: [
416
+ /* @__PURE__ */ jsxs9("div", { className: body, children: [
417
+ /* @__PURE__ */ jsx15("p", { className: title, children: item4.title }),
418
+ item4.description ? /* @__PURE__ */ jsx15("p", { className: description, children: item4.description }) : null
419
+ ] }),
420
+ /* @__PURE__ */ jsx15(
421
+ "button",
422
+ {
423
+ type: "button",
424
+ className: closeButton2,
425
+ "aria-label": "Dismiss",
426
+ onClick: () => dismiss(item4.id),
427
+ children: "\u2715"
428
+ }
429
+ )
430
+ ] }, item4.id)) }),
431
+ document.body
432
+ )
433
+ ] });
434
+ }
435
+
436
+ // src/components/Toast/useToast.ts
437
+ import { useContext } from "react";
438
+ function useToast() {
439
+ const context = useContext(ToastContext);
440
+ if (!context) {
441
+ throw new Error("useToast must be used within a ToastProvider");
442
+ }
443
+ return context;
444
+ }
445
+
446
+ // src/components/DropdownMenu/DropdownMenu.tsx
447
+ import { cloneElement as cloneElement3, isValidElement as isValidElement3, useRef as useRef2, useState as useState4 } from "react";
448
+ import {
449
+ FloatingFocusManager as FloatingFocusManager3,
450
+ FloatingPortal as FloatingPortal4,
451
+ autoUpdate as autoUpdate3,
452
+ flip as flip3,
453
+ offset as offset3,
454
+ shift as shift3,
455
+ useClick as useClick2,
456
+ useDismiss as useDismiss4,
457
+ useFloating as useFloating4,
458
+ useInteractions as useInteractions4,
459
+ useListNavigation,
460
+ useMergeRefs as useMergeRefs3,
461
+ useRole as useRole4
462
+ } from "@floating-ui/react";
463
+
464
+ // src/components/DropdownMenu/DropdownMenu.css.ts
465
+ var item = "DropdownMenu_item__1lgad5x1";
466
+ var menu = "DropdownMenu_menu__1lgad5x0";
467
+
468
+ // src/components/DropdownMenu/MenuContext.ts
469
+ import { createContext as createContext2, useContext as useContext2 } from "react";
470
+ var MenuContext = createContext2(null);
471
+ function useMenuContext() {
472
+ const context = useContext2(MenuContext);
473
+ if (!context) {
474
+ throw new Error("DropdownMenu.Item must be used within a DropdownMenu");
475
+ }
476
+ return context;
477
+ }
478
+
479
+ // src/components/DropdownMenu/DropdownMenu.tsx
480
+ import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
481
+ function DropdownMenu({
482
+ trigger: trigger3,
483
+ placement = "bottom-start",
484
+ children
485
+ }) {
486
+ const [open, setOpen] = useState4(false);
487
+ const [activeIndex, setActiveIndex] = useState4(null);
488
+ const elementsRef = useRef2([]);
489
+ const { refs, floatingStyles, context } = useFloating4({
490
+ open,
491
+ onOpenChange: setOpen,
492
+ placement,
493
+ whileElementsMounted: autoUpdate3,
494
+ middleware: [offset3(4), flip3(), shift3({ padding: 8 })]
495
+ });
496
+ const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions4([
497
+ useClick2(context),
498
+ useDismiss4(context),
499
+ useRole4(context, { role: "menu" }),
500
+ useListNavigation(context, {
501
+ listRef: elementsRef,
502
+ activeIndex,
503
+ onNavigate: setActiveIndex,
504
+ loop: true
505
+ })
506
+ ]);
507
+ const closeMenu = () => setOpen(false);
508
+ const triggerRef = useMergeRefs3([
509
+ refs.setReference,
510
+ trigger3.ref ?? null
511
+ ]);
512
+ return /* @__PURE__ */ jsxs10(Fragment3, { children: [
513
+ cloneElement3(trigger3, getReferenceProps({ ref: triggerRef, ...trigger3.props })),
514
+ open ? /* @__PURE__ */ jsx16(FloatingPortal4, { children: /* @__PURE__ */ jsx16(FloatingFocusManager3, { context, modal: false, children: /* @__PURE__ */ jsx16("div", { ref: refs.setFloating, className: menu, style: floatingStyles, ...getFloatingProps(), children: /* @__PURE__ */ jsx16(MenuContext.Provider, { value: { activeIndex, getItemProps, closeMenu }, children: (children ? Array.isArray(children) ? children : [children] : []).map(
515
+ (child, index) => isValidElement3(child) ? cloneElement3(
516
+ child,
517
+ { key: index, index, elementsRef }
518
+ ) : child
519
+ ) }) }) }) }) : null
520
+ ] });
521
+ }
522
+
523
+ // src/components/DropdownMenu/DropdownMenuItem.tsx
524
+ import { useMergeRefs as useMergeRefs4 } from "@floating-ui/react";
525
+ import { jsx as jsx17 } from "react/jsx-runtime";
526
+ function DropdownMenuItem({
527
+ onSelect,
528
+ disabled,
529
+ className,
530
+ index,
531
+ elementsRef,
532
+ ...rest
533
+ }) {
534
+ const { activeIndex, getItemProps, closeMenu } = useMenuContext();
535
+ const isActive = activeIndex === index;
536
+ const itemRef = useMergeRefs4([
537
+ (node) => {
538
+ if (elementsRef && typeof index === "number") {
539
+ elementsRef.current[index] = node;
540
+ }
541
+ }
542
+ ]);
543
+ return /* @__PURE__ */ jsx17(
544
+ "button",
545
+ {
546
+ ref: itemRef,
547
+ type: "button",
548
+ role: "menuitem",
549
+ disabled,
550
+ "data-active": isActive || void 0,
551
+ className: [item, className].filter(Boolean).join(" "),
552
+ tabIndex: isActive ? 0 : -1,
553
+ ...getItemProps({
554
+ onClick: () => {
555
+ onSelect?.();
556
+ closeMenu();
557
+ },
558
+ ...rest
559
+ })
560
+ }
561
+ );
562
+ }
563
+
564
+ // src/components/DropdownMenu/index.ts
565
+ var DropdownMenu2 = Object.assign(DropdownMenu, { Item: DropdownMenuItem });
566
+
567
+ // src/components/Breadcrumbs/Breadcrumbs.tsx
568
+ import { Children, Fragment as Fragment4, cloneElement as cloneElement4, isValidElement as isValidElement4 } from "react";
569
+
570
+ // src/components/Breadcrumbs/Breadcrumbs.css.ts
571
+ var current = "Breadcrumbs_current__rl5imx3";
572
+ var item2 = "Breadcrumbs_item__rl5imx1";
573
+ var link = "Breadcrumbs_link__rl5imx2";
574
+ var list = "Breadcrumbs_list__rl5imx0";
575
+ var separator = "Breadcrumbs_separator__rl5imx4";
576
+
577
+ // src/components/Breadcrumbs/Breadcrumbs.tsx
578
+ import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
579
+ function Breadcrumbs({
580
+ separator: separatorNode = "/",
581
+ children,
582
+ ...rest
583
+ }) {
584
+ const items = Children.toArray(children).filter(isValidElement4);
585
+ return /* @__PURE__ */ jsx18("nav", { "aria-label": "Breadcrumb", ...rest, children: /* @__PURE__ */ jsx18("ol", { className: list, children: items.map((child, index) => /* @__PURE__ */ jsxs11(Fragment4, { children: [
586
+ cloneElement4(child, {
587
+ isLast: index === items.length - 1
588
+ }),
589
+ index < items.length - 1 ? /* @__PURE__ */ jsx18("li", { className: separator, "aria-hidden": "true", children: separatorNode }) : null
590
+ ] }, index)) }) });
591
+ }
592
+
593
+ // src/components/Breadcrumbs/BreadcrumbsItem.tsx
594
+ import { jsx as jsx19 } from "react/jsx-runtime";
595
+ function BreadcrumbsItem({
596
+ href,
597
+ children,
598
+ isLast,
599
+ className,
600
+ ...rest
601
+ }) {
602
+ return /* @__PURE__ */ jsx19("li", { className: item2, children: isLast || !href ? /* @__PURE__ */ jsx19("span", { className: [current, className].filter(Boolean).join(" "), "aria-current": isLast ? "page" : void 0, children }) : /* @__PURE__ */ jsx19("a", { href, className: [link, className].filter(Boolean).join(" "), ...rest, children }) });
603
+ }
604
+
605
+ // src/components/Breadcrumbs/index.ts
606
+ var Breadcrumbs2 = Object.assign(Breadcrumbs, { Item: BreadcrumbsItem });
607
+
608
+ // src/components/Pagination/getPageRange.ts
609
+ function range(start, end) {
610
+ const output = [];
611
+ for (let i = start; i <= end; i++) {
612
+ output.push(i);
613
+ }
614
+ return output;
615
+ }
616
+ function getPageRange(page, totalPages, siblingCount = 1) {
617
+ const totalPageNumbers = siblingCount * 2 + 5;
618
+ if (totalPageNumbers >= totalPages) {
619
+ return range(1, totalPages);
620
+ }
621
+ const leftSiblingIndex = Math.max(page - siblingCount, 1);
622
+ const rightSiblingIndex = Math.min(page + siblingCount, totalPages);
623
+ const shouldShowLeftEllipsis = leftSiblingIndex > 2;
624
+ const shouldShowRightEllipsis = rightSiblingIndex < totalPages - 1;
625
+ if (!shouldShowLeftEllipsis && shouldShowRightEllipsis) {
626
+ const leftItemCount = 3 + siblingCount * 2;
627
+ return [...range(1, leftItemCount), "ellipsis", totalPages];
628
+ }
629
+ if (shouldShowLeftEllipsis && !shouldShowRightEllipsis) {
630
+ const rightItemCount = 3 + siblingCount * 2;
631
+ return [1, "ellipsis", ...range(totalPages - rightItemCount + 1, totalPages)];
632
+ }
633
+ return [1, "ellipsis", ...range(leftSiblingIndex, rightSiblingIndex), "ellipsis", totalPages];
634
+ }
635
+
636
+ // src/components/Pagination/Pagination.css.ts
637
+ var ellipsis = "Pagination_ellipsis__gcyf9m2";
638
+ var list2 = "Pagination_list__gcyf9m0";
639
+ var pageButton = "Pagination_pageButton__gcyf9m1";
640
+
641
+ // src/components/Pagination/Pagination.tsx
642
+ import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
643
+ function Pagination({
644
+ page,
645
+ totalPages,
646
+ onPageChange,
647
+ siblingCount = 1
648
+ }) {
649
+ const items = getPageRange(page, totalPages, siblingCount);
650
+ return /* @__PURE__ */ jsx20("nav", { "aria-label": "Pagination", children: /* @__PURE__ */ jsxs12("ul", { className: list2, children: [
651
+ /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(
652
+ "button",
653
+ {
654
+ type: "button",
655
+ className: pageButton,
656
+ onClick: () => onPageChange(page - 1),
657
+ disabled: page <= 1,
658
+ "aria-label": "Previous page",
659
+ children: "\u2039"
660
+ }
661
+ ) }),
662
+ items.map(
663
+ (item4, index) => item4 === "ellipsis" ? /* @__PURE__ */ jsx20("li", { className: ellipsis, "aria-hidden": "true", children: "\u2026" }, `ellipsis-${index}`) : /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(
664
+ "button",
665
+ {
666
+ type: "button",
667
+ className: pageButton,
668
+ onClick: () => onPageChange(item4),
669
+ "aria-current": item4 === page ? "page" : void 0,
670
+ "aria-label": `Page ${item4}`,
671
+ children: item4
672
+ }
673
+ ) }, item4)
674
+ ),
675
+ /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(
676
+ "button",
677
+ {
678
+ type: "button",
679
+ className: pageButton,
680
+ onClick: () => onPageChange(page + 1),
681
+ disabled: page >= totalPages,
682
+ "aria-label": "Next page",
683
+ children: "\u203A"
684
+ }
685
+ ) })
686
+ ] }) });
687
+ }
688
+
689
+ // src/components/Accordion/Accordion.tsx
690
+ import { useState as useState5 } from "react";
691
+
692
+ // src/components/Accordion/Accordion.css.ts
693
+ var contentBody = "Accordion_contentBody__1pfgqc46";
694
+ var contentInner = "Accordion_contentInner__1pfgqc45";
695
+ var contentWrapper = "Accordion_contentWrapper__1pfgqc44";
696
+ var icon = "Accordion_icon__1pfgqc43";
697
+ var item3 = "Accordion_item__1pfgqc41";
698
+ var root = "Accordion_root__1pfgqc40";
699
+ var trigger = "Accordion_trigger__1pfgqc42";
700
+
701
+ // src/components/Accordion/AccordionContext.ts
702
+ import { createContext as createContext3, useContext as useContext3 } from "react";
703
+ var AccordionContext = createContext3(null);
704
+ function useAccordionContext() {
705
+ const context = useContext3(AccordionContext);
706
+ if (!context) {
707
+ throw new Error("Accordion.Item must be used within an Accordion");
708
+ }
709
+ return context;
710
+ }
711
+ var AccordionItemContext = createContext3(null);
712
+ function useAccordionItemContext() {
713
+ const context = useContext3(AccordionItemContext);
714
+ if (context === null) {
715
+ throw new Error("Accordion.Trigger and Accordion.Content must be used within an Accordion.Item");
716
+ }
717
+ return context;
718
+ }
719
+
720
+ // src/components/Accordion/Accordion.tsx
721
+ import { jsx as jsx21 } from "react/jsx-runtime";
722
+ function Accordion(props) {
723
+ const { type, children, value, defaultValue, onValueChange, className, ...rest } = props;
724
+ const isControlled = value !== void 0;
725
+ const [internalValues, setInternalValues] = useState5(() => {
726
+ if (type === "single") {
727
+ return props.defaultValue ? [props.defaultValue] : [];
728
+ }
729
+ return props.defaultValue ?? [];
730
+ });
731
+ const currentValues = isControlled ? type === "single" ? props.value ? [props.value] : [] : props.value ?? [] : internalValues;
732
+ const toggle = (itemValue) => {
733
+ const next = type === "single" ? currentValues.includes(itemValue) ? [] : [itemValue] : currentValues.includes(itemValue) ? currentValues.filter((v) => v !== itemValue) : [...currentValues, itemValue];
734
+ if (!isControlled) {
735
+ setInternalValues(next);
736
+ }
737
+ if (type === "single") {
738
+ props.onValueChange?.(next[0] ?? null);
739
+ } else {
740
+ props.onValueChange?.(next);
741
+ }
742
+ };
743
+ const isOpen = (itemValue) => currentValues.includes(itemValue);
744
+ return /* @__PURE__ */ jsx21("div", { className: [root, className].filter(Boolean).join(" "), ...rest, children: /* @__PURE__ */ jsx21(AccordionContext.Provider, { value: { isOpen, toggle }, children }) });
745
+ }
746
+
747
+ // src/components/Accordion/AccordionContent.tsx
748
+ import { jsx as jsx22 } from "react/jsx-runtime";
749
+ function AccordionContent({ children, className, ...rest }) {
750
+ const { isOpen } = useAccordionContext();
751
+ const value = useAccordionItemContext();
752
+ const open = isOpen(value);
753
+ return /* @__PURE__ */ jsx22(
754
+ "div",
755
+ {
756
+ id: `accordion-panel-${value}`,
757
+ role: "region",
758
+ "aria-labelledby": `accordion-trigger-${value}`,
759
+ className: [contentWrapper, className].filter(Boolean).join(" "),
760
+ "data-open": open,
761
+ ...rest,
762
+ children: /* @__PURE__ */ jsx22("div", { className: contentInner, children: /* @__PURE__ */ jsx22("div", { className: contentBody, children }) })
763
+ }
764
+ );
765
+ }
766
+
767
+ // src/components/Accordion/AccordionItem.tsx
768
+ import { jsx as jsx23 } from "react/jsx-runtime";
769
+ function AccordionItem({ value, children }) {
770
+ return /* @__PURE__ */ jsx23("div", { className: item3, children: /* @__PURE__ */ jsx23(AccordionItemContext.Provider, { value, children }) });
771
+ }
772
+
773
+ // src/components/Accordion/AccordionTrigger.tsx
774
+ import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
775
+ function AccordionTrigger({ children, className, ...rest }) {
776
+ const { isOpen, toggle } = useAccordionContext();
777
+ const value = useAccordionItemContext();
778
+ const open = isOpen(value);
779
+ return /* @__PURE__ */ jsx24("h3", { style: { margin: 0 }, children: /* @__PURE__ */ jsxs13(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ id: `accordion-trigger-${value}`,
784
+ className: [trigger, className].filter(Boolean).join(" "),
785
+ "aria-expanded": open,
786
+ "aria-controls": `accordion-panel-${value}`,
787
+ "data-open": open,
788
+ onClick: () => toggle(value),
789
+ ...rest,
790
+ children: [
791
+ children,
792
+ /* @__PURE__ */ jsx24("span", { className: icon, "aria-hidden": "true", children: "\u25BE" })
793
+ ]
794
+ }
795
+ ) });
796
+ }
797
+
798
+ // src/components/Accordion/index.ts
799
+ var Accordion2 = Object.assign(Accordion, {
800
+ Item: AccordionItem,
801
+ Trigger: AccordionTrigger,
802
+ Content: AccordionContent
803
+ });
804
+
805
+ // src/components/Tabs/Tabs.tsx
806
+ import { useState as useState6 } from "react";
807
+
808
+ // src/components/Tabs/TabsContext.ts
809
+ import { createContext as createContext4, useContext as useContext4 } from "react";
810
+ var TabsContext = createContext4(null);
811
+ function useTabsContext() {
812
+ const context = useContext4(TabsContext);
813
+ if (!context) {
814
+ throw new Error("Tabs.List, Tabs.Trigger, and Tabs.Panel must be used within a Tabs component");
815
+ }
816
+ return context;
817
+ }
818
+
819
+ // src/components/Tabs/Tabs.tsx
820
+ import { jsx as jsx25 } from "react/jsx-runtime";
821
+ function Tabs({
822
+ defaultValue,
823
+ value: controlledValue,
824
+ onValueChange,
825
+ children,
826
+ ...rest
827
+ }) {
828
+ const [internalValue, setInternalValue] = useState6(defaultValue ?? "");
829
+ const isControlled = controlledValue !== void 0;
830
+ const value = isControlled ? controlledValue : internalValue;
831
+ const setValue = (next) => {
832
+ if (!isControlled) {
833
+ setInternalValue(next);
834
+ }
835
+ onValueChange?.(next);
836
+ };
837
+ return /* @__PURE__ */ jsx25("div", { ...rest, children: /* @__PURE__ */ jsx25(TabsContext.Provider, { value: { value, setValue }, children }) });
838
+ }
839
+
840
+ // src/components/Tabs/Tabs.css.ts
841
+ var list3 = "Tabs_list__1kvbucq0";
842
+ var panel = "Tabs_panel__1kvbucq2";
843
+ var trigger2 = "Tabs_trigger__1kvbucq1";
844
+
845
+ // src/components/Tabs/TabsList.tsx
846
+ import { jsx as jsx26 } from "react/jsx-runtime";
847
+ function TabsList({ children, className, onKeyDown, ...rest }) {
848
+ const handleKeyDown = (event) => {
849
+ onKeyDown?.(event);
850
+ if (event.defaultPrevented) {
851
+ return;
852
+ }
853
+ const tabs = Array.from(event.currentTarget.querySelectorAll('[role="tab"]'));
854
+ if (tabs.length === 0) {
855
+ return;
856
+ }
857
+ const currentIndex = tabs.indexOf(document.activeElement);
858
+ let nextIndex = null;
859
+ if (event.key === "ArrowRight" || event.key === "ArrowDown") {
860
+ nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % tabs.length;
861
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
862
+ nextIndex = currentIndex < 0 ? tabs.length - 1 : (currentIndex - 1 + tabs.length) % tabs.length;
863
+ } else if (event.key === "Home") {
864
+ nextIndex = 0;
865
+ } else if (event.key === "End") {
866
+ nextIndex = tabs.length - 1;
867
+ }
868
+ if (nextIndex !== null) {
869
+ event.preventDefault();
870
+ tabs[nextIndex]?.focus();
871
+ tabs[nextIndex]?.click();
872
+ }
873
+ };
874
+ return /* @__PURE__ */ jsx26("div", { role: "tablist", className: [list3, className].filter(Boolean).join(" "), onKeyDown: handleKeyDown, ...rest, children });
875
+ }
876
+
877
+ // src/components/Tabs/TabsPanel.tsx
878
+ import { jsx as jsx27 } from "react/jsx-runtime";
879
+ function TabsPanel({ value, children, className, ...rest }) {
880
+ const { value: selected } = useTabsContext();
881
+ if (selected !== value) {
882
+ return null;
883
+ }
884
+ return /* @__PURE__ */ jsx27(
885
+ "div",
886
+ {
887
+ role: "tabpanel",
888
+ id: `panel-${value}`,
889
+ "aria-labelledby": `tab-${value}`,
890
+ tabIndex: 0,
891
+ className: [panel, className].filter(Boolean).join(" "),
892
+ ...rest,
893
+ children
894
+ }
895
+ );
896
+ }
897
+
898
+ // src/components/Tabs/TabsTrigger.tsx
899
+ import { jsx as jsx28 } from "react/jsx-runtime";
900
+ function TabsTrigger({ value, children, className, onClick, ...rest }) {
901
+ const { value: selected, setValue } = useTabsContext();
902
+ const isSelected = selected === value;
903
+ return /* @__PURE__ */ jsx28(
904
+ "button",
905
+ {
906
+ type: "button",
907
+ role: "tab",
908
+ id: `tab-${value}`,
909
+ "aria-selected": isSelected,
910
+ "aria-controls": `panel-${value}`,
911
+ tabIndex: isSelected ? 0 : -1,
912
+ className: [trigger2, className].filter(Boolean).join(" "),
913
+ onClick: (event) => {
914
+ setValue(value);
915
+ onClick?.(event);
916
+ },
917
+ ...rest,
918
+ children
919
+ }
920
+ );
921
+ }
922
+
923
+ // src/components/Tabs/index.ts
924
+ var Tabs2 = Object.assign(Tabs, {
925
+ List: TabsList,
926
+ Trigger: TabsTrigger,
927
+ Panel: TabsPanel
928
+ });
929
+
930
+ // src/components/Badge/Badge.tsx
931
+ import { forwardRef as forwardRef12 } from "react";
932
+
933
+ // src/components/Badge/Badge.css.ts
934
+ var badge = "Badge_badge__1mp11oz0";
935
+ var variant2 = { "default": "Badge_variant_default__1mp11oz1", primary: "Badge_variant_primary__1mp11oz2", success: "Badge_variant_success__1mp11oz3", warning: "Badge_variant_warning__1mp11oz4", danger: "Badge_variant_danger__1mp11oz5" };
936
+
937
+ // src/components/Badge/Badge.tsx
938
+ import { jsx as jsx29 } from "react/jsx-runtime";
939
+ var Badge = forwardRef12(function Badge2({ variant: variantProp = "default", className, ...rest }, ref) {
940
+ const classes = [badge, variant2[variantProp], className].filter(Boolean).join(" ");
941
+ return /* @__PURE__ */ jsx29("span", { ref, className: classes, ...rest });
942
+ });
943
+
944
+ // src/components/Avatar/Avatar.tsx
945
+ import { forwardRef as forwardRef13, useState as useState7 } from "react";
946
+
947
+ // src/components/Avatar/Avatar.css.ts
948
+ var avatar = "Avatar_avatar__g25zgb1";
949
+ var image = "Avatar_image__g25zgb5";
950
+ var size = { sm: "Avatar_size_sm__g25zgb2", md: "Avatar_size_md__g25zgb3", lg: "Avatar_size_lg__g25zgb4" };
951
+ var statusColor = { online: "Avatar_statusColor_online__g25zgb7", away: "Avatar_statusColor_away__g25zgb8", busy: "Avatar_statusColor_busy__g25zgb9", offline: "Avatar_statusColor_offline__g25zgba" };
952
+ var statusDot = "Avatar_statusDot__g25zgb6";
953
+ var wrapper5 = "Avatar_wrapper__g25zgb0";
954
+
955
+ // src/components/Avatar/Avatar.tsx
956
+ import { jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
957
+ function getInitials(name) {
958
+ const parts = name.trim().split(/\s+/);
959
+ const first = parts[0]?.[0] ?? "";
960
+ const last = parts.length > 1 ? parts[parts.length - 1]?.[0] ?? "" : "";
961
+ return (first + last).toUpperCase();
962
+ }
963
+ var Avatar = forwardRef13(function Avatar2({ src, name, size: sizeProp = "md", status, className, ...rest }, ref) {
964
+ const [imageFailed, setImageFailed] = useState7(false);
965
+ const showImage = src && !imageFailed;
966
+ return /* @__PURE__ */ jsxs14("div", { ref, className: [wrapper5, className].filter(Boolean).join(" "), ...rest, children: [
967
+ /* @__PURE__ */ jsx30("div", { className: [avatar, size[sizeProp]].join(" "), children: showImage ? /* @__PURE__ */ jsx30(
968
+ "img",
969
+ {
970
+ src,
971
+ alt: name ?? "",
972
+ className: image,
973
+ onError: () => setImageFailed(true)
974
+ }
975
+ ) : name ? /* @__PURE__ */ jsx30("span", { "aria-hidden": "true", children: getInitials(name) }) : null }),
976
+ status ? /* @__PURE__ */ jsx30(
977
+ "span",
978
+ {
979
+ className: [statusDot, statusColor[status]].join(" "),
980
+ role: "status",
981
+ "aria-label": status
982
+ }
983
+ ) : null
984
+ ] });
985
+ });
986
+
987
+ // src/components/Progress/Progress.css.ts
988
+ var fill = "Progress_fill__160p4ke1";
989
+ var indeterminateFill = "Progress_indeterminateFill__160p4ke3";
990
+ var label2 = "Progress_label__160p4ke4";
991
+ var track2 = "Progress_track__160p4ke0";
992
+
993
+ // src/components/Progress/Progress.tsx
994
+ import { jsx as jsx31, jsxs as jsxs15 } from "react/jsx-runtime";
995
+ function Progress({ value, max = 100, label: labelText, className, ...rest }) {
996
+ const isIndeterminate = value === void 0;
997
+ const percentage = isIndeterminate ? void 0 : Math.min(100, Math.max(0, value / max * 100));
998
+ return /* @__PURE__ */ jsxs15("div", { className, ...rest, children: [
999
+ labelText || !isIndeterminate ? /* @__PURE__ */ jsxs15("div", { className: label2, children: [
1000
+ /* @__PURE__ */ jsx31("span", { children: labelText }),
1001
+ !isIndeterminate ? /* @__PURE__ */ jsxs15("span", { children: [
1002
+ Math.round(percentage),
1003
+ "%"
1004
+ ] }) : null
1005
+ ] }) : null,
1006
+ /* @__PURE__ */ jsx31(
1007
+ "div",
1008
+ {
1009
+ className: track2,
1010
+ role: "progressbar",
1011
+ "aria-valuemin": 0,
1012
+ "aria-valuemax": max,
1013
+ "aria-valuenow": isIndeterminate ? void 0 : value,
1014
+ "aria-label": labelText,
1015
+ children: isIndeterminate ? /* @__PURE__ */ jsx31("div", { className: indeterminateFill }) : /* @__PURE__ */ jsx31("div", { className: fill, style: { width: `${percentage}%` } })
1016
+ }
1017
+ )
1018
+ ] });
1019
+ }
1020
+
1021
+ // src/components/Spinner/Spinner.css.ts
1022
+ var size2 = { sm: "Spinner_size_sm__1hs5uji2", md: "Spinner_size_md__1hs5uji3", lg: "Spinner_size_lg__1hs5uji4" };
1023
+ var spinner = "Spinner_spinner__1hs5uji1";
1024
+ var srOnly = "Spinner_srOnly__1hs5uji5";
1025
+
1026
+ // src/components/Spinner/Spinner.tsx
1027
+ import { jsx as jsx32 } from "react/jsx-runtime";
1028
+ function Spinner({
1029
+ size: sizeProp = "md",
1030
+ label: label3 = "Loading",
1031
+ className,
1032
+ ...rest
1033
+ }) {
1034
+ return /* @__PURE__ */ jsx32(
1035
+ "div",
1036
+ {
1037
+ role: "status",
1038
+ "aria-label": label3,
1039
+ className: [spinner, size2[sizeProp], className].filter(Boolean).join(" "),
1040
+ ...rest,
1041
+ children: /* @__PURE__ */ jsx32("span", { className: srOnly, children: label3 })
1042
+ }
1043
+ );
1044
+ }
1045
+
1046
+ // src/components/Alert/Alert.css.ts
1047
+ var accent2 = { info: "Alert_accent_info__1t3yeql1", success: "Alert_accent_success__1t3yeql2", warning: "Alert_accent_warning__1t3yeql3", danger: "Alert_accent_danger__1t3yeql4" };
1048
+ var alert = "Alert_alert__1t3yeql0";
1049
+ var body2 = "Alert_body__1t3yeql5";
1050
+ var closeButton3 = "Alert_closeButton__1t3yeql8";
1051
+ var description2 = "Alert_description__1t3yeql7";
1052
+ var title2 = "Alert_title__1t3yeql6";
1053
+
1054
+ // src/components/Alert/Alert.tsx
1055
+ import { jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
1056
+ function Alert({
1057
+ variant: variant3 = "info",
1058
+ title: titleText,
1059
+ onDismiss,
1060
+ children,
1061
+ className,
1062
+ ...rest
1063
+ }) {
1064
+ return /* @__PURE__ */ jsxs16(
1065
+ "div",
1066
+ {
1067
+ role: "alert",
1068
+ className: [alert, accent2[variant3], className].filter(Boolean).join(" "),
1069
+ ...rest,
1070
+ children: [
1071
+ /* @__PURE__ */ jsxs16("div", { className: body2, children: [
1072
+ titleText ? /* @__PURE__ */ jsx33("p", { className: title2, children: titleText }) : null,
1073
+ children ? /* @__PURE__ */ jsx33("p", { className: description2, children }) : null
1074
+ ] }),
1075
+ onDismiss ? /* @__PURE__ */ jsx33("button", { type: "button", className: closeButton3, "aria-label": "Dismiss", onClick: onDismiss, children: "\u2715" }) : null
1076
+ ]
1077
+ }
1078
+ );
1079
+ }
1080
+
1081
+ // src/components/DataGrid/DataGrid.tsx
1082
+ import { useCallback as useCallback2, useMemo as useMemo2, useRef as useRef3, useState as useState8 } from "react";
1083
+
1084
+ // src/components/DataGrid/DataGrid.css.ts
1085
+ var body3 = "DataGrid_body__7xivx76";
1086
+ var cell = "DataGrid_cell__7xivx78";
1087
+ var checkboxCell = "DataGrid_checkboxCell__7xivx79";
1088
+ var container = "DataGrid_container__7xivx70";
1089
+ var emptyState = "DataGrid_emptyState__7xivx7a";
1090
+ var headerButton = "DataGrid_headerButton__7xivx73";
1091
+ var headerCell = "DataGrid_headerCell__7xivx72";
1092
+ var headerRow = "DataGrid_headerRow__7xivx71";
1093
+ var resizeHandle = "DataGrid_resizeHandle__7xivx75";
1094
+ var row = "DataGrid_row__7xivx77";
1095
+ var sortIcon = "DataGrid_sortIcon__7xivx74";
1096
+
1097
+ // src/components/DataGrid/DataGrid.tsx
1098
+ import { jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
1099
+ var DEFAULT_COLUMN_WIDTH = 160;
1100
+ var CHECKBOX_COLUMN_WIDTH = 44;
1101
+ function compareValues(a, b) {
1102
+ if (typeof a === "number" && typeof b === "number") {
1103
+ return a - b;
1104
+ }
1105
+ return String(a).localeCompare(String(b));
1106
+ }
1107
+ function getCellValue(column, row2) {
1108
+ if (column.accessor) {
1109
+ return column.accessor(row2);
1110
+ }
1111
+ return row2[column.key];
1112
+ }
1113
+ function DataGrid({
1114
+ columns,
1115
+ data,
1116
+ getRowId,
1117
+ rowHeight = 40,
1118
+ height = 400,
1119
+ overscan = 5,
1120
+ selectable = false,
1121
+ selectedIds: controlledSelectedIds,
1122
+ onSelectionChange,
1123
+ sort: controlledSort,
1124
+ onSortChange,
1125
+ emptyMessage = "No data"
1126
+ }) {
1127
+ const [uncontrolledSort, setUncontrolledSort] = useState8(null);
1128
+ const [uncontrolledSelectedIds, setUncontrolledSelectedIds] = useState8(() => /* @__PURE__ */ new Set());
1129
+ const [columnWidths, setColumnWidths] = useState8(
1130
+ () => Object.fromEntries(columns.map((c) => [c.key, c.width ?? DEFAULT_COLUMN_WIDTH]))
1131
+ );
1132
+ const [scrollTop, setScrollTop] = useState8(0);
1133
+ const sort = controlledSort !== void 0 ? controlledSort : uncontrolledSort;
1134
+ const selectedIds = controlledSelectedIds ?? uncontrolledSelectedIds;
1135
+ const setSort = (next) => {
1136
+ if (controlledSort === void 0) {
1137
+ setUncontrolledSort(next);
1138
+ }
1139
+ onSortChange?.(next);
1140
+ };
1141
+ const setSelectedIds = (next) => {
1142
+ if (controlledSelectedIds === void 0) {
1143
+ setUncontrolledSelectedIds(next);
1144
+ }
1145
+ onSelectionChange?.(next);
1146
+ };
1147
+ const handleSortClick = (column) => {
1148
+ if (!column.sortable) return;
1149
+ if (!sort || sort.key !== column.key) {
1150
+ setSort({ key: column.key, direction: "asc" });
1151
+ } else if (sort.direction === "asc") {
1152
+ setSort({ key: column.key, direction: "desc" });
1153
+ } else {
1154
+ setSort(null);
1155
+ }
1156
+ };
1157
+ const sortedData = useMemo2(() => {
1158
+ if (!sort || !sort.direction) {
1159
+ return data;
1160
+ }
1161
+ const column = columns.find((c) => c.key === sort.key);
1162
+ if (!column) {
1163
+ return data;
1164
+ }
1165
+ const sorted = [...data].sort((a, b) => compareValues(getCellValue(column, a), getCellValue(column, b)));
1166
+ return sort.direction === "desc" ? sorted.reverse() : sorted;
1167
+ }, [data, sort, columns]);
1168
+ const allSelected = sortedData.length > 0 && sortedData.every((r) => selectedIds.has(getRowId(r)));
1169
+ const someSelected = !allSelected && sortedData.some((r) => selectedIds.has(getRowId(r)));
1170
+ const toggleAll = () => {
1171
+ if (allSelected) {
1172
+ setSelectedIds(/* @__PURE__ */ new Set());
1173
+ } else {
1174
+ setSelectedIds(new Set(sortedData.map(getRowId)));
1175
+ }
1176
+ };
1177
+ const toggleRow = (id) => {
1178
+ const next = new Set(selectedIds);
1179
+ if (next.has(id)) {
1180
+ next.delete(id);
1181
+ } else {
1182
+ next.add(id);
1183
+ }
1184
+ setSelectedIds(next);
1185
+ };
1186
+ const resizeState = useRef3(null);
1187
+ const handleResizeStart = useCallback2(
1188
+ (event, column) => {
1189
+ if (column.resizable === false) return;
1190
+ event.preventDefault();
1191
+ event.stopPropagation();
1192
+ resizeState.current = {
1193
+ key: column.key,
1194
+ startX: event.clientX,
1195
+ startWidth: columnWidths[column.key] ?? DEFAULT_COLUMN_WIDTH
1196
+ };
1197
+ const target = event.currentTarget;
1198
+ target.setPointerCapture(event.pointerId);
1199
+ },
1200
+ [columnWidths]
1201
+ );
1202
+ const handleResizeMove = useCallback2((event) => {
1203
+ const state = resizeState.current;
1204
+ if (!state) return;
1205
+ const delta = event.clientX - state.startX;
1206
+ const minWidth = columns.find((c) => c.key === state.key)?.minWidth ?? 60;
1207
+ const nextWidth = Math.max(minWidth, state.startWidth + delta);
1208
+ setColumnWidths((prev) => ({ ...prev, [state.key]: nextWidth }));
1209
+ }, [columns]);
1210
+ const handleResizeEnd = useCallback2((event) => {
1211
+ resizeState.current = null;
1212
+ event.currentTarget.releasePointerCapture(event.pointerId);
1213
+ }, []);
1214
+ const totalHeight = sortedData.length * rowHeight;
1215
+ const visibleCount = Math.ceil(height / rowHeight) + overscan * 2;
1216
+ const startIndex = Math.max(0, Math.floor(scrollTop / rowHeight) - overscan);
1217
+ const endIndex = Math.min(sortedData.length, startIndex + visibleCount);
1218
+ const visibleRows = sortedData.slice(startIndex, endIndex);
1219
+ const totalWidth = (selectable ? CHECKBOX_COLUMN_WIDTH : 0) + columns.reduce((sum, c) => sum + (columnWidths[c.key] ?? DEFAULT_COLUMN_WIDTH), 0);
1220
+ return /* @__PURE__ */ jsxs17(
1221
+ "div",
1222
+ {
1223
+ className: container,
1224
+ style: { height },
1225
+ onScroll: (e) => setScrollTop(e.currentTarget.scrollTop),
1226
+ role: "table",
1227
+ children: [
1228
+ /* @__PURE__ */ jsxs17("div", { className: headerRow, style: { width: totalWidth, minWidth: "100%" }, role: "row", children: [
1229
+ selectable ? /* @__PURE__ */ jsx34("div", { className: checkboxCell, role: "columnheader", children: /* @__PURE__ */ jsx34(
1230
+ "input",
1231
+ {
1232
+ type: "checkbox",
1233
+ checked: allSelected,
1234
+ ref: (el) => {
1235
+ if (el) el.indeterminate = someSelected;
1236
+ },
1237
+ onChange: toggleAll,
1238
+ "aria-label": "Select all rows"
1239
+ }
1240
+ ) }) : null,
1241
+ columns.map((column) => {
1242
+ const width = columnWidths[column.key] ?? DEFAULT_COLUMN_WIDTH;
1243
+ const isSorted = sort?.key === column.key;
1244
+ const direction2 = isSorted ? sort.direction : null;
1245
+ return /* @__PURE__ */ jsxs17(
1246
+ "div",
1247
+ {
1248
+ className: headerCell,
1249
+ style: { width },
1250
+ role: "columnheader",
1251
+ "aria-sort": direction2 === "asc" ? "ascending" : direction2 === "desc" ? "descending" : "none",
1252
+ children: [
1253
+ column.sortable ? /* @__PURE__ */ jsxs17("button", { type: "button", className: headerButton, onClick: () => handleSortClick(column), children: [
1254
+ column.header,
1255
+ /* @__PURE__ */ jsx34("span", { className: sortIcon, "aria-hidden": "true", children: direction2 === "asc" ? "\u25B2" : direction2 === "desc" ? "\u25BC" : "" })
1256
+ ] }) : column.header,
1257
+ column.resizable !== false ? /* @__PURE__ */ jsx34(
1258
+ "div",
1259
+ {
1260
+ className: resizeHandle,
1261
+ onPointerDown: (e) => handleResizeStart(e, column),
1262
+ onPointerMove: handleResizeMove,
1263
+ onPointerUp: handleResizeEnd,
1264
+ role: "separator",
1265
+ "aria-orientation": "vertical",
1266
+ "aria-label": `Resize ${String(column.header)} column`
1267
+ }
1268
+ ) : null
1269
+ ]
1270
+ },
1271
+ column.key
1272
+ );
1273
+ })
1274
+ ] }),
1275
+ sortedData.length === 0 ? /* @__PURE__ */ jsx34("div", { className: emptyState, children: emptyMessage }) : /* @__PURE__ */ jsx34("div", { className: body3, style: { height: totalHeight, width: totalWidth, minWidth: "100%" }, children: visibleRows.map((rowData, i) => {
1276
+ const index = startIndex + i;
1277
+ const id = getRowId(rowData);
1278
+ const isSelected = selectedIds.has(id);
1279
+ const style = { top: index * rowHeight, height: rowHeight, width: totalWidth };
1280
+ return /* @__PURE__ */ jsxs17("div", { className: row, style, role: "row", "data-selected": isSelected || void 0, children: [
1281
+ selectable ? /* @__PURE__ */ jsx34("div", { className: checkboxCell, role: "cell", children: /* @__PURE__ */ jsx34(
1282
+ "input",
1283
+ {
1284
+ type: "checkbox",
1285
+ checked: isSelected,
1286
+ onChange: () => toggleRow(id),
1287
+ "aria-label": `Select row ${index + 1}`
1288
+ }
1289
+ ) }) : null,
1290
+ columns.map((column) => /* @__PURE__ */ jsx34(
1291
+ "div",
1292
+ {
1293
+ className: cell,
1294
+ style: { width: columnWidths[column.key] ?? DEFAULT_COLUMN_WIDTH },
1295
+ role: "cell",
1296
+ children: column.render ? column.render(rowData) : String(getCellValue(column, rowData) ?? "")
1297
+ },
1298
+ column.key
1299
+ ))
1300
+ ] }, id);
1301
+ }) })
1302
+ ]
1303
+ }
1304
+ );
1305
+ }
1306
+
1307
+ // src/index.ts
1308
+ import { vars as vars2, defaultThemeClass, defaultThemeVars } from "@vesture/tokens";
1309
+ export {
1310
+ Accordion2 as Accordion,
1311
+ AccordionContent,
1312
+ AccordionItem,
1313
+ AccordionTrigger,
1314
+ Alert,
1315
+ Avatar,
1316
+ Badge,
1317
+ Breadcrumbs2 as Breadcrumbs,
1318
+ BreadcrumbsItem,
1319
+ Button,
1320
+ Card,
1321
+ Checkbox,
1322
+ DataGrid,
1323
+ Divider,
1324
+ DropdownMenu2 as DropdownMenu,
1325
+ DropdownMenuItem,
1326
+ Input,
1327
+ Label,
1328
+ Modal,
1329
+ Pagination,
1330
+ Popover,
1331
+ Progress,
1332
+ Radio,
1333
+ Select,
1334
+ Spinner,
1335
+ Stack,
1336
+ Switch,
1337
+ Tabs2 as Tabs,
1338
+ TabsList,
1339
+ TabsPanel,
1340
+ TabsTrigger,
1341
+ Textarea,
1342
+ ToastProvider,
1343
+ Tooltip,
1344
+ defaultThemeClass,
1345
+ defaultThemeVars,
1346
+ useToast,
1347
+ vars2 as vars
1348
+ };
1349
+ //# sourceMappingURL=index.js.map