@mvn-ui/react 0.1.2 → 0.1.3
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.css +27 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +16 -6
- package/dist/index.d.ts +16 -6
- package/dist/index.js +206 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +206 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -439,10 +439,10 @@ function ButtonGroup({
|
|
|
439
439
|
"data-orientation": orientation,
|
|
440
440
|
className: cn(
|
|
441
441
|
"inline-flex",
|
|
442
|
+
className,
|
|
442
443
|
isVertical ? "flex-col" : "flex-row",
|
|
443
444
|
// Join children and normalize border radius so the group looks contiguous
|
|
444
|
-
isVertical ? "[&>*]:rounded-none [&>*]:-mt-px [&>:first-child]:mt-0 [&>:first-child]:rounded-t-md [&>:last-child]:rounded-b-md" : "[&>*]:rounded-none [&>*]:-ml-px [&>:first-child]:ml-0 [&>:first-child]:rounded-l-md [&>:last-child]:rounded-r-md"
|
|
445
|
-
className
|
|
445
|
+
isVertical ? "[&>*]:rounded-none [&>*]:-mt-px [&>:first-child]:mt-0 [&>:first-child]:rounded-t-md [&>:last-child]:rounded-b-md" : "[&>*]:rounded-none [&>*]:-ml-px [&>:first-child]:ml-0 [&>:first-child]:rounded-l-md [&>:last-child]:rounded-r-md"
|
|
446
446
|
),
|
|
447
447
|
...props
|
|
448
448
|
}
|
|
@@ -553,8 +553,8 @@ var Input = React49.forwardRef(
|
|
|
553
553
|
children: label
|
|
554
554
|
}
|
|
555
555
|
),
|
|
556
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
557
|
-
leftIcon && /* @__PURE__ */ jsx("div", { className: "absolute left-3
|
|
556
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
557
|
+
leftIcon && /* @__PURE__ */ jsx("div", { className: "absolute left-3 text-muted-foreground pointer-events-none flex items-center justify-center [&_svg]:size-4", children: leftIcon }),
|
|
558
558
|
/* @__PURE__ */ jsx(
|
|
559
559
|
"input",
|
|
560
560
|
{
|
|
@@ -579,7 +579,7 @@ var Input = React49.forwardRef(
|
|
|
579
579
|
...props
|
|
580
580
|
}
|
|
581
581
|
),
|
|
582
|
-
(showClearButton || showPasswordToggle || rightIcon) && /* @__PURE__ */ jsxs("div", { className: "absolute right-3
|
|
582
|
+
(showClearButton || showPasswordToggle || rightIcon) && /* @__PURE__ */ jsxs("div", { className: "absolute right-3 flex items-center gap-1", children: [
|
|
583
583
|
showClearButton && /* @__PURE__ */ jsx(
|
|
584
584
|
"button",
|
|
585
585
|
{
|
|
@@ -600,7 +600,7 @@ var Input = React49.forwardRef(
|
|
|
600
600
|
children: showPassword ? /* @__PURE__ */ jsx(EyeOffIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeIcon, { className: "h-4 w-4" })
|
|
601
601
|
}
|
|
602
602
|
),
|
|
603
|
-
rightIcon && !showPasswordToggle && !showClearButton && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground [&_svg]:size-4", children: rightIcon })
|
|
603
|
+
rightIcon && !showPasswordToggle && !showClearButton && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground flex items-center justify-center [&_svg]:size-4", children: rightIcon })
|
|
604
604
|
] })
|
|
605
605
|
] }),
|
|
606
606
|
error && /* @__PURE__ */ jsx(
|
|
@@ -1096,7 +1096,7 @@ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
|
1096
1096
|
|
|
1097
1097
|
// src/components/ui/switch/index.tsx
|
|
1098
1098
|
init_utils();
|
|
1099
|
-
var Switch = React49.forwardRef(({ className, ...props }, ref) => {
|
|
1099
|
+
var Switch = React49.forwardRef(({ className, offNode, onNode, ...props }, ref) => {
|
|
1100
1100
|
return /* @__PURE__ */ jsx(
|
|
1101
1101
|
SwitchPrimitives.Root,
|
|
1102
1102
|
{
|
|
@@ -1109,13 +1109,17 @@ var Switch = React49.forwardRef(({ className, ...props }, ref) => {
|
|
|
1109
1109
|
className
|
|
1110
1110
|
),
|
|
1111
1111
|
...props,
|
|
1112
|
-
children: /* @__PURE__ */
|
|
1112
|
+
children: /* @__PURE__ */ jsxs(
|
|
1113
1113
|
SwitchPrimitives.Thumb,
|
|
1114
1114
|
{
|
|
1115
1115
|
className: cn(
|
|
1116
|
-
"pointer-events-none
|
|
1116
|
+
"group pointer-events-none relative flex items-center justify-center h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform",
|
|
1117
1117
|
"data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
1118
|
-
)
|
|
1118
|
+
),
|
|
1119
|
+
children: [
|
|
1120
|
+
/* @__PURE__ */ jsx("span", { className: "absolute opacity-0 group-data-[state=checked]:opacity-100 transition-all duration-200", children: onNode }),
|
|
1121
|
+
/* @__PURE__ */ jsx("span", { className: "absolute opacity-100 group-data-[state=checked]:opacity-0 transition-all duration-200", children: offNode })
|
|
1122
|
+
]
|
|
1119
1123
|
}
|
|
1120
1124
|
)
|
|
1121
1125
|
}
|
|
@@ -2921,27 +2925,45 @@ var DialogOverlay = React49.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
2921
2925
|
}
|
|
2922
2926
|
));
|
|
2923
2927
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
2924
|
-
var DialogContent = React49.forwardRef(
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2928
|
+
var DialogContent = React49.forwardRef(
|
|
2929
|
+
({
|
|
2930
|
+
className,
|
|
2931
|
+
children,
|
|
2932
|
+
showClose = true,
|
|
2933
|
+
closeClassName,
|
|
2934
|
+
customClose,
|
|
2935
|
+
...props
|
|
2936
|
+
}, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
2937
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
2938
|
+
/* @__PURE__ */ jsxs(
|
|
2939
|
+
DialogPrimitive.Content,
|
|
2940
|
+
{
|
|
2941
|
+
ref,
|
|
2942
|
+
className: cn(
|
|
2943
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-mvn-gray-200 bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",
|
|
2944
|
+
className
|
|
2945
|
+
),
|
|
2946
|
+
...props,
|
|
2947
|
+
children: [
|
|
2948
|
+
children,
|
|
2949
|
+
showClose && (customClose ? customClose : /* @__PURE__ */ jsxs(
|
|
2950
|
+
DialogPrimitive.Close,
|
|
2951
|
+
{
|
|
2952
|
+
className: cn(
|
|
2953
|
+
"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none data-[state=open]:bg-mvn-gray-100",
|
|
2954
|
+
closeClassName
|
|
2955
|
+
),
|
|
2956
|
+
children: [
|
|
2957
|
+
/* @__PURE__ */ jsx(X, { className: "h-5 w-5" }),
|
|
2958
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
2959
|
+
]
|
|
2960
|
+
}
|
|
2961
|
+
))
|
|
2962
|
+
]
|
|
2963
|
+
}
|
|
2964
|
+
)
|
|
2965
|
+
] })
|
|
2966
|
+
);
|
|
2945
2967
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
2946
2968
|
var DialogHeader = ({
|
|
2947
2969
|
className,
|
|
@@ -2949,10 +2971,7 @@ var DialogHeader = ({
|
|
|
2949
2971
|
}) => /* @__PURE__ */ jsx(
|
|
2950
2972
|
"div",
|
|
2951
2973
|
{
|
|
2952
|
-
className: cn(
|
|
2953
|
-
"flex flex-col space-y-1.5 text-left",
|
|
2954
|
-
className
|
|
2955
|
-
),
|
|
2974
|
+
className: cn("flex flex-col space-y-1.5 text-left", className),
|
|
2956
2975
|
...props
|
|
2957
2976
|
}
|
|
2958
2977
|
);
|
|
@@ -3312,7 +3331,9 @@ var TooltipContent = React49.forwardRef(({ className, sideOffset = 4, ...props }
|
|
|
3312
3331
|
ref,
|
|
3313
3332
|
sideOffset,
|
|
3314
3333
|
className: cn(
|
|
3315
|
-
"z-50 overflow-hidden rounded-md bg-mvn-gray-900 px-3 py-1.5 text-xs text-
|
|
3334
|
+
"z-50 overflow-hidden rounded-md bg-mvn-gray-900 px-3 py-1.5 text-xs text-primary-50 dark:bg-primary-50 dark:text-mvn-gray-900 animate-in fade-in-0 zoom-in-95",
|
|
3335
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
3336
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
3316
3337
|
className
|
|
3317
3338
|
),
|
|
3318
3339
|
...props
|
|
@@ -4325,7 +4346,7 @@ var TabsList = React49.forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
4325
4346
|
ref,
|
|
4326
4347
|
className: cn(
|
|
4327
4348
|
"flex items-stretch gap-0 text-muted-foreground",
|
|
4328
|
-
"data-[orientation=horizontal]:w-full
|
|
4349
|
+
"data-[orientation=horizontal]:w-full",
|
|
4329
4350
|
"data-[orientation=vertical]:w-56 data-[orientation=vertical]:border-r data-[orientation=vertical]:border-border",
|
|
4330
4351
|
"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shrink-0",
|
|
4331
4352
|
className
|
|
@@ -4342,9 +4363,9 @@ var TabsTrigger = React49.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
4342
4363
|
"inline-flex min-w-0 items-center justify-center whitespace-nowrap text-sm font-medium",
|
|
4343
4364
|
"transition-all duration-150 text-muted-foreground hover:text-primary",
|
|
4344
4365
|
"ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
4345
|
-
"data-[orientation=horizontal]:
|
|
4366
|
+
"data-[orientation=horizontal]:px-4 data-[orientation=horizontal]:py-3 data-[orientation=horizontal]:border-b-2 data-[orientation=horizontal]:border-transparent",
|
|
4346
4367
|
"data-[orientation=vertical]:w-full data-[orientation=vertical]:justify-start data-[orientation=vertical]:px-3 data-[orientation=vertical]:py-2 data-[orientation=vertical]:border-l-2 data-[orientation=vertical]:border-border",
|
|
4347
|
-
"data-[state=active]:text-primary data-[state=active]:font-semibold data-[state=active]:
|
|
4368
|
+
"data-[state=active]:text-primary data-[state=active]:font-semibold data-[state=active]:border-primary",
|
|
4348
4369
|
"disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed",
|
|
4349
4370
|
className
|
|
4350
4371
|
),
|
|
@@ -4653,6 +4674,7 @@ var ScrollArea = React49.forwardRef(
|
|
|
4653
4674
|
orientation = "vertical",
|
|
4654
4675
|
scrollbarClassName,
|
|
4655
4676
|
thumbClassName,
|
|
4677
|
+
type = "auto",
|
|
4656
4678
|
...props
|
|
4657
4679
|
}, ref) => {
|
|
4658
4680
|
const showVertical = orientation === "vertical" || orientation === "both";
|
|
@@ -4661,12 +4683,38 @@ var ScrollArea = React49.forwardRef(
|
|
|
4661
4683
|
ScrollAreaPrimitive.Root,
|
|
4662
4684
|
{
|
|
4663
4685
|
ref,
|
|
4686
|
+
type,
|
|
4664
4687
|
className: cn("relative overflow-hidden", className),
|
|
4665
4688
|
...props,
|
|
4666
4689
|
children: [
|
|
4667
|
-
/* @__PURE__ */ jsx(
|
|
4668
|
-
|
|
4669
|
-
|
|
4690
|
+
/* @__PURE__ */ jsx(
|
|
4691
|
+
ScrollAreaPrimitive.Viewport,
|
|
4692
|
+
{
|
|
4693
|
+
className: cn(
|
|
4694
|
+
"h-full w-full rounded-[inherit]",
|
|
4695
|
+
// Fix overflow based on orientation to prevent unwanted scrolling
|
|
4696
|
+
orientation === "vertical" && "!overflow-x-hidden",
|
|
4697
|
+
orientation === "horizontal" && "!overflow-y-hidden"
|
|
4698
|
+
),
|
|
4699
|
+
children
|
|
4700
|
+
}
|
|
4701
|
+
),
|
|
4702
|
+
showVertical && /* @__PURE__ */ jsx(
|
|
4703
|
+
ScrollBar,
|
|
4704
|
+
{
|
|
4705
|
+
orientation: "vertical",
|
|
4706
|
+
className: scrollbarClassName,
|
|
4707
|
+
thumbClassName
|
|
4708
|
+
}
|
|
4709
|
+
),
|
|
4710
|
+
showHorizontal && /* @__PURE__ */ jsx(
|
|
4711
|
+
ScrollBar,
|
|
4712
|
+
{
|
|
4713
|
+
orientation: "horizontal",
|
|
4714
|
+
className: scrollbarClassName,
|
|
4715
|
+
thumbClassName
|
|
4716
|
+
}
|
|
4717
|
+
),
|
|
4670
4718
|
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
|
|
4671
4719
|
]
|
|
4672
4720
|
}
|
|
@@ -4690,7 +4738,7 @@ var ScrollBar = React49.forwardRef(({ className, orientation = "vertical", thumb
|
|
|
4690
4738
|
ScrollAreaPrimitive.ScrollAreaThumb,
|
|
4691
4739
|
{
|
|
4692
4740
|
className: cn(
|
|
4693
|
-
"relative flex-1 rounded-full bg-
|
|
4741
|
+
"relative flex-1 rounded-full bg-muted-foreground/50 hover:bg-muted-foreground transition-colors",
|
|
4694
4742
|
thumbClassName
|
|
4695
4743
|
)
|
|
4696
4744
|
}
|
|
@@ -5336,20 +5384,14 @@ var tableVariants = cva("w-full caption-bottom text-sm", {
|
|
|
5336
5384
|
size: "default"
|
|
5337
5385
|
}
|
|
5338
5386
|
});
|
|
5339
|
-
var Table = React49.forwardRef(({ className, variant, size, wrapperClassName, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
5340
|
-
"
|
|
5387
|
+
var Table = React49.forwardRef(({ className, variant, size, wrapperClassName, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: cn("relative w-full overflow-auto", wrapperClassName), children: /* @__PURE__ */ jsx(
|
|
5388
|
+
"table",
|
|
5341
5389
|
{
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
{
|
|
5346
|
-
ref,
|
|
5347
|
-
className: cn(tableVariants({ variant, size, className })),
|
|
5348
|
-
...props
|
|
5349
|
-
}
|
|
5350
|
-
)
|
|
5390
|
+
ref,
|
|
5391
|
+
className: cn(tableVariants({ variant, size, className })),
|
|
5392
|
+
...props
|
|
5351
5393
|
}
|
|
5352
|
-
));
|
|
5394
|
+
) }));
|
|
5353
5395
|
Table.displayName = "Table";
|
|
5354
5396
|
var TableHeader = React49.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
5355
5397
|
TableHeader.displayName = "TableHeader";
|
|
@@ -6408,6 +6450,8 @@ function useTableVirtualization({
|
|
|
6408
6450
|
});
|
|
6409
6451
|
return arr;
|
|
6410
6452
|
}, [rows, expandable]);
|
|
6453
|
+
const virtualRowPointersRef = useRef(virtualRowPointers);
|
|
6454
|
+
virtualRowPointersRef.current = virtualRowPointers;
|
|
6411
6455
|
const cacheBackingRef = useRef(
|
|
6412
6456
|
/* @__PURE__ */ new Map()
|
|
6413
6457
|
);
|
|
@@ -6441,6 +6485,12 @@ function useTableVirtualization({
|
|
|
6441
6485
|
null
|
|
6442
6486
|
);
|
|
6443
6487
|
const measurementIdleRef = useRef(null);
|
|
6488
|
+
const prefixSumCacheRef = useRef({
|
|
6489
|
+
count: 0,
|
|
6490
|
+
itemSizes: [],
|
|
6491
|
+
offsets: [],
|
|
6492
|
+
totalSize: 0
|
|
6493
|
+
});
|
|
6444
6494
|
const cleanupRaf = useCallback(() => {
|
|
6445
6495
|
if (debounceTimeoutRef.current != null) {
|
|
6446
6496
|
clearTimeout(debounceTimeoutRef.current);
|
|
@@ -6465,10 +6515,16 @@ function useTableVirtualization({
|
|
|
6465
6515
|
measurementIdleRef.current = null;
|
|
6466
6516
|
}
|
|
6467
6517
|
measurementQueueRef.current.clear();
|
|
6518
|
+
prefixSumCacheRef.current = {
|
|
6519
|
+
count: 0,
|
|
6520
|
+
itemSizes: [],
|
|
6521
|
+
offsets: [],
|
|
6522
|
+
totalSize: 0
|
|
6523
|
+
};
|
|
6468
6524
|
}, []);
|
|
6469
6525
|
const estimateSize = useCallback(
|
|
6470
6526
|
(index) => {
|
|
6471
|
-
const item =
|
|
6527
|
+
const item = virtualRowPointersRef.current[index];
|
|
6472
6528
|
if (!item) return baseRowEstimateSize;
|
|
6473
6529
|
const key = item.key;
|
|
6474
6530
|
if (item.kind === "expanded" && !rows[item.rowIndex]?.getIsExpanded()) {
|
|
@@ -6481,21 +6537,23 @@ function useTableVirtualization({
|
|
|
6481
6537
|
if (cached != null) return cached;
|
|
6482
6538
|
return item.kind === "expanded" ? expandContentEstimateSize : baseRowEstimateSize;
|
|
6483
6539
|
},
|
|
6484
|
-
[
|
|
6540
|
+
[baseRowEstimateSize, expandContentEstimateSize]
|
|
6485
6541
|
);
|
|
6486
6542
|
const recomputeVirtualWindow = useCallback(() => {
|
|
6487
6543
|
if (!shouldVirtualize) {
|
|
6488
6544
|
setVirtualWindow(EMPTY_WINDOW);
|
|
6489
6545
|
return;
|
|
6490
6546
|
}
|
|
6547
|
+
const pointers = virtualRowPointersRef.current;
|
|
6491
6548
|
const nextWindow = computeVirtualizedRows({
|
|
6492
|
-
count:
|
|
6549
|
+
count: pointers.length,
|
|
6493
6550
|
getScrollElement: () => tableContainerRef.current,
|
|
6494
6551
|
estimateSize,
|
|
6495
6552
|
overScan,
|
|
6496
6553
|
cache: cacheRef.current,
|
|
6497
6554
|
heightCacheByKey: heightCacheByKeyRef.current,
|
|
6498
|
-
getItemKey: (index) =>
|
|
6555
|
+
getItemKey: (index) => pointers[index]?.key ?? "",
|
|
6556
|
+
prefixSumCache: prefixSumCacheRef.current
|
|
6499
6557
|
});
|
|
6500
6558
|
setVirtualWindow(nextWindow);
|
|
6501
6559
|
}, [estimateSize, overScan]);
|
|
@@ -6528,7 +6586,7 @@ function useTableVirtualization({
|
|
|
6528
6586
|
const { startIndex, endIndex } = virtualWindowRef.current;
|
|
6529
6587
|
if (index < startIndex || index > endIndex) return;
|
|
6530
6588
|
}
|
|
6531
|
-
const item =
|
|
6589
|
+
const item = virtualRowPointersRef.current[index];
|
|
6532
6590
|
if (!item) return;
|
|
6533
6591
|
if (!Number.isFinite(height)) return;
|
|
6534
6592
|
const size = normalizeVirtualSize(height);
|
|
@@ -6582,7 +6640,7 @@ function useTableVirtualization({
|
|
|
6582
6640
|
const { startIndex, endIndex } = virtualWindowRef.current;
|
|
6583
6641
|
if (index < startIndex || index > endIndex) return;
|
|
6584
6642
|
}
|
|
6585
|
-
const item =
|
|
6643
|
+
const item = virtualRowPointersRef.current[index];
|
|
6586
6644
|
const key = item?.key;
|
|
6587
6645
|
if (key != null && heightCacheByKeyRef.current.has(key) || heightCacheByIndexRef.current.has(index)) {
|
|
6588
6646
|
return;
|
|
@@ -6602,7 +6660,7 @@ function useTableVirtualization({
|
|
|
6602
6660
|
return;
|
|
6603
6661
|
}
|
|
6604
6662
|
cacheRef.current.forEach((index, _, key) => {
|
|
6605
|
-
if (index >=
|
|
6663
|
+
if (index >= virtualRowPointersRef.current.length) {
|
|
6606
6664
|
cacheRef.current.remove(index);
|
|
6607
6665
|
heightCacheByIndexRef.current.delete(index);
|
|
6608
6666
|
if (key != null) heightCacheByKeyRef.current.delete(key);
|
|
@@ -6692,7 +6750,8 @@ var computeVirtualizedRows = (config) => {
|
|
|
6692
6750
|
cache,
|
|
6693
6751
|
getItemKey,
|
|
6694
6752
|
getHorizontalScrollElement,
|
|
6695
|
-
heightCacheByKey
|
|
6753
|
+
heightCacheByKey,
|
|
6754
|
+
prefixSumCache
|
|
6696
6755
|
} = config;
|
|
6697
6756
|
if (count <= 0) return EMPTY_WINDOW;
|
|
6698
6757
|
const scrollElement = getScrollElement() ?? null;
|
|
@@ -6706,24 +6765,60 @@ var computeVirtualizedRows = (config) => {
|
|
|
6706
6765
|
Math.max(rawHorizontalScrollOffset, 0),
|
|
6707
6766
|
horizontalTotalSize - horizontalViewportSize
|
|
6708
6767
|
) : Math.max(rawHorizontalScrollOffset, 0);
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
let totalSize
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6768
|
+
let itemSizes;
|
|
6769
|
+
let offsets;
|
|
6770
|
+
let totalSize;
|
|
6771
|
+
const cachedCount = prefixSumCache?.count ?? 0;
|
|
6772
|
+
if (prefixSumCache && cachedCount > 0 && count >= cachedCount) {
|
|
6773
|
+
itemSizes = prefixSumCache.itemSizes.slice(0, cachedCount);
|
|
6774
|
+
offsets = prefixSumCache.offsets.slice(0, cachedCount);
|
|
6775
|
+
totalSize = prefixSumCache.totalSize;
|
|
6776
|
+
if (count > cachedCount) {
|
|
6777
|
+
itemSizes.length = count;
|
|
6778
|
+
offsets.length = count;
|
|
6779
|
+
for (let index = cachedCount; index < count; index++) {
|
|
6780
|
+
offsets[index] = totalSize;
|
|
6781
|
+
const key = getItemKey(index);
|
|
6782
|
+
let size = cache.get(index);
|
|
6783
|
+
if (size == null && key != null) {
|
|
6784
|
+
size = heightCacheByKey.get(key);
|
|
6785
|
+
}
|
|
6786
|
+
if (size == null) {
|
|
6787
|
+
const estimate = estimateSize(index);
|
|
6788
|
+
size = normalizeVirtualSize(estimate);
|
|
6789
|
+
} else {
|
|
6790
|
+
size = normalizeVirtualSize(size);
|
|
6791
|
+
}
|
|
6792
|
+
itemSizes[index] = size;
|
|
6793
|
+
totalSize += size;
|
|
6794
|
+
}
|
|
6795
|
+
}
|
|
6796
|
+
} else {
|
|
6797
|
+
itemSizes = new Array(count);
|
|
6798
|
+
offsets = new Array(count);
|
|
6799
|
+
totalSize = 0;
|
|
6800
|
+
for (let index = 0; index < count; index++) {
|
|
6801
|
+
offsets[index] = totalSize;
|
|
6802
|
+
const key = getItemKey(index);
|
|
6803
|
+
let size = cache.get(index);
|
|
6804
|
+
if (size == null && key != null) {
|
|
6805
|
+
size = heightCacheByKey.get(key);
|
|
6806
|
+
}
|
|
6807
|
+
if (size == null) {
|
|
6808
|
+
const estimate = estimateSize(index);
|
|
6809
|
+
size = normalizeVirtualSize(estimate);
|
|
6810
|
+
} else {
|
|
6811
|
+
size = normalizeVirtualSize(size);
|
|
6812
|
+
}
|
|
6813
|
+
itemSizes[index] = size;
|
|
6814
|
+
totalSize += size;
|
|
6724
6815
|
}
|
|
6725
|
-
|
|
6726
|
-
|
|
6816
|
+
}
|
|
6817
|
+
if (prefixSumCache) {
|
|
6818
|
+
prefixSumCache.count = count;
|
|
6819
|
+
prefixSumCache.itemSizes = itemSizes;
|
|
6820
|
+
prefixSumCache.offsets = offsets;
|
|
6821
|
+
prefixSumCache.totalSize = totalSize;
|
|
6727
6822
|
}
|
|
6728
6823
|
const viewportActive = clientHeight > 0;
|
|
6729
6824
|
const scrollOffset = viewportActive ? Math.min(scrollTop, Math.max(totalSize - clientHeight, 0)) : 0;
|
|
@@ -6731,19 +6826,28 @@ var computeVirtualizedRows = (config) => {
|
|
|
6731
6826
|
let visibleStartIndex = 0;
|
|
6732
6827
|
let visibleEndIndex = 0;
|
|
6733
6828
|
if (viewportActive && totalSize > 0) {
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6829
|
+
let low = 0;
|
|
6830
|
+
let high = count - 1;
|
|
6831
|
+
while (low < high) {
|
|
6832
|
+
const mid = Math.floor((low + high) / 2);
|
|
6833
|
+
if (offsets[mid] + itemSizes[mid] > scrollOffset) {
|
|
6834
|
+
high = mid;
|
|
6835
|
+
} else {
|
|
6836
|
+
low = mid + 1;
|
|
6738
6837
|
}
|
|
6739
6838
|
}
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6839
|
+
visibleStartIndex = low;
|
|
6840
|
+
low = visibleStartIndex;
|
|
6841
|
+
high = count - 1;
|
|
6842
|
+
while (low < high) {
|
|
6843
|
+
const mid = Math.ceil((low + high) / 2);
|
|
6844
|
+
if (offsets[mid] >= viewportLimit) {
|
|
6845
|
+
high = mid - 1;
|
|
6846
|
+
} else {
|
|
6847
|
+
low = mid;
|
|
6744
6848
|
}
|
|
6745
|
-
visibleEndIndex = index;
|
|
6746
6849
|
}
|
|
6850
|
+
visibleEndIndex = Math.max(visibleStartIndex, low);
|
|
6747
6851
|
}
|
|
6748
6852
|
const overScanCount = Math.max(0, Math.ceil(overScan));
|
|
6749
6853
|
const startIndex = Math.max(0, visibleStartIndex - overScanCount);
|
|
@@ -6805,7 +6909,7 @@ function SimpleTable({
|
|
|
6805
6909
|
getRowExpandable,
|
|
6806
6910
|
onExpandedChange,
|
|
6807
6911
|
onLazyScrollLoad,
|
|
6808
|
-
scrollLoadThreshold =
|
|
6912
|
+
scrollLoadThreshold = 42,
|
|
6809
6913
|
numberOfPageButtons = 5,
|
|
6810
6914
|
onClickExport,
|
|
6811
6915
|
baseRowEstimateSize = 42,
|
|
@@ -6890,6 +6994,10 @@ function SimpleTable({
|
|
|
6890
6994
|
if (typeof maxRecords === "number" && data.length >= maxRecords) return;
|
|
6891
6995
|
void handleLazyLoad();
|
|
6892
6996
|
}, [recordPerChunk, data.length, handleLazyLoad, chunkCount, maxRecords]);
|
|
6997
|
+
const onLoadChunkRef = useRef(onLoadChunk);
|
|
6998
|
+
useEffect(() => {
|
|
6999
|
+
onLoadChunkRef.current = onLoadChunk;
|
|
7000
|
+
}, [onLoadChunk]);
|
|
6893
7001
|
const rows = useMemo(
|
|
6894
7002
|
() => table.getRowModel().rows,
|
|
6895
7003
|
[paginationState, sorting, columnFilters]
|
|
@@ -6931,7 +7039,7 @@ function SimpleTable({
|
|
|
6931
7039
|
rafRef.current = null;
|
|
6932
7040
|
const { scrollTop, scrollHeight, clientHeight } = container;
|
|
6933
7041
|
if (scrollHeight - (scrollTop + clientHeight) <= scrollLoadThreshold && scrollTop !== 0 && scrollHeight > clientHeight) {
|
|
6934
|
-
|
|
7042
|
+
onLoadChunkRef.current();
|
|
6935
7043
|
}
|
|
6936
7044
|
});
|
|
6937
7045
|
};
|
|
@@ -6944,7 +7052,7 @@ function SimpleTable({
|
|
|
6944
7052
|
rafRef.current = null;
|
|
6945
7053
|
}
|
|
6946
7054
|
};
|
|
6947
|
-
}, [scrollLoadThreshold,
|
|
7055
|
+
}, [scrollLoadThreshold, virtualizationActive]);
|
|
6948
7056
|
useEffect(() => {
|
|
6949
7057
|
if (virtualizationActive) return;
|
|
6950
7058
|
if (table.getState().pagination.pageIndex === 0) {
|
|
@@ -6953,23 +7061,10 @@ function SimpleTable({
|
|
|
6953
7061
|
}, [virtualizationActive]);
|
|
6954
7062
|
useEffect(() => {
|
|
6955
7063
|
if (!virtualItems.length || !virtualizationActive) return;
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
if (paddingBottom <= scrollLoadThreshold) {
|
|
6961
|
-
onLoadChunk();
|
|
6962
|
-
}
|
|
6963
|
-
});
|
|
6964
|
-
};
|
|
6965
|
-
scheduleCheck();
|
|
6966
|
-
return () => {
|
|
6967
|
-
if (rafRef.current != null) {
|
|
6968
|
-
cancelAnimationFrame(rafRef.current);
|
|
6969
|
-
rafRef.current = null;
|
|
6970
|
-
}
|
|
6971
|
-
};
|
|
6972
|
-
}, [paddingBottom]);
|
|
7064
|
+
if (paddingBottom <= scrollLoadThreshold) {
|
|
7065
|
+
onLoadChunkRef.current();
|
|
7066
|
+
}
|
|
7067
|
+
}, [paddingBottom, scrollLoadThreshold, virtualizationActive]);
|
|
6973
7068
|
const columnCount = table.getAllLeafColumns().length;
|
|
6974
7069
|
useEffect(() => {
|
|
6975
7070
|
if (!selectable || !onSelectionChange) return;
|
|
@@ -10324,8 +10419,9 @@ function SimpleCarousel({
|
|
|
10324
10419
|
}
|
|
10325
10420
|
),
|
|
10326
10421
|
showDots && /* @__PURE__ */ jsx("div", { className: "flex justify-center space-x-2 mt-4", children: Array.from({ length: count }).map((_, index) => /* @__PURE__ */ jsx(
|
|
10327
|
-
|
|
10422
|
+
Button,
|
|
10328
10423
|
{
|
|
10424
|
+
variant: "ghost",
|
|
10329
10425
|
className: cn(
|
|
10330
10426
|
"h-2 w-2 rounded-full transition-colors",
|
|
10331
10427
|
current === index + 1 ? "bg-primary" : "bg-primary/20 hover:bg-primary/40"
|