@mui/x-data-grid-premium 5.17.1 → 5.17.2

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,50 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 5.17.2
7
+
8
+ _Sep 9, 2022_
9
+
10
+ This release will the last regular release for our `v5` packages.
11
+ From now on, we'll be focusing on developing MUI X v6.
12
+ You can check the [roadmap](https://github.com/mui/mui-x/projects/1) for more details on what's coming next.
13
+
14
+ And if you'd like to help, please consider volunteering to give us a [user interview](https://docs.google.com/forms/d/11L_zxL7oD_B-ZrZDuSyIkUzJLzOTUU2M4vHXxMVtWhU/edit).
15
+ We'd love to know more about your use cases, pain points and expectations for the future.
16
+
17
+ The `v5` packages will only get new versions to patch critical bug fixes.
18
+
19
+ We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
20
+
21
+ - 📃 Add support for column grouping when exporting to Excel (#5895) @alexfauquette
22
+ - 🐞 Bugfixes
23
+
24
+ ### `@mui/x-data-grid@v5.17.2` / `@mui/x-data-grid-pro@v5.17.2` / `@mui/x-data-grid-premium@v5.17.2`
25
+
26
+ #### Changes
27
+
28
+ - [DataGrid] Revert mode if cell/row couldn't be saved due to validation error (#5897) @m4theushw
29
+ - [DataGridPremium] Export column grouping in Excel (#5895) @alexfauquette
30
+
31
+ ### `@mui/x-date-pickers@v5.0.1` / `@mui/x-date-pickers-pro@v5.0.1`
32
+
33
+ #### Changes
34
+
35
+ - [DateTimePicker] Remove circular import (#6087) @flaviendelangle
36
+ - [pickers] Add `sx` prop to the equality check of `PickersDay` (#6030) @TheUnlocked
37
+ - [pickers] Add warning when `openTo` is invalid based on available `views` (#6042) @LukasTy
38
+ - [pickers] Allow keyboard navigation to ignore disabled date for left / right arrow (#6082) @alexfauquette
39
+ - [pickers] Fix mobile picker not opening on label click (#6074) @LukasTy
40
+
41
+ ### Docs
42
+
43
+ - [docs] Add Recipes section
44
+
45
+ ### Core
46
+
47
+ - [core] Add `yarn release:tag` script (#5169) @DanailH
48
+ - [core] Upgrade monorepo (#6072) @m4theushw
49
+
6
50
  ## 5.17.1
7
51
 
8
52
  _Sep 5, 2022_
@@ -34,6 +34,11 @@ export interface GridExcelExportOptions extends GridFileExportOptions {
34
34
  * Object mapping column field to Exceljs style
35
35
  * */
36
36
  columnsStyles?: ColumnsStylesInterface;
37
+ /**
38
+ * If `true`, the headers of the column groups will be added into the file.
39
+ * @default true
40
+ */
41
+ includeColumnGroupsHeaders?: boolean;
37
42
  }
38
43
  export interface GridToolbarExportProps extends GridToolbarExportPropsCommunity {
39
44
  excelOptions: GridExcelExportOptions & GridExportDisplayOptions;
@@ -5,6 +5,7 @@ interface BuildExcelOptions {
5
5
  columns: GridStateColDef[];
6
6
  rowIds: GridRowId[];
7
7
  includeHeaders: boolean;
8
+ includeColumnGroupsHeaders: boolean;
8
9
  valueOptionsSheetName: string;
9
10
  exceljsPreProcess?: (processInput: GridExceljsProcessInput) => Promise<void>;
10
11
  exceljsPostProcess?: (processInput: GridExceljsProcessInput) => Promise<void>;
@@ -174,11 +174,79 @@ const serializeColumn = (column, columnsStyles) => {
174
174
  };
175
175
  };
176
176
 
177
+ const addColumnGroupingHeaders = (worksheet, columns, api) => {
178
+ const maxDepth = Math.max(...columns.map(({
179
+ field
180
+ }) => {
181
+ var _api$unstable_getColu, _api$unstable_getColu2;
182
+
183
+ return (_api$unstable_getColu = (_api$unstable_getColu2 = api.unstable_getColumnGroupPath(field)) == null ? void 0 : _api$unstable_getColu2.length) != null ? _api$unstable_getColu : 0;
184
+ }));
185
+
186
+ if (maxDepth === 0) {
187
+ return;
188
+ }
189
+
190
+ const columnGroupDetails = api.unstable_getAllGroupDetails();
191
+
192
+ for (let rowIndex = 0; rowIndex < maxDepth; rowIndex += 1) {
193
+ const row = columns.map(({
194
+ field
195
+ }) => {
196
+ const groupingPath = api.unstable_getColumnGroupPath(field);
197
+
198
+ if (groupingPath.length <= rowIndex) {
199
+ return {
200
+ groupId: null,
201
+ parents: groupingPath
202
+ };
203
+ }
204
+
205
+ return _extends({}, columnGroupDetails[groupingPath[rowIndex]], {
206
+ parents: groupingPath.slice(0, rowIndex)
207
+ });
208
+ });
209
+ const newRow = worksheet.addRow(row.map(group => group.groupId === null ? null : (group == null ? void 0 : group.headerName) || group.groupId)); // use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
210
+
211
+ const lastRowIndex = newRow.worksheet.rowCount;
212
+ let leftIndex = 0;
213
+ let rightIndex = 1;
214
+
215
+ while (rightIndex < columns.length) {
216
+ const {
217
+ groupId: leftGroupId,
218
+ parents: leftParents
219
+ } = row[leftIndex];
220
+ const {
221
+ groupId: rightGroupId,
222
+ parents: rightParents
223
+ } = row[rightIndex];
224
+ const areInSameGroup = leftGroupId === rightGroupId && leftParents.length === rightParents.length && leftParents.every((leftParent, index) => rightParents[index] === leftParent);
225
+
226
+ if (areInSameGroup) {
227
+ rightIndex += 1;
228
+ } else {
229
+ if (rightIndex - leftIndex > 1) {
230
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
231
+ }
232
+
233
+ leftIndex = rightIndex;
234
+ rightIndex += 1;
235
+ }
236
+ }
237
+
238
+ if (rightIndex - leftIndex > 1) {
239
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
240
+ }
241
+ }
242
+ };
243
+
177
244
  export async function buildExcel(options, api) {
178
245
  const {
179
246
  columns,
180
247
  rowIds,
181
248
  includeHeaders,
249
+ includeColumnGroupsHeaders,
182
250
  valueOptionsSheetName,
183
251
  exceljsPreProcess,
184
252
  exceljsPostProcess,
@@ -196,6 +264,10 @@ export async function buildExcel(options, api) {
196
264
  });
197
265
  }
198
266
 
267
+ if (includeColumnGroupsHeaders) {
268
+ addColumnGroupingHeaders(worksheet, columns, api);
269
+ }
270
+
199
271
  if (includeHeaders) {
200
272
  worksheet.addRow(columns.map(column => column.headerName || column.field));
201
273
  }
@@ -15,7 +15,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
15
  export const useGridExcelExport = apiRef => {
16
16
  const logger = useGridLogger(apiRef, 'useGridExcelExport');
17
17
  const getDataAsExcel = React.useCallback((options = {}) => {
18
- var _options$getRowsToExp, _options$includeHeade;
18
+ var _options$getRowsToExp, _options$includeHeade, _options$includeColum;
19
19
 
20
20
  logger.debug(`Get data as excel`);
21
21
  const getRowsToExport = (_options$getRowsToExp = options.getRowsToExport) != null ? _options$getRowsToExp : defaultGetRowsToExport;
@@ -30,6 +30,7 @@ export const useGridExcelExport = apiRef => {
30
30
  columns: exportedColumns,
31
31
  rowIds: exportedRowIds,
32
32
  includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true,
33
+ includeColumnGroupsHeaders: (_options$includeColum = options.includeColumnGroupsHeaders) != null ? _options$includeColum : true,
33
34
  valueOptionsSheetName: (options == null ? void 0 : options.valueOptionsSheetName) || 'Options',
34
35
  columnsStyles: options == null ? void 0 : options.columnsStyles,
35
36
  exceljsPreProcess: options == null ? void 0 : options.exceljsPreProcess,
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.1
1
+ /** @license MUI v5.17.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -203,19 +203,94 @@ var serializeColumn = function serializeColumn(column, columnsStyles) {
203
203
  };
204
204
  };
205
205
 
206
+ var addColumnGroupingHeaders = function addColumnGroupingHeaders(worksheet, columns, api) {
207
+ var maxDepth = Math.max.apply(Math, _toConsumableArray(columns.map(function (_ref2) {
208
+ var _api$unstable_getColu, _api$unstable_getColu2;
209
+
210
+ var field = _ref2.field;
211
+ return (_api$unstable_getColu = (_api$unstable_getColu2 = api.unstable_getColumnGroupPath(field)) == null ? void 0 : _api$unstable_getColu2.length) != null ? _api$unstable_getColu : 0;
212
+ })));
213
+
214
+ if (maxDepth === 0) {
215
+ return;
216
+ }
217
+
218
+ var columnGroupDetails = api.unstable_getAllGroupDetails();
219
+
220
+ var _loop = function _loop(rowIndex) {
221
+ var row = columns.map(function (_ref3) {
222
+ var field = _ref3.field;
223
+ var groupingPath = api.unstable_getColumnGroupPath(field);
224
+
225
+ if (groupingPath.length <= rowIndex) {
226
+ return {
227
+ groupId: null,
228
+ parents: groupingPath
229
+ };
230
+ }
231
+
232
+ return _extends({}, columnGroupDetails[groupingPath[rowIndex]], {
233
+ parents: groupingPath.slice(0, rowIndex)
234
+ });
235
+ });
236
+ var newRow = worksheet.addRow(row.map(function (group) {
237
+ return group.groupId === null ? null : (group == null ? void 0 : group.headerName) || group.groupId;
238
+ })); // use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
239
+
240
+ var lastRowIndex = newRow.worksheet.rowCount;
241
+ var leftIndex = 0;
242
+ var rightIndex = 1;
243
+
244
+ var _loop2 = function _loop2() {
245
+ var _row$leftIndex = row[leftIndex],
246
+ leftGroupId = _row$leftIndex.groupId,
247
+ leftParents = _row$leftIndex.parents;
248
+ var _row$rightIndex = row[rightIndex],
249
+ rightGroupId = _row$rightIndex.groupId,
250
+ rightParents = _row$rightIndex.parents;
251
+ var areInSameGroup = leftGroupId === rightGroupId && leftParents.length === rightParents.length && leftParents.every(function (leftParent, index) {
252
+ return rightParents[index] === leftParent;
253
+ });
254
+
255
+ if (areInSameGroup) {
256
+ rightIndex += 1;
257
+ } else {
258
+ if (rightIndex - leftIndex > 1) {
259
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
260
+ }
261
+
262
+ leftIndex = rightIndex;
263
+ rightIndex += 1;
264
+ }
265
+ };
266
+
267
+ while (rightIndex < columns.length) {
268
+ _loop2();
269
+ }
270
+
271
+ if (rightIndex - leftIndex > 1) {
272
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
273
+ }
274
+ };
275
+
276
+ for (var rowIndex = 0; rowIndex < maxDepth; rowIndex += 1) {
277
+ _loop(rowIndex);
278
+ }
279
+ };
280
+
206
281
  export function buildExcel(_x, _x2) {
207
282
  return _buildExcel.apply(this, arguments);
208
283
  }
209
284
 
210
285
  function _buildExcel() {
211
286
  _buildExcel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options, api) {
212
- var columns, rowIds, includeHeaders, valueOptionsSheetName, exceljsPreProcess, exceljsPostProcess, _options$columnsStyle, columnsStyles, excelJS, workbook, worksheet, columnsWithArrayValueOptions, defaultValueOptionsFormulae, valueOptionsWorksheet;
287
+ var columns, rowIds, includeHeaders, includeColumnGroupsHeaders, valueOptionsSheetName, exceljsPreProcess, exceljsPostProcess, _options$columnsStyle, columnsStyles, excelJS, workbook, worksheet, columnsWithArrayValueOptions, defaultValueOptionsFormulae, valueOptionsWorksheet;
213
288
 
214
289
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
215
290
  while (1) {
216
291
  switch (_context2.prev = _context2.next) {
217
292
  case 0:
218
- columns = options.columns, rowIds = options.rowIds, includeHeaders = options.includeHeaders, valueOptionsSheetName = options.valueOptionsSheetName, exceljsPreProcess = options.exceljsPreProcess, exceljsPostProcess = options.exceljsPostProcess, _options$columnsStyle = options.columnsStyles, columnsStyles = _options$columnsStyle === void 0 ? {} : _options$columnsStyle;
293
+ columns = options.columns, rowIds = options.rowIds, includeHeaders = options.includeHeaders, includeColumnGroupsHeaders = options.includeColumnGroupsHeaders, valueOptionsSheetName = options.valueOptionsSheetName, exceljsPreProcess = options.exceljsPreProcess, exceljsPostProcess = options.exceljsPostProcess, _options$columnsStyle = options.columnsStyles, columnsStyles = _options$columnsStyle === void 0 ? {} : _options$columnsStyle;
219
294
  _context2.next = 3;
220
295
  return getExcelJs();
221
296
 
@@ -239,6 +314,10 @@ function _buildExcel() {
239
314
  });
240
315
 
241
316
  case 10:
317
+ if (includeColumnGroupsHeaders) {
318
+ addColumnGroupingHeaders(worksheet, columns, api);
319
+ }
320
+
242
321
  if (includeHeaders) {
243
322
  worksheet.addRow(columns.map(function (column) {
244
323
  return column.headerName || column.field;
@@ -252,8 +331,8 @@ function _buildExcel() {
252
331
 
253
332
  if (columnsWithArrayValueOptions.length) {
254
333
  valueOptionsWorksheet = workbook.addWorksheet(valueOptionsSheetName);
255
- valueOptionsWorksheet.columns = columnsWithArrayValueOptions.map(function (_ref2) {
256
- var field = _ref2.field;
334
+ valueOptionsWorksheet.columns = columnsWithArrayValueOptions.map(function (_ref4) {
335
+ var field = _ref4.field;
257
336
  return {
258
337
  key: field
259
338
  };
@@ -290,20 +369,20 @@ function _buildExcel() {
290
369
  });
291
370
 
292
371
  if (!exceljsPostProcess) {
293
- _context2.next = 18;
372
+ _context2.next = 19;
294
373
  break;
295
374
  }
296
375
 
297
- _context2.next = 18;
376
+ _context2.next = 19;
298
377
  return exceljsPostProcess({
299
378
  workbook: workbook,
300
379
  worksheet: worksheet
301
380
  });
302
381
 
303
- case 18:
382
+ case 19:
304
383
  return _context2.abrupt("return", workbook);
305
384
 
306
- case 19:
385
+ case 20:
307
386
  case "end":
308
387
  return _context2.stop();
309
388
  }
@@ -18,7 +18,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
18
  export var useGridExcelExport = function useGridExcelExport(apiRef) {
19
19
  var logger = useGridLogger(apiRef, 'useGridExcelExport');
20
20
  var getDataAsExcel = React.useCallback(function () {
21
- var _options$getRowsToExp, _options$includeHeade;
21
+ var _options$getRowsToExp, _options$includeHeade, _options$includeColum;
22
22
 
23
23
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
24
  logger.debug("Get data as excel");
@@ -34,6 +34,7 @@ export var useGridExcelExport = function useGridExcelExport(apiRef) {
34
34
  columns: exportedColumns,
35
35
  rowIds: exportedRowIds,
36
36
  includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true,
37
+ includeColumnGroupsHeaders: (_options$includeColum = options.includeColumnGroupsHeaders) != null ? _options$includeColum : true,
37
38
  valueOptionsSheetName: (options == null ? void 0 : options.valueOptionsSheetName) || 'Options',
38
39
  columnsStyles: options == null ? void 0 : options.columnsStyles,
39
40
  exceljsPreProcess: options == null ? void 0 : options.exceljsPreProcess,
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.1
1
+ /** @license MUI v5.17.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export var getReleaseInfo = function getReleaseInfo() {
3
- var releaseInfo = "MTY2MjMyNTIwMDAwMA==";
3
+ var releaseInfo = "MTY2MjY3NDQwMDAwMA==";
4
4
 
5
5
  if (process.env.NODE_ENV !== 'production') {
6
6
  // A simple hack to set the value in the test environment (has no build step).
@@ -172,11 +172,75 @@ const serializeColumn = (column, columnsStyles) => {
172
172
  };
173
173
  };
174
174
 
175
+ const addColumnGroupingHeaders = (worksheet, columns, api) => {
176
+ const maxDepth = Math.max(...columns.map(({
177
+ field
178
+ }) => api.unstable_getColumnGroupPath(field)?.length ?? 0));
179
+
180
+ if (maxDepth === 0) {
181
+ return;
182
+ }
183
+
184
+ const columnGroupDetails = api.unstable_getAllGroupDetails();
185
+
186
+ for (let rowIndex = 0; rowIndex < maxDepth; rowIndex += 1) {
187
+ const row = columns.map(({
188
+ field
189
+ }) => {
190
+ const groupingPath = api.unstable_getColumnGroupPath(field);
191
+
192
+ if (groupingPath.length <= rowIndex) {
193
+ return {
194
+ groupId: null,
195
+ parents: groupingPath
196
+ };
197
+ }
198
+
199
+ return _extends({}, columnGroupDetails[groupingPath[rowIndex]], {
200
+ parents: groupingPath.slice(0, rowIndex)
201
+ });
202
+ });
203
+ const newRow = worksheet.addRow(row.map(group => group.groupId === null ? null : group?.headerName || group.groupId)); // use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
204
+
205
+ const lastRowIndex = newRow.worksheet.rowCount;
206
+ let leftIndex = 0;
207
+ let rightIndex = 1;
208
+
209
+ while (rightIndex < columns.length) {
210
+ const {
211
+ groupId: leftGroupId,
212
+ parents: leftParents
213
+ } = row[leftIndex];
214
+ const {
215
+ groupId: rightGroupId,
216
+ parents: rightParents
217
+ } = row[rightIndex];
218
+ const areInSameGroup = leftGroupId === rightGroupId && leftParents.length === rightParents.length && leftParents.every((leftParent, index) => rightParents[index] === leftParent);
219
+
220
+ if (areInSameGroup) {
221
+ rightIndex += 1;
222
+ } else {
223
+ if (rightIndex - leftIndex > 1) {
224
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
225
+ }
226
+
227
+ leftIndex = rightIndex;
228
+ rightIndex += 1;
229
+ }
230
+ }
231
+
232
+ if (rightIndex - leftIndex > 1) {
233
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
234
+ }
235
+ }
236
+ };
237
+
175
238
  export async function buildExcel(options, api) {
176
239
  const {
177
240
  columns,
178
241
  rowIds,
179
242
  includeHeaders,
243
+ includeColumnGroupsHeaders,
180
244
  valueOptionsSheetName,
181
245
  exceljsPreProcess,
182
246
  exceljsPostProcess,
@@ -194,6 +258,10 @@ export async function buildExcel(options, api) {
194
258
  });
195
259
  }
196
260
 
261
+ if (includeColumnGroupsHeaders) {
262
+ addColumnGroupingHeaders(worksheet, columns, api);
263
+ }
264
+
197
265
  if (includeHeaders) {
198
266
  worksheet.addRow(columns.map(column => column.headerName || column.field));
199
267
  }
@@ -28,6 +28,7 @@ export const useGridExcelExport = apiRef => {
28
28
  columns: exportedColumns,
29
29
  rowIds: exportedRowIds,
30
30
  includeHeaders: options.includeHeaders ?? true,
31
+ includeColumnGroupsHeaders: options.includeColumnGroupsHeaders ?? true,
31
32
  valueOptionsSheetName: options?.valueOptionsSheetName || 'Options',
32
33
  columnsStyles: options?.columnsStyles,
33
34
  exceljsPreProcess: options?.exceljsPreProcess,
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.1
1
+ /** @license MUI v5.17.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY2MjMyNTIwMDAwMA==";
3
+ const releaseInfo = "MTY2MjY3NDQwMDAwMA==";
4
4
 
5
5
  if (process.env.NODE_ENV !== 'production') {
6
6
  // A simple hack to set the value in the test environment (has no build step).
@@ -189,11 +189,79 @@ const serializeColumn = (column, columnsStyles) => {
189
189
  };
190
190
  };
191
191
 
192
+ const addColumnGroupingHeaders = (worksheet, columns, api) => {
193
+ const maxDepth = Math.max(...columns.map(({
194
+ field
195
+ }) => {
196
+ var _api$unstable_getColu, _api$unstable_getColu2;
197
+
198
+ return (_api$unstable_getColu = (_api$unstable_getColu2 = api.unstable_getColumnGroupPath(field)) == null ? void 0 : _api$unstable_getColu2.length) != null ? _api$unstable_getColu : 0;
199
+ }));
200
+
201
+ if (maxDepth === 0) {
202
+ return;
203
+ }
204
+
205
+ const columnGroupDetails = api.unstable_getAllGroupDetails();
206
+
207
+ for (let rowIndex = 0; rowIndex < maxDepth; rowIndex += 1) {
208
+ const row = columns.map(({
209
+ field
210
+ }) => {
211
+ const groupingPath = api.unstable_getColumnGroupPath(field);
212
+
213
+ if (groupingPath.length <= rowIndex) {
214
+ return {
215
+ groupId: null,
216
+ parents: groupingPath
217
+ };
218
+ }
219
+
220
+ return (0, _extends2.default)({}, columnGroupDetails[groupingPath[rowIndex]], {
221
+ parents: groupingPath.slice(0, rowIndex)
222
+ });
223
+ });
224
+ const newRow = worksheet.addRow(row.map(group => group.groupId === null ? null : (group == null ? void 0 : group.headerName) || group.groupId)); // use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
225
+
226
+ const lastRowIndex = newRow.worksheet.rowCount;
227
+ let leftIndex = 0;
228
+ let rightIndex = 1;
229
+
230
+ while (rightIndex < columns.length) {
231
+ const {
232
+ groupId: leftGroupId,
233
+ parents: leftParents
234
+ } = row[leftIndex];
235
+ const {
236
+ groupId: rightGroupId,
237
+ parents: rightParents
238
+ } = row[rightIndex];
239
+ const areInSameGroup = leftGroupId === rightGroupId && leftParents.length === rightParents.length && leftParents.every((leftParent, index) => rightParents[index] === leftParent);
240
+
241
+ if (areInSameGroup) {
242
+ rightIndex += 1;
243
+ } else {
244
+ if (rightIndex - leftIndex > 1) {
245
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
246
+ }
247
+
248
+ leftIndex = rightIndex;
249
+ rightIndex += 1;
250
+ }
251
+ }
252
+
253
+ if (rightIndex - leftIndex > 1) {
254
+ worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
255
+ }
256
+ }
257
+ };
258
+
192
259
  async function buildExcel(options, api) {
193
260
  const {
194
261
  columns,
195
262
  rowIds,
196
263
  includeHeaders,
264
+ includeColumnGroupsHeaders,
197
265
  valueOptionsSheetName,
198
266
  exceljsPreProcess,
199
267
  exceljsPostProcess,
@@ -211,6 +279,10 @@ async function buildExcel(options, api) {
211
279
  });
212
280
  }
213
281
 
282
+ if (includeColumnGroupsHeaders) {
283
+ addColumnGroupingHeaders(worksheet, columns, api);
284
+ }
285
+
214
286
  if (includeHeaders) {
215
287
  worksheet.addRow(columns.map(column => column.headerName || column.field));
216
288
  }
@@ -31,7 +31,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
31
31
  const useGridExcelExport = apiRef => {
32
32
  const logger = (0, _xDataGrid.useGridLogger)(apiRef, 'useGridExcelExport');
33
33
  const getDataAsExcel = React.useCallback((options = {}) => {
34
- var _options$getRowsToExp, _options$includeHeade;
34
+ var _options$getRowsToExp, _options$includeHeade, _options$includeColum;
35
35
 
36
36
  logger.debug(`Get data as excel`);
37
37
  const getRowsToExport = (_options$getRowsToExp = options.getRowsToExport) != null ? _options$getRowsToExp : _internals.defaultGetRowsToExport;
@@ -46,6 +46,7 @@ const useGridExcelExport = apiRef => {
46
46
  columns: exportedColumns,
47
47
  rowIds: exportedRowIds,
48
48
  includeHeaders: (_options$includeHeade = options.includeHeaders) != null ? _options$includeHeade : true,
49
+ includeColumnGroupsHeaders: (_options$includeColum = options.includeColumnGroupsHeaders) != null ? _options$includeColum : true,
49
50
  valueOptionsSheetName: (options == null ? void 0 : options.valueOptionsSheetName) || 'Options',
50
51
  columnsStyles: options == null ? void 0 : options.columnsStyles,
51
52
  exceljsPreProcess: options == null ? void 0 : options.exceljsPreProcess,
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.1
1
+ /** @license MUI v5.17.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -8,7 +8,7 @@ exports.getReleaseInfo = void 0;
8
8
  var _utils = require("@mui/utils");
9
9
 
10
10
  const getReleaseInfo = () => {
11
- const releaseInfo = "MTY2MjMyNTIwMDAwMA==";
11
+ const releaseInfo = "MTY2MjY3NDQwMDAwMA==";
12
12
 
13
13
  if (process.env.NODE_ENV !== 'production') {
14
14
  // A simple hack to set the value in the test environment (has no build step).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-premium",
3
- "version": "5.17.1",
3
+ "version": "5.17.2",
4
4
  "description": "The Premium plan edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.18.9",
35
35
  "@mui/utils": "^5.9.3",
36
- "@mui/x-data-grid": "5.17.1",
37
- "@mui/x-data-grid-pro": "5.17.1",
36
+ "@mui/x-data-grid": "5.17.2",
37
+ "@mui/x-data-grid-pro": "5.17.2",
38
38
  "@mui/x-license-pro": "5.17.0",
39
39
  "@types/format-util": "^1.0.2",
40
40
  "clsx": "^1.2.1",
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY2MjMyNTIwMDAwMA==";
3
+ const releaseInfo = "MTY2MjY3NDQwMDAwMA==";
4
4
 
5
5
  if (process.env.NODE_ENV !== 'production') {
6
6
  // A simple hack to set the value in the test environment (has no build step).