@mui/x-data-grid 6.10.1 → 6.11.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/DataGrid/DataGrid.d.ts +1 -1
  3. package/DataGrid/DataGrid.js +2 -1
  4. package/colDef/utils.d.ts +1 -1
  5. package/colDef/utils.js +1 -1
  6. package/components/GridRow.d.ts +2 -0
  7. package/components/GridRow.js +50 -22
  8. package/components/cell/GridCell.d.ts +2 -2
  9. package/components/cell/GridCell.js +95 -60
  10. package/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
  11. package/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  12. package/components/containers/GridMainContainer.js +10 -3
  13. package/components/containers/GridRoot.js +7 -13
  14. package/components/containers/GridRootStyles.js +1 -0
  15. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  16. package/hooks/features/columns/gridColumnsUtils.js +2 -2
  17. package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  18. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +7 -4
  19. package/hooks/features/virtualization/useGridVirtualScroller.js +75 -8
  20. package/hooks/utils/useGridAriaAttributes.d.ts +6 -0
  21. package/hooks/utils/useGridAriaAttributes.js +25 -0
  22. package/index.js +1 -1
  23. package/internals/index.d.ts +1 -1
  24. package/internals/index.js +1 -1
  25. package/legacy/DataGrid/DataGrid.js +2 -1
  26. package/legacy/colDef/utils.js +1 -1
  27. package/legacy/components/GridRow.js +47 -21
  28. package/legacy/components/cell/GridCell.js +95 -60
  29. package/legacy/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
  30. package/legacy/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  31. package/legacy/components/containers/GridMainContainer.js +10 -3
  32. package/legacy/components/containers/GridRoot.js +7 -13
  33. package/legacy/components/containers/GridRootStyles.js +1 -0
  34. package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
  35. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  36. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +79 -8
  37. package/legacy/hooks/utils/useGridAriaAttributes.js +25 -0
  38. package/legacy/index.js +1 -1
  39. package/legacy/internals/index.js +1 -1
  40. package/legacy/locales/fiFI.js +29 -31
  41. package/legacy/locales/heIL.js +26 -29
  42. package/legacy/locales/itIT.js +34 -38
  43. package/locales/fiFI.js +29 -31
  44. package/locales/heIL.js +26 -29
  45. package/locales/itIT.js +34 -38
  46. package/models/gridFilterOperator.d.ts +1 -1
  47. package/models/props/DataGridProps.d.ts +7 -1
  48. package/modern/DataGrid/DataGrid.js +2 -1
  49. package/modern/colDef/utils.js +1 -1
  50. package/modern/components/GridRow.js +50 -22
  51. package/modern/components/cell/GridCell.js +92 -57
  52. package/modern/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
  53. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  54. package/modern/components/containers/GridMainContainer.js +9 -3
  55. package/modern/components/containers/GridRoot.js +6 -13
  56. package/modern/components/containers/GridRootStyles.js +1 -0
  57. package/modern/hooks/features/columns/gridColumnsUtils.js +2 -2
  58. package/modern/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  59. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +75 -8
  60. package/modern/hooks/utils/useGridAriaAttributes.js +24 -0
  61. package/modern/index.js +1 -1
  62. package/modern/internals/index.js +1 -1
  63. package/modern/locales/fiFI.js +29 -31
  64. package/modern/locales/heIL.js +26 -29
  65. package/modern/locales/itIT.js +34 -38
  66. package/node/DataGrid/DataGrid.js +2 -1
  67. package/node/colDef/utils.js +1 -1
  68. package/node/components/GridRow.js +50 -22
  69. package/node/components/cell/GridCell.js +92 -57
  70. package/node/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
  71. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  72. package/node/components/containers/GridMainContainer.js +10 -3
  73. package/node/components/containers/GridRoot.js +6 -13
  74. package/node/components/containers/GridRootStyles.js +1 -0
  75. package/node/hooks/features/columns/gridColumnsUtils.js +1 -1
  76. package/node/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  77. package/node/hooks/features/virtualization/useGridVirtualScroller.js +75 -8
  78. package/node/hooks/utils/useGridAriaAttributes.js +31 -0
  79. package/node/index.js +1 -1
  80. package/node/internals/index.js +7 -0
  81. package/node/locales/fiFI.js +29 -31
  82. package/node/locales/heIL.js +26 -29
  83. package/node/locales/itIT.js +34 -38
  84. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
