@optilogic/core 1.0.0-beta.7 → 1.0.0-beta.9
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.cjs +734 -289
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -5
- package/dist/index.d.ts +109 -5
- package/dist/index.js +683 -239
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/data-table.tsx +735 -0
- package/src/index.ts +7 -0
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var tailwindMerge = require('tailwind-merge');
|
|
5
|
-
var
|
|
5
|
+
var React20 = require('react');
|
|
6
6
|
var reactSlot = require('@radix-ui/react-slot');
|
|
7
7
|
var classVarianceAuthority = require('class-variance-authority');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -42,7 +42,7 @@ function _interopNamespace(e) {
|
|
|
42
42
|
return Object.freeze(n);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
var
|
|
45
|
+
var React20__namespace = /*#__PURE__*/_interopNamespace(React20);
|
|
46
46
|
var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
|
|
47
47
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
48
48
|
var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
|
|
@@ -86,7 +86,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
);
|
|
89
|
-
var Button =
|
|
89
|
+
var Button = React20__namespace.forwardRef(
|
|
90
90
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
91
91
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
92
92
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -100,7 +100,7 @@ var Button = React34__namespace.forwardRef(
|
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
Button.displayName = "Button";
|
|
103
|
-
var Input =
|
|
103
|
+
var Input = React20__namespace.forwardRef(
|
|
104
104
|
({ className, type, ...props }, ref) => {
|
|
105
105
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
106
106
|
"input",
|
|
@@ -120,7 +120,7 @@ Input.displayName = "Input";
|
|
|
120
120
|
var labelVariants = classVarianceAuthority.cva(
|
|
121
121
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
122
122
|
);
|
|
123
|
-
var Label =
|
|
123
|
+
var Label = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
124
124
|
LabelPrimitive__namespace.Root,
|
|
125
125
|
{
|
|
126
126
|
ref,
|
|
@@ -129,7 +129,7 @@ var Label = React34__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
129
129
|
}
|
|
130
130
|
));
|
|
131
131
|
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
132
|
-
var Textarea =
|
|
132
|
+
var Textarea = React20__namespace.forwardRef(
|
|
133
133
|
({ className, ...props }, ref) => {
|
|
134
134
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
135
135
|
"textarea",
|
|
@@ -168,7 +168,7 @@ var badgeVariants = classVarianceAuthority.cva(
|
|
|
168
168
|
function Badge({ className, variant, ...props }) {
|
|
169
169
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
|
|
170
170
|
}
|
|
171
|
-
var Checkbox =
|
|
171
|
+
var Checkbox = React20__namespace.forwardRef(({ className, showBorder = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
172
172
|
CheckboxPrimitive__namespace.Root,
|
|
173
173
|
{
|
|
174
174
|
ref,
|
|
@@ -212,7 +212,7 @@ var Checkbox = React34__namespace.forwardRef(({ className, showBorder = true, ..
|
|
|
212
212
|
}
|
|
213
213
|
));
|
|
214
214
|
Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
|
|
215
|
-
var Switch =
|
|
215
|
+
var Switch = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
216
216
|
SwitchPrimitive__namespace.Root,
|
|
217
217
|
{
|
|
218
218
|
className: cn(
|
|
@@ -248,7 +248,7 @@ var Switch = React34__namespace.forwardRef(({ className, ...props }, ref) => /*
|
|
|
248
248
|
}
|
|
249
249
|
));
|
|
250
250
|
Switch.displayName = SwitchPrimitive__namespace.Root.displayName;
|
|
251
|
-
var Progress =
|
|
251
|
+
var Progress = React20__namespace.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
252
252
|
ProgressPrimitive__namespace.Root,
|
|
253
253
|
{
|
|
254
254
|
ref,
|
|
@@ -267,7 +267,7 @@ var Progress = React34__namespace.forwardRef(({ className, value, ...props }, re
|
|
|
267
267
|
}
|
|
268
268
|
));
|
|
269
269
|
Progress.displayName = ProgressPrimitive__namespace.Root.displayName;
|
|
270
|
-
var Separator =
|
|
270
|
+
var Separator = React20__namespace.forwardRef(
|
|
271
271
|
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
272
272
|
SeparatorPrimitive__namespace.Root,
|
|
273
273
|
{
|
|
@@ -296,7 +296,7 @@ function Skeleton({ className, ...props }) {
|
|
|
296
296
|
var Select = SelectPrimitive__namespace.Root;
|
|
297
297
|
var SelectGroup = SelectPrimitive__namespace.Group;
|
|
298
298
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
299
|
-
var SelectTrigger =
|
|
299
|
+
var SelectTrigger = React20__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
300
300
|
SelectPrimitive__namespace.Trigger,
|
|
301
301
|
{
|
|
302
302
|
ref,
|
|
@@ -312,7 +312,7 @@ var SelectTrigger = React34__namespace.forwardRef(({ className, children, ...pro
|
|
|
312
312
|
}
|
|
313
313
|
));
|
|
314
314
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
315
|
-
var SelectScrollUpButton =
|
|
315
|
+
var SelectScrollUpButton = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
316
316
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
317
317
|
{
|
|
318
318
|
ref,
|
|
@@ -325,7 +325,7 @@ var SelectScrollUpButton = React34__namespace.forwardRef(({ className, ...props
|
|
|
325
325
|
}
|
|
326
326
|
));
|
|
327
327
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
328
|
-
var SelectScrollDownButton =
|
|
328
|
+
var SelectScrollDownButton = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
329
329
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
330
330
|
{
|
|
331
331
|
ref,
|
|
@@ -338,7 +338,7 @@ var SelectScrollDownButton = React34__namespace.forwardRef(({ className, ...prop
|
|
|
338
338
|
}
|
|
339
339
|
));
|
|
340
340
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
341
|
-
var SelectContent =
|
|
341
|
+
var SelectContent = React20__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
342
342
|
SelectPrimitive__namespace.Content,
|
|
343
343
|
{
|
|
344
344
|
ref,
|
|
@@ -366,7 +366,7 @@ var SelectContent = React34__namespace.forwardRef(({ className, children, positi
|
|
|
366
366
|
}
|
|
367
367
|
) }));
|
|
368
368
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
369
|
-
var SelectLabel =
|
|
369
|
+
var SelectLabel = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
370
370
|
SelectPrimitive__namespace.Label,
|
|
371
371
|
{
|
|
372
372
|
ref,
|
|
@@ -375,7 +375,7 @@ var SelectLabel = React34__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
375
375
|
}
|
|
376
376
|
));
|
|
377
377
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
378
|
-
var SelectItem =
|
|
378
|
+
var SelectItem = React20__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
379
379
|
SelectPrimitive__namespace.Item,
|
|
380
380
|
{
|
|
381
381
|
ref,
|
|
@@ -391,7 +391,7 @@ var SelectItem = React34__namespace.forwardRef(({ className, children, ...props
|
|
|
391
391
|
}
|
|
392
392
|
));
|
|
393
393
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
394
|
-
var SelectSeparator =
|
|
394
|
+
var SelectSeparator = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
395
395
|
SelectPrimitive__namespace.Separator,
|
|
396
396
|
{
|
|
397
397
|
ref,
|
|
@@ -401,7 +401,7 @@ var SelectSeparator = React34__namespace.forwardRef(({ className, ...props }, re
|
|
|
401
401
|
));
|
|
402
402
|
SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
|
|
403
403
|
var Tabs = TabsPrimitive__namespace.Root;
|
|
404
|
-
var TabsList =
|
|
404
|
+
var TabsList = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
405
405
|
TabsPrimitive__namespace.List,
|
|
406
406
|
{
|
|
407
407
|
ref,
|
|
@@ -415,7 +415,7 @@ var TabsList = React34__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
415
415
|
}
|
|
416
416
|
));
|
|
417
417
|
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
418
|
-
var TabsTrigger =
|
|
418
|
+
var TabsTrigger = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
419
419
|
TabsPrimitive__namespace.Trigger,
|
|
420
420
|
{
|
|
421
421
|
ref,
|
|
@@ -442,7 +442,7 @@ var TabsTrigger = React34__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
442
442
|
}
|
|
443
443
|
));
|
|
444
444
|
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
445
|
-
var TabsContent =
|
|
445
|
+
var TabsContent = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
446
446
|
TabsPrimitive__namespace.Content,
|
|
447
447
|
{
|
|
448
448
|
ref,
|
|
@@ -525,7 +525,7 @@ var accordionContentInnerVariants = classVarianceAuthority.cva("pb-4 pt-0", {
|
|
|
525
525
|
}
|
|
526
526
|
});
|
|
527
527
|
var Accordion = AccordionPrimitive__namespace.Root;
|
|
528
|
-
var AccordionItem =
|
|
528
|
+
var AccordionItem = React20__namespace.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
529
529
|
AccordionPrimitive__namespace.Item,
|
|
530
530
|
{
|
|
531
531
|
ref,
|
|
@@ -535,7 +535,7 @@ var AccordionItem = React34__namespace.forwardRef(({ className, variant, ...prop
|
|
|
535
535
|
}
|
|
536
536
|
));
|
|
537
537
|
AccordionItem.displayName = "AccordionItem";
|
|
538
|
-
var AccordionTrigger =
|
|
538
|
+
var AccordionTrigger = React20__namespace.forwardRef(({ className, children, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
539
539
|
AccordionPrimitive__namespace.Trigger,
|
|
540
540
|
{
|
|
541
541
|
ref,
|
|
@@ -548,7 +548,7 @@ var AccordionTrigger = React34__namespace.forwardRef(({ className, children, var
|
|
|
548
548
|
}
|
|
549
549
|
) }));
|
|
550
550
|
AccordionTrigger.displayName = AccordionPrimitive__namespace.Trigger.displayName;
|
|
551
|
-
var AccordionContent =
|
|
551
|
+
var AccordionContent = React20__namespace.forwardRef(({ className, children, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
552
552
|
AccordionPrimitive__namespace.Content,
|
|
553
553
|
{
|
|
554
554
|
ref,
|
|
@@ -562,7 +562,7 @@ var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
|
562
562
|
var TooltipRoot = TooltipPrimitive__namespace.Root;
|
|
563
563
|
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
564
564
|
var TooltipPortal = TooltipPrimitive__namespace.Portal;
|
|
565
|
-
var TooltipContent =
|
|
565
|
+
var TooltipContent = React20__namespace.forwardRef(({ className, sideOffset = 6, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
566
566
|
TooltipPrimitive__namespace.Content,
|
|
567
567
|
{
|
|
568
568
|
ref,
|
|
@@ -591,7 +591,7 @@ var TooltipContent = React34__namespace.forwardRef(({ className, sideOffset = 6,
|
|
|
591
591
|
}
|
|
592
592
|
) }));
|
|
593
593
|
TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
|
|
594
|
-
var TooltipArrow =
|
|
594
|
+
var TooltipArrow = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
595
595
|
TooltipPrimitive__namespace.Arrow,
|
|
596
596
|
{
|
|
597
597
|
ref,
|
|
@@ -630,7 +630,7 @@ function Tooltip({
|
|
|
630
630
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
631
631
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
632
632
|
var PopoverAnchor = PopoverPrimitive__namespace.Anchor;
|
|
633
|
-
var PopoverContent =
|
|
633
|
+
var PopoverContent = React20__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
634
634
|
PopoverPrimitive__namespace.Content,
|
|
635
635
|
{
|
|
636
636
|
ref,
|
|
@@ -656,7 +656,7 @@ var DropdownMenuGroup = DropdownMenuPrimitive__namespace.Group;
|
|
|
656
656
|
var DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
|
|
657
657
|
var DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
|
|
658
658
|
var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
|
|
659
|
-
var DropdownMenuSubTrigger =
|
|
659
|
+
var DropdownMenuSubTrigger = React20__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
660
660
|
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
661
661
|
{
|
|
662
662
|
ref,
|
|
@@ -675,7 +675,7 @@ var DropdownMenuSubTrigger = React34__namespace.forwardRef(({ className, inset,
|
|
|
675
675
|
}
|
|
676
676
|
));
|
|
677
677
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
|
|
678
|
-
var DropdownMenuSubContent =
|
|
678
|
+
var DropdownMenuSubContent = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
679
679
|
DropdownMenuPrimitive__namespace.SubContent,
|
|
680
680
|
{
|
|
681
681
|
ref,
|
|
@@ -692,7 +692,7 @@ var DropdownMenuSubContent = React34__namespace.forwardRef(({ className, ...prop
|
|
|
692
692
|
}
|
|
693
693
|
));
|
|
694
694
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
|
|
695
|
-
var DropdownMenuContent =
|
|
695
|
+
var DropdownMenuContent = React20__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
696
696
|
DropdownMenuPrimitive__namespace.Content,
|
|
697
697
|
{
|
|
698
698
|
ref,
|
|
@@ -710,7 +710,7 @@ var DropdownMenuContent = React34__namespace.forwardRef(({ className, sideOffset
|
|
|
710
710
|
}
|
|
711
711
|
) }));
|
|
712
712
|
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
|
|
713
|
-
var DropdownMenuItem =
|
|
713
|
+
var DropdownMenuItem = React20__namespace.forwardRef(({ className, inset, destructive, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
714
714
|
DropdownMenuPrimitive__namespace.Item,
|
|
715
715
|
{
|
|
716
716
|
ref,
|
|
@@ -726,7 +726,7 @@ var DropdownMenuItem = React34__namespace.forwardRef(({ className, inset, destru
|
|
|
726
726
|
}
|
|
727
727
|
));
|
|
728
728
|
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
|
|
729
|
-
var DropdownMenuCheckboxItem =
|
|
729
|
+
var DropdownMenuCheckboxItem = React20__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
730
730
|
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
731
731
|
{
|
|
732
732
|
ref,
|
|
@@ -745,7 +745,7 @@ var DropdownMenuCheckboxItem = React34__namespace.forwardRef(({ className, child
|
|
|
745
745
|
}
|
|
746
746
|
));
|
|
747
747
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
|
|
748
|
-
var DropdownMenuRadioItem =
|
|
748
|
+
var DropdownMenuRadioItem = React20__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
749
749
|
DropdownMenuPrimitive__namespace.RadioItem,
|
|
750
750
|
{
|
|
751
751
|
ref,
|
|
@@ -763,7 +763,7 @@ var DropdownMenuRadioItem = React34__namespace.forwardRef(({ className, children
|
|
|
763
763
|
}
|
|
764
764
|
));
|
|
765
765
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
|
|
766
|
-
var DropdownMenuLabel =
|
|
766
|
+
var DropdownMenuLabel = React20__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
767
767
|
DropdownMenuPrimitive__namespace.Label,
|
|
768
768
|
{
|
|
769
769
|
ref,
|
|
@@ -776,7 +776,7 @@ var DropdownMenuLabel = React34__namespace.forwardRef(({ className, inset, ...pr
|
|
|
776
776
|
}
|
|
777
777
|
));
|
|
778
778
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
|
|
779
|
-
var DropdownMenuSeparator =
|
|
779
|
+
var DropdownMenuSeparator = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
780
780
|
DropdownMenuPrimitive__namespace.Separator,
|
|
781
781
|
{
|
|
782
782
|
ref,
|
|
@@ -801,7 +801,7 @@ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
|
801
801
|
var AlertDialog = AlertDialogPrimitive__namespace.Root;
|
|
802
802
|
var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
|
|
803
803
|
var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
|
|
804
|
-
var AlertDialogOverlay =
|
|
804
|
+
var AlertDialogOverlay = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
805
805
|
AlertDialogPrimitive__namespace.Overlay,
|
|
806
806
|
{
|
|
807
807
|
className: cn(
|
|
@@ -815,7 +815,7 @@ var AlertDialogOverlay = React34__namespace.forwardRef(({ className, ...props },
|
|
|
815
815
|
}
|
|
816
816
|
));
|
|
817
817
|
AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
|
|
818
|
-
var AlertDialogContent =
|
|
818
|
+
var AlertDialogContent = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
|
|
819
819
|
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
|
|
820
820
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
821
821
|
AlertDialogPrimitive__namespace.Content,
|
|
@@ -858,7 +858,7 @@ var AlertDialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.
|
|
|
858
858
|
}
|
|
859
859
|
);
|
|
860
860
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
861
|
-
var AlertDialogTitle =
|
|
861
|
+
var AlertDialogTitle = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
862
862
|
AlertDialogPrimitive__namespace.Title,
|
|
863
863
|
{
|
|
864
864
|
ref,
|
|
@@ -867,7 +867,7 @@ var AlertDialogTitle = React34__namespace.forwardRef(({ className, ...props }, r
|
|
|
867
867
|
}
|
|
868
868
|
));
|
|
869
869
|
AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
|
|
870
|
-
var AlertDialogDescription =
|
|
870
|
+
var AlertDialogDescription = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
871
871
|
AlertDialogPrimitive__namespace.Description,
|
|
872
872
|
{
|
|
873
873
|
ref,
|
|
@@ -876,7 +876,7 @@ var AlertDialogDescription = React34__namespace.forwardRef(({ className, ...prop
|
|
|
876
876
|
}
|
|
877
877
|
));
|
|
878
878
|
AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
|
|
879
|
-
var AlertDialogAction =
|
|
879
|
+
var AlertDialogAction = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
880
880
|
AlertDialogPrimitive__namespace.Action,
|
|
881
881
|
{
|
|
882
882
|
ref,
|
|
@@ -885,7 +885,7 @@ var AlertDialogAction = React34__namespace.forwardRef(({ className, ...props },
|
|
|
885
885
|
}
|
|
886
886
|
));
|
|
887
887
|
AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
|
|
888
|
-
var AlertDialogCancel =
|
|
888
|
+
var AlertDialogCancel = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
889
889
|
AlertDialogPrimitive__namespace.Cancel,
|
|
890
890
|
{
|
|
891
891
|
ref,
|
|
@@ -948,7 +948,7 @@ var cardVariants = classVarianceAuthority.cva(
|
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
950
|
);
|
|
951
|
-
var Card =
|
|
951
|
+
var Card = React20__namespace.forwardRef(
|
|
952
952
|
({
|
|
953
953
|
className,
|
|
954
954
|
size,
|
|
@@ -962,7 +962,7 @@ var Card = React34__namespace.forwardRef(
|
|
|
962
962
|
...props
|
|
963
963
|
}, ref) => {
|
|
964
964
|
const isInteractive = interactive || asButton || !!onClick;
|
|
965
|
-
const handleKeyDown =
|
|
965
|
+
const handleKeyDown = React20__namespace.useCallback(
|
|
966
966
|
(e) => {
|
|
967
967
|
if (isInteractive && (e.key === "Enter" || e.key === " ")) {
|
|
968
968
|
e.preventDefault();
|
|
@@ -994,7 +994,7 @@ var Card = React34__namespace.forwardRef(
|
|
|
994
994
|
}
|
|
995
995
|
);
|
|
996
996
|
Card.displayName = "Card";
|
|
997
|
-
var CardHeader =
|
|
997
|
+
var CardHeader = React20__namespace.forwardRef(
|
|
998
998
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
999
999
|
"div",
|
|
1000
1000
|
{
|
|
@@ -1005,7 +1005,7 @@ var CardHeader = React34__namespace.forwardRef(
|
|
|
1005
1005
|
)
|
|
1006
1006
|
);
|
|
1007
1007
|
CardHeader.displayName = "CardHeader";
|
|
1008
|
-
var CardTitle =
|
|
1008
|
+
var CardTitle = React20__namespace.forwardRef(
|
|
1009
1009
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1010
1010
|
"div",
|
|
1011
1011
|
{
|
|
@@ -1016,7 +1016,7 @@ var CardTitle = React34__namespace.forwardRef(
|
|
|
1016
1016
|
)
|
|
1017
1017
|
);
|
|
1018
1018
|
CardTitle.displayName = "CardTitle";
|
|
1019
|
-
var CardDescription =
|
|
1019
|
+
var CardDescription = React20__namespace.forwardRef(
|
|
1020
1020
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1021
1021
|
"div",
|
|
1022
1022
|
{
|
|
@@ -1027,11 +1027,11 @@ var CardDescription = React34__namespace.forwardRef(
|
|
|
1027
1027
|
)
|
|
1028
1028
|
);
|
|
1029
1029
|
CardDescription.displayName = "CardDescription";
|
|
1030
|
-
var CardContent =
|
|
1030
|
+
var CardContent = React20__namespace.forwardRef(
|
|
1031
1031
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
1032
1032
|
);
|
|
1033
1033
|
CardContent.displayName = "CardContent";
|
|
1034
|
-
var CardFooter =
|
|
1034
|
+
var CardFooter = React20__namespace.forwardRef(
|
|
1035
1035
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1036
1036
|
"div",
|
|
1037
1037
|
{
|
|
@@ -1068,17 +1068,17 @@ var cardImageVariants = classVarianceAuthority.cva("w-full object-cover", {
|
|
|
1068
1068
|
position: "top"
|
|
1069
1069
|
}
|
|
1070
1070
|
});
|
|
1071
|
-
var CardImage =
|
|
1071
|
+
var CardImage = React20__namespace.forwardRef(
|
|
1072
1072
|
({ className, aspectRatio, position, fallback, alt, src, onError, ...props }, ref) => {
|
|
1073
|
-
const [hasError, setHasError] =
|
|
1074
|
-
const handleError =
|
|
1073
|
+
const [hasError, setHasError] = React20__namespace.useState(false);
|
|
1074
|
+
const handleError = React20__namespace.useCallback(
|
|
1075
1075
|
(e) => {
|
|
1076
1076
|
setHasError(true);
|
|
1077
1077
|
onError?.(e);
|
|
1078
1078
|
},
|
|
1079
1079
|
[onError]
|
|
1080
1080
|
);
|
|
1081
|
-
|
|
1081
|
+
React20__namespace.useEffect(() => {
|
|
1082
1082
|
setHasError(false);
|
|
1083
1083
|
}, [src]);
|
|
1084
1084
|
if (hasError && fallback) {
|
|
@@ -1149,7 +1149,7 @@ var cardActionsVariants = classVarianceAuthority.cva(
|
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
);
|
|
1152
|
-
var CardActions =
|
|
1152
|
+
var CardActions = React20__namespace.forwardRef(
|
|
1153
1153
|
({ className, showOn, position, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1154
1154
|
"div",
|
|
1155
1155
|
{
|
|
@@ -1161,7 +1161,7 @@ var CardActions = React34__namespace.forwardRef(
|
|
|
1161
1161
|
)
|
|
1162
1162
|
);
|
|
1163
1163
|
CardActions.displayName = "CardActions";
|
|
1164
|
-
var SelectableCard =
|
|
1164
|
+
var SelectableCard = React20__namespace.forwardRef(
|
|
1165
1165
|
({
|
|
1166
1166
|
className,
|
|
1167
1167
|
selected: controlledSelected,
|
|
@@ -1175,10 +1175,10 @@ var SelectableCard = React34__namespace.forwardRef(
|
|
|
1175
1175
|
hover = "border",
|
|
1176
1176
|
...props
|
|
1177
1177
|
}, ref) => {
|
|
1178
|
-
const [uncontrolledSelected, setUncontrolledSelected] =
|
|
1178
|
+
const [uncontrolledSelected, setUncontrolledSelected] = React20__namespace.useState(defaultSelected);
|
|
1179
1179
|
const isControlled = controlledSelected !== void 0;
|
|
1180
1180
|
const isSelected = isControlled ? controlledSelected : uncontrolledSelected;
|
|
1181
|
-
const handleClick =
|
|
1181
|
+
const handleClick = React20__namespace.useCallback(
|
|
1182
1182
|
(e) => {
|
|
1183
1183
|
if (disabled) return;
|
|
1184
1184
|
const newSelected = !isSelected;
|
|
@@ -1190,7 +1190,7 @@ var SelectableCard = React34__namespace.forwardRef(
|
|
|
1190
1190
|
},
|
|
1191
1191
|
[disabled, isSelected, isControlled, onSelectedChange, onClick]
|
|
1192
1192
|
);
|
|
1193
|
-
const handleCheckboxChange =
|
|
1193
|
+
const handleCheckboxChange = React20__namespace.useCallback(
|
|
1194
1194
|
(checked) => {
|
|
1195
1195
|
if (disabled) return;
|
|
1196
1196
|
const newSelected = checked === true;
|
|
@@ -1290,7 +1290,7 @@ var cardGridVariants = classVarianceAuthority.cva("grid", {
|
|
|
1290
1290
|
gap: "md"
|
|
1291
1291
|
}
|
|
1292
1292
|
});
|
|
1293
|
-
var CardGrid =
|
|
1293
|
+
var CardGrid = React20__namespace.forwardRef(
|
|
1294
1294
|
({ className, columns, gap, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1295
1295
|
"div",
|
|
1296
1296
|
{
|
|
@@ -1325,7 +1325,7 @@ var cardListVariants = classVarianceAuthority.cva("flex flex-col", {
|
|
|
1325
1325
|
divided: false
|
|
1326
1326
|
}
|
|
1327
1327
|
});
|
|
1328
|
-
var CardList =
|
|
1328
|
+
var CardList = React20__namespace.forwardRef(
|
|
1329
1329
|
({ className, gap, divided, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1330
1330
|
"div",
|
|
1331
1331
|
{
|
|
@@ -1406,7 +1406,7 @@ var boardVariants = classVarianceAuthority.cva("text-card-foreground", {
|
|
|
1406
1406
|
hover: "none"
|
|
1407
1407
|
}
|
|
1408
1408
|
});
|
|
1409
|
-
var Board =
|
|
1409
|
+
var Board = React20__namespace.forwardRef(
|
|
1410
1410
|
({
|
|
1411
1411
|
className,
|
|
1412
1412
|
elevation,
|
|
@@ -1442,7 +1442,7 @@ var Board = React34__namespace.forwardRef(
|
|
|
1442
1442
|
}
|
|
1443
1443
|
);
|
|
1444
1444
|
Board.displayName = "Board";
|
|
1445
|
-
var BoardHeader =
|
|
1445
|
+
var BoardHeader = React20__namespace.forwardRef(
|
|
1446
1446
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1447
1447
|
"div",
|
|
1448
1448
|
{
|
|
@@ -1453,11 +1453,11 @@ var BoardHeader = React34__namespace.forwardRef(
|
|
|
1453
1453
|
)
|
|
1454
1454
|
);
|
|
1455
1455
|
BoardHeader.displayName = "BoardHeader";
|
|
1456
|
-
var BoardContent =
|
|
1456
|
+
var BoardContent = React20__namespace.forwardRef(
|
|
1457
1457
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-4", className), ...props })
|
|
1458
1458
|
);
|
|
1459
1459
|
BoardContent.displayName = "BoardContent";
|
|
1460
|
-
var Table =
|
|
1460
|
+
var Table = React20__namespace.forwardRef(
|
|
1461
1461
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1462
1462
|
"table",
|
|
1463
1463
|
{
|
|
@@ -1468,11 +1468,11 @@ var Table = React34__namespace.forwardRef(
|
|
|
1468
1468
|
) })
|
|
1469
1469
|
);
|
|
1470
1470
|
Table.displayName = "Table";
|
|
1471
|
-
var TableHeader =
|
|
1471
|
+
var TableHeader = React20__namespace.forwardRef(
|
|
1472
1472
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props })
|
|
1473
1473
|
);
|
|
1474
1474
|
TableHeader.displayName = "TableHeader";
|
|
1475
|
-
var TableBody =
|
|
1475
|
+
var TableBody = React20__namespace.forwardRef(
|
|
1476
1476
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1477
1477
|
"tbody",
|
|
1478
1478
|
{
|
|
@@ -1483,7 +1483,7 @@ var TableBody = React34__namespace.forwardRef(
|
|
|
1483
1483
|
)
|
|
1484
1484
|
);
|
|
1485
1485
|
TableBody.displayName = "TableBody";
|
|
1486
|
-
var TableFooter =
|
|
1486
|
+
var TableFooter = React20__namespace.forwardRef(
|
|
1487
1487
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1488
1488
|
"tfoot",
|
|
1489
1489
|
{
|
|
@@ -1497,7 +1497,7 @@ var TableFooter = React34__namespace.forwardRef(
|
|
|
1497
1497
|
)
|
|
1498
1498
|
);
|
|
1499
1499
|
TableFooter.displayName = "TableFooter";
|
|
1500
|
-
var TableRow =
|
|
1500
|
+
var TableRow = React20__namespace.forwardRef(
|
|
1501
1501
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1502
1502
|
"tr",
|
|
1503
1503
|
{
|
|
@@ -1511,7 +1511,7 @@ var TableRow = React34__namespace.forwardRef(
|
|
|
1511
1511
|
)
|
|
1512
1512
|
);
|
|
1513
1513
|
TableRow.displayName = "TableRow";
|
|
1514
|
-
var TableHead =
|
|
1514
|
+
var TableHead = React20__namespace.forwardRef(
|
|
1515
1515
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1516
1516
|
"th",
|
|
1517
1517
|
{
|
|
@@ -1525,7 +1525,7 @@ var TableHead = React34__namespace.forwardRef(
|
|
|
1525
1525
|
)
|
|
1526
1526
|
);
|
|
1527
1527
|
TableHead.displayName = "TableHead";
|
|
1528
|
-
var TableCell =
|
|
1528
|
+
var TableCell = React20__namespace.forwardRef(
|
|
1529
1529
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1530
1530
|
"td",
|
|
1531
1531
|
{
|
|
@@ -1539,7 +1539,7 @@ var TableCell = React34__namespace.forwardRef(
|
|
|
1539
1539
|
)
|
|
1540
1540
|
);
|
|
1541
1541
|
TableCell.displayName = "TableCell";
|
|
1542
|
-
var TableCaption =
|
|
1542
|
+
var TableCaption = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1543
1543
|
"caption",
|
|
1544
1544
|
{
|
|
1545
1545
|
ref,
|
|
@@ -1548,6 +1548,518 @@ var TableCaption = React34__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
1548
1548
|
}
|
|
1549
1549
|
));
|
|
1550
1550
|
TableCaption.displayName = "TableCaption";
|
|
1551
|
+
var loadingSpinnerVariants = classVarianceAuthority.cva("rounded-full animate-spin border-current", {
|
|
1552
|
+
variants: {
|
|
1553
|
+
/**
|
|
1554
|
+
* Size of the spinner
|
|
1555
|
+
*/
|
|
1556
|
+
size: {
|
|
1557
|
+
sm: "w-4 h-4 border-2",
|
|
1558
|
+
default: "w-8 h-8 border-2",
|
|
1559
|
+
lg: "w-12 h-12 border-[3px]",
|
|
1560
|
+
xl: "w-16 h-16 border-4"
|
|
1561
|
+
},
|
|
1562
|
+
/**
|
|
1563
|
+
* Visual variant
|
|
1564
|
+
*/
|
|
1565
|
+
variant: {
|
|
1566
|
+
/** Primary color spinner (default) */
|
|
1567
|
+
default: "border-primary/20 border-t-primary",
|
|
1568
|
+
/** Accent color spinner */
|
|
1569
|
+
accent: "border-accent/20 border-t-accent",
|
|
1570
|
+
/** Muted/subtle spinner */
|
|
1571
|
+
muted: "border-muted-foreground/20 border-t-muted-foreground",
|
|
1572
|
+
/** Inherits current text color */
|
|
1573
|
+
inherit: "border-current/20 border-t-current"
|
|
1574
|
+
}
|
|
1575
|
+
},
|
|
1576
|
+
defaultVariants: {
|
|
1577
|
+
size: "default",
|
|
1578
|
+
variant: "default"
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
var LoadingSpinner = React20__namespace.forwardRef(
|
|
1582
|
+
({ className, size, variant, label, showDots = false, ...props }, ref) => {
|
|
1583
|
+
const [dots, setDots] = React20__namespace.useState("");
|
|
1584
|
+
React20__namespace.useEffect(() => {
|
|
1585
|
+
if (!showDots || !label) return;
|
|
1586
|
+
const interval = setInterval(() => {
|
|
1587
|
+
setDots((prev) => prev.length >= 3 ? "" : prev + ".");
|
|
1588
|
+
}, 500);
|
|
1589
|
+
return () => clearInterval(interval);
|
|
1590
|
+
}, [showDots, label]);
|
|
1591
|
+
if (label) {
|
|
1592
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1593
|
+
"div",
|
|
1594
|
+
{
|
|
1595
|
+
ref,
|
|
1596
|
+
className: cn("flex flex-col items-center gap-3", className),
|
|
1597
|
+
...props,
|
|
1598
|
+
children: [
|
|
1599
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: loadingSpinnerVariants({ size, variant }) }),
|
|
1600
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
1601
|
+
label,
|
|
1602
|
+
showDots && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-4", children: dots })
|
|
1603
|
+
] })
|
|
1604
|
+
]
|
|
1605
|
+
}
|
|
1606
|
+
);
|
|
1607
|
+
}
|
|
1608
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1609
|
+
"div",
|
|
1610
|
+
{
|
|
1611
|
+
ref,
|
|
1612
|
+
className: cn(loadingSpinnerVariants({ size, variant }), className),
|
|
1613
|
+
...props
|
|
1614
|
+
}
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1617
|
+
);
|
|
1618
|
+
LoadingSpinner.displayName = "LoadingSpinner";
|
|
1619
|
+
function getCellRawValue(row, col) {
|
|
1620
|
+
if (col.accessor) return col.accessor(row);
|
|
1621
|
+
return row[col.key];
|
|
1622
|
+
}
|
|
1623
|
+
function defaultSearch(row, query, columns) {
|
|
1624
|
+
const lowerQuery = query.toLowerCase();
|
|
1625
|
+
return columns.some((col) => {
|
|
1626
|
+
const val = getCellRawValue(row, col);
|
|
1627
|
+
if (val == null) return false;
|
|
1628
|
+
return String(val).toLowerCase().includes(lowerQuery);
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
function defaultSortComparator(a, b, col, direction) {
|
|
1632
|
+
if (col.sortFn) {
|
|
1633
|
+
const result = col.sortFn(a, b);
|
|
1634
|
+
return direction === "asc" ? result : -result;
|
|
1635
|
+
}
|
|
1636
|
+
const aVal = getCellRawValue(a, col);
|
|
1637
|
+
const bVal = getCellRawValue(b, col);
|
|
1638
|
+
const aStr = aVal == null ? "" : String(aVal);
|
|
1639
|
+
const bStr = bVal == null ? "" : String(bVal);
|
|
1640
|
+
const aNum = Number(aStr);
|
|
1641
|
+
const bNum = Number(bStr);
|
|
1642
|
+
if (!isNaN(aNum) && !isNaN(bNum) && aStr !== "" && bStr !== "") {
|
|
1643
|
+
return direction === "asc" ? aNum - bNum : bNum - aNum;
|
|
1644
|
+
}
|
|
1645
|
+
const cmp = aStr.localeCompare(bStr);
|
|
1646
|
+
return direction === "asc" ? cmp : -cmp;
|
|
1647
|
+
}
|
|
1648
|
+
function DataTable({
|
|
1649
|
+
data,
|
|
1650
|
+
columns,
|
|
1651
|
+
getRowKey,
|
|
1652
|
+
// Sorting
|
|
1653
|
+
defaultSort,
|
|
1654
|
+
sort: controlledSort,
|
|
1655
|
+
onSortChange,
|
|
1656
|
+
// Search
|
|
1657
|
+
searchable = false,
|
|
1658
|
+
searchPlaceholder = "Search...",
|
|
1659
|
+
searchValue: controlledSearchValue,
|
|
1660
|
+
onSearchChange,
|
|
1661
|
+
searchFn,
|
|
1662
|
+
// Pagination
|
|
1663
|
+
pageSize: defaultPageSize,
|
|
1664
|
+
pageSizeOptions = [10, 15, 25, 50, 100],
|
|
1665
|
+
currentPage: controlledPage,
|
|
1666
|
+
onPageChange,
|
|
1667
|
+
onPageSizeChange,
|
|
1668
|
+
// Selection
|
|
1669
|
+
selectable,
|
|
1670
|
+
selectedRows: controlledSelectedRows,
|
|
1671
|
+
onSelectedRowsChange,
|
|
1672
|
+
// Row interaction
|
|
1673
|
+
onRowClick,
|
|
1674
|
+
rowClassName,
|
|
1675
|
+
// Pinned rows
|
|
1676
|
+
pinnedRows = [],
|
|
1677
|
+
// Slots
|
|
1678
|
+
toolbar,
|
|
1679
|
+
emptyState,
|
|
1680
|
+
caption,
|
|
1681
|
+
// Loading
|
|
1682
|
+
loading = false,
|
|
1683
|
+
// Styling
|
|
1684
|
+
className
|
|
1685
|
+
}) {
|
|
1686
|
+
const [internalSort, setInternalSort] = React20__namespace.useState(
|
|
1687
|
+
defaultSort ?? null
|
|
1688
|
+
);
|
|
1689
|
+
const [internalSearchValue, setInternalSearchValue] = React20__namespace.useState("");
|
|
1690
|
+
const [internalPage, setInternalPage] = React20__namespace.useState(0);
|
|
1691
|
+
const [internalPageSize, setInternalPageSize] = React20__namespace.useState(
|
|
1692
|
+
defaultPageSize ?? 10
|
|
1693
|
+
);
|
|
1694
|
+
const [internalSelectedRows, setInternalSelectedRows] = React20__namespace.useState([]);
|
|
1695
|
+
const sort = controlledSort !== void 0 ? controlledSort : internalSort;
|
|
1696
|
+
const searchQuery = controlledSearchValue !== void 0 ? controlledSearchValue : internalSearchValue;
|
|
1697
|
+
const page = controlledPage !== void 0 ? controlledPage : internalPage;
|
|
1698
|
+
const pageSize = defaultPageSize != null ? internalPageSize ?? defaultPageSize : void 0;
|
|
1699
|
+
const selectedRowKeys = controlledSelectedRows !== void 0 ? controlledSelectedRows : internalSelectedRows;
|
|
1700
|
+
const handleSortChange = React20__namespace.useCallback(
|
|
1701
|
+
(next) => {
|
|
1702
|
+
if (onSortChange) onSortChange(next);
|
|
1703
|
+
else setInternalSort(next);
|
|
1704
|
+
},
|
|
1705
|
+
[onSortChange]
|
|
1706
|
+
);
|
|
1707
|
+
const handleSearchChange = React20__namespace.useCallback(
|
|
1708
|
+
(value) => {
|
|
1709
|
+
if (onSearchChange) onSearchChange(value);
|
|
1710
|
+
else setInternalSearchValue(value);
|
|
1711
|
+
if (onPageChange) onPageChange(0);
|
|
1712
|
+
else setInternalPage(0);
|
|
1713
|
+
},
|
|
1714
|
+
[onSearchChange, onPageChange]
|
|
1715
|
+
);
|
|
1716
|
+
const handlePageChange = React20__namespace.useCallback(
|
|
1717
|
+
(p) => {
|
|
1718
|
+
if (onPageChange) onPageChange(p);
|
|
1719
|
+
else setInternalPage(p);
|
|
1720
|
+
},
|
|
1721
|
+
[onPageChange]
|
|
1722
|
+
);
|
|
1723
|
+
const handlePageSizeChange = React20__namespace.useCallback(
|
|
1724
|
+
(size) => {
|
|
1725
|
+
if (onPageSizeChange) onPageSizeChange(size);
|
|
1726
|
+
else setInternalPageSize(size);
|
|
1727
|
+
if (onPageChange) onPageChange(0);
|
|
1728
|
+
else setInternalPage(0);
|
|
1729
|
+
},
|
|
1730
|
+
[onPageSizeChange, onPageChange]
|
|
1731
|
+
);
|
|
1732
|
+
const handleSelectionChange = React20__namespace.useCallback(
|
|
1733
|
+
(keys) => {
|
|
1734
|
+
if (onSelectedRowsChange) onSelectedRowsChange(keys);
|
|
1735
|
+
else setInternalSelectedRows(keys);
|
|
1736
|
+
},
|
|
1737
|
+
[onSelectedRowsChange]
|
|
1738
|
+
);
|
|
1739
|
+
const handleHeaderClick = React20__namespace.useCallback(
|
|
1740
|
+
(colKey) => {
|
|
1741
|
+
if (sort?.key === colKey) {
|
|
1742
|
+
if (sort.direction === "asc") {
|
|
1743
|
+
handleSortChange({ key: colKey, direction: "desc" });
|
|
1744
|
+
} else {
|
|
1745
|
+
handleSortChange(null);
|
|
1746
|
+
}
|
|
1747
|
+
} else {
|
|
1748
|
+
handleSortChange({ key: colKey, direction: "asc" });
|
|
1749
|
+
}
|
|
1750
|
+
},
|
|
1751
|
+
[sort, handleSortChange]
|
|
1752
|
+
);
|
|
1753
|
+
const searchedData = React20__namespace.useMemo(() => {
|
|
1754
|
+
if (!searchable || !searchQuery) return data;
|
|
1755
|
+
if (searchFn) return data.filter((row) => searchFn(row, searchQuery));
|
|
1756
|
+
return data.filter((row) => defaultSearch(row, searchQuery, columns));
|
|
1757
|
+
}, [data, searchable, searchQuery, searchFn, columns]);
|
|
1758
|
+
const sortedData = React20__namespace.useMemo(() => {
|
|
1759
|
+
if (!sort) return searchedData;
|
|
1760
|
+
const col = columns.find((c) => c.key === sort.key);
|
|
1761
|
+
if (!col) return searchedData;
|
|
1762
|
+
return [...searchedData].sort(
|
|
1763
|
+
(a, b) => defaultSortComparator(a, b, col, sort.direction)
|
|
1764
|
+
);
|
|
1765
|
+
}, [searchedData, sort, columns]);
|
|
1766
|
+
const pinnedSet = React20__namespace.useMemo(() => new Set(pinnedRows), [pinnedRows]);
|
|
1767
|
+
const { pinnedData, unpinnedData } = React20__namespace.useMemo(() => {
|
|
1768
|
+
if (pinnedSet.size === 0) return { pinnedData: [], unpinnedData: sortedData };
|
|
1769
|
+
const pinned = [];
|
|
1770
|
+
const unpinned = [];
|
|
1771
|
+
const dataByKey = /* @__PURE__ */ new Map();
|
|
1772
|
+
data.forEach((row, i) => {
|
|
1773
|
+
dataByKey.set(getRowKey(row, i), row);
|
|
1774
|
+
});
|
|
1775
|
+
pinnedRows.forEach((key) => {
|
|
1776
|
+
const row = dataByKey.get(key);
|
|
1777
|
+
if (row) pinned.push(row);
|
|
1778
|
+
});
|
|
1779
|
+
sortedData.forEach((row, i) => {
|
|
1780
|
+
const key = getRowKey(row, i);
|
|
1781
|
+
if (!pinnedSet.has(key)) unpinned.push(row);
|
|
1782
|
+
});
|
|
1783
|
+
return { pinnedData: pinned, unpinnedData: unpinned };
|
|
1784
|
+
}, [sortedData, pinnedSet, pinnedRows, data, getRowKey]);
|
|
1785
|
+
const totalUnpinned = unpinnedData.length;
|
|
1786
|
+
const totalPages = pageSize ? Math.max(1, Math.ceil(totalUnpinned / pageSize)) : 1;
|
|
1787
|
+
const paginatedData = React20__namespace.useMemo(() => {
|
|
1788
|
+
if (!pageSize) return unpinnedData;
|
|
1789
|
+
const start = page * pageSize;
|
|
1790
|
+
return unpinnedData.slice(start, start + pageSize);
|
|
1791
|
+
}, [unpinnedData, pageSize, page]);
|
|
1792
|
+
const visibleRows = React20__namespace.useMemo(
|
|
1793
|
+
() => [...pinnedData, ...paginatedData],
|
|
1794
|
+
[pinnedData, paginatedData]
|
|
1795
|
+
);
|
|
1796
|
+
const totalItems = searchedData.length;
|
|
1797
|
+
const visibleKeys = React20__namespace.useMemo(
|
|
1798
|
+
() => visibleRows.map((row, i) => getRowKey(row, i)),
|
|
1799
|
+
[visibleRows, getRowKey]
|
|
1800
|
+
);
|
|
1801
|
+
const allVisibleSelected = visibleKeys.length > 0 && visibleKeys.every((k) => selectedRowKeys.includes(k));
|
|
1802
|
+
const someVisibleSelected = !allVisibleSelected && visibleKeys.some((k) => selectedRowKeys.includes(k));
|
|
1803
|
+
const toggleRowSelection = React20__namespace.useCallback(
|
|
1804
|
+
(key) => {
|
|
1805
|
+
const isSelected = selectedRowKeys.includes(key);
|
|
1806
|
+
const next = isSelected ? selectedRowKeys.filter((k) => k !== key) : [...selectedRowKeys, key];
|
|
1807
|
+
handleSelectionChange(next);
|
|
1808
|
+
},
|
|
1809
|
+
[selectedRowKeys, handleSelectionChange]
|
|
1810
|
+
);
|
|
1811
|
+
const toggleAllVisible = React20__namespace.useCallback(() => {
|
|
1812
|
+
if (allVisibleSelected) {
|
|
1813
|
+
const visibleSet = new Set(visibleKeys);
|
|
1814
|
+
handleSelectionChange(selectedRowKeys.filter((k) => !visibleSet.has(k)));
|
|
1815
|
+
} else {
|
|
1816
|
+
const merged = /* @__PURE__ */ new Set([...selectedRowKeys, ...visibleKeys]);
|
|
1817
|
+
handleSelectionChange(Array.from(merged));
|
|
1818
|
+
}
|
|
1819
|
+
}, [allVisibleSelected, visibleKeys, selectedRowKeys, handleSelectionChange]);
|
|
1820
|
+
const handleRowClick = React20__namespace.useCallback(
|
|
1821
|
+
(row, index, key) => {
|
|
1822
|
+
if (selectable === "highlight") {
|
|
1823
|
+
toggleRowSelection(key);
|
|
1824
|
+
}
|
|
1825
|
+
onRowClick?.(row, index);
|
|
1826
|
+
},
|
|
1827
|
+
[selectable, toggleRowSelection, onRowClick]
|
|
1828
|
+
);
|
|
1829
|
+
const renderCellContent = (row, col, rowIndex) => {
|
|
1830
|
+
if (col.cell) return col.cell(row, rowIndex);
|
|
1831
|
+
const val = getCellRawValue(row, col);
|
|
1832
|
+
if (val == null) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground italic", children: "--" });
|
|
1833
|
+
return String(val);
|
|
1834
|
+
};
|
|
1835
|
+
const alignClass = (align) => {
|
|
1836
|
+
if (align === "center") return "text-center";
|
|
1837
|
+
if (align === "right") return "text-right";
|
|
1838
|
+
return "text-left";
|
|
1839
|
+
};
|
|
1840
|
+
if (loading) {
|
|
1841
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex items-center justify-center py-16", className), children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, { label: "Loading", showDots: true }) });
|
|
1842
|
+
}
|
|
1843
|
+
const showSearch = searchable;
|
|
1844
|
+
const showPagination = pageSize != null;
|
|
1845
|
+
const showCheckboxColumn = selectable === "checkbox";
|
|
1846
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col w-full", className), children: [
|
|
1847
|
+
(showSearch || toolbar) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 pb-4", children: [
|
|
1848
|
+
showSearch && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1 max-w-sm", children: [
|
|
1849
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
|
|
1850
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1851
|
+
Input,
|
|
1852
|
+
{
|
|
1853
|
+
type: "text",
|
|
1854
|
+
placeholder: searchPlaceholder,
|
|
1855
|
+
value: searchQuery,
|
|
1856
|
+
onChange: (e) => handleSearchChange(e.target.value),
|
|
1857
|
+
className: "pl-9"
|
|
1858
|
+
}
|
|
1859
|
+
)
|
|
1860
|
+
] }),
|
|
1861
|
+
toolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: toolbar })
|
|
1862
|
+
] }),
|
|
1863
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
1864
|
+
caption && /* @__PURE__ */ jsxRuntime.jsx(TableCaption, { children: caption }),
|
|
1865
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
1866
|
+
showCheckboxColumn && /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-[40px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
|
+
Checkbox,
|
|
1868
|
+
{
|
|
1869
|
+
checked: allVisibleSelected ? true : someVisibleSelected ? "indeterminate" : false,
|
|
1870
|
+
onCheckedChange: () => toggleAllVisible(),
|
|
1871
|
+
"aria-label": "Select all"
|
|
1872
|
+
}
|
|
1873
|
+
) }),
|
|
1874
|
+
columns.map((col) => {
|
|
1875
|
+
const isSorted = sort?.key === col.key;
|
|
1876
|
+
const sortDir = isSorted ? sort.direction : null;
|
|
1877
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1878
|
+
TableHead,
|
|
1879
|
+
{
|
|
1880
|
+
className: cn(
|
|
1881
|
+
col.width,
|
|
1882
|
+
col.headerClassName,
|
|
1883
|
+
alignClass(col.align),
|
|
1884
|
+
col.sortable && "cursor-pointer select-none"
|
|
1885
|
+
),
|
|
1886
|
+
onClick: col.sortable ? () => handleHeaderClick(col.key) : void 0,
|
|
1887
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1888
|
+
"div",
|
|
1889
|
+
{
|
|
1890
|
+
className: cn(
|
|
1891
|
+
"flex items-center gap-1",
|
|
1892
|
+
col.align === "center" && "justify-center",
|
|
1893
|
+
col.align === "right" && "justify-end"
|
|
1894
|
+
),
|
|
1895
|
+
children: [
|
|
1896
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: col.header }),
|
|
1897
|
+
col.sortable && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex ml-1", children: sortDir === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-3.5 w-3.5" }) : sortDir === "desc" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpDown, { className: "h-3.5 w-3.5 opacity-40" }) })
|
|
1898
|
+
]
|
|
1899
|
+
}
|
|
1900
|
+
)
|
|
1901
|
+
},
|
|
1902
|
+
col.key
|
|
1903
|
+
);
|
|
1904
|
+
})
|
|
1905
|
+
] }) }),
|
|
1906
|
+
pinnedData.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(TableBody, { className: "bg-muted/30 border-b-2 border-border", children: pinnedData.map((row, i) => {
|
|
1907
|
+
const key = getRowKey(row, i);
|
|
1908
|
+
const isSelected = selectedRowKeys.includes(key);
|
|
1909
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1910
|
+
TableRow,
|
|
1911
|
+
{
|
|
1912
|
+
"data-state": isSelected ? "selected" : void 0,
|
|
1913
|
+
className: cn(
|
|
1914
|
+
(onRowClick || selectable === "highlight") && "cursor-pointer",
|
|
1915
|
+
rowClassName?.(row, i)
|
|
1916
|
+
),
|
|
1917
|
+
onClick: () => handleRowClick(row, i, key),
|
|
1918
|
+
children: [
|
|
1919
|
+
showCheckboxColumn && /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "w-[40px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1920
|
+
Checkbox,
|
|
1921
|
+
{
|
|
1922
|
+
checked: isSelected,
|
|
1923
|
+
onCheckedChange: () => toggleRowSelection(key),
|
|
1924
|
+
onClick: (e) => e.stopPropagation(),
|
|
1925
|
+
"aria-label": "Select row"
|
|
1926
|
+
}
|
|
1927
|
+
) }),
|
|
1928
|
+
columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1929
|
+
TableCell,
|
|
1930
|
+
{
|
|
1931
|
+
className: cn(alignClass(col.align), col.className),
|
|
1932
|
+
children: renderCellContent(row, col, i)
|
|
1933
|
+
},
|
|
1934
|
+
col.key
|
|
1935
|
+
))
|
|
1936
|
+
]
|
|
1937
|
+
},
|
|
1938
|
+
key
|
|
1939
|
+
);
|
|
1940
|
+
}) }),
|
|
1941
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: paginatedData.length === 0 && pinnedData.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1942
|
+
TableCell,
|
|
1943
|
+
{
|
|
1944
|
+
colSpan: columns.length + (showCheckboxColumn ? 1 : 0),
|
|
1945
|
+
className: "h-24 text-center",
|
|
1946
|
+
children: emptyState ?? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "No results." })
|
|
1947
|
+
}
|
|
1948
|
+
) }) : paginatedData.map((row, i) => {
|
|
1949
|
+
const globalIndex = pageSize ? page * pageSize + i : i;
|
|
1950
|
+
const key = getRowKey(row, globalIndex);
|
|
1951
|
+
const isSelected = selectedRowKeys.includes(key);
|
|
1952
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1953
|
+
TableRow,
|
|
1954
|
+
{
|
|
1955
|
+
"data-state": isSelected ? "selected" : void 0,
|
|
1956
|
+
className: cn(
|
|
1957
|
+
(onRowClick || selectable === "highlight") && "cursor-pointer",
|
|
1958
|
+
rowClassName?.(row, globalIndex)
|
|
1959
|
+
),
|
|
1960
|
+
onClick: () => handleRowClick(row, globalIndex, key),
|
|
1961
|
+
children: [
|
|
1962
|
+
showCheckboxColumn && /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "w-[40px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1963
|
+
Checkbox,
|
|
1964
|
+
{
|
|
1965
|
+
checked: isSelected,
|
|
1966
|
+
onCheckedChange: () => toggleRowSelection(key),
|
|
1967
|
+
onClick: (e) => e.stopPropagation(),
|
|
1968
|
+
"aria-label": "Select row"
|
|
1969
|
+
}
|
|
1970
|
+
) }),
|
|
1971
|
+
columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1972
|
+
TableCell,
|
|
1973
|
+
{
|
|
1974
|
+
className: cn(alignClass(col.align), col.className),
|
|
1975
|
+
children: renderCellContent(row, col, globalIndex)
|
|
1976
|
+
},
|
|
1977
|
+
col.key
|
|
1978
|
+
))
|
|
1979
|
+
]
|
|
1980
|
+
},
|
|
1981
|
+
key
|
|
1982
|
+
);
|
|
1983
|
+
}) })
|
|
1984
|
+
] }),
|
|
1985
|
+
showPagination && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between pt-4", children: [
|
|
1986
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1987
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Rows per page" }),
|
|
1988
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1989
|
+
Select,
|
|
1990
|
+
{
|
|
1991
|
+
value: String(pageSize),
|
|
1992
|
+
onValueChange: (val) => handlePageSizeChange(Number(val)),
|
|
1993
|
+
children: [
|
|
1994
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 w-[70px]", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: String(pageSize) }) }),
|
|
1995
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: pageSizeOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(opt), children: opt }, opt)) })
|
|
1996
|
+
]
|
|
1997
|
+
}
|
|
1998
|
+
)
|
|
1999
|
+
] }),
|
|
2000
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
2001
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground", children: [
|
|
2002
|
+
"Page ",
|
|
2003
|
+
page + 1,
|
|
2004
|
+
" of ",
|
|
2005
|
+
totalPages,
|
|
2006
|
+
` (${totalItems} total)`
|
|
2007
|
+
] }),
|
|
2008
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2009
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2010
|
+
Button,
|
|
2011
|
+
{
|
|
2012
|
+
variant: "ghost",
|
|
2013
|
+
size: "icon",
|
|
2014
|
+
className: "h-8 w-8",
|
|
2015
|
+
onClick: () => handlePageChange(0),
|
|
2016
|
+
disabled: page === 0,
|
|
2017
|
+
"aria-label": "First page",
|
|
2018
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "h-4 w-4" })
|
|
2019
|
+
}
|
|
2020
|
+
),
|
|
2021
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2022
|
+
Button,
|
|
2023
|
+
{
|
|
2024
|
+
variant: "ghost",
|
|
2025
|
+
size: "icon",
|
|
2026
|
+
className: "h-8 w-8",
|
|
2027
|
+
onClick: () => handlePageChange(page - 1),
|
|
2028
|
+
disabled: page === 0,
|
|
2029
|
+
"aria-label": "Previous page",
|
|
2030
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" })
|
|
2031
|
+
}
|
|
2032
|
+
),
|
|
2033
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2034
|
+
Button,
|
|
2035
|
+
{
|
|
2036
|
+
variant: "ghost",
|
|
2037
|
+
size: "icon",
|
|
2038
|
+
className: "h-8 w-8",
|
|
2039
|
+
onClick: () => handlePageChange(page + 1),
|
|
2040
|
+
disabled: page >= totalPages - 1,
|
|
2041
|
+
"aria-label": "Next page",
|
|
2042
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" })
|
|
2043
|
+
}
|
|
2044
|
+
),
|
|
2045
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2046
|
+
Button,
|
|
2047
|
+
{
|
|
2048
|
+
variant: "ghost",
|
|
2049
|
+
size: "icon",
|
|
2050
|
+
className: "h-8 w-8",
|
|
2051
|
+
onClick: () => handlePageChange(totalPages - 1),
|
|
2052
|
+
disabled: page >= totalPages - 1,
|
|
2053
|
+
"aria-label": "Last page",
|
|
2054
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsRight, { className: "h-4 w-4" })
|
|
2055
|
+
}
|
|
2056
|
+
)
|
|
2057
|
+
] })
|
|
2058
|
+
] })
|
|
2059
|
+
] })
|
|
2060
|
+
] });
|
|
2061
|
+
}
|
|
2062
|
+
DataTable.displayName = "DataTable";
|
|
1551
2063
|
function Modal({
|
|
1552
2064
|
isOpen,
|
|
1553
2065
|
onClose,
|
|
@@ -1558,7 +2070,7 @@ function Modal({
|
|
|
1558
2070
|
zIndex = 50,
|
|
1559
2071
|
className
|
|
1560
2072
|
}) {
|
|
1561
|
-
|
|
2073
|
+
React20__namespace.useEffect(() => {
|
|
1562
2074
|
if (!isOpen) return;
|
|
1563
2075
|
const handleEscape = (e) => {
|
|
1564
2076
|
if (e.key === "Escape") {
|
|
@@ -1568,7 +2080,7 @@ function Modal({
|
|
|
1568
2080
|
window.addEventListener("keydown", handleEscape);
|
|
1569
2081
|
return () => window.removeEventListener("keydown", handleEscape);
|
|
1570
2082
|
}, [isOpen, onClose]);
|
|
1571
|
-
|
|
2083
|
+
React20__namespace.useEffect(() => {
|
|
1572
2084
|
if (isOpen) {
|
|
1573
2085
|
document.body.style.overflow = "hidden";
|
|
1574
2086
|
} else {
|
|
@@ -1683,12 +2195,12 @@ function ConfirmationModal({
|
|
|
1683
2195
|
] }) });
|
|
1684
2196
|
}
|
|
1685
2197
|
function useConfirmation() {
|
|
1686
|
-
const [state, setState] =
|
|
2198
|
+
const [state, setState] = React20__namespace.useState({
|
|
1687
2199
|
open: false,
|
|
1688
2200
|
title: "",
|
|
1689
2201
|
description: ""
|
|
1690
2202
|
});
|
|
1691
|
-
const confirm =
|
|
2203
|
+
const confirm = React20__namespace.useCallback(
|
|
1692
2204
|
(options) => {
|
|
1693
2205
|
return new Promise((resolve) => {
|
|
1694
2206
|
setState({
|
|
@@ -1700,15 +2212,15 @@ function useConfirmation() {
|
|
|
1700
2212
|
},
|
|
1701
2213
|
[]
|
|
1702
2214
|
);
|
|
1703
|
-
const handleConfirm =
|
|
2215
|
+
const handleConfirm = React20__namespace.useCallback(() => {
|
|
1704
2216
|
state.resolve?.(true);
|
|
1705
2217
|
setState((prev) => ({ ...prev, open: false }));
|
|
1706
2218
|
}, [state.resolve]);
|
|
1707
|
-
const handleCancel =
|
|
2219
|
+
const handleCancel = React20__namespace.useCallback(() => {
|
|
1708
2220
|
state.resolve?.(false);
|
|
1709
2221
|
setState((prev) => ({ ...prev, open: false }));
|
|
1710
2222
|
}, [state.resolve]);
|
|
1711
|
-
const handleOpenChange =
|
|
2223
|
+
const handleOpenChange = React20__namespace.useCallback(
|
|
1712
2224
|
(open) => {
|
|
1713
2225
|
if (!open) {
|
|
1714
2226
|
state.resolve?.(false);
|
|
@@ -1744,11 +2256,11 @@ function ResizeHandle({
|
|
|
1744
2256
|
ariaLabel,
|
|
1745
2257
|
className
|
|
1746
2258
|
}) {
|
|
1747
|
-
const [isDragging, setIsDragging] =
|
|
1748
|
-
const [isFocused, setIsFocused] =
|
|
1749
|
-
const startXRef =
|
|
1750
|
-
const handleRef =
|
|
1751
|
-
const handleMouseDown =
|
|
2259
|
+
const [isDragging, setIsDragging] = React20__namespace.useState(false);
|
|
2260
|
+
const [isFocused, setIsFocused] = React20__namespace.useState(false);
|
|
2261
|
+
const startXRef = React20__namespace.useRef(0);
|
|
2262
|
+
const handleRef = React20__namespace.useRef(null);
|
|
2263
|
+
const handleMouseDown = React20__namespace.useCallback(
|
|
1752
2264
|
(e) => {
|
|
1753
2265
|
if (!resizable) return;
|
|
1754
2266
|
e.preventDefault();
|
|
@@ -1759,7 +2271,7 @@ function ResizeHandle({
|
|
|
1759
2271
|
},
|
|
1760
2272
|
[resizable, onDragStart]
|
|
1761
2273
|
);
|
|
1762
|
-
const handleMouseMove =
|
|
2274
|
+
const handleMouseMove = React20__namespace.useCallback(
|
|
1763
2275
|
(e) => {
|
|
1764
2276
|
if (!isDragging) return;
|
|
1765
2277
|
const deltaX = e.clientX - startXRef.current;
|
|
@@ -1768,13 +2280,13 @@ function ResizeHandle({
|
|
|
1768
2280
|
},
|
|
1769
2281
|
[isDragging, onDrag]
|
|
1770
2282
|
);
|
|
1771
|
-
const handleMouseUp =
|
|
2283
|
+
const handleMouseUp = React20__namespace.useCallback(() => {
|
|
1772
2284
|
if (!isDragging) return;
|
|
1773
2285
|
setIsDragging(false);
|
|
1774
2286
|
document.body.style.userSelect = "";
|
|
1775
2287
|
onDragEnd?.();
|
|
1776
2288
|
}, [isDragging, onDragEnd]);
|
|
1777
|
-
const handleKeyDown =
|
|
2289
|
+
const handleKeyDown = React20__namespace.useCallback(
|
|
1778
2290
|
(e) => {
|
|
1779
2291
|
if (!resizable || !onKeyboardResize) return;
|
|
1780
2292
|
let direction = null;
|
|
@@ -1793,7 +2305,7 @@ function ResizeHandle({
|
|
|
1793
2305
|
},
|
|
1794
2306
|
[resizable, onKeyboardResize, orientation]
|
|
1795
2307
|
);
|
|
1796
|
-
|
|
2308
|
+
React20__namespace.useEffect(() => {
|
|
1797
2309
|
if (isDragging) {
|
|
1798
2310
|
window.addEventListener("mousemove", handleMouseMove);
|
|
1799
2311
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -1863,12 +2375,12 @@ function ResizablePanel({
|
|
|
1863
2375
|
className,
|
|
1864
2376
|
dataAttributes = {}
|
|
1865
2377
|
}) {
|
|
1866
|
-
const panelRef =
|
|
1867
|
-
const [isDragging, setIsDragging] =
|
|
1868
|
-
const [localWidth, setLocalWidth] =
|
|
1869
|
-
const [localOuterWidth, setLocalOuterWidth] =
|
|
2378
|
+
const panelRef = React20__namespace.useRef(null);
|
|
2379
|
+
const [isDragging, setIsDragging] = React20__namespace.useState(false);
|
|
2380
|
+
const [localWidth, setLocalWidth] = React20__namespace.useState(null);
|
|
2381
|
+
const [localOuterWidth, setLocalOuterWidth] = React20__namespace.useState(null);
|
|
1870
2382
|
const currentWidthVW = isExpanded ? (isDragging && localWidth !== null ? localWidth : expandedWidthVW) || collapsedSizeVW : collapsedSizeVW;
|
|
1871
|
-
const clampWidth =
|
|
2383
|
+
const clampWidth = React20__namespace.useCallback(
|
|
1872
2384
|
(width) => {
|
|
1873
2385
|
let effectiveMinWidth = minWidthVW;
|
|
1874
2386
|
let effectiveMaxWidth = maxWidthVW;
|
|
@@ -1881,11 +2393,11 @@ function ResizablePanel({
|
|
|
1881
2393
|
},
|
|
1882
2394
|
[minWidthVW, maxWidthVW, orientation, leftWidthVW, isOverlay]
|
|
1883
2395
|
);
|
|
1884
|
-
const handleDragStart =
|
|
2396
|
+
const handleDragStart = React20__namespace.useCallback(() => {
|
|
1885
2397
|
setIsDragging(true);
|
|
1886
2398
|
setLocalWidth(currentWidthVW);
|
|
1887
2399
|
}, [currentWidthVW]);
|
|
1888
|
-
const handleDrag =
|
|
2400
|
+
const handleDrag = React20__namespace.useCallback(
|
|
1889
2401
|
(deltaX) => {
|
|
1890
2402
|
if (!isExpanded || isOverlay) return;
|
|
1891
2403
|
const viewportWidth = window.innerWidth;
|
|
@@ -1904,14 +2416,14 @@ function ResizablePanel({
|
|
|
1904
2416
|
clampWidth
|
|
1905
2417
|
]
|
|
1906
2418
|
);
|
|
1907
|
-
const handleDragEnd =
|
|
2419
|
+
const handleDragEnd = React20__namespace.useCallback(() => {
|
|
1908
2420
|
if (localWidth !== null && onResize) {
|
|
1909
2421
|
onResize(localWidth);
|
|
1910
2422
|
}
|
|
1911
2423
|
setIsDragging(false);
|
|
1912
2424
|
setLocalWidth(null);
|
|
1913
2425
|
}, [localWidth, onResize]);
|
|
1914
|
-
const handleKeyboardResize =
|
|
2426
|
+
const handleKeyboardResize = React20__namespace.useCallback(
|
|
1915
2427
|
(direction) => {
|
|
1916
2428
|
if (!isExpanded || isOverlay || !onResize) return;
|
|
1917
2429
|
const step = 1;
|
|
@@ -1920,13 +2432,13 @@ function ResizablePanel({
|
|
|
1920
2432
|
},
|
|
1921
2433
|
[isExpanded, isOverlay, onResize, currentWidthVW, clampWidth]
|
|
1922
2434
|
);
|
|
1923
|
-
const handleOverlayDragStart =
|
|
2435
|
+
const handleOverlayDragStart = React20__namespace.useCallback(() => {
|
|
1924
2436
|
if (outerWidthVW) {
|
|
1925
2437
|
setIsDragging(true);
|
|
1926
2438
|
setLocalOuterWidth(outerWidthVW);
|
|
1927
2439
|
}
|
|
1928
2440
|
}, [outerWidthVW]);
|
|
1929
|
-
const handleOverlayDrag =
|
|
2441
|
+
const handleOverlayDrag = React20__namespace.useCallback(
|
|
1930
2442
|
(deltaX) => {
|
|
1931
2443
|
if (!isOverlay) return;
|
|
1932
2444
|
const viewportWidth = window.innerWidth;
|
|
@@ -1937,14 +2449,14 @@ function ResizablePanel({
|
|
|
1937
2449
|
},
|
|
1938
2450
|
[isOverlay, localOuterWidth, outerWidthVW]
|
|
1939
2451
|
);
|
|
1940
|
-
const handleOverlayDragEnd =
|
|
2452
|
+
const handleOverlayDragEnd = React20__namespace.useCallback(() => {
|
|
1941
2453
|
if (localOuterWidth !== null && onResizeOverlay) {
|
|
1942
2454
|
onResizeOverlay(localOuterWidth);
|
|
1943
2455
|
}
|
|
1944
2456
|
setIsDragging(false);
|
|
1945
2457
|
setLocalOuterWidth(null);
|
|
1946
2458
|
}, [localOuterWidth, onResizeOverlay]);
|
|
1947
|
-
|
|
2459
|
+
React20__namespace.useEffect(() => {
|
|
1948
2460
|
if (isOverlay && panelRef.current) {
|
|
1949
2461
|
const focusableElement = panelRef.current.querySelector(
|
|
1950
2462
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
@@ -1952,7 +2464,7 @@ function ResizablePanel({
|
|
|
1952
2464
|
focusableElement?.focus();
|
|
1953
2465
|
}
|
|
1954
2466
|
}, [isOverlay]);
|
|
1955
|
-
|
|
2467
|
+
React20__namespace.useEffect(() => {
|
|
1956
2468
|
if (!isOverlay) return;
|
|
1957
2469
|
const handleEscape = (e) => {
|
|
1958
2470
|
if (e.key === "Escape") {
|
|
@@ -2138,74 +2650,6 @@ function Chip({
|
|
|
2138
2650
|
}
|
|
2139
2651
|
);
|
|
2140
2652
|
}
|
|
2141
|
-
var loadingSpinnerVariants = classVarianceAuthority.cva("rounded-full animate-spin border-current", {
|
|
2142
|
-
variants: {
|
|
2143
|
-
/**
|
|
2144
|
-
* Size of the spinner
|
|
2145
|
-
*/
|
|
2146
|
-
size: {
|
|
2147
|
-
sm: "w-4 h-4 border-2",
|
|
2148
|
-
default: "w-8 h-8 border-2",
|
|
2149
|
-
lg: "w-12 h-12 border-[3px]",
|
|
2150
|
-
xl: "w-16 h-16 border-4"
|
|
2151
|
-
},
|
|
2152
|
-
/**
|
|
2153
|
-
* Visual variant
|
|
2154
|
-
*/
|
|
2155
|
-
variant: {
|
|
2156
|
-
/** Primary color spinner (default) */
|
|
2157
|
-
default: "border-primary/20 border-t-primary",
|
|
2158
|
-
/** Accent color spinner */
|
|
2159
|
-
accent: "border-accent/20 border-t-accent",
|
|
2160
|
-
/** Muted/subtle spinner */
|
|
2161
|
-
muted: "border-muted-foreground/20 border-t-muted-foreground",
|
|
2162
|
-
/** Inherits current text color */
|
|
2163
|
-
inherit: "border-current/20 border-t-current"
|
|
2164
|
-
}
|
|
2165
|
-
},
|
|
2166
|
-
defaultVariants: {
|
|
2167
|
-
size: "default",
|
|
2168
|
-
variant: "default"
|
|
2169
|
-
}
|
|
2170
|
-
});
|
|
2171
|
-
var LoadingSpinner = React34__namespace.forwardRef(
|
|
2172
|
-
({ className, size, variant, label, showDots = false, ...props }, ref) => {
|
|
2173
|
-
const [dots, setDots] = React34__namespace.useState("");
|
|
2174
|
-
React34__namespace.useEffect(() => {
|
|
2175
|
-
if (!showDots || !label) return;
|
|
2176
|
-
const interval = setInterval(() => {
|
|
2177
|
-
setDots((prev) => prev.length >= 3 ? "" : prev + ".");
|
|
2178
|
-
}, 500);
|
|
2179
|
-
return () => clearInterval(interval);
|
|
2180
|
-
}, [showDots, label]);
|
|
2181
|
-
if (label) {
|
|
2182
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2183
|
-
"div",
|
|
2184
|
-
{
|
|
2185
|
-
ref,
|
|
2186
|
-
className: cn("flex flex-col items-center gap-3", className),
|
|
2187
|
-
...props,
|
|
2188
|
-
children: [
|
|
2189
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: loadingSpinnerVariants({ size, variant }) }),
|
|
2190
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
2191
|
-
label,
|
|
2192
|
-
showDots && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-4", children: dots })
|
|
2193
|
-
] })
|
|
2194
|
-
]
|
|
2195
|
-
}
|
|
2196
|
-
);
|
|
2197
|
-
}
|
|
2198
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2199
|
-
"div",
|
|
2200
|
-
{
|
|
2201
|
-
ref,
|
|
2202
|
-
className: cn(loadingSpinnerVariants({ size, variant }), className),
|
|
2203
|
-
...props
|
|
2204
|
-
}
|
|
2205
|
-
);
|
|
2206
|
-
}
|
|
2207
|
-
);
|
|
2208
|
-
LoadingSpinner.displayName = "LoadingSpinner";
|
|
2209
2653
|
function Toaster({
|
|
2210
2654
|
position = "top-right",
|
|
2211
2655
|
expand = false,
|
|
@@ -2268,12 +2712,12 @@ function Calendar({
|
|
|
2268
2712
|
const endMonth = props.endMonth ?? props.toDate;
|
|
2269
2713
|
const fromYear = startMonth?.getFullYear();
|
|
2270
2714
|
const toYear = endMonth?.getFullYear();
|
|
2271
|
-
const years =
|
|
2272
|
-
const [internalMonth, setInternalMonth] =
|
|
2715
|
+
const years = React20__namespace.useMemo(() => getYearRange(fromYear, toYear), [fromYear, toYear]);
|
|
2716
|
+
const [internalMonth, setInternalMonth] = React20__namespace.useState(
|
|
2273
2717
|
defaultMonth ?? /* @__PURE__ */ new Date()
|
|
2274
2718
|
);
|
|
2275
2719
|
const displayedMonth = controlledMonth ?? internalMonth;
|
|
2276
|
-
const handleMonthChange =
|
|
2720
|
+
const handleMonthChange = React20__namespace.useCallback(
|
|
2277
2721
|
(newMonth) => {
|
|
2278
2722
|
if (controlledMonth === void 0) {
|
|
2279
2723
|
setInternalMonth(newMonth);
|
|
@@ -2404,8 +2848,8 @@ function DatePicker({
|
|
|
2404
2848
|
matchTriggerWidth = false,
|
|
2405
2849
|
onOpenChange
|
|
2406
2850
|
}) {
|
|
2407
|
-
const [open, setOpen] =
|
|
2408
|
-
const [internalValue, setInternalValue] =
|
|
2851
|
+
const [open, setOpen] = React20__namespace.useState(false);
|
|
2852
|
+
const [internalValue, setInternalValue] = React20__namespace.useState(
|
|
2409
2853
|
defaultValue
|
|
2410
2854
|
);
|
|
2411
2855
|
const isControlled = value !== void 0;
|
|
@@ -2507,15 +2951,15 @@ function DatePickerInput({
|
|
|
2507
2951
|
onOpenChange,
|
|
2508
2952
|
size = "default"
|
|
2509
2953
|
}) {
|
|
2510
|
-
const [open, setOpen] =
|
|
2511
|
-
const [internalValue, setInternalValue] =
|
|
2954
|
+
const [open, setOpen] = React20__namespace.useState(false);
|
|
2955
|
+
const [internalValue, setInternalValue] = React20__namespace.useState(
|
|
2512
2956
|
defaultValue
|
|
2513
2957
|
);
|
|
2514
|
-
const [inputValue, setInputValue] =
|
|
2515
|
-
const inputRef =
|
|
2958
|
+
const [inputValue, setInputValue] = React20__namespace.useState("");
|
|
2959
|
+
const inputRef = React20__namespace.useRef(null);
|
|
2516
2960
|
const isControlled = value !== void 0;
|
|
2517
2961
|
const selectedDate = isControlled ? value : internalValue;
|
|
2518
|
-
|
|
2962
|
+
React20__namespace.useEffect(() => {
|
|
2519
2963
|
if (selectedDate) {
|
|
2520
2964
|
setInputValue(dateFns.format(selectedDate, dateFormat));
|
|
2521
2965
|
} else {
|
|
@@ -2676,11 +3120,11 @@ function FilterPopover({
|
|
|
2676
3120
|
onFilterChange
|
|
2677
3121
|
}) {
|
|
2678
3122
|
const filterType = column.filterType || "text";
|
|
2679
|
-
const [operator, setOperator] =
|
|
3123
|
+
const [operator, setOperator] = React20__namespace.useState(
|
|
2680
3124
|
filter?.operator || getDefaultOperator(filterType)
|
|
2681
3125
|
);
|
|
2682
|
-
const [value, setValue] =
|
|
2683
|
-
const [valueTo, setValueTo] =
|
|
3126
|
+
const [value, setValue] = React20__namespace.useState(filter?.value ?? "");
|
|
3127
|
+
const [valueTo, setValueTo] = React20__namespace.useState(filter?.valueTo ?? "");
|
|
2684
3128
|
function getDefaultOperator(type) {
|
|
2685
3129
|
switch (type) {
|
|
2686
3130
|
case "text":
|
|
@@ -2823,7 +3267,7 @@ function FilterPopover({
|
|
|
2823
3267
|
] })
|
|
2824
3268
|
] });
|
|
2825
3269
|
const renderDateFilter = () => {
|
|
2826
|
-
const dateValue =
|
|
3270
|
+
const dateValue = React20__namespace.useMemo(() => {
|
|
2827
3271
|
if (!value) return void 0;
|
|
2828
3272
|
if (value instanceof Date) return value;
|
|
2829
3273
|
if (typeof value === "string") {
|
|
@@ -2832,7 +3276,7 @@ function FilterPopover({
|
|
|
2832
3276
|
}
|
|
2833
3277
|
return void 0;
|
|
2834
3278
|
}, [value]);
|
|
2835
|
-
const dateToValue =
|
|
3279
|
+
const dateToValue = React20__namespace.useMemo(() => {
|
|
2836
3280
|
if (!valueTo) return void 0;
|
|
2837
3281
|
if (valueTo instanceof Date) return valueTo;
|
|
2838
3282
|
if (typeof valueTo === "string") {
|
|
@@ -2967,7 +3411,7 @@ function HeaderCell({
|
|
|
2967
3411
|
onResizeDoubleClick,
|
|
2968
3412
|
isResizing
|
|
2969
3413
|
}) {
|
|
2970
|
-
const [filterOpen, setFilterOpen] =
|
|
3414
|
+
const [filterOpen, setFilterOpen] = React20__namespace.useState(false);
|
|
2971
3415
|
const isSorted = sorting?.field === column.key;
|
|
2972
3416
|
const isFiltered = !!filter;
|
|
2973
3417
|
const isSortable = column.sortable && onSort;
|
|
@@ -3125,15 +3569,15 @@ function CellEditor({
|
|
|
3125
3569
|
className
|
|
3126
3570
|
}) {
|
|
3127
3571
|
const editorType = column.editorType || "text";
|
|
3128
|
-
const [internalValue, setInternalValue] =
|
|
3129
|
-
const [validationError, setValidationError] =
|
|
3572
|
+
const [internalValue, setInternalValue] = React20__namespace.useState(value);
|
|
3573
|
+
const [validationError, setValidationError] = React20__namespace.useState(
|
|
3130
3574
|
null
|
|
3131
3575
|
);
|
|
3132
|
-
const inputRef =
|
|
3133
|
-
const selectRef =
|
|
3576
|
+
const inputRef = React20__namespace.useRef(null);
|
|
3577
|
+
const selectRef = React20__namespace.useRef(null);
|
|
3134
3578
|
const currentValue = onChange ? value : internalValue;
|
|
3135
3579
|
const setValue = onChange || setInternalValue;
|
|
3136
|
-
const validate =
|
|
3580
|
+
const validate = React20__namespace.useCallback(
|
|
3137
3581
|
(val) => {
|
|
3138
3582
|
if (!column.validator) return true;
|
|
3139
3583
|
const result = column.validator(val, row);
|
|
@@ -3181,7 +3625,7 @@ function CellEditor({
|
|
|
3181
3625
|
}
|
|
3182
3626
|
handleCommit();
|
|
3183
3627
|
};
|
|
3184
|
-
|
|
3628
|
+
React20__namespace.useEffect(() => {
|
|
3185
3629
|
const timer = setTimeout(() => {
|
|
3186
3630
|
if (editorType === "select") {
|
|
3187
3631
|
selectRef.current?.focus();
|
|
@@ -3228,7 +3672,7 @@ function CellEditor({
|
|
|
3228
3672
|
}
|
|
3229
3673
|
);
|
|
3230
3674
|
const renderDateEditor = () => {
|
|
3231
|
-
const dateValue =
|
|
3675
|
+
const dateValue = React20__namespace.useMemo(() => {
|
|
3232
3676
|
if (!currentValue) return void 0;
|
|
3233
3677
|
if (currentValue instanceof Date) return currentValue;
|
|
3234
3678
|
if (typeof currentValue === "string") {
|
|
@@ -3416,7 +3860,7 @@ function useDataGridState(options) {
|
|
|
3416
3860
|
data,
|
|
3417
3861
|
getCellValue: getCellValue2
|
|
3418
3862
|
} = options;
|
|
3419
|
-
const isControlled =
|
|
3863
|
+
const isControlled = React20.useMemo(
|
|
3420
3864
|
() => ({
|
|
3421
3865
|
sorting: controlledSorting !== void 0,
|
|
3422
3866
|
filters: controlledFilters !== void 0,
|
|
@@ -3430,15 +3874,15 @@ function useDataGridState(options) {
|
|
|
3430
3874
|
controlledFocusedCell
|
|
3431
3875
|
]
|
|
3432
3876
|
);
|
|
3433
|
-
const [internalSorting, setInternalSorting] =
|
|
3434
|
-
const [internalFilters, setInternalFilters] =
|
|
3435
|
-
const [internalColumnWidths, setInternalColumnWidths] =
|
|
3436
|
-
const [internalFocusedCell, setInternalFocusedCell] =
|
|
3437
|
-
const [editingCell, setEditingCell] =
|
|
3877
|
+
const [internalSorting, setInternalSorting] = React20.useState(defaultSorting);
|
|
3878
|
+
const [internalFilters, setInternalFilters] = React20.useState(defaultFilters);
|
|
3879
|
+
const [internalColumnWidths, setInternalColumnWidths] = React20.useState(defaultColumnWidths);
|
|
3880
|
+
const [internalFocusedCell, setInternalFocusedCell] = React20.useState(null);
|
|
3881
|
+
const [editingCell, setEditingCell] = React20.useState(null);
|
|
3438
3882
|
const sorting = isControlled.sorting ? controlledSorting : internalSorting;
|
|
3439
3883
|
const filters = isControlled.filters ? controlledFilters : internalFilters;
|
|
3440
3884
|
const focusedCell = isControlled.focusedCell ? controlledFocusedCell : internalFocusedCell;
|
|
3441
|
-
const columnWidths =
|
|
3885
|
+
const columnWidths = React20.useMemo(() => {
|
|
3442
3886
|
const controlled = isControlled.columnWidths ? controlledColumnWidths : internalColumnWidths;
|
|
3443
3887
|
const result = {};
|
|
3444
3888
|
for (const column of columns) {
|
|
@@ -3446,8 +3890,8 @@ function useDataGridState(options) {
|
|
|
3446
3890
|
}
|
|
3447
3891
|
return result;
|
|
3448
3892
|
}, [isControlled.columnWidths, controlledColumnWidths, internalColumnWidths, columns]);
|
|
3449
|
-
const prevStateRef =
|
|
3450
|
-
const state =
|
|
3893
|
+
const prevStateRef = React20.useRef(null);
|
|
3894
|
+
const state = React20.useMemo(
|
|
3451
3895
|
() => ({
|
|
3452
3896
|
sorting,
|
|
3453
3897
|
filters,
|
|
@@ -3457,7 +3901,7 @@ function useDataGridState(options) {
|
|
|
3457
3901
|
}),
|
|
3458
3902
|
[sorting, filters, columnWidths, focusedCell, editingCell]
|
|
3459
3903
|
);
|
|
3460
|
-
|
|
3904
|
+
React20.useEffect(() => {
|
|
3461
3905
|
if (onStateChange) {
|
|
3462
3906
|
const currentState = {
|
|
3463
3907
|
sorting,
|
|
@@ -3472,7 +3916,7 @@ function useDataGridState(options) {
|
|
|
3472
3916
|
}
|
|
3473
3917
|
}
|
|
3474
3918
|
}, [sorting, filters, columnWidths, focusedCell, editingCell, onStateChange]);
|
|
3475
|
-
const setSorting =
|
|
3919
|
+
const setSorting = React20.useCallback(
|
|
3476
3920
|
(newSorting) => {
|
|
3477
3921
|
if (isControlled.sorting) {
|
|
3478
3922
|
onSortChange?.(newSorting);
|
|
@@ -3483,7 +3927,7 @@ function useDataGridState(options) {
|
|
|
3483
3927
|
},
|
|
3484
3928
|
[isControlled.sorting, onSortChange]
|
|
3485
3929
|
);
|
|
3486
|
-
const toggleSort =
|
|
3930
|
+
const toggleSort = React20.useCallback(
|
|
3487
3931
|
(columnKey) => {
|
|
3488
3932
|
const currentSort = sorting.find((s) => s.field === columnKey);
|
|
3489
3933
|
let newSorting;
|
|
@@ -3498,7 +3942,7 @@ function useDataGridState(options) {
|
|
|
3498
3942
|
},
|
|
3499
3943
|
[sorting, setSorting]
|
|
3500
3944
|
);
|
|
3501
|
-
const setFilters =
|
|
3945
|
+
const setFilters = React20.useCallback(
|
|
3502
3946
|
(newFilters) => {
|
|
3503
3947
|
if (isControlled.filters) {
|
|
3504
3948
|
onFilterChange?.(newFilters);
|
|
@@ -3509,7 +3953,7 @@ function useDataGridState(options) {
|
|
|
3509
3953
|
},
|
|
3510
3954
|
[isControlled.filters, onFilterChange]
|
|
3511
3955
|
);
|
|
3512
|
-
const setFilter =
|
|
3956
|
+
const setFilter = React20.useCallback(
|
|
3513
3957
|
(filter, columnKey) => {
|
|
3514
3958
|
const newFilters = filters.filter((f) => f.columnKey !== columnKey);
|
|
3515
3959
|
if (filter) {
|
|
@@ -3519,10 +3963,10 @@ function useDataGridState(options) {
|
|
|
3519
3963
|
},
|
|
3520
3964
|
[filters, setFilters]
|
|
3521
3965
|
);
|
|
3522
|
-
const clearFilters =
|
|
3966
|
+
const clearFilters = React20.useCallback(() => {
|
|
3523
3967
|
setFilters([]);
|
|
3524
3968
|
}, [setFilters]);
|
|
3525
|
-
const setColumnWidth =
|
|
3969
|
+
const setColumnWidth = React20.useCallback(
|
|
3526
3970
|
(columnKey, width) => {
|
|
3527
3971
|
if (isControlled.columnWidths) {
|
|
3528
3972
|
onColumnResize?.(columnKey, width);
|
|
@@ -3536,7 +3980,7 @@ function useDataGridState(options) {
|
|
|
3536
3980
|
},
|
|
3537
3981
|
[isControlled.columnWidths, onColumnResize]
|
|
3538
3982
|
);
|
|
3539
|
-
const setFocusedCell =
|
|
3983
|
+
const setFocusedCell = React20.useCallback(
|
|
3540
3984
|
(cell) => {
|
|
3541
3985
|
if (isControlled.focusedCell) {
|
|
3542
3986
|
onFocusedCellChange?.(cell);
|
|
@@ -3547,7 +3991,7 @@ function useDataGridState(options) {
|
|
|
3547
3991
|
},
|
|
3548
3992
|
[isControlled.focusedCell, onFocusedCellChange]
|
|
3549
3993
|
);
|
|
3550
|
-
const startEditing =
|
|
3994
|
+
const startEditing = React20.useCallback(
|
|
3551
3995
|
(rowIndex, columnKey) => {
|
|
3552
3996
|
if (onCellEditStart) {
|
|
3553
3997
|
const allowed = onCellEditStart(rowIndex, columnKey);
|
|
@@ -3568,10 +4012,10 @@ function useDataGridState(options) {
|
|
|
3568
4012
|
},
|
|
3569
4013
|
[columns, data, getCellValue2, onCellEditStart, setFocusedCell]
|
|
3570
4014
|
);
|
|
3571
|
-
const updateEditingValue =
|
|
4015
|
+
const updateEditingValue = React20.useCallback((value) => {
|
|
3572
4016
|
setEditingCell((prev) => prev ? { ...prev, value } : null);
|
|
3573
4017
|
}, []);
|
|
3574
|
-
const commitEdit =
|
|
4018
|
+
const commitEdit = React20.useCallback((valueOverride) => {
|
|
3575
4019
|
if (!editingCell) return;
|
|
3576
4020
|
const { rowIndex, columnKey, originalValue } = editingCell;
|
|
3577
4021
|
const value = valueOverride !== void 0 ? valueOverride : editingCell.value;
|
|
@@ -3588,7 +4032,7 @@ function useDataGridState(options) {
|
|
|
3588
4032
|
}
|
|
3589
4033
|
setEditingCell(null);
|
|
3590
4034
|
}, [editingCell, columns, data, onCellEdit]);
|
|
3591
|
-
const cancelEdit =
|
|
4035
|
+
const cancelEdit = React20.useCallback(() => {
|
|
3592
4036
|
if (editingCell) {
|
|
3593
4037
|
onCellEditCancel?.(editingCell.rowIndex, editingCell.columnKey);
|
|
3594
4038
|
}
|
|
@@ -3630,22 +4074,22 @@ function useKeyboardNavigation(options) {
|
|
|
3630
4074
|
onScrollToRow,
|
|
3631
4075
|
onScrollToColumn
|
|
3632
4076
|
} = options;
|
|
3633
|
-
const containerRef =
|
|
4077
|
+
const containerRef = React20.useRef(null);
|
|
3634
4078
|
const visibleColumns = getVisibleColumns(columns);
|
|
3635
|
-
const getColumnIndex =
|
|
4079
|
+
const getColumnIndex = React20.useCallback(
|
|
3636
4080
|
(columnKey) => {
|
|
3637
4081
|
return visibleColumns.findIndex((col) => col.key === columnKey);
|
|
3638
4082
|
},
|
|
3639
4083
|
[visibleColumns]
|
|
3640
4084
|
);
|
|
3641
|
-
const getColumnKey =
|
|
4085
|
+
const getColumnKey = React20.useCallback(
|
|
3642
4086
|
(index) => {
|
|
3643
4087
|
const column = visibleColumns[index];
|
|
3644
4088
|
return column ? column.key : null;
|
|
3645
4089
|
},
|
|
3646
4090
|
[visibleColumns]
|
|
3647
4091
|
);
|
|
3648
|
-
const navigateToCell =
|
|
4092
|
+
const navigateToCell = React20.useCallback(
|
|
3649
4093
|
(rowIndex, columnKey) => {
|
|
3650
4094
|
const clampedRow = Math.max(0, Math.min(rowIndex, rowCount - 1));
|
|
3651
4095
|
onFocusedCellChange({ rowIndex: clampedRow, columnKey });
|
|
@@ -3654,7 +4098,7 @@ function useKeyboardNavigation(options) {
|
|
|
3654
4098
|
},
|
|
3655
4099
|
[rowCount, onFocusedCellChange, onScrollToRow, onScrollToColumn]
|
|
3656
4100
|
);
|
|
3657
|
-
const moveFocus =
|
|
4101
|
+
const moveFocus = React20.useCallback(
|
|
3658
4102
|
(rowDelta, colDelta) => {
|
|
3659
4103
|
if (!focusedCell || visibleColumns.length === 0 || rowCount === 0) return;
|
|
3660
4104
|
const currentColIndex = getColumnIndex(focusedCell.columnKey);
|
|
@@ -3694,35 +4138,35 @@ function useKeyboardNavigation(options) {
|
|
|
3694
4138
|
navigateToCell
|
|
3695
4139
|
]
|
|
3696
4140
|
);
|
|
3697
|
-
const jumpToRowStart =
|
|
4141
|
+
const jumpToRowStart = React20.useCallback(() => {
|
|
3698
4142
|
if (!focusedCell || visibleColumns.length === 0) return;
|
|
3699
4143
|
const firstColumnKey = getColumnKey(0);
|
|
3700
4144
|
if (firstColumnKey) {
|
|
3701
4145
|
navigateToCell(focusedCell.rowIndex, firstColumnKey);
|
|
3702
4146
|
}
|
|
3703
4147
|
}, [focusedCell, visibleColumns.length, getColumnKey, navigateToCell]);
|
|
3704
|
-
const jumpToRowEnd =
|
|
4148
|
+
const jumpToRowEnd = React20.useCallback(() => {
|
|
3705
4149
|
if (!focusedCell || visibleColumns.length === 0) return;
|
|
3706
4150
|
const lastColumnKey = getColumnKey(visibleColumns.length - 1);
|
|
3707
4151
|
if (lastColumnKey) {
|
|
3708
4152
|
navigateToCell(focusedCell.rowIndex, lastColumnKey);
|
|
3709
4153
|
}
|
|
3710
4154
|
}, [focusedCell, visibleColumns.length, getColumnKey, navigateToCell]);
|
|
3711
|
-
const jumpToGridStart =
|
|
4155
|
+
const jumpToGridStart = React20.useCallback(() => {
|
|
3712
4156
|
if (visibleColumns.length === 0 || rowCount === 0) return;
|
|
3713
4157
|
const firstColumnKey = getColumnKey(0);
|
|
3714
4158
|
if (firstColumnKey) {
|
|
3715
4159
|
navigateToCell(0, firstColumnKey);
|
|
3716
4160
|
}
|
|
3717
4161
|
}, [visibleColumns.length, rowCount, getColumnKey, navigateToCell]);
|
|
3718
|
-
const jumpToGridEnd =
|
|
4162
|
+
const jumpToGridEnd = React20.useCallback(() => {
|
|
3719
4163
|
if (visibleColumns.length === 0 || rowCount === 0) return;
|
|
3720
4164
|
const lastColumnKey = getColumnKey(visibleColumns.length - 1);
|
|
3721
4165
|
if (lastColumnKey) {
|
|
3722
4166
|
navigateToCell(rowCount - 1, lastColumnKey);
|
|
3723
4167
|
}
|
|
3724
4168
|
}, [visibleColumns.length, rowCount, getColumnKey, navigateToCell]);
|
|
3725
|
-
const handleKeyDown =
|
|
4169
|
+
const handleKeyDown = React20.useCallback(
|
|
3726
4170
|
(event) => {
|
|
3727
4171
|
if (!enabled) return;
|
|
3728
4172
|
const { key, ctrlKey, metaKey, shiftKey } = event;
|
|
@@ -3825,7 +4269,7 @@ function useKeyboardNavigation(options) {
|
|
|
3825
4269
|
onFocusedCellChange
|
|
3826
4270
|
]
|
|
3827
4271
|
);
|
|
3828
|
-
const focusContainer =
|
|
4272
|
+
const focusContainer = React20.useCallback(() => {
|
|
3829
4273
|
containerRef.current?.focus();
|
|
3830
4274
|
}, []);
|
|
3831
4275
|
return {
|
|
@@ -3846,18 +4290,18 @@ function useColumnResize(options) {
|
|
|
3846
4290
|
onResizeStart,
|
|
3847
4291
|
onResizeEnd
|
|
3848
4292
|
} = options;
|
|
3849
|
-
const [isDragging, setIsDragging] =
|
|
3850
|
-
const startXRef =
|
|
3851
|
-
const startWidthRef =
|
|
4293
|
+
const [isDragging, setIsDragging] = React20.useState(false);
|
|
4294
|
+
const startXRef = React20.useRef(0);
|
|
4295
|
+
const startWidthRef = React20.useRef(0);
|
|
3852
4296
|
const minWidth = column.minWidth ?? DEFAULT_MIN_WIDTH;
|
|
3853
4297
|
const maxWidth = column.maxWidth ?? DEFAULT_MAX_WIDTH;
|
|
3854
|
-
const clampWidth =
|
|
4298
|
+
const clampWidth = React20.useCallback(
|
|
3855
4299
|
(width) => {
|
|
3856
4300
|
return Math.max(minWidth, Math.min(maxWidth, width));
|
|
3857
4301
|
},
|
|
3858
4302
|
[minWidth, maxWidth]
|
|
3859
4303
|
);
|
|
3860
|
-
const handleMouseDown =
|
|
4304
|
+
const handleMouseDown = React20.useCallback(
|
|
3861
4305
|
(event) => {
|
|
3862
4306
|
if (!enabled) return;
|
|
3863
4307
|
event.preventDefault();
|
|
@@ -3871,7 +4315,7 @@ function useColumnResize(options) {
|
|
|
3871
4315
|
},
|
|
3872
4316
|
[enabled, currentWidth, onResizeStart]
|
|
3873
4317
|
);
|
|
3874
|
-
const handleMouseMove =
|
|
4318
|
+
const handleMouseMove = React20.useCallback(
|
|
3875
4319
|
(event) => {
|
|
3876
4320
|
if (!isDragging) return;
|
|
3877
4321
|
const deltaX = event.clientX - startXRef.current;
|
|
@@ -3880,7 +4324,7 @@ function useColumnResize(options) {
|
|
|
3880
4324
|
},
|
|
3881
4325
|
[isDragging, clampWidth, onResize]
|
|
3882
4326
|
);
|
|
3883
|
-
const handleMouseUp =
|
|
4327
|
+
const handleMouseUp = React20.useCallback(() => {
|
|
3884
4328
|
if (!isDragging) return;
|
|
3885
4329
|
setIsDragging(false);
|
|
3886
4330
|
document.body.style.userSelect = "";
|
|
@@ -3888,7 +4332,7 @@ function useColumnResize(options) {
|
|
|
3888
4332
|
const finalWidth = clampWidth(currentWidth);
|
|
3889
4333
|
onResizeEnd?.(finalWidth);
|
|
3890
4334
|
}, [isDragging, currentWidth, clampWidth, onResizeEnd]);
|
|
3891
|
-
const handleDoubleClick =
|
|
4335
|
+
const handleDoubleClick = React20.useCallback(
|
|
3892
4336
|
(event) => {
|
|
3893
4337
|
if (!enabled) return;
|
|
3894
4338
|
event.preventDefault();
|
|
@@ -3900,7 +4344,7 @@ function useColumnResize(options) {
|
|
|
3900
4344
|
},
|
|
3901
4345
|
[enabled, column.width, clampWidth, onResize, onResizeEnd]
|
|
3902
4346
|
);
|
|
3903
|
-
|
|
4347
|
+
React20.useEffect(() => {
|
|
3904
4348
|
if (isDragging) {
|
|
3905
4349
|
window.addEventListener("mousemove", handleMouseMove);
|
|
3906
4350
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -3910,7 +4354,7 @@ function useColumnResize(options) {
|
|
|
3910
4354
|
};
|
|
3911
4355
|
}
|
|
3912
4356
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
3913
|
-
|
|
4357
|
+
React20.useEffect(() => {
|
|
3914
4358
|
return () => {
|
|
3915
4359
|
if (isDragging) {
|
|
3916
4360
|
document.body.style.userSelect = "";
|
|
@@ -3942,16 +4386,16 @@ function useColumnResizeManager(options) {
|
|
|
3942
4386
|
onColumnResizeStart,
|
|
3943
4387
|
onColumnResizeEnd
|
|
3944
4388
|
} = options;
|
|
3945
|
-
const [resizingColumn, setResizingColumn] =
|
|
3946
|
-
const startXRef =
|
|
3947
|
-
const startWidthRef =
|
|
3948
|
-
const getColumn =
|
|
4389
|
+
const [resizingColumn, setResizingColumn] = React20.useState(null);
|
|
4390
|
+
const startXRef = React20.useRef(0);
|
|
4391
|
+
const startWidthRef = React20.useRef(0);
|
|
4392
|
+
const getColumn = React20.useCallback(
|
|
3949
4393
|
(columnKey) => {
|
|
3950
4394
|
return columns.find((c) => c.key === columnKey);
|
|
3951
4395
|
},
|
|
3952
4396
|
[columns]
|
|
3953
4397
|
);
|
|
3954
|
-
const clampWidth =
|
|
4398
|
+
const clampWidth = React20.useCallback(
|
|
3955
4399
|
(columnKey, width) => {
|
|
3956
4400
|
const column = getColumn(columnKey);
|
|
3957
4401
|
const minWidth = column?.minWidth ?? DEFAULT_MIN_WIDTH;
|
|
@@ -3960,7 +4404,7 @@ function useColumnResizeManager(options) {
|
|
|
3960
4404
|
},
|
|
3961
4405
|
[getColumn]
|
|
3962
4406
|
);
|
|
3963
|
-
const handleMouseMove =
|
|
4407
|
+
const handleMouseMove = React20.useCallback(
|
|
3964
4408
|
(event) => {
|
|
3965
4409
|
if (!resizingColumn) return;
|
|
3966
4410
|
const deltaX = event.clientX - startXRef.current;
|
|
@@ -3972,7 +4416,7 @@ function useColumnResizeManager(options) {
|
|
|
3972
4416
|
},
|
|
3973
4417
|
[resizingColumn, clampWidth, onColumnResize]
|
|
3974
4418
|
);
|
|
3975
|
-
const handleMouseUp =
|
|
4419
|
+
const handleMouseUp = React20.useCallback(() => {
|
|
3976
4420
|
if (!resizingColumn) return;
|
|
3977
4421
|
const finalWidth = columnWidths[resizingColumn] ?? 200;
|
|
3978
4422
|
setResizingColumn(null);
|
|
@@ -3980,7 +4424,7 @@ function useColumnResizeManager(options) {
|
|
|
3980
4424
|
document.body.style.cursor = "";
|
|
3981
4425
|
onColumnResizeEnd?.(resizingColumn, finalWidth);
|
|
3982
4426
|
}, [resizingColumn, columnWidths, onColumnResizeEnd]);
|
|
3983
|
-
|
|
4427
|
+
React20.useEffect(() => {
|
|
3984
4428
|
if (resizingColumn) {
|
|
3985
4429
|
window.addEventListener("mousemove", handleMouseMove);
|
|
3986
4430
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -3990,7 +4434,7 @@ function useColumnResizeManager(options) {
|
|
|
3990
4434
|
};
|
|
3991
4435
|
}
|
|
3992
4436
|
}, [resizingColumn, handleMouseMove, handleMouseUp]);
|
|
3993
|
-
const getResizeProps =
|
|
4437
|
+
const getResizeProps = React20.useCallback(
|
|
3994
4438
|
(columnKey) => {
|
|
3995
4439
|
const column = getColumn(columnKey);
|
|
3996
4440
|
const isResizable = resizableColumns && column?.resizable !== false;
|
|
@@ -4276,15 +4720,15 @@ function DataGrid({
|
|
|
4276
4720
|
hasMore = false,
|
|
4277
4721
|
loadingMore = false
|
|
4278
4722
|
}) {
|
|
4279
|
-
const parentRef =
|
|
4280
|
-
const headerRef =
|
|
4281
|
-
const [headerHeight, setHeaderHeight] =
|
|
4282
|
-
const [hoveredCell, setHoveredCell] =
|
|
4283
|
-
const visibleColumns =
|
|
4723
|
+
const parentRef = React20__namespace.useRef(null);
|
|
4724
|
+
const headerRef = React20__namespace.useRef(null);
|
|
4725
|
+
const [headerHeight, setHeaderHeight] = React20__namespace.useState(40);
|
|
4726
|
+
const [hoveredCell, setHoveredCell] = React20__namespace.useState(null);
|
|
4727
|
+
const visibleColumns = React20__namespace.useMemo(
|
|
4284
4728
|
() => columns.filter((col) => !col.hidden),
|
|
4285
4729
|
[columns]
|
|
4286
4730
|
);
|
|
4287
|
-
const getCellValue2 =
|
|
4731
|
+
const getCellValue2 = React20__namespace.useCallback(
|
|
4288
4732
|
(row, column) => {
|
|
4289
4733
|
if (column.accessor) {
|
|
4290
4734
|
return column.accessor(row);
|
|
@@ -4313,7 +4757,7 @@ function DataGrid({
|
|
|
4313
4757
|
data,
|
|
4314
4758
|
getCellValue: getCellValue2
|
|
4315
4759
|
});
|
|
4316
|
-
const processedData =
|
|
4760
|
+
const processedData = React20__namespace.useMemo(() => {
|
|
4317
4761
|
let result = data;
|
|
4318
4762
|
if (enableInternalFiltering && !isControlled.filters && state.filters.length > 0) {
|
|
4319
4763
|
result = applyFilters(result, state.filters, visibleColumns);
|
|
@@ -4341,7 +4785,7 @@ function DataGrid({
|
|
|
4341
4785
|
onColumnResizeEnd
|
|
4342
4786
|
});
|
|
4343
4787
|
const shouldVirtualize = virtualized ?? processedData.length > 100;
|
|
4344
|
-
|
|
4788
|
+
React20__namespace.useLayoutEffect(() => {
|
|
4345
4789
|
if (headerRef.current && shouldVirtualize) {
|
|
4346
4790
|
setHeaderHeight(headerRef.current.offsetHeight);
|
|
4347
4791
|
}
|
|
@@ -4353,13 +4797,13 @@ function DataGrid({
|
|
|
4353
4797
|
overscan: DEFAULT_OVERSCAN,
|
|
4354
4798
|
enabled: shouldVirtualize
|
|
4355
4799
|
});
|
|
4356
|
-
const tableWidth =
|
|
4800
|
+
const tableWidth = React20__namespace.useMemo(() => {
|
|
4357
4801
|
return visibleColumns.reduce((acc, col) => {
|
|
4358
4802
|
const width = state.columnWidths[col.key] || col.width || estimateColumnWidth(col);
|
|
4359
4803
|
return acc + width;
|
|
4360
4804
|
}, 0);
|
|
4361
4805
|
}, [visibleColumns, state.columnWidths]);
|
|
4362
|
-
const visibleRowCount =
|
|
4806
|
+
const visibleRowCount = React20__namespace.useMemo(() => {
|
|
4363
4807
|
if (!parentRef.current) return 10;
|
|
4364
4808
|
return Math.floor(parentRef.current.clientHeight / DEFAULT_ROW_HEIGHT);
|
|
4365
4809
|
}, []);
|
|
@@ -4378,7 +4822,7 @@ function DataGrid({
|
|
|
4378
4822
|
rowVirtualizer.scrollToIndex(rowIndex, { align: "auto" });
|
|
4379
4823
|
}
|
|
4380
4824
|
});
|
|
4381
|
-
const handleBlur =
|
|
4825
|
+
const handleBlur = React20__namespace.useCallback(
|
|
4382
4826
|
(event) => {
|
|
4383
4827
|
const target = event.target;
|
|
4384
4828
|
const relatedTarget = event.relatedTarget;
|
|
@@ -4436,7 +4880,7 @@ function DataGrid({
|
|
|
4436
4880
|
},
|
|
4437
4881
|
[state.editingCell, actions]
|
|
4438
4882
|
);
|
|
4439
|
-
|
|
4883
|
+
React20__namespace.useEffect(() => {
|
|
4440
4884
|
if (!infiniteScroll || !hasMore || loadingMore || !parentRef.current) return;
|
|
4441
4885
|
const observer = new IntersectionObserver(
|
|
4442
4886
|
(entries) => {
|
|
@@ -4880,7 +5324,7 @@ function DataGrid({
|
|
|
4880
5324
|
);
|
|
4881
5325
|
}
|
|
4882
5326
|
function PaginationFooter({ pagination }) {
|
|
4883
|
-
const [goToPage, setGoToPage] =
|
|
5327
|
+
const [goToPage, setGoToPage] = React20__namespace.useState("");
|
|
4884
5328
|
const handleGoToPage = () => {
|
|
4885
5329
|
const page = parseInt(goToPage, 10);
|
|
4886
5330
|
if (!isNaN(page) && page >= 1 && page <= pagination.totalPages) {
|
|
@@ -4998,21 +5442,21 @@ function Autocomplete({
|
|
|
4998
5442
|
className,
|
|
4999
5443
|
clearable = false
|
|
5000
5444
|
}) {
|
|
5001
|
-
const [open, setOpen] =
|
|
5002
|
-
const [search, setSearch] =
|
|
5003
|
-
const inputRef =
|
|
5004
|
-
const selectedOption =
|
|
5445
|
+
const [open, setOpen] = React20__namespace.useState(false);
|
|
5446
|
+
const [search, setSearch] = React20__namespace.useState("");
|
|
5447
|
+
const inputRef = React20__namespace.useRef(null);
|
|
5448
|
+
const selectedOption = React20__namespace.useMemo(
|
|
5005
5449
|
() => options.find((opt) => opt.value === value),
|
|
5006
5450
|
[options, value]
|
|
5007
5451
|
);
|
|
5008
|
-
const filteredOptions =
|
|
5452
|
+
const filteredOptions = React20__namespace.useMemo(() => {
|
|
5009
5453
|
if (!search.trim()) return options;
|
|
5010
5454
|
const searchLower = search.toLowerCase();
|
|
5011
5455
|
return options.filter(
|
|
5012
5456
|
(opt) => opt.label.toLowerCase().includes(searchLower) || opt.description?.toLowerCase().includes(searchLower)
|
|
5013
5457
|
);
|
|
5014
5458
|
}, [options, search]);
|
|
5015
|
-
const groupedOptions =
|
|
5459
|
+
const groupedOptions = React20__namespace.useMemo(() => {
|
|
5016
5460
|
const groups = {};
|
|
5017
5461
|
const ungrouped = [];
|
|
5018
5462
|
filteredOptions.forEach((opt) => {
|
|
@@ -5026,7 +5470,7 @@ function Autocomplete({
|
|
|
5026
5470
|
return { groups, ungrouped };
|
|
5027
5471
|
}, [filteredOptions]);
|
|
5028
5472
|
const hasGroups = Object.keys(groupedOptions.groups).length > 0;
|
|
5029
|
-
const handleSelect =
|
|
5473
|
+
const handleSelect = React20__namespace.useCallback(
|
|
5030
5474
|
(optionValue) => {
|
|
5031
5475
|
onChange?.(optionValue);
|
|
5032
5476
|
setOpen(false);
|
|
@@ -5034,7 +5478,7 @@ function Autocomplete({
|
|
|
5034
5478
|
},
|
|
5035
5479
|
[onChange]
|
|
5036
5480
|
);
|
|
5037
|
-
const handleClear =
|
|
5481
|
+
const handleClear = React20__namespace.useCallback(
|
|
5038
5482
|
(e) => {
|
|
5039
5483
|
e.stopPropagation();
|
|
5040
5484
|
onChange?.(void 0);
|
|
@@ -5042,7 +5486,7 @@ function Autocomplete({
|
|
|
5042
5486
|
},
|
|
5043
5487
|
[onChange]
|
|
5044
5488
|
);
|
|
5045
|
-
|
|
5489
|
+
React20__namespace.useEffect(() => {
|
|
5046
5490
|
if (open) {
|
|
5047
5491
|
const timeout = setTimeout(() => {
|
|
5048
5492
|
inputRef.current?.focus();
|
|
@@ -5052,7 +5496,7 @@ function Autocomplete({
|
|
|
5052
5496
|
setSearch("");
|
|
5053
5497
|
}
|
|
5054
5498
|
}, [open]);
|
|
5055
|
-
const handleKeyDown =
|
|
5499
|
+
const handleKeyDown = React20__namespace.useCallback((e) => {
|
|
5056
5500
|
if (e.key === "Escape") {
|
|
5057
5501
|
setOpen(false);
|
|
5058
5502
|
}
|
|
@@ -5228,7 +5672,7 @@ var iconButtonVariants = classVarianceAuthority.cva(
|
|
|
5228
5672
|
}
|
|
5229
5673
|
}
|
|
5230
5674
|
);
|
|
5231
|
-
var IconButton =
|
|
5675
|
+
var IconButton = React20__namespace.forwardRef(
|
|
5232
5676
|
({ className, variant, size, isActive = false, icon, children, ...props }, ref) => {
|
|
5233
5677
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5234
5678
|
"button",
|
|
@@ -5252,7 +5696,7 @@ var IconButton = React34__namespace.forwardRef(
|
|
|
5252
5696
|
);
|
|
5253
5697
|
IconButton.displayName = "IconButton";
|
|
5254
5698
|
function CopyButton({ content, className, size = "md" }) {
|
|
5255
|
-
const [copied, setCopied] =
|
|
5699
|
+
const [copied, setCopied] = React20__namespace.useState(false);
|
|
5256
5700
|
const handleCopy = async () => {
|
|
5257
5701
|
try {
|
|
5258
5702
|
await navigator.clipboard.writeText(content);
|
|
@@ -6025,11 +6469,11 @@ function ThemePicker({
|
|
|
6025
6469
|
align = "end",
|
|
6026
6470
|
side = "bottom"
|
|
6027
6471
|
}) {
|
|
6028
|
-
const [open, setOpen] =
|
|
6029
|
-
const [selectedTheme, setSelectedTheme] =
|
|
6472
|
+
const [open, setOpen] = React20__namespace.useState(false);
|
|
6473
|
+
const [selectedTheme, setSelectedTheme] = React20__namespace.useState(
|
|
6030
6474
|
value || themes[0]
|
|
6031
6475
|
);
|
|
6032
|
-
|
|
6476
|
+
React20__namespace.useEffect(() => {
|
|
6033
6477
|
if (value) {
|
|
6034
6478
|
setSelectedTheme(value);
|
|
6035
6479
|
}
|
|
@@ -6139,19 +6583,19 @@ function getSafePosition(x, y, menuWidth, menuHeight) {
|
|
|
6139
6583
|
return { x: safeX, y: safeY };
|
|
6140
6584
|
}
|
|
6141
6585
|
function MenuItem({ item, onClose, depth = 0 }) {
|
|
6142
|
-
const [isSubmenuOpen, setIsSubmenuOpen] =
|
|
6143
|
-
const [submenuPosition, setSubmenuPosition] =
|
|
6144
|
-
const itemRef =
|
|
6145
|
-
const hoverTimeoutRef =
|
|
6586
|
+
const [isSubmenuOpen, setIsSubmenuOpen] = React20__namespace.useState(false);
|
|
6587
|
+
const [submenuPosition, setSubmenuPosition] = React20__namespace.useState(null);
|
|
6588
|
+
const itemRef = React20__namespace.useRef(null);
|
|
6589
|
+
const hoverTimeoutRef = React20__namespace.useRef(null);
|
|
6146
6590
|
const hasSubmenu = item.submenu && item.submenu.length > 0;
|
|
6147
|
-
|
|
6591
|
+
React20__namespace.useEffect(() => {
|
|
6148
6592
|
return () => {
|
|
6149
6593
|
if (hoverTimeoutRef.current) {
|
|
6150
6594
|
clearTimeout(hoverTimeoutRef.current);
|
|
6151
6595
|
}
|
|
6152
6596
|
};
|
|
6153
6597
|
}, []);
|
|
6154
|
-
const handleMouseEnter =
|
|
6598
|
+
const handleMouseEnter = React20__namespace.useCallback(() => {
|
|
6155
6599
|
if (hoverTimeoutRef.current) {
|
|
6156
6600
|
clearTimeout(hoverTimeoutRef.current);
|
|
6157
6601
|
}
|
|
@@ -6171,22 +6615,22 @@ function MenuItem({ item, onClose, depth = 0 }) {
|
|
|
6171
6615
|
setIsSubmenuOpen(true);
|
|
6172
6616
|
}
|
|
6173
6617
|
}, [hasSubmenu, item.submenu?.length]);
|
|
6174
|
-
const handleMouseLeave =
|
|
6618
|
+
const handleMouseLeave = React20__namespace.useCallback(() => {
|
|
6175
6619
|
hoverTimeoutRef.current = setTimeout(() => {
|
|
6176
6620
|
setIsSubmenuOpen(false);
|
|
6177
6621
|
}, 100);
|
|
6178
6622
|
}, []);
|
|
6179
|
-
const handleSubmenuMouseEnter =
|
|
6623
|
+
const handleSubmenuMouseEnter = React20__namespace.useCallback(() => {
|
|
6180
6624
|
if (hoverTimeoutRef.current) {
|
|
6181
6625
|
clearTimeout(hoverTimeoutRef.current);
|
|
6182
6626
|
}
|
|
6183
6627
|
}, []);
|
|
6184
|
-
const handleSubmenuMouseLeave =
|
|
6628
|
+
const handleSubmenuMouseLeave = React20__namespace.useCallback(() => {
|
|
6185
6629
|
hoverTimeoutRef.current = setTimeout(() => {
|
|
6186
6630
|
setIsSubmenuOpen(false);
|
|
6187
6631
|
}, 100);
|
|
6188
6632
|
}, []);
|
|
6189
|
-
const handleClick =
|
|
6633
|
+
const handleClick = React20__namespace.useCallback(() => {
|
|
6190
6634
|
if (item.disabled) return;
|
|
6191
6635
|
if (!hasSubmenu && item.action) {
|
|
6192
6636
|
item.action();
|
|
@@ -6266,12 +6710,12 @@ function ContextMenu({
|
|
|
6266
6710
|
anchorEl,
|
|
6267
6711
|
className
|
|
6268
6712
|
}) {
|
|
6269
|
-
const menuRef =
|
|
6270
|
-
const [menuPosition, setMenuPosition] =
|
|
6713
|
+
const menuRef = React20__namespace.useRef(null);
|
|
6714
|
+
const [menuPosition, setMenuPosition] = React20__namespace.useState({
|
|
6271
6715
|
x: 0,
|
|
6272
6716
|
y: 0
|
|
6273
6717
|
});
|
|
6274
|
-
|
|
6718
|
+
React20__namespace.useEffect(() => {
|
|
6275
6719
|
if (!isOpen) return;
|
|
6276
6720
|
let x = position.x;
|
|
6277
6721
|
let y = position.y;
|
|
@@ -6290,7 +6734,7 @@ function ContextMenu({
|
|
|
6290
6734
|
}
|
|
6291
6735
|
});
|
|
6292
6736
|
}, [isOpen, position, anchorEl]);
|
|
6293
|
-
|
|
6737
|
+
React20__namespace.useEffect(() => {
|
|
6294
6738
|
if (!isOpen) return;
|
|
6295
6739
|
const handleClickOutside = (e) => {
|
|
6296
6740
|
if (menuRef.current && !menuRef.current.contains(e.target)) {
|
|
@@ -6334,16 +6778,16 @@ function ContextMenu({
|
|
|
6334
6778
|
);
|
|
6335
6779
|
}
|
|
6336
6780
|
function useContextMenu() {
|
|
6337
|
-
const [isOpen, setIsOpen] =
|
|
6338
|
-
const [position, setPosition] =
|
|
6339
|
-
const [targetItem, setTargetItem] =
|
|
6340
|
-
const menuRef =
|
|
6341
|
-
const openMenu =
|
|
6781
|
+
const [isOpen, setIsOpen] = React20__namespace.useState(false);
|
|
6782
|
+
const [position, setPosition] = React20__namespace.useState({ x: 0, y: 0 });
|
|
6783
|
+
const [targetItem, setTargetItem] = React20__namespace.useState(null);
|
|
6784
|
+
const menuRef = React20__namespace.useRef(null);
|
|
6785
|
+
const openMenu = React20__namespace.useCallback((x, y, item) => {
|
|
6342
6786
|
setPosition({ x, y });
|
|
6343
6787
|
setTargetItem(item);
|
|
6344
6788
|
setIsOpen(true);
|
|
6345
6789
|
}, []);
|
|
6346
|
-
const closeMenu =
|
|
6790
|
+
const closeMenu = React20__namespace.useCallback(() => {
|
|
6347
6791
|
setIsOpen(false);
|
|
6348
6792
|
setTargetItem(null);
|
|
6349
6793
|
}, []);
|
|
@@ -6399,6 +6843,7 @@ exports.ContextMenu = ContextMenu;
|
|
|
6399
6843
|
exports.CopyButton = CopyButton;
|
|
6400
6844
|
exports.DARK_ELEGANT_THEME = DARK_ELEGANT_THEME;
|
|
6401
6845
|
exports.DataGrid = DataGrid;
|
|
6846
|
+
exports.DataTable = DataTable;
|
|
6402
6847
|
exports.DatePicker = DatePicker;
|
|
6403
6848
|
exports.DatePickerInput = DatePickerInput;
|
|
6404
6849
|
exports.DropdownMenu = DropdownMenu;
|