@mui/x-tree-view 8.3.1 → 8.4.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 (38) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/RichTreeView/RichTreeView.js +13 -2
  3. package/SimpleTreeView/SimpleTreeView.js +3 -2
  4. package/SimpleTreeView/SimpleTreeView.plugins.d.ts +1 -1
  5. package/TreeItem/TreeItem.js +7 -1
  6. package/TreeItem/TreeItem.types.d.ts +6 -0
  7. package/esm/RichTreeView/RichTreeView.js +11 -0
  8. package/esm/SimpleTreeView/SimpleTreeView.js +1 -0
  9. package/esm/SimpleTreeView/SimpleTreeView.plugins.d.ts +1 -1
  10. package/esm/TreeItem/TreeItem.js +7 -1
  11. package/esm/TreeItem/TreeItem.types.d.ts +6 -0
  12. package/esm/hooks/useTreeItemUtils/useTreeItemUtils.js +4 -6
  13. package/esm/index.js +1 -1
  14. package/esm/internals/TreeViewItemDepthContext/TreeViewItemDepthContext.js +1 -3
  15. package/esm/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -3
  16. package/esm/internals/TreeViewProvider/TreeViewContext.js +1 -3
  17. package/esm/internals/TreeViewProvider/TreeViewStyleContext.js +1 -3
  18. package/esm/internals/components/RichTreeViewItems.js +2 -3
  19. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.js +12 -5
  20. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +9 -0
  21. package/esm/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +2 -0
  22. package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +1 -1
  23. package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +10 -2
  24. package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.types.d.ts +5 -6
  25. package/hooks/useTreeItemUtils/useTreeItemUtils.js +4 -6
  26. package/index.js +1 -1
  27. package/internals/TreeViewItemDepthContext/TreeViewItemDepthContext.js +1 -3
  28. package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -3
  29. package/internals/TreeViewProvider/TreeViewContext.js +1 -3
  30. package/internals/TreeViewProvider/TreeViewStyleContext.js +1 -3
  31. package/internals/components/RichTreeViewItems.js +2 -3
  32. package/internals/plugins/useTreeViewItems/useTreeViewItems.js +12 -5
  33. package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +9 -0
  34. package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +2 -0
  35. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +1 -1
  36. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +10 -2
  37. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.types.d.ts +5 -6
  38. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,116 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.4.0