3
+ const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -64,10 +64,14 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
64
64
  position,
65
65
  rowHeight,
66
66
  className,
67
+ visibleColumns,
67
68
  renderedColumns,
68
69
  containerWidth,
69
70
  firstColumnToRender,
70
71
  isLastVisible = false,
72
+ focusedCellColumnIndexNotInRange,
73
+ isNotVisible,
74
+ focusedCell,
71
75
  onClick,
72
76
  onDoubleClick,
73
77
  onMouseEnter,
@@ -173,7 +177,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
173
177
 
174
178
  // User clicked a button from the "actions" column type
175
179
  const column = apiRef.current.getColumn(field);
176
- if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
180
+ if (column?.type === GRID_ACTIONS_COLUMN_TYPE) {
177
181
  return;
178
182
  }
179
183
  }
@@ -189,6 +193,10 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
189
193
  const getCell = (column, cellProps) => {
190
194
  const disableDragEvents = disableColumnReorder && column.disableReorder || !rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
191
195
  const editCellState = editRowsState[rowId]?.[column.field] ?? null;
196
+ let cellIsNotVisible = false;
197
+ if (focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
198
+ cellIsNotVisible = true;
199
+ }
192
200
  return /*#__PURE__*/_jsx(CellComponent, _extends({
193
201
  column: column,
194
202
  width: cellProps.width,
@@ -199,7 +207,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
199
207
  colIndex: cellProps.indexRelativeToAllColumns,
200
208
  colSpan: cellProps.colSpan,
201
209
  disableDragEvents: disableDragEvents,
202
- editCellState: editCellState
210
+ editCellState: editCellState,
211
+ isNotVisible: cellIsNotVisible
203
212
  }, slotProps?.cell), column.field);
204
213
  };
205
214
  const sizes = useGridSelector(apiRef, () => _extends({}, apiRef.current.unstable_getRowInternalSizes(rowId)), objectShallowCompare);
@@ -221,25 +230,35 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
221
230
  minHeight = maximumSize;
222
231
  }
223
232
  }
