@mui/x-data-grid 6.3.0 → 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 (148) hide show
  1. package/CHANGELOG.md +105 -2
  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/GridPagination.js +3 -1
  9. package/components/base/GridBody.d.ts +1 -0
  10. package/components/base/GridBody.js +6 -3
  11. package/components/containers/GridRootStyles.js +1 -0
  12. package/components/panel/GridPanel.d.ts +2 -1
  13. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  14. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  15. package/components/toolbar/GridToolbarFilterButton.js +3 -1
  16. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
  17. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
  18. package/hooks/features/clipboard/useGridClipboard.js +43 -26
  19. package/hooks/features/dimensions/useGridDimensions.js +2 -4
  20. package/hooks/features/editing/useGridCellEditing.js +7 -3
  21. package/hooks/features/editing/useGridRowEditing.js +7 -3
  22. package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
  23. package/hooks/features/export/serializers/csvSerializer.js +46 -6
  24. package/hooks/features/export/useGridCsvExport.d.ts +2 -1
  25. package/hooks/features/export/useGridCsvExport.js +7 -5
  26. package/hooks/features/focus/useGridFocus.js +2 -2
  27. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  28. package/index.js +1 -1
  29. package/internals/index.d.ts +3 -2
  30. package/internals/index.js +3 -2
  31. package/joy/icons.d.ts +33 -0
  32. package/joy/icons.js +433 -0
  33. package/joy/joySlots.js +254 -42
  34. package/legacy/DataGrid/DataGrid.js +20 -1
  35. package/legacy/DataGrid/useDataGridComponent.js +2 -2
  36. package/legacy/DataGrid/useDataGridProps.js +3 -1
  37. package/legacy/colDef/gridBooleanColDef.js +21 -1
  38. package/legacy/colDef/gridDateColDef.js +10 -2
  39. package/legacy/colDef/gridSingleSelectColDef.js +21 -1
  40. package/legacy/components/GridPagination.js +3 -1
  41. package/legacy/components/base/GridBody.js +6 -3
  42. package/legacy/components/containers/GridRootStyles.js +1 -0
  43. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  44. package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  45. package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
  46. package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
  47. package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -4
  48. package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
  49. package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
  50. package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
  51. package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
  52. package/legacy/hooks/features/focus/useGridFocus.js +2 -2
  53. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -0
  54. package/legacy/index.js +1 -1
  55. package/legacy/internals/index.js +3 -2
  56. package/legacy/joy/icons.js +432 -0
  57. package/legacy/joy/joySlots.js +273 -54
  58. package/legacy/locales/deDE.js +2 -2
  59. package/legacy/locales/frFR.js +6 -6
  60. package/legacy/locales/ptBR.js +1 -1
  61. package/legacy/locales/ukUA.js +8 -9
  62. package/legacy/material/index.js +3 -1
  63. package/legacy/models/api/index.js +0 -1
  64. package/legacy/utils/domUtils.js +14 -1
  65. package/locales/deDE.js +2 -2
  66. package/locales/frFR.js +6 -6
  67. package/locales/ptBR.js +1 -1
  68. package/locales/ukUA.js +8 -9
  69. package/material/index.d.ts +3 -1
  70. package/material/index.js +3 -1
  71. package/models/api/gridApiCommon.d.ts +1 -2
  72. package/models/api/gridCoreApi.d.ts +4 -0
  73. package/models/api/index.d.ts +0 -1
  74. package/models/api/index.js +0 -1
  75. package/models/events/gridEventLookup.d.ts +6 -0
  76. package/models/gridSlotsComponent.d.ts +5 -0
  77. package/models/gridSlotsComponentsProps.d.ts +4 -0
  78. package/models/props/DataGridProps.d.ts +19 -0
  79. package/modern/DataGrid/DataGrid.js +20 -1
  80. package/modern/DataGrid/useDataGridComponent.js +2 -2
  81. package/modern/DataGrid/useDataGridProps.js +3 -1
  82. package/modern/colDef/gridBooleanColDef.js +19 -1
  83. package/modern/colDef/gridDateColDef.js +6 -2
  84. package/modern/colDef/gridSingleSelectColDef.js +21 -1
  85. package/modern/components/GridPagination.js +2 -1
  86. package/modern/components/base/GridBody.js +6 -3
  87. package/modern/components/containers/GridRootStyles.js +1 -0
  88. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  89. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  90. package/modern/components/toolbar/GridToolbarFilterButton.js +3 -1
  91. package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
  92. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
  93. package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
  94. package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
  95. package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
  96. package/modern/hooks/features/export/useGridCsvExport.js +7 -5
  97. package/modern/hooks/features/focus/useGridFocus.js +2 -2
  98. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  99. package/modern/index.js +1 -1
  100. package/modern/internals/index.js +3 -2
  101. package/modern/joy/icons.js +433 -0
  102. package/modern/joy/joySlots.js +248 -41
  103. package/modern/locales/deDE.js +2 -2
  104. package/modern/locales/frFR.js +6 -6
  105. package/modern/locales/ptBR.js +1 -1
  106. package/modern/locales/ukUA.js +8 -9
  107. package/modern/material/index.js +3 -1
  108. package/modern/models/api/index.js +0 -1
  109. package/modern/utils/domUtils.js +13 -1
  110. package/node/DataGrid/DataGrid.js +20 -1
  111. package/node/DataGrid/useDataGridComponent.js +2 -2
  112. package/node/DataGrid/useDataGridProps.js +3 -1
  113. package/node/colDef/gridBooleanColDef.js +19 -1
  114. package/node/colDef/gridDateColDef.js +6 -2
  115. package/node/colDef/gridSingleSelectColDef.js +21 -1
  116. package/node/components/GridPagination.js +2 -1
  117. package/node/components/base/GridBody.js +6 -3
  118. package/node/components/containers/GridRootStyles.js +1 -0
  119. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  120. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  121. package/node/components/toolbar/GridToolbarFilterButton.js +3 -1
  122. package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
  123. package/node/hooks/features/dimensions/useGridDimensions.js +1 -3
  124. package/node/hooks/features/editing/useGridCellEditing.js +7 -3
  125. package/node/hooks/features/editing/useGridRowEditing.js +7 -3
  126. package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
  127. package/node/hooks/features/export/useGridCsvExport.js +6 -3
  128. package/node/hooks/features/focus/useGridFocus.js +2 -2
  129. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  130. package/node/index.js +1 -1
  131. package/node/internals/index.js +23 -1
  132. package/node/joy/icons.js +471 -0
  133. package/node/joy/joySlots.js +248 -40
  134. package/node/locales/deDE.js +2 -2
  135. package/node/locales/frFR.js +6 -6
  136. package/node/locales/ptBR.js +1 -1
  137. package/node/locales/ukUA.js +8 -9
  138. package/node/material/index.js +3 -1
  139. package/node/models/api/index.js +0 -11
  140. package/node/utils/domUtils.js +15 -1
  141. package/package.json +2 -2
  142. package/utils/domUtils.d.ts +1 -0
  143. package/utils/domUtils.js +13 -1
  144. package/legacy/models/api/gridClipboardApi.js +0 -1
  145. package/models/api/gridClipboardApi.d.ts +0 -11
  146. package/models/api/gridClipboardApi.js +0 -1
  147. package/modern/models/api/gridClipboardApi.js +0 -1
  148. package/node/models/api/gridClipboardApi.js +0 -5
