@mui/x-data-grid-pro 5.6.1 → 5.9.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 (119) hide show
  1. package/CHANGELOG.md +275 -53
  2. package/DataGridPro/DataGridPro.d.ts +7 -1
  3. package/DataGridPro/DataGridPro.js +47 -18
  4. package/DataGridPro/useDataGridProComponent.js +15 -13
  5. package/DataGridPro/useDataGridProProps.d.ts +2 -1
  6. package/LICENSE +12 -0
  7. package/README.md +1 -1
  8. package/components/DataGridProColumnHeaders.js +10 -16
  9. package/components/DataGridProVirtualScroller.js +6 -9
  10. package/components/GridDetailPanelToggleCell.js +15 -4
  11. package/components/GridGroupingCriteriaCell.d.ts +2 -5
  12. package/components/GridGroupingCriteriaCell.js +2 -74
  13. package/components/GridTreeDataGroupingCell.js +15 -4
  14. package/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
  15. package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
  16. package/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  17. package/hooks/features/columnResize/useGridColumnResize.js +18 -6
  18. package/hooks/features/detailPanel/useGridDetailPanel.js +12 -4
  19. package/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  20. package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
  21. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +6 -0
  22. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +5 -2
  23. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
  24. package/hooks/features/rowGrouping/useGridRowGrouping.js +45 -168
  25. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
  26. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +131 -4
  27. package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -0
  28. package/hooks/features/treeData/gridTreeDataUtils.js +2 -0
  29. package/hooks/features/treeData/useGridTreeData.d.ts +1 -5
  30. package/hooks/features/treeData/useGridTreeData.js +3 -84
  31. package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
  32. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +73 -4
  33. package/index.d.ts +1 -1
  34. package/index.js +2 -2
  35. package/legacy/DataGridPro/DataGridPro.js +47 -18
  36. package/legacy/DataGridPro/useDataGridProComponent.js +15 -13
  37. package/legacy/components/DataGridProColumnHeaders.js +10 -16
  38. package/legacy/components/DataGridProVirtualScroller.js +6 -9
  39. package/legacy/components/GridDetailPanelToggleCell.js +15 -4
  40. package/legacy/components/GridGroupingCriteriaCell.js +2 -74
  41. package/legacy/components/GridTreeDataGroupingCell.js +15 -4
  42. package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
  43. package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
  44. package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  45. package/legacy/hooks/features/columnResize/useGridColumnResize.js +18 -6
  46. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +12 -4
  47. package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  48. package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
  49. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +19 -2
  50. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +47 -173
  51. package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +138 -4
  52. package/legacy/hooks/features/treeData/gridTreeDataUtils.js +2 -0
  53. package/legacy/hooks/features/treeData/useGridTreeData.js +3 -92
  54. package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +85 -4
  55. package/legacy/index.js +2 -2
  56. package/legacy/utils/domUtils.js +30 -3
  57. package/legacy/utils/releaseInfo.js +15 -0
  58. package/models/dataGridProProps.d.ts +9 -8
  59. package/models/gridGroupingColDefOverride.d.ts +2 -2
  60. package/models/gridGroupingValueGetterParams.d.ts +1 -1
  61. package/modern/DataGridPro/DataGridPro.js +47 -18
  62. package/modern/DataGridPro/useDataGridProComponent.js +13 -13
  63. package/modern/components/DataGridProColumnHeaders.js +10 -16
  64. package/modern/components/DataGridProVirtualScroller.js +6 -9
  65. package/modern/components/GridDetailPanelToggleCell.js +15 -4
  66. package/modern/components/GridGroupingCriteriaCell.js +2 -74
  67. package/modern/components/GridTreeDataGroupingCell.js +15 -4
  68. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
  69. package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
  70. package/modern/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  71. package/modern/hooks/features/columnResize/useGridColumnResize.js +18 -6
  72. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +12 -4
  73. package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  74. package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
  75. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
  76. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +45 -168
  77. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +131 -4
  78. package/modern/hooks/features/treeData/gridTreeDataUtils.js +2 -0
  79. package/modern/hooks/features/treeData/useGridTreeData.js +3 -84
  80. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +73 -4
  81. package/modern/index.js +2 -2
  82. package/modern/utils/domUtils.js +30 -3
  83. package/modern/utils/releaseInfo.js +15 -0
  84. package/node/DataGridPro/DataGridPro.js +45 -17
  85. package/node/DataGridPro/useDataGridProComponent.js +15 -13
  86. package/node/components/DataGridProColumnHeaders.js +10 -16
  87. package/node/components/DataGridProVirtualScroller.js +6 -9
  88. package/node/components/GridDetailPanelToggleCell.js +15 -4
  89. package/node/components/GridGroupingCriteriaCell.js +1 -72
  90. package/node/components/GridTreeDataGroupingCell.js +15 -4
  91. package/node/hooks/features/columnPinning/useGridColumnPinning.js +5 -5
  92. package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +1 -1
  93. package/node/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  94. package/node/hooks/features/columnResize/useGridColumnResize.js +18 -6
  95. package/node/hooks/features/detailPanel/useGridDetailPanel.js +11 -3
  96. package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  97. package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +1 -1
  98. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +24 -5
  99. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +41 -166
  100. package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +134 -1
  101. package/node/hooks/features/treeData/gridTreeDataUtils.js +5 -2
  102. package/node/hooks/features/treeData/useGridTreeData.js +2 -93
  103. package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +75 -3
  104. package/node/index.js +9 -9
  105. package/node/utils/domUtils.js +30 -3
  106. package/node/utils/releaseInfo.js +25 -0
  107. package/package.json +7 -7
  108. package/typeOverloads/modules.d.ts +6 -6
  109. package/typeOverloads/reexports.d.ts +1 -1
  110. package/utils/domUtils.d.ts +2 -1
  111. package/utils/domUtils.js +30 -3
  112. package/utils/releaseInfo.d.ts +1 -0
  113. package/utils/releaseInfo.js +15 -0
  114. package/utils/tree/buildRowTree.d.ts +3 -3
  115. package/components/Watermark.d.ts +0 -2
  116. package/components/Watermark.js +0 -43
  117. package/legacy/components/Watermark.js +0 -43
  118. package/modern/components/Watermark.js +0 -43
  119. package/node/components/Watermark.js +0 -56
