@mui/x-data-grid 9.12.0 → 9.13.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 (74) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/DataGrid/DataGrid.js +1 -1
  3. package/DataGrid/DataGrid.mjs +1 -1
  4. package/components/GridPagination.js +1 -1
  5. package/components/GridPagination.mjs +1 -1
  6. package/components/GridRow.d.mts +1 -0
  7. package/components/GridRow.d.ts +1 -0
  8. package/components/GridRow.js +41 -6
  9. package/components/GridRow.mjs +41 -6
  10. package/components/cell/GridCell.js +7 -4
  11. package/components/cell/GridCell.mjs +7 -4
  12. package/components/cell/GridEditBooleanCell.d.mts +1 -1
  13. package/components/cell/GridEditBooleanCell.d.ts +1 -1
  14. package/components/cell/GridEditBooleanCell.js +4 -4
  15. package/components/cell/GridEditBooleanCell.mjs +4 -4
  16. package/components/cell/GridEditDateCell.d.mts +1 -1
  17. package/components/cell/GridEditDateCell.d.ts +1 -1
  18. package/components/cell/GridEditDateCell.js +5 -5
  19. package/components/cell/GridEditDateCell.mjs +5 -5
  20. package/components/cell/GridEditInputCell.d.mts +1 -1
  21. package/components/cell/GridEditInputCell.d.ts +1 -1
  22. package/components/cell/GridEditInputCell.js +1 -1
  23. package/components/cell/GridEditInputCell.mjs +1 -1
  24. package/components/cell/GridEditLongTextCell.d.mts +1 -1
  25. package/components/cell/GridEditLongTextCell.d.ts +1 -1
  26. package/components/cell/GridEditLongTextCell.js +2 -2
  27. package/components/cell/GridEditLongTextCell.mjs +2 -2
  28. package/components/cell/GridEditSingleSelectCell.d.mts +1 -1
  29. package/components/cell/GridEditSingleSelectCell.d.ts +1 -1
  30. package/components/cell/GridEditSingleSelectCell.js +4 -4
  31. package/components/cell/GridEditSingleSelectCell.mjs +4 -4
  32. package/components/toolbarV8/Toolbar.d.mts +5 -1
  33. package/components/toolbarV8/Toolbar.d.ts +5 -1
  34. package/components/toolbarV8/Toolbar.js +34 -12
  35. package/components/toolbarV8/Toolbar.mjs +33 -11
  36. package/hooks/core/useGridVirtualizer.js +14 -1
  37. package/hooks/core/useGridVirtualizer.mjs +14 -1
  38. package/hooks/features/dataSource/models.d.mts +2 -2
  39. package/hooks/features/dataSource/models.d.ts +2 -2
  40. package/hooks/features/dataSource/useGridDataSourceBase.js +11 -7
  41. package/hooks/features/dataSource/useGridDataSourceBase.mjs +12 -8
  42. package/hooks/features/pivoting/gridPivotingInterfaces.d.mts +2 -2
  43. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +2 -2
  44. package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  45. package/hooks/features/rowSelection/useGridRowSelection.mjs +2 -2
  46. package/hooks/features/rows/gridRowsUtils.d.mts +37 -3
  47. package/hooks/features/rows/gridRowsUtils.d.ts +37 -3
  48. package/hooks/features/rows/gridRowsUtils.js +120 -23
  49. package/hooks/features/rows/gridRowsUtils.mjs +115 -22
  50. package/hooks/features/rows/useGridRows.js +10 -1
  51. package/hooks/features/rows/useGridRows.mjs +10 -1
  52. package/index.js +1 -1
  53. package/index.mjs +1 -1
  54. package/internals/index.d.mts +2 -2
  55. package/internals/index.d.ts +2 -2
  56. package/internals/index.js +28 -0
  57. package/internals/index.mjs +2 -2
  58. package/material/variables.d.mts +6 -1
  59. package/material/variables.d.ts +6 -1
  60. package/material/variables.js +17 -3
  61. package/material/variables.mjs +14 -4
  62. package/models/api/gridRowApi.d.mts +7 -7
  63. package/models/api/gridRowApi.d.ts +7 -7
  64. package/models/gridDataSource.d.mts +3 -0
  65. package/models/gridDataSource.d.ts +3 -0
  66. package/models/gridRows.d.mts +28 -1
  67. package/models/gridRows.d.ts +28 -1
  68. package/models/props/DataGridProps.d.mts +3 -3
  69. package/models/props/DataGridProps.d.ts +3 -3
  70. package/package.json +6 -6
  71. package/utils/keyboardUtils.d.mts +1 -0
  72. package/utils/keyboardUtils.d.ts +1 -0
  73. package/utils/keyboardUtils.js +6 -0
  74. package/utils/keyboardUtils.mjs +5 -0
