@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/dist/step-ag-grid.esm.js
CHANGED
|
@@ -426,147 +426,53 @@ function useInterval(callback, delay) {
|
|
|
426
426
|
}, [delay]);
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
+
const NoContext = () => {
|
|
430
|
+
console.error('Missing GridContextProvider');
|
|
431
|
+
return null;
|
|
432
|
+
};
|
|
429
433
|
const GridContext = createContext({
|
|
430
434
|
gridReady: false,
|
|
431
435
|
gridRenderState: () => null,
|
|
432
|
-
getColDef:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
},
|
|
436
|
-
getColumns: () => {
|
|
437
|
-
console.error('no context provider for getColumns');
|
|
438
|
-
return [];
|
|
439
|
-
},
|
|
440
|
-
getColumnIds: () => {
|
|
441
|
-
console.error('no context provider for getColumnIds');
|
|
442
|
-
return [];
|
|
443
|
-
},
|
|
436
|
+
getColDef: NoContext,
|
|
437
|
+
getColumns: NoContext,
|
|
438
|
+
getColumnIds: NoContext,
|
|
444
439
|
invisibleColumnIds: undefined,
|
|
445
|
-
setInvisibleColumnIds:
|
|
446
|
-
|
|
447
|
-
},
|
|
448
|
-
prePopupOps: () => {
|
|
449
|
-
console.error('no context provider for prePopupOps');
|
|
450
|
-
},
|
|
440
|
+
setInvisibleColumnIds: NoContext,
|
|
441
|
+
prePopupOps: NoContext,
|
|
451
442
|
externallySelectedItemsAreInSync: false,
|
|
452
|
-
setApis:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
selectRowsWithFlashDiff: async () => {
|
|
486
|
-
console.error('no context provider for selectRowsWithFlashDiff');
|
|
487
|
-
},
|
|
488
|
-
flashRows: () => {
|
|
489
|
-
console.error('no context provider for flashRows');
|
|
490
|
-
},
|
|
491
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
492
|
-
flashRowsDiff: async () => {
|
|
493
|
-
console.error('no context provider for flashRows');
|
|
494
|
-
},
|
|
495
|
-
// eslint-disable-next-line @typescript-eslint/require-await,@typescript-eslint/no-misused-promises
|
|
496
|
-
focusByRowById: async () => {
|
|
497
|
-
console.error('no context provider for focusByRowById');
|
|
498
|
-
},
|
|
499
|
-
ensureRowVisible: () => {
|
|
500
|
-
console.error('no context provider for ensureRowVisible');
|
|
501
|
-
return true;
|
|
502
|
-
},
|
|
503
|
-
ensureSelectedRowIsVisible: () => {
|
|
504
|
-
console.error('no context provider for ensureSelectedRowIsVisible');
|
|
505
|
-
},
|
|
506
|
-
getFirstRowId: () => {
|
|
507
|
-
console.error('no context provider for getFirstRowId');
|
|
508
|
-
return -1;
|
|
509
|
-
},
|
|
510
|
-
autoSizeColumns: async () => {
|
|
511
|
-
console.error('no context provider for autoSizeColumns');
|
|
512
|
-
return Promise.resolve(null);
|
|
513
|
-
},
|
|
514
|
-
sizeColumnsToFit: () => {
|
|
515
|
-
console.error('no context provider for autoSizeAllColumns');
|
|
516
|
-
return null;
|
|
517
|
-
},
|
|
518
|
-
editingCells: () => {
|
|
519
|
-
console.error('no context provider for editingCells');
|
|
520
|
-
return false;
|
|
521
|
-
},
|
|
522
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
523
|
-
startCellEditing: async () => {
|
|
524
|
-
console.error('no context provider for startCellEditing');
|
|
525
|
-
},
|
|
526
|
-
resetFocusedCellAfterCellEditing: () => {
|
|
527
|
-
console.error('no context provider for resetFocusedCellAfterCellEditing');
|
|
528
|
-
},
|
|
529
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
530
|
-
updatingCells: async () => {
|
|
531
|
-
console.error('no context provider for modifyUpdating');
|
|
532
|
-
return false;
|
|
533
|
-
},
|
|
534
|
-
redrawRows: () => {
|
|
535
|
-
console.error('no context provider for redrawRows');
|
|
536
|
-
},
|
|
537
|
-
setExternallySelectedItemsAreInSync: () => {
|
|
538
|
-
console.error('no context provider for setExternallySelectedItemsAreInSync');
|
|
539
|
-
},
|
|
540
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
541
|
-
waitForExternallySelectedItemsToBeInSync: async () => {
|
|
542
|
-
console.error('no context provider for waitForExternallySelectedItemsToBeInSync');
|
|
543
|
-
},
|
|
544
|
-
addExternalFilter: () => {
|
|
545
|
-
console.error('no context provider for addExternalFilter');
|
|
546
|
-
},
|
|
547
|
-
removeExternalFilter: () => {
|
|
548
|
-
console.error('no context provider for removeExternalFilter');
|
|
549
|
-
},
|
|
550
|
-
isExternalFilterPresent: () => {
|
|
551
|
-
console.error('no context provider for isExternalFilterPresent');
|
|
552
|
-
return false;
|
|
553
|
-
},
|
|
554
|
-
doesExternalFilterPass: () => {
|
|
555
|
-
console.error('no context provider for doesExternalFilterPass');
|
|
556
|
-
return true;
|
|
557
|
-
},
|
|
558
|
-
downloadCsv: () => {
|
|
559
|
-
console.error('no context provider for downloadCsv');
|
|
560
|
-
},
|
|
561
|
-
onBulkEditingComplete: () => {
|
|
562
|
-
console.error('no context provider for onBulkEditingComplete');
|
|
563
|
-
},
|
|
564
|
-
setOnBulkEditingComplete: () => {
|
|
565
|
-
console.error('no context provider for setOnBulkEditingComplete');
|
|
566
|
-
},
|
|
567
|
-
showNoRowsOverlay: () => {
|
|
568
|
-
console.error('no context provider for showLoadingOverlay');
|
|
569
|
-
},
|
|
443
|
+
setApis: NoContext,
|
|
444
|
+
setQuickFilter: NoContext,
|
|
445
|
+
selectRowsById: NoContext,
|
|
446
|
+
getSelectedRows: NoContext,
|
|
447
|
+
getFilteredSelectedRows: NoContext,
|
|
448
|
+
getSelectedRowIds: NoContext,
|
|
449
|
+
getFilteredSelectedRowIds: NoContext,
|
|
450
|
+
selectRowsDiff: NoContext,
|
|
451
|
+
selectRowsByIdWithFlash: NoContext,
|
|
452
|
+
selectRowsWithFlashDiff: NoContext,
|
|
453
|
+
flashRows: NoContext,
|
|
454
|
+
flashRowsDiff: NoContext,
|
|
455
|
+
focusByRowById: NoContext,
|
|
456
|
+
ensureRowVisible: NoContext,
|
|
457
|
+
ensureSelectedRowIsVisible: NoContext,
|
|
458
|
+
getFirstRowId: NoContext,
|
|
459
|
+
autoSizeColumns: NoContext,
|
|
460
|
+
sizeColumnsToFit: NoContext,
|
|
461
|
+
editingCells: NoContext,
|
|
462
|
+
startCellEditing: NoContext,
|
|
463
|
+
resetFocusedCellAfterCellEditing: NoContext,
|
|
464
|
+
updatingCells: NoContext,
|
|
465
|
+
redrawRows: NoContext,
|
|
466
|
+
setExternallySelectedItemsAreInSync: NoContext,
|
|
467
|
+
waitForExternallySelectedItemsToBeInSync: NoContext,
|
|
468
|
+
addExternalFilter: NoContext,
|
|
469
|
+
removeExternalFilter: NoContext,
|
|
470
|
+
isExternalFilterPresent: NoContext,
|
|
471
|
+
doesExternalFilterPass: NoContext,
|
|
472
|
+
downloadCsv: NoContext,
|
|
473
|
+
onBulkEditingComplete: NoContext,
|
|
474
|
+
setOnBulkEditingComplete: NoContext,
|
|
475
|
+
showNoRowsOverlay: NoContext,
|
|
570
476
|
});
|
|
571
477
|
const useGridContext = () => useContext(GridContext);
|
|
572
478
|
|
|
@@ -2900,7 +2806,7 @@ ModuleRegistry.registerModules([AllCommunityModule]);
|
|
|
2900
2806
|
/**
|
|
2901
2807
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2902
2808
|
*/
|
|
2903
|
-
const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection = 'multiple', suppressColumnVirtualization = true, theme = 'ag-theme-step-default', sizeColumns = 'auto', selectColumnPinned = 'left', contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, suppressReadOnlyStyle = false, ...params }) => {
|
|
2809
|
+
const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection = 'multiple', suppressColumnVirtualization = true, theme = 'ag-theme-step-default', sizeColumns = 'auto', selectColumnPinned = 'left', contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, selectable, autoSelectFirstRow, onCellFocused: paramsOnCellFocused, maxInitialWidth, suppressReadOnlyStyle = false, externalSelectedItems, setExternalSelectedItems, externalSelectedIds, setExternalSelectedIds, ...params }) => {
|
|
2904
2810
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing: propStartCellEditing, } = useGridContext();
|
|
2905
2811
|
// CellEditingStop event happens too much for one edit
|
|
2906
2812
|
const startedEditRef = useRef(false);
|
|
@@ -2910,7 +2816,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2910
2816
|
}, [propStartCellEditing]);
|
|
2911
2817
|
const { updatedDep, anyUpdating, updatingCols } = useContext(GridUpdatingContext);
|
|
2912
2818
|
const gridDivRef = useRef(null);
|
|
2913
|
-
const lastSelectedIds = useRef(
|
|
2819
|
+
const lastSelectedIds = useRef();
|
|
2914
2820
|
const [staleGrid, setStaleGrid] = useState(false);
|
|
2915
2821
|
const [autoSized, setAutoSized] = useState(false);
|
|
2916
2822
|
const postSortRows = usePostSortRowsHook({ setStaleGrid });
|
|
@@ -3036,12 +2942,13 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3036
2942
|
*/
|
|
3037
2943
|
const hasSelectedFirstItem = useRef(false);
|
|
3038
2944
|
useEffect(() => {
|
|
3039
|
-
if (!gridReady || hasSelectedFirstItem.current || !rowData || !externallySelectedItemsAreInSync)
|
|
2945
|
+
if (!gridReady || hasSelectedFirstItem.current || !rowData || !externallySelectedItemsAreInSync) {
|
|
3040
2946
|
return;
|
|
2947
|
+
}
|
|
3041
2948
|
hasSelectedFirstItem.current = true;
|
|
3042
|
-
if (isNotEmpty(rowData) && isEmpty(
|
|
2949
|
+
if (isNotEmpty(rowData) && isEmpty(externalSelectedItems)) {
|
|
3043
2950
|
const firstRowId = getFirstRowId();
|
|
3044
|
-
if (
|
|
2951
|
+
if (autoSelectFirstRow && selectable) {
|
|
3045
2952
|
selectRowsById([firstRowId]);
|
|
3046
2953
|
}
|
|
3047
2954
|
else {
|
|
@@ -3052,31 +2959,51 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3052
2959
|
externallySelectedItemsAreInSync,
|
|
3053
2960
|
focusByRowById,
|
|
3054
2961
|
gridReady,
|
|
3055
|
-
|
|
3056
|
-
|
|
2962
|
+
externalSelectedItems,
|
|
2963
|
+
autoSelectFirstRow,
|
|
3057
2964
|
rowData,
|
|
3058
2965
|
selectRowsById,
|
|
3059
2966
|
getFirstRowId,
|
|
2967
|
+
selectable,
|
|
3060
2968
|
]);
|
|
3061
2969
|
/**
|
|
3062
2970
|
* Ensure external selected items list is in sync with panel.
|
|
3063
2971
|
*/
|
|
3064
2972
|
const synchroniseExternalStateToGridSelection = useCallback(({ api }) => {
|
|
3065
|
-
if (
|
|
3066
|
-
|
|
3067
|
-
|
|
2973
|
+
if (externalSelectedIds && setExternalSelectedIds) {
|
|
2974
|
+
const selectedRowsIds = api.getSelectedRows().map((row) => row.id);
|
|
2975
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
2976
|
+
if (externalSelectedIds.length !== selectedRowsIds.length ||
|
|
2977
|
+
isNotEmpty(xorBy(selectedRowsIds, externalSelectedIds))) {
|
|
2978
|
+
setExternallySelectedItemsAreInSync(false);
|
|
2979
|
+
setExternalSelectedIds([...selectedRowsIds]);
|
|
2980
|
+
}
|
|
2981
|
+
else {
|
|
2982
|
+
setExternallySelectedItemsAreInSync(true);
|
|
2983
|
+
}
|
|
3068
2984
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
2985
|
+
else if (externalSelectedItems && setExternalSelectedItems) {
|
|
2986
|
+
const selectedRows = api.getSelectedRows();
|
|
2987
|
+
// We don't want to update selected Items if it hasn't changed to prevent excess renders
|
|
2988
|
+
if (externalSelectedItems.length !== selectedRows.length ||
|
|
2989
|
+
isNotEmpty(xorBy(selectedRows, externalSelectedItems, (row) => row.id))) {
|
|
2990
|
+
setExternallySelectedItemsAreInSync(false);
|
|
2991
|
+
setExternalSelectedItems([...selectedRows]);
|
|
2992
|
+
}
|
|
2993
|
+
else {
|
|
2994
|
+
setExternallySelectedItemsAreInSync(true);
|
|
2995
|
+
}
|
|
3075
2996
|
}
|
|
3076
2997
|
else {
|
|
3077
2998
|
setExternallySelectedItemsAreInSync(true);
|
|
3078
2999
|
}
|
|
3079
|
-
}, [
|
|
3000
|
+
}, [
|
|
3001
|
+
externalSelectedIds,
|
|
3002
|
+
externalSelectedItems,
|
|
3003
|
+
setExternalSelectedIds,
|
|
3004
|
+
setExternalSelectedItems,
|
|
3005
|
+
setExternallySelectedItemsAreInSync,
|
|
3006
|
+
]);
|
|
3080
3007
|
/**
|
|
3081
3008
|
* Synchronise externally selected items to grid.
|
|
3082
3009
|
* If new ids are selected scroll them into view.
|
|
@@ -3084,19 +3011,26 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3084
3011
|
const synchroniseExternallySelectedItemsToGrid = useCallback(() => {
|
|
3085
3012
|
if (!gridReady)
|
|
3086
3013
|
return;
|
|
3087
|
-
if (!
|
|
3014
|
+
if (!externalSelectedItems && !externalSelectedIds) {
|
|
3088
3015
|
setExternallySelectedItemsAreInSync(true);
|
|
3089
3016
|
return;
|
|
3090
3017
|
}
|
|
3091
|
-
const selectedIds =
|
|
3092
|
-
const lastNewId = last(difference(selectedIds, lastSelectedIds.current));
|
|
3018
|
+
const selectedIds = externalSelectedIds ?? externalSelectedItems?.map((row) => row.id);
|
|
3019
|
+
const lastNewId = last(difference(selectedIds, lastSelectedIds.current ?? []));
|
|
3093
3020
|
if (lastNewId != null) {
|
|
3094
3021
|
ensureRowVisible(lastNewId);
|
|
3095
3022
|
}
|
|
3096
3023
|
lastSelectedIds.current = selectedIds;
|
|
3097
3024
|
selectRowsById(selectedIds);
|
|
3098
3025
|
setExternallySelectedItemsAreInSync(true);
|
|
3099
|
-
}, [
|
|
3026
|
+
}, [
|
|
3027
|
+
gridReady,
|
|
3028
|
+
externalSelectedItems,
|
|
3029
|
+
externalSelectedIds,
|
|
3030
|
+
selectRowsById,
|
|
3031
|
+
setExternallySelectedItemsAreInSync,
|
|
3032
|
+
ensureRowVisible,
|
|
3033
|
+
]);
|
|
3100
3034
|
/**
|
|
3101
3035
|
* Combine grid and cell editable into one function
|
|
3102
3036
|
*/
|
|
@@ -3138,7 +3072,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3138
3072
|
const columnDefs = useMemo(() => {
|
|
3139
3073
|
return params.columnDefs.map(mapColDef);
|
|
3140
3074
|
}, [params.columnDefs, mapColDef]);
|
|
3141
|
-
const hasExternallySelectedItems = !!
|
|
3075
|
+
const hasExternallySelectedItems = !!setExternalSelectedItems || !!setExternalSelectedIds;
|
|
3142
3076
|
/**
|
|
3143
3077
|
* When grid is ready set the apis to the grid context and sync selected items to grid.
|
|
3144
3078
|
*/
|
|
@@ -3268,7 +3202,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3268
3202
|
let comparator = colDef.comparator;
|
|
3269
3203
|
if (sortable && !comparator) {
|
|
3270
3204
|
comparator = (value1, value2, node1, node2) => {
|
|
3271
|
-
let r
|
|
3205
|
+
let r;
|
|
3272
3206
|
if (typeof valueFormatter === 'function') {
|
|
3273
3207
|
r = compareNaturalInsensitive(valueFormatter({
|
|
3274
3208
|
data: node1.data,
|
|
@@ -3465,11 +3399,14 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3465
3399
|
}
|
|
3466
3400
|
}, [params, clearHighlightRowClasses]);
|
|
3467
3401
|
useEffect(() => {
|
|
3468
|
-
if (
|
|
3469
|
-
console.warn('<Grid/> has setExternalSelectedItems parameter, but is missing selectable parameter,' +
|
|
3402
|
+
if ((setExternalSelectedItems || setExternalSelectedIds) && selectable == null) {
|
|
3403
|
+
console.warn('<Grid/> has setExternalSelectedItems/setExternalSelectedIds parameter, but is missing selectable parameter,' +
|
|
3470
3404
|
'this will cause weird delays in editing.\nIf you need to hide selection column use hideSelectColumn=true');
|
|
3471
3405
|
}
|
|
3472
|
-
},
|
|
3406
|
+
},
|
|
3407
|
+
// Only needs to run on startup
|
|
3408
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3409
|
+
[selectable]);
|
|
3473
3410
|
// This is setting a ref in the GridContext so won't be triggering an update loop
|
|
3474
3411
|
setOnBulkEditingComplete(params.onBulkEditingComplete);
|
|
3475
3412
|
const getRowId = useCallback((params) => `${params.data.id}`, []);
|
|
@@ -3513,19 +3450,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3513
3450
|
}
|
|
3514
3451
|
return false;
|
|
3515
3452
|
},
|
|
3516
|
-
onCellClicked:
|
|
3517
|
-
? undefined
|
|
3518
|
-
: clickInputWhenContainingCellClicked,
|
|
3453
|
+
onCellClicked: clickInputWhenContainingCellClicked,
|
|
3519
3454
|
};
|
|
3520
|
-
}, [
|
|
3521
|
-
params.enableClickSelection,
|
|
3522
|
-
params.enableSelectionWithoutKeys,
|
|
3523
|
-
params.hideSelectColumn,
|
|
3524
|
-
params.onRowDragEnd,
|
|
3525
|
-
rowSelection,
|
|
3526
|
-
selectColumnPinned,
|
|
3527
|
-
selectable,
|
|
3528
|
-
]);
|
|
3455
|
+
}, [params.hideSelectColumn, params.onRowDragEnd, rowSelection, selectColumnPinned, selectable]);
|
|
3529
3456
|
const onGridSizeChanged = useCallback((event) => {
|
|
3530
3457
|
if (sizeColumns === 'fit' || (['auto', 'auto-skip-headers'].includes(sizeColumns) && hasSetContentSize.current)) {
|
|
3531
3458
|
event.api.sizeColumnsToFit();
|