package/locales/ukUA.js CHANGED
@@ -51,7 +51,7 @@ const ukUAGrid = {
51
51
  columnsPanelHideAllButton: 'Приховати всі',
52
52
  // Filter panel text
53
53
  filterPanelAddFilter: 'Додати фільтр',
54
- // filterPanelRemoveAll: 'Remove all',
54
+ filterPanelRemoveAll: 'Видалити всі',
55
55
  filterPanelDeleteIconLabel: 'Видалити',
56
56
  filterPanelLogicOperator: 'Логічна функція',
57
57
  filterPanelOperator: 'Оператори',
@@ -81,7 +81,7 @@ const ukUAGrid = {
81
81
  // Column menu text
82
82
  columnMenuLabel: 'Меню',
83
83
  columnMenuShowColumns: 'Показати стовпці',
84
- // columnMenuManageColumns: 'Manage columns',
84
+ columnMenuManageColumns: 'Керування стовпцями',
85
85
  columnMenuFilter: 'Фільтр',
86
86
  columnMenuHideColumn: 'Приховати',
87
87
  columnMenuUnsort: 'Скасувати сортування',
@@ -135,12 +135,11 @@ const ukUAGrid = {
135
135
  // Row reordering text
136
136
  rowReorderingHeaderName: 'Порядок рядків',
137
137
  // Aggregation
138
- aggregationMenuItemHeader: 'Агрегація'
139
- // aggregationFunctionLabelSum: 'sum',
140
- // aggregationFunctionLabelAvg: 'avg',
141
- // aggregationFunctionLabelMin: 'min',
142
- // aggregationFunctionLabelMax: 'max',
143
- // aggregationFunctionLabelSize: 'size',
138
+ aggregationMenuItemHeader: 'Агрегація',
139
+ aggregationFunctionLabelSum: 'сума',
140
+ aggregationFunctionLabelAvg: 'сер',
141
+ aggregationFunctionLabelMin: 'мін',
142
+ aggregationFunctionLabelMax: 'макс',
143
+ aggregationFunctionLabelSize: 'кількість'
144
144
  };
145
-
146
145
  export const ukUA = getGridLocalization(ukUAGrid, ukUACore);
@@ -15,7 +15,8 @@ declare const materialSlots: {
15
15
  BaseButton: import("@mui/material").ExtendButtonBase<import("@mui/material/Button").ButtonTypeMap<{}, "button">>;
16
16
  BaseIconButton: import("@mui/material").ExtendButtonBase<import("@mui/material/IconButton").IconButtonTypeMap<{}, "button">>;
17
17
  BaseTooltip: typeof MUITooltip;
18
- BasePopper: import("react").ForwardRefExoticComponent<Omit<import("@mui/base").PopperProps<"div", {}>, "direction"> & {
18
+ BasePopper: import("react").ForwardRefExoticComponent<Omit<import("@mui/base").PopperProps<"div">, "direction"> & {
19
+ component?: import("react").ElementType<any> | undefined;
19
20
  components?: {
20
21
  Root?: import("react").ElementType<any> | undefined;
21
22
  } | undefined;
@@ -26,6 +27,7 @@ declare const materialSlots: {
26
27
  } & import("react").RefAttributes<HTMLDivElement>>;
27
28
  BaseInputLabel: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/InputLabel").InputLabelTypeMap<{}, "label">>;
28
29
  BaseSelectOption: typeof MUISelectOption;
30
+ BaseChip: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/Chip").ChipTypeMap<{}, "div">>;
29
31
  BooleanCellTrueIcon: import("react").JSXElementConstructor<any>;
30
32
  BooleanCellFalseIcon: import("react").JSXElementConstructor<any>;
31
33
  ColumnMenuIcon: import("react").JSXElementConstructor<any>;
package/material/index.js CHANGED
@@ -9,6 +9,7 @@ import MUIIconButton from '@mui/material/IconButton';
9
9
  import MUITooltip from '@mui/material/Tooltip';
10
10
  import MUIPopper from '@mui/material/Popper';
11
11
  import MUIInputLabel from '@mui/material/InputLabel';
12
+ import MUIChip from '@mui/material/Chip';
12
13
  import { GridColumnUnsortedIcon } from './icons/GridColumnUnsortedIcon';
13
14
  import { GridAddIcon, GridArrowDownwardIcon, GridArrowUpwardIcon, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridDragIcon, GridExpandMoreIcon, GridFilterAltIcon, GridFilterListIcon, GridKeyboardArrowRight, GridMoreVertIcon, GridRemoveIcon, GridSaveAltIcon, GridSearchIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridVisibilityOffIcon, GridViewColumnIcon, GridClearIcon, GridLoadIcon, GridDeleteForeverIcon } from './icons';
14
15
  import MUISelectOption from './components/MUISelectOption';
@@ -60,6 +61,7 @@ const materialSlots = _extends({}, iconSlots, {
60
61
  BaseTooltip: MUITooltip,
61
62
  BasePopper: MUIPopper,
62
63
  BaseInputLabel: MUIInputLabel,
63
- BaseSelectOption: MUISelectOption
64
+ BaseSelectOption: MUISelectOption,
65
+ BaseChip: MUIChip
64
66
  });
65
67
  export default materialSlots;
@@ -1,7 +1,6 @@
1
1
  import { GridColumnApi } from './gridColumnApi';
2
2
  import { GridColumnMenuApi } from './gridColumnMenuApi';
3
3
  import { GridCoreApi, GridCorePrivateApi } from './gridCoreApi';
4
- import { GridClipboardApi } from './gridClipboardApi';
5
4
  import { GridCsvExportApi } from './gridCsvExportApi';
6
5
  import { GridDensityApi } from './gridDensityApi';
7
6
  import { GridEditingApi, GridEditingPrivateApi } from './gridEditingApi';
@@ -28,7 +27,7 @@ import type { GridPaginationApi } from '../../hooks/features/pagination';
28
27
  import type { GridStatePersistenceApi } from '../../hooks/features/statePersistence';
29
28
  import { GridColumnGroupingApi } from './gridColumnGroupingApi';
30
29
  import type { GridInitialStateCommunity, GridStateCommunity } from '../gridStateCommunity';
31
- export interface GridApiCommon<GridState extends GridStateCommunity = any, GridInitialState extends GridInitialStateCommunity = any> extends GridCoreApi, GridPipeProcessingApi, GridDensityApi, GridDimensionsApi, GridRowApi, GridRowsMetaApi, GridEditingApi, GridParamsApi, GridColumnApi, GridRowSelectionApi, GridSortApi, GridPaginationApi, GridCsvExportApi, GridFocusApi, GridFilterApi, GridColumnMenuApi, GridPreferencesPanelApi, GridPrintExportApi, GridDisableVirtualizationApi, GridLocaleTextApi, GridClipboardApi, GridScrollApi, GridColumnSpanningApi, GridStateApi<GridState>, GridStatePersistenceApi<GridInitialState>, GridColumnGroupingApi {
30
+ export interface GridApiCommon<GridState extends GridStateCommunity = any, GridInitialState extends GridInitialStateCommunity = any> extends GridCoreApi, GridPipeProcessingApi, GridDensityApi, GridDimensionsApi, GridRowApi, GridRowsMetaApi, GridEditingApi, GridParamsApi, GridColumnApi, GridRowSelectionApi, GridSortApi, GridPaginationApi, GridCsvExportApi, GridFocusApi, GridFilterApi, GridColumnMenuApi, GridPreferencesPanelApi, GridPrintExportApi, GridDisableVirtualizationApi, GridLocaleTextApi, GridScrollApi, GridColumnSpanningApi, GridStateApi<GridState>, GridStatePersistenceApi<GridInitialState>, GridColumnGroupingApi {
32
31
  }
33
32
  export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon> extends GridCorePrivateApi<Api, PrivateApi>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridVirtualScrollerApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi {
34
33
  }
@@ -53,6 +53,10 @@ export interface GridCorePrivateApi<GridPublicApi extends GridApiCommon, GridPri
53
53
  * The React ref of the grid virtual scroller container element.
54
54
  */
55
55
  virtualScrollerRef?: React.RefObject<HTMLDivElement>;
56
+ /**
57
+ * The React ref of the grid main container div element.
58
+ */
59
+ mainElementRef?: React.RefObject<HTMLDivElement>;
56
60
  register: <V extends 'public' | 'private', T extends V extends 'public' ? Partial<GridPublicApi> : Partial<Omit<GridPrivateApi, keyof GridPublicApi>>>(visibility: V, methods: T) => void;
57
61
  /**
58
62
  * Returns the public API.
@@ -16,7 +16,6 @@ export * from './gridColumnMenuApi';
16
16
  export * from './gridPreferencesPanelApi';
17
17
  export * from './gridPrintExportApi';
18
18
  export * from './gridDisableVirtualizationApi';
19
- export * from './gridClipboardApi';
20
19
  export * from './gridCallbackDetails';
21
20
  export * from './gridScrollApi';
22
21
  export * from './gridVirtualScrollerApi';
@@ -11,7 +11,6 @@ export * from './gridColumnMenuApi';
11
11
  export * from './gridPreferencesPanelApi';
12
12
  export * from './gridPrintExportApi';
13
13
  export * from './gridDisableVirtualizationApi';
14
- export * from './gridClipboardApi';
15
14
  export * from './gridCallbackDetails';
16
15
  export * from './gridScrollApi';
17
16
  export * from './gridVirtualScrollerApi';
@@ -541,6 +541,12 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
541
541
  params: GridRowSelectionCheckboxParams;
542
542
  event: React.ChangeEvent<HTMLElement>;
543
543
  };
544
+ /**
545
+ * Fired when the data is copied to the clipboard
546
+ */
547
+ clipboardCopy: {
548
+ params: string;
549
+ };
544
550
  /**
545
551
  * Fired when the preference panel is closed.
546
552
  */
@@ -60,6 +60,11 @@ export interface GridSlotsComponent extends GridIconSlotsComponent {
60
60
  * @default MenuItem
61
61
  */
62
62
  BaseSelectOption: React.JSXElementConstructor<any>;
63
+ /**
64
+ * The custom Chip component used in the grid.
65
+ * @default Chip
66
+ */
67
+ BaseChip: React.JSXElementConstructor<any>;
63
68
  /**
64
69
  * Component rendered for each cell.
65
70
  * @default GridCell
@@ -10,6 +10,7 @@ import { TooltipProps } from '@mui/material/Tooltip';
10
10
  import type { InputLabelProps } from '@mui/material/InputLabel';
11
11
  import { PopperProps } from '@mui/material/Popper';
12
12
  import { TablePaginationProps } from '@mui/material/TablePagination';
13
+ import { ChipProps } from '@mui/material/Chip';
13
14
  import { GridToolbarProps } from '../components/toolbar/GridToolbar';
14
15
  import { ColumnHeaderFilterIconButtonProps } from '../components/columnHeaders/GridColumnHeaderFilterIconButton';
15
16
  import { GridColumnMenuProps } from '../components/menu/columnMenu/GridColumnMenuProps';
@@ -42,6 +43,8 @@ export interface BaseInputLabelPropsOverrides {
42
43
  }
43
44
  export interface BaseSelectOptionPropsOverrides {
44
45
  }
46
+ export interface BaseChipPropsOverrides {
47
+ }
45
48
  export interface CellPropsOverrides {
46
49
  }
47
50
  export interface ToolbarPropsOverrides {
@@ -90,6 +93,7 @@ export interface GridSlotsComponentsProps {
90
93
  value: any;
91
94
  children?: React.ReactNode;
92
95
  }, BaseSelectOptionPropsOverrides>;
96
+ baseChip?: SlotProps<ChipProps, BaseChipPropsOverrides>;
93
97
  cell?: SlotProps<GridCellProps, CellPropsOverrides>;
94
98
  columnHeaderFilterIconButton?: SlotProps<ColumnHeaderFilterIconButtonProps, ColumnHeaderFilterIconButtonPropsOverrides>;
95
99
  columnMenu?: SlotProps<GridColumnMenuProps, ColumnMenuPropsOverrides>;
@@ -306,6 +306,20 @@ export interface DataGridPropsWithDefaultValues {
306
306
  * @default false
307
307
  */
308
308
  keepColumnPositionIfDraggedOutside: boolean;
309
+ /**
310
+ * If `true`, the grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
311
+ * If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
312
+ * @default: false
313
+ */
314
+ unstable_ignoreValueFormatterDuringExport: boolean | {
315
+ csvExport?: boolean;
316
+ clipboardExport?: boolean;
317
+ };
318
+ /**
319
+ * The character used to separate cell values when copying to the clipboard.
320
+ * @default '\t'
321
+ */
322
+ clipboardCopyCellDelimiter: string;
309
323
  }
310
324
  /**
311
325
  * The `DataGrid` props with no default value.
@@ -679,4 +693,9 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
679
693
  */
680
694
  onProcessRowUpdateError?: (error: any) => void;
681
695
  columnGroupingModel?: GridColumnGroupingModel;
696
+ /**
697
+ * Callback called when the data is copied to the clipboard.
698
+ * @param {string} data The data copied to the clipboard.
699
+ */
700
+ onClipboardCopy?: GridEventListener<'clipboardCopy'>;
682
701
  }
@@ -68,6 +68,11 @@ DataGridRaw.propTypes = {
68
68
  * Override or extend the styles applied to the component.
69
69
  */
70
70
  classes: PropTypes.object,
71
+ /**
72
+ * The character used to separate cell values when copying to the clipboard.
73
+ * @default '\t'
74
+ */
75
+ clipboardCopyCellDelimiter: PropTypes.string,
71
76
  /**
72
77
  * Number of extra columns to be rendered before/after the visible slice.
73
78
  * @default 3
@@ -326,6 +331,11 @@ DataGridRaw.propTypes = {
326
331
  * @param {GridCallbackDetails} details Additional details for this callback.
327
332
  */
328
333
  onCellModesModelChange: PropTypes.func,
334
+ /**
335
+ * Callback called when the data is copied to the clipboard.
336
+ * @param {string} data The data copied to the clipboard.
337
+ */
338
+ onClipboardCopy: PropTypes.func,
329
339
  /**
330
340
  * Callback fired when a click event comes from a column header element.
331
341
  * @param {GridColumnHeaderParams} params With all properties from [[GridColumnHeaderParams]].
@@ -611,5 +621,14 @@ DataGridRaw.propTypes = {
611
621
  /**
612
622
  * The system prop that allows defining system overrides as well as additional CSS styles.
613
623
  */
614
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
624
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
625
+ /**
626
+ * If `true`, the grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
627
+ * If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
628
+ * @default: false
629
+ */
630
+ unstable_ignoreValueFormatterDuringExport: PropTypes.oneOfType([PropTypes.shape({
631
+ clipboardExport: PropTypes.bool,
632
+ csvExport: PropTypes.bool
633
+ }), PropTypes.bool])
615
634
  };
@@ -67,9 +67,9 @@ export const useDataGridComponent = (inputApiRef, props) => {
67
67
  useGridRowsMeta(privateApiRef, props);
68
68
  useGridScroll(privateApiRef, props);
69
69
  useGridColumnMenu(privateApiRef);
70
- useGridCsvExport(privateApiRef);
70
+ useGridCsvExport(privateApiRef, props);
71
71
  useGridPrintExport(privateApiRef, props);
72
- useGridClipboard(privateApiRef);
72
+ useGridClipboard(privateApiRef, props);
73
73
  useGridDimensions(privateApiRef, props);
74
74
  useGridEvents(privateApiRef, props);
75
75
  useGridStatePersistence(privateApiRef);
@@ -66,7 +66,9 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
66
66
  disableColumnReorder: false,
67
67
  disableColumnResize: false,
68
68
  keepNonExistentRowsSelected: false,
69
- keepColumnPositionIfDraggedOutside: false
69
+ keepColumnPositionIfDraggedOutside: false,
70
+ unstable_ignoreValueFormatterDuringExport: false,
71
+ clipboardCopyCellDelimiter: '\t'
70
72
  };
71
73
  const defaultSlots = uncapitalizeObjectKeys(DATA_GRID_DEFAULT_SLOTS_COMPONENTS);
72
74
  export const useDataGridProps = inProps => {
@@ -10,6 +10,22 @@ function gridBooleanFormatter({
10
10
  }) {
11
11
  return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
12
12
  }
13
+ const stringToBoolean = value => {
14
+ switch (value.toLowerCase().trim()) {
15
+ case 'true':
16
+ case 'yes':
17
+ case '1':
18
+ return true;
19
+ case 'false':
20
+ case 'no':
21
+ case '0':
22
+ case 'null':
23
+ case 'undefined':
24
+ return false;
25
+ default:
26
+ return undefined;
27
+ }
28
+ };
13
29
  export const GRID_BOOLEAN_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
14
30
  type: 'boolean',
15
31
  align: 'center',
@@ -21,5 +37,7 @@ export const GRID_BOOLEAN_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
21
37
  filterOperators: getGridBooleanOperators(),
22
38
  getApplyQuickFilterFn: undefined,
23
39
  // @ts-ignore
24
- aggregable: false
40
+ aggregable: false,
41
+ // @ts-ignore
42
+ pastedValueParser: value => stringToBoolean(value)
25
43
  });
@@ -51,7 +51,9 @@ export const GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
51
51
  valueFormatter: gridDateFormatter,
52
52
  filterOperators: getGridDateOperators(),
53
53
  renderEditCell: renderEditDateCell,
54
- getApplyQuickFilterFn: undefined
54
+ getApplyQuickFilterFn: undefined,
55
+ // @ts-ignore
56
+ pastedValueParser: value => new Date(value)
55
57
  });
56
58
  export const GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
57
59
  type: 'dateTime',
@@ -59,5 +61,7 @@ export const GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
59
61
  valueFormatter: gridDateTimeFormatter,
60
62
  filterOperators: getGridDateOperators(true),
61
63
  renderEditCell: renderEditDateCell,
62
- getApplyQuickFilterFn: undefined
64
+ getApplyQuickFilterFn: undefined,
65
+ // @ts-ignore
66
+ pastedValueParser: value => new Date(value)
63
67
  });