@@ -7,7 +7,7 @@ export interface GridEditInputCellProps extends GridRenderEditCellParams {
7
7
  * Callback called when the value is changed by the user.
8
8
  * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
9
9
  * @param {Date | null} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
10
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
10
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
11
11
  */
12
12
  onValueChange?: (event: React.ChangeEvent<HTMLInputElement>, newValue: string) => Promise<void> | void;
13
13
  slotProps?: {
@@ -153,7 +153,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes /* remove-pr
153
153
  * Callback called when the value is changed by the user.
154
154
  * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
155
155
  * @param {Date | null} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
156
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
156
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
157
157
  */
158
158
  onValueChange: _propTypes.default.func,
159
159
  /**
@@ -146,7 +146,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes /* remove-pr
146
146
  * Callback called when the value is changed by the user.
147
147
  * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
148
148
  * @param {Date | null} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
149
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
149
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
150
150
  */
151
151
  onValueChange: PropTypes.func,
152
152
  /**
@@ -7,7 +7,7 @@ export interface GridEditLongTextCellProps extends GridRenderEditCellParams<any,
7
7
  * Callback called when the value is changed by the user.
8
8
  * @param {React.ChangeEvent<HTMLTextAreaElement>} event The event source of the callback.
9
9
  * @param {string} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
10
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
10
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
11
11
  */
12
12
  onValueChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, newValue: string) => Promise<void> | void;
13
13
  /**
@@ -7,7 +7,7 @@ export interface GridEditLongTextCellProps extends GridRenderEditCellParams<any,
7
7
  * Callback called when the value is changed by the user.
8
8
  * @param {React.ChangeEvent<HTMLTextAreaElement>} event The event source of the callback.
9
9
  * @param {string} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
10
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
10
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
11
11
  */
12
12
  onValueChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, newValue: string) => Promise<void> | void;
13
13
  /**
@@ -217,7 +217,7 @@ process.env.NODE_ENV !== "production" ? GridEditLongTextCell.propTypes /* remove
217
217
  * Callback called when the value is changed by the user.
218
218
  * @param {React.ChangeEvent<HTMLTextAreaElement>} event The event source of the callback.
219
219
  * @param {string} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
220
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
220
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
221
221
  */
222
222
  onValueChange: _propTypes.default.func,
223
223
  /**
@@ -359,7 +359,7 @@ process.env.NODE_ENV !== "production" ? GridEditLongTextarea.propTypes /* remove
359
359
  * Callback called when the value is changed by the user.
360
360
  * @param {React.ChangeEvent<HTMLTextAreaElement>} event The event source of the callback.
361
361
  * @param {string} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
362
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
362
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
363
363
  */
364
364
  onValueChange: _propTypes.default.func,
365
365
  /**
@@ -209,7 +209,7 @@ process.env.NODE_ENV !== "production" ? GridEditLongTextCell.propTypes /* remove
209
209
  * Callback called when the value is changed by the user.
210
210
  * @param {React.ChangeEvent<HTMLTextAreaElement>} event The event source of the callback.
211
211
  * @param {string} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
212
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
212
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
213
213
  */
214
214
  onValueChange: PropTypes.func,
215
215
  /**
@@ -351,7 +351,7 @@ process.env.NODE_ENV !== "production" ? GridEditLongTextarea.propTypes /* remove
351
351
  * Callback called when the value is changed by the user.
352
352
  * @param {React.ChangeEvent<HTMLTextAreaElement>} event The event source of the callback.
353
353
  * @param {string} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
354
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
354
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
355
355
  */
356
356
  onValueChange: PropTypes.func,
357
357
  /**
@@ -6,7 +6,7 @@ export interface GridEditSingleSelectCellProps extends GridRenderEditCellParams
6
6
  * Callback called when the value is changed by the user.
7
7
  * @param {Event<any>} event The event source of the callback.
8
8
  * @param {any} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
9
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
9
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
10
10
  */
11
11
  onValueChange?: (event: Parameters<NonNullable<GridSlotProps['baseSelect']['onOpen']>>[0], newValue: any) => Promise<void> | void;
12
12
  /**
@@ -6,7 +6,7 @@ export interface GridEditSingleSelectCellProps extends GridRenderEditCellParams
6
6
  * Callback called when the value is changed by the user.
7
7
  * @param {Event<any>} event The event source of the callback.
8
8
  * @param {any} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
9
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
9
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
10
10
  */
11
11
  onValueChange?: (event: Parameters<NonNullable<GridSlotProps['baseSelect']['onOpen']>>[0], newValue: any) => Promise<void> | void;
