@mui/x-data-grid-pro 5.12.1 → 5.13.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 (70) hide show
  1. package/CHANGELOG.md +155 -8
  2. package/DataGridPro/DataGridPro.js +1 -1
  3. package/DataGridPro/useDataGridProComponent.js +1 -3
  4. package/components/DataGridProColumnHeaders.js +10 -7
  5. package/components/DataGridProVirtualScroller.js +7 -18
  6. package/components/GridDetailPanel.d.ts +19 -0
  7. package/components/GridDetailPanel.js +65 -0
  8. package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
  9. package/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +20 -1
  10. package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +14 -3
  11. package/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
  12. package/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
  13. package/hooks/features/detailPanel/index.d.ts +1 -1
  14. package/hooks/features/detailPanel/index.js +1 -1
  15. package/hooks/features/detailPanel/useGridDetailPanel.d.ts +1 -1
  16. package/hooks/features/detailPanel/useGridDetailPanel.js +113 -19
  17. package/hooks/features/detailPanel/useGridDetailPanelCache.js +10 -3
  18. package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
  19. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
  20. package/index.js +1 -1
  21. package/internals/index.d.ts +0 -1
  22. package/internals/index.js +0 -1
  23. package/legacy/DataGridPro/DataGridPro.js +1 -1
  24. package/legacy/DataGridPro/useDataGridProComponent.js +1 -3
  25. package/legacy/components/DataGridProColumnHeaders.js +10 -7
  26. package/legacy/components/DataGridProVirtualScroller.js +12 -26
  27. package/legacy/components/GridDetailPanel.js +72 -0
  28. package/legacy/hooks/features/detailPanel/gridDetailPanelSelector.js +15 -2
  29. package/legacy/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +3 -1
  30. package/legacy/hooks/features/detailPanel/index.js +1 -1
  31. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +112 -19
  32. package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +10 -3
  33. package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
  34. package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
  35. package/legacy/index.js +1 -1
  36. package/legacy/internals/index.js +0 -1
  37. package/legacy/utils/releaseInfo.js +1 -1
  38. package/models/dataGridProProps.d.ts +2 -2
  39. package/modern/DataGridPro/DataGridPro.js +1 -1
  40. package/modern/DataGridPro/useDataGridProComponent.js +1 -3
  41. package/modern/components/DataGridProColumnHeaders.js +11 -6
  42. package/modern/components/DataGridProVirtualScroller.js +7 -18
  43. package/modern/components/GridDetailPanel.js +65 -0
  44. package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
  45. package/modern/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
  46. package/modern/hooks/features/detailPanel/index.js +1 -1
  47. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +109 -17
  48. package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +8 -3
  49. package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +5 -2
  50. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -2
  51. package/modern/index.js +1 -1
  52. package/modern/internals/index.js +0 -1
  53. package/modern/utils/releaseInfo.js +1 -1
  54. package/node/DataGridPro/DataGridPro.js +1 -1
  55. package/node/DataGridPro/useDataGridProComponent.js +1 -4
  56. package/node/components/DataGridProColumnHeaders.js +11 -7
  57. package/node/components/DataGridProVirtualScroller.js +8 -19
  58. package/node/components/GridDetailPanel.js +83 -0
  59. package/node/hooks/features/detailPanel/gridDetailPanelSelector.js +12 -2
  60. package/node/hooks/features/detailPanel/gridDetailPanelToggleColDef.js +2 -2
  61. package/node/hooks/features/detailPanel/index.js +25 -11
  62. package/node/hooks/features/detailPanel/useGridDetailPanel.js +110 -17
  63. package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +10 -3
  64. package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +8 -2
  65. package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -1
  66. package/node/index.js +1 -1
  67. package/node/internals/index.js +0 -9
  68. package/node/utils/releaseInfo.js +1 -1
  69. package/package.json +5 -5
  70. package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,153 @@
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
+ ## 5.13.0
7
+
8
+ _Jul 7, 2022_
9
+
10
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🎁 `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` are now in beta!
13
+
14
+ - ✨ Allow detail panel's height to match its content (#5163) @m4theushw
15
+
16
+ ```tsx
17
+ <DataGridPro getDetailPanelHeight={() => 'auto'} />
18
+ ```
19
+
20
+ - 🌍 Add Romanian (ro-RO) locale on the data grid (#5345) @rolule
21
+ - 📚 Documentation improvements
22
+ - 🐞 Bugfixes
23
+
24
+ ### `@mui/x-data-grid@v5.13.0` / `@mui/x-data-grid-pro@v5.13.0` / `@mui/x-data-grid-premium@v5.13.0`
25
+
26
+ #### Changes
27
+
28
+ - [DataGrid] Allows to customize variant of value input in filter panel (#4826) @alexfauquette
29
+ - [DataGrid] Add Romanian (ro-RO) locale (#5345) @rolule
30
+ - [DataGrid] Export Norwegian (nb-NO) locale (#5407) @cherniavskii
31
+ - [DataGrid] Fix broken "start editing" integration with Japanese (#5414) @mnajdova
32
+ - [DataGrid] Fix "stop editing" integration with IME e.g. Japanese (#5257) @Gumichocopengin8
33
+ - [DataGrid] Fix dimensions computation with `autoHeight` and scroll x (#5401) @flaviendelangle
34
+ - [DataGrid] Improve Slovak (sk-SK) locale (#5332) @msidlo
35
+ - [DataGrid] Mention Premium plan in error messages and docs warnings (#5328) @cherniavskii
36
+ - [DataGrid] Remove trailing spaces in filter input (#5279) @alexfauquette
37
+ - [DataGridPro] Allow to infer detail panel height from content (#5163) @m4theushw
38
+ - [DataGridPro] Fix the depth of nodes when switching from a non-flat tree to a flat tree (#5362) @flaviendelangle
39
+
40
+ ### `@mui/x-date-pickers@v5.0.0-beta.0` / `@mui/x-date-picker-pro@5.0.0-beta.0`
41
+
42
+ #### Changes
43
+
44
+ - [DateRangePicker] Fix keyboard selection (#5265) @alexfauquette
45
+ - [DayPicker] Remove empty space at the bottom of the day view (#5073) @flaviendelangle
46
+ - [pickers] Add missing type dependencies (#5331) @Methuselah96
47
+ - [pickers] Pass the generics to the components in the theme augmentation (#5199) @toruticas
48
+
49
+ ### Docs
50
+
51
+ - [docs] Explain how to use hooks inside a cell renderer (#5158) @flaviendelangle
52
+ - [docs] Fix server-side pagination demo (#5361) @cherniavskii
53
+ - [docs] Fix typo in the quick filter docs (#5313) @alexfauquette
54
+ - [docs] Improve the "Getting started" page (#5293) @alexfauquette
55
+ - [docs] New page for the pickers action bar customization (#5267) @flaviendelangle
56
+ - [docs] Revise and split up "Overview" page into "Introduction" (#4692) @samuelsycamore
57
+ - [docs] Use `useKeepGroupedColumnsHiddren` from the grid package on remaining demo (#5382) @flaviendelangle
58
+
59
+ ## v5.12.3
60
+
61
+ _Jun 23, 2022_
62
+
63
+ We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
64
+
65
+ - 🌍 Add Swedish (sv-SE) locale on the data grid and the pickers (#5210) @mrxdst
66
+ - 🌍 Add Dutch (nl-NL) locale on the pickers (#5237) @DDukers
67
+ - 📚 Documentation improvements
68
+ - 🐞 Bugfixes
69
+
70
+ ### `@mui/x-data-grid@v5.12.3` / `@mui/x-data-grid-pro@v5.12.3` / `@mui/x-data-grid-premium@v5.12.3`
71
+
72
+ #### Changes
73
+
74
+ - [DataGrid] Do not hide non-hideable column when pressing Hide All button (#5298) @flaviendelangle
75
+ - [DataGrid] Do not regenerate the row tree when the `loading` prop changes (#5213) @flaviendelangle
76
+ - [DataGrid] Fix the default filter operator fallback on state initialization (#5266) @flaviendelangle
77
+ - [DataGrid] Stop using the deprecated `api` prop in the grid components (#5205) @flaviendelangle
78
+ - [DataGrid] Add Swedish (sv-SE) locale (#5210) @mrxdst
79
+ - [DataGridPremium] Fix detail panel on `DataGridPremium` (#5264) @flaviendelangle
80
+ - [DataGridPremium] Fix Excel import with Remix / Vite (#5207) @alexfauquette
81
+ - [DataGridPremium] Fix error with quick filter and grouping rows (#5238) @alexfauquette
82
+
83
+ ### `@mui/x-date-pickers@v5.0.0-alpha.7` / `@mui/x-date-pickers-pro@v5.0.0-alpha.7`
84
+
85
+ #### Changes
86
+
87
+ - [pickers] Export adapters from both `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` (#5204) @flaviendelangle
88
+ - [pickers] Add Dutch (nl-NL) locale (#5237) @DDukers
89
+
90
+ ### Docs
91
+
92
+ - [docs] Add `DataGridPremium` to all API sections (#5196) @flaviendelangle
93
+ - [docs] Add plan badge next to event name in the Events page (#5200) @flaviendelangle
94
+ - [docs] Add section for theme augmentation in the picker docs (#5276) @flaviendelangle
95
+ - [docs] Add waiting for upvote section for row group panel (#5271) @flaviendelangle
96
+ - [docs] Disable ad on main demo page (#5301) @joserodolfofreitas
97
+ - [docs] Fix typo in the `DateRangePicker` documentation (#5259) @flaviendelangle
98
+
99
+ ### Core
100
+
101
+ - [core] Allow having multiple playgrounds (#5288) @alexfauquette
102
+ - [core] Improve typing of `GridFilterInputMultipleSingleSelect` (#5206) @flaviendelangle
103
+ - [core] Remove arbitrary new lines (#5245) @oliviertassinari
104
+ - [core] Remove dead logic (#5282) @oliviertassinari
105
+ - [test] Fix `inputFormat` when testing with different date adapters (#5291) @cherniavskii
106
+ - [test] Fix date assertion in Safari 13 (#5221) @m4theushw
107
+ - [test] Throw if date adapter is not found (#5289) @cherniavskii
108
+ - [test] Use mock for `ResizeObserver` (#5215) @m4theushw
109
+
110
+ ## v5.12.2
111
+
112
+ _Jun 16, 2022_
113
+
114
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
115
+
116
+ - 🚀 Performance improvement for dynamic row height (#5135) @m4theushw
117
+ - 🕒 Add demo of how to use the data grid with date pickers (#5053) @cherniavskii
118
+ - 📚 Documentation improvements
119
+ - 🐞 Bugfixes
120
+
121
+ ### `@mui/x-data-grid@v5.12.2` / `@mui/x-data-grid-pro@v5.12.2` / `@mui/x-data-grid-premium@v5.12.2`
122
+
123
+ #### Changes
124
+
125
+ - [DataGrid] Fix for cosmetic bug on column filter badge (#5170) @simbahandiane
126
+ - [DataGrid] Hide vertical scrollbar if `autoHeight` is enabled (#5164) @m4theushw
127
+ - [DataGrid] Use exponential search to render non-measured rows (#5135) @m4theushw
128
+ - [DataGridPro] Fix label of the detail panel toggle column (#5191) @m4theushw
129
+ - [DataGridPro] Refresh detail panel caches when props change (#5110) @m4theushw
130
+
131
+ ### Docs
132
+
133
+ - [docs] Add example with custom checkbox column (#5161) @flaviendelangle
134
+ - [docs] Batch small changes (#5177) @oliviertassinari
135
+ - [docs] Fix demo currency format (#5034) @oliviertassinari
136
+ - [docs] Fix outdated license description to match the EULA (#5219) @joserodolfofreitas
137
+ - [docs] Fix redundant headers (#5104) @oliviertassinari
138
+ - [docs] Fix some capitalization to match the guidelines (#5105) @oliviertassinari
139
+ - [docs] Improve the `getRowId` doc section (#5156) @flaviendelangle
140
+ - [docs] Instruction to deal with invalid license message (#5074) @joserodolfofreitas
141
+ - [docs] Use redirection in the code (#5114) @oliviertassinari
142
+ - [docs] Add demo of how to use the data grid with date pickers (#5053) @cherniavskii
143
+
144
+ ### Core
145
+
146
+ - [core] Improve inline code rendering within the details tag (#5166) @Harmouch101
147
+ - [core] Remove unused props from plugin typing (#5185) @flaviendelangle
148
+ - [core] Use the scrollbar size from `useGridDimensions` on `DataGridProColumnHeaders` (#5201) @flaviendelangle
149
+ - [core] Fix `GridColTypeDef` type (#5167) @cherniavskii
150
+ - [core] Fix `GridColTypeDef` usage in demo (#5197) @cherniavskii
151
+ - [test] Add `waitFor` before asserting height (#5203) @m4theushw
152
+
6
153
  ## v5.12.1
7
154
 
8
155
  _Jun 9, 2022_
@@ -28,7 +175,7 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
28
175
  - [l10n] Update Japanese (ja-JP) locale (#5122) @hikotq
29
176
  - [l10n] Update Russian (ru-RU) locale (#5069) @Artboomy
30
177
 
31
- ### `@mui/x-date-pickers@5.0.0-alpha.6` / `@mui/x-date-pickers-pro@5.0.0-alpha.6`
178
+ ### `@mui/x-date-pickers@v5.0.0-alpha.6` / `@mui/x-date-pickers-pro@v5.0.0-alpha.6`
32
179
 
33
180
  #### Changes
34
181
 
@@ -95,7 +242,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
95
242
  - [l10n] Add Norwegian (Bokmål) (nb-NO) locale (#5001) @spiftire
96
243
  - [l10n] Add Turkish (tr-TR) locale (#5026) @Rassilion
97
244
 
98
- ### `@mui/x-date-pickers@5.0.0-alpha.5` / `@mui/x-date-pickers-pro@5.0.0-alpha.5`
245
+ ### `@mui/x-date-pickers@v5.0.0-alpha.5` / `@mui/x-date-pickers-pro@v5.0.0-alpha.5`
99
246
 
100
247
  #### Breaking changes
101
248
 
@@ -168,7 +315,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
168
315
  - [DataGridPremium] Support column spanning in the Excel export (#4830) @cherniavskii
169
316
  - [l10n] Improve Russian (ru-RU) locale (#4864) @arvkonstantin
170
317
 
171
- ### `@mui/x-date-pickers@5.0.0-alpha.4` / `@mui/x-date-pickers-pro@5.0.0-alpha.4`
318
+ ### `@mui/x-date-pickers@v5.0.0-alpha.4` / `@mui/x-date-pickers-pro@v5.0.0-alpha.4`
172
319
 
173
320
  #### Breaking changes
174
321
 
@@ -293,7 +440,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
293
440
  - [l10n] Improve German (de-DE) locale (#4748) @sebastianfrey
294
441
  - [l10n] Improve German (de-DE) locale (#4668) @izu-co
295
442
 
296
- ### `@mui/x-date-pickers@5.0.0-alpha.3` / `@mui/x-date-pickers-pro@5.0.0-alpha.3`
443
+ ### `@mui/x-date-pickers@v5.0.0-alpha.3` / `@mui/x-date-pickers-pro@v5.0.0-alpha.3`
297
444
 
298
445
  #### Breaking changes
299
446
 
@@ -394,7 +541,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
394
541
  - [DataGrid] Don't close column menu when updating rows (#4498) @m4theushw
395
542
  - [DataGridPro] Introduce row reorder (#4034) @DanailH
396
543
 
397
- ### `@mui/x-date-pickers@5.0.0-alpha.2` / `@mui/x-date-pickers-pro@5.0.0-alpha.2`
544
+ ### `@mui/x-date-pickers@v5.0.0-alpha.2` / `@mui/x-date-pickers-pro@v5.0.0-alpha.2`
398
545
 
399
546
  - [pickers] Pass `PaperProps` to `DesktopWrapper` component (#4584) @alexfauquette
400
547
  - [TimePicker] Fix bug when time picker clear value (#4582) @alexfauquette
@@ -455,7 +602,7 @@ We'd like to offer a big thanks to the 9 contributors who made this release poss
455
602
  - [DataGridPro] Fix toggling detail panel using keyboard (#4409) @cherniavskii
456
603
  - [l10n] Add Hungarian (hu-HU) locale (#4458) @x22tri
457
604
 
458
- ### `@mui/x-date-pickers@5.0.0-alpha.1` / `@mui/x-date-pickers-pro@5.0.0-alpha.1`
605
+ ### `@mui/x-date-pickers@v5.0.0-alpha.1` / `@mui/x-date-pickers-pro@v5.0.0-alpha.1`
459
606
 
460
607
  - [ClockPicker] Should call `shouldDisableTime` with the hours with meridiem (#4404) @flaviendelangle
461
608
  - [MonthPicker] Clicking on a `PickersMonth` button should not trigger the form submit (#4402) @flaviendelangle
@@ -4084,9 +4231,9 @@ Big thanks to the 8 contributors who made this release possible. Here are some h
4084
4231
 
4085
4232
  ### Docs
4086
4233
 
4087
- - [docs] Data Grid depends on side effects (#666) @oliviertassinari
4234
+ - [docs] Data grid depends on side effects (#666) @oliviertassinari
4088
4235
  - [docs] Clarify the purpose of x-grid-data-generator (#634) @Elius94
4089
- - [docs] Data Grid is in the lab (#612) @oliviertassinari
4236
+ - [docs] Data grid is in the lab (#612) @oliviertassinari
4090
4237
  - [docs] Fix Demo app, downgrade webpack-cli, known issue in latest version (#647) @dtassone
4091
4238
  - [docs] Fix typo in columns.md @stojy
4092
4239
  - [docs] Reduce confusion on /export page (#646) @SerdarMustafa1
@@ -318,7 +318,7 @@ DataGridProRaw.propTypes = {
318
318
  /**
319
319
  * Function that returns the height of the row detail panel.
320
320
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
321
- * @returns {number} The height in pixels.
321
+ * @returns {number | string} The height in pixels or "auto" to use the content height.
322
322
  * @default "() => 500"
323
323
  */
324
324
  getDetailPanelHeight: PropTypes.func,
@@ -8,7 +8,6 @@ import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGrid
8
8
  import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
9
9
  import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
10
10
  import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
11
- import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
12
11
  import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
13
12
  import { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
14
13
  import { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
@@ -51,13 +50,12 @@ export const useDataGridProComponent = (inputApiRef, props) => {
51
50
  useGridTreeData(apiRef);
52
51
  useGridKeyboardNavigation(apiRef, props);
53
52
  useGridSelection(apiRef, props);
54
- useGridDetailPanel(apiRef, props);
55
53
  useGridColumnPinning(apiRef, props);
56
54
  useGridColumns(apiRef, props);
57
55
  useGridRows(apiRef, props);
58
56
  useGridParamsApi(apiRef);
57
+ useGridDetailPanel(apiRef, props);
59
58
  useGridColumnSpanning(apiRef);
60
- useGridDetailPanelCache(apiRef, props);
61
59
  const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
62
60
  useGridEditing(apiRef, props);
63
61
  useGridFocus(apiRef, props);
@@ -4,6 +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 { useEventCallback } from '@mui/material/utils';
7
8
  import { getDataGridUtilityClass, gridClasses, useGridSelector, useGridApiEventHandler, gridVisibleColumnFieldsSelector, GridColumnHeaderSeparatorSides } from '@mui/x-data-grid';
8
9
  import { GridColumnHeaders, GridColumnHeadersInner, useGridColumnHeaders } from '@mui/x-data-grid/internals';
9
10
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
@@ -76,17 +77,19 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
76
77
  const apiRef = useGridApiContext();
77
78
  const visibleColumnFields = useGridSelector(apiRef, gridVisibleColumnFieldsSelector);
78
79
  const [scrollbarSize, setScrollbarSize] = React.useState(0);
79
- const handleContentSizeChange = React.useCallback(() => {
80
- var _apiRef$current$windo;
80
+ const handleContentSizeChange = useEventCallback(() => {
81
+ const rootDimensions = apiRef.current.getRootDimensions();
81
82
 
82
- if (!((_apiRef$current$windo = apiRef.current.windowRef) != null && _apiRef$current$windo.current)) {
83
+ if (!rootDimensions) {
83
84
  return;
84
- } // TODO expose scrollbar size on getRootDimensions
85
+ }
85
86
 
87
+ const newScrollbarSize = rootDimensions.hasScrollY ? rootDimensions.scrollBarSize : 0;
86
88
 
87
- const newScrollbarSize = apiRef.current.windowRef.current.offsetWidth - apiRef.current.windowRef.current.clientWidth;
88
- setScrollbarSize(newScrollbarSize);
89
- }, [apiRef]);
89
+ if (scrollbarSize !== newScrollbarSize) {
90
+ setScrollbarSize(newScrollbarSize);
91
+ }
92
+ });
90
93
  useGridApiEventHandler(apiRef, 'virtualScrollerContentSizeChange', handleContentSizeChange);
91
94
  const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
92
95
  const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields);
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["className", "disableVirtualization"];
4
4
  import * as React from 'react';
5
5
  import { styled, alpha } from '@mui/material/styles';
6
- import Box from '@mui/material/Box';
7
6
  import { unstable_composeClasses as composeClasses } from '@mui/material';
8
7
  import { useGridSelector, getDataGridUtilityClass, gridClasses, gridVisibleColumnFieldsSelector, gridRowsMetaSelector, useGridApiEventHandler } from '@mui/x-data-grid';
9
8
  import { GridVirtualScroller, GridVirtualScrollerContent, GridVirtualScrollerRenderZone, useGridVirtualScroller } from '@mui/x-data-grid/internals';
@@ -11,6 +10,7 @@ import { useGridApiContext } from '../hooks/utils/useGridApiContext';
11
10
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
12
11
  import { gridPinnedColumnsSelector, GridPinnedPosition } from '../hooks/features/columnPinning';
13
12
  import { gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, gridDetailPanelExpandedRowIdsSelector } from '../hooks/features/detailPanel';
13
+ import { GridDetailPanel } from './GridDetailPanel';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
16
  export const filterColumns = (pinnedColumns, columns) => {
@@ -74,19 +74,6 @@ const VirtualScrollerDetailPanels = styled('div', {
74
74
  })({
75
75
  position: 'relative'
76
76
  });
77
- const VirtualScrollerDetailPanel = styled(Box, {
78
- name: 'MuiDataGrid',
79
- slot: 'DetailPanel',
80
- overridesResolver: (props, styles) => styles.detailPanel
81
- })(({
82
- theme
83
- }) => ({
84
- zIndex: 2,
85
- width: '100%',
86
- position: 'absolute',
87
- backgroundColor: theme.palette.background.default,
88
- overflow: 'auto'
89
- }));
90
77
  const VirtualScrollerPinnedColumns = styled('div', {
91
78
  name: 'MuiDataGrid',
92
79
  slot: 'PinnedColumns',
@@ -210,15 +197,17 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
210
197
  const exists = rowIndex !== undefined;
211
198
 
212
199
  if ( /*#__PURE__*/React.isValidElement(content) && exists) {
213
- const height = detailPanelsHeights[id];
200
+ const hasAutoHeight = apiRef.current.unstable_detailPanelHasAutoHeight(id);
201
+ const height = hasAutoHeight ? 'auto' : detailPanelsHeights[id];
214
202
  const sizes = apiRef.current.unstable_getRowInternalSizes(id);
215
203
  const spacingTop = (sizes == null ? void 0 : sizes.spacingTop) || 0;
216
204
  const top = rowsMeta.positions[rowIndex] + apiRef.current.unstable_getRowHeight(id) + spacingTop;
217
- panels.push( /*#__PURE__*/_jsx(VirtualScrollerDetailPanel, {
205
+ panels.push( /*#__PURE__*/_jsx(GridDetailPanel, {
206
+ rowId: id,
218
207
  style: {
219
- top,
220
- height
208
+ top
221
209
  },
210
+ height: height,
222
211
  className: classes.detailPanel,
223
212
  children: content
224
213
  }, i));
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { SxProps, Theme } from '@mui/material/styles';
3
+ import { GridRowId } from '@mui/x-data-grid';
4
+ interface GridDetailPanelProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ /**
6
+ * The system prop that allows defining system overrides as well as additional CSS styles.
7
+ */
8
+ sx?: SxProps<Theme>;
9
+ /**
10
+ * The panel height.
11
+ */
12
+ height: number | 'auto';
13
+ /**
14
+ * The row ID that this panel belongs to.
15
+ */
16
+ rowId: GridRowId;
17
+ }
18
+ declare const GridDetailPanel: (props: GridDetailPanelProps) => JSX.Element;
19
+ export { GridDetailPanel };
@@ -0,0 +1,65 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["rowId", "height", "style"];
4
+ import * as React from 'react';
5
+ import Box from '@mui/material/Box';
6
+ import { styled } from '@mui/material/styles';
7
+ import { useGridApiContext } from '../hooks/utils/useGridApiContext';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const DetailPanel = styled(Box, {
10
+ name: 'MuiDataGrid',
11
+ slot: 'DetailPanel',
12
+ overridesResolver: (props, styles) => styles.detailPanel
13
+ })(({
14
+ theme
15
+ }) => ({
16
+ zIndex: 2,
17
+ width: '100%',
18
+ position: 'absolute',
19
+ backgroundColor: theme.palette.background.default,
20
+ overflow: 'auto'
21
+ }));
22
+
23
+ const GridDetailPanel = props => {
24
+ const {
25
+ rowId,
26
+ height,
27
+ style: styleProp = {}
28
+ } = props,
29
+ other = _objectWithoutPropertiesLoose(props, _excluded);
30
+
31
+ const apiRef = useGridApiContext();
32
+ const ref = React.useRef();
33
+ React.useLayoutEffect(() => {
34
+ if (height === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
35
+ // Fallback for IE
36
+ apiRef.current.unstable_storeDetailPanelHeight(rowId, ref.current.clientHeight);
37
+ }
38
+ }, [apiRef, height, rowId]);
39
+ React.useLayoutEffect(() => {
40
+ const hasFixedHeight = height !== 'auto';
41
+
42
+ if (!ref.current || hasFixedHeight || typeof ResizeObserver === 'undefined') {
43
+ return undefined;
44
+ }
45
+
46
+ const resizeObserver = new ResizeObserver(entries => {
47
+ const [entry] = entries;
48
+ const observedHeight = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
49
+ apiRef.current.unstable_storeDetailPanelHeight(rowId, observedHeight);
50
+ });
51
+ resizeObserver.observe(ref.current);
52
+ return () => resizeObserver.disconnect();
53
+ }, [apiRef, height, rowId]);
54
+
55
+ const style = _extends({}, styleProp, {
56
+ height
57
+ });
58
+
59
+ return /*#__PURE__*/_jsx(DetailPanel, _extends({
60
+ ref: ref,
61
+ style: style
62
+ }, other));
63
+ };
64
+
65
+ export { GridDetailPanel };
@@ -3,4 +3,4 @@ import { GridStateInitializer } from '@mui/x-data-grid/internals';
3
3
  import { GridApiPro } from '../../../models/gridApiPro';
4
4
  import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
5
5
  export declare const columnPinningStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'pinnedColumns' | 'initialState' | 'disableColumnPinning'>>;
6
- export declare const useGridColumnPinning: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'initialState' | 'disableColumnPinning' | 'pinnedColumns' | 'onPinnedColumnsChange'>) => void;
6
+ export declare const useGridColumnPinning: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'disableColumnPinning' | 'pinnedColumns' | 'onPinnedColumnsChange'>) => void;
@@ -1,5 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { GridRowId } from '@mui/x-data-grid';
3
+ declare type DetailPanelHeightCache = Record<GridRowId, {
4
+ autoHeight: boolean;
5
+ height: number;
6
+ }>;
3
7
  /**
4
8
  * The master/detail API interface that is available in the grid [[apiRef]].
5
9
  */
@@ -19,10 +23,25 @@ export interface GridDetailPanelApi {
19
23
  * @param {GridRowId[]} ids The ids of the rows to open the detail panel.
20
24
  */
21
25
  setExpandedDetailPanels: (ids: GridRowId[]) => void;
26
+ /**
27
+ * Stores the panel height measurement and triggers the row height pre-processing.
28
+ * @param {GridRowId} id The id of the row.
29
+ * @param {number} height The new height.
30
+ * @ignore - do not document.
31
+ */
32
+ unstable_storeDetailPanelHeight: (id: GridRowId, height: number) => void;
33
+ /**
34
+ * Determines if the height of a detail panel is "auto".
35
+ * @param {GridRowId} id The id of the row.
36
+ * @return {boolean} `true` if the detail panel height is "auto".
37
+ * @ignore - do not document.
38
+ */
39
+ unstable_detailPanelHasAutoHeight: (id: GridRowId) => boolean;
22
40
  }
23
41
  export interface GridDetailPanelState {
24
42
  expandedRowIds: GridRowId[];
25
43
  contentCache: Record<GridRowId, React.ReactNode>;
26
- heightCache: Record<GridRowId, number>;
44
+ heightCache: DetailPanelHeightCache;
27
45
  }
28
46
  export declare type GridDetailPanelInitialState = Pick<GridDetailPanelState, 'expandedRowIds'>;
47
+ export {};
@@ -1,5 +1,16 @@
1
1
  /// <reference types="react" />
2
+ import { GridRowId } from '@mui/x-data-grid';
2
3
  import { GridStatePro } from '../../../models/gridStatePro';
3
- export declare const gridDetailPanelExpandedRowIdsSelector: (state: GridStatePro) => import("@mui/x-data-grid").GridRowId[];
4
- export declare const gridDetailPanelExpandedRowsContentCacheSelector: (state: GridStatePro) => Record<import("@mui/x-data-grid").GridRowId, import("react").ReactNode>;
5
- export declare const gridDetailPanelExpandedRowsHeightCacheSelector: (state: GridStatePro) => Record<import("@mui/x-data-grid").GridRowId, number>;
4
+ export declare const gridDetailPanelExpandedRowIdsSelector: (state: GridStatePro) => GridRowId[];
5
+ export declare const gridDetailPanelExpandedRowsContentCacheSelector: (state: GridStatePro) => Record<GridRowId, import("react").ReactNode>;
6
+ export declare const gridDetailPanelRawHeightCacheSelector: (state: GridStatePro) => {
7
+ [x: string]: {
8
+ autoHeight: boolean;
9
+ height: number;
10
+ };
11
+ [x: number]: {
12
+ autoHeight: boolean;
13
+ height: number;
14
+ };
15
+ };
16
+ export declare const gridDetailPanelExpandedRowsHeightCacheSelector: import("@mui/x-data-grid").OutputSelector<GridStatePro, Record<GridRowId, number>>;
@@ -1,3 +1,11 @@
1
+ import { createSelector } from '@mui/x-data-grid/internals';
1
2
  export const gridDetailPanelExpandedRowIdsSelector = state => state.detailPanel.expandedRowIds;
2
3
  export const gridDetailPanelExpandedRowsContentCacheSelector = state => state.detailPanel.contentCache;
3
- export const gridDetailPanelExpandedRowsHeightCacheSelector = state => state.detailPanel.heightCache;
4
+ export const gridDetailPanelRawHeightCacheSelector = state => state.detailPanel.heightCache; // TODO v6: Make this selector return the full object, including the autoHeight flag
5
+
6
+ export const gridDetailPanelExpandedRowsHeightCacheSelector = createSelector(gridDetailPanelRawHeightCacheSelector, heightCache => Object.entries(heightCache).reduce((acc, [id, {
7
+ height
8
+ }]) => {
9
+ acc[id] = height || 0;
10
+ return acc;
11
+ }, {}));
@@ -7,7 +7,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
8
8
  export const GRID_DETAIL_PANEL_TOGGLE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
9
9
  field: GRID_DETAIL_PANEL_TOGGLE_FIELD,
10
- headerName: '',
11
10
  type: 'detailPanelToggle',
12
11
  editable: false,
13
12
  sortable: false,
@@ -22,5 +21,6 @@ export const GRID_DETAIL_PANEL_TOGGLE_COL_DEF = _extends({}, GRID_STRING_COL_DEF
22
21
  const expandedRowIds = gridDetailPanelExpandedRowIdsSelector(params.api.state);
23
22
  return expandedRowIds.includes(params.id);
24
23
  },
25
- renderCell: params => /*#__PURE__*/_jsx(GridDetailPanelToggleCell, _extends({}, params))
24
+ renderCell: params => /*#__PURE__*/_jsx(GridDetailPanelToggleCell, _extends({}, params)),
25
+ renderHeader: () => null
26
26
  });
@@ -1,3 +1,3 @@
1
1
  export * from './gridDetailPanelToggleColDef';
2
- export * from './gridDetailPanelSelector';
2
+ export { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, } from './gridDetailPanelSelector';
3
3
  export * from './gridDetailPanelInterface';
@@ -1,3 +1,3 @@
1
1
  export * from './gridDetailPanelToggleColDef';
2
- export * from './gridDetailPanelSelector';
2
+ export { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
3
3
  export * from './gridDetailPanelInterface';
@@ -3,4 +3,4 @@ import { GridStateInitializer } from '@mui/x-data-grid/internals';
3
3
  import { GridApiPro } from '../../../models/gridApiPro';
4
4
  import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
5
5
  export declare const detailPanelStateInitializer: GridStateInitializer<Pick<DataGridProProcessedProps, 'initialState' | 'detailPanelExpandedRowIds'>>;
6
- export declare const useGridDetailPanel: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'initialState' | 'getDetailPanelContent' | 'getDetailPanelHeight' | 'detailPanelExpandedRowIds' | 'onDetailPanelExpandedRowIdsChange' | 'pagination' | 'paginationMode'>) => void;
6
+ export declare const useGridDetailPanel: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'getDetailPanelContent' | 'getDetailPanelHeight' | 'detailPanelExpandedRowIds' | 'onDetailPanelExpandedRowIdsChange'>) => void;