@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
@@ -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
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.12.2
1
+ /** @license MUI v5.13.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -8,7 +8,7 @@ exports.getReleaseInfo = void 0;
8
8
  var _utils = require("@mui/utils");
9
9
 
10
10
  const getReleaseInfo = () => {
11
- const releaseInfo = "MTY1NTMzMDQwMDAwMA==";
11
+ const releaseInfo = "MTY1Nzg1NDAwMDAwMA==";
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.12.2",
3
+ "version": "5.13.1",
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",
@@ -31,14 +31,14 @@
31
31
  "directory": "packages/grid/x-data-grid-pro"
32
32
  },
33
33
  "dependencies": {
34
- "@babel/runtime": "^7.17.2",
34
+ "@babel/runtime": "^7.18.6",
35
35
  "@mui/utils": "^5.4.1",
36
- "@mui/x-data-grid": "5.12.2",
37
- "@mui/x-license-pro": "5.12.2",
36
+ "@mui/x-data-grid": "5.13.1",
37
+ "@mui/x-license-pro": "5.13.1",
38
38
  "@types/format-util": "^1.0.2",
39
- "clsx": "^1.0.4",
39
+ "clsx": "^1.2.1",
40
40
  "prop-types": "^15.8.1",
41
- "reselect": "^4.1.5"
41
+ "reselect": "^4.1.6"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@mui/material": "^5.4.1",
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY1NTMzMDQwMDAwMA==";
3
+ const releaseInfo = "MTY1Nzg1NDAwMDAwMA==";
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).