@linzjs/step-ag-grid 27.0.0 → 27.1.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/dist/src/components/GridCell.d.ts +0 -1
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +0 -1
- package/dist/src/contexts/GridContext.d.ts +1 -1
- package/dist/step-ag-grid.cjs +17 -12
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +17 -12
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +5 -3
- package/src/components/GridCell.tsx +0 -1
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -4
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -4
- package/src/components/gridRender/GridRenderGenericCell.tsx +0 -1
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +10 -1
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +1 -0
|
@@ -15,7 +15,6 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
15
15
|
valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
|
|
16
16
|
cellRenderer?: ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined) | string;
|
|
17
17
|
cellRendererParams?: {
|
|
18
|
-
singleClickEdit?: boolean;
|
|
19
18
|
rightHoverElement?: ReactElement;
|
|
20
19
|
originalCellRenderer?: any;
|
|
21
20
|
editAction?: (selectedRows: TData[]) => void;
|
|
@@ -7,7 +7,6 @@ export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> exte
|
|
|
7
7
|
exportable?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface GenericCellRendererParams<TData extends GridBaseRow> {
|
|
10
|
-
singleClickEdit?: boolean;
|
|
11
10
|
rightHoverElement?: ReactElement | undefined;
|
|
12
11
|
editAction?: (selectedRows: TData[]) => void;
|
|
13
12
|
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
@@ -17,7 +17,7 @@ export interface GridContextType<TData extends GridBaseRow> {
|
|
|
17
17
|
getColDef: (colId?: string) => ColDef | undefined;
|
|
18
18
|
getColumns: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => ColDefT<TData, any>[];
|
|
19
19
|
getColumnIds: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => string[];
|
|
20
|
-
setApis: (gridApi: GridApi | undefined, dataTestId?: string) => void;
|
|
20
|
+
setApis: (gridApi: GridApi | undefined, hasExternallySelectedItems: boolean, dataTestId?: string) => void;
|
|
21
21
|
prePopupOps: () => void;
|
|
22
22
|
postPopupOps: () => void;
|
|
23
23
|
setQuickFilter: (quickFilter: string) => void;
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2939,14 +2939,15 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2939
2939
|
};
|
|
2940
2940
|
});
|
|
2941
2941
|
}, [params.columnDefs, params.loading, params.readOnly, params.defaultColDef?.editable]);
|
|
2942
|
+
const hasExternallySelectedItems = !!params.setExternalSelectedItems;
|
|
2942
2943
|
/**
|
|
2943
2944
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
2944
2945
|
*/
|
|
2945
2946
|
const onGridReady = React.useCallback((event) => {
|
|
2946
|
-
setApis(event.api, dataTestId);
|
|
2947
|
+
setApis(event.api, hasExternallySelectedItems, dataTestId);
|
|
2947
2948
|
event.api.showNoRowsOverlay();
|
|
2948
2949
|
synchroniseExternallySelectedItemsToGrid();
|
|
2949
|
-
}, [dataTestId, setApis, synchroniseExternallySelectedItemsToGrid]);
|
|
2950
|
+
}, [dataTestId, hasExternallySelectedItems, setApis, synchroniseExternallySelectedItemsToGrid]);
|
|
2950
2951
|
/**
|
|
2951
2952
|
* When the grid is being initialized the data may be empty.
|
|
2952
2953
|
* This will resize columns when we have at least one row.
|
|
@@ -2999,7 +3000,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2999
3000
|
* Handle single click edits
|
|
3000
3001
|
*/
|
|
3001
3002
|
const onCellClicked = React.useCallback((event) => {
|
|
3002
|
-
if (event.colDef
|
|
3003
|
+
if (event.colDef.singleClickEdit ?? singleClickEdit) {
|
|
3003
3004
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3004
3005
|
}
|
|
3005
3006
|
}, [singleClickEdit, startCellEditing]);
|
|
@@ -4988,11 +4989,9 @@ const GridPopoverMenu = (colDef, custom) => GridCell({
|
|
|
4988
4989
|
exportable: false,
|
|
4989
4990
|
cellStyle: { flex: 1, justifyContent: 'center' },
|
|
4990
4991
|
cellRenderer: GridRenderPopoutMenuCell,
|
|
4992
|
+
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
4993
|
+
singleClickEdit: true,
|
|
4991
4994
|
...colDef,
|
|
4992
|
-
cellRendererParams: {
|
|
4993
|
-
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
4994
|
-
singleClickEdit: true,
|
|
4995
|
-
},
|
|
4996
4995
|
}, {
|
|
4997
4996
|
editor: GridFormPopoverMenu,
|
|
4998
4997
|
preventAutoEdit: true,
|
|
@@ -5002,10 +5001,7 @@ const GridPopoverMenu = (colDef, custom) => GridCell({
|
|
|
5002
5001
|
const GridPopoverMessage = (colDef, props) => GridCell({
|
|
5003
5002
|
resizable: true,
|
|
5004
5003
|
...colDef,
|
|
5005
|
-
|
|
5006
|
-
singleClickEdit: true,
|
|
5007
|
-
...colDef.cellRendererParams,
|
|
5008
|
-
},
|
|
5004
|
+
singleClickEdit: true,
|
|
5009
5005
|
}, {
|
|
5010
5006
|
editor: GridFormMessage,
|
|
5011
5007
|
...props,
|
|
@@ -5035,6 +5031,7 @@ const GridContextProvider = (props) => {
|
|
|
5035
5031
|
const [quickFilter, _setQuickFilter] = React.useState('');
|
|
5036
5032
|
const [invisibleColumnIds, _setInvisibleColumnIds] = React.useState();
|
|
5037
5033
|
const testId = React.useRef();
|
|
5034
|
+
const hasExternallySelectedItemsRef = React.useRef(false);
|
|
5038
5035
|
const idsBeforeUpdate = React.useRef([]);
|
|
5039
5036
|
const prePopupFocusedCell = React.useRef();
|
|
5040
5037
|
const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = React.useState(false);
|
|
@@ -5098,7 +5095,8 @@ const GridContextProvider = (props) => {
|
|
|
5098
5095
|
/**
|
|
5099
5096
|
* Set the grid api when the grid is ready.
|
|
5100
5097
|
*/
|
|
5101
|
-
const setApis = React.useCallback((gridApi, dataTestId) => {
|
|
5098
|
+
const setApis = React.useCallback((gridApi, hasExternallySelectedItems, dataTestId) => {
|
|
5099
|
+
hasExternallySelectedItemsRef.current = hasExternallySelectedItems;
|
|
5102
5100
|
testId.current = dataTestId;
|
|
5103
5101
|
setGridApi(gridApi);
|
|
5104
5102
|
gridApi?.setGridOption('quickFilterText', quickFilter);
|
|
@@ -5352,10 +5350,17 @@ const GridContextProvider = (props) => {
|
|
|
5352
5350
|
externallySelectedItemsAreInSyncRef.current = externallySelectedItemsAreInSync;
|
|
5353
5351
|
}, [externallySelectedItemsAreInSync]);
|
|
5354
5352
|
const waitForExternallySelectedItemsToBeInSync = React.useCallback(async () => {
|
|
5353
|
+
if (!hasExternallySelectedItemsRef.current) {
|
|
5354
|
+
externallySelectedItemsAreInSyncRef.current = true;
|
|
5355
|
+
return;
|
|
5356
|
+
}
|
|
5355
5357
|
// Wait for up to 5 seconds
|
|
5356
5358
|
for (let i = 0; i < 5000 / 200 && !externallySelectedItemsAreInSyncRef.current; i++) {
|
|
5357
5359
|
await wait(200);
|
|
5358
5360
|
}
|
|
5361
|
+
if (!externallySelectedItemsAreInSyncRef.current) {
|
|
5362
|
+
console.error('externallySelectedItems did not sync with ag-grid selection');
|
|
5363
|
+
}
|
|
5359
5364
|
}, []);
|
|
5360
5365
|
const startCellEditing = React.useCallback(async ({ rowId, colId }) => {
|
|
5361
5366
|
if (!gridApi)
|