@mui/x-data-grid 8.3.1 → 8.4.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 (68) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/DataGrid/DataGrid.js +1 -0
  3. package/components/GridApiContext.js +1 -3
  4. package/components/GridColumnUnsortedIcon.js +2 -1
  5. package/components/GridConfigurationContext.js +1 -3
  6. package/components/GridRow.js +1 -0
  7. package/components/cell/GridActionsCell.js +2 -1
  8. package/components/cell/GridBooleanCell.js +3 -1
  9. package/components/cell/GridEditBooleanCell.js +2 -1
  10. package/components/cell/GridEditDateCell.js +2 -1
  11. package/components/cell/GridEditInputCell.js +2 -1
  12. package/components/cell/GridEditSingleSelectCell.js +2 -1
  13. package/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -1
  14. package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  15. package/components/columnHeaders/GridColumnHeaderSeparator.js +1 -0
  16. package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -0
  17. package/components/containers/GridRootStyles.js +1 -1
  18. package/components/panel/GridPanelContext.js +1 -0
  19. package/components/quickFilter/QuickFilterContext.js +1 -0
  20. package/components/toolbarV8/Toolbar.js +58 -32
  21. package/components/toolbarV8/ToolbarContext.js +1 -0
  22. package/components/toolbarV8/utils.d.ts +5 -0
  23. package/components/toolbarV8/utils.js +23 -0
  24. package/context/GridRootPropsContext.js +1 -3
  25. package/esm/DataGrid/DataGrid.js +1 -0
  26. package/esm/components/GridApiContext.js +1 -3
  27. package/esm/components/GridColumnUnsortedIcon.js +2 -1
  28. package/esm/components/GridConfigurationContext.js +1 -3
  29. package/esm/components/GridRow.js +1 -0
  30. package/esm/components/cell/GridActionsCell.js +2 -1
  31. package/esm/components/cell/GridBooleanCell.js +3 -1
  32. package/esm/components/cell/GridEditBooleanCell.js +2 -1
  33. package/esm/components/cell/GridEditDateCell.js +2 -1
  34. package/esm/components/cell/GridEditInputCell.js +2 -1
  35. package/esm/components/cell/GridEditSingleSelectCell.js +2 -1
  36. package/esm/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -1
  37. package/esm/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  38. package/esm/components/columnHeaders/GridColumnHeaderSeparator.js +1 -0
  39. package/esm/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -0
  40. package/esm/components/containers/GridRootStyles.js +1 -1
  41. package/esm/components/panel/GridPanelContext.js +1 -0
  42. package/esm/components/quickFilter/QuickFilterContext.js +1 -0
  43. package/esm/components/toolbarV8/Toolbar.js +58 -32
  44. package/esm/components/toolbarV8/ToolbarContext.js +1 -0
  45. package/esm/components/toolbarV8/utils.d.ts +5 -0
  46. package/esm/components/toolbarV8/utils.js +17 -0
  47. package/esm/context/GridRootPropsContext.js +1 -3
  48. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  49. package/esm/hooks/features/overlays/useGridOverlays.js +1 -0
  50. package/esm/hooks/features/pagination/useGridPaginationModel.js +1 -1
  51. package/esm/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  52. package/esm/hooks/utils/useGridPrivateApiContext.js +1 -3
  53. package/esm/index.js +1 -1
  54. package/esm/locales/isIS.js +8 -8
  55. package/esm/material/variables.js +5 -0
  56. package/esm/models/events/gridEventLookup.d.ts +9 -0
  57. package/esm/utils/css/context.js +2 -1
  58. package/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
  59. package/hooks/features/overlays/useGridOverlays.js +1 -0
  60. package/hooks/features/pagination/useGridPaginationModel.js +1 -1
  61. package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  62. package/hooks/utils/useGridPrivateApiContext.js +1 -3
  63. package/index.js +1 -1
  64. package/locales/isIS.js +8 -8
  65. package/material/variables.js +5 -0
  66. package/models/events/gridEventLookup.d.ts +9 -0
  67. package/package.json +2 -2
  68. package/utils/css/context.js +2 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,116 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.4.0
