@linzjs/step-ag-grid 29.12.0 → 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.
- package/dist/src/components/Grid.d.ts +7 -12
- package/dist/src/components/GridCell.d.ts +2 -19
- package/dist/src/components/GridCellFiller.d.ts +1 -1
- package/dist/src/components/GridCellMultiEditor.d.ts +1 -2
- package/dist/src/components/GridPopoverHook.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +1 -1
- package/dist/src/components/gridFilter/useGridFilter.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMessage.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +1 -1
- package/dist/src/components/gridPopoverEdit/GridButton.d.ts +1 -2
- package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +2 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -2
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/types.d.ts +26 -0
- package/dist/src/contexts/GridContext.d.ts +12 -12
- package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
- package/dist/src/utils/textValidator.d.ts +1 -1
- package/dist/step-ag-grid.cjs +101 -174
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +101 -174
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +4 -2
- package/src/components/Grid.tsx +83 -62
- package/src/components/GridCell.tsx +1 -25
- package/src/components/GridCellFiller.tsx +1 -1
- package/src/components/GridCellMultiEditor.tsx +2 -2
- package/src/components/GridPopoverHook.tsx +1 -1
- package/src/components/gridFilter/GridFilterButtons.tsx +1 -1
- package/src/components/gridFilter/useGridFilter.ts +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +1 -1
- package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
- package/src/components/gridForm/GridFormMessage.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
- package/src/components/gridForm/GridFormPopoverMenu.tsx +1 -1
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -1
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -1
- package/src/components/gridForm/GridFormTextArea.tsx +1 -1
- package/src/components/gridForm/GridFormTextInput.tsx +1 -1
- package/src/components/gridHook/useGridContextMenu.tsx +1 -1
- package/src/components/gridPopoverEdit/GridButton.tsx +2 -2
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +2 -2
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -2
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +2 -2
- package/src/components/gridRender/GridRenderGenericCell.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/components/types.ts +32 -0
- package/src/contexts/GridContext.tsx +55 -148
- package/src/contexts/GridContextProvider.tsx +11 -11
- package/src/contexts/GridPopoverContext.tsx +1 -1
- package/src/contexts/GridPopoverContextProvider.tsx +1 -1
- package/src/react-menu3/components/MenuButton.tsx +2 -2
- package/src/react-menu3/hooks/useItemState.ts +1 -1
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +3 -3
- package/src/stories/grid/GridReadOnly.stories.tsx +3 -3
- package/src/utils/textValidator.test.ts +1 -1
- package/src/utils/textValidator.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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 '../
|
|
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;
|
package/src/components/index.ts
CHANGED
|
@@ -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:
|
|
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: () =>
|
|
37
|
-
getFilteredSelectedRowIds: () =>
|
|
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?:
|
|
41
|
-
selectRowsByIdWithFlash: (rowIds?:
|
|
42
|
-
flashRows: (rowIds?:
|
|
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:
|
|
45
|
-
ensureRowVisible: (id:
|
|
44
|
+
focusByRowById: (rowId: TData['id'], ifNoCellFocused?: boolean) => void;
|
|
45
|
+
ensureRowVisible: (id: TData['id'] | string) => boolean;
|
|
46
46
|
ensureSelectedRowIsVisible: () => void;
|
|
47
|
-
getFirstRowId: () =>
|
|
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
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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<
|
|
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:
|
|
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:
|
|
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:
|
|
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?:
|
|
336
|
+
(rowIds?: TData['id'][]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: false }),
|
|
337
337
|
[_selectRowsWithOptionalFlash],
|
|
338
338
|
);
|
|
339
339
|
|
|
340
340
|
const selectRowsByIdWithFlash = useCallback(
|
|
341
|
-
(rowIds?:
|
|
341
|
+
(rowIds?: TData['id'][]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: true }),
|
|
342
342
|
[_selectRowsWithOptionalFlash],
|
|
343
343
|
);
|
|
344
344
|
|
|
345
345
|
const flashRows = useCallback(
|
|
346
|
-
(rowIds?:
|
|
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:
|
|
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
|
-
():
|
|
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
|
-
():
|
|
406
|
+
(): TData['id'][] => getFilteredSelectedRows().map((row) => (row as any).id as number),
|
|
407
407
|
[getFilteredSelectedRows],
|
|
408
408
|
);
|
|
409
409
|
|
|
@@ -548,7 +548,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
548
548
|
|
|
549
549
|
const startCellEditingInProgressRef = useRef(false);
|
|
550
550
|
const startCellEditing = useCallback(
|
|
551
|
-
async ({ rowId, colId }: { rowId:
|
|
551
|
+
async ({ rowId, colId }: { rowId: TData['id']; colId: string }) => {
|
|
552
552
|
if (!gridApi || startCellEditingInProgressRef.current) {
|
|
553
553
|
return;
|
|
554
554
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, RefObject, useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
import { GridBaseRow } from '../components/
|
|
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/
|
|
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 [
|
|
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
|
-
|
|
316
|
-
|
|
315
|
+
externalSelectedIds={externalSelectedIds}
|
|
316
|
+
setExternalSelectedIds={setExternalSelectedIds}
|
|
317
317
|
columnDefs={columnDefs}
|
|
318
318
|
rowData={rowData}
|
|
319
319
|
domLayout={'autoHeight'}
|
|
@@ -71,7 +71,7 @@ interface ITestRow {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
|
|
74
|
-
const [
|
|
74
|
+
const [externalSelectedIds, setExternalSelectedIds] = useState<number[]>([]);
|
|
75
75
|
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
76
76
|
() => [
|
|
77
77
|
GridCell({
|
|
@@ -248,8 +248,8 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<I
|
|
|
248
248
|
enableClickSelection={true}
|
|
249
249
|
enableSelectionWithoutKeys={true}
|
|
250
250
|
autoSelectFirstRow={true}
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
externalSelectedIds={externalSelectedIds}
|
|
252
|
+
setExternalSelectedIds={setExternalSelectedIds}
|
|
253
253
|
columnDefs={columnDefs}
|
|
254
254
|
rowData={rowData}
|
|
255
255
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import { GridBaseRow } from '../components/
|
|
3
|
+
import { GridBaseRow } from '../components/types';
|
|
4
4
|
import { TextInputValidator, TextInputValidatorProps } from './textValidator';
|
|
5
5
|
|
|
6
6
|
describe('TextInputValidator', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
-
import { GridBaseRow } from '../components/
|
|
3
|
+
import { GridBaseRow } from '../components/types';
|
|
4
4
|
import { isFloat, stringByteLengthIsInvalid } from './util';
|
|
5
5
|
|
|
6
6
|
export interface TextInputValidatorProps<TData extends GridBaseRow> {
|