@mui/x-data-grid 6.3.1 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/DataGrid/DataGrid.js +20 -1
  3. package/DataGrid/useDataGridComponent.js +2 -2
  4. package/DataGrid/useDataGridProps.js +3 -1
  5. package/colDef/gridBooleanColDef.js +19 -1
  6. package/colDef/gridDateColDef.js +6 -2
  7. package/colDef/gridSingleSelectColDef.js +21 -1
  8. package/components/base/GridBody.js +2 -1
  9. package/components/containers/GridRootStyles.js +1 -0
  10. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  11. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  12. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
  13. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
  14. package/hooks/features/clipboard/useGridClipboard.js +43 -26
  15. package/hooks/features/dimensions/useGridDimensions.js +2 -4
  16. package/hooks/features/editing/useGridCellEditing.js +7 -3
  17. package/hooks/features/editing/useGridRowEditing.js +7 -3
  18. package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
  19. package/hooks/features/export/serializers/csvSerializer.js +46 -6
  20. package/hooks/features/export/useGridCsvExport.d.ts +2 -1
  21. package/hooks/features/export/useGridCsvExport.js +7 -5
  22. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  23. package/index.js +1 -1
  24. package/internals/index.d.ts +3 -2
  25. package/internals/index.js +3 -2
  26. package/joy/icons.d.ts +33 -0
  27. package/joy/icons.js +433 -0
  28. package/joy/joySlots.js +114 -4
  29. package/legacy/DataGrid/DataGrid.js +20 -1
  30. package/legacy/DataGrid/useDataGridComponent.js +2 -2
  31. package/legacy/DataGrid/useDataGridProps.js +3 -1
  32. package/legacy/colDef/gridBooleanColDef.js +21 -1
  33. package/legacy/colDef/gridDateColDef.js +10 -2
  34. package/legacy/colDef/gridSingleSelectColDef.js +21 -1
  35. package/legacy/components/base/GridBody.js +2 -1
  36. package/legacy/components/containers/GridRootStyles.js +1 -0
  37. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  38. package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  39. package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
  40. package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -4
  41. package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
  42. package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
  43. package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
  44. package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
  45. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -0
  46. package/legacy/index.js +1 -1
  47. package/legacy/internals/index.js +3 -2
  48. package/legacy/joy/icons.js +432 -0
  49. package/legacy/joy/joySlots.js +118 -4
  50. package/legacy/locales/deDE.js +2 -2
  51. package/legacy/locales/frFR.js +6 -6
  52. package/legacy/locales/ptBR.js +1 -1
  53. package/legacy/locales/ukUA.js +8 -9
  54. package/legacy/material/index.js +3 -1
  55. package/legacy/models/api/index.js +0 -1
  56. package/legacy/utils/domUtils.js +14 -1
  57. package/locales/deDE.js +2 -2
  58. package/locales/frFR.js +6 -6
  59. package/locales/ptBR.js +1 -1
  60. package/locales/ukUA.js +8 -9
  61. package/material/index.d.ts +1 -0
  62. package/material/index.js +3 -1
  63. package/models/api/gridApiCommon.d.ts +1 -2
  64. package/models/api/gridCoreApi.d.ts +4 -0
  65. package/models/api/index.d.ts +0 -1
  66. package/models/api/index.js +0 -1
  67. package/models/events/gridEventLookup.d.ts +6 -0
  68. package/models/gridSlotsComponent.d.ts +5 -0
  69. package/models/gridSlotsComponentsProps.d.ts +4 -0
  70. package/models/props/DataGridProps.d.ts +19 -0
  71. package/modern/DataGrid/DataGrid.js +20 -1
  72. package/modern/DataGrid/useDataGridComponent.js +2 -2
  73. package/modern/DataGrid/useDataGridProps.js +3 -1
  74. package/modern/colDef/gridBooleanColDef.js +19 -1
  75. package/modern/colDef/gridDateColDef.js +6 -2
  76. package/modern/colDef/gridSingleSelectColDef.js +21 -1
  77. package/modern/components/base/GridBody.js +2 -1
  78. package/modern/components/containers/GridRootStyles.js +1 -0
  79. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  80. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  81. package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
  82. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
  83. package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
  84. package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
  85. package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
  86. package/modern/hooks/features/export/useGridCsvExport.js +7 -5
  87. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  88. package/modern/index.js +1 -1
  89. package/modern/internals/index.js +3 -2
  90. package/modern/joy/icons.js +433 -0
  91. package/modern/joy/joySlots.js +110 -4
  92. package/modern/locales/deDE.js +2 -2
  93. package/modern/locales/frFR.js +6 -6
  94. package/modern/locales/ptBR.js +1 -1
  95. package/modern/locales/ukUA.js +8 -9
  96. package/modern/material/index.js +3 -1
  97. package/modern/models/api/index.js +0 -1
  98. package/modern/utils/domUtils.js +13 -1
  99. package/node/DataGrid/DataGrid.js +20 -1
  100. package/node/DataGrid/useDataGridComponent.js +2 -2
  101. package/node/DataGrid/useDataGridProps.js +3 -1
  102. package/node/colDef/gridBooleanColDef.js +19 -1
  103. package/node/colDef/gridDateColDef.js +6 -2
  104. package/node/colDef/gridSingleSelectColDef.js +21 -1
  105. package/node/components/base/GridBody.js +2 -1
  106. package/node/components/containers/GridRootStyles.js +1 -0
  107. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
  108. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
  109. package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
  110. package/node/hooks/features/dimensions/useGridDimensions.js +1 -3
  111. package/node/hooks/features/editing/useGridCellEditing.js +7 -3
  112. package/node/hooks/features/editing/useGridRowEditing.js +7 -3
  113. package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
  114. package/node/hooks/features/export/useGridCsvExport.js +6 -3
  115. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +11 -0
  116. package/node/index.js +1 -1
  117. package/node/internals/index.js +23 -1
  118. package/node/joy/icons.js +471 -0
  119. package/node/joy/joySlots.js +110 -3
  120. package/node/locales/deDE.js +2 -2
  121. package/node/locales/frFR.js +6 -6
  122. package/node/locales/ptBR.js +1 -1
  123. package/node/locales/ukUA.js +8 -9
  124. package/node/material/index.js +3 -1
  125. package/node/models/api/index.js +0 -11
  126. package/node/utils/domUtils.js +15 -1
  127. package/package.json +1 -1
  128. package/utils/domUtils.d.ts +1 -0
  129. package/utils/domUtils.js +13 -1
  130. package/legacy/models/api/gridClipboardApi.js +0 -1
  131. package/models/api/gridClipboardApi.d.ts +0 -11
  132. package/models/api/gridClipboardApi.js +0 -1
  133. package/modern/models/api/gridClipboardApi.js +0 -1
  134. package/node/models/api/gridClipboardApi.js +0 -5
