@linzjs/step-ag-grid 1.4.0 → 1.4.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 +1 -0
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/src/components/Grid.d.ts +3 -2
- package/dist/step-ag-grid.esm.js +17 -4
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +20 -12
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -24,8 +24,9 @@ export interface GridProps {
|
|
|
24
24
|
quickFilter?: boolean;
|
|
25
25
|
quickFilterPlaceholder?: string;
|
|
26
26
|
quickFilterValue?: string;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
domLayout?: GridOptions["domLayout"];
|
|
28
|
+
externalSelectedItems?: any[];
|
|
29
|
+
setExternalSelectedItems?: (items: any[]) => void;
|
|
29
30
|
onGridReady?: GridOptions["onGridReady"];
|
|
30
31
|
defaultColDef: GridOptions["defaultColDef"];
|
|
31
32
|
columnDefs: GridOptions["columnDefs"];
|
|
@@ -59,16 +60,21 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
59
60
|
/**
|
|
60
61
|
* Ensure external selected items list is in sync with panel.
|
|
61
62
|
*/
|
|
62
|
-
const synchroniseExternalStateToGridSelection = (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const synchroniseExternalStateToGridSelection = useCallback(
|
|
64
|
+
({ api }: SelectionChangedEvent) => {
|
|
65
|
+
if (!params.externalSelectedItems || !params.setExternalSelectedItems) return;
|
|
66
|
+
|
|
67
|
+
const selectedRows = api.getSelectedRows();
|
|
68
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
69
|
+
if (
|
|
70
|
+
params.externalSelectedItems.length != selectedRows.length ||
|
|
71
|
+
isNotEmpty(xorBy(selectedRows, params.externalSelectedItems, (row) => row.id))
|
|
72
|
+
) {
|
|
73
|
+
params.setExternalSelectedItems([...selectedRows]);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[params],
|
|
77
|
+
);
|
|
72
78
|
|
|
73
79
|
/**
|
|
74
80
|
* Synchronise externally selected items to grid.
|
|
@@ -76,6 +82,7 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
76
82
|
*/
|
|
77
83
|
const synchroniseExternallySelectedItemsToGrid = useCallback(() => {
|
|
78
84
|
if (!gridReady()) return;
|
|
85
|
+
if (!params.externalSelectedItems) return;
|
|
79
86
|
|
|
80
87
|
const selectedIds = params.externalSelectedItems.map((row) => row.id) as number[];
|
|
81
88
|
const lastNewId = last(difference(selectedIds, lastSelectedIds.current));
|
|
@@ -253,6 +260,7 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
253
260
|
onCellDoubleClicked={onCellDoubleClick}
|
|
254
261
|
onCellEditingStarted={refreshSelectedRows}
|
|
255
262
|
onCellEditingStopped={onCellEditingStopped}
|
|
263
|
+
domLayout={params.domLayout}
|
|
256
264
|
columnDefs={columnDefs}
|
|
257
265
|
rowData={params.rowData}
|
|
258
266
|
noRowsOverlayComponent={noRowsOverlayComponent}
|