@mui/x-tree-view 7.20.0 → 7.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +200 -31
  2. package/RichTreeView/RichTreeView.js +8 -8
  3. package/SimpleTreeView/SimpleTreeView.js +8 -8
  4. package/TreeItem/TreeItem.js +15 -14
  5. package/TreeItem/TreeItem.types.d.ts +8 -9
  6. package/TreeItem/TreeItemContent.d.ts +5 -5
  7. package/TreeItem/TreeItemContent.js +4 -4
  8. package/TreeItem/treeItemClasses.d.ts +1 -1
  9. package/TreeItem/useTreeItemState.d.ts +2 -2
  10. package/TreeItem2/TreeItem2.types.d.ts +4 -4
  11. package/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +7 -7
  12. package/TreeItem2Icon/TreeItem2Icon.types.d.ts +1 -1
  13. package/TreeItem2LabelInput/TreeItem2LabelInput.types.d.ts +3 -3
  14. package/TreeView/TreeView.d.ts +1 -1
  15. package/TreeView/TreeView.js +8 -8
  16. package/index.js +1 -1
  17. package/internals/corePlugins/corePlugins.d.ts +1 -1
  18. package/internals/corePlugins/corePlugins.js +1 -1
  19. package/internals/corePlugins/useTreeViewId/useTreeViewId.js +3 -3
  20. package/internals/corePlugins/useTreeViewId/useTreeViewId.types.d.ts +1 -1
  21. package/internals/corePlugins/useTreeViewId/useTreeViewId.utils.d.ts +1 -1
  22. package/internals/corePlugins/useTreeViewId/useTreeViewId.utils.js +1 -1
  23. package/internals/index.d.ts +1 -1
  24. package/internals/models/index.d.ts +0 -1
  25. package/internals/models/index.js +1 -2
  26. package/internals/models/treeView.d.ts +2 -2
  27. package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +2 -2
  28. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.d.ts +1 -1
  29. package/internals/plugins/useTreeViewIcons/useTreeViewIcons.types.d.ts +1 -1
  30. package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +2 -2
  31. package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  32. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +3 -3
  33. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +4 -4
  34. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +1 -1
  35. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.types.d.ts +1 -1
  36. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +3 -3
  37. package/models/events.d.ts +4 -0
  38. package/models/index.d.ts +1 -0
  39. package/models/index.js +1 -0
  40. package/modern/RichTreeView/RichTreeView.js +8 -8
  41. package/modern/SimpleTreeView/SimpleTreeView.js +8 -8
  42. package/modern/TreeItem/TreeItem.js +15 -14
  43. package/modern/TreeItem/TreeItemContent.js +4 -4
  44. package/modern/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +7 -7
  45. package/modern/TreeView/TreeView.js +8 -8
  46. package/modern/index.js +1 -1
  47. package/modern/internals/corePlugins/corePlugins.js +1 -1
  48. package/modern/internals/corePlugins/useTreeViewId/useTreeViewId.js +3 -3
  49. package/modern/internals/corePlugins/useTreeViewId/useTreeViewId.utils.js +1 -1
  50. package/modern/internals/models/index.js +1 -2
  51. package/modern/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  52. package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +3 -3
  53. package/modern/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +1 -1
  54. package/modern/models/index.js +1 -0
  55. package/modern/useTreeItem2/useTreeItem2.js +11 -11
  56. package/node/RichTreeView/RichTreeView.js +8 -8
  57. package/node/SimpleTreeView/SimpleTreeView.js +8 -8
  58. package/node/TreeItem/TreeItem.js +15 -14
  59. package/node/TreeItem/TreeItemContent.js +4 -4
  60. package/node/TreeItem2DragAndDropOverlay/TreeItem2DragAndDropOverlay.js +7 -7
  61. package/node/TreeView/TreeView.js +8 -8
  62. package/node/index.js +1 -1
  63. package/node/internals/corePlugins/corePlugins.js +1 -1
  64. package/node/internals/corePlugins/useTreeViewId/useTreeViewId.js +3 -3
  65. package/node/internals/corePlugins/useTreeViewId/useTreeViewId.utils.js +1 -1
  66. package/node/internals/models/index.js +0 -11
  67. package/node/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  68. package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +3 -3
  69. package/node/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +1 -1
  70. package/node/models/index.js +11 -0
  71. package/node/useTreeItem2/useTreeItem2.js +11 -11
  72. package/package.json +2 -2
  73. package/useTreeItem2/useTreeItem2.js +11 -11
  74. package/useTreeItem2/useTreeItem2.types.d.ts +11 -11
  75. package/internals/models/MuiCancellableEvent.d.ts +0 -4
  76. /package/{internals/models/MuiCancellableEvent.js → models/events.js} +0 -0
  77. /package/modern/{internals/models/MuiCancellableEvent.js → models/events.js} +0 -0
  78. /package/node/{internals/models/MuiCancellableEvent.js → models/events.js} +0 -0
