@linzjs/step-ag-grid 29.11.1 → 29.11.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/README.md +1 -1
- package/dist/src/contexts/GridContextProvider.d.ts +4 -1
- package/dist/step-ag-grid.cjs +36 -45
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +34 -46
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +35 -67
- package/src/contexts/GridContextProvider.tsx +31 -26
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +5 -7
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ProcessCellForExportParams } from 'ag-grid-community';
|
|
1
|
+
import { ColumnState, ProcessCellForExportParams } from 'ag-grid-community';
|
|
2
2
|
import { PropsWithChildren, ReactElement } from 'react';
|
|
3
3
|
import { GridBaseRow } from '../components';
|
|
4
|
+
export declare const colStateId: (colState: ColumnState) => string;
|
|
5
|
+
export declare const colStateFlexed: (colState: ColumnState) => boolean;
|
|
6
|
+
export declare const colStateNotFlexed: (colState: ColumnState) => boolean;
|
|
4
7
|
/**
|
|
5
8
|
* Context for AgGrid operations.
|
|
6
9
|
* Make sure you wrap AgGrid in this.
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2785,7 +2785,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2785
2785
|
const hasSetContentSize = React.useRef(false);
|
|
2786
2786
|
const hasSetContentSizeEmpty = React.useRef(false);
|
|
2787
2787
|
const needsAutoSize = React.useRef(true);
|
|
2788
|
-
const requiresInitialSizeToFitRef = React.useRef(false);
|
|
2789
2788
|
const autoSizeResultRef = React.useRef(null);
|
|
2790
2789
|
const prevRowsVisibleRef = React.useRef(false);
|
|
2791
2790
|
const setInitialContentSize = React.useCallback(() => {
|
|
@@ -2828,7 +2827,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2828
2827
|
// We don't do this callback if we have previously had row data, or have already called back for empty
|
|
2829
2828
|
if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
|
|
2830
2829
|
hasSetContentSizeEmpty.current = true;
|
|
2831
|
-
requiresInitialSizeToFitRef.current = true;
|
|
2832
2830
|
params.onContentSize?.(autoSizeResult);
|
|
2833
2831
|
}
|
|
2834
2832
|
}
|
|
@@ -2836,7 +2834,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2836
2834
|
// we have rows now so callback grid size
|
|
2837
2835
|
if (!hasSetContentSize.current) {
|
|
2838
2836
|
hasSetContentSize.current = true;
|
|
2839
|
-
requiresInitialSizeToFitRef.current = true;
|
|
2840
2837
|
params.onContentSize?.(autoSizeResult);
|
|
2841
2838
|
}
|
|
2842
2839
|
}
|
|
@@ -3131,8 +3128,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3131
3128
|
* When cell editing has completed the colId as needing auto-sizing
|
|
3132
3129
|
*/
|
|
3133
3130
|
React.useEffect(() => {
|
|
3134
|
-
if (lastUpdatedDep.current === updatedDep)
|
|
3131
|
+
if (lastUpdatedDep.current === updatedDep) {
|
|
3135
3132
|
return;
|
|
3133
|
+
}
|
|
3136
3134
|
lastUpdatedDep.current = updatedDep;
|
|
3137
3135
|
const colIds = updatingCols();
|
|
3138
3136
|
// Updating possibly completed
|
|
@@ -3171,26 +3169,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3171
3169
|
}
|
|
3172
3170
|
prevLoading.current = newLoading;
|
|
3173
3171
|
}, [params.loading, rowData, showNoRowsOverlay]);
|
|
3174
|
-
/**
|
|
3175
|
-
* Resize columns to fit if required on window/container resize
|
|
3176
|
-
*/
|
|
3177
|
-
const onGridResize = React.useCallback((event) => {
|
|
3178
|
-
if (sizeColumns === 'fit' || (!hasSetContentSizeEmpty.current && !hasSetContentSize.current)) {
|
|
3179
|
-
return;
|
|
3180
|
-
}
|
|
3181
|
-
if (sizeColumns !== 'none') {
|
|
3182
|
-
// Flex columns can expand to fit after resize, but they cannot shrink less than use resized value
|
|
3183
|
-
// Double click column resize handle to reset this behaviour
|
|
3184
|
-
const columnLimits = [
|
|
3185
|
-
...userSizedColIds.current.entries().map(([c, w]) => ({
|
|
3186
|
-
key: c,
|
|
3187
|
-
minWidth: w,
|
|
3188
|
-
maxWidth: w,
|
|
3189
|
-
})),
|
|
3190
|
-
];
|
|
3191
|
-
lodashEs.defer(() => event.api.sizeColumnsToFit({ columnLimits }));
|
|
3192
|
-
}
|
|
3193
|
-
}, [sizeColumns]);
|
|
3194
3172
|
/**
|
|
3195
3173
|
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
3196
3174
|
*/
|
|
@@ -3210,17 +3188,17 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3210
3188
|
switch (e.source) {
|
|
3211
3189
|
case 'uiColumnResized':
|
|
3212
3190
|
userSizedColIds.current.set(colId, width);
|
|
3213
|
-
const colDef = e.column?.getColDef();
|
|
3214
|
-
|
|
3191
|
+
/*const colDef = e.column?.getColDef();
|
|
3192
|
+
if (!colDef?.flex) {
|
|
3215
3193
|
onGridResize(e);
|
|
3216
|
-
|
|
3194
|
+
}*/
|
|
3217
3195
|
break;
|
|
3218
3196
|
case 'autosizeColumns':
|
|
3219
3197
|
userSizedColIds.current.delete(colId);
|
|
3220
|
-
onGridResize(e);
|
|
3198
|
+
//onGridResize(e);
|
|
3221
3199
|
break;
|
|
3222
3200
|
}
|
|
3223
|
-
}, [
|
|
3201
|
+
}, []);
|
|
3224
3202
|
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
3225
3203
|
const startDragYRef = React.useRef(null);
|
|
3226
3204
|
const clearHighlightRowClasses = React.useCallback(() => {
|
|
@@ -3357,21 +3335,18 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3357
3335
|
selectColumnPinned,
|
|
3358
3336
|
selectable,
|
|
3359
3337
|
]);
|
|
3338
|
+
const onGridSizeChanged = React.useCallback((event) => {
|
|
3339
|
+
if (sizeColumns === 'fit') {
|
|
3340
|
+
event.api.sizeColumnsToFit();
|
|
3341
|
+
}
|
|
3342
|
+
}, [sizeColumns]);
|
|
3360
3343
|
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: clsx('Grid-container', theme, 'theme-specific', staleGrid && 'Grid-sortIsStale', gridReady && rowData && autoSized && 'Grid-ready'), children: [gridContextMenu.component, jsxRuntime.jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsxRuntime.jsx(agGridReact.AgGridReact, { theme: 'legacy', rowSelection: selectable
|
|
3361
3344
|
? {
|
|
3362
3345
|
enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
|
|
3363
3346
|
enableClickSelection: params.enableClickSelection ?? false,
|
|
3364
3347
|
mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
|
|
3365
3348
|
}
|
|
3366
|
-
: undefined,
|
|
3367
|
-
// This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
|
|
3368
|
-
if (requiresInitialSizeToFitRef.current) {
|
|
3369
|
-
requiresInitialSizeToFitRef.current = false;
|
|
3370
|
-
lodashEs.delay(() => {
|
|
3371
|
-
sizeColumnsToFit();
|
|
3372
|
-
}, 200);
|
|
3373
|
-
}
|
|
3374
|
-
}, 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 }) })] }));
|
|
3349
|
+
: undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onGridSizeChanged: onGridSizeChanged, 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 }) })] }));
|
|
3375
3350
|
};
|
|
3376
3351
|
const quickFilterParser = (filterStr) => {
|
|
3377
3352
|
// filter is exact matches exactly groups separated by commas
|
|
@@ -5347,6 +5322,7 @@ const waitForCondition = async (error, condition, timeoutMs) => {
|
|
|
5347
5322
|
|
|
5348
5323
|
const colStateId = (colState) => colState.colId;
|
|
5349
5324
|
const colStateFlexed = (colState) => !!colState.flex;
|
|
5325
|
+
const colStateNotFlexed = (colState) => !colState.flex;
|
|
5350
5326
|
/**
|
|
5351
5327
|
* Context for AgGrid operations.
|
|
5352
5328
|
* Make sure you wrap AgGrid in this.
|
|
@@ -5639,22 +5615,34 @@ const GridContextProvider = (props) => {
|
|
|
5639
5615
|
return null;
|
|
5640
5616
|
}
|
|
5641
5617
|
const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
|
|
5642
|
-
const
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5618
|
+
const getVisibleColStates = () => {
|
|
5619
|
+
const colStates = gridApi.getColumnState();
|
|
5620
|
+
return colStates.filter((colState) => {
|
|
5621
|
+
const colId = colState.colId;
|
|
5622
|
+
return (lodashEs.isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
|
|
5623
|
+
});
|
|
5624
|
+
};
|
|
5625
|
+
const getFlexColStates = () => getVisibleColStates().filter(colStateFlexed);
|
|
5626
|
+
const getNonFlexColStates = () => getVisibleColStates().filter(colStateNotFlexed);
|
|
5648
5627
|
// If we don't reset the flex columns auto size it causes issues with random resizing of flex columns
|
|
5628
|
+
let flexColumns = getFlexColStates();
|
|
5629
|
+
let width = 0;
|
|
5649
5630
|
if (!lodashEs.isEmpty(flexColumns)) {
|
|
5650
5631
|
gridApi.autoSizeColumns(flexColumns.map(colStateId), skipHeader);
|
|
5632
|
+
const flexColumnIds = flexColumns.map(colStateId);
|
|
5633
|
+
flexColumns = getVisibleColStates().filter((colState) => flexColumnIds.includes(colState.colId));
|
|
5634
|
+
width += lodashEs.sumBy(flexColumns.filter((col) => !col.hide), 'width');
|
|
5651
5635
|
gridApi.resetColumnState();
|
|
5652
5636
|
}
|
|
5637
|
+
let nonFlexColumns = getNonFlexColStates();
|
|
5653
5638
|
if (!lodashEs.isEmpty(nonFlexColumns)) {
|
|
5654
5639
|
gridApi.autoSizeColumns(nonFlexColumns.map(colStateId), skipHeader);
|
|
5640
|
+
const nonFlexColumnIds = nonFlexColumns.map(colStateId);
|
|
5641
|
+
nonFlexColumns = getVisibleColStates().filter((colState) => nonFlexColumnIds.includes(colState.colId));
|
|
5642
|
+
width += lodashEs.sumBy(nonFlexColumns.filter((col) => !col.hide), 'width');
|
|
5655
5643
|
}
|
|
5656
5644
|
return {
|
|
5657
|
-
width
|
|
5645
|
+
width,
|
|
5658
5646
|
};
|
|
5659
5647
|
}, [gridApi]);
|
|
5660
5648
|
/**
|
|
@@ -6219,6 +6207,9 @@ exports.bearingNumberParser = bearingNumberParser;
|
|
|
6219
6207
|
exports.bearingRangeValidator = bearingRangeValidator;
|
|
6220
6208
|
exports.bearingStringValidator = bearingStringValidator;
|
|
6221
6209
|
exports.bearingValueFormatter = bearingValueFormatter;
|
|
6210
|
+
exports.colStateFlexed = colStateFlexed;
|
|
6211
|
+
exports.colStateId = colStateId;
|
|
6212
|
+
exports.colStateNotFlexed = colStateNotFlexed;
|
|
6222
6213
|
exports.convertDDToDMS = convertDDToDMS;
|
|
6223
6214
|
exports.createCheckboxMultiFilterParams = createCheckboxMultiFilterParams;
|
|
6224
6215
|
exports.defaultValueFormatter = defaultValueFormatter;
|