@linzjs/step-ag-grid 17.4.2 → 17.4.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/src/components/Grid.d.ts +1 -1
- package/dist/step-ag-grid.cjs.js +30 -9
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +30 -9
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +45 -13
- package/src/stories/grid/GridDragRow.stories.tsx +2 -1
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { LuiMiniSpinner, LuiIcon, LuiButton, LuiCheckboxInput, LuiButtonGroup } from '@linzjs/lui';
|
|
3
|
+
import { RowHighlightPosition } from 'ag-grid-community';
|
|
3
4
|
import { AgGridReact } from 'ag-grid-react';
|
|
4
5
|
import { negate, isEmpty, findIndex, defer as defer$1, debounce as debounce$1, xorBy, last, difference, omit, sortBy, delay, partition, pick, groupBy, fromPairs, toPairs, isEqual, compact, filter, sumBy, pull, remove, castArray, flatten } from 'lodash-es';
|
|
5
6
|
import React, { createContext, useContext, useRef, useEffect, useCallback, useState, useMemo, useLayoutEffect, memo, forwardRef, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
|
|
@@ -2523,7 +2524,6 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
2523
2524
|
},
|
|
2524
2525
|
checkboxSelection: params.selectable,
|
|
2525
2526
|
headerComponent: rowSelection === "multiple" ? GridHeaderSelect : null,
|
|
2526
|
-
//headerCheckboxSelection:true,
|
|
2527
2527
|
suppressHeaderKeyboardEvent: (e) => {
|
|
2528
2528
|
if (!params.selectable)
|
|
2529
2529
|
return false;
|
|
@@ -2739,13 +2739,34 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
2739
2739
|
}
|
|
2740
2740
|
}, []);
|
|
2741
2741
|
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
2742
|
-
const
|
|
2743
|
-
const
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2742
|
+
const onRowDragLeave = useCallback((event) => {
|
|
2743
|
+
const clientSideRowModel = event.api.getModel();
|
|
2744
|
+
clientSideRowModel.highlightRowAtPixel(null);
|
|
2745
|
+
}, []);
|
|
2746
|
+
const onRowDragMove = useCallback((event) => {
|
|
2747
|
+
const clientSideRowModel = event.api.getModel();
|
|
2748
|
+
clientSideRowModel.highlightRowAtPixel(event.node, event.y);
|
|
2749
|
+
}, []);
|
|
2750
|
+
const onRowDragEnd = useCallback(async (event) => {
|
|
2751
|
+
const clientSideRowModel = event.api.getModel();
|
|
2752
|
+
if (event.node.rowIndex) {
|
|
2753
|
+
const lastHighlightedRowNode = clientSideRowModel.getLastHighlightedRowNode();
|
|
2754
|
+
const isBelow = lastHighlightedRowNode && lastHighlightedRowNode.highlighted === RowHighlightPosition.Below;
|
|
2755
|
+
let targetIndex = event.overIndex;
|
|
2756
|
+
if (event.node.rowIndex > event.overIndex) {
|
|
2757
|
+
targetIndex += isBelow ? 1 : 0;
|
|
2758
|
+
}
|
|
2759
|
+
else {
|
|
2760
|
+
targetIndex += isBelow ? 0 : -1;
|
|
2761
|
+
}
|
|
2762
|
+
const moved = event.node.data;
|
|
2763
|
+
const target = event.overNode?.data;
|
|
2764
|
+
moved.id != target.id && //moved over a different row
|
|
2765
|
+
moved.rowIndex != targetIndex && //moved to a different index
|
|
2766
|
+
params.onRowDragEnd &&
|
|
2767
|
+
(await params.onRowDragEnd(moved, target, targetIndex));
|
|
2768
|
+
}
|
|
2769
|
+
clientSideRowModel.highlightRowAtPixel(null);
|
|
2749
2770
|
}, [params]);
|
|
2750
2771
|
// This is setting a ref in the GridContext so won't be triggering an update loop
|
|
2751
2772
|
setOnCellEditingComplete(params.onCellEditingComplete);
|
|
@@ -2755,7 +2776,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
2755
2776
|
let rowCount = 0;
|
|
2756
2777
|
event.api.forEachNode(() => rowCount++);
|
|
2757
2778
|
return (jsx(GridNoRowsOverlay, { rowCount: rowCount, filteredRowCount: event.api.getDisplayedRowCount(), noRowsOverlayText: params.noRowsOverlayText }));
|
|
2758
|
-
}, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText,
|
|
2779
|
+
}, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, onRowDragLeave: onRowDragLeave }) })] }));
|
|
2759
2780
|
};
|
|
2760
2781
|
|
|
2761
2782
|
const GridPopoverContext = createContext({
|