@@ -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 @@ var 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;
@@ -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';
@@ -38,4 +38,17 @@ export function getGridCellElement(root, _ref) {
38
38
  var cellSelector = ".".concat(gridClasses.cell, "[data-field=\"").concat(escapeOperandAttributeSelector(field), "\"]");
39
39
  var selector = "".concat(rowSelector, " ").concat(cellSelector);
40
40
  return root.querySelector(selector);
41
- }
41
+ }
42
+
43
+ // https://www.abeautifulsite.net/posts/finding-the-active-element-in-a-shadow-root/
44
+ export var getActiveElement = function getActiveElement() {
45
+ var root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
46
+ var activeEl = root.activeElement;
47
+ if (!activeEl) {
48
+ return null;
49
+ }
50
+ if (activeEl.shadowRoot) {
51
+ return getActiveElement(activeEl.shadowRoot);
52
+ }
53
+ return activeEl;
54
+ };
package/locales/deDE.js CHANGED
@@ -37,7 +37,7 @@ const deDEGrid = {
37
37
  columnsPanelHideAllButton: 'Verberge alle',
38
38
  // Filter panel text
39
39
  filterPanelAddFilter: 'Filter hinzufügen',
40
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Alle entfernen',
41
41
  filterPanelDeleteIconLabel: 'Löschen',
42
42
  filterPanelLogicOperator: 'Logische Operatoren',
43
43
  filterPanelOperator: 'Operatoren',
@@ -67,7 +67,7 @@ const deDEGrid = {
67
67
  // Column menu text
68
68
  columnMenuLabel: 'Menü',
69
69
  columnMenuShowColumns: 'Zeige alle Spalten',
70
- // columnMenuManageColumns: 'Manage columns',
70
+ columnMenuManageColumns: 'Spalten verwalten',
71
71
  columnMenuFilter: 'Filter',
72
72
  columnMenuHideColumn: 'Verbergen',
73
73
  columnMenuUnsort: 'Sortierung deaktivieren',
package/locales/frFR.js CHANGED
@@ -7,7 +7,7 @@ const frFRGrid = {
7
7
  // Density selector toolbar button text
8
8
  toolbarDensity: 'Densité',
9
9
  toolbarDensityLabel: 'Densité',
10
- toolbarDensityCompact: 'Compact',
10
+ toolbarDensityCompact: 'Compacte',
11
11
  toolbarDensityStandard: 'Standard',
12
12
  toolbarDensityComfortable: 'Confortable',
13
13
  // Columns selector toolbar button text
@@ -20,7 +20,7 @@ const frFRGrid = {
20
20
  toolbarFiltersTooltipShow: 'Afficher les filtres',
21
21
  toolbarFiltersTooltipActive: count => count > 1 ? `${count} filtres actifs` : `${count} filtre actif`,
22
22
  // Quick filter toolbar field
23
- toolbarQuickFilterPlaceholder: 'Recherche…',
23
+ toolbarQuickFilterPlaceholder: 'Rechercher…',
24
24
  toolbarQuickFilterLabel: 'Recherche',
25
25
  toolbarQuickFilterDeleteIconLabel: 'Supprimer',
26
26
  // Export selector toolbar button text
@@ -30,7 +30,7 @@ const frFRGrid = {
30
30
  toolbarExportPrint: 'Imprimer',
31
31
  toolbarExportExcel: 'Télécharger pour Excel',
32
32
  // Columns panel text
33
- columnsPanelTextFieldLabel: 'Chercher colonne',
33
+ columnsPanelTextFieldLabel: 'Chercher une colonne',
34
34
  columnsPanelTextFieldPlaceholder: 'Titre de la colonne',
35
35
  columnsPanelDragIconLabel: 'Réorganiser la colonne',
36
36
  columnsPanelShowAllButton: 'Tout afficher',
@@ -43,12 +43,12 @@ const frFRGrid = {
43
43
  filterPanelOperator: 'Opérateur',
44
44
  filterPanelOperatorAnd: 'Et',
45
45
  filterPanelOperatorOr: 'Ou',
46
- filterPanelColumns: 'Colonnes',
46
+ filterPanelColumns: 'Colonne',
47
47
  filterPanelInputLabel: 'Valeur',
48
48
  filterPanelInputPlaceholder: 'Filtrer la valeur',
49
49
  // Filter operators text
50
50
  filterOperatorContains: 'contient',
51
- filterOperatorEquals: 'égal à',
51
+ filterOperatorEquals: 'est égal à',
52
52
  filterOperatorStartsWith: 'commence par',
53
53
  filterOperatorEndsWith: 'se termine par',
54
54
  filterOperatorIs: 'est',
@@ -80,7 +80,7 @@ const frFRGrid = {
80
80
  // Rows selected footer text
81
81
  footerRowSelected: count => count > 1 ? `${count.toLocaleString()} lignes sélectionnées` : `${count.toLocaleString()} ligne sélectionnée`,
82
82
  // Total row amount footer text
83
- footerTotalRows: 'Lignes totales :',
83
+ footerTotalRows: 'Total de lignes :',
84
84
  // Total visible row amount footer text
85
85
  footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} sur ${totalCount.toLocaleString()}`,
86
86
  // Checkbox selection text
package/locales/ptBR.js CHANGED
@@ -37,7 +37,7 @@ const ptBRGrid = {
37
37
  columnsPanelHideAllButton: 'Ocultar todas',
38
38
  // Filter panel text
39
39
  filterPanelAddFilter: 'Adicionar filtro',
40
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Remover todos',
41
41
  filterPanelDeleteIconLabel: 'Excluir',
42
42
  filterPanelLogicOperator: 'Operador lógico',
43
43
  filterPanelOperator: 'Operador',
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);
@@ -27,6 +27,7 @@ declare const materialSlots: {
27
27
  } & import("react").RefAttributes<HTMLDivElement>>;
28
28
  BaseInputLabel: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/InputLabel").InputLabelTypeMap<{}, "label">>;
29
29
  BaseSelectOption: typeof MUISelectOption;
30
+ BaseChip: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material/Chip").ChipTypeMap<{}, "div">>;
30
31
  BooleanCellTrueIcon: import("react").JSXElementConstructor<any>;
31
32
  BooleanCellFalseIcon: import("react").JSXElementConstructor<any>;
32
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
  });
@@ -89,7 +89,8 @@ function GridBody(props) {
89
89
  apiRef.current.register('private', {
90
90
  columnHeadersContainerElementRef: columnsContainerRef,
91
91
  columnHeadersElementRef: columnHeadersRef,
92
- virtualScrollerRef
92
+ virtualScrollerRef,
93
+ mainElementRef: rootRef
93
94
  });
94
95
  const hasDimensions = !!apiRef.current.getRootDimensions();
95
96
  return /*#__PURE__*/_jsxs(GridMainContainer, {
@@ -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
@@ -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
  }