@mui/x-data-grid 9.12.0 → 9.14.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 (92) hide show
  1. package/CHANGELOG.md +301 -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/GridScrollArea.js +20 -7
  11. package/components/GridScrollArea.mjs +21 -8
  12. package/components/base/GridOverlays.js +6 -5
  13. package/components/base/GridOverlays.mjs +6 -5
  14. package/components/cell/GridActionsCell.js +53 -50
  15. package/components/cell/GridActionsCell.mjs +53 -50
  16. package/components/cell/GridActionsCellItem.js +0 -1
  17. package/components/cell/GridActionsCellItem.mjs +0 -1
  18. package/components/cell/GridCell.js +15 -4
  19. package/components/cell/GridCell.mjs +15 -4
  20. package/components/cell/GridEditBooleanCell.d.mts +1 -1
  21. package/components/cell/GridEditBooleanCell.d.ts +1 -1
  22. package/components/cell/GridEditBooleanCell.js +4 -4
  23. package/components/cell/GridEditBooleanCell.mjs +4 -4
  24. package/components/cell/GridEditDateCell.d.mts +1 -1
  25. package/components/cell/GridEditDateCell.d.ts +1 -1
  26. package/components/cell/GridEditDateCell.js +5 -5
  27. package/components/cell/GridEditDateCell.mjs +5 -5
  28. package/components/cell/GridEditInputCell.d.mts +1 -1
  29. package/components/cell/GridEditInputCell.d.ts +1 -1
  30. package/components/cell/GridEditInputCell.js +1 -1
  31. package/components/cell/GridEditInputCell.mjs +1 -1
  32. package/components/cell/GridEditLongTextCell.d.mts +1 -1
  33. package/components/cell/GridEditLongTextCell.d.ts +1 -1
  34. package/components/cell/GridEditLongTextCell.js +2 -2
  35. package/components/cell/GridEditLongTextCell.mjs +2 -2
  36. package/components/cell/GridEditSingleSelectCell.d.mts +1 -1
  37. package/components/cell/GridEditSingleSelectCell.d.ts +1 -1
  38. package/components/cell/GridEditSingleSelectCell.js +4 -4
  39. package/components/cell/GridEditSingleSelectCell.mjs +4 -4
  40. package/components/quickFilter/QuickFilter.js +7 -2
  41. package/components/quickFilter/QuickFilter.mjs +7 -2
  42. package/components/toolbarV8/Toolbar.d.mts +5 -1
  43. package/components/toolbarV8/Toolbar.d.ts +5 -1
  44. package/components/toolbarV8/Toolbar.js +34 -12
  45. package/components/toolbarV8/Toolbar.mjs +33 -11
  46. package/components/virtualization/GridVirtualScroller.js +3 -0
  47. package/components/virtualization/GridVirtualScroller.mjs +3 -0
  48. package/hooks/core/useGridVirtualizer.js +14 -1
  49. package/hooks/core/useGridVirtualizer.mjs +14 -1
  50. package/hooks/features/columnResize/useGridColumnResize.js +4 -1
  51. package/hooks/features/columnResize/useGridColumnResize.mjs +4 -1
  52. package/hooks/features/dataSource/models.d.mts +2 -2
  53. package/hooks/features/dataSource/models.d.ts +2 -2
  54. package/hooks/features/dataSource/useGridDataSourceBase.js +12 -8
  55. package/hooks/features/dataSource/useGridDataSourceBase.mjs +13 -9
  56. package/hooks/features/pivoting/gridPivotingInterfaces.d.mts +2 -2
  57. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +2 -2
  58. package/hooks/features/rowSelection/useGridRowSelection.d.mts +1 -1
  59. package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
  60. package/hooks/features/rowSelection/useGridRowSelection.js +51 -10
  61. package/hooks/features/rowSelection/useGridRowSelection.mjs +53 -12
  62. package/hooks/features/rowSelection/utils.js +5 -0
  63. package/hooks/features/rowSelection/utils.mjs +5 -0
  64. package/hooks/features/rows/gridRowsUtils.d.mts +37 -3
  65. package/hooks/features/rows/gridRowsUtils.d.ts +37 -3
  66. package/hooks/features/rows/gridRowsUtils.js +120 -23
  67. package/hooks/features/rows/gridRowsUtils.mjs +115 -22
  68. package/hooks/features/rows/useGridRows.js +10 -1
  69. package/hooks/features/rows/useGridRows.mjs +10 -1
  70. package/index.js +1 -1
  71. package/index.mjs +1 -1
  72. package/internals/index.d.mts +2 -2
  73. package/internals/index.d.ts +2 -2
  74. package/internals/index.js +28 -0
  75. package/internals/index.mjs +2 -2
  76. package/material/variables.d.mts +6 -1
  77. package/material/variables.d.ts +6 -1
  78. package/material/variables.js +17 -3
  79. package/material/variables.mjs +14 -4
  80. package/models/api/gridRowApi.d.mts +7 -7
  81. package/models/api/gridRowApi.d.ts +7 -7
  82. package/models/gridDataSource.d.mts +3 -0
  83. package/models/gridDataSource.d.ts +3 -0
  84. package/models/gridRows.d.mts +28 -1
  85. package/models/gridRows.d.ts +28 -1
  86. package/models/props/DataGridProps.d.mts +3 -3
  87. package/models/props/DataGridProps.d.ts +3 -3
  88. package/package.json +6 -6
  89. package/utils/keyboardUtils.d.mts +1 -0
  90. package/utils/keyboardUtils.d.ts +1 -0
  91. package/utils/keyboardUtils.js +6 -0
  92. package/utils/keyboardUtils.mjs +5 -0
