@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.
Files changed (126) hide show
  1. package/CHANGELOG.md +96 -2
  2. package/DataGrid/DataGrid.js +5 -0
  3. package/DataGrid/useDataGridComponent.js +2 -0
  4. package/colDef/gridCheckboxSelectionColDef.js +1 -0
  5. package/components/GridDetailPanels.d.ts +2 -2
  6. package/components/GridPinnedRows.d.ts +2 -2
  7. package/components/GridRow.js +5 -0
  8. package/components/cell/GridCell.js +7 -5
  9. package/components/cell/GridEditSingleSelectCell.js +1 -1
  10. package/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
  11. package/components/columnsManagement/GridColumnsManagement.js +17 -5
  12. package/components/containers/GridRootStyles.d.ts +1 -1
  13. package/components/toolbarV8/Toolbar.d.ts +1 -1
  14. package/components/virtualization/GridVirtualScroller.js +5 -5
  15. package/constants/dataGridPropsDefaultValues.js +1 -0
  16. package/esm/DataGrid/DataGrid.js +5 -0
  17. package/esm/DataGrid/useDataGridComponent.js +2 -0
  18. package/esm/colDef/gridCheckboxSelectionColDef.js +1 -0
  19. package/esm/components/GridDetailPanels.d.ts +2 -2
  20. package/esm/components/GridPinnedRows.d.ts +2 -2
  21. package/esm/components/GridRow.js +5 -0
  22. package/esm/components/cell/GridCell.js +7 -5
  23. package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
  24. package/esm/components/columnsManagement/GridColumnsManagement.d.ts +6 -0
  25. package/esm/components/columnsManagement/GridColumnsManagement.js +17 -5
  26. package/esm/components/containers/GridRootStyles.d.ts +1 -1
  27. package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
  28. package/esm/components/virtualization/GridVirtualScroller.js +5 -5
  29. package/esm/constants/dataGridPropsDefaultValues.js +1 -0
  30. package/esm/hooks/core/useGridVirtualizer.d.ts +9 -0
  31. package/esm/hooks/core/useGridVirtualizer.js +223 -0
  32. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  33. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -2
  34. package/esm/hooks/features/columns/useGridColumnSpanning.js +5 -90
  35. package/esm/hooks/features/dimensions/useGridDimensions.js +18 -188
  36. package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
  37. package/esm/hooks/features/keyboardNavigation/utils.d.ts +3 -3
  38. package/esm/hooks/features/keyboardNavigation/utils.js +5 -5
  39. package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
  40. package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
  41. package/esm/hooks/features/pivoting/gridPivotingSelectors.js +1 -2
  42. package/esm/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
  43. package/esm/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
  44. package/esm/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
  45. package/esm/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
  46. package/esm/hooks/features/rows/useGridRowSpanning.js +54 -85
  47. package/esm/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  48. package/esm/hooks/features/rows/useGridRowsMeta.js +17 -187
  49. package/esm/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
  50. package/esm/hooks/features/virtualization/index.d.ts +1 -0
  51. package/esm/hooks/features/virtualization/index.js +1 -0
  52. package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
  53. package/esm/hooks/features/virtualization/useGridVirtualization.js +41 -22
  54. package/esm/hooks/utils/index.d.ts +1 -1
  55. package/esm/hooks/utils/index.js +1 -1
  56. package/esm/hooks/utils/useFirstRender.d.ts +1 -1
  57. package/esm/hooks/utils/useFirstRender.js +1 -8
  58. package/esm/index.js +1 -1
  59. package/esm/internals/index.d.ts +1 -1
  60. package/esm/internals/index.js +1 -1
  61. package/esm/internals/utils/getPinnedCellOffset.js +5 -0
  62. package/esm/locales/frFR.js +18 -21
  63. package/esm/locales/heIL.js +12 -12
  64. package/esm/locales/plPL.js +22 -24
  65. package/esm/models/api/gridApiCommon.d.ts +4 -1
  66. package/esm/models/api/gridColumnSpanning.d.ts +5 -11
  67. package/esm/models/props/DataGridProps.d.ts +5 -0
  68. package/esm/utils/roundToDecimalPlaces.d.ts +1 -1
  69. package/esm/utils/roundToDecimalPlaces.js +1 -3
  70. package/hooks/core/useGridVirtualizer.d.ts +9 -0
  71. package/hooks/core/useGridVirtualizer.js +231 -0
  72. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  73. package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -3
  74. package/hooks/features/columns/useGridColumnSpanning.js +5 -91
  75. package/hooks/features/dimensions/useGridDimensions.js +18 -188
  76. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
  77. package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
  78. package/hooks/features/keyboardNavigation/utils.js +5 -5
  79. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +0 -1
  80. package/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -4
  81. package/hooks/features/pivoting/gridPivotingSelectors.js +2 -3
  82. package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +2 -8
  83. package/hooks/features/rows/gridRowsMetaState.d.ts +2 -18
  84. package/hooks/features/rows/useGridRowAriaAttributes.js +3 -1
  85. package/hooks/features/rows/useGridRowSpanning.d.ts +2 -12
  86. package/hooks/features/rows/useGridRowSpanning.js +54 -85
  87. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  88. package/hooks/features/rows/useGridRowsMeta.js +15 -186
  89. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +1 -1
  90. package/hooks/features/virtualization/index.d.ts +1 -0
  91. package/hooks/features/virtualization/index.js +12 -0
  92. package/hooks/features/virtualization/useGridVirtualization.d.ts +5 -16
  93. package/hooks/features/virtualization/useGridVirtualization.js +42 -24
  94. package/hooks/utils/index.d.ts +1 -1
  95. package/hooks/utils/index.js +12 -12
  96. package/hooks/utils/useFirstRender.d.ts +1 -1
  97. package/hooks/utils/useFirstRender.js +11 -11
  98. package/index.js +1 -1
  99. package/internals/index.d.ts +1 -1
  100. package/internals/index.js +4 -11
  101. package/internals/utils/getPinnedCellOffset.js +5 -0
  102. package/locales/frFR.js +18 -21
  103. package/locales/heIL.js +12 -12
  104. package/locales/plPL.js +22 -24
  105. package/models/api/gridApiCommon.d.ts +4 -1
  106. package/models/api/gridColumnSpanning.d.ts +5 -11
  107. package/models/props/DataGridProps.d.ts +5 -0
  108. package/package.json +5 -5
  109. package/utils/roundToDecimalPlaces.d.ts +1 -1
  110. package/utils/roundToDecimalPlaces.js +7 -4
  111. package/esm/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
  112. package/esm/hooks/features/rows/gridRowSpanningSelectors.js +0 -5
  113. package/esm/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
  114. package/esm/hooks/features/virtualization/useGridVirtualScroller.js +0 -843
  115. package/esm/hooks/utils/useRunOnce.d.ts +0 -5
  116. package/esm/hooks/utils/useRunOnce.js +0 -18
  117. package/esm/utils/platform.d.ts +0 -1
  118. package/esm/utils/platform.js +0 -2
  119. package/hooks/features/rows/gridRowSpanningSelectors.d.ts +0 -10
  120. package/hooks/features/rows/gridRowSpanningSelectors.js +0 -11
  121. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +0 -56
  122. package/hooks/features/virtualization/useGridVirtualScroller.js +0 -854
  123. package/hooks/utils/useRunOnce.d.ts +0 -5
  124. package/hooks/utils/useRunOnce.js +0 -27
  125. package/utils/platform.d.ts +0 -1
  126. 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 _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
