@mui/x-data-grid-pro 5.8.0 → 5.11.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 (170) hide show
  1. package/CHANGELOG.md +333 -66
  2. package/DataGridPro/DataGridPro.d.ts +1 -1
  3. package/DataGridPro/DataGridPro.js +51 -3
  4. package/DataGridPro/useDataGridProComponent.js +9 -4
  5. package/DataGridPro/useDataGridProProps.js +20 -5
  6. package/LICENSE +12 -0
  7. package/README.md +7 -5
  8. package/components/DataGridProColumnHeaders.js +2 -8
  9. package/components/DataGridProVirtualScroller.js +7 -7
  10. package/components/GridDetailPanelToggleCell.js +13 -2
  11. package/components/GridGroupingCriteriaCell.js +2 -2
  12. package/components/GridRowReorderCell.d.ts +5 -0
  13. package/components/GridRowReorderCell.js +72 -0
  14. package/components/GridTreeDataGroupingCell.js +15 -4
  15. package/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
  16. package/hooks/features/columnReorder/useGridColumnReorder.d.ts +0 -1
  17. package/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
  18. package/hooks/features/columnResize/useGridColumnResize.d.ts +0 -1
  19. package/hooks/features/columnResize/useGridColumnResize.js +31 -20
  20. package/hooks/features/detailPanel/useGridDetailPanel.js +14 -6
  21. package/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
  22. package/hooks/features/index.d.ts +1 -1
  23. package/hooks/features/index.js +1 -1
  24. package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +0 -1
  25. package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
  26. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +1 -1
  27. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +1 -1
  28. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
  29. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +0 -2
  30. package/hooks/features/rowGrouping/useGridRowGrouping.js +8 -12
  31. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
  32. package/hooks/features/rowReorder/gridRowReorderColDef.d.ts +2 -0
  33. package/hooks/features/rowReorder/gridRowReorderColDef.js +18 -0
  34. package/hooks/features/rowReorder/index.d.ts +1 -0
  35. package/hooks/features/rowReorder/index.js +1 -0
  36. package/hooks/features/rowReorder/useGridRowReorder.d.ts +8 -0
  37. package/hooks/features/rowReorder/useGridRowReorder.js +111 -0
  38. package/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +4 -0
  39. package/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +51 -0
  40. package/hooks/features/treeData/useGridTreeData.d.ts +0 -3
  41. package/hooks/features/treeData/useGridTreeData.js +2 -8
  42. package/index.d.ts +6 -1
  43. package/index.js +7 -3
  44. package/internals/index.d.ts +19 -0
  45. package/internals/index.js +17 -0
  46. package/internals/package.json +6 -0
  47. package/legacy/DataGridPro/DataGridPro.js +51 -3
  48. package/legacy/DataGridPro/useDataGridProComponent.js +9 -4
  49. package/legacy/DataGridPro/useDataGridProProps.js +20 -5
  50. package/legacy/components/DataGridProColumnHeaders.js +2 -8
  51. package/legacy/components/DataGridProVirtualScroller.js +7 -7
  52. package/legacy/components/GridDetailPanelToggleCell.js +13 -2
  53. package/legacy/components/GridGroupingCriteriaCell.js +2 -2
  54. package/legacy/components/GridRowReorderCell.js +74 -0
  55. package/legacy/components/GridTreeDataGroupingCell.js +15 -4
  56. package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
  57. package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
  58. package/legacy/hooks/features/columnResize/useGridColumnResize.js +31 -20
  59. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +14 -6
  60. package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
  61. package/legacy/hooks/features/index.js +1 -1
  62. package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
  63. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -5
  64. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +8 -12
  65. package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
  66. package/legacy/hooks/features/rowReorder/gridRowReorderColDef.js +20 -0
  67. package/legacy/hooks/features/rowReorder/index.js +1 -0
  68. package/legacy/hooks/features/rowReorder/useGridRowReorder.js +115 -0
  69. package/legacy/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +52 -0
  70. package/legacy/hooks/features/treeData/useGridTreeData.js +2 -8
  71. package/legacy/index.js +7 -3
  72. package/legacy/internals/index.js +17 -0
  73. package/legacy/models/gridRowOrderChangeParams.js +1 -0
  74. package/legacy/models/index.js +1 -2
  75. package/legacy/typeOverloads/index.js +1 -0
  76. package/legacy/utils/domUtils.js +30 -3
  77. package/legacy/utils/index.js +1 -0
  78. package/legacy/utils/releaseInfo.js +1 -1
  79. package/legacy/utils/tree/buildRowTree.js +11 -4
  80. package/legacy/utils/tree/index.js +1 -0
  81. package/models/dataGridProProps.d.ts +36 -24
  82. package/models/gridApiPro.d.ts +3 -2
  83. package/models/gridRowOrderChangeParams.d.ts +18 -0
  84. package/models/gridRowOrderChangeParams.js +1 -0
  85. package/models/gridStatePro.d.ts +4 -3
  86. package/models/index.d.ts +1 -2
  87. package/models/index.js +1 -2
  88. package/modern/DataGridPro/DataGridPro.js +51 -3
  89. package/modern/DataGridPro/useDataGridProComponent.js +9 -4
  90. package/modern/DataGridPro/useDataGridProProps.js +16 -3
  91. package/modern/components/DataGridProColumnHeaders.js +2 -8
  92. package/modern/components/DataGridProVirtualScroller.js +7 -7
  93. package/modern/components/GridDetailPanelToggleCell.js +13 -2
  94. package/modern/components/GridGroupingCriteriaCell.js +2 -2
  95. package/modern/components/GridRowReorderCell.js +72 -0
  96. package/modern/components/GridTreeDataGroupingCell.js +15 -4
  97. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
  98. package/modern/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
  99. package/modern/hooks/features/columnResize/useGridColumnResize.js +31 -20
  100. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +14 -6
  101. package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
  102. package/modern/hooks/features/index.js +1 -1
  103. package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
  104. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
  105. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +8 -12
  106. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
  107. package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +18 -0
  108. package/modern/hooks/features/rowReorder/index.js +1 -0
  109. package/modern/hooks/features/rowReorder/useGridRowReorder.js +111 -0
  110. package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +51 -0
  111. package/modern/hooks/features/treeData/useGridTreeData.js +2 -8
  112. package/modern/index.js +7 -3
  113. package/modern/internals/index.js +17 -0
  114. package/modern/models/gridRowOrderChangeParams.js +1 -0
  115. package/modern/models/index.js +1 -2
  116. package/modern/typeOverloads/index.js +1 -0
  117. package/modern/utils/domUtils.js +30 -3
  118. package/modern/utils/index.js +1 -0
  119. package/modern/utils/releaseInfo.js +1 -1
  120. package/modern/utils/tree/buildRowTree.js +9 -2
  121. package/modern/utils/tree/index.js +1 -0
  122. package/node/DataGridPro/DataGridPro.js +51 -3
  123. package/node/DataGridPro/useDataGridProComponent.js +12 -5
  124. package/node/DataGridPro/useDataGridProProps.js +21 -5
  125. package/node/components/DataGridProColumnHeaders.js +1 -7
  126. package/node/components/DataGridProVirtualScroller.js +6 -6
  127. package/node/components/GridDetailPanelToggleCell.js +13 -2
  128. package/node/components/GridGroupingCriteriaCell.js +1 -1
  129. package/node/components/GridRowReorderCell.js +92 -0
  130. package/node/components/GridTreeDataGroupingCell.js +14 -3
  131. package/node/hooks/features/columnPinning/useGridColumnPinning.js +3 -3
  132. package/node/hooks/features/columnReorder/useGridColumnReorder.js +7 -8
  133. package/node/hooks/features/columnResize/useGridColumnResize.js +30 -19
  134. package/node/hooks/features/detailPanel/useGridDetailPanel.js +13 -5
  135. package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  136. package/node/hooks/features/index.js +4 -4
  137. package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +3 -4
  138. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
  139. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +7 -11
  140. package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +4 -4
  141. package/node/hooks/features/rowReorder/gridRowReorderColDef.js +31 -0
  142. package/node/hooks/features/rowReorder/index.js +18 -0
  143. package/node/hooks/features/rowReorder/useGridRowReorder.js +126 -0
  144. package/node/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +70 -0
  145. package/node/hooks/features/treeData/useGridTreeData.js +1 -6
  146. package/node/index.js +45 -3
  147. package/node/internals/index.js +193 -0
  148. package/node/models/gridRowOrderChangeParams.js +5 -0
  149. package/node/models/index.js +4 -4
  150. package/node/typeOverloads/index.js +18 -0
  151. package/node/utils/domUtils.js +30 -3
  152. package/node/utils/index.js +18 -0
  153. package/node/utils/releaseInfo.js +1 -1
  154. package/node/utils/tree/buildRowTree.js +12 -2
  155. package/node/utils/tree/index.js +13 -0
  156. package/package.json +8 -8
  157. package/typeOverloads/index.d.ts +1 -0
  158. package/typeOverloads/index.js +1 -0
  159. package/typeOverloads/modules.d.ts +41 -15
  160. package/typeOverloads/package.json +6 -0
  161. package/utils/domUtils.d.ts +2 -1
  162. package/utils/domUtils.js +30 -3
  163. package/utils/index.d.ts +1 -0
  164. package/utils/index.js +1 -0
  165. package/utils/package.json +6 -0
  166. package/utils/releaseInfo.js +1 -1
  167. package/utils/tree/buildRowTree.d.ts +1 -0
  168. package/utils/tree/buildRowTree.js +9 -2
  169. package/utils/tree/index.d.ts +1 -0
  170. package/utils/tree/index.js +1 -0
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridValidRowModel } from '@mui/x-data-grid';
3
- import { DataGridProProps } from '../models';
3
+ import { DataGridProProps } from '../models/dataGridProProps';
4
4
  interface DataGridProComponent {
5
5
  <R extends GridValidRowModel = any>(props: DataGridProProps<R> & React.RefAttributes<HTMLDivElement>): JSX.Element;
6
6
  propTypes?: any;
@@ -72,6 +72,11 @@ DataGridProRaw.propTypes = {
72
72
  */
73
73
  autoPageSize: PropTypes.bool,
74
74
 
75
+ /**
76
+ * Controls the modes of the cells.
77
+ */
78
+ cellModesModel: PropTypes.object,
79
+
75
80
  /**
76
81
  * If `true`, the grid get a first column with a checkbox that allows to select rows.
77
82
  * @default false
@@ -225,7 +230,7 @@ DataGridProRaw.propTypes = {
225
230
  disableMultipleColumnsSorting: PropTypes.bool,
226
231
 
227
232
  /**
228
- * If `true`, multiple selection using the CTRL or CMD key is disabled.
233
+ * If `true`, multiple selection using the Ctrl or CMD key is disabled.
229
234
  * @default false
230
235
  */
231
236
  disableMultipleSelection: PropTypes.bool,
@@ -298,7 +303,9 @@ DataGridProRaw.propTypes = {
298
303
  operatorValue: PropTypes.string,
299
304
  value: PropTypes.any
300
305
  })).isRequired,
