@mui/x-data-grid-premium 8.13.1 → 8.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 (52) hide show
  1. package/CHANGELOG.md +109 -1
  2. package/DataGridPremium/DataGridPremium.js +7 -5
  3. package/DataGridPremium/useDataGridPremiumProps.js +3 -2
  4. package/components/GridDataSourceGroupingCriteriaCell.js +8 -2
  5. package/components/GridPremiumToolbar.js +1 -2
  6. package/components/pivotPanel/GridPivotPanelField.js +4 -4
  7. package/esm/DataGridPremium/DataGridPremium.js +7 -5
  8. package/esm/DataGridPremium/useDataGridPremiumProps.js +3 -2
  9. package/esm/components/GridDataSourceGroupingCriteriaCell.js +9 -3
  10. package/esm/components/GridPremiumToolbar.js +1 -2
  11. package/esm/components/pivotPanel/GridPivotPanelField.js +4 -4
  12. package/esm/hooks/features/aggregation/useGridAggregation.js +3 -2
  13. package/esm/hooks/features/dataSource/models.d.ts +52 -1
  14. package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +30 -5
  15. package/esm/hooks/features/dataSource/utils.d.ts +6 -0
  16. package/esm/hooks/features/dataSource/utils.js +140 -0
  17. package/esm/hooks/features/index.d.ts +2 -1
  18. package/esm/hooks/features/index.js +2 -1
  19. package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +23 -13
  20. package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -1
  21. package/esm/hooks/features/pivoting/index.d.ts +1 -0
  22. package/esm/hooks/features/pivoting/index.js +1 -0
  23. package/esm/hooks/features/pivoting/useGridPivoting.d.ts +1 -1
  24. package/esm/hooks/features/pivoting/useGridPivoting.js +83 -32
  25. package/esm/hooks/features/pivoting/utils.d.ts +7 -9
  26. package/esm/hooks/features/pivoting/utils.js +39 -24
  27. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +1 -1
  28. package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +7 -3
  29. package/esm/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
  30. package/esm/index.js +1 -1
  31. package/esm/models/dataGridPremiumProps.d.ts +15 -14
  32. package/hooks/features/aggregation/useGridAggregation.js +2 -1
  33. package/hooks/features/dataSource/models.d.ts +52 -1
  34. package/hooks/features/dataSource/useGridDataSourcePremium.js +29 -4
  35. package/hooks/features/dataSource/utils.d.ts +6 -0
  36. package/hooks/features/dataSource/utils.js +148 -0
  37. package/hooks/features/index.d.ts +2 -1
  38. package/hooks/features/index.js +11 -0
  39. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +23 -13
  40. package/hooks/features/pivoting/gridPivotingSelectors.d.ts +1 -1
  41. package/hooks/features/pivoting/index.d.ts +1 -0
  42. package/hooks/features/pivoting/index.js +12 -0
  43. package/hooks/features/pivoting/useGridPivoting.d.ts +1 -1
  44. package/hooks/features/pivoting/useGridPivoting.js +82 -31
  45. package/hooks/features/pivoting/utils.d.ts +7 -9
  46. package/hooks/features/pivoting/utils.js +42 -27
  47. package/hooks/features/rowGrouping/createGroupingColDef.js +1 -1
  48. package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +6 -2
  49. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
  50. package/index.js +1 -1
  51. package/models/dataGridPremiumProps.d.ts +15 -14
  52. package/package.json +6 -7
