@mui/x-data-grid-pro 5.12.2 → 5.13.1

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 (48) hide show
  1. package/CHANGELOG.md +160 -6
  2. package/DataGridPro/DataGridPro.js +1 -1
  3. package/components/DataGridProColumnHeaders.js +14 -7
  4. package/components/DataGridProVirtualScroller.js +7 -18
  5. package/components/GridDetailPanel.d.ts +19 -0
  6. package/components/GridDetailPanel.js +65 -0
  7. package/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +20 -1
  8. package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +14 -3
  9. package/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
  10. package/hooks/features/detailPanel/index.d.ts +1 -1
  11. package/hooks/features/detailPanel/index.js +1 -1
  12. package/hooks/features/detailPanel/useGridDetailPanel.js +41 -7
  13. package/hooks/features/detailPanel/useGridDetailPanelCache.d.ts +4 -0
  14. package/hooks/features/detailPanel/useGridDetailPanelCache.js +64 -0
  15. package/index.js +1 -1
  16. package/legacy/DataGridPro/DataGridPro.js +1 -1
  17. package/legacy/components/DataGridProColumnHeaders.js +14 -7
  18. package/legacy/components/DataGridProVirtualScroller.js +12 -26
  19. package/legacy/components/GridDetailPanel.js +72 -0
  20. package/legacy/hooks/features/detailPanel/gridDetailPanelSelector.js +15 -2
  21. package/legacy/hooks/features/detailPanel/index.js +1 -1
  22. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +40 -7
  23. package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +64 -0
  24. package/legacy/index.js +1 -1
  25. package/legacy/utils/releaseInfo.js +1 -1
  26. package/models/dataGridProProps.d.ts +2 -2
  27. package/modern/DataGridPro/DataGridPro.js +1 -1
  28. package/modern/components/DataGridProColumnHeaders.js +14 -7
  29. package/modern/components/DataGridProVirtualScroller.js +7 -18
  30. package/modern/components/GridDetailPanel.js +65 -0
  31. package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
  32. package/modern/hooks/features/detailPanel/index.js +1 -1
  33. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +39 -7
  34. package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +62 -0
  35. package/modern/index.js +1 -1
  36. package/modern/utils/releaseInfo.js +1 -1
  37. package/node/DataGridPro/DataGridPro.js +1 -1
  38. package/node/components/DataGridProColumnHeaders.js +14 -7
  39. package/node/components/DataGridProVirtualScroller.js +8 -19
  40. package/node/components/GridDetailPanel.js +83 -0
  41. package/node/hooks/features/detailPanel/gridDetailPanelSelector.js +12 -2
  42. package/node/hooks/features/detailPanel/index.js +25 -11
  43. package/node/hooks/features/detailPanel/useGridDetailPanel.js +40 -6
  44. package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +81 -0
  45. package/node/index.js +1 -1
  46. package/node/utils/releaseInfo.js +1 -1
  47. package/package.json +6 -6
  48. package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,160 @@
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.1
7
+
8
+ _Jul 15, 2022_
9
+
10
+ We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - ✏️ Enter edit mode when pasting in a cell with Ctrl+V (Cmd+V on macOS) (#5405) @alexfauquette
13
+ - 🌍 Many improvements to the locales
14
+ - 📚 Documentation improvements
15
+ - 🐞 Bugfixes
16
+
17
+ ### `@mui/x-data-grid@v5.13.1` / `@mui/x-data-grid-pro@v5.13.1` / `@mui/x-data-grid-premium@v5.13.1`
18
+
19
+ #### Changes
20
+
21
+ - [DataGrid] Fix blank space when using dynamic row height with pagination (#5315) @m4theushw
22
+ - [DataGrid] Start editing with uppercase letter and Ctrl+V (#5405) @alexfauquette
23
+ - [DataGrid] Fix some filters being removed from filter model on filter panel open (#5403) @cherniavskii
24
+ - [DataGridPro] Improve pinned column headers accessibility (#5370) @cherniavskii
25
+ - [l10n] Improve Dutch (nl-NL) locale (#5464) @developenguin
26
+ - [l10n] Improve French (fr-FR) locale (#3211) (#5420) @Zenoo
27
+ - [l10n] Improve German (de-DE) locale (#5448) @sebastianfrey
28
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#5394) @andrepxa
29
+ - [l10n] Improve Romanian (ro-RO) locale (#5449) @rolule
30
+
31
+ ### `@mui/x-date-pickers@v5.0.0-beta.1` / `@mui/x-date-picker-pro@5.0.0-beta.1`
32
+
33
+ #### Changes
34
+
35
+ - [pickers] Add Italian (it-IT) locale (#5467) @felixh10r
36
+ - [pickers] Add Spanish (es-ES) locale (#5468) @felixh10r
37
+ - [pickers] Improve French (fr-FR) locale (#5446) @Zenoo
38
+ - [pickers] Improve German (de-DE) locale (#5447) @sebastianfrey
39
+
40
+ ### Docs
41
+
42
+ - [docs] Fix typo in the sorting page (#5431) @JosephMarinier
43
+ - [docs] Fix description for "Striped rows" example (#5432) @lindapaiste
44
+ - [docs] Make a clear difference between the license and license key (#5316) @oliviertassinari
45
+ - [docs] Update pickers README files (#5456) @cherniavskii
46
+ - [docs] Clarify the scope of support for MUI X (#5423) @joserodolfofreitas
47
+
48
+ ### Core
49
+
50
+ - [core] Add technical support link to \_redirects (#5428) @joserodolfofreitas
51
+ - [core] Improve GitHub bug reproduction template (#5067) @joserodolfofreitas
52
+ - [core] Include playground pages in tsconfig (#5367) @cherniavskii
53
+ - [core] Sort keys like in material-ui @oliviertassinari
54
+ - [test] Wait for flags to load on regression tests (#5473) @m4theushw
55
+
56
+ ## 5.13.0
57
+
58
+ _Jul 7, 2022_
59
+
60
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
61
+
62
+ - 🎁 `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` are now in beta!
63
+
64
+ - ✨ Allow detail panel's height to match its content (#5163) @m4theushw
65
+
66
+ ```tsx
67
+ <DataGridPro getDetailPanelHeight={() => 'auto'} />
68
+ ```
69
+
70
+ - 🌍 Add Romanian (ro-RO) locale on the data grid (#5345) @rolule
71
+ - 📚 Documentation improvements
72
+ - 🐞 Bugfixes
73
+
74
+ ### `@mui/x-data-grid@v5.13.0` / `@mui/x-data-grid-pro@v5.13.0` / `@mui/x-data-grid-premium@v5.13.0`
75
+
76
+ #### Changes
77
+
78
+ - [DataGrid] Allows to customize variant of value input in filter panel (#4826) @alexfauquette
79
+ - [DataGrid] Add Romanian (ro-RO) locale (#5345) @rolule
80
+ - [DataGrid] Export Norwegian (nb-NO) locale (#5407) @cherniavskii
81
+ - [DataGrid] Fix broken "start editing" integration with Japanese (#5414) @mnajdova
82
+ - [DataGrid] Fix "stop editing" integration with IME e.g. Japanese (#5257) @Gumichocopengin8
83
+ - [DataGrid] Fix dimensions computation with `autoHeight` and scroll x (#5401) @flaviendelangle
84
+ - [DataGrid] Improve Slovak (sk-SK) locale (#5332) @msidlo
85
+ - [DataGrid] Mention Premium plan in error messages and docs warnings (#5328) @cherniavskii
86
+ - [DataGrid] Remove trailing spaces in filter input (#5279) @alexfauquette
87
+ - [DataGridPro] Allow to infer detail panel height from content (#5163) @m4theushw
88
+ - [DataGridPro] Fix the depth of nodes when switching from a non-flat tree to a flat tree (#5362) @flaviendelangle
89
+
90
+ ### `@mui/x-date-pickers@v5.0.0-beta.0` / `@mui/x-date-picker-pro@5.0.0-beta.0`
91
+
92
+ #### Changes
93
+
94
+ - [DateRangePicker] Fix keyboard selection (#5265) @alexfauquette
95
+ - [DayPicker] Remove empty space at the bottom of the day view (#5073) @flaviendelangle
96
+ - [pickers] Add missing type dependencies (#5331) @Methuselah96
97
+ - [pickers] Pass the generics to the components in the theme augmentation (#5199) @toruticas
98
+
99
+ ### Docs
100
+
101
+ - [docs] Explain how to use hooks inside a cell renderer (#5158) @flaviendelangle
102
+ - [docs] Fix server-side pagination demo (#5361) @cherniavskii
103
+ - [docs] Fix typo in the quick filter docs (#5313) @alexfauquette
104
+ - [docs] Improve the "Getting started" page (#5293) @alexfauquette
105
+ - [docs] New page for the pickers action bar customization (#5267) @flaviendelangle
106
+ - [docs] Revise and split up "Overview" page into "Introduction" (#4692) @samuelsycamore
107
+ - [docs] Use `useKeepGroupedColumnsHiddren` from the grid package on remaining demo (#5382) @flaviendelangle
108
+
109
+ ## v5.12.3
110
+
111
+ _Jun 23, 2022_
112
+
113
+ We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
114
+
115
+ - 🌍 Add Swedish (sv-SE) locale on the data grid and the pickers (#5210) @mrxdst
116
+ - 🌍 Add Dutch (nl-NL) locale on the pickers (#5237) @DDukers
117
+ - 📚 Documentation improvements
118
+ - 🐞 Bugfixes
119
+
120
+ ### `@mui/x-data-grid@v5.12.3` / `@mui/x-data-grid-pro@v5.12.3` / `@mui/x-data-grid-premium@v5.12.3`
121
+
122
+ #### Changes
123
+
124
+ - [DataGrid] Do not hide non-hideable column when pressing Hide All button (#5298) @flaviendelangle
125
+ - [DataGrid] Do not regenerate the row tree when the `loading` prop changes (#5213) @flaviendelangle
126
+ - [DataGrid] Fix the default filter operator fallback on state initialization (#5266) @flaviendelangle
127
+ - [DataGrid] Stop using the deprecated `api` prop in the grid components (#5205) @flaviendelangle
128
+ - [DataGrid] Add Swedish (sv-SE) locale (#5210) @mrxdst
129
+ - [DataGridPremium] Fix detail panel on `DataGridPremium` (#5264) @flaviendelangle
130
+ - [DataGridPremium] Fix Excel import with Remix / Vite (#5207) @alexfauquette
131
+ - [DataGridPremium] Fix error with quick filter and grouping rows (#5238) @alexfauquette
132
+
133
+ ### `@mui/x-date-pickers@v5.0.0-alpha.7` / `@mui/x-date-pickers-pro@v5.0.0-alpha.7`
134
+
135
+ #### Changes
136
+
137
+ - [pickers] Export adapters from both `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` (#5204) @flaviendelangle
138
+ - [pickers] Add Dutch (nl-NL) locale (#5237) @DDukers
139
+
140
+ ### Docs
141
+
142
+ - [docs] Add `DataGridPremium` to all API sections (#5196) @flaviendelangle
143
+ - [docs] Add plan badge next to event name in the Events page (#5200) @flaviendelangle
144
+ - [docs] Add section for theme augmentation in the picker docs (#5276) @flaviendelangle
145
+ - [docs] Add waiting for upvote section for row group panel (#5271) @flaviendelangle
146
+ - [docs] Disable ad on main demo page (#5301) @joserodolfofreitas
147
+ - [docs] Fix typo in the `DateRangePicker` documentation (#5259) @flaviendelangle
148
+
149
+ ### Core
150
+
151
+ - [core] Allow having multiple playgrounds (#5288) @alexfauquette
152
+ - [core] Improve typing of `GridFilterInputMultipleSingleSelect` (#5206) @flaviendelangle
153
+ - [core] Remove arbitrary new lines (#5245) @oliviertassinari
154
+ - [core] Remove dead logic (#5282) @oliviertassinari
155
+ - [test] Fix `inputFormat` when testing with different date adapters (#5291) @cherniavskii
156
+ - [test] Fix date assertion in Safari 13 (#5221) @m4theushw
157
+ - [test] Throw if date adapter is not found (#5289) @cherniavskii
158
+ - [test] Use mock for `ResizeObserver` (#5215) @m4theushw
159
+
6
160
  ## v5.12.2
7
161
 
8
162
  _Jun 16, 2022_
@@ -71,7 +225,7 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
71
225
  - [l10n] Update Japanese (ja-JP) locale (#5122) @hikotq
72
226
  - [l10n] Update Russian (ru-RU) locale (#5069) @Artboomy
73
227
 
74
- ### `@mui/x-date-pickers@5.0.0-alpha.6` / `@mui/x-date-pickers-pro@5.0.0-alpha.6`
228
+ ### `@mui/x-date-pickers@v5.0.0-alpha.6` / `@mui/x-date-pickers-pro@v5.0.0-alpha.6`
75
229
 
76
230
  #### Changes
77
231
 
@@ -138,7 +292,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
138
292
  - [l10n] Add Norwegian (Bokmål) (nb-NO) locale (#5001) @spiftire
139
293
  - [l10n] Add Turkish (tr-TR) locale (#5026) @Rassilion
140
294
 
141
- ### `@mui/x-date-pickers@5.0.0-alpha.5` / `@mui/x-date-pickers-pro@5.0.0-alpha.5`
295
+ ### `@mui/x-date-pickers@v5.0.0-alpha.5` / `@mui/x-date-pickers-pro@v5.0.0-alpha.5`
142
296
 
143
297
  #### Breaking changes
144
298
 
@@ -211,7 +365,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
211
365
  - [DataGridPremium] Support column spanning in the Excel export (#4830) @cherniavskii
212
366
  - [l10n] Improve Russian (ru-RU) locale (#4864) @arvkonstantin
213
367
 
214
- ### `@mui/x-date-pickers@5.0.0-alpha.4` / `@mui/x-date-pickers-pro@5.0.0-alpha.4`
368
+ ### `@mui/x-date-pickers@v5.0.0-alpha.4` / `@mui/x-date-pickers-pro@v5.0.0-alpha.4`
215
369
 
216
370
  #### Breaking changes
217
371
 
@@ -336,7 +490,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
336
490
  - [l10n] Improve German (de-DE) locale (#4748) @sebastianfrey
337
491
  - [l10n] Improve German (de-DE) locale (#4668) @izu-co
338
492
 
339
- ### `@mui/x-date-pickers@5.0.0-alpha.3` / `@mui/x-date-pickers-pro@5.0.0-alpha.3`
493
+ ### `@mui/x-date-pickers@v5.0.0-alpha.3` / `@mui/x-date-pickers-pro@v5.0.0-alpha.3`
340
494
 
341
495
  #### Breaking changes
342
496
 
@@ -437,7 +591,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
437
591
  - [DataGrid] Don't close column menu when updating rows (#4498) @m4theushw
438
592
  - [DataGridPro] Introduce row reorder (#4034) @DanailH
439
593
 
440
- ### `@mui/x-date-pickers@5.0.0-alpha.2` / `@mui/x-date-pickers-pro@5.0.0-alpha.2`
594
+ ### `@mui/x-date-pickers@v5.0.0-alpha.2` / `@mui/x-date-pickers-pro@v5.0.0-alpha.2`
441
595
 
442
596
  - [pickers] Pass `PaperProps` to `DesktopWrapper` component (#4584) @alexfauquette
443
597
  - [TimePicker] Fix bug when time picker clear value (#4582) @alexfauquette
@@ -498,7 +652,7 @@ We'd like to offer a big thanks to the 9 contributors who made this release poss
498
652
  - [DataGridPro] Fix toggling detail panel using keyboard (#4409) @cherniavskii
499
653
  - [l10n] Add Hungarian (hu-HU) locale (#4458) @x22tri
500
654
 
501
- ### `@mui/x-date-pickers@5.0.0-alpha.1` / `@mui/x-date-pickers-pro@5.0.0-alpha.1`
655
+ ### `@mui/x-date-pickers@v5.0.0-alpha.1` / `@mui/x-date-pickers-pro@v5.0.0-alpha.1`
502
656
 
503
657
  - [ClockPicker] Should call `shouldDisableTime` with the hours with meridiem (#4404) @flaviendelangle
504
658
  - [MonthPicker] Clicking on a `PickersMonth` button should not trigger the form submit (#4402) @flaviendelangle
@@ -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,
@@ -117,15 +117,21 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
117
117
  firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
118
118
  lastColumnIndex: visibleColumnFields.length
119
119
  }) : null;
120
+ const innerProps = getInnerProps();
121
+ const pinnedColumnHeadersProps = {
122
+ role: innerProps.role,
123
+ 'aria-rowindex': innerProps['aria-rowindex']
124
+ };
120
125
  return /*#__PURE__*/_jsxs(GridColumnHeaders, _extends({
121
126
  ref: ref,
122
127
  className: className
123
128
  }, getRootProps(other), {
124
- children: [leftRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, {
129
+ children: [leftRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, _extends({
125
130
  className: classes.leftPinnedColumns,
126
131
  ownerState: {
127
132
  side: GridPinnedPosition.left
128
- },
133
+ }
134
+ }, pinnedColumnHeadersProps, {
129
135
  children: getColumns({
130
136
  renderContext: leftRenderContext,
131
137
  minFirstColumn: leftRenderContext.firstColumnIndex,
@@ -133,22 +139,23 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
133
139
  }, {
134
140
  disableReorder: true
135
141
  })
136
- }), /*#__PURE__*/_jsx(GridColumnHeadersInner, _extends({
142
+ })), /*#__PURE__*/_jsx(GridColumnHeadersInner, _extends({
137
143
  isDragging: isDragging
138
- }, getInnerProps(), {
144
+ }, innerProps, {
139
145
  children: getColumns({
140
146
  renderContext,
141
147
  minFirstColumn: leftPinnedColumns.length,
142
148
  maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
143
149
  })
144
- })), rightRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, {
150
+ })), rightRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, _extends({
145
151
  ownerState: {
146
152
  side: GridPinnedPosition.right
147
153
  },
148
154
  className: classes.rightPinnedColumns,
149
155
  style: {
150
156
  paddingRight: scrollbarSize
151
- },
157
+ }
158
+ }, pinnedColumnHeadersProps, {
152
159
  children: getColumns({
153
160
  renderContext: rightRenderContext,
154
161
  minFirstColumn: rightRenderContext.firstColumnIndex,
@@ -157,6 +164,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
157
164
  disableReorder: true,
158
165
  separatorSide: GridColumnHeaderSeparatorSides.Left
159
166
  })
160
- })]
167
+ }))]
161
168
  }));
162
169
  });
@@ -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 };
@@ -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
+ }, {}));
@@ -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,18 +3,19 @@ import * as React from 'react';
3
3
  import { useGridSelector, useGridApiEventHandler, useGridApiMethod, gridRowIdsSelector } from '@mui/x-data-grid';
4
4
  import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
5
5
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
6
- import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
6
+ import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector, gridDetailPanelRawHeightCacheSelector } from './gridDetailPanelSelector';
7
7
  export const detailPanelStateInitializer = (state, props) => {
8
8
  var _ref, _props$detailPanelExp, _props$initialState, _props$initialState$d;
9
9
 
10
10
  return _extends({}, state, {
11
11
  detailPanel: {
12
+ heightCache: {},
12
13
  expandedRowIds: (_ref = (_props$detailPanelExp = props.detailPanelExpandedRowIds) != null ? _props$detailPanelExp : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$d = _props$initialState.detailPanel) == null ? void 0 : _props$initialState$d.expandedRowIds) != null ? _ref : []
13
14
  }
14
15
  });
15
16
  };
16
17
 
17
- function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight) {
18
+ function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
18
19
  if (typeof getDetailPanelContent !== 'function') {
19
20
  return {};
20
21
  } // TODO change to lazy approach using a Proxy
@@ -28,12 +29,19 @@ function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeig
28
29
  return acc;
29
30
  }, {});
30
31
  const heightCache = rowIds.reduce((acc, id) => {
32
+ var _previousHeightCache$;
33
+
31
34
  if (contentCache[id] == null) {
32
35
  return acc;
33
36
  }
34
37
 
35
38
  const params = apiRef.current.getRowParams(id);
36
- acc[id] = getDetailPanelHeight(params);
39
+ const height = getDetailPanelHeight(params);
40
+ const autoHeight = height === 'auto';
41
+ acc[id] = {
42
+ autoHeight,
43
+ height: autoHeight ? (_previousHeightCache$ = previousHeightCache[id]) == null ? void 0 : _previousHeightCache$.height : height
44
+ };
37
45
  return acc;
38
46
  }, {});
39
47
  return {
@@ -112,10 +120,36 @@ export const useGridDetailPanel = (apiRef, props) => {
112
120
  });
113
121
  apiRef.current.forceUpdate();
114
122
  }, [apiRef]);
123
+ const storeDetailPanelHeight = React.useCallback((id, height) => {
124
+ const heightCache = gridDetailPanelRawHeightCacheSelector(apiRef.current.state);
125
+
126
+ if (!heightCache[id] || heightCache[id].height === height) {
127
+ return;
128
+ }
129
+
130
+ apiRef.current.setState(state => {
131
+ return _extends({}, state, {
132
+ detailPanel: _extends({}, state.detailPanel, {
133
+ heightCache: _extends({}, heightCache, {
134
+ [id]: _extends({}, heightCache[id], {
135
+ height
136
+ })
137
+ })
138
+ })
139
+ });
140
+ });
141
+ apiRef.current.unstable_requestPipeProcessorsApplication('rowHeight');
142
+ }, [apiRef]);
143
+ const detailPanelHasAutoHeight = React.useCallback(id => {
144
+ const heightCache = gridDetailPanelRawHeightCacheSelector(apiRef.current.state);
145
+ return heightCache[id] ? heightCache[id].autoHeight : false;
146
+ }, [apiRef]);
115
147
  const detailPanelApi = {
116
148
  toggleDetailPanel,
117
149
  getExpandedDetailPanels,
118
- setExpandedDetailPanels
150
+ setExpandedDetailPanels,
151
+ unstable_storeDetailPanelHeight: storeDetailPanelHeight,
152
+ unstable_detailPanelHasAutoHeight: detailPanelHasAutoHeight
119
153
  };
120
154
  useGridApiMethod(apiRef, detailPanelApi, 'detailPanelApi');
121
155
  React.useEffect(() => {
@@ -130,7 +164,7 @@ export const useGridDetailPanel = (apiRef, props) => {
130
164
  const updateCachesAndForceUpdate = React.useCallback(() => {
131
165
  apiRef.current.setState(state => {
132
166
  return _extends({}, state, {
133
- detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
167
+ detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
134
168
  });
135
169
  });
136
170
  apiRef.current.forceUpdate();
@@ -145,7 +179,7 @@ export const useGridDetailPanel = (apiRef, props) => {
145
179
 
146
180
  apiRef.current.setState(state => {
147
181
  return _extends({}, state, {
148
- detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
182
+ detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
149
183
  });
150
184
  });
151
185
  previousGetDetailPanelContentProp.current = props.getDetailPanelContent;
@@ -161,7 +195,7 @@ export const useGridDetailPanel = (apiRef, props) => {
161
195
  }
162
196
 
163
197
  updateCachesIfNeeded();
164
- const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef.current.state);
198
+ const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef);
165
199
  return _extends({}, initialValue, {
166
200
  detail: (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0 // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
167
201
 
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { GridApiPro } from '../../../models/gridApiPro';
3
+ import { DataGridProProcessedProps } from '../../../models/dataGridProProps';
4
+ export declare const useGridDetailPanelCache: (apiRef: React.MutableRefObject<GridApiPro>, props: Pick<DataGridProProcessedProps, 'getDetailPanelContent' | 'getDetailPanelHeight'>) => void;