12
12
  /**
@@ -70,14 +70,14 @@ function GridEditSingleSelectCell(props) {
70
70
  const target = event.target;
71
71
  // NativeSelect casts the value to a string.
72
72
  const formattedTargetValue = (0, _filterPanelUtils.getValueFromValueOptions)(target.value, valueOptions, getOptionValue);
73
- if (onValueChange) {
74
- await onValueChange(event, formattedTargetValue);
75
- }
76
73
  await apiRef.current.setEditCellValue({
77
74
  id,
78
75
  field,
79
76
  value: formattedTargetValue
80
77
  }, event);
78
+ if (onValueChange) {
79
+ await onValueChange(event, formattedTargetValue);
80
+ }
81
81
  };
82
82
  const handleClose = (event, reason) => {
83
83
  if (rootProps.editMode === _gridEditRowModel.GridEditModes.Row) {
@@ -174,7 +174,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes /* re
174
174
  * Callback called when the value is changed by the user.
175
175
  * @param {Event<any>} event The event source of the callback.
176
176
  * @param {any} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
177
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
177
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
178
178
  */
179
179
  onValueChange: _propTypes.default.func,
180
180
  /**
@@ -62,14 +62,14 @@ function GridEditSingleSelectCell(props) {
62
62
  const target = event.target;
63
63
  // NativeSelect casts the value to a string.
64
64
  const formattedTargetValue = getValueFromValueOptions(target.value, valueOptions, getOptionValue);
65
- if (onValueChange) {
66
- await onValueChange(event, formattedTargetValue);
67
- }
68
65
  await apiRef.current.setEditCellValue({
69
66
  id,
70
67
  field,
71
68
  value: formattedTargetValue
72
69
  }, event);
70
+ if (onValueChange) {
71
+ await onValueChange(event, formattedTargetValue);
72
+ }
73
73
  };
74
74
  const handleClose = (event, reason) => {
75
75
  if (rootProps.editMode === GridEditModes.Row) {
@@ -166,7 +166,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes /* re
166
166
  * Callback called when the value is changed by the user.
167
167
  * @param {Event<any>} event The event source of the callback.
168
168
  * @param {any} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
169
- * @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
169
+ * @returns {Promise<void> | void} A promise to be awaited after `apiRef.current.setEditCellValue` is called
170
170
  */
171
171
  onValueChange: PropTypes.func,
172
172
  /**
@@ -6,6 +6,10 @@ export type ToolbarProps = React.HTMLAttributes<HTMLDivElement> & {
6
6
  */
7
7
  render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
8
8
  };
9
+ /**
10
+ * The styled `<div />` element rendered by the `<Toolbar />` component.
11
+ * Use it to apply the toolbar styles to other elements, inside or outside of a Data Grid.
12
+ */
9
13
  declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
10
14
  /**
11
15
  * The top level Toolbar component that provides context to child components.
@@ -25,4 +29,4 @@ declare const Toolbar: React.ForwardRefExoticComponent<ToolbarProps> | React.For
25
29
  */
26
30
  render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
27
31
  } & React.RefAttributes<HTMLDivElement>>;
28
- export { Toolbar };
32
+ export { Toolbar, ToolbarRoot };
@@ -6,6 +6,10 @@ export type ToolbarProps = React.HTMLAttributes<HTMLDivElement> & {
6
6
  */
7
7
  render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
8
8
  };
9
+ /**
10
+ * The styled `<div />` element rendered by the `<Toolbar />` component.
11
+ * Use it to apply the toolbar styles to other elements, inside or outside of a Data Grid.
12
+ */
9
13
  declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
10
14
  /**
11
15
  * The top level Toolbar component that provides context to child components.
@@ -25,4 +29,4 @@ declare const Toolbar: React.ForwardRefExoticComponent<ToolbarProps> | React.For
25
29
  */
26
30
  render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
27
31
  } & React.RefAttributes<HTMLDivElement>>;
28
- export { Toolbar };
32
+ export { Toolbar, ToolbarRoot };
@@ -6,7 +6,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.Toolbar = void 0;
9
+ exports.ToolbarRoot = exports.Toolbar = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var React = _interopRequireWildcard(require("react"));
@@ -18,6 +18,7 @@ var _forwardRef = require("@mui/x-internals/forwardRef");
18
18
  var _useComponentRenderer = require("@mui/x-internals/useComponentRenderer");
19
19
  var _ToolbarContext = require("@mui/x-internals/ToolbarContext");
20
20
  var _cssVariables = require("../../constants/cssVariables");
21
+ var _variables = require("../../material/variables");
21
22
  var _gridClasses = require("../../constants/gridClasses");
22
23
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
23
24
  var _jsxRuntime = require("react/jsx-runtime");
@@ -31,19 +32,40 @@ const useUtilityClasses = ownerState => {
31
32
  };
32
33
  return (0, _composeClasses.default)(slots, _gridClasses.getDataGridUtilityClass, classes);
33
34
  };
