@mui/x-tree-view-pro 8.27.2 → 8.28.3

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 CHANGED
@@ -5,6 +5,389 @@
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.28.3
9
+
10
+ _Apr 15, 2026_
11
+
12
+ We'd like to extend a big thank you to the 6 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 🐞 Bugfixes
15
+
16
+ Special thanks go out to this community member for their valuable contribution:
17
+ @nk10nikhil
18
+
19
+ The following team members contributed to this release:
20
+ @flaviendelangle, @LukasTy, @MBilalShafi, @michelengelen, @sai6855
21
+
22
+ ### Data Grid
23
+
24
+ #### `@mui/x-data-grid@8.28.2`
25
+
26
+ Internal changes.
27
+
28
+ #### `@mui/x-data-grid-pro@8.28.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
29
+
30
+ Same changes as in `@mui/x-data-grid@8.28.2`, plus:
31
+
32
+ - [DataGridPro] Improve trigger for nested row reordering (#21996) @MBilalShafi
33
+
34
+ #### `@mui/x-data-grid-premium@8.28.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
35
+
36
+ Same changes as in `@mui/x-data-grid-pro@8.28.2`.
37
+
38
+ ### Date and Time Pickers
39
+
40
+ #### `@mui/x-date-pickers@8.28.3`
41
+
42
+ - [pickers] Ensure correct `display` property on Day component (#21980) @LukasTy
43
+
44
+ #### `@mui/x-date-pickers-pro@8.28.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
45
+
46
+ Same changes as in `@mui/x-date-pickers@8.28.3`.
47
+
48
+ ### Charts
49
+
50
+ #### `@mui/x-charts@8.28.2`
51
+
52
+ - [charts] Add missing export for `ChartsBrushOverlay` (#21993) (#22008) @nk10nikhil
53
+
54
+ #### `@mui/x-charts-pro@8.28.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
55
+
56
+ Same changes as in `@mui/x-charts@8.28.2`.
57
+
58
+ #### `@mui/x-charts-premium@8.28.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
59
+
60
+ Same changes as in `@mui/x-charts-pro@8.28.2`.
61
+
62
+ ### Tree View
63
+
64
+ #### `@mui/x-tree-view@8.28.3`
65
+
66
+ - [tree view] Move `lazyLoadedItems` initialization to state initializer (#22087) @michelengelen
67
+
68
+ #### `@mui/x-tree-view-pro@8.28.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
69
+
70
+ Same changes as in `@mui/x-tree-view@8.28.3`, plus:
71
+
72
+ - [RichTreeViewPro] Allow to auto-expand lazy loaded items (#21957) @flaviendelangle
73
+
74
+ ### Docs
75
+
76
+ - [docs] Fix `TreeDataFullExample` data grid demo crash (#22007) @sai6855
77
+
78
+ ### Miscellaneous
79
+
80
+ - [core] Post v9 stable updates (#22035) @LukasTy
81
+
82
+ ## 8.28.2
83
+
84
+ _Apr 1, 2026_
85
+
86
+ We'd like to extend a big thank you to the 4 contributors who made this release possible.
87
+
88
+ Special thanks go out to this community member for their valuable contribution:
89
+ @mixelburg, @sibananda485
90
+
91
+ The following team members contributed to this release:
92
+ @dav-is, @JCQuintas
93
+
94
+ ### Data Grid
95
+
96
+ #### `@mui/x-data-grid@8.28.2`
97
+
98
+ - [DataGrid] Export `GridColumnUnsortedIconProps` for custom column icon slots (#21898) @mixelburg
99
+
100
+ #### `@mui/x-data-grid-pro@8.28.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
101
+
102
+ Same changes as in `@mui/x-data-grid@8.28.2`.
103
+
104
+ #### `@mui/x-data-grid-premium@8.28.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
105
+
106
+ Same changes as in `@mui/x-data-grid-pro@8.28.2`, plus:
107
+
108
+ - [DataGridPremium] Fix clipboard paste issue in portal (#21949) @sibananda485
109
+
110
+ ### Charts
111
+
112
+ #### `@mui/x-charts@8.28.2`
113
+
114
+ - [charts] Fix zoom slider preview with discard filter mode (#21906) @JCQuintas
115
+
116
+ #### `@mui/x-charts-pro@8.28.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
117
+
118
+ Same changes as in `@mui/x-charts@8.28.2`.
119
+
120
+ #### `@mui/x-charts-premium@8.28.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
121
+
122
+ Same changes as in `@mui/x-charts-pro@8.28.2`.
123
+
124
+ ### Docs
125
+
126
+ - [docs] Fix JSDOM → jsdom casing (#21908) @JCQuintas
127
+
128
+ ### Core
129
+
130
+ - [docs-infra] Set `SEARCH_INDEX` Env for v8 (#21875) @dav-is
131
+
132
+ ## 8.28.1
133
+
134
+ _Mar 26, 2026_
135
+
136
+ We'd like to extend a big thank you to the 2 contributors who made this release possible.
137
+
138
+ The following team members contributed to this release:
139
+ @arminmeh, @cherniavskii
140
+
141
+ ### Data Grid
142
+
143
+ #### `@mui/x-data-grid@8.28.1`
144
+
145
+ - [DataGrid] Prevent repeated `hasScrollbar` state updates (#21847) @arminmeh
146
+
147
+ #### `@mui/x-data-grid-pro@8.28.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
148
+
149
+ Same changes as in `@mui/x-data-grid@8.28.1`, plus:
150
+
151
+ - [DataGridPro] `fetchRows()` API's default `start` and `end` params based on scroll position with lazy loading (#21811) @arminmeh
152
+
153
+ #### `@mui/x-data-grid-premium@8.28.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
154
+
155
+ Same changes as in `@mui/x-data-grid-pro@8.28.1`.
156
+
157
+ ### Core
158
+
159
+ - [internal] Remove headless data grid packages (#21848) @cherniavskii
160
+
161
+ ## 8.28.0
162
+
163
+ _Mar 19, 2026_
164
+
165
+ We'd like to extend a big thank you to the 5 contributors who made this release possible.
166
+
167
+ The following team members contributed to this release:
168
+ @alexfauquette, @brijeshb42, @Janpot, @JCQuintas, @sai6855
169
+
170
+ ### Data Grid
171
+
172
+ #### `@mui/x-data-grid@8.28.0`
173
+
174
+ - [DataGrid] Move `elementOverrides` to constants and remove duplicates (@sai6855) (#21752) @github-actions[bot]
175
+
176
+ #### `@mui/x-data-grid-pro@8.28.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
177
+
178
+ Same changes as in `@mui/x-data-grid@8.28.0`.
179
+
180
+ #### `@mui/x-data-grid-premium@8.28.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
181
+
182
+ Same changes as in `@mui/x-data-grid-pro@8.28.0`.
183
+
184
+ ### Date and Time Pickers
185
+
186
+ #### `@mui/x-date-pickers@8.27.2`
187
+
188
+ Internal changes.
189
+
190
+ #### `@mui/x-date-pickers-pro@8.27.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
191
+
192
+ Same changes as in `@mui/x-date-pickers@8.27.2`.
193
+
194
+ ### Charts
195
+
196
+ #### `@mui/x-charts@8.28.0`
197
+
198
+ - [charts] Improve deprecation warnings (#21760) (#21767) @alexfauquette
199
+ - [charts] Refactor `FunnelChart` classes structure (@JCQuintas) (#21763) @github-actions[bot]
200
+ - [charts] Refactor `Heatmap` classes structure (#21653) (#21745) @JCQuintas
201
+ - [charts] Refactor `PieChart` classes structure (@JCQuintas) (#21715) @github-actions[bot]
202
+ - [charts] Refactor `RadarChart` classes structure (@JCQuintas) (#21730) @github-actions[bot]
203
+ - [charts] Refactor `SankeyChart` classes structure (#21654) (#21726) @JCQuintas
204
+ - [charts] Rename `data-series-id` by `data-series` (#21761) (#21772) @alexfauquette
205
+
206
+ #### `@mui/x-charts-pro@8.28.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
207
+
208
+ Same changes as in `@mui/x-charts@8.28.0`, plus:
209
+
210
+ - [charts-pro] Allow `brush` interaction to accept `requiredKeys/pointerMode` (#21723) @JCQuintas
211
+
212
+ #### `@mui/x-charts-premium@8.28.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
213
+
214
+ Same changes as in `@mui/x-charts-pro@8.28.0`.
215
+
216
+ ### Tree View
217
+
218
+ #### `@mui/x-tree-view@8.27.2`
219
+
220
+ Internal changes.
221
+
222
+ #### `@mui/x-tree-view-pro@8.27.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
223
+
224
+ Same changes as in `@mui/x-tree-view@8.27.2`.
225
+
226
+ ### Codemod
227
+
228
+ #### `@mui/x-codemod@8.27.0`
229
+
230
+ Internal changes.
231
+
232
+ ### Core
233
+
234
+ - [code-infra] Fix contributor generation in changelog (#21712) @brijeshb42
235
+ - [code-infra] Install pkg-pr-new (#21778) @Janpot
236
+
237
+ ## 8.27.5
238
+
239
+ _Mar 11, 2026_
240
+
241
+ We'd like to extend a big thank you to the 7 contributors who made this release possible. Here are some highlights ✨:
242
+
243
+ - 🐞 Bugfixes
244
+
245
+ The following team members contributed to this release:
246
+ @bernardobelchior, @JCQuintas, @MBilalShafi, @michelengelen, @mj12albert, @sai6855, @siriwatknp
247
+
248
+ ### Data Grid
249
+
250
+ #### `@mui/x-data-grid@8.27.5`
251
+
252
+ - [DataGrid] Fix crash when `rows` and `rowModesModel` are updated simultaneously (#21684) @michelengelen
253
+ - [DataGrid] Forward rest props in `GridFilterInputMultipleValue` (#21444) @siriwatknp
254
+ - [DataGrid] Remove double rtl inversion logic for columns pinning (#21443) @siriwatknp
255
+ - [DataGrid] Add missing `resizablePanelHandle` classes to `gridClasses` object (#21632) @sai6855
256
+ - [DataGrid] Refactor `headerAlign` style calls (#21633) @sai6855
257
+ - [DataGrid] Fix keyboard navigation with single-row checkbox selection (#21529) @mj12albert
258
+
259
+ #### `@mui/x-data-grid-pro@8.27.5` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
260
+
261
+ Same changes as in `@mui/x-data-grid@8.27.5`, plus:
262
+
263
+ - [DataGridPro] Add `role="presentation"` to detail panel toggle header content (#21691) @michelengelen
264
+ - [DataGridPro] Fix sorting not reflected in nested server-side data (#21641) @MBilalShafi
265
+
266
+ #### `@mui/x-data-grid-premium@8.27.5` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
267
+
268
+ Same changes as in `@mui/x-data-grid-pro@8.27.5`.
269
+
270
+ ### Charts
271
+
272
+ #### `@mui/x-charts@8.27.5`
273
+
274
+ - [charts] Refactor `BarChart` classes structure (#21601) (#21644) @JCQuintas
275
+ - [charts] Refactor `LineChart` classes structure (#21672) @JCQuintas
276
+ - [charts] Refactor `ScatterChart` classes structure (#21706) @JCQuintas
277
+
278
+ #### `@mui/x-charts-pro@8.27.5` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
279
+
280
+ Same changes as in `@mui/x-charts@8.27.5`, plus:
281
+
282
+ - [charts-pro] Fix image export truncated when page is zoomed out (#21696) @bernardobelchior
283
+
284
+ #### `@mui/x-charts-premium@8.27.5` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
285
+
286
+ Same changes as in `@mui/x-charts-pro@8.27.5`.
287
+
288
+ ### Docs
289
+
290
+ - [docs] Fix `AssistantWithDataSource` demo crashing (#21631) @sai6855
291
+ - [docs] Move Range Bar Chart to existing charts (#21122) @bernardobelchior
292
+
293
+ ### Core
294
+
295
+ - [code-infra] Fix datagrid test flakyness (#21657) @JCQuintas
296
+ - [code-infra] Removed `getTeamMembers` function and usage from the release script (#21608) @michelengelen
297
+
298
+ ### Miscellaneous
299
+
300
+ - [test] Add missing tests for forwarding props to filter operators in DataGrid (#21700) @siriwatknp
301
+
302
+ ## 8.27.4
303
+
304
+ _Mar 5, 2026_
305
+
306
+ We'd like to extend a big thank you to the 6 contributors who made this release possible. Here are some highlights ✨:
307
+
308
+ - 🐞 Bugfixes
309
+ - 🌎 Improve Ukrainian (uk-UA) locale
310
+
311
+ Special thanks go out to this community member for their valuable contribution:
312
+ @lion1963
313
+
314
+ The following team members contributed to this release:
315
+ @arminmeh, @brijeshb42, @dav-is, @JCQuintas, @sai6855
316
+
317
+ ### Data Grid
318
+
319
+ #### `@mui/x-data-grid@8.27.4`
320
+
321
+ - [DataGrid] Prevent unnecessary row selection checkbox rerendering (#21571) @arminmeh
322
+ - [DataGrid] Make `GridScrollArea` overrides resolver dynamic (#21612) @sai6855
323
+ - [l10n] Improve Ukrainian (uk-UA) locale (#21381) @lion1963
324
+
325
+ #### `@mui/x-data-grid-pro@8.27.4` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
326
+
327
+ Same changes as in `@mui/x-data-grid@8.27.4`, plus:
328
+
329
+ - [DataGridPro] Use `getRowId` prop to calculate the tree data row update (#21544) @arminmeh
330
+
331
+ #### `@mui/x-data-grid-premium@8.27.4` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
332
+
333
+ Same changes as in `@mui/x-data-grid-pro@8.27.4`.
334
+
335
+ ### Charts
336
+
337
+ #### `@mui/x-charts@8.27.4`
338
+
339
+ - [charts] Deprecate `ChartDataProvider` in favour of `ChartsDataProvider` (#21549) @JCQuintas
340
+ - [charts] Rename `ChartContainer` to `ChartsContainer` (#21186) @JCQuintas
341
+ - [charts] Rename `ChartZoomSlider` to `ChartsZoomSlider` (#21572) @JCQuintas
342
+
343
+ #### `@mui/x-charts-pro@8.27.4` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
344
+
345
+ Same changes as in `@mui/x-charts@8.27.4`.
346
+
347
+ #### `@mui/x-charts-premium@8.27.4` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
348
+
349
+ Same changes as in `@mui/x-charts-pro@8.27.4`.
350
+
351
+ ### Core
352
+
353
+ - [code-infra] Add eslint rule to prevent `Math.random` in docs (#21505) (#21563) @JCQuintas
354
+ - [code-infra] V8 Dedupe (#21561) @JCQuintas
355
+ - [docs-infra] Apply Cookie Banner to v8.x Branch (#21448) @dav-is
356
+ - [code-infra] Setup checkout to do full clone for non master branches (#21624) @brijeshb42
357
+
358
+ ## 8.27.3
359
+
360
+ _Feb 25, 2026_
361
+
362
+ We'd like to extend a big thank you to the 4 contributors who made this release possible. Here are some highlights ✨:
363
+
364
+ - 🐞 Bugfixes
365
+ - ⚡️ Improved dynamic data support and cache invalidation in lazy loading for Data Grid Pro
366
+
367
+ The following team members contributed to this release:
368
+ @cherniavskii, @michelengelen, @MBilalShafi, @arminmeh
369
+
370
+ ### Data Grid
371
+
372
+ #### `@mui/x-data-grid@8.27.3`
373
+
374
+ - [DataGrid] Preserve key input during row edit when using `rowModesModel` (#21457) @michelengelen
375
+
376
+ #### `@mui/x-data-grid-pro@8.27.3` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
377
+
378
+ Same changes as in `@mui/x-data-grid@8.27.3`, plus:
379
+
380
+ - [DataGridPro] Improve dynamic data support and cache invalidation in lazy loading (#21465) @MBilalShafi
381
+
382
+ #### `@mui/x-data-grid-premium@8.27.3` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
383
+
384
+ Same changes as in `@mui/x-data-grid-pro@8.27.3`.
385
+
386
+ ### Core
387
+
388
+ - [code-infra] Do not append `x` to the last version for the compare API (#21422) @arminmeh
389
+ - [docs-infra] Fix current version detection logic (#21415) @cherniavskii
390
+
8
391
  ## 8.27.2
9
392
 
10
393
  _Feb 20, 2026_
@@ -52,7 +52,7 @@ const RichTreeViewProRoot = exports.RichTreeViewProRoot = (0, _zeroStyled.styled
52
52
  outline: 0,
53
53
  position: 'relative'
54
54
  });
55
- const releaseInfo = "MTc3MTU0NTYwMDAwMA==";
55
+ const releaseInfo = "MTc3NjIxMTIwMDAwMA==";
56
56
 
57
57
  /**
58
58
  *
@@ -332,6 +332,15 @@ process.env.NODE_ENV !== "production" ? RichTreeViewPro.propTypes = {
332
332
  * @param {boolean} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
333
333
  */
334
334
  onItemSelectionToggle: _propTypes.default.func,
335
+ /**
336
+ * Callback fired when the children of an item are loaded from the data source.
337
+ * Only relevant for lazy-loaded tree views.
338
+ * @param {object} parameters The parameters of the callback.
339
+ * @param {R[]} parameters.items The items that were loaded.
340
+ * @param {TreeViewItemId | null} parameters.parentId The id of the parent item whose children were loaded. `null` if the root items were loaded.
341
+ * @param {boolean} parameters.isCacheHit `true` if the items were loaded from the cache, `false` if they were fetched from the data source.
342
+ */
343
+ onItemsLazyLoaded: _propTypes.default.func,
335
344
  /**
336
345
  * Callback fired when Tree Items are selected/deselected.
337
346
  * @param {React.SyntheticEvent} event The DOM event that triggered the change. Can be null when the change is caused by the `publicAPI.setItemSelection()` method.
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.useExtractRichTreeViewProParameters = useExtractRichTreeViewProParameters;
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
- const _excluded = ["apiRef", "slots", "slotProps", "disabledItemsFocusable", "items", "isItemDisabled", "isItemSelectionDisabled", "getItemLabel", "getItemChildren", "getItemId", "onItemClick", "itemChildrenIndentation", "id", "expandedItems", "defaultExpandedItems", "onExpandedItemsChange", "onItemExpansionToggle", "expansionTrigger", "disableSelection", "selectedItems", "defaultSelectedItems", "multiSelect", "checkboxSelection", "selectionPropagation", "onSelectedItemsChange", "onItemSelectionToggle", "onItemFocus", "onItemLabelChange", "isItemEditable", "dataSource", "dataSourceCache", "itemsReordering", "isItemReorderable", "canMoveItemToNewPosition", "onItemPositionChange"];
11
+ const _excluded = ["apiRef", "slots", "slotProps", "disabledItemsFocusable", "items", "isItemDisabled", "isItemSelectionDisabled", "getItemLabel", "getItemChildren", "getItemId", "onItemClick", "itemChildrenIndentation", "id", "expandedItems", "defaultExpandedItems", "onExpandedItemsChange", "onItemExpansionToggle", "expansionTrigger", "disableSelection", "selectedItems", "defaultSelectedItems", "multiSelect", "checkboxSelection", "selectionPropagation", "onSelectedItemsChange", "onItemSelectionToggle", "onItemFocus", "onItemLabelChange", "isItemEditable", "dataSource", "dataSourceCache", "onItemsLazyLoaded", "itemsReordering", "isItemReorderable", "canMoveItemToNewPosition", "onItemPositionChange"];
12
12
  function useExtractRichTreeViewProParameters(props) {
13
13
  const {
14
14
  // Props for Provider
@@ -46,6 +46,7 @@ function useExtractRichTreeViewProParameters(props) {
46
46
  // RichTreeViewProStore parameters
47
47
  dataSource,
48
48
  dataSourceCache,
49
+ onItemsLazyLoaded,
49
50
  itemsReordering,
50
51
  isItemReorderable,
51
52
  canMoveItemToNewPosition,
@@ -86,6 +87,7 @@ function useExtractRichTreeViewProParameters(props) {
86
87
  // RichTreeViewProStore parameters
87
88
  dataSource,
88
89
  dataSourceCache,
90
+ onItemsLazyLoaded,
89
91
  itemsReordering,
90
92
  isItemReorderable,
91
93
  canMoveItemToNewPosition,
@@ -96,7 +98,7 @@ function useExtractRichTreeViewProParameters(props) {
96
98
  // RichTreeViewStore parameters
97
99
  onItemLabelChange, isItemEditable,
98
100
  // RichTreeViewProStore parameters
99
- dataSource, dataSourceCache, itemsReordering, isItemReorderable, canMoveItemToNewPosition, onItemPositionChange]);
101
+ dataSource, dataSourceCache, onItemsLazyLoaded, itemsReordering, isItemReorderable, canMoveItemToNewPosition, onItemPositionChange]);
100
102
  return {
101
103
  apiRef,
102
104
  slots,
@@ -45,7 +45,7 @@ export const RichTreeViewProRoot = styled('ul', {
45
45
  outline: 0,
46
46
  position: 'relative'
47
47
  });
48
- const releaseInfo = "MTc3MTU0NTYwMDAwMA==";
48
+ const releaseInfo = "MTc3NjIxMTIwMDAwMA==";
49
49
 
50
50
  /**
51
51
  *
@@ -325,6 +325,15 @@ process.env.NODE_ENV !== "production" ? RichTreeViewPro.propTypes = {
325
325
  * @param {boolean} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
326
326
  */
327
327
  onItemSelectionToggle: PropTypes.func,
328
+ /**
329
+ * Callback fired when the children of an item are loaded from the data source.
330
+ * Only relevant for lazy-loaded tree views.
331
+ * @param {object} parameters The parameters of the callback.
332
+ * @param {R[]} parameters.items The items that were loaded.
333
+ * @param {TreeViewItemId | null} parameters.parentId The id of the parent item whose children were loaded. `null` if the root items were loaded.
334
+ * @param {boolean} parameters.isCacheHit `true` if the items were loaded from the cache, `false` if they were fetched from the data source.
335
+ */
336
+ onItemsLazyLoaded: PropTypes.func,
328
337
  /**
329
338
  * Callback fired when Tree Items are selected/deselected.
330
339
  * @param {React.SyntheticEvent} event The DOM event that triggered the change. Can be null when the change is caused by the `publicAPI.setItemSelection()` method.
@@ -1,5 +1,5 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
- const _excluded = ["apiRef", "slots", "slotProps", "disabledItemsFocusable", "items", "isItemDisabled", "isItemSelectionDisabled", "getItemLabel", "getItemChildren", "getItemId", "onItemClick", "itemChildrenIndentation", "id", "expandedItems", "defaultExpandedItems", "onExpandedItemsChange", "onItemExpansionToggle", "expansionTrigger", "disableSelection", "selectedItems", "defaultSelectedItems", "multiSelect", "checkboxSelection", "selectionPropagation", "onSelectedItemsChange", "onItemSelectionToggle", "onItemFocus", "onItemLabelChange", "isItemEditable", "dataSource", "dataSourceCache", "itemsReordering", "isItemReorderable", "canMoveItemToNewPosition", "onItemPositionChange"];
2
+ const _excluded = ["apiRef", "slots", "slotProps", "disabledItemsFocusable", "items", "isItemDisabled", "isItemSelectionDisabled", "getItemLabel", "getItemChildren", "getItemId", "onItemClick", "itemChildrenIndentation", "id", "expandedItems", "defaultExpandedItems", "onExpandedItemsChange", "onItemExpansionToggle", "expansionTrigger", "disableSelection", "selectedItems", "defaultSelectedItems", "multiSelect", "checkboxSelection", "selectionPropagation", "onSelectedItemsChange", "onItemSelectionToggle", "onItemFocus", "onItemLabelChange", "isItemEditable", "dataSource", "dataSourceCache", "onItemsLazyLoaded", "itemsReordering", "isItemReorderable", "canMoveItemToNewPosition", "onItemPositionChange"];
3
3
  import * as React from 'react';
4
4
  export function useExtractRichTreeViewProParameters(props) {
5
5
  const {
@@ -38,6 +38,7 @@ export function useExtractRichTreeViewProParameters(props) {
38
38
  // RichTreeViewProStore parameters
39
39
  dataSource,
40
40
  dataSourceCache,
41
+ onItemsLazyLoaded,
41
42
  itemsReordering,
42
43
  isItemReorderable,
43
44
  canMoveItemToNewPosition,
@@ -78,6 +79,7 @@ export function useExtractRichTreeViewProParameters(props) {
78
79
  // RichTreeViewProStore parameters
79
80
  dataSource,
80
81
  dataSourceCache,
82
+ onItemsLazyLoaded,
81
83
  itemsReordering,
82
84
  isItemReorderable,
83
85
  canMoveItemToNewPosition,
@@ -88,7 +90,7 @@ export function useExtractRichTreeViewProParameters(props) {
88
90
  // RichTreeViewStore parameters
89
91
  onItemLabelChange, isItemEditable,
90
92
  // RichTreeViewProStore parameters
91
- dataSource, dataSourceCache, itemsReordering, isItemReorderable, canMoveItemToNewPosition, onItemPositionChange]);
93
+ dataSource, dataSourceCache, onItemsLazyLoaded, itemsReordering, isItemReorderable, canMoveItemToNewPosition, onItemPositionChange]);
92
94
  return {
93
95
  apiRef,
94
96
  slots,
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view-pro v8.27.2
2
+ * @mui/x-tree-view-pro v8.28.3
3
3
  *
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  * This source code is licensed under the SEE LICENSE IN LICENSE license found in the
@@ -4,8 +4,9 @@ import { RichTreeViewProStoreParameters, RichTreeViewProState } from "./RichTree
4
4
  import { TreeViewLazyLoadingPlugin } from "../plugins/lazyLoading/index.js";
5
5
  import { TreeViewItemsReorderingPlugin } from "../plugins/itemsReordering/index.js";
6
6
  export declare class RichTreeViewProStore<R extends TreeViewValidItem<R>, Multiple extends boolean | undefined> extends ExtendableRichTreeViewStore<R, Multiple, RichTreeViewProState<R, Multiple>, RichTreeViewProStoreParameters<R, Multiple>> {
7
- lazyLoading: TreeViewLazyLoadingPlugin;
7
+ lazyLoading: TreeViewLazyLoadingPlugin<R>;
8
8
  itemsReordering: TreeViewItemsReorderingPlugin;
9
+ disposeEffect: () => () => void;
9
10
  constructor(parameters: RichTreeViewProStoreParameters<R, Multiple>);
10
11
  buildPublicAPI(): {
11
12
  updateItemChildren: (itemId: import("@mui/x-tree-view").TreeViewItemId | null) => Promise<void>;
@@ -5,6 +5,10 @@ import { TreeViewItemsReorderingPlugin } from "../plugins/itemsReordering/index.
5
5
  import { parametersToStateMapper } from "./RichTreeViewProStore.utils.js";
6
6
  export class RichTreeViewProStore extends ExtendableRichTreeViewStore {
7
7
  itemsReordering = (() => new TreeViewItemsReorderingPlugin(this))();
8
+ disposeEffect = () => {
9
+ this.lazyLoading.initEffect();
10
+ return this.timeoutManager.clearAll;
11
+ };
8
12
  constructor(parameters) {
9
13
  super(parameters, 'RichTreeViewPro', parametersToStateMapper);
10
14
  this.lazyLoading = new TreeViewLazyLoadingPlugin(this);
@@ -28,7 +28,7 @@ export interface RichTreeViewProStoreParameters<R extends TreeViewValidItem<R>,
28
28
  /**
29
29
  * The data source cache object.
30
30
  */
31
- dataSourceCache?: DataSourceCache;
31
+ dataSourceCache?: DataSourceCache<R>;
32
32
  /**
33
33
  * If `true`, the reordering of items is enabled.
34
34
  * @default false
@@ -54,6 +54,19 @@ export interface RichTreeViewProStoreParameters<R extends TreeViewValidItem<R>,
54
54
  oldPosition: TreeViewItemReorderPosition;
55
55
  newPosition: TreeViewItemReorderPosition;
56
56
  }) => boolean;
57
+ /**
58
+ * Callback fired when the children of an item are loaded from the data source.
59
+ * Only relevant for lazy-loaded tree views.
60
+ * @param {object} parameters The parameters of the callback.
61
+ * @param {R[]} parameters.items The items that were loaded.
62
+ * @param {TreeViewItemId | null} parameters.parentId The id of the parent item whose children were loaded. `null` if the root items were loaded.
63
+ * @param {boolean} parameters.isCacheHit `true` if the items were loaded from the cache, `false` if they were fetched from the data source.
64
+ */
65
+ onItemsLazyLoaded?: (parameters: {
66
+ items: R[];
67
+ parentId: TreeViewItemId | null;
68
+ isCacheHit: boolean;
69
+ }) => void;
57
70
  /**
58
71
  * Callback fired when a Tree Item is moved in the tree.
59
72
  * @param {object} parameters The params describing the item re-ordering.
@@ -4,12 +4,13 @@ import { TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE } from "../plugins/lazyLoadin
4
4
  const DEFAULT_IS_ITEM_REORDERABLE_WHEN_ENABLED = () => true;
5
5
  const DEFAULT_IS_ITEM_REORDERABLE_WHEN_DISABLED = () => false;
6
6
  const deriveStateFromParameters = parameters => ({
7
- lazyLoadedItems: parameters.dataSource ? TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE : null,
8
7
  currentReorder: null,
9
8
  isItemReorderable: parameters.itemsReordering ? parameters.isItemReorderable ?? DEFAULT_IS_ITEM_REORDERABLE_WHEN_ENABLED : DEFAULT_IS_ITEM_REORDERABLE_WHEN_DISABLED
10
9
  });
11
10
  export const parametersToStateMapper = {
12
- getInitialState: (minimalInitialState, parameters) => _extends({}, ExtendableRichTreeViewStore.rawMapper.getInitialState(minimalInitialState, parameters), deriveStateFromParameters(parameters)),
11
+ getInitialState: (minimalInitialState, parameters) => _extends({}, ExtendableRichTreeViewStore.rawMapper.getInitialState(minimalInitialState, parameters), {
12
+ lazyLoadedItems: parameters.dataSource ? TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE : null
13
+ }, deriveStateFromParameters(parameters)),
13
14
  updateStateFromParameters: (newMinimalState, parameters, updateModel) => {
14
15
  const newState = _extends({}, ExtendableRichTreeViewStore.rawMapper.updateStateFromParameters(newMinimalState, parameters, updateModel), deriveStateFromParameters(parameters));
15
16
  return newState;
@@ -1,18 +1,27 @@
1
- import { TreeViewItemId } from '@mui/x-tree-view/models';
1
+ import { TreeViewItemId, TreeViewValidItem } from '@mui/x-tree-view/models';
2
2
  import { RichTreeViewProStore } from "../../RichTreeViewProStore/RichTreeViewProStore.js";
3
3
  export declare const TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE: {
4
4
  loading: {};
5
5
  errors: {};
6
6
  };
7
- export declare class TreeViewLazyLoadingPlugin {
7
+ export declare class TreeViewLazyLoadingPlugin<R extends TreeViewValidItem<R>> {
8
8
  private store;
9
9
  private nestedDataManager;
10
10
  private cache;
11
- constructor(store: RichTreeViewProStore<any, any>);
11
+ private isInsideOnItemsLazyLoaded;
12
+ private initStarted;
13
+ constructor(store: RichTreeViewProStore<R, any>);
14
+ /**
15
+ * Initialize lazy loading.
16
+ * Called from the store's disposeEffect (inside a useEffect) to avoid side effects during render.
17
+ * Uses a flag to ensure initialization only happens once (handles React 18 StrictMode double-firing effects).
18
+ */
19
+ initEffect: () => void;
12
20
  private init;
13
21
  private handleBeforeItemToggleExpansion;
14
22
  private setItemLoading;
15
23
  private setItemError;
24
+ private callOnItemsLazyLoaded;
16
25
  buildPublicAPI: () => {
17
26
  updateItemChildren: (itemId: TreeViewItemId | null) => Promise<void>;
18
27
  };
@@ -41,6 +50,9 @@ export declare class TreeViewLazyLoadingPlugin {
41
50
  * @param {boolean} [parameters.forceRefresh] Whether to force a refresh of the children when the cache already contains some data.
42
51
  * @returns {Promise<void>} The promise resolved when the items are fetched.
43
52
  */
53
+ private getItemId;
54
+ private getInlineChildren;
55
+ private processNestedItemChildren;
44
56
  fetchItemChildren: ({
45
57
  itemId,
46
58
  forceRefresh
@@ -8,14 +8,28 @@ export const TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE = {
8
8
  };
9
9
  export class TreeViewLazyLoadingPlugin {
10
10
  nestedDataManager = (() => new NestedDataManager(this))();
11
+ isInsideOnItemsLazyLoaded = false;
12
+ initStarted = false;
11
13
  constructor(store) {
12
14
  this.store = store;
13
15
  this.cache = store.parameters.dataSourceCache ?? new DataSourceCacheDefault({});
14
16
  if (store.parameters.dataSource != null) {
15
- this.init();
16
17
  store.subscribeEvent('beforeItemToggleExpansion', this.handleBeforeItemToggleExpansion);
17
18
  }
18
19
  }
20
+
21
+ /**
22
+ * Initialize lazy loading.
23
+ * Called from the store's disposeEffect (inside a useEffect) to avoid side effects during render.
24
+ * Uses a flag to ensure initialization only happens once (handles React 18 StrictMode double-firing effects).
25
+ */
26
+ initEffect = () => {
27
+ if (this.store.parameters.dataSource == null || this.initStarted) {
28
+ return;
29
+ }
30
+ this.initStarted = true;
31
+ this.init();
32
+ };
19
33
  init = () => {
20
34
  const store = this.store;
21
35
  // eslint-disable-next-line consistent-this
@@ -108,6 +122,21 @@ export class TreeViewLazyLoadingPlugin {
108
122
  errors
109
123
  }));
110
124
  };
125
+ callOnItemsLazyLoaded(items, parentId, isCacheHit) {
126
+ if (this.isInsideOnItemsLazyLoaded) {
127
+ return;
128
+ }
129
+ this.isInsideOnItemsLazyLoaded = true;
130
+ try {
131
+ this.store.parameters.onItemsLazyLoaded?.({
132
+ items,
133
+ parentId,
134
+ isCacheHit
135
+ });
136
+ } finally {
137
+ this.isInsideOnItemsLazyLoaded = false;
138
+ }
139
+ }
111
140
  buildPublicAPI = () => {
112
141
  return {
113
142
  updateItemChildren: this.updateItemChildren
@@ -144,6 +173,27 @@ export class TreeViewLazyLoadingPlugin {
144
173
  * @param {boolean} [parameters.forceRefresh] Whether to force a refresh of the children when the cache already contains some data.
145
174
  * @returns {Promise<void>} The promise resolved when the items are fetched.
146
175
  */
176
+ getItemId = item => this.store.parameters.getItemId ? this.store.parameters.getItemId(item) : item.id;
177
+ getInlineChildren = item => (this.store.parameters.getItemChildren ? this.store.parameters.getItemChildren(item) : item.children) ?? [];
178
+ processNestedItemChildren = items => {
179
+ const {
180
+ getChildrenCount
181
+ } = this.store.parameters.dataSource;
182
+ for (const item of items) {
183
+ const children = this.getInlineChildren(item);
184
+ if (children.length === 0) {
185
+ continue;
186
+ }
187
+ const itemId = this.getItemId(item);
188
+ this.cache.set(itemId, children);
189
+ this.store.items.setItemChildren({
190
+ items: children,
191
+ parentId: itemId,
192
+ getChildrenCount
193
+ });
194
+ this.processNestedItemChildren(children);
195
+ }
196
+ };
147
197
  fetchItemChildren = async ({
148
198
  itemId,
149
199
  forceRefresh
@@ -179,6 +229,7 @@ export class TreeViewLazyLoadingPlugin {
179
229
  getChildrenCount
180
230
  });
181
231
  this.setItemLoading(itemId, false);
232
+ this.callOnItemsLazyLoaded(cachedData, itemId, true);
182
233
  return;
183
234
  }
184
235
 
@@ -209,6 +260,10 @@ export class TreeViewLazyLoadingPlugin {
209
260
  parentId: itemId,
210
261
  getChildrenCount
211
262
  });
263
+ // pre-cache any inline nested children so expanding them requires no extra network call
264
+ this.processNestedItemChildren(response);
265
+ // notify the user that new items have been loaded
266
+ this.callOnItemsLazyLoaded(response, itemId, false);
212
267
  } catch (error) {
213
268
  const childrenFetchError = error;
214
269
  // set the item error in the state
@@ -1,4 +1,4 @@
1
- import { TreeViewItemId } from '@mui/x-tree-view/models';
1
+ import { TreeViewItemId, TreeViewValidItem } from '@mui/x-tree-view/models';
2
2
  import { TreeViewLazyLoadingPlugin } from "./TreeViewLazyLoadingPlugin.js";
3
3
  export declare enum RequestStatus {
4
4
  QUEUED = 0,
@@ -17,7 +17,7 @@ export declare class NestedDataManager {
17
17
  private settledRequests;
18
18
  private lazyLoadingPlugin;
19
19
  private maxConcurrentRequests;
20
- constructor(lazyLoadingPlugin: TreeViewLazyLoadingPlugin, maxConcurrentRequests?: number);
20
+ constructor(lazyLoadingPlugin: TreeViewLazyLoadingPlugin<TreeViewValidItem<any>>, maxConcurrentRequests?: number);
21
21
  private processQueue;
22
22
  queue: (ids: TreeViewItemId[]) => Promise<void>;
23
23
  setRequestSettled: (id: TreeViewItemId) => Promise<void>;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view-pro v8.27.2
2
+ * @mui/x-tree-view-pro v8.28.3
3
3
  *
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  * This source code is licensed under the SEE LICENSE IN LICENSE license found in the
@@ -4,8 +4,9 @@ import { RichTreeViewProStoreParameters, RichTreeViewProState } from "./RichTree
4
4
  import { TreeViewLazyLoadingPlugin } from "../plugins/lazyLoading/index.js";
5
5
  import { TreeViewItemsReorderingPlugin } from "../plugins/itemsReordering/index.js";
6
6
  export declare class RichTreeViewProStore<R extends TreeViewValidItem<R>, Multiple extends boolean | undefined> extends ExtendableRichTreeViewStore<R, Multiple, RichTreeViewProState<R, Multiple>, RichTreeViewProStoreParameters<R, Multiple>> {
7
- lazyLoading: TreeViewLazyLoadingPlugin;
7
+ lazyLoading: TreeViewLazyLoadingPlugin<R>;
8
8
  itemsReordering: TreeViewItemsReorderingPlugin;
9
+ disposeEffect: () => () => void;
9
10
  constructor(parameters: RichTreeViewProStoreParameters<R, Multiple>);
10
11
  buildPublicAPI(): {
11
12
  updateItemChildren: (itemId: import("@mui/x-tree-view").TreeViewItemId | null) => Promise<void>;
@@ -12,6 +12,10 @@ var _itemsReordering = require("../plugins/itemsReordering");
12
12
  var _RichTreeViewProStore = require("./RichTreeViewProStore.utils");
13
13
  class RichTreeViewProStore extends _internals.ExtendableRichTreeViewStore {
14
14
  itemsReordering = new _itemsReordering.TreeViewItemsReorderingPlugin(this);
15
+ disposeEffect = () => {
16
+ this.lazyLoading.initEffect();
17
+ return this.timeoutManager.clearAll;
18
+ };
15
19
  constructor(parameters) {
16
20
  super(parameters, 'RichTreeViewPro', _RichTreeViewProStore.parametersToStateMapper);
17
21
  this.lazyLoading = new _lazyLoading.TreeViewLazyLoadingPlugin(this);
@@ -28,7 +28,7 @@ export interface RichTreeViewProStoreParameters<R extends TreeViewValidItem<R>,
28
28
  /**
29
29
  * The data source cache object.
30
30
  */
31
- dataSourceCache?: DataSourceCache;
31
+ dataSourceCache?: DataSourceCache<R>;
32
32
  /**
33
33
  * If `true`, the reordering of items is enabled.
34
34
  * @default false
@@ -54,6 +54,19 @@ export interface RichTreeViewProStoreParameters<R extends TreeViewValidItem<R>,
54
54
  oldPosition: TreeViewItemReorderPosition;
55
55
  newPosition: TreeViewItemReorderPosition;
56
56
  }) => boolean;
57
+ /**
58
+ * Callback fired when the children of an item are loaded from the data source.
59
+ * Only relevant for lazy-loaded tree views.
60
+ * @param {object} parameters The parameters of the callback.
61
+ * @param {R[]} parameters.items The items that were loaded.
62
+ * @param {TreeViewItemId | null} parameters.parentId The id of the parent item whose children were loaded. `null` if the root items were loaded.
63
+ * @param {boolean} parameters.isCacheHit `true` if the items were loaded from the cache, `false` if they were fetched from the data source.
64
+ */
65
+ onItemsLazyLoaded?: (parameters: {
66
+ items: R[];
67
+ parentId: TreeViewItemId | null;
68
+ isCacheHit: boolean;
69
+ }) => void;
57
70
  /**
58
71
  * Callback fired when a Tree Item is moved in the tree.
59
72
  * @param {object} parameters The params describing the item re-ordering.
@@ -11,12 +11,13 @@ var _lazyLoading = require("../plugins/lazyLoading");
11
11
  const DEFAULT_IS_ITEM_REORDERABLE_WHEN_ENABLED = () => true;
12
12
  const DEFAULT_IS_ITEM_REORDERABLE_WHEN_DISABLED = () => false;
13
13
  const deriveStateFromParameters = parameters => ({
14
- lazyLoadedItems: parameters.dataSource ? _lazyLoading.TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE : null,
15
14
  currentReorder: null,
16
15
  isItemReorderable: parameters.itemsReordering ? parameters.isItemReorderable ?? DEFAULT_IS_ITEM_REORDERABLE_WHEN_ENABLED : DEFAULT_IS_ITEM_REORDERABLE_WHEN_DISABLED
17
16
  });
18
17
  const parametersToStateMapper = exports.parametersToStateMapper = {
19
- getInitialState: (minimalInitialState, parameters) => (0, _extends2.default)({}, _internals.ExtendableRichTreeViewStore.rawMapper.getInitialState(minimalInitialState, parameters), deriveStateFromParameters(parameters)),
18
+ getInitialState: (minimalInitialState, parameters) => (0, _extends2.default)({}, _internals.ExtendableRichTreeViewStore.rawMapper.getInitialState(minimalInitialState, parameters), {
19
+ lazyLoadedItems: parameters.dataSource ? _lazyLoading.TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE : null
20
+ }, deriveStateFromParameters(parameters)),
20
21
  updateStateFromParameters: (newMinimalState, parameters, updateModel) => {
21
22
  const newState = (0, _extends2.default)({}, _internals.ExtendableRichTreeViewStore.rawMapper.updateStateFromParameters(newMinimalState, parameters, updateModel), deriveStateFromParameters(parameters));
22
23
  return newState;
@@ -1,18 +1,27 @@
1
- import { TreeViewItemId } from '@mui/x-tree-view/models';
1
+ import { TreeViewItemId, TreeViewValidItem } from '@mui/x-tree-view/models';
2
2
  import { RichTreeViewProStore } from "../../RichTreeViewProStore/RichTreeViewProStore.js";
3
3
  export declare const TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE: {
4
4
  loading: {};
5
5
  errors: {};
6
6
  };
7
- export declare class TreeViewLazyLoadingPlugin {
7
+ export declare class TreeViewLazyLoadingPlugin<R extends TreeViewValidItem<R>> {
8
8
  private store;
9
9
  private nestedDataManager;
10
10
  private cache;
11
- constructor(store: RichTreeViewProStore<any, any>);
11
+ private isInsideOnItemsLazyLoaded;
12
+ private initStarted;
13
+ constructor(store: RichTreeViewProStore<R, any>);
14
+ /**
15
+ * Initialize lazy loading.
16
+ * Called from the store's disposeEffect (inside a useEffect) to avoid side effects during render.
17
+ * Uses a flag to ensure initialization only happens once (handles React 18 StrictMode double-firing effects).
18
+ */
19
+ initEffect: () => void;
12
20
  private init;
13
21
  private handleBeforeItemToggleExpansion;
14
22
  private setItemLoading;
15
23
  private setItemError;
24
+ private callOnItemsLazyLoaded;
16
25
  buildPublicAPI: () => {
17
26
  updateItemChildren: (itemId: TreeViewItemId | null) => Promise<void>;
18
27
  };
@@ -41,6 +50,9 @@ export declare class TreeViewLazyLoadingPlugin {
41
50
  * @param {boolean} [parameters.forceRefresh] Whether to force a refresh of the children when the cache already contains some data.
42
51
  * @returns {Promise<void>} The promise resolved when the items are fetched.
43
52
  */
53
+ private getItemId;
54
+ private getInlineChildren;
55
+ private processNestedItemChildren;
44
56
  fetchItemChildren: ({
45
57
  itemId,
46
58
  forceRefresh
@@ -15,14 +15,28 @@ const TREE_VIEW_LAZY_LOADED_ITEMS_INITIAL_STATE = exports.TREE_VIEW_LAZY_LOADED_
15
15
  };
16
16
  class TreeViewLazyLoadingPlugin {
17
17
  nestedDataManager = new _utils2.NestedDataManager(this);
18
+ isInsideOnItemsLazyLoaded = false;
19
+ initStarted = false;
18
20
  constructor(store) {
19
21
  this.store = store;
20
22
  this.cache = store.parameters.dataSourceCache ?? new _utils.DataSourceCacheDefault({});
21
23
  if (store.parameters.dataSource != null) {
22
- this.init();
23
24
  store.subscribeEvent('beforeItemToggleExpansion', this.handleBeforeItemToggleExpansion);
24
25
  }
25
26
  }
27
+
28
+ /**
29
+ * Initialize lazy loading.
30
+ * Called from the store's disposeEffect (inside a useEffect) to avoid side effects during render.
31
+ * Uses a flag to ensure initialization only happens once (handles React 18 StrictMode double-firing effects).
32
+ */
33
+ initEffect = () => {
34
+ if (this.store.parameters.dataSource == null || this.initStarted) {
35
+ return;
36
+ }
37
+ this.initStarted = true;
38
+ this.init();
39
+ };
26
40
  init = () => {
27
41
  const store = this.store;
28
42
  // eslint-disable-next-line consistent-this
@@ -115,6 +129,21 @@ class TreeViewLazyLoadingPlugin {
115
129
  errors
116
130
  }));
117
131
  };
132
+ callOnItemsLazyLoaded(items, parentId, isCacheHit) {
133
+ if (this.isInsideOnItemsLazyLoaded) {
134
+ return;
135
+ }
136
+ this.isInsideOnItemsLazyLoaded = true;
137
+ try {
138
+ this.store.parameters.onItemsLazyLoaded?.({
139
+ items,
140
+ parentId,
141
+ isCacheHit
142
+ });
143
+ } finally {
144
+ this.isInsideOnItemsLazyLoaded = false;
145
+ }
146
+ }
118
147
  buildPublicAPI = () => {
119
148
  return {
120
149
  updateItemChildren: this.updateItemChildren
@@ -151,6 +180,27 @@ class TreeViewLazyLoadingPlugin {
151
180
  * @param {boolean} [parameters.forceRefresh] Whether to force a refresh of the children when the cache already contains some data.
152
181
  * @returns {Promise<void>} The promise resolved when the items are fetched.
153
182
  */
183
+ getItemId = item => this.store.parameters.getItemId ? this.store.parameters.getItemId(item) : item.id;
184
+ getInlineChildren = item => (this.store.parameters.getItemChildren ? this.store.parameters.getItemChildren(item) : item.children) ?? [];
185
+ processNestedItemChildren = items => {
186
+ const {
187
+ getChildrenCount
188
+ } = this.store.parameters.dataSource;
189
+ for (const item of items) {
190
+ const children = this.getInlineChildren(item);
191
+ if (children.length === 0) {
192
+ continue;
193
+ }
194
+ const itemId = this.getItemId(item);
195
+ this.cache.set(itemId, children);
196
+ this.store.items.setItemChildren({
197
+ items: children,
198
+ parentId: itemId,
199
+ getChildrenCount
200
+ });
201
+ this.processNestedItemChildren(children);
202
+ }
203
+ };
154
204
  fetchItemChildren = async ({
155
205
  itemId,
156
206
  forceRefresh
@@ -186,6 +236,7 @@ class TreeViewLazyLoadingPlugin {
186
236
  getChildrenCount
187
237
  });
188
238
  this.setItemLoading(itemId, false);
239
+ this.callOnItemsLazyLoaded(cachedData, itemId, true);
189
240
  return;
190
241
  }
191
242
 
@@ -216,6 +267,10 @@ class TreeViewLazyLoadingPlugin {
216
267
  parentId: itemId,
217
268
  getChildrenCount
218
269
  });
270
+ // pre-cache any inline nested children so expanding them requires no extra network call
271
+ this.processNestedItemChildren(response);
272
+ // notify the user that new items have been loaded
273
+ this.callOnItemsLazyLoaded(response, itemId, false);
219
274
  } catch (error) {
220
275
  const childrenFetchError = error;
221
276
  // set the item error in the state
@@ -1,4 +1,4 @@
1
- import { TreeViewItemId } from '@mui/x-tree-view/models';
1
+ import { TreeViewItemId, TreeViewValidItem } from '@mui/x-tree-view/models';
2
2
  import { TreeViewLazyLoadingPlugin } from "./TreeViewLazyLoadingPlugin.js";
3
3
  export declare enum RequestStatus {
4
4
  QUEUED = 0,
@@ -17,7 +17,7 @@ export declare class NestedDataManager {
17
17
  private settledRequests;
18
18
  private lazyLoadingPlugin;
19
19
  private maxConcurrentRequests;
20
- constructor(lazyLoadingPlugin: TreeViewLazyLoadingPlugin, maxConcurrentRequests?: number);
20
+ constructor(lazyLoadingPlugin: TreeViewLazyLoadingPlugin<TreeViewValidItem<any>>, maxConcurrentRequests?: number);
21
21
  private processQueue;
22
22
  queue: (ids: TreeViewItemId[]) => Promise<void>;
23
23
  setRequestSettled: (id: TreeViewItemId) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-tree-view-pro",
3
- "version": "8.27.2",
3
+ "version": "8.28.3",
4
4
  "author": "MUI Team",
5
5
  "description": "The Pro plan edition of the MUI X Tree View components.",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -40,9 +40,9 @@
40
40
  "react-transition-group": "^4.4.5",
41
41
  "reselect": "^5.1.1",
42
42
  "use-sync-external-store": "^1.6.0",
43
- "@mui/x-internals": "8.26.0",
43
+ "@mui/x-tree-view": "8.28.3",
44
44
  "@mui/x-license": "8.26.0",
45
- "@mui/x-tree-view": "8.27.2"
45
+ "@mui/x-internals": "8.26.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@emotion/react": "^11.9.0",