@mui/x-data-grid 7.24.1 → 7.26.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/CHANGELOG.md +148 -0
- package/DataGrid/DataGrid.js +1 -7
- package/DataGrid/useDataGridComponent.js +2 -2
- package/components/GridRow.d.ts +0 -1
- package/components/GridRow.js +32 -20
- package/components/GridScrollArea.d.ts +5 -2
- package/components/GridScrollArea.js +32 -25
- package/components/GridSkeletonLoadingOverlay.js +2 -1
- package/components/cell/GridCell.d.ts +9 -6
- package/components/cell/GridCell.js +29 -52
- package/components/containers/GridRoot.js +11 -9
- package/components/containers/GridRootStyles.js +138 -40
- package/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/components/virtualization/GridMainContainer.d.ts +10 -0
- package/components/virtualization/GridMainContainer.js +10 -2
- package/components/virtualization/GridVirtualScrollbar.d.ts +4 -0
- package/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/components/virtualization/GridVirtualScroller.js +36 -16
- package/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/hooks/core/useGridStateInitialization.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +0 -5
- package/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/hooks/features/columns/useGridColumns.js +7 -3
- package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +16 -0
- package/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/hooks/features/dimensions/index.d.ts +1 -1
- package/hooks/features/dimensions/index.js +1 -2
- package/hooks/features/dimensions/useGridDimensions.js +102 -77
- package/hooks/features/editing/gridEditingSelectors.d.ts +10 -0
- package/hooks/features/editing/gridEditingSelectors.js +12 -1
- package/hooks/features/editing/index.d.ts +1 -1
- package/hooks/features/editing/index.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridRowEditing.js +8 -9
- package/hooks/features/filter/gridFilterState.d.ts +5 -0
- package/hooks/features/filter/gridFilterState.js +5 -0
- package/hooks/features/filter/useGridFilter.js +6 -13
- package/hooks/features/focus/useGridFocus.js +3 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/hooks/features/keyboardNavigation/utils.d.ts +1 -2
- package/hooks/features/keyboardNavigation/utils.js +0 -5
- package/hooks/features/listView/useGridListView.js +2 -1
- package/hooks/features/pagination/useGridPagination.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +4 -4
- package/hooks/features/rowSelection/utils.js +1 -1
- package/hooks/features/rows/gridRowsMetaState.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +0 -4
- package/hooks/features/rows/gridRowsUtils.js +0 -16
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
- package/hooks/features/rows/useGridParamsApi.js +33 -14
- package/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/hooks/features/rows/useGridRows.js +7 -8
- package/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +15 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
- package/hooks/utils/useGridSelector.d.ts +8 -1
- package/hooks/utils/useGridSelector.js +42 -8
- package/hooks/utils/useIsSSR.d.ts +1 -0
- package/hooks/utils/useIsSSR.js +5 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +29 -2
- package/models/api/gridStateApi.d.ts +1 -0
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +6 -0
- package/modern/DataGrid/DataGrid.js +1 -7
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/components/GridRow.js +32 -20
- package/modern/components/GridScrollArea.js +32 -25
- package/modern/components/GridSkeletonLoadingOverlay.js +2 -1
- package/modern/components/cell/GridCell.js +29 -52
- package/modern/components/containers/GridRoot.js +11 -9
- package/modern/components/containers/GridRootStyles.js +138 -40
- package/modern/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/modern/components/virtualization/GridMainContainer.js +10 -2
- package/modern/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/modern/components/virtualization/GridVirtualScroller.js +36 -16
- package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/modern/hooks/core/useGridStateInitialization.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/modern/hooks/features/columns/useGridColumns.js +7 -3
- package/modern/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/modern/hooks/features/dimensions/index.js +1 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +102 -77
- package/modern/hooks/features/editing/gridEditingSelectors.js +12 -1
- package/modern/hooks/features/editing/index.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +8 -9
- package/modern/hooks/features/filter/gridFilterState.js +5 -0
- package/modern/hooks/features/filter/useGridFilter.js +6 -13
- package/modern/hooks/features/focus/useGridFocus.js +3 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/modern/hooks/features/keyboardNavigation/utils.js +0 -5
- package/modern/hooks/features/listView/useGridListView.js +2 -1
- package/modern/hooks/features/pagination/useGridPagination.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -4
- package/modern/hooks/features/rowSelection/utils.js +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -16
- package/modern/hooks/features/rows/useGridParamsApi.js +33 -14
- package/modern/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/modern/hooks/features/rows/useGridRows.js +7 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/modern/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
- package/modern/hooks/utils/useGridSelector.js +42 -8
- package/modern/hooks/utils/useIsSSR.js +5 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -1
- package/modern/models/api/index.js +0 -1
- package/modern/utils/roundToDecimalPlaces.js +3 -0
- package/modern/utils/utils.js +6 -1
- package/node/DataGrid/DataGrid.js +1 -7
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/components/GridRow.js +28 -17
- package/node/components/GridScrollArea.js +31 -24
- package/node/components/GridSkeletonLoadingOverlay.js +2 -1
- package/node/components/cell/GridCell.js +27 -50
- package/node/components/containers/GridRoot.js +10 -8
- package/node/components/containers/GridRootStyles.js +138 -40
- package/node/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/node/components/virtualization/GridMainContainer.js +10 -2
- package/node/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/node/components/virtualization/GridVirtualScroller.js +36 -16
- package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/node/hooks/core/useGridStateInitialization.js +3 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/columns/gridColumnsSelector.js +1 -13
- package/node/hooks/features/columns/useGridColumns.js +7 -3
- package/node/hooks/features/dimensions/gridDimensionsSelectors.js +38 -2
- package/node/hooks/features/dimensions/index.js +13 -11
- package/node/hooks/features/dimensions/useGridDimensions.js +99 -74
- package/node/hooks/features/editing/gridEditingSelectors.js +12 -2
- package/node/hooks/features/editing/index.js +7 -11
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +6 -7
- package/node/hooks/features/filter/gridFilterState.js +6 -1
- package/node/hooks/features/filter/useGridFilter.js +5 -12
- package/node/hooks/features/focus/useGridFocus.js +3 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -15
- package/node/hooks/features/keyboardNavigation/utils.js +0 -6
- package/node/hooks/features/listView/useGridListView.js +2 -1
- package/node/hooks/features/pagination/useGridPagination.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +3 -3
- package/node/hooks/features/rowSelection/utils.js +1 -1
- package/node/hooks/features/rows/gridRowsUtils.js +0 -17
- package/node/hooks/features/rows/useGridParamsApi.js +33 -14
- package/node/hooks/features/rows/useGridRowSpanning.js +92 -89
- package/node/hooks/features/rows/useGridRows.js +7 -8
- package/node/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/node/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +73 -71
- package/node/hooks/utils/useGridSelector.js +42 -8
- package/node/hooks/utils/useIsSSR.js +12 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +20 -7
- package/node/models/api/index.js +0 -11
- package/node/utils/roundToDecimalPlaces.js +9 -0
- package/node/utils/utils.js +8 -1
- package/package.json +3 -2
- package/utils/roundToDecimalPlaces.d.ts +1 -0
- package/utils/roundToDecimalPlaces.js +3 -0
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +6 -1
|
@@ -6,7 +6,7 @@ import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
|
|
|
6
6
|
import { gridFocusCellSelector } from "../focus/index.js";
|
|
7
7
|
import { gridVisibleRowsSelector } from "../pagination/index.js";
|
|
8
8
|
import { gridRowsLookupSelector } from "../rows/index.js";
|
|
9
|
-
const
|
|
9
|
+
const gridIsFocusedCellOutOfContext = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
|
|
10
10
|
if (!focusedCell) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
@@ -19,7 +19,7 @@ const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridR
|
|
|
19
19
|
const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
|
|
20
20
|
return !isInRenderContext;
|
|
21
21
|
});
|
|
22
|
-
export const gridFocusedVirtualCellSelector = createSelectorMemoized(
|
|
22
|
+
export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContext, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
|
|
23
23
|
if (!isFocusedCellOutOfRenderContext) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
@@ -16,7 +16,7 @@ export declare const useGridVirtualScroller: () => {
|
|
|
16
16
|
};
|
|
17
17
|
getScrollerProps: () => {
|
|
18
18
|
ref: React.RefObject<HTMLDivElement | null>;
|
|
19
|
-
onScroll: (
|
|
19
|
+
onScroll: () => void;
|
|
20
20
|
onWheel: (event: React.WheelEvent) => void;
|
|
21
21
|
onTouchMove: (event: React.TouchEvent) => void;
|
|
22
22
|
style: React.CSSProperties;
|
|
@@ -34,10 +34,24 @@ export declare const useGridVirtualScroller: () => {
|
|
|
34
34
|
getScrollbarVerticalProps: () => {
|
|
35
35
|
ref: React.RefObject<HTMLDivElement | null>;
|
|
36
36
|
role: string;
|
|
37
|
+
scrollPosition: React.RefObject<{
|
|
38
|
+
top: number;
|
|
39
|
+
left: number;
|
|
40
|
+
}>;
|
|
37
41
|
};
|
|
38
42
|
getScrollbarHorizontalProps: () => {
|
|
39
43
|
ref: React.RefObject<HTMLDivElement | null>;
|
|
40
44
|
role: string;
|
|
45
|
+
scrollPosition: React.RefObject<{
|
|
46
|
+
top: number;
|
|
47
|
+
left: number;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
getScrollAreaProps: () => {
|
|
51
|
+
scrollPosition: React.RefObject<{
|
|
52
|
+
top: number;
|
|
53
|
+
left: number;
|
|
54
|
+
}>;
|
|
41
55
|
};
|
|
42
56
|
};
|
|
43
57
|
export declare function areRenderContextsEqual(context1: GridRenderContext, context2: GridRenderContext): boolean;
|
|
@@ -6,15 +6,15 @@ import useLazyRef from '@mui/utils/useLazyRef';
|
|
|
6
6
|
import useTimeout from '@mui/utils/useTimeout';
|
|
7
7
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
8
|
import reactMajor from '@mui/x-internals/reactMajor';
|
|
9
|
+
import { gridDimensionsSelector, gridColumnsTotalWidthSelector, gridContentHeightSelector, gridHasFillerSelector, gridRowHeightSelector, gridVerticalScrollbarWidthSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
9
10
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
10
11
|
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
11
12
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
12
13
|
import { useRunOnce } from "../../utils/useRunOnce.js";
|
|
13
14
|
import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../columns/gridColumnsSelector.js";
|
|
14
|
-
import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
15
15
|
import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
|
|
16
16
|
import { useGridVisibleRows, getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
17
|
-
import {
|
|
17
|
+
import { useGridApiOptionHandler } from "../../utils/index.js";
|
|
18
18
|
import * as platform from "../../../utils/platform.js";
|
|
19
19
|
import { clamp, range } from "../../../utils/utils.js";
|
|
20
20
|
import { selectedIdsLookupSelector } from "../rowSelection/gridRowSelectionSelector.js";
|
|
@@ -25,7 +25,9 @@ import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
|
|
|
25
25
|
import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
|
|
26
26
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
27
27
|
import { minimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
28
|
+
import { EMPTY_PINNED_COLUMN_FIELDS } from "../columns/index.js";
|
|
28
29
|
import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
|
|
30
|
+
import { roundToDecimalPlaces } from "../../../utils/roundToDecimalPlaces.js";
|
|
29
31
|
import { isJSDOM } from "../../../utils/isJSDOM.js";
|
|
30
32
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
33
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
@@ -55,28 +57,26 @@ export const useGridVirtualScroller = () => {
|
|
|
55
57
|
const visibleColumns = useGridSelector(apiRef, () => listView ? [gridListColumnSelector(apiRef.current.state)] : gridVisibleColumnDefinitionsSelector(apiRef));
|
|
56
58
|
const enabledForRows = useGridSelector(apiRef, gridVirtualizationRowEnabledSelector) && !isJSDOM;
|
|
57
59
|
const enabledForColumns = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector) && !isJSDOM;
|
|
58
|
-
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
59
|
-
const outerSize = dimensions.viewportOuterSize;
|
|
60
60
|
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
61
|
-
const pinnedColumnDefinitions =
|
|
62
|
-
const pinnedColumns = listView ?
|
|
63
|
-
left: [],
|
|
64
|
-
right: []
|
|
65
|
-
} : pinnedColumnDefinitions;
|
|
61
|
+
const pinnedColumnDefinitions = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
|
|
62
|
+
const pinnedColumns = listView ? EMPTY_PINNED_COLUMN_FIELDS : pinnedColumnDefinitions;
|
|
66
63
|
const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
|
|
67
64
|
const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
|
|
68
65
|
const isRtl = useRtl();
|
|
69
|
-
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
70
66
|
const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
|
|
71
|
-
const currentPage = useGridVisibleRows(apiRef
|
|
67
|
+
const currentPage = useGridVisibleRows(apiRef);
|
|
72
68
|
const mainRef = apiRef.current.mainElementRef;
|
|
73
69
|
const scrollerRef = apiRef.current.virtualScrollerRef;
|
|
74
70
|
const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
75
71
|
const scrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
76
|
-
const contentHeight = dimensions.contentSize.height;
|
|
77
|
-
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
78
72
|
const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
|
|
79
73
|
const isRenderContextReady = React.useRef(false);
|
|
74
|
+
const rowHeight = useGridSelector(apiRef, gridRowHeightSelector);
|
|
75
|
+
const contentHeight = useGridSelector(apiRef, gridContentHeightSelector);
|
|
76
|
+
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
77
|
+
const needsHorizontalScrollbar = useGridSelector(apiRef, needsHorizontalScrollbarSelector);
|
|
78
|
+
const verticalScrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
|
|
79
|
+
const gridHasFiller = useGridSelector(apiRef, gridHasFillerSelector);
|
|
80
80
|
const previousSize = React.useRef(null);
|
|
81
81
|
const mainRefCallback = React.useCallback(node => {
|
|
82
82
|
mainRef.current = node;
|
|
@@ -84,7 +84,10 @@ export const useGridVirtualScroller = () => {
|
|
|
84
84
|
return undefined;
|
|
85
85
|
}
|
|
86
86
|
const initialRect = node.getBoundingClientRect();
|
|
87
|
-
let lastSize =
|
|
87
|
+
let lastSize = {
|
|
88
|
+
width: roundToDecimalPlaces(initialRect.width, 1),
|
|
89
|
+
height: roundToDecimalPlaces(initialRect.height, 1)
|
|
90
|
+
};
|
|
88
91
|
if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
|
|
89
92
|
previousSize.current = lastSize;
|
|
90
93
|
apiRef.current.publishEvent('resize', lastSize);
|
|
@@ -97,7 +100,10 @@ export const useGridVirtualScroller = () => {
|
|
|
97
100
|
if (!entry) {
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
100
|
-
const newSize =
|
|
103
|
+
const newSize = {
|
|
104
|
+
width: roundToDecimalPlaces(entry.contentRect.width, 1),
|
|
105
|
+
height: roundToDecimalPlaces(entry.contentRect.height, 1)
|
|
106
|
+
};
|
|
101
107
|
if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
@@ -137,7 +143,7 @@ export const useGridVirtualScroller = () => {
|
|
|
137
143
|
const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
|
|
138
144
|
const scrollTimeout = useTimeout();
|
|
139
145
|
const frozenContext = React.useRef(undefined);
|
|
140
|
-
const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx,
|
|
146
|
+
const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
|
|
141
147
|
const updateRenderContext = React.useCallback(nextRenderContext => {
|
|
142
148
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
143
149
|
return;
|
|
@@ -152,22 +158,28 @@ export const useGridVirtualScroller = () => {
|
|
|
152
158
|
});
|
|
153
159
|
|
|
154
160
|
// The lazy-loading hook is listening to `renderedRowsIntervalChange`,
|
|
155
|
-
// but only does something if
|
|
156
|
-
//
|
|
157
|
-
|
|
161
|
+
// but only does something if we already have a render context, because
|
|
162
|
+
// otherwise we would call an update directly on mount
|
|
163
|
+
const isReady = gridDimensionsSelector(apiRef.current.state).isReady;
|
|
164
|
+
if (isReady && didRowsIntervalChange) {
|
|
158
165
|
previousRowContext.current = nextRenderContext;
|
|
159
166
|
apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
|
|
160
167
|
}
|
|
161
168
|
previousContextScrollPosition.current = scrollPosition.current;
|
|
162
|
-
}, [apiRef
|
|
169
|
+
}, [apiRef]);
|
|
163
170
|
const triggerUpdateRenderContext = useEventCallback(() => {
|
|
164
171
|
const scroller = scrollerRef.current;
|
|
165
172
|
if (!scroller) {
|
|
166
173
|
return undefined;
|
|
167
174
|
}
|
|
175
|
+
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
176
|
+
const maxScrollTop = Math.ceil(dimensions.minimumSize.height - dimensions.viewportOuterSize.height);
|
|
177
|
+
const maxScrollLeft = Math.ceil(dimensions.minimumSize.width - dimensions.viewportInnerSize.width);
|
|
178
|
+
|
|
179
|
+
// Clamp the scroll position to the viewport to avoid re-calculating the render context for scroll bounce
|
|
168
180
|
const newScroll = {
|
|
169
|
-
top: scroller.scrollTop,
|
|
170
|
-
left: scroller.scrollLeft
|
|
181
|
+
top: clamp(scroller.scrollTop, 0, maxScrollTop),
|
|
182
|
+
left: isRtl ? clamp(scroller.scrollLeft, -maxScrollLeft, 0) : clamp(scroller.scrollLeft, 0, maxScrollLeft)
|
|
171
183
|
};
|
|
172
184
|
const dx = newScroll.left - scrollPosition.current.left;
|
|
173
185
|
const dy = newScroll.top - scrollPosition.current.top;
|
|
@@ -180,7 +192,7 @@ export const useGridVirtualScroller = () => {
|
|
|
180
192
|
const columnScroll = Math.abs(scrollPosition.current.left - previousContextScrollPosition.current.left);
|
|
181
193
|
|
|
182
194
|
// PERF: use the computed minimum column width instead of a static one
|
|
183
|
-
const didCrossThreshold = rowScroll >=
|
|
195
|
+
const didCrossThreshold = rowScroll >= rowHeight || columnScroll >= MINIMUM_COLUMN_WIDTH;
|
|
184
196
|
const didChangeDirection = scrollCache.direction !== direction;
|
|
185
197
|
const shouldUpdate = didCrossThreshold || didChangeDirection;
|
|
186
198
|
if (!shouldUpdate) {
|
|
@@ -202,7 +214,7 @@ export const useGridVirtualScroller = () => {
|
|
|
202
214
|
}
|
|
203
215
|
}
|
|
204
216
|
scrollCache.direction = direction;
|
|
205
|
-
scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx,
|
|
217
|
+
scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
|
|
206
218
|
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
207
219
|
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
208
220
|
|
|
@@ -214,40 +226,25 @@ export const useGridVirtualScroller = () => {
|
|
|
214
226
|
return nextRenderContext;
|
|
215
227
|
});
|
|
216
228
|
const forceUpdateRenderContext = () => {
|
|
229
|
+
// skip update if dimensions are not ready and virtualization is enabled
|
|
230
|
+
if (!gridDimensionsSelector(apiRef.current.state).isReady && (enabledForRows || enabledForColumns)) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
217
233
|
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
218
234
|
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
219
235
|
// Reset the frozen context when the render context changes, see the illustration in https://github.com/mui/mui-x/pull/12353
|
|
220
236
|
frozenContext.current = undefined;
|
|
221
237
|
updateRenderContext(nextRenderContext);
|
|
222
238
|
};
|
|
223
|
-
const handleScroll = useEventCallback(
|
|
239
|
+
const handleScroll = useEventCallback(() => {
|
|
224
240
|
if (ignoreNextScrollEvent.current) {
|
|
225
241
|
ignoreNextScrollEvent.current = false;
|
|
226
242
|
return;
|
|
227
243
|
}
|
|
228
|
-
const {
|
|
229
|
-
scrollTop,
|
|
230
|
-
scrollLeft
|
|
231
|
-
} = event.currentTarget;
|
|
232
|
-
|
|
233
|
-
// On iOS and macOS, negative offsets are possible when swiping past the start
|
|
234
|
-
if (scrollTop < 0) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (!isRtl) {
|
|
238
|
-
if (scrollLeft < 0) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (isRtl) {
|
|
243
|
-
if (scrollLeft > 0) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
244
|
const nextRenderContext = triggerUpdateRenderContext();
|
|
248
245
|
apiRef.current.publishEvent('scrollPositionChange', {
|
|
249
|
-
top:
|
|
250
|
-
left:
|
|
246
|
+
top: scrollPosition.current.top,
|
|
247
|
+
left: scrollPosition.current.left,
|
|
251
248
|
renderContext: nextRenderContext
|
|
252
249
|
});
|
|
253
250
|
});
|
|
@@ -261,7 +258,12 @@ export const useGridVirtualScroller = () => {
|
|
|
261
258
|
if (!params.rows && !currentPage.range) {
|
|
262
259
|
return [];
|
|
263
260
|
}
|
|
264
|
-
|
|
261
|
+
let baseRenderContext = renderContext;
|
|
262
|
+
if (params.renderContext) {
|
|
263
|
+
baseRenderContext = params.renderContext;
|
|
264
|
+
baseRenderContext.firstColumnIndex = renderContext.firstColumnIndex;
|
|
265
|
+
baseRenderContext.lastColumnIndex = renderContext.lastColumnIndex;
|
|
266
|
+
}
|
|
265
267
|
const isLastSection = !hasBottomPinnedRows && params.position === undefined || hasBottomPinnedRows && params.position === 'bottom';
|
|
266
268
|
const isPinnedSection = params.position !== undefined;
|
|
267
269
|
let rowIndexOffset;
|
|
@@ -355,7 +357,7 @@ export const useGridVirtualScroller = () => {
|
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
359
|
let currentRenderContext = baseRenderContext;
|
|
358
|
-
if (
|
|
360
|
+
if (frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
|
|
359
361
|
currentRenderContext = frozenContext.current;
|
|
360
362
|
}
|
|
361
363
|
const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
|
|
@@ -369,9 +371,8 @@ export const useGridVirtualScroller = () => {
|
|
|
369
371
|
rowId: id,
|
|
370
372
|
index: rowIndex,
|
|
371
373
|
selected: isSelected,
|
|
372
|
-
offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
|
|
373
374
|
offsetLeft: offsetLeft,
|
|
374
|
-
columnsTotalWidth:
|
|
375
|
+
columnsTotalWidth: columnsTotalWidth,
|
|
375
376
|
rowHeight: baseRowHeight,
|
|
376
377
|
pinnedColumns: pinnedColumns,
|
|
377
378
|
visibleColumns: visibleColumns,
|
|
@@ -382,8 +383,8 @@ export const useGridVirtualScroller = () => {
|
|
|
382
383
|
isLastVisible: isLastVisible,
|
|
383
384
|
isNotVisible: isVirtualFocusRow,
|
|
384
385
|
showBottomBorder: showBottomBorder,
|
|
385
|
-
scrollbarWidth:
|
|
386
|
-
gridHasFiller:
|
|
386
|
+
scrollbarWidth: verticalScrollbarWidth,
|
|
387
|
+
gridHasFiller: gridHasFiller
|
|
387
388
|
}, rowProps), id));
|
|
388
389
|
if (isVirtualFocusRow) {
|
|
389
390
|
return;
|
|
@@ -400,7 +401,6 @@ export const useGridVirtualScroller = () => {
|
|
|
400
401
|
});
|
|
401
402
|
return rows;
|
|
402
403
|
};
|
|
403
|
-
const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth > outerSize.width;
|
|
404
404
|
const scrollerStyle = React.useMemo(() => ({
|
|
405
405
|
overflowX: !needsHorizontalScrollbar || listView ? 'hidden' : undefined,
|
|
406
406
|
overflowY: rootProps.autoHeight ? 'hidden' : undefined
|
|
@@ -436,14 +436,11 @@ export const useGridVirtualScroller = () => {
|
|
|
436
436
|
scrollerRef.current.scrollLeft = 0;
|
|
437
437
|
}
|
|
438
438
|
}, [listView, scrollerRef]);
|
|
439
|
-
useRunOnce(
|
|
440
|
-
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
441
|
-
const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
442
|
-
updateRenderContext(initialRenderContext);
|
|
439
|
+
useRunOnce(renderContext !== EMPTY_RENDER_CONTEXT, () => {
|
|
443
440
|
apiRef.current.publishEvent('scrollPositionChange', {
|
|
444
441
|
top: scrollPosition.current.top,
|
|
445
442
|
left: scrollPosition.current.left,
|
|
446
|
-
renderContext
|
|
443
|
+
renderContext
|
|
447
444
|
});
|
|
448
445
|
isRenderContextReady.current = true;
|
|
449
446
|
if (rootProps.initialState?.scroll && scrollerRef.current) {
|
|
@@ -496,9 +493,9 @@ export const useGridVirtualScroller = () => {
|
|
|
496
493
|
apiRef.current.register('private', {
|
|
497
494
|
updateRenderContext: forceUpdateRenderContext
|
|
498
495
|
});
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
496
|
+
useGridApiOptionHandler(apiRef, 'sortedRowsSet', forceUpdateRenderContext);
|
|
497
|
+
useGridApiOptionHandler(apiRef, 'paginationModelChange', forceUpdateRenderContext);
|
|
498
|
+
useGridApiOptionHandler(apiRef, 'columnsChange', forceUpdateRenderContext);
|
|
502
499
|
return {
|
|
503
500
|
renderContext,
|
|
504
501
|
setPanels,
|
|
@@ -527,14 +524,23 @@ export const useGridVirtualScroller = () => {
|
|
|
527
524
|
}),
|
|
528
525
|
getScrollbarVerticalProps: () => ({
|
|
529
526
|
ref: scrollbarVerticalRef,
|
|
530
|
-
role: 'presentation'
|
|
527
|
+
role: 'presentation',
|
|
528
|
+
scrollPosition
|
|
531
529
|
}),
|
|
532
530
|
getScrollbarHorizontalProps: () => ({
|
|
533
531
|
ref: scrollbarHorizontalRef,
|
|
534
|
-
role: 'presentation'
|
|
532
|
+
role: 'presentation',
|
|
533
|
+
scrollPosition
|
|
534
|
+
}),
|
|
535
|
+
getScrollAreaProps: () => ({
|
|
536
|
+
scrollPosition
|
|
535
537
|
})
|
|
536
538
|
};
|
|
537
539
|
};
|
|
540
|
+
// dimension selectors
|
|
541
|
+
function needsHorizontalScrollbarSelector(state) {
|
|
542
|
+
return state.dimensions.viewportOuterSize.width > 0 && state.dimensions.columnsTotalWidth > state.dimensions.viewportOuterSize.width;
|
|
543
|
+
}
|
|
538
544
|
function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
539
545
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
540
546
|
const currentPage = getVisibleRows(apiRef, rootProps);
|
|
@@ -573,6 +579,11 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
|
573
579
|
firstColumnIndex: 0,
|
|
574
580
|
lastColumnIndex: inputs.visibleColumns.length
|
|
575
581
|
};
|
|
582
|
+
if (inputs.listView) {
|
|
583
|
+
return _extends({}, renderContext, {
|
|
584
|
+
lastColumnIndex: 1
|
|
585
|
+
});
|
|
586
|
+
}
|
|
576
587
|
const {
|
|
577
588
|
top,
|
|
578
589
|
left
|
|
@@ -824,13 +835,4 @@ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verti
|
|
|
824
835
|
// eslint unable to figure out enum exhaustiveness
|
|
825
836
|
throw new Error('unreachable');
|
|
826
837
|
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// Round to avoid issues with subpixel rendering
|
|
830
|
-
// https://github.com/mui/mui-x/issues/15721
|
|
831
|
-
function roundDimensions(dimensions) {
|
|
832
|
-
return {
|
|
833
|
-
width: Math.round(dimensions.width * 10) / 10,
|
|
834
|
-
height: Math.round(dimensions.height * 10) / 10
|
|
835
|
-
};
|
|
836
838
|
}
|
|
@@ -5,6 +5,13 @@ import type { OutputSelector, OutputSelectorV8 } from '../../utils/createSelecto
|
|
|
5
5
|
type Selector<Api extends GridApiCommon, Args, T> = ((state: Api['state']) => T) | OutputSelectorV8<Api['state'], Args, T>;
|
|
6
6
|
export declare const objectShallowCompare: typeof fastObjectShallowCompare;
|
|
7
7
|
export declare const argsEqual: (prev: any, curr: any) => boolean;
|
|
8
|
+
type Refs<T> = {
|
|
9
|
+
state: T;
|
|
10
|
+
equals: <U = T>(a: U, b: U) => boolean;
|
|
11
|
+
selector: Selector<any, any, T>;
|
|
12
|
+
args: any;
|
|
13
|
+
subscription: undefined | (() => void);
|
|
14
|
+
};
|
|
8
15
|
export declare const useGridSelector: <Api extends GridApiCommon, T>(apiRef: RefObject<Api>, selector: ((state: Api["state"]) => T) | OutputSelector<Api["state"], T>, equals?: (a: T, b: T) => boolean) => T;
|
|
9
|
-
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: RefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <
|
|
16
|
+
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: RefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: Refs<T>["equals"]) => T;
|
|
10
17
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
4
5
|
import { useLazyRef } from "./useLazyRef.js";
|
|
5
|
-
import { useOnMount } from "./useOnMount.js";
|
|
6
6
|
function isOutputSelector(selector) {
|
|
7
7
|
return selector.acceptsApiRef;
|
|
8
8
|
}
|
|
@@ -42,8 +42,10 @@ const createRefs = () => ({
|
|
|
42
42
|
state: null,
|
|
43
43
|
equals: null,
|
|
44
44
|
selector: null,
|
|
45
|
-
args:
|
|
45
|
+
args: undefined
|
|
46
46
|
});
|
|
47
|
+
const EMPTY = [];
|
|
48
|
+
const emptyGetSnapshot = () => null;
|
|
47
49
|
|
|
48
50
|
// TODO v8: Remove this function
|
|
49
51
|
export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
@@ -60,15 +62,31 @@ export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
|
60
62
|
refs.current.state = state;
|
|
61
63
|
refs.current.equals = equals;
|
|
62
64
|
refs.current.selector = selector;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
const subscribe = React.useCallback(() => {
|
|
66
|
+
if (refs.current.subscription) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
refs.current.subscription = apiRef.current.store.subscribe(() => {
|
|
65
70
|
const newState = applySelector(apiRef, refs.current.selector);
|
|
66
71
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
67
72
|
refs.current.state = newState;
|
|
68
73
|
setState(newState);
|
|
69
74
|
}
|
|
70
75
|
});
|
|
71
|
-
|
|
76
|
+
return null;
|
|
77
|
+
},
|
|
78
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
|
+
EMPTY);
|
|
80
|
+
const unsubscribe = React.useCallback(() => {
|
|
81
|
+
return () => {
|
|
82
|
+
if (refs.current.subscription) {
|
|
83
|
+
refs.current.subscription();
|
|
84
|
+
refs.current.subscription = undefined;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
}, EMPTY);
|
|
89
|
+
useSyncExternalStore(unsubscribe, subscribe, emptyGetSnapshot);
|
|
72
90
|
return state;
|
|
73
91
|
};
|
|
74
92
|
|
|
@@ -96,14 +114,30 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
|
|
|
96
114
|
setState(newState);
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
const subscribe = React.useCallback(() => {
|
|
118
|
+
if (refs.current.subscription) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
refs.current.subscription = apiRef.current.store.subscribe(() => {
|
|
101
122
|
const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
102
123
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
103
124
|
refs.current.state = newState;
|
|
104
125
|
setState(newState);
|
|
105
126
|
}
|
|
106
127
|
});
|
|
107
|
-
|
|
128
|
+
return null;
|
|
129
|
+
},
|
|
130
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
131
|
+
EMPTY);
|
|
132
|
+
const unsubscribe = React.useCallback(() => {
|
|
133
|
+
return () => {
|
|
134
|
+
if (refs.current.subscription) {
|
|
135
|
+
refs.current.subscription();
|
|
136
|
+
refs.current.subscription = undefined;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
|
+
}, EMPTY);
|
|
141
|
+
useSyncExternalStore(unsubscribe, subscribe, emptyGetSnapshot);
|
|
108
142
|
return state;
|
|
109
143
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsSSR: () => boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
2
|
+
const emptySubscribe = () => () => {};
|
|
3
|
+
const clientSnapshot = () => false;
|
|
4
|
+
const serverSnapshot = () => true;
|
|
5
|
+
export const useIsSSR = () => useSyncExternalStore(emptySubscribe, clientSnapshot, serverSnapshot);
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { useGridDensity, densityStateInitializer } from '../hooks/features/densi
|
|
|
30
30
|
export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
31
31
|
export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
|
|
32
32
|
export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
|
|
33
|
+
export { defaultGridFilterLookup } from '../hooks/features/filter/gridFilterState';
|
|
33
34
|
export { passFilterLogic } from '../hooks/features/filter/gridFilterUtils';
|
|
34
35
|
export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, } from '../hooks/features/filter/gridFilterSelector';
|
|
35
36
|
export { isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
|
|
@@ -52,7 +53,6 @@ export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
|
52
53
|
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED } from '../hooks/features/rows/gridRowsUtils';
|
|
53
54
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, } from '../hooks/features/rows/gridRowsSelector';
|
|
54
55
|
export { headerFilteringStateInitializer, useGridHeaderFiltering, } from '../hooks/features/headerFiltering/useGridHeaderFiltering';
|
|
55
|
-
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
56
56
|
export { useGridRowSelection, rowSelectionStateInitializer, } from '../hooks/features/rowSelection/useGridRowSelection';
|
|
57
57
|
export { useGridRowSelectionPreProcessors } from '../hooks/features/rowSelection/useGridRowSelectionPreProcessors';
|
|
58
58
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
@@ -61,6 +61,7 @@ export { gridSortedRowIndexLookupSelector } from '../hooks/features/sorting/grid
|
|
|
61
61
|
export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
62
62
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
63
63
|
export { dimensionsStateInitializer, useGridDimensions, } from '../hooks/features/dimensions/useGridDimensions';
|
|
64
|
+
export * from '../hooks/features/dimensions/gridDimensionsSelectors';
|
|
64
65
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
65
66
|
export type { GridRestoreStatePreProcessingContext } from '../hooks/features/statePersistence/gridStatePersistenceInterface';
|
|
66
67
|
export { useGridVirtualScroller, EMPTY_DETAIL_PANELS, } from '../hooks/features/virtualization/useGridVirtualScroller';
|
package/internals/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { useGridDensity, densityStateInitializer } from "../hooks/features/densi
|
|
|
22
22
|
export { useGridCsvExport } from "../hooks/features/export/useGridCsvExport.js";
|
|
23
23
|
export { useGridPrintExport } from "../hooks/features/export/useGridPrintExport.js";
|
|
24
24
|
export { useGridFilter, filterStateInitializer } from "../hooks/features/filter/useGridFilter.js";
|
|
25
|
+
export { defaultGridFilterLookup } from "../hooks/features/filter/gridFilterState.js";
|
|
25
26
|
export { passFilterLogic } from "../hooks/features/filter/gridFilterUtils.js";
|
|
26
27
|
export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector } from "../hooks/features/filter/gridFilterSelector.js";
|
|
27
28
|
export { isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
|
|
@@ -42,7 +43,6 @@ export { useGridParamsApi } from "../hooks/features/rows/useGridParamsApi.js";
|
|
|
42
43
|
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED } from "../hooks/features/rows/gridRowsUtils.js";
|
|
43
44
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
44
45
|
export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
|
|
45
|
-
export { calculatePinnedRowsHeight } from "../hooks/features/rows/gridRowsUtils.js";
|
|
46
46
|
export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
|
|
47
47
|
export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
|
|
48
48
|
export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
|
|
@@ -50,6 +50,7 @@ export { gridSortedRowIndexLookupSelector } from "../hooks/features/sorting/grid
|
|
|
50
50
|
export { useGridScroll } from "../hooks/features/scroll/useGridScroll.js";
|
|
51
51
|
export { useGridEvents } from "../hooks/features/events/useGridEvents.js";
|
|
52
52
|
export { dimensionsStateInitializer, useGridDimensions } from "../hooks/features/dimensions/useGridDimensions.js";
|
|
53
|
+
export * from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
53
54
|
export { useGridStatePersistence } from "../hooks/features/statePersistence/useGridStatePersistence.js";
|
|
54
55
|
export { useGridVirtualScroller, EMPTY_DETAIL_PANELS } from "../hooks/features/virtualization/useGridVirtualScroller.js";
|
|
55
56
|
export * from "../hooks/features/virtualization/index.js";
|
|
@@ -7,7 +7,7 @@ import { GridEditingApi, GridEditingPrivateApi } from './gridEditingApi';
|
|
|
7
7
|
import type { GridFilterApi } from './gridFilterApi';
|
|
8
8
|
import { GridFocusApi, GridFocusPrivateApi } from './gridFocusApi';
|
|
9
9
|
import type { GridLocaleTextApi } from './gridLocaleTextApi';
|
|
10
|
-
import type { GridParamsApi } from './gridParamsApi';
|
|
10
|
+
import type { GridParamsApi, GridParamsPrivateApi } from './gridParamsApi';
|
|
11
11
|
import { GridPreferencesPanelApi } from './gridPreferencesPanelApi';
|
|
12
12
|
import { GridPrintExportApi } from './gridPrintExportApi';
|
|
13
13
|
import { GridRowApi, GridRowProPrivateApi } from './gridRowApi';
|
|
@@ -31,7 +31,7 @@ import type { DataGridProcessedProps } from '../props/DataGridProps';
|
|
|
31
31
|
import type { GridColumnResizeApi } from '../../hooks/features/columnResize';
|
|
32
32
|
export interface GridApiCommon<GridState extends GridStateCommunity = any, GridInitialState extends GridInitialStateCommunity = any> extends GridCoreApi, GridPipeProcessingApi, GridDensityApi, GridDimensionsApi, GridRowApi, GridRowsMetaApi, GridEditingApi, GridParamsApi, GridColumnApi, GridRowSelectionApi, GridSortApi, GridPaginationApi, GridCsvExportApi, GridFocusApi, GridFilterApi, GridColumnMenuApi, GridPreferencesPanelApi, GridPrintExportApi, GridVirtualizationApi, GridLocaleTextApi, GridScrollApi, GridColumnSpanningApi, GridStateApi<GridState>, GridStatePersistenceApi<GridInitialState>, GridColumnGroupingApi, GridHeaderFilteringApi, GridColumnResizeApi {
|
|
33
33
|
}
|
|
34
|
-
export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon, Props extends DataGridProcessedProps> extends GridCorePrivateApi<Api, PrivateApi, Props>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi, GridHeaderFilteringPrivateApi, GridVirtualizationPrivateApi, GridRowProPrivateApi {
|
|
34
|
+
export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon, Props extends DataGridProcessedProps> extends GridCorePrivateApi<Api, PrivateApi, Props>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi, GridHeaderFilteringPrivateApi, GridVirtualizationPrivateApi, GridRowProPrivateApi, GridParamsPrivateApi {
|
|
35
35
|
}
|
|
36
36
|
export interface GridPrivateApiCommon extends GridApiCommon, GridPrivateOnlyApiCommon<GridApiCommon, GridPrivateApiCommon, DataGridProcessedProps> {
|
|
37
37
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { GridColDef } from '../colDef';
|
|
2
|
+
import { GridStateColDef } from '../colDef/gridColDef';
|
|
3
|
+
import { GridCellMode } from '../gridCell';
|
|
2
4
|
import { GridValidRowModel, GridRowId, GridTreeNode, GridRowModel } from '../gridRows';
|
|
3
5
|
import { GridCellParams } from '../params/gridCellParams';
|
|
4
6
|
import { GridColumnHeaderParams } from '../params/gridColumnHeaderParams';
|
|
@@ -33,10 +35,10 @@ export interface GridParamsApi {
|
|
|
33
35
|
*/
|
|
34
36
|
getRowFormattedValue: <V extends any = any>(row: GridRowModel, colDef: GridColDef) => V;
|
|
35
37
|
/**
|
|
36
|
-
* Gets the
|
|
38
|
+
* Gets the [[GridCellParams]] object that is passed as argument in events.
|
|
37
39
|
* @param {GridRowId} id The id of the row.
|
|
38
40
|
* @param {string} field The column field.
|
|
39
|
-
* @returns {
|
|
41
|
+
* @returns {GridCellParams} The cell params.
|
|
40
42
|
*/
|
|
41
43
|
getCellElement: (id: GridRowId, field: string) => HTMLDivElement | null;
|
|
42
44
|
/**
|
|
@@ -72,3 +74,28 @@ export interface GridParamsApi {
|
|
|
72
74
|
*/
|
|
73
75
|
getColumnHeaderParams: (field: string) => GridColumnHeaderParams;
|
|
74
76
|
}
|
|
77
|
+
export interface GridParamsPrivateApi {
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {Object} CellParamsOverrides
|
|
80
|
+
* @property {GridCellMode} cellMode - The mode of the cell.
|
|
81
|
+
* @property {GridStateColDef} colDef - The column definition.
|
|
82
|
+
* @property {boolean} hasFocus - Indicates if the cell is in focus.
|
|
83
|
+
* @property {GridTreeNode} rowNode - The node of the row that the current cell belongs to.
|
|
84
|
+
* @property {0|-1} tabIndex - The tabIndex value.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Used internally to render the cell based on existing row data provided by the GridRow.
|
|
88
|
+
* @param {GridRowId} id The id of the row.
|
|
89
|
+
* @param {string} field The column field.
|
|
90
|
+
* @param {GridValidRowModel} row The row model.
|
|
91
|
+
* @param {CellParamsOverrides} cellParams The cell params.
|
|
92
|
+
* @returns {GridCellParams} The cell params.
|
|
93
|
+
*/
|
|
94
|
+
getCellParamsForRow: <R extends GridValidRowModel = any, V = unknown, F = V, N extends GridTreeNode = GridTreeNode>(id: GridRowId, field: string, row: R, { cellMode, colDef, hasFocus, rowNode, tabIndex, }: {
|
|
95
|
+
cellMode: GridCellMode;
|
|
96
|
+
colDef: GridStateColDef;
|
|
97
|
+
hasFocus: boolean;
|
|
98
|
+
rowNode: N;
|
|
99
|
+
tabIndex: 0 | -1;
|
|
100
|
+
}) => GridCellParams<R, V, F, N>;
|
|
101
|
+
}
|
package/models/api/index.d.ts
CHANGED
package/models/api/index.js
CHANGED