@mui/x-data-grid-premium 7.4.0 → 7.5.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +132 -5395
  2. package/DataGridPremium/DataGridPremium.js +8 -3
  3. package/components/GridColumnMenuAggregationItem.js +1 -1
  4. package/components/GridColumnMenuRowGroupItem.d.ts +1 -5
  5. package/components/GridColumnMenuRowGroupItem.js +1 -10
  6. package/components/GridColumnMenuRowUngroupItem.d.ts +1 -5
  7. package/components/GridColumnMenuRowUngroupItem.js +1 -10
  8. package/components/GridExcelExportMenuItem.js +2 -1
  9. package/components/GridPremiumColumnMenu.d.ts +1 -2
  10. package/components/GridPremiumColumnMenu.js +1 -11
  11. package/esm/DataGridPremium/DataGridPremium.js +8 -3
  12. package/esm/components/GridColumnMenuAggregationItem.js +1 -1
  13. package/esm/components/GridColumnMenuRowGroupItem.js +2 -12
  14. package/esm/components/GridColumnMenuRowUngroupItem.js +2 -12
  15. package/esm/components/GridExcelExportMenuItem.js +2 -1
  16. package/esm/components/GridPremiumColumnMenu.js +2 -13
  17. package/esm/hooks/features/cellSelection/useGridCellSelection.js +6 -3
  18. package/esm/hooks/features/export/serializer/excelSerializer.js +14 -4
  19. package/esm/hooks/features/export/useGridExcelExport.js +5 -2
  20. package/esm/utils/releaseInfo.js +1 -1
  21. package/hooks/features/cellSelection/useGridCellSelection.js +6 -3
  22. package/hooks/features/export/serializer/excelSerializer.d.ts +3 -8
  23. package/hooks/features/export/serializer/excelSerializer.js +14 -4
  24. package/hooks/features/export/useGridExcelExport.js +5 -2
  25. package/index.js +1 -1
  26. package/modern/DataGridPremium/DataGridPremium.js +8 -3
  27. package/modern/components/GridColumnMenuAggregationItem.js +1 -1
  28. package/modern/components/GridColumnMenuRowGroupItem.js +2 -12
  29. package/modern/components/GridColumnMenuRowUngroupItem.js +2 -12
  30. package/modern/components/GridExcelExportMenuItem.js +2 -1
  31. package/modern/components/GridPremiumColumnMenu.js +2 -13
  32. package/modern/hooks/features/cellSelection/useGridCellSelection.js +6 -3
  33. package/modern/hooks/features/export/serializer/excelSerializer.js +14 -4
  34. package/modern/hooks/features/export/useGridExcelExport.js +5 -2
  35. package/modern/index.js +1 -1
  36. package/modern/utils/releaseInfo.js +1 -1
  37. package/package.json +5 -5
  38. package/utils/releaseInfo.js +1 -1
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import MenuItem from '@mui/material/MenuItem';
4
3
  import ListItemIcon from '@mui/material/ListItemIcon';
5
4
  import ListItemText from '@mui/material/ListItemText';
@@ -8,7 +7,7 @@ import { useGridApiContext } from '../hooks/utils/useGridApiContext';
8
7
  import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrouping/gridRowGroupingSelector';
9
8
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
10
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- function GridColumnMenuRowUngroupItem(props) {
10
+ export function GridColumnMenuRowUngroupItem(props) {
12
11
  const {
13
12
  colDef,
14
13
  onClick
@@ -51,13 +50,4 @@ function GridColumnMenuRowUngroupItem(props) {
51
50
  children: apiRef.current.getLocaleText('groupColumn')(name)
52
51
  })]
53
52
  });
