@mui/x-data-grid 8.9.1 → 8.9.2
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 +96 -2
- package/DataGrid/DataGrid.js +5 -0
- package/DataGrid/useDataGridComponent.js +2 -0
- package/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/components/GridDetailPanels.d.ts +2 -2
- package/components/GridPinnedRows.d.ts +2 -2
- package/components/GridRow.js +5 -0
- package/components/cell/GridCell.js +7 -5
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
- package/components/columnsManagement/GridColumnsManagement.js +17 -5
- package/components/containers/GridRootStyles.d.ts +1 -1
- package/components/toolbarV8/Toolbar.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +5 -5
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/DataGrid/DataGrid.js +5 -0
- package/esm/DataGrid/useDataGridComponent.js +2 -0
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -0
- package/esm/components/GridDetailPanels.d.ts +2 -2
- package/esm/components/GridPinnedRows.d.ts +2 -2
- package/esm/components/GridRow.js +5 -0
- package/esm/components/cell/GridCell.js +7 -5
- package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
- package/esm/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
- package/esm/components/columnsManagement/GridColumnsManagement.js +17 -5
- package/esm/components/containers/GridRootStyles.d.ts +1 -1
- package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
- package/esm/components/virtualization/GridVirtualScroller.js +5 -5
- package/esm/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/hooks/core/useGridVirtualizer.d.ts +9 -0
- package/esm/hooks/core/useGridVirtualizer.js +223 -0
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
- package/esm/hooks/features/columns/useGridColumnSpanning.js +5 -90
- package/esm/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/esm/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/esm/hooks/features/keyboardNavigation/utils.js +5 -5
- package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
- package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
- package/esm/hooks/features/pivoting/gridPivotingSelectors.js +1 -2
- package/esm/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
- package/esm/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
- package/esm/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
- package/esm/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
- package/esm/hooks/features/rows/useGridRowSpanning.js +54 -85
- package/esm/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/esm/hooks/features/rows/useGridRowsMeta.js +17 -187
- package/esm/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/esm/hooks/features/virtualization/index.d.ts +1 -0
- package/esm/hooks/features/virtualization/index.js +1 -0
- package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
- package/esm/hooks/features/virtualization/useGridVirtualization.js +41 -22
- package/esm/hooks/utils/index.d.ts +1 -1
- package/esm/hooks/utils/index.js +1 -1
- package/esm/hooks/utils/useFirstRender.d.ts +1 -1
- package/esm/hooks/utils/useFirstRender.js +1 -8
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/utils/getPinnedCellOffset.js +5 -0
- package/esm/locales/frFR.js +18 -21
- package/esm/locales/heIL.js +12 -12
- package/esm/locales/plPL.js +22 -24
- package/esm/models/api/gridApiCommon.d.ts +4 -1
- package/esm/models/api/gridColumnSpanning.d.ts +5 -11
- package/esm/models/props/DataGridProps.d.ts +5 -0
- package/esm/utils/roundToDecimalPlaces.d.ts +1 -1
- package/esm/utils/roundToDecimalPlaces.js +1 -3
- package/hooks/core/useGridVirtualizer.d.ts +9 -0
- package/hooks/core/useGridVirtualizer.js +231 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
- package/hooks/features/columns/useGridColumnSpanning.js +5 -91
- package/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/hooks/features/keyboardNavigation/utils.js +5 -5
- package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
- package/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
- package/hooks/features/pivoting/gridPivotingSelectors.js +2 -3
- package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
- package/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
- package/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
- package/hooks/features/rows/useGridRowSpanning.js +54 -85
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +15 -186
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
- package/hooks/features/virtualization/index.d.ts +1 -0
- package/hooks/features/virtualization/index.js +12 -0
- package/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
- package/hooks/features/virtualization/useGridVirtualization.js +42 -24
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +12 -12
- package/hooks/utils/useFirstRender.d.ts +1 -1
- package/hooks/utils/useFirstRender.js +11 -11
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +4 -11
- package/internals/utils/getPinnedCellOffset.js +5 -0
- package/locales/frFR.js +18 -21
- package/locales/heIL.js +12 -12
- package/locales/plPL.js +22 -24
- package/models/api/gridApiCommon.d.ts +4 -1
- package/models/api/gridColumnSpanning.d.ts +5 -11
- package/models/props/DataGridProps.d.ts +5 -0
- package/package.json +5 -5
- package/utils/roundToDecimalPlaces.d.ts +1 -1
- package/utils/roundToDecimalPlaces.js +7 -4
- package/esm/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
- package/esm/hooks/features/rows/gridRowSpanningSelectors.js +0 -5
- package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -843
- package/esm/hooks/utils/useRunOnce.d.ts +0 -5
- package/esm/hooks/utils/useRunOnce.js +0 -18
- package/esm/utils/platform.d.ts +0 -1
- package/esm/utils/platform.js +0 -2
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
- package/hooks/features/rows/gridRowSpanningSelectors.js +0 -11
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
- package/hooks/features/virtualization/useGridVirtualScroller.js +0 -854
- package/hooks/utils/useRunOnce.d.ts +0 -5
- package/hooks/utils/useRunOnce.js +0 -27
- package/utils/platform.d.ts +0 -1
- package/utils/platform.js +0 -8
|
@@ -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: RefObject<GridPrivateApiCommunity>,
|
|
10
|
+
export declare const useGridRowsMeta: (apiRef: RefObject<GridPrivateApiCommunity>, _props: Pick<DataGridProcessedProps, "getRowHeight" | "getEstimatedRowHeight" | "getRowSpacing" | "pagination" | "paginationMode" | "rowHeight">) => void;
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
-
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
|
-
import { ResizeObserver } from "../../../utils/ResizeObserver.js";
|
|
6
|
-
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
7
|
-
import { eslintUseValue } from "../../../utils/utils.js";
|
|
8
2
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
9
|
-
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
10
|
-
import { gridDensityFactorSelector } from "../density/densitySelector.js";
|
|
11
3
|
import { gridPaginationSelector } from "../pagination/gridPaginationSelector.js";
|
|
12
4
|
import { useGridRegisterPipeApplier } from "../../core/pipeProcessing/index.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { getValidRowHeight, getRowHeightWarning } from "./gridRowsUtils.js";
|
|
16
|
-
import { gridFocusedVirtualCellSelector } from "../virtualization/gridFocusedVirtualCellSelector.js";
|
|
17
|
-
/* eslint-disable no-underscore-dangle */
|
|
18
|
-
|
|
5
|
+
import { gridRowCountSelector } from "./gridRowsSelector.js";
|
|
6
|
+
import { gridRowHeightSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
19
7
|
export const rowsMetaStateInitializer = (state, props, apiRef) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
// FIXME: This should be handled in the virtualizer eventually, but there are interdependencies
|
|
9
|
+
// between state initializers that need to be untangled carefully.
|
|
10
|
+
|
|
23
11
|
const baseRowHeight = gridRowHeightSelector(apiRef);
|
|
24
12
|
const dataRowCount = gridRowCountSelector(apiRef);
|
|
25
13
|
const pagination = gridPaginationSelector(apiRef);
|
|
@@ -40,178 +28,20 @@ export const rowsMetaStateInitializer = (state, props, apiRef) => {
|
|
|
40
28
|
* @requires useGridPageSize (method)
|
|
41
29
|
* @requires useGridPage (method)
|
|
42
30
|
*/
|
|
43
|
-
export const useGridRowsMeta = (apiRef,
|
|
31
|
+
export const useGridRowsMeta = (apiRef, _props) => {
|
|
32
|
+
const virtualizer = apiRef.current.virtualizer;
|
|
44
33
|
const {
|
|
45
|
-
getRowHeight
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
56
|
-
const rowHeight = useGridSelector(apiRef, gridRowHeightSelector);
|
|
57
|
-
const getRowHeightEntry = rowId => {
|
|
58
|
-
let entry = heightCache.get(rowId);
|
|
59
|
-
if (entry === undefined) {
|
|
60
|
-
entry = {
|
|
61
|
-
content: rowHeight,
|
|
62
|
-
spacingTop: 0,
|
|
63
|
-
spacingBottom: 0,
|
|
64
|
-
detail: 0,
|
|
65
|
-
autoHeight: false,
|
|
66
|
-
needsFirstMeasurement: true
|
|
67
|
-
};
|
|
68
|
-
heightCache.set(rowId, entry);
|
|
69
|
-
}
|
|
70
|
-
return entry;
|
|
71
|
-
};
|
|
72
|
-
const processHeightEntry = React.useCallback(row => {
|
|
73
|
-
// HACK: rowHeight trails behind the most up-to-date value just enough to
|
|
74
|
-
// mess the initial rowsMeta hydration :/
|
|
75
|
-
const baseRowHeight = gridDimensionsSelector(apiRef).rowHeight;
|
|
76
|
-
eslintUseValue(rowHeight);
|
|
77
|
-
const entry = apiRef.current.getRowHeightEntry(row.id);
|
|
78
|
-
if (!getRowHeightProp) {
|
|
79
|
-
entry.content = baseRowHeight;
|
|
80
|
-
entry.needsFirstMeasurement = false;
|
|
81
|
-
} else {
|
|
82
|
-
const rowHeightFromUser = getRowHeightProp(_extends({}, row, {
|
|
83
|
-
densityFactor
|
|
84
|
-
}));
|
|
85
|
-
if (rowHeightFromUser === 'auto') {
|
|
86
|
-
if (entry.needsFirstMeasurement) {
|
|
87
|
-
const estimatedRowHeight = getEstimatedRowHeight ? getEstimatedRowHeight(_extends({}, row, {
|
|
88
|
-
densityFactor
|
|
89
|
-
})) : baseRowHeight;
|
|
90
|
-
|
|
91
|
-
// If the row was not measured yet use the estimated row height
|
|
92
|
-
entry.content = estimatedRowHeight ?? baseRowHeight;
|
|
93
|
-
}
|
|
94
|
-
hasRowWithAutoHeight.current = true;
|
|
95
|
-
entry.autoHeight = true;
|
|
96
|
-
} else {
|
|
97
|
-
// Default back to base rowHeight if getRowHeight returns invalid value.
|
|
98
|
-
entry.content = getValidRowHeight(rowHeightFromUser, baseRowHeight, getRowHeightWarning);
|
|
99
|
-
entry.needsFirstMeasurement = false;
|
|
100
|
-
entry.autoHeight = false;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (getRowSpacing) {
|
|
104
|
-
const indexRelativeToCurrentPage = apiRef.current.getRowIndexRelativeToVisibleRows(row.id);
|
|
105
|
-
const spacing = getRowSpacing(_extends({}, row, {
|
|
106
|
-
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
107
|
-
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
|
|
108
|
-
indexRelativeToCurrentPage
|
|
109
|
-
}));
|
|
110
|
-
entry.spacingTop = spacing.top ?? 0;
|
|
111
|
-
entry.spacingBottom = spacing.bottom ?? 0;
|
|
112
|
-
} else {
|
|
113
|
-
entry.spacingTop = 0;
|
|
114
|
-
entry.spacingBottom = 0;
|
|
115
|
-
}
|
|
116
|
-
apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row);
|
|
117
|
-
return entry;
|
|
118
|
-
}, [apiRef, currentPage.rows, getRowHeightProp, getEstimatedRowHeight, rowHeight, getRowSpacing, densityFactor]);
|
|
119
|
-
const hydrateRowsMeta = React.useCallback(() => {
|
|
120
|
-
hasRowWithAutoHeight.current = false;
|
|
121
|
-
const pinnedTopRowsTotalHeight = pinnedRows.top.reduce((acc, row) => {
|
|
122
|
-
const entry = processHeightEntry(row);
|
|
123
|
-
return acc + entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
|
|
124
|
-
}, 0);
|
|
125
|
-
const pinnedBottomRowsTotalHeight = pinnedRows.bottom.reduce((acc, row) => {
|
|
126
|
-
const entry = processHeightEntry(row);
|
|
127
|
-
return acc + entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
|
|
128
|
-
}, 0);
|
|
129
|
-
const positions = [];
|
|
130
|
-
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
131
|
-
positions.push(acc);
|
|
132
|
-
const entry = processHeightEntry(row);
|
|
133
|
-
const total = entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
|
|
134
|
-
return acc + total;
|
|
135
|
-
}, 0);
|
|
136
|
-
if (!hasRowWithAutoHeight.current) {
|
|
137
|
-
// No row has height=auto, so all rows are already measured
|
|
138
|
-
lastMeasuredRowIndex.current = Infinity;
|
|
139
|
-
}
|
|
140
|
-
const didHeightsChange = pinnedTopRowsTotalHeight !== apiRef.current.state.rowsMeta.pinnedTopRowsTotalHeight || pinnedBottomRowsTotalHeight !== apiRef.current.state.rowsMeta.pinnedBottomRowsTotalHeight || currentPageTotalHeight !== apiRef.current.state.rowsMeta.currentPageTotalHeight;
|
|
141
|
-
const rowsMeta = {
|
|
142
|
-
currentPageTotalHeight,
|
|
143
|
-
positions,
|
|
144
|
-
pinnedTopRowsTotalHeight,
|
|
145
|
-
pinnedBottomRowsTotalHeight
|
|
146
|
-
};
|
|
147
|
-
apiRef.current.setState(state => {
|
|
148
|
-
return _extends({}, state, {
|
|
149
|
-
rowsMeta
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
if (didHeightsChange) {
|
|
153
|
-
apiRef.current.updateDimensions();
|
|
154
|
-
}
|
|
155
|
-
isHeightMetaValid.current = true;
|
|
156
|
-
}, [apiRef, pinnedRows, currentPage.rows, processHeightEntry]);
|
|
157
|
-
const getRowHeight = rowId => {
|
|
158
|
-
return heightCache.get(rowId)?.content ?? rowHeight;
|
|
159
|
-
};
|
|
160
|
-
const storeRowHeightMeasurement = (id, height) => {
|
|
161
|
-
const entry = apiRef.current.getRowHeightEntry(id);
|
|
162
|
-
const didChange = entry.content !== height;
|
|
163
|
-
entry.needsFirstMeasurement = false;
|
|
164
|
-
entry.content = height;
|
|
165
|
-
isHeightMetaValid.current &&= !didChange;
|
|
166
|
-
};
|
|
167
|
-
const rowHasAutoHeight = id => {
|
|
168
|
-
return heightCache.get(id)?.autoHeight ?? false;
|
|
169
|
-
};
|
|
170
|
-
const getLastMeasuredRowIndex = () => {
|
|
171
|
-
return lastMeasuredRowIndex.current;
|
|
172
|
-
};
|
|
173
|
-
const setLastMeasuredRowIndex = index => {
|
|
174
|
-
if (hasRowWithAutoHeight.current && index > lastMeasuredRowIndex.current) {
|
|
175
|
-
lastMeasuredRowIndex.current = index;
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const resetRowHeights = () => {
|
|
179
|
-
heightCache.clear();
|
|
180
|
-
hydrateRowsMeta();
|
|
181
|
-
};
|
|
182
|
-
const resizeObserver = useLazyRef(() => new ResizeObserver(entries => {
|
|
183
|
-
for (let i = 0; i < entries.length; i += 1) {
|
|
184
|
-
const entry = entries[i];
|
|
185
|
-
const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
186
|
-
const rowId = entry.target.__mui_id;
|
|
187
|
-
const focusedVirtualRowId = gridFocusedVirtualCellSelector(apiRef)?.id;
|
|
188
|
-
if (focusedVirtualRowId === rowId && height === 0) {
|
|
189
|
-
// Focused virtual row has 0 height.
|
|
190
|
-
// We don't want to store it to avoid scroll jumping.
|
|
191
|
-
// https://github.com/mui/mui-x/issues/14726
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
|
|
195
|
-
}
|
|
196
|
-
if (!isHeightMetaValid.current) {
|
|
197
|
-
// Avoids "ResizeObserver loop completed with undelivered notifications" error
|
|
198
|
-
requestAnimationFrame(() => {
|
|
199
|
-
apiRef.current.requestPipeProcessorsApplication('rowHeight');
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
})).current;
|
|
203
|
-
const observeRowHeight = (element, rowId) => {
|
|
204
|
-
element.__mui_id = rowId;
|
|
205
|
-
resizeObserver.observe(element);
|
|
206
|
-
return () => resizeObserver.unobserve(element);
|
|
207
|
-
};
|
|
34
|
+
getRowHeight,
|
|
35
|
+
setLastMeasuredRowIndex,
|
|
36
|
+
storeRowHeightMeasurement,
|
|
37
|
+
resetRowHeights,
|
|
38
|
+
hydrateRowsMeta,
|
|
39
|
+
observeRowHeight,
|
|
40
|
+
rowHasAutoHeight,
|
|
41
|
+
getRowHeightEntry,
|
|
42
|
+
getLastMeasuredRowIndex
|
|
43
|
+
} = virtualizer.api.rowsMeta;
|
|
208
44
|
useGridRegisterPipeApplier(apiRef, 'rowHeight', hydrateRowsMeta);
|
|
209
|
-
|
|
210
|
-
// The effect is used to build the rows meta data - currentPageTotalHeight and positions.
|
|
211
|
-
// Because of variable row height this is needed for the virtualization
|
|
212
|
-
useEnhancedEffect(() => {
|
|
213
|
-
hydrateRowsMeta();
|
|
214
|
-
}, [hydrateRowsMeta]);
|
|
215
45
|
const rowsMetaApi = {
|
|
216
46
|
unstable_getRowHeight: getRowHeight,
|
|
217
47
|
unstable_setLastMeasuredRowIndex: setLastMeasuredRowIndex,
|
|
@@ -34,7 +34,7 @@ export declare const gridVirtualizationRowEnabledSelector: (args_0: import("reac
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const gridRenderContextSelector: (args_0: import("react").RefObject<{
|
|
36
36
|
state: GridStateCommunity;
|
|
37
|
-
} | null>) => import("@mui/x-
|
|
37
|
+
} | null>) => import("@mui/x-virtualizer/models").RenderContext;
|
|
38
38
|
/**
|
|
39
39
|
* Get the render context, with only columns filled in.
|
|
40
40
|
* This is cached, so it can be used to only re-render when the column interval changes.
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import {
|
|
2
|
+
import { Virtualization } from '@mui/x-virtualizer';
|
|
3
3
|
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
|
-
import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
5
4
|
import { GridStateInitializer } from "../../utils/useGridInitializeState.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
enabledForColumns: boolean;
|
|
10
|
-
enabledForRows: boolean;
|
|
11
|
-
renderContext: GridRenderContext;
|
|
12
|
-
};
|
|
13
|
-
export declare const EMPTY_RENDER_CONTEXT: {
|
|
14
|
-
firstRowIndex: number;
|
|
15
|
-
lastRowIndex: number;
|
|
16
|
-
firstColumnIndex: number;
|
|
17
|
-
lastColumnIndex: number;
|
|
18
|
-
};
|
|
5
|
+
import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
6
|
+
type RootProps = DataGridProcessedProps;
|
|
7
|
+
export type GridVirtualizationState = { [K in keyof Virtualization.State['virtualization']]: Virtualization.State['virtualization'][K] };
|
|
19
8
|
export declare const virtualizationStateInitializer: GridStateInitializer<RootProps>;
|
|
20
|
-
export declare function useGridVirtualization(apiRef: RefObject<GridPrivateApiCommunity>,
|
|
9
|
+
export declare function useGridVirtualization(apiRef: RefObject<GridPrivateApiCommunity>, rootProps: RootProps): void;
|
|
21
10
|
export {};
|
|
@@ -2,47 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import { EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
|
|
6
|
+
import { isJSDOM } from "../../../utils/isJSDOM.js";
|
|
5
7
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { useGridEventPriority } from "../../utils/index.js";
|
|
9
|
+
const HAS_LAYOUT = !isJSDOM;
|
|
10
|
+
|
|
11
|
+
// HACK: Typescript doesn't use the alias name ("GridVirtualizationState") and changes
|
|
12
|
+
// the autogenerated docs result, but this would otherwise be just:
|
|
13
|
+
// export type GridVirtualizationState = VirtualizationState;
|
|
14
|
+
|
|
15
|
+
// XXX: We want to use the virtualizer as the source of truth for its state, but this needs to
|
|
16
|
+
// stay because some parts of the grid require the `virtualization` state during initialization.
|
|
12
17
|
export const virtualizationStateInitializer = (state, props) => {
|
|
13
18
|
const {
|
|
14
19
|
disableVirtualization,
|
|
15
20
|
autoHeight
|
|
16
21
|
} = props;
|
|
17
22
|
const virtualization = {
|
|
18
|
-
enabled: !disableVirtualization,
|
|
19
|
-
enabledForColumns: !disableVirtualization,
|
|
20
|
-
enabledForRows: !disableVirtualization && !autoHeight,
|
|
23
|
+
enabled: !disableVirtualization && HAS_LAYOUT,
|
|
24
|
+
enabledForColumns: !disableVirtualization && HAS_LAYOUT,
|
|
25
|
+
enabledForRows: !disableVirtualization && !autoHeight && HAS_LAYOUT,
|
|
21
26
|
renderContext: EMPTY_RENDER_CONTEXT
|
|
22
27
|
};
|
|
23
28
|
return _extends({}, state, {
|
|
24
29
|
virtualization
|
|
25
30
|
});
|
|
26
31
|
};
|
|
27
|
-
export function useGridVirtualization(apiRef,
|
|
32
|
+
export function useGridVirtualization(apiRef, rootProps) {
|
|
33
|
+
const {
|
|
34
|
+
virtualizer
|
|
35
|
+
} = apiRef.current;
|
|
36
|
+
const {
|
|
37
|
+
autoHeight,
|
|
38
|
+
disableVirtualization
|
|
39
|
+
} = rootProps;
|
|
40
|
+
|
|
28
41
|
/*
|
|
29
42
|
* API METHODS
|
|
30
43
|
*/
|
|
31
44
|
|
|
32
45
|
const setVirtualization = enabled => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
46
|
+
enabled &&= HAS_LAYOUT;
|
|
47
|
+
virtualizer.store.set('virtualization', _extends({}, virtualizer.store.state.virtualization, {
|
|
48
|
+
enabled,
|
|
49
|
+
enabledForColumns: enabled,
|
|
50
|
+
enabledForRows: enabled && !autoHeight
|
|
39
51
|
}));
|
|
40
52
|
};
|
|
41
53
|
const setColumnVirtualization = enabled => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
54
|
+
enabled &&= HAS_LAYOUT;
|
|
55
|
+
virtualizer.store.set('virtualization', _extends({}, virtualizer.store.state.virtualization, {
|
|
56
|
+
enabledForColumns: enabled
|
|
46
57
|
}));
|
|
47
58
|
};
|
|
48
59
|
const api = {
|
|
@@ -50,14 +61,22 @@ export function useGridVirtualization(apiRef, props) {
|
|
|
50
61
|
unstable_setColumnVirtualization: setColumnVirtualization
|
|
51
62
|
};
|
|
52
63
|
useGridApiMethod(apiRef, api, 'public');
|
|
64
|
+
const forceUpdateRenderContext = virtualizer.api.forceUpdateRenderContext;
|
|
65
|
+
apiRef.current.register('private', {
|
|
66
|
+
updateRenderContext: forceUpdateRenderContext
|
|
67
|
+
});
|
|
53
68
|
|
|
54
69
|
/*
|
|
55
70
|
* EFFECTS
|
|
56
71
|
*/
|
|
57
72
|
|
|
73
|
+
useGridEventPriority(apiRef, 'sortedRowsSet', forceUpdateRenderContext);
|
|
74
|
+
useGridEventPriority(apiRef, 'paginationModelChange', forceUpdateRenderContext);
|
|
75
|
+
useGridEventPriority(apiRef, 'columnsChange', forceUpdateRenderContext);
|
|
76
|
+
|
|
58
77
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
59
78
|
React.useEffect(() => {
|
|
60
|
-
setVirtualization(!
|
|
61
|
-
}, [
|
|
79
|
+
setVirtualization(!rootProps.disableVirtualization);
|
|
80
|
+
}, [disableVirtualization, autoHeight]);
|
|
62
81
|
/* eslint-enable react-hooks/exhaustive-deps */
|
|
63
82
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from '@mui/x-internals/useRunOnce';
|
|
1
2
|
export { useGridEvent, useGridEventPriority, unstable_resetCleanupTracking } from "./useGridEvent.js";
|
|
2
3
|
export * from "./useGridApiMethod.js";
|
|
3
4
|
export * from "./useGridLogger.js";
|
|
@@ -5,6 +6,5 @@ export { useGridSelector } from "./useGridSelector.js";
|
|
|
5
6
|
export * from "./useGridNativeEventListener.js";
|
|
6
7
|
export * from "./useFirstRender.js";
|
|
7
8
|
export * from "./useOnMount.js";
|
|
8
|
-
export * from "./useRunOnce.js";
|
|
9
9
|
export * from "./useRunOncePerLoop.js";
|
|
10
10
|
export type { RenderProp } from '@mui/x-internals/useComponentRenderer';
|
package/esm/hooks/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from '@mui/x-internals/useRunOnce';
|
|
1
2
|
export { useGridEvent, useGridEventPriority, unstable_resetCleanupTracking } from "./useGridEvent.js";
|
|
2
3
|
export * from "./useGridApiMethod.js";
|
|
3
4
|
export * from "./useGridLogger.js";
|
|
@@ -5,5 +6,4 @@ export { useGridSelector } from "./useGridSelector.js";
|
|
|
5
6
|
export * from "./useGridNativeEventListener.js";
|
|
6
7
|
export * from "./useFirstRender.js";
|
|
7
8
|
export * from "./useOnMount.js";
|
|
8
|
-
export * from "./useRunOnce.js";
|
|
9
9
|
export * from "./useRunOncePerLoop.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@mui/x-internals/useFirstRender';
|
package/esm/index.js
CHANGED
package/esm/internals/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColum
|
|
|
12
12
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
13
13
|
export * from "../constants/signature.js";
|
|
14
14
|
export { vars } from "../constants/cssVariables.js";
|
|
15
|
+
export { useGridVirtualizer } from "../hooks/core/useGridVirtualizer.js";
|
|
15
16
|
export { propsStateInitializer } from "../hooks/core/useGridProps.js";
|
|
16
17
|
export { getGridFilter } from "../components/panel/filterPanel/GridFilterPanel.js";
|
|
17
18
|
export { getValueOptions } from "../components/panel/filterPanel/filterPanelUtils.js";
|
|
@@ -72,7 +73,6 @@ export { dimensionsStateInitializer, useGridDimensions } from "../hooks/features
|
|
|
72
73
|
export * from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
73
74
|
export { useGridStatePersistence } from "../hooks/features/statePersistence/useGridStatePersistence.js";
|
|
74
75
|
export type { GridRestoreStatePreProcessingContext } from "../hooks/features/statePersistence/gridStatePersistenceInterface.js";
|
|
75
|
-
export { useGridVirtualScroller, EMPTY_DETAIL_PANELS } from "../hooks/features/virtualization/useGridVirtualScroller.js";
|
|
76
76
|
export * from "../hooks/features/virtualization/index.js";
|
|
77
77
|
export { useGridColumnResize, columnResizeStateInitializer } from "../hooks/features/columnResize/useGridColumnResize.js";
|
|
78
78
|
export { ROW_SELECTION_PROPAGATION_DEFAULT } from "../hooks/features/rowSelection/utils.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColum
|
|
|
8
8
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
9
9
|
export * from "../constants/signature.js";
|
|
10
10
|
export { vars } from "../constants/cssVariables.js";
|
|
11
|
+
export { useGridVirtualizer } from "../hooks/core/useGridVirtualizer.js";
|
|
11
12
|
export { propsStateInitializer } from "../hooks/core/useGridProps.js";
|
|
12
13
|
export { getGridFilter } from "../components/panel/filterPanel/GridFilterPanel.js";
|
|
13
14
|
export { getValueOptions } from "../components/panel/filterPanel/filterPanelUtils.js";
|
|
@@ -58,7 +59,6 @@ export { useGridEvents } from "../hooks/features/events/useGridEvents.js";
|
|
|
58
59
|
export { dimensionsStateInitializer, useGridDimensions } from "../hooks/features/dimensions/useGridDimensions.js";
|
|
59
60
|
export * from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
60
61
|
export { useGridStatePersistence } from "../hooks/features/statePersistence/useGridStatePersistence.js";
|
|
61
|
-
export { useGridVirtualScroller, EMPTY_DETAIL_PANELS } from "../hooks/features/virtualization/useGridVirtualScroller.js";
|
|
62
62
|
export * from "../hooks/features/virtualization/index.js";
|
|
63
63
|
export { useGridColumnResize, columnResizeStateInitializer } from "../hooks/features/columnResize/useGridColumnResize.js";
|
|
64
64
|
export { ROW_SELECTION_PROPAGATION_DEFAULT } from "../hooks/features/rowSelection/utils.js";
|
|
@@ -12,5 +12,10 @@ export const getPinnedCellOffset = (pinnedPosition, computedWidth, columnIndex,
|
|
|
12
12
|
pinnedOffset = undefined;
|
|
13
13
|
break;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
// XXX: fix this properly
|
|
17
|
+
if (Number.isNaN(pinnedOffset)) {
|
|
18
|
+
pinnedOffset = undefined;
|
|
19
|
+
}
|
|
15
20
|
return pinnedOffset;
|
|
16
21
|
};
|
package/esm/locales/frFR.js
CHANGED
|
@@ -3,8 +3,8 @@ const frFRGrid = {
|
|
|
3
3
|
// Root
|
|
4
4
|
noRowsLabel: 'Pas de résultats',
|
|
5
5
|
noResultsOverlayLabel: 'Aucun résultat.',
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
noColumnsOverlayLabel: 'Aucune colonne',
|
|
7
|
+
noColumnsOverlayManageColumns: 'Gérer les colonnes',
|
|
8
8
|
// emptyPivotOverlayLabel: 'Add fields to rows, columns, and values to create a pivot table',
|
|
9
9
|
|
|
10
10
|
// Density selector toolbar button text
|
|
@@ -36,15 +36,13 @@ const frFRGrid = {
|
|
|
36
36
|
// toolbarPivot: 'Pivot',
|
|
37
37
|
|
|
38
38
|
// Toolbar AI Assistant button
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
toolbarAssistant: 'Assistant IA',
|
|
41
40
|
// Columns management text
|
|
42
41
|
columnsManagementSearchTitle: 'Rechercher',
|
|
43
42
|
columnsManagementNoColumns: 'Pas de colonnes',
|
|
44
43
|
columnsManagementShowHideAllText: 'Afficher/masquer toutes',
|
|
45
44
|
columnsManagementReset: 'Réinitialiser',
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
columnsManagementDeleteIconLabel: 'Effacer',
|
|
48
46
|
// Filter panel text
|
|
49
47
|
filterPanelAddFilter: 'Ajouter un filtre',
|
|
50
48
|
filterPanelRemoveAll: 'Tout supprimer',
|
|
@@ -100,15 +98,14 @@ const frFRGrid = {
|
|
|
100
98
|
'headerFilterOperator>=': 'Est supérieur ou égal à',
|
|
101
99
|
'headerFilterOperator<': 'Est inférieur à',
|
|
102
100
|
'headerFilterOperator<=': 'Est inférieur ou égal à',
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
headerFilterClear: 'Effacer le filtre',
|
|
105
102
|
// Filter values text
|
|
106
103
|
filterValueAny: 'tous',
|
|
107
104
|
filterValueTrue: 'vrai',
|
|
108
105
|
filterValueFalse: 'faux',
|
|
109
106
|
// Column menu text
|
|
110
107
|
columnMenuLabel: 'Menu',
|
|
111
|
-
|
|
108
|
+
columnMenuAriaLabel: columnName => `Menu pour la colonne ${columnName}`,
|
|
112
109
|
columnMenuShowColumns: 'Afficher les colonnes',
|
|
113
110
|
columnMenuManageColumns: 'Gérer les colonnes',
|
|
114
111
|
columnMenuFilter: 'Filtrer',
|
|
@@ -157,18 +154,18 @@ const frFRGrid = {
|
|
|
157
154
|
collapseDetailPanel: 'Masquer',
|
|
158
155
|
// Pagination
|
|
159
156
|
paginationRowsPerPage: 'Lignes par page :',
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
157
|
+
paginationDisplayedRows: ({
|
|
158
|
+
from,
|
|
159
|
+
to,
|
|
160
|
+
count,
|
|
161
|
+
estimated
|
|
162
|
+
}) => {
|
|
163
|
+
if (!estimated) {
|
|
164
|
+
return `${from}–${to} sur ${count !== -1 ? count : `plus de ${to}`}`;
|
|
165
|
+
}
|
|
166
|
+
const estimatedLabel = estimated && estimated > to ? `environ ${estimated}` : `plus de ${to}`;
|
|
167
|
+
return `${from}–${to} sur ${count !== -1 ? count : estimatedLabel}`;
|
|
168
|
+
},
|
|
172
169
|
paginationItemAriaLabel: type => {
|
|
173
170
|
if (type === 'first') {
|
|
174
171
|
return 'Aller à la première page';
|
package/esm/locales/heIL.js
CHANGED
|
@@ -156,18 +156,18 @@ const heILGrid = {
|
|
|
156
156
|
collapseDetailPanel: 'כווץ',
|
|
157
157
|
// Pagination
|
|
158
158
|
paginationRowsPerPage: 'שורות בעמוד:',
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
paginationDisplayedRows: ({
|
|
160
|
+
from,
|
|
161
|
+
to,
|
|
162
|
+
count,
|
|
163
|
+
estimated
|
|
164
|
+
}) => {
|
|
165
|
+
if (!estimated) {
|
|
166
|
+
return `${from}-${to} מתוך ${count !== -1 ? count : `יותר מ־${to}`}`;
|
|
167
|
+
}
|
|
168
|
+
const estimatedLabel = estimated && estimated > to ? `כ־${estimated}` : `יותר מ־${to}`;
|
|
169
|
+
return `${from}-${to} מתוך ${count !== -1 ? count : estimatedLabel}`;
|
|
170
|
+
},
|
|
171
171
|
paginationItemAriaLabel: type => {
|
|
172
172
|
if (type === 'first') {
|
|
173
173
|
return 'לעמוד הראשון';
|