@@ -1,28 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { LicenseInfo } from '@mui/x-license-pro';
4
- import { chainPropTypes, ponyfillGlobal } from '@mui/utils';
3
+ import { useLicenseVerifier, Watermark } from '@mui/x-license-pro';
4
+ import { chainPropTypes } from '@mui/utils';
5
5
  import { GridBody, GridErrorHandler, GridFooterPlaceholder, GridHeaderPlaceholder, GridRoot, GridContextProvider } from '@mui/x-data-grid';
6
6
  import { useDataGridProComponent } from './useDataGridProComponent';
7
- import { Watermark } from '../components/Watermark';
8
7
  import { useDataGridProProps } from './useDataGridProProps';
9
8
  import { DataGridProVirtualScroller } from '../components/DataGridProVirtualScroller';
10
- import { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders'; // This is the package release date. Each package version should update this const
11
- // automatically when a new version is published on npm.
12
-
9
+ import { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders';
10
+ import { getReleaseInfo } from '../utils/releaseInfo';
13
11
  import { jsx as _jsx } from "react/jsx-runtime";
14
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- let RELEASE_INFO = "MTY0Njg2NjgwMDAwMA=="; // eslint-disable-next-line no-useless-concat
16
-
17
- if (process.env.NODE_ENV !== 'production' && RELEASE_INFO === '__RELEASE' + '_INFO__') {
18
- // eslint-disable-next-line no-underscore-dangle
19
- RELEASE_INFO = ponyfillGlobal.__MUI_RELEASE_INFO__;
20
- }
21
-
22
- LicenseInfo.setReleaseInfo(RELEASE_INFO);
13
+ const releaseInfo = getReleaseInfo();
23
14
  const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps, ref) {
24
15
  const props = useDataGridProProps(inProps);
25
16
  const apiRef = useDataGridProComponent(props.apiRef, props);
17
+ useLicenseVerifier('x-data-grid-pro', releaseInfo);
26
18
  return /*#__PURE__*/_jsx(GridContextProvider, {
27
19
  apiRef: apiRef,
28
20
  props: props,
@@ -35,7 +27,10 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
35
27
  children: [/*#__PURE__*/_jsx(GridHeaderPlaceholder, {}), /*#__PURE__*/_jsx(GridBody, {
36
28
  ColumnHeadersComponent: DataGridProColumnHeaders,
37
29
  VirtualScrollerComponent: DataGridProVirtualScroller,
38
- children: /*#__PURE__*/_jsx(Watermark, {})
30
+ children: /*#__PURE__*/_jsx(Watermark, {
31
+ packageName: "x-data-grid-pro",
32
+ releaseInfo: releaseInfo
33
+ })
39
34
  }), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
40
35
  })
41
36
  })
@@ -274,6 +269,7 @@ DataGridProRaw.propTypes = {
274
269
  * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
275
270
  */
276
271
  experimentalFeatures: PropTypes.shape({
272
+ newEditingApi: PropTypes.bool,
277
273
  preventCommitWhileValidating: PropTypes.bool,
278
274
  rowGrouping: PropTypes.bool,
279
275
  warnIfFocusStateIsNotSynced: PropTypes.bool
@@ -357,7 +353,8 @@ DataGridProRaw.propTypes = {
357
353
  * Determines the path of a row in the tree data.
358
354
  * For instance, a row with the path ["A", "B"] is the child of the row with the path ["A"].
359
355
  * Note that all paths must contain at least one element.
360
- * @param {GridRowModel} row The row from which we want the path.
356
+ * @template R
357
+ * @param {R} row The row from which we want the path.
361
358
  * @returns {string[]} The path to the row.
362
359
  */
363
360
  getTreeDataPath: PropTypes.func,
@@ -621,7 +618,7 @@ DataGridProRaw.propTypes = {
621
618
  * @param {GridEditCellPropsParams} params With all properties from [[GridEditCellPropsParams]].
622
619
  * @param {MuiEvent<React.SyntheticEvent>} event The event that caused this prop to be called.
623
620
  * @param {GridCallbackDetails} details Additional details for this callback.
624
- * @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/api/data-grid/grid-col-def/)
621
+ * @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/x/api/data-grid/grid-col-def/)
625
622
  */
626
623
  onEditCellPropsChange: PropTypes.func,
627
624
 
@@ -668,6 +665,28 @@ DataGridProRaw.propTypes = {
668
665
  */
669
666
  onPinnedColumnsChange: PropTypes.func,
670
667
 
668
+ /**
669
+ * Callback fired when the preferences panel is closed.
670
+ * @param {GridPreferencePanelParams} params With all properties from [[GridPreferencePanelParams]].
671
+ * @param {MuiEvent<{}>} event The event object.
672
+ * @param {GridCallbackDetails} details Additional details for this callback.
673
+ */
674
+ onPreferencePanelClose: PropTypes.func,
675
+
676
+ /**
677
+ * Callback fired when the preferences panel is opened.
678
+ * @param {GridPreferencePanelParams} params With all properties from [[GridPreferencePanelParams]].
679
+ * @param {MuiEvent<{}>} event The event object.
680
+ * @param {GridCallbackDetails} details Additional details for this callback.
681
+ */
682
+ onPreferencePanelOpen: PropTypes.func,
683
+
684
+ /**
685
+ * Callback called when `processRowUpdate` throws an error or rejects.
686
+ * @param {any} error The error thrown.
687
+ */
688
+ onProcessRowUpdateError: PropTypes.func,
689
+
671
690
  /**
672
691
  * Callback fired when the grid is resized.
673
692
  * @param {ElementSize} containerSize With all properties from [[ElementSize]].
@@ -787,6 +806,16 @@ DataGridProRaw.propTypes = {
787
806
  right: PropTypes.arrayOf(PropTypes.string)
788
807
  }),
789
808
 
809
+ /**
810
+ * Callback called before updating a row with new values in the row and cell editing.
811
+ * Only applied if `props.experimentalFeatures.newEditingApi: true`.
812
+ * @template R
813
+ * @param {R} newRow Row object with the new values.
814
+ * @param {R} oldRow Row object with the old values.
815
+ * @returns {Promise<R> | R} The final values to update the row.
816
+ */
817
+ processRowUpdate: PropTypes.func,
818
+
790
819
  /**
791
820
  * Number of extra rows to be rendered before/after the visible slice.
792
821
  * @default 3
@@ -820,7 +849,7 @@ DataGridProRaw.propTypes = {
820
849
  /**
821
850
  * Set of rows of type [[GridRowsProp]].
822
851
  */
823
- rows: PropTypes.arrayOf(PropTypes.object).isRequired,
852
+ rows: PropTypes.array.isRequired,
824
853
 
825
854
  /**
826
855
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -1,4 +1,4 @@
1
- import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboard, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, useGridRows, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, editingStateInitializer, 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';
@@ -21,25 +21,22 @@ export const useDataGridProComponent = (inputApiRef, props) => {
21
21
  useGridSelectionPreProcessors(apiRef, props);
22
22
  useGridRowGroupingPreProcessors(apiRef, props);
23
23
  useGridTreeDataPreProcessors(apiRef, props);
24
- useGridDetailPanelPreProcessors(apiRef, props);
25
- useGridColumnPinningPreProcessors(apiRef, props); // Must be the last because it changes the order of the columns.
24
+ useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
25
+ // Because it changes the order of the columns.
26
26
 
27
+ useGridColumnPinningPreProcessors(apiRef, props);
28
+ useGridRowsPreProcessors(apiRef);
27
29
  /**
28
30
  * Register all state initializers here.
29
31
  */
30
32
 
33
+ useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
31
34
  useGridInitializeState(selectionStateInitializer, apiRef, props);
32
35
  useGridInitializeState(detailPanelStateInitializer, apiRef, props);
33
36
  useGridInitializeState(columnPinningStateInitializer, apiRef, props);
34
- useGridInitializeState(rowGroupingStateInitializer, apiRef, props); // FIXME Call in the same relative position that useGridRowGrouping is called
35
-
36
37
  useGridInitializeState(columnsStateInitializer, apiRef, props);
37
- useGridRowGrouping(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
38
-
39
- useGridTreeData(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
40
-
41
38
  useGridInitializeState(rowsStateInitializer, apiRef, props);
42
- useGridInitializeState(editingStateInitializer, apiRef, props);
39
+ useGridInitializeState(props.experimentalFeatures?.newEditingApi ? editingStateInitializer_new : editingStateInitializer_old, apiRef, props);
43
40
  useGridInitializeState(focusStateInitializer, apiRef, props);
44
41
  useGridInitializeState(sortingStateInitializer, apiRef, props);
45
42
  useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
@@ -50,18 +47,23 @@ export const useDataGridProComponent = (inputApiRef, props) => {
50
47
  useGridInitializeState(paginationStateInitializer, apiRef, props);
51
48
  useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
52
49
  useGridInitializeState(columnMenuStateInitializer, apiRef, props);
50
+ useGridRowGrouping(apiRef, props);
51
+ useGridTreeData(apiRef);
52
+ useGridKeyboardNavigation(apiRef, props);
53
53
  useGridSelection(apiRef, props);
54
54
  useGridDetailPanel(apiRef, props);
55
55
  useGridColumnPinning(apiRef, props);
56
56
  useGridColumns(apiRef, props);
57
57
  useGridRows(apiRef, props);
58
58
  useGridParamsApi(apiRef);
59
+ useGridColumnSpanning(apiRef);
59
60
  useGridDetailPanelCache(apiRef, props);
61
+ const useGridEditing = props.experimentalFeatures?.newEditingApi ? useGridEditing_new : useGridEditing_old;
60
62
  useGridEditing(apiRef, props);
61
63
  useGridFocus(apiRef, props);
62
- useGridSorting(apiRef, props);
63
64
  useGridPreferencesPanel(apiRef);
64
65
  useGridFilter(apiRef, props);
66
+ useGridSorting(apiRef, props);
65
67
  useGridDensity(apiRef, props);
66
68
  useGridColumnReorder(apiRef, props);
67
69
  useGridColumnResize(apiRef, props);
@@ -70,8 +72,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
70
72
  useGridScroll(apiRef, props);
71
73
  useGridInfiniteLoader(apiRef, props);
72
74
  useGridColumnMenu(apiRef);
73
- useGridKeyboard(apiRef);
74
- useGridKeyboardNavigation(apiRef, props);
75
75
  useGridCsvExport(apiRef);
76
76
  useGridPrintExport(apiRef, props);
77
77
  useGridClipboard(apiRef);
@@ -91,7 +91,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
91
91
  const {
92
92
  isDragging,
93
93
  renderContext,
94
- updateInnerPosition,
95
94
  getRootProps,
96
95
  getInnerProps,
97
96
  getColumns
@@ -105,11 +104,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
105
104
  classes: rootProps.classes
106
105
  };
107
106
  const classes = useUtilityClasses(ownerState);
108
- React.useEffect(() => {
109
- if (renderContext) {
110
- updateInnerPosition(renderContext);
111
- }
112
- }, [renderContext, updateInnerPosition]);
113
107
  const leftRenderContext = renderContext && leftPinnedColumns.length ? _extends({}, renderContext, {
114
108
  firstColumnIndex: 0,
115
109
  lastColumnIndex: leftPinnedColumns.length
@@ -134,7 +128,15 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
134
128
  }, {
135
129
  disableReorder: true
136
130
  })
137
- }), rightRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, {
131
+ }), /*#__PURE__*/_jsx(GridColumnHeadersInner, _extends({
132
+ isDragging: isDragging
133
+ }, getInnerProps(), {
134
+ children: getColumns({
135
+ renderContext,
136
+ minFirstColumn: leftPinnedColumns.length,
137
+ maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
138
+ })
139
+ })), rightRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, {
138
140
  ownerState: {
139
141
  side: GridPinnedPosition.right
140
142
  },
@@ -150,14 +152,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
150
152
  disableReorder: true,
151
153
  separatorSide: GridColumnHeaderSeparatorSides.Left
152
154
  })
153
- }), /*#__PURE__*/_jsx(GridColumnHeadersInner, _extends({
154
- isDragging: isDragging
155
- }, getInnerProps(), {
156
- children: getColumns({
157
- renderContext,
158
- minFirstColumn: leftPinnedColumns.length,
159
- maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
160
- })
161
- }))]
155
+ })]
162
156
  }));