@@ -7,9 +7,36 @@ export type GridRowsProp<R extends GridValidRowModel = GridValidRowModel> = Read
7
7
  * The key value object representing the data of a row.
8
8
  */
9
9
  export type GridRowModel<R extends GridValidRowModel = GridValidRowModel> = R;
10
+ /**
11
+ * @deprecated Use `GridRowModelUpdate` or `GridRowModelReplace` instead.
12
+ */
10
13
  export type GridUpdateAction = 'delete';
11
14
  export interface GridRowModelUpdate extends GridRowModel {
12
- _action?: GridUpdateAction;
15
+ /**
16
+ * - `'delete'` removes the row.
17
+ * - `undefined` (default) performs a shallow, `Object.assign`-style partial merge into
18
+ * the existing row, which produces a new object.
19
+ *
20
+ * To store an object as the row without merging, see [[GridRowModelReplace]].
21
+ */
22
+ _action?: 'delete';
23
+ }
24
+ /**
25
+ * A row update that stores `row` as-is instead of merging it into the existing row.
26
+ * Use this when the row is a class instance (e.g. one with `#private` fields) whose
27
+ * prototype chain and object identity must be preserved across the update:
28
+ * `apiRef.current.getRow(id)` then returns the very object provided in `row`.
29
+ * Any field missing from `row` is removed from the stored row, because a replace is
30
+ * never a merge.
31
+ * It can be passed to `updateRows()` or returned from `processRowUpdate()`.
32
+ */
33
+ export interface GridRowModelReplace<R extends GridValidRowModel = GridValidRowModel> {
34
+ _action: 'replace';
35
+ /**
36
+ * The object stored as the new row, verbatim. Pass the instance itself — spreading it
37
+ * (`{ ...row }`) creates a plain object and defeats the purpose.
38
+ */
39
+ row: R;
13
40
  }
14
41
  /**
15
42
  * The grid rows total height and row positions.
@@ -8,7 +8,7 @@ import type { GridFeatureMode } from "../gridFeatureMode.mjs";
8
8
  import type { Logger } from "../logger.mjs";
9
9
  import type { GridSortDirection, GridSortModel } from "../gridSortModel.mjs";
10
10
  import type { GridSlotsComponent } from "../gridSlotsComponent.mjs";
11
- import type { GridRowId, GridRowIdGetter, GridRowsProp, GridValidRowModel } from "../gridRows.mjs";
11
+ import type { GridRowId, GridRowIdGetter, GridRowModelReplace, GridRowsProp, GridValidRowModel } from "../gridRows.mjs";
12
12
  import type { GridEventListener } from "../events/index.mjs";
13
13
  import type { GridCallbackDetails, GridLocaleText } from "../api/index.mjs";
14
14
  import type { GridApiCommunity } from "../api/gridApiCommunity.mjs";
@@ -816,11 +816,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
816
816
  * @param {R} newRow Row object with the new values.
817
817
  * @param {R} oldRow Row object with the old values.
818
818
  * @param {{ rowId: GridRowId }} params Additional parameters.
819
- * @returns {Promise<R> | R} The final values to update the row.
819
+ * @returns {Promise<R | GridRowModelReplace<R>> | R | GridRowModelReplace<R>} The final values to update the row, or a `{ _action: 'replace', row }` update to store `row` as the new row without merging.
820
820
  */
821
821
  processRowUpdate?: (newRow: R, oldRow: R, params: {
822
822
  rowId: GridRowId;
823
- }) => Promise<R> | R;
823
+ }) => Promise<R | GridRowModelReplace<R>> | R | GridRowModelReplace<R>;
824
824
  /**
825
825
  * Callback called when `processRowUpdate()` throws an error or rejects.
826
826
  * @param {any} error The error thrown.
@@ -8,7 +8,7 @@ import type { GridFeatureMode } from "../gridFeatureMode.js";
8
8
  import type { Logger } from "../logger.js";
9
9
  import type { GridSortDirection, GridSortModel } from "../gridSortModel.js";
10
10
  import type { GridSlotsComponent } from "../gridSlotsComponent.js";
11
- import type { GridRowId, GridRowIdGetter, GridRowsProp, GridValidRowModel } from "../gridRows.js";
11
+ import type { GridRowId, GridRowIdGetter, GridRowModelReplace, GridRowsProp, GridValidRowModel } from "../gridRows.js";
12
12
  import type { GridEventListener } from "../events/index.js";
13
13
  import type { GridCallbackDetails, GridLocaleText } from "../api/index.js";
14
14
  import type { GridApiCommunity } from "../api/gridApiCommunity.js";
@@ -816,11 +816,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
816
816
  * @param {R} newRow Row object with the new values.
817
817
  * @param {R} oldRow Row object with the old values.
818
818
  * @param {{ rowId: GridRowId }} params Additional parameters.
819
- * @returns {Promise<R> | R} The final values to update the row.
819
+ * @returns {Promise<R | GridRowModelReplace<R>> | R | GridRowModelReplace<R>} The final values to update the row, or a `{ _action: 'replace', row }` update to store `row` as the new row without merging.
820
820
  */
