@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/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2783,7 +2783,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2783
2783
|
const hasSetContentSize = useRef(false);
|
|
2784
2784
|
const hasSetContentSizeEmpty = useRef(false);
|
|
2785
2785
|
const needsAutoSize = useRef(true);
|
|
2786
|
-
const requiresInitialSizeToFitRef = useRef(false);
|
|
2787
2786
|
const autoSizeResultRef = useRef(null);
|
|
2788
2787
|
const prevRowsVisibleRef = useRef(false);
|
|
2789
2788
|
const setInitialContentSize = useCallback(() => {
|
|
@@ -2826,7 +2825,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2826
2825
|
// We don't do this callback if we have previously had row data, or have already called back for empty
|
|
2827
2826
|
if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
|
|
2828
2827
|
hasSetContentSizeEmpty.current = true;
|
|
2829
|
-
requiresInitialSizeToFitRef.current = true;
|
|
2830
2828
|
params.onContentSize?.(autoSizeResult);
|
|
2831
2829
|
}
|
|
2832
2830
|
}
|
|
@@ -2834,7 +2832,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2834
2832
|
// we have rows now so callback grid size
|
|
2835
2833
|
if (!hasSetContentSize.current) {
|
|
2836
2834
|
hasSetContentSize.current = true;
|
|
2837
|
-
requiresInitialSizeToFitRef.current = true;
|
|
2838
2835
|
params.onContentSize?.(autoSizeResult);
|
|
2839
2836
|
}
|
|
2840
2837
|
}
|
|
@@ -3129,8 +3126,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3129
3126
|
* When cell editing has completed the colId as needing auto-sizing
|
|
3130
3127
|
*/
|
|
3131
3128
|
useEffect(() => {
|
|
3132
|
-
if (lastUpdatedDep.current === updatedDep)
|
|
3129
|
+
if (lastUpdatedDep.current === updatedDep) {
|
|
3133
3130
|
return;
|
|
3131
|
+
}
|
|
3134
3132
|
lastUpdatedDep.current = updatedDep;
|
|
3135
3133
|
const colIds = updatingCols();
|
|
3136
3134
|
// Updating possibly completed
|
|
@@ -3169,26 +3167,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3169
3167
|
}
|
|
3170
3168
|
prevLoading.current = newLoading;
|
|
3171
3169
|
}, [params.loading, rowData, showNoRowsOverlay]);
|
|
3172
|
-
/**
|
|
3173
|
-
* Resize columns to fit if required on window/container resize
|
|
3174
|
-
*/
|
|
3175
|
-
const onGridResize = useCallback((event) => {
|
|
3176
|
-
if (sizeColumns === 'fit' || (!hasSetContentSizeEmpty.current && !hasSetContentSize.current)) {
|
|
3177
|
-
return;
|
|
3178
|
-
}
|
|
3179
|
-
if (sizeColumns !== 'none') {
|
|
3180
|
-
// Flex columns can expand to fit after resize, but they cannot shrink less than use resized value
|
|
3181
|
-
// Double click column resize handle to reset this behaviour
|
|
3182
|
-
const columnLimits = [
|
|
3183
|
-
...userSizedColIds.current.entries().map(([c, w]) => ({
|
|
3184
|
-
key: c,
|
|
3185
|
-
minWidth: w,
|
|
3186
|
-
maxWidth: w,
|
|
3187
|
-
})),
|
|
3188
|
-
];
|
|
3189
|
-
defer(() => event.api.sizeColumnsToFit({ columnLimits }));
|
|
3190
|
-
}
|
|
3191
|
-
}, [sizeColumns]);
|
|
3192
3170
|
/**
|
|
3193
3171
|
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
3194
3172
|
*/
|
|
@@ -3208,17 +3186,17 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3208
3186
|
switch (e.source) {
|
|
3209
3187
|
case 'uiColumnResized':
|
|
3210
3188
|
userSizedColIds.current.set(colId, width);
|
|
3211
|
-
const colDef = e.column?.getColDef();
|
|
3212
|
-
|
|
3189
|
+
/*const colDef = e.column?.getColDef();
|
|
3190
|
+
if (!colDef?.flex) {
|
|
3213
3191
|
onGridResize(e);
|
|
3214
|
-
|
|
3192
|
+
}*/
|
|
3215
3193
|
break;
|
|
3216
3194
|
case 'autosizeColumns':
|
|
3217
3195
|
userSizedColIds.current.delete(colId);
|
|
3218
|
-
onGridResize(e);
|
|
3196
|
+
//onGridResize(e);
|
|
3219
3197
|
break;
|
|
3220
3198
|
}
|
|
3221
|
-
}, [
|
|
3199
|
+
}, []);
|
|
3222
3200
|
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
3223
3201
|
const startDragYRef = useRef(null);
|
|
3224
3202
|
const clearHighlightRowClasses = useCallback(() => {
|
|
@@ -3355,21 +3333,18 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3355
3333
|
selectColumnPinned,
|
|
3356
3334
|
selectable,
|
|
3357
3335
|
]);
|
|
3336
|
+
const onGridSizeChanged = useCallback((event) => {
|
|
3337
|
+
if (sizeColumns === 'fit') {
|
|
3338
|
+
event.api.sizeColumnsToFit();
|
|
3339
|
+
}
|
|
3340
|
+
}, [sizeColumns]);
|
|
3358
3341
|
return (jsxs("div", { "data-testid": dataTestId, className: clsx('Grid-container', theme, 'theme-specific', staleGrid && 'Grid-sortIsStale', gridReady && rowData && autoSized && 'Grid-ready'), children: [gridContextMenu.component, jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsx(AgGridReact, { theme: 'legacy', rowSelection: selectable
|
|
3359
3342
|
? {
|
|
3360
3343
|
enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
|
|
3361
3344
|
enableClickSelection: params.enableClickSelection ?? false,
|
|
3362
3345
|
mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
|
|
3363
3346
|
}
|
|
3364
|
-
: undefined,
|
|
3365
|
-
// This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
|
|
3366
|
-
if (requiresInitialSizeToFitRef.current) {
|
|
3367
|
-
requiresInitialSizeToFitRef.current = false;
|
|
3368
|
-
delay(() => {
|
|
3369
|
-
sizeColumnsToFit();
|
|
3370
|
-
}, 200);
|
|
3371
|
-
}
|
|
3372
|
-
}, 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 }) })] }));
|
|
3347
|
+
: 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 }) })] }));
|
|
3373
3348
|
};
|
|
3374
3349
|
const quickFilterParser = (filterStr) => {
|
|
3375
3350
|
// filter is exact matches exactly groups separated by commas
|
|
@@ -5345,6 +5320,7 @@ const waitForCondition = async (error, condition, timeoutMs) => {
|
|
|
5345
5320
|
|
|
5346
5321
|
const colStateId = (colState) => colState.colId;
|
|
5347
5322
|
const colStateFlexed = (colState) => !!colState.flex;
|
|
5323
|
+
const colStateNotFlexed = (colState) => !colState.flex;
|
|
5348
5324
|
/**
|
|
5349
5325
|
* Context for AgGrid operations.
|
|
5350
5326
|
* Make sure you wrap AgGrid in this.
|
|
@@ -5637,22 +5613,34 @@ const GridContextProvider = (props) => {
|
|
|
5637
5613
|
return null;
|
|
5638
5614
|
}
|
|
5639
5615
|
const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
|
|
5640
|
-
const
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5616
|
+
const getVisibleColStates = () => {
|
|
5617
|
+
const colStates = gridApi.getColumnState();
|
|
5618
|
+
return colStates.filter((colState) => {
|
|
5619
|
+
const colId = colState.colId;
|
|
5620
|
+
return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
|
|
5621
|
+
});
|
|
5622
|
+
};
|
|
5623
|
+
const getFlexColStates = () => getVisibleColStates().filter(colStateFlexed);
|
|
5624
|
+
const getNonFlexColStates = () => getVisibleColStates().filter(colStateNotFlexed);
|
|
5646
5625
|
// If we don't reset the flex columns auto size it causes issues with random resizing of flex columns
|
|
5626
|
+
let flexColumns = getFlexColStates();
|
|
5627
|
+
let width = 0;
|
|
5647
5628
|
if (!isEmpty(flexColumns)) {
|
|
5648
5629
|
gridApi.autoSizeColumns(flexColumns.map(colStateId), skipHeader);
|
|
5630
|
+
const flexColumnIds = flexColumns.map(colStateId);
|
|
5631
|
+
flexColumns = getVisibleColStates().filter((colState) => flexColumnIds.includes(colState.colId));
|
|
5632
|
+
width += sumBy(flexColumns.filter((col) => !col.hide), 'width');
|
|
5649
5633
|
gridApi.resetColumnState();
|
|
5650
5634
|
}
|
|
5635
|
+
let nonFlexColumns = getNonFlexColStates();
|
|
5651
5636
|
if (!isEmpty(nonFlexColumns)) {
|
|
5652
5637
|
gridApi.autoSizeColumns(nonFlexColumns.map(colStateId), skipHeader);
|
|
5638
|
+
const nonFlexColumnIds = nonFlexColumns.map(colStateId);
|
|
5639
|
+
nonFlexColumns = getVisibleColStates().filter((colState) => nonFlexColumnIds.includes(colState.colId));
|
|
5640
|
+
width += sumBy(nonFlexColumns.filter((col) => !col.hide), 'width');
|
|
5653
5641
|
}
|
|
5654
5642
|
return {
|
|
5655
|
-
width
|
|
5643
|
+
width,
|
|
5656
5644
|
};
|
|
5657
5645
|
}, [gridApi]);
|
|
5658
5646
|
/**
|
|
@@ -6137,5 +6125,5 @@ const useDeferredPromise = () => {
|
|
|
6137
6125
|
};
|
|
6138
6126
|
};
|
|
6139
6127
|
|
|
6140
|
-
export { ActionButton, CancelPromise, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
6128
|
+
export { ActionButton, CancelPromise, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridButton, GridCell, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridEditBoolean, GridFilterButtons, GridFilterColumnsMultiSelect, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridNoRowsOverlayFr, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, TextInputValidator, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, colStateFlexed, colStateId, colStateNotFlexed, convertDDToDMS, createCheckboxMultiFilterParams, defaultValueFormatter, downloadCsvUseValueFormattersProcessCellCallback, findParentWithClass, fnOrVar, generateFilterGetter, hasParentClass, isFloat, isGridCellFiller, isNotEmpty, primitiveToSelectOption, sanitiseFileName, stringByteLengthIsInvalid, suppressCellKeyboardEvents, textMatch, useDeferredPromise, useGridContext, useGridContextMenu, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait, waitForCondition };
|
|
6141
6129
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|