@mui/x-data-grid 8.9.1 → 8.10.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 +217 -8
- 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/GridFooter.js +1 -1
- package/components/GridPagination.js +4 -3
- package/components/GridPinnedRows.d.ts +2 -2
- package/components/GridRow.js +8 -1
- 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/GridFooter.js +1 -1
- package/esm/components/GridPagination.js +3 -2
- package/esm/components/GridPinnedRows.d.ts +2 -2
- package/esm/components/GridRow.js +8 -1
- 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/dataSource/models.d.ts +11 -2
- package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +9 -2
- package/esm/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/esm/hooks/features/editing/useGridRowEditing.js +4 -1
- 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/rowReorder/gridRowReorderInterfaces.d.ts +9 -0
- package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.js +1 -0
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +5 -0
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +3 -0
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/esm/hooks/features/rowSelection/utils.js +5 -0
- 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 +3 -1
- package/esm/internals/index.js +2 -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/nnNO.js +96 -107
- package/esm/locales/plPL.js +22 -24
- package/esm/material/index.js +2 -2
- package/esm/models/api/gridApiCommon.d.ts +4 -1
- package/esm/models/api/gridColumnSpanning.d.ts +5 -11
- package/esm/models/gridStateCommunity.d.ts +2 -0
- 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/dataSource/models.d.ts +11 -2
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +10 -3
- package/hooks/features/dimensions/useGridDimensions.js +18 -188
- package/hooks/features/editing/useGridRowEditing.js +4 -1
- 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/rowReorder/gridRowReorderInterfaces.d.ts +9 -0
- package/hooks/features/rowReorder/gridRowReorderInterfaces.js +5 -0
- package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +5 -0
- package/hooks/features/rowReorder/gridRowReorderSelector.js +9 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/hooks/features/rowSelection/utils.js +5 -0
- 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 +3 -1
- package/internals/index.js +12 -11
- package/internals/utils/getPinnedCellOffset.js +5 -0
- package/locales/frFR.js +18 -21
- package/locales/heIL.js +12 -12
- package/locales/nnNO.js +96 -107
- package/locales/plPL.js +22 -24
- package/material/index.js +2 -2
- package/models/api/gridApiCommon.d.ts +4 -1
- package/models/api/gridColumnSpanning.d.ts +5 -11
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +5 -0
- package/package.json +5 -6
- 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
|
@@ -10,11 +10,8 @@ exports.dimensionsStateInitializer = void 0;
|
|
|
10
10
|
exports.useGridDimensions = useGridDimensions;
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
|
|
16
|
-
var _throttle = require("@mui/x-internals/throttle");
|
|
17
|
-
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
13
|
+
var _store = require("@mui/x-internals/store");
|
|
14
|
+
var _xVirtualizer = require("@mui/x-virtualizer");
|
|
18
15
|
var _useGridEvent = require("../../utils/useGridEvent");
|
|
19
16
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
20
17
|
var _createSelector = require("../../../utils/createSelector");
|
|
@@ -22,10 +19,6 @@ var _useGridLogger = require("../../utils/useGridLogger");
|
|
|
22
19
|
var _columns = require("../columns");
|
|
23
20
|
var _gridDimensionsSelectors = require("./gridDimensionsSelectors");
|
|
24
21
|
var _density = require("../density");
|
|
25
|
-
var _virtualization = require("../virtualization");
|
|
26
|
-
var _utils = require("../../utils");
|
|
27
|
-
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
28
|
-
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
29
22
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
30
23
|
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
31
24
|
var _dataGridPropsDefaultValues = require("../../../constants/dataGridPropsDefaultValues");
|
|
@@ -75,148 +68,10 @@ const columnsTotalWidthSelector = (0, _createSelector.createSelector)(_columns.g
|
|
|
75
68
|
function useGridDimensions(apiRef, props) {
|
|
76
69
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useResizeContainer');
|
|
77
70
|
const errorShown = React.useRef(false);
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const columnsTotalWidth = (0, _utils.useGridSelector)(apiRef, columnsTotalWidthSelector);
|
|
82
|
-
const isFirstSizing = React.useRef(true);
|
|
83
|
-
const {
|
|
84
|
-
rowHeight,
|
|
85
|
-
headerHeight,
|
|
86
|
-
groupHeaderHeight,
|
|
87
|
-
headerFilterHeight,
|
|
88
|
-
headersTotalHeight,
|
|
89
|
-
leftPinnedWidth,
|
|
90
|
-
rightPinnedWidth
|
|
91
|
-
} = getStaticDimensions(props, apiRef, densityFactor, pinnedColumns);
|
|
71
|
+
const virtualizer = apiRef.current.virtualizer;
|
|
72
|
+
const updateDimensions = virtualizer.api.updateDimensions;
|
|
73
|
+
const getViewportPageSize = virtualizer.api.getViewportPageSize;
|
|
92
74
|
const getRootDimensions = React.useCallback(() => (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef), [apiRef]);
|
|
93
|
-
const setDimensions = React.useCallback(dimensions => {
|
|
94
|
-
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
95
|
-
dimensions
|
|
96
|
-
}));
|
|
97
|
-
if (apiRef.current.rootElementRef.current) {
|
|
98
|
-
setCSSVariables(apiRef.current.rootElementRef.current, (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef));
|
|
99
|
-
}
|
|
100
|
-
}, [apiRef]);
|
|
101
|
-
const getViewportPageSize = React.useCallback(() => {
|
|
102
|
-
const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef);
|
|
103
|
-
if (!dimensions.isReady) {
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef);
|
|
107
|
-
|
|
108
|
-
// TODO: Use a combination of scrollTop, dimensions.viewportInnerSize.height and rowsMeta.possitions
|
|
109
|
-
// to find out the maximum number of rows that can fit in the visible part of the grid
|
|
110
|
-
if (props.getRowHeight) {
|
|
111
|
-
const renderContext = (0, _virtualization.gridRenderContextSelector)(apiRef);
|
|
112
|
-
const viewportPageSize = renderContext.lastRowIndex - renderContext.firstRowIndex;
|
|
113
|
-
return Math.min(viewportPageSize - 1, currentPage.rows.length);
|
|
114
|
-
}
|
|
115
|
-
const maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
|
|
116
|
-
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
117
|
-
}, [apiRef, props.getRowHeight, rowHeight]);
|
|
118
|
-
const updateDimensions = React.useCallback(() => {
|
|
119
|
-
if (isFirstSizing.current) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
123
|
-
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
124
|
-
// https://github.com/mui/mui-x/issues/15721
|
|
125
|
-
const scrollbarSize = measureScrollbarSize(apiRef.current.mainElementRef.current, props.scrollbarSize);
|
|
126
|
-
const rowsMeta = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef);
|
|
127
|
-
const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
|
|
128
|
-
const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
|
|
129
|
-
const contentSize = {
|
|
130
|
-
width: columnsTotalWidth,
|
|
131
|
-
height: (0, _roundToDecimalPlaces.roundToDecimalPlaces)(rowsMeta.currentPageTotalHeight, 1)
|
|
132
|
-
};
|
|
133
|
-
let viewportOuterSize;
|
|
134
|
-
let viewportInnerSize;
|
|
135
|
-
let hasScrollX = false;
|
|
136
|
-
let hasScrollY = false;
|
|
137
|
-
if (props.autoHeight) {
|
|
138
|
-
hasScrollY = false;
|
|
139
|
-
hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
|
|
140
|
-
viewportOuterSize = {
|
|
141
|
-
width: rootDimensionsRef.current.width,
|
|
142
|
-
height: topContainerHeight + bottomContainerHeight + contentSize.height
|
|
143
|
-
};
|
|
144
|
-
viewportInnerSize = {
|
|
145
|
-
width: Math.max(0, viewportOuterSize.width - (hasScrollY ? scrollbarSize : 0)),
|
|
146
|
-
height: Math.max(0, viewportOuterSize.height - (hasScrollX ? scrollbarSize : 0))
|
|
147
|
-
};
|
|
148
|
-
} else {
|
|
149
|
-
viewportOuterSize = {
|
|
150
|
-
width: rootDimensionsRef.current.width,
|
|
151
|
-
height: rootDimensionsRef.current.height
|
|
152
|
-
};
|
|
153
|
-
viewportInnerSize = {
|
|
154
|
-
width: Math.max(0, viewportOuterSize.width),
|
|
155
|
-
height: Math.max(0, viewportOuterSize.height - topContainerHeight - bottomContainerHeight)
|
|
156
|
-
};
|
|
157
|
-
const content = contentSize;
|
|
158
|
-
const container = viewportInnerSize;
|
|
159
|
-
const hasScrollXIfNoYScrollBar = content.width > container.width;
|
|
160
|
-
const hasScrollYIfNoXScrollBar = content.height > container.height;
|
|
161
|
-
if (hasScrollXIfNoYScrollBar || hasScrollYIfNoXScrollBar) {
|
|
162
|
-
hasScrollY = hasScrollYIfNoXScrollBar;
|
|
163
|
-
hasScrollX = content.width + (hasScrollY ? scrollbarSize : 0) > container.width;
|
|
164
|
-
|
|
165
|
-
// We recalculate the scroll y to consider the size of the x scrollbar.
|
|
166
|
-
if (hasScrollX) {
|
|
167
|
-
hasScrollY = content.height + scrollbarSize > container.height;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (hasScrollY) {
|
|
171
|
-
viewportInnerSize.width -= scrollbarSize;
|
|
172
|
-
}
|
|
173
|
-
if (hasScrollX) {
|
|
174
|
-
viewportInnerSize.height -= scrollbarSize;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const rowWidth = Math.max(viewportOuterSize.width, columnsTotalWidth + (hasScrollY ? scrollbarSize : 0));
|
|
178
|
-
const minimumSize = {
|
|
179
|
-
width: columnsTotalWidth,
|
|
180
|
-
height: topContainerHeight + contentSize.height + bottomContainerHeight
|
|
181
|
-
};
|
|
182
|
-
const newDimensions = {
|
|
183
|
-
isReady: true,
|
|
184
|
-
root: rootDimensionsRef.current,
|
|
185
|
-
viewportOuterSize,
|
|
186
|
-
viewportInnerSize,
|
|
187
|
-
contentSize,
|
|
188
|
-
minimumSize,
|
|
189
|
-
hasScrollX,
|
|
190
|
-
hasScrollY,
|
|
191
|
-
scrollbarSize,
|
|
192
|
-
headerHeight,
|
|
193
|
-
groupHeaderHeight,
|
|
194
|
-
headerFilterHeight,
|
|
195
|
-
rowWidth,
|
|
196
|
-
rowHeight,
|
|
197
|
-
columnsTotalWidth,
|
|
198
|
-
leftPinnedWidth,
|
|
199
|
-
rightPinnedWidth,
|
|
200
|
-
headersTotalHeight,
|
|
201
|
-
topContainerHeight,
|
|
202
|
-
bottomContainerHeight
|
|
203
|
-
};
|
|
204
|
-
const prevDimensions = apiRef.current.state.dimensions;
|
|
205
|
-
if ((0, _isDeepEqual.isDeepEqual)(prevDimensions, newDimensions)) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
setDimensions(newDimensions);
|
|
209
|
-
if (!areElementSizesEqual(newDimensions.viewportInnerSize, prevDimensions.viewportInnerSize)) {
|
|
210
|
-
apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
|
|
211
|
-
}
|
|
212
|
-
apiRef.current.updateRenderContext?.();
|
|
213
|
-
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
214
|
-
const updateDimensionCallback = (0, _useEventCallback.default)(updateDimensions);
|
|
215
|
-
const debouncedUpdateDimensions = React.useMemo(() => props.resizeThrottleMs > 0 ? (0, _throttle.throttle)(() => {
|
|
216
|
-
updateDimensionCallback();
|
|
217
|
-
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
218
|
-
}, props.resizeThrottleMs) : undefined, [apiRef, props.resizeThrottleMs, updateDimensionCallback]);
|
|
219
|
-
React.useEffect(() => debouncedUpdateDimensions?.clear, [debouncedUpdateDimensions]);
|
|
220
75
|
const apiPublic = {
|
|
221
76
|
getRootDimensions
|
|
222
77
|
};
|
|
@@ -224,14 +79,12 @@ function useGridDimensions(apiRef, props) {
|
|
|
224
79
|
updateDimensions,
|
|
225
80
|
getViewportPageSize
|
|
226
81
|
};
|
|
227
|
-
(0, _useEnhancedEffect.default)(updateDimensions, [updateDimensions]);
|
|
228
82
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, apiPublic, 'public');
|
|
229
83
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, apiPrivate, 'private');
|
|
230
|
-
const handleRootMount =
|
|
84
|
+
const handleRootMount = root => {
|
|
231
85
|
setCSSVariables(root, (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef));
|
|
232
|
-
}
|
|
233
|
-
const handleResize =
|
|
234
|
-
rootDimensionsRef.current = size;
|
|
86
|
+
};
|
|
87
|
+
const handleResize = size => {
|
|
235
88
|
if (size.height === 0 && !errorShown.current && !props.autoHeight && !_isJSDOM.isJSDOM) {
|
|
236
89
|
logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
237
90
|
errorShown.current = true;
|
|
@@ -240,17 +93,19 @@ function useGridDimensions(apiRef, props) {
|
|
|
240
93
|
logger.error(['The parent DOM element of the Data Grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
241
94
|
errorShown.current = true;
|
|
242
95
|
}
|
|
243
|
-
|
|
244
|
-
// We want to initialize the grid dimensions as soon as possible to avoid flickering
|
|
245
|
-
isFirstSizing.current = false;
|
|
246
|
-
updateDimensions();
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
debouncedUpdateDimensions();
|
|
250
|
-
}, [updateDimensions, props.autoHeight, debouncedUpdateDimensions, logger]);
|
|
96
|
+
};
|
|
251
97
|
(0, _useGridEvent.useGridEventPriority)(apiRef, 'rootMount', handleRootMount);
|
|
252
98
|
(0, _useGridEvent.useGridEventPriority)(apiRef, 'resize', handleResize);
|
|
253
99
|
(0, _useGridEvent.useGridEventPriority)(apiRef, 'debouncedResize', props.onResize);
|
|
100
|
+
(0, _store.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.dimensions, (previous, next) => {
|
|
101
|
+
if (apiRef.current.rootElementRef.current) {
|
|
102
|
+
setCSSVariables(apiRef.current.rootElementRef.current, next);
|
|
103
|
+
}
|
|
104
|
+
if (!areElementSizesEqual(next.viewportInnerSize, previous.viewportInnerSize)) {
|
|
105
|
+
apiRef.current.publishEvent('viewportInnerSizeChange', next.viewportInnerSize);
|
|
106
|
+
}
|
|
107
|
+
apiRef.current.publishEvent('debouncedResize', next.root);
|
|
108
|
+
});
|
|
254
109
|
}
|
|
255
110
|
function setCSSVariables(root, dimensions) {
|
|
256
111
|
const set = (k, v) => root.style.setProperty(k, v);
|
|
@@ -280,31 +135,6 @@ function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
|
|
|
280
135
|
rightPinnedWidth: pinnedColumnns.right.reduce((w, col) => w + col.computedWidth, 0)
|
|
281
136
|
};
|
|
282
137
|
}
|
|
283
|
-
const scrollbarSizeCache = new WeakMap();
|
|
284
|
-
function measureScrollbarSize(element, scrollbarSize) {
|
|
285
|
-
if (scrollbarSize !== undefined) {
|
|
286
|
-
return scrollbarSize;
|
|
287
|
-
}
|
|
288
|
-
if (element === null) {
|
|
289
|
-
return 0;
|
|
290
|
-
}
|
|
291
|
-
const cachedSize = scrollbarSizeCache.get(element);
|
|
292
|
-
if (cachedSize !== undefined) {
|
|
293
|
-
return cachedSize;
|
|
294
|
-
}
|
|
295
|
-
const doc = (0, _ownerDocument.default)(element);
|
|
296
|
-
const scrollDiv = doc.createElement('div');
|
|
297
|
-
scrollDiv.style.width = '99px';
|
|
298
|
-
scrollDiv.style.height = '99px';
|
|
299
|
-
scrollDiv.style.position = 'absolute';
|
|
300
|
-
scrollDiv.style.overflow = 'scroll';
|
|
301
|
-
scrollDiv.className = 'scrollDiv';
|
|
302
|
-
element.appendChild(scrollDiv);
|
|
303
|
-
const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
304
|
-
element.removeChild(scrollDiv);
|
|
305
|
-
scrollbarSizeCache.set(element, size);
|
|
306
|
-
return size;
|
|
307
|
-
}
|
|
308
138
|
function areElementSizesEqual(a, b) {
|
|
309
139
|
return a.width === b.width && a.height === b.height;
|
|
310
140
|
}
|
|
@@ -350,7 +350,10 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
350
350
|
if (fieldToFocus) {
|
|
351
351
|
apiRef.current.setCellFocus(id, fieldToFocus);
|
|
352
352
|
}
|
|
353
|
-
columns.filter(column =>
|
|
353
|
+
columns.filter(column => {
|
|
354
|
+
const isCellEditable = apiRef.current.getCellParams(id, column.field).isEditable;
|
|
355
|
+
return isCellEditable && column.editable && !!column.preProcessEditCellProps && deleteValue;
|
|
356
|
+
}).forEach(column => {
|
|
354
357
|
const field = column.field;
|
|
355
358
|
const value = apiRef.current.getCellValue(id, field);
|
|
356
359
|
const newValue = deleteValue ? (0, _utils2.getDefaultCellValue)(column) : initialValue ?? value;
|
|
@@ -65,7 +65,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
const field = (0, _gridColumnsSelector.gridVisibleColumnFieldsSelector)(apiRef)[colIndex];
|
|
68
|
-
const nonRowSpannedRowId = (0, _utils.findNonRowSpannedCell)(apiRef, rowId,
|
|
68
|
+
const nonRowSpannedRowId = (0, _utils.findNonRowSpannedCell)(apiRef, rowId, colIndex, rowSpanScanDirection);
|
|
69
69
|
// `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
70
70
|
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
71
71
|
const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === nonRowSpannedRowId);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { GridRowId } from "../../../models/index.js";
|
|
3
|
+
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
4
|
export declare const getLeftColumnIndex: ({
|
|
5
5
|
currentColIndex,
|
|
6
6
|
firstColIndex,
|
|
@@ -23,4 +23,4 @@ export declare const getRightColumnIndex: ({
|
|
|
23
23
|
lastColIndex: number;
|
|
24
24
|
isRtl: boolean;
|
|
25
25
|
}) => number | null;
|
|
26
|
-
export declare function findNonRowSpannedCell(apiRef: RefObject<
|
|
26
|
+
export declare function findNonRowSpannedCell(apiRef: RefObject<GridPrivateApiCommunity>, rowId: GridRowId, colIndex: number, rowSpanScanDirection: 'up' | 'down'): GridRowId;
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.findNonRowSpannedCell = findNonRowSpannedCell;
|
|
7
7
|
exports.getRightColumnIndex = exports.getLeftColumnIndex = void 0;
|
|
8
|
+
var _xVirtualizer = require("@mui/x-virtualizer");
|
|
8
9
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
9
|
-
var _gridRowSpanningSelectors = require("../rows/gridRowSpanningSelectors");
|
|
10
10
|
const getLeftColumnIndex = ({
|
|
11
11
|
currentColIndex,
|
|
12
12
|
firstColIndex,
|
|
@@ -43,9 +43,9 @@ const getRightColumnIndex = ({
|
|
|
43
43
|
return null;
|
|
44
44
|
};
|
|
45
45
|
exports.getRightColumnIndex = getRightColumnIndex;
|
|
46
|
-
function findNonRowSpannedCell(apiRef, rowId,
|
|
47
|
-
const rowSpanHiddenCells =
|
|
48
|
-
if (!rowSpanHiddenCells[rowId]?.[
|
|
46
|
+
function findNonRowSpannedCell(apiRef, rowId, colIndex, rowSpanScanDirection) {
|
|
47
|
+
const rowSpanHiddenCells = _xVirtualizer.Rowspan.selectors.hiddenCells(apiRef.current.virtualizer.store.state);
|
|
48
|
+
if (!rowSpanHiddenCells[rowId]?.[colIndex]) {
|
|
49
49
|
return rowId;
|
|
50
50
|
}
|
|
51
51
|
const filteredSortedRowIds = (0, _gridFilterSelector.gridFilteredSortedRowIdsSelector)(apiRef);
|
|
@@ -53,7 +53,7 @@ function findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection) {
|
|
|
53
53
|
let nextRowIndex = filteredSortedRowIds.indexOf(rowId) + (rowSpanScanDirection === 'down' ? 1 : -1);
|
|
54
54
|
while (nextRowIndex >= 0 && nextRowIndex < filteredSortedRowIds.length) {
|
|
55
55
|
const nextRowId = filteredSortedRowIds[nextRowIndex];
|
|
56
|
-
if (!rowSpanHiddenCells[nextRowId]?.[
|
|
56
|
+
if (!rowSpanHiddenCells[nextRowId]?.[colIndex]) {
|
|
57
57
|
return nextRowId;
|
|
58
58
|
}
|
|
59
59
|
nextRowIndex += rowSpanScanDirection === 'down' ? 1 : -1;
|
|
@@ -2,7 +2,6 @@ import type { GridRowModelUpdate } from '@mui/x-data-grid';
|
|
|
2
2
|
import type { GridColDef } from "../../../models/colDef/index.js";
|
|
3
3
|
export interface GridPivotingStatePartial {
|
|
4
4
|
active: boolean;
|
|
5
|
-
panelOpen: boolean;
|
|
6
5
|
initialColumns: Map<string, GridColDef> | undefined;
|
|
7
6
|
}
|
|
8
7
|
export interface GridPivotingPrivateApiCommunity {
|
|
@@ -5,7 +5,4 @@ export declare const gridPivotActiveSelector: (args_0: import("react").RefObject
|
|
|
5
5
|
} | null>) => boolean;
|
|
6
6
|
export declare const gridPivotInitialColumnsSelector: (args_0: import("react").RefObject<{
|
|
7
7
|
state: GridStateCommunity;
|
|
8
|
-
} | null>) => Map<string, GridColDef>;
|
|
9
|
-
export declare const gridPivotPanelOpenSelector: (args_0: import("react").RefObject<{
|
|
10
|
-
state: GridStateCommunity;
|
|
11
|
-
} | null>) => boolean;
|
|
8
|
+
} | null>) => Map<string, GridColDef>;
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.gridPivotInitialColumnsSelector = exports.gridPivotActiveSelector = void 0;
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
const gridPivotingStateSelector = (0, _createSelector.createRootSelector)(
|
|
9
9
|
// @ts-ignore
|
|
10
10
|
state => state.pivoting);
|
|
11
11
|
const gridPivotActiveSelector = exports.gridPivotActiveSelector = (0, _createSelector.createSelector)(gridPivotingStateSelector, pivoting => pivoting?.active);
|
|
12
12
|
const emptyColumns = new Map();
|
|
13
|
-
const gridPivotInitialColumnsSelector = exports.gridPivotInitialColumnsSelector = (0, _createSelector.createSelector)(gridPivotingStateSelector, pivoting => pivoting?.initialColumns || emptyColumns);
|
|
14
|
-
const gridPivotPanelOpenSelector = exports.gridPivotPanelOpenSelector = (0, _createSelector.createSelector)(gridPivotingStateSelector, pivoting => pivoting?.panelOpen);
|
|
13
|
+
const gridPivotInitialColumnsSelector = exports.gridPivotInitialColumnsSelector = (0, _createSelector.createSelector)(gridPivotingStateSelector, pivoting => pivoting?.initialColumns || emptyColumns);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
|
|
2
|
+
export declare const gridRowReorderStateSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, import("./gridRowReorderInterfaces.js").GridRowReorderState>;
|
|
3
|
+
export declare const gridIsRowDragActiveSelector: (args_0: import("react").RefObject<{
|
|
4
|
+
state: GridStateCommunity;
|
|
5
|
+
} | null>) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.gridRowReorderStateSelector = exports.gridIsRowDragActiveSelector = void 0;
|
|
7
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
8
|
+
const gridRowReorderStateSelector = exports.gridRowReorderStateSelector = (0, _createSelector.createRootSelector)(state => state.rowReorder);
|
|
9
|
+
const gridIsRowDragActiveSelector = exports.gridIsRowDragActiveSelector = (0, _createSelector.createSelector)(gridRowReorderStateSelector, rowReorder => rowReorder?.isActive ?? false);
|
|
@@ -51,7 +51,8 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
51
51
|
callback(...args);
|
|
52
52
|
}
|
|
53
53
|
}, [props.rowSelection]);
|
|
54
|
-
const
|
|
54
|
+
const isNestedData = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector) > 1;
|
|
55
|
+
const applyAutoSelection = props.signature !== _signature.GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants) && isNestedData;
|
|
55
56
|
const propRowSelectionModel = React.useMemo(() => {
|
|
56
57
|
return props.rowSelectionModel;
|
|
57
58
|
}, [props.rowSelectionModel]);
|
|
@@ -70,7 +71,6 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
70
71
|
} = props;
|
|
71
72
|
const canHaveMultipleSelection = (0, _utils.isMultipleRowSelectionEnabled)(props);
|
|
72
73
|
const tree = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowTreeSelector);
|
|
73
|
-
const isNestedData = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector) > 1;
|
|
74
74
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
75
75
|
let endId = id;
|
|
76
76
|
const startId = lastRowToggled.current ?? id;
|
|
@@ -144,6 +144,11 @@ const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, auto
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
|
+
// For root level rows, we don't need to traverse parents
|
|
148
|
+
const rowNode = tree[selectedRow];
|
|
149
|
+
if (!rowNode || rowNode.parent === _gridRowsUtils.GRID_ROOT_GROUP_ID) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
147
152
|
traverseParents(selectedRow);
|
|
148
153
|
}
|
|
149
154
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
+
import type { HeightEntry } from '@mui/x-virtualizer/models';
|
|
1
2
|
import { GridRowId } from "../../../models/gridRows.js";
|
|
2
|
-
export type HeightEntry
|
|
3
|
-
content: number;
|
|
4
|
-
spacingTop: number;
|
|
5
|
-
spacingBottom: number;
|
|
6
|
-
detail: number;
|
|
7
|
-
autoHeight: boolean;
|
|
8
|
-
needsFirstMeasurement: boolean;
|
|
9
|
-
};
|
|
3
|
+
export type { HeightEntry } from '@mui/x-virtualizer/models';
|
|
10
4
|
export type HeightCache = Map<GridRowId, HeightEntry>;
|
|
11
5
|
export interface GridRowsMetaInternalCache {
|
|
12
6
|
/**
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
+
import { RowsMetaState } from '@mui/x-virtualizer/models';
|
|
1
2
|
/**
|
|
2
3
|
* The grid rows total height and row positions.
|
|
3
4
|
*/
|
|
4
|
-
export interface GridRowsMetaState {
|
|
5
|
-
/**
|
|
6
|
-
* The sum of all visible grid rows in the current rows.
|
|
7
|
-
*/
|
|
8
|
-
currentPageTotalHeight: number;
|
|
9
|
-
/**
|
|
10
|
-
* The grid rows positions.
|
|
11
|
-
*/
|
|
12
|
-
positions: number[];
|
|
13
|
-
/**
|
|
14
|
-
* The total height of the pinned top rows.
|
|
15
|
-
*/
|
|
16
|
-
pinnedTopRowsTotalHeight: number;
|
|
17
|
-
/**
|
|
18
|
-
* The total height of the pinned bottom rows.
|
|
19
|
-
*/
|
|
20
|
-
pinnedBottomRowsTotalHeight: number;
|
|
21
|
-
}
|
|
5
|
+
export interface GridRowsMetaState extends RowsMetaState {}
|
|
@@ -16,7 +16,9 @@ const useGridRowAriaAttributes = () => {
|
|
|
16
16
|
const ariaAttributes = {};
|
|
17
17
|
const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
|
|
18
18
|
ariaAttributes['aria-rowindex'] = ariaRowIndex;
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
// XXX: fix this properly
|
|
21
|
+
if (rowNode && apiRef.current.isRowSelectable(rowNode.id)) {
|
|
20
22
|
ariaAttributes['aria-selected'] = apiRef.current.isRowSelected(rowNode.id);
|
|
21
23
|
}
|
|
22
24
|
return ariaAttributes;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import
|
|
3
|
-
import type { GridRowId } from "../../../models/gridRows.js";
|
|
2
|
+
import { RowSpanningState } from '@mui/x-virtualizer/models';
|
|
4
3
|
import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
5
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
6
5
|
import type { GridStateInitializer } from "../../utils/useGridInitializeState.js";
|
|
7
|
-
export interface GridRowSpanningState {
|
|
8
|
-
spannedCells: Record<GridRowId, Record<GridColDef['field'], number>>;
|
|
9
|
-
hiddenCells: Record<GridRowId, Record<GridColDef['field'], boolean>>;
|
|
10
|
-
/**
|
|
11
|
-
* For each hidden cell, it contains the row index corresponding to the cell that is
|
|
12
|
-
* the origin of the hidden cell. i.e. the cell which is spanned.
|
|
13
|
-
* Used by the virtualization to properly keep the spanned cells in view.
|
|
14
|
-
*/
|
|
15
|
-
hiddenCellOriginMap: Record<number, Record<GridColDef['field'], number>>;
|
|
16
|
-
}
|
|
6
|
+
export interface GridRowSpanningState extends RowSpanningState {}
|
|
17
7
|
export type RowRange = {
|
|
18
8
|
firstRowIndex: number;
|
|
19
9
|
lastRowIndex: number;
|