163
157
  });
@@ -173,9 +173,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
173
173
  }, [renderContext, updateRenderZonePosition]);
174
174
  useGridApiEventHandler(apiRef, GridEvents.columnWidthChange, refreshRenderZonePosition);
175
175
  useGridApiEventHandler(apiRef, GridEvents.columnOrderChange, refreshRenderZonePosition);
176
- React.useEffect(() => {
177
- refreshRenderZonePosition();
178
- }, [refreshRenderZonePosition]);
179
176
  const leftRenderContext = renderContext && leftPinnedColumns.length > 0 ? _extends({}, renderContext, {
180
177
  firstColumnIndex: 0,
181
178
  lastColumnIndex: leftPinnedColumns.length
@@ -241,7 +238,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
241
238
  maxLastColumn: leftRenderContext.lastColumnIndex,
242
239
  availableSpace: 0
243
240
  })
244
- }), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
241
+ }), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
242
+ children: getRows({
243
+ renderContext
244
+ })
245
+ })), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
245
246
  ref: rightColumns,
246
247
  ownerState: {
247
248
  side: GridPinnedPosition.right
@@ -254,11 +255,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
254
255
  maxLastColumn: rightRenderContext.lastColumnIndex,
255
256
  availableSpace: 0
256
257
  })
257
- }), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
258
- children: getRows({
259
- renderContext
260
- })
261
- })), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
258
+ }), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
262
259
  className: classes.detailPanels,