224
- const style = _extends({}, styleProp, {
225
- maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
226
- // max-height doesn't support "auto"
227
- minHeight
228
- });
229
- if (sizes?.spacingTop) {
230
- const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
231
- style[property] = sizes.spacingTop;
232
- }
233
- if (sizes?.spacingBottom) {
234
- const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
235
- let propertyValue = style[property];
236
- // avoid overriding existing value
237
- if (typeof propertyValue !== 'number') {
238
- propertyValue = parseInt(propertyValue || '0', 10);
233
+ const style = React.useMemo(() => {
234
+ if (isNotVisible) {
235
+ return {
236
+ opacity: 0,
237
+ width: 0,
238
+ height: 0
239
+ };
239
240
  }
240
- propertyValue += sizes.spacingBottom;
241
- style[property] = propertyValue;
242
- }
241
+ const rowStyle = _extends({}, styleProp, {
242
+ maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
243
+ // max-height doesn't support "auto"
244
+ minHeight
245
+ });
246
+ if (sizes?.spacingTop) {
247
+ const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
248
+ rowStyle[property] = sizes.spacingTop;
249
+ }
250
+ if (sizes?.spacingBottom) {
251
+ const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
252
+ let propertyValue = rowStyle[property];
253
+ // avoid overriding existing value
254
+ if (typeof propertyValue !== 'number') {
255
+ propertyValue = parseInt(propertyValue || '0', 10);
256
+ }
257
+ propertyValue += sizes.spacingBottom;
258
+ rowStyle[property] = propertyValue;
259
+ }
260
+ return rowStyle;
261
+ }, [isNotVisible, rowHeight, styleProp, minHeight, sizes, rootProps.rowSpacingType]);
243
262
  const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
244
263
  if (typeof rootProps.getRowClassName === 'function') {
245
264
  const indexRelativeToCurrentPage = index - (currentPage.range?.firstRowIndex || 0);
@@ -259,7 +278,14 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
259
278
  const cells = [];
260
279
  for (let i = 0; i < renderedColumns.length; i += 1) {
261
280
  const column = renderedColumns[i];
262
- const indexRelativeToAllColumns = firstColumnToRender + i;
281
+ let indexRelativeToAllColumns = firstColumnToRender + i;
282
+ if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) {
283
+ if (visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
284
+ indexRelativeToAllColumns = focusedCellColumnIndexNotInRange;
285
+ } else {
286
+ indexRelativeToAllColumns -= 1;
287
+ }
288
+ }
263
289
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
264
290
  if (cellColSpanInfo && !cellColSpanInfo.spannedByColSpan) {
265
291
  if (rowType !== 'skeletonRow') {
@@ -322,12 +348,14 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
322
348
  * If `null`, no cell in this row has focus.
323
349
  */
324
350
  focusedCell: PropTypes.string,
351
+ focusedCellColumnIndexNotInRange: PropTypes.number,
325
352
  /**
326
353
  * Index of the row in the whole sorted and filtered dataset.
327
354
  * If some rows above have expanded children, this index also take those children into account.
328
355
  */
329
356
  index: PropTypes.number.isRequired,
330
357
  isLastVisible: PropTypes.bool,
358
+ isNotVisible: PropTypes.bool,
331
359
  lastColumnToRender: PropTypes.number.isRequired,
332
360
  onClick: PropTypes.func,
333
361
  onDoubleClick: PropTypes.func,
@@ -1,10 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["changeReason", "unstable_updateValueOnRender"],
4
- _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
- _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
4
+ _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
+ _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
6
6
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
7
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
8
7
  import * as React from 'react';
9
8
  import PropTypes from 'prop-types';
10
9
  import clsx from 'clsx';
@@ -176,6 +175,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
176
175
  showRightBorder,
177
176
  colSpan,
178
177
  disableDragEvents,
178
+ isNotVisible,
179
179
  onClick,
180
180
  onDoubleClick,
181
181
  onMouseDown,
@@ -226,13 +226,23 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
226
226
  propHandler(event);
227
227
  }
228
228
  }, [apiRef, field, rowId]);
229
- const style = {
230
- minWidth: width,
231
- maxWidth: width,
232
- minHeight: height,
233
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
234
- };
229
+ const style = React.useMemo(() => {
230
+ if (isNotVisible) {
231
+ return {
232
+ padding: 0,
233
+ opacity: 0,
234
+ width: 0
235
+ };
236
+ }
237
+ const cellStyle = {
238
+ minWidth: width,
239
+ maxWidth: width,
240
+ minHeight: height,
241
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
242
+ };
235
243
 
244
+ return cellStyle;
245
+ }, [width, height, isNotVisible]);
236
246
  React.useEffect(() => {
237
247
  if (!hasFocus || cellMode === GridCellModes.Edit) {
238
248
  return;
@@ -275,6 +285,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
275
285
  children = /*#__PURE__*/_jsx("div", {
276
286
  className: classes.content,
277
287
  title: valueString,
288
+ role: "presentation",
278
289
  children: valueString
279
290
  });
280
291
  }
@@ -287,27 +298,32 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
287
298
  onDragEnter: publish('cellDragEnter', onDragEnter),
288
299
  onDragOver: publish('cellDragOver', onDragOver)
289
300
  };
290
- return /*#__PURE__*/_jsx("div", _extends({
291
- ref: handleRef,
292
- className: clsx(className, classes.root),
293
- role: "cell",
294
- "data-field": field,
295
- "data-colindex": colIndex,
296
- "aria-colindex": colIndex + 1,
297
- "aria-colspan": colSpan,
298
- style: style,
299
- tabIndex: tabIndex,
300
- onClick: publish('cellClick', onClick),
301
- onDoubleClick: publish('cellDoubleClick', onDoubleClick),
302
- onMouseOver: publish('cellMouseOver', onMouseOver),
303
- onMouseDown: publishMouseDown('cellMouseDown'),
304
- onMouseUp: publishMouseUp('cellMouseUp'),
305
- onKeyDown: publish('cellKeyDown', onKeyDown),
306
- onKeyUp: publish('cellKeyUp', onKeyUp)
307
- }, draggableEventHandlers, other, {
308
- onFocus: handleFocus,
309
- children: children
310
- }));
301
+ const ariaV7 = rootProps.experimentalFeatures?.ariaV7;
302
+ return (
303
+ /*#__PURE__*/
304
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
305
+ _jsx("div", _extends({
306
+ ref: handleRef,
307
+ className: clsx(className, classes.root),
308
+ role: ariaV7 ? 'gridcell' : 'cell',
309
+ "data-field": field,
310
+ "data-colindex": colIndex,
311
+ "aria-colindex": colIndex + 1,
312
+ "aria-colspan": colSpan,
313
+ style: style,
314
+ tabIndex: tabIndex,
315
+ onClick: publish('cellClick', onClick),
316
+ onDoubleClick: publish('cellDoubleClick', onDoubleClick),
317
+ onMouseOver: publish('cellMouseOver', onMouseOver),
318
+ onMouseDown: publishMouseDown('cellMouseDown'),
319
+ onMouseUp: publishMouseUp('cellMouseUp'),
320
+ onKeyDown: publish('cellKeyDown', onKeyDown),
321
+ onKeyUp: publish('cellKeyUp', onKeyUp)
322
+ }, draggableEventHandlers, other, {
323
+ onFocus: handleFocus,
324
+ children: children
325
+ }))
326
+ );
311
327
  });