301
- linkOperator: PropTypes.oneOf(['and', 'or'])
306
+ linkOperator: PropTypes.oneOf(['and', 'or']),
307
+ quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
308
+ quickFilterValues: PropTypes.array
302
309
  }),
303
310
 
304
311
  /**
@@ -430,6 +437,14 @@ DataGridProRaw.propTypes = {
430
437
  */
431
438
  isRowSelectable: PropTypes.func,
432
439
 
440
+ /**
441
+ * If `true`, the selection model will retain selected rows that do not exist.
442
+ * Useful when using server side pagination and row selections need to be retained
443
+ * when changing pages.
444
+ * @default false
445
+ */
446
+ keepNonExistentRowsSelected: PropTypes.bool,
447
+
433
448
  /**
434
449
  * If `true`, a loading overlay is displayed.
435
450
  */
@@ -517,6 +532,13 @@ DataGridProRaw.propTypes = {
517
532
  */
518
533
  onCellKeyDown: PropTypes.func,
519
534
 
535
+ /**
536
+ * Callback fired when the `cellModesModel` prop changes.
537
+ * @param {GridCellModesModel} cellModesModel Object containig which cells are in "edit" mode.
538
+ * @param {GridCallbackDetails} details Additional details for this callback.
539
+ */
540
+ onCellModesModelChange: PropTypes.func,
541
+
520
542
  /**
521
543
  * Callback fired when a click event comes from a column header element.
522
544
  * @param {GridColumnHeaderParams} params With all properties from [[GridColumnHeaderParams]].
@@ -618,7 +640,7 @@ DataGridProRaw.propTypes = {
618
640
  * @param {GridEditCellPropsParams} params With all properties from [[GridEditCellPropsParams]].
619
641
  * @param {MuiEvent<React.SyntheticEvent>} event The event that caused this prop to be called.
620
642
  * @param {GridCallbackDetails} details Additional details for this callback.
621
- * @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/api/data-grid/grid-col-def/)
643
+ * @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/x/api/data-grid/grid-col-def/)
622
644
  */
623
645
  onEditCellPropsChange: PropTypes.func,
624
646
 
@@ -740,6 +762,21 @@ DataGridProRaw.propTypes = {
740
762
  */
741
763
  onRowGroupingModelChange: PropTypes.func,
742
764
 
765
+ /**
766
+ * Callback fired when the `rowModesModel` prop changes.
767
+ * @param {GridRowModesModel} rowModesModel Object containig which rows are in "edit" mode.
768
+ * @param {GridCallbackDetails} details Additional details for this callback.
769
+ */
770
+ onRowModesModelChange: PropTypes.func,
771
+
772
+ /**
773
+ * Callback fired when a row is being reordered.
774
+ * @param {GridRowOrderChangeParams} params With all properties from [[GridRowOrderChangeParams]].
775
+ * @param {MuiEvent<{}>} event The event object.
776
+ * @param {GridCallbackDetails} details Additional details for this callback.
777
+ */
778
+ onRowOrderChange: PropTypes.func,
779
+
743
780
  /**
744
781
  * Callback fired when scrolling to the bottom of the grid viewport.
745
782
  * @param {GridRowScrollEndParams} params With all properties from [[GridRowScrollEndParams]].
@@ -846,6 +883,17 @@ DataGridProRaw.propTypes = {
846
883
  */
847
884
  rowHeight: PropTypes.number,
848
885
 
886
+ /**
887
+ * Controls the modes of the rows.
888
+ */
889
+ rowModesModel: PropTypes.object,
890
+
891
+ /**
892
+ * If `true`, the reordering of rows is enabled.
893
+ * @default false
894
+ */
895
+ rowReordering: PropTypes.bool,
896
+
849
897
  /**
850
898
  * Set of rows of type [[GridRowsProp]].
851
899
  */
@@ -1,17 +1,19 @@
1
- import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing_new, useGridEditing_old, editingStateInitializer_old, editingStateInitializer_new, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer } from '@mui/x-data-grid/internals';
1
+ import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing_new, useGridEditing_old, editingStateInitializer_old, editingStateInitializer_new, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, useGridColumnSpanning, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer } from '@mui/x-data-grid/internals';
2
2
  // Pro-only features
