@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
@@ -22,10 +22,9 @@ var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusState
22
22
  var _useGridParamsApi = require("../../hooks/features/rows/useGridParamsApi");
23
23
  var _jsxRuntime = require("react/jsx-runtime");
24
24
  const _excluded = ["changeReason", "unstable_updateValueOnRender"],
25
- _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"],
26
- _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
25
+ _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"],
26
+ _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"],
27
27
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
28
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
29
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
29
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
30
  const EMPTY_CELL_PARAMS = {
@@ -185,6 +184,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
185
184
  showRightBorder,
186
185
  colSpan,
187
186
  disableDragEvents,
187
+ isNotVisible,
188
188
  onClick,
189
189
  onDoubleClick,
190
190
  onMouseDown,
@@ -235,13 +235,23 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
235
235
  propHandler(event);
236
236
  }
237
237
  }, [apiRef, field, rowId]);
238
- const style = {
239
- minWidth: width,
240
- maxWidth: width,
241
- minHeight: height,
242
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
243
- };
238
+ const style = React.useMemo(() => {
239
+ if (isNotVisible) {
240
+ return {
241
+ padding: 0,
242
+ opacity: 0,
243
+ width: 0
244
+ };
245
+ }
246
+ const cellStyle = {
247
+ minWidth: width,
248
+ maxWidth: width,
249
+ minHeight: height,
250
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
251
+ };
244
252
 
253
+ return cellStyle;
254
+ }, [width, height, isNotVisible]);
245
255
  React.useEffect(() => {
246
256
  if (!hasFocus || cellMode === _models.GridCellModes.Edit) {
247
257
  return;
@@ -284,6 +294,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
284
294
  children = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
285
295
  className: classes.content,
286
296
  title: valueString,
297
+ role: "presentation",
287
298
  children: valueString
288
299
  });
289
300
  }
@@ -296,27 +307,32 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
296
307
  onDragEnter: publish('cellDragEnter', onDragEnter),
297
308
  onDragOver: publish('cellDragOver', onDragOver)
298
309
  };
299
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
300
- ref: handleRef,
301
- className: (0, _clsx.default)(className, classes.root),
302
- role: "cell",
303
- "data-field": field,
304
- "data-colindex": colIndex,
305
- "aria-colindex": colIndex + 1,
306
- "aria-colspan": colSpan,
307
- style: style,
308
- tabIndex: tabIndex,
309
- onClick: publish('cellClick', onClick),
310
- onDoubleClick: publish('cellDoubleClick', onDoubleClick),
311
- onMouseOver: publish('cellMouseOver', onMouseOver),
312
- onMouseDown: publishMouseDown('cellMouseDown'),
313
- onMouseUp: publishMouseUp('cellMouseUp'),
314
- onKeyDown: publish('cellKeyDown', onKeyDown),
315
- onKeyUp: publish('cellKeyUp', onKeyUp)
316
- }, draggableEventHandlers, other, {
317
- onFocus: handleFocus,
318
- children: children
319
- }));
310
+ const ariaV7 = rootProps.experimentalFeatures?.ariaV7;
311
+ return (
312
+ /*#__PURE__*/
313
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
314
+ (0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
315
+ ref: handleRef,
316
+ className: (0, _clsx.default)(className, classes.root),
317
+ role: ariaV7 ? 'gridcell' : 'cell',
318
+ "data-field": field,
319
+ "data-colindex": colIndex,
320
+ "aria-colindex": colIndex + 1,
321
+ "aria-colspan": colSpan,
322
+ style: style,
323
+ tabIndex: tabIndex,
324
+ onClick: publish('cellClick', onClick),
325
+ onDoubleClick: publish('cellDoubleClick', onDoubleClick),
326
+ onMouseOver: publish('cellMouseOver', onMouseOver),
327
+ onMouseDown: publishMouseDown('cellMouseDown'),
328
+ onMouseUp: publishMouseUp('cellMouseUp'),
329
+ onKeyDown: publish('cellKeyDown', onKeyDown),
330
+ onKeyUp: publish('cellKeyUp', onKeyUp)
331
+ }, draggableEventHandlers, other, {
332
+ onFocus: handleFocus,
333
+ children: children
334
+ }))
335
+ );
320
336
  });
321
337
  exports.GridCell = GridCell;
322
338
  const MemoizedCellWrapper = (0, _fastMemo.fastMemo)(GridCellWrapper);
@@ -363,6 +379,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
363
379
  isValidating: _propTypes.default.bool,
