@mui/x-data-grid-premium 6.19.5 → 6.19.8

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,95 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.19.8
7
+
8
+ _Mar 20, 2024_
9
+
10
+ We'd like to offer a big thanks to the 3 contributors who made this release possible.
11
+
12
+ ### Data Grid
13
+
14
+ #### `@mui/x-data-grid@6.19.8`
15
+
16
+ - [DataGrid] Fix `ElementType` usage (#12505) @cherniavskii
17
+ - [DataGrid] Fix cell value formatting on copy (#12483) @sai6855
18
+ - [DataGrid] Fix checkbox selection when filtering (#12485) @g1mishra
19
+
20
+ #### `@mui/x-data-grid-pro@6.19.8` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
21
+
22
+ Same changes as in `@mui/x-data-grid@6.19.8`.
23
+
24
+ #### `@mui/x-data-grid-premium@6.19.8` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
25
+
26
+ Same changes as in `@mui/x-data-grid-pro@6.19.8`, plus:
27
+
28
+ - [DataGridPremium] Add support for confirmation before clipboard paste (#12466) @cherniavskii
29
+
30
+ ### Docs
31
+
32
+ - [docs] Update links to v7 (#12495) @cherniavskii
33
+
34
+ ## 6.19.7
35
+
36
+ _Mar 14, 2024_
37
+
38
+ We'd like to offer a big thanks to @LukasTy who made this release possible.
39
+
40
+ ### Date Pickers
41
+
42
+ #### `@mui/x-date-pickers@6.19.7`
43
+
44
+ - [pickers] Keep the existing time when looking for closest enabled date (#12410) @LukasTy
45
+
46
+ #### `@mui/x-date-pickers-pro@6.19.7` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
47
+
48
+ Same changes as in `@mui/x-date-pickers@6.19.7`.
49
+
50
+ ### Docs
51
+
52
+ - [docs] Add Pickers custom start of week section (#12425) @LukasTy
53
+
54
+ ## 6.19.6
55
+
56
+ _Mar 1, 2024_
57
+
58
+ We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
59
+
60
+ - 🌍 Improve Korean (ko-KR) and Chinese (zh-CN) locales on the Pickers
61
+ - 🐞 Bugfixes
62
+ - 📚 Documentation improvements
63
+
64
+ ### Data Grid
65
+
66
+ #### `@mui/x-data-grid@6.19.6`
67
+
68
+ - [DataGrid] Fix error when existing rows are passed to `replaceRows` (@martijn-basesoft)
69
+
70
+ #### `@mui/x-data-grid-pro@6.19.6` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
71
+
72
+ Same changes as in `@mui/x-data-grid@6.19.6`.
73
+
74
+ #### `@mui/x-data-grid-premium@6.19.6` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
75
+
76
+ Same changes as in `@mui/x-data-grid-pro@6.19.6`, plus:
77
+
78
+ - [DataGridPremium] Make clipboard copy respect the sorting during cell selection (#12255) @MBilalShafi
79
+
80
+ ### Date Pickers
81
+
82
+ #### `@mui/x-date-pickers@6.19.6`
83
+
84
+ - [l10n] Improve Chinese (zh-CN) locale (#12250) @headironc
85
+ - [l10n] Improve Korean (ko-KR) locale (#12186) @Luzi
86
+
87
+ #### `@mui/x-date-pickers-pro@6.19.6` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
88
+
89
+ Same changes as in `@mui/x-date-pickers@6.19.6`.
90
+
91
+ ### Docs
92
+
93
+ - [docs] Update lazy loading demo to show skeleton rows during initial rows fetch (#12062) @cherniavskii
94
+
6
95
  ## 6.19.5
7
96
 
8
97
  _Feb 23, 2024_
@@ -489,6 +489,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
489
489
  * @param {GridCallbackDetails} details Additional details for this callback.
490
490
  */
491
491
  onAggregationModelChange: PropTypes.func,
492
+ /**
493
+ * Callback fired before the clipboard paste operation starts.
494
+ * Use it to confirm or cancel the paste operation.
495
+ * @param {object} params Params passed to the callback.
496
+ * @param {string[][]} params.data The raw pasted data split by rows and cells.
497
+ * @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
498
+ */
499
+ onBeforeClipboardPasteStart: PropTypes.func,
492
500
  /**
493
501
  * Callback fired when any cell is clicked.
494
502
  * @param {GridCellParams} params With all properties from [[GridCellParams]].
@@ -2,7 +2,7 @@ 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
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 } from '@mui/x-data-grid-pro';
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';
6
6
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
7
7
  export const cellSelectionStateInitializer = (state, props) => {
8
8
  var _props$unstable_cellS, _props$initialState;
@@ -22,6 +22,7 @@ export const useGridCellSelection = (apiRef, props) => {
22
22
  const lastMouseDownCell = React.useRef();
23
23
  const mousePosition = React.useRef(null);
24
24
  const autoScrollRAF = React.useRef();
25
+ const sortedRowIds = useGridSelector(apiRef, gridSortedRowIdsSelector);
25
26
  const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
26
27
  const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
27
28
  const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -445,7 +446,9 @@ export const useGridCellSelection = (apiRef, props) => {
445
446
  return value;
446
447
  }
447
448
  const cellSelectionModel = apiRef.current.unstable_getCellSelectionModel();
448
- const copyData = Object.keys(cellSelectionModel).reduce((acc, rowId) => {
449
+ const unsortedSelectedRowIds = Object.keys(cellSelectionModel);
450
+ const sortedSelectedRowIds = sortedRowIds.filter(id => unsortedSelectedRowIds.includes(`${id}`));
451
+ const copyData = sortedSelectedRowIds.reduce((acc, rowId) => {
449
452
  const fieldsMap = cellSelectionModel[rowId];
450
453
  const rowString = Object.keys(fieldsMap).reduce((acc2, field) => {
451
454
  let cellData;
@@ -453,7 +456,8 @@ export const useGridCellSelection = (apiRef, props) => {
453
456
  const cellParams = apiRef.current.getCellParams(rowId, field);
454
457
  cellData = serializeCellValue(cellParams, {
455
458
  delimiterCharacter: clipboardCopyCellDelimiter,
456
- ignoreValueFormatter
459
+ ignoreValueFormatter,
460
+ shouldAppendQuotes: true
457
461
  });
458
462
  } else {
459
463
  cellData = '';
@@ -463,7 +467,7 @@ export const useGridCellSelection = (apiRef, props) => {
463
467
  return acc === '' ? rowString : [acc, rowString].join('\r\n');
464
468
  }, '');
465
469
  return copyData;
466
- }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
470
+ }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter, sortedRowIds]);
467
471
  useGridRegisterPipeProcessor(apiRef, 'isCellSelected', checkIfCellIsSelected);
468
472
  useGridRegisterPipeProcessor(apiRef, 'cellClassName', addClassesToCells);
469
473
  useGridRegisterPipeProcessor(apiRef, 'canUpdateFocus', canUpdateFocus);
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
3
3
  import type { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
4
- export declare const useGridClipboardImport: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, 'pagination' | 'paginationMode' | 'processRowUpdate' | 'onProcessRowUpdateError' | 'getRowId' | 'onClipboardPasteStart' | 'onClipboardPasteEnd' | 'experimentalFeatures' | 'unstable_splitClipboardPastedText' | 'disableClipboardPaste'>) => void;
4
+ export declare const useGridClipboardImport: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, 'pagination' | 'paginationMode' | 'processRowUpdate' | 'onProcessRowUpdateError' | 'getRowId' | 'onClipboardPasteStart' | 'onClipboardPasteEnd' | 'experimentalFeatures' | 'unstable_splitClipboardPastedText' | 'disableClipboardPaste' | 'onBeforeClipboardPasteStart'>) => void;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector } from '@mui/x-data-grid';
3
+ import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector, useGridLogger } from '@mui/x-data-grid';
4
4
  import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef } 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';
@@ -249,7 +249,12 @@ export const useGridClipboardImport = (apiRef, props) => {
249
249
  const getRowId = props.getRowId;
250
250
  const enableClipboardPaste = (_ref = !props.disableClipboardPaste && ((_props$experimentalFe = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe.clipboardPaste)) != null ? _ref : false;
251
251
  const rootEl = (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE.current;
252
+ const logger = useGridLogger(apiRef, 'useGridClipboardImport');
252
253
  const splitClipboardPastedText = props.unstable_splitClipboardPastedText;
254
+ const {
255
+ pagination,
256
+ onBeforeClipboardPasteStart
257
+ } = props;
253
258
  const handlePaste = React.useCallback(async (params, event) => {
254
259
  if (!enableClipboardPaste) {
255
260
  return;
@@ -276,6 +281,16 @@ export const useGridClipboardImport = (apiRef, props) => {
276
281
  if (!pastedData) {
277
282
  return;
278
283
  }
284
+ if (onBeforeClipboardPasteStart) {
285
+ try {
286
+ await onBeforeClipboardPasteStart({
287
+ data: pastedData
288
+ });
289
+ } catch (error) {
290
+ logger.debug('Clipboard paste operation cancelled');
291
+ return;
292
+ }
293
+ }
279
294
  const cellUpdater = new CellValueUpdater({
280
295
  apiRef,
281
296
  processRowUpdate,
@@ -291,10 +306,10 @@ export const useGridClipboardImport = (apiRef, props) => {
291
306
  updateCell: (...args) => {
292
307
  cellUpdater.updateCell(...args);
293
308
  },
294
- pagination: props.pagination
309
+ pagination
295
310
  });
296
311
  cellUpdater.applyUpdates();
297
- }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, props.pagination]);
312
+ }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
298
313
  const checkIfCanStartEditing = React.useCallback((initialValue, {
299
314
  event
300
315
  }) => {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.19.5
2
+ * @mui/x-data-grid-premium v6.19.8
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -489,6 +489,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
489
489
  * @param {GridCallbackDetails} details Additional details for this callback.
490
490
  */
491
491
  onAggregationModelChange: PropTypes.func,
492
+ /**
493
+ * Callback fired before the clipboard paste operation starts.
494
+ * Use it to confirm or cancel the paste operation.
495
+ * @param {object} params Params passed to the callback.
496
+ * @param {string[][]} params.data The raw pasted data split by rows and cells.
497
+ * @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
498
+ */
499
+ onBeforeClipboardPasteStart: PropTypes.func,
492
500
  /**
493
501
  * Callback fired when any cell is clicked.
494
502
  * @param {GridCellParams} params With all properties from [[GridCellParams]].
@@ -6,7 +6,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import * as React from 'react';
7
7
  import { ownerDocument, useEventCallback } from '@mui/material/utils';
8
8
  import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
9
- import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector, GRID_REORDER_COL_DEF } from '@mui/x-data-grid-pro';
9
+ 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';
10
10
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
11
11
  export var cellSelectionStateInitializer = function cellSelectionStateInitializer(state, props) {
12
12
  var _props$unstable_cellS, _props$initialState;
@@ -26,6 +26,7 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
26
26
  var lastMouseDownCell = React.useRef();
27
27
  var mousePosition = React.useRef(null);
28
28
  var autoScrollRAF = React.useRef();
29
+ var sortedRowIds = useGridSelector(apiRef, gridSortedRowIdsSelector);
29
30
  var ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
30
31
  var ignoreValueFormatter = (_typeof(ignoreValueFormatterProp) === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
31
32
  var clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -429,7 +430,11 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
429
430
  return value;
430
431
  }
431
432
  var cellSelectionModel = apiRef.current.unstable_getCellSelectionModel();
432
- var copyData = Object.keys(cellSelectionModel).reduce(function (acc, rowId) {
433
+ var unsortedSelectedRowIds = Object.keys(cellSelectionModel);
434
+ var sortedSelectedRowIds = sortedRowIds.filter(function (id) {
435
+ return unsortedSelectedRowIds.includes("".concat(id));
436
+ });
437
+ var copyData = sortedSelectedRowIds.reduce(function (acc, rowId) {
433
438
  var fieldsMap = cellSelectionModel[rowId];
434
439
  var rowString = Object.keys(fieldsMap).reduce(function (acc2, field) {
435
440
  var cellData;
@@ -437,7 +442,8 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
437
442
  var cellParams = apiRef.current.getCellParams(rowId, field);
438
443
  cellData = serializeCellValue(cellParams, {
439
444
  delimiterCharacter: clipboardCopyCellDelimiter,
440
- ignoreValueFormatter: ignoreValueFormatter
445
+ ignoreValueFormatter: ignoreValueFormatter,
446
+ shouldAppendQuotes: true
441
447
  });
442
448
  } else {
443
449
  cellData = '';
@@ -447,7 +453,7 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
447
453
  return acc === '' ? rowString : [acc, rowString].join('\r\n');
448
454
  }, '');
449
455
  return copyData;
450
- }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
456
+ }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter, sortedRowIds]);
451
457
  useGridRegisterPipeProcessor(apiRef, 'isCellSelected', checkIfCellIsSelected);
452
458
  useGridRegisterPipeProcessor(apiRef, 'cellClassName', addClassesToCells);
453
459
  useGridRegisterPipeProcessor(apiRef, 'canUpdateFocus', canUpdateFocus);
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import * as React from 'react';
7
- import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector } from '@mui/x-data-grid';
7
+ import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector, useGridLogger } from '@mui/x-data-grid';
8
8
  import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef } from '@mui/x-data-grid/internals';
9
9
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_REORDER_COL_DEF } from '@mui/x-data-grid-pro';
10
10
  import { unstable_debounce as debounce } from '@mui/utils';
@@ -294,7 +294,10 @@ export var useGridClipboardImport = function useGridClipboardImport(apiRef, prop
294
294
  var getRowId = props.getRowId;
295
295
  var enableClipboardPaste = (_ref4 = !props.disableClipboardPaste && ((_props$experimentalFe = props.experimentalFeatures) == null ? void 0 : _props$experimentalFe.clipboardPaste)) != null ? _ref4 : false;
296
296
  var rootEl = (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE.current;
297
+ var logger = useGridLogger(apiRef, 'useGridClipboardImport');
297
298
  var splitClipboardPastedText = props.unstable_splitClipboardPastedText;
299
+ var pagination = props.pagination,
300
+ onBeforeClipboardPasteStart = props.onBeforeClipboardPasteStart;
298
301
  var handlePaste = React.useCallback( /*#__PURE__*/function () {
299
302
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params, event) {
300
303
  var focusedCell, cellMode, text, pastedData, cellUpdater;
@@ -348,6 +351,24 @@ export var useGridClipboardImport = function useGridClipboardImport(apiRef, prop
348
351
  }
349
352
  return _context2.abrupt("return");
350
353
  case 19:
354
+ if (!onBeforeClipboardPasteStart) {
355
+ _context2.next = 29;
356
+ break;
357
+ }
358
+ _context2.prev = 20;
359
+ _context2.next = 23;
360
+ return onBeforeClipboardPasteStart({
361
+ data: pastedData
362
+ });
363
+ case 23:
364
+ _context2.next = 29;
365
+ break;
366
+ case 25:
367
+ _context2.prev = 25;
368
+ _context2.t0 = _context2["catch"](20);
369
+ logger.debug('Clipboard paste operation cancelled');
370
+ return _context2.abrupt("return");
371
+ case 29:
351
372
  cellUpdater = new CellValueUpdater({
352
373
  apiRef: apiRef,
353
374
  processRowUpdate: processRowUpdate,
@@ -363,19 +384,19 @@ export var useGridClipboardImport = function useGridClipboardImport(apiRef, prop
363
384
  updateCell: function updateCell() {
364
385
  cellUpdater.updateCell.apply(cellUpdater, arguments);
365
386
  },
366
- pagination: props.pagination
387
+ pagination: pagination
367
388
  });
368
389
  cellUpdater.applyUpdates();
369
- case 23:
390
+ case 33:
370
391
  case "end":
371
392
  return _context2.stop();
372
393
  }
373
- }, _callee2);
394
+ }, _callee2, null, [[20, 25]]);
374
395
  }));
375
396
  return function (_x3, _x4) {
376
397
  return _ref5.apply(this, arguments);
377
398
  };
378
- }(), [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, props.pagination]);
399
+ }(), [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
379
400
  var checkIfCanStartEditing = React.useCallback(function (initialValue, _ref6) {
380
401
  var event = _ref6.event;
381
402
  if (isPasteShortcut(event) && enableClipboardPaste) {
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.19.5
2
+ * @mui/x-data-grid-premium v6.19.8
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 var getReleaseInfo = function getReleaseInfo() {
3
- var releaseInfo = "MTcwODYyODQwMDAwMA==";
3
+ var releaseInfo = "MTcxMDg4NTYwMDAwMA==";
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
@@ -143,6 +143,16 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
143
143
  * @param {string} inProgress Indicates if the task is in progress.
144
144
  */
145
145
  onExcelExportStateChange?: (inProgress: 'pending' | 'finished') => void;
146
+ /**
147
+ * Callback fired before the clipboard paste operation starts.
148
+ * Use it to confirm or cancel the paste operation.
149
+ * @param {object} params Params passed to the callback.
150
+ * @param {string[][]} params.data The raw pasted data split by rows and cells.
151
+ * @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
152
+ */
153
+ onBeforeClipboardPasteStart?: (params: {
154
+ data: string[][];
155
+ }) => Promise<any>;
146
156
  /**
147
157
  * Callback fired when the clipboard paste operation starts.
148
158
  */
@@ -489,6 +489,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
489
489
  * @param {GridCallbackDetails} details Additional details for this callback.
490
490
  */
491
491
  onAggregationModelChange: PropTypes.func,
492
+ /**
493
+ * Callback fired before the clipboard paste operation starts.
494
+ * Use it to confirm or cancel the paste operation.
495
+ * @param {object} params Params passed to the callback.
496
+ * @param {string[][]} params.data The raw pasted data split by rows and cells.
497
+ * @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
498
+ */
499
+ onBeforeClipboardPasteStart: PropTypes.func,
492
500
  /**
493
501
  * Callback fired when any cell is clicked.
494
502
  * @param {GridCellParams} params With all properties from [[GridCellParams]].
@@ -2,7 +2,7 @@ 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
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 } from '@mui/x-data-grid-pro';
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';
6
6
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
7
7
  export const cellSelectionStateInitializer = (state, props) => _extends({}, state, {
8
8
  cellSelection: _extends({}, props.unstable_cellSelectionModel ?? props.initialState?.cellSelection)
@@ -19,6 +19,7 @@ export const useGridCellSelection = (apiRef, props) => {
19
19
  const lastMouseDownCell = React.useRef();
20
20
  const mousePosition = React.useRef(null);
21
21
  const autoScrollRAF = React.useRef();
22
+ const sortedRowIds = useGridSelector(apiRef, gridSortedRowIdsSelector);
22
23
  const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
23
24
  const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
24
25
  const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -436,7 +437,9 @@ export const useGridCellSelection = (apiRef, props) => {
436
437
  return value;
437
438
  }
438
439
  const cellSelectionModel = apiRef.current.unstable_getCellSelectionModel();
439
- const copyData = Object.keys(cellSelectionModel).reduce((acc, rowId) => {
440
+ const unsortedSelectedRowIds = Object.keys(cellSelectionModel);
441
+ const sortedSelectedRowIds = sortedRowIds.filter(id => unsortedSelectedRowIds.includes(`${id}`));
442
+ const copyData = sortedSelectedRowIds.reduce((acc, rowId) => {
440
443
  const fieldsMap = cellSelectionModel[rowId];
441
444
  const rowString = Object.keys(fieldsMap).reduce((acc2, field) => {
442
445
  let cellData;
@@ -444,7 +447,8 @@ export const useGridCellSelection = (apiRef, props) => {
444
447
  const cellParams = apiRef.current.getCellParams(rowId, field);
445
448
  cellData = serializeCellValue(cellParams, {
446
449
  delimiterCharacter: clipboardCopyCellDelimiter,
447
- ignoreValueFormatter
450
+ ignoreValueFormatter,
451
+ shouldAppendQuotes: true
448
452
  });
449
453
  } else {
450
454
  cellData = '';
@@ -454,7 +458,7 @@ export const useGridCellSelection = (apiRef, props) => {
454
458
  return acc === '' ? rowString : [acc, rowString].join('\r\n');
455
459
  }, '');
456
460
  return copyData;
457
- }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
461
+ }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter, sortedRowIds]);
458
462
  useGridRegisterPipeProcessor(apiRef, 'isCellSelected', checkIfCellIsSelected);
459
463
  useGridRegisterPipeProcessor(apiRef, 'cellClassName', addClassesToCells);
460
464
  useGridRegisterPipeProcessor(apiRef, 'canUpdateFocus', canUpdateFocus);
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector } from '@mui/x-data-grid';
3
+ import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector, useGridLogger } from '@mui/x-data-grid';
4
4
  import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef } 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';
@@ -247,7 +247,12 @@ export const useGridClipboardImport = (apiRef, props) => {
247
247
  const getRowId = props.getRowId;
248
248
  const enableClipboardPaste = (!props.disableClipboardPaste && props.experimentalFeatures?.clipboardPaste) ?? false;
249
249
  const rootEl = apiRef.current.rootElementRef?.current;
250
+ const logger = useGridLogger(apiRef, 'useGridClipboardImport');
250
251
  const splitClipboardPastedText = props.unstable_splitClipboardPastedText;
252
+ const {
253
+ pagination,
254
+ onBeforeClipboardPasteStart
255
+ } = props;
251
256
  const handlePaste = React.useCallback(async (params, event) => {
252
257
  if (!enableClipboardPaste) {
253
258
  return;
@@ -274,6 +279,16 @@ export const useGridClipboardImport = (apiRef, props) => {
274
279
  if (!pastedData) {
275
280
  return;
276
281
  }
282
+ if (onBeforeClipboardPasteStart) {
283
+ try {
284
+ await onBeforeClipboardPasteStart({
285
+ data: pastedData
286
+ });
287
+ } catch (error) {
288
+ logger.debug('Clipboard paste operation cancelled');
289
+ return;
290
+ }
291
+ }
277
292
  const cellUpdater = new CellValueUpdater({
278
293
  apiRef,
279
294
  processRowUpdate,
@@ -289,10 +304,10 @@ export const useGridClipboardImport = (apiRef, props) => {
289
304
  updateCell: (...args) => {
290
305
  cellUpdater.updateCell(...args);
291
306
  },
292
- pagination: props.pagination
307
+ pagination
293
308
  });
294
309
  cellUpdater.applyUpdates();
295
- }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, props.pagination]);
310
+ }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
296
311
  const checkIfCanStartEditing = React.useCallback((initialValue, {
297
312
  event
298
313
  }) => {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.19.5
2
+ * @mui/x-data-grid-premium v6.19.8
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 = "MTcwODYyODQwMDAwMA==";
3
+ const releaseInfo = "MTcxMDg4NTYwMDAwMA==";
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
@@ -497,6 +497,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
497
497
  * @param {GridCallbackDetails} details Additional details for this callback.
498
498
  */
499
499
  onAggregationModelChange: _propTypes.default.func,
500
+ /**
501
+ * Callback fired before the clipboard paste operation starts.
502
+ * Use it to confirm or cancel the paste operation.
503
+ * @param {object} params Params passed to the callback.
504
+ * @param {string[][]} params.data The raw pasted data split by rows and cells.
505
+ * @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
506
+ */
507
+ onBeforeClipboardPasteStart: _propTypes.default.func,
500
508
  /**
501
509
  * Callback fired when any cell is clicked.
502
510
  * @param {GridCellParams} params With all properties from [[GridCellParams]].
@@ -29,6 +29,7 @@ const useGridCellSelection = (apiRef, props) => {
29
29
  const lastMouseDownCell = React.useRef();
30
30
  const mousePosition = React.useRef(null);
31
31
  const autoScrollRAF = React.useRef();
32
+ const sortedRowIds = (0, _xDataGridPro.useGridSelector)(apiRef, _xDataGridPro.gridSortedRowIdsSelector);
32
33
  const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
33
34
  const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
34
35
  const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -446,7 +447,9 @@ const useGridCellSelection = (apiRef, props) => {
446
447
  return value;
447
448
  }
448
449
  const cellSelectionModel = apiRef.current.unstable_getCellSelectionModel();
449
- const copyData = Object.keys(cellSelectionModel).reduce((acc, rowId) => {
450
+ const unsortedSelectedRowIds = Object.keys(cellSelectionModel);
451
+ const sortedSelectedRowIds = sortedRowIds.filter(id => unsortedSelectedRowIds.includes(`${id}`));
452
+ const copyData = sortedSelectedRowIds.reduce((acc, rowId) => {
450
453
  const fieldsMap = cellSelectionModel[rowId];
451
454
  const rowString = Object.keys(fieldsMap).reduce((acc2, field) => {
452
455
  let cellData;
@@ -454,7 +457,8 @@ const useGridCellSelection = (apiRef, props) => {
454
457
  const cellParams = apiRef.current.getCellParams(rowId, field);
455
458
  cellData = (0, _internals.serializeCellValue)(cellParams, {
456
459
  delimiterCharacter: clipboardCopyCellDelimiter,
457
- ignoreValueFormatter
460
+ ignoreValueFormatter,
461
+ shouldAppendQuotes: true
458
462
  });
459
463
  } else {
460
464
  cellData = '';
@@ -464,7 +468,7 @@ const useGridCellSelection = (apiRef, props) => {
464
468
  return acc === '' ? rowString : [acc, rowString].join('\r\n');
465
469
  }, '');
466
470
  return copyData;
467
- }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
471
+ }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter, sortedRowIds]);
468
472
  (0, _internals.useGridRegisterPipeProcessor)(apiRef, 'isCellSelected', checkIfCellIsSelected);
469
473
  (0, _internals.useGridRegisterPipeProcessor)(apiRef, 'cellClassName', addClassesToCells);
470
474
  (0, _internals.useGridRegisterPipeProcessor)(apiRef, 'canUpdateFocus', canUpdateFocus);
@@ -256,7 +256,12 @@ const useGridClipboardImport = (apiRef, props) => {
256
256
  const getRowId = props.getRowId;
257
257
  const enableClipboardPaste = (!props.disableClipboardPaste && props.experimentalFeatures?.clipboardPaste) ?? false;
258
258
  const rootEl = apiRef.current.rootElementRef?.current;
259
+ const logger = (0, _xDataGrid.useGridLogger)(apiRef, 'useGridClipboardImport');
259
260
  const splitClipboardPastedText = props.unstable_splitClipboardPastedText;
261
+ const {
262
+ pagination,
263
+ onBeforeClipboardPasteStart
264
+ } = props;
260
265
  const handlePaste = React.useCallback(async (params, event) => {
261
266
  if (!enableClipboardPaste) {
262
267
  return;
@@ -283,6 +288,16 @@ const useGridClipboardImport = (apiRef, props) => {
283
288
  if (!pastedData) {
284
289
  return;
285
290
  }
291
+ if (onBeforeClipboardPasteStart) {
292
+ try {
293
+ await onBeforeClipboardPasteStart({
294
+ data: pastedData
295
+ });
296
+ } catch (error) {
297
+ logger.debug('Clipboard paste operation cancelled');
298
+ return;
299
+ }
300
+ }
286
301
  const cellUpdater = new CellValueUpdater({
287
302
  apiRef,
288
303
  processRowUpdate,
@@ -298,10 +313,10 @@ const useGridClipboardImport = (apiRef, props) => {
298
313
  updateCell: (...args) => {
299
314
  cellUpdater.updateCell(...args);
300
315
  },
301
- pagination: props.pagination
316
+ pagination
302
317
  });
303
318
  cellUpdater.applyUpdates();
304
- }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, props.pagination]);
319
+ }, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
305
320
  const checkIfCanStartEditing = React.useCallback((initialValue, {
306
321
  event
307
322
  }) => {
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.19.5
2
+ * @mui/x-data-grid-premium v6.19.8
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -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 = "MTcwODYyODQwMDAwMA==";
9
+ const releaseInfo = "MTcxMDg4NTYwMDAwMA==";
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-premium",
3
- "version": "6.19.5",
3
+ "version": "6.19.8",
4
4
  "description": "The Premium plan edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.23.2",
35
35
  "@mui/utils": "^5.14.16",
36
- "@mui/x-data-grid": "6.19.5",
37
- "@mui/x-data-grid-pro": "6.19.5",
36
+ "@mui/x-data-grid": "6.19.8",
37
+ "@mui/x-data-grid-pro": "6.19.8",
38
38
  "@mui/x-license-pro": "6.10.2",
39
39
  "@types/format-util": "^1.0.3",
40
40
  "clsx": "^2.0.0",
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcwODYyODQwMDAwMA==";
3
+ const releaseInfo = "MTcxMDg4NTYwMDAwMA==";
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