34
- const ToolbarRoot = (0, _styles.styled)('div', {
35
+
36
+ /**
37
+ * The styled `<div />` element rendered by the `<Toolbar />` component.
38
+ * Use it to apply the toolbar styles to other elements, inside or outside of a Data Grid.
39
+ */
40
+ const ToolbarRoot = exports.ToolbarRoot = (0, _styles.styled)('div', {
35
41
  name: 'MuiDataGrid',
36
42
  slot: 'Toolbar'
37
- })({
38
- flex: '0 1 1px',
39
- display: 'flex',
40
- alignItems: 'center',
41
- justifyContent: 'end',
42
- gap: _cssVariables.vars.spacing(0.25),
43
- padding: _cssVariables.vars.spacing(0.75),
44
- minHeight: 52,
45
- boxSizing: 'border-box',
46
- borderBottom: `1px solid ${_cssVariables.vars.colors.border.base}`
43
+ })(({
44
+ theme
45
+ }) => {
46
+ // The Data Grid CSS variables are only defined on the Data Grid root element, so they are
47
+ // declared with a fallback to keep the styles working when rendered outside of a Data Grid.
48
+ const spacingUnit = `var(${_cssVariables.vars.keys.spacingUnit}, ${(0, _variables.getSpacingUnit)(theme)})`;
49
+ const borderColor = `var(${_cssVariables.vars.keys.colors.border.base}, ${(0, _variables.getBorderColor)(theme)})`;
50
+ const background = `var(${_cssVariables.vars.keys.colors.background.base}, ${(0, _variables.getBackgroundBase)(theme)})`;
51
+ const foreground = `var(${_cssVariables.vars.keys.colors.foreground.base}, ${(theme.vars || theme).palette.text.primary})`;
52
+ const fontBody = (0, _variables.getFontBody)(theme);
53
+ return {
54
+ flex: '0 1 1px',
55
+ display: 'flex',
56
+ alignItems: 'center',
57
+ justifyContent: 'end',
58
+ gap: `calc(${spacingUnit} * 0.25)`,
59
+ padding: `calc(${spacingUnit} * 0.75)`,
60
+ minHeight: 52,
61
+ boxSizing: 'border-box',
62
+ borderBottom: `1px solid ${borderColor}`,
63
+ // Inherited from the Data Grid root inside a grid, declared here so the component keeps
64
+ // matching it when rendered on its own.
65
+ backgroundColor: background,
66
+ color: foreground,
67
+ font: fontBody ? `var(${_cssVariables.vars.keys.typography.font.body}, ${fontBody})` : undefined
68
+ };
47
69
  });
48
70
 
49
71
  /**
@@ -12,6 +12,7 @@ import { forwardRef } from '@mui/x-internals/forwardRef';
12
12
  import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
13
13
  import { ToolbarContextProvider } from '@mui/x-internals/ToolbarContext';
14
14
  import { vars } from "../../constants/cssVariables.mjs";
15
+ import { getBackgroundBase, getBorderColor, getFontBody, getSpacingUnit } from "../../material/variables.mjs";
15
16
  import { getDataGridUtilityClass } from "../../constants/gridClasses.mjs";
16
17
  import { useGridRootProps } from "../../hooks/utils/useGridRootProps.mjs";
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -24,19 +25,40 @@ const useUtilityClasses = ownerState => {
24
25
  };
25
26
  return composeClasses(slots, getDataGridUtilityClass, classes);
26
27
  };
28
+
29
+ /**
30
+ * The styled `<div />` element rendered by the `<Toolbar />` component.
31
+ * Use it to apply the toolbar styles to other elements, inside or outside of a Data Grid.
32
+ */
27
33
  const ToolbarRoot = styled('div', {
28
34
  name: 'MuiDataGrid',
29
35
  slot: 'Toolbar'
30
- })({
31
- flex: '0 1 1px',
32
- display: 'flex',
33
- alignItems: 'center',
34
- justifyContent: 'end',
35
- gap: vars.spacing(0.25),
36
- padding: vars.spacing(0.75),
37
- minHeight: 52,
38
- boxSizing: 'border-box',
39
- borderBottom: `1px solid ${vars.colors.border.base}`
36
+ })(({
37
+ theme
38
+ }) => {
39
+ // The Data Grid CSS variables are only defined on the Data Grid root element, so they are
40
+ // declared with a fallback to keep the styles working when rendered outside of a Data Grid.
41
+ const spacingUnit = `var(${vars.keys.spacingUnit}, ${getSpacingUnit(theme)})`;
42
+ const borderColor = `var(${vars.keys.colors.border.base}, ${getBorderColor(theme)})`;
43
+ const background = `var(${vars.keys.colors.background.base}, ${getBackgroundBase(theme)})`;
44
+ const foreground = `var(${vars.keys.colors.foreground.base}, ${(theme.vars || theme).palette.text.primary})`;
45
+ const fontBody = getFontBody(theme);
46
+ return {
47
+ flex: '0 1 1px',
48
+ display: 'flex',
49
+ alignItems: 'center',
50
+ justifyContent: 'end',
51
+ gap: `calc(${spacingUnit} * 0.25)`,
52
+ padding: `calc(${spacingUnit} * 0.75)`,
53
+ minHeight: 52,
54
+ boxSizing: 'border-box',
55
+ borderBottom: `1px solid ${borderColor}`,
56
+ // Inherited from the Data Grid root inside a grid, declared here so the component keeps
57
+ // matching it when rendered on its own.
58
+ backgroundColor: background,
59
+ color: foreground,
60
+ font: fontBody ? `var(${vars.keys.typography.font.body}, ${fontBody})` : undefined
61
+ };
40
62
  });
41
63
 
42
64
  /**
@@ -82,4 +104,4 @@ process.env.NODE_ENV !== "production" ? Toolbar.propTypes /* remove-proptypes */
82
104
  */
83
105
  render: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
84
106
  } : void 0;
85
- export { Toolbar };
107
+ export { Toolbar, ToolbarRoot };
@@ -67,6 +67,18 @@ function useGridVirtualizer() {
67
67
  listView
68
68
  } = rootProps;
69
69
  const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
70
+ // Convert visible row-header columns to their indexes once per column-model change. Each GridRow
71
+ // uses this ordered list to render those cells even when they fall outside its horizontal render
72
+ // context. This keeps the row-identifying cells available to assistive technology while scrolling.
73
+ const retainedColumnIndexes = React.useMemo(() => {
74
+ const indexes = [];
75
+ visibleColumns.forEach((column, index) => {
76
+ if (column.rowHeader) {
77
+ indexes.push(index);
78
+ }
79
+ });
80
+ return indexes;
81
+ }, [visibleColumns]);
70
82
  const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
71
83
  const pinnedColumns = (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef);
72
84
  const rowSelectionManager = (0, _useGridSelector.useGridSelector)(apiRef, _rowSelection.gridRowSelectionManagerSelector);
@@ -219,6 +231,7 @@ function useGridVirtualizer() {
219
231
  rowHeight: params.baseRowHeight,
220
232
  pinnedColumns: pinnedColumns,
221
233
  visibleColumns: visibleColumns,
234
+ retainedColumnIndexes: retainedColumnIndexes,
222
235
  firstColumnIndex: params.firstColumnIndex,
223
236
  lastColumnIndex: params.lastColumnIndex,
224
237
  focusedColumnIndex: params.focusedColumnIndex,
@@ -228,7 +241,7 @@ function useGridVirtualizer() {
228
241
  showBottomBorder: params.showBottomBorder,
229
242
  scrollbarWidth: verticalScrollbarWidth,
230
243
  gridHasFiller: hasFiller
231
- }, rowSlotProps), params.id), [columnsTotalWidth, hasFiller, isRowSelected, pinnedColumns, RowSlot, rowSlotProps, verticalScrollbarWidth, visibleColumns]),
244
+ }, rowSlotProps), params.id), [columnsTotalWidth, hasFiller, isRowSelected, pinnedColumns, retainedColumnIndexes, RowSlot, rowSlotProps, verticalScrollbarWidth, visibleColumns]),
232
245
  renderInfiniteLoadingTrigger: React.useCallback(id => apiRef.current.getInfiniteLoadingTriggerElement?.({
233
246
  lastRowId: id
234
247
  }), [apiRef])