364
380
  value: _propTypes.default.any
365
381
  }),
382
+ isNotVisible: _propTypes.default.bool,
366
383
  height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
367
384
  onClick: _propTypes.default.func,
368
385
  onDoubleClick: _propTypes.default.func,
@@ -388,6 +405,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
388
405
  showRightBorder,
389
406
  colSpan,
390
407
  disableDragEvents,
408
+ isNotVisible,
391
409
  onClick,
392
410
  onDoubleClick,
393
411
  onMouseDown,
@@ -482,13 +500,23 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
482
500
  propHandler(event);
483
501
  }
484
502
  }, [apiRef, field, rowId]);
485
- const style = {
486
- minWidth: width,
487
- maxWidth: width,
488
- minHeight: height,
489
- maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
490
- };
503
+ const style = React.useMemo(() => {
504
+ if (isNotVisible) {
505
+ return {
506
+ padding: 0,
507
+ opacity: 0,
508
+ width: 0
509
+ };
510
+ }
511
+ const cellStyle = {
512
+ minWidth: width,
513
+ maxWidth: width,
514
+ minHeight: height,
515
+ maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
516
+ };
491
517
 
518
+ return cellStyle;
519
+ }, [width, height, isNotVisible]);
492
520
  React.useEffect(() => {
493
521
  if (!hasFocus || cellMode === _models.GridCellModes.Edit) {
494
522
  return;
@@ -550,6 +578,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
550
578
  children = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
551
579
  className: classes.content,
552
580
  title: valueString,
581
+ role: "presentation",
553
582
  children: valueString
554
583
  });
555
584
  }
@@ -562,27 +591,32 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
562
591
  onDragEnter: publish('cellDragEnter', onDragEnter),
563
592
  onDragOver: publish('cellDragOver', onDragOver)
564
593
  };
565
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
566
- ref: handleRef,
567
- className: (0, _clsx.default)(className, classNames, classes.root),
568
- role: "cell",
569
- "data-field": field,
570
- "data-colindex": colIndex,
571
- "aria-colindex": colIndex + 1,
572
- "aria-colspan": colSpan,
573
- style: style,
574
- tabIndex: tabIndex,
575
- onClick: publish('cellClick', onClick),
576
- onDoubleClick: publish('cellDoubleClick', onDoubleClick),
577
- onMouseOver: publish('cellMouseOver', onMouseOver),
578
- onMouseDown: publishMouseDown('cellMouseDown'),
579
- onMouseUp: publishMouseUp('cellMouseUp'),
580
- onKeyDown: publish('cellKeyDown', onKeyDown),
581
- onKeyUp: publish('cellKeyUp', onKeyUp)
582
- }, draggableEventHandlers, other, {
583
- onFocus: handleFocus,
584
- children: children
585
- }));
594
+ const ariaV7 = rootProps.experimentalFeatures?.ariaV7;
595
+ return (
596
+ /*#__PURE__*/
597
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
598
+ (0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
599
+ ref: handleRef,
600
+ className: (0, _clsx.default)(className, classNames, classes.root),
601
+ role: ariaV7 ? 'gridcell' : 'cell',
602
+ "data-field": field,
603
+ "data-colindex": colIndex,
604
+ "aria-colindex": colIndex + 1,
605
+ "aria-colspan": colSpan,
606
+ style: style,
607
+ tabIndex: tabIndex,
608
+ onClick: publish('cellClick', onClick),
609
+ onDoubleClick: publish('cellDoubleClick', onDoubleClick),
610
+ onMouseOver: publish('cellMouseOver', onMouseOver),
611
+ onMouseDown: publishMouseDown('cellMouseDown'),
612
+ onMouseUp: publishMouseUp('cellMouseUp'),
613
+ onKeyDown: publish('cellKeyDown', onKeyDown),
614
+ onKeyUp: publish('cellKeyUp', onKeyUp)
615
+ }, draggableEventHandlers, other, {
616
+ onFocus: handleFocus,
617
+ children: children
618
+ }))
619
+ );
586
620
  });
587
621
  process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
588
622
  // ----------------------------- Warning --------------------------------
@@ -602,6 +636,7 @@ process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
602
636
  value: _propTypes.default.any
603
637
  }),
604
638
  height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
639
+ isNotVisible: _propTypes.default.bool,
605
640
  onClick: _propTypes.default.func,
606
641
  onDoubleClick: _propTypes.default.func,
607
642
  onDragEnter: _propTypes.default.func,
