@mui/x-data-grid 7.5.0 → 7.6.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 (231) hide show
  1. package/CHANGELOG.md +148 -5418
  2. package/DataGrid/DataGrid.js +2 -2
  3. package/components/GridColumnHeaders.js +1 -1
  4. package/components/GridFooter.js +1 -1
  5. package/components/GridLoadingOverlay.js +1 -1
  6. package/components/GridNoRowsOverlay.js +1 -1
  7. package/components/GridPagination.js +1 -1
  8. package/components/GridRow.js +1 -1
  9. package/components/GridRowCount.js +1 -1
  10. package/components/GridScrollArea.d.ts +2 -5
  11. package/components/GridScrollArea.js +1 -10
  12. package/components/GridSelectedRowCount.js +1 -1
  13. package/components/base/GridOverlays.js +1 -1
  14. package/components/cell/GridActionsCell.js +1 -1
  15. package/components/cell/GridActionsCellItem.js +1 -1
  16. package/components/cell/GridBooleanCell.js +1 -1
  17. package/components/cell/GridCell.js +2 -2
  18. package/components/cell/GridEditBooleanCell.js +1 -1
  19. package/components/cell/GridEditDateCell.js +1 -1
  20. package/components/cell/GridEditInputCell.js +1 -1
  21. package/components/cell/GridEditSingleSelectCell.js +1 -1
  22. package/components/cell/GridSkeletonCell.js +1 -1
  23. package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -1
  24. package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  25. package/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
  26. package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -1
  27. package/components/columnHeaders/GridColumnHeaderTitle.js +1 -1
  28. package/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
  29. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  30. package/components/columnSelection/GridHeaderCheckbox.js +1 -1
  31. package/components/columnsManagement/GridColumnsManagement.js +1 -1
  32. package/components/containers/GridFooterContainer.js +1 -1
  33. package/components/containers/GridOverlay.js +1 -1
  34. package/components/containers/GridRoot.js +1 -1
  35. package/components/containers/GridToolbarContainer.js +1 -1
  36. package/components/menu/GridMenu.js +1 -1
  37. package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  38. package/components/menu/columnMenu/GridColumnMenu.js +1 -1
  39. package/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  40. package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.js +1 -1
  41. package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -1
  42. package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -1
  43. package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -1
  44. package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
  45. package/components/panel/GridColumnsPanel.js +1 -1
  46. package/components/panel/GridPanel.js +1 -1
  47. package/components/panel/GridPanelContent.js +1 -1
  48. package/components/panel/GridPanelFooter.js +1 -1
  49. package/components/panel/GridPanelHeader.js +1 -1
  50. package/components/panel/GridPanelWrapper.js +1 -1
  51. package/components/panel/filterPanel/GridFilterForm.js +1 -1
  52. package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  53. package/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  54. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  55. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  56. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  57. package/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  58. package/components/panel/filterPanel/GridFilterPanel.js +1 -1
  59. package/components/toolbar/GridToolbar.js +1 -1
  60. package/components/toolbar/GridToolbarColumnsButton.js +1 -1
  61. package/components/toolbar/GridToolbarDensitySelector.js +1 -1
  62. package/components/toolbar/GridToolbarExport.js +1 -1
  63. package/components/toolbar/GridToolbarExportContainer.js +1 -1
  64. package/components/toolbar/GridToolbarFilterButton.js +1 -1
  65. package/components/toolbar/GridToolbarQuickFilter.js +1 -1
  66. package/hooks/features/clipboard/useGridClipboard.js +8 -5
  67. package/hooks/features/columnResize/useGridColumnResize.js +5 -26
  68. package/hooks/features/columns/gridColumnsUtils.js +18 -13
  69. package/hooks/features/columns/useGridColumnSpanning.js +5 -5
  70. package/hooks/features/export/serializers/csvSerializer.d.ts +3 -6
  71. package/hooks/features/export/serializers/csvSerializer.js +28 -32
  72. package/hooks/features/export/useGridCsvExport.js +8 -5
  73. package/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
  74. package/index.d.ts +1 -0
  75. package/index.js +1 -2
  76. package/locales/faIR.js +4 -4
  77. package/locales/fiFI.js +4 -5
  78. package/models/api/gridColumnSpanning.d.ts +2 -0
  79. package/models/gridExport.d.ts +7 -0
  80. package/models/gridSlotsComponent.d.ts +1 -1
  81. package/models/props/DataGridProps.d.ts +1 -1
  82. package/modern/DataGrid/DataGrid.js +2 -2
  83. package/modern/components/GridColumnHeaders.js +1 -1
  84. package/modern/components/GridFooter.js +1 -1
  85. package/modern/components/GridLoadingOverlay.js +1 -1
  86. package/modern/components/GridNoRowsOverlay.js +1 -1
  87. package/modern/components/GridPagination.js +1 -1
  88. package/modern/components/GridRow.js +1 -1
  89. package/modern/components/GridRowCount.js +1 -1
  90. package/modern/components/GridScrollArea.js +1 -10
  91. package/modern/components/GridSelectedRowCount.js +1 -1
  92. package/modern/components/base/GridOverlays.js +1 -1
  93. package/modern/components/cell/GridActionsCell.js +1 -1
  94. package/modern/components/cell/GridActionsCellItem.js +1 -1
  95. package/modern/components/cell/GridBooleanCell.js +1 -1
  96. package/modern/components/cell/GridCell.js +2 -2
  97. package/modern/components/cell/GridEditBooleanCell.js +1 -1
  98. package/modern/components/cell/GridEditDateCell.js +1 -1
  99. package/modern/components/cell/GridEditInputCell.js +1 -1
  100. package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
  101. package/modern/components/cell/GridSkeletonCell.js +1 -1
  102. package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -1
  103. package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  104. package/modern/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
  105. package/modern/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -1
  106. package/modern/components/columnHeaders/GridColumnHeaderTitle.js +1 -1
  107. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
  108. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  109. package/modern/components/columnSelection/GridHeaderCheckbox.js +1 -1
  110. package/modern/components/columnsManagement/GridColumnsManagement.js +1 -1
  111. package/modern/components/containers/GridFooterContainer.js +1 -1
  112. package/modern/components/containers/GridOverlay.js +1 -1
  113. package/modern/components/containers/GridRoot.js +1 -1
  114. package/modern/components/containers/GridToolbarContainer.js +1 -1
  115. package/modern/components/menu/GridMenu.js +1 -1
  116. package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  117. package/modern/components/menu/columnMenu/GridColumnMenu.js +1 -1
  118. package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  119. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.js +1 -1
  120. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -1
  121. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -1
  122. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -1
  123. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
  124. package/modern/components/panel/GridColumnsPanel.js +1 -1
  125. package/modern/components/panel/GridPanel.js +1 -1
  126. package/modern/components/panel/GridPanelContent.js +1 -1
  127. package/modern/components/panel/GridPanelFooter.js +1 -1
  128. package/modern/components/panel/GridPanelHeader.js +1 -1
  129. package/modern/components/panel/GridPanelWrapper.js +1 -1
  130. package/modern/components/panel/filterPanel/GridFilterForm.js +1 -1
  131. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  132. package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  133. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  134. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  135. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  136. package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  137. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
  138. package/modern/components/toolbar/GridToolbar.js +1 -1
  139. package/modern/components/toolbar/GridToolbarColumnsButton.js +1 -1
  140. package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
  141. package/modern/components/toolbar/GridToolbarExport.js +1 -1
  142. package/modern/components/toolbar/GridToolbarExportContainer.js +1 -1
  143. package/modern/components/toolbar/GridToolbarFilterButton.js +1 -1
  144. package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
  145. package/modern/hooks/features/clipboard/useGridClipboard.js +8 -5
  146. package/modern/hooks/features/columnResize/useGridColumnResize.js +5 -26
  147. package/modern/hooks/features/columns/gridColumnsUtils.js +18 -13
  148. package/modern/hooks/features/columns/useGridColumnSpanning.js +5 -5
  149. package/modern/hooks/features/export/serializers/csvSerializer.js +28 -32
  150. package/modern/hooks/features/export/useGridCsvExport.js +8 -5
  151. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
  152. package/modern/index.js +1 -2
  153. package/modern/locales/faIR.js +4 -4
  154. package/modern/locales/fiFI.js +4 -5
  155. package/modern/utils/domUtils.js +1 -2
  156. package/node/DataGrid/DataGrid.js +2 -2
  157. package/node/components/GridColumnHeaders.js +1 -1
  158. package/node/components/GridFooter.js +1 -1
  159. package/node/components/GridLoadingOverlay.js +1 -1
  160. package/node/components/GridNoRowsOverlay.js +1 -1
  161. package/node/components/GridPagination.js +1 -1
  162. package/node/components/GridRow.js +1 -1
  163. package/node/components/GridRowCount.js +1 -1
  164. package/node/components/GridScrollArea.js +0 -8
  165. package/node/components/GridSelectedRowCount.js +1 -1
  166. package/node/components/base/GridOverlays.js +1 -1
  167. package/node/components/cell/GridActionsCell.js +1 -1
  168. package/node/components/cell/GridActionsCellItem.js +1 -1
  169. package/node/components/cell/GridBooleanCell.js +1 -1
  170. package/node/components/cell/GridCell.js +2 -2
  171. package/node/components/cell/GridEditBooleanCell.js +1 -1
  172. package/node/components/cell/GridEditDateCell.js +1 -1
  173. package/node/components/cell/GridEditInputCell.js +1 -1
  174. package/node/components/cell/GridEditSingleSelectCell.js +1 -1
  175. package/node/components/cell/GridSkeletonCell.js +1 -1
  176. package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -1
  177. package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  178. package/node/components/columnHeaders/GridColumnHeaderSeparator.js +1 -1
  179. package/node/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -1
  180. package/node/components/columnHeaders/GridColumnHeaderTitle.js +1 -1
  181. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
  182. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  183. package/node/components/columnSelection/GridHeaderCheckbox.js +1 -1
  184. package/node/components/columnsManagement/GridColumnsManagement.js +1 -1
  185. package/node/components/containers/GridFooterContainer.js +1 -1
  186. package/node/components/containers/GridOverlay.js +1 -1
  187. package/node/components/containers/GridRoot.js +1 -1
  188. package/node/components/containers/GridToolbarContainer.js +1 -1
  189. package/node/components/menu/GridMenu.js +1 -1
  190. package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  191. package/node/components/menu/columnMenu/GridColumnMenu.js +1 -1
  192. package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  193. package/node/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.js +1 -1
  194. package/node/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.js +1 -1
  195. package/node/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.js +1 -1
  196. package/node/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.js +1 -1
  197. package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +1 -1
  198. package/node/components/panel/GridColumnsPanel.js +1 -1
  199. package/node/components/panel/GridPanel.js +1 -1
  200. package/node/components/panel/GridPanelContent.js +1 -1
  201. package/node/components/panel/GridPanelFooter.js +1 -1
  202. package/node/components/panel/GridPanelHeader.js +1 -1
  203. package/node/components/panel/GridPanelWrapper.js +1 -1
  204. package/node/components/panel/filterPanel/GridFilterForm.js +1 -1
  205. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  206. package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
  207. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  208. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  209. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
  210. package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
  211. package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
  212. package/node/components/toolbar/GridToolbar.js +1 -1
  213. package/node/components/toolbar/GridToolbarColumnsButton.js +1 -1
  214. package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
  215. package/node/components/toolbar/GridToolbarExport.js +1 -1
  216. package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
  217. package/node/components/toolbar/GridToolbarFilterButton.js +1 -1
  218. package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
  219. package/node/hooks/features/clipboard/useGridClipboard.js +8 -5
  220. package/node/hooks/features/columnResize/useGridColumnResize.js +5 -26
  221. package/node/hooks/features/columns/gridColumnsUtils.js +18 -13
  222. package/node/hooks/features/columns/useGridColumnSpanning.js +5 -5
  223. package/node/hooks/features/export/serializers/csvSerializer.js +28 -32
  224. package/node/hooks/features/export/useGridCsvExport.js +8 -5
  225. package/node/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
  226. package/node/index.js +1 -1
  227. package/node/locales/faIR.js +4 -4
  228. package/node/locales/fiFI.js +4 -5
  229. package/node/utils/domUtils.js +1 -2
  230. package/package.json +4 -3
  231. package/utils/domUtils.js +1 -2