263
260
  children: detailPanels
264
261
  })]
@@ -73,16 +73,27 @@ 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.
83
94
  * @param {GridRowId} id The row id.
84
95
  * @param {string} field The field.
85
- * @returns {GridCellValue} The cell value.
96
+ * @returns {any} The cell value.
86
97
  * @deprecated Use `params.row` to directly access the fields you want instead.
87
98
  */
88
99
  getValue: PropTypes.func.isRequired,
@@ -105,7 +116,7 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
105
116
  /**
106
117
  * The row model of the row that the current cell belongs to.
107
118
  */
108
- row: PropTypes.any.isRequired,
119
+ row: PropTypes.object.isRequired,
109
120
 
110
121
  /**
111
122
  * The node of the row that the current cell belongs to.
@@ -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 };
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
3
  import IconButton from '@mui/material/IconButton';
5
4
  import Box from '@mui/material/Box';
@@ -20,7 +19,7 @@ const useUtilityClasses = ownerState => {
20
19
  return composeClasses(slots, getDataGridUtilityClass, classes);
21
20
  };
22
21
 
23
- const GridGroupingCriteriaCell = props => {
22
+ export const GridGroupingCriteriaCell = props => {
24
23
  const {
25
24
  id,
26
25
  field,
@@ -74,75 +73,4 @@ const GridGroupingCriteriaCell = props => {
74
73
  children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? ` (${filteredDescendantCount})` : '']
75
74
  })]
76
75
  });
77
- };
78
-
79
- process.env.NODE_ENV !== "production" ? GridGroupingCriteriaCell.propTypes = {
80
- // ----------------------------- Warning --------------------------------
81
- // | These PropTypes are generated from the TypeScript type definitions |
82
- // | To update them edit the TypeScript types and run "yarn proptypes" |
83
- // ----------------------------------------------------------------------
84
-
85
- /**
86
- * GridApi that let you manipulate the grid.
87
- */
88
- api: PropTypes.any.isRequired,
89
-
90
- /**
91
- * The mode of the cell.
92
- */
93
- cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
94
-
95
- /**
96
- * The column of the row that the current cell belongs to.
97
- */
98
- colDef: PropTypes.object.isRequired,
99
-
100
- /**
101
- * The column field of the cell that triggered the event.
102
- */
103
- field: PropTypes.string.isRequired,
104
-
105
- /**
106
- * The cell value formatted with the column valueFormatter.
107
- */
108
- formattedValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool]),
109
-
110
- /**
111
- * Get the cell value of a row and field.
112
- * @param {GridRowId} id The row id.
113
- * @param {string} field The field.
114
- * @returns {GridCellValue} The cell value.
115
- */
116
- getValue: PropTypes.func.isRequired,
117
-
118
- /**
119
- * If true, the cell is the active element.
120
- */
121
- hasFocus: PropTypes.bool.isRequired,
122
-
123
- /**
124
- * The grid row id.
125
- */
126
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
127
-
128
- /**
129
- * If true, the cell is editable.
130
- */
131
- isEditable: PropTypes.bool,
132
-
133
- /**
134
- * The row model of the row that the current cell belongs to.
135
- */
136
- row: PropTypes.object.isRequired,
137
-
138
- /**
139
- * the tabIndex value.
140
- */
141
- tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
142
-
143
- /**
144
- * The cell value, but if the column has valueGetter, use getValue.
145
- */
146
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool])
147
- } : void 0;
148
- export { GridGroupingCriteriaCell };
76
+ };
@@ -105,16 +105,27 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
105
105
  */