@@ -51,6 +51,8 @@ const GridBaseColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnH
51
51
  ref: ref,
52
52
  className: (0, _clsx.default)(className, classes.root),
53
53
  ownerState: rootProps
54
- }, other));
54
+ }, other, {
55
+ role: "presentation"
56
+ }));
55
57
  });
56
58
  exports.GridBaseColumnHeaders = GridBaseColumnHeaders;
@@ -83,10 +83,12 @@ const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridG
83
83
  }, other, {
84
84
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({
85
85
  className: classes.draggableContainer,
86
- draggable: isDraggable
86
+ draggable: isDraggable,
87
+ role: "presentation"
87
88
  }, draggableContainerProps, {
88
89
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
89
90
  className: classes.titleContainer,
91
+ role: "presentation",
90
92
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
91
93
  className: classes.titleContainerContent,
92
94
  children: headerComponent !== undefined ? headerComponent : /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridColumnHeaderTitle.GridColumnHeaderTitle, {
@@ -1,14 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.GridMainContainer = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
9
  var React = _interopRequireWildcard(require("react"));
8
10
  var _utils = require("@mui/utils");
9
11
  var _system = require("@mui/system");
10
12
  var _gridClasses = require("../../constants/gridClasses");
11
13
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
14
+ var _useGridAriaAttributes = require("../../hooks/utils/useGridAriaAttributes");
12
15
  var _jsxRuntime = require("react/jsx-runtime");
13
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -35,11 +38,15 @@ const GridMainContainerRoot = (0, _system.styled)('div', {
35
38
  const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
36
39
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
37
40
  const classes = useUtilityClasses(rootProps);
38
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridMainContainerRoot, {
41
+ const getAriaAttributes = rootProps.experimentalFeatures?.ariaV7 // ariaV7 should never change
42
+ ? _useGridAriaAttributes.useGridAriaAttributes : null;
43
+ const ariaAttributes = typeof getAriaAttributes === 'function' ? getAriaAttributes() : null;
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridMainContainerRoot, (0, _extends2.default)({
39
45
  ref: ref,
40
46
  className: classes.root,
41
- ownerState: rootProps,
47
+ ownerState: rootProps
48
+ }, ariaAttributes, {
42
49
  children: props.children
43
- });
50
+ }));
44
51
  });
45
52
  exports.GridMainContainer = GridMainContainer;
@@ -12,14 +12,12 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _clsx = _interopRequireDefault(require("clsx"));
13
13
  var _utils = require("@mui/utils");
14
14
  var _GridRootStyles = require("./GridRootStyles");
15
- var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
16
15
  var _useGridSelector = require("../../hooks/utils/useGridSelector");
17
16
  var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiContext");
18
17
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
19
18
  var _gridClasses = require("../../constants/gridClasses");
20
19
  var _densitySelector = require("../../hooks/features/density/densitySelector");
21
- var _gridColumnGroupsSelector = require("../../hooks/features/columnGrouping/gridColumnGroupsSelector");
22
- var _gridRowsSelector = require("../../hooks/features/rows/gridRowsSelector");
20
+ var _useGridAriaAttributes = require("../../hooks/utils/useGridAriaAttributes");
23
21
  var _jsxRuntime = require("react/jsx-runtime");
24
22
  const _excluded = ["children", "className"];
25
23
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -43,13 +41,12 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
43
41
  } = props,
44
42
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
45
43
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
46
- const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
47
- const totalRowCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowCountSelector);
48
44
  const densityValue = (0, _useGridSelector.useGridSelector)(apiRef, _densitySelector.gridDensityValueSelector);
49
- const headerGroupingMaxDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector);
50
45
  const rootContainerRef = React.useRef(null);
51
46
  const handleRef = (0, _utils.unstable_useForkRef)(rootContainerRef, ref);
52
- const pinnedRowsCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsCountSelector);
47
+ const getAriaAttributes = rootProps.experimentalFeatures?.ariaV7 // ariaV7 should never change
48
+ ? null : _useGridAriaAttributes.useGridAriaAttributes;
49
+ const ariaAttributes = typeof getAriaAttributes === 'function' ? getAriaAttributes() : null;
53
50
  const ownerState = (0, _extends2.default)({}, rootProps, {
54
51
  density: densityValue
55
52
  });