@@ -22,27 +22,6 @@ var _gridColumnsInterfaces = require("../columns/gridColumnsInterfaces");
22
22
  var _columns = require("../columns");
23
23
  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); }
24
24
  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; }
25
- // TODO: remove support for Safari < 13.
26
- // https://caniuse.com/#search=touch-action
27
- //
28
- // Safari, on iOS, supports touch action since v13.
29
- // Over 80% of the iOS phones are compatible
30
- // in August 2020.
31
- // Utilizing the CSS.supports method to check if touch-action is supported.
32
- // Since CSS.supports is supported on all but Edge@12 and IE and touch-action
33
- // is supported on both Edge@12 and IE if CSS.supports is not available that means that
34
- // touch-action will be supported
35
- let cachedSupportsTouchActionNone = false;
36
- function doesSupportTouchActionNone() {
37
- if (cachedSupportsTouchActionNone === undefined) {
38
- if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
39
- cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
40
- } else {
41
- cachedSupportsTouchActionNone = true;
42
- }
43
- }
44
- return cachedSupportsTouchActionNone;
45
- }
46
25
  function trackFinger(event, currentTouchId) {
47
26
  if (currentTouchId !== undefined && event.changedTouches) {
48
27
  for (let i = 0; i < event.changedTouches.length; i += 1) {
@@ -304,6 +283,10 @@ const useGridColumnResize = (apiRef, props) => {
304
283
  if (refs.colDef) {
305
284
  apiRef.current.setColumnWidth(refs.colDef.field, refs.colDef.width);
306
285
  logger.debug(`Updating col ${refs.colDef.field} with new width: ${refs.colDef.width}`);
286
+
287
+ // Since during resizing we update the columns width outside of React, React is unable to
288
+ // reapply the right style properties. We need to sync the state manually.
289
+ // So we reapply the same logic as in https://github.com/mui/mui-x/blob/0511bf65543ca05d2602a5a3e0a6156f2fc8e759/packages/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx#L405
307
290
  const columnsState = (0, _columns.gridColumnsStateSelector)(apiRef.current.state);
308
291
  refs.groupHeaderElements.forEach(element => {
309
292
  const fields = (0, _domUtils.getFieldsFromGroupHeaderElem)(element);
@@ -397,10 +380,6 @@ const useGridColumnResize = (apiRef, props) => {
397
380
  if (!cellSeparator) {
398
381
  return;
399
382
  }
400
- // If touch-action: none; is not supported we need to prevent the scroll manually.
401
- if (!doesSupportTouchActionNone()) {
402
- event.preventDefault();
403
- }
404
383
  const touch = event.changedTouches[0];
405
384
  if (touch != null) {
406
385
  // A number that uniquely identifies the current finger in the touch session.
@@ -572,7 +551,7 @@ const useGridColumnResize = (apiRef, props) => {
572
551
  }
573
552
  });
574
553
  (0, _utils2.useGridNativeEventListener)(apiRef, () => apiRef.current.columnHeadersContainerRef?.current, 'touchstart', handleTouchStart, {
575
- passive: doesSupportTouchActionNone()
554
+ passive: true
576
555
  });
577
556
  (0, _utils2.useGridApiMethod)(apiRef, {
578
557
  autosizeColumns
@@ -129,24 +129,29 @@ const hydrateColumnsWidth = (rawState, dimensions) => {
129
129
  const flexColumns = [];
130
130
 
131
131
  // For the non-flex columns, compute their width
132
- // For the flex columns, compute there minimum width and how much width must be allocated during the flex allocation
132
+ // For the flex columns, compute their minimum width and how much width must be allocated during the flex allocation
133
133
  rawState.orderedFields.forEach(columnField => {
134
- const newColumn = (0, _extends2.default)({}, rawState.lookup[columnField]);
135
- if (rawState.columnVisibilityModel[columnField] === false) {
136
- newColumn.computedWidth = 0;
137
- } else {
138
- let computedWidth;
139
- if (newColumn.flex && newColumn.flex > 0) {
140
- totalFlexUnits += newColumn.flex;
141
- computedWidth = 0;
142
- flexColumns.push(newColumn);
134
+ let column = rawState.lookup[columnField];
135
+ let computedWidth = 0;
136
+ let isFlex = false;
137
+ if (rawState.columnVisibilityModel[columnField] !== false) {
138
+ if (column.flex && column.flex > 0) {
139
+ totalFlexUnits += column.flex;
140
+ isFlex = true;
143
141
  } else {
144
- computedWidth = (0, _utils.clamp)(newColumn.width || _colDef.GRID_STRING_COL_DEF.width, newColumn.minWidth || _colDef.GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || _colDef.GRID_STRING_COL_DEF.maxWidth);
142
+ computedWidth = (0, _utils.clamp)(column.width || _colDef.GRID_STRING_COL_DEF.width, column.minWidth || _colDef.GRID_STRING_COL_DEF.minWidth, column.maxWidth || _colDef.GRID_STRING_COL_DEF.maxWidth);
145
143
  }
146
144
  widthAllocatedBeforeFlex += computedWidth;
147
- newColumn.computedWidth = computedWidth;
148
145
  }
149
- columnsLookup[columnField] = newColumn;
146
+ if (column.computedWidth !== computedWidth) {
147
+ column = (0, _extends2.default)({}, column, {
148
+ computedWidth
149
+ });
150
+ }
151
+ if (isFlex) {
152
+ flexColumns.push(column);
153
+ }
154
+ columnsLookup[columnField] = column;
150
155
  });
151
156
  const availableWidth = dimensions === undefined ? 0 : dimensions.viewportOuterSize.width - (dimensions.hasScrollY ? dimensions.scrollbarSize : 0);
152
157
  const initialFreeSpace = Math.max(availableWidth - widthAllocatedBeforeFlex, 0);
@@ -18,6 +18,9 @@ const useGridColumnSpanning = apiRef => {
18
18
  const getCellColSpanInfo = (rowId, columnIndex) => {
19
19
  return lookup.current[rowId]?.[columnIndex];
20
20
  };
21
+ const resetColSpan = () => {
22
+ lookup.current = {};
23
+ };
21
24
 
22
25
  // Calculate `colSpan` for each cell in the row
23
26
  const calculateColSpan = React.useCallback(({
@@ -45,15 +48,12 @@ const useGridColumnSpanning = apiRef => {
45
48
  unstable_getCellColSpanInfo: getCellColSpanInfo
46
49
  };
47
50
  const columnSpanningPrivateApi = {
51
+ resetColSpan,
48
52
  calculateColSpan
49
53
  };
50
54
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, columnSpanningPublicApi, 'public');
51
55
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, columnSpanningPrivateApi, 'private');
52
- const handleColumnReorderChange = React.useCallback(() => {
53
- // `colSpan` needs to be recalculated after column reordering
54
- lookup.current = {};
55
- }, []);
56
- (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnOrderChange', handleColumnReorderChange);
56
+ (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnOrderChange', resetColSpan);
57
57
  };
58
58
  exports.useGridColumnSpanning = useGridColumnSpanning;
59
59
  function calculateCellColSpan(params) {
@@ -7,14 +7,20 @@ exports.buildCSV = buildCSV;
7
7
  exports.serializeCellValue = void 0;
8
8
  var _colDef = require("../../../../colDef");
9
9
  var _warning = require("../../../../utils/warning");
10
- function sanitizeCellValue(value, delimiterCharacter, shouldAppendQuotes) {
10
+ function sanitizeCellValue(value, csvOptions) {
11
11
  if (typeof value === 'string') {
12
- if (shouldAppendQuotes) {
12
+ if (csvOptions.shouldAppendQuotes || csvOptions.escapeFormulas) {
13
13
  const escapedValue = value.replace(/"/g, '""');
14
- // Make sure value containing delimiter or line break won't be split into multiple rows
15
- if ([delimiterCharacter, '\n', '\r', '"'].some(delimiter => value.includes(delimiter))) {
14
+ // Make sure value containing delimiter or line break won't be split into multiple cells
15
+ if ([csvOptions.delimiter, '\n', '\r', '"'].some(delimiter => value.includes(delimiter))) {
16
16
  return `"${escapedValue}"`;
17
17
  }
18
+ if (csvOptions.escapeFormulas) {
19
+ // See https://owasp.org/www-community/attacks/CSV_Injection
20
+ if (['=', '+', '-', '@', '\t', '\r'].includes(escapedValue[0])) {
21
+ return `'${escapedValue}`;
22
+ }
23
+ }
18
24
  return escapedValue;
19
25
  }
20
26
  return value;
@@ -23,9 +29,8 @@ function sanitizeCellValue(value, delimiterCharacter, shouldAppendQuotes) {
23
29
  }
24
30
  const serializeCellValue = (cellParams, options) => {
25
31
  const {
26
- delimiterCharacter,
27
- ignoreValueFormatter,
28
- shouldAppendQuotes
32
+ csvOptions,
33
+ ignoreValueFormatter
29
34
  } = options;
30
35
  let value;
31
36
  if (ignoreValueFormatter) {
@@ -42,7 +47,7 @@ const serializeCellValue = (cellParams, options) => {
42
47
  } else {
43
48
  value = cellParams.formattedValue;
44
49
  }
45
- return sanitizeCellValue(value, delimiterCharacter, shouldAppendQuotes);
50
+ return sanitizeCellValue(value, csvOptions);
46
51
  };
47
52
  exports.serializeCellValue = serializeCellValue;
48
53
  const objectFormattedValueWarning = (0, _warning.buildWarning)(['MUI X: 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.']);
@@ -55,12 +60,12 @@ class CSVRow {
55
60
  }
56
61
  addValue(value) {
57
62
  if (!this.isEmpty) {
58
- this.rowString += this.options.delimiterCharacter;
63
+ this.rowString += this.options.csvOptions.delimiter;
59
64
  }
60
65
  if (value === null || value === undefined) {
61
66
  this.rowString += '';
62
67
  } else if (typeof this.options.sanitizeCellValue === 'function') {
63
- this.rowString += this.options.sanitizeCellValue(value, this.options.delimiterCharacter, this.options.shouldAppendQuotes);
68
+ this.rowString += this.options.sanitizeCellValue(value, this.options.csvOptions);
64
69
  } else {
65
70
  this.rowString += value;
66
71
  }
@@ -74,13 +79,11 @@ const serializeRow = ({
74
79
  id,
75
80
  columns,
76
81
  getCellParams,
77
- delimiterCharacter,
78
- ignoreValueFormatter,
79
- shouldAppendQuotes
82
+ csvOptions,
83
+ ignoreValueFormatter
80
84
  }) => {
81
85
  const row = new CSVRow({
82
- delimiterCharacter,
83
- shouldAppendQuotes
86
+ csvOptions
84
87
  });
85
88
  columns.forEach(column => {
86
89
  const cellParams = getCellParams(id, column.field);
@@ -90,9 +93,8 @@ const serializeRow = ({
90
93
  }
91
94
  }
92
95
  row.addValue(serializeCellValue(cellParams, {
93
- delimiterCharacter,
94
96
  ignoreValueFormatter,
95
- shouldAppendQuotes
97
+ csvOptions
96
98
  }));
97
99
  });
98
100
  return row.getRowString();
@@ -101,27 +103,23 @@ function buildCSV(options) {
101
103
  const {
102
104
  columns,
103
105
  rowIds,
104
- delimiterCharacter,
105
- includeHeaders,
106
- includeColumnGroupsHeaders,
106
+ csvOptions,
107
107
  ignoreValueFormatter,
108
- apiRef,
109
- shouldAppendQuotes
108
+ apiRef
110
109
  } = options;
111
110
  const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
112
111
  id,
113
112
  columns,
114
113
  getCellParams: apiRef.current.getCellParams,
115
- delimiterCharacter,
116
114
  ignoreValueFormatter,
117
- shouldAppendQuotes
115
+ csvOptions
118
116
  })}\r\n`, '').trim();
119
- if (!includeHeaders) {
117
+ if (!csvOptions.includeHeaders) {
120
118
  return CSVBody;
121
119
  }
122
120
  const filteredColumns = columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field);
123
121
  const headerRows = [];
124
- if (includeColumnGroupsHeaders) {
122
+ if (csvOptions.includeColumnGroupsHeaders) {
125
123
  const columnGroupLookup = apiRef.current.getAllGroupDetails();
126
124
  let maxColumnGroupsDepth = 0;
127
125
  const columnGroupPathsLookup = filteredColumns.reduce((acc, column) => {
@@ -132,9 +130,8 @@ function buildCSV(options) {
132
130
  }, {});
133
131
  for (let i = 0; i < maxColumnGroupsDepth; i += 1) {
134
132
  const headerGroupRow = new CSVRow({
135
- delimiterCharacter,
136
- sanitizeCellValue,
137
- shouldAppendQuotes
133
+ csvOptions,
134
+ sanitizeCellValue
138
135
  });
139
136
  headerRows.push(headerGroupRow);
140
137
  filteredColumns.forEach(column => {
@@ -145,9 +142,8 @@ function buildCSV(options) {
145
142
  }
146
143
  }
147
144
  const mainHeaderRow = new CSVRow({
148
- delimiterCharacter,
149
- sanitizeCellValue,
150
- shouldAppendQuotes
145
+ csvOptions,
146
+ sanitizeCellValue
151
147
  });
152
148
  filteredColumns.forEach(column => {
153
149
  mainHeaderRow.addValue(column.headerName || column.field);
@@ -39,12 +39,15 @@ const useGridCsvExport = (apiRef, props) => {
39
39
  return (0, _csvSerializer.buildCSV)({
40
40
  columns: exportedColumns,
41
41
  rowIds: exportedRowIds,
42
- delimiterCharacter: options.delimiter || ',',
43
- includeHeaders: options.includeHeaders ?? true,
44
- includeColumnGroupsHeaders: options.includeColumnGroupsHeaders ?? true,
42
+ csvOptions: {
43
+ delimiter: options.delimiter || ',',
44
+ shouldAppendQuotes: options.shouldAppendQuotes ?? true,
45
+ includeHeaders: options.includeHeaders ?? true,
46
+ includeColumnGroupsHeaders: options.includeColumnGroupsHeaders ?? true,
47
+ escapeFormulas: options.escapeFormulas ?? true
48
+ },
45
49
  ignoreValueFormatter,
46
- apiRef,
47
- shouldAppendQuotes: options.shouldAppendQuotes ?? true
50
+ apiRef
48
51
  });
49
52
  }, [logger, apiRef, ignoreValueFormatter]);
50
53
  const exportDataAsCsv = React.useCallback(options => {
@@ -54,7 +54,14 @@ const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, ho
54
54
  direction: ScrollDirection.NONE,
55
55
  buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
56
56
  });
57
- const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
57
+ let isJSDOM = false;
58
+ try {
59
+ if (typeof window !== 'undefined') {
60
+ isJSDOM = /jsdom/.test(window.navigator.userAgent);
61
+ }
62
+ } catch (_) {
63
+ /* ignore */
64
+ }
58
65
  const useGridVirtualScroller = () => {
59
66
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
60
67
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.5.0
2
+ * @mui/x-data-grid v7.6.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -9,7 +9,7 @@ var _getGridLocalization = require("../utils/getGridLocalization");
9
9
  const faIRGrid = {
10
10
  // Root
11
11
  noRowsLabel: 'بدون سطر',
12
- noResultsOverlayLabel: 'نتیجه ای پیدا نشد.',
12
+ noResultsOverlayLabel: 'نتیجه‌ای پیدا نشد.',
13
13
  // Density selector toolbar button text
14
14
  toolbarDensity: 'تراکم',
15
15
  toolbarDensityLabel: 'تراکم',
@@ -103,12 +103,12 @@ const faIRGrid = {
103
103
  columnMenuFilter: 'فیلتر',
104
104
  columnMenuHideColumn: 'مخفی',
105
105
  columnMenuUnsort: 'نامرتب‌کردن',
106
- columnMenuSortAsc: 'مرتب‌کردن صعودی',
107
- columnMenuSortDesc: 'مرتب‌کردن نزولی',
106
+ columnMenuSortAsc: 'مرتب‌سازی صعودی',
107
+ columnMenuSortDesc: 'مرتب‌سازی نزولی',
108
108
  // Column header text
109
109
  columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} فیلتر‌های فعال` : `${count} فیلتر فعال`,
110
110
  columnHeaderFiltersLabel: 'نمایش فیلترها',
111
- columnHeaderSortIconLabel: 'مرتب‌کردن',
111
+ columnHeaderSortIconLabel: 'مرتب‌سازی',
112
112
  // Rows selected footer text
113
113
  footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} سطرهای انتخاب شده` : `${count.toLocaleString()} سطر انتخاب شده`,
114
114
  // Total row amount footer text
@@ -36,11 +36,10 @@ const fiFIGrid = {
36
36
  toolbarExportPrint: 'Tulosta',
37
37
  toolbarExportExcel: 'Lataa Excel-muodossa',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
- // columnsManagementReset: 'Reset',
43
-
39
+ columnsManagementSearchTitle: 'Hae',
40
+ columnsManagementNoColumns: 'Ei sarakkeita näytettäväksi',
41
+ columnsManagementShowHideAllText: 'Näytä/Piilota kaikki',
42
+ columnsManagementReset: 'Palauta',
44
43
  // Filter panel text
45
44
  filterPanelAddFilter: 'Lisää suodatin',
46
45
  filterPanelRemoveAll: 'Poista kaikki',
@@ -79,8 +79,7 @@ function findHeaderElementFromField(elem, field) {
79
79
  return elem.querySelector(`[data-field="${field}"]`);
80
80
  }
81
81
  function getFieldsFromGroupHeaderElem(colCellEl) {
82
- const fieldsString = colCellEl.getAttribute('data-fields');
83
- return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
82
+ return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
84
83
  }
85
84
  function findGroupHeaderElementsFromField(elem, field) {
86
85
  return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.5.0",
3
+ "version": "7.6.0",
4
4
  "description": "The Community plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -37,8 +37,9 @@
37
37
  "directory": "packages/x-data-grid"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.24.5",
41
- "@mui/system": "^5.15.14",
40
+ "@babel/runtime": "^7.24.6",
41
+ "@mui/internal-test-utils": "1.0.0-dev.20240529-082515-213b5e33ab",
42
+ "@mui/system": "^5.15.15",
42
43
  "@mui/utils": "^5.15.14",
43
44
  "clsx": "^2.1.1",
44
45
  "prop-types": "^15.8.1",
package/utils/domUtils.js CHANGED
@@ -54,8 +54,7 @@ export function findHeaderElementFromField(elem, field) {
54
54
  return elem.querySelector(`[data-field="${field}"]`);
55
55
  }
56
56
  export function getFieldsFromGroupHeaderElem(colCellEl) {
57
- const fieldsString = colCellEl.getAttribute('data-fields');
58
- return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
57
+ return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
59
58
  }
60
59
  export function findGroupHeaderElementsFromField(elem, field) {
61
60
  return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);