312
328
  const MemoizedCellWrapper = fastMemo(GridCellWrapper);
313
329
  process.env.NODE_ENV !== "production" ? GridCellWrapper.propTypes = {
@@ -352,6 +368,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
352
368
  isValidating: PropTypes.bool,
353
369
  value: PropTypes.any
354
370
  }),
371
+ isNotVisible: PropTypes.bool,
355
372
  height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
356
373
  onClick: PropTypes.func,
357
374
  onDoubleClick: PropTypes.func,
@@ -378,6 +395,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
378
395
  showRightBorder,
379
396
  colSpan,
380
397
  disableDragEvents,
398
+ isNotVisible,
381
399
  onClick,
382
400
  onDoubleClick,
383
401
  onMouseDown,
@@ -472,13 +490,23 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
472
490
  propHandler(event);
473
491
  }
474
492
  }, [apiRef, field, rowId]);
475
- const style = {
476
- minWidth: width,
477
- maxWidth: width,
478
- minHeight: height,
479
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
480
- };
493
+ const style = React.useMemo(() => {
494
+ if (isNotVisible) {
495
+ return {
496
+ padding: 0,
497
+ opacity: 0,
498
+ width: 0
499
+ };
500
+ }
501
+ const cellStyle = {
502
+ minWidth: width,
503
+ maxWidth: width,
504
+ minHeight: height,
505
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
506
+ };
481
507
 
508
+ return cellStyle;
509
+ }, [width, height, isNotVisible]);
482
510
  React.useEffect(() => {
483
511
  if (!hasFocus || cellMode === GridCellModes.Edit) {
484
512
  return;
@@ -540,6 +568,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
540
568
  children = /*#__PURE__*/_jsx("div", {
541
569
  className: classes.content,
542
570
  title: valueString,
571
+ role: "presentation",
543
572
  children: valueString
544
573
  });
545
574
  }
@@ -552,27 +581,32 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
552
581
  onDragEnter: publish('cellDragEnter', onDragEnter),
553
582
  onDragOver: publish('cellDragOver', onDragOver)
554
583
  };
555
- return /*#__PURE__*/_jsx("div", _extends({
556
- ref: handleRef,
557
- className: clsx(className, classNames, classes.root),
558
- role: "cell",
559
- "data-field": field,
560
- "data-colindex": colIndex,
561
- "aria-colindex": colIndex + 1,
562
- "aria-colspan": colSpan,
563
- style: style,
564
- tabIndex: tabIndex,
565
- onClick: publish('cellClick', onClick),
566
- onDoubleClick: publish('cellDoubleClick', onDoubleClick),
567
- onMouseOver: publish('cellMouseOver', onMouseOver),
568
- onMouseDown: publishMouseDown('cellMouseDown'),
569
- onMouseUp: publishMouseUp('cellMouseUp'),
570
- onKeyDown: publish('cellKeyDown', onKeyDown),
571
- onKeyUp: publish('cellKeyUp', onKeyUp)
572
- }, draggableEventHandlers, other, {
573
- onFocus: handleFocus,
574
- children: children
575
- }));
584
+ const ariaV7 = rootProps.experimentalFeatures?.ariaV7;
585
+ return (
586
+ /*#__PURE__*/
587
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
588
+ _jsx("div", _extends({
589
+ ref: handleRef,
590
+ className: clsx(className, classNames, classes.root),
591
+ role: ariaV7 ? 'gridcell' : 'cell',
592
+ "data-field": field,
593
+ "data-colindex": colIndex,
594
+ "aria-colindex": colIndex + 1,
595
+ "aria-colspan": colSpan,
596
+ style: style,
597
+ tabIndex: tabIndex,
598
+ onClick: publish('cellClick', onClick),
599
+ onDoubleClick: publish('cellDoubleClick', onDoubleClick),
600
+ onMouseOver: publish('cellMouseOver', onMouseOver),
601
+ onMouseDown: publishMouseDown('cellMouseDown'),
602
+ onMouseUp: publishMouseUp('cellMouseUp'),
603
+ onKeyDown: publish('cellKeyDown', onKeyDown),
604
+ onKeyUp: publish('cellKeyUp', onKeyUp)
605
+ }, draggableEventHandlers, other, {
606
+ onFocus: handleFocus,
607
+ children: children
608
+ }))
609
+ );
576
610
  });