3
3
  import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
4
4
  import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
5
5
  import { useGridColumnResize, columnResizeStateInitializer } from '../hooks/features/columnResize/useGridColumnResize';
6
6
  import { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
7
7
  import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
8
- import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
9
- import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
10
8
  import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
11
9
  import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
12
10
  import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
13
11
  import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
14
12
  import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
13
+ import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
14
+ import { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
15
+ import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
16
+ import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
15
17
  export const useDataGridProComponent = (inputApiRef, props) => {
16
18
  var _props$experimentalFe, _props$experimentalFe2;
17
19
 
@@ -21,6 +23,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
21
23
  */
22
24
 
23
25
  useGridSelectionPreProcessors(apiRef, props);
26
+ useGridRowReorderPreProcessors(apiRef, props);
24
27
  useGridRowGroupingPreProcessors(apiRef, props);
25
28
  useGridTreeDataPreProcessors(apiRef, props);
26
29
  useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
@@ -58,18 +61,20 @@ export const useDataGridProComponent = (inputApiRef, props) => {
58
61
  useGridColumns(apiRef, props);
59
62
  useGridRows(apiRef, props);
60
63
  useGridParamsApi(apiRef);
64
+ useGridColumnSpanning(apiRef);
61
65
  useGridDetailPanelCache(apiRef, props);
62
66
  const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
63
67
  useGridEditing(apiRef, props);
64
68
  useGridFocus(apiRef, props);
65
- useGridSorting(apiRef, props);
66
69
  useGridPreferencesPanel(apiRef);
67
70
  useGridFilter(apiRef, props);
71
+ useGridSorting(apiRef, props);
68
72
  useGridDensity(apiRef, props);
69
73
  useGridColumnReorder(apiRef, props);
70
74
  useGridColumnResize(apiRef, props);
71
75
  useGridPagination(apiRef, props);
72
76
  useGridRowsMeta(apiRef, props);
77
+ useGridRowReorder(apiRef, props);
73
78
  useGridScroll(apiRef, props);
74
79
  useGridInfiniteLoader(apiRef, props);
75
80
  useGridColumnMenu(apiRef);
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useThemeProps } from '@mui/material/styles';
4
4
  import { DATA_GRID_DEFAULT_SLOTS_COMPONENTS, GRID_DEFAULT_LOCALE_TEXT, DATA_GRID_PROPS_DEFAULT_VALUES } from '@mui/x-data-grid';
5
+ import { buildWarning } from '@mui/x-data-grid/internals';
5
6
 
6
7
  /**
7
8
  * The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
@@ -11,12 +12,14 @@ export const DATA_GRID_PRO_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PROPS_D
11
12
  treeData: false,
12
13
  defaultGroupingExpansionDepth: 0,
13
14
  disableColumnPinning: false,
14
- disableRowGrouping: false,
15
15
  disableChildrenFiltering: false,
16
16
  disableChildrenSorting: false,
17
- rowGroupingColumnMode: 'single',
18
- getDetailPanelHeight: () => 500
17
+ rowReordering: false,
18
+ getDetailPanelHeight: () => 500,
19
+ disableRowGrouping: false,
20
+ rowGroupingColumnMode: 'single'
19
21
  });
22
+ const rowGroupingWarning = buildWarning(['MUI: The row grouping has been moved to the new `@mui/x-data-grid-premium` package.', 'The feature is deprecated in `@mui/x-data-grid-pro`, and it will soon be removed from this package.'], 'error');
20
23
  export const useDataGridProProps = inProps => {
21
24
  const themedProps = useThemeProps({
22
25
  props: inProps,
@@ -36,11 +39,23 @@ export const useDataGridProProps = inProps => {
36
39
  });
37
40
  return mergedComponents;
38
41
  }, [themedProps.components]);
42
+
43
+ if (process.env.NODE_ENV !== 'production') {
44
+ // eslint-disable-next-line react-hooks/rules-of-hooks
45
+ React.useEffect(() => {
46
+ var _themedProps$experime;
47
+
48
+ if ((_themedProps$experime = themedProps.experimentalFeatures) != null && _themedProps$experime.rowGrouping) {
49
+ rowGroupingWarning();
50
+ }
51
+ }, [themedProps.experimentalFeatures]);
52
+ }
53
+
39
54
  return React.useMemo(() => {
40
- var _themedProps$experime;
55
+ var _themedProps$experime2;
41
56
 
42
57
  return _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
43
- disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$experime = themedProps.experimentalFeatures) != null && _themedProps$experime.rowGrouping),
58
+ disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$experime2 = themedProps.experimentalFeatures) != null && _themedProps$experime2.rowGrouping),
44
59
  localeText,
45
60
  components,
46
61
  signature: 'DataGridPro'
package/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Commercial License
2
+
3
+ Copyright (c) 2020 Material-UI SAS
4
+
5
+ MUI X Pro (https://mui.com/pricing/) is commercial software. You must purchase
6
+ a license and agree to the End User License Agreement (EULA: https://mui.com/r/x-license-eula)
7
+ to be able to use the software.
8
+
9
+ Commercial licenses can be obtained at https://mui.com/r/x-get-license?scope=pro.
10
+ You are free to install and try the software without a license key as long as it
11
+ is not used for the development of a feature intended for production use. You can
12
+ find more details under the "Evaluation (trial) licenses" section of the EULA.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mui/x-data-grid-pro
2
2
 
3
- This package is the commercial edition of the data grid component.
3
+ This package is the Pro Plan edition of the data grid component.
4
4
  It's part of MUI X, an open core extension of MUI, with advanced components.
5
5
 
6
6
  ## Installation
@@ -15,15 +15,17 @@ npm install @mui/x-data-grid-pro
15
15
  yarn add @mui/x-data-grid-pro
16
16
  ```
17
17
 
18
- This component has three peer dependencies that you will need to install as well.
18
+ This component has the following peer dependencies that you will need to install as well.
19
19
 
20
20
  ```json
21
21
  "peerDependencies": {
22
- "@mui/material": "^5.0.0",
23
- "react": "^17.0.0"
22
+ "@mui/material": "^5.2.8",
23
+ "@mui/system": "^5.2.8",
24
+ "react": "^17.0.2 || ^18.0.0",
25
+ "react-dom": "^17.0.2 || ^18.0.0"
24
26
  },
25
27
  ```
26
28
 
27
29
  ## Documentation
28
30
 
29
- [The documentation](https://mui.com/components/data-grid/)
31
+ [The documentation](https://mui.com/x/react-data-grid/)
@@ -4,7 +4,7 @@ const _excluded = ["style", "className", "innerRef"];
4
4
  import * as React from 'react';
5
5
  import { unstable_composeClasses as composeClasses } from '@mui/material';
6
6
  import { styled, alpha } from '@mui/material/styles';
7
- import { getDataGridUtilityClass, gridClasses, useGridSelector, useGridApiEventHandler, gridVisibleColumnFieldsSelector, GridEvents, GridColumnHeaderSeparatorSides } from '@mui/x-data-grid';
7
+ import { getDataGridUtilityClass, gridClasses, useGridSelector, useGridApiEventHandler, gridVisibleColumnFieldsSelector, GridColumnHeaderSeparatorSides } from '@mui/x-data-grid';
8
8
  import { GridColumnHeaders, GridColumnHeadersInner, useGridColumnHeaders } from '@mui/x-data-grid/internals';
9
9
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
10
10
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
@@ -87,13 +87,12 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
87
87
  const newScrollbarSize = apiRef.current.windowRef.current.offsetWidth - apiRef.current.windowRef.current.clientWidth;
88
88
  setScrollbarSize(newScrollbarSize);
89
89
  }, [apiRef]);
90
- useGridApiEventHandler(apiRef, GridEvents.virtualScrollerContentSizeChange, handleContentSizeChange);
90
+ useGridApiEventHandler(apiRef, 'virtualScrollerContentSizeChange', handleContentSizeChange);
91
91
  const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
92
92
  const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields);
93
93
  const {
94
94
  isDragging,
95
95
  renderContext,
96
- updateInnerPosition,
97
96
  getRootProps,
98
97
  getInnerProps,
99
98
  getColumns
@@ -107,11 +106,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
107
106
  classes: rootProps.classes
108
107
  };
109
108
  const classes = useUtilityClasses(ownerState);
110
- React.useEffect(() => {
111
- if (renderContext) {
112
- updateInnerPosition(renderContext);
113
- }
114
- }, [renderContext, updateInnerPosition]);
115
109
  const leftRenderContext = renderContext && leftPinnedColumns.length ? _extends({}, renderContext, {
116
110
  firstColumnIndex: 0,
117
111
  lastColumnIndex: leftPinnedColumns.length
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import { styled, alpha } from '@mui/material/styles';
6
6
  import Box from '@mui/material/Box';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/material';
8
- import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler, GridEvents } from '@mui/x-data-grid';
8
+ import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler } from '@mui/x-data-grid';
9
9
  import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
10
10
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
11
11
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
@@ -71,7 +71,9 @@ const VirtualScrollerDetailPanels = styled('div', {
71
71
  name: 'MuiDataGrid',
72
72
  slot: 'DetailPanels',
73
73
  overridesResolver: (props, styles) => styles.detailPanels
74
- })({});
74
+ })({
75
+ position: 'relative'
76
+ });
75
77
  const VirtualScrollerDetailPanel = styled(Box, {
76
78
  name: 'MuiDataGrid',
77
79
  slot: 'DetailPanel',
@@ -173,11 +175,9 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
173
175
  updateRenderZonePosition(renderContext);
174
176
  }
175
177
  }, [renderContext, updateRenderZonePosition]);
176
- useGridApiEventHandler(apiRef, GridEvents.columnWidthChange, refreshRenderZonePosition);
177
- useGridApiEventHandler(apiRef, GridEvents.columnOrderChange, refreshRenderZonePosition);
178
- React.useEffect(() => {
179
- refreshRenderZonePosition();
180
- }, [refreshRenderZonePosition]);
178
+ useGridApiEventHandler(apiRef, 'columnWidthChange', refreshRenderZonePosition);
179
+ useGridApiEventHandler(apiRef, 'columnOrderChange', refreshRenderZonePosition);
180
+ useGridApiEventHandler(apiRef, 'rowOrderChange', refreshRenderZonePosition);
181
181
  const leftRenderContext = renderContext && leftPinnedColumns.length > 0 ? _extends({}, renderContext, {
182
182
  firstColumnIndex: 0,
183
183
  lastColumnIndex: leftPinnedColumns.length
@@ -73,10 +73,21 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
73
73
  */
74
74
  field: PropTypes.string.isRequired,
75
75
 
76
+ /**
77
+ * A ref allowing to set imperative focus.
78
+ * It can be passed to the element that should receive focus.
79
+ * @ignore - do not document.
80
+ */
81
+ focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
82
+ current: PropTypes.shape({
83
+ focus: PropTypes.func.isRequired
84
+ })
85
+ })]),
86
+
76
87
  /**
77
88
  * The cell value formatted with the column valueFormatter.
78
89
  */
