@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
@@ -19,12 +19,17 @@ var _jsxRuntime = require("react/jsx-runtime");
19
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
21
  const releaseInfo = (0, _releaseInfo.getReleaseInfo)();
22
- const dataGridPremiumPropValidators = [..._internals.propValidatorsDataGrid, ..._internals.propValidatorsDataGridPro];
22
+ let dataGridPremiumPropValidators;
23
+ if (process.env.NODE_ENV !== 'production') {
24
+ dataGridPremiumPropValidators = [..._internals.propValidatorsDataGrid, ..._internals.propValidatorsDataGridPro];
25
+ }
23
26
  const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremium(inProps, ref) {
24
27
  const props = (0, _useDataGridPremiumProps.useDataGridPremiumProps)(inProps);
25
28
  const privateApiRef = (0, _useDataGridPremiumComponent.useDataGridPremiumComponent)(props.apiRef, props);
26
29
  (0, _xLicense.useLicenseVerifier)('x-data-grid-premium', releaseInfo);
27
- (0, _internals.validateProps)(props, dataGridPremiumPropValidators);
30
+ if (process.env.NODE_ENV !== 'production') {
31
+ (0, _internals.validateProps)(props, dataGridPremiumPropValidators);
32
+ }
28
33
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGridPro.GridContextProvider, {
29
34
  privateApiRef: privateApiRef,
30
35
  props: props,
@@ -54,7 +59,7 @@ const DataGridPremium = exports.DataGridPremium = /*#__PURE__*/React.memo(DataGr
54
59
  process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
55
60
  // ----------------------------- Warning --------------------------------
56
61
  // | These PropTypes are generated from the TypeScript type definitions |
57
- // | To update them edit the TypeScript types and run "yarn proptypes" |
62
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
58
63
  // ----------------------------------------------------------------------
59
64
  /**
60
65
  * Aggregation functions available on the grid.
@@ -109,7 +109,7 @@ function GridColumnMenuAggregationItem(props) {
109
109
  process.env.NODE_ENV !== "production" ? GridColumnMenuAggregationItem.propTypes = {
110
110
  // ----------------------------- Warning --------------------------------
111
111
  // | These PropTypes are generated from the TypeScript type definitions |
112
- // | To update them edit the TypeScript types and run "yarn proptypes" |
112
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
113
113
  // ----------------------------------------------------------------------
114
114
  colDef: _propTypes.default.object.isRequired,
115
115
  onClick: _propTypes.default.func.isRequired
@@ -1,7 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { GridColumnMenuItemProps } from '@mui/x-data-grid-pro';
3
- declare function GridColumnMenuRowGroupItem(props: GridColumnMenuItemProps): React.JSX.Element | null;
4
- declare namespace GridColumnMenuRowGroupItem {
5
- var propTypes: any;
6
- }
7
- export { GridColumnMenuRowGroupItem };
3
+ export declare function GridColumnMenuRowGroupItem(props: GridColumnMenuItemProps): React.JSX.Element | null;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.GridColumnMenuRowGroupItem = GridColumnMenuRowGroupItem;
8
8
  var React = _interopRequireWildcard(require("react"));
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
9
  var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
11
10
  var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon"));
12
11
  var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
@@ -55,12 +54,4 @@ function GridColumnMenuRowGroupItem(props) {
55
54
  });
56
55
  }
57
56
  return renderUnGroupingMenuItem((0, _gridRowGroupingUtils.getRowGroupingCriteriaFromGroupingField)(colDef.field));
58
- }
59
- process.env.NODE_ENV !== "production" ? GridColumnMenuRowGroupItem.propTypes = {
60
- // ----------------------------- Warning --------------------------------
61
- // | These PropTypes are generated from the TypeScript type definitions |
62
- // | To update them edit the TypeScript types and run "yarn proptypes" |
63
- // ----------------------------------------------------------------------
64
- colDef: _propTypes.default.object.isRequired,
65
- onClick: _propTypes.default.func.isRequired
66
- } : void 0;
57
+ }
@@ -1,7 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { GridColumnMenuItemProps } from '@mui/x-data-grid-pro';
3
- declare function GridColumnMenuRowUngroupItem(props: GridColumnMenuItemProps): React.JSX.Element | null;
4
- declare namespace GridColumnMenuRowUngroupItem {
5
- var propTypes: any;
6
- }
7
- export { GridColumnMenuRowUngroupItem };
3
+ export declare function GridColumnMenuRowUngroupItem(props: GridColumnMenuItemProps): React.JSX.Element | null;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.GridColumnMenuRowUngroupItem = GridColumnMenuRowUngroupItem;
8
8
  var React = _interopRequireWildcard(require("react"));
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
9
  var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
11
10
  var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon"));
12
11
  var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
@@ -60,12 +59,4 @@ function GridColumnMenuRowUngroupItem(props) {
60
59
  children: apiRef.current.getLocaleText('groupColumn')(name)
61
60
  })]
62
61
  });
63
- }
64
- process.env.NODE_ENV !== "production" ? GridColumnMenuRowUngroupItem.propTypes = {
65
- // ----------------------------- Warning --------------------------------
66
- // | These PropTypes are generated from the TypeScript type definitions |
67
- // | To update them edit the TypeScript types and run "yarn proptypes" |
68
- // ----------------------------------------------------------------------
69
- colDef: _propTypes.default.object.isRequired,
70
- onClick: _propTypes.default.func.isRequired
71
- } : void 0;
62
+ }
@@ -34,13 +34,14 @@ function GridExcelExportMenuItem(props) {
34
34
  process.env.NODE_ENV !== "production" ? GridExcelExportMenuItem.propTypes = {
35
35
  // ----------------------------- Warning --------------------------------
36
36
  // | These PropTypes are generated from the TypeScript type definitions |
37
- // | To update them edit the TypeScript types and run "yarn proptypes" |
37
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
38
38
  // ----------------------------------------------------------------------
39
39
  hideMenu: _propTypes.default.func,
40
40
  options: _propTypes.default.shape({
41
41
  allColumns: _propTypes.default.bool,
42
42
  columnsStyles: _propTypes.default.object,
43
43
  disableToolbarButton: _propTypes.default.bool,
44
+ escapeFormulas: _propTypes.default.bool,
44
45
  exceljsPostProcess: _propTypes.default.func,
45
46
  exceljsPreProcess: _propTypes.default.func,
46
47
  fields: _propTypes.default.arrayOf(_propTypes.default.string),
@@ -30,5 +30,4 @@ export declare const GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM: {
30
30
  displayOrder: number;
31
31
  };
32
32
  };
33
- declare const GridPremiumColumnMenu: React.ForwardRefExoticComponent<GridColumnMenuProps & React.RefAttributes<HTMLUListElement>>;
34
- export { GridPremiumColumnMenu };
33
+ export declare const GridPremiumColumnMenu: React.ForwardRefExoticComponent<GridColumnMenuProps & React.RefAttributes<HTMLUListElement>>;
@@ -9,7 +9,6 @@ exports.GridColumnMenuGroupingItem = GridColumnMenuGroupingItem;
9
9
  exports.GridPremiumColumnMenu = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
12
  var _xDataGridPro = require("@mui/x-data-grid-pro");
14
13
  var _GridColumnMenuAggregationItem = require("./GridColumnMenuAggregationItem");
15
14
  var _rowGrouping = require("../hooks/features/rowGrouping");
@@ -46,13 +45,4 @@ const GridPremiumColumnMenu = exports.GridPremiumColumnMenu = /*#__PURE__*/React
46
45
  defaultSlots: GRID_COLUMN_MENU_SLOTS_PREMIUM,
47
46
  defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM
48
47
  }));
