@mui/x-tree-view 7.19.0 → 7.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,96 @@
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.20.0
7
+
8
+ _Oct 11, 2024_
9
+
10
+ We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 📚 Updated ["What's new"](https://mui.com/x/whats-new/) page giving more detailed overview of the latest new features and other highlights
13
+ - 📚 New [collapsible column groups demo](https://mui.com/x/react-data-grid/column-groups/#collapsible-column-groups) for the Data Grid component
14
+ - 📚 New [Tree Item Customization](https://mui.com/x/react-tree-view/tree-item-customization/) documentation to learn how to use the new APIs to create custom Tree Items. The old APIs (`props.ContentComponent` and `props.ContentProps`) have been deprecated and will be removed in the new major version of the Tree View component.
15
+ - 🌍 Improve Japanese (ja-JP) locale on the Data Grid component
16
+ - 🐞 Bugfixes
17
+ - 📚 Other documentation improvements
18
+
19
+ Special thanks go out to the community contributors who have helped make this release possible:
20
+ @k-rajat19, @kalyan90, @uma-neko, @vfbiby.
21
+ Following are all team members who have contributed to this release: @alelthomas, @arminmeh, @arthurbalduini,
22
+ @cherniavskii, @flaviendelangle, @JCQuintas, @MBilalShafi, @noraleonte, @oliviertassinari, @samuelsycamore, @siriwatknp.
23
+
24
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
25
+
26
+ ### Data Grid
27
+
28
+ #### `@mui/x-data-grid@7.20.0`
29
+
30
+ - [DataGrid] Add `onColumnHeaderContextMenu` event (#14734) @vfbiby
31
+ - [DataGrid] Avoid row spanning computation of outdated rows (#14902) @MBilalShafi
32
+ - [DataGrid] Fix scrollbar position not being updated after `scrollToIndexes` (#14888) @arminmeh
33
+ - [DataGrid] Pass `rowId` param to `processRowUpdate` (#14821) @k-rajat19
34
+ - [l10n] Improve Japanese (ja-JP) locale (#14870) @uma-neko
35
+
36
+ #### `@mui/x-data-grid-pro@7.20.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
37
+
38
+ Same changes as in `@mui/x-data-grid@7.20.0`, plus:
39
+
40
+ - [DataGridPro] Fix wording on the `rowSelectionPropagation` JSDoc and doc section (#14907) @flaviendelangle
41
+
42
+ #### `@mui/x-data-grid-premium@7.20.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
43
+
44
+ Same changes as in `@mui/x-data-grid-pro@7.20.0`.
45
+
46
+ ### Date and Time Pickers
47
+
48
+ #### `@mui/x-date-pickers@7.20.0`
49
+
50
+ - [pickers] Add `PageUp` and `PageDown` support for time components (#14812) @arthurbalduini
51
+ - [pickers] Fix regression on `PickerValidDate` (#14896) @flaviendelangle
52
+ - [pickers] Move the `DateFieldInPickerProps` interface to the `DatePicker` folder and rename it `DatePickerFieldProps` (same for time and date time) (#14828) @flaviendelangle
53
+
54
+ #### `@mui/x-date-pickers-pro@7.20.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-date-pickers@7.20.0`.
57
+
58
+ ### Charts
59
+
60
+ #### `@mui/x-charts@7.20.0`
61
+
62
+ No changes since `@mui/x-charts@v7.19.0`.
63
+
64
+ #### `@mui/x-charts-pro@7.0.0-beta.4` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
65
+
66
+ Same changes as in `@mui/x-charts@7.20.0`.
67
+
68
+ ### Tree View
69
+
70
+ #### `@mui/x-tree-view@7.20.0`
71
+
72
+ - [TreeItem] Deprecate the `ContentComponent` and `ContentProps` props (#14908) @flaviendelangle
73
+ - [TreeView] Rework how items are being rendered in Rich Tree View components (#14749) @flaviendelangle
74
+
75
+ ### Docs
76
+
77
+ - [docs] Update "What's new" page (#14858) @cherniavskii
78
+ - [docs] Add collapsible column groups demo (#14818) @cherniavskii
79
+ - [docs] Add custom columns panel demo (#14825) @cherniavskii
80
+ - [docs] Capitalize all instances of "Data Grid" (#14884) @samuelsycamore
81
+ - [docs] Divide charts `tooltip` and `highlighting` pages (#14824) @JCQuintas
82
+ - [docs] Document the `TreeItem2` component and the `useTreeItem2` hook (#14551) @noraleonte
83
+ - [docs] Fix column pinning for "Disable detail panel content scroll" section (#14854 and #14885) @kalyan90
84
+ - [docs] Fix detail panel demo not working well with pinned columns (#14883) @cherniavskii
85
+ - [docs] New recipe of a read-only field (#14606) @flaviendelangle
86
+ - [docs] Change demo name example (#14822) @alelthomas
87
+
88
+ ### Core
89
+
90
+ - [core] Support `@mui/utils` v6 (#14867) @siriwatknp
91
+ - [code-infra] Remove deprecated `data-mui-test` in favour of `data-testid` (#14882) @JCQuintas
92
+ - [code-infra] Update renovate config and add a `vitest` group (#14856) @JCQuintas
93
+ - [test] Replace `waitFor()` with `act()` (#14851) @oliviertassinari
94
+ - [test] Restore "pnpm tc" CLI (#14852) @oliviertassinari
95
+
6
96
  ## 7.19.0
7
97
 
8
98
  _Oct 4, 2024_
@@ -90,13 +180,13 @@ Same changes as in `@mui/x-charts@7.19.0`.
90
180
 
91
181
  - [TreeView] Apply experimental features in `getDefaultizedParams` instead of in the plugin render (#14661) @flaviendelangle
92
182
  - [TreeView] Export `publicAPI` form `useTreeItem2Utils` (#14729) @noraleonte
93
- - [TreeView] Fix cursor navigation interfering with browser shortcut keys (#14798) @sai6855
183
+ - [TreeView] Fix cursor navigation interfering with browser shortcut keys (#14798) @sai6855
94
184
  - [TreeView] Fix invalid test for items reordering (#14665) @flaviendelangle
95
185
  - [TreeView] Remove `instance.getTreeItemIdAttribute` (#14667) @flaviendelangle
96
186
 
97
187
  ### Docs
98
188
 
99
- - [docs] Added warning callout for Firefox reordering bug (#14516) @michelengelen
189
+ - [docs] Added warning callout for Firefox reordering bug (#14516) @michelengelen
100
190
  - [docs] Copyedit `pages.ts` navigation (#14782) @samuelsycamore
101
191
  - [docs] Fix typo in row spanning doc (#14770) @flaviendelangle
102
192
  - [docs] Fix typo in the Tree View migration guide to v7 (#14727) @Sanderand
@@ -121,7 +211,7 @@ We'd like to offer a big thanks to the 14 contributors who made this release pos
121
211
 
122
212
  - 💫 Support [Row spanning](https://mui.com/x/react-data-grid/row-spanning/) on the Data Grid that automatically merges the consecutive cells in a column based on the cell value
123
213
 
124
- <img width="600" src="https://github.com/user-attachments/assets/d32ec936-d238-4c92-9e1a-af6788d74cdf" alt="data grid row spanning" />
214
+ <img width="600" src="https://github.com/user-attachments/assets/d32ec936-d238-4c92-9e1a-af6788d74cdf" alt="Data Grid row spanning" />
125
215
 
126
216
  - ⏰ Support `date-fns` v4 (#14673) @LukasTy
127
217
  - 🎉 Add option for Pickers to change the order of displayed years (#11780) @thomasmoon
@@ -560,7 +650,7 @@ We'd like to offer a big thanks to the 12 contributors who made this release pos
560
650
  #### `@mui/x-data-grid@7.13.0`
561
651
 
562
652
  - [DataGrid] Fix CSV export for `null` and `undefined` values (#14166) @k-rajat19
563
- - [DataGrid] Fix error logged during skeleton loading with nested data grid (#14186) @KenanYusuf
653
+ - [DataGrid] Fix error logged during skeleton loading with nested Data Grid (#14186) @KenanYusuf
564
654
  - [DataGrid] Remove needless check in `useGridStateInitialization` (#14181) @k-rajat19
565
655
  - [DataGrid] Add recipe for persisting filters in local storage (#14208) @cherniavskii
566
656
  - [l10n] Improve Vietnamese (vi-VN) locale (#14216) @hungnd-casso
@@ -678,6 +768,8 @@ Same changes as in `@mui/x-charts@7.12.1`, plus:
678
768
 
679
769
  #### `@mui/x-tree-view@7.12.1`
680
770
 
771
+ No changes since `@mui/x-tree-view@7.12.0`.
772
+
681
773
  ### Docs
682
774
 
683
775
  - [docs] Add a warning to promote the usage of `updateRows` (#14027) @MBilalShafi
@@ -1528,7 +1620,7 @@ Same changes as in `@mui/x-date-pickers@7.6.0`.
1528
1620
  - [docs] Fix a small typo in property comment (#13245) @Janpot
1529
1621
  - [docs] Improve the Data Grid FAQ page (#13258) @MBilalShafi
1530
1622
  - [docs] Removes unused lines in TreeItem2 styling (#13264) @arthurbalduini
1531
- - [docs] Small improvements on accessibility data grid doc (#13233) @arthurbalduini
1623
+ - [docs] Small improvements on accessibility Data Grid doc (#13233) @arthurbalduini
1532
1624
  - [docs] Update Pickers demo configurations (#13303) @LukasTy
1533
1625
 
1534
1626
  ### Core
@@ -1542,7 +1634,7 @@ Same changes as in `@mui/x-date-pickers@7.6.0`.
1542
1634
  - [test] Use test-utils from npm (#12880) @michaldudak
1543
1635
  - [typescript] Remove duplicate `DateRangePosition` type in favor of `RangePosition` (#13288) @LukasTy
1544
1636
 
1545
- ## v7.5.1
1637
+ ## 7.5.1
1546
1638
 
1547
1639
  _May 23, 2024_
1548
1640
 
@@ -1602,7 +1694,7 @@ Same changes as in `@mui/x-date-pickers@7.5.1`.
1602
1694
  - [code-infra] Run corepack enable on all CI jobs (#13205) @Janpot
1603
1695
  - [code-infra] Use `nx` for lerna tasks (#13166) @LukasTy
1604
1696
 
1605
- ## v7.5.0
1697
+ ## 7.5.0
1606
1698
 
1607
1699
  _May 17, 2024_
1608
1700
 
@@ -2127,7 +2219,7 @@ Same changes as in `@mui/x-date-pickers@7.1.1`, plus:
2127
2219
  - [docs] Fix typo in `getItemId` prop description (#12637) @flaviendelangle
2128
2220
  - [docs] Make the Charts `margin` usage more visible (#12591) @alexfauquette
2129
2221
  - [docs] Match IE 11 spacing with Material UI @oliviertassinari
2130
- - [docs] Move data grid interfaces to standard API page layout (#12016) @alexfauquette
2222
+ - [docs] Move Data Grid interfaces to standard API page layout (#12016) @alexfauquette
2131
2223
  - [docs] Remove ` around @default values (#12158) @alexfauquette
2132
2224
  - [docs] Remove `day` from the default `dayOfWeekFormatter` function params (#12644) @LukasTy
2133
2225
  - [docs] Use `TreeItem2` for icon expansion example on `RichTreeView` (#12563) @flaviendelangle
@@ -3568,7 +3660,7 @@ Same changes as in `@mui/x-date-pickers@7.0.0-alpha.9`.
3568
3660
  - [docs] Fix generated tree view API docs (#11737) @LukasTy
3569
3661
  - [docs] Generate docs for Tree View slots (#11730) @flaviendelangle
3570
3662
  - [docs] Improve codemod for v7 (#11650) @oliviertassinari
3571
- - [docs] Improve data grid `pageSizeOptions` prop documentation (#11682) @oliviertassinari
3663
+ - [docs] Improve Data Grid `pageSizeOptions` prop documentation (#11682) @oliviertassinari
3572
3664
  - [docs] Parse markdown on API docs demo titles (#11728) @LukasTy
3573
3665
  - [docs] Remove the description from the `className` prop (#11693) @oliviertassinari
3574
3666
  - [docs] Uplift `SimpleTreeView` customization examples (#11424) @noraleonte
@@ -3656,8 +3748,8 @@ Same changes as in `@mui/x-date-pickers@7.0.0-alpha.8`.
3656
3748
  - [docs] Fix parsing of `x-date-pickers-pro` demo adapter imports (#11628) @LukasTy
3657
3749
  - [docs] Improve `git diff` format @oliviertassinari
3658
3750
  - [docs] Push up the MUI X brand (#11533) @oliviertassinari
3659
- - [docs] Remove old data grid translation files (#11646) @cherniavskii
3660
- - [docs] Improve Server-side data grid docs (#11589) @oliviertassinari
3751
+ - [docs] Remove old Data Grid translation files (#11646) @cherniavskii
3752
+ - [docs] Improve Server-side Data Grid docs (#11589) @oliviertassinari
3661
3753
  - [docs] Improve charts landing page (#11570) @oliviertassinari
3662
3754
 
3663
3755
  ### Core
@@ -4167,7 +4259,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
4167
4259
 
4168
4260
  - The clipboard related exports `ignoreValueFormatterDuringExport` and `splitClipboardPastedText` are no longer prefixed with `unstable_`.
4169
4261
 
4170
- - The deprecated constants `SUBMIT_FILTER_STROKE_TIME` and `SUBMIT_FILTER_DATE_STROKE_TIME` have been removed from the `DataGrid` exports. Use the [`filterDebounceMs`](https://next.mui.com/x/api/data-grid/data-grid/#data-grid-prop-filterDebounceMs) prop to customize filter debounce time.
4262
+ - The deprecated constants `SUBMIT_FILTER_STROKE_TIME` and `SUBMIT_FILTER_DATE_STROKE_TIME` have been removed from the Data Grid exports. Use the [`filterDebounceMs`](https://next.mui.com/x/api/data-grid/data-grid/#data-grid-prop-filterDebounceMs) prop to customize filter debounce time.
4171
4263
 
4172
4264
  - The `slots.preferencesPanel` slot and the `slotProps.preferencesPanel` prop were removed. Use `slots.panel` and `slotProps.panel` instead.
4173
4265
 
@@ -4879,7 +4971,7 @@ A special shoutout to thank the 12 contributors who made this release possible.
4879
4971
  - 🚀 First v7 alpha release
4880
4972
  - ✨ Fix aggregation label not showing when `renderHeader` is used (#10961) @cherniavskii
4881
4973
  - 📘 Server side data source [early documentation](https://mui.com/x/react-data-grid/server-side-data/)
4882
- - 💫 New recipes added for the data grid
4974
+ - 💫 New recipes added for the Data Grid
4883
4975
  - 📈 `<ChartsReferenceLine />` component is now available
4884
4976
  - 🌍 Add Basque (eu) locale, improve Czech (cs-CZ) and Spanish (es-ES) locales
4885
4977
  - 🐞 Bugfixes
@@ -11,7 +11,7 @@ import { styled, createUseThemeProps } from "../internals/zero-styled/index.js";
11
11
  import { useTreeView } from "../internals/useTreeView/index.js";
12
12
  import { TreeViewProvider } from "../internals/TreeViewProvider/index.js";
13
13
  import { RICH_TREE_VIEW_PLUGINS } from "./RichTreeView.plugins.js";
14
- import { TreeItem } from "../TreeItem/index.js";
14
+ import { RichTreeViewItems } from "../internals/components/RichTreeViewItems.js";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  const useThemeProps = createUseThemeProps('MuiRichTreeView');
17
17
  const useUtilityClasses = ownerState => {
@@ -34,33 +34,6 @@ export const RichTreeViewRoot = styled('ul', {
34
34
  outline: 0,
35
35
  position: 'relative'
36
36
  });
37
- function WrappedTreeItem({
38
- slots,
39
- slotProps,
40
- label,
41
- id,
42
- itemId,
43
- children
44
- }) {
45
- const Item = slots?.item ?? TreeItem;
46
- const itemProps = useSlotProps({
47
- elementType: Item,
48
- externalSlotProps: slotProps?.item,
49
- additionalProps: {
50
- itemId,
51
- id,
52
- label
53
- },
54
- ownerState: {
55
- itemId,
56
- label
57
- }
58
- });
59
- return /*#__PURE__*/_jsx(Item, _extends({}, itemProps, {
60
- children: children
61
- }));
62
- }
63
-
64
37
  /**
65
38
  *
66
39
  * Demos:
@@ -103,26 +76,14 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
103
76
  getSlotProps: getRootProps,
104
77
  ownerState: props
105
78
  });
106
- const itemsToRender = instance.getItemsToRender();
107
- const renderItem = ({
108
- label,
109
- itemId,
110
- id,
111
- children
112
- }) => {
113
- return /*#__PURE__*/_jsx(WrappedTreeItem, {
114
- slots: slots,
115
- slotProps: slotProps,
116
- label: label,
117
- id: id,
118
- itemId: itemId,
119
- children: children?.map(renderItem)
120
- }, itemId);
121
- };
122
79
  return /*#__PURE__*/_jsx(TreeViewProvider, {
123
80
  value: contextValue,
124
81
  children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
125
- children: itemsToRender.map(renderItem)
82
+ children: /*#__PURE__*/_jsx(RichTreeViewItems, {
83
+ slots: slots,
84
+ slotProps: slotProps,
85
+ itemsToRender: instance.getItemsToRender()
86
+ })
126
87
  }))
127
88
  });
128
89
  });
@@ -19,6 +19,7 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
19
19
  import useSlotProps from '@mui/utils/useSlotProps';
20
20
  import unsupportedProp from '@mui/utils/unsupportedProp';
21
21
  import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
22
+ import { warnOnce } from '@mui/x-internals/warning';
22
23
  import { styled, createUseThemeProps } from "../internals/zero-styled/index.js";
23
24
  import { TreeItemContent } from "./TreeItemContent.js";
24
25
  import { treeItemClasses, getTreeItemUtilityClass } from "./treeItemClasses.js";
@@ -220,6 +221,15 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
220
221
  handleCancelItemLabelEditing,
221
222
  handleSaveItemLabel
222
223
  } = useTreeItemState(itemId);
224
+ if (process.env.NODE_ENV !== 'production') {
225
+ // Checking directly the `props` to avoid having the default value applied
226
+ if (props.ContentComponent) {
227
+ warnOnce(['MUI X: The ContentComponent prop of the TreeItem component is deprecated and will be removed in the next major release.', 'You can use the new TreeItem2 component or the new useTreeItem2 hook to customize the rendering of the content.', 'For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.']);
228
+ }
229
+ if (props.ContentProps) {
230
+ warnOnce(['MUI X: The ContentProps prop of the TreeItem component is deprecated and will be removed in the next major release.', 'You can use the new TreeItem2 component or the new useTreeItem2 hook to customize the rendering of the content.', 'For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.']);
231
+ }
232
+ }
223
233
  const {
224
234
  contentRef,
225
235
  rootRef,
@@ -442,11 +452,13 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
442
452
  className: PropTypes.string,
443
453
  /**
444
454
  * The component used to render the content of the item.
455
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
445
456
  * @default TreeItemContent
446
457
  */
447
458
  ContentComponent: elementTypeAcceptingRef,
448
459
  /**
449
460
  * Props applied to ContentComponent.
461
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
450
462
  */
451
463
  ContentProps: PropTypes.object,
452
464
  /**
@@ -66,11 +66,13 @@ export interface TreeItemProps extends Omit<React.HTMLAttributes<HTMLLIElement>,
66
66
  slotProps?: TreeItemSlotProps;
67
67
  /**
68
68
  * The component used to render the content of the item.
69
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
69
70
  * @default TreeItemContent
70
71
  */
71
72
  ContentComponent?: React.JSXElementConstructor<TreeItemContentProps>;
72
73
  /**
73
74
  * Props applied to ContentComponent.
75
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
74
76
  */
75
77
  ContentProps?: React.HTMLAttributes<HTMLElement> & {
76
78
  ref?: React.Ref<HTMLElement>;
@@ -73,35 +73,31 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
73
73
  }
74
74
  toggleItemEditing();
75
75
  };
76
- return (
77
- /*#__PURE__*/
78
- /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */
79
- _jsxs("div", _extends({}, other, {
80
- className: clsx(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
81
- onClick: handleClick,
82
- onMouseDown: handleMouseDown,
83
- ref: ref,
84
- children: [/*#__PURE__*/_jsx("div", {
85
- className: classes.iconContainer,
86
- children: icon
87
- }), checkboxSelection && /*#__PURE__*/_jsx(Checkbox, {
88
- className: classes.checkbox,
89
- checked: selected,
90
- onChange: handleCheckboxSelection,
91
- disabled: disabled || disableSelection,
92
- ref: checkboxRef,
93
- tabIndex: -1
94
- }), editing ? /*#__PURE__*/_jsx(TreeItem2LabelInput, _extends({}, labelInputProps, {
95
- className: classes.labelInput
96
- })) : /*#__PURE__*/_jsx("div", _extends({
97
- className: classes.label
98
- }, editable && {
99
- onDoubleClick: handleLabelDoubleClick
100
- }, {
101
- children: label
102
- })), dragAndDropOverlayProps && /*#__PURE__*/_jsx(TreeItem2DragAndDropOverlay, _extends({}, dragAndDropOverlayProps))]
103
- }))
104
- );
76
+ return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */_jsxs("div", _extends({}, other, {
77
+ className: clsx(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
78
+ onClick: handleClick,
79
+ onMouseDown: handleMouseDown,
80
+ ref: ref,
81
+ children: [/*#__PURE__*/_jsx("div", {
82
+ className: classes.iconContainer,
83
+ children: icon
84
+ }), checkboxSelection && /*#__PURE__*/_jsx(Checkbox, {
85
+ className: classes.checkbox,
86
+ checked: selected,
87
+ onChange: handleCheckboxSelection,
88
+ disabled: disabled || disableSelection,
89
+ ref: checkboxRef,
90
+ tabIndex: -1
91
+ }), editing ? /*#__PURE__*/_jsx(TreeItem2LabelInput, _extends({}, labelInputProps, {
92
+ className: classes.labelInput
93
+ })) : /*#__PURE__*/_jsx("div", _extends({
94
+ className: classes.label
95
+ }, editable && {
96
+ onDoubleClick: handleLabelDoubleClick
97
+ }, {
98
+ children: label
99
+ })), dragAndDropOverlayProps && /*#__PURE__*/_jsx(TreeItem2DragAndDropOverlay, _extends({}, dragAndDropOverlayProps))]
100
+ }));
105
101
  });
106
102
  process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
107
103
  // ----------------------------- Warning --------------------------------
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.19.0
2
+ * @mui/x-tree-view v7.20.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ import { SlotComponentProps } from '@mui/utils';
3
+ import { TreeItem, TreeItemProps } from '../../TreeItem';
4
+ import { TreeItem2Props } from '../../TreeItem2';
5
+ import { TreeViewItemId } from '../../models';
6
+ import { TreeViewItemToRenderProps } from '../plugins/useTreeViewItems';
7
+ interface RichTreeViewItemsOwnerState {
8
+ itemId: TreeViewItemId;
9
+ label: string;
10
+ }
11
+ export interface RichTreeViewItemsSlots {
12
+ /**
13
+ * Custom component for the item.
14
+ * @default TreeItem.
15
+ */
16
+ item?: React.JSXElementConstructor<TreeItemProps> | React.JSXElementConstructor<TreeItem2Props>;
17
+ }
18
+ export interface RichTreeViewItemsSlotProps {
19
+ item?: SlotComponentProps<typeof TreeItem, {}, RichTreeViewItemsOwnerState>;
20
+ }
21
+ export interface RichTreeViewItemsProps {
22
+ itemsToRender: TreeViewItemToRenderProps[];
23
+ /**
24
+ * Overridable component slots.
25
+ * @default {}
26
+ */
27
+ slots?: RichTreeViewItemsSlots;
28
+ /**
29
+ * The props used for each component slot.
30
+ * @default {}
31
+ */
32
+ slotProps?: RichTreeViewItemsSlotProps;
33
+ }
34
+ export declare function RichTreeViewItems(props: RichTreeViewItemsProps): React.JSX.Element;
35
+ export {};
@@ -0,0 +1,56 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["ownerState"];
4
+ import * as React from 'react';
5
+ import useSlotProps from '@mui/utils/useSlotProps';
6
+ import { TreeItem } from "../../TreeItem/index.js";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ function WrappedTreeItem({
9
+ slots,
10
+ slotProps,
11
+ label,
12
+ id,
13
+ itemId,
14
+ itemsToRender
15
+ }) {
16
+ const Item = slots?.item ?? TreeItem;
17
+ const _useSlotProps = useSlotProps({
18
+ elementType: Item,
19
+ externalSlotProps: slotProps?.item,
20
+ additionalProps: {
21
+ itemId,
22
+ id,
23
+ label
24
+ },
25
+ ownerState: {
26
+ itemId,
27
+ label
28
+ }
29
+ }),
30
+ itemProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded);
31
+ const children = React.useMemo(() => itemsToRender ? /*#__PURE__*/_jsx(RichTreeViewItems, {
32
+ itemsToRender: itemsToRender,
33
+ slots: slots,
34
+ slotProps: slotProps
35
+ }) : null, [itemsToRender, slots, slotProps]);
36
+ return /*#__PURE__*/_jsx(Item, _extends({}, itemProps, {
37
+ children: children
38
+ }));
39
+ }
40
+ export function RichTreeViewItems(props) {
41
+ const {
42
+ itemsToRender,
43
+ slots,
44
+ slotProps
45
+ } = props;
46
+ return /*#__PURE__*/_jsx(React.Fragment, {
47
+ children: itemsToRender.map(item => /*#__PURE__*/_jsx(WrappedTreeItem, {
48
+ slots: slots,
49
+ slotProps: slotProps,
50
+ label: item.label,
51
+ id: item.id,
52
+ itemId: item.itemId,
53
+ itemsToRender: item.children
54
+ }, item.itemId))
55
+ });
56
+ }
@@ -1,5 +1,6 @@
1
1
  export { useTreeView } from './useTreeView';
2
2
  export { TreeViewProvider, useTreeViewContext } from './TreeViewProvider';
3
+ export { RichTreeViewItems } from './components/RichTreeViewItems';
3
4
  export { unstable_resetCleanupTracking } from './hooks/useInstanceEventHandler';
4
5
  export type { TreeViewPlugin, TreeViewPluginSignature, ConvertPluginsIntoSignatures, MergeSignaturesProperty, TreeViewPublicAPI, TreeViewExperimentalFeatures, TreeViewItemMeta, TreeViewInstance, DefaultizedProps, TreeViewItemPlugin, MuiCancellableEvent, MuiCancellableEventHandler, } from './models';
5
6
  export type { TreeViewCorePluginParameters } from './corePlugins';
@@ -1,5 +1,6 @@
1
1
  export { useTreeView } from "./useTreeView/index.js";
2
2
  export { TreeViewProvider, useTreeViewContext } from "./TreeViewProvider/index.js";
3
+ export { RichTreeViewItems } from "./components/RichTreeViewItems.js";
3
4
  export { unstable_resetCleanupTracking } from "./hooks/useInstanceEventHandler.js";
4
5
 
5
6
  // Core plugins
@@ -1,3 +1,3 @@
1
1
  export { useTreeViewItems } from './useTreeViewItems';
2
- export type { UseTreeViewItemsSignature, UseTreeViewItemsParameters, UseTreeViewItemsDefaultizedParameters, UseTreeViewItemsState, } from './useTreeViewItems.types';
2
+ export type { UseTreeViewItemsSignature, UseTreeViewItemsParameters, UseTreeViewItemsDefaultizedParameters, UseTreeViewItemsState, TreeViewItemToRenderProps, } from './useTreeViewItems.types';
3
3
  export { buildSiblingIndexes, TREE_VIEW_ROOT_PARENT_ID } from './useTreeViewItems.utils';
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { TreeViewItemMeta, DefaultizedProps, TreeViewPluginSignature } from '../../models';
3
3
  import { TreeViewBaseItem, TreeViewItemId } from '../../../models';
4
- interface TreeViewItemProps {
4
+ export interface TreeViewItemToRenderProps {
5
5
  label: string;
6
6
  itemId: string;
7
7
  id: string | undefined;
8
- children?: TreeViewItemProps[];
8
+ children?: TreeViewItemToRenderProps[];
9
9
  }
10
10
  export interface UseTreeViewItemsPublicAPI<R extends {}> {
11
11
  /**
@@ -31,7 +31,7 @@ export interface UseTreeViewItemsPublicAPI<R extends {}> {
31
31
  getItemOrderedChildrenIds: (itemId: TreeViewItemId | null) => TreeViewItemId[];
32
32
  /**
33
33
  * Get all the items in the same format as provided by `props.items`.
34
- * @returns {TreeViewItemProps[]} The items in the tree.
34
+ * @returns {TreeViewItemToRenderProps[]} The items in the tree.
35
35
  */
36
36
  getItemTree: () => TreeViewBaseItem[];
37
37
  }
@@ -46,10 +46,10 @@ export interface UseTreeViewItemsInstance<R extends {}> extends UseTreeViewItems
46
46
  /**
47
47
  * Get the item that should be rendered.
48
48
  * This method is only used on Rich Tree View components.
49
- * Check the `TreeViewItemProps` type for more information.
50
- * @returns {TreeViewItemProps[]} The items to render.
49
+ * Check the `TreeViewItemToRenderProps` type for more information.
50
+ * @returns {TreeViewItemToRenderProps[]} The items to render.
51
51
  */
52
- getItemsToRender: () => TreeViewItemProps[];
52
+ getItemsToRender: () => TreeViewItemToRenderProps[];
53
53
  /**
54
54
  * Check if a given item is disabled.
55
55
  * An item is disabled if it was marked as disabled or if one of its ancestors is disabled.
@@ -11,7 +11,7 @@ import { styled, createUseThemeProps } from "../internals/zero-styled/index.js";
11
11
  import { useTreeView } from "../internals/useTreeView/index.js";
12
12
  import { TreeViewProvider } from "../internals/TreeViewProvider/index.js";
13
13
  import { RICH_TREE_VIEW_PLUGINS } from "./RichTreeView.plugins.js";
14
- import { TreeItem } from "../TreeItem/index.js";
14
+ import { RichTreeViewItems } from "../internals/components/RichTreeViewItems.js";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  const useThemeProps = createUseThemeProps('MuiRichTreeView');
17
17
  const useUtilityClasses = ownerState => {
@@ -34,33 +34,6 @@ export const RichTreeViewRoot = styled('ul', {
34
34
  outline: 0,
35
35
  position: 'relative'
36
36
  });
37
- function WrappedTreeItem({
38
- slots,
39
- slotProps,
40
- label,
41
- id,
42
- itemId,
43
- children
44
- }) {
45
- const Item = slots?.item ?? TreeItem;
46
- const itemProps = useSlotProps({
47
- elementType: Item,
48
- externalSlotProps: slotProps?.item,
49
- additionalProps: {
50
- itemId,
51
- id,
52
- label
53
- },
54
- ownerState: {
55
- itemId,
56
- label
57
- }
58
- });
59
- return /*#__PURE__*/_jsx(Item, _extends({}, itemProps, {
60
- children: children
61
- }));
62
- }
63
-
64
37
  /**
65
38
  *
66
39
  * Demos:
@@ -103,26 +76,14 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
103
76
  getSlotProps: getRootProps,
104
77
  ownerState: props
105
78
  });
106
- const itemsToRender = instance.getItemsToRender();
107
- const renderItem = ({
108
- label,
109
- itemId,
110
- id,
111
- children
112
- }) => {
113
- return /*#__PURE__*/_jsx(WrappedTreeItem, {
114
- slots: slots,
115
- slotProps: slotProps,
116
- label: label,
117
- id: id,
118
- itemId: itemId,
119
- children: children?.map(renderItem)
120
- }, itemId);
121
- };
122
79
  return /*#__PURE__*/_jsx(TreeViewProvider, {
123
80
  value: contextValue,
124
81
  children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
125
- children: itemsToRender.map(renderItem)
82
+ children: /*#__PURE__*/_jsx(RichTreeViewItems, {
83
+ slots: slots,
84
+ slotProps: slotProps,
85
+ itemsToRender: instance.getItemsToRender()
86
+ })
126
87
  }))
127
88
  });
128
89
  });
@@ -19,6 +19,7 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
19
19
  import useSlotProps from '@mui/utils/useSlotProps';
20
20
  import unsupportedProp from '@mui/utils/unsupportedProp';
21
21
  import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
22
+ import { warnOnce } from '@mui/x-internals/warning';
22
23
  import { styled, createUseThemeProps } from "../internals/zero-styled/index.js";
23
24
  import { TreeItemContent } from "./TreeItemContent.js";
24
25
  import { treeItemClasses, getTreeItemUtilityClass } from "./treeItemClasses.js";
@@ -220,6 +221,15 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
220
221
  handleCancelItemLabelEditing,
221
222
  handleSaveItemLabel
222
223
  } = useTreeItemState(itemId);
224
+ if (process.env.NODE_ENV !== 'production') {
225
+ // Checking directly the `props` to avoid having the default value applied
226
+ if (props.ContentComponent) {
227
+ warnOnce(['MUI X: The ContentComponent prop of the TreeItem component is deprecated and will be removed in the next major release.', 'You can use the new TreeItem2 component or the new useTreeItem2 hook to customize the rendering of the content.', 'For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.']);
228
+ }
229
+ if (props.ContentProps) {
230
+ warnOnce(['MUI X: The ContentProps prop of the TreeItem component is deprecated and will be removed in the next major release.', 'You can use the new TreeItem2 component or the new useTreeItem2 hook to customize the rendering of the content.', 'For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.']);
231
+ }
232
+ }
223
233
  const {
224
234
  contentRef,
225
235
  rootRef,
@@ -442,11 +452,13 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
442
452
  className: PropTypes.string,
443
453
  /**
444
454
  * The component used to render the content of the item.
455
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
445
456
  * @default TreeItemContent
446
457
  */
447
458
  ContentComponent: elementTypeAcceptingRef,
448
459
  /**
449
460
  * Props applied to ContentComponent.
461
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
450
462
  */
451
463
  ContentProps: PropTypes.object,
452
464
  /**
@@ -73,35 +73,31 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
73
73
  }
74
74
  toggleItemEditing();
75
75
  };
76
- return (
77
- /*#__PURE__*/
78
- /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */
79
- _jsxs("div", _extends({}, other, {
80
- className: clsx(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
81
- onClick: handleClick,
82
- onMouseDown: handleMouseDown,
83
- ref: ref,
84
- children: [/*#__PURE__*/_jsx("div", {
85
- className: classes.iconContainer,
86
- children: icon
87
- }), checkboxSelection && /*#__PURE__*/_jsx(Checkbox, {
88
- className: classes.checkbox,
89
- checked: selected,
90
- onChange: handleCheckboxSelection,
91
- disabled: disabled || disableSelection,
92
- ref: checkboxRef,
93
- tabIndex: -1
94
- }), editing ? /*#__PURE__*/_jsx(TreeItem2LabelInput, _extends({}, labelInputProps, {
95
- className: classes.labelInput
96
- })) : /*#__PURE__*/_jsx("div", _extends({
97
- className: classes.label
98
- }, editable && {
99
- onDoubleClick: handleLabelDoubleClick
100
- }, {
101
- children: label
102
- })), dragAndDropOverlayProps && /*#__PURE__*/_jsx(TreeItem2DragAndDropOverlay, _extends({}, dragAndDropOverlayProps))]
103
- }))
104
- );
76
+ return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */_jsxs("div", _extends({}, other, {
77
+ className: clsx(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
78
+ onClick: handleClick,
79
+ onMouseDown: handleMouseDown,
80
+ ref: ref,
81
+ children: [/*#__PURE__*/_jsx("div", {
82
+ className: classes.iconContainer,
83
+ children: icon
84
+ }), checkboxSelection && /*#__PURE__*/_jsx(Checkbox, {
85
+ className: classes.checkbox,
86
+ checked: selected,
87
+ onChange: handleCheckboxSelection,
88
+ disabled: disabled || disableSelection,
89
+ ref: checkboxRef,
90
+ tabIndex: -1
91
+ }), editing ? /*#__PURE__*/_jsx(TreeItem2LabelInput, _extends({}, labelInputProps, {
92
+ className: classes.labelInput
93
+ })) : /*#__PURE__*/_jsx("div", _extends({
94
+ className: classes.label
95
+ }, editable && {
96
+ onDoubleClick: handleLabelDoubleClick
97
+ }, {
98
+ children: label
99
+ })), dragAndDropOverlayProps && /*#__PURE__*/_jsx(TreeItem2DragAndDropOverlay, _extends({}, dragAndDropOverlayProps))]
100
+ }));
105
101
  });
106
102
  process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
107
103
  // ----------------------------- Warning --------------------------------
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.19.0
2
+ * @mui/x-tree-view v7.20.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,56 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["ownerState"];
4
+ import * as React from 'react';
5
+ import useSlotProps from '@mui/utils/useSlotProps';
6
+ import { TreeItem } from "../../TreeItem/index.js";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ function WrappedTreeItem({
9
+ slots,
10
+ slotProps,
11
+ label,
12
+ id,
13
+ itemId,
14
+ itemsToRender
15
+ }) {
16
+ const Item = slots?.item ?? TreeItem;
17
+ const _useSlotProps = useSlotProps({
18
+ elementType: Item,
19
+ externalSlotProps: slotProps?.item,
20
+ additionalProps: {
21
+ itemId,
22
+ id,
23
+ label
24
+ },
25
+ ownerState: {
26
+ itemId,
27
+ label
28
+ }
29
+ }),
30
+ itemProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded);
31
+ const children = React.useMemo(() => itemsToRender ? /*#__PURE__*/_jsx(RichTreeViewItems, {
32
+ itemsToRender: itemsToRender,
33
+ slots: slots,
34
+ slotProps: slotProps
35
+ }) : null, [itemsToRender, slots, slotProps]);
36
+ return /*#__PURE__*/_jsx(Item, _extends({}, itemProps, {
37
+ children: children
38
+ }));
39
+ }
40
+ export function RichTreeViewItems(props) {
41
+ const {
42
+ itemsToRender,
43
+ slots,
44
+ slotProps
45
+ } = props;
46
+ return /*#__PURE__*/_jsx(React.Fragment, {
47
+ children: itemsToRender.map(item => /*#__PURE__*/_jsx(WrappedTreeItem, {
48
+ slots: slots,
49
+ slotProps: slotProps,
50
+ label: item.label,
51
+ id: item.id,
52
+ itemId: item.itemId,
53
+ itemsToRender: item.children
54
+ }, item.itemId))
55
+ });
56
+ }
@@ -1,5 +1,6 @@
1
1
  export { useTreeView } from "./useTreeView/index.js";
2
2
  export { TreeViewProvider, useTreeViewContext } from "./TreeViewProvider/index.js";
3
+ export { RichTreeViewItems } from "./components/RichTreeViewItems.js";
3
4
  export { unstable_resetCleanupTracking } from "./hooks/useInstanceEventHandler.js";
4
5
 
5
6
  // Core plugins
@@ -18,7 +18,7 @@ var _zeroStyled = require("../internals/zero-styled");
18
18
  var _useTreeView = require("../internals/useTreeView");
19
19
  var _TreeViewProvider = require("../internals/TreeViewProvider");
20
20
  var _RichTreeView = require("./RichTreeView.plugins");
21
- var _TreeItem = require("../TreeItem");
21
+ var _RichTreeViewItems = require("../internals/components/RichTreeViewItems");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
  const useThemeProps = (0, _zeroStyled.createUseThemeProps)('MuiRichTreeView');
24
24
  const useUtilityClasses = ownerState => {
@@ -41,33 +41,6 @@ const RichTreeViewRoot = exports.RichTreeViewRoot = (0, _zeroStyled.styled)('ul'
41
41
  outline: 0,
42
42
  position: 'relative'
43
43
  });
44
- function WrappedTreeItem({
45
- slots,
46
- slotProps,
47
- label,
48
- id,
49
- itemId,
50
- children
51
- }) {
52
- const Item = slots?.item ?? _TreeItem.TreeItem;
53
- const itemProps = (0, _useSlotProps.default)({
54
- elementType: Item,
55
- externalSlotProps: slotProps?.item,
56
- additionalProps: {
57
- itemId,
58
- id,
59
- label
60
- },
61
- ownerState: {
62
- itemId,
63
- label
64
- }
65
- });
66
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Item, (0, _extends2.default)({}, itemProps, {
67
- children: children
68
- }));
69
- }
70
-
71
44
  /**
72
45
  *
73
46
  * Demos:
@@ -110,26 +83,14 @@ const RichTreeView = exports.RichTreeView = /*#__PURE__*/React.forwardRef(functi
110
83
  getSlotProps: getRootProps,
111
84
  ownerState: props
112
85
  });
113
- const itemsToRender = instance.getItemsToRender();
114
- const renderItem = ({
115
- label,
116
- itemId,
117
- id,
118
- children
119
- }) => {
120
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedTreeItem, {
121
- slots: slots,
122
- slotProps: slotProps,
123
- label: label,
124
- id: id,
125
- itemId: itemId,
126
- children: children?.map(renderItem)
127
- }, itemId);
128
- };
129
86
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeViewProvider.TreeViewProvider, {
130
87
  value: contextValue,
131
88
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({}, rootProps, {
132
- children: itemsToRender.map(renderItem)
89
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RichTreeViewItems.RichTreeViewItems, {
90
+ slots: slots,
91
+ slotProps: slotProps,
92
+ itemsToRender: instance.getItemsToRender()
93
+ })
133
94
  }))
134
95
  });
135
96
  });
@@ -22,6 +22,7 @@ var _resolveComponentProps = _interopRequireDefault(require("@mui/utils/resolveC
22
22
  var _useSlotProps4 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
23
23
  var _unsupportedProp = _interopRequireDefault(require("@mui/utils/unsupportedProp"));
24
24
  var _elementTypeAcceptingRef = _interopRequireDefault(require("@mui/utils/elementTypeAcceptingRef"));
25
+ var _warning = require("@mui/x-internals/warning");
25
26
  var _zeroStyled = require("../internals/zero-styled");
26
27
  var _TreeItemContent = require("./TreeItemContent");
27
28
  var _treeItemClasses = require("./treeItemClasses");
@@ -227,6 +228,15 @@ const TreeItem = exports.TreeItem = /*#__PURE__*/React.forwardRef(function TreeI
227
228
  handleCancelItemLabelEditing,
228
229
  handleSaveItemLabel
229
230
  } = (0, _useTreeItemState.useTreeItemState)(itemId);
231
+ if (process.env.NODE_ENV !== 'production') {
232
+ // Checking directly the `props` to avoid having the default value applied
233
+ if (props.ContentComponent) {
234
+ (0, _warning.warnOnce)(['MUI X: The ContentComponent prop of the TreeItem component is deprecated and will be removed in the next major release.', 'You can use the new TreeItem2 component or the new useTreeItem2 hook to customize the rendering of the content.', 'For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.']);
235
+ }
236
+ if (props.ContentProps) {
237
+ (0, _warning.warnOnce)(['MUI X: The ContentProps prop of the TreeItem component is deprecated and will be removed in the next major release.', 'You can use the new TreeItem2 component or the new useTreeItem2 hook to customize the rendering of the content.', 'For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.']);
238
+ }
239
+ }
230
240
  const {
231
241
  contentRef,
232
242
  rootRef,
@@ -449,11 +459,13 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
449
459
  className: _propTypes.default.string,
450
460
  /**
451
461
  * The component used to render the content of the item.
462
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
452
463
  * @default TreeItemContent
453
464
  */
454
465
  ContentComponent: _elementTypeAcceptingRef.default,
455
466
  /**
456
467
  * Props applied to ContentComponent.
468
+ * @deprecated Consider using the `TreeItem2` component or the `useTreeItem2` hook instead. For more detail, see https://mui.com/x/react-tree-view/tree-item-customization/.
457
469
  */
458
470
  ContentProps: _propTypes.default.object,
459
471
  /**
@@ -81,35 +81,31 @@ const TreeItemContent = exports.TreeItemContent = /*#__PURE__*/React.forwardRef(
81
81
  }
82
82
  toggleItemEditing();
83
83
  };
84
- return (
85
- /*#__PURE__*/
86
- /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */
87
- (0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({}, other, {
88
- className: (0, _clsx.default)(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
89
- onClick: handleClick,
90
- onMouseDown: handleMouseDown,
91
- ref: ref,
92
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
93
- className: classes.iconContainer,
94
- children: icon
95
- }), checkboxSelection && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
96
- className: classes.checkbox,
97
- checked: selected,
98
- onChange: handleCheckboxSelection,
99
- disabled: disabled || disableSelection,
100
- ref: checkboxRef,
101
- tabIndex: -1
102
- }), editing ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeItem2LabelInput.TreeItem2LabelInput, (0, _extends2.default)({}, labelInputProps, {
103
- className: classes.labelInput
104
- })) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
105
- className: classes.label
106
- }, editable && {
107
- onDoubleClick: handleLabelDoubleClick
108
- }, {
109
- children: label
110
- })), dragAndDropOverlayProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeItem2DragAndDropOverlay.TreeItem2DragAndDropOverlay, (0, _extends2.default)({}, dragAndDropOverlayProps))]
111
- }))
112
- );
84
+ return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */(0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({}, other, {
85
+ className: (0, _clsx.default)(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
86
+ onClick: handleClick,
87
+ onMouseDown: handleMouseDown,
88
+ ref: ref,
89
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
90
+ className: classes.iconContainer,
91
+ children: icon
92
+ }), checkboxSelection && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
93
+ className: classes.checkbox,
94
+ checked: selected,
95
+ onChange: handleCheckboxSelection,
96
+ disabled: disabled || disableSelection,
97
+ ref: checkboxRef,
98
+ tabIndex: -1
99
+ }), editing ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeItem2LabelInput.TreeItem2LabelInput, (0, _extends2.default)({}, labelInputProps, {
100
+ className: classes.labelInput
101
+ })) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
102
+ className: classes.label
103
+ }, editable && {
104
+ onDoubleClick: handleLabelDoubleClick
105
+ }, {
106
+ children: label
107
+ })), dragAndDropOverlayProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeItem2DragAndDropOverlay.TreeItem2DragAndDropOverlay, (0, _extends2.default)({}, dragAndDropOverlayProps))]
108
+ }));
113
109
  });
114
110
  process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
115
111
  // ----------------------------- Warning --------------------------------
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.19.0
2
+ * @mui/x-tree-view v7.20.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.RichTreeViewItems = RichTreeViewItems;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
13
+ var _TreeItem = require("../../TreeItem");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ const _excluded = ["ownerState"];
16
+ function WrappedTreeItem({
17
+ slots,
18
+ slotProps,
19
+ label,
20
+ id,
21
+ itemId,
22
+ itemsToRender
23
+ }) {
24
+ const Item = slots?.item ?? _TreeItem.TreeItem;
25
+ const _useSlotProps = (0, _useSlotProps2.default)({
26
+ elementType: Item,
27
+ externalSlotProps: slotProps?.item,
28
+ additionalProps: {
29
+ itemId,
30
+ id,
31
+ label
32
+ },
33
+ ownerState: {
34
+ itemId,
35
+ label
36
+ }
37
+ }),
38
+ itemProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded);
39
+ const children = React.useMemo(() => itemsToRender ? /*#__PURE__*/(0, _jsxRuntime.jsx)(RichTreeViewItems, {
40
+ itemsToRender: itemsToRender,
41
+ slots: slots,
42
+ slotProps: slotProps
43
+ }) : null, [itemsToRender, slots, slotProps]);
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Item, (0, _extends2.default)({}, itemProps, {
45
+ children: children
46
+ }));
47
+ }
48
+ function RichTreeViewItems(props) {
49
+ const {
50
+ itemsToRender,
51
+ slots,
52
+ slotProps
53
+ } = props;
54
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
55
+ children: itemsToRender.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedTreeItem, {
56
+ slots: slots,
57
+ slotProps: slotProps,
58
+ label: item.label,
59
+ id: item.id,
60
+ itemId: item.itemId,
61
+ itemsToRender: item.children
62
+ }, item.itemId))
63
+ });
64
+ }
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "RichTreeViewItems", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _RichTreeViewItems.RichTreeViewItems;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "TREE_VIEW_ROOT_PARENT_ID", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -95,6 +101,7 @@ Object.defineProperty(exports, "useTreeViewSelection", {
95
101
  });
96
102
  var _useTreeView = require("./useTreeView");
97
103
  var _TreeViewProvider = require("./TreeViewProvider");
104
+ var _RichTreeViewItems = require("./components/RichTreeViewItems");
98
105
  var _useInstanceEventHandler = require("./hooks/useInstanceEventHandler");
99
106
  var _useTreeViewExpansion = require("./plugins/useTreeViewExpansion");
100
107
  var _useTreeViewSelection = require("./plugins/useTreeViewSelection");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-tree-view",
3
- "version": "7.19.0",
3
+ "version": "7.20.0",
4
4
  "description": "The community edition of the Tree View components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -33,13 +33,13 @@
33
33
  "directory": "packages/x-tree-view"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/runtime": "^7.25.6",
37
- "@mui/utils": "^5.16.6",
36
+ "@babel/runtime": "^7.25.7",
37
+ "@mui/utils": "^5.16.6 || ^6.0.0",
38
38
  "@types/react-transition-group": "^4.4.11",
39
39
  "clsx": "^2.1.1",
40
40
  "prop-types": "^15.8.1",
41
41
  "react-transition-group": "^4.4.5",
42
- "@mui/x-internals": "7.18.0"
42
+ "@mui/x-internals": "7.20.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@emotion/react": "^11.9.0",
@@ -1,3 +1,3 @@
1
1
  export declare const useTreeItem2: <TSignatures extends import("./useTreeItem2.types").UseTreeItem2MinimalPlugins = import("./useTreeItem2.types").UseTreeItem2MinimalPlugins, TOptionalSignatures extends import("./useTreeItem2.types").UseTreeItem2OptionalPlugins = readonly []>(parameters: import("@mui/x-tree-view/useTreeItem2").UseTreeItem2Parameters) => import("@mui/x-tree-view/useTreeItem2").UseTreeItem2ReturnValue<TSignatures, TOptionalSignatures>;
2
2
  export declare const unstable_useTreeItem2: <TSignatures extends import("./useTreeItem2.types").UseTreeItem2MinimalPlugins = import("./useTreeItem2.types").UseTreeItem2MinimalPlugins, TOptionalSignatures extends import("./useTreeItem2.types").UseTreeItem2OptionalPlugins = readonly []>(parameters: import("@mui/x-tree-view/useTreeItem2").UseTreeItem2Parameters) => import("@mui/x-tree-view/useTreeItem2").UseTreeItem2ReturnValue<TSignatures, TOptionalSignatures>;
3
- export type { UseTreeItem2Parameters, UseTreeItem2ReturnValue, UseTreeItem2Status, UseTreeItem2RootSlotOwnProps, UseTreeItem2ContentSlotOwnProps, UseTreeItem2LabelInputSlotOwnProps, UseTreeItem2LabelSlotOwnProps, UseTreeItem2IconContainerSlotOwnProps, UseTreeItem2GroupTransitionSlotOwnProps, UseTreeItem2DragAndDropOverlaySlotOwnProps, } from './useTreeItem2.types';
3
+ export type { UseTreeItem2Parameters, UseTreeItem2ReturnValue, UseTreeItem2Status, UseTreeItem2RootSlotOwnProps, UseTreeItem2ContentSlotOwnProps, UseTreeItem2LabelInputSlotOwnProps, UseTreeItem2LabelSlotOwnProps, UseTreeItem2CheckboxSlotOwnProps, UseTreeItem2IconContainerSlotOwnProps, UseTreeItem2GroupTransitionSlotOwnProps, UseTreeItem2DragAndDropOverlaySlotOwnProps, } from './useTreeItem2.types';
@@ -83,7 +83,7 @@ export type UseTreeItem2LabelInputSlotProps<ExternalProps = {}> = ExternalProps
83
83
  export interface UseTreeItem2CheckboxSlotOwnProps {
84
84
  visible: boolean;
85
85
  checked: boolean;
86
- onChange: React.ChangeEventHandler<HTMLInputElement>;
86
+ onChange: MuiCancellableEventHandler<React.ChangeEvent<HTMLInputElement>>;
87
87
  disabled: boolean;
88
88
  ref: React.RefObject<HTMLButtonElement>;
89
89
  tabIndex: -1;