79
- formattedValue: PropTypes.any.isRequired,
90
+ formattedValue: PropTypes.any,
80
91
 
81
92
  /**
82
93
  * Get the cell value of a row and field.
@@ -120,6 +131,6 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
120
131
  /**
121
132
  * The cell value, but if the column has valueGetter, use getValue.
122
133
  */
123
- value: PropTypes.any.isRequired
134
+ value: PropTypes.any
124
135
  } : void 0;
125
136
  export { GridDetailPanelToggleCell };
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { unstable_composeClasses as composeClasses } from '@mui/material';
3
3
  import IconButton from '@mui/material/IconButton';
4
4
  import Box from '@mui/material/Box';
5
- import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass, GridEvents } from '@mui/x-data-grid';
5
+ import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
6
6
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
7
7
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -44,7 +44,7 @@ export const GridGroupingCriteriaCell = props => {
44
44
  event.stopPropagation();
45
45
  }
46
46
 
47
- apiRef.current.publishEvent(GridEvents.cellKeyDown, props, event);
47
+ apiRef.current.publishEvent('cellKeyDown', props, event);
48
48
  };
49
49
 
50
50
  const handleClick = event => {
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { GridRenderCellParams } from '@mui/x-data-grid';
3
+ declare const GridRowReorderCell: (params: GridRenderCellParams) => JSX.Element;
4
+ export { GridRowReorderCell };
5
+ export declare const renderRowReorderCell: (params: GridRenderCellParams) => JSX.Element;
@@ -0,0 +1,72 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { unstable_composeClasses as composeClasses } from '@mui/material';
4
+ import { gridRowTreeDepthSelector, gridSortModelSelector, useGridApiContext, useGridSelector, getDataGridUtilityClass, gridEditRowsStateSelector } from '@mui/x-data-grid';
5
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+
9
+ const useUtilityClasses = ownerState => {
10
+ const {
11
+ isDraggable,
12
+ classes
13
+ } = ownerState;
14
+ const slots = {
15
+ root: ['rowReorderCell', isDraggable && 'rowReorderCell--draggable'],
16
+ placeholder: ['rowReorderCellPlaceholder']
17
+ };
18
+ return composeClasses(slots, getDataGridUtilityClass, classes);
19
+ };
20
+
21
+ const GridRowReorderCell = params => {
22
+ const apiRef = useGridApiContext();
23
+ const rootProps = useGridRootProps();
24
+ const sortModel = useGridSelector(apiRef, gridSortModelSelector);
25
+ const treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
26
+ const editRowsState = useGridSelector(apiRef, gridEditRowsStateSelector); // eslint-disable-next-line no-underscore-dangle
27
+
28
+ const cellValue = params.row.__reorder__ || params.id; // TODO: remove sortModel and treeDepth checks once row reorder is compatible
29
+
30
+ const isDraggable = !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0;
31
+ const ownerState = {
32
+ isDraggable,
33
+ classes: rootProps.classes
34
+ };
35
+ const classes = useUtilityClasses(ownerState);
36
+ const publish = React.useCallback((eventName, propHandler) => event => {
37
+ // Ignore portal
38
+ // The target is not an element when triggered by a Select inside the cell
39
+ // See https://github.com/mui/material-ui/issues/10534
40
+ if (event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
41
+ return;
42
+ } // The row might have been deleted
43
+
44
+
45
+ if (!apiRef.current.getRow(params.row.id)) {
46
+ return;
47
+ }
48
+
49
+ apiRef.current.publishEvent(eventName, apiRef.current.getRowParams(params.row.id), event);
50
+
51
+ if (propHandler) {
52
+ propHandler(event);
53
+ }
54
+ }, [apiRef, params.row.id]);
55
+ const draggableEventHandlers = {
56
+ onDragStart: publish('rowDragStart'),
57
+ onDragOver: publish('rowDragOver'),
58
+ onDragEnd: publish('rowDragEnd')
59
+ };
60
+ return /*#__PURE__*/_jsxs("div", _extends({
61
+ className: classes.root,
62
+ draggable: isDraggable
63
+ }, draggableEventHandlers, {
64
+ children: [/*#__PURE__*/_jsx(rootProps.components.RowReorderIcon, {}), /*#__PURE__*/_jsx("div", {
65
+ className: classes.placeholder,
66
+ children: cellValue
67
+ })]
68
+ }));
69
+ };
70
+
71
+ export { GridRowReorderCell };
72
+ export const renderRowReorderCell = params => /*#__PURE__*/_jsx(GridRowReorderCell, _extends({}, params));
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
4
  import IconButton from '@mui/material/IconButton';
5
5
  import Box from '@mui/material/Box';
6
- import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass, GridEvents } from '@mui/x-data-grid';
6
+ import { useGridSelector, gridFilteredDescendantCountLookupSelector, getDataGridUtilityClass } from '@mui/x-data-grid';
7
7
  import { isNavigationKey } from '@mui/x-data-grid/internals';
