@mui/x-tree-view 7.11.0 → 7.12.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 (111) hide show
  1. package/CHANGELOG.md +194 -4
  2. package/RichTreeView/RichTreeView.js +11 -7
  3. package/RichTreeView/RichTreeView.types.d.ts +1 -1
  4. package/SimpleTreeView/SimpleTreeView.js +11 -7
  5. package/SimpleTreeView/SimpleTreeView.types.d.ts +1 -1
  6. package/TreeItem/TreeItem.js +36 -10
  7. package/TreeItem/TreeItem.types.d.ts +1 -1
  8. package/TreeItem/TreeItemContent.d.ts +2 -0
  9. package/TreeItem/TreeItemContent.js +11 -3
  10. package/TreeItem/treeItemClasses.d.ts +2 -0
  11. package/TreeItem/treeItemClasses.js +1 -1
  12. package/TreeItem/useTreeItemState.d.ts +1 -0
  13. package/TreeItem/useTreeItemState.js +5 -1
  14. package/TreeItem2/TreeItem2.js +15 -3
  15. package/TreeItem2/TreeItem2.types.d.ts +8 -1
  16. package/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.d.ts +4 -0
  17. package/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +69 -0
  18. package/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.types.d.ts +6 -0
  19. package/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.types.js +1 -0
  20. package/TreeItem2DragAndDropOverlay/index.d.ts +2 -0
  21. package/TreeItem2DragAndDropOverlay/index.js +1 -0
  22. package/TreeItem2DragAndDropOverlay/package.json +6 -0
  23. package/TreeItem2Icon/TreeItem2Icon.js +3 -2
  24. package/TreeItem2Icon/TreeItem2Icon.types.d.ts +1 -1
  25. package/TreeItem2Provider/TreeItem2Provider.js +1 -1
  26. package/TreeView/TreeView.js +8 -3
  27. package/hooks/useTreeItem2Utils/useTreeItem2Utils.js +1 -1
  28. package/index.js +1 -1
  29. package/internals/TreeViewProvider/index.d.ts +1 -0
  30. package/internals/TreeViewProvider/index.js +2 -1
  31. package/internals/index.d.ts +6 -5
  32. package/internals/index.js +4 -3
  33. package/internals/models/index.d.ts +2 -0
  34. package/internals/models/index.js +3 -1
  35. package/internals/models/itemPlugin.d.ts +37 -0
  36. package/internals/models/itemPlugin.js +1 -0
  37. package/internals/models/plugin.d.ts +2 -15
  38. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.d.ts +2 -3
  39. package/internals/plugins/useTreeViewIcons/useTreeViewIcons.types.d.ts +1 -1
  40. package/internals/plugins/useTreeViewItems/index.d.ts +2 -1
  41. package/internals/plugins/useTreeViewItems/index.js +2 -1
  42. package/internals/plugins/useTreeViewItems/useTreeViewItems.js +6 -2
  43. package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +18 -4
  44. package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  45. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +2 -2
  46. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +1 -2
  47. package/internals/useTreeView/useTreeView.types.d.ts +1 -1
  48. package/internals/useTreeView/useTreeViewBuildContext.js +23 -1
  49. package/internals/utils/tree.d.ts +8 -0
  50. package/internals/utils/tree.js +11 -0
  51. package/internals/utils/warning.d.ts +2 -1
  52. package/internals/utils/warning.js +19 -12
  53. package/models/items.d.ts +1 -0
  54. package/modern/RichTreeView/RichTreeView.js +11 -7
  55. package/modern/SimpleTreeView/SimpleTreeView.js +11 -7
  56. package/modern/TreeItem/TreeItem.js +36 -10
  57. package/modern/TreeItem/TreeItemContent.js +11 -3
  58. package/modern/TreeItem/treeItemClasses.js +1 -1
  59. package/modern/TreeItem/useTreeItemState.js +5 -1
  60. package/modern/TreeItem2/TreeItem2.js +15 -3
  61. package/modern/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +69 -0
  62. package/modern/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.types.js +1 -0
  63. package/modern/TreeItem2DragAndDropOverlay/index.js +1 -0
  64. package/modern/TreeItem2Icon/TreeItem2Icon.js +3 -2
  65. package/modern/TreeItem2Provider/TreeItem2Provider.js +1 -1
  66. package/modern/TreeView/TreeView.js +8 -3
  67. package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +1 -1
  68. package/modern/index.js +1 -1
  69. package/modern/internals/TreeViewProvider/index.js +2 -1
  70. package/modern/internals/index.js +4 -3
  71. package/modern/internals/models/index.js +3 -1
  72. package/modern/internals/models/itemPlugin.js +1 -0
  73. package/modern/internals/plugins/useTreeViewItems/index.js +2 -1
  74. package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +6 -2
  75. package/modern/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  76. package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +2 -2
  77. package/modern/internals/useTreeView/useTreeViewBuildContext.js +23 -1
  78. package/modern/internals/utils/tree.js +11 -0
  79. package/modern/internals/utils/warning.js +19 -12
  80. package/modern/useTreeItem2/useTreeItem2.js +43 -15
  81. package/node/RichTreeView/RichTreeView.js +12 -8
  82. package/node/SimpleTreeView/SimpleTreeView.js +11 -7
  83. package/node/TreeItem/TreeItem.js +45 -19
  84. package/node/TreeItem/TreeItemContent.js +11 -3
  85. package/node/TreeItem/treeItemClasses.js +1 -1
  86. package/node/TreeItem/useTreeItemState.js +6 -2
  87. package/node/TreeItem2/TreeItem2.js +21 -9
  88. package/node/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +77 -0
  89. package/node/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.types.js +5 -0
  90. package/node/TreeItem2DragAndDropOverlay/index.js +12 -0
  91. package/node/TreeItem2Icon/TreeItem2Icon.js +6 -5
  92. package/node/TreeItem2Provider/TreeItem2Provider.js +2 -2
  93. package/node/TreeView/TreeView.js +8 -3
  94. package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +2 -2
  95. package/node/index.js +1 -1
  96. package/node/internals/TreeViewProvider/index.js +8 -1
  97. package/node/internals/index.js +27 -2
  98. package/node/internals/models/index.js +22 -0
  99. package/node/internals/models/itemPlugin.js +5 -0
  100. package/node/internals/plugins/useTreeViewItems/index.js +14 -1
  101. package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +6 -2
  102. package/node/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +2 -2
  103. package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +1 -1
  104. package/node/internals/useTreeView/useTreeViewBuildContext.js +23 -1
  105. package/node/internals/utils/tree.js +14 -2
  106. package/node/internals/utils/warning.js +21 -14
  107. package/node/useTreeItem2/useTreeItem2.js +49 -21
  108. package/package.json +5 -6
  109. package/useTreeItem2/index.d.ts +1 -1
  110. package/useTreeItem2/useTreeItem2.js +43 -15
  111. package/useTreeItem2/useTreeItem2.types.d.ts +17 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,196 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.12.0