106
106
  field: PropTypes.string.isRequired,
107
107
 
108
+ /**
109
+ * A ref allowing to set imperative focus.
110
+ * It can be passed to the element that should receive focus.
111
+ * @ignore - do not document.
112
+ */
113
+ focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
114
+ current: PropTypes.shape({
115
+ focus: PropTypes.func.isRequired
116
+ })
117
+ })]),
118
+
108
119
  /**
109
120
  * The cell value formatted with the column valueFormatter.
110
121
  */
111
- formattedValue: PropTypes.any.isRequired,
122
+ formattedValue: PropTypes.any,
112
123
 
113
124
  /**
114
125
  * Get the cell value of a row and field.
115
126
  * @param {GridRowId} id The row id.
116
127
  * @param {string} field The field.
117
- * @returns {GridCellValue} The cell value.
128
+ * @returns {any} The cell value.
118
129
  * @deprecated Use `params.row` to directly access the fields you want instead.
119
130
  */
120
131
  getValue: PropTypes.func.isRequired,
@@ -138,7 +149,7 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
138
149
  /**
139
150
  * The row model of the row that the current cell belongs to.
140
151
  */
141
- row: PropTypes.any.isRequired,
152
+ row: PropTypes.object.isRequired,
142
153
 
143
154
  /**
144
155
  * The node of the row that the current cell belongs to.
@@ -153,6 +164,6 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
153
164
  /**
154
165
  * The cell value, but if the column has valueGetter, use getValue.
155
166
  */
