@mui/x-tree-view 7.11.1 → 7.12.1

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 (101) hide show
  1. package/CHANGELOG.md +178 -4
  2. package/RichTreeView/RichTreeView.js +9 -4
  3. package/RichTreeView/RichTreeView.types.d.ts +1 -1
  4. package/SimpleTreeView/SimpleTreeView.js +9 -4
  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 +5 -4
  32. package/internals/index.js +3 -2
  33. package/internals/models/index.d.ts +1 -0
  34. package/internals/models/index.js +2 -1
  35. package/internals/models/itemPlugin.d.ts +3 -2
  36. package/internals/models/plugin.d.ts +1 -1
  37. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.d.ts +2 -3
  38. package/internals/plugins/useTreeViewIcons/useTreeViewIcons.types.d.ts +1 -1
  39. package/internals/plugins/useTreeViewItems/index.d.ts +2 -1
  40. package/internals/plugins/useTreeViewItems/index.js +2 -1
  41. package/internals/plugins/useTreeViewItems/useTreeViewItems.js +6 -2
  42. package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +18 -4
  43. package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  44. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +2 -2
  45. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +1 -2
  46. package/internals/useTreeView/useTreeView.types.d.ts +1 -1
  47. package/internals/utils/tree.d.ts +8 -0
  48. package/internals/utils/tree.js +11 -0
  49. package/models/items.d.ts +1 -0
  50. package/modern/RichTreeView/RichTreeView.js +9 -4
  51. package/modern/SimpleTreeView/SimpleTreeView.js +9 -4
  52. package/modern/TreeItem/TreeItem.js +36 -10
  53. package/modern/TreeItem/TreeItemContent.js +11 -3
  54. package/modern/TreeItem/treeItemClasses.js +1 -1
  55. package/modern/TreeItem/useTreeItemState.js +5 -1
  56. package/modern/TreeItem2/TreeItem2.js +15 -3
  57. package/modern/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +69 -0
  58. package/modern/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.types.js +1 -0
  59. package/modern/TreeItem2DragAndDropOverlay/index.js +1 -0
  60. package/modern/TreeItem2Icon/TreeItem2Icon.js +3 -2
  61. package/modern/TreeItem2Provider/TreeItem2Provider.js +1 -1
  62. package/modern/TreeView/TreeView.js +8 -3
  63. package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +1 -1
  64. package/modern/index.js +1 -1
  65. package/modern/internals/TreeViewProvider/index.js +2 -1
  66. package/modern/internals/index.js +3 -2
  67. package/modern/internals/models/index.js +2 -1
  68. package/modern/internals/plugins/useTreeViewItems/index.js +2 -1
  69. package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +6 -2
  70. package/modern/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  71. package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +2 -2
  72. package/modern/internals/utils/tree.js +11 -0
  73. package/modern/useTreeItem2/useTreeItem2.js +43 -15
  74. package/node/RichTreeView/RichTreeView.js +11 -6
  75. package/node/SimpleTreeView/SimpleTreeView.js +10 -5
  76. package/node/TreeItem/TreeItem.js +45 -19
  77. package/node/TreeItem/TreeItemContent.js +11 -3
  78. package/node/TreeItem/treeItemClasses.js +1 -1
  79. package/node/TreeItem/useTreeItemState.js +6 -2
  80. package/node/TreeItem2/TreeItem2.js +21 -9
  81. package/node/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +77 -0
  82. package/node/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.types.js +5 -0
  83. package/node/TreeItem2DragAndDropOverlay/index.js +12 -0
  84. package/node/TreeItem2Icon/TreeItem2Icon.js +6 -5
  85. package/node/TreeItem2Provider/TreeItem2Provider.js +2 -2
  86. package/node/TreeView/TreeView.js +8 -3
  87. package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +2 -2
  88. package/node/index.js +1 -1
  89. package/node/internals/TreeViewProvider/index.js +8 -1
  90. package/node/internals/index.js +25 -0
  91. package/node/internals/models/index.js +11 -0
  92. package/node/internals/plugins/useTreeViewItems/index.js +14 -1
  93. package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +6 -2
  94. package/node/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +2 -2
  95. package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +1 -1
  96. package/node/internals/utils/tree.js +14 -2
  97. package/node/useTreeItem2/useTreeItem2.js +49 -21
  98. package/package.json +11 -4
  99. package/useTreeItem2/index.d.ts +1 -1
  100. package/useTreeItem2/useTreeItem2.js +43 -15
  101. package/useTreeItem2/useTreeItem2.types.d.ts +17 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,180 @@
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.1
7
+
8
+ _Aug 8, 2024_
9
+
10
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🎨 Charts get a new component to display color mapping in the legend
13
+ - 🚀 The `@mui/x-charts-pro` is released in alpha version 🧪. This new package introduces two main features:
14
+ - The Heatmap component
15
+ - The zoom interaction on the bar, line, and scatter charts
16
+ - 🌍 Improve Dutch (nl-NL) locale on the Date and Time Pickers
17
+ - 🐞 Bugfixes
18
+
19
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
20
+
21
+ ### Data Grid
22
+
23
+ #### `@mui/x-data-grid@7.12.1`
24
+
25
+ - [DataGrid] Fix `checkboxSelectionVisibleOnly` behavior with server-side pagination (#14083) @MBilalShafi
26
+ - [DataGrid] Fix `columnHeadersContainerRef` being `undefined` before mount (#14051) @samwato
27
+ - [DataGrid] Support Yarn PnP (#14126) @cherniavskii
28
+
29
+ #### `@mui/x-data-grid-pro@7.12.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
30
+
31
+ Same changes as in `@mui/x-data-grid@7.12.1`.
32
+
33
+ #### `@mui/x-data-grid-premium@7.12.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
34
+
35
+ Same changes as in `@mui/x-data-grid-pro@7.12.1`.
36
+
37
+ ### Date and Time Pickers
38
+
39
+ #### `@mui/x-date-pickers@7.12.1`
40
+
41
+ - [l10n] Improve Dutch (nlNL) locale (pickers) (#14036) @Robin1896
42
+
43
+ #### `@mui/x-date-pickers-pro@7.12.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
44
+
45
+ Same changes as in `@mui/x-date-pickers@7.12.1`.
46
+
47
+ ### Charts
48
+
49
+ #### `@mui/x-charts@7.12.1`
50
+
51
+ - [charts] Fix charts vendor publish config (#14073) @JCQuintas
52
+ - [charts] Move `plugins` to `PluginProvider` (#14056) @JCQuintas
53
+
54
+ #### `@mui/x-date-charts-pro@7.0.0-alpha.0` [![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@7.12.1`, plus:
57
+
58
+ - [charts-pro] Release the pro package in alpha (#13859) @alexfauquette
59
+
60
+ ### Tree View
61
+
62
+ #### `@mui/x-tree-view@7.12.1`
63
+
64
+ ### Docs
65
+
66
+ - [docs] Add a warning to promote the usage of `updateRows` (#14027) @MBilalShafi
67
+ - [docs] Disable ad in `Rich Tree View-Ordering` page (#14123) @oliviertassinari
68
+ - [docs] Redesign Date and Time Pickers overview page (#13241) @noraleonte
69
+
70
+ - [CHANGELOG] Polish details @oliviertassinari
71
+ - [code-infra] Use concurrency 1 in CircleCI (#14110) @JCQuintas
72
+ - [infra] Re-added the removal of `Latest Version` section (#14132) @michelengelen
73
+
74
+ ## 7.12.0
75
+
76
+ _Aug 1, 2024_
77
+
78
+ ### 💵 Our commercial offering is evolving
79
+
80
+ The [Pro plan](https://mui.com/x/introduction/licensing/#pro-plan) is receiving two new packages:
81
+
82
+ - `@mui/x-tree-view-pro` (available today!)
83
+ - `@mui/x-charts-pro` (available in the coming weeks)
84
+
85
+ As always, every feature released as part of the MIT plan will remain free and MIT licensed forever.
86
+
87
+ 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.
88
+
89
+ ### Highlights
90
+
91
+ We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
92
+
93
+ - 🎁 Introduce [item reordering using drag and drop](https://mui.com/x/react-tree-view/rich-tree-view/ordering/) on the `RichTreeViewPro` component
94
+
95
+ <img width="287" src="https://github.com/user-attachments/assets/78bd83c5-7ce4-4ed7-acf9-be70b2dbce54" alt="Item reordering using drag and drop" />
96
+
97
+ - 📦 Support CommonJS bundle out of the box on `@mui/x-charts` by adding vendored D3 dependencies.
98
+
99
+ - 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.
100
+ - For more context, the initial issue is caused by D3 only exporting ESM.
101
+
102
+ ![image](https://github.com/user-attachments/assets/d705b4de-0c93-420e-a416-528e7a044c1d)
103
+
104
+ - The solution up until now was to export charts with only ESM. But some frameworks are confused by this configuration.
105
+
106
+ ![image](https://github.com/user-attachments/assets/18a09703-9dd4-4226-a33d-167af059219c)
107
+
108
+ - So in order to fix this, we are providing a CJS version of D3.
109
+
110
+ ![image](https://github.com/user-attachments/assets/56387fe6-85d8-4750-bb9d-9866d5be68fa)
111
+
112
+ - 🌍 Improve Turkish (tr-TR) locale on the Data Grid
113
+ - 🌍 Improve Finnish (fi-FI) locale on the Date and Time Pickers
114
+ - 🐞 Bugfixes
115
+ - 📚 Documentation improvements
116
+
117
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
118
+
119
+ ### Data Grid
120
+
121
+ #### `@mui/x-data-grid@7.12.0`
122
+
123
+ - [DataGrid] Fix crash when updating columns immediately after scrolling (#13781) @cherniavskii
124
+ - [DataGrid] Fix `role=presentation` a11y issue (#13891) @romgrk
125
+ - [DataGrid] Fix top corner pixels & outline radius (#13943) @romgrk
126
+ - [DataGrid] Refactor: remove useless copy (#14039) @romgrk
127
+ - [l10n] Improve Turkish (tr-TR) locale (#13996) @bagcivan
128
+
129
+ #### `@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')
130
+
131
+ Same changes as in `@mui/x-data-grid@7.12.0`.
132
+
133
+ #### `@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')
134
+
135
+ Same changes as in `@mui/x-data-grid-pro@7.12.0`.
136
+
137
+ ### Date and Time Pickers
138
+
139
+ #### `@mui/x-date-pickers@7.12.0`
140
+
141
+ - [l10n] Improve Finnish (fi-FI) locale (#14054) @frozenzia
142
+
143
+ #### `@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')
144
+
145
+ Same changes as in `@mui/x-date-pickers@7.12.0`.
146
+
147
+ ### Charts
148
+
149
+ #### `@mui/x-charts@7.12.0`
150
+
151
+ - [charts] Fix incorrect `axisId` prop being allowed in xAxis/yAxis config. Use `id` instead. (#13986) @JCQuintas
152
+ - [charts] Use vendor to have Common JS bundle working out of the box (#13608) @alexfauquette
153
+ - [charts] Divide the `SeriesProvider` to use in filtering (#14026) @JCQuintas
154
+
155
+ ### Tree View
156
+
157
+ #### `@mui/x-tree-view@7.12.0`
158
+
159
+ - [TreeView] Add new prop `onItemClick` on the Tree View components (#14018) @flaviendelangle
160
+ - [TreeView] Add new utility function `isEventTargetInDescendants` (#13982) @flaviendelangle
161
+ - [TreeView] Support item reordering using drag and drop (#12213) @flaviendelangle
162
+
163
+ ### Docs
164
+
165
+ - [docs] Add Pickers `minDate` and `maxDate` `default` description (#14024) @LukasTy
166
+ - [docs] Fix 404 (#13989) @alexfauquette
167
+ - [docs] Fix Vale errors (#14025) @oliviertassinari
168
+ - [docs] Update on `renderCell` & autogenerated rows (#13879) @romgrk
169
+
170
+ ### Core
171
+
172
+ - [core] Fix event naming convention @oliviertassinari
173
+ - [core] Replace @mui/base with @mui/utils + @mui/material (#13823) @mnajdova
174
+ - [core] Test `charts` performance with codspeed (#13952) @JCQuintas
175
+ - [infra] Consolidate issue cleanup and support labeling action (#14031) @michelengelen
176
+ - [infra] Revert `vale` action `paths` filtering (#14038) @LukasTy
177
+ - [test] Fix adapters code coverage (#13969) @alexfauquette
178
+ - [test] Fix mocha config to run charts tests (#14041) @alexfauquette
179
+
6
180
  ## 7.11.1
7
181
 
8
182
  _Jul 25, 2024_
@@ -143,8 +317,8 @@ Same changes as in `@mui/x-date-pickers@7.11.0`, plus:
143
317
  - [charts] Defaultize axis on top level `useChartContainerProps` (#13817) @JCQuintas
144
318
  - [charts] Fix charts not passing `className` to root element (#13647) @JCQuintas
145
319
  - [charts] Generate API documentation for pro components (#13822) @alexfauquette
146
- - [charts] Improve zoomed highlight behaviour (unreleased) (#13868) @JCQuintas
147
- - [charts] Allow zoom on Y axis and add zoom options to configure zooming behaviour (unreleased) (#13726) @JCQuintas
320
+ - [charts] Improve zoomed highlight behavior (unreleased) (#13868) @JCQuintas
321
+ - [charts] Allow zoom on Y axis and add zoom options to configure zooming behavior (unreleased) (#13726) @JCQuintas
148
322
  - [charts] Disable animations while zooming (unreleased) (#13807) @JCQuintas
149
323
 
150
324
  ### Tree View
@@ -617,7 +791,7 @@ Same changes as in `@mui/x-date-pickers@7.6.2`.
617
791
 
618
792
  #### `@mui/x-charts@7.6.2`
619
793
 
620
- - [charts] Add `Initializable` type and behaviour to allow checking if a complex context has been initialized. (#13365) @JCQuintas
794
+ - [charts] Add `Initializable` type and behavior to allow checking if a complex context has been initialized. (#13365) @JCQuintas
621
795
  - [charts] Fix some props not working in `xAxis` and `yAxis` (#13372) @Valyok26
622
796
  - [charts] Harmonize charts types (#13366) @alexfauquette
623
797
  - [charts] Introduce plugins system (#13367) @alexfauquette
@@ -625,7 +799,7 @@ Same changes as in `@mui/x-date-pickers@7.6.2`.
625
799
 
626
800
  ### Docs
627
801
 
628
- - [docs] Add badges like in Material UI @oliviertassinari
802
+ - [docs] Add badges like in Material UI @oliviertassinari
629
803
  - [docs] Update twitter.com to x.com @oliviertassinari
630
804
  - [docs] Fix the description of `tickInterval` (#13355) @alexfauquette
631
805
  - [docs] Adjust the code example for `quickFilterValues` (#12919) @michelengelen
@@ -2,7 +2,7 @@ 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';
@@ -241,6 +241,12 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
241
241
  * @param {array} itemIds The ids of the expanded items.
242
242
  */
243
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,
244
250
  /**
245
251
  * Callback fired when a tree item is expanded or collapsed.
246
252
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
@@ -249,10 +255,9 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
249
255
  */
250
256
  onItemExpansionToggle: PropTypes.func,
251
257
  /**
252
- * Callback fired when tree items are focused.
253
- * @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.
254
260
  * @param {string} itemId The id of the focused item.
255
- * @param {string} value of the focused item.
256
261
  */
257
262
  onItemFocus: PropTypes.func,
258
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,7 +2,7 @@ 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';
@@ -177,6 +177,12 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
177
177
  * @param {array} itemIds The ids of the expanded items.
178
178
  */
179
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,
180
186
  /**
181
187
  * Callback fired when a tree item is expanded or collapsed.
182
188
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
@@ -185,10 +191,9 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
185
191
  */
186
192
  onItemExpansionToggle: PropTypes.func,
187
193
  /**
188
- * Callback fired when tree items are focused.
189
- * @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.
190
196
  * @param {string} itemId The id of the focused item.
191
- * @param {string} value of the focused item.
192
197
  */
193
198
  onItemFocus: PropTypes.func,
194
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
  };
@@ -9,13 +9,14 @@ import unsupportedProp from '@mui/utils/unsupportedProp';
9
9
  import { alpha } from '@mui/material/styles';
10
10
  import Collapse from '@mui/material/Collapse';
11
11
  import MuiCheckbox from '@mui/material/Checkbox';
12
- import { useSlotProps } from '@mui/base/utils';
12
+ import useSlotProps from '@mui/utils/useSlotProps';
13
13
  import { shouldForwardProp } from '@mui/system/createStyled';
14
14
  import composeClasses from '@mui/utils/composeClasses';
15
15
  import { styled, createUseThemeProps } from '../internals/zero-styled';
16
16
  import { unstable_useTreeItem2 as useTreeItem2 } from '../useTreeItem2';
17
17
  import { getTreeItemUtilityClass } from '../TreeItem';
18
18
  import { TreeItem2Icon } from '../TreeItem2Icon';
19
+ import { TreeItem2DragAndDropOverlay } from '../TreeItem2DragAndDropOverlay';
19
20
  import { TreeItem2Provider } from '../TreeItem2Provider';
20
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
22
  const useThemeProps = createUseThemeProps('MuiTreeItem2');
@@ -42,6 +43,7 @@ export const TreeItem2Content = styled('div', {
42
43
  width: '100%',
43
44
  boxSizing: 'border-box',
44
45
  // prevent width + padding to overflow
46
+ position: 'relative',
45
47
  display: 'flex',
46
48
  alignItems: 'center',
47
49
  gap: theme.spacing(1),
@@ -176,7 +178,8 @@ const useUtilityClasses = ownerState => {
176
178
  iconContainer: ['iconContainer'],
177
179
  checkbox: ['checkbox'],
178
180
  label: ['label'],
179
- groupTransition: ['groupTransition']
181
+ groupTransition: ['groupTransition'],
182
+ dragAndDropOverlay: ['dragAndDropOverlay']
180
183
  };
181
184
  return composeClasses(slots, getTreeItemUtilityClass, classes);
182
185
  };
@@ -212,6 +215,7 @@ export const TreeItem2 = /*#__PURE__*/React.forwardRef(function TreeItem2(inProp
212
215
  getCheckboxProps,
213
216
  getLabelProps,
214
217
  getGroupTransitionProps,
218
+ getDragAndDropOverlayProps,
215
219
  status
216
220
  } = useTreeItem2({
217
221
  id,
@@ -274,6 +278,14 @@ export const TreeItem2 = /*#__PURE__*/React.forwardRef(function TreeItem2(inProp
274
278
  ownerState: {},
275
279
  className: classes.groupTransition
276
280
  });
281
+ const DragAndDropOverlay = slots.dragAndDropOverlay ?? TreeItem2DragAndDropOverlay;
282
+ const dragAndDropOverlayProps = useSlotProps({
283
+ elementType: DragAndDropOverlay,
284
+ getSlotProps: getDragAndDropOverlayProps,
285
+ externalSlotProps: slotProps.dragAndDropOverlay,
286
+ ownerState: {},
287
+ className: classes.dragAndDropOverlay
288
+ });
277
289
  return /*#__PURE__*/_jsx(TreeItem2Provider, {
278
290
  itemId: itemId,
279
291
  children: /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
@@ -284,7 +296,7 @@ export const TreeItem2 = /*#__PURE__*/React.forwardRef(function TreeItem2(inProp
284
296
  slots: slots,
285
297
  slotProps: slotProps
286
298
  })
287
- })), /*#__PURE__*/_jsx(Checkbox, _extends({}, checkboxProps)), /*#__PURE__*/_jsx(Label, _extends({}, labelProps))]
299
+ })), /*#__PURE__*/_jsx(Checkbox, _extends({}, checkboxProps)), /*#__PURE__*/_jsx(Label, _extends({}, labelProps)), /*#__PURE__*/_jsx(DragAndDropOverlay, _extends({}, dragAndDropOverlayProps))]
288
300
  })), children && /*#__PURE__*/_jsx(TreeItem2GroupTransition, _extends({
289
301
  as: GroupTransition
290
302
  }, groupTransitionProps))]
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/base/utils';
2
+ import { SlotComponentProps } from '@mui/utils';
3
3
  import { UseTreeItem2Parameters, UseTreeItem2Status } from '../useTreeItem2';
4
4
  import { TreeItemClasses } from '../TreeItem';
5
5
  import { TreeItem2IconSlotProps, TreeItem2IconSlots } from '../TreeItem2Icon';
@@ -36,6 +36,12 @@ export interface TreeItem2Slots extends TreeItem2IconSlots {
36
36
  * @default TreeItem2Label
37
37
  */
38
38
  label?: React.ElementType;
39
+ /**
40
+ * The component that renders the overlay when an item reordering is ongoing.
41
+ * Warning: This slot is only useful when using the `RichTreeViewPro` component.
42
+ * @default TreeItem2DragAndDropOverlay
43
+ */
44
+ dragAndDropOverlay?: React.ElementType;
39
45
  }
40
46
  export interface TreeItem2SlotProps extends TreeItem2IconSlotProps {
41
47
  root?: SlotComponentProps<'li', {}, {}>;
@@ -44,6 +50,7 @@ export interface TreeItem2SlotProps extends TreeItem2IconSlotProps {
44
50
  iconContainer?: SlotComponentProps<'div', {}, {}>;
45
51
  checkbox?: SlotComponentProps<'button', {}, {}>;
46
52
  label?: SlotComponentProps<'div', {}, {}>;
53
+ dragAndDropOverlay?: SlotComponentProps<'div', {}, {}>;
47
54
  }
48
55
  export interface TreeItem2Props extends Omit<UseTreeItem2Parameters, 'rootRef'>, Omit<React.HTMLAttributes<HTMLLIElement>, 'onFocus'> {
49
56
  className?: string;
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { TreeItem2DragAndDropOverlayProps } from './TreeItem2DragAndDropOverlay.types';
3
+ declare function TreeItem2DragAndDropOverlay(props: TreeItem2DragAndDropOverlayProps): React.JSX.Element | null;
4
+ export { TreeItem2DragAndDropOverlay };