8
8
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
9
9
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
@@ -47,7 +47,7 @@ const GridTreeDataGroupingCell = props => {
47
47
  }
48
48
 
49
49
  if (isNavigationKey(event.key) && !event.shiftKey) {
50
- apiRef.current.publishEvent(GridEvents.cellNavigationKeyDown, props, event);
50
+ apiRef.current.publishEvent('cellNavigationKeyDown', props, event);
51
51
  }
52
52
  };
53
53
 
@@ -107,10 +107,21 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
107
107
  */
108
108
  field: PropTypes.string.isRequired,
109
109
 
110
+ /**
111
+ * A ref allowing to set imperative focus.
112
+ * It can be passed to the element that should receive focus.
113
+ * @ignore - do not document.
114
+ */
115
+ focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
116
+ current: PropTypes.shape({
117
+ focus: PropTypes.func.isRequired
118
+ })
119
+ })]),
120
+
110
121
  /**
111
122
  * The cell value formatted with the column valueFormatter.
112
123
  */
113
- formattedValue: PropTypes.any.isRequired,
124
+ formattedValue: PropTypes.any,
114
125
 
115
126
  /**
116
127
  * Get the cell value of a row and field.
@@ -155,6 +166,6 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
155
166
  /**
156
167
  * The cell value, but if the column has valueGetter, use getValue.
157
168
  */
