@mui/x-tree-view 8.19.0 → 8.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +310 -0
  2. package/RichTreeView/RichTreeView.js +1 -1
  3. package/RichTreeView/RichTreeView.types.d.ts +1 -1
  4. package/SimpleTreeView/SimpleTreeView.js +1 -1
  5. package/SimpleTreeView/SimpleTreeView.types.d.ts +1 -1
  6. package/esm/RichTreeView/RichTreeView.js +1 -1
  7. package/esm/RichTreeView/RichTreeView.types.d.ts +1 -1
  8. package/esm/SimpleTreeView/SimpleTreeView.js +1 -1
  9. package/esm/SimpleTreeView/SimpleTreeView.types.d.ts +1 -1
  10. package/esm/hooks/index.d.ts +4 -2
  11. package/esm/hooks/index.js +4 -2
  12. package/esm/hooks/useRichTreeViewApiRef.d.ts +8 -0
  13. package/esm/hooks/useRichTreeViewApiRef.js +7 -0
  14. package/esm/hooks/useSimpleTreeViewApiRef.d.ts +8 -0
  15. package/esm/hooks/useSimpleTreeViewApiRef.js +7 -0
  16. package/esm/hooks/useTreeViewApiRef.d.ts +1 -0
  17. package/esm/hooks/useTreeViewApiRef.js +1 -0
  18. package/esm/index.js +1 -1
  19. package/esm/internals/components/RichTreeViewItems.js +2 -1
  20. package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +2 -2
  21. package/esm/models/items.d.ts +4 -1
  22. package/esm/useTreeItem/useTreeItem.js +7 -6
  23. package/hooks/index.d.ts +4 -2
  24. package/hooks/index.js +16 -2
  25. package/hooks/useRichTreeViewApiRef.d.ts +8 -0
  26. package/hooks/useRichTreeViewApiRef.js +14 -0
  27. package/hooks/useSimpleTreeViewApiRef.d.ts +8 -0
  28. package/hooks/useSimpleTreeViewApiRef.js +14 -0
  29. package/hooks/useTreeViewApiRef.d.ts +1 -0
  30. package/hooks/useTreeViewApiRef.js +1 -0
  31. package/index.js +1 -1
  32. package/internals/components/RichTreeViewItems.js +2 -1
  33. package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +2 -2
  34. package/models/items.d.ts +4 -1
  35. package/package.json +2 -2
  36. package/useTreeItem/useTreeItem.js +7 -6
