@linzjs/step-ag-grid 29.2.0 → 29.2.1
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 +2 -1
- package/dist/step-ag-grid.cjs +34 -14
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +34 -14
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Grid.tsx +42 -13
- package/src/contexts/GridContextProvider.tsx +3 -1
- package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingAgGrid.stories.tsx +28 -0
- package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +169 -0
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2760,7 +2760,7 @@ ModuleRegistry.registerModules([AllCommunityModule]);
|
|
|
2760
2760
|
/**
|
|
2761
2761
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2762
2762
|
*/
|
|
2763
|
-
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, ...params }) => {
|
|
2763
|
+
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, allowResizeInStorybook, onCellFocused: paramsOnCellFocused, ...params }) => {
|
|
2764
2764
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing, } = useGridContext();
|
|
2765
2765
|
const { updatedDep, updatingCols } = useContext(GridUpdatingContext);
|
|
2766
2766
|
const gridDivRef = useRef(null);
|
|
@@ -2791,7 +2791,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2791
2791
|
}
|
|
2792
2792
|
const skipHeader = sizeColumns === 'auto-skip-headers' && gridRendered === 'rows-visible';
|
|
2793
2793
|
if (sizeColumns === 'auto' || skipHeader) {
|
|
2794
|
-
const result = autoSizeColumns({
|
|
2794
|
+
const result = autoSizeColumns({
|
|
2795
|
+
skipHeader,
|
|
2796
|
+
userSizedColIds: new Set(userSizedColIds.current.keys()),
|
|
2797
|
+
includeFlex: true,
|
|
2798
|
+
});
|
|
2795
2799
|
if (!result) {
|
|
2796
2800
|
needsAutoSize.current = true;
|
|
2797
2801
|
return;
|
|
@@ -2987,7 +2991,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2987
2991
|
return;
|
|
2988
2992
|
const skipHeader = sizeColumns === 'auto-skip-headers';
|
|
2989
2993
|
if (hasSetContentSize.current) {
|
|
2990
|
-
autoSizeColumns({
|
|
2994
|
+
autoSizeColumns({
|
|
2995
|
+
skipHeader,
|
|
2996
|
+
userSizedColIds: new Set(userSizedColIds.current.keys()),
|
|
2997
|
+
colIds: colIdsEdited.current,
|
|
2998
|
+
});
|
|
2991
2999
|
}
|
|
2992
3000
|
colIdsEdited.current.clear();
|
|
2993
3001
|
}, [autoSizeColumns, rowData?.length, setInitialContentSize, sizeColumns, updatedDep, updatingCols]);
|
|
@@ -3085,7 +3093,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3085
3093
|
if (hasSetContentSize.current) {
|
|
3086
3094
|
autoSizeColumns({
|
|
3087
3095
|
skipHeader,
|
|
3088
|
-
userSizedColIds: userSizedColIds.current,
|
|
3096
|
+
userSizedColIds: new Set(userSizedColIds.current.keys()),
|
|
3089
3097
|
colIds: colIdsEdited.current,
|
|
3090
3098
|
});
|
|
3091
3099
|
}
|
|
@@ -3114,25 +3122,36 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3114
3122
|
/**
|
|
3115
3123
|
* Resize columns to fit if required on window/container resize
|
|
3116
3124
|
*/
|
|
3117
|
-
const onGridSizeChanged = useCallback(() => {
|
|
3118
|
-
if (sizeColumns !== 'none') {
|
|
3119
|
-
|
|
3125
|
+
const onGridSizeChanged = useCallback((event) => {
|
|
3126
|
+
if (sizeColumns !== 'none' && (!window.__STORYBOOK_PREVIEW__ || allowResizeInStorybook)) {
|
|
3127
|
+
const columnLimits = [
|
|
3128
|
+
...userSizedColIds.current.entries().map(([c, w]) => ({
|
|
3129
|
+
key: c,
|
|
3130
|
+
minWidth: w,
|
|
3131
|
+
})),
|
|
3132
|
+
];
|
|
3133
|
+
event.api.sizeColumnsToFit({ columnLimits });
|
|
3120
3134
|
}
|
|
3121
|
-
}, [
|
|
3135
|
+
}, [allowResizeInStorybook, sizeColumns]);
|
|
3122
3136
|
/**
|
|
3123
3137
|
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
3124
3138
|
*/
|
|
3125
|
-
const userSizedColIds = useRef(new
|
|
3139
|
+
const userSizedColIds = useRef(new Map());
|
|
3126
3140
|
/**
|
|
3127
3141
|
* Lock/unlock column width on user edit/reset.
|
|
3128
3142
|
*/
|
|
3129
3143
|
const onColumnResized = useCallback((e) => {
|
|
3130
3144
|
const colId = e.column?.getColId();
|
|
3131
|
-
if (colId == null)
|
|
3145
|
+
if (colId == null) {
|
|
3132
3146
|
return;
|
|
3147
|
+
}
|
|
3148
|
+
const width = e.column?.getActualWidth();
|
|
3149
|
+
if (width == null) {
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3133
3152
|
switch (e.source) {
|
|
3134
|
-
case '
|
|
3135
|
-
userSizedColIds.current.
|
|
3153
|
+
case 'uiColumnResized':
|
|
3154
|
+
userSizedColIds.current.set(colId, width);
|
|
3136
3155
|
break;
|
|
3137
3156
|
case 'autosizeColumns':
|
|
3138
3157
|
userSizedColIds.current.delete(colId);
|
|
@@ -3190,7 +3209,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3190
3209
|
// Prevent repeated callbacks to cell focus when focus didn't change
|
|
3191
3210
|
const { sourceEvent } = event;
|
|
3192
3211
|
if (sourceEvent) {
|
|
3193
|
-
const cell = sourceEvent.target
|
|
3212
|
+
const cell = sourceEvent.target?.closest?.('.ag-cell') ?? null;
|
|
3194
3213
|
if (window.__stepaggrid_lastfocuseventtarget === cell) {
|
|
3195
3214
|
return;
|
|
3196
3215
|
}
|
|
@@ -5415,8 +5434,9 @@ const GridContextProvider = (props) => {
|
|
|
5415
5434
|
* Resize columns to fit container
|
|
5416
5435
|
*/
|
|
5417
5436
|
const autoSizeColumns = useCallback(({ skipHeader, colIds, userSizedColIds, includeFlex } = {}) => {
|
|
5418
|
-
if (!gridApi || !gridApi.getColumnState())
|
|
5437
|
+
if (!gridApi || !gridApi.getColumnState()) {
|
|
5419
5438
|
return null;
|
|
5439
|
+
}
|
|
5420
5440
|
const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
|
|
5421
5441
|
const colsToResize = gridApi.getColumnState()?.filter?.((colState) => {
|
|
5422
5442
|
const colId = colState.colId;
|