821
821
  processRowUpdate?: (newRow: R, oldRow: R, params: {
822
822
  rowId: GridRowId;
823
- }) => Promise<R> | R;
823
+ }) => Promise<R | GridRowModelReplace<R>> | R | GridRowModelReplace<R>;
824
824
  /**
825
825
  * Callback called when `processRowUpdate()` throws an error or rejects.
826
826
  * @param {any} error The error thrown.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "9.12.0",
3
+ "version": "9.14.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The Community plan edition of the MUI X Data Grid components.",
6
6
  "license": "MIT",
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/runtime": "^7.29.7",
41
- "@base-ui/utils": "^0.3.1",
42
- "@mui/utils": "^9.3.0",
41
+ "@base-ui/utils": "^0.3.2",
42
+ "@mui/utils": "^9.4.0",
43
+ "@mui/x-internals": "^9.14.0",
44
+ "@mui/x-virtualizer": "0.7.2",
43
45
  "clsx": "^2.1.1",
44
46
  "prop-types": "^15.8.1",
45
- "use-sync-external-store": "^1.6.0",
46
- "@mui/x-internals": "^9.12.0",
47
- "@mui/x-virtualizer": "0.7.0"
47
+ "use-sync-external-store": "^1.7.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@emotion/react": "^11.9.0",
@@ -5,6 +5,7 @@ export declare const isKeyboardEvent: (event: any) => event is React.KeyboardEve
5
5
  export declare const isHideMenuKey: (key: React.KeyboardEvent['key']) => key is "Escape" | "Tab";
6
6
  export declare function isPasteShortcut(event: React.KeyboardEvent): boolean;
7
7
  export declare function isCopyShortcut(event: KeyboardEvent): boolean;
8
+ export declare function isSelectAllShortcut(event: React.KeyboardEvent): boolean;
8
9
  export declare function isUndoShortcut(event: React.KeyboardEvent): boolean;
9
10
  export declare function isFillDownShortcut(event: React.KeyboardEvent): boolean;
10
11
  export declare function isFillRightShortcut(event: React.KeyboardEvent): boolean;
@@ -5,6 +5,7 @@ export declare const isKeyboardEvent: (event: any) => event is React.KeyboardEve
5
5
  export declare const isHideMenuKey: (key: React.KeyboardEvent['key']) => key is "Escape" | "Tab";
6
6
  export declare function isPasteShortcut(event: React.KeyboardEvent): boolean;
7
7
  export declare function isCopyShortcut(event: KeyboardEvent): boolean;
8
+ export declare function isSelectAllShortcut(event: React.KeyboardEvent): boolean;
8
9
  export declare function isUndoShortcut(event: React.KeyboardEvent): boolean;
9
10
  export declare function isFillDownShortcut(event: React.KeyboardEvent): boolean;
10
11
  export declare function isFillRightShortcut(event: React.KeyboardEvent): boolean;
@@ -10,6 +10,7 @@ exports.isNavigationKey = exports.isKeyboardEvent = exports.isHideMenuKey = void
10
10
  exports.isPasteShortcut = isPasteShortcut;
11
11
  exports.isPrintableKey = isPrintableKey;
12
12
  exports.isRedoShortcut = isRedoShortcut;
13
+ exports.isSelectAllShortcut = isSelectAllShortcut;
13
14
  exports.isUndoShortcut = isUndoShortcut;
14
15
  // Non printable keys have a name, for example "ArrowRight", see the whole list:
15
16
  // https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
@@ -44,6 +45,11 @@ function isPasteShortcut(event) {
44
45
  function isCopyShortcut(event) {
45
46
  return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'C' && !event.shiftKey && !event.altKey;
46
47
  }
48
+
49
+ // Checks if the keyboard event corresponds to the select-all shortcut (CTRL+A or CMD+A) across different localization keyboards.
50
+ function isSelectAllShortcut(event) {
51
+ return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey;
52
+ }
47
53
  function isUndoShortcut(event) {
48
54
  return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'Z' && !event.shiftKey && !event.altKey;
49
55
  }
@@ -28,6 +28,11 @@ export function isPasteShortcut(event) {
28
28
  export function isCopyShortcut(event) {
29
29
  return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'C' && !event.shiftKey && !event.altKey;
30
30
  }
31
+
32
+ // Checks if the keyboard event corresponds to the select-all shortcut (CTRL+A or CMD+A) across different localization keyboards.
33
+ export function isSelectAllShortcut(event) {
34
+ return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey;
35
+ }
31
36
  export function isUndoShortcut(event) {
32
37
  return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'Z' && !event.shiftKey && !event.altKey;
33
38
  }