@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
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -359,16 +359,18 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
359
359
|
});
|
|
360
360
|
}, [params.columnDefs, params.loading, params.readOnly, params.defaultColDef?.editable]);
|
|
361
361
|
|
|
362
|
+
const hasExternallySelectedItems = !!params.setExternalSelectedItems;
|
|
363
|
+
|
|
362
364
|
/**
|
|
363
365
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
364
366
|
*/
|
|
365
367
|
const onGridReady = useCallback(
|
|
366
368
|
(event: GridReadyEvent) => {
|
|
367
|
-
setApis(event.api, dataTestId);
|
|
369
|
+
setApis(event.api, hasExternallySelectedItems, dataTestId);
|
|
368
370
|
event.api.showNoRowsOverlay();
|
|
369
371
|
synchroniseExternallySelectedItemsToGrid();
|
|
370
372
|
},
|
|
371
|
-
[dataTestId, setApis, synchroniseExternallySelectedItemsToGrid],
|
|
373
|
+
[dataTestId, hasExternallySelectedItems, setApis, synchroniseExternallySelectedItemsToGrid],
|
|
372
374
|
);
|
|
373
375
|
|
|
374
376
|
/**
|
|
@@ -433,7 +435,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
433
435
|
*/
|
|
434
436
|
const onCellClicked = useCallback(
|
|
435
437
|
(event: CellClickedEvent) => {
|
|
436
|
-
if (event.colDef
|
|
438
|
+
if (event.colDef.singleClickEdit ?? singleClickEdit) {
|
|
437
439
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
438
440
|
}
|
|
439
441
|
},
|
|
@@ -66,7 +66,6 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
66
66
|
| ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
|
|
67
67
|
| string;
|
|
68
68
|
cellRendererParams?: {
|
|
69
|
-
singleClickEdit?: boolean;
|
|
70
69
|
rightHoverElement?: ReactElement;
|
|
71
70
|
originalCellRenderer?: any;
|
|
72
71
|
editAction?: (selectedRows: TData[]) => void;
|
|
@@ -21,11 +21,9 @@ export const GridPopoverMenu = <TData extends GridBaseRow>(
|
|
|
21
21
|
exportable: false,
|
|
22
22
|
cellStyle: { flex: 1, justifyContent: 'center' },
|
|
23
23
|
cellRenderer: GridRenderPopoutMenuCell,
|
|
24
|
+
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
25
|
+
singleClickEdit: true,
|
|
24
26
|
...colDef,
|
|
25
|
-
cellRendererParams: {
|
|
26
|
-
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
27
|
-
singleClickEdit: true,
|
|
28
|
-
},
|
|
29
27
|
},
|
|
30
28
|
{
|
|
31
29
|
editor: GridFormPopoverMenu,
|
|
@@ -11,10 +11,7 @@ export const GridPopoverMessage = <TData extends GridBaseRow, TValue = any>(
|
|
|
11
11
|
{
|
|
12
12
|
resizable: true,
|
|
13
13
|
...colDef,
|
|
14
|
-
|
|
15
|
-
singleClickEdit: true,
|
|
16
|
-
...colDef.cellRendererParams,
|
|
17
|
-
},
|
|
14
|
+
singleClickEdit: true,
|
|
18
15
|
},
|
|
19
16
|
{
|
|
20
17
|
editor: GridFormMessage,
|
|
@@ -10,7 +10,6 @@ export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> exte
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface GenericCellRendererParams<TData extends GridBaseRow> {
|
|
13
|
-
singleClickEdit?: boolean;
|
|
14
13
|
rightHoverElement?: ReactElement | undefined;
|
|
15
14
|
editAction?: (selectedRows: TData[]) => void;
|
|
16
15
|
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
@@ -23,7 +23,7 @@ export interface GridContextType<TData extends GridBaseRow> {
|
|
|
23
23
|
filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string),
|
|
24
24
|
) => ColDefT<TData, any>[];
|
|
25
25
|
getColumnIds: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => string[];
|
|
26
|
-
setApis: (gridApi: GridApi | undefined, dataTestId?: string) => void;
|
|
26
|
+
setApis: (gridApi: GridApi | undefined, hasExternallySelectedItems: boolean, dataTestId?: string) => void;
|
|
27
27
|
prePopupOps: () => void;
|
|
28
28
|
postPopupOps: () => void;
|
|
29
29
|
setQuickFilter: (quickFilter: string) => void;
|
|
@@ -23,6 +23,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
23
23
|
const [quickFilter, _setQuickFilter] = useState('');
|
|
24
24
|
const [invisibleColumnIds, _setInvisibleColumnIds] = useState<string[]>();
|
|
25
25
|
const testId = useRef<string | undefined>();
|
|
26
|
+
const hasExternallySelectedItemsRef = useRef(false);
|
|
26
27
|
const idsBeforeUpdate = useRef<number[]>([]);
|
|
27
28
|
const prePopupFocusedCell = useRef<CellPosition>();
|
|
28
29
|
const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
|
|
@@ -101,7 +102,8 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
101
102
|
* Set the grid api when the grid is ready.
|
|
102
103
|
*/
|
|
103
104
|
const setApis = useCallback(
|
|
104
|
-
(gridApi: GridApi | undefined, dataTestId?: string) => {
|
|
105
|
+
(gridApi: GridApi | undefined, hasExternallySelectedItems: boolean, dataTestId?: string) => {
|
|
106
|
+
hasExternallySelectedItemsRef.current = hasExternallySelectedItems;
|
|
105
107
|
testId.current = dataTestId;
|
|
106
108
|
setGridApi(gridApi);
|
|
107
109
|
gridApi?.setGridOption('quickFilterText', quickFilter);
|
|
@@ -474,10 +476,17 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
474
476
|
}, [externallySelectedItemsAreInSync]);
|
|
475
477
|
|
|
476
478
|
const waitForExternallySelectedItemsToBeInSync = useCallback(async () => {
|
|
479
|
+
if (!hasExternallySelectedItemsRef.current) {
|
|
480
|
+
externallySelectedItemsAreInSyncRef.current = true;
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
477
483
|
// Wait for up to 5 seconds
|
|
478
484
|
for (let i = 0; i < 5000 / 200 && !externallySelectedItemsAreInSyncRef.current; i++) {
|
|
479
485
|
await wait(200);
|
|
480
486
|
}
|
|
487
|
+
if (!externallySelectedItemsAreInSyncRef.current) {
|
|
488
|
+
console.error('externallySelectedItems did not sync with ag-grid selection');
|
|
489
|
+
}
|
|
481
490
|
}, []);
|
|
482
491
|
|
|
483
492
|
const startCellEditing = useCallback(
|