54
- }
55
- process.env.NODE_ENV !== "production" ? GridColumnMenuRowUngroupItem.propTypes = {
56
- // ----------------------------- Warning --------------------------------
57
- // | These PropTypes are generated from the TypeScript type definitions |
58
- // | To update them edit the TypeScript types and run "yarn proptypes" |
59
- // ----------------------------------------------------------------------
60
- colDef: PropTypes.object.isRequired,
61
- onClick: PropTypes.func.isRequired
62
- } : void 0;
63
- export { GridColumnMenuRowUngroupItem };
53
+ }
@@ -25,13 +25,14 @@ function GridExcelExportMenuItem(props) {
25
25
  process.env.NODE_ENV !== "production" ? GridExcelExportMenuItem.propTypes = {
26
26
  // ----------------------------- Warning --------------------------------
27
27
  // | These PropTypes are generated from the TypeScript type definitions |
28
- // | To update them edit the TypeScript types and run "yarn proptypes" |
28
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
29
29
  // ----------------------------------------------------------------------
30
30
  hideMenu: PropTypes.func,
31
31
  options: PropTypes.shape({
32
32
  allColumns: PropTypes.bool,
33
33
  columnsStyles: PropTypes.object,
34
34
  disableToolbarButton: PropTypes.bool,
35
+ escapeFormulas: PropTypes.bool,
35
36
  exceljsPostProcess: PropTypes.func,
36
37
  exceljsPreProcess: PropTypes.func,
37
38
  fields: PropTypes.arrayOf(PropTypes.string),
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import PropTypes from 'prop-types';
4
3
  import { GridGenericColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } from '@mui/x-data-grid-pro';
5
4
  import { GridColumnMenuAggregationItem } from './GridColumnMenuAggregationItem';
6
5
  import { isGroupingColumn } from '../hooks/features/rowGrouping';
@@ -28,21 +27,11 @@ export const GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM = _extends({}, GRID_COLUMN_MENU
28
27
  displayOrder: 27
29
28
  }
30
29
  });
31
- const GridPremiumColumnMenu = /*#__PURE__*/React.forwardRef(function GridPremiumColumnMenuSimple(props, ref) {
30
+ export const GridPremiumColumnMenu = /*#__PURE__*/React.forwardRef(function GridPremiumColumnMenuSimple(props, ref) {
32
31
  return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({
33
32
  ref: ref
34
33
  }, props, {
35
34
  defaultSlots: GRID_COLUMN_MENU_SLOTS_PREMIUM,
36
35
  defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM
37
36
  }));
38
- });
39
- process.env.NODE_ENV !== "production" ? GridPremiumColumnMenu.propTypes = {
40
- // ----------------------------- Warning --------------------------------
41
- // | These PropTypes are generated from the TypeScript type definitions |
42
- // | To update them edit the TypeScript types and run "yarn proptypes" |
43
- // ----------------------------------------------------------------------
44
- colDef: PropTypes.object.isRequired,
45
- hideMenu: PropTypes.func.isRequired,
46
- open: PropTypes.bool.isRequired
47
- } : void 0;
48
- export { GridPremiumColumnMenu };
37
+ });
@@ -445,9 +445,12 @@ export const useGridCellSelection = (apiRef, props) => {
445
445
  if (fieldsMap[field]) {
446
446
  const cellParams = apiRef.current.getCellParams(rowId, field);
447
447
  cellData = serializeCellValue(cellParams, {
448
- delimiterCharacter: clipboardCopyCellDelimiter,
449
- ignoreValueFormatter,
450
- shouldAppendQuotes: false
448
+ csvOptions: {
449
+ delimiter: clipboardCopyCellDelimiter,
450
+ shouldAppendQuotes: false,
451
+ escapeFormulas: false
452
+ },
453
+ ignoreValueFormatter
451
454
  });
452
455
  } else {
453
456
  cellData = '';
@@ -23,7 +23,7 @@ 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) => {
26
+ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) => {
27
27
  const row = {};
28
28
  const dataValidation = {};
29
29
  const mergedCells = [];
@@ -49,6 +49,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
49
49
  });
50
50
  }
51
51
  const cellParams = api.getCellParams(id, column.field);