9
+
10
+ _May 21, 2025_
11
+
12
+ We'd like to offer a big thanks to the 21 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 🔺 Support regular [`pyramid` variation in the `<FunnelChart />` component](https://mui.com/x/react-charts/funnel/#pyramid-chart):
15
+
16
+ <img width="398" alt="Pyramid funnel chart" src="https://github.com/user-attachments/assets/90ccb221-3a48-4ffa-8878-89c6db16da86" />
17
+
18
+ - 📚 Documentation improvements
19
+ - 🌎 Improve Icelandic (is-IS) locale on the Data Grid
20
+ - 🐞 Bugfixes
21
+
22
+ Special thanks go out to the community members for their valuable contributions:
23
+ @aizerin, @arminmeh, @campmarc, @jyash97, @mapache-salvaje, @noraleonte, @nusr, @ragnarr18, @romgrk, @whereisrmsqhs.
24
+ Following are all team members who have contributed to this release:
25
+ @alexfauquette, @bernardobelchior, @flaviendelangle, @JCQuintas, @KenanYusuf, @LukasTy, @MBilalShafi, @rita-codes.
26
+
27
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
28
+
29
+ ### Data Grid
30
+
31
+ #### `@mui/x-data-grid@8.4.0`
32
+
33
+ - [DataGrid] Fix content rendering for large rows while using automatic page size (#14737) @campmarc
34
+ - [DataGrid] Fix disabled typography variants crashing grid (#17934) @KenanYusuf
35
+ - [DataGrid] Fix tree data demo crash (#17904) @MBilalShafi
36
+ - [DataGrid] Use `exclude` selection model type if quick filter does not have actual values (#17899) @arminmeh
37
+ - [DataGrid] Fix clipboard copy behavior for cell ranges with empty cells (#16797) @nusr
38
+ - [l10n] Improve Icelandic (is-IS) locale (#17915) @ragnarr18
39
+
40
+ #### `@mui/x-data-grid-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
41
+
42
+ Same changes as in `@mui/x-data-grid@8.4.0`, plus:
43
+
44
+ - [DataGridPro] Add `aria-expanded` attribute to the master detail toggle button (#17122) @whereisrmsqhs
45
+ - [DataGridPro] Preserve row state during server-side lazy loading (#17743) @arminmeh
46
+ - [DataGridPro] Prevent text selection when reordering rows (#16568) @jyash97
47
+
48
+ #### `@mui/x-data-grid-premium@8.4.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
49
+
50
+ Same changes as in `@mui/x-data-grid-pro@8.4.0`.
51
+
52
+ ### Date and Time Pickers
53
+
54
+ #### `@mui/x-date-pickers@8.4.0`
55
+
56
+ - [fields] Ensure fresh `disabled` value is used when focusing or clicking (#17914) @aizerin
57
+ - [fields] Improve the field controlled edition (#17816) @flaviendelangle
58
+ - [pickers] Fix `PickersTextField` overflow (#17942) @noraleonte
59
+
60
+ #### `@mui/x-date-pickers-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
61
+
62
+ Same changes as in `@mui/x-date-pickers@8.4.0`.
63
+
64
+ ### Charts
65
+
66
+ #### `@mui/x-charts@8.4.0`
67
+
68
+ - [charts] Add grouped axes demo (#17848) @bernardobelchior
69
+ - [charts] Enable tooltip disable portal (#17871) @alexfauquette
70
+ - [charts] Improve performance in scatter chart (#17849) @bernardobelchior
71
+ - [charts] Recreate `isPointInside` less often (#17850) @bernardobelchior
72
+ - [charts] Try fix for flaky `useAnimate` test (#17777) @JCQuintas
73
+ - [charts] Add `isXInside` and `isYInside` (#17911) @bernardobelchior
74
+
75
+ #### `@mui/x-charts-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
76
+
77
+ Same changes as in `@mui/x-charts@8.4.0`, plus:
78
+
79
+ - [charts-pro] Add size for zoom slider (#17736) @bernardobelchior
80
+ - [charts-pro] Add zoom slider tooltip (#17733) @bernardobelchior
81
+ - [charts-pro] Clean and document Heatmap Tooltip (#17933) @alexfauquette
82
+ - [charts-pro] Introduce `Pyramid` chart (#17783) @JCQuintas
83
+ - [charts-pro] Update zoom slider nomenclature (#17938) @bernardobelchior
84
+ - [charts-pro] Fix error when importing rasterizehtml (#17897) @bernardobelchior
85
+
86
+ ### Tree View
87
+
88
+ #### `@mui/x-tree-view@8.4.0`
89
+
90
+ - [TreeView] Add `getItemChildren` prop in `RichTreeView` (#17894) @rita-codes
91
+ - [TreeView] Add a method in the `apiRef` to toggle the editing status of an item (#17768) @rita-codes
92
+ - [TreeView] Add missing sx prop on the Tree Item component (#17930) @flaviendelangle
93
+
94
+ #### `@mui/x-tree-view-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
95
+
96
+ Same changes as in `@mui/x-tree-view@8.4.0`.
97
+
98
+ ### Docs
99
+
100
+ - [docs] Add a recipe for drag and drop row grouping (#17638) @KenanYusuf
101
+ - [docs] Add introductory text to Data Grid component pages (#17902) @KenanYusuf
102
+ - [docs] Refactor embedded CodeSandbox on Data Grid—Quickstart page (#17749) @rita-codes
103
+ - [docs] Remove double border on Data Grid—Quickstart demo (#17932) @rita-codes
104
+ - [docs] Standardize `apiRef` copy (#17776) @mapache-salvaje
105
+ - [docs][DataGrid] Revise server-side data docs (#17007) @mapache-salvaje
106
+ - [docs][DataGrid] Audit and revise the tree data doc (#17650) @mapache-salvaje
107
+ - [docs][pickers] Fix migration guide references to range fields (#17861) @LukasTy
108
+ - [docs][charts] Reorganize the Tooltip documentation (#17917) @alexfauquette
109
+
110
+ ### Core
111
+
112
+ - [core] refactor: remove manual `displayName` (#17845) @romgrk
113
+ - [code-infra] Document how to use `vitest` cli (#17847) @JCQuintas
114
+ - [code-infra] Increase charts export test timeout (#17909) @JCQuintas
115
+ - [code-infra] Set `isolatedModules=true` in tsconfig (#17781) @JCQuintas
116
+ - [infra] Ensure proper docs preview path resolution (#17863) @LukasTy
117
+
8
118
  ## 8.3.1
9
119
 
10
120
  _May 14, 2025_
@@ -57,6 +57,7 @@ const DataGridRaw = (0, _forwardRef.forwardRef)(function DataGrid(inProps, ref)
57
57
  * - [DataGrid API](https://mui.com/x/api/data-grid/data-grid/)
58
58
  */
59
59
  const DataGrid = exports.DataGrid = /*#__PURE__*/React.memo(DataGridRaw);
60
+ if (process.env.NODE_ENV !== "production") DataGrid.displayName = "DataGrid";
60
61
  DataGridRaw.propTypes = {
61
62
  // ----------------------------- Warning --------------------------------
62
63
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -8,6 +8,4 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.GridApiContext = void 0;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  const GridApiContext = exports.GridApiContext = /*#__PURE__*/React.createContext(undefined);
11
- if (process.env.NODE_ENV !== 'production') {
12
- GridApiContext.displayName = 'GridApiContext';
13
- }
11
+ if (process.env.NODE_ENV !== "production") GridApiContext.displayName = "GridApiContext";
@@ -21,4 +21,5 @@ const GridColumnUnsortedIcon = exports.GridColumnUnsortedIcon = /*#__PURE__*/Rea
21
21
  const [nextSortDirection] = sortingOrder;
22
22
  const Icon = nextSortDirection === 'asc' ? rootProps.slots.columnSortedAscendingIcon : rootProps.slots.columnSortedDescendingIcon;
23
23
  return Icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, (0, _extends2.default)({}, other)) : null;
24
- });
24
+ });
25
+ if (process.env.NODE_ENV !== "production") GridColumnUnsortedIcon.displayName = "GridColumnUnsortedIcon";
@@ -8,6 +8,4 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.GridConfigurationContext = void 0;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  const GridConfigurationContext = exports.GridConfigurationContext = /*#__PURE__*/React.createContext(undefined);
11
- if (process.env.NODE_ENV !== 'production') {
12
- GridConfigurationContext.displayName = 'GridConfigurationContext';
13
- }
11
+ if (process.env.NODE_ENV !== "production") GridConfigurationContext.displayName = "GridConfigurationContext";
@@ -253,6 +253,7 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
253
253
  rowNode: rowNode
254
254
  }, slotProps?.cell), column.field);
255
255
  };
256
+ if (process.env.NODE_ENV !== "production") getCell.displayName = "getCell";
256
257
  const leftCells = pinnedColumns.left.map((column, i) => {
257
258
  const indexRelativeToAllColumns = i;
258
259
  return getCell(column, i, indexRelativeToAllColumns, pinnedColumns.left.length, _constants.PinnedColumnPosition.LEFT);
@@ -267,4 +267,5 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
267
267
  value: _propTypes.default.any
268
268
  } : void 0;
269
269
  const renderActionsCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridActionsCell, (0, _extends2.default)({}, params));
270
- exports.renderActionsCell = renderActionsCell;
270
+ exports.renderActionsCell = renderActionsCell;
271
+ if (process.env.NODE_ENV !== "production") renderActionsCell.displayName = "renderActionsCell";
@@ -123,10 +123,12 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
123
123
  value: _propTypes.default.any
124
124
  } : void 0;
125
125
  const GridBooleanCell = exports.GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
126
+ if (process.env.NODE_ENV !== "production") GridBooleanCell.displayName = "GridBooleanCell";
126
127
  const renderBooleanCell = params => {
127
128
  if (params.field !== _constants.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && (0, _gridRowsUtils.isAutogeneratedRowNode)(params.rowNode)) {
128
129
  return '';
129
130
  }
130
131
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridBooleanCell, (0, _extends2.default)({}, params));
131
132
  };
132
- exports.renderBooleanCell = renderBooleanCell;
133
+ exports.renderBooleanCell = renderBooleanCell;
134
+ if (process.env.NODE_ENV !== "production") renderBooleanCell.displayName = "renderBooleanCell";
@@ -145,4 +145,5 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
145
145
  value: _propTypes.default.any
146
146
  } : void 0;
147
147
  const renderEditBooleanCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditBooleanCell, (0, _extends2.default)({}, params));
148
- exports.renderEditBooleanCell = renderEditBooleanCell;
148
+ exports.renderEditBooleanCell = renderEditBooleanCell;
149
+ if (process.env.NODE_ENV !== "production") renderEditBooleanCell.displayName = "renderEditBooleanCell";
@@ -199,4 +199,5 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
199
199
  value: _propTypes.default.any
200
200
  } : void 0;
201
201
  const renderEditDateCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditDateCell, (0, _extends2.default)({}, params));
202
- exports.renderEditDateCell = renderEditDateCell;
202
+ exports.renderEditDateCell = renderEditDateCell;
203
+ if (process.env.NODE_ENV !== "production") renderEditDateCell.displayName = "renderEditDateCell";
@@ -173,4 +173,5 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
173
173
  value: _propTypes.default.any
174
174
  } : void 0;
175
175
  const renderEditInputCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditInputCell, (0, _extends2.default)({}, params));
176
- exports.renderEditInputCell = renderEditInputCell;
176
+ exports.renderEditInputCell = renderEditInputCell;
177
+ if (process.env.NODE_ENV !== "production") renderEditInputCell.displayName = "renderEditInputCell";
@@ -195,4 +195,5 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
195
195
  value: _propTypes.default.any
196
196
  } : void 0;
197
197
  const renderEditSingleSelectCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditSingleSelectCell, (0, _extends2.default)({}, params));
198
- exports.renderEditSingleSelectCell = renderEditSingleSelectCell;
198
+ exports.renderEditSingleSelectCell = renderEditSingleSelectCell;
199
+ if (process.env.NODE_ENV !== "production") renderEditSingleSelectCell.displayName = "renderEditSingleSelectCell";
@@ -68,4 +68,5 @@ const ColumnHeaderMenuIcon = exports.ColumnHeaderMenuIcon = /*#__PURE__*/React.m
68
68
  }))
69
69
  }))
70
70
  });
71
- });
71
+ });
72
+ if (process.env.NODE_ENV !== "production") ColumnHeaderMenuIcon.displayName = "ColumnHeaderMenuIcon";
@@ -118,7 +118,7 @@ function GridColumnHeaderItem(props) {
118
118
  onDragStart: publish('columnHeaderDragStart'),
119
119
  onDragEnter: publish('columnHeaderDragEnter'),
120
120
  onDragOver: publish('columnHeaderDragOver'),
121
- onDragEnd: publish('columnHeaderDragEnd')
121
+ onDragEndCapture: publish('columnHeaderDragEnd')
122
122
  } : {}, [isDraggable, publish]);
123
123
  const columnHeaderSeparatorProps = React.useMemo(() => ({
124
124
  onMouseDown: publish('columnSeparatorMouseDown'),
@@ -66,6 +66,7 @@ function GridColumnHeaderSeparatorRaw(props) {
66
66
  );
67
67
  }
68
68
  const GridColumnHeaderSeparator = exports.GridColumnHeaderSeparator = /*#__PURE__*/React.memo(GridColumnHeaderSeparatorRaw);
69
+ if (process.env.NODE_ENV !== "production") GridColumnHeaderSeparator.displayName = "GridColumnHeaderSeparator";
69
70
  process.env.NODE_ENV !== "production" ? GridColumnHeaderSeparatorRaw.propTypes = {
70
71
  // ----------------------------- Warning --------------------------------
71
72
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -20,6 +20,7 @@ function GridColumnHeaderSortIconRaw(props) {
20
20
  });
21
21
  }
22
22
  const GridColumnHeaderSortIcon = exports.GridColumnHeaderSortIcon = /*#__PURE__*/React.memo(GridColumnHeaderSortIconRaw);
23
+ if (process.env.NODE_ENV !== "production") GridColumnHeaderSortIcon.displayName = "GridColumnHeaderSortIcon";
23
24
  process.env.NODE_ENV !== "production" ? GridColumnHeaderSortIconRaw.propTypes = {
24
25
  // ----------------------------- Warning --------------------------------
25
26
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -663,7 +663,7 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
663
663
  borderTop: 'none'
664
664
  }
665
665
  },
666
- [`&.${_gridClasses.gridClasses['root--disableUserSelection']} .${_gridClasses.gridClasses.cell}`]: {
666
+ [`&.${_gridClasses.gridClasses['root--disableUserSelection']}`]: {
667
667
  userSelect: 'none'
668
668
  },
669
669
  [`& .${_gridClasses.gridClasses['row--dynamicHeight']} > .${_gridClasses.gridClasses.cell}`]: {
@@ -10,6 +10,7 @@ exports.useGridPanelContext = useGridPanelContext;
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  const GridPanelContext = exports.GridPanelContext = /*#__PURE__*/React.createContext(undefined);
13
+ if (process.env.NODE_ENV !== "production") GridPanelContext.displayName = "GridPanelContext";
13
14
  function useGridPanelContext() {
14
15
  const context = React.useContext(GridPanelContext);
15
16
  if (context === undefined) {
@@ -8,6 +8,7 @@ exports.QuickFilterContext = void 0;
8
8
  exports.useQuickFilterContext = useQuickFilterContext;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  const QuickFilterContext = exports.QuickFilterContext = /*#__PURE__*/React.createContext(undefined);
11
+ if (process.env.NODE_ENV !== "production") QuickFilterContext.displayName = "QuickFilterContext";
11
12
  function useQuickFilterContext() {
12
13
  const context = React.useContext(QuickFilterContext);
13
14
  if (context === undefined) {
@@ -19,6 +19,7 @@ var _gridClasses = require("../../constants/gridClasses");
19
19
  var _useGridComponentRenderer = require("../../hooks/utils/useGridComponentRenderer");
20
20
  var _ToolbarContext = require("./ToolbarContext");
21
21
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
22
+ var _utils = require("./utils");
22
23
  var _jsxRuntime = require("react/jsx-runtime");
23
24
  const _excluded = ["render", "className"];
24
25
  const useUtilityClasses = ownerState => {
@@ -67,21 +68,11 @@ const Toolbar = exports.Toolbar = (0, _forwardRef.forwardRef)(function Toolbar(p
67
68
  const classes = useUtilityClasses(rootProps);
68
69
  const [focusableItemId, setFocusableItemId] = React.useState(null);
69
70
  const [items, setItems] = React.useState([]);
70
- const registerItem = React.useCallback((id, itemRef) => {
71
- setItems(prevItems => [...prevItems, {
72
- id,
73
- ref: itemRef
74
- }]);
75
- }, []);
76
- const unregisterItem = React.useCallback(id => {
77
- setItems(prevItems => prevItems.filter(i => i.id !== id));
78
- if (focusableItemId === id) {
79
- setFocusableItemId(null);
80
- }
81
- }, [focusableItemId]);
71
+ const getSortedItems = React.useCallback(() => items.sort(_utils.sortByDocumentPosition), [items]);
82
72
  const findEnabledItem = React.useCallback((startIndex, step, wrap = true) => {
83
73
  let index = startIndex;
84
- const itemCount = items.length;
74
+ const sortedItems = getSortedItems();
75
+ const itemCount = sortedItems.length;
85
76
 
86
77
  // Look for enabled items in the specified direction
87
78
  for (let i = 0; i < itemCount; i += 1) {
@@ -101,53 +92,93 @@ const Toolbar = exports.Toolbar = (0, _forwardRef.forwardRef)(function Toolbar(p
101
92
  }
102
93
 
103
94
  // Return if we found an enabled item
104
- if (!items[index].ref.current?.disabled && items[index].ref.current?.ariaDisabled !== 'true') {
95
+ if (!sortedItems[index].ref.current?.disabled && sortedItems[index].ref.current?.ariaDisabled !== 'true') {
105
96
  return index;
106
97
  }
107
98
  }
108
99
 
109
100
  // If we've checked all items and found none enabled
110
101
  return -1;
111
- }, [items]);
102
+ }, [getSortedItems]);
103
+ const registerItem = React.useCallback((id, itemRef) => {
104
+ setItems(prevItems => [...prevItems, {
105
+ id,
106
+ ref: itemRef
107
+ }]);
108
+ }, []);
109
+ const unregisterItem = React.useCallback(id => {
110
+ setItems(prevItems => prevItems.filter(i => i.id !== id));
111
+ }, []);
112
112
  const onItemKeyDown = React.useCallback(event => {
113
113
  if (!focusableItemId) {
114
114
  return;
115
115
  }
116
- const currentIndex = items.findIndex(item => item.id === focusableItemId);
116
+ const sortedItems = getSortedItems();
117
+ const focusableItemIndex = sortedItems.findIndex(item => item.id === focusableItemId);
117
118
  let newIndex = -1;
118
119
  if (event.key === 'ArrowRight') {
119
120
  event.preventDefault();
120
- newIndex = findEnabledItem(currentIndex, 1);
121
+ newIndex = findEnabledItem(focusableItemIndex, 1);
121
122
  } else if (event.key === 'ArrowLeft') {
122
123
  event.preventDefault();
123
- newIndex = findEnabledItem(currentIndex, -1);
124
+ newIndex = findEnabledItem(focusableItemIndex, -1);
124
125
  } else if (event.key === 'Home') {
125
126
  event.preventDefault();
126
127
  newIndex = findEnabledItem(-1, 1, false);
127
128
  } else if (event.key === 'End') {
128
129
  event.preventDefault();
129
- newIndex = findEnabledItem(items.length, -1, false);
130
+ newIndex = findEnabledItem(sortedItems.length, -1, false);
130
131
  }
131
- if (newIndex >= 0 && newIndex < items.length) {
132
- const item = items[newIndex];
132
+
133
+ // TODO: Check why this is necessary
134
+ if (newIndex >= 0 && newIndex < sortedItems.length) {
135
+ const item = sortedItems[newIndex];
133
136
  setFocusableItemId(item.id);
134
137
  item.ref.current?.focus();
135
138
  }
136
- }, [items, focusableItemId, findEnabledItem]);
139
+ }, [getSortedItems, focusableItemId, findEnabledItem]);
137
140
  const onItemFocus = React.useCallback(id => {
138
141
  if (focusableItemId !== id) {
139
142
  setFocusableItemId(id);
140
143
  }
141
- }, [focusableItemId]);
144
+ }, [focusableItemId, setFocusableItemId]);
142
145
  const onItemDisabled = React.useCallback(id => {
143
- const currentIndex = items.findIndex(item => item.id === id);
146
+ const sortedItems = getSortedItems();
147
+ const currentIndex = sortedItems.findIndex(item => item.id === id);
144
148
  const newIndex = findEnabledItem(currentIndex, 1);
145
- if (newIndex >= 0 && newIndex < items.length) {
146
- const item = items[newIndex];
149
+ if (newIndex >= 0 && newIndex < sortedItems.length) {
150
+ const item = sortedItems[newIndex];
147
151
  setFocusableItemId(item.id);
148
152
  item.ref.current?.focus();
149
153
  }
150
- }, [items, findEnabledItem]);
154
+ }, [getSortedItems, findEnabledItem]);
155
+ React.useEffect(() => {
156
+ const sortedItems = getSortedItems();
157
+ if (sortedItems.length > 0) {
158
+ // Set initial focusable item
159
+ if (!focusableItemId) {
160
+ setFocusableItemId(sortedItems[0].id);
161
+ return;
162
+ }
163
+ const focusableItemIndex = sortedItems.findIndex(item => item.id === focusableItemId);
164
+ if (!sortedItems[focusableItemIndex]) {
165
+ // Last item has been removed from the items array
166
+ const item = sortedItems[sortedItems.length - 1];
167
+ if (item) {
168
+ setFocusableItemId(item.id);
169
+ item.ref.current?.focus();
170
+ }
171
+ } else if (focusableItemIndex === -1) {
172
+ // Focused item has been removed from the items array
173
+ const item = sortedItems[focusableItemIndex];
174
+ if (item) {
175
+ setFocusableItemId(item.id);
176
+ item.ref.current?.focus();
177
+ }
178
+ }
179
+ }
180
+ // eslint-disable-next-line react-hooks/exhaustive-deps
181
+ }, [getSortedItems, findEnabledItem]);
151
182
  const contextValue = React.useMemo(() => ({
152
183
  focusableItemId,
153
184
  registerItem,
@@ -164,11 +195,6 @@ const Toolbar = exports.Toolbar = (0, _forwardRef.forwardRef)(function Toolbar(p
164
195
  }, other, {
165
196
  ref
166
197
  }));
167
- React.useEffect(() => {
168
- if (items.length > 0) {
169
- setFocusableItemId(items[0].id);
170
- }
171
- }, [items]);
172
198
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToolbarContext.ToolbarContext.Provider, {
173
199
  value: contextValue,
174
200
  children: element
@@ -8,6 +8,7 @@ exports.ToolbarContext = void 0;
8
8
  exports.useToolbarContext = useToolbarContext;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  const ToolbarContext = exports.ToolbarContext = /*#__PURE__*/React.createContext(undefined);
11
+ if (process.env.NODE_ENV !== "production") ToolbarContext.displayName = "ToolbarContext";
11
12
  function useToolbarContext() {
12
13
  const context = React.useContext(ToolbarContext);
13
14
  if (context === undefined) {
@@ -0,0 +1,5 @@
1
+ export declare function sortByDocumentPosition(a: {
2
+ ref: React.RefObject<HTMLButtonElement | null>;
3
+ }, b: {
4
+ ref: React.RefObject<HTMLButtonElement | null>;
5
+ }): 0 | 1 | -1;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sortByDocumentPosition = sortByDocumentPosition;
7
+ /* eslint-disable no-bitwise */
8
+ function sortByDocumentPosition(a, b) {
9
+ if (!a.ref.current || !b.ref.current) {
10
+ return 0;
11
+ }
12
+ const position = a.ref.current.compareDocumentPosition(b.ref.current);
13
+ if (!position) {
14
+ return 0;
15
+ }
16
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) {
17
+ return -1;
18
+ }
19
+ if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) {
20
+ return 1;
21
+ }
22
+ return 0;
23
+ }
@@ -8,6 +8,4 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.GridRootPropsContext = void 0;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  const GridRootPropsContext = exports.GridRootPropsContext = /*#__PURE__*/React.createContext(undefined);
11
- if (process.env.NODE_ENV !== 'production') {
12
- GridRootPropsContext.displayName = 'GridRootPropsContext';
13
- }
11
+ if (process.env.NODE_ENV !== "production") GridRootPropsContext.displayName = "GridRootPropsContext";
@@ -50,6 +50,7 @@ const DataGridRaw = forwardRef(function DataGrid(inProps, ref) {
50
50
  * - [DataGrid API](https://mui.com/x/api/data-grid/data-grid/)
51
51
  */
52
52
  export const DataGrid = /*#__PURE__*/React.memo(DataGridRaw);
53
+ if (process.env.NODE_ENV !== "production") DataGrid.displayName = "DataGrid";
53
54
  DataGridRaw.propTypes = {
54
55
  // ----------------------------- Warning --------------------------------
55
56
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -2,6 +2,4 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  export const GridApiContext = /*#__PURE__*/React.createContext(undefined);
5
- if (process.env.NODE_ENV !== 'production') {
6
- GridApiContext.displayName = 'GridApiContext';
7
- }
5
+ if (process.env.NODE_ENV !== "production") GridApiContext.displayName = "GridApiContext";
@@ -13,4 +13,5 @@ export const GridColumnUnsortedIcon = /*#__PURE__*/React.memo(function GridColum
13
13
  const [nextSortDirection] = sortingOrder;
14
14
  const Icon = nextSortDirection === 'asc' ? rootProps.slots.columnSortedAscendingIcon : rootProps.slots.columnSortedDescendingIcon;
15
15
  return Icon ? /*#__PURE__*/_jsx(Icon, _extends({}, other)) : null;
16
- });
16
+ });
17
+ if (process.env.NODE_ENV !== "production") GridColumnUnsortedIcon.displayName = "GridColumnUnsortedIcon";
@@ -2,6 +2,4 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  export const GridConfigurationContext = /*#__PURE__*/React.createContext(undefined);
5
- if (process.env.NODE_ENV !== 'production') {
6
- GridConfigurationContext.displayName = 'GridConfigurationContext';
7
- }
5
+ if (process.env.NODE_ENV !== "production") GridConfigurationContext.displayName = "GridConfigurationContext";
@@ -246,6 +246,7 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
246
246
  rowNode: rowNode
247
247
  }, slotProps?.cell), column.field);
248
248
  };
249
+ if (process.env.NODE_ENV !== "production") getCell.displayName = "getCell";
249
250
  const leftCells = pinnedColumns.left.map((column, i) => {
250
251
  const indexRelativeToAllColumns = i;
251
252
  return getCell(column, i, indexRelativeToAllColumns, pinnedColumns.left.length, PinnedColumnPosition.LEFT);
@@ -258,4 +258,5 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
258
258
  value: PropTypes.any
259
259
  } : void 0;
260
260
  export { GridActionsCell };
261
- export const renderActionsCell = params => /*#__PURE__*/_jsx(GridActionsCell, _extends({}, params));
261
+ export const renderActionsCell = params => /*#__PURE__*/_jsx(GridActionsCell, _extends({}, params));
262
+ if (process.env.NODE_ENV !== "production") renderActionsCell.displayName = "renderActionsCell";
@@ -115,10 +115,12 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
115
115
  value: PropTypes.any
116
116
  } : void 0;
117
117
  const GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
118
+ if (process.env.NODE_ENV !== "production") GridBooleanCell.displayName = "GridBooleanCell";
118
119
  export { GridBooleanCell };
119
120
  export const renderBooleanCell = params => {
120
121
  if (params.field !== GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && isAutogeneratedRowNode(params.rowNode)) {
121
122
  return '';
122
123
  }
123
124
  return /*#__PURE__*/_jsx(GridBooleanCell, _extends({}, params));
124
- };
125
+ };
126
+ if (process.env.NODE_ENV !== "production") renderBooleanCell.displayName = "renderBooleanCell";
@@ -136,4 +136,5 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
136
136
  value: PropTypes.any
137
137
  } : void 0;
138
138
  export { GridEditBooleanCell };
139
- export const renderEditBooleanCell = params => /*#__PURE__*/_jsx(GridEditBooleanCell, _extends({}, params));
139
+ export const renderEditBooleanCell = params => /*#__PURE__*/_jsx(GridEditBooleanCell, _extends({}, params));
140
+ if (process.env.NODE_ENV !== "production") renderEditBooleanCell.displayName = "renderEditBooleanCell";
@@ -190,4 +190,5 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
190
190
  value: PropTypes.any
191
191
  } : void 0;
192
192
  export { GridEditDateCell };
193
- export const renderEditDateCell = params => /*#__PURE__*/_jsx(GridEditDateCell, _extends({}, params));
193
+ export const renderEditDateCell = params => /*#__PURE__*/_jsx(GridEditDateCell, _extends({}, params));
194
+ if (process.env.NODE_ENV !== "production") renderEditDateCell.displayName = "renderEditDateCell";
@@ -165,4 +165,5 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
165
165
  value: PropTypes.any
166
166
  } : void 0;
167
167
  export { GridEditInputCell };
168
- export const renderEditInputCell = params => /*#__PURE__*/_jsx(GridEditInputCell, _extends({}, params));
168
+ export const renderEditInputCell = params => /*#__PURE__*/_jsx(GridEditInputCell, _extends({}, params));
169
+ if (process.env.NODE_ENV !== "production") renderEditInputCell.displayName = "renderEditInputCell";
@@ -186,4 +186,5 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
186
186
  value: PropTypes.any
187
187
  } : void 0;
188
188
  export { GridEditSingleSelectCell };
189
- export const renderEditSingleSelectCell = params => /*#__PURE__*/_jsx(GridEditSingleSelectCell, _extends({}, params));
189
+ export const renderEditSingleSelectCell = params => /*#__PURE__*/_jsx(GridEditSingleSelectCell, _extends({}, params));
190
+ if (process.env.NODE_ENV !== "production") renderEditSingleSelectCell.displayName = "renderEditSingleSelectCell";
@@ -60,4 +60,5 @@ export const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
60
60
  }))
61
61
  }))
62
62
  });
63
- });
63
+ });
64
+ if (process.env.NODE_ENV !== "production") ColumnHeaderMenuIcon.displayName = "ColumnHeaderMenuIcon";
@@ -110,7 +110,7 @@ function GridColumnHeaderItem(props) {
110
110
  onDragStart: publish('columnHeaderDragStart'),
111
111
  onDragEnter: publish('columnHeaderDragEnter'),
112
112
  onDragOver: publish('columnHeaderDragOver'),
113
- onDragEnd: publish('columnHeaderDragEnd')
113
+ onDragEndCapture: publish('columnHeaderDragEnd')
114
114
  } : {}, [isDraggable, publish]);
