@linzjs/step-ag-grid 7.11.12 → 7.12.0
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/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { AgGridReact } from "ag-grid-react";
|
|
|
4
4
|
import { CellClickedEvent, ColDef } from "ag-grid-community";
|
|
5
5
|
import { CellEvent, GridReadyEvent, SelectionChangedEvent } from "ag-grid-community/dist/lib/events";
|
|
6
6
|
import { GridOptions } from "ag-grid-community/dist/lib/entities/gridOptions";
|
|
7
|
-
import { difference, last, xorBy } from "lodash-es";
|
|
7
|
+
import { difference, isEmpty, last, xorBy } from "lodash-es";
|
|
8
8
|
import { GridContext } from "../contexts/GridContext";
|
|
9
9
|
import { usePostSortRowsHook } from "./PostSortRowsHook";
|
|
10
10
|
import { fnOrVar, isNotEmpty } from "../utils/util";
|
|
@@ -35,6 +35,7 @@ export interface GridProps {
|
|
|
35
35
|
rowClassRules?: GridOptions["rowClassRules"];
|
|
36
36
|
rowSelection?: "single" | "multiple";
|
|
37
37
|
autoSelectFirstRow?: boolean;
|
|
38
|
+
onColumnMoved?: GridOptions["onColumnMoved"];
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -65,12 +66,8 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
65
66
|
useEffect(() => {
|
|
66
67
|
if (!gridReady || !params.autoSelectFirstRow || hasSelectedFirstItem.current || !params.rowData) return;
|
|
67
68
|
hasSelectedFirstItem.current = true;
|
|
68
|
-
if (isNotEmpty(params.rowData)) {
|
|
69
|
-
|
|
70
|
-
params.setExternalSelectedItems([params.rowData[0]]);
|
|
71
|
-
} else {
|
|
72
|
-
selectRowsById([params.rowData[0].id]);
|
|
73
|
-
}
|
|
69
|
+
if (isNotEmpty(params.rowData) && isEmpty(params.externalSelectedItems)) {
|
|
70
|
+
selectRowsById([params.rowData[0].id]);
|
|
74
71
|
}
|
|
75
72
|
}, [gridReady, params, params.autoSelectFirstRow, params.rowData, selectRowsById]);
|
|
76
73
|
|
|
@@ -343,6 +340,7 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
343
340
|
onSortChanged={ensureSelectedRowIsVisible}
|
|
344
341
|
postSortRows={params.postSortRows ?? postSortRows}
|
|
345
342
|
onSelectionChanged={synchroniseExternalStateToGridSelection}
|
|
343
|
+
onColumnMoved={params.onColumnMoved}
|
|
346
344
|
/>
|
|
347
345
|
</div>
|
|
348
346
|
);
|