@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
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2336,7 +2336,7 @@ const useGridContextMenu = ({ contextMenuSelectRow, contextMenu: ContextMenu, })
|
|
|
2336
2336
|
/**
|
|
2337
2337
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2338
2338
|
*/
|
|
2339
|
-
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 }) => {
|
|
2339
|
+
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 }) => {
|
|
2340
2340
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnCellEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, stopEditing, } = useContext(GridContext);
|
|
2341
2341
|
const { checkUpdating, updatedDep, updatingCols } = useContext(GridUpdatingContext);
|
|
2342
2342
|
const gridDivRef = useRef(null);
|
|
@@ -2817,7 +2817,7 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
2817
2817
|
let rowCount = 0;
|
|
2818
2818
|
event.api.forEachNode(() => rowCount++);
|
|
2819
2819
|
return (jsx(GridNoRowsOverlay, { loading: !rowData || params.loading === true, rowCount: rowCount, headerRowHeight: headerRowCount * rowHeight, filteredRowCount: event.api.getDisplayedRowCount(), noRowsOverlayText: params.noRowsOverlayText, noRowsMatchingOverlayText: params.noRowsMatchingOverlayText }));
|
|
2820
|
-
}, 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 }) })] }));
|
|
2820
|
+
}, 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 }) })] }));
|
|
2821
2821
|
};
|
|
2822
2822
|
|
|
2823
2823
|
const GridPopoverContext = createContext({
|
|
@@ -5023,7 +5023,23 @@ const GridContextProvider = (props) => {
|
|
|
5023
5023
|
}
|
|
5024
5024
|
}, []);
|
|
5025
5025
|
const onFilterChanged = useMemo(() => debounce(() => {
|
|
5026
|
-
|
|
5026
|
+
// This is terrible, but there's no other way for me to check whether a filter has changed the grid
|
|
5027
|
+
const getDisplayedRowsHash = () => {
|
|
5028
|
+
const arr = [];
|
|
5029
|
+
gridApi?.forEachNodeAfterFilter((rowNode) => {
|
|
5030
|
+
arr.push(rowNode.id);
|
|
5031
|
+
});
|
|
5032
|
+
return arr.join("|");
|
|
5033
|
+
};
|
|
5034
|
+
if (gridApi) {
|
|
5035
|
+
const hasFocusedCell = gridApi.getFocusedCell();
|
|
5036
|
+
const preHash = hasFocusedCell && getDisplayedRowsHash();
|
|
5037
|
+
gridApi.onFilterChanged();
|
|
5038
|
+
const postHash = hasFocusedCell && getDisplayedRowsHash();
|
|
5039
|
+
// Ag-grid has a bug where if a focused cell comes into view after a filter the filter loses focus
|
|
5040
|
+
// So the focus is cleared to prevent this
|
|
5041
|
+
preHash !== postHash && gridApi.clearFocusedCell();
|
|
5042
|
+
}
|
|
5027
5043
|
}, 200), [gridApi]);
|
|
5028
5044
|
const addExternalFilter = (filter) => {
|
|
5029
5045
|
externalFilters.current.push(filter);
|