@mui/x-data-grid-pro 7.1.1 → 7.3.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,167 @@
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
+ ## 7.3.0
7
+
8
+ _Apr 18, 2024_
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
+ - 📄 Support [unknown and estimated row count in server-side pagination](https://mui.com/x/react-data-grid/pagination/#index-based-pagination) (#12490) @MBilalShafi
13
+ - 🎨 Support color scales in Charts (#12490) @alexfauquette
14
+ Add a [`colorMap` configuration](https://mui.com/x/react-charts/styling/#values-color) to an axis, and the chart will use it to select colors.
15
+ Each impacted chart ([bar charts](https://mui.com/x/react-charts/bars/#color-scale), [line charts](https://mui.com/x/react-charts/lines/#color-scale), [scatter charts](https://mui.com/x/react-charts/scatter/#color-scale)) has a dedicated section explaining how this color map is impacting it.
16
+
17
+ <img src="https://github.com/mui/mui-x/assets/45398769/f0066606-3486-4c4e-b3be-7fdd56d763c3" alt="scatter chart with gradient along y-axis" />
18
+
19
+ - 🌍 Improve Danish (da-DK) locale on the Data Grid
20
+ - 🐞 Bugfixes
21
+ - 📚 Documentation improvements
22
+
23
+ ### Data Grid
24
+
25
+ #### `@mui/x-data-grid@7.3.0`
26
+
27
+ - [DataGrid] Fix calling `onCellEditStop` on error (#12747) @sai6855
28
+ - [DataGrid] Fix column resize (#12792) @romgrk
29
+ - [DataGrid] Fix column separators (#12808) @romgrk
30
+ - [DataGrid] Limit panel width to not exceed screen width (#12799) @cherniavskii
31
+ - [DataGrid] Support advanced server-side pagination use cases (#12474) @MBilalShafi
32
+ - [DataGrid] Support state export and restore on grid density (#12671) @MBilalShafi
33
+ - [l10n] Improve Danish (da-DK) locale (#12784) @EmilBahnsen
34
+
35
+ #### `@mui/x-data-grid-pro@7.3.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
36
+
37
+ Same changes as in `@mui/x-data-grid@7.3.0`, plus:
38
+
39
+ - [DataGridPro] Implement header filter height (#12666) @romgrk
40
+
41
+ #### `@mui/x-data-grid-premium@7.3.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
42
+
43
+ Same changes as in `@mui/x-data-grid-pro@7.3.0`.
44
+
45
+ ### Charts
46
+
47
+ #### Breaking change
48
+
49
+ A typo fix:
50
+
51
+ ```diff
52
+ - ContinuouseScaleName
53
+ + ContinuousScaleName
54
+ ```
55
+
56
+ #### `@mui/x-charts@7.3.0`
57
+
58
+ - [charts] Add `dataIndex` to series `valueFormatter` (#12745) @JCQuintas
59
+ - [charts] Add color scale (#12490) @alexfauquette
60
+ - [charts] Do not document the usage of `DEFAULT_X_AXIS_KEY` and `DEFAULT_Y_AXIS_KEY` (#12780) @alexfauquette
61
+ - [charts] Export more utils (#12744) @alexfauquette
62
+ - [charts] Fix passing slot props down to `PieArcLabel` (#12806) @JCQuintas
63
+
64
+ ### Tree View
65
+
66
+ #### `@mui/x-tree-view@7.3.0`
67
+
68
+ - [TreeView] Support `defaultMuiPrevented` on the `onFocus` prop of the root slot (#12813) @flaviendelangle
69
+
70
+ ### Docs
71
+
72
+ - [docs] Add grid cell display example to the migration guide (#12793) @romgrk
73
+ - [docs] Use charts classes objects (#12781) @alexfauquette
74
+ - [docs] Fix layout shift on demos (#12816) @zanivan
75
+ - [test] Increase timeout for test that sometimes fail on `DateTimeRangePicker` (#12786) @LukasTy
76
+
77
+ ### Core
78
+
79
+ - [docs-infra] Prepare infra to document charts interfaces (#12653) @alexfauquette
80
+
81
+ ## 7.2.0
82
+
83
+ _Apr 12, 2024_
84
+
85
+ We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
86
+
87
+ - 🎨 Make grid colors customizable through the MUI themes API
88
+ - 🌍 Improve French (fr-FR), German (de-DE), and Swedish (sv-SE) locales on the Data Grid and Pickers
89
+ - 🐞 Bugfixes
90
+ - 📚 Documentation improvements
91
+
92
+ ### Data Grid
93
+
94
+ #### `@mui/x-data-grid@7.2.0`
95
+
96
+ - [DataGrid] Add missing `api` property to `GridCallbackDetails` (#12742) @sai6855
97
+ - [DataGrid] Do not escape double quotes when copying to clipboard (#12722) @cherniavskii
98
+ - [DataGrid] Fix column vertical border (#12741) @romgrk
99
+ - [DataGrid] Fix invalid date error when filtering `date`/`dateTime` columns (#12709) @cherniavskii
100
+ - [DataGrid] Fix overflow with dynamic row height (#12683) @romgrk
101
+ - [DataGrid] Make colors customizable (#12614) @romgrk
102
+ - [l10n] Improve French (fr-FR) locale (#12755) @derek-0000
103
+ - [l10n] Improve German (de-DE) locale (#12752) @Jens-Schoen
104
+ - [l10n] Improve Swedish (sv-SE) locale (#12731) @pontusdacke
105
+
106
+ #### `@mui/x-data-grid-pro@7.2.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
107
+
108
+ Same changes as in `@mui/x-data-grid@7.2.0`.
109
+
110
+ #### `@mui/x-data-grid-premium@7.2.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
111
+
112
+ Same changes as in `@mui/x-data-grid-pro@7.2.0`, plus:
113
+
114
+ - [DataGridPremium] Fix clipboard paste not working when cell loses focus (#12724) @cherniavskii
115
+
116
+ ### Date and Time Pickers
117
+
118
+ #### `@mui/x-date-pickers@7.2.0`
119
+
120
+ - [fields] Fix field editing after closing the picker (#12675) @LukasTy
121
+ - [l10n] Improve French (fr-FR) locale (#12692) @FaroukBel
122
+ - [l10n] Improve German (de-DE) locale (#12752) @Jens-Schoen
123
+ - [l10n] Improve Swedish (sv-SE) locale (#12731) @pontusdacke
124
+ - [pickers] Fix desktop date time Pickers grid layout (#12748) @LukasTy
125
+
126
+ #### `@mui/x-date-pickers-pro@7.2.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
127
+
128
+ Same changes as in `@mui/x-date-pickers@7.2.0`, plus:
129
+
130
+ - [DateTimeRangePicker] Fix desktop toolbar style (#12760) @LukasTy
131
+
132
+ ### Charts
133
+
134
+ #### `@mui/x-charts@7.2.0`
135
+
136
+ - [charts] Fix Bar chart with empty dataset throwing an error (#12708) @JCQuintas
137
+ - [charts] Fix `tickLabelInterval` not working on `YAxis` (#12746) @JCQuintas
138
+
139
+ ### Tree View
140
+
141
+ #### `@mui/x-tree-view@7.2.0`
142
+
143
+ - [TreeView] Add a new lookup to access an item index without expansive computation (#12729) @flaviendelangle
144
+ - [TreeView] Clean up usage of term "node" in internals (#12655) @noraleonte
145
+ - [TreeView] Improve performance by removing `getNavigableChildrenIds` method (#12713) @flaviendelangle
146
+ - [TreeView] Remove `state.items.itemTree` (#12717) @flaviendelangle
147
+ - [TreeView] Remove remaining occurences of the word "node" in the codebase (#12712) @flaviendelangle
148
+ - [TreeView] Return `instance` and `publicAPI` methods from plugin and populate the main objects inside `useTreeView` (#12650) @flaviendelangle
149
+ - [TreeView] Fix behaviors when the item order changes (#12369) @flaviendelangle
150
+
151
+ ### Docs
152
+
153
+ - [docs] Add `AxisFormatter` documentation for customizing tick/tooltip value formatting (#12700) @JCQuintas
154
+ - [docs] Add file explorer example to rich tree view customization docs (#12707) @noraleonte
155
+ - [docs] Do not use import of depth 3 in the doc (#12716) @flaviendelangle
156
+ - [docs] Explain how to clip plots with composition (#12679) @alexfauquette
157
+ - [docs] Fix typo in Data Grid v7 migration page (#12720) @bfaulk96
158
+ - [docs] Fix typo in Pickers v7 migration page (#12721) @bfaulk96
159
+
160
+ ### Core
161
+
162
+ - [core] Support multiple resolved `l10n` PR packages (#12735) @LukasTy
163
+ - [core] Update Netlify release references in release README (#12687) @LukasTy
164
+ - [core] Use `describeTreeView` for icons tests (#12672) @flaviendelangle
165
+ - [core] Use `describeTreeView` in existing tests for `useTreeViewItems` (#12732) @flaviendelangle
166
+
6
167
  ## 7.1.1
7
168
 
8
169
  _Apr 5, 2024_
@@ -2972,6 +3133,56 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
2972
3133
  - [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
2973
3134
  - [license] Correctly throw errors (#10924) @oliviertassinari
2974
3135
 
3136
+ ## 6.19.11
3137
+
3138
+ _Apr 18, 2024_
3139
+
3140
+ We'd like to offer a big thanks to the 1 contributor who made this release possible. Here are some highlights ✨:
3141
+
3142
+ - 🐞 Bugfixes
3143
+
3144
+ ### Data Grid
3145
+
3146
+ #### `@mui/x-data-grid@6.19.11`
3147
+
3148
+ - [DataGrid] Fix virtualization memory leak (#12812) @romgrk
3149
+
3150
+ #### `@mui/x-data-grid-pro@6.19.11` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
3151
+
3152
+ Same changes as in `@mui/x-data-grid@6.19.11`.
3153
+
3154
+ #### `@mui/x-data-grid-premium@6.19.11` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
3155
+
3156
+ Same changes as in `@mui/x-data-grid-pro@6.19.11`.
3157
+
3158
+ ## 6.19.10
3159
+
3160
+ _Apr 12, 2024_
3161
+
3162
+ We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
3163
+
3164
+ - 🐞 Bugfixes
3165
+ - 📚 Documentation improvements
3166
+
3167
+ ### Data Grid
3168
+
3169
+ #### `@mui/x-data-grid@6.19.10`
3170
+
3171
+ - [DataGrid] Do not escape double quotes when copying to clipboard (#12734) @cherniavskii
3172
+ - [DataGrid] Fix bug in suspense (#12754) @cherniavskii
3173
+
3174
+ #### `@mui/x-data-grid-pro@6.19.10` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
3175
+
3176
+ Same changes as in `@mui/x-data-grid@6.19.10`.
3177
+
3178
+ #### `@mui/x-data-grid-premium@6.19.10` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
3179
+
3180
+ Same changes as in `@mui/x-data-grid-pro@6.19.10`.
3181
+
3182
+ ### Core
3183
+
3184
+ - [core] Update the docs release source branch (#12685) @LukasTy
3185
+
2975
3186
  ## 6.19.9
2976
3187
 
2977
3188
  _Apr 5, 2024_
@@ -245,6 +245,12 @@ DataGridProRaw.propTypes = {
245
245
  * @default "cell"
246
246
  */
247
247
  editMode: _propTypes.default.oneOf(['cell', 'row']),
248
+ /**
249
+ * Use if the actual rowCount is not known upfront, but an estimation is available.
250
+ * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
251
+ * Applicable only with `paginationMode="server"` and when `rowCount="-1"`
252
+ */
253
+ estimatedRowCount: _propTypes.default.number,
248
254
  /**
249
255
  * Unstable features, breaking changes might be introduced.
250
256
  * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
@@ -345,6 +351,10 @@ DataGridProRaw.propTypes = {
345
351
  * The grouping column used by the tree data.
346
352
  */
347
353
  groupingColDef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
354
+ /**
355
+ * Override the height of the header filters.
356
+ */
357
+ headerFilterHeight: _propTypes.default.number,
348
358
  /**
349
359
  * If `true`, enables the data grid filtering on header feature.
350
360
  * @default false
@@ -603,6 +613,11 @@ DataGridProRaw.propTypes = {
603
613
  * @param {GridCallbackDetails} details Additional details for this callback.
604
614
  */
605
615
  onMenuOpen: _propTypes.default.func,
616
+ /**
617
+ * Callback fired when the pagination meta has changed.
618
+ * @param {GridPaginationMeta} paginationMeta Updated pagination meta.
619
+ */
620
+ onPaginationMetaChange: _propTypes.default.func,
606
621
  /**
607
622
  * Callback fired when the pagination model has changed.
608
623
  * @param {GridPaginationModel} model Updated pagination model.
@@ -726,6 +741,13 @@ DataGridProRaw.propTypes = {
726
741
  * @default false
727
742
  */
728
743
  pagination: _propTypes.default.bool,
744
+ /**
745
+ * The extra information about the pagination state of the Data Grid.
746
+ * Only applicable with `paginationMode="server"`.
747
+ */
748
+ paginationMeta: _propTypes.default.shape({
749
+ hasNextPage: _propTypes.default.bool
750
+ }),
729
751
  /**
730
752
  * Pagination can be processed on the server or client-side.
731
753
  * Set it to 'client' if you would like to handle the pagination on the client-side.
@@ -772,6 +794,7 @@ DataGridProRaw.propTypes = {
772
794
  /**
773
795
  * Set the total number of rows, if it is different from the length of the value `rows` prop.
774
796
  * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
797
+ * Only works with `paginationMode="server"`, ignored when `paginationMode="client"`.
775
798
  */
776
799
  rowCount: _propTypes.default.number,
777
800
  /**
@@ -20,6 +20,7 @@ export interface GridHeaderFilterCellProps extends Pick<GridStateColDef, 'header
20
20
  style?: React.CSSProperties;
21
21
  indexInSection: number;
22
22
  sectionLength: number;
23
+ gridHasFiller: boolean;
23
24
  }
24
25
  declare const Memoized: React.ForwardRefExoticComponent<GridHeaderFilterCellProps & React.RefAttributes<HTMLDivElement>>;
25
26
  export { Memoized as GridHeaderFilterCell };
@@ -17,7 +17,7 @@ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
17
17
  var _GridHeaderFilterMenuContainer = require("./GridHeaderFilterMenuContainer");
18
18
  var _GridHeaderFilterClearButton = require("./GridHeaderFilterClearButton");
19
19
  var _jsxRuntime = require("react/jsx-runtime");
20
- const _excluded = ["colIndex", "height", "hasFocus", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon", "pinnedPosition", "style", "indexInSection", "sectionLength"];
20
+ const _excluded = ["colIndex", "height", "hasFocus", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon", "pinnedPosition", "style", "indexInSection", "sectionLength", "gridHasFiller"];
21
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
23
  const useUtilityClasses = ownerState => {
@@ -53,7 +53,8 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
53
53
  pinnedPosition,
54
54
  style: styleProp,
55
55
  indexInSection,
56
- sectionLength
56
+ sectionLength,
57
+ gridHasFiller
57
58
  } = props,
58
59
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
59
60
  const apiRef = (0, _internals.useGridPrivateApiContext)();
@@ -172,7 +173,7 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
172
173
  onBlur: publish('headerFilterBlur')
173
174
  }), [onMouseDown, onKeyDown, publish]);
174
175
  const showLeftBorder = (0, _internals.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
175
- const showRightBorder = (0, _internals.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
176
+ const showRightBorder = (0, _internals.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
176
177
  const ownerState = (0, _extends2.default)({}, rootProps, {
177
178
  pinnedPosition,
178
179
  colDef,
@@ -252,6 +253,7 @@ process.env.NODE_ENV !== "production" ? GridHeaderFilterCell.propTypes = {
252
253
  // ----------------------------------------------------------------------
253
254
  colDef: _propTypes.default.object.isRequired,
254
255
  colIndex: _propTypes.default.number.isRequired,
256
+ gridHasFiller: _propTypes.default.bool.isRequired,
255
257
  hasFocus: _propTypes.default.bool,
256
258
  /**
257
259
  * Class name that will be added in the column header cell.
@@ -238,6 +238,12 @@ DataGridProRaw.propTypes = {
238
238
  * @default "cell"
239
239
  */
240
240
  editMode: PropTypes.oneOf(['cell', 'row']),
241
+ /**
242
+ * Use if the actual rowCount is not known upfront, but an estimation is available.
243
+ * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
244
+ * Applicable only with `paginationMode="server"` and when `rowCount="-1"`
245
+ */
246
+ estimatedRowCount: PropTypes.number,
241
247
  /**
242
248
  * Unstable features, breaking changes might be introduced.
243
249
  * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
@@ -338,6 +344,10 @@ DataGridProRaw.propTypes = {
338
344
  * The grouping column used by the tree data.
339
345
  */
340
346
  groupingColDef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
347
+ /**
348
+ * Override the height of the header filters.
349
+ */
350
+ headerFilterHeight: PropTypes.number,
341
351
  /**
342
352
  * If `true`, enables the data grid filtering on header feature.
343
353
  * @default false
@@ -596,6 +606,11 @@ DataGridProRaw.propTypes = {
596
606
  * @param {GridCallbackDetails} details Additional details for this callback.
597
607
  */
598
608
  onMenuOpen: PropTypes.func,
609
+ /**
610
+ * Callback fired when the pagination meta has changed.
611
+ * @param {GridPaginationMeta} paginationMeta Updated pagination meta.
612
+ */
613
+ onPaginationMetaChange: PropTypes.func,
599
614
  /**
600
615
  * Callback fired when the pagination model has changed.
601
616
  * @param {GridPaginationModel} model Updated pagination model.
@@ -719,6 +734,13 @@ DataGridProRaw.propTypes = {
719
734
  * @default false
720
735
  */
721
736
  pagination: PropTypes.bool,
737
+ /**
738
+ * The extra information about the pagination state of the Data Grid.
739
+ * Only applicable with `paginationMode="server"`.
740
+ */
741
+ paginationMeta: PropTypes.shape({
742
+ hasNextPage: PropTypes.bool
743
+ }),
722
744
  /**
723
745
  * Pagination can be processed on the server or client-side.
724
746
  * Set it to 'client' if you would like to handle the pagination on the client-side.
@@ -765,6 +787,7 @@ DataGridProRaw.propTypes = {
765
787
  /**
766
788
  * Set the total number of rows, if it is different from the length of the value `rows` prop.
767
789
  * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
790
+ * Only works with `paginationMode="server"`, ignored when `paginationMode="client"`.
768
791
  */
769
792
  rowCount: PropTypes.number,
770
793
  /**
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["colIndex", "height", "hasFocus", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon", "pinnedPosition", "style", "indexInSection", "sectionLength"];
3
+ const _excluded = ["colIndex", "height", "hasFocus", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon", "pinnedPosition", "style", "indexInSection", "sectionLength", "gridHasFiller"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -45,7 +45,8 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
45
45
  pinnedPosition,
46
46
  style: styleProp,
47
47
  indexInSection,
48
- sectionLength
48
+ sectionLength,
49
+ gridHasFiller
49
50
  } = props,
50
51
  other = _objectWithoutPropertiesLoose(props, _excluded);
51
52
  const apiRef = useGridPrivateApiContext();
@@ -164,7 +165,7 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
164
165
  onBlur: publish('headerFilterBlur')
165
166
  }), [onMouseDown, onKeyDown, publish]);
166
167
  const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
167
- const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
168
+ const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
168
169
  const ownerState = _extends({}, rootProps, {
169
170
  pinnedPosition,
170
171
  colDef,
@@ -244,6 +245,7 @@ process.env.NODE_ENV !== "production" ? GridHeaderFilterCell.propTypes = {
244
245
  // ----------------------------------------------------------------------
245
246
  colDef: PropTypes.object.isRequired,
246
247
  colIndex: PropTypes.number.isRequired,
248
+ gridHasFiller: PropTypes.bool.isRequired,
247
249
  hasFocus: PropTypes.bool,
248
250
  /**
249
251
  * Class name that will be added in the column header cell.
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["getColumnsToRender", "renderContext", "leftRenderContext", "rightRenderContext", "pinnedColumns", "visibleColumns", "getCellOffsetStyle"];
4
4
  import * as React from 'react';
5
- import { gridFocusColumnHeaderFilterSelector, useGridSelector, gridFilterModelSelector, gridTabIndexColumnHeaderFilterSelector, getDataGridUtilityClass, GridPinnedColumnPosition } from '@mui/x-data-grid';
5
+ import { gridFocusColumnHeaderFilterSelector, useGridSelector, gridFilterModelSelector, gridTabIndexColumnHeaderFilterSelector, getDataGridUtilityClass, GridPinnedColumnPosition, gridDimensionsSelector } from '@mui/x-data-grid';
6
6
  import { useGridColumnHeaders as useGridColumnHeadersCommunity, useGridPrivateApiContext, getGridFilter, GridColumnHeaderRow } from '@mui/x-data-grid/internals';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useGridRootProps } from '../../utils/useGridRootProps';
@@ -48,8 +48,9 @@ export const useGridColumnHeaders = props => {
48
48
  const rootProps = useGridRootProps();
49
49
  const classes = useUtilityClasses(rootProps);
50
50
  const disableHeaderFiltering = !rootProps.headerFilters;
51
- const dimensions = apiRef.current.getRootDimensions();
51
+ const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
52
52
  const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
53
+ const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
53
54
  const columnHeaderFilterFocus = useGridSelector(apiRef, gridFocusColumnHeaderFilterSelector);
54
55
  const getFilterItem = React.useCallback(colDef => {
55
56
  const filterModelItem = filterModel?.items.find(it => it.field === colDef.field && it.operator !== 'isAnyOf');
@@ -93,7 +94,7 @@ export const useGridColumnHeaders = props => {
93
94
  });
94
95
  filters.push( /*#__PURE__*/_jsx(rootProps.slots.headerFilterCell, _extends({
95
96
  colIndex: columnIndex,
96
- height: dimensions.headerHeight,
97
+ height: dimensions.headerFilterHeight,
97
98
  width: colDef.computedWidth,
98
99
  colDef: colDef,
99
100
  hasFocus: hasFocus,
@@ -105,7 +106,8 @@ export const useGridColumnHeaders = props => {
105
106
  pinnedPosition: pinnedPosition,
106
107
  style: style,
107
108
  indexInSection: i,
108
- sectionLength: renderedColumns.length
109
+ sectionLength: renderedColumns.length,
110
+ gridHasFiller: gridHasFiller
109
111
  }, rootProps.slotProps?.headerFilterCell), `${colDef.field}-filter`));
110
112
  }
111
113
  return otherProps.getFillers(params, filters, 0, true);
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxMjI2NDQwMDAwMA==";
3
+ const releaseInfo = "MTcxMzM5MTIwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
@@ -56,8 +56,9 @@ const useGridColumnHeaders = props => {
56
56
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
57
57
  const classes = useUtilityClasses(rootProps);
58
58
  const disableHeaderFiltering = !rootProps.headerFilters;
59
- const dimensions = apiRef.current.getRootDimensions();
59
+ const dimensions = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridDimensionsSelector);
60
60
  const filterModel = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridFilterModelSelector);
61
+ const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
61
62
  const columnHeaderFilterFocus = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridFocusColumnHeaderFilterSelector);
62
63
  const getFilterItem = React.useCallback(colDef => {
63
64
  const filterModelItem = filterModel?.items.find(it => it.field === colDef.field && it.operator !== 'isAnyOf');
@@ -101,7 +102,7 @@ const useGridColumnHeaders = props => {
101
102
  });
102
103
  filters.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.headerFilterCell, (0, _extends2.default)({
103
104
  colIndex: columnIndex,
104
- height: dimensions.headerHeight,
105
+ height: dimensions.headerFilterHeight,
105
106
  width: colDef.computedWidth,
106
107
  colDef: colDef,
107
108
  hasFocus: hasFocus,
@@ -113,7 +114,8 @@ const useGridColumnHeaders = props => {
113
114
  pinnedPosition: pinnedPosition,
114
115
  style: style,
115
116
  indexInSection: i,
116
- sectionLength: renderedColumns.length
117
+ sectionLength: renderedColumns.length,
118
+ gridHasFiller: gridHasFiller
117
119
  }, rootProps.slotProps?.headerFilterCell), `${colDef.field}-filter`));
118
120
  }
119
121
  return otherProps.getFillers(params, filters, 0, true);
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-pro v7.1.1
2
+ * @mui/x-data-grid-pro v7.3.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridEventListener, GridCallbackDetails, GridRowParams, GridRowId, GridValidRowModel, GridGroupNode, GridFeatureMode } from '@mui/x-data-grid';
3
- import { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, GridPinnedColumnFields, DataGridProSharedPropsWithDefaultValue } from '@mui/x-data-grid/internals';
3
+ import { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, GridPinnedColumnFields, DataGridProSharedPropsWithDefaultValue, DataGridProSharedPropsWithoutDefaultValue } from '@mui/x-data-grid/internals';
4
4
  import type { GridPinnedRowsProp } from '../hooks/features/rowPinning';
5
5
  import { GridApiPro } from './gridApiPro';
6
6
  import { GridGroupingColDefOverride, GridGroupingColDefOverrideParams } from './gridGroupingColDefOverride';
@@ -99,7 +99,7 @@ export interface DataGridProPropsWithDefaultValue<R extends GridValidRowModel =
99
99
  */
100
100
  keepColumnPositionIfDraggedOutside: boolean;
101
101
  }
102
- export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridPropsWithoutDefaultValue<R>, 'initialState' | 'componentsProps' | 'slotProps'> {
102
+ export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridPropsWithoutDefaultValue<R>, 'initialState' | 'componentsProps' | 'slotProps'>, DataGridProSharedPropsWithoutDefaultValue {
103
103
  /**
104
104
  * The ref object that allows grid manipulation. Can be instantiated with `useGridApiRef()`.
105
105
  */
@@ -238,6 +238,12 @@ DataGridProRaw.propTypes = {
238
238
  * @default "cell"
239
239
  */
240
240
  editMode: PropTypes.oneOf(['cell', 'row']),
241
+ /**
242
+ * Use if the actual rowCount is not known upfront, but an estimation is available.
243
+ * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
244
+ * Applicable only with `paginationMode="server"` and when `rowCount="-1"`
245
+ */
246
+ estimatedRowCount: PropTypes.number,
241
247
  /**
242
248
  * Unstable features, breaking changes might be introduced.
243
249
  * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
@@ -338,6 +344,10 @@ DataGridProRaw.propTypes = {
338
344
  * The grouping column used by the tree data.
339
345
  */
340
346
  groupingColDef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
347
+ /**
348
+ * Override the height of the header filters.
349
+ */
350
+ headerFilterHeight: PropTypes.number,
341
351
  /**
342
352
  * If `true`, enables the data grid filtering on header feature.
343
353
  * @default false
@@ -596,6 +606,11 @@ DataGridProRaw.propTypes = {
596
606
  * @param {GridCallbackDetails} details Additional details for this callback.
597
607
  */
598
608
  onMenuOpen: PropTypes.func,
609
+ /**
610
+ * Callback fired when the pagination meta has changed.
611
+ * @param {GridPaginationMeta} paginationMeta Updated pagination meta.
612
+ */
613
+ onPaginationMetaChange: PropTypes.func,
599
614
  /**
600
615
  * Callback fired when the pagination model has changed.
601
616
  * @param {GridPaginationModel} model Updated pagination model.
@@ -719,6 +734,13 @@ DataGridProRaw.propTypes = {
719
734
  * @default false
720
735
  */
721
736
  pagination: PropTypes.bool,
737
+ /**
738
+ * The extra information about the pagination state of the Data Grid.
739
+ * Only applicable with `paginationMode="server"`.
740
+ */
741
+ paginationMeta: PropTypes.shape({
742
+ hasNextPage: PropTypes.bool
743
+ }),
722
744
  /**
723
745
  * Pagination can be processed on the server or client-side.
724
746
  * Set it to 'client' if you would like to handle the pagination on the client-side.
@@ -765,6 +787,7 @@ DataGridProRaw.propTypes = {
765
787
  /**
766
788
  * Set the total number of rows, if it is different from the length of the value `rows` prop.
767
789
  * If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
790
+ * Only works with `paginationMode="server"`, ignored when `paginationMode="client"`.
768
791
  */
769
792
  rowCount: PropTypes.number,
770
793
  /**
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["colIndex", "height", "hasFocus", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon", "pinnedPosition", "style", "indexInSection", "sectionLength"];
3
+ const _excluded = ["colIndex", "height", "hasFocus", "width", "headerClassName", "colDef", "item", "headerFilterMenuRef", "InputComponentProps", "showClearIcon", "pinnedPosition", "style", "indexInSection", "sectionLength", "gridHasFiller"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -45,7 +45,8 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
45
45
  pinnedPosition,
46
46
  style: styleProp,
47
47
  indexInSection,
48
- sectionLength
48
+ sectionLength,
49
+ gridHasFiller
49
50
  } = props,
50
51
  other = _objectWithoutPropertiesLoose(props, _excluded);
51
52
  const apiRef = useGridPrivateApiContext();
@@ -164,7 +165,7 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
164
165
  onBlur: publish('headerFilterBlur')
165
166
  }), [onMouseDown, onKeyDown, publish]);
166
167
  const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
167
- const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
168
+ const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
168
169
  const ownerState = _extends({}, rootProps, {
169
170
  pinnedPosition,
170
171
  colDef,
@@ -244,6 +245,7 @@ process.env.NODE_ENV !== "production" ? GridHeaderFilterCell.propTypes = {
244
245
  // ----------------------------------------------------------------------
245
246
  colDef: PropTypes.object.isRequired,
246
247
  colIndex: PropTypes.number.isRequired,
248
+ gridHasFiller: PropTypes.bool.isRequired,
247
249
  hasFocus: PropTypes.bool,
248
250
  /**
249
251
  * Class name that will be added in the column header cell.
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["getColumnsToRender", "renderContext", "leftRenderContext", "rightRenderContext", "pinnedColumns", "visibleColumns", "getCellOffsetStyle"];
4
4
  import * as React from 'react';
5
- import { gridFocusColumnHeaderFilterSelector, useGridSelector, gridFilterModelSelector, gridTabIndexColumnHeaderFilterSelector, getDataGridUtilityClass, GridPinnedColumnPosition } from '@mui/x-data-grid';
5
+ import { gridFocusColumnHeaderFilterSelector, useGridSelector, gridFilterModelSelector, gridTabIndexColumnHeaderFilterSelector, getDataGridUtilityClass, GridPinnedColumnPosition, gridDimensionsSelector } from '@mui/x-data-grid';
6
6
  import { useGridColumnHeaders as useGridColumnHeadersCommunity, useGridPrivateApiContext, getGridFilter, GridColumnHeaderRow } from '@mui/x-data-grid/internals';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useGridRootProps } from '../../utils/useGridRootProps';
@@ -48,8 +48,9 @@ export const useGridColumnHeaders = props => {
48
48
  const rootProps = useGridRootProps();
49
49
  const classes = useUtilityClasses(rootProps);
50
50
  const disableHeaderFiltering = !rootProps.headerFilters;
51
- const dimensions = apiRef.current.getRootDimensions();
51
+ const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
52
52
  const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
53
+ const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
53
54
  const columnHeaderFilterFocus = useGridSelector(apiRef, gridFocusColumnHeaderFilterSelector);
54
55
  const getFilterItem = React.useCallback(colDef => {
55
56
  const filterModelItem = filterModel?.items.find(it => it.field === colDef.field && it.operator !== 'isAnyOf');
@@ -93,7 +94,7 @@ export const useGridColumnHeaders = props => {
93
94
  });
94
95
  filters.push( /*#__PURE__*/_jsx(rootProps.slots.headerFilterCell, _extends({
95
96
  colIndex: columnIndex,
96
- height: dimensions.headerHeight,
97
+ height: dimensions.headerFilterHeight,
97
98
  width: colDef.computedWidth,
98
99
  colDef: colDef,
99
100
  hasFocus: hasFocus,
@@ -105,7 +106,8 @@ export const useGridColumnHeaders = props => {
105
106
  pinnedPosition: pinnedPosition,
106
107
  style: style,
107
108
  indexInSection: i,
108
- sectionLength: renderedColumns.length
109
+ sectionLength: renderedColumns.length,
110
+ gridHasFiller: gridHasFiller
109
111
  }, rootProps.slotProps?.headerFilterCell), `${colDef.field}-filter`));
110
112
  }
111
113
  return otherProps.getFillers(params, filters, 0, true);
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-pro v7.1.1
2
+ * @mui/x-data-grid-pro v7.3.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxMjI2NDQwMDAwMA==";
3
+ const releaseInfo = "MTcxMzM5MTIwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-pro",
3
- "version": "7.1.1",
3
+ "version": "7.3.0",
4
4
  "description": "The Pro plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -35,8 +35,8 @@
35
35
  "@babel/runtime": "^7.24.0",
36
36
  "@mui/system": "^5.15.14",
37
37
  "@mui/utils": "^5.15.14",
38
- "@mui/x-data-grid": "7.1.1",
39
- "@mui/x-license": "7.1.1",
38
+ "@mui/x-data-grid": "7.3.0",
39
+ "@mui/x-license": "7.2.0",
40
40
  "@types/format-util": "^1.0.4",
41
41
  "clsx": "^2.1.0",
42
42
  "prop-types": "^15.8.1",
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getReleaseInfo = void 0;
7
7
  var _utils = require("@mui/utils");
8
8
  const getReleaseInfo = () => {
9
- const releaseInfo = "MTcxMjI2NDQwMDAwMA==";
9
+ const releaseInfo = "MTcxMzM5MTIwMDAwMA==";
10
10
  if (process.env.NODE_ENV !== 'production') {
11
11
  // A simple hack to set the value in the test environment (has no build step).
12
12
  // eslint-disable-next-line no-useless-concat
@@ -1,56 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import { useGridApiEventHandler, gridDataRowIdsSelector } from '@mui/x-data-grid';
4
- function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
5
- if (typeof getDetailPanelContent !== 'function') {
6
- return {};
7
- }
8
-
9
- // TODO change to lazy approach using a Proxy
10
- // only call getDetailPanelContent when asked for an id
11
- const rowIds = gridDataRowIdsSelector(apiRef);
12
- const contentCache = rowIds.reduce((acc, id) => {
13
- const params = apiRef.current.getRowParams(id);
14
- acc[id] = getDetailPanelContent(params);
15
- return acc;
16
- }, {});
17
- const heightCache = rowIds.reduce((acc, id) => {
18
- if (contentCache[id] == null) {
19
- return acc;
20
- }
21
- const params = apiRef.current.getRowParams(id);
22
- const height = getDetailPanelHeight(params);
23
- const autoHeight = height === 'auto';
24
- acc[id] = {
25
- autoHeight,
26
- height: !autoHeight ? height : previousHeightCache[id]?.height
27
- };
28
- return acc;
29
- }, {});
30
- return {
31
- contentCache,
32
- heightCache
33
- };
34
- }
35
- export const useGridDetailPanelCache = (apiRef, props) => {
36
- const updateCaches = React.useCallback(() => {
37
- apiRef.current.setState(state => {
38
- return _extends({}, state, {
39
- detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
40
- });
41
- });
42
- apiRef.current.forceUpdate();
43
- }, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
44
- useGridApiEventHandler(apiRef, 'sortedRowsSet', updateCaches);
45
- const isFirstRender = React.useRef(true);
46
- if (isFirstRender.current) {
47
- isFirstRender.current = false;
48
- updateCaches();
49
- }
50
- React.useEffect(() => {
51
- if (isFirstRender.current) {
52
- return;
53
- }
54
- updateCaches();
55
- }, [updateCaches]);
56
- };
@@ -1,4 +0,0 @@
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;
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useGridDetailPanelCache = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var React = _interopRequireWildcard(require("react"));
10
- var _xDataGrid = require("@mui/x-data-grid");
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
14
- if (typeof getDetailPanelContent !== 'function') {
15
- return {};
16
- }
17
-
18
- // TODO change to lazy approach using a Proxy
19
- // only call getDetailPanelContent when asked for an id
20
- const rowIds = (0, _xDataGrid.gridDataRowIdsSelector)(apiRef);
21
- const contentCache = rowIds.reduce((acc, id) => {
22
- const params = apiRef.current.getRowParams(id);
23
- acc[id] = getDetailPanelContent(params);
24
- return acc;
25
- }, {});
26
- const heightCache = rowIds.reduce((acc, id) => {
27
- if (contentCache[id] == null) {
28
- return acc;
29
- }
30
- const params = apiRef.current.getRowParams(id);
31
- const height = getDetailPanelHeight(params);
32
- const autoHeight = height === 'auto';
33
- acc[id] = {
34
- autoHeight,
35
- height: !autoHeight ? height : previousHeightCache[id]?.height
36
- };
37
- return acc;
38
- }, {});
39
- return {
40
- contentCache,
41
- heightCache
42
- };
43
- }
44
- const useGridDetailPanelCache = (apiRef, props) => {
45
- const updateCaches = React.useCallback(() => {
46
- apiRef.current.setState(state => {
47
- return (0, _extends2.default)({}, state, {
48
- detailPanel: (0, _extends2.default)({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
49
- });
50
- });
51
- apiRef.current.forceUpdate();
52
- }, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
53
- (0, _xDataGrid.useGridApiEventHandler)(apiRef, 'sortedRowsSet', updateCaches);
54
- const isFirstRender = React.useRef(true);
55
- if (isFirstRender.current) {
56
- isFirstRender.current = false;
57
- updateCaches();
58
- }
59
- React.useEffect(() => {
60
- if (isFirstRender.current) {
61
- return;
62
- }
63
- updateCaches();
64
- }, [updateCaches]);
65
- };
66
- exports.useGridDetailPanelCache = useGridDetailPanelCache;
@@ -1,56 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import { useGridApiEventHandler, gridDataRowIdsSelector } from '@mui/x-data-grid';
4
- function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
5
- if (typeof getDetailPanelContent !== 'function') {
6
- return {};
7
- }
8
-
9
- // TODO change to lazy approach using a Proxy
10
- // only call getDetailPanelContent when asked for an id
11
- const rowIds = gridDataRowIdsSelector(apiRef);
12
- const contentCache = rowIds.reduce((acc, id) => {
13
- const params = apiRef.current.getRowParams(id);
14
- acc[id] = getDetailPanelContent(params);
15
- return acc;
16
- }, {});
17
- const heightCache = rowIds.reduce((acc, id) => {
18
- if (contentCache[id] == null) {
19
- return acc;
20
- }
21
- const params = apiRef.current.getRowParams(id);
22
- const height = getDetailPanelHeight(params);
23
- const autoHeight = height === 'auto';
24
- acc[id] = {
25
- autoHeight,
26
- height: !autoHeight ? height : previousHeightCache[id]?.height
27
- };
28
- return acc;
29
- }, {});
30
- return {
31
- contentCache,
32
- heightCache
33
- };
34
- }
35
- export const useGridDetailPanelCache = (apiRef, props) => {
36
- const updateCaches = React.useCallback(() => {
37
- apiRef.current.setState(state => {
38
- return _extends({}, state, {
39
- detailPanel: _extends({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
40
- });
41
- });
42
- apiRef.current.forceUpdate();
43
- }, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
44
- useGridApiEventHandler(apiRef, 'sortedRowsSet', updateCaches);
45
- const isFirstRender = React.useRef(true);
46
- if (isFirstRender.current) {
47
- isFirstRender.current = false;
48
- updateCaches();
49
- }
50
- React.useEffect(() => {
51
- if (isFirstRender.current) {
52
- return;
53
- }
54
- updateCaches();
55
- }, [updateCaches]);
56
- };