52
+ let cellValue;
52
53
  switch (cellParams.colDef.type) {
53
54
  case 'singleSelect':
54
55
  {
@@ -92,7 +93,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
92
93
  }
93
94
  case 'boolean':
94
95
  case 'number':
95
- row[column.field] = api.getCellParams(id, column.field).value;
96
+ cellValue = api.getCellParams(id, column.field).value;
96
97
  break;
97
98
  case 'date':
98
99
  case 'dateTime':
@@ -112,7 +113,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
112
113
  case 'actions':
113
114
  break;
114
115
  default:
115
- row[column.field] = api.getCellParams(id, column.field).formattedValue;
116
+ cellValue = api.getCellParams(id, column.field).formattedValue;
116
117
  if (process.env.NODE_ENV !== 'production') {
117
118
  if (String(cellParams.formattedValue) === '[object Object]') {
118
119
  warnInvalidFormattedValue();
@@ -120,6 +121,15 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
120
121
  }
121
122
  break;
122
123
  }
124
+ if (typeof cellValue === 'string' && options.escapeFormulas) {
125
+ // See https://owasp.org/www-community/attacks/CSV_Injection
126
+ if (['=', '+', '-', '@', '\t', '\r'].includes(cellValue[0])) {
127
+ cellValue = `'${cellValue}`;
128
+ }
129
+ }
130
+ if (typeof cellValue !== 'undefined') {
131
+ row[column.field] = cellValue;
132
+ }
123
133
  });
124
134
  return {
125
135
  row,
@@ -301,7 +311,7 @@ export async function buildExcel(options, api) {
301
311
  const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, api);
302
312
  createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
303
313
  rowIds.forEach(id => {
304
- const serializedRow = serializeRow(id, columns, api, valueOptionsData);
314
+ const serializedRow = serializeRow(id, columns, api, valueOptionsData, options);
305
315
  addSerializedRowToWorksheet(serializedRow, worksheet);
306
316
  });
307
317
  if (exceljsPostProcess) {
@@ -34,7 +34,8 @@ export const useGridExcelExport = (apiRef, props) => {
34
34
  valueOptionsSheetName: options?.valueOptionsSheetName || 'Options',
35
35
  columnsStyles: options?.columnsStyles,
36
36
  exceljsPreProcess: options?.exceljsPreProcess,
37
- exceljsPostProcess: options?.exceljsPostProcess
37
+ exceljsPostProcess: options?.exceljsPostProcess,
38
+ escapeFormulas: options.escapeFormulas ?? true
38
39
  }, apiRef.current);
39
40
  }, [logger, apiRef]);
40
41
  const exportDataAsExcel = React.useCallback(async (options = {}) => {
@@ -87,7 +88,9 @@ export const useGridExcelExport = (apiRef, props) => {
87
88
  });
88
89
  const valueOptionsData = await getDataForValueOptionsSheet(exportedColumns, valueOptionsSheetName, apiRef.current);
89
90
  const serializedColumns = serializeColumns(exportedColumns, options.columnsStyles || {});
90
- const serializedRows = exportedRowIds.map(id => serializeRow(id, exportedColumns, apiRef.current, valueOptionsData));
91
+ const serializedRows = exportedRowIds.map(id => serializeRow(id, exportedColumns, apiRef.current, valueOptionsData, {
92
+ escapeFormulas: options.escapeFormulas ?? true
93
+ }));
91
94
  const columnGroupPaths = exportedColumns.reduce((acc, column) => {
92
95
  acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
93
96
  return acc;
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v7.4.0
2
+ * @mui/x-data-grid-premium v7.5.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 = "MTcxNTMxMzYwMDAwMA==";
3
+ const releaseInfo = "MTcxNjQxNTIwMDAwMA==";
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.4.0",
3
+ "version": "7.5.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,7 +33,7 @@
33
33
  "directory": "packages/x-data-grid-premium"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/runtime": "^7.24.0",
36
+ "@babel/runtime": "^7.24.5",
37
37
  "@mui/system": "^5.15.14",
38
38
  "@mui/utils": "^5.15.14",
39
39
  "@types/format-util": "^1.0.4",
@@ -41,9 +41,9 @@
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.4.0",
45
- "@mui/x-data-grid-pro": "7.4.0",
46
- "@mui/x-license": "7.2.0"
44
+ "@mui/x-data-grid": "7.5.1",
45
+ "@mui/x-data-grid-pro": "7.5.1",
46
+ "@mui/x-license": "7.2.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 = "MTcxNTMxMzYwMDAwMA==";
9
+ const releaseInfo = "MTcxNjQxNTIwMDAwMA==";
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