@mui/x-data-grid-premium 8.10.1 → 8.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 (62) hide show
  1. package/CHANGELOG.md +221 -8
  2. package/DataGridPremium/DataGridPremium.js +6 -4
  3. package/DataGridPremium/useDataGridPremiumComponent.d.ts +2 -1
  4. package/DataGridPremium/useDataGridPremiumComponent.js +2 -2
  5. package/esm/DataGridPremium/DataGridPremium.js +6 -4
  6. package/esm/DataGridPremium/useDataGridPremiumComponent.d.ts +2 -1
  7. package/esm/DataGridPremium/useDataGridPremiumComponent.js +2 -2
  8. package/esm/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +1 -0
  9. package/esm/hooks/features/clipboard/useGridClipboardImport.js +1 -1
  10. package/esm/hooks/features/export/serializer/setupExcelExportWebWorker.js +1 -2
  11. package/esm/hooks/features/rowGrouping/createGroupingColDef.d.ts +2 -1
  12. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +31 -7
  13. package/esm/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +1 -0
  14. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
  15. package/esm/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
  16. package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +48 -2
  17. package/esm/hooks/features/rowReorder/operations.d.ts +40 -0
  18. package/esm/hooks/features/rowReorder/operations.js +535 -0
  19. package/esm/hooks/features/rowReorder/reorderExecutor.d.ts +15 -0
  20. package/esm/hooks/features/rowReorder/reorderExecutor.js +25 -0
  21. package/esm/hooks/features/rowReorder/reorderValidator.d.ts +16 -0
  22. package/esm/hooks/features/rowReorder/reorderValidator.js +116 -0
  23. package/esm/hooks/features/rowReorder/types.d.ts +42 -0
  24. package/esm/hooks/features/rowReorder/types.js +1 -0
  25. package/esm/hooks/features/rowReorder/utils.d.ts +127 -0
  26. package/esm/hooks/features/rowReorder/utils.js +343 -0
  27. package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +7 -0
  28. package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +52 -0
  29. package/esm/index.js +1 -1
  30. package/esm/models/gridGroupingValueSetter.d.ts +14 -0
  31. package/esm/models/gridGroupingValueSetter.js +1 -0
  32. package/esm/models/index.d.ts +1 -0
  33. package/esm/models/index.js +1 -0
  34. package/esm/typeOverloads/modules.d.ts +7 -1
  35. package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +1 -0
  36. package/hooks/features/clipboard/useGridClipboardImport.js +1 -1
  37. package/hooks/features/export/serializer/setupExcelExportWebWorker.js +1 -2
  38. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +2 -1
  39. package/hooks/features/rowGrouping/createGroupingColDef.js +31 -7
  40. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +1 -0
  41. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
  42. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
  43. package/hooks/features/rowGrouping/useGridRowGrouping.js +46 -0
  44. package/hooks/features/rowReorder/operations.d.ts +40 -0
  45. package/hooks/features/rowReorder/operations.js +546 -0
  46. package/hooks/features/rowReorder/reorderExecutor.d.ts +15 -0
  47. package/hooks/features/rowReorder/reorderExecutor.js +31 -0
  48. package/hooks/features/rowReorder/reorderValidator.d.ts +16 -0
  49. package/hooks/features/rowReorder/reorderValidator.js +122 -0
  50. package/hooks/features/rowReorder/types.d.ts +42 -0
  51. package/hooks/features/rowReorder/types.js +5 -0
  52. package/hooks/features/rowReorder/utils.d.ts +127 -0
  53. package/hooks/features/rowReorder/utils.js +360 -0
  54. package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +7 -0
  55. package/hooks/features/rows/useGridRowsOverridableMethods.js +60 -0
  56. package/index.js +1 -1
  57. package/models/gridGroupingValueSetter.d.ts +14 -0
  58. package/models/gridGroupingValueSetter.js +5 -0
  59. package/models/index.d.ts +1 -0
  60. package/models/index.js +11 -0
  61. package/package.json +5 -5
  62. package/typeOverloads/modules.d.ts +7 -1
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useGridRowsOverridableMethods = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _xDataGridPro = require("@mui/x-data-grid-pro");
10
+ var _internals = require("@mui/x-data-grid-pro/internals");
11
+ var _reorderExecutor = require("../rowReorder/reorderExecutor");
12
+ const useGridRowsOverridableMethods = (apiRef, props) => {
13
+ const {
14
+ processRowUpdate,
15
+ onProcessRowUpdateError
16
+ } = props;
17
+ const setRowIndex = React.useCallback(async (sourceRowId, targetOriginalIndex) => {
18
+ const sortedFilteredRowIds = (0, _xDataGridPro.gridExpandedSortedRowIdsSelector)(apiRef);
19
+ const sortedFilteredRowIndexLookup = (0, _internals.gridExpandedSortedRowIndexLookupSelector)(apiRef);
20
+ const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
21
+ const sourceNode = (0, _xDataGridPro.gridRowNodeSelector)(apiRef, sourceRowId);
22
+ if (!sourceNode) {
23
+ throw new Error(`MUI X: No row with id #${sourceRowId} found.`);
24
+ }
25
+ if (sourceNode.type === 'footer') {
26
+ throw new Error(`MUI X: The row reordering do not support reordering of footer rows.`);
27
+ }
28
+
29
+ /**
30
+ * Row Grouping Reordering Use Cases
31
+ * =================================
32
+ *
33
+ * | Case | Source Node | Target Node | Parent Relationship | Action |
34
+ * | :--- | :---------- | :---------- | :------------------------ | :-------------------------------------------------------------------------- |
35
+ * | A ✅ | Leaf | Leaf | Same parent | Swap positions (similar to flat tree structure) |
36
+ * | B ✅ | Group | Group | Same parent | Swap positions (along with their descendants) |
37
+ * | C ✅ | Leaf | Leaf | Different parents | Make source node a child of target's parent and update parent nodes in tree |
38
+ * | D ✅ | Leaf | Group | Different parents | Make source a child of target, only allowed at same depth as source.parent |
39
+ * | E ❌ | Leaf | Group | Target is source's parent | Not allowed, will have no difference |
40
+ * | F ❌ | Group | Leaf | Any | Not allowed, will break the row grouping criteria |
41
+ * | G ✅ | Group | Group | Different parents | Only allowed at same depth to preserve grouping criteria |
42
+ */
43
+
44
+ const executionContext = {
45
+ sourceRowId,
46
+ placeholderIndex: targetOriginalIndex,
47
+ sortedFilteredRowIds,
48
+ sortedFilteredRowIndexLookup,
49
+ rowTree,
50
+ apiRef,
51
+ processRowUpdate,
52
+ onProcessRowUpdateError
53
+ };
54
+ await _reorderExecutor.rowGroupingReorderExecutor.execute(executionContext);
55
+ }, [apiRef, processRowUpdate, onProcessRowUpdateError]);
56
+ return {
57
+ setRowIndex
58
+ };
59
+ };
60
+ exports.useGridRowsOverridableMethods = useGridRowsOverridableMethods;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v8.10.1
2
+ * @mui/x-data-grid-premium v8.11.0
3
3
  *
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  * This source code is licensed under the SEE LICENSE IN LICENSE license found in the
@@ -0,0 +1,14 @@
1
+ import { RefObject } from '@mui/x-internals/types';
2
+ import { GridValidRowModel, GridColDef, GridKeyValue } from '@mui/x-data-grid-pro';
3
+ import { GridApiPremium } from "./gridApiPremium.js";
4
+ /**
5
+ * Function signature for setting a grouping value on a row.
6
+ * This is the inverse operation of GridGroupingValueGetter.
7
+ *
8
+ * @param {GridKeyValue | null | undefined} groupingValue The grouping value to set
9
+ * @param {R} row The row to update
10
+ * @param {GridColDef<R>} column The column definition
11
+ * @param {RefObject<GridApiPremium>} apiRef Reference to the grid API
12
+ * @returns {R} The updated row with the new grouping value applied
13
+ */
14
+ export type GridGroupingValueSetter<R extends GridValidRowModel = GridValidRowModel> = (groupingValue: GridKeyValue | null | undefined, row: R, column: GridColDef<R>, apiRef: RefObject<GridApiPremium>) => R;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/models/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./gridApiPremium.js";
2
2
  export * from "./gridGroupingValueGetter.js";