158
- value: PropTypes.any.isRequired
169
+ value: PropTypes.any
159
170
  } : void 0;
160
171
  export { GridTreeDataGroupingCell };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import MuiDivider from '@mui/material/Divider';
4
- import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, GridEvents, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
4
+ import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
5
5
  import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
6
6
  import { GridColumnPinningMenuItems } from '../../../components/GridColumnPinningMenuItems';
7
7
  import { GridPinnedPosition } from './gridColumnPinningInterface';
@@ -83,8 +83,8 @@ export const useGridColumnPinning = (apiRef, props) => {
83
83
  const handleMouseLeave = React.useCallback((params, event) => {
84
84
  updateHoveredClassOnSiblingRows(event);
85
85
  }, [updateHoveredClassOnSiblingRows]);
86
- useGridApiEventHandler(apiRef, GridEvents.rowMouseEnter, handleMouseEnter);
87
- useGridApiEventHandler(apiRef, GridEvents.rowMouseLeave, handleMouseLeave);
86
+ useGridApiEventHandler(apiRef, 'rowMouseEnter', handleMouseEnter);
87
+ useGridApiEventHandler(apiRef, 'rowMouseLeave', handleMouseLeave);
88
88
  /**
89
89
  * PRE-PROCESSING
90
90
  */
@@ -191,7 +191,7 @@ export const useGridColumnPinning = (apiRef, props) => {
191
191
  propModel: props.pinnedColumns,
192
192
  propOnChange: props.onPinnedColumnsChange,
193
193
  stateSelector: gridPinnedColumnsSelector,
194
- changeEvent: GridEvents.pinnedColumnsChange
194
+ changeEvent: 'pinnedColumnsChange'
195
195
  });
