@bmsuisse/datagrid 0.31.1 → 0.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2272,7 +2272,7 @@ function renderCellModeCell(column, row, rawValue, ctx) {
|
|
|
2272
2272
|
}
|
|
2273
2273
|
|
|
2274
2274
|
// src/cell-editing/SelectionOverlay.tsx
|
|
2275
|
-
import { useLayoutEffect as useLayoutEffect2, useState as useState9 } from "react";
|
|
2275
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef9, useState as useState9 } from "react";
|
|
2276
2276
|
import { Fragment as Fragment2, jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2277
2277
|
function cellSelector(rowId, columnId) {
|
|
2278
2278
|
const escape = (value) => typeof CSS !== "undefined" && CSS.escape ? CSS.escape(value) : value.replace(/["\\]/g, "\\$&");
|
|
@@ -2305,13 +2305,27 @@ function SelectionOverlay({
|
|
|
2305
2305
|
}) {
|
|
2306
2306
|
const [rect, setRect] = useState9(void 0);
|
|
2307
2307
|
const [previewRect, setPreviewRect] = useState9(void 0);
|
|
2308
|
-
|
|
2308
|
+
const recomputeRef = useRef9(() => {
|
|
2309
|
+
});
|
|
2310
|
+
recomputeRef.current = () => {
|
|
2309
2311
|
const container = containerRef.current;
|
|
2310
2312
|
const nextRect = range && container ? computeRangeRect(container, range) : void 0;
|
|
2311
2313
|
setRect((prev) => rectsEqual(prev, nextRect) ? prev : nextRect);
|
|
2312
2314
|
const nextPreviewRect = fillPreviewRange && container ? computeRangeRect(container, fillPreviewRange) : void 0;
|
|
2313
2315
|
setPreviewRect((prev) => rectsEqual(prev, nextPreviewRect) ? prev : nextPreviewRect);
|
|
2316
|
+
};
|
|
2317
|
+
useLayoutEffect2(() => {
|
|
2318
|
+
recomputeRef.current();
|
|
2314
2319
|
});
|
|
2320
|
+
useLayoutEffect2(() => {
|
|
2321
|
+
const container = containerRef.current;
|
|
2322
|
+
if (!container) return;
|
|
2323
|
+
function handleScroll() {
|
|
2324
|
+
recomputeRef.current();
|
|
2325
|
+
}
|
|
2326
|
+
container.addEventListener("scroll", handleScroll, { passive: true });
|
|
2327
|
+
return () => container.removeEventListener("scroll", handleScroll);
|
|
2328
|
+
}, [containerRef.current]);
|
|
2315
2329
|
if (!rect) return null;
|
|
2316
2330
|
return /* @__PURE__ */ jsxs16(Fragment2, { children: [
|
|
2317
2331
|
/* @__PURE__ */ jsx27(
|
|
@@ -2803,7 +2817,7 @@ import { BarsArrowDownIcon, BarsArrowUpIcon, FunnelIcon as FunnelIcon7 } from "@
|
|
|
2803
2817
|
import { columnResizingFeature, columnSizingFeature, flexRender, tableFeatures, useTable } from "@tanstack/react-table";
|
|
2804
2818
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
2805
2819
|
import { ChevronRight, Loader2 } from "lucide-react";
|
|
2806
|
-
import { Fragment as Fragment3, useEffect as useEffect10, useMemo as useMemo8, useRef as
|
|
2820
|
+
import { Fragment as Fragment3, useEffect as useEffect10, useMemo as useMemo8, useRef as useRef12, useState as useState14 } from "react";
|
|
2807
2821
|
|
|
2808
2822
|
// src/cell-editing/renderAlwaysEditCell.tsx
|
|
2809
2823
|
import {
|
|
@@ -2942,9 +2956,9 @@ function useGroupExpansion(defaultGroupsExpanded, controlledExpandedGroups, onEx
|
|
|
2942
2956
|
}
|
|
2943
2957
|
|
|
2944
2958
|
// src/hooks/useStickyGroupHeaderTop.ts
|
|
2945
|
-
import { useLayoutEffect as useLayoutEffect3, useRef as
|
|
2959
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef10, useState as useState12 } from "react";
|
|
2946
2960
|
function useStickyGroupHeaderTop(enabled) {
|
|
2947
|
-
const theadRef =
|
|
2961
|
+
const theadRef = useRef10(null);
|
|
2948
2962
|
const [groupHeaderTop, setGroupHeaderTop] = useState12(0);
|
|
2949
2963
|
useLayoutEffect3(() => {
|
|
2950
2964
|
if (!enabled) return;
|
|
@@ -3012,11 +3026,11 @@ function processClientData(data, state) {
|
|
|
3012
3026
|
import { useCallback as useCallback4, useEffect as useEffect9, useMemo as useMemo7, useState as useState13 } from "react";
|
|
3013
3027
|
|
|
3014
3028
|
// src/hooks/useDebouncedCallback.ts
|
|
3015
|
-
import { useEffect as useEffect8, useMemo as useMemo6, useRef as
|
|
3029
|
+
import { useEffect as useEffect8, useMemo as useMemo6, useRef as useRef11 } from "react";
|
|
3016
3030
|
function useDebouncedCallback(callback, delayMs) {
|
|
3017
|
-
const callbackRef =
|
|
3031
|
+
const callbackRef = useRef11(callback);
|
|
3018
3032
|
callbackRef.current = callback;
|
|
3019
|
-
const timeoutRef =
|
|
3033
|
+
const timeoutRef = useRef11(void 0);
|
|
3020
3034
|
useEffect8(() => {
|
|
3021
3035
|
return () => {
|
|
3022
3036
|
clearTimeout(timeoutRef.current);
|
|
@@ -3269,7 +3283,7 @@ function DataGrid({
|
|
|
3269
3283
|
hasCellEditing ? cellEditing : void 0,
|
|
3270
3284
|
getRowId
|
|
3271
3285
|
);
|
|
3272
|
-
const atomicGestureRef =
|
|
3286
|
+
const atomicGestureRef = useRef12(void 0);
|
|
3273
3287
|
const visibleColumns = useVisibleColumns(columns, columnVisibility);
|
|
3274
3288
|
const serverRowCount = dataSource.mode === "server" ? dataSource.rowCount : void 0;
|
|
3275
3289
|
const { rows, rowCount } = useMemo8(() => {
|
|
@@ -3423,7 +3437,7 @@ function DataGrid({
|
|
|
3423
3437
|
return map;
|
|
3424
3438
|
}, [visibleColumns, enableColumnResizing, leftPinnedOffsets, rightPinnedOffsets, columnSizing]);
|
|
3425
3439
|
const tableRows = table.getRowModel().rows;
|
|
3426
|
-
const truncationWarnedRef =
|
|
3440
|
+
const truncationWarnedRef = useRef12(false);
|
|
3427
3441
|
useEffect10(() => {
|
|
3428
3442
|
if (process.env.NODE_ENV === "production") return;
|
|
3429
3443
|
if (showPagination) return;
|
|
@@ -3454,7 +3468,7 @@ function DataGrid({
|
|
|
3454
3468
|
}
|
|
3455
3469
|
return items;
|
|
3456
3470
|
}, [shouldVirtualize, groupedBuckets, tableRows, isGroupExpanded]);
|
|
3457
|
-
const scrollRef =
|
|
3471
|
+
const scrollRef = useRef12(null);
|
|
3458
3472
|
const virtualizer = useVirtualizer({
|
|
3459
3473
|
count: flatItems.length,
|
|
3460
3474
|
getScrollElement: () => scrollRef.current,
|
|
@@ -3466,7 +3480,10 @@ function DataGrid({
|
|
|
3466
3480
|
const paddingTop = virtualItems.length > 0 ? virtualItems[0].start : 0;
|
|
3467
3481
|
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end : 0;
|
|
3468
3482
|
const lastVisibleIndex = virtualItems.length > 0 ? virtualItems[virtualItems.length - 1].index : -1;
|
|
3469
|
-
const notifiedForLengthRef =
|
|
3483
|
+
const notifiedForLengthRef = useRef12(-1);
|
|
3484
|
+
useEffect10(() => {
|
|
3485
|
+
notifiedForLengthRef.current = -1;
|
|
3486
|
+
}, [state.filter, state.sort]);
|
|
3470
3487
|
useEffect10(() => {
|
|
3471
3488
|
if (!virtualize?.onEndReached) return;
|
|
3472
3489
|
if (lastVisibleIndex < 0 || lastVisibleIndex < flatItems.length - 1) return;
|
|
@@ -3493,8 +3510,8 @@ function DataGrid({
|
|
|
3493
3510
|
if (index !== void 0) virtualizer.scrollToIndex(index);
|
|
3494
3511
|
}
|
|
3495
3512
|
});
|
|
3496
|
-
const clickCellRef =
|
|
3497
|
-
const dragMovedRef =
|
|
3513
|
+
const clickCellRef = useRef12(null);
|
|
3514
|
+
const dragMovedRef = useRef12(false);
|
|
3498
3515
|
const [pendingOpenEnumCell, setPendingOpenEnumCell] = useState14(void 0);
|
|
3499
3516
|
atomicGestureRef.current = {
|
|
3500
3517
|
shouldOpenEnum: (rowId, columnId) => pendingOpenEnumCell?.rowId === rowId && pendingOpenEnumCell?.columnId === columnId,
|
|
@@ -3518,8 +3535,8 @@ function DataGrid({
|
|
|
3518
3535
|
if (!column || row === void 0 || !isEditable(column, row)) return;
|
|
3519
3536
|
cellEditingCtx.onBeginEdit(cell);
|
|
3520
3537
|
}
|
|
3521
|
-
const pendingDragCellRef =
|
|
3522
|
-
const dragRafRef =
|
|
3538
|
+
const pendingDragCellRef = useRef12(null);
|
|
3539
|
+
const dragRafRef = useRef12(null);
|
|
3523
3540
|
useEffect10(() => {
|
|
3524
3541
|
if (!cellSelection.isDragging) return;
|
|
3525
3542
|
function handleMouseMove(event) {
|
|
@@ -3559,8 +3576,8 @@ function DataGrid({
|
|
|
3559
3576
|
dragRafRef.current = null;
|
|
3560
3577
|
};
|
|
3561
3578
|
}, [cellSelection.isDragging, cellSelection.updateDrag, cellSelection.endDrag]);
|
|
3562
|
-
const pendingFillCellRef =
|
|
3563
|
-
const fillRafRef =
|
|
3579
|
+
const pendingFillCellRef = useRef12(null);
|
|
3580
|
+
const fillRafRef = useRef12(null);
|
|
3564
3581
|
useEffect10(() => {
|
|
3565
3582
|
if (!cellSelection.isFillDragging) return;
|
|
3566
3583
|
function handleMouseMove(event) {
|
|
@@ -3597,7 +3614,7 @@ function DataGrid({
|
|
|
3597
3614
|
fillRafRef.current = null;
|
|
3598
3615
|
};
|
|
3599
3616
|
}, [cellSelection.isFillDragging, cellSelection.updateFillDrag, cellSelection.endFillDrag]);
|
|
3600
|
-
const wasEditingCellRef =
|
|
3617
|
+
const wasEditingCellRef = useRef12(void 0);
|
|
3601
3618
|
useEffect10(() => {
|
|
3602
3619
|
const wasEditing = wasEditingCellRef.current !== void 0;
|
|
3603
3620
|
wasEditingCellRef.current = cellEditingCtx?.editingCell;
|
|
@@ -4137,7 +4154,7 @@ function DataGrid({
|
|
|
4137
4154
|
// src/tree/TreeDataGrid.tsx
|
|
4138
4155
|
import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
|
|
4139
4156
|
import { AlertCircle, ChevronDown as ChevronDown2, ChevronRight as ChevronRight2, Loader2 as Loader22 } from "lucide-react";
|
|
4140
|
-
import { Fragment as Fragment5, useEffect as useEffect11, useMemo as useMemo10, useRef as
|
|
4157
|
+
import { Fragment as Fragment5, useEffect as useEffect11, useMemo as useMemo10, useRef as useRef13 } from "react";
|
|
4141
4158
|
|
|
4142
4159
|
// src/tree/flattenTree.ts
|
|
4143
4160
|
function flattenTree(roots, accessors, expanded, childrenOverride) {
|
|
@@ -4388,7 +4405,7 @@ function TreeDataGrid({
|
|
|
4388
4405
|
childrenMap: controlledChildrenMap,
|
|
4389
4406
|
onChildrenMapChange
|
|
4390
4407
|
});
|
|
4391
|
-
const didAutoExpand =
|
|
4408
|
+
const didAutoExpand = useRef13(false);
|
|
4392
4409
|
useEffect11(() => {
|
|
4393
4410
|
if (didAutoExpand.current) return;
|
|
4394
4411
|
didAutoExpand.current = true;
|
|
@@ -4464,7 +4481,7 @@ function TreeDataGrid({
|
|
|
4464
4481
|
for (const column of visibleColumns) map.set(column.id, `p-2 ${alignClassName(column)}`);
|
|
4465
4482
|
return map;
|
|
4466
4483
|
}, [visibleColumns]);
|
|
4467
|
-
const scrollRef =
|
|
4484
|
+
const scrollRef = useRef13(null);
|
|
4468
4485
|
const shouldVirtualize = !groupBy && flatRows.length > virtualizeThreshold;
|
|
4469
4486
|
const virtualizer = useVirtualizer2({
|
|
4470
4487
|
count: flatRows.length,
|