@mui/x-data-grid 7.23.6 → 7.24.1
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/CHANGELOG.md +150 -0
- package/DataGrid/DataGrid.js +4 -5
- package/DataGrid/useDataGridComponent.d.ts +2 -1
- package/DataGrid/useDataGridComponent.js +1 -1
- package/components/GridHeaders.js +2 -2
- package/components/GridRow.d.ts +5 -9
- package/components/GridRow.js +28 -105
- package/components/GridSkeletonLoadingOverlay.js +18 -18
- package/components/cell/GridCell.d.ts +9 -16
- package/components/cell/GridCell.js +17 -35
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
- package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
- package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/components/containers/GridRoot.d.ts +2 -2
- package/components/containers/GridRoot.js +14 -6
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/GridPanel.js +2 -1
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
- package/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/components/virtualization/GridVirtualScroller.js +4 -4
- package/context/GridContextProvider.d.ts +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
- package/hooks/core/useGridApiInitialization.d.ts +2 -2
- package/hooks/core/useGridInitialization.d.ts +2 -2
- package/hooks/core/useGridIsRtl.d.ts +2 -2
- package/hooks/core/useGridLocaleText.d.ts +2 -2
- package/hooks/core/useGridLoggerFactory.d.ts +2 -2
- package/hooks/core/useGridRefs.d.ts +2 -2
- package/hooks/core/useGridStateInitialization.d.ts +2 -2
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
- package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
- package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
- package/hooks/features/columns/useGridColumns.d.ts +2 -2
- package/hooks/features/density/useGridDensity.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
- package/hooks/features/editing/useGridEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
- package/hooks/features/events/useGridEvents.d.ts +2 -2
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.d.ts +2 -2
- package/hooks/features/export/useGridPrintExport.d.ts +2 -2
- package/hooks/features/export/utils.d.ts +2 -2
- package/hooks/features/filter/gridFilterSelector.js +6 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +7 -7
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/useGridFilter.d.ts +2 -2
- package/hooks/features/focus/useGridFocus.d.ts +2 -2
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/hooks/features/listView/useGridListView.d.ts +2 -2
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
- package/hooks/features/pagination/gridPaginationSelector.d.ts +20 -1
- package/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/hooks/features/pagination/useGridPagination.d.ts +3 -3
- package/hooks/features/pagination/useGridPagination.js +5 -3
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/hooks/features/preferencesPanel/index.d.ts +1 -1
- package/hooks/features/preferencesPanel/index.js +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +2 -2
- package/hooks/features/rowSelection/utils.d.ts +3 -2
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +2 -2
- package/hooks/features/rows/gridRowsSelector.js +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +2 -2
- package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
- package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
- package/hooks/features/scroll/useGridScroll.d.ts +2 -2
- package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
- package/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/hooks/features/sorting/useGridSorting.d.ts +2 -2
- package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
- package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
- package/hooks/utils/useGridApiContext.d.ts +2 -2
- package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
- package/hooks/utils/useGridApiMethod.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +2 -2
- package/hooks/utils/useGridApiRef.js +3 -1
- package/hooks/utils/useGridInitializeState.d.ts +3 -3
- package/hooks/utils/useGridLogger.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
- package/hooks/utils/useGridSelector.d.ts +3 -3
- package/hooks/utils/useGridVisibleRows.d.ts +8 -6
- package/hooks/utils/useGridVisibleRows.js +5 -28
- package/index.js +1 -1
- package/internals/constants.d.ts +6 -0
- package/internals/constants.js +8 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/utils/attachPinnedStyle.d.ts +2 -0
- package/internals/utils/attachPinnedStyle.js +9 -0
- package/internals/utils/getPinnedCellOffset.d.ts +3 -3
- package/internals/utils/getPinnedCellOffset.js +6 -7
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/locales/faIR.js +5 -6
- package/locales/urPK.js +9 -10
- package/models/colDef/gridColDef.d.ts +9 -8
- package/models/events/gridEventLookup.d.ts +6 -1
- package/models/gridExport.d.ts +2 -2
- package/models/gridFilterOperator.d.ts +2 -1
- package/models/gridStateCommunity.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +2 -1
- package/modern/DataGrid/DataGrid.js +4 -5
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/components/GridHeaders.js +2 -2
- package/modern/components/GridRow.js +28 -105
- package/modern/components/GridSkeletonLoadingOverlay.js +18 -18
- package/modern/components/cell/GridCell.js +17 -35
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/modern/components/containers/GridRoot.js +14 -6
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/GridPanel.js +2 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/modern/components/virtualization/GridVirtualScroller.js +4 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/modern/hooks/features/filter/gridFilterSelector.js +6 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
- package/modern/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/modern/hooks/features/pagination/useGridPagination.js +5 -3
- package/modern/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/modern/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/modern/hooks/features/preferencesPanel/index.js +1 -1
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +2 -2
- package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
- package/modern/hooks/utils/useGridApiRef.js +3 -1
- package/modern/hooks/utils/useGridVisibleRows.js +5 -28
- package/modern/index.js +1 -1
- package/modern/internals/constants.js +8 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/attachPinnedStyle.js +9 -0
- package/modern/internals/utils/getPinnedCellOffset.js +6 -7
- package/modern/internals/utils/index.js +2 -1
- package/modern/locales/faIR.js +5 -6
- package/modern/locales/urPK.js +9 -10
- package/modern/utils/cellBorderUtils.js +5 -5
- package/modern/utils/domUtils.js +7 -2
- package/modern/utils/isJSDOM.js +1 -0
- package/modern/utils/rtlFlipSide.js +22 -0
- package/node/DataGrid/DataGrid.js +2 -3
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/components/GridHeaders.js +2 -2
- package/node/components/GridRow.js +27 -104
- package/node/components/GridSkeletonLoadingOverlay.js +17 -17
- package/node/components/cell/GridCell.js +18 -36
- package/node/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
- package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/containers/GridRoot.js +14 -6
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/GridPanel.js +2 -1
- package/node/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/node/components/virtualization/GridVirtualScroller.js +4 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/node/hooks/features/filter/gridFilterSelector.js +6 -1
- package/node/hooks/features/filter/gridFilterUtils.js +3 -3
- package/node/hooks/features/pagination/gridPaginationSelector.js +41 -3
- package/node/hooks/features/pagination/useGridPagination.js +5 -3
- package/node/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/node/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +9 -2
- package/node/hooks/features/preferencesPanel/index.js +11 -10
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/node/hooks/features/rows/gridRowsSelector.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +1 -1
- package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +49 -0
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +94 -52
- package/node/hooks/utils/useGridApiRef.js +3 -1
- package/node/hooks/utils/useGridVisibleRows.js +3 -28
- package/node/index.js +1 -1
- package/node/internals/constants.js +9 -2
- package/node/internals/index.js +12 -0
- package/node/internals/utils/attachPinnedStyle.js +15 -0
- package/node/internals/utils/getPinnedCellOffset.js +6 -7
- package/node/internals/utils/index.js +11 -0
- package/node/locales/faIR.js +5 -6
- package/node/locales/urPK.js +9 -10
- package/node/utils/cellBorderUtils.js +5 -5
- package/node/utils/domUtils.js +7 -2
- package/node/utils/isJSDOM.js +7 -0
- package/node/utils/rtlFlipSide.js +29 -0
- package/package.json +2 -2
- package/utils/cellBorderUtils.d.ts +3 -3
- package/utils/cellBorderUtils.js +5 -5
- package/utils/createSelector.d.ts +3 -3
- package/utils/domUtils.js +7 -2
- package/utils/getPublicApiRef.d.ts +2 -1
- package/utils/isJSDOM.d.ts +1 -0
- package/utils/isJSDOM.js +1 -0
- package/utils/rtlFlipSide.d.ts +2 -0
- package/utils/rtlFlipSide.js +22 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode } from '../../../models';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridApiCommunity, GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
@@ -20,7 +20,7 @@ export declare const getTopLevelRowCount: ({ tree, rowCountProp, }: {
|
|
|
20
20
|
rowCountProp: DataGridProcessedProps["rowCount"];
|
|
21
21
|
}) => number;
|
|
22
22
|
export declare const getRowsStateFromCache: ({ apiRef, rowCountProp, loadingProp, previousTree, previousTreeDepths, previousGroupsToFetch, }: Pick<GridRowTreeCreationParams, "previousTree" | "previousTreeDepths" | "previousGroupsToFetch"> & {
|
|
23
|
-
apiRef:
|
|
23
|
+
apiRef: RefObject<GridPrivateApiCommunity>;
|
|
24
24
|
rowCountProp: number | undefined;
|
|
25
25
|
loadingProp: boolean | undefined;
|
|
26
26
|
}) => GridRowsState;
|
|
@@ -33,12 +33,12 @@ export declare const updateCacheWithNewRows: ({ previousCache, getRowId, updates
|
|
|
33
33
|
updates: GridRowModelUpdate[];
|
|
34
34
|
groupKeys?: string[];
|
|
35
35
|
}) => GridRowsInternalCache;
|
|
36
|
-
export declare function calculatePinnedRowsHeight(apiRef:
|
|
36
|
+
export declare function calculatePinnedRowsHeight(apiRef: RefObject<GridApiCommunity>): {
|
|
37
37
|
top: number;
|
|
38
38
|
bottom: number;
|
|
39
39
|
};
|
|
40
40
|
export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
|
|
41
|
-
export declare function computeRowsUpdates(apiRef:
|
|
41
|
+
export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
|
|
42
42
|
export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
|
|
43
43
|
export declare const rowHeightWarning: string;
|
|
44
44
|
export declare const getRowHeightWarning: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
export declare class MissingRowIdError extends Error {
|
|
@@ -11,4 +11,4 @@ export declare class MissingRowIdError extends Error {
|
|
|
11
11
|
* TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
|
|
12
12
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
13
13
|
*/
|
|
14
|
-
export declare function useGridParamsApi(apiRef:
|
|
14
|
+
export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView'>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import type { GridColDef } from '../../../models/colDef';
|
|
3
3
|
import type { GridRowId } from '../../../models/gridRows';
|
|
4
4
|
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
@@ -24,4 +24,4 @@ export type RowRange = {
|
|
|
24
24
|
* @requires filterStateInitializer (method) - should be initialized before
|
|
25
25
|
*/
|
|
26
26
|
export declare const rowSpanningStateInitializer: GridStateInitializer;
|
|
27
|
-
export declare const useGridRowSpanning: (apiRef:
|
|
27
|
+
export declare const useGridRowSpanning: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "unstable_rowSpanning" | "pagination" | "paginationMode">) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
5
|
export declare const rowsStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'unstable_dataSource' | 'rows' | 'rowCount' | 'getRowId' | 'loading'>>;
|
|
6
|
-
export declare const useGridRows: (apiRef:
|
|
6
|
+
export declare const useGridRows: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rows" | "getRowId" | "rowCount" | "throttleRowsMs" | "signature" | "pagination" | "paginationMode" | "loading" | "unstable_dataSource">) => void;
|
|
@@ -6,7 +6,7 @@ import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
|
6
6
|
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
|
|
7
7
|
import { useTimeout } from "../../utils/useTimeout.js";
|
|
8
8
|
import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
|
-
import {
|
|
9
|
+
import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
10
10
|
import { gridSortedRowIdsSelector } from "../sorting/gridSortingSelector.js";
|
|
11
11
|
import { gridFilteredRowsLookupSelector } from "../filter/gridFilterSelector.js";
|
|
12
12
|
import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutogeneratedRowNode, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel, computeRowsUpdates } from "./gridRowsUtils.js";
|
|
@@ -39,7 +39,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
const logger = useGridLogger(apiRef, 'useGridRows');
|
|
42
|
-
const currentPage =
|
|
42
|
+
const currentPage = getVisibleRows(apiRef);
|
|
43
43
|
const lastUpdateMs = React.useRef(Date.now());
|
|
44
44
|
const lastRowCount = React.useRef(props.rowCount);
|
|
45
45
|
const timeout = useTimeout();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
@@ -7,4 +7,4 @@ export declare const rowsMetaStateInitializer: GridStateInitializer;
|
|
|
7
7
|
* @requires useGridPageSize (method)
|
|
8
8
|
* @requires useGridPage (method)
|
|
9
9
|
*/
|
|
10
|
-
export declare const useGridRowsMeta: (apiRef:
|
|
10
|
+
export declare const useGridRowsMeta: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "getRowHeight" | "getEstimatedRowHeight" | "getRowSpacing" | "pagination" | "paginationMode" | "rowHeight" | "rowPositionsDebounceMs">) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
-
export declare const useGridRowsPreProcessors: (apiRef:
|
|
3
|
+
export declare const useGridRowsPreProcessors: (apiRef: RefObject<GridPrivateApiCommunity>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
/**
|
|
@@ -9,4 +9,4 @@ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
|
9
9
|
* @requires useGridFilter (state)
|
|
10
10
|
* @requires useGridColumnSpanning (method)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridScroll: (apiRef:
|
|
12
|
+
export declare const useGridScroll: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "pagination" | "unstable_listView">) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridSortingModelApplier } from './gridSortingState';
|
|
3
3
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
4
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
@@ -8,10 +8,10 @@ export declare const mergeStateWithSortModel: (sortModel: GridSortModel, disable
|
|
|
8
8
|
/**
|
|
9
9
|
* Generates a method to easily sort a list of rows according to the current sort model.
|
|
10
10
|
* @param {GridSortModel} sortModel The model with which we want to sort the rows.
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
12
12
|
* @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
|
|
13
13
|
*/
|
|
14
|
-
export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, apiRef:
|
|
14
|
+
export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, apiRef: RefObject<GridApiCommunity>) => GridSortingModelApplier | null;
|
|
15
15
|
export declare const getNextGridSortDirection: (sortingOrder: readonly GridSortDirection[], current?: GridSortDirection) => GridSortDirection;
|
|
16
16
|
export declare const gridStringOrNumberComparator: GridComparatorFn;
|
|
17
17
|
export declare const gridNumberComparator: GridComparatorFn;
|
|
@@ -19,7 +19,7 @@ const isDesc = direction => direction === 'desc';
|
|
|
19
19
|
/**
|
|
20
20
|
* Transform an item of the sorting model into a method comparing two rows.
|
|
21
21
|
* @param {GridSortItem} sortItem The sort item we want to apply.
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
23
23
|
* @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
|
|
24
24
|
*/
|
|
25
25
|
const parseSortItem = (sortItem, apiRef) => {
|
|
@@ -72,7 +72,7 @@ const compareRows = (parsedSortItems, row1, row2) => {
|
|
|
72
72
|
/**
|
|
73
73
|
* Generates a method to easily sort a list of rows according to the current sort model.
|
|
74
74
|
* @param {GridSortModel} sortModel The model with which we want to sort the rows.
|
|
75
|
-
* @param {
|
|
75
|
+
* @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
76
76
|
* @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
|
|
77
77
|
*/
|
|
78
78
|
export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
@@ -7,4 +7,4 @@ export declare const sortingStateInitializer: GridStateInitializer<Pick<DataGrid
|
|
|
7
7
|
* @requires useGridRows (event)
|
|
8
8
|
* @requires useGridColumns (event)
|
|
9
9
|
*/
|
|
10
|
-
export declare const useGridSorting: (apiRef:
|
|
10
|
+
export declare const useGridSorting: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting">) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
-
export declare const useGridStatePersistence: (apiRef:
|
|
3
|
+
export declare const useGridStatePersistence: (apiRef: RefObject<GridPrivateApiCommunity>) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const gridFocusedVirtualCellSelector: import("../../..").OutputSelector<import("../../../models/gridStateCommunity").GridStateCommunity, {
|
|
2
|
+
rowIndex: number;
|
|
3
|
+
columnIndex: number;
|
|
4
|
+
id?: import("../../..").GridRowId | undefined;
|
|
5
|
+
field?: string | undefined;
|
|
6
|
+
} | null>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createSelector } from 'reselect';
|
|
3
|
+
import { createSelectorMemoized } from "../../../utils/createSelector.js";
|
|
4
|
+
import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
|
|
5
|
+
import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
|
|
6
|
+
import { gridFocusCellSelector } from "../focus/index.js";
|
|
7
|
+
import { gridVisibleRowsSelector } from "../pagination/index.js";
|
|
8
|
+
import { gridRowsLookupSelector } from "../rows/index.js";
|
|
9
|
+
const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
|
|
10
|
+
if (!focusedCell) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const row = rows[focusedCell.id];
|
|
14
|
+
if (!row) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const rowIndex = currentPage.rowToIndexMap.get(row);
|
|
18
|
+
const columnIndex = visibleColumns.slice(renderContext.firstColumnIndex, renderContext.lastColumnIndex).findIndex(column => column.field === focusedCell.field);
|
|
19
|
+
const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
|
|
20
|
+
return !isInRenderContext;
|
|
21
|
+
});
|
|
22
|
+
export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContex, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
|
|
23
|
+
if (!isFocusedCellOutOfRenderContext) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const row = rows[focusedCell.id];
|
|
27
|
+
if (!row) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const rowIndex = currentPage.rowToIndexMap.get(row);
|
|
31
|
+
if (rowIndex === undefined) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const columnIndex = visibleColumns.findIndex(column => column.field === focusedCell.field);
|
|
35
|
+
if (columnIndex === -1) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return _extends({}, focusedCell, {
|
|
39
|
+
rowIndex,
|
|
40
|
+
columnIndex
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridPinnedRowsPosition } from '../rows/gridRowsInterfaces';
|
|
3
|
-
import type
|
|
3
|
+
import { type GridRenderContext, type GridColumnsRenderContext, type GridRowEntry, type GridRowId } from '../../../models';
|
|
4
4
|
export type VirtualScroller = ReturnType<typeof useGridVirtualScroller>;
|
|
5
5
|
export declare const EMPTY_DETAIL_PANELS: Readonly<Map<GridRowId, React.ReactNode>>;
|
|
6
6
|
export declare const useGridVirtualScroller: () => {
|
|
@@ -26,6 +26,7 @@ export declare const useGridVirtualScroller: () => {
|
|
|
26
26
|
getContentProps: () => {
|
|
27
27
|
style: React.CSSProperties;
|
|
28
28
|
role: string;
|
|
29
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
29
30
|
};
|
|
30
31
|
getRenderZoneProps: () => {
|
|
31
32
|
role: string;
|
|
@@ -13,7 +13,6 @@ import { useRunOnce } from "../../utils/useRunOnce.js";
|
|
|
13
13
|
import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../columns/gridColumnsSelector.js";
|
|
14
14
|
import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
15
15
|
import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
|
|
16
|
-
import { gridFocusCellSelector, gridTabIndexCellSelector } from "../focus/gridFocusStateSelector.js";
|
|
17
16
|
import { useGridVisibleRows, getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
18
17
|
import { useGridApiEventHandler } from "../../utils/index.js";
|
|
19
18
|
import * as platform from "../../../utils/platform.js";
|
|
@@ -26,6 +25,8 @@ import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
|
|
|
26
25
|
import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
|
|
27
26
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
28
27
|
import { minimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
28
|
+
import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
|
|
29
|
+
import { isJSDOM } from "../../../utils/isJSDOM.js";
|
|
29
30
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
31
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
31
32
|
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
@@ -45,14 +46,6 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
|
|
|
45
46
|
direction: ScrollDirection.NONE,
|
|
46
47
|
buffer: bufferForDirection(isRtl, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
|
|
47
48
|
});
|
|
48
|
-
let isJSDOM = false;
|
|
49
|
-
try {
|
|
50
|
-
if (typeof window !== 'undefined') {
|
|
51
|
-
isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
52
|
-
}
|
|
53
|
-
} catch (_) {
|
|
54
|
-
/* ignore */
|
|
55
|
-
}
|
|
56
49
|
export const useGridVirtualScroller = () => {
|
|
57
50
|
const apiRef = useGridPrivateApiContext();
|
|
58
51
|
const rootProps = useGridRootProps();
|
|
@@ -73,12 +66,9 @@ export const useGridVirtualScroller = () => {
|
|
|
73
66
|
const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
|
|
74
67
|
const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
|
|
75
68
|
const isRtl = useRtl();
|
|
76
|
-
const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
|
|
77
|
-
const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
|
|
78
69
|
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
79
70
|
const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
|
|
80
71
|
const currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
81
|
-
const gridRootRef = apiRef.current.rootElementRef;
|
|
82
72
|
const mainRef = apiRef.current.mainElementRef;
|
|
83
73
|
const scrollerRef = apiRef.current.virtualScrollerRef;
|
|
84
74
|
const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
@@ -86,6 +76,7 @@ export const useGridVirtualScroller = () => {
|
|
|
86
76
|
const contentHeight = dimensions.contentSize.height;
|
|
87
77
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
88
78
|
const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
|
|
79
|
+
const isRenderContextReady = React.useRef(false);
|
|
89
80
|
const previousSize = React.useRef(null);
|
|
90
81
|
const mainRefCallback = React.useCallback(node => {
|
|
91
82
|
mainRef.current = node;
|
|
@@ -138,17 +129,15 @@ export const useGridVirtualScroller = () => {
|
|
|
138
129
|
* work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
|
|
139
130
|
* that are part of this old context will keep their same render context as to avoid re-rendering.
|
|
140
131
|
*/
|
|
141
|
-
const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
132
|
+
const scrollPosition = React.useRef(rootProps.initialState?.scroll ?? EMPTY_SCROLL_POSITION);
|
|
133
|
+
const ignoreNextScrollEvent = React.useRef(false);
|
|
142
134
|
const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
143
135
|
const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
|
|
144
136
|
const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
|
|
137
|
+
const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
|
|
145
138
|
const scrollTimeout = useTimeout();
|
|
146
139
|
const frozenContext = React.useRef(undefined);
|
|
147
140
|
const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
|
|
148
|
-
const focusedCell = {
|
|
149
|
-
rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
|
|
150
|
-
columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
|
|
151
|
-
};
|
|
152
141
|
const updateRenderContext = React.useCallback(nextRenderContext => {
|
|
153
142
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
154
143
|
return;
|
|
@@ -232,6 +221,10 @@ export const useGridVirtualScroller = () => {
|
|
|
232
221
|
updateRenderContext(nextRenderContext);
|
|
233
222
|
};
|
|
234
223
|
const handleScroll = useEventCallback(event => {
|
|
224
|
+
if (ignoreNextScrollEvent.current) {
|
|
225
|
+
ignoreNextScrollEvent.current = false;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
235
228
|
const {
|
|
236
229
|
scrollTop,
|
|
237
230
|
scrollLeft
|
|
@@ -290,14 +283,14 @@ export const useGridVirtualScroller = () => {
|
|
|
290
283
|
const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
|
|
291
284
|
const rowIndexes = params.rows ? range(0, params.rows.length) : range(firstRowToRender, lastRowToRender);
|
|
292
285
|
let virtualRowIndex = -1;
|
|
293
|
-
if (!isPinnedSection &&
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
286
|
+
if (!isPinnedSection && focusedVirtualCell) {
|
|
287
|
+
if (focusedVirtualCell.rowIndex < firstRowToRender) {
|
|
288
|
+
rowIndexes.unshift(focusedVirtualCell.rowIndex);
|
|
289
|
+
virtualRowIndex = focusedVirtualCell.rowIndex;
|
|
297
290
|
}
|
|
298
|
-
if (
|
|
299
|
-
|
|
300
|
-
|
|
291
|
+
if (focusedVirtualCell.rowIndex > lastRowToRender) {
|
|
292
|
+
rowIndexes.push(focusedVirtualCell.rowIndex);
|
|
293
|
+
virtualRowIndex = focusedVirtualCell.rowIndex;
|
|
301
294
|
}
|
|
302
295
|
}
|
|
303
296
|
const rows = [];
|
|
@@ -337,7 +330,6 @@ export const useGridVirtualScroller = () => {
|
|
|
337
330
|
});
|
|
338
331
|
}
|
|
339
332
|
}
|
|
340
|
-
const hasFocus = cellFocus?.id === id;
|
|
341
333
|
const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
|
|
342
334
|
let isSelected;
|
|
343
335
|
if (selectedRowsLookup[id] == null) {
|
|
@@ -362,19 +354,16 @@ export const useGridVirtualScroller = () => {
|
|
|
362
354
|
isLastVisible = isLastVisibleInSection;
|
|
363
355
|
}
|
|
364
356
|
}
|
|
365
|
-
const isVirtualRow = rowIndexInPage === virtualRowIndex;
|
|
366
|
-
const isNotVisible = isVirtualRow;
|
|
367
|
-
let tabbableCell = null;
|
|
368
|
-
if (cellTabIndex !== null && cellTabIndex.id === id) {
|
|
369
|
-
const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
|
|
370
|
-
tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
|
|
371
|
-
}
|
|
372
357
|
let currentRenderContext = baseRenderContext;
|
|
373
358
|
if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
|
|
374
359
|
currentRenderContext = frozenContext.current;
|
|
375
360
|
}
|
|
361
|
+
const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
|
|
362
|
+
const isVirtualFocusColumn = focusedVirtualCell?.rowIndex === rowIndex;
|
|
376
363
|
const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, pinnedColumns.left.length);
|
|
377
364
|
const showBottomBorder = isLastVisibleInSection && params.position === 'top';
|
|
365
|
+
const firstColumnIndex = currentRenderContext.firstColumnIndex;
|
|
366
|
+
const lastColumnIndex = currentRenderContext.lastColumnIndex;
|
|
378
367
|
rows.push(/*#__PURE__*/_jsx(rootProps.slots.row, _extends({
|
|
379
368
|
row: model,
|
|
380
369
|
rowId: id,
|
|
@@ -382,19 +371,21 @@ export const useGridVirtualScroller = () => {
|
|
|
382
371
|
selected: isSelected,
|
|
383
372
|
offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
|
|
384
373
|
offsetLeft: offsetLeft,
|
|
385
|
-
|
|
374
|
+
columnsTotalWidth: dimensions.columnsTotalWidth,
|
|
386
375
|
rowHeight: baseRowHeight,
|
|
387
|
-
tabbableCell: tabbableCell,
|
|
388
376
|
pinnedColumns: pinnedColumns,
|
|
389
377
|
visibleColumns: visibleColumns,
|
|
390
|
-
|
|
391
|
-
|
|
378
|
+
firstColumnIndex: firstColumnIndex,
|
|
379
|
+
lastColumnIndex: lastColumnIndex,
|
|
380
|
+
focusedColumnIndex: isVirtualFocusColumn ? focusedVirtualCell.columnIndex : undefined,
|
|
392
381
|
isFirstVisible: isFirstVisible,
|
|
393
382
|
isLastVisible: isLastVisible,
|
|
394
|
-
isNotVisible:
|
|
395
|
-
showBottomBorder: showBottomBorder
|
|
383
|
+
isNotVisible: isVirtualFocusRow,
|
|
384
|
+
showBottomBorder: showBottomBorder,
|
|
385
|
+
scrollbarWidth: dimensions.hasScrollY ? dimensions.scrollbarSize : 0,
|
|
386
|
+
gridHasFiller: dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width
|
|
396
387
|
}, rowProps), id));
|
|
397
|
-
if (
|
|
388
|
+
if (isVirtualFocusRow) {
|
|
398
389
|
return;
|
|
399
390
|
}
|
|
400
391
|
const panel = panels.get(id);
|
|
@@ -425,18 +416,21 @@ export const useGridVirtualScroller = () => {
|
|
|
425
416
|
}
|
|
426
417
|
return size;
|
|
427
418
|
}, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
|
|
428
|
-
React.
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
useEnhancedEffect(() => {
|
|
432
|
-
// TODO a scroll reset should not be necessary
|
|
433
|
-
if (enabledForColumns) {
|
|
434
|
-
scrollerRef.current.scrollLeft = 0;
|
|
419
|
+
const onContentSizeApplied = React.useCallback(node => {
|
|
420
|
+
if (!node) {
|
|
421
|
+
return;
|
|
435
422
|
}
|
|
436
|
-
|
|
437
|
-
|
|
423
|
+
apiRef.current.publishEvent('virtualScrollerContentSizeChange', {
|
|
424
|
+
columnsTotalWidth,
|
|
425
|
+
contentHeight
|
|
426
|
+
});
|
|
427
|
+
}, [apiRef, columnsTotalWidth, contentHeight]);
|
|
428
|
+
useEnhancedEffect(() => {
|
|
429
|
+
if (!isRenderContextReady.current) {
|
|
430
|
+
return;
|
|
438
431
|
}
|
|
439
|
-
|
|
432
|
+
apiRef.current.updateRenderContext?.();
|
|
433
|
+
}, [apiRef, enabledForColumns, enabledForRows]);
|
|
440
434
|
useEnhancedEffect(() => {
|
|
441
435
|
if (listView) {
|
|
442
436
|
scrollerRef.current.scrollLeft = 0;
|
|
@@ -451,6 +445,53 @@ export const useGridVirtualScroller = () => {
|
|
|
451
445
|
left: scrollPosition.current.left,
|
|
452
446
|
renderContext: initialRenderContext
|
|
453
447
|
});
|
|
448
|
+
isRenderContextReady.current = true;
|
|
449
|
+
if (rootProps.initialState?.scroll && scrollerRef.current) {
|
|
450
|
+
const scroller = scrollerRef.current;
|
|
451
|
+
const {
|
|
452
|
+
top,
|
|
453
|
+
left
|
|
454
|
+
} = rootProps.initialState.scroll;
|
|
455
|
+
|
|
456
|
+
// On initial mount, if we have columns available, we can restore the horizontal scroll immediately, but we need to skip the resulting scroll event, otherwise we would recalculate the render context at position top=0, left=restoredValue, but the initial render context is already calculated based on the initial value of scrollPosition ref.
|
|
457
|
+
const isScrollRestored = {
|
|
458
|
+
top: !(top > 0),
|
|
459
|
+
left: !(left > 0)
|
|
460
|
+
};
|
|
461
|
+
if (!isScrollRestored.left && columnsTotalWidth) {
|
|
462
|
+
scroller.scrollLeft = left;
|
|
463
|
+
ignoreNextScrollEvent.current = true;
|
|
464
|
+
isScrollRestored.left = true;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// For the sake of completeness, but I'm not sure if contentHeight is ever available at this point. Maybe when virtualisation is disabled?
|
|
468
|
+
if (!isScrollRestored.top && contentHeight) {
|
|
469
|
+
scroller.scrollTop = top;
|
|
470
|
+
ignoreNextScrollEvent.current = true;
|
|
471
|
+
isScrollRestored.top = true;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// To restore the vertical scroll, we need to wait until the rows are available in the DOM (otherwise there's nowhere to scroll), but before paint to avoid reflows
|
|
475
|
+
if (!isScrollRestored.top || !isScrollRestored.left) {
|
|
476
|
+
const unsubscribeContentSizeChange = apiRef.current.subscribeEvent('virtualScrollerContentSizeChange', params => {
|
|
477
|
+
if (!isScrollRestored.left && params.columnsTotalWidth) {
|
|
478
|
+
scroller.scrollLeft = left;
|
|
479
|
+
ignoreNextScrollEvent.current = true;
|
|
480
|
+
isScrollRestored.left = true;
|
|
481
|
+
}
|
|
482
|
+
if (!isScrollRestored.top && params.contentHeight) {
|
|
483
|
+
scroller.scrollTop = top;
|
|
484
|
+
ignoreNextScrollEvent.current = true;
|
|
485
|
+
isScrollRestored.top = true;
|
|
486
|
+
}
|
|
487
|
+
if (isScrollRestored.left && isScrollRestored.top) {
|
|
488
|
+
unsubscribeContentSizeChange();
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
return unsubscribeContentSizeChange;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return undefined;
|
|
454
495
|
});
|
|
455
496
|
apiRef.current.register('private', {
|
|
456
497
|
updateRenderContext: forceUpdateRenderContext
|
|
@@ -478,7 +519,8 @@ export const useGridVirtualScroller = () => {
|
|
|
478
519
|
}),
|
|
479
520
|
getContentProps: () => ({
|
|
480
521
|
style: contentSize,
|
|
481
|
-
role: 'presentation'
|
|
522
|
+
role: 'presentation',
|
|
523
|
+
ref: onContentSizeApplied
|
|
482
524
|
}),
|
|
483
525
|
getRenderZoneProps: () => ({
|
|
484
526
|
role: 'rowgroup'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridRenderContext } from '../../../models';
|
|
3
3
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
4
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
@@ -17,5 +17,5 @@ export declare const EMPTY_RENDER_CONTEXT: {
|
|
|
17
17
|
lastColumnIndex: number;
|
|
18
18
|
};
|
|
19
19
|
export declare const virtualizationStateInitializer: GridStateInitializer<RootProps>;
|
|
20
|
-
export declare function useGridVirtualization(apiRef:
|
|
20
|
+
export declare function useGridVirtualization(apiRef: RefObject<GridPrivateApiCommunity>, props: RootProps): void;
|
|
21
21
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridApiCommon } from '../../models/api/gridApiCommon';
|
|
3
3
|
import { GridApiCommunity } from '../../models/api/gridApiCommunity';
|
|
4
|
-
export declare function useGridApiContext<Api extends GridApiCommon = GridApiCommunity>():
|
|
4
|
+
export declare function useGridApiContext<Api extends GridApiCommon = GridApiCommunity>(): RefObject<Api>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { EventListenerOptions } from '@mui/x-internals/EventManager';
|
|
3
3
|
import { GridEventListener, GridEvents } from '../../models/events';
|
|
4
4
|
import { CleanupTracking } from '../../utils/cleanupTracking/CleanupTracking';
|
|
@@ -15,8 +15,8 @@ declare enum GridSignature {
|
|
|
15
15
|
interface RegistryContainer {
|
|
16
16
|
registry: CleanupTracking | null;
|
|
17
17
|
}
|
|
18
|
-
export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends GridEvents>(apiRef:
|
|
18
|
+
export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends GridEvents>(apiRef: RefObject<Api>, eventName: E, handler?: GridEventListener<E>, options?: EventListenerOptions) => void;
|
|
19
19
|
export declare const unstable_resetCleanupTracking: () => void;
|
|
20
|
-
export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends GridEvents>(apiRef:
|
|
21
|
-
export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEvents>(apiRef:
|
|
20
|
+
export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends GridEvents>(apiRef: RefObject<Api>, eventName: E, handler?: GridEventListener<E>, options?: EventListenerOptions) => void;
|
|
21
|
+
export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEvents>(apiRef: RefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
|
|
22
22
|
export { GridSignature };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
3
3
|
type GetPublicApiType<PrivateApi> = PrivateApi extends {
|
|
4
4
|
getPublicApi: () => infer PublicApi;
|
|
5
5
|
} ? PublicApi : never;
|
|
6
|
-
export declare function useGridApiMethod<PrivateApi extends GridPrivateApiCommon, PublicApi extends GetPublicApiType<PrivateApi>, PrivateOnlyApi extends Omit<PrivateApi, keyof PublicApi>, V extends 'public' | 'private', T extends V extends 'public' ? Partial<PublicApi> : Partial<PrivateOnlyApi>>(privateApiRef:
|
|
6
|
+
export declare function useGridApiMethod<PrivateApi extends GridPrivateApiCommon, PublicApi extends GetPublicApiType<PrivateApi>, PrivateOnlyApi extends Omit<PrivateApi, keyof PublicApi>, V extends 'public' | 'private', T extends V extends 'public' ? Partial<PublicApi> : Partial<PrivateOnlyApi>>(privateApiRef: RefObject<PrivateApi>, apiMethods: T, visibility: V): void;
|
|
7
7
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridApiCommon } from '../../models';
|
|
3
3
|
import { GridApiCommunity } from '../../models/api/gridApiCommunity';
|
|
4
4
|
/**
|
|
5
5
|
* Hook that instantiate a [[GridApiRef]].
|
|
6
6
|
*/
|
|
7
|
-
export declare const useGridApiRef: <Api extends GridApiCommon = GridApiCommunity>() =>
|
|
7
|
+
export declare const useGridApiRef: <Api extends GridApiCommon = GridApiCommunity>() => RefObject<Api>;
|
|
@@ -2,4 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook that instantiate a [[GridApiRef]].
|
|
4
4
|
*/
|
|
5
|
-
export const useGridApiRef = () =>
|
|
5
|
+
export const useGridApiRef = () =>
|
|
6
|
+
// TODO v8: initialize with null (see https://github.com/mui/mui-x/issues/16135#issuecomment-2589395230 and https://github.com/mui/mui-x/issues/16000#issuecomment-2567820735)
|
|
7
|
+
React.useRef({});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
3
3
|
import { GridPrivateApiCommunity } from '../../models/api/gridApiCommunity';
|
|
4
4
|
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
|
|
5
5
|
type DeepPartial<T> = {
|
|
6
6
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
7
7
|
};
|
|
8
|
-
export type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity> = (state: DeepPartial<PrivateApi['state']>, props: P, privateApiRef:
|
|
9
|
-
export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps>, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(initializer: GridStateInitializer<P, PrivateApi>, privateApiRef:
|
|
8
|
+
export type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity> = (state: DeepPartial<PrivateApi['state']>, props: P, privateApiRef: RefObject<PrivateApi>) => DeepPartial<PrivateApi['state']>;
|
|
9
|
+
export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps>, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(initializer: GridStateInitializer<P, PrivateApi>, privateApiRef: RefObject<PrivateApi>, props: P) => void;
|
|
10
10
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { Logger } from '../../models/logger';
|
|
3
3
|
import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
4
|
-
export declare function useGridLogger<PrivateApi extends GridPrivateApiCommon>(privateApiRef:
|
|
4
|
+
export declare function useGridLogger<PrivateApi extends GridPrivateApiCommon>(privateApiRef: RefObject<PrivateApi>, name: string): Logger;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
3
|
import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
3
|
-
export declare const useGridNativeEventListener: <PrivateApi extends GridPrivateApiCommon, K extends keyof HTMLElementEventMap>(apiRef:
|
|
4
|
+
export declare const useGridNativeEventListener: <PrivateApi extends GridPrivateApiCommon, K extends keyof HTMLElementEventMap>(apiRef: RefObject<PrivateApi>, ref: React.RefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: (event: HTMLElementEventMap[K]) => any, options?: AddEventListenerOptions) => void;
|