577
611
  process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
578
612
  // ----------------------------- Warning --------------------------------
@@ -592,6 +626,7 @@ process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
592
626
  value: PropTypes.any
593
627
  }),
594
628
  height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
629
+ isNotVisible: PropTypes.bool,
595
630
  onClick: PropTypes.func,
596
631
  onDoubleClick: PropTypes.func,
597
632
  onDragEnter: PropTypes.func,
@@ -42,5 +42,7 @@ export const GridBaseColumnHeaders = /*#__PURE__*/React.forwardRef(function Grid
42
42
  ref: ref,
43
43
  className: clsx(className, classes.root),
44
44
  ownerState: rootProps
45
- }, other));
45
+ }, other, {
46
+ role: "presentation"
47
+ }));
46
48
  });
@@ -75,10 +75,12 @@ const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridG
75
75
  }, other, {
76
76
  children: [/*#__PURE__*/_jsxs("div", _extends({
77
77
  className: classes.draggableContainer,
78
- draggable: isDraggable
78
+ draggable: isDraggable,
79
+ role: "presentation"
79
80
  }, draggableContainerProps, {
80
81
  children: [/*#__PURE__*/_jsxs("div", {
81
82
  className: classes.titleContainer,
83
+ role: "presentation",
82
84
  children: [/*#__PURE__*/_jsx("div", {
83
85
  className: classes.titleContainerContent,
84
86
  children: headerComponent !== undefined ? headerComponent : /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
@@ -1,8 +1,10 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
3
4
  import { styled } from '@mui/system';
4
5
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
5
6
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
7
+ import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
6
8
  import { jsx as _jsx } from "react/jsx-runtime";
7
9
  const useUtilityClasses = ownerState => {
8
10
  const {
@@ -27,10 +29,14 @@ const GridMainContainerRoot = styled('div', {
27
29
  export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
28
30
  const rootProps = useGridRootProps();
29
31
  const classes = useUtilityClasses(rootProps);
30
- return /*#__PURE__*/_jsx(GridMainContainerRoot, {
32
+ const getAriaAttributes = rootProps.experimentalFeatures?.ariaV7 // ariaV7 should never change
33
+ ? useGridAriaAttributes : null;
34
+ const ariaAttributes = typeof getAriaAttributes === 'function' ? getAriaAttributes() : null;
35
+ return /*#__PURE__*/_jsx(GridMainContainerRoot, _extends({
31
36
  ref: ref,
32
37
  className: classes.root,
33
- ownerState: rootProps,
38
+ ownerState: rootProps
39
+ }, ariaAttributes, {
34
40
  children: props.children
35
- });
41
+ }));
36
42
  });
@@ -6,14 +6,12 @@ import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
7
7
  import { unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_capitalize as capitalize, unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { GridRootStyles } from './GridRootStyles';
9
- import { gridVisibleColumnDefinitionsSelector } from '../../hooks/features/columns/gridColumnsSelector';
10
9
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
11
10
  import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
12
11
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
13
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
14
13
  import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
15
- import { gridColumnGroupsHeaderMaxDepthSelector } from '../../hooks/features/columnGrouping/gridColumnGroupsSelector';
16
- import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
14
+ import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
17
15
  import { jsx as _jsx } from "react/jsx-runtime";
18
16
  const useUtilityClasses = ownerState => {
19
17
  const {
@@ -34,13 +32,12 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
34
32
  } = props,
35
33
  other = _objectWithoutPropertiesLoose(props, _excluded);
36
34
  const apiRef = useGridPrivateApiContext();
37
- const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
38
- const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
39
35
  const densityValue = useGridSelector(apiRef, gridDensityValueSelector);
40
- const headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
41
36
  const rootContainerRef = React.useRef(null);
42
37
  const handleRef = useForkRef(rootContainerRef, ref);
43
- const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
38
+ const getAriaAttributes = rootProps.experimentalFeatures?.ariaV7 // ariaV7 should never change
39
+ ? null : useGridAriaAttributes;
40
+ const ariaAttributes = typeof getAriaAttributes === 'function' ? getAriaAttributes() : null;
44
41
  const ownerState = _extends({}, rootProps, {
45
42
  density: densityValue
46
43
  });
@@ -60,12 +57,8 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
60
57
  return /*#__PURE__*/_jsx(GridRootStyles, _extends({
61
58
  ref: handleRef,
62
59
  className: clsx(className, classes.root),
63
- ownerState: ownerState,
64
- role: "grid",
65
- "aria-colcount": visibleColumns.length,
66
- "aria-rowcount": headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
67
- "aria-multiselectable": !rootProps.disableMultipleRowSelection
68
- }, other, {
60
+ ownerState: ownerState
61
+ }, ariaAttributes, other, {
69
62
  children: children
70
63
  }));
71
64
  });
@@ -159,6 +159,7 @@ export const GridRootStyles = styled('div', {
159
159
  '--unstable_DataGrid-radius': typeof radius === 'number' ? `${radius}px` : radius,
160
160
  '--unstable_DataGrid-headWeight': theme.typography.fontWeightMedium,
161
161
  '--unstable_DataGrid-overlayBackground': theme.vars ? `rgba(${theme.vars.palette.background.defaultChannel} / ${theme.vars.palette.action.disabledOpacity})` : alpha(theme.palette.background.default, theme.palette.action.disabledOpacity),
162
+ '--DataGrid-cellOffsetMultiplier': 2,
162
163
  flex: 1,
163
164
  boxSizing: 'border-box',
164
165
  position: 'relative',
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { DEFAULT_GRID_COL_TYPE_KEY } from '../../../colDef';
2
+ import { DEFAULT_GRID_COL_TYPE_KEY, GRID_STRING_COL_DEF } from '../../../colDef';
3
3
  import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from './gridColumnsSelector';
4
4
  import { clamp } from '../../../utils/utils';
5
5
  import { gridDensityFactorSelector } from '../density/densitySelector';
@@ -127,7 +127,7 @@ export const hydrateColumnsWidth = (rawState, viewportInnerWidth) => {
127
127
  computedWidth = 0;
128
128
  flexColumns.push(newColumn);
129
129
  } else {
130
- computedWidth = clamp(newColumn.width, newColumn.minWidth, newColumn.maxWidth);
130
+ computedWidth = clamp(newColumn.width || GRID_STRING_COL_DEF.width, newColumn.minWidth || GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || GRID_STRING_COL_DEF.maxWidth);
131
131
  }
132
132
  widthAllocatedBeforeFlex += computedWidth;
133
133
  newColumn.computedWidth = computedWidth;
@@ -244,7 +244,7 @@ export const useGridRowSelection = (apiRef, props) => {
244
244
  }
245
245
  if (field) {
246
246
  const column = apiRef.current.getColumn(field);
247
- if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
247
+ if (column?.type === GRID_ACTIONS_COLUMN_TYPE) {
248
248
  return;
249
249
  }
250
250
  }
@@ -97,9 +97,33 @@ export const useGridVirtualScroller = props => {
97
97
  const rowStyleCache = React.useRef(Object.create(null));
98
98
  const prevGetRowProps = React.useRef();
99
99
  const prevRootRowStyle = React.useRef();
100
- const getRenderedColumnsRef = React.useRef(defaultMemoize((columns, firstColumnToRender, lastColumnToRender) => {
101
- return columns.slice(firstColumnToRender, lastColumnToRender);
100
+ const getRenderedColumnsRef = React.useRef(defaultMemoize((columns, firstColumnToRender, lastColumnToRender, minFirstColumn, maxLastColumn, indexOfColumnWithFocusedCell) => {
101
+ // If the selected column is not within the current range of columns being displayed,
102
+ // we need to render it at either the left or right of the columns,
103
+ // depending on whether it is above or below the range.
104
+ let focusedCellColumnIndexNotInRange;
105
+ const renderedColumns = columns.slice(firstColumnToRender, lastColumnToRender);
106
+ if (indexOfColumnWithFocusedCell > -1) {
107
+ // check if it is not on the left pinned column.
108
+ if (firstColumnToRender > indexOfColumnWithFocusedCell && indexOfColumnWithFocusedCell >= minFirstColumn) {
109
+ focusedCellColumnIndexNotInRange = indexOfColumnWithFocusedCell;
110
+ }
111
+ // check if it is not on the right pinned column.
112
+ else if (lastColumnToRender < indexOfColumnWithFocusedCell && indexOfColumnWithFocusedCell < maxLastColumn) {
113
+ focusedCellColumnIndexNotInRange = indexOfColumnWithFocusedCell;
114
+ }
115
+ }
116
+ return {
117
+ focusedCellColumnIndexNotInRange,
118
+ renderedColumns
119
+ };
102
120
  }, MEMOIZE_OPTIONS));
121
+ const indexOfColumnWithFocusedCell = React.useMemo(() => {
122
+ if (cellFocus !== null) {
123
+ return visibleColumns.findIndex(column => column.field === cellFocus.field);
124
+ }
125
+ return -1;
126
+ }, [cellFocus, visibleColumns]);
103
127
  const getNearestIndexToRender = React.useCallback(offset => {
104
128
  const lastMeasuredIndexRelativeToAllRows = apiRef.current.getLastMeasuredRowIndex();
105
129
  let allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
@@ -306,6 +330,12 @@ export const useGridVirtualScroller = props => {
306
330
  const handleTouchMove = useEventCallback(event => {
307
331
  apiRef.current.publishEvent('virtualScrollerTouchMove', {}, event);
308
332
  });
333
+ const indexOfRowWithFocusedCell = React.useMemo(() => {
334
+ if (cellFocus !== null) {
335
+ return currentPage.rows.findIndex(row => row.id === cellFocus.id);
336
+ }
337
+ return -1;
338
+ }, [cellFocus, currentPage.rows]);
309
339
  const getRows = (params = {
310
340
  renderContext
311
341
  }) => {
@@ -356,6 +386,28 @@ export const useGridVirtualScroller = props => {
356
386
  });
357
387
  }
358
388
  }
389
+ // If the selected row is not within the current range of rows being displayed,
390
+ // we need to render it at either the top or bottom of the rows,
391
+ // depending on whether it is above or below the range.
392
+
393
+ let isRowWithFocusedCellNotInRange = false;
394
+ if (indexOfRowWithFocusedCell > -1) {
395
+ const rowWithFocusedCell = currentPage.rows[indexOfRowWithFocusedCell];
396
+ if (firstRowToRender > indexOfRowWithFocusedCell || lastRowToRender < indexOfRowWithFocusedCell) {
397
+ isRowWithFocusedCellNotInRange = true;
398
+ if (indexOfRowWithFocusedCell > firstRowToRender) {
399
+ renderedRows.push(rowWithFocusedCell);
400
+ } else {
401
+ renderedRows.unshift(rowWithFocusedCell);
402
+ }
403
+ apiRef.current.calculateColSpan({
404
+ rowId: rowWithFocusedCell.id,
405
+ minFirstColumn,
406
+ maxLastColumn,
407
+ columns: visibleColumns
408
+ });
409
+ }
410
+ }
359
411
  const [initialFirstColumnToRender, lastColumnToRender] = getRenderableIndexes({
360
412
  firstIndex: nextRenderContext.firstColumnIndex,
361
413
  lastIndex: nextRenderContext.lastColumnIndex,
@@ -370,7 +422,14 @@ export const useGridVirtualScroller = props => {
370
422
  lastRowToRender,
371
423
  visibleRows: currentPage.rows
372
424
  });
373
- const renderedColumns = getRenderedColumnsRef.current(visibleColumns, firstColumnToRender, lastColumnToRender);
425
+ let isColumnWihFocusedCellNotInRange = false;
426
+ if (firstColumnToRender > indexOfColumnWithFocusedCell || lastColumnToRender < indexOfColumnWithFocusedCell) {
427
+ isColumnWihFocusedCellNotInRange = true;
428
+ }
429
+ const {
430
+ focusedCellColumnIndexNotInRange,
431
+ renderedColumns
432
+ } = getRenderedColumnsRef.current(visibleColumns, firstColumnToRender, lastColumnToRender, minFirstColumn, maxLastColumn, isColumnWihFocusedCellNotInRange ? indexOfColumnWithFocusedCell : -1);
374
433
  const _ref = rootProps.slotProps?.row || {},
375
434
  {
376
435
  style: rootRowStyle
@@ -386,7 +445,8 @@ export const useGridVirtualScroller = props => {
386
445
  id,
387
446
  model
388
447
  } = renderedRows[i];
389
- const lastVisibleRowIndex = firstRowToRender + i === currentPage.rows.length - 1;
448
+ const isRowNotVisible = isRowWithFocusedCellNotInRange && cellFocus.id === id;
449
+ const lastVisibleRowIndex = isRowWithFocusedCellNotInRange ? firstRowToRender + i === currentPage.rows.length : firstRowToRender + i === currentPage.rows.length - 1;
390
450
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
391
451
  let isSelected;
392
452
  if (selectedRowsLookup[id] == null) {
@@ -398,6 +458,8 @@ export const useGridVirtualScroller = props => {
398
458
  onRowRender(id);
399
459
  }
400
460
  const focusedCell = cellFocus !== null && cellFocus.id === id ? cellFocus.field : null;
461
+ const columnWithFocusedCellNotInRange = focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange];
462
+ const renderedColumnsWithFocusedCell = columnWithFocusedCellNotInRange && focusedCell ? [columnWithFocusedCellNotInRange, ...renderedColumns] : renderedColumns;
401
463
  let tabbableCell = null;
402
464
  if (cellTabIndex !== null && cellTabIndex.id === id) {
403
465
  const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
@@ -415,10 +477,12 @@ export const useGridVirtualScroller = props => {
415
477
  rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
416
478
  row: model,
417
479
  rowId: id,
480
+ focusedCellColumnIndexNotInRange: focusedCellColumnIndexNotInRange,
481
+ isNotVisible: isRowNotVisible,
418
482
  rowHeight: baseRowHeight,
419
483
  focusedCell: focusedCell,
420
484
  tabbableCell: tabbableCell,
421
- renderedColumns: renderedColumns,
485
+ renderedColumns: renderedColumnsWithFocusedCell,
422
486
  visibleColumns: visibleColumns,
423
487
  firstColumnToRender: firstColumnToRender,
424
488
  lastColumnToRender: lastColumnToRender,
@@ -485,15 +549,18 @@ export const useGridVirtualScroller = props => {
485
549
  onWheel: handleWheel,
486
550
  onTouchMove: handleTouchMove
487
551
  }, inputProps, {
488
- style: inputProps.style ? _extends({}, inputProps.style, rootStyle) : rootStyle
552
+ style: inputProps.style ? _extends({}, inputProps.style, rootStyle) : rootStyle,
553
+ role: 'presentation'
489
554
  }),
490
555
  getContentProps: ({
491
556
  style
492
557
  } = {}) => ({
493
- style: style ? _extends({}, style, contentSize) : contentSize
558
+ style: style ? _extends({}, style, contentSize) : contentSize,
559
+ role: 'presentation'
494
560
  }),
495
561
  getRenderZoneProps: () => ({
496
- ref: renderZoneRef
562
+ ref: renderZoneRef,
563
+ role: 'rowgroup'
497
564
  })
498
565
  };
499
566
  };