package/CHANGELOG.md CHANGED
@@ -5,6 +5,114 @@
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.14.0
9
+
10
+ _Oct 9, 2025_
11
+
12
+ We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 📊 The [Chart zoom now supports the `pressAndDrag` gesture](https://mui.com/x/react-charts/zoom-and-pan/#zoom-interactions-configuration). Pan by pressing and dragging.
15
+ - 🔄 [Server-side pivoting](https://mui.com/x/react-data-grid/server-side-data/pivoting/) support for the Data Grid
16
+ - 🐞 Bugfixes
17
+ - 📚 Documentation improvements
18
+
19
+ Special thanks go out to the community members for their valuable contributions:
20
+ @djpremier, @Utkarsh-0304
21
+
22
+ The following are all team members who have contributed to this release:
23
+ @alexfauquette, @bernardobelchior, @flaviendelangle, @hasdfa, @Janpot, @JCQuintas, @prakhargupta1, @rita-codes, @noraleonte, @brijeshb42, @arminmeh, @michelengelen
24
+
25
+ ### Data Grid
26
+
27
+ #### `@mui/x-data-grid@8.14.0`
28
+
29
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#19658) @djpremier
30
+
31
+ #### `@mui/x-data-grid-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
32
+
33
+ Same changes as in `@mui/x-data-grid@8.14.0`.
34
+
35
+ #### `@mui/x-data-grid-premium@8.14.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
36
+
37
+ Same changes as in `@mui/x-data-grid-pro@8.14.0`, plus:
38
+
39
+ - [DataGridPremium] Server-side pivoting (#19575) @arminmeh
40
+
41
+ ### Date and Time Pickers
42
+
43
+ #### `@mui/x-date-pickers@8.14.0`
44
+
45
+ - [pickers] Fixed the extra element for the disabled date picker (#19387) @Utkarsh-0304
46
+ - [pickers] Fix input `autoCapitalize` value for Firefox compatibility (#19285) @michelengelen
47
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#19658) @djpremier
48
+
49
+ #### `@mui/x-date-pickers-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
+
51
+ Same changes as in `@mui/x-date-pickers@8.14.0`.
52
+
53
+ ### Charts
54
+
55
+ #### `@mui/x-charts@8.14.0`
56
+
57
+ - [charts] Add `pressAndDrag` pan gesture (#19779) @JCQuintas
58
+ - [charts] Allow `minPointers` and `maxPointers` to be configured by pointer type (#19794) @JCQuintas
59
+ - [charts] Correct scale domain types (#19844) @bernardobelchior
60
+ - [charts] Fix tooltip position when scrolling (#19857) @alexfauquette
61
+ - [charts] Link item highlight with keyboard navigation (#19768) @alexfauquette
62
+ - [charts] Refactor domain/scale selectors (#19832) @bernardobelchior
63
+ - [charts] Remove min/max from ordinal configuration (#19789) @alexfauquette
64
+ - [charts] Simplify axes filters selectors (#19833) @bernardobelchior
65
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#19658) @djpremier
66
+
67
+ #### `@mui/x-charts-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
68
+
69
+ Same changes as in `@mui/x-charts@8.14.0`.
70
+
71
+ #### `@mui/x-charts-premium@8.14.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
72
+
73
+ Same changes as in `@mui/x-charts-pro@8.14.0`.
74
+
75
+ ### Tree View
76
+
77
+ #### `@mui/x-tree-view@8.14.0`
78
+
79
+ - [tree view] Fix Tree View tooltip anchoring on overview page (#19806) @noraleonte
80
+
81
+ #### `@mui/x-tree-view-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
82
+
83
+ Same changes as in `@mui/x-tree-view@8.14.0`.
84
+
85
+ ### Codemod
86
+
87
+ #### `@mui/x-codemod@8.14.0`
88
+
89
+ Internal changes.
90
+
91
+ ### Docs
92
+
93
+ - [docs] Add overview section for pie chart (#19672) @prakhargupta1
94
+ - [docs] Fix demo title knob keys (#19843) @JCQuintas
95
+ - [docs] Hide UI elements of unsupported features in the data source demos (#19849) @arminmeh
96
+
97
+ ### Core
98
+
99
+ - [code-infra] Cleanup unused dependencies (#19788) @brijeshb42
100
+ - [code-infra] Fix pnpm-lock issue (#19861) @JCQuintas
101
+ - [code-infra] Improve publishing docs (#19404) @Janpot
102
+ - [code-infra] Remove tsconfig `baseUrl` (#19837) @Janpot
103
+ - [code-infra] Support custom npm dist tags during release (#19803) @Janpot
104
+ - [code-infra] Wait longer for print dialog (#19795) @JCQuintas
105
+ - [code-infra] Replace `lodash` with `es-toolkit` (#19853) @bernardobelchior
106
+ - [code-infra] Update release script PR checklist (#19785) @bernardobelchior
107
+ - [code-infra] Remove remaining usages of `lodash` (#19864) @bernardobelchior
108
+ - [docs-infra] Add `title` knob (#19792) @JCQuintas
109
+ - [docs-infra] Fix missing key in title knob (#19804) @JCQuintas
110
+
111
+ ### Miscellaneous
112
+
113
+ - [x-telemetry] Fix transpile issues (#19761) @hasdfa
114
+ - [x-telemetry] Fix ref to deleted file (#19842) @JCQuintas
115
+
8
116
  ## 8.13.1
9
117
 
10
118
  _Oct 1, 2025_
@@ -222,7 +330,7 @@ We'd like to extend a big thank you to the 15 contributors who made this release
222
330
 
223
331
  ![Grid x Charts](https://github.com/user-attachments/assets/0817c36f-f87f-4688-8f30-fa0db638ca8c)
224
332
 
225
- 👉 [🎥 Watch the full video](https://github.com/user-attachments/assets/28f1848e-dc85-4077-8756-a3e88afd4e54)
333
+ 👉 [🎥 Watch the full video](https://github.com/user-attachments/assets/28f1848e-dc85-4077-8756-a3e88afd4e54)
226
334
 
227
335
  - ⌨️ Charts keyboard navigation
228
336
  - ⚡️ Charts: Add new `renderer="svg-batch"` prop to Scatter charts that provides improved performance for large datasets
@@ -48,7 +48,7 @@ const configuration = {
48
48
  useGridParamsOverridableMethods: _useGridParamsOverridableMethods.useGridParamsOverridableMethods
49
49
  }
50
50
  };
51
- const releaseInfo = "MTc1OTI3NjgwMDAwMA==";
51
+ const releaseInfo = "MTc1OTk2ODAwMDAwMA==";
52
52
  const watermark = /*#__PURE__*/(0, _jsxRuntime.jsx)(_xLicense.Watermark, {
53
53
  packageName: "x-data-grid-premium",
54
54
  releaseInfo: releaseInfo
@@ -493,7 +493,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
493
493
  * @param {GridColDef} column The column to generate derived columns for.
494
494
  * @param {GridLocaleTextApi['getLocaleText']} getLocaleText The function to get the locale text.
495
495
  * @returns {GridColDef[] | undefined} The derived columns.
496
- * @default {defaultGetPivotDerivedColumns} Creates year and quarter columns for date columns.
496
+ * @default {defaultGetPivotDerivedColumns | undefined} Creates year and quarter columns for date columns if not in server side mode.
497
497
  */
498
498
  getPivotDerivedColumns: _propTypes.default.func,
499
499
  /**
@@ -1118,16 +1118,18 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
1118
1118
  pivotActive: _propTypes.default.bool,
1119
1119
  /**
1120
1120
  * The column definition overrides for the columns generated by the pivoting feature.
1121
- * @param {string} originalColumnField The field of the original column.
1122
- * @param {string[]} columnGroupPath The path of the column groups the column belongs to.
1123
- * @returns {Partial<GridPivotingColDefOverrides> | undefined | void} The column definition overrides.
1121
+ * Pass either a partial column definition to apply the same overrides to all pivot columns, or a callback to apply different overrides to each pivot column.
1122
+ * For server-side pivoting, only the `PivotingColDefCallback` signature is supported, and the prop is required.
1123
+ * @type {Partial<GridPivotingColDefOverrides> | PivotingColDefCallback}
1124
1124
  * @default undefined
1125
+ * @throws {Error} If `undefined` and `dataSource` is provided.
1125
1126
  */
1126
1127
  pivotingColDef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
1127
1128
  align: _propTypes.default.oneOf(['center', 'left', 'right']),
1128
1129
  cellClassName: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
1129
1130
  description: _propTypes.default.string,
1130
1131
  display: _propTypes.default.oneOf(['flex', 'text']),
1132
+ field: _propTypes.default.string,
1131
1133
  flex: _propTypes.default.number,
1132
1134
  headerAlign: _propTypes.default.oneOf(['center', 'left', 'right']),
1133
1135
  headerClassName: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
@@ -43,7 +43,6 @@ const DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PREMIUM_PROPS_D
43
43
  return text.split(/\r\n|\n|\r/).map(row => row.split(delimiter));
44
44
  },
45
45
  disablePivoting: false,
46
- getPivotDerivedColumns: _utils.defaultGetPivotDerivedColumns,
47
46
  aiAssistant: false,
48
47
  chartsIntegration: false
49
48
  });
@@ -62,7 +61,9 @@ const useDataGridPremiumProps = inProps => {
62
61
  }), [themedProps.slots]);
63
62
  return React.useMemo(() => (0, _extends2.default)({}, DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES, themedProps.dataSource ? {
64
63
  aggregationFunctions: {}
65
- } : {}, themedProps, {
64
+ } : {
65
+ getPivotDerivedColumns: _utils.defaultGetPivotDerivedColumns
66
+ }, themedProps, {
66
67
  localeText,
67
68
  slots
68
69
  }, getDataGridPremiumForcedProps(themedProps)), [themedProps, localeText, slots]);
@@ -13,6 +13,7 @@ var _internals = require("@mui/x-data-grid-pro/internals");
13
13
  var _xDataGridPro = require("@mui/x-data-grid-pro");
14
14
  var _useGridApiContext = require("../hooks/utils/useGridApiContext");
15
15
  var _useGridRootProps = require("../hooks/utils/useGridRootProps");
16
+ var _gridRowGroupingSelector = require("../hooks/features/rowGrouping/gridRowGroupingSelector");
16
17
  var _jsxRuntime = require("react/jsx-runtime");
17
18
  const useUtilityClasses = ownerState => {
18
19
  const {
@@ -89,7 +90,12 @@ function GridDataSourceGroupingCriteriaCell(props) {
89
90
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
90
91
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
91
92
  const row = (0, _xDataGridPro.useGridSelector)(apiRef, _internals.gridRowSelector, id);
93
+ const pivotActive = (0, _xDataGridPro.useGridSelector)(apiRef, _internals.gridPivotActiveSelector);
94
+ const rowGroupingModelLength = (0, _xDataGridPro.useGridSelector)(apiRef, _gridRowGroupingSelector.gridRowGroupingModelSelector).length;
92
95
  const classes = useUtilityClasses(rootProps);
96
+ const shouldShowToggleContainer = !pivotActive || rowGroupingModelLength > 1;
97
+ // Do not allow expand/collapse the last grouping criteria cell when in pivot mode
98
+ const shouldShowToggleButton = !pivotActive || rowNode.depth < rowGroupingModelLength - 1;
93
99
  let descendantCount = 0;
94
100
  if (row) {
95
101
  descendantCount = rootProps.dataSource?.getChildrenCount?.(row) ?? 0;
@@ -112,9 +118,9 @@ function GridDataSourceGroupingCriteriaCell(props) {
112
118
  style: {
113
119
  marginLeft: rootProps.rowGroupingColumnMode === 'multiple' ? 0 : `calc(var(--DataGrid-cellOffsetMultiplier) * ${_internals.vars.spacing(rowNode.depth)})`
114
120
  },
115
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
121
+ children: [shouldShowToggleContainer && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
116
122
  className: classes.toggle,
117
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridGroupingCriteriaCellIcon, {
123
+ children: shouldShowToggleButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridGroupingCriteriaCellIcon, {
118
124
  id: id,
119
125
  field: field,
120
126
  rowNode: rowNode,
@@ -15,7 +15,6 @@ var _export = require("./export");
15
15
  var _useGridRootProps = require("../hooks/utils/useGridRootProps");
16
16
  var _useGridApiContext = require("../hooks/utils/useGridApiContext");
17
17
  var _PivotPanelTrigger = require("./pivotPanel/PivotPanelTrigger");
18
- var _utils = require("../hooks/features/pivoting/utils");
19
18
  var _aiAssistantPanel = require("./aiAssistantPanel");
20
19
  var _ChartsPanelTrigger = require("./chartsPanel/ChartsPanelTrigger");
21
20
  var _jsxRuntime = require("react/jsx-runtime");
@@ -25,7 +24,7 @@ function GridPremiumToolbar(props) {
25
24
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
26
25
  const other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
27
26
  const additionalItems = /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
28
- children: [(0, _utils.isPivotingAvailable)(rootProps) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PivotPanelTrigger.PivotPanelTrigger, {
27
+ children: [!rootProps.disablePivoting && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PivotPanelTrigger.PivotPanelTrigger, {
29
28
  render: (triggerProps, state) => /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, {
30
29
  title: apiRef.current.getLocaleText('toolbarPivot'),
31
30
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGridPro.ToolbarButton, (0, _extends2.default)({}, triggerProps, {
@@ -140,8 +140,8 @@ function AggregationSelect({
140
140
  const availableAggregationFunctions = React.useMemo(() => (0, _gridAggregationUtils.getAvailableAggregationFunctions)({
141
141
  aggregationFunctions: rootProps.aggregationFunctions,
142
142
  colDef,
143
- isDataSource: false
144
- }), [colDef, rootProps.aggregationFunctions]);
143
+ isDataSource: !!rootProps.dataSource
144
+ }), [colDef, rootProps.aggregationFunctions, rootProps.dataSource]);
145
145
  const handleClick = func => {
146
146
  apiRef.current.setPivotModel(prev => {
147
147
  return (0, _extends2.default)({}, prev, {
@@ -157,7 +157,7 @@ function AggregationSelect({
157
157
  });
158
158
  setAggregationMenuOpen(false);
159
159
  };
160
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
160
+ return availableAggregationFunctions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
161
161
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseChip, {
162
162
  label: (0, _gridAggregationUtils.getAggregationFunctionLabel)({
163
163
  apiRef,
@@ -198,7 +198,7 @@ function AggregationSelect({
198
198
  }), func))
199
199
  }))
200
200
  })]
201
- });
201
+ }) : null;
202
202
  }
203
203
  function GridPivotPanelField(props) {
204
204
  const {
@@ -41,7 +41,7 @@ const configuration = {
41
41
  useGridParamsOverridableMethods
42
42
  }
43
43
  };
44
- const releaseInfo = "MTc1OTI3NjgwMDAwMA==";
44
+ const releaseInfo = "MTc1OTk2ODAwMDAwMA==";
45
45
  const watermark = /*#__PURE__*/_jsx(Watermark, {
46
46
  packageName: "x-data-grid-premium",
47
47
  releaseInfo: releaseInfo
@@ -486,7 +486,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
486
486
  * @param {GridColDef} column The column to generate derived columns for.
487
487
  * @param {GridLocaleTextApi['getLocaleText']} getLocaleText The function to get the locale text.
488
488
  * @returns {GridColDef[] | undefined} The derived columns.
489
- * @default {defaultGetPivotDerivedColumns} Creates year and quarter columns for date columns.
489
+ * @default {defaultGetPivotDerivedColumns | undefined} Creates year and quarter columns for date columns if not in server side mode.
490
490
  */
491
491
  getPivotDerivedColumns: PropTypes.func,
492
492
  /**
@@ -1111,16 +1111,18 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
1111
1111
  pivotActive: PropTypes.bool,
1112
1112
  /**
1113
1113
  * The column definition overrides for the columns generated by the pivoting feature.
1114
- * @param {string} originalColumnField The field of the original column.
1115
- * @param {string[]} columnGroupPath The path of the column groups the column belongs to.
1116
- * @returns {Partial<GridPivotingColDefOverrides> | undefined | void} The column definition overrides.
1114
+ * Pass either a partial column definition to apply the same overrides to all pivot columns, or a callback to apply different overrides to each pivot column.
1115
+ * For server-side pivoting, only the `PivotingColDefCallback` signature is supported, and the prop is required.
1116
+ * @type {Partial<GridPivotingColDefOverrides> | PivotingColDefCallback}
1117
1117
  * @default undefined
1118
+ * @throws {Error} If `undefined` and `dataSource` is provided.
1118
1119
  */
1119
1120
  pivotingColDef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1120
1121
  align: PropTypes.oneOf(['center', 'left', 'right']),
1121
1122
  cellClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1122
1123
  description: PropTypes.string,
1123
1124
  display: PropTypes.oneOf(['flex', 'text']),
1125
+ field: PropTypes.string,
1124
1126
  flex: PropTypes.number,
1125
1127
  headerAlign: PropTypes.oneOf(['center', 'left', 'right']),
1126
1128
  headerClassName: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
@@ -35,7 +35,6 @@ export const DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PRO
35
35
  return text.split(/\r\n|\n|\r/).map(row => row.split(delimiter));
36
36
  },
37
37
  disablePivoting: false,
38
- getPivotDerivedColumns: defaultGetPivotDerivedColumns,
39
38
  aiAssistant: false,
40
39
  chartsIntegration: false
41
40
  });
@@ -54,7 +53,9 @@ export const useDataGridPremiumProps = inProps => {
54
53
  }), [themedProps.slots]);
55
54
  return React.useMemo(() => _extends({}, DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES, themedProps.dataSource ? {
56
55
  aggregationFunctions: {}
57
- } : {}, themedProps, {
56
+ } : {
57
+ getPivotDerivedColumns: defaultGetPivotDerivedColumns
58
+ }, themedProps, {
58
59
  localeText,
59
60
  slots
60
61
  }, getDataGridPremiumForcedProps(themedProps)), [themedProps, localeText, slots]);
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import composeClasses from '@mui/utils/composeClasses';
4
- import { useGridPrivateApiContext, gridDataSourceErrorSelector, gridDataSourceLoadingIdSelector, gridRowSelector, vars } from '@mui/x-data-grid-pro/internals';
4
+ import { useGridPrivateApiContext, gridDataSourceErrorSelector, gridDataSourceLoadingIdSelector, gridRowSelector, vars, gridPivotActiveSelector } from '@mui/x-data-grid-pro/internals';
5
5
  import { useGridSelector, getDataGridUtilityClass } from '@mui/x-data-grid-pro';
6
6
  import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
7
7
  import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
8
+ import { gridRowGroupingModelSelector } from "../hooks/features/rowGrouping/gridRowGroupingSelector.js";
8
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const useUtilityClasses = ownerState => {
10
11
  const {
@@ -81,7 +82,12 @@ export function GridDataSourceGroupingCriteriaCell(props) {
81
82
  const rootProps = useGridRootProps();
82
83
  const apiRef = useGridApiContext();
83
84
  const row = useGridSelector(apiRef, gridRowSelector, id);
85
+ const pivotActive = useGridSelector(apiRef, gridPivotActiveSelector);
86
+ const rowGroupingModelLength = useGridSelector(apiRef, gridRowGroupingModelSelector).length;
84
87
  const classes = useUtilityClasses(rootProps);
88
+ const shouldShowToggleContainer = !pivotActive || rowGroupingModelLength > 1;
89
+ // Do not allow expand/collapse the last grouping criteria cell when in pivot mode
90
+ const shouldShowToggleButton = !pivotActive || rowNode.depth < rowGroupingModelLength - 1;
85
91
  let descendantCount = 0;
86
92
  if (row) {
87
93
  descendantCount = rootProps.dataSource?.getChildrenCount?.(row) ?? 0;
@@ -104,9 +110,9 @@ export function GridDataSourceGroupingCriteriaCell(props) {
104
110
  style: {
105
111
  marginLeft: rootProps.rowGroupingColumnMode === 'multiple' ? 0 : `calc(var(--DataGrid-cellOffsetMultiplier) * ${vars.spacing(rowNode.depth)})`
106
112
  },
107
- children: [/*#__PURE__*/_jsx("div", {
113
+ children: [shouldShowToggleContainer && /*#__PURE__*/_jsx("div", {
108
114
  className: classes.toggle,
109
- children: /*#__PURE__*/_jsx(GridGroupingCriteriaCellIcon, {
115
+ children: shouldShowToggleButton && /*#__PURE__*/_jsx(GridGroupingCriteriaCellIcon, {
110
116
  id: id,
111
117
  field: field,
112
118
  rowNode: rowNode,
@@ -8,7 +8,6 @@ import { ExportExcel } from "./export/index.js";
8
8
  import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
9
9
  import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
10
10
  import { PivotPanelTrigger } from "./pivotPanel/PivotPanelTrigger.js";
11
- import { isPivotingAvailable } from "../hooks/features/pivoting/utils.js";
12
11
  import { AiAssistantPanelTrigger } from "./aiAssistantPanel/index.js";
13
12
  import { ChartsPanelTrigger } from "./chartsPanel/ChartsPanelTrigger.js";
14
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -17,7 +16,7 @@ export function GridPremiumToolbar(props) {
17
16
  const apiRef = useGridApiContext();
18
17
  const other = _objectWithoutPropertiesLoose(props, _excluded);
19
18
  const additionalItems = /*#__PURE__*/_jsxs(React.Fragment, {
20
- children: [isPivotingAvailable(rootProps) && /*#__PURE__*/_jsx(PivotPanelTrigger, {
19
+ children: [!rootProps.disablePivoting && /*#__PURE__*/_jsx(PivotPanelTrigger, {
21
20
  render: (triggerProps, state) => /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
22
21
  title: apiRef.current.getLocaleText('toolbarPivot'),
23
22
  children: /*#__PURE__*/_jsx(ToolbarButton, _extends({}, triggerProps, {
@@ -133,8 +133,8 @@ function AggregationSelect({
133
133
  const availableAggregationFunctions = React.useMemo(() => getAvailableAggregationFunctions({
134
134
  aggregationFunctions: rootProps.aggregationFunctions,
135
135
  colDef,
136
- isDataSource: false
137
- }), [colDef, rootProps.aggregationFunctions]);
136
+ isDataSource: !!rootProps.dataSource
137
+ }), [colDef, rootProps.aggregationFunctions, rootProps.dataSource]);
138
138
  const handleClick = func => {
139
139
  apiRef.current.setPivotModel(prev => {
140
140
  return _extends({}, prev, {
@@ -150,7 +150,7 @@ function AggregationSelect({
150
150
  });
151
151
  setAggregationMenuOpen(false);
152
152
  };
153
- return /*#__PURE__*/_jsxs(React.Fragment, {
153
+ return availableAggregationFunctions.length > 0 ? /*#__PURE__*/_jsxs(React.Fragment, {
154
154
  children: [/*#__PURE__*/_jsx(rootProps.slots.baseChip, {
155
155
  label: getAggregationFunctionLabel({
156
156
  apiRef,
@@ -191,7 +191,7 @@ function AggregationSelect({
191
191
  }), func))
192
192
  }))
193
193
  })]
194
- });
194
+ }) : null;
195
195
  }
196
196
  function GridPivotPanelField(props) {
197
197
  const {
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import { isObjectEmpty } from '@mui/x-internals/isObjectEmpty';
6
6
  import { gridColumnLookupSelector, useGridEvent, useGridApiMethod, useRunOncePerLoop, gridRenderContextSelector, gridVisibleColumnFieldsSelector, gridSortModelSelector } from '@mui/x-data-grid-pro';
7
- import { useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
7
+ import { useGridRegisterPipeProcessor, gridPivotActiveSelector } from '@mui/x-data-grid-pro/internals';
8
8
  import { gridAggregationLookupSelector, gridAggregationModelSelector } from "./gridAggregationSelectors.js";
9
9
  import { getAggregationRules, mergeStateWithAggregationModel, areAggregationRulesEqual } from "./gridAggregationUtils.js";
10
10
  import { createAggregationLookup, shouldApplySorting } from "./createAggregationLookup.js";
@@ -156,6 +156,7 @@ export const useGridAggregation = (apiRef, props) => {
156
156
  * EVENTS
157
157
  */
158
158
  const checkAggregationRulesDiff = React.useCallback(() => {
159
+ const pivotingActive = gridPivotActiveSelector(apiRef);
159
160
  const {
160
161
  rulesOnLastRowHydration,
161
162
  rulesOnLastColumnHydration
@@ -163,7 +164,7 @@ export const useGridAggregation = (apiRef, props) => {
163
164
  const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.dataSource);
164
165
 
165
166
  // Re-apply the row hydration to add / remove the aggregation footers
166
- if (!props.dataSource && !areAggregationRulesEqual(rulesOnLastRowHydration, aggregationRules)) {
167
+ if ((!props.dataSource || pivotingActive) && !areAggregationRulesEqual(rulesOnLastRowHydration, aggregationRules)) {
167
168
  apiRef.current.requestPipeProcessorsApplication('hydrateRows');
168
169
  deferredApplyAggregation();
169
170
  }
@@ -1,5 +1,22 @@
1
- import type { GridColDef, GridRowId, GridValidRowModel, GridDataSource, GridGetRowsResponse, GridGetRowsParams, GridDataSourceApiBase, GridDataSourcePrivateApi } from '@mui/x-data-grid-pro';
1
+ import type { GridColDef, GridRowId, GridValidRowModel, GridDataSource, GridGetRowsResponse, GridGetRowsParams, GridDataSourceApiBase, GridDataSourcePrivateApi, GridRowModel } from '@mui/x-data-grid-pro';
2
2
  import type { GridAggregationModel } from "../aggregation/gridAggregationInterfaces.js";
3
+ import type { GridPivotModel } from "../pivoting/gridPivotingInterfaces.js";
4
+ export interface GridGetRowsResponsePivotColumn {
5
+ key: string;
6
+ group: string | GridRowModel;
7
+ children?: GridGetRowsResponsePivotColumn[];
8
+ }
9
+ /**
10
+ * Path to a pivot column group.
11
+ * @param {string} key Pivot column key.
12
+ * @param {string} field Pivot column field.
13
+ * @param {string | GridRowModel} value Path value that is either a string or a part of row model needed to get the formatted value of the original column.
14
+ */
15
+ export interface GridDataSourcePivotColumnGroupPath {
16
+ key: string;
17
+ field: string;
18
+ value: string | GridRowModel;
19
+ }
3
20
  export interface GridGetRowsResponsePremium extends GridGetRowsResponse {
4
21
  /**
5
22
  * Row to be used for aggregation footer row.
@@ -7,6 +24,32 @@ export interface GridGetRowsResponsePremium extends GridGetRowsResponse {
7
24
  * `GridGetRowsParams.aggregationModel`.
8
25
  */
9
26
  aggregateRow?: GridValidRowModel;
27
+ /**
28
+ * Defines the structure of pivot columns to be created from the pivoted data.
29
+ * Each node in the tree must have a `key` and `group` property.
30
+ * `key` is used to identify the column group and will be passed to the `pivotingColDef` callback as the column path parameter.
31
+ * `group` is either a string or a part of a row model needed to get the formatted value of the original column.
32
+ * optionally,`children` is a list of the next level nodes.
33
+ * Each node at the last level of the tree will be a column group containing each pivot value as a column.
34
+ *
35
+ * Structure:
36
+ * The `group` property can be a string or an object:
37
+ * - Strings are used directly as column group header names (e.g. `"2025"`, `"January"`)
38
+ * - Objects contain data that will be formatted into header names using the column's valueFormatter or valueGetter
39
+ * (e.g. `{date: "2025-01-01"}` could be formatted as `"Jan 2025"`)
40
+ *
41
+ * Examples:
42
+ * - `[{key: "Y", group: "Yes"}, {key: "N", group: "No"}]` - Creates column groups with values "Yes" and "No"
43
+ * - `[{key: "2025", group: "2025", children: [{key: "January", group: "January"}, {key: "February", group: "February"}]}]` - Creates a column group with value "2025"
44
+ * that has column groups "January" and "February"
45
+ * - `[
46
+ * {key: "2025-01", group: {date: "2025-01-01"}, children: [{key: "01", group: {date: "2025-01-01"}}]},
47
+ * {key: "2025-02", group: {date: "2025-02-01"}, children: [{key: "02", group: {date: "2025-02-01"}}]},
48
+ * ]` - Creates two levels of column groups with values returned from the value formatters of the columns used for pivoting.
49
+ * Even though the same values are passed, the header names can be different based on the valueFormatter or valueGetter.
50
+ * One pivoting column may format the date as a year and the other as a month.
51
+ */
52
+ pivotColumns?: GridGetRowsResponsePivotColumn[];
10
53
  }
11
54
  export interface GridGetRowsParamsPremium extends GridGetRowsParams {
12
55
  /**
@@ -17,6 +60,14 @@ export interface GridGetRowsParamsPremium extends GridGetRowsParams {
17
60
  * List of grouped columns (only applicable with `rowGrouping`).
18
61
  */
19
62
  groupFields?: GridColDef['field'][];
63
+ /**
64
+ * Visible rows, columns and values from the pivot model (only applicable with `pivoting`).
65
+ */
66
+ pivotModel?: {
67
+ columns: Omit<GridPivotModel['columns'], 'hidden'>;
68
+ rows: Omit<GridPivotModel['rows'], 'hidden'>;
69
+ values: Omit<GridPivotModel['values'], 'hidden'>;
70
+ };
20
71
  }
21
72
  export interface GridDataSourcePremium extends Omit<GridDataSource, 'getRows'> {
22
73
  /**
@@ -3,9 +3,11 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import { useGridEvent as addEventHandler, useGridApiMethod, GRID_ROOT_GROUP_ID, useGridEvent } from '@mui/x-data-grid-pro';
6
- import { useGridDataSourceBasePro, useGridRegisterStrategyProcessor, useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
6
+ import { useGridDataSourceBasePro, useGridRegisterStrategyProcessor, useGridRegisterPipeProcessor, gridPivotInitialColumnsSelector, runIf, gridPivotActiveSelector } from '@mui/x-data-grid-pro/internals';
7
+ import { gridPivotModelSelector } from "../pivoting/gridPivotingSelectors.js";
8
+ import { getPropsOverrides } from "./utils.js";
7
9
  function getKeyPremium(params) {
8
- return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.aggregationModel]);
10
+ return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.pivotModel ? {} : params.aggregationModel, params.pivotModel]);
9
11
  }
10
12
  const options = {
11
13
  cacheOptions: {
@@ -21,6 +23,9 @@ export const useGridDataSourcePremium = (apiRef, props) => {
21
23
  setStrategyAvailability
22
24
  } = useGridDataSourceBasePro(apiRef, props, options);
23
25
  const aggregateRowRef = React.useRef({});
26
+ const initialColumns = gridPivotInitialColumnsSelector(apiRef);
27
+ const pivotActive = gridPivotActiveSelector(apiRef);
28
+ const pivotModel = gridPivotModelSelector(apiRef);
24
29
  const processDataSourceRows = React.useCallback(({
25
30
  params,
26
31
  response
@@ -34,11 +39,29 @@ export const useGridDataSourcePremium = (apiRef, props) => {
34
39
  }
35
40
  apiRef.current.applyAggregation();
36
41
  }
42
+ if (response.pivotColumns) {
43
+ const pivotingColDef = props.pivotingColDef;
44
+ if (!pivotingColDef || typeof pivotingColDef !== 'function') {
45
+ throw new Error('MUI X: No `pivotingColDef()` prop provided with to the Data Grid, but response contains `pivotColumns`.\n\n\
46
+ You need a callback to return at least a field column prop for each generated pivot column.\n\n\
47
+ See [server-side pivoting](https://mui.com/x/react-data-grid/server-side-data/pivoting/) documentation for more details.');
48
+ }
49
+
50
+ // Update the grid state with new columns and column grouping model
51
+ const partialPropsOverrides = getPropsOverrides(response.pivotColumns, pivotingColDef, pivotModel, initialColumns, apiRef);
52
+ apiRef.current.setState(state => {
53
+ return _extends({}, state, {
54
+ pivoting: _extends({}, state.pivoting, {
55
+ propsOverrides: _extends({}, state.pivoting.propsOverrides, partialPropsOverrides)
56
+ })
57
+ });
58
+ });
59
+ }
37
60
  return {
38
61
  params,
39
62
  response
40
63
  };
41
- }, [apiRef]);
64
+ }, [apiRef, props.pivotingColDef, initialColumns, pivotModel]);
42
65
  const resolveGroupAggregation = React.useCallback((groupId, field) => {
43
66
  if (groupId === GRID_ROOT_GROUP_ID) {
44
67
  return props.dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
@@ -56,8 +79,10 @@ export const useGridDataSourcePremium = (apiRef, props) => {
56
79
  Object.entries(events).forEach(([event, handler]) => {
57
80
  addEventHandler(apiRef, event, handler);
58
81
  });
59
- useGridEvent(apiRef, 'rowGroupingModelChange', () => debouncedFetchRows());
60
- useGridEvent(apiRef, 'aggregationModelChange', () => debouncedFetchRows());
82
+ useGridEvent(apiRef, 'rowGroupingModelChange', runIf(!pivotActive, () => debouncedFetchRows()));
83
+ useGridEvent(apiRef, 'aggregationModelChange', runIf(!pivotActive, () => debouncedFetchRows()));
84
+ useGridEvent(apiRef, 'pivotModeChange', runIf(!pivotActive, () => debouncedFetchRows()));
85
+ useGridEvent(apiRef, 'pivotModelChange', runIf(pivotActive, () => debouncedFetchRows()));
61
86
  React.useEffect(() => {
62
87
  setStrategyAvailability();
63
88
  }, [setStrategyAvailability]);
@@ -0,0 +1,6 @@
1
+ import type { RefObject } from '@mui/x-internals/types';
2
+ import { GridColDef } from '@mui/x-data-grid-pro';
3
+ import type { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
4
+ import type { GridPivotingDynamicPropsOverrides, PivotingColDefCallback, GridPivotModel } from "../pivoting/gridPivotingInterfaces.js";
5
+ import type { GridGetRowsResponsePivotColumn } from "./models.js";
6
+ export declare const getPropsOverrides: (pivotColumns: GridGetRowsResponsePivotColumn[], pivotingColDef: PivotingColDefCallback, pivotModel: GridPivotModel, initialColumns: Map<string, GridColDef>, apiRef: RefObject<GridPrivateApiPremium>) => GridPivotingDynamicPropsOverrides;