196
196
  const checkIfEnabled = React.useCallback(methodName => {
197
197
  if (props.disableColumnPinning) {
@@ -4,7 +4,6 @@ import { GridApiPro } from '../../../models/gridApiPro';
4
4
  import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
5
5
  export declare const columnReorderStateInitializer: GridStateInitializer;
6
6
  /**
7
- * Only available in DataGridPro
8
7
  * @requires useGridColumns (method)
9
8
  */
10
9
  export declare const useGridColumnReorder: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'disableColumnReorder' | 'classes'>) => void;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
- import { useGridApiEventHandler, getDataGridUtilityClass, GridEvents, useGridLogger } from '@mui/x-data-grid';
4
+ import { useGridApiEventHandler, getDataGridUtilityClass, useGridLogger } from '@mui/x-data-grid';
5
5
  import { gridColumnReorderDragColSelector } from './columnReorderSelector';
6
6
  const CURSOR_MOVE_DIRECTION_LEFT = 'left';
7
7
  const CURSOR_MOVE_DIRECTION_RIGHT = 'right';
@@ -28,7 +28,6 @@ export const columnReorderStateInitializer = state => _extends({}, state, {
28
28
  }
29
29
  });
30
30
  /**
31
- * Only available in DataGridPro
32
31
  * @requires useGridColumns (method)
33
32
  */
34
33
 
@@ -50,7 +49,7 @@ export const useGridColumnReorder = (apiRef, props) => {
50
49
  clearTimeout(removeDnDStylesTimeout.current);
51
50
  };
52
51
  }, []);
