@mui/x-data-grid-pro 5.11.1 → 5.12.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 (110) hide show
  1. package/CHANGELOG.md +95 -18
  2. package/DataGridPro/DataGridPro.js +26 -27
  3. package/DataGridPro/useDataGridProComponent.js +0 -5
  4. package/DataGridPro/useDataGridProProps.js +6 -27
  5. package/README.md +2 -2
  6. package/components/DataGridProVirtualScroller.d.ts +1 -1
  7. package/components/DataGridProVirtualScroller.js +6 -3
  8. package/components/GridRowReorderCell.js +3 -3
  9. package/hooks/features/columnPinning/gridColumnPinningInterface.d.ts +6 -0
  10. package/hooks/features/columnPinning/useGridColumnPinning.js +72 -27
  11. package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
  12. package/hooks/features/rowReorder/useGridRowReorder.js +5 -1
  13. package/index.d.ts +0 -2
  14. package/index.js +2 -5
  15. package/legacy/DataGridPro/DataGridPro.js +26 -27
  16. package/legacy/DataGridPro/useDataGridProComponent.js +0 -5
  17. package/legacy/DataGridPro/useDataGridProProps.js +1 -20
  18. package/legacy/components/DataGridProVirtualScroller.js +6 -3
  19. package/legacy/components/GridRowReorderCell.js +5 -3
  20. package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +81 -32
  21. package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +70 -5
  22. package/legacy/hooks/features/rowReorder/useGridRowReorder.js +5 -1
  23. package/legacy/index.js +2 -5
  24. package/legacy/utils/releaseInfo.js +1 -1
  25. package/models/dataGridProProps.d.ts +0 -26
  26. package/models/gridApiPro.d.ts +1 -2
  27. package/models/gridStatePro.d.ts +0 -3
  28. package/modern/DataGridPro/DataGridPro.js +26 -27
  29. package/modern/DataGridPro/useDataGridProComponent.js +0 -5
  30. package/modern/DataGridPro/useDataGridProProps.js +1 -16
  31. package/modern/components/DataGridProVirtualScroller.js +6 -3
  32. package/modern/components/GridRowReorderCell.js +3 -3
  33. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +72 -27
  34. package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +67 -4
  35. package/modern/hooks/features/rowReorder/useGridRowReorder.js +5 -1
  36. package/modern/index.js +2 -5
  37. package/modern/utils/releaseInfo.js +1 -1
  38. package/node/DataGridPro/DataGridPro.js +26 -27
  39. package/node/DataGridPro/useDataGridProComponent.js +0 -7
  40. package/node/DataGridPro/useDataGridProProps.js +6 -28
  41. package/node/components/DataGridProVirtualScroller.js +6 -3
  42. package/node/components/GridRowReorderCell.js +3 -3
  43. package/node/hooks/features/columnPinning/useGridColumnPinning.js +71 -23
  44. package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +68 -5
  45. package/node/hooks/features/rowReorder/useGridRowReorder.js +5 -1
  46. package/node/index.js +2 -30
  47. package/node/utils/releaseInfo.js +1 -1
  48. package/package.json +6 -6
  49. package/typeOverloads/modules.d.ts +9 -21
  50. package/utils/releaseInfo.js +1 -1
  51. package/components/GridGroupingColumnLeafCell.d.ts +0 -4
  52. package/components/GridGroupingColumnLeafCell.js +0 -22
  53. package/components/GridGroupingCriteriaCell.d.ts +0 -7
  54. package/components/GridGroupingCriteriaCell.js +0 -78
  55. package/components/GridRowGroupableColumnMenuItems.d.ts +0 -11
  56. package/components/GridRowGroupableColumnMenuItems.js +0 -63
  57. package/components/GridRowGroupingColumnMenuItems.d.ts +0 -11
  58. package/components/GridRowGroupingColumnMenuItems.js +0 -58
  59. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +0 -43
  60. package/hooks/features/rowGrouping/createGroupingColDef.js +0 -318
  61. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +0 -37
  62. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -1
  63. package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +0 -4
  64. package/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -5
  65. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +0 -27
  66. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -139
  67. package/hooks/features/rowGrouping/index.d.ts +0 -3
  68. package/hooks/features/rowGrouping/index.js +0 -3
  69. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +0 -11
  70. package/hooks/features/rowGrouping/useGridRowGrouping.js +0 -200
  71. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +0 -4
  72. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -203
  73. package/legacy/components/GridGroupingColumnLeafCell.js +0 -20
  74. package/legacy/components/GridGroupingCriteriaCell.js +0 -74
  75. package/legacy/components/GridRowGroupableColumnMenuItems.js +0 -61
  76. package/legacy/components/GridRowGroupingColumnMenuItems.js +0 -56
  77. package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +0 -319
  78. package/legacy/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -1
  79. package/legacy/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -13
  80. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -147
  81. package/legacy/hooks/features/rowGrouping/index.js +0 -3
  82. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +0 -206
  83. package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -217
  84. package/legacy/models/gridGroupingValueGetterParams.js +0 -1
  85. package/models/gridGroupingValueGetterParams.d.ts +0 -31
  86. package/models/gridGroupingValueGetterParams.js +0 -1
  87. package/modern/components/GridGroupingColumnLeafCell.js +0 -20
  88. package/modern/components/GridGroupingCriteriaCell.js +0 -76
  89. package/modern/components/GridRowGroupableColumnMenuItems.js +0 -61
  90. package/modern/components/GridRowGroupingColumnMenuItems.js +0 -56
  91. package/modern/hooks/features/rowGrouping/createGroupingColDef.js +0 -302
  92. package/modern/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -1
  93. package/modern/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -5
  94. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -137
  95. package/modern/hooks/features/rowGrouping/index.js +0 -3
  96. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +0 -192
  97. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -203
  98. package/modern/models/gridGroupingValueGetterParams.js +0 -1
  99. package/node/components/GridGroupingColumnLeafCell.js +0 -38
  100. package/node/components/GridGroupingCriteriaCell.js +0 -99
  101. package/node/components/GridRowGroupableColumnMenuItems.js +0 -82
  102. package/node/components/GridRowGroupingColumnMenuItems.js +0 -78
  103. package/node/hooks/features/rowGrouping/createGroupingColDef.js +0 -341
  104. package/node/hooks/features/rowGrouping/gridRowGroupingInterfaces.js +0 -5
  105. package/node/hooks/features/rowGrouping/gridRowGroupingSelector.js +0 -18
  106. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +0 -172
  107. package/node/hooks/features/rowGrouping/index.js +0 -51
  108. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +0 -228
  109. package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +0 -227
  110. package/node/models/gridGroupingValueGetterParams.js +0 -5