156
- value: PropTypes.any.isRequired
167
+ value: PropTypes.any
157
168
  } : void 0;
158
169
  export { GridTreeDataGroupingCell };
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import MuiDivider from '@mui/material/Divider';
4
4
  import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, GridEvents, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
5
- import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
5
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
6
6
  import { GridColumnPinningMenuItems } from '../../../components/GridColumnPinningMenuItems';
7
7
  import { GridPinnedPosition } from './gridColumnPinningInterface';
8
8
  import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
@@ -175,11 +175,11 @@ export const useGridColumnPinning = (apiRef, props) => {
175
175
 
176
176
  return params;
177
177
  }, [apiRef]);
178
- useGridRegisterPreProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
179
- useGridRegisterPreProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
180
- useGridRegisterPreProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
181
- useGridRegisterPreProcessor(apiRef, 'exportState', stateExportPreProcessing);
182
- useGridRegisterPreProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
178
+ useGridRegisterPipeProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
179
+ useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
180
+ useGridRegisterPipeProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
181
+ useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
182
+ useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
183
183
  apiRef.current.unstable_updateControlState({
184
184
  stateId: 'pinnedColumns',
185
185
  propModel: props.pinnedColumns,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
3
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
4
4
  import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
5
5
  import { columnPinningStateInitializer } from './useGridColumnPinning';
6
6
  import { filterColumns } from '../../../components/DataGridProVirtualScroller';
@@ -41,5 +41,5 @@ export const useGridColumnPinningPreProcessors = (apiRef, props) => {
41
41
  all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
42
42
  });
43
43
  }, [disableColumnPinning, pinnedColumns]);