9
+
10
+ _May 21, 2025_
11
+
12
+ We'd like to offer a big thanks to the 21 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 🔺 Support regular [`pyramid` variation in the `<FunnelChart />` component](https://mui.com/x/react-charts/funnel/#pyramid-chart):
15
+
16
+ <img width="398" alt="Pyramid funnel chart" src="https://github.com/user-attachments/assets/90ccb221-3a48-4ffa-8878-89c6db16da86" />
17
+
18
+ - 📚 Documentation improvements
19
+ - 🌎 Improve Icelandic (is-IS) locale on the Data Grid
20
+ - 🐞 Bugfixes
21
+
22
+ Special thanks go out to the community members for their valuable contributions:
23
+ @aizerin, @arminmeh, @campmarc, @jyash97, @mapache-salvaje, @noraleonte, @nusr, @ragnarr18, @romgrk, @whereisrmsqhs.
24
+ Following are all team members who have contributed to this release:
25
+ @alexfauquette, @bernardobelchior, @flaviendelangle, @JCQuintas, @KenanYusuf, @LukasTy, @MBilalShafi, @rita-codes.
26
+
27
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
28
+
29
+ ### Data Grid
30
+
31
+ #### `@mui/x-data-grid@8.4.0`
32
+
33
+ - [DataGrid] Fix content rendering for large rows while using automatic page size (#14737) @campmarc
34
+ - [DataGrid] Fix disabled typography variants crashing grid (#17934) @KenanYusuf
35
+ - [DataGrid] Fix tree data demo crash (#17904) @MBilalShafi
36
+ - [DataGrid] Use `exclude` selection model type if quick filter does not have actual values (#17899) @arminmeh
37
+ - [DataGrid] Fix clipboard copy behavior for cell ranges with empty cells (#16797) @nusr
38
+ - [l10n] Improve Icelandic (is-IS) locale (#17915) @ragnarr18
39
+
40
+ #### `@mui/x-data-grid-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
41
+
42
+ Same changes as in `@mui/x-data-grid@8.4.0`, plus:
43
+
44
+ - [DataGridPro] Add `aria-expanded` attribute to the master detail toggle button (#17122) @whereisrmsqhs
45
+ - [DataGridPro] Preserve row state during server-side lazy loading (#17743) @arminmeh
46
+ - [DataGridPro] Prevent text selection when reordering rows (#16568) @jyash97
47
+
48
+ #### `@mui/x-data-grid-premium@8.4.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
49
+
50
+ Same changes as in `@mui/x-data-grid-pro@8.4.0`.
51
+
52
+ ### Date and Time Pickers
53
+
54
+ #### `@mui/x-date-pickers@8.4.0`
55
+
56
+ - [fields] Ensure fresh `disabled` value is used when focusing or clicking (#17914) @aizerin
57
+ - [fields] Improve the field controlled edition (#17816) @flaviendelangle
58
+ - [pickers] Fix `PickersTextField` overflow (#17942) @noraleonte
59
+
60
+ #### `@mui/x-date-pickers-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
61
+
62
+ Same changes as in `@mui/x-date-pickers@8.4.0`.
63
+
64
+ ### Charts
65
+
66
+ #### `@mui/x-charts@8.4.0`
67
+
68
+ - [charts] Add grouped axes demo (#17848) @bernardobelchior
69
+ - [charts] Enable tooltip disable portal (#17871) @alexfauquette
70
+ - [charts] Improve performance in scatter chart (#17849) @bernardobelchior
71
+ - [charts] Recreate `isPointInside` less often (#17850) @bernardobelchior
72
+ - [charts] Try fix for flaky `useAnimate` test (#17777) @JCQuintas
73
+ - [charts] Add `isXInside` and `isYInside` (#17911) @bernardobelchior
74
+
75
+ #### `@mui/x-charts-pro@8.4.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-charts@8.4.0`, plus:
78
+
79
+ - [charts-pro] Add size for zoom slider (#17736) @bernardobelchior
80
+ - [charts-pro] Add zoom slider tooltip (#17733) @bernardobelchior
81
+ - [charts-pro] Clean and document Heatmap Tooltip (#17933) @alexfauquette
82
+ - [charts-pro] Introduce `Pyramid` chart (#17783) @JCQuintas
83
+ - [charts-pro] Update zoom slider nomenclature (#17938) @bernardobelchior
84
+ - [charts-pro] Fix error when importing rasterizehtml (#17897) @bernardobelchior
85
+
86
+ ### Tree View
87
+
88
+ #### `@mui/x-tree-view@8.4.0`
89
+
90
+ - [TreeView] Add `getItemChildren` prop in `RichTreeView` (#17894) @rita-codes
91
+ - [TreeView] Add a method in the `apiRef` to toggle the editing status of an item (#17768) @rita-codes
92
+ - [TreeView] Add missing sx prop on the Tree Item component (#17930) @flaviendelangle
93
+
94
+ #### `@mui/x-tree-view-pro@8.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
95
+
96
+ Same changes as in `@mui/x-tree-view@8.4.0`.
97
+
98
+ ### Docs
99
+
100
+ - [docs] Add a recipe for drag and drop row grouping (#17638) @KenanYusuf
101
+ - [docs] Add introductory text to Data Grid component pages (#17902) @KenanYusuf
102
+ - [docs] Refactor embedded CodeSandbox on Data Grid—Quickstart page (#17749) @rita-codes
103
+ - [docs] Remove double border on Data Grid—Quickstart demo (#17932) @rita-codes
104
+ - [docs] Standardize `apiRef` copy (#17776) @mapache-salvaje
105
+ - [docs][DataGrid] Revise server-side data docs (#17007) @mapache-salvaje
106
+ - [docs][DataGrid] Audit and revise the tree data doc (#17650) @mapache-salvaje
107
+ - [docs][pickers] Fix migration guide references to range fields (#17861) @LukasTy
108
+ - [docs][charts] Reorganize the Tooltip documentation (#17917) @alexfauquette
109
+
110
+ ### Core
111
+
112
+ - [core] refactor: remove manual `displayName` (#17845) @romgrk
113
+ - [code-infra] Document how to use `vitest` cli (#17847) @JCQuintas
114
+ - [code-infra] Increase charts export test timeout (#17909) @JCQuintas
115
+ - [code-infra] Set `isolatedModules=true` in tsconfig (#17781) @JCQuintas
116
+ - [infra] Ensure proper docs preview path resolution (#17863) @LukasTy
117
+
8
118
  ## 8.3.1
9
119
 
10
120
  _May 14, 2025_
@@ -20,7 +20,7 @@ var _richTreeViewClasses = require("./richTreeViewClasses");
20
20
  var _zeroStyled = require("../internals/zero-styled");
21
21
  var _useTreeView = require("../internals/useTreeView");
22
22
  var _TreeViewProvider = require("../internals/TreeViewProvider");
23
- var _RichTreeView = require("./RichTreeView.plugins");
23
+ var _RichTreeView2 = require("./RichTreeView.plugins");
24
24
  var _RichTreeViewItems = require("../internals/components/RichTreeViewItems");
25
25
  var _useSelector = require("../internals/hooks/useSelector");
26
26
  var _useTreeViewItems = require("../internals/plugins/useTreeViewItems/useTreeViewItems.selectors");
@@ -86,7 +86,7 @@ const RichTreeView = exports.RichTreeView = /*#__PURE__*/React.forwardRef(functi
86
86
  getRootProps,
87
87
  contextValue
88
88
  } = (0, _useTreeView.useTreeView)({
89
- plugins: _RichTreeView.RICH_TREE_VIEW_PLUGINS,
89
+ plugins: _RichTreeView2.RICH_TREE_VIEW_PLUGINS,
90
90
  rootRef: ref,
91
91
  props: other
92
92
  });
@@ -125,6 +125,7 @@ const RichTreeView = exports.RichTreeView = /*#__PURE__*/React.forwardRef(functi
125
125
  }))
126
126
  });
127
127
  });
128
+ if (process.env.NODE_ENV !== "production") RichTreeView.displayName = "RichTreeView";
128
129
  process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
129
130
  // ----------------------------- Warning --------------------------------
130
131
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -141,6 +142,7 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
141
142
  getItemOrderedChildrenIds: _propTypes.default.func.isRequired,
142
143
  getItemTree: _propTypes.default.func.isRequired,
143
144
  getParentId: _propTypes.default.func.isRequired,
145
+ setEditedItem: _propTypes.default.func.isRequired,
144
146
  setIsItemDisabled: _propTypes.default.func.isRequired,
145
147
  setItemExpansion: _propTypes.default.func.isRequired,
146
148
  setItemSelection: _propTypes.default.func.isRequired,
@@ -189,6 +191,15 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
189
191
  * @default 'content'
190
192
  */
191
193
  expansionTrigger: _propTypes.default.oneOf(['content', 'iconContainer']),
194
+ /**
195
+ * Used to determine the children of a given item.
196
+ *
197
+ * @template R
198
+ * @param {R} item The item to check.
199
+ * @returns {R[]} The children of the item.
200
+ * @default (item) => item.children
201
+ */
202
+ getItemChildren: _propTypes.default.func,
192
203
  /**
193
204
  * Used to determine the id of a given item.
194
205
  *
@@ -18,7 +18,7 @@ var _zeroStyled = require("../internals/zero-styled");
18
18
  var _simpleTreeViewClasses = require("./simpleTreeViewClasses");
19
19
  var _useTreeView = require("../internals/useTreeView");
20
20
  var _TreeViewProvider = require("../internals/TreeViewProvider");
21
- var _SimpleTreeView = require("./SimpleTreeView.plugins");
21
+ var _SimpleTreeView2 = require("./SimpleTreeView.plugins");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
  const _excluded = ["slots", "slotProps"];
24
24
  const useThemeProps = (0, _zeroStyled.createUseThemeProps)('MuiSimpleTreeView');
@@ -83,7 +83,7 @@ const SimpleTreeView = exports.SimpleTreeView = /*#__PURE__*/React.forwardRef(fu
83
83
  getRootProps,
84
84
  contextValue
85
85
  } = (0, _useTreeView.useTreeView)({
86
- plugins: _SimpleTreeView.SIMPLE_TREE_VIEW_PLUGINS,
86
+ plugins: _SimpleTreeView2.SIMPLE_TREE_VIEW_PLUGINS,
87
87
  rootRef: ref,
88
88
  props: (0, _extends2.default)({}, other, {
89
89
  items: EMPTY_ITEMS
@@ -106,6 +106,7 @@ const SimpleTreeView = exports.SimpleTreeView = /*#__PURE__*/React.forwardRef(fu
106
106
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({}, rootProps))
107
107
  });
108
108
  });
109
+ if (process.env.NODE_ENV !== "production") SimpleTreeView.displayName = "SimpleTreeView";
109
110
  process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
110
111
  // ----------------------------- Warning --------------------------------
111
112
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -6,4 +6,4 @@ import { UseTreeViewFocusParameters } from "../internals/plugins/useTreeViewFocu
6
6
  import { ConvertPluginsIntoSignatures } from "../internals/models/index.js";
7
7
  export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewItemsSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewExpansionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewSelectionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewFocusSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewKeyboardNavigationSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewJSXItemsSignature>];
8
8
  export type SimpleTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
9
- export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
9
+ export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
@@ -167,6 +167,7 @@ const TreeItemCheckbox = exports.TreeItemCheckbox = (0, _zeroStyled.styled)(/*#_
167
167
  })({
168
168
  padding: 0
169
169
  });
170
+ if (process.env.NODE_ENV !== "production") TreeItemCheckbox.displayName = "TreeItemCheckbox";
170
171
  const useUtilityClasses = classesProp => {
171
172
  const {
172
173
  classes: classesFromTreeView
@@ -350,6 +351,7 @@ const TreeItem = exports.TreeItem = /*#__PURE__*/React.forwardRef(function TreeI
350
351
  }))
351
352
  }));
352
353
  });
354
+ if (process.env.NODE_ENV !== "production") TreeItem.displayName = "TreeItem";
353
355
  process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
354
356
  // ----------------------------- Warning --------------------------------
355
357
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -404,5 +406,9 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
404
406
  * Overridable component slots.
405
407
  * @default {}
406
408
  */
407
- slots: _propTypes.default.object
409
+ slots: _propTypes.default.object,
410
+ /**
411
+ * The system prop that allows defining system overrides as well as additional CSS styles.
412
+ */
413
+ sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
408
414
  } : void 0;
@@ -1,4 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { SxProps } from '@mui/system';
3
+ import { Theme } from '@mui/material/styles';
2
4
  import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
5
  import { TransitionProps } from '@mui/material/transitions';
4
6
  import { SlotComponentProps } from '@mui/utils/types';
@@ -76,6 +78,10 @@ export interface TreeItemSlotProps extends TreeItemIconSlotProps {
76
78
  }
77
79
  export interface TreeItemProps extends Omit<UseTreeItemParameters, 'rootRef'>, Omit<React.HTMLAttributes<HTMLLIElement>, 'onFocus'> {
78
80
  className?: string;
81
+ /**
82
+ * The system prop that allows defining system overrides as well as additional CSS styles.
83
+ */
84
+ sx?: SxProps<Theme>;
79
85
  /**
80
86
  * Override or extend the styles applied to the component.
81
87
  */
@@ -118,6 +118,7 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
118
118
  }))
119
119
  });
120
120
  });
121
+ if (process.env.NODE_ENV !== "production") RichTreeView.displayName = "RichTreeView";
121
122
  process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
122
123
  // ----------------------------- Warning --------------------------------
123
124
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -134,6 +135,7 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
134
135
  getItemOrderedChildrenIds: PropTypes.func.isRequired,
135
136
  getItemTree: PropTypes.func.isRequired,
136
137
  getParentId: PropTypes.func.isRequired,
138
+ setEditedItem: PropTypes.func.isRequired,
137
139
  setIsItemDisabled: PropTypes.func.isRequired,
138
140
  setItemExpansion: PropTypes.func.isRequired,
139
141
  setItemSelection: PropTypes.func.isRequired,
@@ -182,6 +184,15 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
182
184
  * @default 'content'
183
185
  */
184
186
  expansionTrigger: PropTypes.oneOf(['content', 'iconContainer']),
187
+ /**
188
+ * Used to determine the children of a given item.
189
+ *
190
+ * @template R
191
+ * @param {R} item The item to check.
192
+ * @returns {R[]} The children of the item.
193
+ * @default (item) => item.children
194
+ */
195
+ getItemChildren: PropTypes.func,
185
196
  /**
186
197
  * Used to determine the id of a given item.
187
198
  *
@@ -99,6 +99,7 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
99
99
  children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps))
100
100
  });
101
101
  });
102
+ if (process.env.NODE_ENV !== "production") SimpleTreeView.displayName = "SimpleTreeView";
102
103
  process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
103
104
  // ----------------------------- Warning --------------------------------
104
105
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -6,4 +6,4 @@ import { UseTreeViewFocusParameters } from "../internals/plugins/useTreeViewFocu
6
6
  import { ConvertPluginsIntoSignatures } from "../internals/models/index.js";
7
7
  export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewItemsSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewExpansionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewSelectionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewFocusSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewKeyboardNavigationSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewJSXItemsSignature>];
8
8
  export type SimpleTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
9
- export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
9
+ export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
@@ -160,6 +160,7 @@ export const TreeItemCheckbox = styled(/*#__PURE__*/React.forwardRef((props, ref
160
160
  })({
161
161
  padding: 0
162
162
  });
163
+ if (process.env.NODE_ENV !== "production") TreeItemCheckbox.displayName = "TreeItemCheckbox";
163
164
  const useUtilityClasses = classesProp => {
164
165
  const {
165
166
  classes: classesFromTreeView
@@ -343,6 +344,7 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
343
344
  }))
344
345
  }));
345
346
  });
347
+ if (process.env.NODE_ENV !== "production") TreeItem.displayName = "TreeItem";
346
348
  process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
347
349
  // ----------------------------- Warning --------------------------------
348
350
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -397,5 +399,9 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
397
399
  * Overridable component slots.
398
400
  * @default {}
399
401
  */
400
- slots: PropTypes.object
402
+ slots: PropTypes.object,
403
+ /**
404
+ * The system prop that allows defining system overrides as well as additional CSS styles.
405
+ */
406
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
401
407
  } : void 0;
@@ -1,4 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { SxProps } from '@mui/system';
3
+ import { Theme } from '@mui/material/styles';
2
4
  import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
5
  import { TransitionProps } from '@mui/material/transitions';
4
6
  import { SlotComponentProps } from '@mui/utils/types';
@@ -76,6 +78,10 @@ export interface TreeItemSlotProps extends TreeItemIconSlotProps {
76
78
  }
77
79
  export interface TreeItemProps extends Omit<UseTreeItemParameters, 'rootRef'>, Omit<React.HTMLAttributes<HTMLLIElement>, 'onFocus'> {
78
80
  className?: string;
81
+ /**
82
+ * The system prop that allows defining system overrides as well as additional CSS styles.
83
+ */
84
+ sx?: SxProps<Theme>;
79
85
  /**
80
86
  * Override or extend the styles applied to the component.
81
87
  */
@@ -118,12 +118,10 @@ export const useTreeItemUtils = ({
118
118
  if (!hasPlugin(instance, useTreeViewLabel)) {
119
119
  return;
120
120
  }
121
- if (isEditable) {
122
- if (isEditing) {
123
- instance.setEditedItemId(null);
124
- } else {
125
- instance.setEditedItemId(itemId);
126
- }
121
+ if (isEditing) {
122
+ instance.setEditedItem(null);
123
+ } else {
124
+ instance.setEditedItem(itemId);
127
125
  }
128
126
  };
129
127
  const handleSaveItemLabel = (event, newLabel) => {
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v8.3.1
2
+ * @mui/x-tree-view v8.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,5 +1,3 @@
1
1
  import * as React from 'react';
2
2
  export const TreeViewItemDepthContext = /*#__PURE__*/React.createContext(() => -1);
3
- if (process.env.NODE_ENV !== 'production') {
4
- TreeViewItemDepthContext.displayName = 'TreeViewItemDepthContext';
5
- }
3
+ if (process.env.NODE_ENV !== "production") TreeViewItemDepthContext.displayName = "TreeViewItemDepthContext";
@@ -5,9 +5,7 @@ import { escapeOperandAttributeSelector } from "../utils/utils.js";
5
5
  import { selectorItemOrderedChildrenIds } from "../plugins/useTreeViewItems/useTreeViewItems.selectors.js";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export const TreeViewChildrenItemContext = /*#__PURE__*/React.createContext(null);
8
- if (process.env.NODE_ENV !== 'production') {
9
- TreeViewChildrenItemContext.displayName = 'TreeViewChildrenItemContext';
10
- }
8
+ if (process.env.NODE_ENV !== "production") TreeViewChildrenItemContext.displayName = "TreeViewChildrenItemContext";
11
9
  export function TreeViewChildrenItemProvider(props) {
12
10
  const {
13
11
  children,
@@ -3,9 +3,7 @@ import * as React from 'react';
3
3
  * @ignore - internal component.
4
4
  */
5
5
  export const TreeViewContext = /*#__PURE__*/React.createContext(null);
6
- if (process.env.NODE_ENV !== 'production') {
7
- TreeViewContext.displayName = 'TreeViewContext';
8
- }
6
+ if (process.env.NODE_ENV !== "production") TreeViewContext.displayName = "TreeViewContext";
9
7
  export const useTreeViewContext = () => {
10
8
  const context = React.useContext(TreeViewContext);
11
9
  if (context == null) {
@@ -7,9 +7,7 @@ export const TreeViewStyleContext = /*#__PURE__*/React.createContext({
7
7
  slots: {},
8
8
  slotProps: {}
9
9
  });
10
- if (process.env.NODE_ENV !== 'production') {
11
- TreeViewStyleContext.displayName = 'TreeViewStyleContext';
12
- }
10
+ if (process.env.NODE_ENV !== "production") TreeViewStyleContext.displayName = "TreeViewStyleContext";
13
11
  export const useTreeViewStyleContext = () => {
14
12
  return React.useContext(TreeViewStyleContext);
15
13
  };
@@ -10,9 +10,7 @@ import { selectorItemMeta, selectorItemOrderedChildrenIds } from "../plugins/use
10
10
  import { useTreeViewContext } from "../TreeViewProvider/index.js";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  const RichTreeViewItemsContext = /*#__PURE__*/React.createContext(null);
13
- if (process.env.NODE_ENV !== 'production') {
14
- RichTreeViewItemsContext.displayName = 'RichTreeViewItemsProvider';
15
- }
13
+ if (process.env.NODE_ENV !== "production") RichTreeViewItemsContext.displayName = "RichTreeViewItemsContext";
16
14
  const WrappedTreeItem = /*#__PURE__*/React.memo(function WrappedTreeItem({
17
15
  itemSlot,
18
16
  itemSlotProps,
@@ -43,6 +41,7 @@ const WrappedTreeItem = /*#__PURE__*/React.memo(function WrappedTreeItem({
43
41
  children: children?.map(renderItemForRichTreeView)
44
42
  }));
45
43
  }, fastObjectShallowCompare);
44
+ if (process.env.NODE_ENV !== "production") WrappedTreeItem.displayName = "WrappedTreeItem";
46
45
  export function RichTreeViewItems(props) {
47
46
  const {
48
47
  slots,
@@ -21,6 +21,7 @@ const processItemsLookups = ({
21
21
  items,
22
22
  isItemDisabled,
23
23
  getItemLabel,
24
+ getItemChildren,
24
25
  getItemId,
25
26
  initialDepth = 0,
26
27
  initialParentId = null,
@@ -39,12 +40,13 @@ const processItemsLookups = ({
39
40
  if (label == null) {
40
41
  throw new Error(['MUI X: The Tree View component requires all items to have a `label` property.', 'Alternatively, you can use the `getItemLabel` prop to specify a custom label for each item.', 'An item was provided without label in the `items` prop:', JSON.stringify(item)].join('\n'));
41
42
  }
43
+ const children = getItemChildren ? getItemChildren(item) : item.children;
42
44
  itemMetaLookup[id] = {
43
45
  id,
44
46
  label,
45
47
  parentId,
46
48
  idAttribute: undefined,
47
- expandable: getChildrenCount ? getChildrenCount(item) > 0 : !!item.children?.length,
49
+ expandable: getChildrenCount ? getChildrenCount(item) > 0 : !!children?.length,
48
50
  disabled: isItemDisabled ? isItemDisabled(item) : false,
49
51
  depth
50
52
  };
@@ -57,7 +59,7 @@ const processItemsLookups = ({
57
59
 
58
60
  // if lazy loading is enabled, we don't want to process children passed through the `items` prop
59
61
  if (!ignoreChildren) {
60
- item.children?.forEach(child => processItem(child, depth + 1, id));
62
+ children?.forEach(child => processItem(child, depth + 1, id));
61
63
  }
62
64
  };
63
65
  items?.forEach(item => processItem(item, initialDepth, initialParentId));
@@ -160,6 +162,7 @@ export const useTreeViewItems = ({
160
162
  isItemDisabled: params.isItemDisabled,
161
163
  getItemId: params.getItemId,
162
164
  getItemLabel: params.getItemLabel,
165
+ getItemChildren: params.getItemChildren,
163
166
  getChildrenCount,
164
167
  initialDepth: depth,
165
168
  initialParentId: parentId,
@@ -241,7 +244,8 @@ export const useTreeViewItems = ({
241
244
  items: params.items,
242
245
  isItemDisabled: params.isItemDisabled,
243
246
  getItemId: params.getItemId,
244
- getItemLabel: params.getItemLabel
247
+ getItemLabel: params.getItemLabel,
248
+ getItemChildren: params.getItemChildren
245
249
  });
246
250
  Object.values(prevState.items.itemMetaLookup).forEach(item => {
247
251
  if (!newState.itemMetaLookup[item.id]) {
@@ -254,7 +258,7 @@ export const useTreeViewItems = ({
254
258
  items: _extends({}, prevState.items, newState)
255
259
  });
256
260
  });
257
- }, [instance, store, params.items, params.disabledItemsFocusable, params.isItemDisabled, params.getItemId, params.getItemLabel]);
261
+ }, [instance, store, params.items, params.disabledItemsFocusable, params.isItemDisabled, params.getItemId, params.getItemLabel, params.getItemChildren]);
258
262
 
259
263
  // Wrap `props.onItemClick` with `useEventCallback` to prevent unneeded context updates.
260
264
  const handleItemClick = useEventCallback((event, itemId) => {
@@ -294,7 +298,8 @@ useTreeViewItems.getInitialState = params => ({
294
298
  items: params.items,
295
299
  isItemDisabled: params.isItemDisabled,
296
300
  getItemId: params.getItemId,
297
- getItemLabel: params.getItemLabel
301
+ getItemLabel: params.getItemLabel,
302
+ getItemChildren: params.getItemChildren
298
303
  }), {
299
304
  loading: false,
300
305
  error: null
@@ -314,11 +319,13 @@ useTreeViewItems.wrapRoot = ({
314
319
  children: children
315
320
  });
316
321
  };
322
+ if (process.env.NODE_ENV !== "production") useTreeViewItems.wrapRoot.displayName = "useTreeViewItems.wrapRoot";
317
323
  useTreeViewItems.params = {
318
324
  disabledItemsFocusable: true,
319
325
  items: true,
320
326
  isItemDisabled: true,
321
327
  getItemLabel: true,
328
+ getItemChildren: true,
322
329
  getItemId: true,
323
330
  onItemClick: true,
324
331
  itemChildrenIndentation: true
@@ -115,6 +115,15 @@ export interface UseTreeViewItemsParameters<R extends {
115
115
  * @default (item) => item.label
116
116
  */
117
117
  getItemLabel?: (item: R) => string;
118
+ /**
119
+ * Used to determine the children of a given item.
120
+ *
121
+ * @template R
122
+ * @param {R} item The item to check.
123
+ * @returns {R[]} The children of the item.
124
+ * @default (item) => item.children
125
+ */
126
+ getItemChildren?: (item: R) => R[] | undefined;
118
127
  /**
119
128
  * Used to determine the id of a given item.
120
129
  *
@@ -170,6 +170,7 @@ useTreeViewJSXItems.wrapItem = ({
170
170
  })
171
171
  });
172
172
  };
173
+ if (process.env.NODE_ENV !== "production") useTreeViewJSXItems.wrapItem.displayName = "useTreeViewJSXItems.wrapItem";
173
174
  useTreeViewJSXItems.wrapRoot = ({
174
175
  children
175
176
  }) => /*#__PURE__*/_jsx(TreeViewChildrenItemProvider, {
@@ -180,4 +181,5 @@ useTreeViewJSXItems.wrapRoot = ({
180
181
  children: children
181
182
  })
182
183
  });
184
+ if (process.env.NODE_ENV !== "production") useTreeViewJSXItems.wrapRoot.displayName = "useTreeViewJSXItems.wrapRoot";
183
185
  useTreeViewJSXItems.params = {};
@@ -99,7 +99,7 @@ export const useTreeViewKeyboardNavigation = ({
99
99
  case key === 'Enter':
100
100
  {
101
101
  if (hasPlugin(instance, useTreeViewLabel) && selectorIsItemEditable(store.value, itemId) && !selectorIsItemBeingEdited(store.value, itemId)) {
102
- instance.setEditedItemId(itemId);
102
+ instance.setEditedItem(itemId);
103
103
  } else if (canToggleItemExpansion(itemId)) {
104
104
  instance.setItemExpansion({
105
105
  event,
@@ -1,11 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
3
  import { useTreeViewLabelItemPlugin } from "./useTreeViewLabel.itemPlugin.js";
4
+ import { selectorIsItemEditable } from "./useTreeViewLabel.selectors.js";
4
5
  export const useTreeViewLabel = ({
5
6
  store,
6
7
  params
7
8
  }) => {
8
- const setEditedItemId = editedItemId => {
9
+ const setEditedItem = editedItemId => {
10
+ if (editedItemId !== null) {
11
+ const isEditable = selectorIsItemEditable(store.value, editedItemId);
12
+ if (!isEditable) {
13
+ return;
14
+ }
15
+ }
9
16
  store.update(prevState => _extends({}, prevState, {
10
17
  label: _extends({}, prevState.label, {
11
18
  editedItemId
@@ -44,10 +51,11 @@ export const useTreeViewLabel = ({
44
51
  }, [store, params.isItemEditable]);
45
52
  return {
46
53
  instance: {
47
- setEditedItemId,
54
+ setEditedItem,
48
55
  updateItemLabel
49
56
  },
50
57
  publicAPI: {
58
+ setEditedItem,
51
59
  updateItemLabel
52
60
  }
53
61
  };
@@ -10,15 +10,14 @@ export interface UseTreeViewLabelPublicAPI {
10
10
  * @param {string} newLabel The new label of the item.
11
11
  */
12
12
  updateItemLabel: (itemId: TreeViewItemId, newLabel: string) => void;
13
- }
14
- export interface UseTreeViewLabelInstance extends UseTreeViewLabelPublicAPI {
15
13
  /**
16
- * Updates which item is currently being edited.
17
- * @param {TreeViewItemId} itemId The id of the item that is currently being edited.
18
- * @returns {void}.
14
+ * Set which item is currently being edited.
15
+ * You can pass `null` to exit editing mode.
16
+ * @param {TreeViewItemId | null} itemId The id of the item to edit, or `null` to exit editing mode.
19
17
  */
20
- setEditedItemId: (itemId: TreeViewItemId | null) => void;
18
+ setEditedItem: (itemId: TreeViewItemId | null) => void;
21
19
  }
20
+ export interface UseTreeViewLabelInstance extends UseTreeViewLabelPublicAPI {}
22
21
  export interface UseTreeViewLabelParameters<R extends {}> {
23
22
  /**
24
23
  * Callback fired when the label of an item changes.
@@ -123,12 +123,10 @@ const useTreeItemUtils = ({
123
123
  if (!(0, _plugins.hasPlugin)(instance, _useTreeViewLabel.useTreeViewLabel)) {
124
124
  return;
125
125
  }
126
- if (isEditable) {
127
- if (isEditing) {
128
- instance.setEditedItemId(null);
129
- } else {
130
- instance.setEditedItemId(itemId);
131
- }
126
+ if (isEditing) {
127
+ instance.setEditedItem(null);
128
+ } else {
129
+ instance.setEditedItem(itemId);
132
130
  }
133
131
  };
134
132
  const handleSaveItemLabel = (event, newLabel) => {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v8.3.1
2
+ * @mui/x-tree-view v8.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -7,6 +7,4 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.TreeViewItemDepthContext = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  const TreeViewItemDepthContext = exports.TreeViewItemDepthContext = /*#__PURE__*/React.createContext(() => -1);
10
- if (process.env.NODE_ENV !== 'production') {
11
- TreeViewItemDepthContext.displayName = 'TreeViewItemDepthContext';
12
- }
10
+ if (process.env.NODE_ENV !== "production") TreeViewItemDepthContext.displayName = "TreeViewItemDepthContext";
@@ -14,9 +14,7 @@ var _utils = require("../utils/utils");
14
14
  var _useTreeViewItems = require("../plugins/useTreeViewItems/useTreeViewItems.selectors");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  const TreeViewChildrenItemContext = exports.TreeViewChildrenItemContext = /*#__PURE__*/React.createContext(null);
17
- if (process.env.NODE_ENV !== 'production') {
18
- TreeViewChildrenItemContext.displayName = 'TreeViewChildrenItemContext';
19
- }
17
+ if (process.env.NODE_ENV !== "production") TreeViewChildrenItemContext.displayName = "TreeViewChildrenItemContext";
20
18
  function TreeViewChildrenItemProvider(props) {
21
19
  const {
22
20
  children,
@@ -10,9 +10,7 @@ var React = _interopRequireWildcard(require("react"));
10
10
  * @ignore - internal component.
11
11
  */
12
12
  const TreeViewContext = exports.TreeViewContext = /*#__PURE__*/React.createContext(null);
13
- if (process.env.NODE_ENV !== 'production') {
14
- TreeViewContext.displayName = 'TreeViewContext';
15
- }
13
+ if (process.env.NODE_ENV !== "production") TreeViewContext.displayName = "TreeViewContext";
16
14
  const useTreeViewContext = () => {
17
15
  const context = React.useContext(TreeViewContext);
18
16
  if (context == null) {
@@ -14,9 +14,7 @@ const TreeViewStyleContext = exports.TreeViewStyleContext = /*#__PURE__*/React.c
14
14
  slots: {},
15
15
  slotProps: {}
16
16
  });
17
- if (process.env.NODE_ENV !== 'production') {
18
- TreeViewStyleContext.displayName = 'TreeViewStyleContext';
19
- }
17
+ if (process.env.NODE_ENV !== "production") TreeViewStyleContext.displayName = "TreeViewStyleContext";
20
18
  const useTreeViewStyleContext = () => {
21
19
  return React.useContext(TreeViewStyleContext);
22
20
  };
@@ -18,9 +18,7 @@ var _TreeViewProvider = require("../TreeViewProvider");
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
  const _excluded = ["ownerState"];
20
20
  const RichTreeViewItemsContext = /*#__PURE__*/React.createContext(null);
21
- if (process.env.NODE_ENV !== 'production') {
22
- RichTreeViewItemsContext.displayName = 'RichTreeViewItemsProvider';
23
- }
21
+ if (process.env.NODE_ENV !== "production") RichTreeViewItemsContext.displayName = "RichTreeViewItemsContext";
24
22
  const WrappedTreeItem = /*#__PURE__*/React.memo(function WrappedTreeItem({
25
23
  itemSlot,
26
24
  itemSlotProps,
@@ -51,6 +49,7 @@ const WrappedTreeItem = /*#__PURE__*/React.memo(function WrappedTreeItem({
51
49
  children: children?.map(renderItemForRichTreeView)
52
50
  }));
53
51
  }, _fastObjectShallowCompare.fastObjectShallowCompare);
52
+ if (process.env.NODE_ENV !== "production") WrappedTreeItem.displayName = "WrappedTreeItem";
54
53
  function RichTreeViewItems(props) {
55
54
  const {
56
55
  slots,
@@ -29,6 +29,7 @@ const processItemsLookups = ({
29
29
  items,
30
30
  isItemDisabled,
31
31
  getItemLabel,
32
+ getItemChildren,
32
33
  getItemId,
33
34
  initialDepth = 0,
34
35
  initialParentId = null,
@@ -47,12 +48,13 @@ const processItemsLookups = ({
47
48
  if (label == null) {
48
49
  throw new Error(['MUI X: The Tree View component requires all items to have a `label` property.', 'Alternatively, you can use the `getItemLabel` prop to specify a custom label for each item.', 'An item was provided without label in the `items` prop:', JSON.stringify(item)].join('\n'));
49
50
  }
51
+ const children = getItemChildren ? getItemChildren(item) : item.children;
50
52
  itemMetaLookup[id] = {
51
53
  id,
52
54
  label,
53
55
  parentId,
54
56
  idAttribute: undefined,
55
- expandable: getChildrenCount ? getChildrenCount(item) > 0 : !!item.children?.length,
57
+ expandable: getChildrenCount ? getChildrenCount(item) > 0 : !!children?.length,
56
58
  disabled: isItemDisabled ? isItemDisabled(item) : false,
57
59
  depth
58
60
  };
@@ -65,7 +67,7 @@ const processItemsLookups = ({
65
67
 
66
68
  // if lazy loading is enabled, we don't want to process children passed through the `items` prop
67
69
  if (!ignoreChildren) {
68
- item.children?.forEach(child => processItem(child, depth + 1, id));
70
+ children?.forEach(child => processItem(child, depth + 1, id));
69
71
  }
70
72
  };
71
73
  items?.forEach(item => processItem(item, initialDepth, initialParentId));
@@ -168,6 +170,7 @@ const useTreeViewItems = ({
168
170
  isItemDisabled: params.isItemDisabled,
169
171
  getItemId: params.getItemId,
170
172
  getItemLabel: params.getItemLabel,
173
+ getItemChildren: params.getItemChildren,
171
174
  getChildrenCount,
172
175
  initialDepth: depth,
173
176
  initialParentId: parentId,
@@ -249,7 +252,8 @@ const useTreeViewItems = ({
249
252
  items: params.items,
250
253
  isItemDisabled: params.isItemDisabled,
251
254
  getItemId: params.getItemId,
252
- getItemLabel: params.getItemLabel
255
+ getItemLabel: params.getItemLabel,
256
+ getItemChildren: params.getItemChildren
253
257
  });
254
258
  Object.values(prevState.items.itemMetaLookup).forEach(item => {
255
259
  if (!newState.itemMetaLookup[item.id]) {
@@ -262,7 +266,7 @@ const useTreeViewItems = ({
262
266
  items: (0, _extends2.default)({}, prevState.items, newState)
263
267
  });
264
268
  });
265
- }, [instance, store, params.items, params.disabledItemsFocusable, params.isItemDisabled, params.getItemId, params.getItemLabel]);
269
+ }, [instance, store, params.items, params.disabledItemsFocusable, params.isItemDisabled, params.getItemId, params.getItemLabel, params.getItemChildren]);
266
270
 
267
271
  // Wrap `props.onItemClick` with `useEventCallback` to prevent unneeded context updates.
268
272
  const handleItemClick = (0, _useEventCallback.default)((event, itemId) => {
@@ -303,7 +307,8 @@ useTreeViewItems.getInitialState = params => ({
303
307
  items: params.items,
304
308
  isItemDisabled: params.isItemDisabled,
305
309
  getItemId: params.getItemId,
306
- getItemLabel: params.getItemLabel
310
+ getItemLabel: params.getItemLabel,
311
+ getItemChildren: params.getItemChildren
307
312
  }), {
308
313
  loading: false,
309
314
  error: null
@@ -323,11 +328,13 @@ useTreeViewItems.wrapRoot = ({
323
328
  children: children
324
329
  });
325
330
  };
331
+ if (process.env.NODE_ENV !== "production") useTreeViewItems.wrapRoot.displayName = "useTreeViewItems.wrapRoot";
326
332
  useTreeViewItems.params = {
327
333
  disabledItemsFocusable: true,
328
334
  items: true,
329
335
  isItemDisabled: true,
330
336
  getItemLabel: true,
337
+ getItemChildren: true,
331
338
  getItemId: true,
332
339
  onItemClick: true,
333
340
  itemChildrenIndentation: true
@@ -115,6 +115,15 @@ export interface UseTreeViewItemsParameters<R extends {
115
115
  * @default (item) => item.label
116
116
  */
117
117
  getItemLabel?: (item: R) => string;
118
+ /**
119
+ * Used to determine the children of a given item.
120
+ *
121
+ * @template R
122
+ * @param {R} item The item to check.
123
+ * @returns {R[]} The children of the item.
124
+ * @default (item) => item.children
125
+ */
126
+ getItemChildren?: (item: R) => R[] | undefined;
118
127
  /**
119
128
  * Used to determine the id of a given item.
120
129
  *
@@ -179,6 +179,7 @@ useTreeViewJSXItems.wrapItem = ({
179
179
  })
180
180
  });
181
181
  };
182
+ if (process.env.NODE_ENV !== "production") useTreeViewJSXItems.wrapItem.displayName = "useTreeViewJSXItems.wrapItem";
182
183
  useTreeViewJSXItems.wrapRoot = ({
183
184
  children
184
185
  }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeViewChildrenItemProvider.TreeViewChildrenItemProvider, {
@@ -189,4 +190,5 @@ useTreeViewJSXItems.wrapRoot = ({
189
190
  children: children
190
191
  })
191
192
  });
193
+ if (process.env.NODE_ENV !== "production") useTreeViewJSXItems.wrapRoot.displayName = "useTreeViewJSXItems.wrapRoot";
192
194
  useTreeViewJSXItems.params = {};
@@ -107,7 +107,7 @@ const useTreeViewKeyboardNavigation = ({
107
107
  case key === 'Enter':
108
108
  {
109
109
  if ((0, _plugins.hasPlugin)(instance, _useTreeViewLabel.useTreeViewLabel) && (0, _useTreeViewLabel2.selectorIsItemEditable)(store.value, itemId) && !(0, _useTreeViewLabel2.selectorIsItemBeingEdited)(store.value, itemId)) {
110
- instance.setEditedItemId(itemId);
110
+ instance.setEditedItem(itemId);
111
111
  } else if (canToggleItemExpansion(itemId)) {
112
112
  instance.setItemExpansion({
113
113
  event,
@@ -8,11 +8,18 @@ exports.useTreeViewLabel = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
10
10
  var _useTreeViewLabel = require("./useTreeViewLabel.itemPlugin");
11
+ var _useTreeViewLabel2 = require("./useTreeViewLabel.selectors");
11
12
  const useTreeViewLabel = ({
12
13
  store,
13
14
  params
14
15
  }) => {
15
- const setEditedItemId = editedItemId => {
16
+ const setEditedItem = editedItemId => {
17
+ if (editedItemId !== null) {
18
+ const isEditable = (0, _useTreeViewLabel2.selectorIsItemEditable)(store.value, editedItemId);
19
+ if (!isEditable) {
20
+ return;
21
+ }
22
+ }
16
23
  store.update(prevState => (0, _extends2.default)({}, prevState, {
17
24
  label: (0, _extends2.default)({}, prevState.label, {
18
25
  editedItemId
@@ -51,10 +58,11 @@ const useTreeViewLabel = ({
51
58
  }, [store, params.isItemEditable]);
52
59
  return {
53
60
  instance: {
54
- setEditedItemId,
61
+ setEditedItem,
55
62
  updateItemLabel
56
63
  },
57
64
  publicAPI: {
65
+ setEditedItem,
58
66
  updateItemLabel
59
67
  }
60
68
  };
@@ -10,15 +10,14 @@ export interface UseTreeViewLabelPublicAPI {
10
10
  * @param {string} newLabel The new label of the item.
11
11
  */
12
12
  updateItemLabel: (itemId: TreeViewItemId, newLabel: string) => void;
13
- }
14
- export interface UseTreeViewLabelInstance extends UseTreeViewLabelPublicAPI {
15
13
  /**
16
- * Updates which item is currently being edited.
17
- * @param {TreeViewItemId} itemId The id of the item that is currently being edited.
18
- * @returns {void}.
14
+ * Set which item is currently being edited.
15
+ * You can pass `null` to exit editing mode.
16
+ * @param {TreeViewItemId | null} itemId The id of the item to edit, or `null` to exit editing mode.
19
17
  */
20
- setEditedItemId: (itemId: TreeViewItemId | null) => void;
18
+ setEditedItem: (itemId: TreeViewItemId | null) => void;
21
19
  }
20
+ export interface UseTreeViewLabelInstance extends UseTreeViewLabelPublicAPI {}
22
21
  export interface UseTreeViewLabelParameters<R extends {}> {
23
22
  /**
24
23
  * Callback fired when the label of an item changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-tree-view",
3
- "version": "8.3.1",
3
+ "version": "8.4.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of the MUI X Tree View components.",
6
6
  "main": "./index.js",
@@ -41,7 +41,7 @@
41
41
  "react-transition-group": "^4.4.5",
42
42
  "reselect": "^5.1.1",
43
43
  "use-sync-external-store": "^1.5.0",
44
- "@mui/x-internals": "8.3.1"
44
+ "@mui/x-internals": "8.4.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@emotion/react": "^11.9.0",