@@ -5,9 +5,8 @@ import { TransitionProps } from '@mui/material/transitions';
5
5
  import { SxProps } from '@mui/system';
6
6
  import { TreeItemContentProps } from './TreeItemContent';
7
7
  import { TreeItemClasses } from './treeItemClasses';
8
- import { TreeViewItemId } from '../models';
8
+ import { TreeViewItemId, TreeViewCancellableEventHandler } from '../models';
9
9
  import { SlotComponentPropsFromProps } from '../internals/models';
10
- import { MuiCancellableEventHandler } from '../internals/models/MuiCancellableEvent';
11
10
  import { UseTreeViewIconsSignature } from '../internals/plugins/useTreeViewIcons';
12
11
  import { UseTreeViewSelectionSignature } from '../internals/plugins/useTreeViewSelection';
13
12
  import { UseTreeViewItemsSignature } from '../internals/plugins/useTreeViewItems';
@@ -28,7 +27,7 @@ export interface TreeItemSlots {
28
27
  */
29
28
  endIcon?: React.ElementType;
30
29
  /**
31
- * The icon to display next to the tree item's label.
30
+ * The icon to display next to the Tree Item's label.
32
31
  */
33
32
  icon?: React.ElementType;
34
33
  /**
@@ -66,13 +65,13 @@ export interface TreeItemProps extends Omit<React.HTMLAttributes<HTMLLIElement>,
66
65
  slotProps?: TreeItemSlotProps;
67
66
  /**
68
67
  * 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/.
68
+ * @deprecated Consider using the `<TreeItem2 />` component or the `useTreeItem2` hook instead. For more details, see https://mui.com/x/react-tree-view/tree-item-customization/.
70
69
  * @default TreeItemContent
71
70
  */
72
71
  ContentComponent?: React.JSXElementConstructor<TreeItemContentProps>;
73
72
  /**
74
73
  * 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
+ * @deprecated Consider using the `<TreeItem2 />` component or the `useTreeItem2` hook instead. For more details, see https://mui.com/x/react-tree-view/tree-item-customization/.
76
75
  */
77
76
  ContentProps?: React.HTMLAttributes<HTMLElement> & {
78
77
  ref?: React.Ref<HTMLElement>;
@@ -88,7 +87,7 @@ export interface TreeItemProps extends Omit<React.HTMLAttributes<HTMLLIElement>,
88
87
  */
89
88
  onFocus?: null;
90
89
  /**
91
- * The tree item label.
90
+ * The Tree Item label.
92
91
  */
93
92
  label?: React.ReactNode;
94
93
  /**
@@ -102,7 +101,7 @@ export interface TreeItemProps extends Omit<React.HTMLAttributes<HTMLLIElement>,
102
101
  /**
103
102
  * Callback fired when a key of the keyboard is pressed on the item.
104
103
  */
105
- onKeyDown?: MuiCancellableEventHandler<React.KeyboardEvent<HTMLLIElement>>;
104
+ onKeyDown?: TreeViewCancellableEventHandler<React.KeyboardEvent<HTMLLIElement>>;
106
105
  }
107
106
  export interface TreeItemOwnerState extends TreeItemProps {
108
107
  expanded: boolean;
@@ -112,7 +111,7 @@ export interface TreeItemOwnerState extends TreeItemProps {
112
111
  indentationAtItemLevel: boolean;
113
112
  }
114
113
  /**
115
- * Plugins that need to be present in the Tree View in order for `TreeItem` to work correctly.
114
+ * Plugins that need to be present in the Tree View in order for Tree Item to work correctly.
116
115
  */
117
116
  export type TreeItemMinimalPlugins = readonly [
118
117
  UseTreeViewIconsSignature,
@@ -123,6 +122,6 @@ export type TreeItemMinimalPlugins = readonly [
123
122
  UseTreeViewKeyboardNavigationSignature
124
123
  ];
125
124
  /**
126
- * Plugins that `TreeItem` can use if they are present, but are not required.
125
+ * Plugins that Tree Item can use if they are present, but are not required.
127
126
  */
128
127
  export type TreeItemOptionalPlugins = readonly [];
@@ -17,7 +17,7 @@ export interface TreeItemContentProps extends React.HTMLAttributes<HTMLElement>
17
17
  focused: string;
18
18
  /** State class applied to the element when disabled. */
19
19
  disabled: string;
20
- /** Styles applied to the tree item icon and collapse/expand icon. */
20
+ /** Styles applied to the Tree Item icon and collapse/expand icon. */
21
21
  iconContainer: string;
22
22
  /** Styles applied to the label element. */
23
23
  label: string;
@@ -31,7 +31,7 @@ export interface TreeItemContentProps extends React.HTMLAttributes<HTMLElement>
31
31
  editable: string;
32
32
  };
33
33
  /**
34
- * The tree item label.
34
+ * The Tree Item label.
35
35
  */
36
36
  label?: React.ReactNode;
37
37
  /**
@@ -39,15 +39,15 @@ export interface TreeItemContentProps extends React.HTMLAttributes<HTMLElement>
39
39
  */
40
40
  itemId: string;
41
41
  /**
42
- * The icon to display next to the tree item's label.
42
+ * The icon to display next to the Tree Item's label.
43
43
  */
44
44
  icon?: React.ReactNode;
45
45
  /**
46
- * The icon to display next to the tree item's label. Either an expansion or collapse icon.
46
+ * The icon to display next to the Tree Item's label. Either an expansion or collapse icon.
47
47
  */
48
48
  expansionIcon?: React.ReactNode;
49
49
  /**
50
- * The icon to display next to the tree item's label. Either a parent or end icon.
50
+ * The icon to display next to the Tree Item's label. Either a parent or end icon.
51
51
  */
52
52
  displayIcon?: React.ReactNode;
53
53
  dragAndDropOverlayProps?: TreeItem2DragAndDropOverlayProps;
@@ -110,7 +110,7 @@ process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
110
110
  classes: PropTypes.object.isRequired,
111
111
  className: PropTypes.string,
112
112
  /**
113
- * The icon to display next to the tree item's label. Either a parent or end icon.
113
+ * The icon to display next to the Tree Item's label. Either a parent or end icon.
114
114
  */
115
115
  displayIcon: PropTypes.node,
116
116
  dragAndDropOverlayProps: PropTypes.shape({
@@ -118,11 +118,11 @@ process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
118
118
  style: PropTypes.object
119
119
  }),
120
120
  /**
121
- * The icon to display next to the tree item's label. Either an expansion or collapse icon.
121
+ * The icon to display next to the Tree Item's label. Either an expansion or collapse icon.
122
122
  */
123
123
  expansionIcon: PropTypes.node,
124
124
  /**
125
- * The icon to display next to the tree item's label.
125
+ * The icon to display next to the Tree Item's label.
126
126
  */
127
127
  icon: PropTypes.node,
128
128
  /**
@@ -130,7 +130,7 @@ process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
130
130
  */
131
131
  itemId: PropTypes.string.isRequired,
132
132
  /**
133
- * The tree item label.
133
+ * The Tree Item label.
134
134
  */
135
135
  label: PropTypes.node,
136
136
  labelInputProps: PropTypes.shape({
@@ -13,7 +13,7 @@ export interface TreeItemClasses {
13
13
  focused: string;
14
14
  /** State class applied to the element when disabled. */
15
15
  disabled: string;
16
- /** Styles applied to the tree item icon. */
16
+ /** Styles applied to the Tree Item icon. */
17
17
  iconContainer: string;
18
18
  /** Styles applied to the label element. */
19
19
  label: string;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { MuiCancellableEvent } from '../internals/models/MuiCancellableEvent';
2
+ import { TreeViewCancellableEvent } from '../models';
3
3
  export declare function useTreeItemState(itemId: string): {
4
4
  disabled: boolean;
5
5
  expanded: boolean;
@@ -16,6 +16,6 @@ export declare function useTreeItemState(itemId: string): {
16
16
  preventSelection: (event: React.MouseEvent<HTMLDivElement>) => void;
17
17
  expansionTrigger: "content" | "iconContainer" | undefined;
18
18
  toggleItemEditing: () => void;
19
- handleSaveItemLabel: (event: React.SyntheticEvent & MuiCancellableEvent, label: string) => void;
19
+ handleSaveItemLabel: (event: React.SyntheticEvent & TreeViewCancellableEvent, label: string) => void;
20
20
  handleCancelItemLabelEditing: (event: React.SyntheticEvent) => void;
21
21
  };
@@ -3,7 +3,7 @@ import { SlotComponentProps } from '@mui/utils';
3
3
  import { UseTreeItem2Parameters, UseTreeItem2Status } from '../useTreeItem2';
4
4
  import { TreeItemClasses } from '../TreeItem';
5
5
  import { TreeItem2IconSlotProps, TreeItem2IconSlots } from '../TreeItem2Icon';
6
- import { MuiCancellableEventHandler } from '../internals/models/MuiCancellableEvent';
6
+ import { TreeViewCancellableEventHandler } from '../models';
7
7
  export interface TreeItem2Slots extends TreeItem2IconSlots {
8
8
  /**
9
9
  * The component that renders the root.
@@ -43,7 +43,7 @@ export interface TreeItem2Slots extends TreeItem2IconSlots {
43
43
  labelInput?: React.ElementType;
44
44
  /**
45
45
  * The component that renders the overlay when an item reordering is ongoing.
46
- * Warning: This slot is only useful when using the `RichTreeViewPro` component.
46
+ * Warning: This slot is only useful when using the `<RichTreeViewPro />` component.
47
47
  * @default TreeItem2DragAndDropOverlay
48
48
  */
49
49
  dragAndDropOverlay?: React.ElementType;
@@ -82,11 +82,11 @@ export interface TreeItem2Props extends Omit<UseTreeItem2Parameters, 'rootRef'>,
82
82
  /**
83
83
  * Callback fired when the item root is blurred.
84
84
  */
85
- onBlur?: MuiCancellableEventHandler<React.FocusEvent<HTMLLIElement>>;
85
+ onBlur?: TreeViewCancellableEventHandler<React.FocusEvent<HTMLLIElement>>;
86
86
  /**
87
87
  * Callback fired when a key is pressed on the keyboard and the tree is in focus.
88
88
  */
89
- onKeyDown?: MuiCancellableEventHandler<React.KeyboardEvent<HTMLLIElement>>;
89
+ onKeyDown?: TreeViewCancellableEventHandler<React.KeyboardEvent<HTMLLIElement>>;
90
90
  }
91
91
  export interface TreeItem2OwnerState extends Omit<TreeItem2Props, 'disabled'>, UseTreeItem2Status {
92
92
  }
@@ -26,7 +26,7 @@ const TreeItem2DragAndDropOverlayRoot = styled('div', {
26
26
  style: {
27
27
  marginLeft: 'calc(var(--TreeView-indentMultiplier) * var(--TreeView-itemDepth))',
28
28
  borderRadius: theme.shape.borderRadius,
29
- backgroundColor: alpha((theme.vars || theme).palette.primary.dark, 0.15)
29
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.dark} / ${0.15})` : alpha(theme.palette.primary.dark, 0.15)
30
30
  }
31
31
  }, {
32
32
  props: {
@@ -34,9 +34,9 @@ const TreeItem2DragAndDropOverlayRoot = styled('div', {
34
34
  },
35
35
  style: _extends({
36
36
  marginLeft: 'calc(var(--TreeView-indentMultiplier) * var(--TreeView-itemDepth))',
37
- borderTop: `1px solid ${alpha((theme.vars || theme).palette.grey[900], 0.6)}`
37
+ borderTop: theme.vars ? `1px solid rgba(${theme.vars.palette.grey[900]} / ${0.6})` : `1px solid ${alpha(theme.palette.grey[900], 0.6)}`
38
38
  }, theme.applyStyles('dark', {
39
- borderTopColor: alpha((theme.vars || theme).palette.grey[100], 0.6)
39
+ borderTopColor: theme.vars ? `rgba(${theme.vars.palette.grey[100]} / ${0.6})` : alpha(theme.palette.grey[100], 0.6)
40
40
  }))
41
41
  }, {
42
42
  props: {
@@ -44,9 +44,9 @@ const TreeItem2DragAndDropOverlayRoot = styled('div', {
44
44
  },
45
45
  style: _extends({
46
46
  marginLeft: 'calc(var(--TreeView-indentMultiplier) * var(--TreeView-itemDepth))',
47
- borderBottom: `1px solid ${alpha((theme.vars || theme).palette.grey[900], 0.6)}`
47
+ borderBottom: theme.vars ? `1px solid rgba(${theme.vars.palette.grey[900]} / ${0.6})` : `1px solid ${alpha(theme.palette.grey[900], 0.6)}`
48
48
  }, theme.applyStyles('dark', {
49
- borderBottomColor: alpha((theme.vars || theme).palette.grey[100], 0.6)
49
+ borderBottomColor: theme.vars ? `rgba(${theme.vars.palette.grey[100]} / ${0.6})` : alpha(theme.palette.grey[100], 0.6)
50
50
  }))
51
51
  }, {
52
52
  props: {
@@ -54,9 +54,9 @@ const TreeItem2DragAndDropOverlayRoot = styled('div', {
54
54
  },
55
55
  style: _extends({
56
56
  marginLeft: 'calc(var(--TreeView-indentMultiplier) * calc(var(--TreeView-itemDepth) - 1))',
57
- borderBottom: `1px solid ${alpha((theme.vars || theme).palette.grey[900], 0.6)}`
57
+ borderBottom: theme.vars ? `1px solid rgba(${theme.vars.palette.grey[900]} / ${0.6})` : `1px solid ${alpha(theme.palette.grey[900], 0.6)}`
58
58
  }, theme.applyStyles('dark', {
59
- borderBottomColor: alpha((theme.vars || theme).palette.grey[900], 0.6)
59
+ borderBottomColor: theme.vars ? `rgba(${theme.vars.palette.grey[100]} / ${0.6})` : alpha(theme.palette.grey[100], 0.6)
60
60
  }))
61
61
  }]
62
62
  }));
@@ -15,7 +15,7 @@ export interface TreeItem2IconSlots {
15
15
  */
16
16
  endIcon?: React.ElementType;
17
17
  /**
18
- * The icon to display next to the tree item's label.
18
+ * The icon to display next to the Tree Item's label.
19
19
  */
20
20
  icon?: React.ElementType;
21
21
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { MuiCancellableEventHandler } from '../internals/models/MuiCancellableEvent';
2
+ import { TreeViewCancellableEventHandler } from '../models';
3
3
  export interface TreeItem2LabelInputProps {
4
4
  value?: string;
5
5
  /**
@@ -7,8 +7,8 @@ export interface TreeItem2LabelInputProps {
7
7
  */
8
8
  'data-element'?: 'labelInput';
9
9
  onChange?: React.ChangeEventHandler<HTMLInputElement>;
10
- onKeyDown?: MuiCancellableEventHandler<React.KeyboardEvent<HTMLInputElement>>;
11
- onBlur?: MuiCancellableEventHandler<React.FocusEvent<HTMLInputElement>>;
10
+ onKeyDown?: TreeViewCancellableEventHandler<React.KeyboardEvent<HTMLInputElement>>;
11
+ onBlur?: TreeViewCancellableEventHandler<React.FocusEvent<HTMLInputElement>>;
12
12
  autoFocus?: true;
13
13
  type?: 'text';
14
14
  }
@@ -4,7 +4,7 @@ type TreeViewComponent = (<Multiple extends boolean | undefined = undefined>(pro
4
4
  propTypes?: any;
5
5
  };
6
6
  /**
7
- * This component has been deprecated in favor of the new `SimpleTreeView` component.
7
+ * This component has been deprecated in favor of the new Simple Tree View component.
8
8
  * You can have a look at how to migrate to the new component in the v7 [migration guide](https://mui.com/x/migration/migration-tree-view-v6/#use-simpletreeview-instead-of-treeview)
9
9
  *
10
10
  * Demos:
@@ -32,7 +32,7 @@ const warn = () => {
32
32
  };
33
33
 
34
34
  /**
35
- * This component has been deprecated in favor of the new `SimpleTreeView` component.
35
+ * This component has been deprecated in favor of the new Simple Tree View component.
36
36
  * You can have a look at how to migrate to the new component in the v7 [migration guide](https://mui.com/x/migration/migration-tree-view-v6/#use-simpletreeview-instead-of-treeview)
37
37
  *
38
38
  * Demos:
@@ -82,7 +82,7 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
82
82
  })
83
83
  }),
84
84
  /**
85
- * If `true`, the tree view renders a checkbox at the left of its label that allows selecting it.
85
+ * If `true`, the Tree View renders a checkbox at the left of its label that allows selecting it.
86
86
  * @default false
87
87
  */
88
88
  checkboxSelection: PropTypes.bool,
@@ -152,39 +152,39 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
152
152
  */
153
153
  multiSelect: PropTypes.bool,
154
154
  /**
155
- * Callback fired when tree items are expanded/collapsed.
155
+ * Callback fired when Tree Items are expanded/collapsed.
156
156
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
157
157
  * @param {array} itemIds The ids of the expanded items.
158
158
  */
159
159
  onExpandedItemsChange: PropTypes.func,
160
160
  /**
161
- * Callback fired when the `content` slot of a given tree item is clicked.
161
+ * Callback fired when the `content` slot of a given Tree Item is clicked.
162
162
  * @param {React.MouseEvent} event The DOM event that triggered the change.
163
163
  * @param {string} itemId The id of the focused item.
164
164
  */
165
165
  onItemClick: PropTypes.func,
166
166
  /**
167
- * Callback fired when a tree item is expanded or collapsed.
167
+ * Callback fired when a Tree Item is expanded or collapsed.
168
168
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
169
169
  * @param {array} itemId The itemId of the modified item.
170
170
  * @param {array} isExpanded `true` if the item has just been expanded, `false` if it has just been collapsed.
171
171
  */
172
172
  onItemExpansionToggle: PropTypes.func,
173
173
  /**
174
- * Callback fired when a given tree item is focused.
174
+ * Callback fired when a given Tree Item is focused.
175
175
  * @param {React.SyntheticEvent | null} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
176
176
  * @param {string} itemId The id of the focused item.
177
177
  */
178
178
  onItemFocus: PropTypes.func,
179
179
  /**
180
- * Callback fired when a tree item is selected or deselected.
180
+ * Callback fired when a Tree Item is selected or deselected.
181
181
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
182
182
  * @param {array} itemId The itemId of the modified item.
183
183
  * @param {array} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
184
184
  */
185
185
  onItemSelectionToggle: PropTypes.func,
186
186
  /**
187
- * Callback fired when tree items are selected/deselected.
187
+ * Callback fired when Tree Items are selected/deselected.
188
188
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
189
189
  * @param {string[] | string} itemIds The ids of the selected items.
190
190
  * When `multiSelect` is `true`, this is an array of strings; when false (default) a string.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.20.0
2
+ * @mui/x-tree-view v7.22.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -2,7 +2,7 @@ import { UseTreeViewIdParameters } from './useTreeViewId';
2
2
  import { ConvertPluginsIntoSignatures } from '../models';
3
3
  /**
4
4
  * Internal plugins that create the tools used by the other plugins.
5
- * These plugins are used by the tree view components.
5
+ * These plugins are used by the Tree View components.
6
6
  */
7
7
  export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("..").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("..").TreeViewPlugin<import("./useTreeViewOptionalPlugins").UseTreeViewOptionalPluginsSignature>, import("..").TreeViewPlugin<import("./useTreeViewId").UseTreeViewIdSignature>];
8
8
  export type TreeViewCorePluginSignatures = ConvertPluginsIntoSignatures<typeof TREE_VIEW_CORE_PLUGINS>;
@@ -3,6 +3,6 @@ import { useTreeViewOptionalPlugins } from "./useTreeViewOptionalPlugins/index.j
3
3
  import { useTreeViewId } from "./useTreeViewId/index.js";
4
4
  /**
5
5
  * Internal plugins that create the tools used by the other plugins.
6
- * These plugins are used by the tree view components.
6
+ * These plugins are used by the Tree View components.
7
7
  */
8
8
  export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewOptionalPlugins, useTreeViewId];
@@ -6,10 +6,9 @@ export const useTreeViewId = ({
6
6
  state,
7
7
  setState
8
8
  }) => {
9
- const treeId = state.id.treeId;
10
9
  React.useEffect(() => {
11
10
  setState(prevState => {
12
- if (prevState.id.treeId === params.id) {
11
+ if (prevState.id.treeId === params.id && prevState.id.treeId !== undefined) {
13
12
  return prevState;
14
13
  }
15
14
  return _extends({}, prevState, {
@@ -19,6 +18,7 @@ export const useTreeViewId = ({
19
18
  });
20
19
  });
21
20
  }, [setState, params.id]);
21
+ const treeId = params.id ?? state.id.treeId;
22
22
  return {
23
23
  getRootProps: () => ({
24
24
  id: treeId
@@ -35,6 +35,6 @@ useTreeViewId.getInitialState = ({
35
35
  id
36
36
  }) => ({
37
37
  id: {
38
- treeId: id ?? createTreeViewDefaultId()
38
+ treeId: id ?? undefined
39
39
  }
40
40
  });
@@ -9,7 +9,7 @@ export interface UseTreeViewIdParameters {
9
9
  export type UseTreeViewIdDefaultizedParameters = UseTreeViewIdParameters;
10
10
  export interface UseTreeViewIdState {
11
11
  id: {
12
- treeId: string;
12
+ treeId: string | undefined;
13
13
  };
14
14
  }
15
15
  interface UseTreeViewIdContextValue {
@@ -1,7 +1,7 @@
1
1
  import { TreeViewItemId } from '../../../models';
2
2
  export declare const createTreeViewDefaultId: () => string;
3
3
  /**
4
- * Generate the id attribute (i.e.: the `id` attribute passed to the DOM element) of a tree item.
4
+ * Generate the id attribute (i.e.: the `id` attribute passed to the DOM element) of a Tree Item.
5
5
  * If the user explicitly defined an id attribute, it will be returned.
6
6
  * Otherwise, the method creates a unique id for the item based on the Tree View id attribute and the item `itemId`
7
7
  * @param {object} params The parameters to determine the id attribute of the item.
@@ -5,7 +5,7 @@ export const createTreeViewDefaultId = () => {
5
5
  };
6
6
 
7
7
  /**
8
- * Generate the id attribute (i.e.: the `id` attribute passed to the DOM element) of a tree item.
8
+ * Generate the id attribute (i.e.: the `id` attribute passed to the DOM element) of a Tree Item.
9
9
  * If the user explicitly defined an id attribute, it will be returned.
10
10
  * Otherwise, the method creates a unique id for the item based on the Tree View id attribute and the item `itemId`
11
11
  * @param {object} params The parameters to determine the id attribute of the item.
@@ -2,7 +2,7 @@ export { useTreeView } from './useTreeView';
2
2
  export { TreeViewProvider, useTreeViewContext } from './TreeViewProvider';
3
3
  export { RichTreeViewItems } from './components/RichTreeViewItems';
4
4
  export { unstable_resetCleanupTracking } from './hooks/useInstanceEventHandler';
5
- export type { TreeViewPlugin, TreeViewPluginSignature, ConvertPluginsIntoSignatures, MergeSignaturesProperty, TreeViewPublicAPI, TreeViewExperimentalFeatures, TreeViewItemMeta, TreeViewInstance, DefaultizedProps, TreeViewItemPlugin, MuiCancellableEvent, MuiCancellableEventHandler, } from './models';
5
+ export type { TreeViewPlugin, TreeViewPluginSignature, ConvertPluginsIntoSignatures, MergeSignaturesProperty, TreeViewPublicAPI, TreeViewExperimentalFeatures, TreeViewItemMeta, TreeViewInstance, DefaultizedProps, TreeViewItemPlugin, } from './models';
6
6
  export type { TreeViewCorePluginParameters } from './corePlugins';
7
7
  export { useTreeViewExpansion } from './plugins/useTreeViewExpansion';
8
8
  export type { UseTreeViewExpansionSignature, UseTreeViewExpansionParameters, } from './plugins/useTreeViewExpansion';
@@ -2,4 +2,3 @@ export * from './helpers';
2
2
  export * from './plugin';
3
3
  export * from './itemPlugin';
4
4
  export * from './treeView';
5
- export * from './MuiCancellableEvent';
@@ -1,5 +1,4 @@
1
1
  export * from "./helpers.js";
2
2
  export * from "./plugin.js";
3
3
  export * from "./itemPlugin.js";
4
- export * from "./treeView.js";
5
- export * from "./MuiCancellableEvent.js";
4
+ export * from "./treeView.js";
@@ -8,11 +8,11 @@ export interface TreeViewItemMeta {
8
8
  expandable: boolean;
9
9
  disabled: boolean;
10
10
  /**
11
- * Only defined for `RichTreeView` and `RichTreeViewPro`.
11
+ * Only defined for `<RichTreeView />` and `<RichTreeViewPro />`.
12
12
  */
13
13
  depth?: number;
14
14
  /**
15
- * Only defined for `RichTreeView` and `RichTreeViewPro`.
15
+ * Only defined for `<RichTreeView />` and `<RichTreeViewPro />`.
16
16
  */
17
17
  label?: string;
18
18
  }
@@ -54,13 +54,13 @@ export interface UseTreeViewExpansionParameters {
54
54
  */
55
55
  defaultExpandedItems?: string[];
56
56
  /**
57
- * Callback fired when tree items are expanded/collapsed.
57
+ * Callback fired when Tree Items are expanded/collapsed.
58
58
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
59
59
  * @param {array} itemIds The ids of the expanded items.
60
60
  */
61
61
  onExpandedItemsChange?: (event: React.SyntheticEvent, itemIds: string[]) => void;
62
62
  /**
63
- * Callback fired when a tree item is expanded or collapsed.
63
+ * Callback fired when a Tree Item is expanded or collapsed.
64
64
  * @param {React.SyntheticEvent} event The DOM event that triggered the change.
65
65
  * @param {array} itemId The itemId of the modified item.
66
66
  * @param {array} isExpanded `true` if the item has just been expanded, `false` if it has just been collapsed.
@@ -37,7 +37,7 @@ export interface UseTreeViewFocusInstance extends UseTreeViewFocusPublicAPI {
37
37
  }
38
38
  export interface UseTreeViewFocusParameters {
39
39
  /**
40
- * Callback fired when a given tree item is focused.
40
+ * Callback fired when a given Tree Item is focused.
41
41
  * @param {React.SyntheticEvent | null} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
42
42
  * @param {string} itemId The id of the focused item.
43
43
  */
@@ -17,7 +17,7 @@ interface UseTreeViewIconsSlots {
17
17
  expandIcon?: React.ElementType;
18
18
  /**
19
19
  * The default icon displayed next to an end item.
20
- * This is applied to all tree items and can be overridden by the TreeItem `icon` slot prop.
20
+ * This is applied to all Tree Items and can be overridden by the TreeItem `icon` slot prop.
21
21
  */
22
22
  endIcon?: React.ElementType;
23
23
  }
@@ -10,7 +10,7 @@ export interface TreeViewItemToRenderProps {
10
10
  export interface UseTreeViewItemsPublicAPI<R extends {}> {
11
11
  /**
12
12
  * Get the item with the given id.
13
- * When used in the `SimpleTreeView`, it returns an object with the `id` and `label` properties.
13
+ * When used in the Simple Tree View, it returns an object with the `id` and `label` properties.
14
14
  * @param {string} itemId The id of the item to retrieve.
15
15
  * @returns {R} The item with the given id.
16
16
  */
@@ -117,7 +117,7 @@ export interface UseTreeViewItemsParameters<R extends {
117
117
  */
118
118
  getItemId?: (item: R) => TreeViewItemId;
119
119
  /**
120
- * Callback fired when the `content` slot of a given tree item is clicked.
120
+ * Callback fired when the `content` slot of a given Tree Item is clicked.
121
121
  * @param {React.MouseEvent} event The DOM event that triggered the change.
122
122
  * @param {string} itemId The id of the focused item.
123
123
  */
@@ -25,7 +25,7 @@ export const useTreeViewJSXItems = ({
25
25
  itemMetaMap: _extends({}, prevState.items.itemMetaMap, {
26
26
  [item.id]: item
27
27
  }),
28
- // For `SimpleTreeView`, we don't have a proper `item` object, so we create a very basic one.
28
+ // For Simple Tree View, we don't have a proper `item` object, so we create a very basic one.
29
29
  itemMap: _extends({}, prevState.items.itemMap, {
30
30
  [item.id]: {
31
31
  id: item.id,
@@ -4,7 +4,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
4
4
  import { getFirstNavigableItem, getLastNavigableItem, getNextNavigableItem, getPreviousNavigableItem, isTargetInDescendants } from "../../utils/tree.js";
5
5
  import { hasPlugin } from "../../utils/plugins.js";
6
6
  import { useTreeViewLabel } from "../useTreeViewLabel/index.js";
7
- function isPrintableCharacter(string) {
7
+ function isPrintableKey(string) {
8
8
  return !!string && string.length === 1 && !!string.match(/\S/);
9
9
  }
10
10
  export const useTreeViewKeyboardNavigation = ({
@@ -227,7 +227,7 @@ export const useTreeViewKeyboardNavigation = ({
227
227
 
228
228
  // Multi select behavior when pressing Ctrl + a
229
229
  // Selects all the items
230
- case key === 'a' && ctrlPressed && params.multiSelect && !params.disableSelection:
230
+ case String.fromCharCode(event.keyCode) === 'A' && ctrlPressed && params.multiSelect && !params.disableSelection:
231
231
  {
232
232
  instance.selectAllNavigableItems(event);
233
233
  event.preventDefault();
@@ -236,7 +236,7 @@ export const useTreeViewKeyboardNavigation = ({
236
236
 
237
237
  // Type-ahead
238
238
  // TODO: Support typing multiple characters
239
- case !ctrlPressed && !event.shiftKey && isPrintableCharacter(key):
239
+ case !ctrlPressed && !event.shiftKey && isPrintableKey(key):
240
240
  {
241
241
  const matchingItem = getFirstMatchingItem(itemId, key);
242
242
  if (matchingItem != null) {
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { TreeViewPluginSignature, MuiCancellableEvent } from '../../models';
2
+ import { TreeViewPluginSignature } from '../../models';
3
3
  import { UseTreeViewItemsSignature } from '../useTreeViewItems';
4
4
  import { UseTreeViewSelectionSignature } from '../useTreeViewSelection';
5
5
  import { UseTreeViewFocusSignature } from '../useTreeViewFocus';
6
6
  import { UseTreeViewExpansionSignature } from '../useTreeViewExpansion';
7
- import { TreeViewItemId } from '../../../models';
7
+ import { TreeViewItemId, TreeViewCancellableEvent } from '../../../models';
8
8
  import { UseTreeViewLabelSignature } from '../useTreeViewLabel';
9
9
  export interface UseTreeViewKeyboardNavigationInstance {
10
10
  /**
@@ -17,10 +17,10 @@ export interface UseTreeViewKeyboardNavigationInstance {
17
17
  /**
18
18
  * Callback fired when a key is pressed on an item.
19
19
  * Handles all the keyboard navigation logic.
20
- * @param {React.KeyboardEvent<HTMLElement> & MuiCancellableEvent} event The keyboard event that triggered the callback.
20
+ * @param {React.KeyboardEvent<HTMLElement> & TreeViewCancellableEvent} event The keyboard event that triggered the callback.
21
21
  * @param {TreeViewItemId} itemId The id of the item that the event was triggered on.
22
22
  */
23
- handleItemKeyDown: (event: React.KeyboardEvent<HTMLElement> & MuiCancellableEvent, itemId: TreeViewItemId) => void;
23
+ handleItemKeyDown: (event: React.KeyboardEvent<HTMLElement> & TreeViewCancellableEvent, itemId: TreeViewItemId) => void;
24
24
  }
25
25
  export type UseTreeViewKeyboardNavigationSignature = TreeViewPluginSignature<{
26
26
  instance: UseTreeViewKeyboardNavigationInstance;
@@ -73,7 +73,7 @@ useTreeViewLabel.getDefaultizedParams = ({
73
73
  const canUseFeature = experimentalFeatures?.labelEditing;
74
74
  if (process.env.NODE_ENV !== 'production') {
75
75
  if (params.isItemEditable && !canUseFeature) {
76
- warnOnce(['MUI X: The label editing feature requires the `labelEditing` experimental feature to be enabled.', 'You can do it by passing `experimentalFeatures={{ labelEditing: true}}` to the `RichTreeViewPro` component.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/editing/']);
76
+ warnOnce(['MUI X: The label editing feature requires the `labelEditing` experimental feature to be enabled.', 'You can do it by passing `experimentalFeatures={{ labelEditing: true}}` to the Rich Tree View Pro component.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/editing/']);
77
77
  }
78
78
  }
79
79
  return _extends({}, params, {
@@ -37,7 +37,7 @@ export interface UseTreeViewLabelInstance extends UseTreeViewLabelPublicAPI {
37
37
  */
38
38
  isItemEditable: (itemId: TreeViewItemId) => boolean;
39
39
  /**
40
- * Set to `true` if the tree view is editable.
40
+ * Set to `true` if the Tree View is editable.
41
41
  */
42
42
  isTreeViewEditable: boolean;
43
43
  }