@linzjs/step-ag-grid 29.3.2 → 29.3.4
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 +41 -11
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +42 -12
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +52 -13
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2763,8 +2763,14 @@ agGridCommunity.ModuleRegistry.registerModules([agGridCommunity.AllCommunityModu
|
|
|
2763
2763
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
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
|
-
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing, } = useGridContext();
|
|
2767
|
-
|
|
2766
|
+
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing: propStartCellEditing, } = useGridContext();
|
|
2767
|
+
// CellEditingStop event happens too much for one edit
|
|
2768
|
+
const startedEditRef = React.useRef(false);
|
|
2769
|
+
const startCellEditing = React.useCallback((props) => {
|
|
2770
|
+
startedEditRef.current = true;
|
|
2771
|
+
return propStartCellEditing(props);
|
|
2772
|
+
}, [propStartCellEditing]);
|
|
2773
|
+
const { updatedDep, anyUpdating, updatingCols } = React.useContext(GridUpdatingContext);
|
|
2768
2774
|
const gridDivRef = React.useRef(null);
|
|
2769
2775
|
const lastSelectedIds = React.useRef([]);
|
|
2770
2776
|
const [staleGrid, setStaleGrid] = React.useState(false);
|
|
@@ -2778,7 +2784,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2778
2784
|
const hasSetContentSize = React.useRef(false);
|
|
2779
2785
|
const hasSetContentSizeEmpty = React.useRef(false);
|
|
2780
2786
|
const needsAutoSize = React.useRef(true);
|
|
2781
|
-
const requiresInitialSizeToFitRef = React.useRef(
|
|
2787
|
+
const requiresInitialSizeToFitRef = React.useRef(false);
|
|
2782
2788
|
const autoSizeResultRef = React.useRef(null);
|
|
2783
2789
|
const prevRowsVisibleRef = React.useRef(false);
|
|
2784
2790
|
const setInitialContentSize = React.useCallback(() => {
|
|
@@ -2839,9 +2845,12 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2839
2845
|
console.error('Unknown value returned from hasGridRendered');
|
|
2840
2846
|
}
|
|
2841
2847
|
}
|
|
2848
|
+
else {
|
|
2849
|
+
sizeColumnsToFit();
|
|
2850
|
+
}
|
|
2842
2851
|
setAutoSized(true);
|
|
2843
2852
|
needsAutoSize.current = false;
|
|
2844
|
-
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns]);
|
|
2853
|
+
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
2845
2854
|
const lastOwnerDocumentRef = React.useRef();
|
|
2846
2855
|
const wasVisibleRef = React.useRef(false);
|
|
2847
2856
|
/**
|
|
@@ -2990,7 +2999,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2990
2999
|
* This will resize columns when we have at least one row.
|
|
2991
3000
|
*/
|
|
2992
3001
|
const previousRowDataLength = React.useRef(0);
|
|
2993
|
-
const
|
|
3002
|
+
const onRowDataUpdated = React.useCallback(() => {
|
|
2994
3003
|
const length = rowData?.length ?? 0;
|
|
2995
3004
|
if (previousRowDataLength.current !== length) {
|
|
2996
3005
|
// We need to autosize all cells again
|
|
@@ -3002,10 +3011,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3002
3011
|
return;
|
|
3003
3012
|
lastUpdatedDep.current = updatedDep;
|
|
3004
3013
|
// Don't update while there are spinners
|
|
3005
|
-
if (
|
|
3014
|
+
if (anyUpdating()) {
|
|
3006
3015
|
return;
|
|
3016
|
+
}
|
|
3007
3017
|
const skipHeader = sizeColumns === 'auto-skip-headers';
|
|
3008
|
-
if (hasSetContentSize.current) {
|
|
3018
|
+
if ((sizeColumns === 'auto' || sizeColumns === 'auto-skip-headers') && hasSetContentSize.current) {
|
|
3009
3019
|
autoSizeColumns({
|
|
3010
3020
|
skipHeader,
|
|
3011
3021
|
userSizedColIds: new Set(userSizedColIds.current.keys()),
|
|
@@ -3013,7 +3023,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3013
3023
|
});
|
|
3014
3024
|
}
|
|
3015
3025
|
colIdsEdited.current.clear();
|
|
3016
|
-
}, [autoSizeColumns, rowData?.length, setInitialContentSize, sizeColumns, updatedDep,
|
|
3026
|
+
}, [autoSizeColumns, rowData?.length, setInitialContentSize, sizeColumns, updatedDep, anyUpdating]);
|
|
3017
3027
|
/**
|
|
3018
3028
|
* Show/hide no rows overlay when model changes.
|
|
3019
3029
|
*/
|
|
@@ -3038,6 +3048,24 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3038
3048
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3039
3049
|
}
|
|
3040
3050
|
}, [singleClickEdit, startCellEditing]);
|
|
3051
|
+
const onCellEditingStopped = React.useCallback((event) => {
|
|
3052
|
+
if (!startedEditRef.current) {
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
startedEditRef.current = false;
|
|
3056
|
+
const api = event.api;
|
|
3057
|
+
// We need to redraw on fit as the updated row heights aren't visible
|
|
3058
|
+
if (sizeColumns === 'fit') {
|
|
3059
|
+
lodashEs.delay(() => {
|
|
3060
|
+
// Don't update if currently editing, that will stop the edit
|
|
3061
|
+
if (!anyUpdating() && document.querySelectorAll('.szh-menu--state-open').length === 0) {
|
|
3062
|
+
if (!api.isDestroyed()) {
|
|
3063
|
+
api.redrawRows();
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
}, 500);
|
|
3067
|
+
}
|
|
3068
|
+
}, [anyUpdating, sizeColumns]);
|
|
3041
3069
|
/**
|
|
3042
3070
|
* If cell has an edit action invoke it (if editable)
|
|
3043
3071
|
*/
|
|
@@ -3138,7 +3166,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3138
3166
|
* Resize columns to fit if required on window/container resize
|
|
3139
3167
|
*/
|
|
3140
3168
|
const onGridResize = React.useCallback((event) => {
|
|
3141
|
-
if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
|
|
3169
|
+
if (sizeColumns === 'fit' || (!hasSetContentSizeEmpty.current && !hasSetContentSize.current)) {
|
|
3142
3170
|
return;
|
|
3143
3171
|
}
|
|
3144
3172
|
if (sizeColumns !== 'none') {
|
|
@@ -3330,9 +3358,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3330
3358
|
// This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
|
|
3331
3359
|
if (requiresInitialSizeToFitRef.current) {
|
|
3332
3360
|
requiresInitialSizeToFitRef.current = false;
|
|
3333
|
-
|
|
3361
|
+
lodashEs.delay(() => {
|
|
3362
|
+
sizeColumnsToFit();
|
|
3363
|
+
}, 200);
|
|
3334
3364
|
}
|
|
3335
|
-
}, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridResize, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated:
|
|
3365
|
+
}, 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 }) })] }));
|
|
3336
3366
|
};
|
|
3337
3367
|
const quickFilterParser = (filterStr) => {
|
|
3338
3368
|
// filter is exact matches exactly groups separated by commas
|