44
- useGridRegisterPreProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
44
+ useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
45
45
  };
@@ -116,7 +116,7 @@ export const useGridColumnReorder = (apiRef, props) => {
116
116
  canBeReordered = targetColIndex < visibleColumns.length - 1 && !visibleColumns[targetColIndex + 1].disableReorder;
117
117
  }
118
118
 
119
- const canBeReorderedProcessed = apiRef.current.unstable_applyPreProcessors('canBeReordered', canBeReordered, {
119
+ const canBeReorderedProcessed = apiRef.current.unstable_applyPipeProcessors('canBeReordered', canBeReordered, {
120
120
  targetIndex: targetColVisibleIndex
121
121
  });
122
122
 
@@ -100,17 +100,29 @@ export const useGridColumnResize = (apiRef, props) => {
100
100
 
101
101
  const updateWidth = newWidth => {
102
102
  logger.debug(`Updating width to ${newWidth} for col ${colDefRef.current.field}`);
103
+ const prevWidth = colElementRef.current.offsetWidth;
104
+ const widthDiff = newWidth - prevWidth;
103
105
  colDefRef.current.computedWidth = newWidth;
104
106
  colDefRef.current.width = newWidth;
105
- colDefRef.current.flex = undefined;
107
+ colDefRef.current.flex = 0;
106
108
  colElementRef.current.style.width = `${newWidth}px`;
107
109
  colElementRef.current.style.minWidth = `${newWidth}px`;
108
110
  colElementRef.current.style.maxWidth = `${newWidth}px`;
109
111
  colCellElementsRef.current.forEach(element => {
110
112
  const div = element;
111
- div.style.width = `${newWidth}px`;
112
- div.style.minWidth = `${newWidth}px`;
113
- div.style.maxWidth = `${newWidth}px`;
113
+ let finalWidth;
114
+
115
+ if (div.getAttribute('aria-colspan') === '1') {
116
+ finalWidth = `${newWidth}px`;
117
+ } else {
118
+ // Cell with colspan > 1 cannot be just updated width new width.
119
+ // Instead, we add width diff to the current width.
120
+ finalWidth = `${div.offsetWidth + widthDiff}px`;
121
+ }
122
+
123
+ div.style.width = finalWidth;
124
+ div.style.minWidth = finalWidth;
125
+ div.style.maxWidth = finalWidth;
114
126
  });
115
127
  };
116
128
 
@@ -170,7 +182,7 @@ export const useGridColumnResize = (apiRef, props) => {
170
182
  }, event);
171
183
  colDefRef.current = colDef;
172
184
  colElementRef.current = apiRef.current.columnHeadersContainerElementRef?.current.querySelector(`[data-field="${colDef.field}"]`);
173
- colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
185
+ colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
174
186
  const doc = ownerDocument(apiRef.current.rootElementRef.current);
175
187
  doc.body.style.cursor = 'col-resize';
176
188
  separatorSide.current = getSeparatorSide(event.currentTarget);
@@ -245,7 +257,7 @@ export const useGridColumnResize = (apiRef, props) => {
245
257
  }, event);
246
258
  colDefRef.current = colDef;
247
259
  colElementRef.current = findHeaderElementFromField(apiRef.current.columnHeadersElementRef?.current, colDef.field);
248
- colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
260
+ colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
249
261
  separatorSide.current = getSeparatorSide(event.target);
250
262
  initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
251
263
  const doc = ownerDocument(event.currentTarget);
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { GridEvents, useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
4
- import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
4
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
5
5
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
6
6
  import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
7
7
  export const detailPanelStateInitializer = (state, props) => {
@@ -33,11 +33,19 @@ export const useGridDetailPanel = (apiRef, props) => {
33
33
  apiRef.current.toggleDetailPanel(params.id);
34
34
  }, [apiRef, contentCache, props.getDetailPanelContent]);
35
35
  const handleCellKeyDown = React.useCallback((params, event) => {
36
- if (!event.ctrlKey || event.key !== 'Enter' || props.getDetailPanelContent == null) {
36
+ if (props.getDetailPanelContent == null) {
37
37
  return;
38
38
  }
39
39
 
40
- apiRef.current.toggleDetailPanel(params.id);
40
+ if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
41
+ // TODO v6: only support Space on the detail toggle
42
+ apiRef.current.toggleDetailPanel(params.id);
43
+ return;
44
+ }
45
+
46
+ if (params.field === GRID_DETAIL_PANEL_TOGGLE_FIELD && event.key === ' ') {
47
+ apiRef.current.toggleDetailPanel(params.id);
48
+ }
41
49
  }, [apiRef, props.getDetailPanelContent]);
42
50
  useGridApiEventHandler(apiRef, GridEvents.cellClick, handleCellClick);
43
51
  useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
@@ -54,7 +62,7 @@ export const useGridDetailPanel = (apiRef, props) => {
54
62
 
55
63
  });
56
64
  }, [apiRef, expandedRowIds]);
