@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/README.md
CHANGED
|
@@ -275,7 +275,6 @@ test("click Delete menu option removes row from the table", async () => {
|
|
|
275
275
|
If your grid has a data-testid a global will be exposed in window with the helper scrollRowIntoViewById.
|
|
276
276
|
This will throw an exception if the row id is not found.
|
|
277
277
|
|
|
278
|
-
|
|
279
278
|
```tsx
|
|
280
279
|
window.__stepAgGrid.grids[dataTestId].scrollRowIntoViewById("1000")
|
|
281
280
|
```
|
|
@@ -61,6 +61,10 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
61
61
|
* If you want to stretch to container width if width is greater than the container add a flex column.
|
|
62
62
|
*/
|
|
63
63
|
sizeColumns?: 'fit' | 'auto' | 'auto-skip-headers' | 'none';
|
|
64
|
+
/**
|
|
65
|
+
* On first don't return a content size larger than this.
|
|
66
|
+
*/
|
|
67
|
+
maxInitialWidth?: number;
|
|
64
68
|
/**
|
|
65
69
|
* When pressing tab whilst editing the grid will select and edit the next cell if available.
|
|
66
70
|
* Once the last cell to edit closes this callback is called.
|
|
@@ -88,4 +92,4 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
88
92
|
/**
|
|
89
93
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
90
94
|
*/
|
|
91
|
-
export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, onCellFocused: paramsOnCellFocused, ...params }: GridProps<TData>) => ReactElement;
|
|
95
|
+
export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, ...params }: GridProps<TData>) => ReactElement;
|
|
@@ -13,6 +13,7 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
13
13
|
editable?: boolean | EditableCallback<TData, ValueType>;
|
|
14
14
|
valueGetter?: string | ValueGetterFunc<TData, ValueType>;
|
|
15
15
|
valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
|
|
16
|
+
maxInitialWidth?: number;
|
|
16
17
|
cellRenderer?: ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined) | string;
|
|
17
18
|
cellRendererParams?: {
|
|
18
19
|
rightHoverElement?: ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColDef, GridApi, IRowNode } from 'ag-grid-community';
|
|
1
|
+
import { ColDef, GridApi, IRowNode, ISizeColumnsToFitParams } from 'ag-grid-community';
|
|
2
2
|
import { CsvExportParams } from 'ag-grid-community';
|
|
3
3
|
import { ColDefT, GridBaseRow } from '../components';
|
|
4
4
|
export type GridFilterExternal<TData extends GridBaseRow> = (data: TData, rowNode: IRowNode) => boolean;
|
|
@@ -40,7 +40,7 @@ export interface GridContextType<TData extends GridBaseRow> {
|
|
|
40
40
|
ensureSelectedRowIsVisible: () => void;
|
|
41
41
|
getFirstRowId: () => number;
|
|
42
42
|
autoSizeColumns: (props?: AutoSizeColumnsProps) => AutoSizeColumnsResult;
|
|
43
|
-
sizeColumnsToFit: () => void;
|
|
43
|
+
sizeColumnsToFit: (paramsOrGridWidth?: ISizeColumnsToFitParams) => void;
|
|
44
44
|
startCellEditing: ({ rowId, colId }: StartCellEditingProps) => Promise<void>;
|
|
45
45
|
resetFocusedCellAfterCellEditing: () => void;
|
|
46
46
|
updatingCells: (props: {
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2762,7 +2762,7 @@ agGridCommunity.ModuleRegistry.registerModules([agGridCommunity.AllCommunityModu
|
|
|
2762
2762
|
/**
|
|
2763
2763
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2764
2764
|
*/
|
|
2765
|
-
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 }) => {
|
|
2765
|
+
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 }) => {
|
|
2766
2766
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing, } = useGridContext();
|
|
2767
2767
|
const { updatedDep, updatingCols } = React.useContext(GridUpdatingContext);
|
|
2768
2768
|
const gridDivRef = React.useRef(null);
|
|
@@ -2802,6 +2802,10 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2802
2802
|
needsAutoSize.current = true;
|
|
2803
2803
|
return;
|
|
2804
2804
|
}
|
|
2805
|
+
// Default max intial width is 256x initial visible column count, max of 80% window width
|
|
2806
|
+
const maxWidth = maxInitialWidth ||
|
|
2807
|
+
lodashEs.sum(params.columnDefs.map((c) => (!c.hide ? c.maxInitialWidth || 128 : 0)));
|
|
2808
|
+
result.width = Math.min(result.width, maxWidth);
|
|
2805
2809
|
if (gridRendered === 'empty') {
|
|
2806
2810
|
if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
|
|
2807
2811
|
hasSetContentSizeEmpty.current = true;
|
|
@@ -2830,7 +2834,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2830
2834
|
}
|
|
2831
2835
|
setAutoSized(true);
|
|
2832
2836
|
needsAutoSize.current = false;
|
|
2833
|
-
}, [autoSizeColumns, gridRenderState, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
2837
|
+
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns, sizeColumnsToFit]);
|
|
2834
2838
|
const lastOwnerDocumentRef = React.useRef();
|
|
2835
2839
|
const wasVisibleRef = React.useRef(false);
|
|
2836
2840
|
/**
|
|
@@ -2839,7 +2843,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2839
2843
|
*/
|
|
2840
2844
|
useInterval(() => {
|
|
2841
2845
|
// If grid has become visible after previously being hidden, then refocus the last focused cell.
|
|
2842
|
-
const visible = !!gridDivRef.current?.checkVisibility();
|
|
2846
|
+
const visible = !!gridDivRef.current?.checkVisibility?.();
|
|
2843
2847
|
if (visible && !wasVisibleRef.current) {
|
|
2844
2848
|
wasVisibleRef.current = true;
|
|
2845
2849
|
const el = window.__stepaggrid_lastfocuseventtarget;
|
|
@@ -5456,9 +5460,9 @@ const GridContextProvider = (props) => {
|
|
|
5456
5460
|
/**
|
|
5457
5461
|
* Resize columns to fit container
|
|
5458
5462
|
*/
|
|
5459
|
-
const sizeColumnsToFit = React.useCallback(() => {
|
|
5463
|
+
const sizeColumnsToFit = React.useCallback((paramsOrGridWidth) => {
|
|
5460
5464
|
if (gridApi && !gridApi?.isDestroyed()) {
|
|
5461
|
-
gridApi.sizeColumnsToFit();
|
|
5465
|
+
gridApi.sizeColumnsToFit(paramsOrGridWidth);
|
|
5462
5466
|
}
|
|
5463
5467
|
}, [gridApi]);
|
|
5464
5468
|
/**
|