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