@mui/x-data-grid-premium 7.5.1 → 7.6.1

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,117 @@
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
+ ## 7.6.1
7
+
8
+ _May 31, 2024_
9
+
10
+ We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ 🐞 Address the `@mui/internal-test-utils` added as a direct dependency to `@mui/x-data-grid` by mistake.
13
+
14
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
15
+
16
+ ### Data Grid
17
+
18
+ #### `@mui/x-data-grid@7.6.1`
19
+
20
+ - [DataGrid] Fix column resize not working with special character (#13069) @oukunan
21
+ - [DataGrid] Move `@mui/internal-test-utils` to dev dependency (#13318) @LukasTy
22
+
23
+ #### `@mui/x-data-grid-pro@7.6.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
24
+
25
+ Same changes as in `@mui/x-data-grid@7.6.1`.
26
+
27
+ #### `@mui/x-data-grid-premium@7.6.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
28
+
29
+ Same changes as in `@mui/x-data-grid-pro@7.6.1`.
30
+
31
+ ## 7.6.0
32
+
33
+ _May 30, 2024_
34
+
35
+ We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
36
+
37
+ - 🎁 Allow to define and customize the indentation of nested items in the Tree View
38
+ - ✨ Allow charts highlights to be controlled
39
+ - 🌍 Improve Persian (fa-IR) locale on the Data Grid
40
+ - 🐞 Bugfixes
41
+ - 📚 Documentation improvements
42
+
43
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
44
+
45
+ ### Data Grid
46
+
47
+ #### `@mui/x-data-grid@7.6.0`
48
+
49
+ - [DataGrid] Avoid re-rendering all cells on column change (#12980) @romgrk
50
+ - [DataGrid] Export `GridColumnHeadersProps` (#13229) @cherniavskii
51
+ - [DataGrid] Fix header filters' issue with custom filters (#13255) @MBilalShafi
52
+ - [DataGrid] Remove dead logic to support Safari < 13 (#13249) @oliviertassinari
53
+ - [l10n] Improve Persian (fa-IR) locale (#12994) @amiryxe
54
+
55
+ #### `@mui/x-data-grid-pro@7.6.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
56
+
57
+ Same changes as in `@mui/x-data-grid@7.6.0`.
58
+
59
+ #### `@mui/x-data-grid-premium@7.6.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
60
+
61
+ Same changes as in `@mui/x-data-grid-pro@7.6.0`, plus:
62
+
63
+ - [DataGridPremium] Fix excel export causing column with wrong width (#13191) @romgrk
64
+
65
+ ### Date and Time Pickers
66
+
67
+ #### `@mui/x-date-pickers@7.6.0`
68
+
69
+ - [pickers] Fix `DateBuilderReturnType` when the date is `undefined` (#13244) @alexey-kozlenkov
70
+
71
+ #### `@mui/x-date-pickers-pro@7.6.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
72
+
73
+ Same changes as in `@mui/x-date-pickers@7.6.0`.
74
+
75
+ ### Charts
76
+
77
+ #### `@mui/x-charts@7.6.0`
78
+
79
+ - [charts] Allow charts highlights to be controlled (#12828) @JCQuintas
80
+ - [charts] Refactor axis band scaleType check (#13295) @JCQuintas
81
+ - [charts] Refactor checkScaleErrors to improve readability and simplify axis message logic (#13305) @JCQuintas
82
+
83
+ ### Tree View
84
+
85
+ #### `@mui/x-tree-view@7.6.0`
86
+
87
+ - [TreeView] Add JSDoc to every instance method (#13219) @flaviendelangle
88
+ - [TreeView] Allow to customize the indentation of nested items (#13225) @flaviendelangle
89
+ - [TreeView] Allow to define indentation at the item level (#13126) @flaviendelangle
90
+
91
+ ### Docs
92
+
93
+ - [docs] Add Bulk editing demo for the Community plan (#12800) @cherniavskii
94
+ - [docs] Add conditional label formatting on tooltip page and link to label page (#13235) @JCQuintas
95
+ - [docs] Add information about key combinations on a11y sections (#13234) @arthurbalduini
96
+ - [docs] Cleanup of the Tree View demos (#13237) @flaviendelangle
97
+ - [docs] Document how to customize a subsection of a line chart (#13210) @alexfauquette
98
+ - [docs] Fix Pickers FAQ callout (#13238) @LukasTy
99
+ - [docs] Fix Vale errors @oliviertassinari
100
+ - [docs] Fix a small typo in property comment (#13245) @Janpot
101
+ - [docs] Improve the Data Grid FAQ page (#13258) @MBilalShafi
102
+ - [docs] Removes unused lines in TreeItem2 styling (#13264) @arthurbalduini
103
+ - [docs] Small improvements on accessibility data grid doc (#13233) @arthurbalduini
104
+ - [docs] Update Pickers demo configurations (#13303) @LukasTy
105
+
106
+ ### Core
107
+
108
+ - [core] Add comment on why logic to sync column header (#13248) @oliviertassinari
109
+ - [core] Fix `l10n` script execution with arguments (#13297) @LukasTy
110
+ - [core] Prevent "Add reviewers" workflow from triggering since it doesn't work (#13236) @JCQuintas
111
+ - [docs-infra] Fix `@mui/material` version used in sandboxes (#13260) @LukasTy
112
+ - [test] Use `describeTreeView` for keyboard navigation tests on disabled items (#13184) @flaviendelangle
113
+ - [test] Use `describeTreeView` for remaining items tests (#13262) @flaviendelangle
114
+ - [test] Use test-utils from npm (#12880) @michaldudak
115
+ - [typescript] Remove duplicate `DateRangePosition` type in favor of `RangePosition` (#13288) @LukasTy
116
+
6
117
  ## v7.5.1
7
118
 
8
119
  _May 23, 2024_
@@ -339,7 +450,7 @@ Same changes as in `@mui/x-date-pickers@7.3.1`.
339
450
  ### Core
340
451
 
341
452
  - [core] Fix `l10n` GH workflow (#12895) @LukasTy
342
- - [core] Match Base UI and Toolpad @oliviertassinari
453
+ - [core] Match Base UI and Toolpad @oliviertassinari
343
454
  - [core] Remove redundant `setupFiles` entries in `package.json` (#12899) @LukasTy
344
455
  - [core] Use `describeTreeView` for focus tests (#12698) @flaviendelangle
345
456
  - [core] Use `describeTreeView` for type-ahead tests (#12811) @flaviendelangle
@@ -92,7 +92,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
92
92
  */
93
93
  'aria-labelledby': _propTypes.default.string,
94
94
  /**
95
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
95
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
96
96
  * @default false
97
97
  */
98
98
  autoHeight: _propTypes.default.bool,
@@ -84,7 +84,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
84
84
  */
85
85
  'aria-labelledby': PropTypes.string,
86
86
  /**
87
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
87
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
88
88
  * @default false
89
89
  */
90
90
  autoHeight: PropTypes.bool,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { GRID_DATE_COL_DEF, GRID_DATETIME_COL_DEF } from '@mui/x-data-grid-pro';
3
- import { buildWarning, isObject, isSingleSelectColDef } from '@mui/x-data-grid/internals';
3
+ import { buildWarning, isObject, isSingleSelectColDef, gridHasColSpanSelector } from '@mui/x-data-grid/internals';
4
4
  const getExcelJs = async () => {
5
5
  const excelJsModule = await import('exceljs');
6
6
  return excelJsModule.default ?? excelJsModule;
@@ -23,22 +23,30 @@ const getFormattedValueOptions = (colDef, row, valueOptions, api) => {
23
23
  }
24
24
  return valueOptionsFormatted.map(option => typeof option === 'object' ? option.label : option);
25
25
  };
26
- export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) => {
26
+ /**
27
+ * FIXME: This function mutates the colspan info, but colspan info assumes that the columns
28
+ * passed to it are always consistent. In this case, the exported columns may differ from the
29
+ * actual rendered columns.
30
+ * The caller of this function MUST call `resetColSpan()` before and after usage.
31
+ */
32
+ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormulae, options) => {
27
33
  const row = {};
28
34
  const dataValidation = {};
29
35
  const mergedCells = [];
30
- const firstCellParams = api.getCellParams(id, columns[0].field);
36
+ const firstCellParams = apiRef.current.getCellParams(id, columns[0].field);
31
37
  const outlineLevel = firstCellParams.rowNode.depth;
32
-
33
- // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
34
- api.calculateColSpan({
35
- rowId: id,
36
- minFirstColumn: 0,
37
- maxLastColumn: columns.length,
38
- columns
39
- });
38
+ const hasColSpan = gridHasColSpanSelector(apiRef);
39
+ if (hasColSpan) {
40
+ // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
41
+ apiRef.current.calculateColSpan({
42
+ rowId: id,
43
+ minFirstColumn: 0,
44
+ maxLastColumn: columns.length,
45
+ columns
46
+ });
47
+ }
40
48
  columns.forEach((column, colIndex) => {
41
- const colSpanInfo = api.unstable_getCellColSpanInfo(id, colIndex);
49
+ const colSpanInfo = hasColSpan ? apiRef.current.unstable_getCellColSpanInfo(id, colIndex) : undefined;
42
50
  if (colSpanInfo && colSpanInfo.spannedByColSpan) {
43
51
  return;
44
52
  }
@@ -48,7 +56,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
48
56
  rightIndex: colIndex + colSpanInfo.cellProps.colSpan
49
57
  });
50
58
  }
51
- const cellParams = api.getCellParams(id, column.field);
59
+ const cellParams = apiRef.current.getCellParams(id, column.field);
52
60
  let cellValue;
53
61
  switch (cellParams.colDef.type) {
54
62
  case 'singleSelect':
@@ -62,7 +70,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
62
70
  row,
63
71
  field: cellParams.field
64
72
  });
65
- const formattedValueOptions = getFormattedValueOptions(castColumn, row, valueOptions, api);
73
+ const formattedValueOptions = getFormattedValueOptions(castColumn, row, valueOptions, apiRef.current);
66
74
  dataValidation[castColumn.field] = {
67
75
  type: 'list',
68
76
  allowBlank: true,
@@ -78,7 +86,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
78
86
  formulae: [address]
79
87
  };
80
88
  }
81
- const formattedValue = api.getCellParams(id, castColumn.field).formattedValue;
89
+ const formattedValue = apiRef.current.getCellParams(id, castColumn.field).formattedValue;
82
90
  if (process.env.NODE_ENV !== 'production') {
83
91
  if (String(cellParams.formattedValue) === '[object Object]') {
84
92
  warnInvalidFormattedValue();
@@ -93,7 +101,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
93
101
  }
94
102
  case 'boolean':
95
103
  case 'number':
96
- cellValue = api.getCellParams(id, column.field).value;
104
+ cellValue = apiRef.current.getCellParams(id, column.field).value;
97
105
  break;
98
106
  case 'date':
99
107
  case 'dateTime':
@@ -101,7 +109,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
101
109
  // Excel does not do any timezone conversion, so we create a date using UTC instead of local timezone
102
110
  // Solution from: https://github.com/exceljs/exceljs/issues/486#issuecomment-432557582
103
111
  // About Date.UTC(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
104
- const value = api.getCellParams(id, column.field).value;
112
+ const value = apiRef.current.getCellParams(id, column.field).value;
105
113
  // value may be `undefined` in auto-generated grouping rows
106
114
  if (!value) {
107
115
  break;
@@ -113,7 +121,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
113
121
  case 'actions':
114
122
  break;
115
123
  default:
116
- cellValue = api.getCellParams(id, column.field).formattedValue;
124
+ cellValue = apiRef.current.getCellParams(id, column.field).formattedValue;
117
125
  if (process.env.NODE_ENV !== 'production') {
118
126
  if (String(cellParams.formattedValue) === '[object Object]') {
119
127
  warnInvalidFormattedValue();
@@ -276,7 +284,7 @@ async function createValueOptionsSheetIfNeeded(valueOptionsData, sheetName, work
276
284
  valueOptionsWorksheet.getColumn(field).values = values;
277
285
  });
278
286
  }
279
- export async function buildExcel(options, api) {
287
+ export async function buildExcel(options, apiRef) {
280
288
  const {
281
289
  columns,
282
290
  rowIds,
@@ -300,20 +308,22 @@ export async function buildExcel(options, api) {
300
308
  }
301
309
  if (includeColumnGroupsHeaders) {
302
310
  const columnGroupPaths = columns.reduce((acc, column) => {
303
- acc[column.field] = api.getColumnGroupPath(column.field);
311
+ acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
304
312
  return acc;
305
313
  }, {});
306
- addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, api.getAllGroupDetails());
314
+ addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, apiRef.current.getAllGroupDetails());
307
315
  }
308
316
  if (includeHeaders) {
309
317
  worksheet.addRow(columns.map(column => column.headerName ?? column.field));
310
318
  }
311
- const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, api);
319
+ const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, apiRef.current);
312
320
  createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
321
+ apiRef.current.resetColSpan();
313
322
  rowIds.forEach(id => {
314
- const serializedRow = serializeRow(id, columns, api, valueOptionsData, options);
323
+ const serializedRow = serializeRowUnsafe(id, columns, apiRef, valueOptionsData, options);
315
324
  addSerializedRowToWorksheet(serializedRow, worksheet);
316
325
  });
326
+ apiRef.current.resetColSpan();
317
327
  if (exceljsPostProcess) {
318
328
  await exceljsPostProcess({
319
329
  workbook,
@@ -3,7 +3,7 @@ const _excluded = ["worker", "exceljsPostProcess", "exceljsPreProcess", "columns
3
3
  import * as React from 'react';
4
4
  import { useGridApiMethod, useGridLogger, useGridApiOptionHandler } from '@mui/x-data-grid';
5
5
  import { useGridRegisterPipeProcessor, exportAs, getColumnsToExport, defaultGetRowsToExport } from '@mui/x-data-grid/internals';
6
- import { buildExcel, getDataForValueOptionsSheet, serializeColumns, serializeRow } from './serializer/excelSerializer';
6
+ import { buildExcel, getDataForValueOptionsSheet, serializeColumns, serializeRowUnsafe } from './serializer/excelSerializer';
7
7
  import { GridExcelExportMenuItem } from '../../../components';
8
8
 
9
9
  /**
@@ -36,7 +36,7 @@ export const useGridExcelExport = (apiRef, props) => {
36
36
  exceljsPreProcess: options?.exceljsPreProcess,
37
37
  exceljsPostProcess: options?.exceljsPostProcess,
38
38
  escapeFormulas: options.escapeFormulas ?? true
39
- }, apiRef.current);
39
+ }, apiRef);
40
40
  }, [logger, apiRef]);
41
41
  const exportDataAsExcel = React.useCallback(async (options = {}) => {
42
42
  const {
@@ -88,9 +88,11 @@ export const useGridExcelExport = (apiRef, props) => {
88
88
  });
89
89
  const valueOptionsData = await getDataForValueOptionsSheet(exportedColumns, valueOptionsSheetName, apiRef.current);
90
90
  const serializedColumns = serializeColumns(exportedColumns, options.columnsStyles || {});
91
- const serializedRows = exportedRowIds.map(id => serializeRow(id, exportedColumns, apiRef.current, valueOptionsData, {
91
+ apiRef.current.resetColSpan();
92
+ const serializedRows = exportedRowIds.map(id => serializeRowUnsafe(id, exportedColumns, apiRef, valueOptionsData, {
92
93
  escapeFormulas: options.escapeFormulas ?? true
93
94
  }));
95
+ apiRef.current.resetColSpan();
94
96
  const columnGroupPaths = exportedColumns.reduce((acc, column) => {
95
97
  acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
96
98
  return acc;
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxNjQxNTIwMDAwMA==";
3
+ const releaseInfo = "MTcxNzEwMjgwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type * as Excel from 'exceljs';
2
3
  import { GridRowId, GridColDef } from '@mui/x-data-grid-pro';
3
4
  import { GridStateColDef, GridColumnGroupLookup } from '@mui/x-data-grid/internals';
@@ -12,7 +13,13 @@ interface SerializedRow {
12
13
  rightIndex: number;
13
14
  }[];
14
15
  }
15
- export declare const serializeRow: (id: GridRowId, columns: GridStateColDef[], api: GridPrivateApiPremium, defaultValueOptionsFormulae: {
16
+ /**
17
+ * FIXME: This function mutates the colspan info, but colspan info assumes that the columns
18
+ * passed to it are always consistent. In this case, the exported columns may differ from the
19
+ * actual rendered columns.
20
+ * The caller of this function MUST call `resetColSpan()` before and after usage.
21
+ */
22
+ export declare const serializeRowUnsafe: (id: GridRowId, columns: GridStateColDef[], apiRef: React.MutableRefObject<GridPrivateApiPremium>, defaultValueOptionsFormulae: {
16
23
  [field: string]: {
17
24
  address: string;
18
25
  };
@@ -47,7 +54,7 @@ interface BuildExcelOptions extends Pick<GridExcelExportOptions, 'exceljsPreProc
47
54
  rowIds: GridRowId[];
48
55
  columnsStyles?: ColumnsStylesInterface;
49
56
  }
50
- export declare function buildExcel(options: BuildExcelOptions, api: GridPrivateApiPremium): Promise<Excel.Workbook>;
57
+ export declare function buildExcel(options: BuildExcelOptions, apiRef: React.MutableRefObject<GridPrivateApiPremium>): Promise<Excel.Workbook>;
51
58
  export interface ExcelExportInitEvent {
52
59
  serializedColumns: SerializedColumns;
53
60
  serializedRows: SerializedRow[];
@@ -8,7 +8,7 @@ exports.buildExcel = buildExcel;
8
8
  exports.getDataForValueOptionsSheet = getDataForValueOptionsSheet;
9
9
  exports.serializeColumn = void 0;
10
10
  exports.serializeColumns = serializeColumns;
11
- exports.serializeRow = void 0;
11
+ exports.serializeRowUnsafe = void 0;
12
12
  exports.setupExcelExportWebWorker = setupExcelExportWebWorker;
13
13
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
14
  var _xDataGridPro = require("@mui/x-data-grid-pro");
@@ -37,22 +37,30 @@ const getFormattedValueOptions = (colDef, row, valueOptions, api) => {
37
37
  }
38
38
  return valueOptionsFormatted.map(option => typeof option === 'object' ? option.label : option);
39
39
  };
40
- const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) => {
40
+ /**
41
+ * FIXME: This function mutates the colspan info, but colspan info assumes that the columns
42
+ * passed to it are always consistent. In this case, the exported columns may differ from the
43
+ * actual rendered columns.
44
+ * The caller of this function MUST call `resetColSpan()` before and after usage.
45
+ */
46
+ const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormulae, options) => {
41
47
  const row = {};
42
48
  const dataValidation = {};
43
49
  const mergedCells = [];
44
- const firstCellParams = api.getCellParams(id, columns[0].field);
50
+ const firstCellParams = apiRef.current.getCellParams(id, columns[0].field);
45
51
  const outlineLevel = firstCellParams.rowNode.depth;
46
-
47
- // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
48
- api.calculateColSpan({
49
- rowId: id,
50
- minFirstColumn: 0,
51
- maxLastColumn: columns.length,
52
- columns
53
- });
52
+ const hasColSpan = (0, _internals.gridHasColSpanSelector)(apiRef);
53
+ if (hasColSpan) {
54
+ // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
55
+ apiRef.current.calculateColSpan({
56
+ rowId: id,
57
+ minFirstColumn: 0,
58
+ maxLastColumn: columns.length,
59
+ columns
60
+ });
61
+ }
54
62
  columns.forEach((column, colIndex) => {
55
- const colSpanInfo = api.unstable_getCellColSpanInfo(id, colIndex);
63
+ const colSpanInfo = hasColSpan ? apiRef.current.unstable_getCellColSpanInfo(id, colIndex) : undefined;
56
64
  if (colSpanInfo && colSpanInfo.spannedByColSpan) {
57
65
  return;
58
66
  }
@@ -62,7 +70,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
62
70
  rightIndex: colIndex + colSpanInfo.cellProps.colSpan
63
71
  });
64
72
  }
65
- const cellParams = api.getCellParams(id, column.field);
73
+ const cellParams = apiRef.current.getCellParams(id, column.field);
66
74
  let cellValue;
67
75
  switch (cellParams.colDef.type) {
68
76
  case 'singleSelect':
@@ -76,7 +84,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
76
84
  row,
77
85
  field: cellParams.field
78
86
  });
79
- const formattedValueOptions = getFormattedValueOptions(castColumn, row, valueOptions, api);
87
+ const formattedValueOptions = getFormattedValueOptions(castColumn, row, valueOptions, apiRef.current);
80
88
  dataValidation[castColumn.field] = {
81
89
  type: 'list',
82
90
  allowBlank: true,
@@ -92,7 +100,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
92
100
  formulae: [address]
93
101
  };
94
102
  }
95
- const formattedValue = api.getCellParams(id, castColumn.field).formattedValue;
103
+ const formattedValue = apiRef.current.getCellParams(id, castColumn.field).formattedValue;
96
104
  if (process.env.NODE_ENV !== 'production') {
97
105
  if (String(cellParams.formattedValue) === '[object Object]') {
98
106
  warnInvalidFormattedValue();
@@ -107,7 +115,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
107
115
  }
108
116
  case 'boolean':
109
117
  case 'number':
110
- cellValue = api.getCellParams(id, column.field).value;
118
+ cellValue = apiRef.current.getCellParams(id, column.field).value;
111
119
  break;
112
120
  case 'date':
113
121
  case 'dateTime':
@@ -115,7 +123,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
115
123
  // Excel does not do any timezone conversion, so we create a date using UTC instead of local timezone
116
124
  // Solution from: https://github.com/exceljs/exceljs/issues/486#issuecomment-432557582
117
125
  // About Date.UTC(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
118
- const value = api.getCellParams(id, column.field).value;
126
+ const value = apiRef.current.getCellParams(id, column.field).value;
119
127
  // value may be `undefined` in auto-generated grouping rows
120
128
  if (!value) {
121
129
  break;
@@ -127,7 +135,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
127
135
  case 'actions':
128
136
  break;
129
137
  default:
130
- cellValue = api.getCellParams(id, column.field).formattedValue;
138
+ cellValue = apiRef.current.getCellParams(id, column.field).formattedValue;
131
139
  if (process.env.NODE_ENV !== 'production') {
132
140
  if (String(cellParams.formattedValue) === '[object Object]') {
133
141
  warnInvalidFormattedValue();
@@ -152,7 +160,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) =>
152
160
  mergedCells
153
161
  };
154
162
  };
155
- exports.serializeRow = serializeRow;
163
+ exports.serializeRowUnsafe = serializeRowUnsafe;
156
164
  const defaultColumnsStyles = {
157
165
  [_xDataGridPro.GRID_DATE_COL_DEF.type]: {
158
166
  numFmt: 'dd.mm.yyyy'
@@ -292,7 +300,7 @@ async function createValueOptionsSheetIfNeeded(valueOptionsData, sheetName, work
292
300
  valueOptionsWorksheet.getColumn(field).values = values;
293
301
  });
294
302
  }
295
- async function buildExcel(options, api) {
303
+ async function buildExcel(options, apiRef) {
296
304
  const {
297
305
  columns,
298
306
  rowIds,
@@ -316,20 +324,22 @@ async function buildExcel(options, api) {
316
324
  }
317
325
  if (includeColumnGroupsHeaders) {
318
326
  const columnGroupPaths = columns.reduce((acc, column) => {
319
- acc[column.field] = api.getColumnGroupPath(column.field);
327
+ acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
320
328
  return acc;
321
329
  }, {});
322
- addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, api.getAllGroupDetails());
330
+ addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, apiRef.current.getAllGroupDetails());
323
331
  }
324
332
  if (includeHeaders) {
325
333
  worksheet.addRow(columns.map(column => column.headerName ?? column.field));
326
334
  }
327
- const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, api);
335
+ const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, apiRef.current);
328
336
  createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
337
+ apiRef.current.resetColSpan();
329
338
  rowIds.forEach(id => {
330
- const serializedRow = serializeRow(id, columns, api, valueOptionsData, options);
339
+ const serializedRow = serializeRowUnsafe(id, columns, apiRef, valueOptionsData, options);
331
340
  addSerializedRowToWorksheet(serializedRow, worksheet);
332
341
  });
342
+ apiRef.current.resetColSpan();
333
343
  if (exceljsPostProcess) {
334
344
  await exceljsPostProcess({
335
345
  workbook,
@@ -44,7 +44,7 @@ const useGridExcelExport = (apiRef, props) => {
44
44
  exceljsPreProcess: options?.exceljsPreProcess,
45
45
  exceljsPostProcess: options?.exceljsPostProcess,
46
46
  escapeFormulas: options.escapeFormulas ?? true
47
- }, apiRef.current);
47
+ }, apiRef);
48
48
  }, [logger, apiRef]);
49
49
  const exportDataAsExcel = React.useCallback(async (options = {}) => {
50
50
  const {
@@ -96,9 +96,11 @@ const useGridExcelExport = (apiRef, props) => {
96
96
  });
97
97
  const valueOptionsData = await (0, _excelSerializer.getDataForValueOptionsSheet)(exportedColumns, valueOptionsSheetName, apiRef.current);
98
98
  const serializedColumns = (0, _excelSerializer.serializeColumns)(exportedColumns, options.columnsStyles || {});
99
- const serializedRows = exportedRowIds.map(id => (0, _excelSerializer.serializeRow)(id, exportedColumns, apiRef.current, valueOptionsData, {
99
+ apiRef.current.resetColSpan();
100
+ const serializedRows = exportedRowIds.map(id => (0, _excelSerializer.serializeRowUnsafe)(id, exportedColumns, apiRef, valueOptionsData, {
100
101
  escapeFormulas: options.escapeFormulas ?? true
101
102
  }));
103
+ apiRef.current.resetColSpan();
102
104
  const columnGroupPaths = exportedColumns.reduce((acc, column) => {
103
105
  acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
104
106
  return acc;
package/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './hooks';
22
22
  export * from './models';
23
23
  export * from './components';
24
24
  export { GridColumnHeaders } from '@mui/x-data-grid-pro';
25
+ export type { GridColumnHeadersProps } from '@mui/x-data-grid-pro';
25
26
  export type { DataGridPremiumProps, GridExperimentalPremiumFeatures, } from './models/dataGridPremiumProps';
26
27
  export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
27
28
  export type { GridApi, GridInitialState, GridState } from './typeOverloads/reexports';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v7.5.1
2
+ * @mui/x-data-grid-premium v7.6.1
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -84,7 +84,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
84
84
  */
85
85
  'aria-labelledby': PropTypes.string,
86
86
  /**
87
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
87
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
88
88
  * @default false
89
89
  */
90
90
  autoHeight: PropTypes.bool,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { GRID_DATE_COL_DEF, GRID_DATETIME_COL_DEF } from '@mui/x-data-grid-pro';
3
- import { buildWarning, isObject, isSingleSelectColDef } from '@mui/x-data-grid/internals';
3
+ import { buildWarning, isObject, isSingleSelectColDef, gridHasColSpanSelector } from '@mui/x-data-grid/internals';
4
4
  const getExcelJs = async () => {
5
5
  const excelJsModule = await import('exceljs');
6
6
  return excelJsModule.default ?? excelJsModule;
@@ -23,22 +23,30 @@ const getFormattedValueOptions = (colDef, row, valueOptions, api) => {
23
23
  }
24
24
  return valueOptionsFormatted.map(option => typeof option === 'object' ? option.label : option);
25
25
  };
26
- export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) => {
26
+ /**
27
+ * FIXME: This function mutates the colspan info, but colspan info assumes that the columns
28
+ * passed to it are always consistent. In this case, the exported columns may differ from the
29
+ * actual rendered columns.
30
+ * The caller of this function MUST call `resetColSpan()` before and after usage.
31
+ */
32
+ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormulae, options) => {
27
33
  const row = {};
28
34
  const dataValidation = {};
29
35
  const mergedCells = [];
30
- const firstCellParams = api.getCellParams(id, columns[0].field);
36
+ const firstCellParams = apiRef.current.getCellParams(id, columns[0].field);
31
37
  const outlineLevel = firstCellParams.rowNode.depth;
32
-
33
- // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
34
- api.calculateColSpan({
35
- rowId: id,
36
- minFirstColumn: 0,
37
- maxLastColumn: columns.length,
38
- columns
39
- });
38
+ const hasColSpan = gridHasColSpanSelector(apiRef);
39
+ if (hasColSpan) {
40
+ // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
41
+ apiRef.current.calculateColSpan({
42
+ rowId: id,
43
+ minFirstColumn: 0,
44
+ maxLastColumn: columns.length,
45
+ columns
46
+ });
47
+ }
40
48
  columns.forEach((column, colIndex) => {
41
- const colSpanInfo = api.unstable_getCellColSpanInfo(id, colIndex);
49
+ const colSpanInfo = hasColSpan ? apiRef.current.unstable_getCellColSpanInfo(id, colIndex) : undefined;
42
50
  if (colSpanInfo && colSpanInfo.spannedByColSpan) {
43
51
  return;
44
52
  }
@@ -48,7 +56,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
48
56
  rightIndex: colIndex + colSpanInfo.cellProps.colSpan
49
57
  });
50
58
  }
51
- const cellParams = api.getCellParams(id, column.field);
59
+ const cellParams = apiRef.current.getCellParams(id, column.field);
52
60
  let cellValue;
53
61
  switch (cellParams.colDef.type) {
54
62
  case 'singleSelect':
@@ -62,7 +70,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
62
70
  row,
63
71
  field: cellParams.field
64
72
  });
65
- const formattedValueOptions = getFormattedValueOptions(castColumn, row, valueOptions, api);
73
+ const formattedValueOptions = getFormattedValueOptions(castColumn, row, valueOptions, apiRef.current);
66
74
  dataValidation[castColumn.field] = {
67
75
  type: 'list',
68
76
  allowBlank: true,
@@ -78,7 +86,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
78
86
  formulae: [address]
79
87
  };
80
88
  }
81
- const formattedValue = api.getCellParams(id, castColumn.field).formattedValue;
89
+ const formattedValue = apiRef.current.getCellParams(id, castColumn.field).formattedValue;
82
90
  if (process.env.NODE_ENV !== 'production') {
83
91
  if (String(cellParams.formattedValue) === '[object Object]') {
84
92
  warnInvalidFormattedValue();
@@ -93,7 +101,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
93
101
  }
94
102
  case 'boolean':
95
103
  case 'number':
96
- cellValue = api.getCellParams(id, column.field).value;
104
+ cellValue = apiRef.current.getCellParams(id, column.field).value;
97
105
  break;
98
106
  case 'date':
99
107
  case 'dateTime':
@@ -101,7 +109,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
101
109
  // Excel does not do any timezone conversion, so we create a date using UTC instead of local timezone
102
110
  // Solution from: https://github.com/exceljs/exceljs/issues/486#issuecomment-432557582
103
111
  // About Date.UTC(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
104
- const value = api.getCellParams(id, column.field).value;
112
+ const value = apiRef.current.getCellParams(id, column.field).value;
105
113
  // value may be `undefined` in auto-generated grouping rows
106
114
  if (!value) {
107
115
  break;
@@ -113,7 +121,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, opti
113
121
  case 'actions':
114
122
  break;
115
123
  default:
116
- cellValue = api.getCellParams(id, column.field).formattedValue;
124
+ cellValue = apiRef.current.getCellParams(id, column.field).formattedValue;
117
125
  if (process.env.NODE_ENV !== 'production') {
118
126
  if (String(cellParams.formattedValue) === '[object Object]') {
119
127
  warnInvalidFormattedValue();
@@ -276,7 +284,7 @@ async function createValueOptionsSheetIfNeeded(valueOptionsData, sheetName, work
276
284
  valueOptionsWorksheet.getColumn(field).values = values;
277
285
  });
278
286
  }
279
- export async function buildExcel(options, api) {
287
+ export async function buildExcel(options, apiRef) {
280
288
  const {
281
289
  columns,
282
290
  rowIds,
@@ -300,20 +308,22 @@ export async function buildExcel(options, api) {
300
308
  }
301
309
  if (includeColumnGroupsHeaders) {
302
310
  const columnGroupPaths = columns.reduce((acc, column) => {
303
- acc[column.field] = api.getColumnGroupPath(column.field);
311
+ acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
304
312
  return acc;
305
313
  }, {});
306
- addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, api.getAllGroupDetails());
314
+ addColumnGroupingHeaders(worksheet, serializedColumns, columnGroupPaths, apiRef.current.getAllGroupDetails());
307
315
  }
308
316
  if (includeHeaders) {
309
317
  worksheet.addRow(columns.map(column => column.headerName ?? column.field));
310
318
  }
311
- const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, api);
319
+ const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, apiRef.current);
312
320
  createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
321
+ apiRef.current.resetColSpan();
313
322
  rowIds.forEach(id => {
314
- const serializedRow = serializeRow(id, columns, api, valueOptionsData, options);
323
+ const serializedRow = serializeRowUnsafe(id, columns, apiRef, valueOptionsData, options);
315
324
  addSerializedRowToWorksheet(serializedRow, worksheet);
316
325
  });
326
+ apiRef.current.resetColSpan();
317
327
  if (exceljsPostProcess) {
318
328
  await exceljsPostProcess({
319
329
  workbook,
@@ -3,7 +3,7 @@ const _excluded = ["worker", "exceljsPostProcess", "exceljsPreProcess", "columns
3
3
  import * as React from 'react';
4
4
  import { useGridApiMethod, useGridLogger, useGridApiOptionHandler } from '@mui/x-data-grid';
5
5
  import { useGridRegisterPipeProcessor, exportAs, getColumnsToExport, defaultGetRowsToExport } from '@mui/x-data-grid/internals';
6
- import { buildExcel, getDataForValueOptionsSheet, serializeColumns, serializeRow } from './serializer/excelSerializer';
6
+ import { buildExcel, getDataForValueOptionsSheet, serializeColumns, serializeRowUnsafe } from './serializer/excelSerializer';
7
7
  import { GridExcelExportMenuItem } from '../../../components';
8
8
 
9
9
  /**
@@ -36,7 +36,7 @@ export const useGridExcelExport = (apiRef, props) => {
36
36
  exceljsPreProcess: options?.exceljsPreProcess,
37
37
  exceljsPostProcess: options?.exceljsPostProcess,
38
38
  escapeFormulas: options.escapeFormulas ?? true
39
- }, apiRef.current);
39
+ }, apiRef);
40
40
  }, [logger, apiRef]);
41
41
  const exportDataAsExcel = React.useCallback(async (options = {}) => {
42
42
  const {
@@ -88,9 +88,11 @@ export const useGridExcelExport = (apiRef, props) => {
88
88
  });
89
89
  const valueOptionsData = await getDataForValueOptionsSheet(exportedColumns, valueOptionsSheetName, apiRef.current);
90
90
  const serializedColumns = serializeColumns(exportedColumns, options.columnsStyles || {});
91
- const serializedRows = exportedRowIds.map(id => serializeRow(id, exportedColumns, apiRef.current, valueOptionsData, {
91
+ apiRef.current.resetColSpan();
92
+ const serializedRows = exportedRowIds.map(id => serializeRowUnsafe(id, exportedColumns, apiRef, valueOptionsData, {
92
93
  escapeFormulas: options.escapeFormulas ?? true
93
94
  }));
95
+ apiRef.current.resetColSpan();
94
96
  const columnGroupPaths = exportedColumns.reduce((acc, column) => {
95
97
  acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
96
98
  return acc;
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v7.5.1
2
+ * @mui/x-data-grid-premium v7.6.1
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxNjQxNTIwMDAwMA==";
3
+ const releaseInfo = "MTcxNzEwMjgwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-premium",
3
- "version": "7.5.1",
3
+ "version": "7.6.1",
4
4
  "description": "The Premium plan edition of the Data Grid Components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -33,17 +33,17 @@
33
33
  "directory": "packages/x-data-grid-premium"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/runtime": "^7.24.5",
37
- "@mui/system": "^5.15.14",
36
+ "@babel/runtime": "^7.24.6",
37
+ "@mui/system": "^5.15.15",
38
38
  "@mui/utils": "^5.15.14",
39
39
  "@types/format-util": "^1.0.4",
40
40
  "clsx": "^2.1.1",
41
41
  "exceljs": "^4.4.0",
42
42
  "prop-types": "^15.8.1",
43
43
  "reselect": "^4.1.8",
44
- "@mui/x-data-grid": "7.5.1",
45
- "@mui/x-data-grid-pro": "7.5.1",
46
- "@mui/x-license": "7.2.1"
44
+ "@mui/x-data-grid": "7.6.1",
45
+ "@mui/x-data-grid-pro": "7.6.1",
46
+ "@mui/x-license": "7.6.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@mui/material": "^5.15.14",
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getReleaseInfo = void 0;
7
7
  var _utils = require("@mui/utils");
8
8
  const getReleaseInfo = () => {
9
- const releaseInfo = "MTcxNjQxNTIwMDAwMA==";
9
+ const releaseInfo = "MTcxNzEwMjgwMDAwMA==";
10
10
  if (process.env.NODE_ENV !== 'production') {
11
11
  // A simple hack to set the value in the test environment (has no build step).
12
12
  // eslint-disable-next-line no-useless-concat