@@ -59,6 +59,18 @@ export function useGridVirtualizer() {
59
59
  listView
60
60
  } = rootProps;
61
61
  const visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
62
+ // Convert visible row-header columns to their indexes once per column-model change. Each GridRow
63
+ // uses this ordered list to render those cells even when they fall outside its horizontal render
64
+ // context. This keeps the row-identifying cells available to assistive technology while scrolling.
65
+ const retainedColumnIndexes = React.useMemo(() => {
66
+ const indexes = [];
67
+ visibleColumns.forEach((column, index) => {
68
+ if (column.rowHeader) {
69
+ indexes.push(index);
70
+ }
71
+ });
72
+ return indexes;
73
+ }, [visibleColumns]);
62
74
  const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
63
75
  const pinnedColumns = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
64
76
  const rowSelectionManager = useGridSelector(apiRef, gridRowSelectionManagerSelector);
@@ -211,6 +223,7 @@ export function useGridVirtualizer() {
211
223
  rowHeight: params.baseRowHeight,
212
224
  pinnedColumns: pinnedColumns,
213
225
  visibleColumns: visibleColumns,
226
+ retainedColumnIndexes: retainedColumnIndexes,
214
227
  firstColumnIndex: params.firstColumnIndex,
215
228
  lastColumnIndex: params.lastColumnIndex,
216
229
  focusedColumnIndex: params.focusedColumnIndex,
@@ -220,7 +233,7 @@ export function useGridVirtualizer() {
220
233
  showBottomBorder: params.showBottomBorder,
221
234
  scrollbarWidth: verticalScrollbarWidth,
222
235
  gridHasFiller: hasFiller
223
- }, rowSlotProps), params.id), [columnsTotalWidth, hasFiller, isRowSelected, pinnedColumns, RowSlot, rowSlotProps, verticalScrollbarWidth, visibleColumns]),
236
+ }, rowSlotProps), params.id), [columnsTotalWidth, hasFiller, isRowSelected, pinnedColumns, retainedColumnIndexes, RowSlot, rowSlotProps, verticalScrollbarWidth, visibleColumns]),
224
237
  renderInfiniteLoadingTrigger: React.useCallback(id => apiRef.current.getInfiniteLoadingTriggerElement?.({
225
238
  lastRowId: id
226
239
  }), [apiRef])
