@linzjs/step-ag-grid 29.11.4 → 29.13.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.
Files changed (87) hide show
  1. package/dist/src/components/Grid.d.ts +7 -12
  2. package/dist/src/components/GridCell.d.ts +2 -19
  3. package/dist/src/components/GridCellFiller.d.ts +1 -1
  4. package/dist/src/components/GridCellMultiEditor.d.ts +1 -2
  5. package/dist/src/components/GridPopoverHook.d.ts +1 -1
  6. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +1 -1
  7. package/dist/src/components/gridFilter/useGridFilter.d.ts +1 -1
  8. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
  9. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -1
  10. package/dist/src/components/gridForm/GridFormMessage.d.ts +1 -1
  11. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
  12. package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +1 -1
  13. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +1 -1
  14. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +1 -1
  15. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +1 -1
  16. package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
  17. package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
  18. package/dist/src/components/gridHook/useGridContextMenu.d.ts +1 -1
  19. package/dist/src/components/gridPopoverEdit/GridButton.d.ts +1 -2
  20. package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +2 -2
  21. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +2 -2
  22. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +2 -2
  23. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +2 -2
  24. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
  25. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  26. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +2 -2
  27. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +2 -2
  28. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +2 -2
  29. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -2
  30. package/dist/src/components/index.d.ts +1 -0
  31. package/dist/src/components/types.d.ts +26 -0
  32. package/dist/src/contexts/GridContext.d.ts +12 -12
  33. package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
  34. package/dist/src/utils/__tests__/storybookTestUtil.ts +28 -1
  35. package/dist/src/utils/__tests__/testQuick.ts +2 -0
  36. package/dist/src/utils/textValidator.d.ts +1 -1
  37. package/dist/src/utils/util.d.ts +1 -0
  38. package/dist/step-ag-grid.cjs +326 -214
  39. package/dist/step-ag-grid.cjs.map +1 -1
  40. package/dist/step-ag-grid.esm.js +327 -216
  41. package/dist/step-ag-grid.esm.js.map +1 -1
  42. package/package.json +5 -2
  43. package/src/components/Grid.tsx +130 -65
  44. package/src/components/GridCell.tsx +1 -25
  45. package/src/components/GridCellFiller.tsx +1 -1
  46. package/src/components/GridCellMultiEditor.tsx +2 -2
  47. package/src/components/GridPopoverHook.tsx +1 -1
  48. package/src/components/gridFilter/GridFilterButtons.tsx +1 -1
  49. package/src/components/gridFilter/useGridFilter.ts +1 -1
  50. package/src/components/gridForm/GridFormDropDown.tsx +1 -1
  51. package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
  52. package/src/components/gridForm/GridFormMessage.tsx +1 -1
  53. package/src/components/gridForm/GridFormMultiSelect.tsx +1 -1
  54. package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
  55. package/src/components/gridForm/GridFormPopoverMenu.tsx +1 -1
  56. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -1
  57. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -1
  58. package/src/components/gridForm/GridFormTextArea.tsx +1 -1
  59. package/src/components/gridForm/GridFormTextInput.tsx +1 -1
  60. package/src/components/gridHook/useGridContextMenu.tsx +1 -1
  61. package/src/components/gridPopoverEdit/GridButton.tsx +2 -2
  62. package/src/components/gridPopoverEdit/GridEditBoolean.tsx +2 -2
  63. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +2 -2
  64. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +2 -2
  65. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +2 -2
  66. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +2 -2
  67. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -2
  68. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -2
  69. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +2 -2
  70. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +2 -2
  71. package/src/components/gridRender/GridRenderGenericCell.tsx +1 -2
  72. package/src/components/index.ts +1 -0
  73. package/src/components/types.ts +32 -0
  74. package/src/contexts/GridContext.tsx +55 -148
  75. package/src/contexts/GridContextProvider.tsx +61 -56
  76. package/src/contexts/GridPopoverContext.tsx +1 -1
  77. package/src/contexts/GridPopoverContextProvider.tsx +1 -1
  78. package/src/react-menu3/components/MenuButton.tsx +2 -2
  79. package/src/react-menu3/hooks/useItemState.ts +1 -1
  80. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +3 -3
  81. package/src/stories/grid/GridReadOnly.stories.tsx +3 -3
  82. package/src/stories/grid/GridSorting.stories.tsx +189 -0
  83. package/src/utils/__tests__/storybookTestUtil.ts +28 -1
  84. package/src/utils/__tests__/testQuick.ts +2 -0
  85. package/src/utils/textValidator.test.ts +1 -1
  86. package/src/utils/textValidator.ts +1 -1
  87. package/src/utils/util.ts +19 -0
