@linzjs/step-ag-grid 29.3.1 → 29.3.3
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/step-ag-grid.cjs +37 -18
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +38 -19
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +44 -20
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2764,7 +2764,7 @@ agGridCommunity.ModuleRegistry.registerModules([agGridCommunity.AllCommunityModu
|
|
|
2764
2764
|
*/
|
|
2765
2765
|
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, ...params }) => {
|
|
2766
2766
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing, } = useGridContext();
|
|
2767
|
-
const { updatedDep, updatingCols } = React.useContext(GridUpdatingContext);
|
|
2767
|
+
const { updatedDep, anyUpdating, updatingCols } = React.useContext(GridUpdatingContext);
|
|
2768
2768
|
const gridDivRef = React.useRef(null);
|
|
2769
2769
|
const lastSelectedIds = React.useRef([]);
|
|
2770
2770
|
const [staleGrid, setStaleGrid] = React.useState(false);
|
|
@@ -2778,7 +2778,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2778
2778
|
const hasSetContentSize = React.useRef(false);
|
|
2779
2779
|
const hasSetContentSizeEmpty = React.useRef(false);
|
|
2780
2780
|
const needsAutoSize = React.useRef(true);
|
|
2781
|
-
const requiresInitialSizeToFitRef = React.useRef(
|
|
2781
|
+
const requiresInitialSizeToFitRef = React.useRef(false);
|
|
2782
2782
|
const autoSizeResultRef = React.useRef(null);
|
|
2783
2783
|
const prevRowsVisibleRef = React.useRef(false);
|
|
2784
2784
|
const setInitialContentSize = React.useCallback(() => {
|
|
@@ -2838,15 +2838,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2838
2838
|
// It should be impossible to get here
|
|
2839
2839
|
console.error('Unknown value returned from hasGridRendered');
|
|
2840
2840
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
lodashEs.delay(() => {
|
|
2845
|
-
if (requiresInitialSizeToFitRef.current) {
|
|
2846
|
-
requiresInitialSizeToFitRef.current = false;
|
|
2847
|
-
sizeColumnsToFit();
|
|
2848
|
-
}
|
|
2849
|
-
}, 50);
|
|
2841
|
+
}
|
|
2842
|
+
else {
|
|
2843
|
+
sizeColumnsToFit();
|
|
2850
2844
|
}
|
|
2851
2845
|
setAutoSized(true);
|
|
2852
2846
|
needsAutoSize.current = false;
|
|
@@ -2999,7 +2993,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2999
2993
|
* This will resize columns when we have at least one row.
|
|
3000
2994
|
*/
|
|
3001
2995
|
const previousRowDataLength = React.useRef(0);
|
|
3002
|
-
const
|
|
2996
|
+
const onRowDataUpdated = React.useCallback(() => {
|
|
3003
2997
|
const length = rowData?.length ?? 0;
|
|
3004
2998
|
if (previousRowDataLength.current !== length) {
|
|
3005
2999
|
// We need to autosize all cells again
|
|
@@ -3011,10 +3005,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3011
3005
|
return;
|
|
3012
3006
|
lastUpdatedDep.current = updatedDep;
|
|
3013
3007
|
// Don't update while there are spinners
|
|
3014
|
-
if (
|
|
3008
|
+
if (anyUpdating()) {
|
|
3015
3009
|
return;
|
|
3010
|
+
}
|
|
3016
3011
|
const skipHeader = sizeColumns === 'auto-skip-headers';
|
|
3017
|
-
if (hasSetContentSize.current) {
|
|
3012
|
+
if ((sizeColumns === 'auto' || sizeColumns === 'auto-skip-headers') && hasSetContentSize.current) {
|
|
3018
3013
|
autoSizeColumns({
|
|
3019
3014
|
skipHeader,
|
|
3020
3015
|
userSizedColIds: new Set(userSizedColIds.current.keys()),
|
|
@@ -3022,7 +3017,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3022
3017
|
});
|
|
3023
3018
|
}
|
|
3024
3019
|
colIdsEdited.current.clear();
|
|
3025
|
-
}, [autoSizeColumns, rowData?.length, setInitialContentSize, sizeColumns, updatedDep,
|
|
3020
|
+
}, [autoSizeColumns, rowData?.length, setInitialContentSize, sizeColumns, updatedDep, anyUpdating]);
|
|
3026
3021
|
/**
|
|
3027
3022
|
* Show/hide no rows overlay when model changes.
|
|
3028
3023
|
*/
|
|
@@ -3047,6 +3042,20 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3047
3042
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3048
3043
|
}
|
|
3049
3044
|
}, [singleClickEdit, startCellEditing]);
|
|
3045
|
+
const onCellEditingStopped = React.useCallback((event) => {
|
|
3046
|
+
const api = event.api;
|
|
3047
|
+
// We need to redraw on fit as the updated row heights aren't visible
|
|
3048
|
+
if (sizeColumns === 'fit') {
|
|
3049
|
+
lodashEs.delay(() => {
|
|
3050
|
+
// Don't update if currently editing, that will stop the edit
|
|
3051
|
+
if (!anyUpdating() && document.querySelectorAll('.szh-menu--state-open').length === 0) {
|
|
3052
|
+
if (!api.isDestroyed()) {
|
|
3053
|
+
api.redrawRows();
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
}, 500);
|
|
3057
|
+
}
|
|
3058
|
+
}, [anyUpdating, sizeColumns]);
|
|
3050
3059
|
/**
|
|
3051
3060
|
* If cell has an edit action invoke it (if editable)
|
|
3052
3061
|
*/
|
|
@@ -3147,6 +3156,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3147
3156
|
* Resize columns to fit if required on window/container resize
|
|
3148
3157
|
*/
|
|
3149
3158
|
const onGridResize = React.useCallback((event) => {
|
|
3159
|
+
if (sizeColumns === 'fit' || (!hasSetContentSizeEmpty.current && !hasSetContentSize.current)) {
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3150
3162
|
if (sizeColumns !== 'none') {
|
|
3151
3163
|
// Flex columns can expand to fit after resize, but they cannot shrink less than use resized value
|
|
3152
3164
|
// Double click column resize handle to reset this behaviour
|
|
@@ -3157,7 +3169,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3157
3169
|
maxWidth: w,
|
|
3158
3170
|
})),
|
|
3159
3171
|
];
|
|
3160
|
-
requiresInitialSizeToFitRef.current = false;
|
|
3161
3172
|
lodashEs.defer(() => event.api.sizeColumnsToFit({ columnLimits }));
|
|
3162
3173
|
}
|
|
3163
3174
|
}, [sizeColumns]);
|
|
@@ -3331,9 +3342,17 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3331
3342
|
? {
|
|
3332
3343
|
enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
|
|
3333
3344
|
enableClickSelection: params.enableClickSelection ?? false,
|
|
3334
|
-
mode: rowSelection
|
|
3345
|
+
mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
|
|
3346
|
+
}
|
|
3347
|
+
: undefined, onDisplayedColumnsChanged: () => {
|
|
3348
|
+
// This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
|
|
3349
|
+
if (requiresInitialSizeToFitRef.current) {
|
|
3350
|
+
requiresInitialSizeToFitRef.current = false;
|
|
3351
|
+
lodashEs.delay(() => {
|
|
3352
|
+
sizeColumnsToFit();
|
|
3353
|
+
}, 200);
|
|
3335
3354
|
}
|
|
3336
|
-
|
|
3355
|
+
}, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridResize, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataUpdated, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData, onRowClicked: params.onRowClicked, onRowDoubleClicked: params.onRowDoubleClicked, suppressStartEditOnTab: true }) })] }));
|
|
3337
3356
|
};
|
|
3338
3357
|
const quickFilterParser = (filterStr) => {
|
|
3339
3358
|
// filter is exact matches exactly groups separated by commas
|