@mui/x-data-grid-pro 8.14.0 → 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 +202 -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 +63 -8
- package/esm/hooks/features/dataSource/useGridDataSourcePro.js +4 -2
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +0 -1
- package/esm/internals/index.js +0 -1
- package/esm/utils/tree/insertDataRowInTree.d.ts +1 -8
- package/esm/utils/tree/insertDataRowInTree.js +1 -6
- package/esm/utils/tree/removeDataRowFromTree.d.ts +1 -8
- package/esm/utils/tree/removeDataRowFromTree.js +4 -12
- package/esm/utils/tree/updateRowTree.js +1 -9
- package/esm/utils/tree/utils.d.ts +1 -2
- package/esm/utils/tree/utils.js +0 -9
- package/hooks/features/dataSource/models.d.ts +4 -3
- package/hooks/features/dataSource/useGridDataSourceBasePro.d.ts +9 -4
- package/hooks/features/dataSource/useGridDataSourceBasePro.js +61 -6
- package/hooks/features/dataSource/useGridDataSourcePro.js +4 -2
- package/index.js +1 -1
- package/internals/index.d.ts +0 -1
- package/internals/index.js +8 -16
- package/package.json +3 -3
- package/utils/tree/insertDataRowInTree.d.ts +1 -8
- package/utils/tree/insertDataRowInTree.js +1 -6
- package/utils/tree/removeDataRowFromTree.d.ts +1 -8
- package/utils/tree/removeDataRowFromTree.js +4 -12
- package/utils/tree/updateRowTree.js +0 -8
- package/utils/tree/utils.d.ts +1 -2
- package/utils/tree/utils.js +1 -11
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,208 @@
|
|
|
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
|
+
|
|
115
|
+
## 8.14.1
|
|
116
|
+
|
|
117
|
+
_Oct 16, 2025_
|
|
118
|
+
|
|
119
|
+
We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
120
|
+
|
|
121
|
+
- 🚀 Charts have optimized data structures for closest point calculations — initial render times reduced by ~25% for 1,000+ data points, with greater gains at larger scales (#19790) @bernardobelchior
|
|
122
|
+
- 🐞 Bugfixes
|
|
123
|
+
- 📚 Documentation improvements
|
|
124
|
+
|
|
125
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
126
|
+
@djpremier, @jacknot, @justdoit1897, @mellis481, @sai6855
|
|
127
|
+
|
|
128
|
+
The following are all team members who have contributed to this release:
|
|
129
|
+
@arminmeh, @bernardobelchior, @brijeshb42, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @noraleonte, @siriwatknp
|
|
130
|
+
|
|
131
|
+
### Data Grid
|
|
132
|
+
|
|
133
|
+
#### `@mui/x-data-grid@8.14.1`
|
|
134
|
+
|
|
135
|
+
- [DataGrid] Fix cell not rerendering on `isCellEditable` prop change (#19898) @cherniavskii
|
|
136
|
+
- [DataGrid] Fix virtualizer memory leaks (#19886) @cherniavskii
|
|
137
|
+
- [DataGrid] Fix tree data unable to deselect row for exclude model (#19846) @siriwatknp
|
|
138
|
+
- [l10n] Improve Italian (it-IT) locale (#19322) @jacknot and (#19940) @justdoit1897
|
|
139
|
+
|
|
140
|
+
#### `@mui/x-data-grid-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
141
|
+
|
|
142
|
+
Same changes as in `@mui/x-data-grid@8.14.1`, plus:
|
|
143
|
+
|
|
144
|
+
- [DataGridPro] Clear cache before new request to the nested request queue after a row has been edited (#19873) @arminmeh
|
|
145
|
+
|
|
146
|
+
#### `@mui/x-data-grid-premium@8.14.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
147
|
+
|
|
148
|
+
Same changes as in `@mui/x-data-grid-pro@8.14.1`.
|
|
149
|
+
|
|
150
|
+
### Date and Time Pickers
|
|
151
|
+
|
|
152
|
+
#### `@mui/x-date-pickers@8.14.1`
|
|
153
|
+
|
|
154
|
+
Internal changes.
|
|
155
|
+
|
|
156
|
+
#### `@mui/x-date-pickers-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
157
|
+
|
|
158
|
+
Same changes as in `@mui/x-date-pickers@8.14.1`.
|
|
159
|
+
|
|
160
|
+
### Charts
|
|
161
|
+
|
|
162
|
+
#### `@mui/x-charts@8.14.1`
|
|
163
|
+
|
|
164
|
+
- [charts] Fix `minBarSize` when y-axis is reversed (#19932) @bernardobelchior
|
|
165
|
+
- [charts] Fix bar chart border radius when axis is reversed (#19895) @bernardobelchior
|
|
166
|
+
- [charts] Fix scatter chart `datasetKeys.id` not being optional (#19897) @bernardobelchior
|
|
167
|
+
- [charts] Use more performant data structure for closest point (#19790) @bernardobelchior
|
|
168
|
+
- [charts] Fix `GaugeValueArc` having wrong class (#19965) @bernardobelchior
|
|
169
|
+
- [charts] Fix `undefined` path when highlight empty line chart axis (#19969) @bernardobelchior
|
|
170
|
+
|
|
171
|
+
#### `@mui/x-charts-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
172
|
+
|
|
173
|
+
Same changes as in `@mui/x-charts@8.14.1`, plus:
|
|
174
|
+
|
|
175
|
+
- [charts-pro] Add `highlighting` to Sankey chart (#19662) @JCQuintas
|
|
176
|
+
|
|
177
|
+
#### `@mui/x-charts-premium@8.14.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
178
|
+
|
|
179
|
+
Same changes as in `@mui/x-charts-pro@8.14.1`.
|
|
180
|
+
|
|
181
|
+
### Tree View
|
|
182
|
+
|
|
183
|
+
#### `@mui/x-tree-view@8.14.1`
|
|
184
|
+
|
|
185
|
+
- [tree view] Do not forward the `ownerState` to the icon (#19772) @flaviendelangle
|
|
186
|
+
|
|
187
|
+
#### `@mui/x-tree-view-pro@8.14.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
188
|
+
|
|
189
|
+
Same changes as in `@mui/x-tree-view@8.14.1`.
|
|
190
|
+
|
|
191
|
+
### Codemod
|
|
192
|
+
|
|
193
|
+
#### `@mui/x-codemod@8.14.0`
|
|
194
|
+
|
|
195
|
+
Internal changes.
|
|
196
|
+
|
|
197
|
+
### Docs
|
|
198
|
+
|
|
199
|
+
- [docs] Add `'bumpX'` and `'bumpY'` curve types to the interpolation demo (#19676) @djpremier
|
|
200
|
+
- [docs] Add scatter chart with linear regression demo (#19900) @bernardobelchior
|
|
201
|
+
- [docs] Correctly describe Data Grid's row selection behavior (#19968) @arminmeh
|
|
202
|
+
- [docs] Fix `isExpanded` type in tree view docs (#19092) @mellis481
|
|
203
|
+
|
|
204
|
+
### Core
|
|
205
|
+
|
|
206
|
+
- [code-infra] Disable Netlify cache plugin (#19950) @Janpot
|
|
207
|
+
- [code-infra] Lint json through eslint (#19890) @Janpot
|
|
208
|
+
- [docs-infra] Use published netlify cache plugin package (#19929) @brijeshb42
|
|
209
|
+
|
|
8
210
|
## 8.14.0
|
|
9
211
|
|
|
10
212
|
_Oct 9, 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";
|
|
@@ -27,17 +27,17 @@ export const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
27
27
|
return null;
|
|
28
28
|
}, [apiRef, nestedDataManager]);
|
|
29
29
|
const handleEditRow = React.useCallback((params, updatedRow) => {
|
|
30
|
-
const groupKeys = getGroupKeys(gridRowTreeSelector(apiRef), params.rowId);
|
|
31
|
-
apiRef.current.updateNestedRows([updatedRow], groupKeys);
|
|
32
30
|
if (updatedRow && !isDeepEqual(updatedRow, params.previousRow)) {
|
|
33
31
|
// Reset the outdated cache, only if the row is _actually_ updated
|
|
34
32
|
apiRef.current.dataSource.cache.clear();
|
|
35
33
|
}
|
|
34
|
+
const groupKeys = getGroupKeys(gridRowTreeSelector(apiRef), params.rowId);
|
|
35
|
+
apiRef.current.updateNestedRows([updatedRow], groupKeys);
|
|
36
36
|
}, [apiRef]);
|
|
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
package/esm/internals/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export { useGridInfiniteLoadingIntersection } from "../hooks/features/serverSide
|
|
|
25
25
|
export { dataSourceStateInitializer } from "../hooks/features/dataSource/useGridDataSourcePro.js";
|
|
26
26
|
export { useGridDataSourceBasePro } from "../hooks/features/dataSource/useGridDataSourceBasePro.js";
|
|
27
27
|
export { gridDataSourceErrorSelector, gridDataSourceLoadingIdSelector } from "../hooks/features/dataSource/gridDataSourceSelector.js";
|
|
28
|
-
export { getGroupKeys } from "../hooks/features/dataSource/utils.js";
|
|
29
28
|
export type { GridExperimentalProFeatures, DataGridProPropsWithoutDefaultValue, DataGridProPropsWithDefaultValue } from "../models/dataGridProProps.js";
|
|
30
29
|
export type { GridProSlotProps } from "../models/gridProSlotProps.js";
|
|
31
30
|
export { createRowTree } from "../utils/tree/createRowTree.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -28,7 +28,6 @@ export { useGridInfiniteLoadingIntersection } from "../hooks/features/serverSide
|
|
|
28
28
|
export { dataSourceStateInitializer } from "../hooks/features/dataSource/useGridDataSourcePro.js";
|
|
29
29
|
export { useGridDataSourceBasePro } from "../hooks/features/dataSource/useGridDataSourceBasePro.js";
|
|
30
30
|
export { gridDataSourceErrorSelector, gridDataSourceLoadingIdSelector } from "../hooks/features/dataSource/gridDataSourceSelector.js";
|
|
31
|
-
export { getGroupKeys } from "../hooks/features/dataSource/utils.js";
|
|
32
31
|
export { createRowTree } from "../utils/tree/createRowTree.js";
|
|
33
32
|
export { updateRowTree } from "../utils/tree/updateRowTree.js";
|
|
34
33
|
export { sortRowTree } from "../utils/tree/sortRowTree.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridRowId, GridRowTreeConfig } from '@mui/x-data-grid';
|
|
2
|
-
import { GridTreeDepths
|
|
2
|
+
import { GridTreeDepths } from '@mui/x-data-grid/internals';
|
|
3
3
|
import { GridTreePathDuplicateHandler, RowTreeBuilderGroupingCriterion } from "./models.js";
|
|
4
4
|
import { DataGridProProps } from "../../models/dataGridProProps.js";
|
|
5
5
|
interface InsertDataRowInTreeParams {
|
|
@@ -32,12 +32,6 @@ interface InsertDataRowInTreeParams {
|
|
|
32
32
|
* - `treeDepths[nodeDepth] = treeDepth[nodeDepth] + 1` => valid
|
|
33
33
|
*/
|
|
34
34
|
treeDepths: GridTreeDepths;
|
|
35
|
-
/**
|
|
36
|
-
* Object tracking the action performed on each group.
|
|
37
|
-
* Used to decide which groups to refresh on sorting, filtering, aggregation, ...
|
|
38
|
-
* If not defined, then the tracking will be skipped.
|
|
39
|
-
*/
|
|
40
|
-
updatedGroupsManager?: GridRowTreeUpdatedGroupsManager;
|
|
41
35
|
/**
|
|
42
36
|
* Callback fired when trying to insert a data row for a path already populated by another data row.
|
|
43
37
|
*/
|
|
@@ -57,7 +51,6 @@ interface InsertDataRowInTreeParams {
|
|
|
57
51
|
export declare const insertDataRowInTree: ({
|
|
58
52
|
id,
|
|
59
53
|
path,
|
|
60
|
-
updatedGroupsManager,
|
|
61
54
|
previousTree,
|
|
62
55
|
tree,
|
|
63
56
|
treeDepths,
|
|
@@ -9,7 +9,6 @@ import { updateGroupDefaultExpansion, checkGroupChildrenExpansion, getGroupRowId
|
|
|
9
9
|
export const insertDataRowInTree = ({
|
|
10
10
|
id,
|
|
11
11
|
path,
|
|
12
|
-
updatedGroupsManager,
|
|
13
12
|
previousTree,
|
|
14
13
|
tree,
|
|
15
14
|
treeDepths,
|
|
@@ -52,7 +51,7 @@ export const insertDataRowInTree = ({
|
|
|
52
51
|
childrenExpanded: false,
|
|
53
52
|
serverChildrenCount
|
|
54
53
|
};
|
|
55
|
-
const shouldFetchChildren = checkGroupChildrenExpansion(node, defaultGroupingExpansionDepth, maxDepth, isGroupExpandedByDefault
|
|
54
|
+
const shouldFetchChildren = checkGroupChildrenExpansion(node, defaultGroupingExpansionDepth, maxDepth, isGroupExpandedByDefault);
|
|
56
55
|
if (shouldFetchChildren) {
|
|
57
56
|
groupsToFetch?.add(id);
|
|
58
57
|
}
|
|
@@ -65,7 +64,6 @@ export const insertDataRowInTree = ({
|
|
|
65
64
|
groupingKey: key
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
|
-
updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
|
|
69
67
|
insertNodeInTree(node, tree, treeDepths, previousTree);
|
|
70
68
|
} else {
|
|
71
69
|
const existingNodeWithPartialPath = tree[existingNodeIdWithPartialPath];
|
|
@@ -73,8 +71,6 @@ export const insertDataRowInTree = ({
|
|
|
73
71
|
// If we already have an auto-generated group matching the partial path,
|
|
74
72
|
// We replace it with the node from of data row passed to `insertNodeInTree`
|
|
75
73
|
if (existingNodeWithPartialPath.type === 'group' && existingNodeWithPartialPath.isAutoGenerated) {
|
|
76
|
-
updatedGroupsManager?.addAction(parentNodeId, 'removeChildren');
|
|
77
|
-
updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
|
|
78
74
|
updateGroupNodeIdAndAutoGenerated({
|
|
79
75
|
tree,
|
|
80
76
|
previousTree,
|
|
@@ -111,7 +107,6 @@ export const insertDataRowInTree = ({
|
|
|
111
107
|
childrenFromPath: {},
|
|
112
108
|
childrenExpanded: false
|
|
113
109
|
};
|
|
114
|
-
updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
|
|
115
110
|
insertNodeInTree(updateGroupDefaultExpansion(autoGeneratedGroupNode, defaultGroupingExpansionDepth, maxDepth, isGroupExpandedByDefault, previousTree?.[nodeId]?.childrenExpanded), tree, treeDepths, previousTree);
|
|
116
111
|
parentNodeId = nodeId;
|
|
117
112
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridRowId, GridRowTreeConfig } from '@mui/x-data-grid';
|
|
2
|
-
import { GridTreeDepths
|
|
2
|
+
import { GridTreeDepths } from '@mui/x-data-grid/internals';
|
|
3
3
|
interface RemoveDataRowFromTreeParams {
|
|
4
4
|
/**
|
|
5
5
|
* ID of the data row to remove from the tree.
|
|
@@ -22,12 +22,6 @@ interface RemoveDataRowFromTreeParams {
|
|
|
22
22
|
* - `treeDepths[nodeDepth] = treeDepth[nodeDepth] + 1` => valid
|
|
23
23
|
*/
|
|
24
24
|
treeDepths: GridTreeDepths;
|
|
25
|
-
/**
|
|
26
|
-
* Object tracking the action performed on each group.
|
|
27
|
-
* Used to decide which groups to refresh on sorting, filtering, aggregation, ...
|
|
28
|
-
* If not defined, then the tracking will be skipped.
|
|
29
|
-
*/
|
|
30
|
-
updatedGroupsManager?: GridRowTreeUpdatedGroupsManager;
|
|
31
25
|
groupingName: string;
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
@@ -41,7 +35,6 @@ export declare const removeDataRowFromTree: ({
|
|
|
41
35
|
id,
|
|
42
36
|
tree,
|
|
43
37
|
treeDepths,
|
|
44
|
-
updatedGroupsManager,
|
|
45
38
|
groupingName
|
|
46
39
|
}: RemoveDataRowFromTreeParams) => void;
|
|
47
40
|
export {};
|
|
@@ -23,8 +23,7 @@ const removeNode = ({
|
|
|
23
23
|
const removeNodeAndCleanParent = ({
|
|
24
24
|
node,
|
|
25
25
|
tree,
|
|
26
|
-
treeDepths
|
|
27
|
-
updatedGroupsManager
|
|
26
|
+
treeDepths
|
|
28
27
|
}) => {
|
|
29
28
|
removeNode({
|
|
30
29
|
node,
|
|
@@ -32,7 +31,6 @@ const removeNodeAndCleanParent = ({
|
|
|
32
31
|
treeDepths
|
|
33
32
|
});
|
|
34
33
|
const parentNode = tree[node.parent];
|
|
35
|
-
updatedGroupsManager?.addAction(parentNode.id, 'removeChildren');
|
|
36
34
|
const shouldDeleteGroup = parentNode.id !== GRID_ROOT_GROUP_ID && parentNode.children.length === 0;
|
|
37
35
|
if (shouldDeleteGroup) {
|
|
38
36
|
if (parentNode.isAutoGenerated) {
|
|
@@ -55,11 +53,8 @@ const removeNodeAndCleanParent = ({
|
|
|
55
53
|
const replaceDataGroupWithAutoGeneratedGroup = ({
|
|
56
54
|
node,
|
|
57
55
|
tree,
|
|
58
|
-
treeDepths
|
|
59
|
-
updatedGroupsManager
|
|
56
|
+
treeDepths
|
|
60
57
|
}) => {
|
|
61
|
-
updatedGroupsManager?.addAction(node.parent, 'removeChildren');
|
|
62
|
-
updatedGroupsManager?.addAction(node.parent, 'insertChildren');
|
|
63
58
|
updateGroupNodeIdAndAutoGenerated({
|
|
64
59
|
previousTree: null,
|
|
65
60
|
tree,
|
|
@@ -86,7 +81,6 @@ export const removeDataRowFromTree = ({
|
|
|
86
81
|
id,
|
|
87
82
|
tree,
|
|
88
83
|
treeDepths,
|
|
89
|
-
updatedGroupsManager,
|
|
90
84
|
groupingName
|
|
91
85
|
}) => {
|
|
92
86
|
const node = tree[id];
|
|
@@ -94,15 +88,13 @@ export const removeDataRowFromTree = ({
|
|
|
94
88
|
replaceDataGroupWithAutoGeneratedGroup({
|
|
95
89
|
node,
|
|
96
90
|
tree,
|
|
97
|
-
treeDepths
|
|
98
|
-
updatedGroupsManager
|
|
91
|
+
treeDepths
|
|
99
92
|
});
|
|
100
93
|
} else if (groupingName === TreeDataStrategy.Default || groupingName === RowGroupingStrategy.Default) {
|
|
101
94
|
removeNodeAndCleanParent({
|
|
102
95
|
node,
|
|
103
96
|
tree,
|
|
104
|
-
treeDepths
|
|
105
|
-
updatedGroupsManager
|
|
97
|
+
treeDepths
|
|
106
98
|
});
|
|
107
99
|
} else {
|
|
108
100
|
removeNode({
|
|
@@ -4,11 +4,10 @@ import { getTreeNodeDescendants } from '@mui/x-data-grid/internals';
|
|
|
4
4
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
5
5
|
import { insertDataRowInTree } from "./insertDataRowInTree.js";
|
|
6
6
|
import { removeDataRowFromTree } from "./removeDataRowFromTree.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getNodePathInTree } from "./utils.js";
|
|
8
8
|
export const updateRowTree = params => {
|
|
9
9
|
const tree = _extends({}, params.previousTree);
|
|
10
10
|
const treeDepths = _extends({}, params.previousTreeDepth);
|
|
11
|
-
const updatedGroupsManager = createUpdatedGroupsManager();
|
|
12
11
|
const groupsToFetch = params.previousGroupsToFetch ? new Set([...params.previousGroupsToFetch]) : new Set([]);
|
|
13
12
|
for (let i = 0; i < params.nodes.inserted.length; i += 1) {
|
|
14
13
|
const {
|
|
@@ -20,7 +19,6 @@ export const updateRowTree = params => {
|
|
|
20
19
|
previousTree: params.previousTree,
|
|
21
20
|
tree,
|
|
22
21
|
treeDepths,
|
|
23
|
-
updatedGroupsManager,
|
|
24
22
|
id,
|
|
25
23
|
path,
|
|
26
24
|
serverChildrenCount,
|
|
@@ -36,7 +34,6 @@ export const updateRowTree = params => {
|
|
|
36
34
|
removeDataRowFromTree({
|
|
37
35
|
tree,
|
|
38
36
|
treeDepths,
|
|
39
|
-
updatedGroupsManager,
|
|
40
37
|
id: nodeId,
|
|
41
38
|
groupingName: params.groupingName
|
|
42
39
|
});
|
|
@@ -56,7 +53,6 @@ export const updateRowTree = params => {
|
|
|
56
53
|
removeDataRowFromTree({
|
|
57
54
|
tree,
|
|
58
55
|
treeDepths,
|
|
59
|
-
updatedGroupsManager,
|
|
60
56
|
id,
|
|
61
57
|
groupingName: params.groupingName
|
|
62
58
|
});
|
|
@@ -64,7 +60,6 @@ export const updateRowTree = params => {
|
|
|
64
60
|
previousTree: params.previousTree,
|
|
65
61
|
tree,
|
|
66
62
|
treeDepths,
|
|
67
|
-
updatedGroupsManager,
|
|
68
63
|
id,
|
|
69
64
|
path,
|
|
70
65
|
serverChildrenCount,
|
|
@@ -74,8 +69,6 @@ export const updateRowTree = params => {
|
|
|
74
69
|
groupsToFetch,
|
|
75
70
|
maxDepth: params.maxDepth
|
|
76
71
|
});
|
|
77
|
-
} else {
|
|
78
|
-
updatedGroupsManager?.addAction(tree[id].parent, 'modifyChildren');
|
|
79
72
|
}
|
|
80
73
|
}
|
|
81
74
|
|
|
@@ -86,7 +79,6 @@ export const updateRowTree = params => {
|
|
|
86
79
|
treeDepths,
|
|
87
80
|
groupingName: params.groupingName,
|
|
88
81
|
dataRowIds,
|
|
89
|
-
updatedGroupsManager,
|
|
90
82
|
groupsToFetch: Array.from(groupsToFetch)
|
|
91
83
|
};
|
|
92
84
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridFilterState, GridGroupNode, GridRowId, GridRowTreeConfig, GridRowsState, GridTreeNode } from '@mui/x-data-grid';
|
|
2
|
-
import { GridTreeDepths
|
|
2
|
+
import { GridTreeDepths } from '@mui/x-data-grid/internals';
|
|
3
3
|
import { RowTreeBuilderGroupingCriterion } from "./models.js";
|
|
4
4
|
import { DataGridProProps } from "../../models/dataGridProProps.js";
|
|
5
5
|
export declare const getGroupRowIdFromPath: (path: RowTreeBuilderGroupingCriterion[]) => string;
|
|
@@ -44,7 +44,6 @@ export declare const updateGroupNodeIdAndAutoGenerated: ({
|
|
|
44
44
|
tree: GridRowTreeConfig;
|
|
45
45
|
treeDepths: GridTreeDepths;
|
|
46
46
|
}) => void;
|
|
47
|
-
export declare const createUpdatedGroupsManager: () => GridRowTreeUpdatedGroupsManager;
|
|
48
47
|
export declare const getVisibleRowsLookup: ({
|
|
49
48
|
tree,
|
|
50
49
|
filteredRowsLookup
|
package/esm/utils/tree/utils.js
CHANGED
|
@@ -151,15 +151,6 @@ export const updateGroupNodeIdAndAutoGenerated = ({
|
|
|
151
151
|
const groupNode = _extends({}, node, updatedNode);
|
|
152
152
|
insertNodeInTree(groupNode, tree, treeDepths, previousTree);
|
|
153
153
|
};
|
|
154
|
-
export const createUpdatedGroupsManager = () => ({
|
|
155
|
-
value: {},
|
|
156
|
-
addAction(groupId, action) {
|
|
157
|
-
if (!this.value[groupId]) {
|
|
158
|
-
this.value[groupId] = {};
|
|
159
|
-
}
|
|
160
|
-
this.value[groupId][action] = true;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
154
|
export const getVisibleRowsLookup = ({
|
|
164
155
|
tree,
|
|
165
156
|
filteredRowsLookup
|
|
@@ -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">;
|
|
@@ -34,17 +34,17 @@ const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
34
34
|
return null;
|
|
35
35
|
}, [apiRef, nestedDataManager]);
|
|
36
36
|
const handleEditRow = React.useCallback((params, updatedRow) => {
|
|
37
|
-
const groupKeys = (0, _utils.getGroupKeys)((0, _xDataGrid.gridRowTreeSelector)(apiRef), params.rowId);
|
|
38
|
-
apiRef.current.updateNestedRows([updatedRow], groupKeys);
|
|
39
37
|
if (updatedRow && !(0, _isDeepEqual.isDeepEqual)(updatedRow, params.previousRow)) {
|
|
40
38
|
// Reset the outdated cache, only if the row is _actually_ updated
|
|
41
39
|
apiRef.current.dataSource.cache.clear();
|
|
42
40
|
}
|
|
41
|
+
const groupKeys = (0, _utils.getGroupKeys)((0, _xDataGrid.gridRowTreeSelector)(apiRef), params.rowId);
|
|
42
|
+
apiRef.current.updateNestedRows([updatedRow], groupKeys);
|
|
43
43
|
}, [apiRef]);
|
|
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/internals/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export { useGridInfiniteLoadingIntersection } from "../hooks/features/serverSide
|
|
|
25
25
|
export { dataSourceStateInitializer } from "../hooks/features/dataSource/useGridDataSourcePro.js";
|
|
26
26
|
export { useGridDataSourceBasePro } from "../hooks/features/dataSource/useGridDataSourceBasePro.js";
|
|
27
27
|
export { gridDataSourceErrorSelector, gridDataSourceLoadingIdSelector } from "../hooks/features/dataSource/gridDataSourceSelector.js";
|
|
28
|
-
export { getGroupKeys } from "../hooks/features/dataSource/utils.js";
|
|
29
28
|
export type { GridExperimentalProFeatures, DataGridProPropsWithoutDefaultValue, DataGridProPropsWithDefaultValue } from "../models/dataGridProProps.js";
|
|
30
29
|
export type { GridProSlotProps } from "../models/gridProSlotProps.js";
|
|
31
30
|
export { createRowTree } from "../utils/tree/createRowTree.js";
|
package/internals/index.js
CHANGED
|
@@ -37,7 +37,6 @@ var _exportNames = {
|
|
|
37
37
|
useGridDataSourceBasePro: true,
|
|
38
38
|
gridDataSourceErrorSelector: true,
|
|
39
39
|
gridDataSourceLoadingIdSelector: true,
|
|
40
|
-
getGroupKeys: true,
|
|
41
40
|
createRowTree: true,
|
|
42
41
|
updateRowTree: true,
|
|
43
42
|
sortRowTree: true,
|
|
@@ -97,22 +96,16 @@ Object.defineProperty(exports, "detailPanelStateInitializer", {
|
|
|
97
96
|
return _useGridDetailPanel.detailPanelStateInitializer;
|
|
98
97
|
}
|
|
99
98
|
});
|
|
100
|
-
Object.defineProperty(exports, "getGroupKeys", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
get: function () {
|
|
103
|
-
return _utils.getGroupKeys;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
99
|
Object.defineProperty(exports, "getParentPath", {
|
|
107
100
|
enumerable: true,
|
|
108
101
|
get: function () {
|
|
109
|
-
return
|
|
102
|
+
return _utils2.getParentPath;
|
|
110
103
|
}
|
|
111
104
|
});
|
|
112
105
|
Object.defineProperty(exports, "getVisibleRowsLookup", {
|
|
113
106
|
enumerable: true,
|
|
114
107
|
get: function () {
|
|
115
|
-
return
|
|
108
|
+
return _utils.getVisibleRowsLookup;
|
|
116
109
|
}
|
|
117
110
|
});
|
|
118
111
|
Object.defineProperty(exports, "gridDataSourceErrorSelector", {
|
|
@@ -130,13 +123,13 @@ Object.defineProperty(exports, "gridDataSourceLoadingIdSelector", {
|
|
|
130
123
|
Object.defineProperty(exports, "insertNodeInTree", {
|
|
131
124
|
enumerable: true,
|
|
132
125
|
get: function () {
|
|
133
|
-
return
|
|
126
|
+
return _utils.insertNodeInTree;
|
|
134
127
|
}
|
|
135
128
|
});
|
|
136
129
|
Object.defineProperty(exports, "removeNodeFromTree", {
|
|
137
130
|
enumerable: true,
|
|
138
131
|
get: function () {
|
|
139
|
-
return
|
|
132
|
+
return _utils.removeNodeFromTree;
|
|
140
133
|
}
|
|
141
134
|
});
|
|
142
135
|
Object.defineProperty(exports, "rowPinningStateInitializer", {
|
|
@@ -154,13 +147,13 @@ Object.defineProperty(exports, "rowReorderStateInitializer", {
|
|
|
154
147
|
Object.defineProperty(exports, "skipFiltering", {
|
|
155
148
|
enumerable: true,
|
|
156
149
|
get: function () {
|
|
157
|
-
return
|
|
150
|
+
return _utils2.skipFiltering;
|
|
158
151
|
}
|
|
159
152
|
});
|
|
160
153
|
Object.defineProperty(exports, "skipSorting", {
|
|
161
154
|
enumerable: true,
|
|
162
155
|
get: function () {
|
|
163
|
-
return
|
|
156
|
+
return _utils2.skipSorting;
|
|
164
157
|
}
|
|
165
158
|
});
|
|
166
159
|
Object.defineProperty(exports, "sortRowTree", {
|
|
@@ -338,12 +331,11 @@ var _useGridInfiniteLoadingIntersection = require("../hooks/features/serverSideL
|
|
|
338
331
|
var _useGridDataSourcePro = require("../hooks/features/dataSource/useGridDataSourcePro");
|
|
339
332
|
var _useGridDataSourceBasePro = require("../hooks/features/dataSource/useGridDataSourceBasePro");
|
|
340
333
|
var _gridDataSourceSelector = require("../hooks/features/dataSource/gridDataSourceSelector");
|
|
341
|
-
var _utils = require("../hooks/features/dataSource/utils");
|
|
342
334
|
var _createRowTree = require("../utils/tree/createRowTree");
|
|
343
335
|
var _updateRowTree = require("../utils/tree/updateRowTree");
|
|
344
336
|
var _sortRowTree = require("../utils/tree/sortRowTree");
|
|
345
|
-
var
|
|
346
|
-
var
|
|
337
|
+
var _utils = require("../utils/tree/utils");
|
|
338
|
+
var _utils2 = require("../hooks/features/serverSideTreeData/utils");
|
|
347
339
|
var _propValidation = require("./propValidation");
|
|
348
340
|
Object.keys(_propValidation).forEach(function (key) {
|
|
349
341
|
if (key === "default" || key === "__esModule") return;
|
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.
|
|
40
|
+
"@mui/x-data-grid": "8.15.0",
|
|
41
41
|
"@mui/x-internals": "8.14.0",
|
|
42
|
-
"@mui/x-license": "8.
|
|
42
|
+
"@mui/x-license": "8.15.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.9.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridRowId, GridRowTreeConfig } from '@mui/x-data-grid';
|
|
2
|
-
import { GridTreeDepths
|
|
2
|
+
import { GridTreeDepths } from '@mui/x-data-grid/internals';
|
|
3
3
|
import { GridTreePathDuplicateHandler, RowTreeBuilderGroupingCriterion } from "./models.js";
|
|
4
4
|
import { DataGridProProps } from "../../models/dataGridProProps.js";
|
|
5
5
|
interface InsertDataRowInTreeParams {
|
|
@@ -32,12 +32,6 @@ interface InsertDataRowInTreeParams {
|
|
|
32
32
|
* - `treeDepths[nodeDepth] = treeDepth[nodeDepth] + 1` => valid
|
|
33
33
|
*/
|
|
34
34
|
treeDepths: GridTreeDepths;
|
|
35
|
-
/**
|
|
36
|
-
* Object tracking the action performed on each group.
|
|
37
|
-
* Used to decide which groups to refresh on sorting, filtering, aggregation, ...
|
|
38
|
-
* If not defined, then the tracking will be skipped.
|
|
39
|
-
*/
|
|
40
|
-
updatedGroupsManager?: GridRowTreeUpdatedGroupsManager;
|
|
41
35
|
/**
|
|
42
36
|
* Callback fired when trying to insert a data row for a path already populated by another data row.
|
|
43
37
|
*/
|
|
@@ -57,7 +51,6 @@ interface InsertDataRowInTreeParams {
|
|
|
57
51
|
export declare const insertDataRowInTree: ({
|
|
58
52
|
id,
|
|
59
53
|
path,
|
|
60
|
-
updatedGroupsManager,
|
|
61
54
|
previousTree,
|
|
62
55
|
tree,
|
|
63
56
|
treeDepths,
|
|
@@ -15,7 +15,6 @@ var _utils = require("./utils");
|
|
|
15
15
|
const insertDataRowInTree = ({
|
|
16
16
|
id,
|
|
17
17
|
path,
|
|
18
|
-
updatedGroupsManager,
|
|
19
18
|
previousTree,
|
|
20
19
|
tree,
|
|
21
20
|
treeDepths,
|
|
@@ -58,7 +57,7 @@ const insertDataRowInTree = ({
|
|
|
58
57
|
childrenExpanded: false,
|
|
59
58
|
serverChildrenCount
|
|
60
59
|
};
|
|
61
|
-
const shouldFetchChildren = (0, _utils.checkGroupChildrenExpansion)(node, defaultGroupingExpansionDepth, maxDepth, isGroupExpandedByDefault
|
|
60
|
+
const shouldFetchChildren = (0, _utils.checkGroupChildrenExpansion)(node, defaultGroupingExpansionDepth, maxDepth, isGroupExpandedByDefault);
|
|
62
61
|
if (shouldFetchChildren) {
|
|
63
62
|
groupsToFetch?.add(id);
|
|
64
63
|
}
|
|
@@ -71,7 +70,6 @@ const insertDataRowInTree = ({
|
|
|
71
70
|
groupingKey: key
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
|
-
updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
|
|
75
73
|
(0, _utils.insertNodeInTree)(node, tree, treeDepths, previousTree);
|
|
76
74
|
} else {
|
|
77
75
|
const existingNodeWithPartialPath = tree[existingNodeIdWithPartialPath];
|
|
@@ -79,8 +77,6 @@ const insertDataRowInTree = ({
|
|
|
79
77
|
// If we already have an auto-generated group matching the partial path,
|
|
80
78
|
// We replace it with the node from of data row passed to `insertNodeInTree`
|
|
81
79
|
if (existingNodeWithPartialPath.type === 'group' && existingNodeWithPartialPath.isAutoGenerated) {
|
|
82
|
-
updatedGroupsManager?.addAction(parentNodeId, 'removeChildren');
|
|
83
|
-
updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
|
|
84
80
|
(0, _utils.updateGroupNodeIdAndAutoGenerated)({
|
|
85
81
|
tree,
|
|
86
82
|
previousTree,
|
|
@@ -117,7 +113,6 @@ const insertDataRowInTree = ({
|
|
|
117
113
|
childrenFromPath: {},
|
|
118
114
|
childrenExpanded: false
|
|
119
115
|
};
|
|
120
|
-
updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
|
|
121
116
|
(0, _utils.insertNodeInTree)((0, _utils.updateGroupDefaultExpansion)(autoGeneratedGroupNode, defaultGroupingExpansionDepth, maxDepth, isGroupExpandedByDefault, previousTree?.[nodeId]?.childrenExpanded), tree, treeDepths, previousTree);
|
|
122
117
|
parentNodeId = nodeId;
|
|
123
118
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridRowId, GridRowTreeConfig } from '@mui/x-data-grid';
|
|
2
|
-
import { GridTreeDepths
|
|
2
|
+
import { GridTreeDepths } from '@mui/x-data-grid/internals';
|
|
3
3
|
interface RemoveDataRowFromTreeParams {
|
|
4
4
|
/**
|
|
5
5
|
* ID of the data row to remove from the tree.
|
|
@@ -22,12 +22,6 @@ interface RemoveDataRowFromTreeParams {
|
|
|
22
22
|
* - `treeDepths[nodeDepth] = treeDepth[nodeDepth] + 1` => valid
|
|
23
23
|
*/
|
|
24
24
|
treeDepths: GridTreeDepths;
|
|
25
|
-
/**
|
|
26
|
-
* Object tracking the action performed on each group.
|
|
27
|
-
* Used to decide which groups to refresh on sorting, filtering, aggregation, ...
|
|
28
|
-
* If not defined, then the tracking will be skipped.
|
|
29
|
-
*/
|
|
30
|
-
updatedGroupsManager?: GridRowTreeUpdatedGroupsManager;
|
|
31
25
|
groupingName: string;
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
@@ -41,7 +35,6 @@ export declare const removeDataRowFromTree: ({
|
|
|
41
35
|
id,
|
|
42
36
|
tree,
|
|
43
37
|
treeDepths,
|
|
44
|
-
updatedGroupsManager,
|
|
45
38
|
groupingName
|
|
46
39
|
}: RemoveDataRowFromTreeParams) => void;
|
|
47
40
|
export {};
|
|
@@ -29,8 +29,7 @@ const removeNode = ({
|
|
|
29
29
|
const removeNodeAndCleanParent = ({
|
|
30
30
|
node,
|
|
31
31
|
tree,
|
|
32
|
-
treeDepths
|
|
33
|
-
updatedGroupsManager
|
|
32
|
+
treeDepths
|
|
34
33
|
}) => {
|
|
35
34
|
removeNode({
|
|
36
35
|
node,
|
|
@@ -38,7 +37,6 @@ const removeNodeAndCleanParent = ({
|
|
|
38
37
|
treeDepths
|
|
39
38
|
});
|
|
40
39
|
const parentNode = tree[node.parent];
|
|
41
|
-
updatedGroupsManager?.addAction(parentNode.id, 'removeChildren');
|
|
42
40
|
const shouldDeleteGroup = parentNode.id !== _xDataGrid.GRID_ROOT_GROUP_ID && parentNode.children.length === 0;
|
|
43
41
|
if (shouldDeleteGroup) {
|
|
44
42
|
if (parentNode.isAutoGenerated) {
|
|
@@ -61,11 +59,8 @@ const removeNodeAndCleanParent = ({
|
|
|
61
59
|
const replaceDataGroupWithAutoGeneratedGroup = ({
|
|
62
60
|
node,
|
|
63
61
|
tree,
|
|
64
|
-
treeDepths
|
|
65
|
-
updatedGroupsManager
|
|
62
|
+
treeDepths
|
|
66
63
|
}) => {
|
|
67
|
-
updatedGroupsManager?.addAction(node.parent, 'removeChildren');
|
|
68
|
-
updatedGroupsManager?.addAction(node.parent, 'insertChildren');
|
|
69
64
|
(0, _utils.updateGroupNodeIdAndAutoGenerated)({
|
|
70
65
|
previousTree: null,
|
|
71
66
|
tree,
|
|
@@ -92,7 +87,6 @@ const removeDataRowFromTree = ({
|
|
|
92
87
|
id,
|
|
93
88
|
tree,
|
|
94
89
|
treeDepths,
|
|
95
|
-
updatedGroupsManager,
|
|
96
90
|
groupingName
|
|
97
91
|
}) => {
|
|
98
92
|
const node = tree[id];
|
|
@@ -100,15 +94,13 @@ const removeDataRowFromTree = ({
|
|
|
100
94
|
replaceDataGroupWithAutoGeneratedGroup({
|
|
101
95
|
node,
|
|
102
96
|
tree,
|
|
103
|
-
treeDepths
|
|
104
|
-
updatedGroupsManager
|
|
97
|
+
treeDepths
|
|
105
98
|
});
|
|
106
99
|
} else if (groupingName === _gridTreeDataUtils.TreeDataStrategy.Default || groupingName === _internals.RowGroupingStrategy.Default) {
|
|
107
100
|
removeNodeAndCleanParent({
|
|
108
101
|
node,
|
|
109
102
|
tree,
|
|
110
|
-
treeDepths
|
|
111
|
-
updatedGroupsManager
|
|
103
|
+
treeDepths
|
|
112
104
|
});
|
|
113
105
|
} else {
|
|
114
106
|
removeNode({
|
|
@@ -15,7 +15,6 @@ var _utils = require("./utils");
|
|
|
15
15
|
const updateRowTree = params => {
|
|
16
16
|
const tree = (0, _extends2.default)({}, params.previousTree);
|
|
17
17
|
const treeDepths = (0, _extends2.default)({}, params.previousTreeDepth);
|
|
18
|
-
const updatedGroupsManager = (0, _utils.createUpdatedGroupsManager)();
|
|
19
18
|
const groupsToFetch = params.previousGroupsToFetch ? new Set([...params.previousGroupsToFetch]) : new Set([]);
|
|
20
19
|
for (let i = 0; i < params.nodes.inserted.length; i += 1) {
|
|
21
20
|
const {
|
|
@@ -27,7 +26,6 @@ const updateRowTree = params => {
|
|
|
27
26
|
previousTree: params.previousTree,
|
|
28
27
|
tree,
|
|
29
28
|
treeDepths,
|
|
30
|
-
updatedGroupsManager,
|
|
31
29
|
id,
|
|
32
30
|
path,
|
|
33
31
|
serverChildrenCount,
|
|
@@ -43,7 +41,6 @@ const updateRowTree = params => {
|
|
|
43
41
|
(0, _removeDataRowFromTree.removeDataRowFromTree)({
|
|
44
42
|
tree,
|
|
45
43
|
treeDepths,
|
|
46
|
-
updatedGroupsManager,
|
|
47
44
|
id: nodeId,
|
|
48
45
|
groupingName: params.groupingName
|
|
49
46
|
});
|
|
@@ -63,7 +60,6 @@ const updateRowTree = params => {
|
|
|
63
60
|
(0, _removeDataRowFromTree.removeDataRowFromTree)({
|
|
64
61
|
tree,
|
|
65
62
|
treeDepths,
|
|
66
|
-
updatedGroupsManager,
|
|
67
63
|
id,
|
|
68
64
|
groupingName: params.groupingName
|
|
69
65
|
});
|
|
@@ -71,7 +67,6 @@ const updateRowTree = params => {
|
|
|
71
67
|
previousTree: params.previousTree,
|
|
72
68
|
tree,
|
|
73
69
|
treeDepths,
|
|
74
|
-
updatedGroupsManager,
|
|
75
70
|
id,
|
|
76
71
|
path,
|
|
77
72
|
serverChildrenCount,
|
|
@@ -81,8 +76,6 @@ const updateRowTree = params => {
|
|
|
81
76
|
groupsToFetch,
|
|
82
77
|
maxDepth: params.maxDepth
|
|
83
78
|
});
|
|
84
|
-
} else {
|
|
85
|
-
updatedGroupsManager?.addAction(tree[id].parent, 'modifyChildren');
|
|
86
79
|
}
|
|
87
80
|
}
|
|
88
81
|
|
|
@@ -93,7 +86,6 @@ const updateRowTree = params => {
|
|
|
93
86
|
treeDepths,
|
|
94
87
|
groupingName: params.groupingName,
|
|
95
88
|
dataRowIds,
|
|
96
|
-
updatedGroupsManager,
|
|
97
89
|
groupsToFetch: Array.from(groupsToFetch)
|
|
98
90
|
};
|
|
99
91
|
};
|
package/utils/tree/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridFilterState, GridGroupNode, GridRowId, GridRowTreeConfig, GridRowsState, GridTreeNode } from '@mui/x-data-grid';
|
|
2
|
-
import { GridTreeDepths
|
|
2
|
+
import { GridTreeDepths } from '@mui/x-data-grid/internals';
|
|
3
3
|
import { RowTreeBuilderGroupingCriterion } from "./models.js";
|
|
4
4
|
import { DataGridProProps } from "../../models/dataGridProProps.js";
|
|
5
5
|
export declare const getGroupRowIdFromPath: (path: RowTreeBuilderGroupingCriterion[]) => string;
|
|
@@ -44,7 +44,6 @@ export declare const updateGroupNodeIdAndAutoGenerated: ({
|
|
|
44
44
|
tree: GridRowTreeConfig;
|
|
45
45
|
treeDepths: GridTreeDepths;
|
|
46
46
|
}) => void;
|
|
47
|
-
export declare const createUpdatedGroupsManager: () => GridRowTreeUpdatedGroupsManager;
|
|
48
47
|
export declare const getVisibleRowsLookup: ({
|
|
49
48
|
tree,
|
|
50
49
|
filteredRowsLookup
|
package/utils/tree/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateGroupNodeIdAndAutoGenerated = exports.updateGroupDefaultExpansion = exports.removeNodeFromTree = exports.insertNodeInTree = exports.getVisibleRowsLookup = exports.getNodePathInTree = exports.getGroupRowIdFromPath = exports.
|
|
7
|
+
exports.updateGroupNodeIdAndAutoGenerated = exports.updateGroupDefaultExpansion = exports.removeNodeFromTree = exports.insertNodeInTree = exports.getVisibleRowsLookup = exports.getNodePathInTree = exports.getGroupRowIdFromPath = exports.checkGroupChildrenExpansion = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _xDataGrid = require("@mui/x-data-grid");
|
|
10
10
|
const getGroupRowIdFromPath = path => {
|
|
@@ -165,16 +165,6 @@ const updateGroupNodeIdAndAutoGenerated = ({
|
|
|
165
165
|
insertNodeInTree(groupNode, tree, treeDepths, previousTree);
|
|
166
166
|
};
|
|
167
167
|
exports.updateGroupNodeIdAndAutoGenerated = updateGroupNodeIdAndAutoGenerated;
|
|
168
|
-
const createUpdatedGroupsManager = () => ({
|
|
169
|
-
value: {},
|
|
170
|
-
addAction(groupId, action) {
|
|
171
|
-
if (!this.value[groupId]) {
|
|
172
|
-
this.value[groupId] = {};
|
|
173
|
-
}
|
|
174
|
-
this.value[groupId][action] = true;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
exports.createUpdatedGroupsManager = createUpdatedGroupsManager;
|
|
178
168
|
const getVisibleRowsLookup = ({
|
|
179
169
|
tree,
|
|
180
170
|
filteredRowsLookup
|