@mui/x-data-grid-pro 7.7.1 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +166 -1
  2. package/DataGridPro/DataGridPro.js +13 -1
  3. package/DataGridPro/useDataGridProComponent.js +6 -1
  4. package/DataGridPro/useDataGridProProps.js +10 -3
  5. package/components/GridDataSourceTreeDataGroupingCell.d.ts +12 -0
  6. package/components/GridDataSourceTreeDataGroupingCell.js +120 -0
  7. package/components/GridDetailPanel.js +2 -2
  8. package/components/GridTreeDataGroupingCell.js +1 -4
  9. package/esm/DataGridPro/DataGridPro.js +13 -1
  10. package/esm/DataGridPro/useDataGridProComponent.js +6 -1
  11. package/esm/DataGridPro/useDataGridProProps.js +9 -3
  12. package/esm/components/GridDataSourceTreeDataGroupingCell.js +111 -0
  13. package/esm/components/GridDetailPanel.js +1 -1
  14. package/esm/components/GridTreeDataGroupingCell.js +1 -4
  15. package/esm/hooks/features/dataSource/cache.js +36 -0
  16. package/esm/hooks/features/dataSource/gridDataSourceSelector.js +24 -0
  17. package/esm/hooks/features/dataSource/useGridDataSource.js +218 -0
  18. package/esm/hooks/features/dataSource/utils.js +87 -0
  19. package/esm/hooks/features/index.js +3 -1
  20. package/esm/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +148 -0
  21. package/esm/hooks/features/serverSideTreeData/utils.js +18 -0
  22. package/esm/hooks/features/treeData/useGridTreeData.js +6 -2
  23. package/esm/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
  24. package/esm/internals/index.js +2 -0
  25. package/esm/internals/propValidation.js +1 -1
  26. package/esm/models/index.js +2 -1
  27. package/esm/utils/releaseInfo.js +1 -1
  28. package/esm/utils/tree/createRowTree.js +6 -2
  29. package/esm/utils/tree/insertDataRowInTree.js +34 -10
  30. package/esm/utils/tree/updateRowTree.js +13 -5
  31. package/esm/utils/tree/utils.js +5 -1
  32. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  33. package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
  34. package/hooks/features/columnReorder/useGridColumnReorder.d.ts +1 -1
  35. package/hooks/features/dataSource/cache.d.ts +18 -0
  36. package/hooks/features/dataSource/cache.js +43 -0
  37. package/hooks/features/dataSource/gridDataSourceSelector.d.ts +14 -0
  38. package/hooks/features/dataSource/gridDataSourceSelector.js +32 -0
  39. package/hooks/features/dataSource/interfaces.d.ts +50 -0
  40. package/hooks/features/dataSource/useGridDataSource.d.ts +6 -0
  41. package/hooks/features/dataSource/useGridDataSource.js +229 -0
  42. package/hooks/features/dataSource/utils.d.ts +29 -0
  43. package/hooks/features/dataSource/utils.js +95 -0
  44. package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +0 -1
  45. package/hooks/features/detailPanel/useGridDetailPanel.d.ts +1 -1
  46. package/hooks/features/index.d.ts +2 -0
  47. package/hooks/features/index.js +22 -0
  48. package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +1 -1
  49. package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
  50. package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
  51. package/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
  52. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +2 -2
  53. package/hooks/features/rowReorder/useGridRowReorder.d.ts +1 -1
  54. package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts +4 -0
  55. package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +158 -0
  56. package/hooks/features/serverSideTreeData/utils.d.ts +6 -0
  57. package/hooks/features/serverSideTreeData/utils.js +25 -0
  58. package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -2
  59. package/hooks/features/treeData/useGridTreeData.d.ts +2 -1
  60. package/hooks/features/treeData/useGridTreeData.js +6 -2
  61. package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
  62. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
  63. package/hooks/utils/useGridApiContext.d.ts +0 -1
  64. package/hooks/utils/useGridApiRef.d.ts +0 -1
  65. package/hooks/utils/useGridPrivateApiContext.d.ts +0 -1
  66. package/index.js +1 -1
  67. package/internals/index.d.ts +2 -0
  68. package/internals/index.js +23 -0
  69. package/internals/propValidation.js +1 -1
  70. package/material/index.d.ts +0 -1
  71. package/models/dataGridProProps.d.ts +17 -11
  72. package/models/gridApiPro.d.ts +3 -3
  73. package/models/gridProSlotsComponent.d.ts +0 -1
  74. package/models/gridStatePro.d.ts +2 -0
  75. package/models/index.d.ts +1 -0
  76. package/modern/DataGridPro/DataGridPro.js +13 -1
  77. package/modern/DataGridPro/useDataGridProComponent.js +6 -1
  78. package/modern/DataGridPro/useDataGridProProps.js +9 -3
  79. package/modern/components/GridDataSourceTreeDataGroupingCell.js +111 -0
  80. package/modern/components/GridDetailPanel.js +1 -1
  81. package/modern/components/GridTreeDataGroupingCell.js +1 -4
  82. package/modern/hooks/features/dataSource/cache.js +36 -0
  83. package/modern/hooks/features/dataSource/gridDataSourceSelector.js +24 -0
  84. package/modern/hooks/features/dataSource/useGridDataSource.js +218 -0
  85. package/modern/hooks/features/dataSource/utils.js +87 -0
  86. package/modern/hooks/features/index.js +3 -1
  87. package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +148 -0
  88. package/modern/hooks/features/serverSideTreeData/utils.js +18 -0
  89. package/modern/hooks/features/treeData/useGridTreeData.js +6 -2
  90. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
  91. package/modern/index.js +1 -1
  92. package/modern/internals/index.js +2 -0
  93. package/modern/internals/propValidation.js +1 -1
  94. package/modern/models/index.js +2 -1
  95. package/modern/utils/releaseInfo.js +1 -1
  96. package/modern/utils/tree/createRowTree.js +6 -2
  97. package/modern/utils/tree/insertDataRowInTree.js +34 -10
  98. package/modern/utils/tree/updateRowTree.js +13 -5
  99. package/modern/utils/tree/utils.js +5 -1
  100. package/package.json +6 -5
  101. package/typeOverloads/modules.d.ts +0 -1
  102. package/utils/releaseInfo.js +1 -1
  103. package/utils/tree/createRowTree.js +6 -2
  104. package/utils/tree/insertDataRowInTree.d.ts +3 -1
  105. package/utils/tree/insertDataRowInTree.js +33 -9
  106. package/utils/tree/models.d.ts +1 -0
  107. package/utils/tree/updateRowTree.d.ts +1 -0
  108. package/utils/tree/updateRowTree.js +13 -5
  109. package/utils/tree/utils.d.ts +5 -4
  110. package/utils/tree/utils.js +7 -2
  111. package/models/dataSource.d.ts +0 -64
  112. /package/esm/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
  113. /package/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
  114. /package/modern/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,171 @@
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.9.0
7
+
8
+ _Jul 5, 2024_
9
+
10
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🔄 Add loading overlay variants, including a skeleton loader option to the Data Grid component. See [Loading overlay docs](https://mui.com/x/react-data-grid/overlays/#loading-overlay) for more details.
13
+ - 🌳 Add `selectItem` and `getItemDOMElement` methods to the TreeView component public API
14
+ - ⛏️ Make the `usePickersTranslations` hook public in the pickers component
15
+ - 🐞 Bugfixes
16
+
17
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
18
+
19
+ ### Data Grid
20
+
21
+ #### `@mui/x-data-grid@7.9.0`
22
+
23
+ - [DataGrid] Add skeleton loading overlay support (#13293) @KenanYusuf
24
+ - [DataGrid] Fix pagination when `pagination={undefined}` (#13349) @sai6855
25
+
26
+ #### `@mui/x-data-grid-pro@7.9.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
27
+
28
+ Same changes as in `@mui/x-data-grid@7.9.0`.
29
+
30
+ #### `@mui/x-data-grid-premium@7.9.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
31
+
32
+ Same changes as in `@mui/x-data-grid-pro@7.9.0`.
33
+
34
+ ### Date and Time Pickers
35
+
36
+ #### `@mui/x-date-pickers@7.9.0`
37
+
38
+ - [pickers] Make the `usePickersTranslations` hook public (#13657) @flaviendelangle
39
+
40
+ #### `@mui/x-date-pickers-pro@7.9.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
41
+
42
+ Same changes as in `@mui/x-date-pickers@7.9.0`.
43
+
44
+ ### Charts
45
+
46
+ #### `@mui/x-charts@7.9.0`
47
+
48
+ - [charts] Add Heatmap (unreleased) (#13209) @alexfauquette
49
+ - [charts] Add initial `Zoom&Pan` to the Pro charts (unreleased) (#13405) @JCQuintas
50
+ - [charts] Fix Axis Highlight on horizontal bar charts regression (#13717) @JCQuintas
51
+ - [charts] Improve charts interaction for mobile users (#13692) @JCQuintas
52
+ - [charts] Add documentation on how to disable the tooltip on charts (#13724) @JCQuintas
53
+
54
+ ### Tree View
55
+
56
+ #### `@mui/x-tree-view@7.9.0`
57
+
58
+ - [TreeView] Add `selectItem` and `getItemDOMElement` methods to the public API (#13485) @flaviendelangle
59
+
60
+ ### Docs
61
+
62
+ - [docs] Fix custom "no results overlay" demo in dark mode (#13715) @KenanYusuf
63
+
64
+ ### Core
65
+
66
+ - [core] Add `react_next` workflow in CircleCI (#13360) @cherniavskii
67
+ - [core] Create a new package to share utils across X packages (#13528) @flaviendelangle
68
+ - [core] Fix dependency setup (#13684) @LukasTy
69
+ - [core] Remove `jscodeshift-add-imports` package (#13720) @LukasTy
70
+ - [code-infra] Cleanup monorepo and `@mui/docs` usage (#13713) @LukasTy
71
+
72
+ ## 7.8.0
73
+
74
+ _Jun 28, 2024_
75
+
76
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
77
+
78
+ - 🛰 Introduce server-side data source for improved server integration in the Data Grid.
79
+
80
+ Supports server-side pagination, sorting and filtering on plain and tree data, and automatic caching.
81
+
82
+ To enable, provide a `getRows` function to the `unstable_dataSource` prop on the Data Grid component.
83
+
84
+ ```tsx
85
+ const dataSource = {
86
+ getRows: async (params: GridServerGetRowsParams) => {
87
+ const data = await fetch(
88
+ `https://api.example.com/data?${new URLSearchParams({
89
+ page: params.page,
90
+ pageSize: params.pageSize,
91
+ sortModel: JSON.stringify(params.sortModel),
92
+ filterModel: JSON.stringify(params.filterModel),
93
+ }).toString()}`,
94
+ );
95
+ return {
96
+ rows: data.rows,
97
+ totalRows: data.totalRows,
98
+ };
99
+ },
100
+ }
101
+ <DataGridPro
102
+ unstable_dataSource={dataSource}
103
+ {...otherProps}
104
+ />
105
+ ```
106
+
107
+ See [server-side data documentation](https://mui.com/x/react-data-grid/server-side-data/) for more details.
108
+
109
+ - 📈 Support Date data on the BarChart component
110
+ - ↕️ Support custom column sort icons on the Data Grid
111
+ - 🖱️ Support modifying the expansion trigger on the Tree View components
112
+
113
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
114
+
115
+ ### Data Grid
116
+
117
+ #### `@mui/x-data-grid@7.8.0`
118
+
119
+ - [DataGrid] Add `columnHeaderSortIcon` slot (#13563) @arminmeh
120
+ - [DataGrid] Fix dimensions lag issue after autosize (#13587) @MBilalShafi
121
+ - [DataGrid] Fix print export failure when `hideFooter` option is set (#13034) @tarunrajput
122
+
123
+ #### `@mui/x-data-grid-pro@7.8.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
124
+
125
+ Same changes as in `@mui/x-data-grid@7.8.0`, plus:
126
+
127
+ - [DataGridPro] Fix multi-sorting indicator being cut off (#13625) @KenanYusuf
128
+ - [DataGridPro] Server-side tree data support (#12317) @MBilalShafi
129
+
130
+ #### `@mui/x-data-grid-premium@7.8.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
131
+
132
+ Same changes as in `@mui/x-data-grid-pro@7.8.0`.
133
+
134
+ ### Date and Time Pickers
135
+
136
+ #### `@mui/x-date-pickers@7.8.0`
137
+
138
+ - [fields] Fix section clearing behavior on Android (#13652) @LukasTy
139
+
140
+ #### `@mui/x-date-pickers-pro@7.8.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
141
+
142
+ Same changes as in `@mui/x-date-pickers@7.8.0`.
143
+
144
+ ### Charts
145
+
146
+ #### `@mui/x-charts@7.8.0`
147
+
148
+ - [charts] Fix line chart props not passing correct event handlers (#13609) @JCQuintas
149
+ - [charts] Support BarChart with `Date` data (#13471) @alexfauquette
150
+ - [charts] Support RTL for y-axis (#13614) @alexfauquette
151
+ - [charts] Use default values instead of non-null assertion to prevent error being thrown (#13637) @JCQuintas
152
+
153
+ ### Tree View
154
+
155
+ #### `@mui/x-tree-view@7.8.0`
156
+
157
+ - [TreeView] Add `expansionTrigger` prop (#13533) @noraleonte
158
+ - [TreeView] Support experimental features from plugin's dependencies (#13632) @flaviendelangle
159
+
160
+ ### Docs
161
+
162
+ - [docs] Add callout for `Luxon` `throwOnInvalid` support (#13621) @LukasTy
163
+ - [docs] Add "Overlays" section to the Data Grid documentation (#13624) @KenanYusuf
164
+
165
+ ### Core
166
+
167
+ - [core] Add eslint rule to restrict import from `../internals` root (#13633) @JCQuintas
168
+ - [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
169
+ - [license] Allow usage of charts and tree view pro package for old premium licenses (#13619) @flaviendelangle
170
+
6
171
  ## 7.7.1
7
172
 
8
173
  _Jun 21, 2024_
@@ -44,7 +209,7 @@ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
44
209
  - [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
45
210
  - [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
46
211
  - [pickers] Fix controlled `view` behavior (#13552) @LukasTy
47
- - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
212
+ - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
48
213
 
49
214
  #### `@mui/x-date-pickers-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
215
 
@@ -906,5 +906,17 @@ DataGridProRaw.propTypes = {
906
906
  * If `true`, the rows will be gathered in a tree structure according to the `getTreeDataPath` prop.
907
907
  * @default false
908
908
  */
909
- treeData: _propTypes.default.bool
909
+ treeData: _propTypes.default.bool,
910
+ unstable_dataSource: _propTypes.default.shape({
911
+ getChildrenCount: _propTypes.default.func,
912
+ getGroupKey: _propTypes.default.func,
913
+ getRows: _propTypes.default.func.isRequired,
914
+ updateRow: _propTypes.default.func
915
+ }),
916
+ unstable_dataSourceCache: _propTypes.default.shape({
917
+ clear: _propTypes.default.func.isRequired,
918
+ get: _propTypes.default.func.isRequired,
919
+ set: _propTypes.default.func.isRequired
920
+ }),
921
+ unstable_onDataSourceError: _propTypes.default.func
910
922
  };
@@ -9,6 +9,7 @@ var _useGridInfiniteLoader = require("../hooks/features/infiniteLoader/useGridIn
9
9
  var _useGridColumnReorder = require("../hooks/features/columnReorder/useGridColumnReorder");
10
10
  var _useGridTreeData = require("../hooks/features/treeData/useGridTreeData");
11
11
  var _useGridTreeDataPreProcessors = require("../hooks/features/treeData/useGridTreeDataPreProcessors");
12
+ var _useGridDataSourceTreeDataPreProcessors = require("../hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors");
12
13
  var _useGridColumnPinning = require("../hooks/features/columnPinning/useGridColumnPinning");
13
14
  var _useGridColumnPinningPreProcessors = require("../hooks/features/columnPinning/useGridColumnPinningPreProcessors");
14
15
  var _useGridDetailPanel = require("../hooks/features/detailPanel/useGridDetailPanel");
@@ -19,6 +20,7 @@ var _useGridLazyLoader = require("../hooks/features/lazyLoader/useGridLazyLoader
19
20
  var _useGridLazyLoaderPreProcessors = require("../hooks/features/lazyLoader/useGridLazyLoaderPreProcessors");
20
21
  var _useGridRowPinning = require("../hooks/features/rowPinning/useGridRowPinning");
21
22
  var _useGridRowPinningPreProcessors = require("../hooks/features/rowPinning/useGridRowPinningPreProcessors");
23
+ var _useGridDataSource = require("../hooks/features/dataSource/useGridDataSource");
22
24
  // Pro-only features
23
25
 
24
26
  const useDataGridProComponent = (inputApiRef, props) => {
@@ -30,6 +32,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
30
32
  (0, _internals.useGridRowSelectionPreProcessors)(apiRef, props);
31
33
  (0, _useGridRowReorderPreProcessors.useGridRowReorderPreProcessors)(apiRef, props);
32
34
  (0, _useGridTreeDataPreProcessors.useGridTreeDataPreProcessors)(apiRef, props);
35
+ (0, _useGridDataSourceTreeDataPreProcessors.useGridDataSourceTreeDataPreProcessors)(apiRef, props);
33
36
  (0, _useGridLazyLoaderPreProcessors.useGridLazyLoaderPreProcessors)(apiRef, props);
34
37
  (0, _useGridRowPinningPreProcessors.useGridRowPinningPreProcessors)(apiRef);
35
38
  (0, _useGridDetailPanelPreProcessors.useGridDetailPanelPreProcessors)(apiRef, props);
@@ -62,8 +65,9 @@ const useDataGridProComponent = (inputApiRef, props) => {
62
65
  (0, _internals.useGridInitializeState)(_internals.columnMenuStateInitializer, apiRef, props);
63
66
  (0, _internals.useGridInitializeState)(_internals.columnGroupsStateInitializer, apiRef, props);
64
67
  (0, _internals.useGridInitializeState)(_internals.virtualizationStateInitializer, apiRef, props);
68
+ (0, _internals.useGridInitializeState)(_useGridDataSource.dataSourceStateInitializer, apiRef, props);
65
69
  (0, _internals.useGridHeaderFiltering)(apiRef, props);
66
- (0, _useGridTreeData.useGridTreeData)(apiRef);
70
+ (0, _useGridTreeData.useGridTreeData)(apiRef, props);
67
71
  (0, _internals.useGridKeyboardNavigation)(apiRef, props);
68
72
  (0, _internals.useGridRowSelection)(apiRef, props);
69
73
  (0, _useGridColumnPinning.useGridColumnPinning)(apiRef, props);
@@ -96,6 +100,7 @@ const useDataGridProComponent = (inputApiRef, props) => {
96
100
  (0, _internals.useGridEvents)(apiRef, props);
97
101
  (0, _internals.useGridStatePersistence)(apiRef);
98
102
  (0, _internals.useGridVirtualization)(apiRef, props);
103
+ (0, _useGridDataSource.useGridDataSource)(apiRef, props);
99
104
  return apiRef;
100
105
  };
101
106
  exports.useDataGridProComponent = useDataGridProComponent;
@@ -13,6 +13,14 @@ var _internals = require("@mui/x-data-grid/internals");
13
13
  var _dataGridProDefaultSlotsComponents = require("../constants/dataGridProDefaultSlotsComponents");
14
14
  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); }
15
15
  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 && {}.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; }
16
+ const getDataGridProForcedProps = themedProps => (0, _extends2.default)({
17
+ signature: 'DataGridPro'
18
+ }, themedProps.unstable_dataSource ? {
19
+ filterMode: 'server',
20
+ sortingMode: 'server',
21
+ paginationMode: 'server'
22
+ } : {});
23
+
16
24
  /**
17
25
  * The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
18
26
  */
@@ -46,8 +54,7 @@ const useDataGridProProps = inProps => {
46
54
  }), [themedProps.slots]);
47
55
  return React.useMemo(() => (0, _extends2.default)({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
48
56
  localeText,
49
- slots,
50
- signature: 'DataGridPro'
51
- }), [themedProps, localeText, slots]);
57
+ slots
58
+ }, getDataGridProForcedProps(themedProps)), [themedProps, localeText, slots]);
52
59
  };
53
60
  exports.useDataGridProProps = useDataGridProProps;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { GridRenderCellParams, GridDataSourceGroupNode } from '@mui/x-data-grid';
3
+ interface GridTreeDataGroupingCellProps extends GridRenderCellParams<any, any, any, GridDataSourceGroupNode> {
4
+ hideDescendantCount?: boolean;
5
+ /**
6
+ * The cell offset multiplier used for calculating cell offset (`rowNode.depth * offsetMultiplier` px).
7
+ * @default 2
8
+ */
9
+ offsetMultiplier?: number;
10
+ }
11
+ export declare function GridDataSourceTreeDataGroupingCell(props: GridTreeDataGroupingCellProps): React.JSX.Element;
12
+ export {};
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GridDataSourceTreeDataGroupingCell = GridDataSourceTreeDataGroupingCell;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _utils = require("@mui/utils");
11
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
12
+ var _Badge = _interopRequireDefault(require("@mui/material/Badge"));
13
+ var _xDataGrid = require("@mui/x-data-grid");
14
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
15
+ var _useGridRootProps = require("../hooks/utils/useGridRootProps");
16
+ var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ 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); }
19
+ 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 && {}.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; }
20
+ const useUtilityClasses = ownerState => {
21
+ const {
22
+ classes
23
+ } = ownerState;
24
+ const slots = {
25
+ root: ['treeDataGroupingCell'],
26
+ toggle: ['treeDataGroupingCellToggle'],
27
+ loadingContainer: ['treeDataGroupingCellLoadingContainer']
28
+ };
29
+ return (0, _utils.unstable_composeClasses)(slots, _xDataGrid.getDataGridUtilityClass, classes);
30
+ };
31
+ function GridTreeDataGroupingCellIcon(props) {
32
+ const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
33
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
34
+ const classes = useUtilityClasses(rootProps);
35
+ const {
36
+ rowNode,
37
+ id,
38
+ field,
39
+ descendantCount
40
+ } = props;
41
+ const loadingSelector = state => state.dataSource.loading[id] ?? false;
42
+ const errorSelector = state => state.dataSource.errors[id];
43
+ const isDataLoading = (0, _xDataGrid.useGridSelector)(apiRef, loadingSelector);
44
+ const error = (0, _xDataGrid.useGridSelector)(apiRef, errorSelector);
45
+ const handleClick = event => {
46
+ if (!rowNode.childrenExpanded) {
47
+ // always fetch/get from cache the children when the node is expanded
48
+ apiRef.current.unstable_dataSource.fetchRows(id);
49
+ } else {
50
+ apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
51
+ }
52
+ apiRef.current.setCellFocus(id, field);
53
+ event.stopPropagation(); // TODO remove event.stopPropagation
54
+ };
55
+ const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
56
+ if (isDataLoading) {
57
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
58
+ className: classes.loadingContainer,
59
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
60
+ size: "1rem",
61
+ color: "inherit"
62
+ })
63
+ });
64
+ }
65
+ return descendantCount > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
66
+ size: "small",
67
+ onClick: handleClick,
68
+ tabIndex: -1,
69
+ "aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand')
70
+ }, rootProps?.slotProps?.baseIconButton, {
71
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, {
72
+ title: error?.message ?? null,
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
74
+ variant: "dot",
75
+ color: "error",
76
+ invisible: !error,
77
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
78
+ fontSize: "inherit"
79
+ })
80
+ })
81
+ })
82
+ })) : null;
83
+ }
84
+ function GridDataSourceTreeDataGroupingCell(props) {
85
+ const {
86
+ id,
87
+ field,
88
+ formattedValue,
89
+ rowNode,
90
+ hideDescendantCount,
91
+ offsetMultiplier = 2
92
+ } = props;
93
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
94
+ const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
95
+ const rowSelector = state => state.rows.dataRowIdToModelLookup[id];
96
+ const row = (0, _xDataGrid.useGridSelector)(apiRef, rowSelector);
97
+ const classes = useUtilityClasses(rootProps);
98
+ let descendantCount = 0;
99
+ if (row) {
100
+ descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
101
+ }
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
103
+ className: classes.root,
104
+ sx: {
105
+ ml: rowNode.depth * offsetMultiplier
106
+ },
107
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
108
+ className: classes.toggle,
109
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridTreeDataGroupingCellIcon, {
110
+ id: id,
111
+ field: field,
112
+ rowNode: rowNode,
113
+ row: row,
114
+ descendantCount: descendantCount
115
+ })
116
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
117
+ children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && descendantCount > 0 ? ` (${descendantCount})` : '']
118
+ })]
119
+ });
120
+ }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.GridDetailPanel = GridDetailPanel;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _styles = require("@mui/material/styles");
9
- var _internals = require("@mui/x-data-grid/internals");
9
+ var _useResizeObserver = require("@mui/x-internals/useResizeObserver");
10
10
  var _useGridRootProps = require("../hooks/utils/useGridRootProps");
11
11
  var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
12
12
  var _jsxRuntime = require("react/jsx-runtime");
@@ -41,7 +41,7 @@ function GridDetailPanel(props) {
41
41
  apiRef.current.storeDetailPanelHeight(rowId, ref.current.clientHeight);
42
42
  }
43
43
  }, [apiRef, hasAutoHeight, rowId]);
44
- (0, _internals.useResizeObserver)(ref, entries => {
44
+ (0, _useResizeObserver.useResizeObserver)(ref, entries => {
45
45
  const [entry] = entries;
46
46
  const observedHeight = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
47
47
  apiRef.current.storeDetailPanelHeight(rowId, observedHeight);
@@ -37,10 +37,7 @@ function GridTreeDataGroupingCell(props) {
37
37
  } = props;
38
38
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
39
39
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
40
- const ownerState = {
41
- classes: rootProps.classes
42
- };
43
- const classes = useUtilityClasses(ownerState);
40
+ const classes = useUtilityClasses(rootProps);
44
41
  const filteredDescendantCountLookup = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridFilteredDescendantCountLookupSelector);
45
42
  const filteredDescendantCount = filteredDescendantCountLookup[rowNode.id] ?? 0;
46
43
  const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
@@ -898,5 +898,17 @@ DataGridProRaw.propTypes = {
898
898
  * If `true`, the rows will be gathered in a tree structure according to the `getTreeDataPath` prop.
899
899
  * @default false
900
900
  */
901
- treeData: PropTypes.bool
901
+ treeData: PropTypes.bool,
902
+ unstable_dataSource: PropTypes.shape({
903
+ getChildrenCount: PropTypes.func,
904
+ getGroupKey: PropTypes.func,
905
+ getRows: PropTypes.func.isRequired,
906
+ updateRow: PropTypes.func
907
+ }),
908
+ unstable_dataSourceCache: PropTypes.shape({
909
+ clear: PropTypes.func.isRequired,
910
+ get: PropTypes.func.isRequired,
911
+ set: PropTypes.func.isRequired
912
+ }),
913
+ unstable_onDataSourceError: PropTypes.func
902
914
  };
@@ -4,6 +4,7 @@ import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridI
4
4
  import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
5
5
  import { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
6
6
  import { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
7
+ import { useGridDataSourceTreeDataPreProcessors } from '../hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors';
7
8
  import { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
8
9
  import { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
9
10
  import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
@@ -14,6 +15,7 @@ import { useGridLazyLoader } from '../hooks/features/lazyLoader/useGridLazyLoade
14
15
  import { useGridLazyLoaderPreProcessors } from '../hooks/features/lazyLoader/useGridLazyLoaderPreProcessors';
15
16
  import { useGridRowPinning, rowPinningStateInitializer } from '../hooks/features/rowPinning/useGridRowPinning';
16
17
  import { useGridRowPinningPreProcessors } from '../hooks/features/rowPinning/useGridRowPinningPreProcessors';
18
+ import { useGridDataSource, dataSourceStateInitializer } from '../hooks/features/dataSource/useGridDataSource';
17
19
  export const useDataGridProComponent = (inputApiRef, props) => {
18
20
  const apiRef = useGridInitialization(inputApiRef, props);
19
21
 
@@ -23,6 +25,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
23
25
  useGridRowSelectionPreProcessors(apiRef, props);
24
26
  useGridRowReorderPreProcessors(apiRef, props);
25
27
  useGridTreeDataPreProcessors(apiRef, props);
28
+ useGridDataSourceTreeDataPreProcessors(apiRef, props);
26
29
  useGridLazyLoaderPreProcessors(apiRef, props);
27
30
  useGridRowPinningPreProcessors(apiRef);
28
31
  useGridDetailPanelPreProcessors(apiRef, props);
@@ -55,8 +58,9 @@ export const useDataGridProComponent = (inputApiRef, props) => {
55
58
  useGridInitializeState(columnMenuStateInitializer, apiRef, props);
56
59
  useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
57
60
  useGridInitializeState(virtualizationStateInitializer, apiRef, props);
61
+ useGridInitializeState(dataSourceStateInitializer, apiRef, props);
58
62
  useGridHeaderFiltering(apiRef, props);
59
- useGridTreeData(apiRef);
63
+ useGridTreeData(apiRef, props);
60
64
  useGridKeyboardNavigation(apiRef, props);
61
65
  useGridRowSelection(apiRef, props);
62
66
  useGridColumnPinning(apiRef, props);
@@ -89,5 +93,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
89
93
  useGridEvents(apiRef, props);
90
94
  useGridStatePersistence(apiRef);
91
95
  useGridVirtualization(apiRef, props);
96
+ useGridDataSource(apiRef, props);
92
97
  return apiRef;
93
98
  };
@@ -4,6 +4,13 @@ import { useThemeProps } from '@mui/material/styles';
4
4
  import { GRID_DEFAULT_LOCALE_TEXT, DATA_GRID_PROPS_DEFAULT_VALUES } from '@mui/x-data-grid';
5
5
  import { computeSlots, useProps } from '@mui/x-data-grid/internals';
6
6
  import { DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS } from '../constants/dataGridProDefaultSlotsComponents';
7
+ const getDataGridProForcedProps = themedProps => _extends({
8
+ signature: 'DataGridPro'
9
+ }, themedProps.unstable_dataSource ? {
10
+ filterMode: 'server',
11
+ sortingMode: 'server',
12
+ paginationMode: 'server'
13
+ } : {});
7
14
 
8
15
  /**
9
16
  * The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
@@ -38,7 +45,6 @@ export const useDataGridProProps = inProps => {
38
45
  }), [themedProps.slots]);
39
46
  return React.useMemo(() => _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, themedProps, {
40
47
  localeText,
41
- slots,
42
- signature: 'DataGridPro'
43
- }), [themedProps, localeText, slots]);
48
+ slots
49
+ }, getDataGridProForcedProps(themedProps)), [themedProps, localeText, slots]);
44
50
  };
@@ -0,0 +1,111 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
+ import Box from '@mui/material/Box';
5
+ import Badge from '@mui/material/Badge';
6
+ import { getDataGridUtilityClass, useGridSelector } from '@mui/x-data-grid';
7
+ import CircularProgress from '@mui/material/CircularProgress';
8
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
9
+ import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const useUtilityClasses = ownerState => {
12
+ const {
13
+ classes
14
+ } = ownerState;
15
+ const slots = {
16
+ root: ['treeDataGroupingCell'],
17
+ toggle: ['treeDataGroupingCellToggle'],
18
+ loadingContainer: ['treeDataGroupingCellLoadingContainer']
19
+ };
20
+ return composeClasses(slots, getDataGridUtilityClass, classes);
21
+ };
22
+ function GridTreeDataGroupingCellIcon(props) {
23
+ const apiRef = useGridPrivateApiContext();
24
+ const rootProps = useGridRootProps();
25
+ const classes = useUtilityClasses(rootProps);
26
+ const {
27
+ rowNode,
28
+ id,
29
+ field,
30
+ descendantCount
31
+ } = props;
32
+ const loadingSelector = state => state.dataSource.loading[id] ?? false;
33
+ const errorSelector = state => state.dataSource.errors[id];
34
+ const isDataLoading = useGridSelector(apiRef, loadingSelector);
35
+ const error = useGridSelector(apiRef, errorSelector);
36
+ const handleClick = event => {
37
+ if (!rowNode.childrenExpanded) {
38
+ // always fetch/get from cache the children when the node is expanded
39
+ apiRef.current.unstable_dataSource.fetchRows(id);
40
+ } else {
41
+ apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
42
+ }
43
+ apiRef.current.setCellFocus(id, field);
44
+ event.stopPropagation(); // TODO remove event.stopPropagation
45
+ };
46
+ const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;
47
+ if (isDataLoading) {
48
+ return /*#__PURE__*/_jsx("div", {
49
+ className: classes.loadingContainer,
50
+ children: /*#__PURE__*/_jsx(CircularProgress, {
51
+ size: "1rem",
52
+ color: "inherit"
53
+ })
54
+ });
55
+ }
56
+ return descendantCount > 0 ? /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
57
+ size: "small",
58
+ onClick: handleClick,
59
+ tabIndex: -1,
60
+ "aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand')
61
+ }, rootProps?.slotProps?.baseIconButton, {
62
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
63
+ title: error?.message ?? null,
64
+ children: /*#__PURE__*/_jsx(Badge, {
65
+ variant: "dot",
66
+ color: "error",
67
+ invisible: !error,
68
+ children: /*#__PURE__*/_jsx(Icon, {
69
+ fontSize: "inherit"
70
+ })
71
+ })
72
+ })
73
+ })) : null;
74
+ }
75
+ export function GridDataSourceTreeDataGroupingCell(props) {
76
+ const {
77
+ id,
78
+ field,
79
+ formattedValue,
80
+ rowNode,
81
+ hideDescendantCount,
82
+ offsetMultiplier = 2
83
+ } = props;
84
+ const rootProps = useGridRootProps();
85
+ const apiRef = useGridPrivateApiContext();
86
+ const rowSelector = state => state.rows.dataRowIdToModelLookup[id];
87
+ const row = useGridSelector(apiRef, rowSelector);
88
+ const classes = useUtilityClasses(rootProps);
89
+ let descendantCount = 0;
90
+ if (row) {
91
+ descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
92
+ }
93
+ return /*#__PURE__*/_jsxs(Box, {
94
+ className: classes.root,
95
+ sx: {
96
+ ml: rowNode.depth * offsetMultiplier
97
+ },
98
+ children: [/*#__PURE__*/_jsx("div", {
99
+ className: classes.toggle,
100
+ children: /*#__PURE__*/_jsx(GridTreeDataGroupingCellIcon, {
101
+ id: id,
102
+ field: field,
103
+ rowNode: rowNode,
104
+ row: row,
105
+ descendantCount: descendantCount
106
+ })
107
+ }), /*#__PURE__*/_jsxs("span", {
108
+ children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && descendantCount > 0 ? ` (${descendantCount})` : '']
109
+ })]
110
+ });
111
+ }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { styled } from '@mui/material/styles';
3
- import { useResizeObserver } from '@mui/x-data-grid/internals';
3
+ import { useResizeObserver } from '@mui/x-internals/useResizeObserver';
4
4
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
5
5
  import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -28,10 +28,7 @@ function GridTreeDataGroupingCell(props) {
28
28
  } = props;
29
29
  const rootProps = useGridRootProps();
30
30
  const apiRef = useGridApiContext();
31
- const ownerState = {
32
- classes: rootProps.classes
33
- };
34
- const classes = useUtilityClasses(ownerState);
31
+ const classes = useUtilityClasses(rootProps);
35
32
  const filteredDescendantCountLookup = useGridSelector(apiRef, gridFilteredDescendantCountLookupSelector);
36
33
  const filteredDescendantCount = filteredDescendantCountLookup[rowNode.id] ?? 0;
37
34
  const Icon = rowNode.childrenExpanded ? rootProps.slots.treeDataCollapseIcon : rootProps.slots.treeDataExpandIcon;