@linzjs/step-ag-grid 29.2.2 → 29.2.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/README.md +0 -1
- package/dist/src/components/Grid.d.ts +5 -1
- package/dist/src/components/GridCell.d.ts +1 -0
- package/dist/src/contexts/GridContext.d.ts +2 -2
- package/dist/step-ag-grid.cjs +9 -5
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +10 -6
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Grid.tsx +14 -3
- package/src/components/GridCell.tsx +1 -0
- package/src/contexts/GridContext.tsx +2 -2
- package/src/contexts/GridContextProvider.tsx +9 -5
- package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +14 -3
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { LuiMiniSpinner, LuiStatusSpinner, LuiIcon, LuiButtonGroup, LuiButton, LuiCheckboxInput } from '@linzjs/lui';
|
|
3
3
|
import { ModuleRegistry, AllCommunityModule } from 'ag-grid-community';
|
|
4
4
|
import { AgGridReact } from 'ag-grid-react';
|
|
5
|
-
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, xorBy, last, difference, omit, sortBy, delay, partition, compact, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
|
|
5
|
+
import { negate, isEmpty, findIndex, defer, debounce as debounce$1, sum, xorBy, last, difference, omit, sortBy, delay, partition, compact, pick, groupBy, fromPairs, toPairs, isEqual, pull, filter, sumBy, remove, flatten, castArray } from 'lodash-es';
|
|
6
6
|
import React, { useRef, useLayoutEffect, useEffect, createContext, useContext, useState, useMemo, memo, forwardRef, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1, useId } from 'react';
|
|
7
7
|
import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
|
|
8
8
|
|
|
@@ -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, onCellFocused: paramsOnCellFocused, maxInitialWidth, ...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);
|
|
@@ -2800,6 +2800,10 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2800
2800
|
needsAutoSize.current = true;
|
|
2801
2801
|
return;
|
|
2802
2802
|
}
|
|
2803
|
+
// Default max intial width is 256x initial visible column count, max of 80% window width
|
|
2804
|
+
const maxWidth = maxInitialWidth ||
|
|
2805
|
+
sum(params.columnDefs.map((c) => (!c.hide ? c.maxInitialWidth || 128 : 0)));
|
|
2806
|
+
result.width = Math.min(result.width, maxWidth);
|
|
2803
2807
|
if (gridRendered === 'empty') {
|
|
2804
2808
|
if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
|
|
2805
2809
|
hasSetContentSizeEmpty.current = true;
|
|
@@ -2828,7 +2832,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2828
2832
|
}
|
|
2829
2833
|
setAutoSized(true);
|
|
2830
2834
|
needsAutoSize.current = false;
|
|
2831
|
-
}, [autoSizeColumns, gridRenderState, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
2835
|
+
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
2832
2836
|
const lastOwnerDocumentRef = useRef();
|
|
2833
2837
|
const wasVisibleRef = useRef(false);
|
|
2834
2838
|
/**
|
|
@@ -2837,7 +2841,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2837
2841
|
*/
|
|
2838
2842
|
useInterval(() => {
|
|
2839
2843
|
// If grid has become visible after previously being hidden, then refocus the last focused cell.
|
|
2840
|
-
const visible = !!gridDivRef.current?.checkVisibility();
|
|
2844
|
+
const visible = !!gridDivRef.current?.checkVisibility?.();
|
|
2841
2845
|
if (visible && !wasVisibleRef.current) {
|
|
2842
2846
|
wasVisibleRef.current = true;
|
|
2843
2847
|
const el = window.__stepaggrid_lastfocuseventtarget;
|
|
@@ -5454,9 +5458,9 @@ const GridContextProvider = (props) => {
|
|
|
5454
5458
|
/**
|
|
5455
5459
|
* Resize columns to fit container
|
|
5456
5460
|
*/
|
|
5457
|
-
const sizeColumnsToFit = useCallback(() => {
|
|
5461
|
+
const sizeColumnsToFit = useCallback((paramsOrGridWidth) => {
|
|
5458
5462
|
if (gridApi && !gridApi?.isDestroyed()) {
|
|
5459
|
-
gridApi.sizeColumnsToFit();
|
|
5463
|
+
gridApi.sizeColumnsToFit(paramsOrGridWidth);
|
|
5460
5464
|
}
|
|
5461
5465
|
}, [gridApi]);
|
|
5462
5466
|
/**
|