53
- const handleColumnHeaderDragStart = React.useCallback((params, event) => {
52
+ const handleDragStart = React.useCallback((params, event) => {
54
53
  if (props.disableColumnReorder || params.colDef.disableReorder) {
55
54
  return;
56
55
  }
@@ -156,10 +155,10 @@ export const useGridColumnReorder = (apiRef, props) => {
156
155
  }));
157
156
  apiRef.current.forceUpdate();
158
157
  }, [props.disableColumnReorder, logger, apiRef]);
159
- useGridApiEventHandler(apiRef, GridEvents.columnHeaderDragStart, handleColumnHeaderDragStart);
160
- useGridApiEventHandler(apiRef, GridEvents.columnHeaderDragEnter, handleDragEnter);
161
- useGridApiEventHandler(apiRef, GridEvents.columnHeaderDragOver, handleDragOver);
162
- useGridApiEventHandler(apiRef, GridEvents.columnHeaderDragEnd, handleDragEnd);
163
- useGridApiEventHandler(apiRef, GridEvents.cellDragEnter, handleDragEnter);
164
- useGridApiEventHandler(apiRef, GridEvents.cellDragOver, handleDragOver);
158
+ useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleDragStart);
159
+ useGridApiEventHandler(apiRef, 'columnHeaderDragEnter', handleDragEnter);
160
+ useGridApiEventHandler(apiRef, 'columnHeaderDragOver', handleDragOver);
161
+ useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleDragEnd);
162
+ useGridApiEventHandler(apiRef, 'cellDragEnter', handleDragEnter);
163
+ useGridApiEventHandler(apiRef, 'cellDragOver', handleDragOver);
165
164
  };
@@ -4,7 +4,6 @@ import { GridApiPro } from '../../../models/gridApiPro';
4
4
  import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
5
5
  export declare const columnResizeStateInitializer: GridStateInitializer;
6
6
  /**
7
- * Only available in DataGridPro
8
7
  * @requires useGridColumns (method, event)
9
8
  * TODO: improve experience for last column
10
9
  */