@linzjs/step-ag-grid 17.0.5 → 17.0.7

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.
@@ -67,4 +67,4 @@ export interface GridProps {
67
67
  /**
68
68
  * Wrapper for AgGrid to add commonly used functionality.
69
69
  */
70
- export declare const Grid: ({ "data-testid": dataTestId, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, ...params }: GridProps) => ReactElement;
70
+ export declare const Grid: ({ "data-testid": dataTestId, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, rowHeight, ...params }: GridProps) => ReactElement;
@@ -7,6 +7,7 @@ export interface AutoSizeColumnsProps {
7
7
  skipHeader?: boolean;
8
8
  colIds?: Set<string> | string[];
9
9
  userSizedColIds?: Set<string>;
10
+ includeFlex?: boolean;
10
11
  }
11
12
  export type AutoSizeColumnsResult = {
12
13
  width: number;
@@ -2341,7 +2341,7 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
2341
2341
  /**
2342
2342
  * Wrapper for AgGrid to add commonly used functionality.
2343
2343
  */
2344
- const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, ...params }) => {
2344
+ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, rowHeight = theme === "ag-theme-step-default" ? 40 : theme === "ag-theme-step-compact" ? 36 : undefined, ...params }) => {
2345
2345
  const { gridReady, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnCellEditingComplete, getColDef, } = React.useContext(GridContext);
2346
2346
  const { checkUpdating, updatedDep, updatingCols } = React.useContext(GridUpdatingContext);
2347
2347
  const { prePopupOps } = React.useContext(GridContext);
@@ -2373,7 +2373,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2373
2373
  }
2374
2374
  const skipHeader = sizeColumns === "auto-skip-headers" && !lodashEs.isEmpty(params.rowData);
2375
2375
  if (sizeColumns === "auto" || skipHeader) {
2376
- const result = autoSizeColumns({ skipHeader, userSizedColIds: userSizedColIds.current });
2376
+ const result = autoSizeColumns({ skipHeader, userSizedColIds: userSizedColIds.current, includeFlex: true });
2377
2377
  if (lodashEs.isEmpty(params.rowData)) {
2378
2378
  if (!hasSetContentSizeEmpty.current && result && !hasSetContentSize.current) {
2379
2379
  hasSetContentSizeEmpty.current = true;
@@ -2755,7 +2755,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
2755
2755
  const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
2756
2756
  // This is setting a ref in the GridContext so won't be triggering an update loop
2757
2757
  setOnCellEditingComplete(params.onCellEditingComplete);
2758
- return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsxRuntime.jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsxRuntime.jsx(agGridReact.AgGridReact, { rowHeight: params.rowHeight, animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: (params) => `${params.data.id}`, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: () => {
2758
+ return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && autoSized && "Grid-ready"), children: [gridContextMenu.component, jsxRuntime.jsx("div", { style: { flex: 1 }, ref: gridDivRef, children: jsxRuntime.jsx(agGridReact.AgGridReact, { rowHeight: rowHeight, animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: (params) => `${params.data.id}`, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: () => {
2759
2759
  setInitialContentSize();
2760
2760
  }, onRowDataUpdated: onRowDataChanged, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: { minWidth: 48, ...lodashEs.omit(params.defaultColDef, ["editable"]) }, columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: (event) => {
2761
2761
  let rowCount = 0;
@@ -4737,13 +4737,15 @@ const GridContextProvider = (props) => {
4737
4737
  /**
4738
4738
  * Resize columns to fit container
4739
4739
  */
4740
- const autoSizeColumns = React.useCallback(({ skipHeader, colIds, userSizedColIds } = {}) => {
4740
+ const autoSizeColumns = React.useCallback(({ skipHeader, colIds, userSizedColIds, includeFlex } = {}) => {
4741
4741
  if (!columnApi)
4742
4742
  return null;
4743
4743
  const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
4744
4744
  const colsToResize = columnApi.getColumnState().filter((colState) => {
4745
4745
  const colId = colState.colId;
4746
- return (lodashEs.isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId) && !colState.flex;
4746
+ return ((lodashEs.isEmpty(colIdsSet) || colIdsSet.has(colId)) &&
4747
+ !userSizedColIds?.has(colId) &&
4748
+ (includeFlex || !colState.flex));
4747
4749
  });
4748
4750
  if (!lodashEs.isEmpty(colsToResize)) {
4749
4751
  columnApi.autoSizeColumns(colsToResize.map((colState) => colState.colId), skipHeader);