package/CHANGELOG.md CHANGED
@@ -3,6 +3,85 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## v5.12.0
7
+
8
+ _May 31, 2022_
9
+
10
+ We'd like to offer a big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🎁 Introduce support for [dynamic row height](https://mui.com/x/react-data-grid/rows/#dynamic-row-height) (#4859) @m4theushw
13
+
14
+ <img src="https://user-images.githubusercontent.com/42154031/171183167-718d7bcd-ec0f-459e-97fe-0f650abb4a99.gif" width="800">
15
+
16
+ - ⚠️ Remove deprecated row grouping feature from `@mui/x-data-grid-pro`
17
+
18
+ Row grouping is available through the `@mui/x-data-grid-premium` package - see [Premium plan release blogpost](https://mui.com/blog/premium-plan-release/).
19
+
20
+ - 🐞 Bug fixes and improvements
21
+
22
+ ### `@mui/x-data-grid@v5.12.0` / `@mui/x-data-grid-pro@v5.12.0` / `@mui/x-data-grid-premium@v5.12.0`
23
+
24
+ - [DataGrid] Support dynamic row height (#4859) @m4theushw
25
+ - [DataGrid] Add `onMenuOpen` and `onMenuClose` props (#4825) @DanailH
26
+ - [DataGrid] Add generics to `GridActionsColDef` to match `GridColDef` (#4982) @subvertallchris
27
+ - [DataGrid] Disable drag event handlers when row or column reorder are disabled (#4857) @DanailH
28
+ - [DataGrid] Allow other attempts to stop edit mode if the first failed (#5016) @m4theushw
29
+ - [DataGrid] Better reflect the dependency on Material UI (#4795) @oliviertassinari
30
+ - [DataGrid] Add an id to the filter item created when opening the filter panel (#5014) @flaviendelangle
31
+ - [DataGrid] Use column visibility model on Hide All / Show All when enabled (#5050) @flaviendelangle
32
+ - [DataGridPro] Unpin columns back to original position (#4512) @m4theushw
33
+ - [DataGridPro] Remove experimental row grouping from Pro plan (#4949) @flaviendelangle
34
+ - [DataGridPro] Allow to scroll detail panel content if it overflows the panel (#4979) @cherniavskii
35
+ - [DataGridPro] Do not call `setRowIndex` when dragging a column over a row (#4987) @flaviendelangle
36
+ - [l10n] Add Norwegian (Bokmål) (nb-NO) locale (#5001) @spiftire
37
+ - [l10n] Add Turkish (tr-TR) locale (#5026) @Rassilion
38
+
39
+ ### `@mui/x-date-pickers@5.0.0-alpha.5` / `@mui/x-date-pickers-pro@5.0.0-alpha.5`
40
+
41
+ #### Breaking changes
42
+
43
+ - [pickers] Restructure props in `MonthPicker` / `YearPicker` and `DayPicker` (#4814) @flaviendelangle
44
+
45
+ The props of `MonthPicker` / `YearPicker` and `DayPicker` have been reworked to make them more consistent for a standalone usage (#4814) @flaviendelangle
46
+
47
+ **MonthPicker**: The prop `onMonthChange` has been removed, you can use `onChange` instead since every change is a month change
48
+
49
+ **YearPicker**: The prop `onYearPicker` has been removed, you can use `onChange` instead since every change is a year change
50
+
51
+ **DayPicker**: The prop `isDateDisabled` has been removed, you can now use the same validation props as for the other components (`maxDate`, `minDate`, `shouldDisableDate`, `disableFuture` and `disablePast`)
52
+
53
+ #### Changes
54
+
55
+ - [pickers] Add German (de-DE) translations (#4974) @felixh10r
56
+ - [pickers] Support action bar on static pickers and improve typing (#5015) @flaviendelangle
57
+
58
+ ### Docs
59
+
60
+ - [docs] Add docs sections / pages for upcoming features on pickers (#4603) @flaviendelangle
61
+ - [docs] Add docs for filter panel components (#4919) @m4theushw
62
+ - [docs] Explain how to manage focus with `renderCell` (#4254) @alexfauquette
63
+ - [docs] Fix broken links to GitHub source (#5003) @Edwardveb
64
+ - [docs] Fix navigation links (#4956) @oliviertassinari
65
+ - [docs] Fix typo on rows docs (#4952) @jamesRadicl
66
+ - [docs] New WAI-ARIA guidelines location (#4957) @oliviertassinari
67
+ - [docs] Add "Slots" section to the right nav in the API pages (#4993) @DanailH
68
+ - [docs] Fix docs feedback widget not working (#4905) @cherniavskii
69
+ - [docs] Replace custom notes and warning with callouts (#5008) @flaviendelangle
70
+
71
+ ### Core
72
+
73
+ - [core] Avoid Order ID to refer to GitHub issues/PRs (#5005) @oliviertassinari
74
+ - [core] Improve the workflow for incomplete issues (#5012) @mnajdova
75
+ - [core] Remove dead code on row grouping tree creation (#4945) @flaviendelangle
76
+ - [core] Use new cache api for the row grouping last model tracking (#4980) @flaviendelangle
77
+ - [core] Ensure that PRs have atleast 1 label (#5011) @DanailH
78
+ - [core] Fix trailing-space @oliviertassinari
79
+ - [core] Stop Renovate PR updates when PR is on hold (#5020) @cherniavskii
80
+ - [license] Remove support for UTF-8 (#4893) @oliviertassinari
81
+ - [license] Tweak error messages (#4907) @mbrookes
82
+ - [test] Skip Safari and Firefox on broken tests (#4994) @alexfauquette
83
+ - [test] Make argos screenshots stable (#5061) @m4theushw
84
+
6
85
  ## v5.11.1
7
86
 
8
87
  _May 20, 2022_
@@ -38,30 +117,28 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
38
117
 
39
118
  To decide which button must be displayed and in which order, you can now use the `actions` prop of the `actionBar` component slot props.
40
119
 
41
- ```jsx
42
- <DatePicker
43
- componentsProps={{
44
- actionBar: {
45
- // The actions will be the same between desktop and mobile
46
- actions: ['clear'],
120
+ ```jsx
121
+ <DatePicker
122
+ componentsProps={{
123
+ actionBar: {
124
+ // The actions will be the same between desktop and mobile
125
+ actions: ['clear'],
47
126
 
48
- // The actions will be different between desktop and mobile
49
- actions: (variant) => variant === 'desktop' ? [] : ['clear'],
50
- }
51
- }}
52
- />
53
- ```
127
+ // The actions will be different between desktop and mobile
128
+ actions: (variant) => (variant === 'desktop' ? [] : ['clear']),
129
+ },
130
+ }}
131
+ />
132
+ ```
54
133
 
55
134
  The build-in `ActionBar` component supports 4 different actions: `'clear'`, `'cancel'`, `'accept'`, and `'today'`.
56
135
  By default, the pickers will render the cancel and accept button on mobile and no action on desktop.
57
136
 
58
137
  If you need other actions, you can provide your own component to the `ActionBar` component slot
59
138
 
60
- ```jsx
61
- <DatePicker
62
- components={{ ActionBar: CustomActionBar }}
63
- />
64
- ```
139
+ ```jsx
140
+ <DatePicker components={{ ActionBar: CustomActionBar }} />
141
+ ```
65
142
 
66
143
  #### Changes
67
144
 
@@ -121,7 +198,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
121
198
 
122
199
  - 👔 **Excel export**. You can find this new Premium feature at: https://mui.com/x/react-data-grid/export/#excel-export.
123
200
 
124
- - 🔎 **Quick filtering**. You can now add a quick filtering search bar to your grid. To do so, either pass `showQuickFilter` prop to the `<GridToolbar />` or use the `<GridToolbarQuickFilter />` component in your custom toolbar. More information about how to customize the filtering logic is in the [documentation]( https://mui.com/x/react-data-grid/filtering/#quick-filter).
201
+ - 🔎 **Quick filtering**. You can now add a quick filtering search bar to your grid. To do so, either pass `showQuickFilter` prop to the `<GridToolbar />` or use the `<GridToolbarQuickFilter />` component in your custom toolbar. More information about how to customize the filtering logic is in the [documentation](https://mui.com/x/react-data-grid/filtering/#quick-filter).
125
202
 
126
203
  <img src="https://user-images.githubusercontent.com/13808724/167700105-5a5acc7c-5463-4871-8514-3d09e2f365ae.png" width="724">
127
204
 
@@ -235,12 +235,6 @@ DataGridProRaw.propTypes = {
235
235
  */
236
236
  disableMultipleSelection: PropTypes.bool,
237
237
 
238
- /**
239
- * If `true`, the row grouping is disabled.
240
- * @default false
241
- */
242
- disableRowGrouping: PropTypes.bool,
243
-
244
238
  /**
245
239
  * If `true`, the selection on click on a row or cell is disabled.
246
240
  * @default false
@@ -276,7 +270,6 @@ DataGridProRaw.propTypes = {
276
270
  experimentalFeatures: PropTypes.shape({
277
271
  newEditingApi: PropTypes.bool,
278
272
  preventCommitWhileValidating: PropTypes.bool,
279
- rowGrouping: PropTypes.bool,
280
273
  warnIfFocusStateIsNotSynced: PropTypes.bool
281
274
  }),
282
275
 
@@ -330,6 +323,15 @@ DataGridProRaw.propTypes = {
330
323
  */
331
324
  getDetailPanelHeight: PropTypes.func,
332
325
 
326
+ /**
327
+ * Function that returns the estimated height for a row.
328
+ * Only works if dynamic row height is used.
329
+ * Once the row height is measured this value is discarded.
330
+ * @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
331
+ * @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
332
+ */
333
+ getEstimatedRowHeight: PropTypes.func,
334
+
333
335
  /**
334
336
  * Function that applies CSS classes dynamically on rows.
335
337
  * @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
@@ -340,7 +342,7 @@ DataGridProRaw.propTypes = {
340
342
  /**
341
343
  * Function that sets the row height per row.
342
344
  * @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
343
- * @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
345
+ * @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
344
346
  */
345
347
  getRowHeight: PropTypes.func,
346
348
 
@@ -666,6 +668,22 @@ DataGridProRaw.propTypes = {
666
668
  */
667
669
  onFilterModelChange: PropTypes.func,
668
670
 
671
+ /**
672
+ * Callback fired when the menu is closed.
673
+ * @param {GridMenuParams} params With all properties from [[GridMenuParams]].
674
+ * @param {MuiEvent<{}>} event The event object.
675
+ * @param {GridCallbackDetails} details Additional details for this callback.
676
+ */
677
+ onMenuClose: PropTypes.func,
678
+
679
+ /**
680
+ * Callback fired when the menu is opened.
681
+ * @param {GridMenuParams} params With all properties from [[GridMenuParams]].
682
+ * @param {MuiEvent<{}>} event The event object.
683
+ * @param {GridCallbackDetails} details Additional details for this callback.
684
+ */
685
+ onMenuOpen: PropTypes.func,
686
+
669
687
  /**
670
688
  * Callback fired when the current page has changed.
671
689
  * @param {number} page Index of the page displayed on the Grid.
@@ -755,13 +773,6 @@ DataGridProRaw.propTypes = {
755
773
  */
756
774
  onRowEditStop: PropTypes.func,
757
775
 
758
- /**
759
- * Callback fired when the row grouping model changes.
760
- * @param {GridRowGroupingModel} model Columns used as grouping criteria.
761
- * @param {GridCallbackDetails} details Additional details for this callback.
762
- */
763
- onRowGroupingModelChange: PropTypes.func,
764
-
765
776
  /**
766
777
  * Callback fired when the `rowModesModel` prop changes.
767
778
  * @param {GridRowModesModel} rowModesModel Object containig which rows are in "edit" mode.
@@ -865,18 +876,6 @@ DataGridProRaw.propTypes = {
865
876
  */
866
877
  rowCount: PropTypes.number,
867
878
 
868
- /**
869
- * If `single`, all column we are grouping by will be represented in the same grouping the same column.
870
- * If `multiple`, each column we are grouping by will be represented in its own column.
871
- * @default 'single'
872
- */
873
- rowGroupingColumnMode: PropTypes.oneOf(['multiple', 'single']),
874
-
875
- /**
876
- * Set the row grouping model of the grid.
877
- */
878
- rowGroupingModel: PropTypes.arrayOf(PropTypes.string),
879
-
880
879
  /**
881
880
  * Set the height in pixel of a row in the grid.
882
881
  * @default 52
@@ -12,8 +12,6 @@ import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDe
12
12
  import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
13
13
  import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
14
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';
17
15
  export const useDataGridProComponent = (inputApiRef, props) => {
18
16
  var _props$experimentalFe, _props$experimentalFe2;
19
17
 
@@ -24,7 +22,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
24
22
 
25
23
  useGridSelectionPreProcessors(apiRef, props);
26
24
  useGridRowReorderPreProcessors(apiRef, props);
27
- useGridRowGroupingPreProcessors(apiRef, props);
28
25
  useGridTreeDataPreProcessors(apiRef, props);
29
26
  useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
30
27
  // Because it changes the order of the columns.
@@ -35,7 +32,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
35
32
  * Register all state initializers here.
36
33
  */
37
34
 
38
- useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
39
35
  useGridInitializeState(selectionStateInitializer, apiRef, props);
40
36
  useGridInitializeState(detailPanelStateInitializer, apiRef, props);
41
37
  useGridInitializeState(columnPinningStateInitializer, apiRef, props);
@@ -52,7 +48,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
52
48
  useGridInitializeState(paginationStateInitializer, apiRef, props);
53
49
  useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
54
50
  useGridInitializeState(columnMenuStateInitializer, apiRef, props);
55
- useGridRowGrouping(apiRef, props);
56
51
  useGridTreeData(apiRef);
57
52
  useGridKeyboardNavigation(apiRef, props);
58
53
  useGridSelection(apiRef, props);
@@ -2,7 +2,6 @@ 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';
6
5
 
7
6
  /**
8
7
  * The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
@@ -15,11 +14,8 @@ export const DATA_GRID_PRO_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PROPS_D
15
14
  disableChildrenFiltering: false,
16
15
  disableChildrenSorting: false,
17
16
  rowReordering: false,
18
- getDetailPanelHeight: () => 500,
19
- disableRowGrouping: false,
20
- rowGroupingColumnMode: 'single'
17
+ getDetailPanelHeight: () => 500
21
18
  });
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');
23
19
  export const useDataGridProProps = inProps => {
24
20
  const themedProps = useThemeProps({
25
21
  props: inProps,
@@ -39,26 +35,9 @@ export const useDataGridProProps = inProps => {
39
35
  });
40
36
  return mergedComponents;
41
37
  }, [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
-
54
- return React.useMemo(() => {
55
- var _themedProps$experime2;
56
-
57
- return _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
58
- disableRowGrouping: themedProps.disableRowGrouping || !((_themedProps$experime2 = themedProps.experimentalFeatures) != null && _themedProps$experime2.rowGrouping),
59
- localeText,
60
- components,
61
- signature: 'DataGridPro'
62
- });
63
- }, [themedProps, localeText, components]);
38
+ return React.useMemo(() => _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
39
+ localeText,
40
+ components,
41
+ signature: 'DataGridPro'
42
+ }), [themedProps, localeText, components]);
64
43
  };
package/README.md CHANGED
@@ -19,8 +19,8 @@ This component has the following peer dependencies that you will need to install
19
19
 
20
20
  ```json
21
21
  "peerDependencies": {
22
- "@mui/material": "^5.2.8",
23
- "@mui/system": "^5.2.8",
22
+ "@mui/material": "^5.4.1",
23
+ "@mui/system": "^5.4.1",
24
24
  "react": "^17.0.2 || ^18.0.0"
25
25
  },
26
26
  ```
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridPinnedColumns } from '../hooks/features/columnPinning';
3
- export declare const filterColumns: (pinnedColumns: GridPinnedColumns, columns: string[]) => any[][];
3
+ export declare const filterColumns: (pinnedColumns: GridPinnedColumns, columns: string[]) => [string[], string[]];
4
4
  interface DataGridProVirtualScrollerProps extends React.HTMLAttributes<HTMLDivElement> {
5
5
  disableVirtualization?: boolean;
6
6
  }
@@ -84,7 +84,8 @@ const VirtualScrollerDetailPanel = styled(Box, {
84
84
  zIndex: 2,
85
85
  width: '100%',
86
86
  position: 'absolute',
87
- backgroundColor: theme.palette.background.default
87
+ backgroundColor: theme.palette.background.default,
88
+ overflow: 'auto'
88
89
  }));
89
90
  const VirtualScrollerPinnedColumns = styled('div', {
90
91
  name: 'MuiDataGrid',
@@ -241,7 +242,8 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
241
242
  renderContext: leftRenderContext,
242
243
  minFirstColumn: leftRenderContext.firstColumnIndex,
243
244
  maxLastColumn: leftRenderContext.lastColumnIndex,
244
- availableSpace: 0
245
+ availableSpace: 0,
246
+ ignoreAutoHeight: true
245
247
  })
246
248
  }), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
247
249
  children: getRows({
@@ -258,7 +260,8 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
258
260
  renderContext: rightRenderContext,
259
261
  minFirstColumn: rightRenderContext.firstColumnIndex,
260
262
  maxLastColumn: rightRenderContext.lastColumnIndex,
261
- availableSpace: 0
263
+ availableSpace: 0,
264
+ ignoreAutoHeight: true
262
265
  })
263
266
  }), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
264
267
  className: classes.detailPanels,
@@ -27,7 +27,7 @@ const GridRowReorderCell = params => {
27
27
 
28
28
  const cellValue = params.row.__reorder__ || params.id; // TODO: remove sortModel and treeDepth checks once row reorder is compatible
29
29
 
30
- const isDraggable = !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0;
30
+ const isDraggable = React.useMemo(() => !!rootProps.rowReordering && !sortModel.length && treeDepth === 1 && Object.keys(editRowsState).length === 0, [rootProps.rowReordering, sortModel, treeDepth, editRowsState]);
31
31
  const ownerState = {
32
32
  isDraggable,
33
33
  classes: rootProps.classes
@@ -52,11 +52,11 @@ const GridRowReorderCell = params => {
52
52
  propHandler(event);
53
53
  }
54
54
  }, [apiRef, params.row.id]);
55
- const draggableEventHandlers = {
55
+ const draggableEventHandlers = isDraggable ? {
56
56
  onDragStart: publish('rowDragStart'),
57
57
  onDragOver: publish('rowDragOver'),
58
58
  onDragEnd: publish('rowDragEnd')
59
- };
59
+ } : null;
60
60
  return /*#__PURE__*/_jsxs("div", _extends({
61
61
  className: classes.root,
62
62
  draggable: isDraggable
@@ -39,4 +39,10 @@ export interface GridColumnPinningApi {
39
39
  */
40
40
  isColumnPinned: (field: string) => GridPinnedPosition | false;
41
41
  }
42
+ export interface GridColumnPinningInternalCache {
43
+ /**
44
+ * Stores the fields in their original position, before being pinned.
45
+ */
46
+ orderedFieldsBeforePinningColumns: string[] | null;
47
+ }
42
48
  export { GridPinnedPosition };
@@ -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, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
4
+ import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, useGridApiMethod, useGridApiEventHandler, gridColumnFieldsSelector } 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';
@@ -13,9 +13,12 @@ const Divider = () => /*#__PURE__*/_jsx(MuiDivider, {
13
13
  onClick: event => event.stopPropagation()
14
14
  });
15
15
 
16
- export const columnPinningStateInitializer = (state, props) => {
16
+ export const columnPinningStateInitializer = (state, props, apiRef) => {
17
17
  var _props$initialState;
18
18
 
19
+ apiRef.current.unstable_caches.columnPinning = {
20
+ orderedFieldsBeforePinningColumns: null
21
+ };
19
22
  let model;
20
23
 
21
24
  if (props.disableColumnPinning) {
@@ -205,34 +208,20 @@ export const useGridColumnPinning = (apiRef, props) => {
205
208
  return;
206
209
  }
207
210
 
208
- apiRef.current.setState(state => {
209
- const otherSide = side === GridPinnedPosition.right ? GridPinnedPosition.left : GridPinnedPosition.right;
210
-
211
- const newPinnedColumns = _extends({}, state.pinnedColumns, {
212
- [side]: [...(state.pinnedColumns[side] || []), field],
213
- [otherSide]: (state.pinnedColumns[otherSide] || []).filter(column => column !== field)
214
- });
215
-
216
- return _extends({}, state, {
217
- pinnedColumns: newPinnedColumns
218
- });
219
- });
220
- apiRef.current.forceUpdate();
221
- }, [apiRef, checkIfEnabled]);
211
+ const otherSide = side === GridPinnedPosition.right ? GridPinnedPosition.left : GridPinnedPosition.right;
212
+ const newPinnedColumns = {
213
+ [side]: [...(pinnedColumns[side] || []), field],
214
+ [otherSide]: (pinnedColumns[otherSide] || []).filter(column => column !== field)
215
+ };
216
+ apiRef.current.setPinnedColumns(newPinnedColumns);
217
+ }, [apiRef, checkIfEnabled, pinnedColumns]);
222
218
  const unpinColumn = React.useCallback(field => {
223
219
  checkIfEnabled('unpinColumn');
224
- apiRef.current.setState(state => {
225
- const newPinnedColumns = _extends({}, state.pinnedColumns, {
226
- left: (state.pinnedColumns.left || []).filter(column => column !== field),
227
- right: (state.pinnedColumns.right || []).filter(column => column !== field)
228
- });
229
-
230
- return _extends({}, state, {
231
- pinnedColumns: newPinnedColumns
232
- });
220
+ apiRef.current.setPinnedColumns({
221
+ left: (pinnedColumns.left || []).filter(column => column !== field),
222
+ right: (pinnedColumns.right || []).filter(column => column !== field)
233
223
  });
234
- apiRef.current.forceUpdate();
235
- }, [apiRef, checkIfEnabled]);
224
+ }, [apiRef, checkIfEnabled, pinnedColumns.left, pinnedColumns.right]);
236
225
  const getPinnedColumns = React.useCallback(() => {
237
226
  checkIfEnabled('getPinnedColumns');
238
227
  return gridPinnedColumnsSelector(apiRef.current.state);
@@ -266,6 +255,62 @@ export const useGridColumnPinning = (apiRef, props) => {
266
255
  isColumnPinned
267
256
  };
268
257
  useGridApiMethod(apiRef, columnPinningApi, 'columnPinningApi');
258
+ const handleColumnOrderChange = React.useCallback(params => {
259
+ if (!apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns) {
260
+ return;
261
+ }
262
+
263
+ const {
264
+ field,
265
+ targetIndex,
266
+ oldIndex
267
+ } = params;
268
+ const delta = targetIndex > oldIndex ? 1 : -1;
269
+ const latestColumnFields = gridColumnFieldsSelector(apiRef);
270
+ /**
271
+ * When a column X is reordered to somewhere else, the position where this column X is dropped
272
+ * on must be moved to left or right to make room for it. The ^^^ below represents the column
273
+ * which gave space to receive X.
274
+ *
275
+ * | X | B | C | D | -> | B | C | D | X | (e.g. X moved to after D, so delta=1)
276
+ * ^^^ ^^^
277
+ *
278
+ * | A | B | C | X | -> | X | A | B | C | (e.g. X moved before A, so delta=-1)
279
+ * ^^^ ^^^
280
+ *
281
+ * If column P is pinned, it will not move to provide space. However, it will jump to the next
282
+ * non-pinned column.
283
+ *
284
+ * | X | B | P | D | -> | B | D | P | X | (e.g. X moved to after D, with P pinned)
285
+ * ^^^ ^^^
286
+ */
287
+
288
+ const siblingField = latestColumnFields[targetIndex - delta];
289
+ const newOrderedFieldsBeforePinningColumns = [...apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns]; // The index to start swapping fields
290
+
291
+ let i = newOrderedFieldsBeforePinningColumns.findIndex(column => column === field); // The index of the field to swap with
292
+
293
+ let j = i + delta; // When to stop swapping fields.
294
+ // We stop one field before because the swap is done with i + 1 (if delta=1)
295
+
296
+ const stop = newOrderedFieldsBeforePinningColumns.findIndex(column => column === siblingField);
297
+
298
+ while (delta > 0 ? i < stop : i > stop) {
299
+ // If the field to swap with is a pinned column, jump to the next
300
+ while (apiRef.current.isColumnPinned(newOrderedFieldsBeforePinningColumns[j])) {
301
+ j += delta;
302
+ }
303
+
304
+ const temp = newOrderedFieldsBeforePinningColumns[i];
305
+ newOrderedFieldsBeforePinningColumns[i] = newOrderedFieldsBeforePinningColumns[j];
306
+ newOrderedFieldsBeforePinningColumns[j] = temp;
307
+ i = j;
308
+ j = i + delta;
309
+ }
310
+
311
+ apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
312
+ }, [apiRef]);
313
+ useGridApiEventHandler(apiRef, 'columnOrderChange', handleColumnOrderChange);
269
314
  React.useEffect(() => {
270
315
  if (props.pinnedColumns) {
271
316
  apiRef.current.setPinnedColumns(props.pinnedColumns);
@@ -23,23 +23,86 @@ export const useGridColumnPinningPreProcessors = (apiRef, props) => {
23
23
  pinnedColumns = gridPinnedColumnsSelector(initializedState);
24
24
  }
25
25
 
26
+ const prevAllPinnedColumns = React.useRef();
26
27
  const reorderPinnedColumns = React.useCallback(columnsState => {
27
28
  if (columnsState.all.length === 0 || disableColumnPinning) {
28
29
  return columnsState;
29
30
  }
30
31
 
31
32
  const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, columnsState.all);
33
+ let newOrderedFields;
34
+ const allPinnedColumns = [...leftPinnedColumns, ...rightPinnedColumns];
35
+ const {
36
+ orderedFieldsBeforePinningColumns
37
+ } = apiRef.current.unstable_caches.columnPinning;
32
38
 
33
- if (leftPinnedColumns.length === 0 && rightPinnedColumns.length === 0) {
34
- return columnsState;
39
+ if (orderedFieldsBeforePinningColumns) {
40
+ newOrderedFields = new Array(columnsState.all.length).fill(null);
41
+ const newOrderedFieldsBeforePinningColumns = [...newOrderedFields]; // Contains the fields not added to the orderedFields array yet
42
+
43
+ const remainingFields = [...columnsState.all]; // First, we check if the column was unpinned since the last processing.
44
+ // If yes and it still exists, we move it back to the same position it was before pinning
45
+
46
+ prevAllPinnedColumns.current.forEach(field => {
47
+ if (!allPinnedColumns.includes(field) && columnsState.lookup[field]) {
48
+ // Get the position before pinning
49
+ const index = orderedFieldsBeforePinningColumns.indexOf(field);
50
+ newOrderedFields[index] = field;
51
+ newOrderedFieldsBeforePinningColumns[index] = field; // This field was already consumed so we prevent from being added again
52
+
53
+ remainingFields.splice(remainingFields.indexOf(field), 1);
54
+ }
55
+ }); // For columns still pinned, we keep stored their original positions
56
+
57
+ allPinnedColumns.forEach(field => {
58
+ let index = orderedFieldsBeforePinningColumns.indexOf(field); // If index = -1, the pinned field didn't exist in the last processing, it's possibly being added now
59
+ // If index >= newOrderedFieldsBeforePinningColumns.length, then one or more columns were removed
60
+ // In both cases, use the position from the columns array
61
+ // TODO: detect removed columns and decrease the positions after it
62
+
63
+ if (index === -1 || index >= newOrderedFieldsBeforePinningColumns.length) {
64
+ index = columnsState.all.indexOf(field);
65
+ } // The fallback above may make the column to be inserted in a position already occupied
66
+ // In this case, put it in any empty slot available
67
+
68
+
69
+ if (newOrderedFieldsBeforePinningColumns[index] !== null) {
70
+ index = 0;
71
+
72
+ while (newOrderedFieldsBeforePinningColumns[index] !== null) {
73
+ index += 1;
74
+ }
75
+ }
76
+
77
+ newOrderedFields[index] = field;
78
+ newOrderedFieldsBeforePinningColumns[index] = field; // This field was already consumed so we prevent from being added again
79
+
80
+ remainingFields.splice(remainingFields.indexOf(field), 1);
81
+ }); // The fields remaining are those that're neither pinnned nor were unpinned
82
+ // For these, we spread them across both arrays making sure to not override existing values
83
+
84
+ let i = 0;
85
+ remainingFields.forEach(field => {
86
+ while (newOrderedFieldsBeforePinningColumns[i] !== null) {
87
+ i += 1;
88
+ }
89
+
90
+ newOrderedFieldsBeforePinningColumns[i] = field;
91
+ newOrderedFields[i] = field;
92
+ });
93
+ apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = newOrderedFieldsBeforePinningColumns;
94
+ } else {
95
+ newOrderedFields = [...columnsState.all];
96
+ apiRef.current.unstable_caches.columnPinning.orderedFieldsBeforePinningColumns = [...columnsState.all];
35
97
  }
36
98
 
37
- const centerColumns = columnsState.all.filter(field => {
99
+ prevAllPinnedColumns.current = allPinnedColumns;
100
+ const centerColumns = newOrderedFields.filter(field => {
38
101
  return !leftPinnedColumns.includes(field) && !rightPinnedColumns.includes(field);
39
102
  });
40
103
  return _extends({}, columnsState, {
41
104
  all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
42
105
  });
43
- }, [disableColumnPinning, pinnedColumns]);
106
+ }, [apiRef, disableColumnPinning, pinnedColumns]);
44
107
  useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
45
108
  };
@@ -60,6 +60,10 @@ export const useGridRowReorder = (apiRef, props) => {
60
60
  originRowIndex.current = apiRef.current.getRowIndex(params.id);
61
61
  }, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
62
62
  const handleDragOver = React.useCallback((params, event) => {
63
+ if (dragRowId === '') {
64
+ return;
65
+ }
66
+
63
67
  logger.debug(`Dragging over row ${params.id}`);
64
68
  event.preventDefault(); // Prevent drag events propagation.
65
69
  // For more information check here https://github.com/mui/mui-x/issues/2680.
@@ -75,7 +79,7 @@ export const useGridRowReorder = (apiRef, props) => {
75
79
  // Call the gridEditRowsStateSelector directly to avoid infnite loop
76
80
  const editRowsState = gridEditRowsStateSelector(apiRef.current.state);
77
81
 
78
- if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
82
+ if (dragRowId === '' || isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
79
83
  return;
80
84
  }
81
85
 
package/index.d.ts CHANGED
@@ -17,5 +17,3 @@ export * from './utils';
17
17
  export type { DataGridProProps, GridExperimentalProFeatures } from './models/dataGridProProps';
18
18
  export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
19
19
  export type { GridApiRef, GridApi, GridInitialState, GridState } from './typeOverloads/reexports';
20
- export * from './hooks/features/rowGrouping';
21
- export * from './models/gridGroupingValueGetterParams';