49
- });
50
- process.env.NODE_ENV !== "production" ? GridPremiumColumnMenu.propTypes = {
51
- // ----------------------------- Warning --------------------------------
52
- // | These PropTypes are generated from the TypeScript type definitions |
53
- // | To update them edit the TypeScript types and run "yarn proptypes" |
54
- // ----------------------------------------------------------------------
55
- colDef: _propTypes.default.object.isRequired,
56
- hideMenu: _propTypes.default.func.isRequired,
57
- open: _propTypes.default.bool.isRequired
58
- } : void 0;
48
+ });
@@ -11,12 +11,17 @@ import { useDataGridPremiumProps } from './useDataGridPremiumProps';
11
11
  import { getReleaseInfo } from '../utils/releaseInfo';
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  const releaseInfo = getReleaseInfo();
14
- const dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
14
+ let dataGridPremiumPropValidators;
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
17
+ }
15
18
  const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremium(inProps, ref) {
16
19
  const props = useDataGridPremiumProps(inProps);
17
20
  const privateApiRef = useDataGridPremiumComponent(props.apiRef, props);
18
21
  useLicenseVerifier('x-data-grid-premium', releaseInfo);
19
- validateProps(props, dataGridPremiumPropValidators);
22
+ if (process.env.NODE_ENV !== 'production') {
23
+ validateProps(props, dataGridPremiumPropValidators);
24
+ }
20
25
  return /*#__PURE__*/_jsx(GridContextProvider, {
21
26
  privateApiRef: privateApiRef,
22
27
  props: props,
@@ -46,7 +51,7 @@ export const DataGridPremium = /*#__PURE__*/React.memo(DataGridPremiumRaw);
46
51
  process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
47
52
  // ----------------------------- Warning --------------------------------
48
53
  // | These PropTypes are generated from the TypeScript type definitions |
49
- // | To update them edit the TypeScript types and run "yarn proptypes" |
54
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
50
55
  // ----------------------------------------------------------------------
51
56
  /**
52
57
  * Aggregation functions available on the grid.
@@ -100,7 +100,7 @@ function GridColumnMenuAggregationItem(props) {
100
100
  process.env.NODE_ENV !== "production" ? GridColumnMenuAggregationItem.propTypes = {
101
101
  // ----------------------------- Warning --------------------------------
102
102
  // | These PropTypes are generated from the TypeScript type definitions |
103
- // | To update them edit the TypeScript types and run "yarn proptypes" |
103
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
104
104
  // ----------------------------------------------------------------------
105
105
  colDef: PropTypes.object.isRequired,
106
106
  onClick: PropTypes.func.isRequired
@@ -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';
@@ -9,7 +8,7 @@ import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrou
9
8
  import { getRowGroupingCriteriaFromGroupingField, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, isGroupingColumn } from '../hooks/features/rowGrouping/gridRowGroupingUtils';
10
9
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
11
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
- function GridColumnMenuRowGroupItem(props) {
11
+ export function GridColumnMenuRowGroupItem(props) {
13
12
  const {
14
13
  colDef,
15
14
  onClick
@@ -46,13 +45,4 @@ function GridColumnMenuRowGroupItem(props) {
46
45
  });
47
46
  }
48
47
  return renderUnGroupingMenuItem(getRowGroupingCriteriaFromGroupingField(colDef.field));
49
- }
50
- process.env.NODE_ENV !== "production" ? GridColumnMenuRowGroupItem.propTypes = {
51
- // ----------------------------- Warning --------------------------------
52
- // | These PropTypes are generated from the TypeScript type definitions |
53
- // | To update them edit the TypeScript types and run "yarn proptypes" |
54
- // ----------------------------------------------------------------------
55
- colDef: PropTypes.object.isRequired,
56
- onClick: PropTypes.func.isRequired
57
- } : void 0;
58
- export { GridColumnMenuRowGroupItem };
48
+ }
@@ -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;
@@ -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
@@ -455,9 +455,12 @@ const useGridCellSelection = (apiRef, props) => {
455
455
  if (fieldsMap[field]) {
456
456
  const cellParams = apiRef.current.getCellParams(rowId, field);
457
457
  cellData = (0, _internals.serializeCellValue)(cellParams, {
458
- delimiterCharacter: clipboardCopyCellDelimiter,
459
- ignoreValueFormatter,
460
- shouldAppendQuotes: false
458
+ csvOptions: {
459
+ delimiter: clipboardCopyCellDelimiter,
460
+ shouldAppendQuotes: false,
461
+ escapeFormulas: false
462
+ },
463
+ ignoreValueFormatter
461
464
  });
462
465
  } else {
463
466
  cellData = '';
@@ -1,7 +1,7 @@
1
1
  import type * as Excel from 'exceljs';
2
2
  import { GridRowId, GridColDef } from '@mui/x-data-grid-pro';
3
3
  import { GridStateColDef, GridColumnGroupLookup } from '@mui/x-data-grid/internals';
4
- import { GridExceljsProcessInput, ColumnsStylesInterface, GridExcelExportOptions } from '../gridExcelExportInterface';
4
+ import { ColumnsStylesInterface, GridExcelExportOptions } from '../gridExcelExportInterface';
5
5
  import { GridPrivateApiPremium } from '../../../../models/gridApiPremium';
6
6
  interface SerializedRow {
7
7
  row: Record<string, undefined | number | boolean | string | Date>;
@@ -16,7 +16,7 @@ export declare const serializeRow: (id: GridRowId, columns: GridStateColDef[], a
16
16
  [field: string]: {
17
17
  address: string;
18
18
  };
19
- }) => SerializedRow;
19
+ }, options: Pick<BuildExcelOptions, 'escapeFormulas'>) => SerializedRow;
20
20
  export declare const serializeColumn: (column: GridColDef, columnsStyles: ColumnsStylesInterface) => {
21
21
  key: string;
22
22
  headerText: string;
@@ -42,14 +42,9 @@ type ValueOptionsData = Record<string, {
42
42
  address: string;
43
43
  }>;
44
44
  export declare function getDataForValueOptionsSheet(columns: GridStateColDef[], valueOptionsSheetName: string, api: GridPrivateApiPremium): Promise<ValueOptionsData>;
45
- interface BuildExcelOptions {
45
+ interface BuildExcelOptions extends Pick<GridExcelExportOptions, 'exceljsPreProcess' | 'exceljsPostProcess'>, Pick<Required<GridExcelExportOptions>, 'valueOptionsSheetName' | 'includeHeaders' | 'includeColumnGroupsHeaders' | 'escapeFormulas'> {
46
46
  columns: GridStateColDef[];
47
47
  rowIds: GridRowId[];
48
- includeHeaders: boolean;
49
- includeColumnGroupsHeaders: boolean;
50
- valueOptionsSheetName: string;
51
- exceljsPreProcess?: (processInput: GridExceljsProcessInput) => Promise<void>;
52
- exceljsPostProcess?: (processInput: GridExceljsProcessInput) => Promise<void>;
53
48
  columnsStyles?: ColumnsStylesInterface;
54
49
  }
55
50
  export declare function buildExcel(options: BuildExcelOptions, api: GridPrivateApiPremium): Promise<Excel.Workbook>;
@@ -37,7 +37,7 @@ 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) => {
40
+ const serializeRow = (id, columns, api, defaultValueOptionsFormulae, options) => {
41
41
  const row = {};
42
42
  const dataValidation = {};
43
43
  const mergedCells = [];
@@ -63,6 +63,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
63
63
  });
64
64
  }
65
65
  const cellParams = api.getCellParams(id, column.field);
66
+ let cellValue;
66
67
  switch (cellParams.colDef.type) {
67
68
  case 'singleSelect':
68
69
  {
@@ -106,7 +107,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
106
107
  }
107
108
  case 'boolean':
108
109
  case 'number':
109
- row[column.field] = api.getCellParams(id, column.field).value;
110
+ cellValue = api.getCellParams(id, column.field).value;
110
111
  break;
111
112
  case 'date':
112
113
  case 'dateTime':
@@ -126,7 +127,7 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
126
127
  case 'actions':
127
128
  break;
128
129
  default:
129
- row[column.field] = api.getCellParams(id, column.field).formattedValue;
130
+ cellValue = api.getCellParams(id, column.field).formattedValue;
130
131
  if (process.env.NODE_ENV !== 'production') {
131
132
  if (String(cellParams.formattedValue) === '[object Object]') {
132
133
  warnInvalidFormattedValue();
@@ -134,6 +135,15 @@ const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
134
135
  }
135
136
  break;
136
137
  }
138
+ if (typeof cellValue === 'string' && options.escapeFormulas) {
139
+ // See https://owasp.org/www-community/attacks/CSV_Injection
140
+ if (['=', '+', '-', '@', '\t', '\r'].includes(cellValue[0])) {
141
+ cellValue = `'${cellValue}`;
142
+ }
143
+ }
144
+ if (typeof cellValue !== 'undefined') {
145
+ row[column.field] = cellValue;
146
+ }
137
147
  });
138
148
  return {
139
149
  row,
@@ -317,7 +327,7 @@ async function buildExcel(options, api) {
317
327
  const valueOptionsData = await getDataForValueOptionsSheet(columns, valueOptionsSheetName, api);
318
328
  createValueOptionsSheetIfNeeded(valueOptionsData, valueOptionsSheetName, workbook);
319
329
  rowIds.forEach(id => {
320
- const serializedRow = serializeRow(id, columns, api, valueOptionsData);
330
+ const serializedRow = serializeRow(id, columns, api, valueOptionsData, options);
321
331
  addSerializedRowToWorksheet(serializedRow, worksheet);
322
332
  });
323
333
  if (exceljsPostProcess) {
@@ -42,7 +42,8 @@ const useGridExcelExport = (apiRef, props) => {
42
42
  valueOptionsSheetName: options?.valueOptionsSheetName || 'Options',
43
43
  columnsStyles: options?.columnsStyles,
44
44
  exceljsPreProcess: options?.exceljsPreProcess,
45
- exceljsPostProcess: options?.exceljsPostProcess
45
+ exceljsPostProcess: options?.exceljsPostProcess,
46
+ escapeFormulas: options.escapeFormulas ?? true
46
47
  }, apiRef.current);
47
48
  }, [logger, apiRef]);
48
49
  const exportDataAsExcel = React.useCallback(async (options = {}) => {
@@ -95,7 +96,9 @@ const useGridExcelExport = (apiRef, props) => {
95
96
  });
96
97
  const valueOptionsData = await (0, _excelSerializer.getDataForValueOptionsSheet)(exportedColumns, valueOptionsSheetName, apiRef.current);
97
98
  const serializedColumns = (0, _excelSerializer.serializeColumns)(exportedColumns, options.columnsStyles || {});
98
- const serializedRows = exportedRowIds.map(id => (0, _excelSerializer.serializeRow)(id, exportedColumns, apiRef.current, valueOptionsData));
99
+ const serializedRows = exportedRowIds.map(id => (0, _excelSerializer.serializeRow)(id, exportedColumns, apiRef.current, valueOptionsData, {
100
+ escapeFormulas: options.escapeFormulas ?? true
101
+ }));
99
102
  const columnGroupPaths = exportedColumns.reduce((acc, column) => {
100
103
  acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
101
104
  return acc;
package/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
@@ -11,12 +11,17 @@ import { useDataGridPremiumProps } from './useDataGridPremiumProps';
11
11
  import { getReleaseInfo } from '../utils/releaseInfo';
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  const releaseInfo = getReleaseInfo();
14
- const dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
14
+ let dataGridPremiumPropValidators;
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
17
+ }
15
18
  const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremium(inProps, ref) {
16
19
  const props = useDataGridPremiumProps(inProps);
17
20
  const privateApiRef = useDataGridPremiumComponent(props.apiRef, props);
18
21
  useLicenseVerifier('x-data-grid-premium', releaseInfo);
19
- validateProps(props, dataGridPremiumPropValidators);
22
+ if (process.env.NODE_ENV !== 'production') {
23
+ validateProps(props, dataGridPremiumPropValidators);
24
+ }
20
25
  return /*#__PURE__*/_jsx(GridContextProvider, {
21
26
  privateApiRef: privateApiRef,
22
27
  props: props,
@@ -46,7 +51,7 @@ export const DataGridPremium = /*#__PURE__*/React.memo(DataGridPremiumRaw);
46
51
  process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
47
52
  // ----------------------------- Warning --------------------------------
48
53
  // | These PropTypes are generated from the TypeScript type definitions |
49
- // | To update them edit the TypeScript types and run "yarn proptypes" |
54
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
50
55
  // ----------------------------------------------------------------------
51
56
  /**
52
57
  * Aggregation functions available on the grid.
@@ -100,7 +100,7 @@ function GridColumnMenuAggregationItem(props) {
100
100
  process.env.NODE_ENV !== "production" ? GridColumnMenuAggregationItem.propTypes = {
101
101
  // ----------------------------- Warning --------------------------------
102
102
  // | These PropTypes are generated from the TypeScript type definitions |
103
- // | To update them edit the TypeScript types and run "yarn proptypes" |
103
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
104
104
  // ----------------------------------------------------------------------
105
105
  colDef: PropTypes.object.isRequired,
106
106
  onClick: PropTypes.func.isRequired
@@ -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';
@@ -9,7 +8,7 @@ import { gridRowGroupingSanitizedModelSelector } from '../hooks/features/rowGrou
9
8
  import { getRowGroupingCriteriaFromGroupingField, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, isGroupingColumn } from '../hooks/features/rowGrouping/gridRowGroupingUtils';
10
9
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
11
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
- function GridColumnMenuRowGroupItem(props) {
11
+ export function GridColumnMenuRowGroupItem(props) {
13
12
  const {
14
13
  colDef,
15
14
  onClick
@@ -46,13 +45,4 @@ function GridColumnMenuRowGroupItem(props) {
46
45
  });
47
46
  }
48
47
  return renderUnGroupingMenuItem(getRowGroupingCriteriaFromGroupingField(colDef.field));
49
- }
50
- process.env.NODE_ENV !== "production" ? GridColumnMenuRowGroupItem.propTypes = {
51
- // ----------------------------- Warning --------------------------------
52
- // | These PropTypes are generated from the TypeScript type definitions |
53
- // | To update them edit the TypeScript types and run "yarn proptypes" |
54
- // ----------------------------------------------------------------------
55
- colDef: PropTypes.object.isRequired,
56
- onClick: PropTypes.func.isRequired
57
- } : void 0;
58
- export { GridColumnMenuRowGroupItem };
48
+ }