7
+
8
+ _Aug 1, 2024_
9
+
10
+ ### 💵 Our commercial offering is evolving
11
+
12
+ The [Pro plan](https://mui.com/x/introduction/licensing/#pro-plan) is receiving two new packages:
13
+
14
+ - `@mui/x-tree-view-pro` (available today!)
15
+ - `@mui/x-charts-pro` (available in the coming weeks)
16
+
17
+ As always, every feature released as part of the MIT plan will remain free and MIT licensed forever.
18
+
19
+ This expansion of the Pro plan comes with some adjustments to our pricing strategy. Learn more about those in the [Upcoming changes to MUI X pricing in 2024](https://mui.com/blog/mui-x-sep-2024-price-update/) blog post.
20
+
21
+ ### Highlights
22
+
23
+ We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
24
+
25
+ - 🎁 Introduce [item reordering using drag and drop](https://mui.com/x/react-tree-view/rich-tree-view/ordering/) on the `RichTreeViewPro` component
26
+
27
+ <img width="384" src="https://github.com/user-attachments/assets/78bd83c5-7ce4-4ed7-acf9-be70b2dbce54" alt="Item reordering using drag and drop" />
28
+
29
+ - 📦 Support Common JS bundle out of the box on `@mui/x-charts` by adding vendored D3 dependencies.
30
+
31
+ - This modifies how the package imports D3.js. It will impact you if you use `d3` packages installed by `@mui/x-charts` and don't have them in your `package.json`. You shouldn't be affected otherwise.
32
+ - For more context, the initial issue is caused by D3 only exporting ESM.
33
+
34
+ ![image](https://github.com/user-attachments/assets/d705b4de-0c93-420e-a416-528e7a044c1d)
35
+
36
+ - The solution up until now was to export charts with only ESM. But some frameworks are confused by this configuration.
37
+
38
+ ![image](https://github.com/user-attachments/assets/18a09703-9dd4-4226-a33d-167af059219c)
39
+
40
+ - So in order to fix this, we are providing a CJS version of D3.
41
+
42
+ ![image](https://github.com/user-attachments/assets/56387fe6-85d8-4750-bb9d-9866d5be68fa)
43
+
44
+ - 🌍 Improve Turkish (tr-TR) locale on the Data Grid
45
+ - 🌍 Improve Finnish (fi-FI) locale on the Date and Time Pickers
46
+ - 🐞 Bugfixes
47
+ - 📚 Documentation improvements
48
+
49
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
50
+
51
+ ### Data Grid
52
+
53
+ #### `@mui/x-data-grid@7.12.0`
54
+
55
+ - [DataGrid] Fix crash when updating columns immediately after scrolling (#13781) @cherniavskii
56
+ - [DataGrid] Fix `role=presentation` a11y issue (#13891) @romgrk
57
+ - [DataGrid] Fix top corner pixels & outline radius (#13943) @romgrk
58
+ - [DataGrid] Refactor: remove useless copy (#14039) @romgrk
59
+ - [l10n] Improve Turkish (tr-TR) locale (#13996) @bagcivan
60
+
61
+ #### `@mui/x-data-grid-pro@7.12.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
62
+
63
+ Same changes as in `@mui/x-data-grid@7.12.0`.
64
+
65
+ #### `@mui/x-data-grid-premium@7.12.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
66
+
67
+ Same changes as in `@mui/x-data-grid-pro@7.12.0`.
68
+
69
+ ### Date and Time Pickers
70
+
71
+ #### `@mui/x-date-pickers@7.12.0`
72
+
73
+ - [l10n] Improve Finnish (fi-FI) locale (#14054) @frozenzia
74
+
75
+ #### `@mui/x-date-pickers-pro@7.12.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
76
+
77
+ Same changes as in `@mui/x-date-pickers@7.12.0`.
78
+
79
+ ### Charts
80
+
81
+ #### `@mui/x-charts@7.12.0`
82
+
83
+ - [charts] Fix incorrect `axisId` prop being allowed in xAxis/yAxis config. Use `id` instead. (#13986) @JCQuintas
84
+ - [charts] Use vendor to have Common JS bundle working out of the box (#13608) @alexfauquette
85
+ - [charts] Divide the `SeriesProvider` to use in filtering (#14026) @JCQuintas
86
+
87
+ ### Tree View
88
+
89
+ #### `@mui/x-tree-view@7.12.0`
90
+
91
+ - [TreeView] Add new prop `onItemClick` on the Tree View components (#14018) @flaviendelangle
92
+ - [TreeView] Add new utility function `isEventTargetInDescendants` (#13982) @flaviendelangle
93
+ - [TreeView] Support item reordering using drag and drop (#12213) @flaviendelangle
94
+
95
+ ### Docs
96
+
97
+ - [docs] Add Pickers `minDate` and `maxDate` `default` description (#14024) @LukasTy
98
+ - [docs] Fix 404 (#13989) @alexfauquette
99
+ - [docs] Fix Vale errors (#14025) @oliviertassinari
100
+ - [docs] Update on `renderCell` & autogenerated rows (#13879) @romgrk
101
+
102
+ ### Core
103
+
104
+ - [core] Fix event naming convention @oliviertassinari
105
+ - [core] Replace @mui/base with @mui/utils + @mui/material (#13823) @mnajdova
106
+ - [core] Test `charts` performance with codspeed (#13952) @JCQuintas
107
+ - [infra] Consolidate issue cleanup and support labeling action (#14031) @michelengelen
108
+ - [infra] Revert `vale` action `paths` filtering (#14038) @LukasTy
109
+ - [test] Fix adapters code coverage (#13969) @alexfauquette
110
+ - [test] Fix mocha config to run charts tests (#14041) @alexfauquette
111
+
112
+ ## 7.11.1
113
+
114
+ _Jul 25, 2024_
115
+
116
+ We'd like to offer a big thanks to the 18 contributors who made this release possible. Here are some highlights ✨:
117
+
118
+ - 🔎 Allow `Zoom` to be controllable for charts (#13858) @JCQuintas
119
+ - 🌍 Add Icelandic (is-IS) and Norwegian Nynorsk (nn-NO) locales on the Data Grid
120
+ - 🌍 Improve Norwegian Bokmål (nb-NO) and German (de-DE) locales on the Data Grid
121
+ - 🌍 Add Norwegian Nynorsk (nn-NO) locale on the Date and Time Pickers
122
+ - 🐞 Bugfixes
123
+ - 📚 Documentation improvements
124
+
125
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
126
+
127
+ ### Data Grid
128
+
129
+ #### `@mui/x-data-grid@7.11.1`
130
+
131
+ - [DataGrid] Remove dead code in internal `GridPreferencesPanel` (#13934) @k-rajat19
132
+ - [DataGrid] Do not miss to escape formulas in CSV export (#13888) @arminmeh
133
+ - [l10n] Add Icelandic (is-IS) locale (#13283) @magnimarels
134
+ - [l10n] Add Norwegian nynorsk (nn-NO) locale and improve Norwegian bokmål (nb-NO) locale (#13588) @AnderzL7
135
+ - [l10n] Improve German (de-DE) locale (#13910) @lhilgert9
136
+
137
+ #### `@mui/x-data-grid-pro@7.11.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
138
+
139
+ Same changes as in `@mui/x-data-grid@7.11.1`.
140
+
141
+ #### `@mui/x-data-grid-premium@7.11.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
142
+
143
+ Same changes as in `@mui/x-data-grid-pro@7.11.1`, plus:
144
+
145
+ - [DataGridPremium] Pass the `api` object to events (#13893) @pcorpet
146
+ - [DataGridPremium] Fix paste to selected cells (#13967) @romgrk
147
+
148
+ ### Date and Time Pickers
149
+
150
+ #### `@mui/x-date-pickers@7.11.1`
151
+
152
+ - [fields] Prevent keyboard editing when disabled (#13900) @arthurbalduini
153
+ - [l10n] Add Norwegian Nynorsk (nn-NO) locale (#13946) @AnderzL7
154
+
155
+ #### `@mui/x-date-pickers-pro@7.11.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
156
+
157
+ Same changes as in `@mui/x-date-pickers@7.11.1`.
158
+
159
+ ### Charts
160
+
161
+ #### `@mui/x-charts@7.11.1`
162
+
163
+ - [charts] Add `ownerState` function to `slotProps` typing when available (#13965) @alexfauquette
164
+ - [charts] Allow `Zoom` to be controllable (#13858) @JCQuintas
165
+ - [charts] Deprecate `xAxisKey` /`zAxisKey` in favor of `xAxisId`/`zAxisId` (#13940) @alexfauquette
166
+ - [charts] Hide empty arcs in the PieChart (#13897) @alexfauquette
167
+ - [charts] Limit the trigger of exit charts (#13682) @alexfauquette
168
+
169
+ ### Tree View
170
+
171
+ #### `@mui/x-tree-view@7.11.1`
172
+
173
+ - [TreeView] Allow the plugins to enrich the props passed to the item slots (#13953) @flaviendelangle
174
+
175
+ ### Docs
176
+
177
+ - [docs] Bump pnpm priority as a package manager (#13894) @oliviertassinari
178
+ - [docs] Explicitly mark charts pro as not released (#13905) @alexfauquette
179
+ - [docs] Fix dot consistency a11y table @oliviertassinari
180
+ - [docs] Fix some typos in charts docs (#13906) @cratiu222
181
+ - [docs] Fix spelling (#13902) @nnsW3
182
+ - [docs] Improve error message when moving between plans (#13874) @oliviertassinari
183
+ - [docs] Update `SparkLineChart` reference not being correctly capitalised (#13960) @duckboy81
184
+ - [docs] Fix scroll demos disorientation (#13909) @oliviertassinari
185
+
186
+ ### Core
187
+
188
+ - [core] Add `@mui/material-nextjs` to `MUI Core` renovate group (#13966) @LukasTy
189
+ - [core] Remove warning message in production (#13911) @oliviertassinari
190
+ - [code-infra] Reuse `useReactVersion` script from the monorepo (#13710) @cherniavskii
191
+ - [infra] Adds order id validation action (#13957) @michelengelen
192
+ - [infra] Fix order id validator action (#13971) @michelengelen
193
+ - [infra] Fix regex in order id validation (#13976) @michelengelen
194
+ - [infra] Issue template improvement (#13954) @michelengelen
195
+
6
196
  ## 7.11.0
7
197
 
8
198
  _Jul 18, 2024_
@@ -59,8 +249,8 @@ Same changes as in `@mui/x-date-pickers@7.11.0`, plus:
59
249
  - [charts] Defaultize axis on top level `useChartContainerProps` (#13817) @JCQuintas
60
250
  - [charts] Fix charts not passing `className` to root element (#13647) @JCQuintas
61
251
  - [charts] Generate API documentation for pro components (#13822) @alexfauquette
62
- - [charts] Improve zoomed highlight behaviour (unreleased) (#13868) @JCQuintas
63
- - [charts] Allow zoom on Y axis and add zoom options to configure zooming behaviour (unreleased) (#13726) @JCQuintas
252
+ - [charts] Improve zoomed highlight behavior (unreleased) (#13868) @JCQuintas
253
+ - [charts] Allow zoom on Y axis and add zoom options to configure zooming behavior (unreleased) (#13726) @JCQuintas
64
254
  - [charts] Disable animations while zooming (unreleased) (#13807) @JCQuintas
65
255
 
66
256
  ### Tree View
@@ -533,7 +723,7 @@ Same changes as in `@mui/x-date-pickers@7.6.2`.
533
723
 
534
724
  #### `@mui/x-charts@7.6.2`
535
725
 
536
- - [charts] Add `Initializable` type and behaviour to allow checking if a complex context has been initialized. (#13365) @JCQuintas
726
+ - [charts] Add `Initializable` type and behavior to allow checking if a complex context has been initialized. (#13365) @JCQuintas
537
727
  - [charts] Fix some props not working in `xAxis` and `yAxis` (#13372) @Valyok26
538
728
  - [charts] Harmonize charts types (#13366) @alexfauquette
539
729
  - [charts] Introduce plugins system (#13367) @alexfauquette
@@ -541,7 +731,7 @@ Same changes as in `@mui/x-date-pickers@7.6.2`.
541
731
 
542
732
  ### Docs
543
733
 
544
- - [docs] Add badges like in Material UI @oliviertassinari
734
+ - [docs] Add badges like in Material UI @oliviertassinari
545
735
  - [docs] Update twitter.com to x.com @oliviertassinari
546
736
  - [docs] Fix the description of `tickInterval` (#13355) @alexfauquette
547
737
  - [docs] Adjust the code example for `quickFilterValues` (#12919) @michelengelen
@@ -2,14 +2,14 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import composeClasses from '@mui/utils/composeClasses';
5
- import { useSlotProps } from '@mui/base/utils';
5
+ import useSlotProps from '@mui/utils/useSlotProps';
6
6
  import { getRichTreeViewUtilityClass } from './richTreeViewClasses';
7
7
  import { styled, createUseThemeProps } from '../internals/zero-styled';
8
8
  import { useTreeView } from '../internals/useTreeView';
9
9
  import { TreeViewProvider } from '../internals/TreeViewProvider';
10
10
  import { RICH_TREE_VIEW_PLUGINS } from './RichTreeView.plugins';
11
11
  import { TreeItem } from '../TreeItem';
12
- import { buildWarning } from '../internals/utils/warning';
12
+ import { warnOnce } from '../internals/utils/warning';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const useThemeProps = createUseThemeProps('MuiRichTreeView');
15
15
  const useUtilityClasses = ownerState => {
@@ -58,7 +58,6 @@ function WrappedTreeItem({
58
58
  children: children
59
59
  }));
60
60
  }
61
- const childrenWarning = buildWarning(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/']);
62
61
 
63
62
  /**
64
63
  *
@@ -77,7 +76,7 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
77
76
  });
78
77
  if (process.env.NODE_ENV !== 'production') {
79
78
  if (props.children != null) {
80
- childrenWarning();
79
+ warnOnce(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/.']);
81
80
  }
82
81
  }
83
82
  const {
@@ -242,6 +241,12 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
242
241
  * @param {array} itemIds The ids of the expanded items.
243
242
  */
244
243
  onExpandedItemsChange: PropTypes.func,
244
+ /**
245
+ * Callback fired when the `content` slot of a given tree item is clicked.
246
+ * @param {React.MouseEvent} event The DOM event that triggered the change.
247
+ * @param {string} itemId The id of the focused item.
248
+ */
249
+ onItemClick: PropTypes.func,
245
250
  /**
246
251
  * Callback fired when a tree item is expanded or collapsed.
247
252
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
@@ -250,10 +255,9 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
250
255
  */
251
256
  onItemExpansionToggle: PropTypes.func,
252
257
  /**
253
- * Callback fired when tree items are focused.
254
- * @param {React.SyntheticEvent} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
258
+ * Callback fired when a given tree item is focused.
259
+ * @param {React.SyntheticEvent | null} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
255
260
  * @param {string} itemId The id of the focused item.
256
- * @param {string} value of the focused item.
257
261
  */
258
262
  onItemFocus: PropTypes.func,
259
263
  /**
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Theme } from '@mui/material/styles';
3
3
  import { SxProps } from '@mui/system';
4
- import { SlotComponentProps } from '@mui/base/utils';
4
+ import { SlotComponentProps } from '@mui/utils';
5
5
  import { RichTreeViewClasses } from './richTreeViewClasses';
6
6
  import { RichTreeViewPluginParameters, RichTreeViewPluginSlotProps, RichTreeViewPluginSlots, RichTreeViewPluginSignatures } from './RichTreeView.plugins';
7
7
  import { TreeItemProps } from '../TreeItem';
@@ -2,13 +2,13 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import composeClasses from '@mui/utils/composeClasses';
5
- import { useSlotProps } from '@mui/base/utils';
5
+ import useSlotProps from '@mui/utils/useSlotProps';
6
6
  import { styled, createUseThemeProps } from '../internals/zero-styled';
7
7
  import { getSimpleTreeViewUtilityClass } from './simpleTreeViewClasses';
8
8
  import { useTreeView } from '../internals/useTreeView';
9
9
  import { TreeViewProvider } from '../internals/TreeViewProvider';
10
10
  import { SIMPLE_TREE_VIEW_PLUGINS } from './SimpleTreeView.plugins';
11
- import { buildWarning } from '../internals/utils/warning';
11
+ import { warnOnce } from '../internals/utils/warning';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const useThemeProps = createUseThemeProps('MuiSimpleTreeView');
14
14
  const useUtilityClasses = ownerState => {
@@ -32,7 +32,6 @@ export const SimpleTreeViewRoot = styled('ul', {
32
32
  position: 'relative'
33
33
  });
34
34
  const EMPTY_ITEMS = [];
35
- const itemsPropWarning = buildWarning(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/']);
36
35
 
37
36
  /**
38
37
  *
@@ -52,7 +51,7 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
52
51
  const ownerState = props;
53
52
  if (process.env.NODE_ENV !== 'production') {
54
53
  if (props.items != null) {
55
- itemsPropWarning();
54
+ warnOnce(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/.']);
56
55
  }
57
56
  }
58
57
  const {
@@ -178,6 +177,12 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
178
177
  * @param {array} itemIds The ids of the expanded items.
179
178
  */
180
179
  onExpandedItemsChange: PropTypes.func,
180
+ /**
181
+ * Callback fired when the `content` slot of a given tree item is clicked.
182
+ * @param {React.MouseEvent} event The DOM event that triggered the change.
183
+ * @param {string} itemId The id of the focused item.
184
+ */
185
+ onItemClick: PropTypes.func,
181
186
  /**
182
187
  * Callback fired when a tree item is expanded or collapsed.
183
188
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
@@ -186,10 +191,9 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
186
191
  */
187
192
  onItemExpansionToggle: PropTypes.func,
188
193
  /**
189
- * Callback fired when tree items are focused.
190
- * @param {React.SyntheticEvent} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
194
+ * Callback fired when a given tree item is focused.
195
+ * @param {React.SyntheticEvent | null} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
191
196
  * @param {string} itemId The id of the focused item.
192
- * @param {string} value of the focused item.
193
197
  */
194
198
  onItemFocus: PropTypes.func,
195
199
  /**
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Theme } from '@mui/material/styles';
3
- import { SlotComponentProps } from '@mui/base/utils';
3
+ import { SlotComponentProps } from '@mui/utils';
4
4
  import { SxProps } from '@mui/system';
5
5
  import { SimpleTreeViewClasses } from './simpleTreeViewClasses';
6
6
  import { SimpleTreeViewPluginParameters, SimpleTreeViewPluginSlotProps, SimpleTreeViewPluginSlots, SimpleTreeViewPluginSignatures } from './SimpleTreeView.plugins';
@@ -8,17 +8,19 @@ import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import Collapse from '@mui/material/Collapse';
11
- import { resolveComponentProps, useSlotProps } from '@mui/base/utils';
12
11
  import useForkRef from '@mui/utils/useForkRef';
13
12
  import { shouldForwardProp } from '@mui/system/createStyled';
14
13
  import { alpha } from '@mui/material/styles';
14
+ import composeClasses from '@mui/utils/composeClasses';
15
+ import extractEventHandlers from '@mui/utils/extractEventHandlers';
16
+ import resolveComponentProps from '@mui/utils/resolveComponentProps';
17
+ import useSlotProps from '@mui/utils/useSlotProps';
15
18
  import unsupportedProp from '@mui/utils/unsupportedProp';
16
19
  import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
17
- import { unstable_composeClasses as composeClasses } from '@mui/base';
18
20
  import { styled, createUseThemeProps } from '../internals/zero-styled';
19
21
  import { TreeItemContent } from './TreeItemContent';
20
22
  import { treeItemClasses, getTreeItemUtilityClass } from './treeItemClasses';
21
- import { useTreeViewContext } from '../internals/TreeViewProvider/useTreeViewContext';
23
+ import { useTreeViewContext } from '../internals/TreeViewProvider';
22
24
  import { TreeViewCollapseIcon, TreeViewExpandIcon } from '../icons';
23
25
  import { TreeItem2Provider } from '../TreeItem2Provider';
24
26
  import { TreeViewItemDepthContext } from '../internals/TreeViewItemDepthContext';
@@ -72,6 +74,7 @@ const StyledTreeItemContent = styled(TreeItemContent, {
72
74
  width: '100%',
73
75
  boxSizing: 'border-box',
74
76
  // prevent width + padding to overflow
77
+ position: 'relative',
75
78
  display: 'flex',
76
79
  alignItems: 'center',
77
80
  gap: theme.spacing(1),
@@ -166,14 +169,16 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
166
169
  const {
167
170
  icons: contextIcons,
168
171
  runItemPlugins,
172
+ items: {
173
+ disabledItemsFocusable,
174
+ indentationAtItemLevel
175
+ },
169
176
  selection: {
170
177
  multiSelect
171
178
  },
172
179
  expansion: {
173
180
  expansionTrigger
174
181
  },
175
- disabledItemsFocusable,
176
- indentationAtItemLevel,
177
182
  instance
178
183
  } = useTreeViewContext();
179
184
  const depthContext = React.useContext(TreeViewItemDepthContext);
@@ -206,10 +211,13 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
206
211
  } = useTreeItemState(itemId);
207
212
  const {
208
213
  contentRef,
209
- rootRef
214
+ rootRef,
215
+ propsEnhancers
210
216
  } = runItemPlugins(props);
211
- const handleRootRef = useForkRef(inRef, rootRef);
212
- const handleContentRef = useForkRef(ContentProps?.ref, contentRef);
217
+ const rootRefObject = React.useRef(null);
218
+ const contentRefObject = React.useRef(null);
219
+ const handleRootRef = useForkRef(inRef, rootRef, rootRefObject);
220
+ const handleContentRef = useForkRef(ContentProps?.ref, contentRef, contentRefObject);
213
221
  const slots = {
214
222
  expandIcon: inSlots?.expandIcon ?? contextIcons.slots.expandIcon ?? TreeViewExpandIcon,
215
223
  collapseIcon: inSlots?.collapseIcon ?? contextIcons.slots.collapseIcon ?? TreeViewCollapseIcon,
@@ -317,6 +325,21 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
317
325
  };
318
326
  const idAttribute = instance.getTreeItemIdAttribute(itemId, id);
319
327
  const tabIndex = instance.canItemBeTabbed(itemId) ? 0 : -1;
328
+ const enhancedRootProps = propsEnhancers.root?.({
329
+ rootRefObject,
330
+ contentRefObject,
331
+ externalEventHandlers: extractEventHandlers(other)
332
+ }) ?? {};
333
+ const enhancedContentProps = propsEnhancers.content?.({
334
+ rootRefObject,
335
+ contentRefObject,
336
+ externalEventHandlers: extractEventHandlers(ContentProps)
337
+ }) ?? {};
338
+ const enhancedDragAndDropOverlayProps = propsEnhancers.dragAndDropOverlay?.({
339
+ rootRefObject,
340
+ contentRefObject,
341
+ externalEventHandlers: {}
342
+ }) ?? {};
320
343
  return /*#__PURE__*/_jsx(TreeItem2Provider, {
321
344
  itemId: itemId,
322
345
  children: /*#__PURE__*/_jsxs(TreeItemRoot, _extends({
@@ -335,7 +358,8 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
335
358
  ref: handleRootRef,
336
359
  style: indentationAtItemLevel ? _extends({}, other.style, {
337
360
  '--TreeView-itemDepth': typeof depthContext === 'function' ? depthContext(itemId) : depthContext
338
- }) : other.style,
361
+ }) : other.style
362
+ }, enhancedRootProps, {
339
363
  children: [/*#__PURE__*/_jsx(StyledTreeItemContent, _extends({
340
364
  as: ContentComponent,
341
365
  classes: {
@@ -356,7 +380,9 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
356
380
  expansionIcon: expansionIcon,
357
381
  displayIcon: displayIcon,
358
382
  ownerState: ownerState
359
- }, ContentProps, {
383
+ }, ContentProps, enhancedContentProps, enhancedDragAndDropOverlayProps.action == null ? {} : {
384
+ dragAndDropOverlayProps: enhancedDragAndDropOverlayProps
385
+ }, {
360
386
  ref: handleContentRef
361
387
  })), children && /*#__PURE__*/_jsx(TreeItemGroup, _extends({
362
388
  as: GroupTransition
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Theme } from '@mui/material/styles';
3
- import { SlotComponentProps } from '@mui/base/utils';
3
+ import { SlotComponentProps } from '@mui/utils';
4
4
  import { TransitionProps } from '@mui/material/transitions';
5
5
  import { SxProps } from '@mui/system';
6
6
  import { TreeItemContentProps } from './TreeItemContent';
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { TreeItem2DragAndDropOverlayProps } from '../TreeItem2DragAndDropOverlay';
2
3
  export interface TreeItemContentProps extends React.HTMLAttributes<HTMLElement> {
3
4
  className?: string;
4
5
  /**
@@ -42,6 +43,7 @@ export interface TreeItemContentProps extends React.HTMLAttributes<HTMLElement>
42
43
  * The icon to display next to the tree item's label. Either a parent or end icon.
43
44
  */
44
45
  displayIcon?: React.ReactNode;
46
+ dragAndDropOverlayProps?: TreeItem2DragAndDropOverlayProps;
45
47
  }
46
48
  export type TreeItemContentClassKey = keyof NonNullable<TreeItemContentProps['classes']>;
47
49
  /**
@@ -1,11 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["classes", "className", "displayIcon", "expansionIcon", "icon", "label", "itemId", "onClick", "onMouseDown"];
3
+ const _excluded = ["classes", "className", "displayIcon", "expansionIcon", "icon", "label", "itemId", "onClick", "onMouseDown", "dragAndDropOverlayProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
7
7
  import Checkbox from '@mui/material/Checkbox';
8
8
  import { useTreeItemState } from './useTreeItemState';
9
+ import { TreeItem2DragAndDropOverlay } from '../TreeItem2DragAndDropOverlay';
9
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
11
  /**
11
12
  * @ignore - internal component.
@@ -20,7 +21,8 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
20
21
  label,
21
22
  itemId,
22
23
  onClick,
23
- onMouseDown
24
+ onMouseDown,
25
+ dragAndDropOverlayProps
24
26
  } = props,
25
27
  other = _objectWithoutPropertiesLoose(props, _excluded);
26
28
  const {
@@ -33,6 +35,7 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
33
35
  handleExpansion,
34
36
  handleSelection,
35
37
  handleCheckboxSelection,
38
+ handleContentClick,
36
39
  preventSelection,
37
40
  expansionTrigger
38
41
  } = useTreeItemState(itemId);
@@ -45,6 +48,7 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
45
48
  }
46
49
  };
47
50
  const handleClick = event => {
51
+ handleContentClick?.(event, itemId);
48
52
  if (checkboxRef.current?.contains(event.target)) {
49
53
  return;
50
54
  }
@@ -79,7 +83,7 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
79
83
  }), /*#__PURE__*/_jsx("div", {
80
84
  className: classes.label,
81
85
  children: label
82
- })]
86
+ }), dragAndDropOverlayProps && /*#__PURE__*/_jsx(TreeItem2DragAndDropOverlay, _extends({}, dragAndDropOverlayProps))]
83
87
  }))
84
88
  );
85
89
  });
@@ -97,6 +101,10 @@ process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
97
101
  * The icon to display next to the tree item's label. Either a parent or end icon.
98
102
  */
99
103
  displayIcon: PropTypes.node,
104
+ dragAndDropOverlayProps: PropTypes.shape({
105
+ action: PropTypes.oneOf(['make-child', 'move-to-parent', 'reorder-above', 'reorder-below']),
106
+ style: PropTypes.object
107
+ }),
100
108
  /**
101
109
  * The icon to display next to the tree item's label. Either an expansion or collapse icon.
102
110
  */
@@ -19,6 +19,8 @@ export interface TreeItemClasses {
19
19
  label: string;
20
20
  /** Styles applied to the checkbox element. */
21
21
  checkbox: string;
22
+ /** Styles applied to the drag and drop overlay. */
23
+ dragAndDropOverlay: string;
22
24
  }
23
25
  export type TreeItemClassKey = keyof TreeItemClasses;
24
26
  export declare function getTreeItemUtilityClass(slot: string): string;
@@ -3,4 +3,4 @@ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
3
3
  export function getTreeItemUtilityClass(slot) {
4
4
  return generateUtilityClass('MuiTreeItem', slot);
5
5
  }
6
- export const treeItemClasses = generateUtilityClasses('MuiTreeItem', ['root', 'groupTransition', 'content', 'expanded', 'selected', 'focused', 'disabled', 'iconContainer', 'label', 'checkbox']);
6
+ export const treeItemClasses = generateUtilityClasses('MuiTreeItem', ['root', 'groupTransition', 'content', 'expanded', 'selected', 'focused', 'disabled', 'iconContainer', 'label', 'checkbox', 'dragAndDropOverlay']);
@@ -9,6 +9,7 @@ export declare function useTreeItemState(itemId: string): {
9
9
  handleExpansion: (event: React.MouseEvent<HTMLDivElement>) => void;
10
10
  handleSelection: (event: React.MouseEvent) => void;
11
11
  handleCheckboxSelection: (event: React.ChangeEvent<HTMLInputElement>) => void;
12
+ handleContentClick: ((event: React.MouseEvent, itemId: string) => void) | undefined;
12
13
  preventSelection: (event: React.MouseEvent<HTMLDivElement>) => void;
13
14
  expansionTrigger: "content" | "iconContainer" | undefined;
14
15
  };
@@ -1,7 +1,10 @@
1
- import { useTreeViewContext } from '../internals/TreeViewProvider/useTreeViewContext';
1
+ import { useTreeViewContext } from '../internals/TreeViewProvider';
2
2
  export function useTreeItemState(itemId) {
3
3
  const {
4
4
  instance,
5
+ items: {
6
+ onItemClick
7
+ },
5
8
  selection: {
6
9
  multiSelect,
7
10
  checkboxSelection,
@@ -86,6 +89,7 @@ export function useTreeItemState(itemId) {
86
89
  handleExpansion,
87
90
  handleSelection,
88
91
  handleCheckboxSelection,
92
+ handleContentClick: onItemClick,
89
93
  preventSelection,
90
94
  expansionTrigger
91
95
  };