@mui/x-data-grid-pro 8.14.1 → 8.15.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 +107 -0
- package/DataGridPro/DataGridPro.js +1 -1
- package/esm/DataGridPro/DataGridPro.js +1 -1
- package/esm/hooks/features/dataSource/models.d.ts +4 -3
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +9 -4
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.js +61 -6
- package/esm/hooks/features/dataSource/useGridDataSourcePro.js +4 -2
- package/esm/index.js +1 -1
- package/hooks/features/dataSource/models.d.ts +4 -3
- package/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +9 -4
- package/hooks/features/dataSource/useGridDataSourceBasePro.js +59 -4
- package/hooks/features/dataSource/useGridDataSourcePro.js +4 -2
- package/index.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,113 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.15.0
|
|
9
|
+
|
|
10
|
+
_Oct 23, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🖌️ Add new [`brush` charts interaction](https://mui.com/x/react-charts/brush/) for building custom behavior.
|
|
15
|
+

|
|
16
|
+
- ⚡️ Performance improvements for large bar charts
|
|
17
|
+
- 🤖 Data Grid AI assistant can now [visualize the query results](https://mui.com/x/react-data-grid/ai-assistant/#data-visualization) by controlling the chart integration settings
|
|
18
|
+
- 📦 DataGrid uses an internal MUI fork of ExcelJS that does not depend on vulnerable versions of NPM packages
|
|
19
|
+
- 🐞 Bugfixes
|
|
20
|
+
- 📚 Documentation improvements
|
|
21
|
+
|
|
22
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
23
|
+
@ZagrebaAlex
|
|
24
|
+
|
|
25
|
+
The following are all team members who have contributed to this release:
|
|
26
|
+
@alexfauquette, @bernardobelchior, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @KenanYusuf, @prakhargupta1, @rita-codes, @siriwatknp, @arminmeh, @brijeshb42, @noraleonte
|
|
27
|
+
|
|
28
|
+
### Data Grid
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid@8.15.0`
|
|
31
|
+
|
|
32
|
+
- [DataGrid] Fix `dataSource.fetchRows` API's return type (#20068) @arminmeh
|
|
33
|
+
|
|
34
|
+
#### `@mui/x-data-grid-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
35
|
+
|
|
36
|
+
Same changes as in `@mui/x-data-grid@8.15.0`, plus:
|
|
37
|
+
|
|
38
|
+
- [DataGridPro] Keep children in the tree after parent row is re-fetched with the data source (#19934) @arminmeh
|
|
39
|
+
- [DataGridPro] Support scroll shadows customization (#19982) @KenanYusuf
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-data-grid-premium@8.15.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
42
|
+
|
|
43
|
+
Same changes as in `@mui/x-data-grid-pro@8.15.0`, plus:
|
|
44
|
+
|
|
45
|
+
- [DataGridPremium] Use ExcelJS fork (#19796) @cherniavskii
|
|
46
|
+
- [DataGridPremium] Support data visualization in AI Assistant (#19831) @arminmeh
|
|
47
|
+
|
|
48
|
+
### Date and Time Pickers
|
|
49
|
+
|
|
50
|
+
#### `@mui/x-date-pickers@8.15.0`
|
|
51
|
+
|
|
52
|
+
Internal changes.
|
|
53
|
+
|
|
54
|
+
#### `@mui/x-date-pickers-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
55
|
+
|
|
56
|
+
Same changes as in `@mui/x-date-pickers@8.15.0`.
|
|
57
|
+
|
|
58
|
+
### Charts
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-charts@8.15.0`
|
|
61
|
+
|
|
62
|
+
- [charts] Add `ChartsBrushOverlay` and allow brush configuration (#19956) @JCQuintas
|
|
63
|
+
- [charts] Add `getStringSize` benchmark. Remove benchmarks from built package. (#19995) @bernardobelchior
|
|
64
|
+
- [charts] Batch string size measurement (#19994) @bernardobelchior
|
|
65
|
+
- [charts] Fix console issue (#20025) @JCQuintas
|
|
66
|
+
- [charts] Fix is[ZoomFeature]Enabled type (#20058) @alexfauquette
|
|
67
|
+
- [charts] Fix reference line middle spacing (#20004) @JCQuintas
|
|
68
|
+
- [charts] Improve `getStringSize` and `batchMeasureStrings` performance (#19996) @bernardobelchior
|
|
69
|
+
- [charts] Improve deep export script (#20007) @JCQuintas
|
|
70
|
+
- [charts] Improve string measurement benchmarks (#19999) @bernardobelchior
|
|
71
|
+
- [charts] Measure string sizes using SVG elements (#19981) @bernardobelchior
|
|
72
|
+
- [l10n] Improve Greek (gr-GR) locale (#20060) @ZagrebaAlex
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-charts-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
75
|
+
|
|
76
|
+
Same changes as in `@mui/x-charts@8.15.0`, plus:
|
|
77
|
+
|
|
78
|
+
- [charts-pro] Fix pan with `axis.reverse` (#20031) @JCQuintas
|
|
79
|
+
|
|
80
|
+
#### `@mui/x-charts-premium@8.15.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
81
|
+
|
|
82
|
+
Same changes as in `@mui/x-charts-pro@8.15.0`.
|
|
83
|
+
|
|
84
|
+
### Tree View
|
|
85
|
+
|
|
86
|
+
#### `@mui/x-tree-view@8.15.0`
|
|
87
|
+
|
|
88
|
+
- [tree view] Multi character type-ahead (#19942) @noraleonte
|
|
89
|
+
|
|
90
|
+
#### `@mui/x-tree-view-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
91
|
+
|
|
92
|
+
Same changes as in `@mui/x-tree-view@8.15.0`.
|
|
93
|
+
|
|
94
|
+
### Codemod
|
|
95
|
+
|
|
96
|
+
#### `@mui/x-codemod@8.14.0`
|
|
97
|
+
|
|
98
|
+
Internal changes.
|
|
99
|
+
|
|
100
|
+
### Docs
|
|
101
|
+
|
|
102
|
+
- [docs] Add overview section for scatter chart and heatmap (#19888) @prakhargupta1
|
|
103
|
+
- [docs] Add charts bell curve example (#20003) @JCQuintas
|
|
104
|
+
- [docs] Add grouped multiple fields for Data Grid row grouping recipe (#19964) @siriwatknp
|
|
105
|
+
- [docs] Add Data Grid loading state recipe (#19958) @siriwatknp
|
|
106
|
+
|
|
107
|
+
### Core
|
|
108
|
+
|
|
109
|
+
- [code-infra] Remove @mui/monorepo usage for react versioning (#19894) @Janpot
|
|
110
|
+
- [code-infra] Remove invalid `environment: 'browser'` from vitest browser config (#19993) @bernardobelchior
|
|
111
|
+
- [code-infra] Remove unused babel aliases (#19987) @Janpot
|
|
112
|
+
- [code-infra] Turn on all testing-library eslint rules (#19946) @brijeshb42
|
|
113
|
+
- [docs-infra] Fix broken hash link (#20062) @Janpot
|
|
114
|
+
|
|
8
115
|
## 8.14.1
|
|
9
116
|
|
|
10
117
|
_Oct 16, 2025_
|
|
@@ -32,7 +32,7 @@ const configuration = {
|
|
|
32
32
|
useFilterValueGetter: apiRef => apiRef.current.getRowValue
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
const releaseInfo = "
|
|
35
|
+
const releaseInfo = "MTc2MTE3NzYwMDAwMA==";
|
|
36
36
|
const watermark = /*#__PURE__*/(0, _jsxRuntime.jsx)(_xLicense.Watermark, {
|
|
37
37
|
packageName: "x-data-grid-pro",
|
|
38
38
|
releaseInfo: releaseInfo
|
|
@@ -25,7 +25,7 @@ const configuration = {
|
|
|
25
25
|
useFilterValueGetter: apiRef => apiRef.current.getRowValue
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
const releaseInfo = "
|
|
28
|
+
const releaseInfo = "MTc2MTE3NzYwMDAwMA==";
|
|
29
29
|
const watermark = /*#__PURE__*/_jsx(Watermark, {
|
|
30
30
|
packageName: "x-data-grid-pro",
|
|
31
31
|
releaseInfo: releaseInfo
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GridValidRowModel, GridRowId, GridGetRowsResponse, GridDataSource, GridGetRowsParams } from '@mui/x-data-grid';
|
|
2
|
-
import type { GridDataSourceApiBase } from '@mui/x-data-grid/internals';
|
|
2
|
+
import type { GridDataSourceApiBase, GridDataSourceFetchRowsParams } from '@mui/x-data-grid/internals';
|
|
3
3
|
export interface GridDataSourceState {
|
|
4
4
|
loading: Record<GridRowId, boolean>;
|
|
5
5
|
errors: Record<GridRowId, any>;
|
|
@@ -42,9 +42,10 @@ export interface GridDataSourceApiBasePro extends Omit<GridDataSourceApiBase, 'f
|
|
|
42
42
|
* If no `parentId` option is provided, it fetches the root rows.
|
|
43
43
|
* Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.).
|
|
44
44
|
* @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`).
|
|
45
|
-
* @param {
|
|
45
|
+
* @param {GridDataSourceFetchRowsParams<GridGetRowsParamsPro>} params Request parameters override.
|
|
46
|
+
* @returns {Promise<void>} A promise that resolves when the rows are fetched.
|
|
46
47
|
*/
|
|
47
|
-
fetchRows: (parentId?: GridRowId, params?:
|
|
48
|
+
fetchRows: (parentId?: GridRowId, params?: GridDataSourceFetchRowsParams<GridGetRowsParamsPro>) => Promise<void>;
|
|
48
49
|
/**
|
|
49
50
|
* Set the loading state of a parent row.
|
|
50
51
|
* @param {string} parentId The id of the parent node.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridRowId } from '@mui/x-data-grid';
|
|
3
|
-
import { CacheChunkManager, DataSourceRowsUpdateStrategy, GridDataSourceBaseOptions } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { CacheChunkManager, DataSourceRowsUpdateStrategy, GridDataSourceBaseOptions, GridStrategyProcessor } from '@mui/x-data-grid/internals';
|
|
4
4
|
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
5
5
|
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
6
6
|
import { GridDataSourceApiPro, GridDataSourcePrivateApiPro } from "./models.js";
|
|
@@ -13,11 +13,16 @@ export declare const useGridDataSourceBasePro: <Api extends GridPrivateApiPro>(a
|
|
|
13
13
|
public: GridDataSourceApiPro;
|
|
14
14
|
private: GridDataSourcePrivateApiPro;
|
|
15
15
|
};
|
|
16
|
-
debouncedFetchRows: ((parentId?: import("@mui/x-data-grid").GridRowId, params?: import("@mui/x-data-grid/
|
|
17
|
-
|
|
16
|
+
debouncedFetchRows: ((parentId?: import("@mui/x-data-grid").GridRowId, params?: import("@mui/x-data-grid/internals").GridDataSourceFetchRowsParams<import("@mui/x-data-grid").GridGetRowsParams>) => Promise<void>) & import("@mui/utils/debounce").Cancelable;
|
|
17
|
+
flatTreeStrategyProcessor: {
|
|
18
18
|
strategyName: DataSourceRowsUpdateStrategy;
|
|
19
19
|
group: "dataSourceRowsUpdate";
|
|
20
|
-
processor:
|
|
20
|
+
processor: GridStrategyProcessor<"dataSourceRowsUpdate">;
|
|
21
|
+
};
|
|
22
|
+
groupedDataStrategyProcessor: {
|
|
23
|
+
strategyName: DataSourceRowsUpdateStrategy;
|
|
24
|
+
group: "dataSourceRowsUpdate";
|
|
25
|
+
processor: GridStrategyProcessor<"dataSourceRowsUpdate">;
|
|
21
26
|
};
|
|
22
27
|
events: {
|
|
23
28
|
strategyAvailabilityChange: import("@mui/x-data-grid").GridEventListener<"strategyAvailabilityChange">;
|
|
@@ -4,8 +4,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
6
6
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
7
|
-
import { useGridSelector, GridGetRowsError, gridRowIdSelector, gridRowNodeSelector, gridRowTreeSelector } from '@mui/x-data-grid';
|
|
8
|
-
import { gridRowGroupsToFetchSelector, useGridDataSourceBase, CacheChunkManager, gridGetRowsParamsSelector, DataSourceRowsUpdateStrategy, GridStrategyGroup } from '@mui/x-data-grid/internals';
|
|
7
|
+
import { useGridSelector, GridGetRowsError, gridRowIdSelector, gridRowNodeSelector, gridRowTreeSelector, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
|
|
8
|
+
import { gridRowGroupsToFetchSelector, useGridDataSourceBase, CacheChunkManager, gridGetRowsParamsSelector, DataSourceRowsUpdateStrategy, GridStrategyGroup, getTreeNodeDescendants } from '@mui/x-data-grid/internals';
|
|
9
9
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
10
10
|
import { NestedDataManager, RequestStatus, getGroupKeys } from "./utils.js";
|
|
11
11
|
import { gridDataSourceErrorsSelector } from "./gridDataSourceSelector.js";
|
|
@@ -37,7 +37,7 @@ export const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
37
37
|
const {
|
|
38
38
|
api,
|
|
39
39
|
debouncedFetchRows,
|
|
40
|
-
strategyProcessor,
|
|
40
|
+
strategyProcessor: flatTreeStrategyProcessor,
|
|
41
41
|
events,
|
|
42
42
|
cacheChunkManager,
|
|
43
43
|
cache
|
|
@@ -47,8 +47,9 @@ export const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
47
47
|
handleEditRow
|
|
48
48
|
}, options));
|
|
49
49
|
const setStrategyAvailability = React.useCallback(() => {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const targetStrategy = props.treeData ? DataSourceRowsUpdateStrategy.GroupedData : DataSourceRowsUpdateStrategy.Default;
|
|
51
|
+
apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, targetStrategy, props.dataSource && !props.lazyLoading ? () => true : () => false);
|
|
52
|
+
}, [apiRef, props.dataSource, props.lazyLoading, props.treeData]);
|
|
52
53
|
const onDataSourceErrorProp = props.onDataSourceError;
|
|
53
54
|
const fetchRowChildren = React.useCallback(async id => {
|
|
54
55
|
const pipedParams = apiRef.current.unstable_applyPipeProcessors('getRowsParams', {});
|
|
@@ -205,6 +206,55 @@ export const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
205
206
|
apiRef.current.updateNestedRows(removedRows, rowNode.path);
|
|
206
207
|
}
|
|
207
208
|
}, [apiRef]);
|
|
209
|
+
const handleGroupedDataUpdate = React.useCallback(params => {
|
|
210
|
+
if ('error' in params) {
|
|
211
|
+
apiRef.current.setRows([]);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const {
|
|
215
|
+
response,
|
|
216
|
+
options: {
|
|
217
|
+
keepChildrenExpanded
|
|
218
|
+
}
|
|
219
|
+
} = params;
|
|
220
|
+
if (response.rowCount !== undefined) {
|
|
221
|
+
apiRef.current.setRowCount(response.rowCount);
|
|
222
|
+
}
|
|
223
|
+
if (keepChildrenExpanded === false) {
|
|
224
|
+
apiRef.current.setRows(response.rows);
|
|
225
|
+
} else {
|
|
226
|
+
const tree = gridRowTreeSelector(apiRef);
|
|
227
|
+
// Remove existing outdated rows before setting the new ones
|
|
228
|
+
// Create a set of the current root rows
|
|
229
|
+
const parentRowsToDelete = new Set(getTreeNodeDescendants(tree, GRID_ROOT_GROUP_ID, false, true));
|
|
230
|
+
// Remove from the list the rows that are again in the response
|
|
231
|
+
response.rows.forEach(row => {
|
|
232
|
+
parentRowsToDelete.delete(gridRowIdSelector(apiRef, row));
|
|
233
|
+
});
|
|
234
|
+
const rowsToDelete = [];
|
|
235
|
+
if (parentRowsToDelete.size > 0) {
|
|
236
|
+
parentRowsToDelete.forEach(parentRowId => {
|
|
237
|
+
const descendants = getTreeNodeDescendants(tree, parentRowId, false, false);
|
|
238
|
+
for (let i = descendants.length - 1; i >= 0; i -= 1) {
|
|
239
|
+
// delete deepest descendants first
|
|
240
|
+
rowsToDelete.push({
|
|
241
|
+
id: descendants[i],
|
|
242
|
+
_action: 'delete'
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
rowsToDelete.push({
|
|
246
|
+
id: parentRowId,
|
|
247
|
+
_action: 'delete'
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
apiRef.current.updateRows(response.rows.concat(rowsToDelete));
|
|
252
|
+
}
|
|
253
|
+
apiRef.current.unstable_applyPipeProcessors('processDataSourceRows', {
|
|
254
|
+
params: params.fetchParams,
|
|
255
|
+
response
|
|
256
|
+
}, true);
|
|
257
|
+
}, [apiRef]);
|
|
208
258
|
const dataSourceApi = {
|
|
209
259
|
dataSource: _extends({}, api.public.dataSource, {
|
|
210
260
|
setChildrenLoading,
|
|
@@ -229,7 +279,12 @@ export const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
229
279
|
private: dataSourcePrivateApi
|
|
230
280
|
},
|
|
231
281
|
debouncedFetchRows,
|
|
232
|
-
|
|
282
|
+
flatTreeStrategyProcessor,
|
|
283
|
+
groupedDataStrategyProcessor: {
|
|
284
|
+
strategyName: DataSourceRowsUpdateStrategy.GroupedData,
|
|
285
|
+
group: 'dataSourceRowsUpdate',
|
|
286
|
+
processor: handleGroupedDataUpdate
|
|
287
|
+
},
|
|
233
288
|
events,
|
|
234
289
|
setStrategyAvailability,
|
|
235
290
|
cacheChunkManager,
|
|
@@ -21,13 +21,15 @@ const options = {
|
|
|
21
21
|
export const useGridDataSourcePro = (apiRef, props) => {
|
|
22
22
|
const {
|
|
23
23
|
api,
|
|
24
|
-
|
|
24
|
+
flatTreeStrategyProcessor,
|
|
25
|
+
groupedDataStrategyProcessor,
|
|
25
26
|
events,
|
|
26
27
|
setStrategyAvailability
|
|
27
28
|
} = useGridDataSourceBasePro(apiRef, props, options);
|
|
28
29
|
useGridApiMethod(apiRef, api.public, 'public');
|
|
29
30
|
useGridApiMethod(apiRef, api.private, 'private');
|
|
30
|
-
useGridRegisterStrategyProcessor(apiRef,
|
|
31
|
+
useGridRegisterStrategyProcessor(apiRef, flatTreeStrategyProcessor.strategyName, flatTreeStrategyProcessor.group, flatTreeStrategyProcessor.processor);
|
|
32
|
+
useGridRegisterStrategyProcessor(apiRef, groupedDataStrategyProcessor.strategyName, groupedDataStrategyProcessor.group, groupedDataStrategyProcessor.processor);
|
|
31
33
|
Object.entries(events).forEach(([event, handler]) => {
|
|
32
34
|
addEventHandler(apiRef, event, handler);
|
|
33
35
|
});
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GridValidRowModel, GridRowId, GridGetRowsResponse, GridDataSource, GridGetRowsParams } from '@mui/x-data-grid';
|
|
2
|
-
import type { GridDataSourceApiBase } from '@mui/x-data-grid/internals';
|
|
2
|
+
import type { GridDataSourceApiBase, GridDataSourceFetchRowsParams } from '@mui/x-data-grid/internals';
|
|
3
3
|
export interface GridDataSourceState {
|
|
4
4
|
loading: Record<GridRowId, boolean>;
|
|
5
5
|
errors: Record<GridRowId, any>;
|
|
@@ -42,9 +42,10 @@ export interface GridDataSourceApiBasePro extends Omit<GridDataSourceApiBase, 'f
|
|
|
42
42
|
* If no `parentId` option is provided, it fetches the root rows.
|
|
43
43
|
* Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.).
|
|
44
44
|
* @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`).
|
|
45
|
-
* @param {
|
|
45
|
+
* @param {GridDataSourceFetchRowsParams<GridGetRowsParamsPro>} params Request parameters override.
|
|
46
|
+
* @returns {Promise<void>} A promise that resolves when the rows are fetched.
|
|
46
47
|
*/
|
|
47
|
-
fetchRows: (parentId?: GridRowId, params?:
|
|
48
|
+
fetchRows: (parentId?: GridRowId, params?: GridDataSourceFetchRowsParams<GridGetRowsParamsPro>) => Promise<void>;
|
|
48
49
|
/**
|
|
49
50
|
* Set the loading state of a parent row.
|
|
50
51
|
* @param {string} parentId The id of the parent node.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridRowId } from '@mui/x-data-grid';
|
|
3
|
-
import { CacheChunkManager, DataSourceRowsUpdateStrategy, GridDataSourceBaseOptions } from '@mui/x-data-grid/internals';
|
|
3
|
+
import { CacheChunkManager, DataSourceRowsUpdateStrategy, GridDataSourceBaseOptions, GridStrategyProcessor } from '@mui/x-data-grid/internals';
|
|
4
4
|
import { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
5
5
|
import { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
6
6
|
import { GridDataSourceApiPro, GridDataSourcePrivateApiPro } from "./models.js";
|
|
@@ -13,11 +13,16 @@ export declare const useGridDataSourceBasePro: <Api extends GridPrivateApiPro>(a
|
|
|
13
13
|
public: GridDataSourceApiPro;
|
|
14
14
|
private: GridDataSourcePrivateApiPro;
|
|
15
15
|
};
|
|
16
|
-
debouncedFetchRows: ((parentId?: import("@mui/x-data-grid").GridRowId, params?: import("@mui/x-data-grid/
|
|
17
|
-
|
|
16
|
+
debouncedFetchRows: ((parentId?: import("@mui/x-data-grid").GridRowId, params?: import("@mui/x-data-grid/internals").GridDataSourceFetchRowsParams<import("@mui/x-data-grid").GridGetRowsParams>) => Promise<void>) & import("@mui/utils/debounce").Cancelable;
|
|
17
|
+
flatTreeStrategyProcessor: {
|
|
18
18
|
strategyName: DataSourceRowsUpdateStrategy;
|
|
19
19
|
group: "dataSourceRowsUpdate";
|
|
20
|
-
processor:
|
|
20
|
+
processor: GridStrategyProcessor<"dataSourceRowsUpdate">;
|
|
21
|
+
};
|
|
22
|
+
groupedDataStrategyProcessor: {
|
|
23
|
+
strategyName: DataSourceRowsUpdateStrategy;
|
|
24
|
+
group: "dataSourceRowsUpdate";
|
|
25
|
+
processor: GridStrategyProcessor<"dataSourceRowsUpdate">;
|
|
21
26
|
};
|
|
22
27
|
events: {
|
|
23
28
|
strategyAvailabilityChange: import("@mui/x-data-grid").GridEventListener<"strategyAvailabilityChange">;
|
|
@@ -44,7 +44,7 @@ const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
44
44
|
const {
|
|
45
45
|
api,
|
|
46
46
|
debouncedFetchRows,
|
|
47
|
-
strategyProcessor,
|
|
47
|
+
strategyProcessor: flatTreeStrategyProcessor,
|
|
48
48
|
events,
|
|
49
49
|
cacheChunkManager,
|
|
50
50
|
cache
|
|
@@ -54,8 +54,9 @@ const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
54
54
|
handleEditRow
|
|
55
55
|
}, options));
|
|
56
56
|
const setStrategyAvailability = React.useCallback(() => {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const targetStrategy = props.treeData ? _internals.DataSourceRowsUpdateStrategy.GroupedData : _internals.DataSourceRowsUpdateStrategy.Default;
|
|
58
|
+
apiRef.current.setStrategyAvailability(_internals.GridStrategyGroup.DataSource, targetStrategy, props.dataSource && !props.lazyLoading ? () => true : () => false);
|
|
59
|
+
}, [apiRef, props.dataSource, props.lazyLoading, props.treeData]);
|
|
59
60
|
const onDataSourceErrorProp = props.onDataSourceError;
|
|
60
61
|
const fetchRowChildren = React.useCallback(async id => {
|
|
61
62
|
const pipedParams = apiRef.current.unstable_applyPipeProcessors('getRowsParams', {});
|
|
@@ -212,6 +213,55 @@ const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
212
213
|
apiRef.current.updateNestedRows(removedRows, rowNode.path);
|
|
213
214
|
}
|
|
214
215
|
}, [apiRef]);
|
|
216
|
+
const handleGroupedDataUpdate = React.useCallback(params => {
|
|
217
|
+
if ('error' in params) {
|
|
218
|
+
apiRef.current.setRows([]);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const {
|
|
222
|
+
response,
|
|
223
|
+
options: {
|
|
224
|
+
keepChildrenExpanded
|
|
225
|
+
}
|
|
226
|
+
} = params;
|
|
227
|
+
if (response.rowCount !== undefined) {
|
|
228
|
+
apiRef.current.setRowCount(response.rowCount);
|
|
229
|
+
}
|
|
230
|
+
if (keepChildrenExpanded === false) {
|
|
231
|
+
apiRef.current.setRows(response.rows);
|
|
232
|
+
} else {
|
|
233
|
+
const tree = (0, _xDataGrid.gridRowTreeSelector)(apiRef);
|
|
234
|
+
// Remove existing outdated rows before setting the new ones
|
|
235
|
+
// Create a set of the current root rows
|
|
236
|
+
const parentRowsToDelete = new Set((0, _internals.getTreeNodeDescendants)(tree, _xDataGrid.GRID_ROOT_GROUP_ID, false, true));
|
|
237
|
+
// Remove from the list the rows that are again in the response
|
|
238
|
+
response.rows.forEach(row => {
|
|
239
|
+
parentRowsToDelete.delete((0, _xDataGrid.gridRowIdSelector)(apiRef, row));
|
|
240
|
+
});
|
|
241
|
+
const rowsToDelete = [];
|
|
242
|
+
if (parentRowsToDelete.size > 0) {
|
|
243
|
+
parentRowsToDelete.forEach(parentRowId => {
|
|
244
|
+
const descendants = (0, _internals.getTreeNodeDescendants)(tree, parentRowId, false, false);
|
|
245
|
+
for (let i = descendants.length - 1; i >= 0; i -= 1) {
|
|
246
|
+
// delete deepest descendants first
|
|
247
|
+
rowsToDelete.push({
|
|
248
|
+
id: descendants[i],
|
|
249
|
+
_action: 'delete'
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
rowsToDelete.push({
|
|
253
|
+
id: parentRowId,
|
|
254
|
+
_action: 'delete'
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
apiRef.current.updateRows(response.rows.concat(rowsToDelete));
|
|
259
|
+
}
|
|
260
|
+
apiRef.current.unstable_applyPipeProcessors('processDataSourceRows', {
|
|
261
|
+
params: params.fetchParams,
|
|
262
|
+
response
|
|
263
|
+
}, true);
|
|
264
|
+
}, [apiRef]);
|
|
215
265
|
const dataSourceApi = {
|
|
216
266
|
dataSource: (0, _extends2.default)({}, api.public.dataSource, {
|
|
217
267
|
setChildrenLoading,
|
|
@@ -236,7 +286,12 @@ const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
236
286
|
private: dataSourcePrivateApi
|
|
237
287
|
},
|
|
238
288
|
debouncedFetchRows,
|
|
239
|
-
|
|
289
|
+
flatTreeStrategyProcessor,
|
|
290
|
+
groupedDataStrategyProcessor: {
|
|
291
|
+
strategyName: _internals.DataSourceRowsUpdateStrategy.GroupedData,
|
|
292
|
+
group: 'dataSourceRowsUpdate',
|
|
293
|
+
processor: handleGroupedDataUpdate
|
|
294
|
+
},
|
|
240
295
|
events,
|
|
241
296
|
setStrategyAvailability,
|
|
242
297
|
cacheChunkManager,
|
|
@@ -29,13 +29,15 @@ const options = {
|
|
|
29
29
|
const useGridDataSourcePro = (apiRef, props) => {
|
|
30
30
|
const {
|
|
31
31
|
api,
|
|
32
|
-
|
|
32
|
+
flatTreeStrategyProcessor,
|
|
33
|
+
groupedDataStrategyProcessor,
|
|
33
34
|
events,
|
|
34
35
|
setStrategyAvailability
|
|
35
36
|
} = (0, _useGridDataSourceBasePro.useGridDataSourceBasePro)(apiRef, props, options);
|
|
36
37
|
(0, _xDataGrid.useGridApiMethod)(apiRef, api.public, 'public');
|
|
37
38
|
(0, _xDataGrid.useGridApiMethod)(apiRef, api.private, 'private');
|
|
38
|
-
(0, _internals.useGridRegisterStrategyProcessor)(apiRef,
|
|
39
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, flatTreeStrategyProcessor.strategyName, flatTreeStrategyProcessor.group, flatTreeStrategyProcessor.processor);
|
|
40
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, groupedDataStrategyProcessor.strategyName, groupedDataStrategyProcessor.group, groupedDataStrategyProcessor.processor);
|
|
39
41
|
Object.entries(events).forEach(([event, handler]) => {
|
|
40
42
|
(0, _xDataGrid.useGridEvent)(apiRef, event, handler);
|
|
41
43
|
});
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-pro",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.15.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The Pro plan edition of the MUI X Data Grid components.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@mui/utils": "^7.3.3",
|
|
38
38
|
"clsx": "^2.1.1",
|
|
39
39
|
"prop-types": "^15.8.1",
|
|
40
|
-
"@mui/x-data-grid": "8.
|
|
41
|
-
"@mui/x-
|
|
42
|
-
"@mui/x-
|
|
40
|
+
"@mui/x-data-grid": "8.15.0",
|
|
41
|
+
"@mui/x-internals": "8.14.0",
|
|
42
|
+
"@mui/x-license": "8.15.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.9.0",
|