3
+ export * from "./gridGroupingValueSetter.js";
3
4
  export * from "./gridPremiumIconSlotsComponent.js";
4
5
  export * from "./gridPremiumSlotsComponent.js";
5
6
  export * from "./gridPastedValueParser.js";
package/models/index.js CHANGED
@@ -25,6 +25,17 @@ Object.keys(_gridGroupingValueGetter).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
+ var _gridGroupingValueSetter = require("./gridGroupingValueSetter");
29
+ Object.keys(_gridGroupingValueSetter).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _gridGroupingValueSetter[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _gridGroupingValueSetter[key];
36
+ }
37
+ });
38
+ });
28
39
  var _gridPremiumIconSlotsComponent = require("./gridPremiumIconSlotsComponent");
29
40
  Object.keys(_gridPremiumIconSlotsComponent).forEach(function (key) {
30
41
  if (key === "default" || key === "__esModule") return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-premium",
3
- "version": "8.10.1",
3
+ "version": "8.11.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The Premium plan edition of the MUI X Data Grid Components.",
6
6
  "main": "./index.js",
@@ -40,10 +40,10 @@
40
40
  "clsx": "^2.1.1",
41
41
  "exceljs": "^4.4.0",
42
42
  "prop-types": "^15.8.1",
43
- "@mui/x-data-grid": "8.10.1",
44
- "@mui/x-data-grid-pro": "8.10.1",
45
- "@mui/x-license": "8.10.1",
46
- "@mui/x-internals": "8.10.0"
43
+ "@mui/x-license": "8.11.0",
44
+ "@mui/x-internals": "8.11.0",
45
+ "@mui/x-data-grid-pro": "8.11.0",
46
+ "@mui/x-data-grid": "8.11.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@emotion/react": "^11.9.0",
@@ -1,6 +1,6 @@
1
1
  import { GridExportDisplayOptions, GridValidRowModel } from '@mui/x-data-grid-pro';
2
2
  import type { GridPipeProcessingLookupPro, GridControlledStateEventLookupPro, GridApiCachesPro, GridEventLookupPro } from '@mui/x-data-grid-pro/typeOverloads';
3
- import type { GridGroupingValueGetter, GridPastedValueParser } from "../models/index.js";
3
+ import type { GridGroupingValueGetter, GridGroupingValueSetter, GridPastedValueParser } from "../models/index.js";
4
4
  import type { GridRowGroupingModel, GridAggregationModel, GridAggregationCellMeta, GridAggregationHeaderMeta, GridCellSelectionModel, Conversation } from "../hooks/index.js";
5
5
  import { GridRowGroupingInternalCache } from "../hooks/features/rowGrouping/gridRowGroupingInterfaces.js";
6
6
  import { GridAggregationInternalCache } from "../hooks/features/aggregation/gridAggregationInterfaces.js";
@@ -107,6 +107,12 @@ export interface GridColDefPremium<R extends GridValidRowModel = any, V = any, F
107
107
  * @returns {GridKeyValue | null | undefined} The cell key.
108
108
  */
109
109
  groupingValueGetter?: GridGroupingValueGetter<R>;
110
+ /**
111
+ * Function that takes a grouping value and updates the row data accordingly.
112
+ * This is the inverse operation of `groupingValueGetter`.
113
+ * @returns {R} The updated row.
114
+ */
115
+ groupingValueSetter?: GridGroupingValueSetter<R>;
110
116
  /**
111
117
  * Function that takes the clipboard-pasted value and converts it to a value used internally.
112
118
  * @returns {V} The converted value.