@@ -1,5 +1,5 @@
1
1
  import type { GridDataSourceCache, GridGetRowsParams, GridUpdateRowParams, GridGetRowsOptions } from "../../../models/gridDataSource.mjs";
2
- import type { GridRowId, GridRowModel } from "../../../models/gridRows.mjs";
2
+ import type { GridRowId, GridRowModel, GridRowModelReplace, GridRowModelUpdate } from "../../../models/gridRows.mjs";
3
3
  import type { GridDataSourceCacheDefaultConfig } from "./cache.mjs";
4
4
  /**
5
5
  * The parameters for the `fetchRows` method.
@@ -43,5 +43,5 @@ export interface GridDataSourceBaseOptions {
43
43
  cacheOptions?: GridDataSourceCacheDefaultConfig;
44
44
  fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void;
45
45
  clearDataSourceState?: () => void;
46
- handleEditRow?: (params: GridUpdateRowParams, updatedRow: GridRowModel) => void;
46
+ handleEditRow?: (params: GridUpdateRowParams, rowUpdate: GridRowModelUpdate | GridRowModelReplace) => void;
47
47
  }
@@ -1,5 +1,5 @@
1
1
  import type { GridDataSourceCache, GridGetRowsParams, GridUpdateRowParams, GridGetRowsOptions } from "../../../models/gridDataSource.js";
2
- import type { GridRowId, GridRowModel } from "../../../models/gridRows.js";
2
+ import type { GridRowId, GridRowModel, GridRowModelReplace, GridRowModelUpdate } from "../../../models/gridRows.js";
3
3
  import type { GridDataSourceCacheDefaultConfig } from "./cache.js";
4
4
  /**
5
5
  * The parameters for the `fetchRows` method.
@@ -43,5 +43,5 @@ export interface GridDataSourceBaseOptions {
43
43
  cacheOptions?: GridDataSourceCacheDefaultConfig;
44
44
  fetchRowChildren?: (parents: GridRowId[], fetchParams: GridGetRowsParams[], showChildrenLoading?: boolean) => void;
45
45
  clearDataSourceState?: () => void;
46
- handleEditRow?: (params: GridUpdateRowParams, updatedRow: GridRowModel) => void;
46
+ handleEditRow?: (params: GridUpdateRowParams, rowUpdate: GridRowModelUpdate | GridRowModelReplace) => void;
47
47
  }
@@ -254,16 +254,20 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
254
254
  }
255
255
  try {
256
256
  const finalRowUpdate = await dataSourceUpdateRow(params);
257
- if (typeof handleEditRowOption === 'function') {
258
- handleEditRowOption(params, finalRowUpdate);
259
- return finalRowUpdate;
260
- }
261
- if (finalRowUpdate && !(0, _isDeepEqual.isDeepEqual)(finalRowUpdate, params.previousRow)) {
257
+ // `dataSource.updateRow()` can resolve with a `{ _action: 'replace', row }` update.
258
+ // The row update methods unwrap it themselves, everything else works with the row it
259
+ // holds: comparing the envelope with the previous row would never match.
260
+ const updatedRow = finalRowUpdate && (0, _gridRowsUtils.isReplaceUpdate)(finalRowUpdate) ? (0, _gridRowsUtils.getReplaceRow)(finalRowUpdate) : finalRowUpdate;
261
+ if (updatedRow && !(0, _isDeepEqual.isDeepEqual)(updatedRow, params.previousRow)) {
262
262
  // Reset the outdated cache, only if the row is _actually_ updated
263
263
  apiRef.current.dataSource.cache.clear();
264
264
  }
265
- apiRef.current.updateNestedRows([finalRowUpdate], []);
266
- return finalRowUpdate;
265
+ if (typeof handleEditRowOption === 'function') {
266
+ handleEditRowOption(params, finalRowUpdate);
267
+ } else {
268
+ apiRef.current.updateNestedRows([finalRowUpdate], []);
269
+ }
270
+ return updatedRow;
267
271
  } catch (errorThrown) {
268
272
  if (typeof onDataSourceErrorProp === 'function') {
269
273
  onDataSourceErrorProp(new _gridDataSourceError.GridUpdateRowError({
@@ -9,7 +9,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
9
9
  import debounce from '@mui/utils/debounce';
10
10
  import { warnOnce } from '@mui/x-internals/warning';
11
11
  import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
12
- import { GRID_ROOT_GROUP_ID } from "../rows/gridRowsUtils.mjs";
12
+ import { GRID_ROOT_GROUP_ID, getReplaceRow, isReplaceUpdate } from "../rows/gridRowsUtils.mjs";
13
13
  import { runIf } from "../../../utils/utils.mjs";
14
14
  import { GridStrategyGroup } from "../../core/strategyProcessing/index.mjs";
15
15
  import { useGridSelector } from "../../utils/useGridSelector.mjs";
@@ -247,16 +247,20 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
247
247
  }
248
248
  try {
249
249
  const finalRowUpdate = await dataSourceUpdateRow(params);
250
- if (typeof handleEditRowOption === 'function') {
251
- handleEditRowOption(params, finalRowUpdate);
252
- return finalRowUpdate;
253
- }
254
- if (finalRowUpdate && !isDeepEqual(finalRowUpdate, params.previousRow)) {
250
+ // `dataSource.updateRow()` can resolve with a `{ _action: 'replace', row }` update.
251
+ // The row update methods unwrap it themselves, everything else works with the row it
252
+ // holds: comparing the envelope with the previous row would never match.
253
+ const updatedRow = finalRowUpdate && isReplaceUpdate(finalRowUpdate) ? getReplaceRow(finalRowUpdate) : finalRowUpdate;
254
+ if (updatedRow && !isDeepEqual(updatedRow, params.previousRow)) {
255
255
  // Reset the outdated cache, only if the row is _actually_ updated
256
256
  apiRef.current.dataSource.cache.clear();
257
257
  }
258
- apiRef.current.updateNestedRows([finalRowUpdate], []);
259
- return finalRowUpdate;
258
+ if (typeof handleEditRowOption === 'function') {
259
+ handleEditRowOption(params, finalRowUpdate);
260
+ } else {
261
+ apiRef.current.updateNestedRows([finalRowUpdate], []);
262
+ }
263
+ return updatedRow;
260
264
  } catch (errorThrown) {
261
265
  if (typeof onDataSourceErrorProp === 'function') {
262
266
  onDataSourceErrorProp(new GridUpdateRowError({
@@ -1,10 +1,10 @@
1
- import type { GridRowModelUpdate } from '@mui/x-data-grid';
1
+ import type { GridRowModelUpdate, GridRowModelReplace } from '@mui/x-data-grid';
2
2
  import type { GridColDef } from "../../../models/colDef/index.mjs";
3
3
  export interface GridPivotingStatePartial {
4
4
  active: boolean;
5
5
  initialColumns: Map<string, GridColDef> | undefined;
6
6
  }
7
7
  export interface GridPivotingPrivateApiCommunity {
8
- updateNonPivotRows: (rows: readonly GridRowModelUpdate[], keepPreviousRows?: boolean) => void;
8
+ updateNonPivotRows: (rows: ReadonlyArray<GridRowModelUpdate | GridRowModelReplace>, keepPreviousRows?: boolean) => void;
9
9
  updateNonPivotColumns: (columns: readonly GridColDef[], keepPreviousColumns?: boolean) => void;
10
10
  }
@@ -1,10 +1,10 @@
1
- import type { GridRowModelUpdate } from '@mui/x-data-grid';
1
+ import type { GridRowModelUpdate, GridRowModelReplace } from '@mui/x-data-grid';
2
2
  import type { GridColDef } from "../../../models/colDef/index.js";
3
3
  export interface GridPivotingStatePartial {
4
4
  active: boolean;
5
5
  initialColumns: Map<string, GridColDef> | undefined;
6
6
  }
7
7
  export interface GridPivotingPrivateApiCommunity {
8
- updateNonPivotRows: (rows: readonly GridRowModelUpdate[], keepPreviousRows?: boolean) => void;
8
+ updateNonPivotRows: (rows: ReadonlyArray<GridRowModelUpdate | GridRowModelReplace>, keepPreviousRows?: boolean) => void;
9
9
  updateNonPivotColumns: (columns: readonly GridColDef[], keepPreviousColumns?: boolean) => void;
10
10
  }
@@ -542,7 +542,7 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
542
542
  handleSingleRowSelection(params.id, event);
543
543
  return;
544
544
  }
545
- if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
545
+ if ((0, _keyboardUtils.isSelectAllShortcut)(event)) {
546
546
  event.preventDefault();
547
547
  if (canHaveMultipleSelection) {
548
548
  toggleAllRows(true);
@@ -15,7 +15,7 @@ import { gridFocusCellSelector } from "../focus/gridFocusStateSelector.mjs";
15
15
  import { gridExpandedSortedRowIdsSelector, gridFilteredRowsLookupSelector, gridFilterModelSelector, gridQuickFilterValuesSelector } from "../filter/gridFilterSelector.mjs";
16
16
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.mjs";
17
17
  import { GridCellModes } from "../../../models/gridEditRowModel.mjs";
18
- import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.mjs";
18
+ import { isKeyboardEvent, isNavigationKey, isSelectAllShortcut } from "../../../utils/keyboardUtils.mjs";
19
19
  import { getVisibleRows } from "../../utils/useGridVisibleRows.mjs";
20
20
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.mjs";
21
21
  import { gridClasses } from "../../../constants/gridClasses.mjs";
@@ -534,7 +534,7 @@ You need to upgrade to DataGridPro or DataGridPremium component to unlock multip
534
534
  handleSingleRowSelection(params.id, event);
535
535
  return;
536
536
  }
537
- if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
537
+ if (isSelectAllShortcut(event)) {
538
538
  event.preventDefault();
539
539
  if (canHaveMultipleSelection) {
540
540
  toggleAllRows(true);
@@ -1,5 +1,5 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
- import type { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridColDef, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode, GridValidRowModel } from "../../../models/index.mjs";
2
+ import type { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridColDef, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowModelReplace, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode, GridValidRowModel } from "../../../models/index.mjs";
3
3
  import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.mjs";
4
4
  import type { GridApiCommunity, GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
5
5
  import type { GridRowsInternalCache, GridRowsState, GridRowTreeCreationParams } from "./gridRowsInterfaces.mjs";
@@ -43,6 +43,40 @@ export declare const getRowsStateFromCache: ({
43
43
  export declare const isAutogeneratedRow: (row: GridRowModel) => boolean;
44
44
  export declare const isAutogeneratedRowNode: (rowNode: GridTreeNode) => rowNode is GridFooterNode | GridSkeletonRowNode | GridAutoGeneratedGroupNode | GridAutoGeneratedPinnedRowNode;
45
45
  export declare const getTreeNodeDescendants: (tree: GridRowTreeConfig, parentId: GridRowId, skipAutoGeneratedRows: boolean, directChildrenOnly?: boolean) => GridRowId[];
46
+ export declare const isReplaceUpdate: (update: GridRowModelUpdate | GridRowModelReplace) => update is GridRowModelReplace;
47
+ /**
48
+ * Extracts the replacement row from a `{ _action: 'replace', row }` update.
49
+ * The marker lives on the throwaway envelope, so the row object itself is never touched.
50
+ * @param {GridRowModelReplace} update The update provided to `updateRows()`.
51
+ * @returns {GridRowModel} The object to store as the row, verbatim.
52
+ */
53
+ export declare const getReplaceRow: (update: GridRowModelReplace) => GridRowModel;
54
+ /**
55
+ * Merges a partial update into the existing row.
56
+ * Prototype-preservation rules:
57
+ * 1. If partialRow is a class instance (non-plain object), use its prototype — the
58
+ * caller is passing in a fully-constructed instance and owns the prototype chain.
59
+ * 2. If partialRow is a plain object (Object.prototype), prefer oldRow's prototype so
60
+ * that a partial-update object does not silently discard the existing row's class.
61
+ * 3. If both are plain objects the result is also a plain object (no-op).
62
+ *
63
+ * Note: private class fields (#field syntax) cannot be preserved through a spread-style
64
+ * merge because the brand check is tied to the original instance. Rows that rely on
65
+ * private fields must either supply a fully-constructed instance as partialRow (rule 1
66
+ * above) or use `_action: 'replace'` rather than a plain-object partial update.
67
+ * @param {GridRowModel} oldRow The row currently stored in the lookup.
68
+ * @param {GridRowModelUpdate} partialRow The update to merge into it.
69
+ * @returns {GridRowModel} The merged row.
70
+ */
71
+ export declare const mergeRowUpdate: (oldRow: GridRowModel, partialRow: GridRowModelUpdate) => GridRowModel;
72
+ /**
73
+ * Warns when a replace demotes a class instance to a plain object, which happens when the
74
+ * replacement was built with a spread instead of being passed as-is.
75
+ * Dev-only, does nothing in production.
76
+ * @param {GridRowModel | undefined} oldRow The row being replaced, if any.
77
+ * @param {GridRowModel} replacement The row provided in a `{ _action: 'replace', row }` update.
78
+ */
79
+ export declare const warnIfReplaceLosesPrototype: (oldRow: GridRowModel | undefined, replacement: GridRowModel) => void;
46
80
  export declare const updateCacheWithNewRows: ({
47
81
  previousCache,
48
82
  getRowId,
@@ -51,10 +85,10 @@ export declare const updateCacheWithNewRows: ({
51
85
  }: {
52
86
  previousCache: GridRowsInternalCache;
53
87
  getRowId: DataGridProcessedProps['getRowId'];
54
- updates: GridRowModelUpdate[];
88
+ updates: Array<GridRowModelUpdate | GridRowModelReplace>;
55
89
  groupKeys?: string[];
56
90
  }) => GridRowsInternalCache;
57
91
  export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
58
- export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
92
+ export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: Array<GridRowModelUpdate | GridRowModelReplace>, getRowId: DataGridProcessedProps['getRowId']): (GridRowModelReplace<GridValidRowModel> | GridRowModelUpdate)[];
59
93
  export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
60
94
  export declare const rowHeightWarning: string;