@@ -69,12 +66,8 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
69
66
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridRootStyles.GridRootStyles, (0, _extends2.default)({
70
67
  ref: handleRef,
71
68
  className: (0, _clsx.default)(className, classes.root),
72
- ownerState: ownerState,
73
- role: "grid",
74
- "aria-colcount": visibleColumns.length,
75
- "aria-rowcount": headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
76
- "aria-multiselectable": !rootProps.disableMultipleRowSelection
77
- }, other, {
69
+ ownerState: ownerState
70
+ }, ariaAttributes, other, {
78
71
  children: children
79
72
  }));
80
73
  });
@@ -166,6 +166,7 @@ const GridRootStyles = (0, _styles.styled)('div', {
166
166
  '--unstable_DataGrid-radius': typeof radius === 'number' ? `${radius}px` : radius,
167
167
  '--unstable_DataGrid-headWeight': theme.typography.fontWeightMedium,
168
168
  '--unstable_DataGrid-overlayBackground': theme.vars ? `rgba(${theme.vars.palette.background.defaultChannel} / ${theme.vars.palette.action.disabledOpacity})` : (0, _styles.alpha)(theme.palette.background.default, theme.palette.action.disabledOpacity),
169
+ '--DataGrid-cellOffsetMultiplier': 2,
169
170
  flex: 1,
170
171
  boxSizing: 'border-box',
171
172
  position: 'relative',
@@ -141,7 +141,7 @@ const hydrateColumnsWidth = (rawState, viewportInnerWidth) => {
141
141
  computedWidth = 0;
142
142
  flexColumns.push(newColumn);
143
143
  } else {
144
- computedWidth = (0, _utils.clamp)(newColumn.width, newColumn.minWidth, newColumn.maxWidth);
144
+ computedWidth = (0, _utils.clamp)(newColumn.width || _colDef.GRID_STRING_COL_DEF.width, newColumn.minWidth || _colDef.GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || _colDef.GRID_STRING_COL_DEF.maxWidth);
145
145
  }
146
146
  widthAllocatedBeforeFlex += computedWidth;
147
147
  newColumn.computedWidth = computedWidth;
@@ -254,7 +254,7 @@ const useGridRowSelection = (apiRef, props) => {
254
254
  }
255
255
  if (field) {
256
256
  const column = apiRef.current.getColumn(field);
257
- if (column.type === _colDef.GRID_ACTIONS_COLUMN_TYPE) {
257
+ if (column?.type === _colDef.GRID_ACTIONS_COLUMN_TYPE) {
258
258
  return;
259
259
  }
260
260
  }
@@ -110,9 +110,33 @@ const useGridVirtualScroller = props => {
110
110
  const rowStyleCache = React.useRef(Object.create(null));
111
111
  const prevGetRowProps = React.useRef();
112
112
  const prevRootRowStyle = React.useRef();
113
- const getRenderedColumnsRef = React.useRef((0, _reselect.defaultMemoize)((columns, firstColumnToRender, lastColumnToRender) => {
114
- return columns.slice(firstColumnToRender, lastColumnToRender);
113
+ const getRenderedColumnsRef = React.useRef((0, _reselect.defaultMemoize)((columns, firstColumnToRender, lastColumnToRender, minFirstColumn, maxLastColumn, indexOfColumnWithFocusedCell) => {
114
+ // If the selected column is not within the current range of columns being displayed,
115
+ // we need to render it at either the left or right of the columns,
116
+ // depending on whether it is above or below the range.
117
+ let focusedCellColumnIndexNotInRange;
118
+ const renderedColumns = columns.slice(firstColumnToRender, lastColumnToRender);
119
+ if (indexOfColumnWithFocusedCell > -1) {
120
+ // check if it is not on the left pinned column.
121
+ if (firstColumnToRender > indexOfColumnWithFocusedCell && indexOfColumnWithFocusedCell >= minFirstColumn) {
122
+ focusedCellColumnIndexNotInRange = indexOfColumnWithFocusedCell;
123
+ }
124
+ // check if it is not on the right pinned column.
125
+ else if (lastColumnToRender < indexOfColumnWithFocusedCell && indexOfColumnWithFocusedCell < maxLastColumn) {
126
+ focusedCellColumnIndexNotInRange = indexOfColumnWithFocusedCell;
127
+ }
128
+ }
129
+ return {
130
+ focusedCellColumnIndexNotInRange,
131
+ renderedColumns
132
+ };
115
133
  }, MEMOIZE_OPTIONS));
134
+ const indexOfColumnWithFocusedCell = React.useMemo(() => {
135
+ if (cellFocus !== null) {
136
+ return visibleColumns.findIndex(column => column.field === cellFocus.field);
137
+ }
138
+ return -1;
139
+ }, [cellFocus, visibleColumns]);
116
140
  const getNearestIndexToRender = React.useCallback(offset => {
117
141
  const lastMeasuredIndexRelativeToAllRows = apiRef.current.getLastMeasuredRowIndex();
118
142
  let allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
@@ -319,6 +343,12 @@ const useGridVirtualScroller = props => {
319
343
  const handleTouchMove = (0, _utils.unstable_useEventCallback)(event => {
320
344
  apiRef.current.publishEvent('virtualScrollerTouchMove', {}, event);
321
345
  });
346
+ const indexOfRowWithFocusedCell = React.useMemo(() => {
347
+ if (cellFocus !== null) {
348
+ return currentPage.rows.findIndex(row => row.id === cellFocus.id);
349
+ }
350
+ return -1;
351
+ }, [cellFocus, currentPage.rows]);
322
352
  const getRows = (params = {
323
353
  renderContext
324
354
  }) => {
@@ -369,6 +399,28 @@ const useGridVirtualScroller = props => {
369
399
  });
370
400
  }
371
401
  }
402
+ // If the selected row is not within the current range of rows being displayed,
403
+ // we need to render it at either the top or bottom of the rows,
404
+ // depending on whether it is above or below the range.
405
+
406
+ let isRowWithFocusedCellNotInRange = false;
407
+ if (indexOfRowWithFocusedCell > -1) {
408
+ const rowWithFocusedCell = currentPage.rows[indexOfRowWithFocusedCell];
409
+ if (firstRowToRender > indexOfRowWithFocusedCell || lastRowToRender < indexOfRowWithFocusedCell) {
410
+ isRowWithFocusedCellNotInRange = true;
411
+ if (indexOfRowWithFocusedCell > firstRowToRender) {
412
+ renderedRows.push(rowWithFocusedCell);
413
+ } else {
414
+ renderedRows.unshift(rowWithFocusedCell);
415
+ }
416
+ apiRef.current.calculateColSpan({
417
+ rowId: rowWithFocusedCell.id,
418
+ minFirstColumn,
419
+ maxLastColumn,
420
+ columns: visibleColumns
421
+ });
422
+ }
423
+ }
372
424
  const [initialFirstColumnToRender, lastColumnToRender] = getRenderableIndexes({
373
425
  firstIndex: nextRenderContext.firstColumnIndex,
374
426
  lastIndex: nextRenderContext.lastColumnIndex,
@@ -383,7 +435,14 @@ const useGridVirtualScroller = props => {
383
435
  lastRowToRender,
384
436
  visibleRows: currentPage.rows
385
437
  });
386
- const renderedColumns = getRenderedColumnsRef.current(visibleColumns, firstColumnToRender, lastColumnToRender);
438
+ let isColumnWihFocusedCellNotInRange = false;
439
+ if (firstColumnToRender > indexOfColumnWithFocusedCell || lastColumnToRender < indexOfColumnWithFocusedCell) {
440
+ isColumnWihFocusedCellNotInRange = true;
441
+ }
442
+ const {
443
+ focusedCellColumnIndexNotInRange,
444
+ renderedColumns
445
+ } = getRenderedColumnsRef.current(visibleColumns, firstColumnToRender, lastColumnToRender, minFirstColumn, maxLastColumn, isColumnWihFocusedCellNotInRange ? indexOfColumnWithFocusedCell : -1);
387
446
  const _ref = rootProps.slotProps?.row || {},
388
447
  {
389
448
  style: rootRowStyle
@@ -399,7 +458,8 @@ const useGridVirtualScroller = props => {
399
458
  id,
400
459
  model
401
460
  } = renderedRows[i];
402
- const lastVisibleRowIndex = firstRowToRender + i === currentPage.rows.length - 1;
461
+ const isRowNotVisible = isRowWithFocusedCellNotInRange && cellFocus.id === id;
462
+ const lastVisibleRowIndex = isRowWithFocusedCellNotInRange ? firstRowToRender + i === currentPage.rows.length : firstRowToRender + i === currentPage.rows.length - 1;
403
463
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
404
464
  let isSelected;
405
465
  if (selectedRowsLookup[id] == null) {
@@ -411,6 +471,8 @@ const useGridVirtualScroller = props => {
411
471
  onRowRender(id);
412
472
  }
413
473
  const focusedCell = cellFocus !== null && cellFocus.id === id ? cellFocus.field : null;
474
+ const columnWithFocusedCellNotInRange = focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange];
475
+ const renderedColumnsWithFocusedCell = columnWithFocusedCellNotInRange && focusedCell ? [columnWithFocusedCellNotInRange, ...renderedColumns] : renderedColumns;
414
476
  let tabbableCell = null;
415
477
  if (cellTabIndex !== null && cellTabIndex.id === id) {
416
478
  const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
@@ -428,10 +490,12 @@ const useGridVirtualScroller = props => {
428
490
  rows.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.row, (0, _extends2.default)({
429
491
  row: model,
430
492
  rowId: id,
493
+ focusedCellColumnIndexNotInRange: focusedCellColumnIndexNotInRange,
494
+ isNotVisible: isRowNotVisible,
431
495
  rowHeight: baseRowHeight,
432
496
  focusedCell: focusedCell,
433
497
  tabbableCell: tabbableCell,
434
- renderedColumns: renderedColumns,
498
+ renderedColumns: renderedColumnsWithFocusedCell,
435
499
  visibleColumns: visibleColumns,
436
500
  firstColumnToRender: firstColumnToRender,
437
501
  lastColumnToRender: lastColumnToRender,
@@ -498,15 +562,18 @@ const useGridVirtualScroller = props => {
498
562
  onWheel: handleWheel,
499
563
  onTouchMove: handleTouchMove
500
564
  }, inputProps, {
501
- style: inputProps.style ? (0, _extends2.default)({}, inputProps.style, rootStyle) : rootStyle
565
+ style: inputProps.style ? (0, _extends2.default)({}, inputProps.style, rootStyle) : rootStyle,
566
+ role: 'presentation'
502
567
  }),
503
568
  getContentProps: ({
504
569
  style
505
570
  } = {}) => ({
506
- style: style ? (0, _extends2.default)({}, style, contentSize) : contentSize
571
+ style: style ? (0, _extends2.default)({}, style, contentSize) : contentSize,
572
+ role: 'presentation'
507
573
  }),
508
574
  getRenderZoneProps: () => ({
509
- ref: renderZoneRef
575
+ ref: renderZoneRef,
576
+ role: 'rowgroup'
510
577
  })
511
578
  };
512
579
  };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useGridAriaAttributes = void 0;
7
+ var _gridColumnsSelector = require("../features/columns/gridColumnsSelector");
8
+ var _useGridSelector = require("./useGridSelector");
9
+ var _useGridRootProps = require("./useGridRootProps");
10
+ var _gridColumnGroupsSelector = require("../features/columnGrouping/gridColumnGroupsSelector");
11
+ var _gridRowsSelector = require("../features/rows/gridRowsSelector");
12
+ var _useGridPrivateApiContext = require("./useGridPrivateApiContext");
13
+ const useGridAriaAttributes = () => {
14
+ const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
15
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
16
+ const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
17
+ const totalRowCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowCountSelector);
18
+ const headerGroupingMaxDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector);
19
+ const pinnedRowsCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsCountSelector);
20
+ let role = 'grid';
21
+ if (rootProps.experimentalFeatures?.ariaV7 && rootProps.treeData) {
22
+ role = 'treegrid';
23
+ }
24
+ return {
25
+ role,
26
+ 'aria-colcount': visibleColumns.length,
27
+ 'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
28
+ 'aria-multiselectable': !rootProps.disableMultipleRowSelection
29
+ };
30
+ };
31
+ exports.useGridAriaAttributes = useGridAriaAttributes;
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.10.1
2
+ * @mui/x-data-grid v6.11.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -52,6 +52,7 @@ var _exportNames = {
52
52
  getTreeNodeDescendants: true,
53
53
  buildRootGroup: true,
54
54
  getRowIdFromRowModel: true,
55
+ GRID_ID_AUTOGENERATED: true,
55
56
  calculatePinnedRowsHeight: true,
56
57
  useGridRowsMeta: true,
57
58
  rowsMetaStateInitializer: true,
@@ -104,6 +105,12 @@ Object.defineProperty(exports, "GRID_DEFAULT_STRATEGY", {
104
105
  return _strategyProcessing.GRID_DEFAULT_STRATEGY;
105
106
  }
106
107
  });
108
+ Object.defineProperty(exports, "GRID_ID_AUTOGENERATED", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _gridRowsUtils.GRID_ID_AUTOGENERATED;
112
+ }
113
+ });
107
114
  Object.defineProperty(exports, "GridBaseColumnHeaders", {
108
115
  enumerable: true,
109
116
  get: function () {