115
115
  const columnHeaderSeparatorProps = React.useMemo(() => ({
116
116
  onMouseDown: publish('columnSeparatorMouseDown'),
@@ -58,6 +58,7 @@ function GridColumnHeaderSeparatorRaw(props) {
58
58
  );
59
59
  }
60
60
  const GridColumnHeaderSeparator = /*#__PURE__*/React.memo(GridColumnHeaderSeparatorRaw);
61
+ if (process.env.NODE_ENV !== "production") GridColumnHeaderSeparator.displayName = "GridColumnHeaderSeparator";
61
62
  process.env.NODE_ENV !== "production" ? GridColumnHeaderSeparatorRaw.propTypes = {
62
63
  // ----------------------------- Warning --------------------------------
63
64
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -12,6 +12,7 @@ function GridColumnHeaderSortIconRaw(props) {
12
12
  });
13
13
  }
14
14
  const GridColumnHeaderSortIcon = /*#__PURE__*/React.memo(GridColumnHeaderSortIconRaw);
15
+ if (process.env.NODE_ENV !== "production") GridColumnHeaderSortIcon.displayName = "GridColumnHeaderSortIcon";
15
16
  process.env.NODE_ENV !== "production" ? GridColumnHeaderSortIconRaw.propTypes = {
16
17
  // ----------------------------- Warning --------------------------------
17
18
  // | These PropTypes are generated from the TypeScript type definitions |