@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
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@linzjs/step-ag-grid",
|
|
3
3
|
"repository": "github:linz/step-ag-grid.git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "29.
|
|
5
|
+
"version": "29.13.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"aggrid",
|
|
8
8
|
"ag-grid",
|
|
@@ -51,7 +51,9 @@
|
|
|
51
51
|
"css": "sass ./src/styles/index.scss:dist/index.css --no-source-map",
|
|
52
52
|
"test": "cross-env NODE_OPTIONS='--no-experimental-global-navigator' vitest run",
|
|
53
53
|
"test:watch": "vitest --watch",
|
|
54
|
-
"lint": "eslint
|
|
54
|
+
"lint": "run-s lint:eslint lint:circulardeps",
|
|
55
|
+
"lint:eslint": "eslint ./src --ext .js,.ts,.tsx --cache --ignore-path .gitignore",
|
|
56
|
+
"lint:circulardeps": "npx madge --circular --extensions ts,tsx ./src",
|
|
55
57
|
"lint:fix": "eslint ./src --ext .js,.ts,.tsx --fix --cache --ignore-path .gitignore",
|
|
56
58
|
"storybook": "storybook dev -p 6006",
|
|
57
59
|
"build-storybook": "storybook build",
|
package/src/components/Grid.tsx
CHANGED
|
@@ -39,19 +39,10 @@ import { GridHeaderSelect } from './gridHeader';
|
|
|
39
39
|
import { GridContextMenuComponent, useGridContextMenu } from './gridHook';
|
|
40
40
|
import { GridNoRowsOverlay } from './GridNoRowsOverlay';
|
|
41
41
|
import { usePostSortRowsHook } from './PostSortRowsHook';
|
|
42
|
+
import { GridBaseRow, GridOnRowDragEndProps } from './types';
|
|
42
43
|
|
|
43
44
|
ModuleRegistry.registerModules([AllCommunityModule]);
|
|
44
45
|
|
|
45
|
-
export interface GridBaseRow {
|
|
46
|
-
id: string | number;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface GridOnRowDragEndProps<TData extends GridBaseRow> {
|
|
50
|
-
movedRow: TData;
|
|
51
|
-
targetRow: TData;
|
|
52
|
-
direction: -1 | 1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
56
47
|
readOnly?: boolean; // set all editables to false when read only, make all styles black, otherwise style is gray for not editable
|
|
57
48
|
defaultPostSort?: boolean; // Retain sort order after edit, Defaults to true.
|
|
@@ -62,8 +53,10 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
62
53
|
theme?: string; // should have prefix ag-theme-
|
|
63
54
|
['data-testid']?: string;
|
|
64
55
|
domLayout?: GridOptions['domLayout'];
|
|
65
|
-
externalSelectedItems?:
|
|
66
|
-
|
|
56
|
+
externalSelectedItems?: TData[];
|
|
57
|
+
externalSelectedIds?: TData['id'][];
|
|
58
|
+
setExternalSelectedItems?: (items: TData[]) => void;
|
|
59
|
+
setExternalSelectedIds?: (ids: TData['id'][]) => void;
|
|
67
60
|
defaultColDef?: GridOptions['defaultColDef'];
|
|
68
61
|
columnDefs: ColDef<TData>[] | ColGroupDef<TData>[];
|
|
69
62
|
rowData: GridOptions['rowData'];
|
|
@@ -113,7 +106,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
113
106
|
/**
|
|
114
107
|
* Context menu definition if required.
|
|
115
108
|
*/
|
|
116
|
-
contextMenu?: GridContextMenuComponent<
|
|
109
|
+
contextMenu?: GridContextMenuComponent<TData>;
|
|
117
110
|
|
|
118
111
|
/**
|
|
119
112
|
* Whether to select row on context menu.
|
|
@@ -149,9 +142,14 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
149
142
|
rowData,
|
|
150
143
|
rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40,
|
|
151
144
|
selectable,
|
|
145
|
+
autoSelectFirstRow,
|
|
152
146
|
onCellFocused: paramsOnCellFocused,
|
|
153
147
|
maxInitialWidth,
|
|
154
148
|
suppressReadOnlyStyle = false,
|
|
149
|
+
externalSelectedItems,
|
|
150
|
+
setExternalSelectedItems,
|
|
151
|
+
externalSelectedIds,
|
|
152
|
+
setExternalSelectedIds,
|
|
155
153
|
...params
|
|
156
154
|
}: GridProps<TData>): ReactElement => {
|
|
157
155
|
const {
|
|
@@ -178,7 +176,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
178
176
|
// CellEditingStop event happens too much for one edit
|
|
179
177
|
const startedEditRef = useRef(false);
|
|
180
178
|
const startCellEditing = useCallback(
|
|
181
|
-
(props: StartCellEditingProps) => {
|
|
179
|
+
(props: StartCellEditingProps<TData>) => {
|
|
182
180
|
startedEditRef.current = true;
|
|
183
181
|
return propStartCellEditing(props);
|
|
184
182
|
},
|
|
@@ -188,7 +186,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
188
186
|
const { updatedDep, anyUpdating, updatingCols } = useContext(GridUpdatingContext);
|
|
189
187
|
|
|
190
188
|
const gridDivRef = useRef<HTMLDivElement>(null);
|
|
191
|
-
const lastSelectedIds = useRef<
|
|
189
|
+
const lastSelectedIds = useRef<TData['id'][] | undefined>();
|
|
192
190
|
|
|
193
191
|
const [staleGrid, setStaleGrid] = useState(false);
|
|
194
192
|
const [autoSized, setAutoSized] = useState(false);
|
|
@@ -326,11 +324,13 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
326
324
|
*/
|
|
327
325
|
const hasSelectedFirstItem = useRef(false);
|
|
328
326
|
useEffect(() => {
|
|
329
|
-
if (!gridReady || hasSelectedFirstItem.current || !rowData || !externallySelectedItemsAreInSync)
|
|
327
|
+
if (!gridReady || hasSelectedFirstItem.current || !rowData || !externallySelectedItemsAreInSync) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
330
|
hasSelectedFirstItem.current = true;
|
|
331
|
-
if (isNotEmpty(rowData) && isEmpty(
|
|
331
|
+
if (isNotEmpty(rowData) && isEmpty(externalSelectedItems)) {
|
|
332
332
|
const firstRowId = getFirstRowId();
|
|
333
|
-
if (
|
|
333
|
+
if (autoSelectFirstRow && selectable) {
|
|
334
334
|
selectRowsById([firstRowId]);
|
|
335
335
|
} else {
|
|
336
336
|
focusByRowById(firstRowId, true);
|
|
@@ -340,11 +340,12 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
340
340
|
externallySelectedItemsAreInSync,
|
|
341
341
|
focusByRowById,
|
|
342
342
|
gridReady,
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
externalSelectedItems,
|
|
344
|
+
autoSelectFirstRow,
|
|
345
345
|
rowData,
|
|
346
346
|
selectRowsById,
|
|
347
347
|
getFirstRowId,
|
|
348
|
+
selectable,
|
|
348
349
|
]);
|
|
349
350
|
|
|
350
351
|
/**
|
|
@@ -352,24 +353,43 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
352
353
|
*/
|
|
353
354
|
const synchroniseExternalStateToGridSelection = useCallback(
|
|
354
355
|
({ api }: SelectionChangedEvent) => {
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
356
|
+
if (externalSelectedIds && setExternalSelectedIds) {
|
|
357
|
+
const selectedRowsIds = api.getSelectedRows().map((row: TData) => row.id);
|
|
358
|
+
|
|
359
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
360
|
+
if (
|
|
361
|
+
externalSelectedIds.length !== selectedRowsIds.length ||
|
|
362
|
+
isNotEmpty(xorBy(selectedRowsIds, externalSelectedIds))
|
|
363
|
+
) {
|
|
364
|
+
setExternallySelectedItemsAreInSync(false);
|
|
365
|
+
setExternalSelectedIds([...selectedRowsIds]);
|
|
366
|
+
} else {
|
|
367
|
+
setExternallySelectedItemsAreInSync(true);
|
|
368
|
+
}
|
|
369
|
+
} else if (externalSelectedItems && setExternalSelectedItems) {
|
|
370
|
+
const selectedRows = api.getSelectedRows();
|
|
371
|
+
|
|
372
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
373
|
+
if (
|
|
374
|
+
externalSelectedItems.length !== selectedRows.length ||
|
|
375
|
+
isNotEmpty(xorBy(selectedRows, externalSelectedItems, (row) => row.id))
|
|
376
|
+
) {
|
|
377
|
+
setExternallySelectedItemsAreInSync(false);
|
|
378
|
+
setExternalSelectedItems([...selectedRows]);
|
|
379
|
+
} else {
|
|
380
|
+
setExternallySelectedItemsAreInSync(true);
|
|
381
|
+
}
|
|
368
382
|
} else {
|
|
369
383
|
setExternallySelectedItemsAreInSync(true);
|
|
370
384
|
}
|
|
371
385
|
},
|
|
372
|
-
[
|
|
386
|
+
[
|
|
387
|
+
externalSelectedIds,
|
|
388
|
+
externalSelectedItems,
|
|
389
|
+
setExternalSelectedIds,
|
|
390
|
+
setExternalSelectedItems,
|
|
391
|
+
setExternallySelectedItemsAreInSync,
|
|
392
|
+
],
|
|
373
393
|
);
|
|
374
394
|
|
|
375
395
|
/**
|
|
@@ -378,20 +398,27 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
378
398
|
*/
|
|
379
399
|
const synchroniseExternallySelectedItemsToGrid = useCallback(() => {
|
|
380
400
|
if (!gridReady) return;
|
|
381
|
-
if (!
|
|
401
|
+
if (!externalSelectedItems && !externalSelectedIds) {
|
|
382
402
|
setExternallySelectedItemsAreInSync(true);
|
|
383
403
|
return;
|
|
384
404
|
}
|
|
385
405
|
|
|
386
|
-
const selectedIds =
|
|
387
|
-
const lastNewId = last(difference(selectedIds, lastSelectedIds.current));
|
|
406
|
+
const selectedIds = externalSelectedIds ?? externalSelectedItems?.map((row) => row.id);
|
|
407
|
+
const lastNewId = last(difference(selectedIds, lastSelectedIds.current ?? []));
|
|
388
408
|
if (lastNewId != null) {
|
|
389
409
|
ensureRowVisible(lastNewId);
|
|
390
410
|
}
|
|
391
411
|
lastSelectedIds.current = selectedIds;
|
|
392
412
|
selectRowsById(selectedIds);
|
|
393
413
|
setExternallySelectedItemsAreInSync(true);
|
|
394
|
-
}, [
|
|
414
|
+
}, [
|
|
415
|
+
gridReady,
|
|
416
|
+
externalSelectedItems,
|
|
417
|
+
externalSelectedIds,
|
|
418
|
+
selectRowsById,
|
|
419
|
+
setExternallySelectedItemsAreInSync,
|
|
420
|
+
ensureRowVisible,
|
|
421
|
+
]);
|
|
395
422
|
|
|
396
423
|
/**
|
|
397
424
|
* Combine grid and cell editable into one function
|
|
@@ -431,7 +458,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
431
458
|
cellClassRules: {
|
|
432
459
|
...colDef.cellClassRules,
|
|
433
460
|
'GridCell-readonly': (ccp: CellClassParams<TData>) =>
|
|
434
|
-
!suppressReadOnlyStyle && !editable(ccp as
|
|
461
|
+
!suppressReadOnlyStyle && !editable(ccp as unknown as EditableCallbackParams<TData>),
|
|
435
462
|
},
|
|
436
463
|
};
|
|
437
464
|
}
|
|
@@ -446,7 +473,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
446
473
|
return params.columnDefs.map(mapColDef);
|
|
447
474
|
}, [params.columnDefs, mapColDef]);
|
|
448
475
|
|
|
449
|
-
const hasExternallySelectedItems = !!
|
|
476
|
+
const hasExternallySelectedItems = !!setExternalSelectedItems || !!setExternalSelectedIds;
|
|
450
477
|
|
|
451
478
|
/**
|
|
452
479
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
@@ -606,7 +633,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
606
633
|
let comparator = colDef.comparator;
|
|
607
634
|
if (sortable && !comparator) {
|
|
608
635
|
comparator = (value1, value2, node1, node2) => {
|
|
609
|
-
let r
|
|
636
|
+
let r;
|
|
610
637
|
if (typeof valueFormatter === 'function') {
|
|
611
638
|
r = compareNaturalInsensitive(
|
|
612
639
|
valueFormatter({
|
|
@@ -828,14 +855,19 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
828
855
|
[params, clearHighlightRowClasses],
|
|
829
856
|
);
|
|
830
857
|
|
|
831
|
-
useEffect(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
'
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
858
|
+
useEffect(
|
|
859
|
+
() => {
|
|
860
|
+
if ((setExternalSelectedItems || setExternalSelectedIds) && selectable == null) {
|
|
861
|
+
console.warn(
|
|
862
|
+
'<Grid/> has setExternalSelectedItems/setExternalSelectedIds parameter, but is missing selectable parameter,' +
|
|
863
|
+
'this will cause weird delays in editing.\nIf you need to hide selection column use hideSelectColumn=true',
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
// Only needs to run on startup
|
|
868
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
869
|
+
[selectable],
|
|
870
|
+
);
|
|
839
871
|
|
|
840
872
|
// This is setting a ref in the GridContext so won't be triggering an update loop
|
|
841
873
|
setOnBulkEditingComplete(params.onBulkEditingComplete);
|
|
@@ -897,20 +929,9 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
897
929
|
}
|
|
898
930
|
return false;
|
|
899
931
|
},
|
|
900
|
-
onCellClicked:
|
|
901
|
-
params.enableSelectionWithoutKeys || params.enableClickSelection
|
|
902
|
-
? undefined
|
|
903
|
-
: clickInputWhenContainingCellClicked,
|
|
932
|
+
onCellClicked: clickInputWhenContainingCellClicked,
|
|
904
933
|
};
|
|
905
|
-
}, [
|
|
906
|
-
params.enableClickSelection,
|
|
907
|
-
params.enableSelectionWithoutKeys,
|
|
908
|
-
params.hideSelectColumn,
|
|
909
|
-
params.onRowDragEnd,
|
|
910
|
-
rowSelection,
|
|
911
|
-
selectColumnPinned,
|
|
912
|
-
selectable,
|
|
913
|
-
]);
|
|
934
|
+
}, [params.hideSelectColumn, params.onRowDragEnd, rowSelection, selectColumnPinned, selectable]);
|
|
914
935
|
|
|
915
936
|
const onGridSizeChanged = useCallback(
|
|
916
937
|
(event: GridSizeChangedEvent<TData>) => {
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ColDef,
|
|
3
|
-
EditableCallback,
|
|
4
3
|
GetQuickFilterTextParams,
|
|
5
4
|
ICellEditorParams,
|
|
6
5
|
ICellRendererParams,
|
|
7
|
-
} from 'ag-grid-community';
|
|
8
|
-
import {
|
|
9
6
|
SuppressKeyboardEventParams,
|
|
10
7
|
ValueFormatterFunc,
|
|
11
8
|
ValueFormatterParams,
|
|
12
|
-
ValueGetterFunc,
|
|
13
9
|
} from 'ag-grid-community';
|
|
14
10
|
import { forwardRef, ReactElement, useContext } from 'react';
|
|
15
11
|
|
|
16
12
|
import { GridPopoverContextProvider } from '../contexts/GridPopoverContextProvider';
|
|
17
13
|
import { GridUpdatingContext } from '../contexts/GridUpdatingContext';
|
|
18
14
|
import { fnOrVar } from '../utils/util';
|
|
19
|
-
import { GridBaseRow } from './Grid';
|
|
20
15
|
import { GridCellMultiSelectClassRules } from './GridCellMultiSelectClassRules';
|
|
21
16
|
import { GridIcon } from './GridIcon';
|
|
22
17
|
import { GridLoadableCell } from './GridLoadableCell';
|
|
23
18
|
import { GenericCellColDef, GenericCellRendererParams } from './gridRender';
|
|
19
|
+
import { ColDefT, GridBaseRow } from './types';
|
|
24
20
|
|
|
25
21
|
export interface GenericCellEditorProps<E> {
|
|
26
22
|
multiEdit?: boolean;
|
|
@@ -74,26 +70,6 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
|
74
70
|
);
|
|
75
71
|
};
|
|
76
72
|
|
|
77
|
-
// This is so that typescript retains the row type to pass to the GridCells
|
|
78
|
-
export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
|
|
79
|
-
editable?: boolean | EditableCallback<TData, ValueType>;
|
|
80
|
-
valueGetter?: string | ValueGetterFunc<TData, ValueType>;
|
|
81
|
-
valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
|
|
82
|
-
cellRenderer?:
|
|
83
|
-
| ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
|
|
84
|
-
| string;
|
|
85
|
-
cellRendererParams?: {
|
|
86
|
-
rightHoverElement?: ReactElement;
|
|
87
|
-
originalCellRenderer?: any;
|
|
88
|
-
editAction?: (selectedRows: TData[]) => void;
|
|
89
|
-
shortcutKeys?: Record<string, () => void>;
|
|
90
|
-
error?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
91
|
-
warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
92
|
-
info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
93
|
-
};
|
|
94
|
-
editor?: (editorProps: any) => ReactElement;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
73
|
export const suppressCellKeyboardEvents = (e: SuppressKeyboardEventParams) => {
|
|
98
74
|
const shortcutKeys = e.colDef.cellRendererParams?.shortcutKeys ?? {};
|
|
99
75
|
const exec = shortcutKeys[e.event.key];
|
|
@@ -2,10 +2,10 @@ import { CellEditorSelectorResult } from 'ag-grid-community';
|
|
|
2
2
|
import { ICellEditorParams } from 'ag-grid-community';
|
|
3
3
|
import { ComponentProps, ReactElement } from 'react';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { ColDefT, GenericCellEditorComponentWrapper, GridCell } from './GridCell';
|
|
5
|
+
import { GenericCellEditorComponentWrapper, GridCell } from './GridCell';
|
|
7
6
|
import { GridCellMultiSelectClassRules } from './GridCellMultiSelectClassRules';
|
|
8
7
|
import { GenericCellColDef } from './gridRender';
|
|
8
|
+
import { ColDefT, GridBaseRow } from './types';
|
|
9
9
|
|
|
10
10
|
export const Editor = <FN extends (param: any) => ReactElement>(props: {
|
|
11
11
|
multiEdit: boolean;
|
|
@@ -4,7 +4,7 @@ import { useGridPopoverContext } from '../contexts/GridPopoverContext';
|
|
|
4
4
|
import { ControlledMenu } from '../react-menu3';
|
|
5
5
|
import { MenuCloseEvent } from '../react-menu3/types';
|
|
6
6
|
import { CloseReason } from '../react-menu3/utils';
|
|
7
|
-
import { GridBaseRow } from './
|
|
7
|
+
import { GridBaseRow } from './types';
|
|
8
8
|
|
|
9
9
|
export interface GridPopoverHookProps<TData> {
|
|
10
10
|
className: string | undefined;
|
|
@@ -4,7 +4,7 @@ import clsx, { ClassValue } from 'clsx';
|
|
|
4
4
|
import { ReactElement, useMemo, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
import { GridFilterExternal } from '../../contexts/GridContext';
|
|
7
|
-
import { GridBaseRow } from '../
|
|
7
|
+
import { GridBaseRow } from '../types';
|
|
8
8
|
import { useGridFilter } from './useGridFilter';
|
|
9
9
|
|
|
10
10
|
export interface GridFilterButtonsOption<TData extends GridBaseRow> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import { GridFilterExternal, useGridContext } from '../../contexts/GridContext';
|
|
4
|
-
import { GridBaseRow } from '../
|
|
4
|
+
import { GridBaseRow } from '../types';
|
|
5
5
|
|
|
6
6
|
export const useGridFilter = <TData extends GridBaseRow>(filter: GridFilterExternal<TData> | undefined) => {
|
|
7
7
|
const { addExternalFilter, removeExternalFilter } = useGridContext<TData>();
|
|
@@ -11,9 +11,9 @@ import { ClickEvent } from '../../react-menu3/types';
|
|
|
11
11
|
import { textMatch } from '../../utils/textMatcher';
|
|
12
12
|
import { isNotEmpty } from '../../utils/util';
|
|
13
13
|
import { ComponentLoadingWrapper } from '../ComponentLoadingWrapper';
|
|
14
|
-
import { GridBaseRow } from '../Grid';
|
|
15
14
|
import { CellEditorCommon } from '../GridCell';
|
|
16
15
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
16
|
+
import { GridBaseRow } from '../types';
|
|
17
17
|
|
|
18
18
|
export interface GridPopoutEditDropDownSelectedItem<TData extends GridBaseRow, TOption> {
|
|
19
19
|
// Note the row that was clicked on will be first
|
|
@@ -3,9 +3,9 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useGridPopoverContext } from '../../contexts/GridPopoverContext';
|
|
4
4
|
import { TextInputFormatted } from '../../lui/TextInputFormatted';
|
|
5
5
|
import { bearingNumberParser, bearingStringValidator } from '../../utils/bearing';
|
|
6
|
-
import { GridBaseRow } from '../Grid';
|
|
7
6
|
import { CellEditorCommon } from '../GridCell';
|
|
8
7
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
8
|
+
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridFormEditBearingProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
11
11
|
formatValue?: (value: any) => string;
|
|
@@ -3,9 +3,9 @@ import { ReactElement, useEffect, useState } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { useGridPopoverContext } from '../../contexts/GridPopoverContext';
|
|
5
5
|
import { ComponentLoadingWrapper } from '../ComponentLoadingWrapper';
|
|
6
|
-
import { GridBaseRow } from '../Grid';
|
|
7
6
|
import { CellEditorCommon } from '../GridCell';
|
|
8
7
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
8
|
+
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridFormMessageProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
11
11
|
message: (selectedRows: TData[]) => Promise<string | ReactElement> | string | ReactElement;
|
|
@@ -21,10 +21,10 @@ import { FocusableItem, MenuDivider, MenuHeader, MenuItem } from '../../react-me
|
|
|
21
21
|
import { ClickEvent } from '../../react-menu3/types';
|
|
22
22
|
import { textMatch } from '../../utils/textMatcher';
|
|
23
23
|
import { ComponentLoadingWrapper } from '../ComponentLoadingWrapper';
|
|
24
|
-
import { GridBaseRow } from '../Grid';
|
|
25
24
|
import { CellEditorCommon } from '../GridCell';
|
|
26
25
|
import { GridIcon } from '../GridIcon';
|
|
27
26
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
27
|
+
import { GridBaseRow } from '../types';
|
|
28
28
|
import { MenuSeparatorString } from './GridFormDropDown';
|
|
29
29
|
|
|
30
30
|
type HeaderGroupType = Record<string, MultiSelectOption[]> | undefined;
|
|
@@ -5,10 +5,10 @@ import { ReactElement, useCallback, useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import { useGridPopoverContext } from '../../contexts/GridPopoverContext';
|
|
6
6
|
import { MenuItem } from '../../react-menu3';
|
|
7
7
|
import { ClickEvent } from '../../react-menu3/types';
|
|
8
|
-
import { GridBaseRow } from '../Grid';
|
|
9
8
|
import { CellEditorCommon } from '../GridCell';
|
|
10
9
|
import { GridIcon } from '../GridIcon';
|
|
11
10
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
11
|
+
import { GridBaseRow } from '../types';
|
|
12
12
|
|
|
13
13
|
export interface MultiSelectGridOption {
|
|
14
14
|
value: any;
|
|
@@ -6,9 +6,9 @@ import { GridSubComponentContext } from '../../contexts/GridSubComponentContext'
|
|
|
6
6
|
import { FocusableItem, MenuDivider, MenuItem, SubMenu } from '../../react-menu3';
|
|
7
7
|
import { ClickEvent } from '../../react-menu3/types';
|
|
8
8
|
import { ComponentLoadingWrapper } from '../ComponentLoadingWrapper';
|
|
9
|
-
import { GridBaseRow } from '../Grid';
|
|
10
9
|
import { CellEditorCommon } from '../GridCell';
|
|
11
10
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
11
|
+
import { GridBaseRow } from '../types';
|
|
12
12
|
|
|
13
13
|
export interface GridFormPopoverMenuProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
14
14
|
options: (selectedRows: TData[]) => Promise<MenuOption<TData>[]> | MenuOption<TData>[];
|
|
@@ -4,8 +4,8 @@ import { ReactElement, useCallback, useContext, useEffect } from 'react';
|
|
|
4
4
|
import { GridSubComponentContext } from '../../contexts/GridSubComponentContext';
|
|
5
5
|
import { TextAreaInput } from '../../lui/TextAreaInput';
|
|
6
6
|
import { TextInputValidator, TextInputValidatorProps } from '../../utils/textValidator';
|
|
7
|
-
import { GridBaseRow } from '../Grid';
|
|
8
7
|
import { CellEditorCommon } from '../GridCell';
|
|
8
|
+
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridSubComponentTextAreaProps<TData extends GridBaseRow>
|
|
11
11
|
extends TextInputValidatorProps<TData>,
|
|
@@ -3,8 +3,8 @@ import { ReactElement, useCallback, useContext, useEffect } from 'react';
|
|
|
3
3
|
import { GridSubComponentContext } from '../../contexts/GridSubComponentContext';
|
|
4
4
|
import { TextInputFormatted } from '../../lui/TextInputFormatted';
|
|
5
5
|
import { TextInputValidator, TextInputValidatorProps } from '../../utils/textValidator';
|
|
6
|
-
import { GridBaseRow } from '../Grid';
|
|
7
6
|
import { CellEditorCommon } from '../GridCell';
|
|
7
|
+
import { GridBaseRow } from '../types';
|
|
8
8
|
|
|
9
9
|
export interface GridFormSubComponentTextInputProps<TData extends GridBaseRow>
|
|
10
10
|
extends TextInputValidatorProps<TData>,
|
|
@@ -3,9 +3,9 @@ import { ReactElement, useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useGridPopoverContext } from '../../contexts/GridPopoverContext';
|
|
4
4
|
import { TextAreaInput } from '../../lui/TextAreaInput';
|
|
5
5
|
import { TextInputValidator, TextInputValidatorProps } from '../../utils/textValidator';
|
|
6
|
-
import { GridBaseRow } from '../Grid';
|
|
7
6
|
import { CellEditorCommon } from '../GridCell';
|
|
8
7
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
8
|
+
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridFormTextAreaProps<TData extends GridBaseRow>
|
|
11
11
|
extends TextInputValidatorProps<TData>,
|
|
@@ -3,9 +3,9 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useGridPopoverContext } from '../../contexts/GridPopoverContext';
|
|
4
4
|
import { TextInputFormatted } from '../../lui/TextInputFormatted';
|
|
5
5
|
import { TextInputValidator, TextInputValidatorProps } from '../../utils/textValidator';
|
|
6
|
-
import { GridBaseRow } from '../Grid';
|
|
7
6
|
import { CellEditorCommon } from '../GridCell';
|
|
8
7
|
import { useGridPopoverHook } from '../GridPopoverHook';
|
|
8
|
+
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridFormTextInputProps<TData extends GridBaseRow>
|
|
11
11
|
extends TextInputValidatorProps<TData>,
|
|
@@ -4,7 +4,7 @@ import { ReactElement, useCallback, useContext, useRef, useState } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import { GridContext } from '../../contexts/GridContext';
|
|
6
6
|
import { ControlledMenu } from '../../react-menu3';
|
|
7
|
-
import { GridBaseRow } from '../
|
|
7
|
+
import { GridBaseRow } from '../types';
|
|
8
8
|
|
|
9
9
|
export interface GridContextMenuComponentProps<TData extends GridBaseRow> {
|
|
10
10
|
selectedRows: TData[];
|
|
@@ -2,9 +2,9 @@ import { LuiButton, LuiIcon } from '@linzjs/lui';
|
|
|
2
2
|
import { CellFocusedEvent, ICellEditorParams, ICellRendererParams } from 'ag-grid-community';
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { ColDefT, GridCell } from '../GridCell';
|
|
5
|
+
import { GridCell } from '../GridCell';
|
|
7
6
|
import { GenericCellColDef } from '../gridRender';
|
|
7
|
+
import { ColDefT, GridBaseRow } from '../types';
|
|
8
8
|
|
|
9
9
|
const ButtonCellRenderer = <TData extends GridBaseRow>(props: ICellRendererParams<TData>) => {
|
|
10
10
|
const { data, node, column, colDef, api } = props;
|
|
@@ -5,9 +5,9 @@ import { useEffect, useRef } from 'react';
|
|
|
5
5
|
|
|
6
6
|
import { fnOrVar } from '../../utils/util';
|
|
7
7
|
import { clickInputWhenContainingCellClicked } from '../clickInputWhenContainingCellClicked';
|
|
8
|
-
import {
|
|
9
|
-
import { CellEditorCommon, ColDefT, GridCell } from '../GridCell';
|
|
8
|
+
import { CellEditorCommon, GridCell } from '../GridCell';
|
|
10
9
|
import { GenericCellColDef } from '../gridRender';
|
|
10
|
+
import { ColDefT, GridBaseRow } from '../types';
|
|
11
11
|
|
|
12
12
|
const BooleanCellRenderer = (props: CustomCellEditorProps) => {
|
|
13
13
|
const { onValueChange, value, api, node, column, colDef, data } = props;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { ColDefT, GenericCellEditorProps, GridCell } from '../GridCell';
|
|
3
|
+
import { GenericCellEditorProps, GridCell } from '../GridCell';
|
|
5
4
|
import { GridFormMultiSelect, GridFormMultiSelectProps } from '../gridForm/GridFormMultiSelect';
|
|
6
5
|
import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
|
|
6
|
+
import { ColDefT, GridBaseRow } from '../types';
|
|
7
7
|
|
|
8
8
|
export const GridPopoutEditMultiSelect = <TData extends GridBaseRow, TValue = any>(
|
|
9
9
|
colDef: GenericCellColDef<TData, TValue>,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
|
|
3
|
-
import {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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>,
|