@@ -51,5 +51,25 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
51
51
  return valueOption ? colDef.getOptionLabel(valueOption) : '';
52
52
  },
53
53
  renderEditCell: renderEditSingleSelectCell,
54
- filterOperators: getGridSingleSelectOperators()
54
+ filterOperators: getGridSingleSelectOperators(),
55
+ // @ts-ignore
56
+ pastedValueParser: (value, params) => {
57
+ const colDef = params.colDef;
58
+ const colDefValueOptions = colDef.valueOptions;
59
+ const valueOptions = typeof colDefValueOptions === 'function' ? colDefValueOptions({
60
+ field: colDef.field
61
+ }) : colDefValueOptions || [];
62
+ const getOptionValue = colDef.getOptionValue;
63
+ const valueOption = valueOptions.find(option => {
64
+ if (getOptionValue(option) === value) {
65
+ return true;
66
+ }
67
+ return false;
68
+ });
69
+ if (valueOption) {
70
+ return value;
71
+ }
72
+ // do not paste the value if it is not in the valueOptions
73
+ return undefined;
74
+ }
55
75
  });
@@ -41,7 +41,8 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
41
41
  if (process.env.NODE_ENV !== 'production') {
42
42
  // eslint-disable-next-line react-hooks/rules-of-hooks
43
43
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
44
- if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(paginationModel.pageSize)) {
44
+ const pageSize = rootProps.paginationModel?.pageSize ?? paginationModel.pageSize;
45
+ if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
45
46
  console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
46
47
  warnedOnceMissingInPageSizeOptions.current = true;
47
48
  }