package/CHANGELOG.md CHANGED
@@ -5,6 +5,316 @@
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.22.0
9
+
10
+ _Dec 11, 2025_
11
+
12
+ We'd like to extend a big thank you to the 11 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - Each Tree View component now exposes its own hook to initialize the `apiRef` object with accurate typing:
15
+
16
+ ```diff
17
+ -import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';
18
+ +import { useSimpleTreeViewApiRef } from '@mui/x-tree-view/hooks';
19
+ -const apiRef = useTreeViewApiRef();
20
+ +const apiRef = useSimpleTreeViewApiRef();
21
+
22
+ -import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';
23
+ +import { useRichTreeViewApiRef } from '@mui/x-tree-view/hooks';
24
+ -const apiRef = useTreeViewApiRef();
25
+ +const apiRef = useRichTreeViewApiRef();
26
+
27
+ -import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';
28
+ +import { useRichTreeViewProApiRef } from '@mui/x-tree-view-pro/hooks';
29
+ -const apiRef = useTreeViewApiRef();
30
+ +const apiRef = useRichTreeViewProApiRef();
31
+ ```
32
+
33
+ - 📚 [Tutorial](https://mui.com/x/react-data-grid/tutorials/server-side-data/) on building a Data Grid with server-side data
34
+ - 🐞 Bugfixes
35
+
36
+ Special thanks go out to this community member for their valuable contributions:
37
+ @kzhgit
38
+
39
+ The following team members contributed to this release:
40
+ @alexfauquette, @arminmeh, @bernardobelchior, @cherniavskii, @flaviendelangle, @JCQuintas, @mapache-salvaje, @michelengelen, @noraleonte, @oliviertassinari
41
+
42
+ ### Data Grid
43
+
44
+ #### `@mui/x-data-grid@8.22.0`
45
+
46
+ - [DataGrid] Sync component props with theme defaults (#20590) @michelengelen
47
+ - [DataGrid] Add fallback for CSS `color-mix` if it is unsupported (#20597) @cherniavskii
48
+ - [DataGrid] Use `baseTooltip` slot for column header sort icon (#20460) @kzhgit
49
+
50
+ #### `@mui/x-data-grid-pro@8.22.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
51
+
52
+ Same changes as in `@mui/x-data-grid@8.22.0`.
53
+
54
+ #### `@mui/x-data-grid-premium@8.22.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
55
+
56
+ Same changes as in `@mui/x-data-grid-pro@8.22.0`, plus:
57
+
58
+ - [DataGridPremium] Handle pivoting column name generation for empty strings (#20608) @arminmeh
59
+ - [DataGridPremium] Pass a row with aggregated value to the custom aggregation function `valueFormatter` (#20607) @arminmeh
60
+
61
+ ### Date and Time Pickers
62
+
63
+ #### `@mui/x-date-pickers@8.22.0`
64
+
65
+ - [pickers] Fix invalid date tests (#20606) @michelengelen
66
+
67
+ #### `@mui/x-date-pickers-pro@8.22.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
68
+
69
+ Same changes as in `@mui/x-date-pickers@8.22.0`.
70
+
71
+ ### Charts
72
+
73
+ #### `@mui/x-charts@8.22.0`
74
+
75
+ - [charts] Add consistent animation duration and timing (#20564) @JCQuintas
76
+ - [charts] Extract a tooltip plugin from the interaction one (#20591) @alexfauquette
77
+ - [charts] General type improvements (#20565) @JCQuintas
78
+ - [charts] Place ordinal ticks according to a continuous scale (#19808) @alexfauquette
79
+ - [charts] Remove layout data from the tooltip internals (#20548) @alexfauquette
80
+ - [charts] Remove usage of focus outline for item highlight (#19856) @alexfauquette
81
+ - [charts] Simplify `MarkPlot` by moving calculation to `useMarkPlotData` (#20570) @JCQuintas
82
+ - [charts] Use `store.state` over `store.getSnapshot()` (#20616) @bernardobelchior
83
+ - [charts] Vendor flatqueue (#20610) @bernardobelchior
84
+ - [charts] Extract pie layout computation (#20611) @alexfauquette
85
+ - [charts][infra] Enable `@typescript-eslint/consistent-type-imports` eslint rules (#20560) @JCQuintas
86
+ - [charts][infra] Enable `import/no-cycle` eslint rules (#20554) @JCQuintas
87
+
88
+ #### `@mui/x-charts-pro@8.22.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
89
+
90
+ Same changes as in `@mui/x-charts@8.22.0`, plus:
91
+
92
+ - [charts-pro] Display sankey labels on top of nodes (#20569) @alexfauquette
93
+
94
+ #### `@mui/x-charts-premium@8.22.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
95
+
96
+ Same changes as in `@mui/x-charts-pro@8.22.0`.
97
+
98
+ ### Tree View
99
+
100
+ #### `@mui/x-tree-view@8.22.0`
101
+
102
+ - [tree view] Expose one hook per component to initialize the `apiRef` (#20235) @flaviendelangle
103
+ - [tree view] Update the typing of `updateItemChildren()` to accept `null` (#20483) @noraleonte
104
+
105
+ #### `@mui/x-tree-view-pro@8.22.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
106
+
107
+ Same changes as in `@mui/x-tree-view@8.22.0`.
108
+
109
+ ### Codemod
110
+
111
+ #### `@mui/x-codemod@8.22.0`
112
+
113
+ Internal changes.
114
+
115
+ ### Docs
116
+
117
+ - [docs] Add tutorial on building a Data Grid with server-side data (DX-22) (#19782) @mapache-salvaje
118
+ - [docs] Modify the default value for the stacking demo (#20596) @alexfauquette
119
+ - [docs] Revise the Charts Custom Components doc (#19793) @mapache-salvaje
120
+ - [docs] Remove copy-pasted `aria-label` (#20620) @alexfauquette
121
+
122
+ ### Core
123
+
124
+ - [internal] Remove unsafe dependency version from range (#20574) @oliviertassinari
125
+
126
+ ### Miscellaneous
127
+
128
+ - Bump `@mui/monorepo` digest to `800638d` (#20337) @renovate[bot]
129
+ - Bump `@next/eslint-plugin-next` to `15.5.7` (#20575) @renovate[bot]
130
+ - Bump GitHub Actions (#20577) @renovate[bot]
131
+ - Bump Tanstack query to `^5.90.12` (#20582) @renovate[bot]
132
+ - Bump Vite & Vitest (#20583) @renovate[bot]
133
+ - Bump `eslint` to `^8.48.1` (#20576) @renovate[bot]
134
+ - Bump `markdown-to-jsx` to `^9.3.2` (#20507) @renovate[bot]
135
+ - Bump `motion` to `^12.23.25` (#20579) @renovate[bot]
136
+ - Bump react monorepo to `19.2.1` (#20581) @renovate[bot]
137
+ - Bump `react-hook-form` to `^7.68.0` (#20584) @renovate[bot]
138
+ - Bump `react-router` to `^7.10.1` (#20341) @renovate[bot]
139
+ - Bump `tsx` to `^4.21.0` (#20585) @renovate[bot]
140
+ - Bump MUI infra packages (#20478) @renovate[bot]
141
+ - [infra] Automatically add teams to release PRs (#20558) @JCQuintas
142
+ - [infra] Fix codeowners typo (#20562) @JCQuintas
143
+
144
+ ## 8.21.0
145
+
146
+ _Dec 3, 2025_
147
+
148
+ We'd like to extend a big thank you to the 8 contributors who made this release possible. Here are some highlights ✨:
149
+
150
+ - ✨ Add [tick spacing property](https://mui.com/x/react-charts/axis/#tick-spacing) to charts axis to control the distance between ticks.
151
+
152
+ The following team members contributed to this release:
153
+ @alexfauquette, @bernardobelchior, @ElliottMiller, @Janpot, @JCQuintas, @romgrk, @sai6855, @siriwatknp
154
+
155
+ ### Data Grid
156
+
157
+ #### `@mui/x-data-grid@8.21.0`
158
+
159
+ - [DataGrid] Fix autosizing header width calculation (#20323) @siriwatknp
160
+ - [DataGrid] Virtualizer refactor (#19465) @romgrk
161
+
162
+ #### `@mui/x-data-grid-pro@8.21.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
163
+
164
+ Same changes as in `@mui/x-data-grid@8.21.0`.
165
+
166
+ #### `@mui/x-data-grid-premium@8.21.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
167
+
168
+ Same changes as in `@mui/x-data-grid-pro@8.21.0`, plus:
169
+
170
+ - [DataGridPremium] Prevent pasting to non-editable cells (#20333) @ElliottMiller
171
+
172
+ ### Date and Time Pickers
173
+
174
+ #### `@mui/x-date-pickers@8.21.0`
175
+
176
+ Internal changes.
177
+
178
+ #### `@mui/x-date-pickers-pro@8.21.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
179
+
180
+ Same changes as in `@mui/x-date-pickers@8.21.0`.
181
+
182
+ ### Charts
183
+
184
+ #### `@mui/x-charts@8.21.0`
185
+
186
+ - [charts] Fix string measuring types (#20454) @bernardobelchior
187
+ - [charts] Fix typo in performance note for CustomLineMarks demo (#20529) @sai6855
188
+ - [charts] Introduce the notion of series with positions (#20461) @alexfauquette
189
+ - [charts] Migrate from sinon to Vitest mocking utilities for x-charts\* packages (#20444) @Copilot
190
+ - [charts] Move series-level values to series computed data in bar plot (#20467) @bernardobelchior
191
+ - [charts] Refactor bar chart components in preparation for range bar chart (#20521) @bernardobelchior
192
+ - [charts] Remove unnecessary `any` types (#20527) @sai6855
193
+ - [charts] Remove unused `drawingArea` from `findClosestPoints` (#20471) @bernardobelchior
194
+ - [charts] Revert `useIsHydrated` to default=false (#20511) @JCQuintas
195
+ - [charts] Support tooltip anchor position for radar (#20422) @alexfauquette
196
+ - [charts] Add tick spacing property (#20282) @bernardobelchior
197
+ - [charts] Fix Vitest lint error (#20550) @bernardobelchior
198
+ - [charts] Fix infinite loop when highlighting pie slices or scatter points (#20549) @bernardobelchior
199
+
200
+ #### `@mui/x-charts-pro@8.21.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
201
+
202
+ Same changes as in `@mui/x-charts@8.21.0`, plus:
203
+
204
+ - [charts-pro] Add support for `anchor="node"` on Sankey tooltip (#20462) @alexfauquette
205
+
206
+ #### `@mui/x-charts-premium@8.21.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
207
+
208
+ Same changes as in `@mui/x-charts-pro@8.21.0`.
209
+
210
+ ### Tree View
211
+
212
+ #### `@mui/x-tree-view@8.21.0`
213
+
214
+ Internal changes.
215
+
216
+ #### `@mui/x-tree-view-pro@8.21.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
217
+
218
+ Same changes as in `@mui/x-tree-view@8.21.0`.
219
+
220
+ ### Codemod
221
+
222
+ #### `@mui/x-codemod@8.21.0`
223
+
224
+ Internal changes.
225
+
226
+ ### Docs
227
+
228
+ - [docs] Migrate to `next/font` for fonts loading (#20407) @Copilot
229
+
230
+ ### Core
231
+
232
+ - [code-infra] Enable vitest eslint plugin (#20530) @Janpot
233
+ - [code-infra] Fix missing font loading for local fonts (#20480) @Janpot
234
+ - [internal] Performance: use raw `useSyncExternalStore` (#20447) @romgrk
235
+ - [code-infra] Enable `vitest/expect-expect` and `vitest/no-standalone-expect` rules for x-charts packages (#20535) @Copilot
236
+
237
+ ### Miscellaneous
238
+
239
+ - Bump @types/d3-sankey to ^0.12.5 (#20489) @renovate[bot]
240
+ - Bump @types/react to 19.2.7 (#20490) @renovate[bot]
241
+ - Bump @types/yargs to ^17.0.35 (#20491) @renovate[bot]
242
+ - Bump Vite & Vitest to ^4.0.14 (#20500) @renovate[bot]
243
+ - Bump csstype to ^3.2.3 (#20493) @renovate[bot]
244
+ - Bump es-toolkit to ^1.42.0 (#20494) @renovate[bot]
245
+ - Bump eslint to ^8.48.0 (#20495) @renovate[bot]
246
+ - Bump lerna to ^9.0.3 (#20496) @renovate[bot]
247
+ - Bump lucide-react to ^0.555.0 (#20502) @renovate[bot]
248
+ - Bump playwright monorepo (#20503) @renovate[bot]
249
+ - Bump pnpm to 10.24.0 (#20504) @renovate[bot]
250
+ - Bump react monorepo (#20340) @renovate[bot]
251
+ - Bump react-hook-form to ^7.66.1 (#20497) @renovate[bot]
252
+ - Bump rimraf to ^6.1.2 (#20498) @renovate[bot]
253
+ - Bump webpack-bundle-analyzer to ^5.0.1 (#20508) @renovate[bot]
254
+ - Bump next to ^15.5.7 [SECURITY] (#20555) @renovate[bot]
255
+
256
+ ## 8.20.0
257
+
258
+ _Nov 26, 2025_
259
+
260
+ We'd like to extend a big thank you to the 8 contributors who made this release possible. Here are some highlights ✨:
261
+
262
+ - 🔃 Data Grid tree data now supports row reordering. See the [Drag-and-drop tree data reordering](https://mui.com/x/react-data-grid/tree-data/#drag-and-drop-tree-data-reordering) section for more details.
263
+ - 🐞 Bugfixes
264
+
265
+ The following team members contributed to this release:
266
+ @alexfauquette, @arminmeh, @bernardobelchior, @cherniavskii, @siriwatknp, @JCQuintas, @MBilalShafi, @prakhargupta1
267
+
268
+ ### Data Grid
269
+
270
+ #### `@mui/x-data-grid@8.20.0`
271
+
272
+ - [DataGrid] Fix RTL virtualization to display columns when viewport width is larger than the grid (#20409) @siriwatknp
273
+ - [DataGrid] Fix row range selection (#20442) @arminmeh
274
+ - [DataGrid] Initialize data grid core packages (#20276) @cherniavskii
275
+ - [DataGrid] Improve accessibility of the sort icon (#20430) @arminmeh
276
+ - [DataGrid] Use `viewport` as a boundary for the `BasePopper` flip (#20311) @arminmeh
277
+
278
+ #### `@mui/x-data-grid-pro@8.20.0` [![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-data-grid@8.20.0`, plus:
281
+
282
+ - [DataGridPro] Avoid automatic scroll back to the focused header filter after it leaves the viewport (#20416) @arminmeh
283
+ - [DataGridPro] Tree data row reordering (#19401) @MBilalShafi
284
+
285
+ #### `@mui/x-data-grid-premium@8.20.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
286
+
287
+ Same changes as in `@mui/x-data-grid-pro@8.20.0`.
288
+
289
+ ### Charts
290
+
291
+ #### `@mui/x-charts@8.20.0`
292
+
293
+ - [charts] Fix item tooltip position with node anchor (#20421) @alexfauquette
294
+ - [charts] Fix radar item tooltip closing bug (#20429) @alexfauquette
295
+ - [charts] Move series processing to selector (#20388) @JCQuintas
296
+ - [charts] Prevent pointer out from removing controlled highlight (#20385) @alexfauquette
297
+
298
+ #### `@mui/x-charts-pro@8.20.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
299
+
300
+ Same changes as in `@mui/x-charts@8.20.0`, plus:
301
+
302
+ - [charts-pro] Fix Content-Security-Policy nonce not being correctly set on export (#20395) @bernardobelchior
303
+ - [charts-pro] Improve vertical zoom slider thumb on mobile (#20439) @bernardobelchior
304
+ - [charts-pro] Provide arguments to the `AreaPlotRoot` styled component (#20414) @arminmeh
305
+ - [charts-pro] Remove grid outside the drawing area (#20412) @alexfauquette
306
+
307
+ #### `@mui/x-charts-premium@8.20.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
308
+
309
+ Same changes as in `@mui/x-charts-pro@8.20.0`, plus:
310
+
311
+ - [charts-premium] Add explicit return type to `ChartsRenderer` for better compatibility with React 18 (#20413) @arminmeh
312
+
313
+ ### Docs
314
+
315
+ - [docs] Add `llms.txt` link to the sidebar (#20312) @siriwatknp
316
+ - [docs] Add a line chart demo for the Overview section (#20239) @prakhargupta1
317
+
8
318
  ## 8.19.0
9
319
 
10
320
  _Nov 20, 2025_
@@ -132,7 +132,7 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
132
132
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
133
133
  // ----------------------------------------------------------------------
134
134
  /**
135
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
135
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useRichTreeViewApiRef()`.
136
136
  */
137
137
  apiRef: _propTypes.default.shape({
138
138
  current: _propTypes.default.shape({
@@ -41,7 +41,7 @@ export interface RichTreeViewProps<R extends {}, Multiple extends boolean | unde
41
41
  */
42
42
  slotProps?: RichTreeViewSlotProps<R, Multiple>;
43
43
  /**
44
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
44
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useRichTreeViewApiRef()`.
45
45
  */
46
46
  apiRef?: RichTreeViewApiRef;
47
47
  }
@@ -113,7 +113,7 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
113
113
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
114
114
  // ----------------------------------------------------------------------
115
115
  /**
116
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
116
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useSimpleTreeViewApiRef()`.
117
117
  */
118
118
  apiRef: _propTypes.default.shape({
119
119
  current: _propTypes.default.shape({
@@ -40,7 +40,7 @@ export interface SimpleTreeViewProps<Multiple extends boolean | undefined> exten
40
40
  */
41
41
  sx?: SxProps<Theme>;
42
42
  /**
43
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
43
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useSimpleTreeViewApiRef()`.
44
44
  */
45
45
  apiRef?: SimpleTreeViewApiRef;
46
46
  }
@@ -125,7 +125,7 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
125
125
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
126
126
  // ----------------------------------------------------------------------
127
127
  /**
128
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
128
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useRichTreeViewApiRef()`.
129
129
  */
130
130
  apiRef: PropTypes.shape({
131
131
  current: PropTypes.shape({
@@ -41,7 +41,7 @@ export interface RichTreeViewProps<R extends {}, Multiple extends boolean | unde
41
41
  */
42
42
  slotProps?: RichTreeViewSlotProps<R, Multiple>;
43
43
  /**
44
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
44
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useRichTreeViewApiRef()`.
45
45
  */
46
46
  apiRef?: RichTreeViewApiRef;
47
47
  }
@@ -106,7 +106,7 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
106
106
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
107
107
  // ----------------------------------------------------------------------
108
108
  /**
109
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
109
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useSimpleTreeViewApiRef()`.
110
110
  */
111
111
  apiRef: PropTypes.shape({
112
112
  current: PropTypes.shape({
@@ -40,7 +40,7 @@ export interface SimpleTreeViewProps<Multiple extends boolean | undefined> exten
40
40
  */
41
41
  sx?: SxProps<Theme>;
42
42
  /**
43
- * The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
43
+ * The ref object that allows Tree View manipulation. Can be instantiated with `useSimpleTreeViewApiRef()`.
44
44
  */
45
45
  apiRef?: SimpleTreeViewApiRef;
46
46
  }
@@ -1,4 +1,6 @@
1
- export { useTreeViewApiRef } from "./useTreeViewApiRef.js";
2
1
  export { useTreeItemUtils } from "./useTreeItemUtils/index.js";
3
2
  export { useTreeItemModel } from "./useTreeItemModel.js";
4
- export { useApplyPropagationToSelectedItemsOnMount } from "./useApplyPropagationToSelectedItemsOnMount.js";
3
+ export { useApplyPropagationToSelectedItemsOnMount } from "./useApplyPropagationToSelectedItemsOnMount.js";
4
+ export { useTreeViewApiRef } from "./useTreeViewApiRef.js";
5
+ export { useRichTreeViewApiRef } from "./useRichTreeViewApiRef.js";
6
+ export { useSimpleTreeViewApiRef } from "./useSimpleTreeViewApiRef.js";
@@ -1,4 +1,6 @@
1
- export { useTreeViewApiRef } from "./useTreeViewApiRef.js";
2
1
  export { useTreeItemUtils } from "./useTreeItemUtils/index.js";
3
2
  export { useTreeItemModel } from "./useTreeItemModel.js";
4
- export { useApplyPropagationToSelectedItemsOnMount } from "./useApplyPropagationToSelectedItemsOnMount.js";
3
+ export { useApplyPropagationToSelectedItemsOnMount } from "./useApplyPropagationToSelectedItemsOnMount.js";
4
+ export { useTreeViewApiRef } from "./useTreeViewApiRef.js";
5
+ export { useRichTreeViewApiRef } from "./useRichTreeViewApiRef.js";
6
+ export { useSimpleTreeViewApiRef } from "./useSimpleTreeViewApiRef.js";
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { TreeViewDefaultItemModelProperties, TreeViewValidItem } from "../models/index.js";
3
+ import { TreeViewPublicAPI } from "../internals/models/index.js";
4
+ import { RichTreeViewPluginSignatures } from "../RichTreeView/RichTreeView.plugins.js";
5
+ /**
6
+ * Creates the ref to pass to the `apiRef` prop of the `RichTreeView` component.
7
+ */
8
+ export declare function useRichTreeViewApiRef<R extends TreeViewValidItem<R> = TreeViewDefaultItemModelProperties>(): React.RefObject<TreeViewPublicAPI<RichTreeViewPluginSignatures> | undefined>;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Creates the ref to pass to the `apiRef` prop of the `RichTreeView` component.
4
+ */
5
+ export function useRichTreeViewApiRef() {
6
+ return React.useRef(undefined);
7
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { TreeViewDefaultItemModelProperties, TreeViewValidItem } from "../models/index.js";
3
+ import { TreeViewPublicAPI } from "../internals/models/index.js";
4
+ import { SimpleTreeViewPluginSignatures } from "../SimpleTreeView/SimpleTreeView.plugins.js";
5
+ /**
6
+ * Creates the ref to pass to the `apiRef` prop of the `SimpleTreeView` component.
7
+ */
8
+ export declare function useSimpleTreeViewApiRef<R extends TreeViewValidItem<R> = TreeViewDefaultItemModelProperties>(): React.RefObject<TreeViewPublicAPI<SimpleTreeViewPluginSignatures> | undefined>;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Creates the ref to pass to the `apiRef` prop of the `SimpleTreeView` component.
4
+ */
5
+ export function useSimpleTreeViewApiRef() {
6
+ return React.useRef(undefined);
7
+ }
@@ -3,5 +3,6 @@ import { TreeViewAnyPluginSignature, TreeViewPublicAPI } from "../internals/mode
3
3
  import { RichTreeViewPluginSignatures } from "../RichTreeView/RichTreeView.plugins.js";
4
4
  /**
5
5
  * Hook that instantiates a [[TreeViewApiRef]].
6
+ * @deprecated Use `useRichTreeViewApiRef`, `useRichTreeViewProApiRef` or `useSimpleTreeViewApiRef` instead.
6
7
  */
7
8
  export declare const useTreeViewApiRef: <TSignatures extends readonly TreeViewAnyPluginSignature[] = RichTreeViewPluginSignatures>() => React.RefObject<TreeViewPublicAPI<TSignatures> | undefined>;
@@ -3,5 +3,6 @@
3
3
  import * as React from 'react';
4
4
  /**
5
5
  * Hook that instantiates a [[TreeViewApiRef]].
6
+ * @deprecated Use `useRichTreeViewApiRef`, `useRichTreeViewProApiRef` or `useSimpleTreeViewApiRef` instead.
6
7
  */
7
8
  export const useTreeViewApiRef = () => React.useRef(undefined);
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v8.19.0
2
+ * @mui/x-tree-view v8.22.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -16,6 +16,7 @@ const RichTreeViewItemsContext = /*#__PURE__*/React.createContext(null);
16
16
  if (process.env.NODE_ENV !== "production") RichTreeViewItemsContext.displayName = "RichTreeViewItemsContext";
17
17
  const EMPTY_ARRAY = [];
18
18
  const selectorNoChildren = () => EMPTY_ARRAY;
19
+ const selectorChildrenIdsNull = state => itemsSelectors.itemOrderedChildrenIds(state, null);
19
20
  const WrappedTreeItem = /*#__PURE__*/React.memo(function WrappedTreeItem({
20
21
  itemSlot,
21
22
  itemSlotProps,
@@ -59,7 +60,7 @@ export function RichTreeViewItems(props) {
59
60
  const itemSlot = slots?.item;
60
61
  const itemSlotProps = slotProps?.item;
61
62
  const domStructure = useStore(store, itemsSelectors.domStructure);
62
- const items = useStore(store, domStructure === 'flat' ? state => expansionSelectors.flatList(state) : state => itemsSelectors.itemOrderedChildrenIds(state, null));
63
+ const items = useStore(store, domStructure === 'flat' ? expansionSelectors.flatList : selectorChildrenIdsNull);
63
64
  const skipChildren = domStructure === 'flat';
64
65
  const renderItem = React.useCallback(itemId => {
65
66
  return /*#__PURE__*/_jsx(WrappedTreeItem, {
@@ -30,10 +30,10 @@ export interface UseTreeViewLazyLoadingPublicAPI {
30
30
  * Method used for updating an item's children.
31
31
  * Only relevant for lazy-loaded tree views.
32
32
  *
33
- * @param {TreeViewItemId} itemId The The id of the item to update the children of.
33
+ * @param {TreeViewItemId | null} itemId The id of the item to update the children of. If null is passed, it will update the root's children.
34
34
  * @returns {Promise<void>} The promise resolved when the items are fetched.
35
35
  */
36
- updateItemChildren: (itemId: TreeViewItemId) => Promise<void>;
36
+ updateItemChildren: (itemId: TreeViewItemId | null) => Promise<void>;
37
37
  }
38
38
  export interface UseTreeViewLazyLoadingInstance extends UseTreeViewLazyLoadingPublicAPI {
39
39
  /**
@@ -4,9 +4,12 @@ export type TreeViewDefaultItemModelProperties = {
4
4
  label: string;
5
5
  children?: TreeViewDefaultItemModelProperties[];
6
6
  };
7
- export type TreeViewBaseItem<R extends {} = TreeViewDefaultItemModelProperties> = R & {
7
+ export type TreeViewBaseItem<R extends object = TreeViewDefaultItemModelProperties> = R & {
8
8
  children?: TreeViewBaseItem<R>[];
9
9
  };
10
+ export type TreeViewValidItem<R extends object> = {
11
+ children?: R[];
12
+ };
10
13
  export type TreeViewItemsReorderingAction = 'reorder-above' | 'reorder-below' | 'make-child' | 'move-to-parent';
11
14
  export interface TreeViewSelectionPropagation {
12
15
  descendants?: boolean;
@@ -15,6 +15,12 @@ import { itemsSelectors } from "../internals/plugins/useTreeViewItems/index.js";
15
15
  import { idSelectors } from "../internals/corePlugins/useTreeViewId/index.js";
16
16
  import { expansionSelectors } from "../internals/plugins/useTreeViewExpansion/index.js";
17
17
  import { selectionSelectors } from "../internals/plugins/useTreeViewSelection/index.js";
18
+ const depthSelector = (state, itemId, depthContext) => {
19
+ if (typeof depthContext === 'function') {
20
+ return depthContext(state, itemId);
21
+ }
22
+ return depthContext;
23
+ };
18
24
  export const useTreeItem = parameters => {
19
25
  const {
20
26
  runItemPlugins,
@@ -23,12 +29,7 @@ export const useTreeItem = parameters => {
23
29
  store
24
30
  } = useTreeViewContext();
25
31
  const depthContext = React.useContext(TreeViewItemDepthContext);
26
- const depth = useStore(store, (...params) => {
27
- if (typeof depthContext === 'function') {
28
- return depthContext(...params);
29
- }
30
- return depthContext;
31
- }, parameters.itemId);
32
+ const depth = useStore(store, depthSelector, parameters.itemId, depthContext);
32
33
  const {
33
34
  id,
34
35
  itemId,
package/hooks/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- export { useTreeViewApiRef } from "./useTreeViewApiRef.js";
2
1
  export { useTreeItemUtils } from "./useTreeItemUtils/index.js";
3
2
  export { useTreeItemModel } from "./useTreeItemModel.js";
4
- export { useApplyPropagationToSelectedItemsOnMount } from "./useApplyPropagationToSelectedItemsOnMount.js";
3
+ export { useApplyPropagationToSelectedItemsOnMount } from "./useApplyPropagationToSelectedItemsOnMount.js";
4
+ export { useTreeViewApiRef } from "./useTreeViewApiRef.js";
5
+ export { useRichTreeViewApiRef } from "./useRichTreeViewApiRef.js";
6
+ export { useSimpleTreeViewApiRef } from "./useSimpleTreeViewApiRef.js";
package/hooks/index.js CHANGED
@@ -9,6 +9,18 @@ Object.defineProperty(exports, "useApplyPropagationToSelectedItemsOnMount", {
9
9
  return _useApplyPropagationToSelectedItemsOnMount.useApplyPropagationToSelectedItemsOnMount;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "useRichTreeViewApiRef", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _useRichTreeViewApiRef.useRichTreeViewApiRef;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "useSimpleTreeViewApiRef", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _useSimpleTreeViewApiRef.useSimpleTreeViewApiRef;
22
+ }
23
+ });
12
24
  Object.defineProperty(exports, "useTreeItemModel", {
13
25
  enumerable: true,
14
26
  get: function () {
@@ -27,7 +39,9 @@ Object.defineProperty(exports, "useTreeViewApiRef", {
27
39
  return _useTreeViewApiRef.useTreeViewApiRef;
28
40
  }
29
41
  });
30
- var _useTreeViewApiRef = require("./useTreeViewApiRef");
31
42
  var _useTreeItemUtils = require("./useTreeItemUtils");
32
43
  var _useTreeItemModel = require("./useTreeItemModel");
33
- var _useApplyPropagationToSelectedItemsOnMount = require("./useApplyPropagationToSelectedItemsOnMount");
44
+ var _useApplyPropagationToSelectedItemsOnMount = require("./useApplyPropagationToSelectedItemsOnMount");
45
+ var _useTreeViewApiRef = require("./useTreeViewApiRef");
46
+ var _useRichTreeViewApiRef = require("./useRichTreeViewApiRef");
47
+ var _useSimpleTreeViewApiRef = require("./useSimpleTreeViewApiRef");
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { TreeViewDefaultItemModelProperties, TreeViewValidItem } from "../models/index.js";
3
+ import { TreeViewPublicAPI } from "../internals/models/index.js";
4
+ import { RichTreeViewPluginSignatures } from "../RichTreeView/RichTreeView.plugins.js";
5
+ /**
6
+ * Creates the ref to pass to the `apiRef` prop of the `RichTreeView` component.
7
+ */
8
+ export declare function useRichTreeViewApiRef<R extends TreeViewValidItem<R> = TreeViewDefaultItemModelProperties>(): React.RefObject<TreeViewPublicAPI<RichTreeViewPluginSignatures> | undefined>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useRichTreeViewApiRef = useRichTreeViewApiRef;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ /**
10
+ * Creates the ref to pass to the `apiRef` prop of the `RichTreeView` component.
11
+ */
12
+ function useRichTreeViewApiRef() {
13
+ return React.useRef(undefined);
14
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { TreeViewDefaultItemModelProperties, TreeViewValidItem } from "../models/index.js";
3
+ import { TreeViewPublicAPI } from "../internals/models/index.js";
4
+ import { SimpleTreeViewPluginSignatures } from "../SimpleTreeView/SimpleTreeView.plugins.js";
5
+ /**
6
+ * Creates the ref to pass to the `apiRef` prop of the `SimpleTreeView` component.
7
+ */
8
+ export declare function useSimpleTreeViewApiRef<R extends TreeViewValidItem<R> = TreeViewDefaultItemModelProperties>(): React.RefObject<TreeViewPublicAPI<SimpleTreeViewPluginSignatures> | undefined>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useSimpleTreeViewApiRef = useSimpleTreeViewApiRef;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ /**
10
+ * Creates the ref to pass to the `apiRef` prop of the `SimpleTreeView` component.
11
+ */
12
+ function useSimpleTreeViewApiRef() {
13
+ return React.useRef(undefined);
14
+ }
@@ -3,5 +3,6 @@ import { TreeViewAnyPluginSignature, TreeViewPublicAPI } from "../internals/mode
3
3
  import { RichTreeViewPluginSignatures } from "../RichTreeView/RichTreeView.plugins.js";
4
4
  /**
5
5
  * Hook that instantiates a [[TreeViewApiRef]].
6
+ * @deprecated Use `useRichTreeViewApiRef`, `useRichTreeViewProApiRef` or `useSimpleTreeViewApiRef` instead.
6
7
  */
7
8
  export declare const useTreeViewApiRef: <TSignatures extends readonly TreeViewAnyPluginSignature[] = RichTreeViewPluginSignatures>() => React.RefObject<TreeViewPublicAPI<TSignatures> | undefined>;
@@ -9,6 +9,7 @@ exports.useTreeViewApiRef = void 0;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  /**
11
11
  * Hook that instantiates a [[TreeViewApiRef]].
12
+ * @deprecated Use `useRichTreeViewApiRef`, `useRichTreeViewProApiRef` or `useSimpleTreeViewApiRef` instead.
12
13
  */
13
14
  const useTreeViewApiRef = () => React.useRef(undefined);
14
15
  exports.useTreeViewApiRef = useTreeViewApiRef;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v8.19.0
2
+ * @mui/x-tree-view v8.22.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -23,6 +23,7 @@ const RichTreeViewItemsContext = /*#__PURE__*/React.createContext(null);
23
23
  if (process.env.NODE_ENV !== "production") RichTreeViewItemsContext.displayName = "RichTreeViewItemsContext";
24
24
  const EMPTY_ARRAY = [];
25
25
  const selectorNoChildren = () => EMPTY_ARRAY;
26
+ const selectorChildrenIdsNull = state => _useTreeViewItems.itemsSelectors.itemOrderedChildrenIds(state, null);
26
27
  const WrappedTreeItem = /*#__PURE__*/React.memo(function WrappedTreeItem({
27
28
  itemSlot,
28
29
  itemSlotProps,
@@ -66,7 +67,7 @@ function RichTreeViewItems(props) {
66
67
  const itemSlot = slots?.item;
67
68
  const itemSlotProps = slotProps?.item;
68
69
  const domStructure = (0, _store.useStore)(store, _useTreeViewItems.itemsSelectors.domStructure);
69
- const items = (0, _store.useStore)(store, domStructure === 'flat' ? state => _useTreeViewExpansion.expansionSelectors.flatList(state) : state => _useTreeViewItems.itemsSelectors.itemOrderedChildrenIds(state, null));
70
+ const items = (0, _store.useStore)(store, domStructure === 'flat' ? _useTreeViewExpansion.expansionSelectors.flatList : selectorChildrenIdsNull);
70
71
  const skipChildren = domStructure === 'flat';
71
72
  const renderItem = React.useCallback(itemId => {
72
73
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedTreeItem, {
@@ -30,10 +30,10 @@ export interface UseTreeViewLazyLoadingPublicAPI {
30
30
  * Method used for updating an item's children.
31
31
  * Only relevant for lazy-loaded tree views.
32
32
  *
33
- * @param {TreeViewItemId} itemId The The id of the item to update the children of.
33
+ * @param {TreeViewItemId | null} itemId The id of the item to update the children of. If null is passed, it will update the root's children.
34
34
  * @returns {Promise<void>} The promise resolved when the items are fetched.
35
35
  */
36
- updateItemChildren: (itemId: TreeViewItemId) => Promise<void>;
36
+ updateItemChildren: (itemId: TreeViewItemId | null) => Promise<void>;
37
37
  }
38
38
  export interface UseTreeViewLazyLoadingInstance extends UseTreeViewLazyLoadingPublicAPI {
39
39
  /**
package/models/items.d.ts CHANGED
@@ -4,9 +4,12 @@ export type TreeViewDefaultItemModelProperties = {
4
4
  label: string;
5
5
  children?: TreeViewDefaultItemModelProperties[];
6
6
  };
7
- export type TreeViewBaseItem<R extends {} = TreeViewDefaultItemModelProperties> = R & {
7
+ export type TreeViewBaseItem<R extends object = TreeViewDefaultItemModelProperties> = R & {
8
8
  children?: TreeViewBaseItem<R>[];
9
9
  };
10
+ export type TreeViewValidItem<R extends object> = {
11
+ children?: R[];
12
+ };
10
13
  export type TreeViewItemsReorderingAction = 'reorder-above' | 'reorder-below' | 'make-child' | 'move-to-parent';
11
14
  export interface TreeViewSelectionPropagation {
12
15
  descendants?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-tree-view",
3
- "version": "8.19.0",
3
+ "version": "8.22.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of the MUI X Tree View components.",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "clsx": "^2.1.1",
39
39
  "prop-types": "^15.8.1",
40
40
  "react-transition-group": "^4.4.5",
41
- "@mui/x-internals": "8.19.0"
41
+ "@mui/x-internals": "8.22.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@emotion/react": "^11.9.0",
@@ -22,6 +22,12 @@ var _useTreeViewItems = require("../internals/plugins/useTreeViewItems");
22
22
  var _useTreeViewId2 = require("../internals/corePlugins/useTreeViewId");
23
23
  var _useTreeViewExpansion = require("../internals/plugins/useTreeViewExpansion");
24
24
  var _useTreeViewSelection = require("../internals/plugins/useTreeViewSelection");
25
+ const depthSelector = (state, itemId, depthContext) => {
26
+ if (typeof depthContext === 'function') {
27
+ return depthContext(state, itemId);
28
+ }
29
+ return depthContext;
30
+ };
25
31
  const useTreeItem = parameters => {
26
32
  const {
27
33
  runItemPlugins,
@@ -30,12 +36,7 @@ const useTreeItem = parameters => {
30
36
  store
31
37
  } = (0, _TreeViewProvider.useTreeViewContext)();
32
38
  const depthContext = React.useContext(_TreeViewItemDepthContext.TreeViewItemDepthContext);
33
- const depth = (0, _store.useStore)(store, (...params) => {
34
- if (typeof depthContext === 'function') {
35
- return depthContext(...params);
36
- }
37
- return depthContext;
38
- }, parameters.itemId);
39
+ const depth = (0, _store.useStore)(store, depthSelector, parameters.itemId, depthContext);
39
40
  const {
40
41
  id,
41
42
  itemId,