14
- var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
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 rootDimensionsRef = React.useRef(EMPTY_SIZE);
79
- const pinnedColumns = (0, _utils.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
80
- const densityFactor = (0, _utils.useGridSelector)(apiRef, _density.gridDensityFactorSelector);
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 = React.useCallback(root => {
84
+ const handleRootMount = root => {
231
85
  setCSSVariables(root, (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef));
232
- }, [apiRef]);
233
- const handleResize = React.useCallback(size => {
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
- if (isFirstSizing.current || !debouncedUpdateDimensions) {
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
  }
@@ -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, field, rowSpanScanDirection);
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 { GridColDef, GridRowId } from "../../../models/index.js";
3
- import { GridApiCommunity } from "../../../models/api/gridApiCommunity.js";
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<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
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, field, rowSpanScanDirection) {
47
- const rowSpanHiddenCells = (0, _gridRowSpanningSelectors.gridRowSpanningHiddenCellsSelector)(apiRef);
48
- if (!rowSpanHiddenCells[rowId]?.[field]) {
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]?.[field]) {
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.gridPivotPanelOpenSelector = exports.gridPivotInitialColumnsSelector = exports.gridPivotActiveSelector = void 0;
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);
@@ -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
- if (apiRef.current.isRowSelectable(rowNode.id)) {
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 type { GridColDef } from "../../../models/colDef/index.js";
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;