@mui/x-data-grid-premium 7.0.0-beta.6 → 7.0.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 (41) hide show
  1. package/CHANGELOG.md +311 -12
  2. package/DataGridPremium/DataGridPremium.js +26 -18
  3. package/README.md +1 -1
  4. package/esm/DataGridPremium/DataGridPremium.js +26 -18
  5. package/esm/components/GridAggregationHeader.js +1 -2
  6. package/esm/components/GridColumnMenuAggregationItem.js +2 -3
  7. package/esm/components/GridColumnMenuRowGroupItem.js +1 -2
  8. package/esm/components/GridColumnMenuRowUngroupItem.js +1 -2
  9. package/esm/components/GridExcelExportMenuItem.js +1 -1
  10. package/esm/components/GridGroupingColumnLeafCell.js +1 -2
  11. package/esm/components/GridGroupingCriteriaCell.js +2 -3
  12. package/esm/hooks/features/aggregation/gridAggregationUtils.js +4 -4
  13. package/esm/hooks/features/aggregation/useGridAggregation.js +1 -2
  14. package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +1 -2
  15. package/esm/hooks/features/aggregation/wrapColumnWithAggregation.js +5 -9
  16. package/esm/hooks/features/cellSelection/useGridCellSelection.js +25 -34
  17. package/esm/hooks/features/clipboard/useGridClipboardImport.js +21 -8
  18. package/esm/hooks/features/export/serializer/excelSerializer.js +9 -22
  19. package/esm/hooks/features/export/useGridExcelExport.js +9 -11
  20. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +23 -32
  21. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -7
  22. package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +5 -9
  23. package/esm/hooks/utils/useKeepGroupedColumnsHidden.js +7 -9
  24. package/esm/utils/releaseInfo.js +1 -1
  25. package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +1 -1
  26. package/hooks/features/cellSelection/useGridCellSelection.d.ts +1 -1
  27. package/hooks/features/cellSelection/useGridCellSelection.js +12 -12
  28. package/hooks/features/clipboard/useGridClipboardImport.d.ts +1 -1
  29. package/hooks/features/clipboard/useGridClipboardImport.js +18 -3
  30. package/hooks/features/rowGrouping/createGroupingColDef.js +3 -2
  31. package/index.js +1 -1
  32. package/models/dataGridPremiumProps.d.ts +12 -2
  33. package/models/gridApiPremium.d.ts +2 -2
  34. package/modern/DataGridPremium/DataGridPremium.js +26 -18
  35. package/modern/hooks/features/cellSelection/useGridCellSelection.js +14 -14
  36. package/modern/hooks/features/clipboard/useGridClipboardImport.js +19 -4
  37. package/modern/hooks/features/rowGrouping/createGroupingColDef.js +3 -2
  38. package/modern/index.js +1 -1
  39. package/modern/utils/releaseInfo.js +1 -1
  40. package/package.json +7 -7
  41. package/utils/releaseInfo.js +1 -1
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { ownerDocument, useEventCallback } from '@mui/material/utils';
4
- import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
5
- import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector, GRID_REORDER_COL_DEF, useGridSelector, gridSortedRowIdsSelector } from '@mui/x-data-grid-pro';
4
+ import { getTotalHeaderHeight, isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
5
+ import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector, GRID_REORDER_COL_DEF, useGridSelector, gridSortedRowIdsSelector, gridDimensionsSelector } from '@mui/x-data-grid-pro';
6
6
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
7
7
  export const cellSelectionStateInitializer = (state, props) => _extends({}, state, {
8
8
  cellSelection: _extends({}, props.cellSelectionModel ?? props.initialState?.cellSelection)
@@ -20,6 +20,8 @@ export const useGridCellSelection = (apiRef, props) => {
20
20
  const mousePosition = React.useRef(null);
21
21
  const autoScrollRAF = React.useRef();
22
22
  const sortedRowIds = useGridSelector(apiRef, gridSortedRowIdsSelector);
23
+ const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
24
+ const totalHeaderHeight = getTotalHeaderHeight(apiRef, props.columnHeaderHeight);
23
25
  const ignoreValueFormatterProp = props.ignoreValueFormatterDuringExport;
24
26
  const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
25
27
  const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -166,10 +168,6 @@ export const useGridCellSelection = (apiRef, props) => {
166
168
  if (!apiRef.current.virtualScrollerRef?.current) {
167
169
  return;
168
170
  }
169
- const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
170
- if (!virtualScrollerRect) {
171
- return;
172
- }
173
171
  function autoScroll() {
174
172
  if (!mousePosition.current || !apiRef.current.virtualScrollerRef?.current) {
175
173
  return;
@@ -181,11 +179,10 @@ export const useGridCellSelection = (apiRef, props) => {
181
179
  const {
182
180
  height,
183
181
  width
184
- } = virtualScrollerRect;
182
+ } = dimensions.viewportInnerSize;
185
183
  let deltaX = 0;
186
184
  let deltaY = 0;
187
185
  let factor = 0;
188
- const dimensions = apiRef.current.getRootDimensions();
189
186
  if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions.hasScrollY) {
190
187
  // When scrolling up, the multiplier increases going closer to the top edge
191
188
  factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
@@ -216,7 +213,7 @@ export const useGridCellSelection = (apiRef, props) => {
216
213
  autoScrollRAF.current = requestAnimationFrame(autoScroll);
217
214
  }
218
215
  autoScroll();
219
- }, [apiRef]);
216
+ }, [apiRef, dimensions]);
220
217
  const handleCellMouseOver = React.useCallback((params, event) => {
221
218
  if (!lastMouseDownCell.current) {
222
219
  return;
@@ -234,13 +231,15 @@ export const useGridCellSelection = (apiRef, props) => {
234
231
  return;
235
232
  }
236
233
  const {
237
- height,
238
- width,
239
234
  x,
240
235
  y
241
236
  } = virtualScrollerRect;
237
+ const {
238
+ height,
239
+ width
240
+ } = dimensions.viewportInnerSize;
242
241
  const mouseX = event.clientX - x;
243
- const mouseY = event.clientY - y;
242
+ const mouseY = event.clientY - y - totalHeaderHeight;
244
243
  mousePosition.current = {
245
244
  x: mouseX,
246
245
  y: mouseY
@@ -255,7 +254,7 @@ export const useGridCellSelection = (apiRef, props) => {
255
254
  // Mouse has left the sensitivity area while auto scroll is on
256
255
  stopAutoScroll();
257
256
  }
258
- }, [apiRef, startAutoScroll, stopAutoScroll]);
257
+ }, [apiRef, startAutoScroll, stopAutoScroll, totalHeaderHeight, dimensions]);
259
258
  const handleCellClick = useEventCallback((params, event) => {
260
259
  const {
261
260
  id,
@@ -447,7 +446,8 @@ export const useGridCellSelection = (apiRef, props) => {
447
446
  const cellParams = apiRef.current.getCellParams(rowId, field);
448
447
  cellData = serializeCellValue(cellParams, {
449
448
  delimiterCharacter: clipboardCopyCellDelimiter,
450
- ignoreValueFormatter
449
+ ignoreValueFormatter,
450
+ shouldAppendQuotes: true
451
451
  });
452
452
  } else {
453
453
  cellData = '';
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector } from '@mui/x-data-grid';
4
- import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef, isPasteShortcut } from '@mui/x-data-grid/internals';
4
+ import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef, isPasteShortcut, useGridLogger } from '@mui/x-data-grid/internals';
5
5
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_REORDER_COL_DEF } from '@mui/x-data-grid-pro';
6
6
  import { unstable_debounce as debounce } from '@mui/utils';
7
- const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/#server-side-persistence.'], 'error');
7
+ const missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/#server-side-persistence.'], 'error');
8
8
  const columnFieldsToExcludeFromPaste = [GRID_CHECKBOX_SELECTION_FIELD, GRID_REORDER_COL_DEF.field, GRID_DETAIL_PANEL_TOGGLE_FIELD];
9
9
 
10
10
  // Batches rows that are updated during clipboard paste to reduce `updateRows` calls
@@ -240,7 +240,12 @@ export const useGridClipboardImport = (apiRef, props) => {
240
240
  const getRowId = props.getRowId;
241
241
  const enableClipboardPaste = !props.disableClipboardPaste;
242
242
  const rootEl = apiRef.current.rootElementRef?.current;
243
+ const logger = useGridLogger(apiRef, 'useGridClipboardImport');
243
244
  const splitClipboardPastedText = props.splitClipboardPastedText;
245
+ const {
246
+ pagination,
247
+ onBeforeClipboardPasteStart
248
+ } = props;
244
249
  const handlePaste = React.useCallback(async (params, event) => {
245
250
  if (!enableClipboardPaste) {
246
251
  return;
@@ -267,6 +272,16 @@ export const useGridClipboardImport = (apiRef, props) => {
267
272
  if (!pastedData) {
268
273
  return;
269
274
  }
275
+ if (onBeforeClipboardPasteStart) {
276
+ try {
277
+ await onBeforeClipboardPasteStart({
278
+ data: pastedData
279
+ });
280
+ } catch (error) {
281
+ logger.debug('Clipboard paste operation cancelled');
282
+ return;
283
+ }
284
+ }
270
285
  const cellUpdater = new CellValueUpdater({
271
286
  apiRef,
272
287
  processRowUpdate,
@@ -282,10 +297,10 @@ export const useGridClipboardImport = (apiRef, props) => {
282
297
  updateCell: (...args) => {
283
298
  cellUpdater.updateCell(...args);
284
299
  },
285
- pagination: props.pagination
300
+ pagination
286
301
  });
287
302
  cellUpdater.applyUpdates();
288
- }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, props.pagination]);
303
+ }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
289
304
  const checkIfCanStartEditing = React.useCallback((initialValue, {
290
305
  event
291
306
  }) => {
@@ -64,8 +64,9 @@ const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
64
64
  valueOptions: isSingleSelectColDef(groupedByColDef) ? groupedByColDef.valueOptions : undefined,
65
65
  sortComparator: (v1, v2, cellParams1, cellParams2) => {
66
66
  // We only want to sort the groups of the current grouping criteria
67
- if (cellParams1.rowNode.type === 'group' && cellParams1.rowNode.groupingField === groupedByColDef.field && cellParams2.rowNode.type === 'group' && cellParams2.rowNode.groupingField === groupedByColDef.field) {
68
- return groupedByColDef.sortComparator(v1, v2, cellParams1, cellParams2);
67
+ if (cellParams1.rowNode.type === 'group' && cellParams2.rowNode.type === 'group' && cellParams1.rowNode.groupingField === cellParams2.rowNode.groupingField) {
68
+ const colDef = cellParams1.api.getColumn(cellParams1.rowNode.groupingField);
69
+ return colDef.sortComparator(v1, v2, cellParams1, cellParams2);
69
70
  }
70
71
  return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
71
72
  },
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v7.0.0-beta.6
2
+ * @mui/x-data-grid-premium v7.0.0
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 = "MTcwOTg1MjQwMDAwMA==";
3
+ const releaseInfo = "MTcxMTA1ODQwMDAwMA==";
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.0.0-beta.6",
3
+ "version": "7.0.0",
4
4
  "description": "The Premium plan edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -33,11 +33,11 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.24.0",
36
- "@mui/system": "^5.15.9",
37
- "@mui/utils": "^5.15.9",
38
- "@mui/x-data-grid": "7.0.0-beta.6",
39
- "@mui/x-data-grid-pro": "7.0.0-beta.6",
40
- "@mui/x-license": "7.0.0-beta.6",
36
+ "@mui/system": "^5.15.14",
37
+ "@mui/utils": "^5.15.14",
38
+ "@mui/x-data-grid": "7.0.0",
39
+ "@mui/x-data-grid-pro": "7.0.0",
40
+ "@mui/x-license": "7.0.0",
41
41
  "@types/format-util": "^1.0.4",
42
42
  "clsx": "^2.1.0",
43
43
  "exceljs": "^4.4.0",
@@ -45,7 +45,7 @@
45
45
  "reselect": "^4.1.8"
46
46
  },
47
47
  "peerDependencies": {
48
- "@mui/material": "^5.15.0",
48
+ "@mui/material": "^5.15.14",
49
49
  "react": "^17.0.0 || ^18.0.0",
50
50
  "react-dom": "^17.0.0 || ^18.0.0"
51
51
  },
@@ -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 = "MTcwOTg1MjQwMDAwMA==";
9
+ const releaseInfo = "MTcxMTA1ODQwMDAwMA==";
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