@bmsuisse/datagrid 0.31.0 → 0.31.1
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.d.ts +28 -5
- package/dist/index.js +153 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -668,7 +668,11 @@ declare function BooleanEditor<TRow>({ column, rowId, value, onChange, error, au
|
|
|
668
668
|
declare function DateEditor<TRow>({ column, rowId, value, onChange, error, autoFocus, }: EditWidgetProps<DateColumn<TRow>>): ReactElement;
|
|
669
669
|
|
|
670
670
|
/** Default inline editor for `type: "enum"` columns: a single-value select over `column.options`. */
|
|
671
|
-
declare function EnumEditor<TRow>({ column, rowId, value, onChange, error, autoFocus, }: EditWidgetProps<EnumColumn<TRow>>
|
|
671
|
+
declare function EnumEditor<TRow>({ column, rowId, value, onChange, error, autoFocus, open, onOpenChange, }: EditWidgetProps<EnumColumn<TRow>> & {
|
|
672
|
+
/** Controls the dropdown's own open state — omit to let `<Select>` manage it itself (the default, used everywhere except `AlwaysEditCell`; see that file's own doc for why it needs control here). */
|
|
673
|
+
open?: boolean;
|
|
674
|
+
onOpenChange?: (open: boolean) => void;
|
|
675
|
+
}): ReactElement;
|
|
672
676
|
|
|
673
677
|
/**
|
|
674
678
|
* Default inline editor for a `type: "string"` column with `multiline: true`:
|
|
@@ -1420,9 +1424,18 @@ interface DataGridProps<TRow> {
|
|
|
1420
1424
|
/**
|
|
1421
1425
|
* Renders the built-in Previous/Next pagination footer. Defaults to true.
|
|
1422
1426
|
* Set to false when a caller renders its own pagination UI instead (e.g.
|
|
1423
|
-
* one with specific `data-testid`s an existing test suite depends on)
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1427
|
+
* one with specific `data-testid`s an existing test suite depends on), or
|
|
1428
|
+
* to disable pagination altogether and render every row.
|
|
1429
|
+
*
|
|
1430
|
+
* When `false` and no explicit `pageSize` is given (via `initialState` or
|
|
1431
|
+
* `gridState`), the effective page size becomes unbounded instead of
|
|
1432
|
+
* defaulting to 20 — hiding the pagination UI with no page size in mind
|
|
1433
|
+
* means "show every row," not "silently truncate to the first page." A
|
|
1434
|
+
* caller who explicitly sets `pageSize` alongside `showPagination: false`
|
|
1435
|
+
* still gets exactly that page size (deliberate fixed-size chunking with
|
|
1436
|
+
* no UI). This only affects `"client"` mode's own row slicing; in
|
|
1437
|
+
* `"server"` mode, whether every row actually comes back is up to your
|
|
1438
|
+
* `dataSource`.
|
|
1426
1439
|
*/
|
|
1427
1440
|
showPagination?: boolean;
|
|
1428
1441
|
/**
|
|
@@ -1609,8 +1622,18 @@ interface GridStateController {
|
|
|
1609
1622
|
* across the component's lifetime — start controlled and stay controlled,
|
|
1610
1623
|
* or start uncontrolled and stay uncontrolled; toggling to `undefined`
|
|
1611
1624
|
* later does not hand ownership back, it just stops resyncing.
|
|
1625
|
+
*
|
|
1626
|
+
* `showPagination`, when `false` and the caller did NOT explicitly provide
|
|
1627
|
+
* `initialState.pageSize`, seeds `pageSize` as effectively unbounded instead
|
|
1628
|
+
* of `DEFAULT_STATE`'s 20 — "hide the pagination controls" means "no
|
|
1629
|
+
* pagination" by default, matching `<DataGrid>`'s `showPagination` doc. A
|
|
1630
|
+
* caller who explicitly sets `initialState.pageSize` (deliberate fixed-size
|
|
1631
|
+
* chunking with no UI, alongside `showPagination: false`) still gets exactly
|
|
1632
|
+
* that value; this only changes what happens when they didn't ask for a
|
|
1633
|
+
* particular page size at all. Has no effect once `externalState` is in
|
|
1634
|
+
* play — a controlled `GridState` is always fully caller-specified.
|
|
1612
1635
|
*/
|
|
1613
|
-
declare function useGridState<TRow>(dataSource: DataSource<TRow>, initialState?: Partial<GridState>, externalState?: GridState): GridStateController;
|
|
1636
|
+
declare function useGridState<TRow>(dataSource: DataSource<TRow>, initialState?: Partial<GridState>, externalState?: GridState, showPagination?: boolean): GridStateController;
|
|
1614
1637
|
|
|
1615
1638
|
interface ClientProcessingResult<TRow> {
|
|
1616
1639
|
rows: TRow[];
|
package/dist/index.js
CHANGED
|
@@ -1477,25 +1477,36 @@ function EnumEditor({
|
|
|
1477
1477
|
value,
|
|
1478
1478
|
onChange,
|
|
1479
1479
|
error,
|
|
1480
|
-
autoFocus
|
|
1480
|
+
autoFocus,
|
|
1481
|
+
open,
|
|
1482
|
+
onOpenChange
|
|
1481
1483
|
}) {
|
|
1482
1484
|
const errorId = editErrorId(rowId, column.id);
|
|
1483
1485
|
return /* @__PURE__ */ jsxs11("div", { children: [
|
|
1484
|
-
/* @__PURE__ */ jsxs11(
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1486
|
+
/* @__PURE__ */ jsxs11(
|
|
1487
|
+
Select,
|
|
1488
|
+
{
|
|
1489
|
+
value: value === null || value === void 0 ? "" : String(value),
|
|
1490
|
+
onValueChange: onChange,
|
|
1491
|
+
open,
|
|
1492
|
+
onOpenChange,
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ jsx18(
|
|
1495
|
+
SelectTrigger,
|
|
1496
|
+
{
|
|
1497
|
+
className: "h-8",
|
|
1498
|
+
"aria-label": `Edit ${column.header}`,
|
|
1499
|
+
"aria-invalid": error ? true : void 0,
|
|
1500
|
+
"aria-describedby": error ? errorId : void 0,
|
|
1501
|
+
"data-testid": `edit-${rowId}-${column.id}`,
|
|
1502
|
+
autoFocus,
|
|
1503
|
+
children: /* @__PURE__ */ jsx18(SelectValue, {})
|
|
1504
|
+
}
|
|
1505
|
+
),
|
|
1506
|
+
/* @__PURE__ */ jsx18(SelectContent, { children: column.options.map((option) => /* @__PURE__ */ jsx18(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
1507
|
+
]
|
|
1508
|
+
}
|
|
1509
|
+
),
|
|
1499
1510
|
error && /* @__PURE__ */ jsx18(EditFieldError, { id: errorId, message: error })
|
|
1500
1511
|
] });
|
|
1501
1512
|
}
|
|
@@ -2792,16 +2803,25 @@ import { BarsArrowDownIcon, BarsArrowUpIcon, FunnelIcon as FunnelIcon7 } from "@
|
|
|
2792
2803
|
import { columnResizingFeature, columnSizingFeature, flexRender, tableFeatures, useTable } from "@tanstack/react-table";
|
|
2793
2804
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
2794
2805
|
import { ChevronRight, Loader2 } from "lucide-react";
|
|
2795
|
-
import { Fragment as Fragment3, useEffect as
|
|
2806
|
+
import { Fragment as Fragment3, useEffect as useEffect10, useMemo as useMemo8, useRef as useRef11, useState as useState14 } from "react";
|
|
2796
2807
|
|
|
2797
2808
|
// src/cell-editing/renderAlwaysEditCell.tsx
|
|
2798
|
-
import {
|
|
2809
|
+
import {
|
|
2810
|
+
useEffect as useEffect7,
|
|
2811
|
+
useState as useState10
|
|
2812
|
+
} from "react";
|
|
2799
2813
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2800
2814
|
function AlwaysEditCell(props) {
|
|
2801
|
-
const { column, row, rawValue, ctx } = props;
|
|
2815
|
+
const { column, row, rawValue, ctx, atomicGesture } = props;
|
|
2802
2816
|
const rowId = ctx.getRowId(row);
|
|
2803
2817
|
const resolvedValue = ctx.resolveValue(rowId, column.id, rawValue);
|
|
2804
2818
|
const [draft, setDraft] = useState10(void 0);
|
|
2819
|
+
const [enumOpen, setEnumOpen] = useState10(false);
|
|
2820
|
+
const isBuiltinEnum = column.type === "enum" && !column.renderEditCell;
|
|
2821
|
+
const shouldOpenEnumNow = isBuiltinEnum && (atomicGesture?.shouldOpenEnum(rowId, column.id) ?? false);
|
|
2822
|
+
useEffect7(() => {
|
|
2823
|
+
if (shouldOpenEnumNow) setEnumOpen(true);
|
|
2824
|
+
}, [shouldOpenEnumNow]);
|
|
2805
2825
|
if (!isEditable(column, row)) {
|
|
2806
2826
|
return /* @__PURE__ */ jsx32("span", { "data-testid": `cell-${rowId}-${column.id}`, className: "block w-full", children: column.cell ? column.cell(resolvedValue, row) : defaultFormat(column, resolvedValue) });
|
|
2807
2827
|
}
|
|
@@ -2848,7 +2868,52 @@ function AlwaysEditCell(props) {
|
|
|
2848
2868
|
if (validate(draft.value)) setDraft(void 0);
|
|
2849
2869
|
else commit(draft.value);
|
|
2850
2870
|
}
|
|
2851
|
-
|
|
2871
|
+
function suppressNative(event) {
|
|
2872
|
+
event.stopPropagation();
|
|
2873
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
2874
|
+
return true;
|
|
2875
|
+
}
|
|
2876
|
+
function handleModifierCapture(event) {
|
|
2877
|
+
if (!isAtomic || isBuiltinEnum) return false;
|
|
2878
|
+
if (!(event.shiftKey || event.ctrlKey || event.metaKey)) return false;
|
|
2879
|
+
return suppressNative(event);
|
|
2880
|
+
}
|
|
2881
|
+
function handleEnumOpenCapture(event) {
|
|
2882
|
+
if (!isBuiltinEnum || enumOpen) return false;
|
|
2883
|
+
return suppressNative(event);
|
|
2884
|
+
}
|
|
2885
|
+
function handlePointerDownCapture(event) {
|
|
2886
|
+
const suppressed = handleModifierCapture(event) || handleEnumOpenCapture(event);
|
|
2887
|
+
if (suppressed) atomicGesture?.registerSelection(rowId, column.id, event.shiftKey);
|
|
2888
|
+
}
|
|
2889
|
+
function handleClickCapture(event) {
|
|
2890
|
+
handleModifierCapture(event);
|
|
2891
|
+
handleEnumOpenCapture(event);
|
|
2892
|
+
}
|
|
2893
|
+
return /* @__PURE__ */ jsx32(
|
|
2894
|
+
"fieldset",
|
|
2895
|
+
{
|
|
2896
|
+
disabled: ctx.disabled,
|
|
2897
|
+
onKeyDown: handleKeyDown,
|
|
2898
|
+
onBlur: handleBlur,
|
|
2899
|
+
onPointerDownCapture: handlePointerDownCapture,
|
|
2900
|
+
onClickCapture: handleClickCapture,
|
|
2901
|
+
className: "contents",
|
|
2902
|
+
children: column.type === "enum" && !column.renderEditCell ? /* @__PURE__ */ jsx32(
|
|
2903
|
+
EnumEditor,
|
|
2904
|
+
{
|
|
2905
|
+
column,
|
|
2906
|
+
rowId,
|
|
2907
|
+
value: currentValue,
|
|
2908
|
+
onChange,
|
|
2909
|
+
error,
|
|
2910
|
+
autoFocus: false,
|
|
2911
|
+
open: enumOpen,
|
|
2912
|
+
onOpenChange: setEnumOpen
|
|
2913
|
+
}
|
|
2914
|
+
) : column.renderEditCell ? column.renderEditCell(currentValue, row, onChange, error, false) : renderDefaultEditWidget(column, rowId, currentValue, onChange, error, false)
|
|
2915
|
+
}
|
|
2916
|
+
);
|
|
2852
2917
|
}
|
|
2853
2918
|
|
|
2854
2919
|
// src/hooks/useGroupExpansion.ts
|
|
@@ -2944,15 +3009,15 @@ function processClientData(data, state) {
|
|
|
2944
3009
|
}
|
|
2945
3010
|
|
|
2946
3011
|
// src/grid/useGridState.ts
|
|
2947
|
-
import { useCallback as useCallback4, useEffect as
|
|
3012
|
+
import { useCallback as useCallback4, useEffect as useEffect9, useMemo as useMemo7, useState as useState13 } from "react";
|
|
2948
3013
|
|
|
2949
3014
|
// src/hooks/useDebouncedCallback.ts
|
|
2950
|
-
import { useEffect as
|
|
3015
|
+
import { useEffect as useEffect8, useMemo as useMemo6, useRef as useRef10 } from "react";
|
|
2951
3016
|
function useDebouncedCallback(callback, delayMs) {
|
|
2952
3017
|
const callbackRef = useRef10(callback);
|
|
2953
3018
|
callbackRef.current = callback;
|
|
2954
3019
|
const timeoutRef = useRef10(void 0);
|
|
2955
|
-
|
|
3020
|
+
useEffect8(() => {
|
|
2956
3021
|
return () => {
|
|
2957
3022
|
clearTimeout(timeoutRef.current);
|
|
2958
3023
|
};
|
|
@@ -2981,10 +3046,12 @@ function nextSortDir(current, descFirst) {
|
|
|
2981
3046
|
if (current === first) return second;
|
|
2982
3047
|
return void 0;
|
|
2983
3048
|
}
|
|
2984
|
-
function useGridState(dataSource, initialState, externalState) {
|
|
2985
|
-
const [state, setState] = useState13(
|
|
2986
|
-
()
|
|
2987
|
-
|
|
3049
|
+
function useGridState(dataSource, initialState, externalState, showPagination = true) {
|
|
3050
|
+
const [state, setState] = useState13(() => {
|
|
3051
|
+
if (externalState) return externalState;
|
|
3052
|
+
const pageSize = initialState?.pageSize ?? (showPagination ? DEFAULT_STATE.pageSize : Number.MAX_SAFE_INTEGER);
|
|
3053
|
+
return { ...DEFAULT_STATE, ...initialState, pageSize };
|
|
3054
|
+
});
|
|
2988
3055
|
const notifyRaw = useCallback4(
|
|
2989
3056
|
(next) => {
|
|
2990
3057
|
if (dataSource.mode === "server") dataSource.onStateChange(next);
|
|
@@ -3002,7 +3069,7 @@ function useGridState(dataSource, initialState, externalState) {
|
|
|
3002
3069
|
},
|
|
3003
3070
|
[notifyRaw, cancelDebouncedNotify]
|
|
3004
3071
|
);
|
|
3005
|
-
|
|
3072
|
+
useEffect9(() => {
|
|
3006
3073
|
if (!externalState) return;
|
|
3007
3074
|
cancelDebouncedNotify();
|
|
3008
3075
|
setState(externalState);
|
|
@@ -3107,7 +3174,7 @@ function computeHeaderRuns(columns) {
|
|
|
3107
3174
|
}
|
|
3108
3175
|
return runs;
|
|
3109
3176
|
}
|
|
3110
|
-
function toTanstackColumns(columns, editingCtxRef, cellEditingCtxRef) {
|
|
3177
|
+
function toTanstackColumns(columns, editingCtxRef, cellEditingCtxRef, atomicGestureRef) {
|
|
3111
3178
|
return columns.map((column) => ({
|
|
3112
3179
|
id: column.id,
|
|
3113
3180
|
header: column.header,
|
|
@@ -3116,7 +3183,16 @@ function toTanstackColumns(columns, editingCtxRef, cellEditingCtxRef) {
|
|
|
3116
3183
|
cell: (info) => {
|
|
3117
3184
|
const cellEditingCtx = cellEditingCtxRef.current;
|
|
3118
3185
|
if (!cellEditingCtx) return renderEditableCell(column, info.row.original, info.getValue(), editingCtxRef.current);
|
|
3119
|
-
return cellEditingCtx.alwaysEdit ? /* @__PURE__ */ jsx33(
|
|
3186
|
+
return cellEditingCtx.alwaysEdit ? /* @__PURE__ */ jsx33(
|
|
3187
|
+
AlwaysEditCell,
|
|
3188
|
+
{
|
|
3189
|
+
column,
|
|
3190
|
+
row: info.row.original,
|
|
3191
|
+
rawValue: info.getValue(),
|
|
3192
|
+
ctx: cellEditingCtx,
|
|
3193
|
+
atomicGesture: atomicGestureRef.current
|
|
3194
|
+
}
|
|
3195
|
+
) : renderCellModeCell(column, info.row.original, info.getValue(), cellEditingCtx);
|
|
3120
3196
|
}
|
|
3121
3197
|
}));
|
|
3122
3198
|
}
|
|
@@ -3156,7 +3232,8 @@ function DataGrid({
|
|
|
3156
3232
|
const { state, filtersByColumn, setColumnFilter, toggleSort, setPage } = useGridState(
|
|
3157
3233
|
dataSource,
|
|
3158
3234
|
initialState,
|
|
3159
|
-
gridState
|
|
3235
|
+
gridState,
|
|
3236
|
+
showPagination
|
|
3160
3237
|
);
|
|
3161
3238
|
const [internalSelectedIds, setInternalSelectedIds] = useState14(/* @__PURE__ */ new Set());
|
|
3162
3239
|
const selectedIds = controlledSelectedIds ?? internalSelectedIds;
|
|
@@ -3192,6 +3269,7 @@ function DataGrid({
|
|
|
3192
3269
|
hasCellEditing ? cellEditing : void 0,
|
|
3193
3270
|
getRowId
|
|
3194
3271
|
);
|
|
3272
|
+
const atomicGestureRef = useRef11(void 0);
|
|
3195
3273
|
const visibleColumns = useVisibleColumns(columns, columnVisibility);
|
|
3196
3274
|
const serverRowCount = dataSource.mode === "server" ? dataSource.rowCount : void 0;
|
|
3197
3275
|
const { rows, rowCount } = useMemo8(() => {
|
|
@@ -3218,7 +3296,7 @@ function DataGrid({
|
|
|
3218
3296
|
updateSelectedIds(next);
|
|
3219
3297
|
}
|
|
3220
3298
|
const tanstackColumns = useMemo8(
|
|
3221
|
-
() => toTanstackColumns(visibleColumns, editingCtxRef, cellEditingCtxRef),
|
|
3299
|
+
() => toTanstackColumns(visibleColumns, editingCtxRef, cellEditingCtxRef, atomicGestureRef),
|
|
3222
3300
|
[visibleColumns]
|
|
3223
3301
|
);
|
|
3224
3302
|
const columnById = useMemo8(() => {
|
|
@@ -3345,6 +3423,18 @@ function DataGrid({
|
|
|
3345
3423
|
return map;
|
|
3346
3424
|
}, [visibleColumns, enableColumnResizing, leftPinnedOffsets, rightPinnedOffsets, columnSizing]);
|
|
3347
3425
|
const tableRows = table.getRowModel().rows;
|
|
3426
|
+
const truncationWarnedRef = useRef11(false);
|
|
3427
|
+
useEffect10(() => {
|
|
3428
|
+
if (process.env.NODE_ENV === "production") return;
|
|
3429
|
+
if (showPagination) return;
|
|
3430
|
+
if (truncationWarnedRef.current) return;
|
|
3431
|
+
if (!gridState && initialState?.pageSize !== void 0) return;
|
|
3432
|
+
if (tableRows.length >= rowCount) return;
|
|
3433
|
+
truncationWarnedRef.current = true;
|
|
3434
|
+
console.warn(
|
|
3435
|
+
`[DataGrid] showPagination={false} but only ${tableRows.length} of ${rowCount} row(s) are rendered, with no pagination UI to reach the rest. Pass an explicit pageSize (via initialState or gridState) that covers every row you want visible, or a dataSource that returns all of them.`
|
|
3436
|
+
);
|
|
3437
|
+
}, [showPagination, gridState, initialState?.pageSize, tableRows.length, rowCount]);
|
|
3348
3438
|
const groupedBuckets = useMemo8(
|
|
3349
3439
|
() => groupBy ? groupRows(tableRows, (row) => groupBy(row.original)) : void 0,
|
|
3350
3440
|
[tableRows, groupBy]
|
|
@@ -3377,7 +3467,7 @@ function DataGrid({
|
|
|
3377
3467
|
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end : 0;
|
|
3378
3468
|
const lastVisibleIndex = virtualItems.length > 0 ? virtualItems[virtualItems.length - 1].index : -1;
|
|
3379
3469
|
const notifiedForLengthRef = useRef11(-1);
|
|
3380
|
-
|
|
3470
|
+
useEffect10(() => {
|
|
3381
3471
|
if (!virtualize?.onEndReached) return;
|
|
3382
3472
|
if (lastVisibleIndex < 0 || lastVisibleIndex < flatItems.length - 1) return;
|
|
3383
3473
|
if (virtualize.hasMore === false) return;
|
|
@@ -3405,6 +3495,21 @@ function DataGrid({
|
|
|
3405
3495
|
});
|
|
3406
3496
|
const clickCellRef = useRef11(null);
|
|
3407
3497
|
const dragMovedRef = useRef11(false);
|
|
3498
|
+
const [pendingOpenEnumCell, setPendingOpenEnumCell] = useState14(void 0);
|
|
3499
|
+
atomicGestureRef.current = {
|
|
3500
|
+
shouldOpenEnum: (rowId, columnId) => pendingOpenEnumCell?.rowId === rowId && pendingOpenEnumCell?.columnId === columnId,
|
|
3501
|
+
// Mirrors exactly what `handleCellMouseDown` below does for every other
|
|
3502
|
+
// cell, minus the click-to-edit-only tail end (irrelevant here — always
|
|
3503
|
+
// invoked under `alwaysEdit`, same as that function's own early return
|
|
3504
|
+
// for it) — see `AtomicGestureContext.registerSelection`'s own doc for
|
|
3505
|
+
// why `AlwaysEditCell` can't just rely on that function running on its
|
|
3506
|
+
// own for a gesture it suppresses.
|
|
3507
|
+
registerSelection: (rowId, columnId, extend) => {
|
|
3508
|
+
cellSelection.startSelection({ rowId, columnId }, { extend });
|
|
3509
|
+
clickCellRef.current = { rowId, columnId, extend, wasEditing: false };
|
|
3510
|
+
dragMovedRef.current = false;
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3408
3513
|
function beginEditFromClick(cell) {
|
|
3409
3514
|
if (!cellEditingCtx) return;
|
|
3410
3515
|
if (cellEditingCtx.editingCell?.rowId === cell.rowId && cellEditingCtx.editingCell.columnId === cell.columnId) return;
|
|
@@ -3415,7 +3520,7 @@ function DataGrid({
|
|
|
3415
3520
|
}
|
|
3416
3521
|
const pendingDragCellRef = useRef11(null);
|
|
3417
3522
|
const dragRafRef = useRef11(null);
|
|
3418
|
-
|
|
3523
|
+
useEffect10(() => {
|
|
3419
3524
|
if (!cellSelection.isDragging) return;
|
|
3420
3525
|
function handleMouseMove(event) {
|
|
3421
3526
|
const cellEl = event.target?.closest("[data-cell-row]");
|
|
@@ -3435,7 +3540,15 @@ function DataGrid({
|
|
|
3435
3540
|
cellSelection.endDrag();
|
|
3436
3541
|
const clickCell = clickCellRef.current;
|
|
3437
3542
|
clickCellRef.current = null;
|
|
3438
|
-
if (clickCell
|
|
3543
|
+
if (!clickCell || clickCell.extend || clickCell.wasEditing || dragMovedRef.current) return;
|
|
3544
|
+
if (cellEditingCtx?.alwaysEdit) {
|
|
3545
|
+
const column = columnById.get(clickCell.columnId);
|
|
3546
|
+
if (column?.type === "enum" && !column.renderEditCell) {
|
|
3547
|
+
setPendingOpenEnumCell({ rowId: clickCell.rowId, columnId: clickCell.columnId });
|
|
3548
|
+
}
|
|
3549
|
+
return;
|
|
3550
|
+
}
|
|
3551
|
+
beginEditFromClick(clickCell);
|
|
3439
3552
|
}
|
|
3440
3553
|
window.addEventListener("mousemove", handleMouseMove);
|
|
3441
3554
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -3448,7 +3561,7 @@ function DataGrid({
|
|
|
3448
3561
|
}, [cellSelection.isDragging, cellSelection.updateDrag, cellSelection.endDrag]);
|
|
3449
3562
|
const pendingFillCellRef = useRef11(null);
|
|
3450
3563
|
const fillRafRef = useRef11(null);
|
|
3451
|
-
|
|
3564
|
+
useEffect10(() => {
|
|
3452
3565
|
if (!cellSelection.isFillDragging) return;
|
|
3453
3566
|
function handleMouseMove(event) {
|
|
3454
3567
|
const cellEl = event.target?.closest("[data-cell-row]");
|
|
@@ -3485,7 +3598,7 @@ function DataGrid({
|
|
|
3485
3598
|
};
|
|
3486
3599
|
}, [cellSelection.isFillDragging, cellSelection.updateFillDrag, cellSelection.endFillDrag]);
|
|
3487
3600
|
const wasEditingCellRef = useRef11(void 0);
|
|
3488
|
-
|
|
3601
|
+
useEffect10(() => {
|
|
3489
3602
|
const wasEditing = wasEditingCellRef.current !== void 0;
|
|
3490
3603
|
wasEditingCellRef.current = cellEditingCtx?.editingCell;
|
|
3491
3604
|
if (!wasEditing || cellEditingCtx?.editingCell) return;
|
|
@@ -3501,10 +3614,10 @@ function DataGrid({
|
|
|
3501
3614
|
const columnId = cellEl?.dataset.cellCol;
|
|
3502
3615
|
if (rowId === void 0 || columnId === void 0) return;
|
|
3503
3616
|
cellSelection.startSelection({ rowId, columnId }, { extend: event.shiftKey });
|
|
3504
|
-
if (cellEditingCtx?.alwaysEdit) return;
|
|
3505
3617
|
const wasEditing = cellEditingCtx?.editingCell?.rowId === rowId && cellEditingCtx.editingCell.columnId === columnId;
|
|
3506
3618
|
clickCellRef.current = { rowId, columnId, extend: event.shiftKey, wasEditing };
|
|
3507
3619
|
dragMovedRef.current = false;
|
|
3620
|
+
if (cellEditingCtx?.alwaysEdit) return;
|
|
3508
3621
|
if (wasEditing) return;
|
|
3509
3622
|
scrollRef.current?.focus();
|
|
3510
3623
|
}
|
|
@@ -4024,7 +4137,7 @@ function DataGrid({
|
|
|
4024
4137
|
// src/tree/TreeDataGrid.tsx
|
|
4025
4138
|
import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
|
|
4026
4139
|
import { AlertCircle, ChevronDown as ChevronDown2, ChevronRight as ChevronRight2, Loader2 as Loader22 } from "lucide-react";
|
|
4027
|
-
import { Fragment as Fragment5, useEffect as
|
|
4140
|
+
import { Fragment as Fragment5, useEffect as useEffect11, useMemo as useMemo10, useRef as useRef12 } from "react";
|
|
4028
4141
|
|
|
4029
4142
|
// src/tree/flattenTree.ts
|
|
4030
4143
|
function flattenTree(roots, accessors, expanded, childrenOverride) {
|
|
@@ -4276,7 +4389,7 @@ function TreeDataGrid({
|
|
|
4276
4389
|
onChildrenMapChange
|
|
4277
4390
|
});
|
|
4278
4391
|
const didAutoExpand = useRef12(false);
|
|
4279
|
-
|
|
4392
|
+
useEffect11(() => {
|
|
4280
4393
|
if (didAutoExpand.current) return;
|
|
4281
4394
|
didAutoExpand.current = true;
|
|
4282
4395
|
if (initialExpandedLevel > 0) void expandToLevel(initialExpandedLevel);
|