@@ -18,7 +18,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
18
18
  function GridBody(props) {
19
19
  const {
20
20
  VirtualScrollerComponent,
21
- ColumnHeadersProps
21
+ ColumnHeadersProps,
22
+ children
22
23
  } = props;
23
24
  const apiRef = useGridPrivateApiContext();
24
25
  const rootProps = useGridRootProps();
@@ -88,7 +89,8 @@ function GridBody(props) {
88
89
  apiRef.current.register('private', {
89
90
  columnHeadersContainerElementRef: columnsContainerRef,
90
91
  columnHeadersElementRef: columnHeadersRef,
91
- virtualScrollerRef
92
+ virtualScrollerRef,
93
+ mainElementRef: rootRef
92
94
  });
93
95
  const hasDimensions = !!apiRef.current.getRootDimensions();
94
96
  return /*#__PURE__*/_jsxs(GridMainContainer, {
@@ -119,7 +121,7 @@ function GridBody(props) {
119
121
  , {
120
122
  ref: virtualScrollerRef,
121
123
  disableVirtualization: isVirtualizationDisabled
122
- })]
124
+ }), children]
123
125
  });
124
126
  }
125
127
  process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
@@ -127,6 +129,7 @@ process.env.NODE_ENV !== "production" ? GridBody.propTypes = {
127
129
  // | These PropTypes are generated from the TypeScript type definitions |
128
130
  // | To update them edit the TypeScript types and run "yarn proptypes" |
129
131
  // ----------------------------------------------------------------------
132
+ children: PropTypes.node,
130
133
  ColumnHeadersProps: PropTypes.object,
131
134
  VirtualScrollerComponent: PropTypes.elementType.isRequired
132
135
  } : void 0;
