@alaarab/ogrid-react 2.1.6 → 2.1.8
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/esm/index.js
CHANGED
|
@@ -74,6 +74,9 @@ function getCellValue(item, col) {
|
|
|
74
74
|
if (col.valueGetter) return col.valueGetter(item);
|
|
75
75
|
return item[col.columnId];
|
|
76
76
|
}
|
|
77
|
+
function isColumnEditable(col, item) {
|
|
78
|
+
return col.editable === true || typeof col.editable === "function" && col.editable(item);
|
|
79
|
+
}
|
|
77
80
|
function isColumnGroupDef(c) {
|
|
78
81
|
return "children" in c && Array.isArray(c.children);
|
|
79
82
|
}
|
|
@@ -735,9 +738,9 @@ function getHeaderFilterConfig(col, input) {
|
|
|
735
738
|
function getCellRenderDescriptor(item, col, rowIndex, colIdx, input) {
|
|
736
739
|
const rowId = input.getRowId(item);
|
|
737
740
|
const globalColIndex = colIdx + input.colOffset;
|
|
738
|
-
const colEditable = col
|
|
739
|
-
const canEditInline = input.editable !== false &&
|
|
740
|
-
const canEditPopup = input.editable !== false &&
|
|
741
|
+
const colEditable = isColumnEditable(col, item);
|
|
742
|
+
const canEditInline = input.editable !== false && colEditable && !!input.onCellValueChanged && typeof col.cellEditor !== "function";
|
|
743
|
+
const canEditPopup = input.editable !== false && colEditable && !!input.onCellValueChanged && typeof col.cellEditor === "function" && col.cellEditorPopup !== false;
|
|
741
744
|
const canEditAny = canEditInline || canEditPopup;
|
|
742
745
|
const isEditing = input.editingCell?.rowId === rowId && input.editingCell?.columnId === col.columnId;
|
|
743
746
|
const isActive = !input.isDragging && input.activeCell?.rowIndex === rowIndex && input.activeCell?.columnIndex === globalColIndex;
|
|
@@ -850,6 +853,18 @@ function measureRange(container, range, colOffset) {
|
|
|
850
853
|
height: brRect.bottom - tlRect.top
|
|
851
854
|
};
|
|
852
855
|
}
|
|
856
|
+
function buildCellIndex(container) {
|
|
857
|
+
const index = /* @__PURE__ */ new Map();
|
|
858
|
+
if (!container) return index;
|
|
859
|
+
const cells = container.querySelectorAll("[data-row-index][data-col-index]");
|
|
860
|
+
for (let i = 0; i < cells.length; i++) {
|
|
861
|
+
const el = cells[i];
|
|
862
|
+
const r = el.getAttribute("data-row-index") ?? "";
|
|
863
|
+
const c = el.getAttribute("data-col-index") ?? "";
|
|
864
|
+
index.set(`${r},${c}`, el);
|
|
865
|
+
}
|
|
866
|
+
return index;
|
|
867
|
+
}
|
|
853
868
|
function injectGlobalStyles(id, css) {
|
|
854
869
|
if (typeof document === "undefined") return;
|
|
855
870
|
if (document.getElementById(id)) return;
|
|
@@ -1003,8 +1018,7 @@ function applyCellDeletion(range, items, visibleCols) {
|
|
|
1003
1018
|
if (r >= items.length || c >= visibleCols.length) continue;
|
|
1004
1019
|
const item = items[r];
|
|
1005
1020
|
const col = visibleCols[c];
|
|
1006
|
-
|
|
1007
|
-
if (!colEditable) continue;
|
|
1021
|
+
if (!isColumnEditable(col, item)) continue;
|
|
1008
1022
|
const oldValue = getCellValue(item, col);
|
|
1009
1023
|
const result = parseValue("", oldValue, item, col);
|
|
1010
1024
|
if (!result.valid) continue;
|
|
@@ -1100,8 +1114,7 @@ function applyPastedValues(parsedRows, anchorRow, anchorCol, items, visibleCols)
|
|
|
1100
1114
|
if (targetRow >= items.length || targetCol >= visibleCols.length) continue;
|
|
1101
1115
|
const item = items[targetRow];
|
|
1102
1116
|
const col = visibleCols[targetCol];
|
|
1103
|
-
|
|
1104
|
-
if (!colEditable) continue;
|
|
1117
|
+
if (!isColumnEditable(col, item)) continue;
|
|
1105
1118
|
const rawValue = cells[c] ?? "";
|
|
1106
1119
|
const oldValue = getCellValue(item, col);
|
|
1107
1120
|
const result = parseValue(rawValue, oldValue, item, col);
|
|
@@ -1124,8 +1137,7 @@ function applyCutClear(cutRange, items, visibleCols) {
|
|
|
1124
1137
|
if (r >= items.length || c >= visibleCols.length) continue;
|
|
1125
1138
|
const item = items[r];
|
|
1126
1139
|
const col = visibleCols[c];
|
|
1127
|
-
|
|
1128
|
-
if (!colEditable) continue;
|
|
1140
|
+
if (!isColumnEditable(col, item)) continue;
|
|
1129
1141
|
const oldValue = getCellValue(item, col);
|
|
1130
1142
|
const result = parseValue("", oldValue, item, col);
|
|
1131
1143
|
if (!result.valid) continue;
|
|
@@ -1152,8 +1164,7 @@ function applyFillValues(range, sourceRow, sourceCol, items, visibleCols) {
|
|
|
1152
1164
|
if (row >= items.length || col >= visibleCols.length) continue;
|
|
1153
1165
|
const item = items[row];
|
|
1154
1166
|
const colDef = visibleCols[col];
|
|
1155
|
-
|
|
1156
|
-
if (!colEditable) continue;
|
|
1167
|
+
if (!isColumnEditable(colDef, item)) continue;
|
|
1157
1168
|
const oldValue = getCellValue(item, colDef);
|
|
1158
1169
|
const result = parseValue(startValue, oldValue, item, colDef);
|
|
1159
1170
|
if (!result.valid) continue;
|
|
@@ -1631,7 +1642,7 @@ var EMPTY_LOADING_OPTIONS2 = {};
|
|
|
1631
1642
|
function useOGrid(props, ref) {
|
|
1632
1643
|
const {
|
|
1633
1644
|
columns: columnsProp,
|
|
1634
|
-
getRowId,
|
|
1645
|
+
getRowId: getRowIdProp,
|
|
1635
1646
|
data,
|
|
1636
1647
|
dataSource,
|
|
1637
1648
|
page: controlledPage,
|
|
@@ -1646,7 +1657,7 @@ function useOGrid(props, ref) {
|
|
|
1646
1657
|
onFiltersChange,
|
|
1647
1658
|
onVisibleColumnsChange,
|
|
1648
1659
|
columnOrder,
|
|
1649
|
-
onColumnOrderChange,
|
|
1660
|
+
onColumnOrderChange: onColumnOrderChangeProp,
|
|
1650
1661
|
onColumnResized,
|
|
1651
1662
|
onColumnPinned,
|
|
1652
1663
|
defaultPageSize = DEFAULT_PAGE_SIZE,
|
|
@@ -1661,9 +1672,9 @@ function useOGrid(props, ref) {
|
|
|
1661
1672
|
suppressHorizontalScroll,
|
|
1662
1673
|
editable,
|
|
1663
1674
|
cellSelection,
|
|
1664
|
-
onCellValueChanged,
|
|
1665
|
-
onUndo,
|
|
1666
|
-
onRedo,
|
|
1675
|
+
onCellValueChanged: onCellValueChangedProp,
|
|
1676
|
+
onUndo: onUndoProp,
|
|
1677
|
+
onRedo: onRedoProp,
|
|
1667
1678
|
canUndo,
|
|
1668
1679
|
canRedo,
|
|
1669
1680
|
rowSelection = "none",
|
|
@@ -1685,6 +1696,32 @@ function useOGrid(props, ref) {
|
|
|
1685
1696
|
"aria-label": ariaLabel,
|
|
1686
1697
|
"aria-labelledby": ariaLabelledBy
|
|
1687
1698
|
} = props;
|
|
1699
|
+
const getRowIdStableRef = useLatestRef(getRowIdProp);
|
|
1700
|
+
const getRowId = useCallback((item) => getRowIdStableRef.current(item), [getRowIdStableRef]);
|
|
1701
|
+
const onColumnOrderChangeRef = useLatestRef(onColumnOrderChangeProp);
|
|
1702
|
+
const onColumnOrderChange = useMemo(
|
|
1703
|
+
() => onColumnOrderChangeProp ? (order) => onColumnOrderChangeRef.current?.(order) : void 0,
|
|
1704
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1705
|
+
[!!onColumnOrderChangeProp]
|
|
1706
|
+
);
|
|
1707
|
+
const onCellValueChangedRef = useLatestRef(onCellValueChangedProp);
|
|
1708
|
+
const onCellValueChanged = useMemo(
|
|
1709
|
+
() => onCellValueChangedProp ? (event) => onCellValueChangedRef.current?.(event) : void 0,
|
|
1710
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1711
|
+
[!!onCellValueChangedProp]
|
|
1712
|
+
);
|
|
1713
|
+
const onUndoRef = useLatestRef(onUndoProp);
|
|
1714
|
+
const onUndo = useMemo(
|
|
1715
|
+
() => onUndoProp ? () => onUndoRef.current?.() : void 0,
|
|
1716
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1717
|
+
[!!onUndoProp]
|
|
1718
|
+
);
|
|
1719
|
+
const onRedoRef = useLatestRef(onRedoProp);
|
|
1720
|
+
const onRedo = useMemo(
|
|
1721
|
+
() => onRedoProp ? () => onRedoRef.current?.() : void 0,
|
|
1722
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1723
|
+
[!!onRedoProp]
|
|
1724
|
+
);
|
|
1688
1725
|
const columnChooserPlacement = columnChooserProp === false ? "none" : columnChooserProp === "sidebar" ? "sidebar" : "toolbar";
|
|
1689
1726
|
const columns = useMemo(() => flattenColumns(columnsProp), [columnsProp]);
|
|
1690
1727
|
const isServerSide = dataSource != null;
|
|
@@ -2241,18 +2278,6 @@ function useCellSelection(params) {
|
|
|
2241
2278
|
useEffect(() => {
|
|
2242
2279
|
const markedCells = /* @__PURE__ */ new Set();
|
|
2243
2280
|
let cellIndex = null;
|
|
2244
|
-
const buildCellIndex = () => {
|
|
2245
|
-
const wrapper = wrapperRef.current;
|
|
2246
|
-
if (!wrapper) return;
|
|
2247
|
-
cellIndex = /* @__PURE__ */ new Map();
|
|
2248
|
-
const cells = wrapper.querySelectorAll("[data-row-index][data-col-index]");
|
|
2249
|
-
for (let i = 0; i < cells.length; i++) {
|
|
2250
|
-
const el = cells[i];
|
|
2251
|
-
const r = el.getAttribute("data-row-index") ?? "";
|
|
2252
|
-
const c = el.getAttribute("data-col-index") ?? "";
|
|
2253
|
-
cellIndex.set(`${r},${c}`, el);
|
|
2254
|
-
}
|
|
2255
|
-
};
|
|
2256
2281
|
const styleCellInRange = (el, r, c, minR, maxR, minC, maxC, anchor) => {
|
|
2257
2282
|
if (!el.hasAttribute(DRAG_ATTR)) el.setAttribute(DRAG_ATTR, "");
|
|
2258
2283
|
const isAnchor = anchor && r === anchor.row && c === anchor.col;
|
|
@@ -2292,13 +2317,13 @@ function useCellSelection(params) {
|
|
|
2292
2317
|
markedCells.delete(el);
|
|
2293
2318
|
}
|
|
2294
2319
|
}
|
|
2295
|
-
if (!cellIndex) buildCellIndex();
|
|
2320
|
+
if (!cellIndex) cellIndex = buildCellIndex(wrapperRef.current);
|
|
2296
2321
|
for (let r = minR; r <= maxR; r++) {
|
|
2297
2322
|
for (let c = minC; c <= maxC; c++) {
|
|
2298
2323
|
const key = `${r},${c + colOff}`;
|
|
2299
2324
|
let el = cellIndex?.get(key);
|
|
2300
2325
|
if (el && !el.isConnected) {
|
|
2301
|
-
buildCellIndex();
|
|
2326
|
+
cellIndex = buildCellIndex(wrapperRef.current);
|
|
2302
2327
|
el = cellIndex?.get(key);
|
|
2303
2328
|
}
|
|
2304
2329
|
if (el) {
|
|
@@ -2397,7 +2422,7 @@ function useCellSelection(params) {
|
|
|
2397
2422
|
if (!dragMovedRef.current) {
|
|
2398
2423
|
dragMovedRef.current = true;
|
|
2399
2424
|
setIsDragging(true);
|
|
2400
|
-
buildCellIndex();
|
|
2425
|
+
cellIndex = buildCellIndex(wrapperRef.current);
|
|
2401
2426
|
}
|
|
2402
2427
|
lastMousePosRef.current = { cx: e.clientX, cy: e.clientY };
|
|
2403
2428
|
updateAutoScroll();
|
|
@@ -2865,6 +2890,7 @@ function useKeyboardNavigation(params) {
|
|
|
2865
2890
|
}
|
|
2866
2891
|
function useUndoRedo(params) {
|
|
2867
2892
|
const { onCellValueChanged, maxUndoDepth = 100 } = params;
|
|
2893
|
+
const onCellValueChangedRef = useLatestRef(onCellValueChanged);
|
|
2868
2894
|
const stackRef = useRef(null);
|
|
2869
2895
|
if (stackRef.current === null) {
|
|
2870
2896
|
stackRef.current = new UndoRedoStack(maxUndoDepth);
|
|
@@ -2878,16 +2904,17 @@ function useUndoRedo(params) {
|
|
|
2878
2904
|
}, []);
|
|
2879
2905
|
const wrapped = useCallback(
|
|
2880
2906
|
(event) => {
|
|
2881
|
-
if (!
|
|
2907
|
+
if (!onCellValueChangedRef.current) return;
|
|
2882
2908
|
const stack = getStack();
|
|
2883
2909
|
stack.record(event);
|
|
2884
2910
|
if (!stack.isBatching) {
|
|
2885
2911
|
setHistoryLength(stack.historyLength);
|
|
2886
2912
|
setRedoLength(stack.redoLength);
|
|
2887
2913
|
}
|
|
2888
|
-
|
|
2914
|
+
onCellValueChangedRef.current(event);
|
|
2889
2915
|
},
|
|
2890
|
-
|
|
2916
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2917
|
+
[getStack]
|
|
2891
2918
|
);
|
|
2892
2919
|
const beginBatch = useCallback(() => {
|
|
2893
2920
|
getStack().beginBatch();
|
|
@@ -2899,7 +2926,7 @@ function useUndoRedo(params) {
|
|
|
2899
2926
|
setRedoLength(stack.redoLength);
|
|
2900
2927
|
}, [getStack]);
|
|
2901
2928
|
const undo = useCallback(() => {
|
|
2902
|
-
if (!
|
|
2929
|
+
if (!onCellValueChangedRef.current) return;
|
|
2903
2930
|
const stack = getStack();
|
|
2904
2931
|
const lastBatch = stack.undo();
|
|
2905
2932
|
if (!lastBatch) return;
|
|
@@ -2907,24 +2934,24 @@ function useUndoRedo(params) {
|
|
|
2907
2934
|
setRedoLength(stack.redoLength);
|
|
2908
2935
|
for (let i = lastBatch.length - 1; i >= 0; i--) {
|
|
2909
2936
|
const ev = lastBatch[i];
|
|
2910
|
-
|
|
2937
|
+
onCellValueChangedRef.current({
|
|
2911
2938
|
...ev,
|
|
2912
2939
|
oldValue: ev.newValue,
|
|
2913
2940
|
newValue: ev.oldValue
|
|
2914
2941
|
});
|
|
2915
2942
|
}
|
|
2916
|
-
}, [
|
|
2943
|
+
}, [getStack]);
|
|
2917
2944
|
const redo = useCallback(() => {
|
|
2918
|
-
if (!
|
|
2945
|
+
if (!onCellValueChangedRef.current) return;
|
|
2919
2946
|
const stack = getStack();
|
|
2920
2947
|
const nextBatch = stack.redo();
|
|
2921
2948
|
if (!nextBatch) return;
|
|
2922
2949
|
setHistoryLength(stack.historyLength);
|
|
2923
2950
|
setRedoLength(stack.redoLength);
|
|
2924
2951
|
for (const ev of nextBatch) {
|
|
2925
|
-
|
|
2952
|
+
onCellValueChangedRef.current(ev);
|
|
2926
2953
|
}
|
|
2927
|
-
}, [
|
|
2954
|
+
}, [getStack]);
|
|
2928
2955
|
return {
|
|
2929
2956
|
onCellValueChanged: onCellValueChanged ? wrapped : void 0,
|
|
2930
2957
|
undo,
|
|
@@ -2952,7 +2979,7 @@ function useFillHandle(params) {
|
|
|
2952
2979
|
items,
|
|
2953
2980
|
visibleCols,
|
|
2954
2981
|
editable,
|
|
2955
|
-
onCellValueChanged,
|
|
2982
|
+
onCellValueChanged: onCellValueChangedProp,
|
|
2956
2983
|
selectionRange,
|
|
2957
2984
|
setSelectionRange,
|
|
2958
2985
|
setActiveCell,
|
|
@@ -2961,30 +2988,18 @@ function useFillHandle(params) {
|
|
|
2961
2988
|
beginBatch,
|
|
2962
2989
|
endBatch
|
|
2963
2990
|
} = params;
|
|
2991
|
+
const onCellValueChangedRef = useLatestRef(onCellValueChangedProp);
|
|
2964
2992
|
const [fillDrag, setFillDrag] = useState(null);
|
|
2965
2993
|
const fillDragEndRef = useRef({ endRow: 0, endCol: 0 });
|
|
2966
2994
|
const rafRef = useRef(0);
|
|
2967
2995
|
const liveFillRangeRef = useRef(null);
|
|
2968
2996
|
const colOffsetRef = useLatestRef(colOffset);
|
|
2969
2997
|
useEffect(() => {
|
|
2970
|
-
if (!fillDrag || editable === false || !
|
|
2998
|
+
if (!fillDrag || editable === false || !onCellValueChangedRef.current || !wrapperRef.current) return;
|
|
2971
2999
|
fillDragEndRef.current = { endRow: fillDrag.startRow, endCol: fillDrag.startCol };
|
|
2972
3000
|
liveFillRangeRef.current = null;
|
|
2973
3001
|
const markedCells = /* @__PURE__ */ new Set();
|
|
2974
|
-
let cellIndex =
|
|
2975
|
-
const buildCellIndex = () => {
|
|
2976
|
-
const wrapper = wrapperRef.current;
|
|
2977
|
-
if (!wrapper) return;
|
|
2978
|
-
cellIndex = /* @__PURE__ */ new Map();
|
|
2979
|
-
const cells = wrapper.querySelectorAll("[data-row-index][data-col-index]");
|
|
2980
|
-
for (let i = 0; i < cells.length; i++) {
|
|
2981
|
-
const el = cells[i];
|
|
2982
|
-
const r = el.getAttribute("data-row-index") ?? "";
|
|
2983
|
-
const c = el.getAttribute("data-col-index") ?? "";
|
|
2984
|
-
cellIndex.set(`${r},${c}`, el);
|
|
2985
|
-
}
|
|
2986
|
-
};
|
|
2987
|
-
buildCellIndex();
|
|
3002
|
+
let cellIndex = buildCellIndex(wrapperRef.current);
|
|
2988
3003
|
const applyDragAttrs = (range) => {
|
|
2989
3004
|
const wrapper = wrapperRef.current;
|
|
2990
3005
|
if (!wrapper) return;
|
|
@@ -3006,8 +3021,8 @@ function useFillHandle(params) {
|
|
|
3006
3021
|
const key = `${r},${c + colOff}`;
|
|
3007
3022
|
let el = cellIndex?.get(key);
|
|
3008
3023
|
if (el && !el.isConnected) {
|
|
3009
|
-
buildCellIndex();
|
|
3010
|
-
el = cellIndex
|
|
3024
|
+
cellIndex = buildCellIndex(wrapperRef.current);
|
|
3025
|
+
el = cellIndex.get(key);
|
|
3011
3026
|
}
|
|
3012
3027
|
if (el) {
|
|
3013
3028
|
if (!el.hasAttribute(DRAG_ATTR2)) el.setAttribute(DRAG_ATTR2, "");
|
|
@@ -3021,7 +3036,6 @@ function useFillHandle(params) {
|
|
|
3021
3036
|
el.removeAttribute(DRAG_ATTR2);
|
|
3022
3037
|
}
|
|
3023
3038
|
markedCells.clear();
|
|
3024
|
-
cellIndex = null;
|
|
3025
3039
|
};
|
|
3026
3040
|
let lastFillMousePos = null;
|
|
3027
3041
|
const resolveRange = (cx, cy) => {
|
|
@@ -3081,7 +3095,7 @@ function useFillHandle(params) {
|
|
|
3081
3095
|
const fillEvents = applyFillValues(norm, fillDrag.startRow, fillDrag.startCol, items, visibleCols);
|
|
3082
3096
|
if (fillEvents.length > 0) {
|
|
3083
3097
|
beginBatch?.();
|
|
3084
|
-
for (const evt of fillEvents)
|
|
3098
|
+
for (const evt of fillEvents) onCellValueChangedRef.current?.(evt);
|
|
3085
3099
|
endBatch?.();
|
|
3086
3100
|
}
|
|
3087
3101
|
setFillDrag(null);
|
|
@@ -3101,7 +3115,6 @@ function useFillHandle(params) {
|
|
|
3101
3115
|
visibleCols,
|
|
3102
3116
|
setSelectionRange,
|
|
3103
3117
|
setActiveCell,
|
|
3104
|
-
onCellValueChanged,
|
|
3105
3118
|
beginBatch,
|
|
3106
3119
|
endBatch,
|
|
3107
3120
|
colOffsetRef,
|
|
@@ -3577,11 +3590,14 @@ function useDataGridEditing(params) {
|
|
|
3577
3590
|
pendingEditorValue,
|
|
3578
3591
|
setPendingEditorValue,
|
|
3579
3592
|
onCellValueChanged,
|
|
3580
|
-
setActiveCell
|
|
3593
|
+
setActiveCell,
|
|
3594
|
+
setSelectionRange,
|
|
3595
|
+
colOffset
|
|
3581
3596
|
} = params;
|
|
3582
3597
|
const [popoverAnchorEl, setPopoverAnchorEl] = useState(null);
|
|
3583
3598
|
const visibleColsRef = useLatestRef(params.visibleCols);
|
|
3584
3599
|
const itemsLengthRef = useLatestRef(params.itemsLength);
|
|
3600
|
+
const onCellValueChangedRef = useLatestRef(onCellValueChanged);
|
|
3585
3601
|
const commitCellEdit = useCallback(
|
|
3586
3602
|
(item, columnId, oldValue, newValue, rowIndex, globalColIndex) => {
|
|
3587
3603
|
const col = visibleColsRef.current.find((c) => c.columnId === columnId);
|
|
@@ -3595,7 +3611,7 @@ function useDataGridEditing(params) {
|
|
|
3595
3611
|
}
|
|
3596
3612
|
newValue = result.value;
|
|
3597
3613
|
}
|
|
3598
|
-
|
|
3614
|
+
onCellValueChangedRef.current?.({
|
|
3599
3615
|
item,
|
|
3600
3616
|
columnId,
|
|
3601
3617
|
oldValue,
|
|
@@ -3606,10 +3622,14 @@ function useDataGridEditing(params) {
|
|
|
3606
3622
|
setPopoverAnchorEl(null);
|
|
3607
3623
|
setPendingEditorValue(void 0);
|
|
3608
3624
|
if (rowIndex < itemsLengthRef.current - 1) {
|
|
3609
|
-
|
|
3625
|
+
const newRow = rowIndex + 1;
|
|
3626
|
+
const localCol = globalColIndex - colOffset;
|
|
3627
|
+
setActiveCell({ rowIndex: newRow, columnIndex: globalColIndex });
|
|
3628
|
+
setSelectionRange({ startRow: newRow, startCol: localCol, endRow: newRow, endCol: localCol });
|
|
3610
3629
|
}
|
|
3611
3630
|
},
|
|
3612
|
-
|
|
3631
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3632
|
+
[setEditingCell, setPendingEditorValue, setActiveCell, setSelectionRange, colOffset, visibleColsRef, itemsLengthRef]
|
|
3613
3633
|
);
|
|
3614
3634
|
const cancelPopoverEdit = useCallback(() => {
|
|
3615
3635
|
setEditingCell(null);
|
|
@@ -3885,6 +3905,7 @@ function useDataGridState(params) {
|
|
|
3885
3905
|
});
|
|
3886
3906
|
const {
|
|
3887
3907
|
selectionRange,
|
|
3908
|
+
setSelectionRange,
|
|
3888
3909
|
cutRange,
|
|
3889
3910
|
copyRange,
|
|
3890
3911
|
isDragging,
|
|
@@ -3898,7 +3919,9 @@ function useDataGridState(params) {
|
|
|
3898
3919
|
visibleCols,
|
|
3899
3920
|
itemsLength: items.length,
|
|
3900
3921
|
onCellValueChanged,
|
|
3901
|
-
setActiveCell
|
|
3922
|
+
setActiveCell,
|
|
3923
|
+
setSelectionRange,
|
|
3924
|
+
colOffset
|
|
3902
3925
|
});
|
|
3903
3926
|
const {
|
|
3904
3927
|
sortBy,
|
|
@@ -3909,6 +3932,7 @@ function useDataGridState(params) {
|
|
|
3909
3932
|
loadingFilterOptions,
|
|
3910
3933
|
peopleSearch
|
|
3911
3934
|
} = props;
|
|
3935
|
+
const hasPeopleSearch = !!peopleSearch;
|
|
3912
3936
|
const onFilterChangeRef = useLatestRef(onFilterChange);
|
|
3913
3937
|
const peopleSearchRef = useLatestRef(peopleSearch);
|
|
3914
3938
|
const stableOnFilterChange = useCallback(
|
|
@@ -3928,7 +3952,7 @@ function useDataGridState(params) {
|
|
|
3928
3952
|
onFilterChange: stableOnFilterChange,
|
|
3929
3953
|
filterOptions,
|
|
3930
3954
|
loadingFilterOptions,
|
|
3931
|
-
peopleSearch:
|
|
3955
|
+
peopleSearch: hasPeopleSearch ? stablePeopleSearch : void 0
|
|
3932
3956
|
}),
|
|
3933
3957
|
[
|
|
3934
3958
|
sortBy,
|
|
@@ -3938,7 +3962,7 @@ function useDataGridState(params) {
|
|
|
3938
3962
|
stableOnFilterChange,
|
|
3939
3963
|
filterOptions,
|
|
3940
3964
|
loadingFilterOptions,
|
|
3941
|
-
|
|
3965
|
+
hasPeopleSearch,
|
|
3942
3966
|
stablePeopleSearch
|
|
3943
3967
|
]
|
|
3944
3968
|
);
|
|
@@ -24,6 +24,13 @@ export interface UseDataGridEditingParams<T> {
|
|
|
24
24
|
rowIndex: number;
|
|
25
25
|
columnIndex: number;
|
|
26
26
|
} | null) => void;
|
|
27
|
+
setSelectionRange: (range: {
|
|
28
|
+
startRow: number;
|
|
29
|
+
startCol: number;
|
|
30
|
+
endRow: number;
|
|
31
|
+
endCol: number;
|
|
32
|
+
} | null) => void;
|
|
33
|
+
colOffset: number;
|
|
27
34
|
}
|
|
28
35
|
export interface UseDataGridEditingResult<T> {
|
|
29
36
|
editing: DataGridEditingState<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, GRID_CONTEXT_MENU_ITEMS, COLUMN_HEADER_MENU_ITEMS, getContextMenuHandlers, getColumnHeaderMenuItems, formatShortcut, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, computeNextSortState, measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, applyPastedValues, applyCutClear, applyFillValues, computeArrowNavigation, applyCellDeletion, applyRangeRowSelection, computeRowSelectionState, UndoRedoStack, } from '@alaarab/ogrid-core';
|
|
1
|
+
export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, GRID_CONTEXT_MENU_ITEMS, COLUMN_HEADER_MENU_ITEMS, getContextMenuHandlers, getColumnHeaderMenuItems, formatShortcut, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, computeNextSortState, measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX, findCtrlArrowTarget, computeTabNavigation, rangesEqual, clampSelectionToBounds, computeAutoScrollSpeed, formatCellValueForTsv, formatSelectionAsTsv, parseTsvClipboard, applyPastedValues, applyCutClear, applyFillValues, computeArrowNavigation, applyCellDeletion, applyRangeRowSelection, computeRowSelectionState, UndoRedoStack, buildCellIndex, } from '@alaarab/ogrid-core';
|
|
2
2
|
export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, ParseValueResult, AggregationResult, IColumnHeaderMenuItem, ColumnHeaderMenuInput, ColumnHeaderMenuHandlers, ArrowNavigationContext, ArrowNavigationResult, } from '@alaarab/ogrid-core';
|
|
3
3
|
export { getHeaderFilterConfig, getCellRenderDescriptor, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, } from './dataGridViewModel';
|
|
4
4
|
export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, } from './dataGridViewModel';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alaarab/ogrid-react",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"description": "OGrid React – React hooks, headless components, and utilities for OGrid data grids.",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=18"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@alaarab/ogrid-core": "2.1.
|
|
42
|
+
"@alaarab/ogrid-core": "2.1.8",
|
|
43
43
|
"@tanstack/react-virtual": "^3.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|