@linzjs/step-ag-grid 29.11.1 → 29.11.2

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.
@@ -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
  }
@@ -2844,6 +2841,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2844
2841
  }
2845
2842
  }
2846
2843
  else {
2844
+ console.log('sizeColumnsToFit 3');
2847
2845
  sizeColumnsToFit();
2848
2846
  }
2849
2847
  setAutoSized(true);
@@ -3129,8 +3127,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3129
3127
  * When cell editing has completed the colId as needing auto-sizing
3130
3128
  */
3131
3129
  useEffect(() => {
3132
- if (lastUpdatedDep.current === updatedDep)
3130
+ if (lastUpdatedDep.current === updatedDep) {
3133
3131
  return;
3132
+ }
3134
3133
  lastUpdatedDep.current = updatedDep;
3135
3134
  const colIds = updatingCols();
3136
3135
  // Updating possibly completed
@@ -3169,26 +3168,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3169
3168
  }
3170
3169
  prevLoading.current = newLoading;
3171
3170
  }, [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
3171
  /**
3193
3172
  * Set of column I'd's that are prevented from auto-sizing as they are user set
3194
3173
  */
@@ -3208,17 +3187,17 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3208
3187
  switch (e.source) {
3209
3188
  case 'uiColumnResized':
3210
3189
  userSizedColIds.current.set(colId, width);
3211
- const colDef = e.column?.getColDef();
3212
- if (!colDef?.flex) {
3190
+ /*const colDef = e.column?.getColDef();
3191
+ if (!colDef?.flex) {
3213
3192
  onGridResize(e);
3214
- }
3193
+ }*/
3215
3194
  break;
3216
3195
  case 'autosizeColumns':
3217
3196
  userSizedColIds.current.delete(colId);
3218
- onGridResize(e);
3197
+ //onGridResize(e);
3219
3198
  break;
3220
3199
  }
3221
- }, [onGridResize]);
3200
+ }, []);
3222
3201
  const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
3223
3202
  const startDragYRef = useRef(null);
3224
3203
  const clearHighlightRowClasses = useCallback(() => {
@@ -3361,15 +3340,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3361
3340
  enableClickSelection: params.enableClickSelection ?? false,
3362
3341
  mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
3363
3342
  }
3364
- : undefined, onDisplayedColumnsChanged: () => {
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 }) })] }));
3343
+ : undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, 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 }) })] }));
3373
3344
  };
3374
3345
  const quickFilterParser = (filterStr) => {
3375
3346
  // filter is exact matches exactly groups separated by commas
@@ -5345,6 +5316,7 @@ const waitForCondition = async (error, condition, timeoutMs) => {
5345
5316
 
5346
5317
  const colStateId = (colState) => colState.colId;
5347
5318
  const colStateFlexed = (colState) => !!colState.flex;
5319
+ const colStateNotFlexed = (colState) => !colState.flex;
5348
5320
  /**
5349
5321
  * Context for AgGrid operations.
5350
5322
  * Make sure you wrap AgGrid in this.
@@ -5637,22 +5609,34 @@ const GridContextProvider = (props) => {
5637
5609
  return null;
5638
5610
  }
5639
5611
  const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
5640
- const colStates = gridApi.getColumnState();
5641
- const relevantCols = colStates?.filter((colState) => {
5642
- const colId = colState.colId;
5643
- return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
5644
- });
5645
- const [flexColumns, nonFlexColumns] = partition(relevantCols, colStateFlexed);
5612
+ const getVisibleColStates = () => {
5613
+ const colStates = gridApi.getColumnState();
5614
+ return colStates.filter((colState) => {
5615
+ const colId = colState.colId;
5616
+ return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
5617
+ });
5618
+ };
5619
+ const getFlexColStates = () => getVisibleColStates().filter(colStateFlexed);
5620
+ const getNonFlexColStates = () => getVisibleColStates().filter(colStateNotFlexed);
5646
5621
  // If we don't reset the flex columns auto size it causes issues with random resizing of flex columns
5622
+ let flexColumns = getFlexColStates();
5623
+ let width = 0;
5647
5624
  if (!isEmpty(flexColumns)) {
5648
5625
  gridApi.autoSizeColumns(flexColumns.map(colStateId), skipHeader);
5626
+ const flexColumnIds = flexColumns.map(colStateId);
5627
+ flexColumns = getVisibleColStates().filter((colState) => flexColumnIds.includes(colState.colId));
5628
+ width += sumBy(flexColumns.filter((col) => !col.hide), 'width');
5649
5629
  gridApi.resetColumnState();
5650
5630
  }
5631
+ let nonFlexColumns = getNonFlexColStates();
5651
5632
  if (!isEmpty(nonFlexColumns)) {
5652
5633
  gridApi.autoSizeColumns(nonFlexColumns.map(colStateId), skipHeader);
5634
+ const nonFlexColumnIds = nonFlexColumns.map(colStateId);
5635
+ nonFlexColumns = getVisibleColStates().filter((colState) => nonFlexColumnIds.includes(colState.colId));
5636
+ width += sumBy(nonFlexColumns.filter((col) => !col.hide), 'width');
5653
5637
  }
5654
5638
  return {
5655
- width: sumBy(gridApi.getColumnState().filter((col) => !col.hide), 'width'),
5639
+ width,
5656
5640
  };
5657
5641
  }, [gridApi]);
5658
5642
  /**
@@ -6137,5 +6121,5 @@ const useDeferredPromise = () => {
6137
6121
  };
6138
6122
  };
6139
6123
 
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 };
6124
+ 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
6125
  //# sourceMappingURL=step-ag-grid.esm.js.map