57
- useGridRegisterPreProcessor(apiRef, 'rowHeight', addDetailHeight);
65
+ useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
58
66
  apiRef.current.unstable_updateControlState({
59
67
  stateId: 'detailPanels',
60
68
  propModel: props.detailPanelExpandedRowIds,
@@ -39,7 +39,7 @@ export const useGridDetailPanelCache = (apiRef, props) => {
39
39
  });
40
40
  apiRef.current.forceUpdate();
41
41
  }, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
42
- useGridApiEventHandler(apiRef, GridEvents.visibleRowsSet, updateCaches);
42
+ useGridApiEventHandler(apiRef, GridEvents.sortedRowsSet, updateCaches);
43
43
  const isFirstRender = React.useRef(true);
44
44
 
45
45
  if (isFirstRender.current) {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
2
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
3
3
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_DETAIL_PANEL_TOGGLE_COL_DEF } from './gridDetailPanelToggleColDef';
4
4
  export const useGridDetailPanelPreProcessors = (apiRef, props) => {
5
5
  const addToggleColumn = React.useCallback(columnsState => {
@@ -24,5 +24,5 @@ export const useGridDetailPanelPreProcessors = (apiRef, props) => {
24
24
  columnsState.lookup[GRID_DETAIL_PANEL_TOGGLE_FIELD] = GRID_DETAIL_PANEL_TOGGLE_COL_DEF;
25
25
  return columnsState;
26
26
  }, [props.getDetailPanelContent]);
27
- useGridRegisterPreProcessor(apiRef, 'hydrateColumns', addToggleColumn);
27
+ useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', addToggleColumn);
28
28
  };