@@ -149,6 +149,7 @@ export const GridRootStyles = styled('div', {
149
149
  outline: 'none',
150
150
  height: '100%',
151
151
  display: 'flex',
152
+ overflow: 'hidden',
152
153
  flexDirection: 'column',
153
154
  overflowAnchor: 'none',
154
155
  // Keep the same scrolling position
@@ -4,7 +4,6 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "c
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
7
- import Chip from '@mui/material/Chip';
8
7
  import { unstable_useId as useId } from '@mui/utils';
9
8
  import { isSingleSelectColDef } from './filterPanelUtils';
10
9
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
@@ -96,7 +95,7 @@ function GridFilterInputMultipleSingleSelect(props) {
96
95
  value: filteredValues,
97
96
  onChange: handleChange,
98
97
  getOptionLabel: getOptionLabel,
99
- renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/_jsx(Chip, _extends({
98
+ renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/_jsx(rootProps.slots.baseChip, _extends({
100
99
  variant: "outlined",
101
100
  size: "small",
102
101
  label: getOptionLabel(option)
@@ -4,7 +4,6 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "c
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import Autocomplete from '@mui/material/Autocomplete';
7
- import Chip from '@mui/material/Chip';
8
7
  import { unstable_useId as useId } from '@mui/utils';
9
8
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
10
9
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -55,7 +54,7 @@ function GridFilterInputMultipleValue(props) {
55
54
  id: id,
56
55
  value: filterValueState,
57
56
  onChange: handleChange,
58
- renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/_jsx(Chip, _extends({
57
+ renderTags: (value, getTagProps) => value.map((option, index) => /*#__PURE__*/_jsx(rootProps.slots.baseChip, _extends({
59
58
  variant: "outlined",
60
59
  size: "small",
61
60
  label: option
@@ -68,7 +68,9 @@ const GridToolbarFilterButton = /*#__PURE__*/React.forwardRef(function GridToolb
68
68
  children: activeFilters.map((item, index) => _extends({}, lookup[item.field] && /*#__PURE__*/_jsx("li", {
69
69
  children: `${lookup[item.field].headerName || item.field}
70
70
  ${getOperatorLabel(item)}
71
- ${item.value ? getFilterItemValue(item) : ''}`
71
+ ${
72
+ // implicit check for null and undefined
73
+ item.value != null ? getFilterItemValue(item) : ''}`
72
74
  }, index)))
73
75
  })]
74
76
  });
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
- import { useGridApiMethod, useGridNativeEventListener } from '../../utils';
2
+ import { useGridApiOptionHandler, useGridNativeEventListener } from '../../utils';
3
+ import { gridFocusCellSelector } from '../focus/gridFocusStateSelector';
4
+ import { serializeCellValue } from '../export/serializers/csvSerializer';
3
5
  function writeToClipboardPolyfill(data) {
4
6
  const span = document.createElement('span');
5
7
  span.style.whiteSpace = 'pre';
@@ -18,6 +20,15 @@ function writeToClipboardPolyfill(data) {
18
20
  document.body.removeChild(span);
19
21
  }
20
22
  }
23
+ function copyToClipboard(data) {
24
+ if (navigator.clipboard) {
25
+ navigator.clipboard.writeText(data).catch(() => {
26
+ writeToClipboardPolyfill(data);
27
+ });
28
+ } else {
29
+ writeToClipboardPolyfill(data);
30
+ }
31
+ }
21
32
  function hasNativeSelection(element) {
22
33
  // When getSelection is called on an <iframe> that is not displayed Firefox will return null.
23
34
  if (window.getSelection()?.toString()) {
@@ -37,24 +48,11 @@ function hasNativeSelection(element) {
37
48
  * @requires useGridCsvExport (method)
38
49
  * @requires useGridSelection (method)
39
50
  */
40
- export const useGridClipboard = apiRef => {
41
- const copySelectedRowsToClipboard = React.useCallback(() => {
42
- if (apiRef.current.getSelectedRows().size === 0) {
43
- return;
44
- }
45
- const data = apiRef.current.getDataAsCsv({
46
- includeHeaders: false,
47
- delimiter: '\t'
48
- });
49
- if (navigator.clipboard) {
50
- navigator.clipboard.writeText(data).catch(() => {
51
- writeToClipboardPolyfill(data);
52
- });
53
- } else {
54
- writeToClipboardPolyfill(data);
55
- }
56
- }, [apiRef]);
57
- const handleKeydown = React.useCallback(event => {
51
+ export const useGridClipboard = (apiRef, props) => {
52
+ const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
53
+ const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
54
+ const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
55
+ const handleCopy = React.useCallback(event => {
58
56
  const isModifierKeyPressed = event.ctrlKey || event.metaKey;
59
57
  // event.code === 'KeyC' is not enough as event.code assume a QWERTY keyboard layout which would
60
58
  // be wrong with a Dvorak keyboard (as if pressing J).
@@ -66,11 +64,30 @@ export const useGridClipboard = apiRef => {
66
64
  if (hasNativeSelection(event.target)) {
67
65
  return;
68
66
  }
69
- apiRef.current.unstable_copySelectedRowsToClipboard();
70
- }, [apiRef]);
71
- useGridNativeEventListener(apiRef, apiRef.current.rootElementRef, 'keydown', handleKeydown);
72
- const clipboardApi = {
73
- unstable_copySelectedRowsToClipboard: copySelectedRowsToClipboard
74
- };
75
- useGridApiMethod(apiRef, clipboardApi, 'public');
67
+ let textToCopy = '';
68
+ const selectedRows = apiRef.current.getSelectedRows();
69
+ if (selectedRows.size > 0) {
70
+ textToCopy = apiRef.current.getDataAsCsv({
71
+ includeHeaders: false,
72
+ // TODO: make it configurable
73
+ delimiter: clipboardCopyCellDelimiter
74
+ });
75
+ } else {
76
+ const focusedCell = gridFocusCellSelector(apiRef);
77
+ if (focusedCell) {
78
+ const cellParams = apiRef.current.getCellParams(focusedCell.id, focusedCell.field);
79
+ textToCopy = serializeCellValue(cellParams, {
80
+ delimiterCharacter: clipboardCopyCellDelimiter,
81
+ ignoreValueFormatter
82
+ });
83
+ }
84
+ }
85
+ textToCopy = apiRef.current.unstable_applyPipeProcessors('clipboardCopy', textToCopy);
86
+ if (textToCopy) {
87
+ copyToClipboard(textToCopy);
88
+ apiRef.current.publishEvent('clipboardCopy', textToCopy);
89
+ }
90
+ }, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
91
+ useGridNativeEventListener(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
92
+ useGridApiOptionHandler(apiRef, 'clipboardCopy', props.onClipboardCopy);
76
93
  };
@@ -10,7 +10,6 @@ import { getVisibleRows } from '../../utils/useGridVisibleRows';
10
10
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
11
11
  import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
12
12
  import { getTotalHeaderHeight } from '../columns/gridColumnsUtils';
13
- import { gridClasses } from '../../../constants/gridClasses';
14
13
  const isTestEnvironment = process.env.NODE_ENV === 'test';
15
14
  const hasScroll = ({
16
15
  content,
@@ -150,8 +149,7 @@ export function useGridDimensions(apiRef, props) {
150
149
  return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
151
150
  }, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
152
151
  const computeSizeAndPublishResizeEvent = React.useCallback(() => {
153
- const rootEl = apiRef.current.rootElementRef?.current;
154
- const mainEl = rootEl?.querySelector(`.${gridClasses.main}`);
152
+ const mainEl = apiRef.current.mainElementRef?.current;
155
153
  if (!mainEl) {
156
154
  return;
157
155
  }
@@ -90,10 +90,14 @@ export const useGridCellEditing = (apiRef, props) => {
90
90
  }
91
91
  } else if (params.isEditable) {
92
92
  let reason;
93
- if (event.key === ' ') {
94
- return; // Space scrolls to the last row
93
+ const canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
94
+ event,
95
+ cellParams: params,
96
+ editMode: 'cell'
97
+ });
98
+ if (!canStartEditing) {
99
+ return;
95
100
  }
96
-
97
101
  if (isPrintableKey(event)) {
98
102
  reason = GridCellEditStartReasons.printableKeyDown;
99
103
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
@@ -143,10 +143,14 @@ export const useGridRowEditing = (apiRef, props) => {
143
143
  }
144
144
  } else if (params.isEditable) {
145
145
  let reason;
146
- if (event.key === ' ') {
147
- return; // Space scrolls to the last row
146
+ const canStartEditing = apiRef.current.unstable_applyPipeProcessors('canStartEditing', true, {
147
+ event,
148
+ cellParams: params,
149
+ editMode: 'row'
150
+ });
151
+ if (!canStartEditing) {
152
+ return;
148
153
  }
149
-
150
154
  if (isPrintableKey(event)) {
151
155
  reason = GridRowEditStartReasons.printableKeyDown;
152
156
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {