@mui/x-data-grid-pro 5.12.3 → 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.
- package/CHANGELOG.md +53 -0
- package/DataGridPro/DataGridPro.js +1 -1
- package/components/DataGridProVirtualScroller.js +7 -18
- package/components/GridDetailPanel.d.ts +19 -0
- package/components/GridDetailPanel.js +65 -0
- package/hooks/features/detailPanel/gridDetailPanelInterface.d.ts +20 -1
- package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +14 -3
- package/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
- package/hooks/features/detailPanel/index.d.ts +1 -1
- package/hooks/features/detailPanel/index.js +1 -1
- package/hooks/features/detailPanel/useGridDetailPanel.js +41 -7
- package/hooks/features/detailPanel/useGridDetailPanelCache.d.ts +4 -0
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +64 -0
- package/index.js +1 -1
- package/legacy/DataGridPro/DataGridPro.js +1 -1
- package/legacy/components/DataGridProVirtualScroller.js +12 -26
- package/legacy/components/GridDetailPanel.js +72 -0
- package/legacy/hooks/features/detailPanel/gridDetailPanelSelector.js +15 -2
- package/legacy/hooks/features/detailPanel/index.js +1 -1
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +40 -7
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +64 -0
- package/legacy/index.js +1 -1
- package/legacy/utils/releaseInfo.js +1 -1
- package/models/dataGridProProps.d.ts +2 -2
- package/modern/DataGridPro/DataGridPro.js +1 -1
- package/modern/components/DataGridProVirtualScroller.js +7 -18
- package/modern/components/GridDetailPanel.js +65 -0
- package/modern/hooks/features/detailPanel/gridDetailPanelSelector.js +9 -1
- package/modern/hooks/features/detailPanel/index.js +1 -1
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +39 -7
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +62 -0
- package/modern/index.js +1 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +1 -1
- package/node/components/DataGridProVirtualScroller.js +8 -19
- package/node/components/GridDetailPanel.js +83 -0
- package/node/hooks/features/detailPanel/gridDetailPanelSelector.js +12 -2
- package/node/hooks/features/detailPanel/index.js +25 -11
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +40 -6
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +81 -0
- package/node/index.js +1 -1
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +3 -3
- package/utils/releaseInfo.js +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.GridDetailPanel = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
|
+
|
|
14
|
+
var React = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
17
|
+
|
|
18
|
+
var _styles = require("@mui/material/styles");
|
|
19
|
+
|
|
20
|
+
var _useGridApiContext = require("../hooks/utils/useGridApiContext");
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
const _excluded = ["rowId", "height", "style"];
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
const DetailPanel = (0, _styles.styled)(_Box.default, {
|
|
31
|
+
name: 'MuiDataGrid',
|
|
32
|
+
slot: 'DetailPanel',
|
|
33
|
+
overridesResolver: (props, styles) => styles.detailPanel
|
|
34
|
+
})(({
|
|
35
|
+
theme
|
|
36
|
+
}) => ({
|
|
37
|
+
zIndex: 2,
|
|
38
|
+
width: '100%',
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
backgroundColor: theme.palette.background.default,
|
|
41
|
+
overflow: 'auto'
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const GridDetailPanel = props => {
|
|
45
|
+
const {
|
|
46
|
+
rowId,
|
|
47
|
+
height,
|
|
48
|
+
style: styleProp = {}
|
|
49
|
+
} = props,
|
|
50
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
51
|
+
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
52
|
+
const ref = React.useRef();
|
|
53
|
+
React.useLayoutEffect(() => {
|
|
54
|
+
if (height === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
|
|
55
|
+
// Fallback for IE
|
|
56
|
+
apiRef.current.unstable_storeDetailPanelHeight(rowId, ref.current.clientHeight);
|
|
57
|
+
}
|
|
58
|
+
}, [apiRef, height, rowId]);
|
|
59
|
+
React.useLayoutEffect(() => {
|
|
60
|
+
const hasFixedHeight = height !== 'auto';
|
|
61
|
+
|
|
62
|
+
if (!ref.current || hasFixedHeight || typeof ResizeObserver === 'undefined') {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
67
|
+
const [entry] = entries;
|
|
68
|
+
const observedHeight = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
69
|
+
apiRef.current.unstable_storeDetailPanelHeight(rowId, observedHeight);
|
|
70
|
+
});
|
|
71
|
+
resizeObserver.observe(ref.current);
|
|
72
|
+
return () => resizeObserver.disconnect();
|
|
73
|
+
}, [apiRef, height, rowId]);
|
|
74
|
+
const style = (0, _extends2.default)({}, styleProp, {
|
|
75
|
+
height
|
|
76
|
+
});
|
|
77
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DetailPanel, (0, _extends2.default)({
|
|
78
|
+
ref: ref,
|
|
79
|
+
style: style
|
|
80
|
+
}, other));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
exports.GridDetailPanel = GridDetailPanel;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridDetailPanelExpandedRowsHeightCacheSelector = exports.gridDetailPanelExpandedRowsContentCacheSelector = exports.gridDetailPanelExpandedRowIdsSelector = void 0;
|
|
6
|
+
exports.gridDetailPanelRawHeightCacheSelector = exports.gridDetailPanelExpandedRowsHeightCacheSelector = exports.gridDetailPanelExpandedRowsContentCacheSelector = exports.gridDetailPanelExpandedRowIdsSelector = void 0;
|
|
7
|
+
|
|
8
|
+
var _internals = require("@mui/x-data-grid/internals");
|
|
7
9
|
|
|
8
10
|
const gridDetailPanelExpandedRowIdsSelector = state => state.detailPanel.expandedRowIds;
|
|
9
11
|
|
|
@@ -13,6 +15,14 @@ const gridDetailPanelExpandedRowsContentCacheSelector = state => state.detailPan
|
|
|
13
15
|
|
|
14
16
|
exports.gridDetailPanelExpandedRowsContentCacheSelector = gridDetailPanelExpandedRowsContentCacheSelector;
|
|
15
17
|
|
|
16
|
-
const
|
|
18
|
+
const gridDetailPanelRawHeightCacheSelector = state => state.detailPanel.heightCache; // TODO v6: Make this selector return the full object, including the autoHeight flag
|
|
19
|
+
|
|
17
20
|
|
|
21
|
+
exports.gridDetailPanelRawHeightCacheSelector = gridDetailPanelRawHeightCacheSelector;
|
|
22
|
+
const gridDetailPanelExpandedRowsHeightCacheSelector = (0, _internals.createSelector)(gridDetailPanelRawHeightCacheSelector, heightCache => Object.entries(heightCache).reduce((acc, [id, {
|
|
23
|
+
height
|
|
24
|
+
}]) => {
|
|
25
|
+
acc[id] = height || 0;
|
|
26
|
+
return acc;
|
|
27
|
+
}, {}));
|
|
18
28
|
exports.gridDetailPanelExpandedRowsHeightCacheSelector = gridDetailPanelExpandedRowsHeightCacheSelector;
|
|
@@ -3,11 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
gridDetailPanelExpandedRowIdsSelector: true,
|
|
8
|
+
gridDetailPanelExpandedRowsContentCacheSelector: true,
|
|
9
|
+
gridDetailPanelExpandedRowsHeightCacheSelector: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "gridDetailPanelExpandedRowIdsSelector", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _gridDetailPanelSelector.gridDetailPanelExpandedRowIdsSelector;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "gridDetailPanelExpandedRowsContentCacheSelector", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _gridDetailPanelSelector.gridDetailPanelExpandedRowsContentCacheSelector;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "gridDetailPanelExpandedRowsHeightCacheSelector", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _gridDetailPanelSelector.gridDetailPanelExpandedRowsHeightCacheSelector;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
6
29
|
|
|
7
30
|
var _gridDetailPanelToggleColDef = require("./gridDetailPanelToggleColDef");
|
|
8
31
|
|
|
9
32
|
Object.keys(_gridDetailPanelToggleColDef).forEach(function (key) {
|
|
10
33
|
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
11
35
|
if (key in exports && exports[key] === _gridDetailPanelToggleColDef[key]) return;
|
|
12
36
|
Object.defineProperty(exports, key, {
|
|
13
37
|
enumerable: true,
|
|
@@ -19,21 +43,11 @@ Object.keys(_gridDetailPanelToggleColDef).forEach(function (key) {
|
|
|
19
43
|
|
|
20
44
|
var _gridDetailPanelSelector = require("./gridDetailPanelSelector");
|
|
21
45
|
|
|
22
|
-
Object.keys(_gridDetailPanelSelector).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _gridDetailPanelSelector[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _gridDetailPanelSelector[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
46
|
var _gridDetailPanelInterface = require("./gridDetailPanelInterface");
|
|
34
47
|
|
|
35
48
|
Object.keys(_gridDetailPanelInterface).forEach(function (key) {
|
|
36
49
|
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
37
51
|
if (key in exports && exports[key] === _gridDetailPanelInterface[key]) return;
|
|
38
52
|
Object.defineProperty(exports, key, {
|
|
39
53
|
enumerable: true,
|
|
@@ -28,6 +28,7 @@ const detailPanelStateInitializer = (state, props) => {
|
|
|
28
28
|
|
|
29
29
|
return (0, _extends2.default)({}, state, {
|
|
30
30
|
detailPanel: {
|
|
31
|
+
heightCache: {},
|
|
31
32
|
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 : []
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -35,7 +36,7 @@ const detailPanelStateInitializer = (state, props) => {
|
|
|
35
36
|
|
|
36
37
|
exports.detailPanelStateInitializer = detailPanelStateInitializer;
|
|
37
38
|
|
|
38
|
-
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight) {
|
|
39
|
+
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
|
|
39
40
|
if (typeof getDetailPanelContent !== 'function') {
|
|
40
41
|
return {};
|
|
41
42
|
} // TODO change to lazy approach using a Proxy
|
|
@@ -49,12 +50,19 @@ function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeig
|
|
|
49
50
|
return acc;
|
|
50
51
|
}, {});
|
|
51
52
|
const heightCache = rowIds.reduce((acc, id) => {
|
|
53
|
+
var _previousHeightCache$;
|
|
54
|
+
|
|
52
55
|
if (contentCache[id] == null) {
|
|
53
56
|
return acc;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
const params = apiRef.current.getRowParams(id);
|
|
57
|
-
|
|
60
|
+
const height = getDetailPanelHeight(params);
|
|
61
|
+
const autoHeight = height === 'auto';
|
|
62
|
+
acc[id] = {
|
|
63
|
+
autoHeight,
|
|
64
|
+
height: autoHeight ? (_previousHeightCache$ = previousHeightCache[id]) == null ? void 0 : _previousHeightCache$.height : height
|
|
65
|
+
};
|
|
58
66
|
return acc;
|
|
59
67
|
}, {});
|
|
60
68
|
return {
|
|
@@ -133,10 +141,36 @@ const useGridDetailPanel = (apiRef, props) => {
|
|
|
133
141
|
});
|
|
134
142
|
apiRef.current.forceUpdate();
|
|
135
143
|
}, [apiRef]);
|
|
144
|
+
const storeDetailPanelHeight = React.useCallback((id, height) => {
|
|
145
|
+
const heightCache = (0, _gridDetailPanelSelector.gridDetailPanelRawHeightCacheSelector)(apiRef.current.state);
|
|
146
|
+
|
|
147
|
+
if (!heightCache[id] || heightCache[id].height === height) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
apiRef.current.setState(state => {
|
|
152
|
+
return (0, _extends2.default)({}, state, {
|
|
153
|
+
detailPanel: (0, _extends2.default)({}, state.detailPanel, {
|
|
154
|
+
heightCache: (0, _extends2.default)({}, heightCache, {
|
|
155
|
+
[id]: (0, _extends2.default)({}, heightCache[id], {
|
|
156
|
+
height
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
apiRef.current.unstable_requestPipeProcessorsApplication('rowHeight');
|
|
163
|
+
}, [apiRef]);
|
|
164
|
+
const detailPanelHasAutoHeight = React.useCallback(id => {
|
|
165
|
+
const heightCache = (0, _gridDetailPanelSelector.gridDetailPanelRawHeightCacheSelector)(apiRef.current.state);
|
|
166
|
+
return heightCache[id] ? heightCache[id].autoHeight : false;
|
|
167
|
+
}, [apiRef]);
|
|
136
168
|
const detailPanelApi = {
|
|
137
169
|
toggleDetailPanel,
|
|
138
170
|
getExpandedDetailPanels,
|
|
139
|
-
setExpandedDetailPanels
|
|
171
|
+
setExpandedDetailPanels,
|
|
172
|
+
unstable_storeDetailPanelHeight: storeDetailPanelHeight,
|
|
173
|
+
unstable_detailPanelHasAutoHeight: detailPanelHasAutoHeight
|
|
140
174
|
};
|
|
141
175
|
(0, _xDataGrid.useGridApiMethod)(apiRef, detailPanelApi, 'detailPanelApi');
|
|
142
176
|
React.useEffect(() => {
|
|
@@ -151,7 +185,7 @@ const useGridDetailPanel = (apiRef, props) => {
|
|
|
151
185
|
const updateCachesAndForceUpdate = React.useCallback(() => {
|
|
152
186
|
apiRef.current.setState(state => {
|
|
153
187
|
return (0, _extends2.default)({}, state, {
|
|
154
|
-
detailPanel: (0, _extends2.default)({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
|
|
188
|
+
detailPanel: (0, _extends2.default)({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
|
|
155
189
|
});
|
|
156
190
|
});
|
|
157
191
|
apiRef.current.forceUpdate();
|
|
@@ -166,7 +200,7 @@ const useGridDetailPanel = (apiRef, props) => {
|
|
|
166
200
|
|
|
167
201
|
apiRef.current.setState(state => {
|
|
168
202
|
return (0, _extends2.default)({}, state, {
|
|
169
|
-
detailPanel: (0, _extends2.default)({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight))
|
|
203
|
+
detailPanel: (0, _extends2.default)({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
|
|
170
204
|
});
|
|
171
205
|
});
|
|
172
206
|
previousGetDetailPanelContentProp.current = props.getDetailPanelContent;
|
|
@@ -182,7 +216,7 @@ const useGridDetailPanel = (apiRef, props) => {
|
|
|
182
216
|
}
|
|
183
217
|
|
|
184
218
|
updateCachesIfNeeded();
|
|
185
|
-
const heightCache = (0, _gridDetailPanelSelector.gridDetailPanelExpandedRowsHeightCacheSelector)(apiRef
|
|
219
|
+
const heightCache = (0, _gridDetailPanelSelector.gridDetailPanelExpandedRowsHeightCacheSelector)(apiRef);
|
|
186
220
|
return (0, _extends2.default)({}, initialValue, {
|
|
187
221
|
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)
|
|
188
222
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useGridDetailPanelCache = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _xDataGrid = require("@mui/x-data-grid");
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight, previousHeightCache) {
|
|
21
|
+
if (typeof getDetailPanelContent !== 'function') {
|
|
22
|
+
return {};
|
|
23
|
+
} // TODO change to lazy approach using a Proxy
|
|
24
|
+
// only call getDetailPanelContent when asked for an id
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const rowIds = (0, _xDataGrid.gridRowIdsSelector)(apiRef);
|
|
28
|
+
const contentCache = rowIds.reduce((acc, id) => {
|
|
29
|
+
const params = apiRef.current.getRowParams(id);
|
|
30
|
+
acc[id] = getDetailPanelContent(params);
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
const heightCache = rowIds.reduce((acc, id) => {
|
|
34
|
+
var _previousHeightCache$;
|
|
35
|
+
|
|
36
|
+
if (contentCache[id] == null) {
|
|
37
|
+
return acc;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const params = apiRef.current.getRowParams(id);
|
|
41
|
+
const height = getDetailPanelHeight(params);
|
|
42
|
+
const autoHeight = height === 'auto';
|
|
43
|
+
acc[id] = {
|
|
44
|
+
autoHeight,
|
|
45
|
+
height: !autoHeight ? height : (_previousHeightCache$ = previousHeightCache[id]) == null ? void 0 : _previousHeightCache$.height
|
|
46
|
+
};
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
return {
|
|
50
|
+
contentCache,
|
|
51
|
+
heightCache
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const useGridDetailPanelCache = (apiRef, props) => {
|
|
56
|
+
const updateCaches = React.useCallback(() => {
|
|
57
|
+
apiRef.current.setState(state => {
|
|
58
|
+
return (0, _extends2.default)({}, state, {
|
|
59
|
+
detailPanel: (0, _extends2.default)({}, state.detailPanel, cacheContentAndHeight(apiRef, props.getDetailPanelContent, props.getDetailPanelHeight, state.detailPanel.heightCache))
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
apiRef.current.forceUpdate();
|
|
63
|
+
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
64
|
+
(0, _xDataGrid.useGridApiEventHandler)(apiRef, 'sortedRowsSet', updateCaches);
|
|
65
|
+
const isFirstRender = React.useRef(true);
|
|
66
|
+
|
|
67
|
+
if (isFirstRender.current) {
|
|
68
|
+
isFirstRender.current = false;
|
|
69
|
+
updateCaches();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
if (isFirstRender.current) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
updateCaches();
|
|
78
|
+
}, [updateCaches]);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.useGridDetailPanelCache = useGridDetailPanelCache;
|
package/node/index.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.getReleaseInfo = void 0;
|
|
|
8
8
|
var _utils = require("@mui/utils");
|
|
9
9
|
|
|
10
10
|
const getReleaseInfo = () => {
|
|
11
|
-
const releaseInfo = "
|
|
11
|
+
const releaseInfo = "MTY1NzE0NDgwMDAwMA==";
|
|
12
12
|
|
|
13
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
14
14
|
// A simple hack to set the value in the test environment (has no build step).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-pro",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.13.0",
|
|
4
4
|
"description": "The Pro plan edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.17.2",
|
|
35
35
|
"@mui/utils": "^5.4.1",
|
|
36
|
-
"@mui/x-data-grid": "5.
|
|
36
|
+
"@mui/x-data-grid": "5.13.0",
|
|
37
37
|
"@mui/x-license-pro": "5.12.3",
|
|
38
38
|
"@types/format-util": "^1.0.2",
|
|
39
|
-
"clsx": "^1.
|
|
39
|
+
"clsx": "^1.2.1",
|
|
40
40
|
"prop-types": "^15.8.1",
|
|
41
41
|
"reselect": "^4.1.6"
|
|
42
42
|
},
|
package/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY1NzE0NDgwMDAwMA==";
|
|
4
4
|
|
|
5
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
6
|
// A simple hack to set the value in the test environment (has no build step).
|