@linzjs/step-ag-grid 7.11.6 → 7.11.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/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/step-ag-grid.esm.js +28 -2
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +12 -0
- package/src/contexts/GridContextProvider.tsx +16 -3
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +8 -3
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -178,6 +178,18 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
178
178
|
suppressSizeToFit: true,
|
|
179
179
|
checkboxSelection: true,
|
|
180
180
|
headerComponent: GridHeaderSelect,
|
|
181
|
+
suppressHeaderKeyboardEvent: (e) => {
|
|
182
|
+
if (e.event.key === "Enter" && !e.event.repeat) {
|
|
183
|
+
const selectedNodeCount = e.api.getSelectedRows().length;
|
|
184
|
+
if (selectedNodeCount == 0) {
|
|
185
|
+
e.api.selectAllFiltered();
|
|
186
|
+
} else {
|
|
187
|
+
e.api.deselectAll();
|
|
188
|
+
}
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
},
|
|
181
193
|
onCellClicked: clickSelectorCheckboxWhenContainingCellClicked,
|
|
182
194
|
},
|
|
183
195
|
...adjustColDefs,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement, ReactNode, useContext, useRef, useState } from "react";
|
|
2
|
-
import { GridApi, RowNode } from "ag-grid-community";
|
|
2
|
+
import { ColDef, GridApi, RowNode } from "ag-grid-community";
|
|
3
3
|
import { GridContext } from "./GridContext";
|
|
4
|
-
import { delay, difference, isEmpty, last, sortBy } from "lodash-es";
|
|
4
|
+
import { defer, delay, difference, isEmpty, last, sortBy } from "lodash-es";
|
|
5
5
|
import { isNotEmpty, wait } from "../utils/util";
|
|
6
6
|
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
7
7
|
import { GridBaseRow } from "../components/Grid";
|
|
@@ -131,7 +131,20 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
|
131
131
|
(node) => node.data.id,
|
|
132
132
|
);
|
|
133
133
|
const firstNode = rowsThatNeedSelecting[0];
|
|
134
|
-
|
|
134
|
+
if (firstNode) {
|
|
135
|
+
gridApi.ensureNodeVisible(firstNode);
|
|
136
|
+
const colDefs = gridApi.getColumnDefs();
|
|
137
|
+
if (colDefs && colDefs.length) {
|
|
138
|
+
const col = colDefs[0] as ColDef; // We don't support ColGroupDef
|
|
139
|
+
const rowIndex = firstNode.rowIndex;
|
|
140
|
+
if (rowIndex != null && col != null) {
|
|
141
|
+
const colId = col.colId;
|
|
142
|
+
// We need to make sure we aren't currently editing a cell otherwise tests will fail
|
|
143
|
+
// as they will start to edit the cell before this stuff has a chance to run
|
|
144
|
+
colId != null && defer(() => isEmpty(gridApi.getEditingCells()) && gridApi.setFocusedCell(rowIndex, colId));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
135
148
|
if (select) {
|
|
136
149
|
// Select rows that shouldn't be selected
|
|
137
150
|
rowsThatNeedSelecting.forEach((node) => node.setSelected(true));
|
|
@@ -7,7 +7,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/clien
|
|
|
7
7
|
import { GridUpdatingContextProvider } from "../../contexts/GridUpdatingContextProvider";
|
|
8
8
|
import { GridContextProvider } from "../../contexts/GridContextProvider";
|
|
9
9
|
import { Grid, GridProps } from "../../components/Grid";
|
|
10
|
-
import { useCallback, useMemo, useState } from "react";
|
|
10
|
+
import { useCallback, useContext, useMemo, useState } from "react";
|
|
11
11
|
import { ColDefT, GridCell } from "../../components/GridCell";
|
|
12
12
|
import { IFormTestRow } from "./FormTest";
|
|
13
13
|
import { isFloat, wait } from "../../utils/util";
|
|
@@ -15,6 +15,7 @@ import { GridPopoverTextArea } from "../../components/gridPopoverEdit/GridPopove
|
|
|
15
15
|
import { GridPopoverTextInput } from "../../components/gridPopoverEdit/GridPopoverTextInput";
|
|
16
16
|
import { ActionButton } from "../../lui/ActionButton";
|
|
17
17
|
import { GridPopoverMenu } from "../../components/gridPopoverEdit/GridPopoverMenu";
|
|
18
|
+
import { GridContext } from "../../contexts/GridContext";
|
|
18
19
|
|
|
19
20
|
export default {
|
|
20
21
|
title: "Components / Grids",
|
|
@@ -37,6 +38,7 @@ export default {
|
|
|
37
38
|
} as ComponentMeta<typeof Grid>;
|
|
38
39
|
|
|
39
40
|
const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridProps) => {
|
|
41
|
+
const { selectRowsWithFlashDiff } = useContext(GridContext);
|
|
40
42
|
const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
|
|
41
43
|
const [rowData, setRowData] = useState([
|
|
42
44
|
{ id: 1000, name: "IS IS DP12345", nameType: "IS", numba: "IX", plan: "DP 12345", distance: 10 },
|
|
@@ -155,9 +157,12 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
|
|
|
155
157
|
|
|
156
158
|
const addRowAction = useCallback(async () => {
|
|
157
159
|
await wait(1000);
|
|
160
|
+
|
|
158
161
|
const lastRow = rowData[rowData.length - 1];
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
await selectRowsWithFlashDiff(async () => {
|
|
163
|
+
setRowData([...rowData, { id: lastRow.id + 1, name: "?", nameType: "?", numba: "?", plan: "", distance: null }]);
|
|
164
|
+
});
|
|
165
|
+
}, [rowData, selectRowsWithFlashDiff]);
|
|
161
166
|
|
|
162
167
|
return (
|
|
163
168
|
<>
|