@mui/x-data-grid 6.3.1 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/DataGrid/DataGrid.js +20 -1
  3. package/DataGrid/useDataGridComponent.js +2 -2
  4. package/DataGrid/useDataGridProps.js +3 -1
  5. package/colDef/gridBooleanColDef.js +19 -1
  6. package/colDef/gridDateColDef.js +6 -2
  7. package/colDef/gridSingleSelectColDef.js +21 -1
  8. package/components/base/GridBody.js +2 -1
  9. package/components/containers/GridRootStyles.js +1 -0
  10. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  11. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  12. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
  13. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
  14. package/hooks/features/clipboard/useGridClipboard.js +43 -26
  15. package/hooks/features/dimensions/useGridDimensions.js +2 -4
  16. package/hooks/features/editing/useGridCellEditing.js +7 -3
  17. package/hooks/features/editing/useGridRowEditing.js +7 -3
  18. package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
  19. package/hooks/features/export/serializers/csvSerializer.js +46 -6
  20. package/hooks/features/export/useGridCsvExport.d.ts +2 -1
  21. package/hooks/features/export/useGridCsvExport.js +7 -5
  22. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  23. package/index.js +1 -1
  24. package/internals/index.d.ts +3 -2
  25. package/internals/index.js +3 -2
  26. package/joy/icons.d.ts +33 -0
  27. package/joy/icons.js +433 -0
  28. package/joy/joySlots.js +114 -4
  29. package/legacy/DataGrid/DataGrid.js +20 -1
  30. package/legacy/DataGrid/useDataGridComponent.js +2 -2
  31. package/legacy/DataGrid/useDataGridProps.js +3 -1
  32. package/legacy/colDef/gridBooleanColDef.js +21 -1
  33. package/legacy/colDef/gridDateColDef.js +10 -2
  34. package/legacy/colDef/gridSingleSelectColDef.js +21 -1
  35. package/legacy/components/base/GridBody.js +2 -1
  36. package/legacy/components/containers/GridRootStyles.js +1 -0
  37. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  38. package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  39. package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
  40. package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -4
  41. package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
  42. package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
  43. package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
  44. package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
  45. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -0
  46. package/legacy/index.js +1 -1
  47. package/legacy/internals/index.js +3 -2
  48. package/legacy/joy/icons.js +432 -0
  49. package/legacy/joy/joySlots.js +118 -4
  50. package/legacy/locales/deDE.js +2 -2
  51. package/legacy/locales/frFR.js +6 -6
  52. package/legacy/locales/ptBR.js +1 -1
  53. package/legacy/locales/ukUA.js +8 -9
  54. package/legacy/material/index.js +3 -1
  55. package/legacy/models/api/index.js +0 -1
  56. package/legacy/utils/domUtils.js +14 -1
  57. package/locales/deDE.js +2 -2
  58. package/locales/frFR.js +6 -6
  59. package/locales/ptBR.js +1 -1
  60. package/locales/ukUA.js +8 -9
  61. package/material/index.d.ts +1 -0
  62. package/material/index.js +3 -1
  63. package/models/api/gridApiCommon.d.ts +1 -2
  64. package/models/api/gridCoreApi.d.ts +4 -0
  65. package/models/api/index.d.ts +0 -1
  66. package/models/api/index.js +0 -1
  67. package/models/events/gridEventLookup.d.ts +6 -0
  68. package/models/gridSlotsComponent.d.ts +5 -0
  69. package/models/gridSlotsComponentsProps.d.ts +4 -0
  70. package/models/props/DataGridProps.d.ts +19 -0
  71. package/modern/DataGrid/DataGrid.js +20 -1
  72. package/modern/DataGrid/useDataGridComponent.js +2 -2
  73. package/modern/DataGrid/useDataGridProps.js +3 -1
  74. package/modern/colDef/gridBooleanColDef.js +19 -1
  75. package/modern/colDef/gridDateColDef.js +6 -2
  76. package/modern/colDef/gridSingleSelectColDef.js +21 -1
  77. package/modern/components/base/GridBody.js +2 -1
  78. package/modern/components/containers/GridRootStyles.js +1 -0
  79. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  80. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  81. package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
  82. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
  83. package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
  84. package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
  85. package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
  86. package/modern/hooks/features/export/useGridCsvExport.js +7 -5
  87. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  88. package/modern/index.js +1 -1
  89. package/modern/internals/index.js +3 -2
  90. package/modern/joy/icons.js +433 -0
  91. package/modern/joy/joySlots.js +110 -4
  92. package/modern/locales/deDE.js +2 -2
  93. package/modern/locales/frFR.js +6 -6
  94. package/modern/locales/ptBR.js +1 -1
  95. package/modern/locales/ukUA.js +8 -9
  96. package/modern/material/index.js +3 -1
  97. package/modern/models/api/index.js +0 -1
  98. package/modern/utils/domUtils.js +13 -1
  99. package/node/DataGrid/DataGrid.js +20 -1
  100. package/node/DataGrid/useDataGridComponent.js +2 -2
  101. package/node/DataGrid/useDataGridProps.js +3 -1
  102. package/node/colDef/gridBooleanColDef.js +19 -1
  103. package/node/colDef/gridDateColDef.js +6 -2
  104. package/node/colDef/gridSingleSelectColDef.js +21 -1
  105. package/node/components/base/GridBody.js +2 -1
  106. package/node/components/containers/GridRootStyles.js +1 -0
  107. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  108. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  109. package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
  110. package/node/hooks/features/dimensions/useGridDimensions.js +1 -3
  111. package/node/hooks/features/editing/useGridCellEditing.js +7 -3
  112. package/node/hooks/features/editing/useGridRowEditing.js +7 -3
  113. package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
  114. package/node/hooks/features/export/useGridCsvExport.js +6 -3
  115. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  116. package/node/index.js +1 -1
  117. package/node/internals/index.js +23 -1
  118. package/node/joy/icons.js +471 -0
  119. package/node/joy/joySlots.js +110 -3
  120. package/node/locales/deDE.js +2 -2
  121. package/node/locales/frFR.js +6 -6
  122. package/node/locales/ptBR.js +1 -1
  123. package/node/locales/ukUA.js +8 -9
  124. package/node/material/index.js +3 -1
  125. package/node/models/api/index.js +0 -11
  126. package/node/utils/domUtils.js +15 -1
  127. package/package.json +1 -1
  128. package/utils/domUtils.d.ts +1 -0
  129. package/utils/domUtils.js +13 -1
  130. package/legacy/models/api/gridClipboardApi.js +0 -1
  131. package/models/api/gridClipboardApi.d.ts +0 -11
  132. package/models/api/gridClipboardApi.js +0 -1
  133. package/modern/models/api/gridClipboardApi.js +0 -1
  134. package/node/models/api/gridClipboardApi.js +0 -5
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.buildCSV = buildCSV;
7
+ exports.serializeCellValue = void 0;
7
8
  var _colDef = require("../../../../colDef");
