@linzjs/step-ag-grid 21.2.0 → 21.3.0
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/dist/src/components/Grid.d.ts +2 -1
- package/dist/step-ag-grid.cjs.js +19 -3
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +19 -3
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +3 -1
- package/src/contexts/GridContextProvider.tsx +18 -1
- package/src/stories/grid/GridReadOnly.stories.tsx +8 -1
|
@@ -7,6 +7,7 @@ export interface GridBaseRow {
|
|
|
7
7
|
}
|
|
8
8
|
export interface GridProps {
|
|
9
9
|
readOnly?: boolean;
|
|
10
|
+
defaultPostSort?: boolean;
|
|
10
11
|
selectable?: boolean;
|
|
11
12
|
theme?: string;
|
|
12
13
|
["data-testid"]?: string;
|
|
@@ -77,4 +78,4 @@ export interface GridProps {
|
|
|
77
78
|
/**
|
|
78
79
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
79
80
|
*/
|
|
80
|
-
export declare const Grid: ({ "data-testid": dataTestId, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, ...params }: GridProps) => ReactElement;
|
|
81
|
+
export declare const Grid: ({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, ...params }: GridProps) => ReactElement;
|
package/dist/step-ag-grid.cjs.js
CHANGED
|
@@ -2338,7 +2338,7 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2338
2338
|
/**
|
|
2339
2339
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2340
2340
|
*/
|
|
2341
|
-
const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === "ag-theme-step-default" ? 40 : theme === "ag-theme-step-compact" ? 36 : 40, ...params }) => {
|
|
2341
|
+
const Grid = ({ "data-testid": dataTestId, defaultPostSort = true, rowSelection = "multiple", suppressColumnVirtualization = true, theme = "ag-theme-step-default", sizeColumns = "auto", selectColumnPinned = null, contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === "ag-theme-step-default" ? 40 : theme === "ag-theme-step-compact" ? 36 : 40, ...params }) => {
|
|
2342
2342
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnCellEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, stopEditing, } = React.useContext(GridContext);
|
|
2343
2343
|
const { checkUpdating, updatedDep, updatingCols } = React.useContext(GridUpdatingContext);
|
|
2344
2344
|
const gridDivRef = React.useRef(null);
|
|
@@ -2819,7 +2819,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
2819
2819
|
let rowCount = 0;
|
|
2820
2820
|
event.api.forEachNode(() => rowCount++);
|
|
2821
2821
|
return (jsxRuntime.jsx(GridNoRowsOverlay, { loading: !rowData || params.loading === true, rowCount: rowCount, headerRowHeight: headerRowCount * rowHeight, filteredRowCount: event.api.getDisplayedRowCount(), noRowsOverlayText: params.noRowsOverlayText, noRowsMatchingOverlayText: params.noRowsMatchingOverlayText }));
|
|
2822
|
-
}, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, onRowDragLeave: onRowDragLeave, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData }) })] }));
|
|
2822
|
+
}, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, onRowDragLeave: onRowDragLeave, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData }) })] }));
|
|
2823
2823
|
};
|
|
2824
2824
|
|
|
2825
2825
|
const GridPopoverContext = React.createContext({
|
|
@@ -5025,7 +5025,23 @@ const GridContextProvider = (props) => {
|
|
|
5025
5025
|
}
|
|
5026
5026
|
}, []);
|
|
5027
5027
|
const onFilterChanged = React.useMemo(() => debounce(() => {
|
|
5028
|
-
|
|
5028
|
+
// This is terrible, but there's no other way for me to check whether a filter has changed the grid
|
|
5029
|
+
const getDisplayedRowsHash = () => {
|
|
5030
|
+
const arr = [];
|
|
5031
|
+
gridApi?.forEachNodeAfterFilter((rowNode) => {
|
|
5032
|
+
arr.push(rowNode.id);
|
|
5033
|
+
});
|
|
5034
|
+
return arr.join("|");
|
|
5035
|
+
};
|
|
5036
|
+
if (gridApi) {
|
|
5037
|
+
const hasFocusedCell = gridApi.getFocusedCell();
|
|
5038
|
+
const preHash = hasFocusedCell && getDisplayedRowsHash();
|
|
5039
|
+
gridApi.onFilterChanged();
|
|
5040
|
+
const postHash = hasFocusedCell && getDisplayedRowsHash();
|
|
5041
|
+
// Ag-grid has a bug where if a focused cell comes into view after a filter the filter loses focus
|
|
5042
|
+
// So the focus is cleared to prevent this
|
|
5043
|
+
preHash !== postHash && gridApi.clearFocusedCell();
|
|
5044
|
+
}
|
|
5029
5045
|
}, 200), [gridApi]);
|
|
5030
5046
|
const addExternalFilter = (filter) => {
|
|
5031
5047
|
externalFilters.current.push(filter);
|