@@ -1,9 +1,9 @@
1
1
  import clsx from 'clsx';
2
2
 
3
- import { GridBaseRow } from '../Grid';
4
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
3
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
5
4
  import { GridFormMultiSelectGrid, GridFormMultiSelectGridProps } from '../gridForm/GridFormMultiSelectGrid';
6
5
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
6
+ import { ColDefT, GridBaseRow } from '../types';
7
7
 
8
8
  export const GridPopoutEditMultiSelectGrid = <TData extends GridBaseRow, TValue = any>(
9
9
  colDef: GenericCellColDef<TData, TValue>,
@@ -6,10 +6,10 @@ import {
6
6
  bearingRangeValidator,
7
7
  bearingValueFormatter,
8
8
  } from '../../utils/bearing';
9
- import { GridBaseRow } from '../Grid';
10
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
9
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
11
10
  import { GridFormEditBearing, GridFormEditBearingProps } from '../gridForm/GridFormEditBearing';
12
11
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
12
+ import { ColDefT, GridBaseRow } from '../types';
13
13
 
14
14
  const GridPopoverEditBearingLike = <TData extends GridBaseRow, TValue = any>(
15
15
  colDef: GenericCellColDef<TData, TValue>,
@@ -1,9 +1,9 @@
1
1
  import clsx from 'clsx';
2
2
 
3
- import { GridBaseRow } from '../Grid';
4
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
3
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
5
4
  import { GridFormDropDown, GridFormDropDownProps } from '../gridForm/GridFormDropDown';
6
5
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
6
+ import { ColDefT, GridBaseRow } from '../types';
7
7
 
8
8
  export const GridPopoverEditDropDown = <TData extends GridBaseRow, TValue = any, TOptionValue = any>(
9
9
  colDef: GenericCellColDef<TData, TValue>,
@@ -1,8 +1,8 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
1
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
3
2
  import { GridFormPopoverMenu, GridFormPopoverMenuProps } from '../gridForm/GridFormPopoverMenu';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
5
4
  import { GridRenderPopoutMenuCell } from '../gridRender/GridRenderPopoutMenuCell';
5
+ import { ColDefT, GridBaseRow } from '../types';
6
6
 
7
7
  /**
8
8
  * Popout burger menu
@@ -1,7 +1,7 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
1
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
3
2
  import { GridFormMessage, GridFormMessageProps } from '../gridForm/GridFormMessage';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
 
6
6
  export const GridPopoverMessage = <TData extends GridBaseRow, TValue = any>(
7
7
  colDef: GenericCellColDef<TData, TValue>,
@@ -1,7 +1,7 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
1
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
3
2
  import { GridFormTextArea, GridFormTextAreaProps } from '../gridForm/GridFormTextArea';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
 
6
6
  export const GridPopoverTextArea = <TData extends GridBaseRow, TValue = any>(
7
7
  colDef: GenericCellColDef<TData, TValue>,
@@ -1,7 +1,7 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
1
+ import { GenericCellEditorProps, GridCell } from '../GridCell';
3
2
  import { GridFormTextInput, GridFormTextInputProps } from '../gridForm/GridFormTextInput';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
 
6
6
  export const GridPopoverTextInput = <TData extends GridBaseRow, TValue = any>(
7
7
  colDef: GenericCellColDef<TData, TValue>,
@@ -2,8 +2,7 @@ import { ICellRendererParams } from 'ag-grid-community';
2
2
  import { SuppressKeyboardEventParams } from 'ag-grid-community';
3
3
  import { ReactElement } from 'react';
4
4
 
5
- import { GridBaseRow } from '../Grid';
6
- import { ColDefT } from '../GridCell';
5
+ import { ColDefT, GridBaseRow } from '../types';
7
6
 
8
7
  export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> extends ColDefT<TData, TValue> {
9
8
  exportable?: boolean;
@@ -15,3 +15,4 @@ export * from './GridPopoverHook';
15
15
  export * from './gridRender';
16
16
  export * from './GridWrapper';
17
17
  export * from './PostSortRowsHook';
18
+ export * from './types';
@@ -0,0 +1,32 @@
1
+ import { ColDef, EditableCallback, ICellRendererParams, ValueFormatterFunc, ValueGetterFunc } from 'ag-grid-community';
2
+ import { ReactElement } from 'react';
3
+
4
+ export interface GridBaseRow {
5
+ id: string | number;
6
+ }
7
+
8
+ export interface GridOnRowDragEndProps<TData extends GridBaseRow> {
9
+ movedRow: TData;
10
+ targetRow: TData;
11
+ direction: -1 | 1;
12
+ }
13
+
14
+ // This is so that typescript retains the row type to pass to the GridCells
15
+ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
16
+ editable?: boolean | EditableCallback<TData, ValueType>;
17
+ valueGetter?: string | ValueGetterFunc<TData, ValueType>;
18
+ valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
19
+ cellRenderer?:
20
+ | ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
21
+ | string;
22
+ cellRendererParams?: {
23
+ rightHoverElement?: ReactElement;
24
+ originalCellRenderer?: any;
25
+ editAction?: (selectedRows: TData[]) => void;
26
+ shortcutKeys?: Record<string, () => void>;
27
+ error?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
28
+ warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
29
+ info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
30
+ };
31
+ editor?: (editorProps: any) => ReactElement;
32
+ }
@@ -2,7 +2,7 @@ import { ColDef, GridApi, IRowNode, ISizeColumnsToFitParams } from 'ag-grid-comm
2
2
  import { CsvExportParams } from 'ag-grid-community';
3
3
  import { createContext, useContext } from 'react';
4
4
 
5
- import { ColDefT, GridBaseRow } from '../components';
5
+ import { ColDefT, GridBaseRow } from '../components/types';
6
6
 
7
7
  export type GridFilterExternal<TData extends GridBaseRow> = (data: TData, rowNode: IRowNode) => boolean;
8
8
 
@@ -14,8 +14,8 @@ export interface AutoSizeColumnsProps {
14
14
 
15
15
  export type AutoSizeColumnsResult = { width: number } | null;
16
16
 
17
- export interface StartCellEditingProps {
18
- rowId: number;
17
+ export interface StartCellEditingProps<TData extends GridBaseRow> {
18
+ rowId: TData['id'];
19
19
  colId: string;
20
20
  }
21
21
 
@@ -33,21 +33,21 @@ export interface GridContextType<TData extends GridBaseRow> {
33
33
  editingCells: () => boolean;
34
34
  getSelectedRows: <T extends GridBaseRow>() => T[];
35
35
  getFilteredSelectedRows: <T extends GridBaseRow>() => T[];
36
- getSelectedRowIds: () => number[];
37
- getFilteredSelectedRowIds: () => number[];
36
+ getSelectedRowIds: () => TData['id'][];
37
+ getFilteredSelectedRowIds: () => TData['id'][];
38
38
  selectRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
39
39
  selectRowsWithFlashDiff: (updateFn: () => Promise<any>) => Promise<void>;
40
- selectRowsById: (rowIds?: number[]) => void;
41
- selectRowsByIdWithFlash: (rowIds?: number[]) => void;
42
- flashRows: (rowIds?: number[]) => void;
40
+ selectRowsById: (rowIds?: TData['id'][]) => void;
41
+ selectRowsByIdWithFlash: (rowIds?: TData['id'][]) => void;
42
+ flashRows: (rowIds?: TData['id'][]) => void;
43
43
  flashRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
44
- focusByRowById: (rowId: number, ifNoCellFocused?: boolean) => void;
45
- ensureRowVisible: (id: number | string) => boolean;
44
+ focusByRowById: (rowId: TData['id'], ifNoCellFocused?: boolean) => void;
45
+ ensureRowVisible: (id: TData['id'] | string) => boolean;
46
46
  ensureSelectedRowIsVisible: () => void;
47
- getFirstRowId: () => number;
47
+ getFirstRowId: () => TData['id'];
48
48
  autoSizeColumns: (props?: AutoSizeColumnsProps) => Promise<AutoSizeColumnsResult>;
49
49
  sizeColumnsToFit: (paramsOrGridWidth?: ISizeColumnsToFitParams) => void;
50
- startCellEditing: ({ rowId, colId }: StartCellEditingProps) => Promise<void>;
50
+ startCellEditing: ({ rowId, colId }: StartCellEditingProps<TData>) => Promise<void>;
51
51
  // Restores the previous focus after cell editing
52
52
  resetFocusedCellAfterCellEditing: () => void;
53
53
  updatingCells: (
@@ -72,147 +72,54 @@ export interface GridContextType<TData extends GridBaseRow> {
72
72
  showNoRowsOverlay: () => void;
73
73
  }
74
74
 
75
+ const NoContext = <T,>(): T => {
76
+ console.error('Missing GridContextProvider');
77
+ return null as T;
78
+ };
79
+
75
80
  export const GridContext = createContext<GridContextType<any>>({
76
81
  gridReady: false,
77
82
  gridRenderState: () => null,
78
- getColDef: () => {
79
- console.error('no context provider for getColDef');
80
- return undefined;
81
- },
82
- getColumns: () => {
83
- console.error('no context provider for getColumns');
84
- return [];
85
- },
86
- getColumnIds: () => {
87
- console.error('no context provider for getColumnIds');
88
- return [];
89
- },
83
+ getColDef: NoContext,
84
+ getColumns: NoContext,
85
+ getColumnIds: NoContext,
90
86
  invisibleColumnIds: undefined,
91
- setInvisibleColumnIds: () => {
92
- console.error('no context provider for setInvisibleColumnIds');
93
- },
94
- prePopupOps: () => {
95
- console.error('no context provider for prePopupOps');
96
- },
87
+ setInvisibleColumnIds: NoContext,
88
+ prePopupOps: NoContext,
97
89
  externallySelectedItemsAreInSync: false,
98
- setApis: () => {
99
- console.error('no context provider for setApis');
100
- },
101
- setQuickFilter: () => {
102
- console.error('no context provider for setQuickFilter');
103
- },
104
- selectRowsById: () => {
105
- console.error('no context provider for selectRows');
106
- },
107
- getSelectedRows: <T,>(): T[] => {
108
- console.error('no context provider for getSelectedRows');
109
- return [];
110
- },
111
- getFilteredSelectedRows: <T,>(): T[] => {
112
- console.error('no context provider for getFilteredSelectedRows');
113
- return [];
114
- },
115
- getSelectedRowIds: () => {
116
- console.error('no context provider for getSelectedRowIds');
117
- return [];
118
- },
119
- getFilteredSelectedRowIds: () => {
120
- console.error('no context provider for getFilteredSelectedRowIds');
121
- return [];
122
- },
123
- // eslint-disable-next-line @typescript-eslint/require-await
124
- selectRowsDiff: async () => {
125
- console.error('no context provider for selectRowsDiff');
126
- },
127
- selectRowsByIdWithFlash: () => {
128
- console.error('no context provider for selectRowsWithFlash');
129
- },
130
- // eslint-disable-next-line @typescript-eslint/require-await
131
- selectRowsWithFlashDiff: async () => {
132
- console.error('no context provider for selectRowsWithFlashDiff');
133
- },
134
- flashRows: () => {
135
- console.error('no context provider for flashRows');
136
- },
137
- // eslint-disable-next-line @typescript-eslint/require-await
138
- flashRowsDiff: async () => {
139
- console.error('no context provider for flashRows');
140
- },
141
- // eslint-disable-next-line @typescript-eslint/require-await,@typescript-eslint/no-misused-promises
142
- focusByRowById: async () => {
143
- console.error('no context provider for focusByRowById');
144
- },
145
- ensureRowVisible: () => {
146
- console.error('no context provider for ensureRowVisible');
147
- return true;
148
- },
149
- ensureSelectedRowIsVisible: () => {
150
- console.error('no context provider for ensureSelectedRowIsVisible');
151
- },
152
- getFirstRowId: () => {
153
- console.error('no context provider for getFirstRowId');
154
- return -1;
155
- },
156
- autoSizeColumns: async () => {
157
- console.error('no context provider for autoSizeColumns');
158
- return Promise.resolve(null);
159
- },
160
- sizeColumnsToFit: () => {
161
- console.error('no context provider for autoSizeAllColumns');
162
- return null;
163
- },
164
- editingCells: () => {
165
- console.error('no context provider for editingCells');
166
- return false;
167
- },
168
- // eslint-disable-next-line @typescript-eslint/require-await
169
- startCellEditing: async () => {
170
- console.error('no context provider for startCellEditing');
171
- },
172
- resetFocusedCellAfterCellEditing: () => {
173
- console.error('no context provider for resetFocusedCellAfterCellEditing');
174
- },
175
- // eslint-disable-next-line @typescript-eslint/require-await
176
- updatingCells: async () => {
177
- console.error('no context provider for modifyUpdating');
178
- return false;
179
- },
180
- redrawRows: () => {
181
- console.error('no context provider for redrawRows');
182
- },
183
- setExternallySelectedItemsAreInSync: () => {
184
- console.error('no context provider for setExternallySelectedItemsAreInSync');
185
- },
186
- // eslint-disable-next-line @typescript-eslint/require-await
187
- waitForExternallySelectedItemsToBeInSync: async () => {
188
- console.error('no context provider for waitForExternallySelectedItemsToBeInSync');
189
- },
190
- addExternalFilter: () => {
191
- console.error('no context provider for addExternalFilter');
192
- },
193
- removeExternalFilter: () => {
194
- console.error('no context provider for removeExternalFilter');
195
- },
196
- isExternalFilterPresent: () => {
197
- console.error('no context provider for isExternalFilterPresent');
198
- return false;
199
- },
200
- doesExternalFilterPass: () => {
201
- console.error('no context provider for doesExternalFilterPass');
202
- return true;
203
- },
204
- downloadCsv: () => {
205
- console.error('no context provider for downloadCsv');
206
- },
207
- onBulkEditingComplete: () => {
208
- console.error('no context provider for onBulkEditingComplete');
209
- },
210
- setOnBulkEditingComplete: () => {
211
- console.error('no context provider for setOnBulkEditingComplete');
212
- },
213
- showNoRowsOverlay: () => {
214
- console.error('no context provider for showLoadingOverlay');
215
- },
90
+ setApis: NoContext,
91
+ setQuickFilter: NoContext,
92
+ selectRowsById: NoContext,
93
+ getSelectedRows: NoContext,
94
+ getFilteredSelectedRows: NoContext,
95
+ getSelectedRowIds: NoContext,
96
+ getFilteredSelectedRowIds: NoContext,
97
+ selectRowsDiff: NoContext,
98
+ selectRowsByIdWithFlash: NoContext,
99
+ selectRowsWithFlashDiff: NoContext,
100
+ flashRows: NoContext,
101
+ flashRowsDiff: NoContext,
102
+ focusByRowById: NoContext,
103
+ ensureRowVisible: NoContext,
104
+ ensureSelectedRowIsVisible: NoContext,
105
+ getFirstRowId: NoContext,
106
+ autoSizeColumns: NoContext,
107
+ sizeColumnsToFit: NoContext,
108
+ editingCells: NoContext,
109
+ startCellEditing: NoContext,
110
+ resetFocusedCellAfterCellEditing: NoContext,
111
+ updatingCells: NoContext,
112
+ redrawRows: NoContext,
113
+ setExternallySelectedItemsAreInSync: NoContext,
114
+ waitForExternallySelectedItemsToBeInSync: NoContext,
115
+ addExternalFilter: NoContext,
116
+ removeExternalFilter: NoContext,
117
+ isExternalFilterPresent: NoContext,
118
+ doesExternalFilterPass: NoContext,
119
+ downloadCsv: NoContext,
120
+ onBulkEditingComplete: NoContext,
121
+ setOnBulkEditingComplete: NoContext,
122
+ showNoRowsOverlay: NoContext,
216
123
  });
217
124
 
218
125
  export const useGridContext = <TData extends GridBaseRow>() => useContext<GridContextType<TData>>(GridContext);
@@ -38,7 +38,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
38
38
  const [invisibleColumnIds, _setInvisibleColumnIds] = useState<string[]>();
39
39
  const testId = useRef<string | undefined>();
40
40
  const hasExternallySelectedItemsRef = useRef(false);
41
- const idsBeforeUpdate = useRef<number[]>([]);
41
+ const idsBeforeUpdate = useRef<TData['id'][]>([]);
42
42
  const prePopupFocusedCell = useRef<CellPosition>();
43
43
  const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
44
44
  const externalFilters = useRef<GridFilterExternal<TData>[]>([]);
@@ -169,7 +169,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
169
169
  * Get all row id's in grid.
170
170
  */
171
171
  const _getAllRowIds = useCallback(() => {
172
- const result: number[] = [];
172
+ const result: TData['id'][] = [];
173
173
  return gridApiOp(
174
174
  (gridApi) => {
175
175
  gridApi.forEachNode((node) => result.push(node.data.id));
@@ -205,7 +205,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
205
205
  * @param rowIds Row ids to get from grid.
206
206
  */
207
207
  const _rowIdsToNodes = useCallback(
208
- (rowIds: number[]): IRowNode[] => {
208
+ (rowIds: TData['id'][]): IRowNode[] => {
209
209
  return gridApiOp(
210
210
  (gridApi) => compact(rowIds.map((rowId) => gridApi.getRowNode('' + rowId))),
211
211
  () => [] as RowNode[],
@@ -248,7 +248,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
248
248
  ifNoCellFocused = false,
249
249
  retryCount = 15,
250
250
  }: {
251
- rowIds: number[] | undefined;
251
+ rowIds: TData['id'][] | undefined;
252
252
  select: boolean;
253
253
  flash: boolean;
254
254
  ifNoCellFocused?: boolean;
@@ -333,17 +333,17 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
333
333
  );
334
334
 
335
335
  const selectRowsById = useCallback(
336
- (rowIds?: number[]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: false }),
336
+ (rowIds?: TData['id'][]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: false }),
337
337
  [_selectRowsWithOptionalFlash],
338
338
  );
339
339
 
340
340
  const selectRowsByIdWithFlash = useCallback(
341
- (rowIds?: number[]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: true }),
341
+ (rowIds?: TData['id'][]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: true }),
342
342
  [_selectRowsWithOptionalFlash],
343
343
  );
344
344
 
345
345
  const flashRows = useCallback(
346
- (rowIds?: number[]) => _selectRowsWithOptionalFlash({ rowIds, select: false, flash: true }),
346
+ (rowIds?: TData['id'][]) => _selectRowsWithOptionalFlash({ rowIds, select: false, flash: true }),
347
347
  [_selectRowsWithOptionalFlash],
348
348
  );
349
349
 
@@ -375,7 +375,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
375
375
  );
376
376
 
377
377
  const focusByRowById = useCallback(
378
- (rowId: number, ifNoCellFocused?: boolean) =>
378
+ (rowId: TData['id'], ifNoCellFocused?: boolean) =>
379
379
  _selectRowsWithOptionalFlash({ rowIds: [rowId], select: false, flash: false, ifNoCellFocused }),
380
380
  [_selectRowsWithOptionalFlash],
381
381
  );
@@ -398,12 +398,12 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
398
398
  }, [gridApiOp]);
399
399
 
400
400
  const getSelectedRowIds = useCallback(
401
- (): number[] => getSelectedRows().map((row) => (row as any).id as number),
401
+ (): TData['id'][] => getSelectedRows().map((row) => (row as any).id as number),
402
402
  [getSelectedRows],
403
403
  );
404
404
 
405
405
  const getFilteredSelectedRowIds = useCallback(
406
- (): number[] => getFilteredSelectedRows().map((row) => (row as any).id as number),
406
+ (): TData['id'][] => getFilteredSelectedRows().map((row) => (row as any).id as number),
407
407
  [getFilteredSelectedRows],
408
408
  );
409
409
 
@@ -439,59 +439,64 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
439
439
  return null;
440
440
  }
441
441
 
442
- const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
442
+ try {
443
+ const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
443
444
 
444
- const getVisibleColStates = () => {
445
- const colStates = gridApi.getColumnState();
446
- return colStates.filter((colState) => {
447
- const colId = colState.colId;
448
- return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
445
+ const getVisibleColStates = () => {
446
+ const colStates = gridApi.getColumnState();
447
+ return colStates.filter((colState) => {
448
+ const colId = colState.colId;
449
+ return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
450
+ });
451
+ };
452
+ const getFlexColStates = () => getVisibleColStates().filter(colStateFlexed);
453
+ const getNonFlexColStates = () => getVisibleColStates().filter(colStateNotFlexed);
454
+
455
+ // You cannot autosize flex columns it will break layout randomly
456
+ // So, a flex column is assumed to be 150 wide, unless width is provided
457
+ const flexColumns = getFlexColStates().map(colStateId);
458
+ let width = 0;
459
+ flexColumns.forEach((colId) => {
460
+ const colDef = gridApi.getColumnDef(colId) as { flexAutoSizeWidth?: number } | undefined;
461
+ width += colDef?.flexAutoSizeWidth ?? 200;
449
462
  });
450
- };
451
- const getFlexColStates = () => getVisibleColStates().filter(colStateFlexed);
452
- const getNonFlexColStates = () => getVisibleColStates().filter(colStateNotFlexed);
453
-
454
- // You cannot autosize flex columns it will break layout randomly
455
- // So, a flex column is assumed to be 150 wide, unless width is provided
456
- const flexColumns = getFlexColStates().map(colStateId);
457
- let width = 0;
458
- flexColumns.forEach((colId) => {
459
- const colDef = gridApi.getColumnDef(colId) as { flexAutoSizeWidth?: number } | undefined;
460
- width += colDef?.flexAutoSizeWidth ?? 200;
461
- });
462
463
 
463
- const nonFlexColumns = getNonFlexColStates();
464
- const nonFlexColumnIds = nonFlexColumns.map(colStateId);
465
- gridApi.autoSizeColumns({ colIds: nonFlexColumnIds, skipHeader });
464
+ const nonFlexColumns = getNonFlexColStates();
465
+ const nonFlexColumnIds = nonFlexColumns.map(colStateId);
466
+ gridApi.autoSizeColumns({ colIds: nonFlexColumnIds, skipHeader });
466
467
 
467
- const calcSubWidth = () => {
468
- const updatedFlexColumns = getVisibleColStates().filter((colState) =>
469
- nonFlexColumnIds.includes(colState.colId),
470
- );
471
- return sumBy(
472
- updatedFlexColumns.filter((col) => !col.hide),
473
- 'width',
474
- );
475
- };
468
+ const calcSubWidth = () => {
469
+ const updatedFlexColumns = getVisibleColStates().filter((colState) =>
470
+ nonFlexColumnIds.includes(colState.colId),
471
+ );
472
+ return sumBy(
473
+ updatedFlexColumns.filter((col) => !col.hide),
474
+ 'width',
475
+ );
476
+ };
476
477
 
477
- // ag-grid updates widths asynchronously, so we wait here for the default calculated width to change
478
- let lastSubWidth = calcSubWidth();
479
- const endTime = Date.now() + 1000;
480
- while (Date.now() < endTime) {
481
- await wait(40);
482
- const newSubWidth = calcSubWidth();
483
- if (lastSubWidth !== newSubWidth) {
484
- lastSubWidth = newSubWidth;
485
- break;
478
+ // ag-grid updates widths asynchronously, so we wait here for the default calculated width to change
479
+ let lastSubWidth = calcSubWidth();
480
+ const endTime = Date.now() + 1000;
481
+ while (Date.now() < endTime) {
482
+ await wait(40);
483
+ const newSubWidth = calcSubWidth();
484
+ if (lastSubWidth !== newSubWidth) {
485
+ lastSubWidth = newSubWidth;
486
+ break;
487
+ }
486
488
  }
487
- }
488
489
 
489
- width += lastSubWidth;
490
+ width += lastSubWidth;
490
491
 
491
- gridApi.sizeColumnsToFit();
492
- return {
493
- width,
494
- };
492
+ gridApi.sizeColumnsToFit();
493
+ return {
494
+ width,
495
+ };
496
+ } catch (ex) {
497
+ console.info('autosize failed', ex);
498
+ return null;
499
+ }
495
500
  },
496
501
  [gridApi],
497
502
  );
@@ -543,7 +548,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
543
548
 
544
549
  const startCellEditingInProgressRef = useRef(false);
545
550
  const startCellEditing = useCallback(
546
- async ({ rowId, colId }: { rowId: number; colId: string }) => {
551
+ async ({ rowId, colId }: { rowId: TData['id']; colId: string }) => {
547
552
  if (!gridApi || startCellEditingInProgressRef.current) {
548
553
  return;
549
554
  }
@@ -1,6 +1,6 @@
1
1
  import { createContext, RefObject, useContext } from 'react';
2
2
 
3
- import { GridBaseRow } from '../components/Grid';
3
+ import { GridBaseRow } from '../components/types';
4
4
 
5
5
  export interface GridPopoverContextType<TData extends GridBaseRow> {
6
6
  anchorRef: RefObject<Element>;
@@ -2,7 +2,7 @@ import { ICellEditorParams } from 'ag-grid-community';
2
2
  import { sortBy } from 'lodash-es';
3
3
  import { PropsWithChildren, RefObject, useCallback, useContext, useMemo, useRef, useState } from 'react';
4
4
 
5
- import { GridBaseRow } from '../components/Grid';
5
+ import { GridBaseRow } from '../components/types';
6
6
  import { GridContext } from './GridContext';
7
7
  import { GridPopoverContext } from './GridPopoverContext';
8
8
 
@@ -1,8 +1,8 @@
1
1
  import { forwardRef, LegacyRef, ReactNode, useMemo } from 'react';
2
2
 
3
- import { useBEM } from '../hooks';
3
+ import { useBEM } from '../hooks/useBEM';
4
4
  import { BaseProps, MenuButtonModifiers } from '../types';
5
- import { menuButtonClass } from '../utils';
5
+ import { menuButtonClass } from '../utils/constants';
6
6
 
7
7
  export interface MenuButtonProps extends BaseProps<MenuButtonModifiers> {
8
8
  disabled?: boolean;
@@ -2,7 +2,7 @@ import { FocusEvent, MutableRefObject, useContext, useEffect, useRef } from 'rea
2
2
 
3
3
  import { ItemSettingsContext } from '../contexts/ItemSettingsContext';
4
4
  import { MenuListItemContext } from '../contexts/MenuListItemContext';
5
- import { HoverActionTypes } from '../utils';
5
+ import { HoverActionTypes } from '../utils/constants';
6
6
  import { useItemEffect } from './useItemEffect';
7
7
 
8
8
  // This hook includes some common stateful logic in MenuItem and FocusableItem
@@ -66,7 +66,7 @@ interface ICode {
66
66
  }
67
67
 
68
68
  const GridEditDropDownTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
69
- const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
69
+ const [externalSelectedIds, setExternalSelectedIds] = useState<number[]>([]);
70
70
 
71
71
  const optionsFn = useCallback(async (selectedRows: ITestRow[], filter?: string) => {
72
72
  // eslint-disable-next-line no-console
@@ -312,8 +312,8 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridPro
312
312
  </GridFilters>
313
313
  <Grid
314
314
  {...props}
315
- externalSelectedItems={externalSelectedItems}
316
- setExternalSelectedItems={setExternalSelectedItems}
315
+ externalSelectedIds={externalSelectedIds}
316
+ setExternalSelectedIds={setExternalSelectedIds}
317
317
  columnDefs={columnDefs}
318
318
  rowData={rowData}
319
319
  domLayout={'autoHeight'}