8
9
  var _warning = require("../../../../utils/warning");
9
- const serializeCellValue = (value, delimiterCharacter) => {
10
+ function sanitizeCellValue(value, delimiterCharacter) {
10
11
  if (typeof value === 'string') {
11
12
  const formattedValue = value.replace(/"/g, '""');
12
13
 
@@ -17,16 +18,48 @@ const serializeCellValue = (value, delimiterCharacter) => {
17
18
  return formattedValue;
18
19
  }
19
20
  return value;
21
+ }
22
+ const serializeCellValue = (cellParams, options) => {
23
+ const {
24
+ delimiterCharacter,
25
+ ignoreValueFormatter
26
+ } = options;
27
+ let value;
28
+ if (ignoreValueFormatter) {
29
+ const columnType = cellParams.colDef.type;
30
+ if (columnType === 'number') {
31
+ value = String(cellParams.value);
32
+ } else if (columnType === 'date' || columnType === 'dateTime') {
33
+ value = cellParams.value?.toISOString();
34
+ } else if (typeof cellParams.value?.toString === 'function') {
35
+ value = cellParams.value.toString();
36
+ } else {
37
+ value = cellParams.value;
38
+ }
39
+ } else {
40
+ value = cellParams.formattedValue;
41
+ }
42
+ return sanitizeCellValue(value, delimiterCharacter);
20
43
  };
44
+ exports.serializeCellValue = serializeCellValue;
21
45
  const objectFormattedValueWarning = (0, _warning.buildWarning)(['MUI: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
22
- const serializeRow = (id, columns, getCellParams, delimiterCharacter) => columns.map(column => {
46
+ const serializeRow = ({
47
+ id,
48
+ columns,
49
+ getCellParams,
50
+ delimiterCharacter,
51
+ ignoreValueFormatter
52
+ }) => columns.map(column => {
23
53
  const cellParams = getCellParams(id, column.field);
24
54
  if (process.env.NODE_ENV !== 'production') {
25
55
  if (String(cellParams.formattedValue) === '[object Object]') {
26
56
  objectFormattedValueWarning();
27
57
  }
28
58
  }
29
- return serializeCellValue(cellParams.formattedValue, delimiterCharacter);
59
+ return serializeCellValue(cellParams, {
60
+ delimiterCharacter,
61
+ ignoreValueFormatter
62
+ });
30
63
  });
31
64
  function buildCSV(options) {
32
65
  const {
@@ -34,12 +67,19 @@ function buildCSV(options) {
34
67
  rowIds,
35
68
  getCellParams,
36
69
  delimiterCharacter,
37
- includeHeaders
70
+ includeHeaders,
71
+ ignoreValueFormatter
38
72
  } = options;
39
- const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow(id, columns, getCellParams, delimiterCharacter).join(delimiterCharacter)}\r\n`, '').trim();
73
+ const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
74
+ id,
75
+ columns,
76
+ getCellParams,
77
+ delimiterCharacter,
78
+ ignoreValueFormatter
79
+ }).join(delimiterCharacter)}\r\n`, '').trim();
40
80
  if (!includeHeaders) {
41
81
  return CSVBody;
42
82
  }
43
- const CSVHead = `${columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => serializeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
83
+ const CSVHead = `${columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => sanitizeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
44
84
  return `${CSVHead}${CSVBody}`.trim();
45
85
  }
@@ -22,8 +22,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
22
22
  * @requires useGridSelection (state)
23
23
  * @requires useGridParamsApi (method)
24
24
  */
25
- const useGridCsvExport = apiRef => {
25
+ const useGridCsvExport = (apiRef, props) => {
26
26
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridCsvExport');
27
+ const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
28
+ const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.csvExport : ignoreValueFormatterProp) || false;
27
29
  const getDataAsCsv = React.useCallback((options = {}) => {
28
30
  logger.debug(`Get data as CSV`);
29
31
  const exportedColumns = (0, _utils.getColumnsToExport)({
@@ -39,9 +41,10 @@ const useGridCsvExport = apiRef => {
39
41
  rowIds: exportedRowIds,
40
42
  getCellParams: apiRef.current.getCellParams,
41
43
  delimiterCharacter: options.delimiter || ',',
42
- includeHeaders: options.includeHeaders ?? true
44
+ includeHeaders: options.includeHeaders ?? true,
45
+ ignoreValueFormatter
43
46
  });
44
- }, [logger, apiRef]);
47
+ }, [logger, apiRef, ignoreValueFormatter]);
45
48
  const exportDataAsCsv = React.useCallback(options => {
46
49
  logger.debug(`Export data as CSV`);
47
50
  const csv = getDataAsCsv(options);
@@ -20,6 +20,7 @@ var _gridRowsSelector = require("../rows/gridRowsSelector");
20
20
  var _focus = require("../focus");
21
21
  var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
22
22
  var _useGridSelector = require("../../utils/useGridSelector");
23
+ var _pipeProcessing = require("../../core/pipeProcessing");
23
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
26
  function enrichPageRowsWithPinnedRows(apiRef, rows) {
@@ -458,6 +459,16 @@ const useGridKeyboardNavigation = (apiRef, props) => {
458
459
  event.preventDefault();
459
460
  }
460
461
  }, [apiRef, currentPageRows, theme.direction, getRowIdFromIndex, goToCell, goToHeader]);
462
+ const checkIfCanStartEditing = React.useCallback((initialValue, {
463
+ event
464
+ }) => {
465
+ if (event.key === ' ') {
466
+ // Space scrolls to the last row
467
+ return false;
468
+ }
469
+ return initialValue;
470
+ }, []);
471
+ (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'canStartEditing', checkIfCanStartEditing);
461
472
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
462
473
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
463
474
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.3.1
2
+ * @mui/x-data-grid v6.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -65,12 +65,14 @@ var _exportNames = {
65
65
  useGridVirtualScroller: true,
66
66
  getRenderableIndexes: true,
67
67
  useGridVisibleRows: true,
68
+ getVisibleRows: true,
68
69
  useGridInitializeState: true,
69
70
  getColumnsToExport: true,
70
71
  defaultGetRowsToExport: true,
71
72
  createSelector: true,
72
73
  unstable_resetCreateSelectorCache: true,
73
74
  findParentElementFromClassName: true,
75
+ getActiveElement: true,
74
76
  isNavigationKey: true,
75
77
  clamp: true,
76
78
  isDeepEqual: true,
@@ -79,7 +81,8 @@ var _exportNames = {
79
81
  isObject: true,
80
82
  buildWarning: true,
81
83
  exportAs: true,
82
- useGridPrivateApiContext: true
84
+ useGridPrivateApiContext: true,
85
+ serializeCellValue: true
83
86
  };
84
87
  Object.defineProperty(exports, "DATA_GRID_DEFAULT_SLOTS_COMPONENTS", {
85
88
  enumerable: true,
@@ -213,6 +216,12 @@ Object.defineProperty(exports, "focusStateInitializer", {
213
216
  return _useGridFocus.focusStateInitializer;
214
217
  }
215
218
  });
219
+ Object.defineProperty(exports, "getActiveElement", {
220
+ enumerable: true,
221
+ get: function () {
222
+ return _domUtils.getActiveElement;
223
+ }
224
+ });
216
225
  Object.defineProperty(exports, "getColumnsToExport", {
217
226
  enumerable: true,
218
227
  get: function () {
@@ -237,6 +246,12 @@ Object.defineProperty(exports, "getTreeNodeDescendants", {
237
246
  return _gridRowsUtils.getTreeNodeDescendants;
238
247
  }
239
248
  });
249
+ Object.defineProperty(exports, "getVisibleRows", {
250
+ enumerable: true,
251
+ get: function () {
252
+ return _useGridVisibleRows.getVisibleRows;
253
+ }
254
+ });
240
255
  Object.defineProperty(exports, "gridAdditionalRowGroupsSelector", {
241
256
  enumerable: true,
242
257
  get: function () {
@@ -327,6 +342,12 @@ Object.defineProperty(exports, "rowsStateInitializer", {
327
342
  return _useGridRows.rowsStateInitializer;
328
343
  }
329
344
  });
345
+ Object.defineProperty(exports, "serializeCellValue", {
346
+ enumerable: true,
347
+ get: function () {
348
+ return _csvSerializer.serializeCellValue;
349
+ }
350
+ });
330
351
  Object.defineProperty(exports, "sortingStateInitializer", {
331
352
  enumerable: true,
332
353
  get: function () {
@@ -588,6 +609,7 @@ var _utils2 = require("../utils/utils");
588
609
  var _warning = require("../utils/warning");
589
610
  var _exportAs = require("../utils/exportAs");
590
611
  var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
612
+ var _csvSerializer = require("../hooks/features/export/serializers/csvSerializer");
591
613
  var _utils3 = require("./utils");
592
614
  Object.keys(_utils3).forEach(function (key) {
593
615
  if (key === "default" || key === "__esModule") return;