@mui/x-tree-view 7.0.0-alpha.9 → 7.0.0-beta.2

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # MUI X Tree View
1
+ # MUI X Tree View
2
2
 
3
3
  This package is the community edition of the tree view components.
4
- It's part of [MUI X](https://mui.com/x/), an open-core extension of MUI Core, with advanced components.
4
+ It's part of [MUI X](https://mui.com/x/), an open-core extension of MUI Core, with advanced components.
5
5
 
6
6
  ## Installation
7
7
 
@@ -127,24 +127,6 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
127
127
  * Used when the item's expansion is controlled.
128
128
  */
129
129
  expandedNodes: PropTypes.arrayOf(PropTypes.string),
130
- /**
131
- * Used to determine the string label for a given item.
132
- *
133
- * @template R
134
- * @param {R} item The item to check.
135
- * @returns {string} The id of the item.
136
- * @default `(item) => item.id`
137
- */
138
- getItemId: PropTypes.func,
139
- /**
140
- * Used to determine the string label for a given item.
141
- *
142
- * @template R
143
- * @param {R} item The item to check.
144
- * @returns {string} The label of the item.
145
- * @default `(item) => item.label`
146
- */
147
- getItemLabel: PropTypes.func,
148
130
  /**
149
131
  * This prop is used to help implement the accessibility logic.
150
132
  * If you don't provide this prop. It falls back to a randomly generated id.
@@ -4,5 +4,5 @@ export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/mo
4
4
  export type SimpleTreeViewPlugins = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
5
5
  export type SimpleTreeViewPluginSlots = DefaultTreeViewPluginSlots;
6
6
  export type SimpleTreeViewPluginSlotProps = DefaultTreeViewPluginSlotProps;
7
- export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends Omit<DefaultTreeViewPluginParameters<any, Multiple>, 'items' | 'isItemDisabled'> {
7
+ export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends Omit<DefaultTreeViewPluginParameters<any, Multiple>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemId'> {
8
8
  }
@@ -59,12 +59,14 @@ const StyledTreeItemContent = styled(TreeItemContent, {
59
59
  })(({
60
60
  theme
61
61
  }) => ({
62
- padding: '0 8px',
62
+ padding: theme.spacing(0.5, 1),
63
+ borderRadius: theme.shape.borderRadius,
63
64
  width: '100%',
64
65
  boxSizing: 'border-box',
65
66
  // prevent width + padding to overflow
66
67
  display: 'flex',
67
68
  alignItems: 'center',
69
+ gap: theme.spacing(1),
68
70
  cursor: 'pointer',
69
71
  WebkitTapHighlightColor: 'transparent',
70
72
  '&:hover': {
@@ -95,8 +97,7 @@ const StyledTreeItemContent = styled(TreeItemContent, {
95
97
  }
96
98
  },
97
99
  [`& .${treeItemClasses.iconContainer}`]: {
98
- marginRight: 4,
99
- width: 15,
100
+ width: 16,
100
101
  display: 'flex',
101
102
  flexShrink: 0,
102
103
  justifyContent: 'center',
@@ -105,7 +106,6 @@ const StyledTreeItemContent = styled(TreeItemContent, {
105
106
  }
106
107
  },
107
108
  [`& .${treeItemClasses.label}`]: _extends({
108
- paddingLeft: 4,
109
109
  width: '100%',
110
110
  boxSizing: 'border-box',
111
111
  // prevent width + padding to overflow
@@ -121,7 +121,7 @@ const TreeItemGroup = styled(Collapse, {
121
121
  })({
122
122
  margin: 0,
123
123
  padding: 0,
124
- marginLeft: 17
124
+ paddingLeft: 12
125
125
  });
126
126
 
127
127
  /**
@@ -179,7 +179,13 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
179
179
  endIcon: (_inSlots$endIcon = inSlots == null ? void 0 : inSlots.endIcon) != null ? _inSlots$endIcon : contextIcons.slots.endIcon,
180
180
  icon: inSlots == null ? void 0 : inSlots.icon
181
181
  };
182
- const expandable = Boolean(Array.isArray(children) ? children.length : children);
182
+ const isExpandable = reactChildren => {
183
+ if (Array.isArray(reactChildren)) {
184
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
185
+ }
186
+ return Boolean(reactChildren);
187
+ };
188
+ const expandable = isExpandable(children);
183
189
  const expanded = instance.isNodeExpanded(nodeId);
184
190
  const focused = instance.isNodeFocused(nodeId);
185
191
  const selected = instance.isNodeSelected(nodeId);
@@ -100,24 +100,6 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
100
100
  * Used when the item's expansion is controlled.
101
101
  */
102
102
  expandedNodes: PropTypes.arrayOf(PropTypes.string),
103
- /**
104
- * Used to determine the string label for a given item.
105
- *
106
- * @template R
107
- * @param {R} item The item to check.
108
- * @returns {string} The id of the item.
109
- * @default `(item) => item.id`
110
- */
111
- getItemId: PropTypes.func,
112
- /**
113
- * Used to determine the string label for a given item.
114
- *
115
- * @template R
116
- * @param {R} item The item to check.
117
- * @returns {string} The label of the item.
118
- * @default `(item) => item.label`
119
- */
120
- getItemLabel: PropTypes.func,
121
103
  /**
122
104
  * This prop is used to help implement the accessibility logic.
123
105
  * If you don't provide this prop. It falls back to a randomly generated id.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.0.0-alpha.9
2
+ * @mui/x-tree-view v7.0.0-beta.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -12,11 +12,16 @@ export const useTreeViewJSXNodes = ({
12
12
  setState
13
13
  }) => {
14
14
  const insertJSXNode = useEventCallback(node => {
15
- setState(prevState => _extends({}, prevState, {
16
- nodeMap: _extends({}, prevState.nodeMap, {
17
- [node.id]: node
18
- })
19
- }));
15
+ setState(prevState => {
16
+ if (prevState.nodeMap[node.id] != null) {
17
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', `Tow items were provided with the same id in the \`items\` prop: "${node.id}"`].join('\n'));
18
+ }
19
+ return _extends({}, prevState, {
20
+ nodeMap: _extends({}, prevState.nodeMap, {
21
+ [node.id]: node
22
+ })
23
+ });
24
+ });
20
25
  });
21
26
  const removeJSXNode = useEventCallback(nodeId => {
22
27
  setState(prevState => {
@@ -64,7 +69,13 @@ const useTreeViewJSXNodesItemPlugin = ({
64
69
  const {
65
70
  instance
66
71
  } = useTreeViewContext();
67
- const expandable = Boolean(Array.isArray(children) ? children.length : children);
72
+ const isExpandable = reactChildren => {
73
+ if (Array.isArray(reactChildren)) {
74
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
75
+ }
76
+ return Boolean(reactChildren);
77
+ };
78
+ const expandable = isExpandable(children);
68
79
  const [treeItemElement, setTreeItemElement] = React.useState(null);
69
80
  const contentRef = React.useRef(null);
70
81
  const handleRef = useForkRef(setTreeItemElement, ref);
@@ -16,6 +16,9 @@ const updateState = ({
16
16
  if (id == null) {
17
17
  throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', 'An item was provided without id in the `items` prop:', JSON.stringify(item)].join('\n'));
18
18
  }
19
+ if (nodeMap[id] != null) {
20
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', `Tow items were provided with the same id in the \`items\` prop: "${id}"`].join('\n'));
21
+ }
19
22
  const label = getItemLabel ? getItemLabel(item) : item.label;
20
23
  if (label == null) {
21
24
  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'));
@@ -125,24 +125,6 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
125
125
  * Used when the item's expansion is controlled.
126
126
  */
127
127
  expandedNodes: PropTypes.arrayOf(PropTypes.string),
128
- /**
129
- * Used to determine the string label for a given item.
130
- *
131
- * @template R
132
- * @param {R} item The item to check.
133
- * @returns {string} The id of the item.
134
- * @default `(item) => item.id`
135
- */
136
- getItemId: PropTypes.func,
137
- /**
138
- * Used to determine the string label for a given item.
139
- *
140
- * @template R
141
- * @param {R} item The item to check.
142
- * @returns {string} The label of the item.
143
- * @default `(item) => item.label`
144
- */
145
- getItemLabel: PropTypes.func,
146
128
  /**
147
129
  * This prop is used to help implement the accessibility logic.
148
130
  * If you don't provide this prop. It falls back to a randomly generated id.
@@ -56,12 +56,14 @@ var StyledTreeItemContent = styled(TreeItemContent, {
56
56
  })(function (_ref3) {
57
57
  var theme = _ref3.theme;
58
58
  return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
59
- padding: '0 8px',
59
+ padding: theme.spacing(0.5, 1),
60
+ borderRadius: theme.shape.borderRadius,
60
61
  width: '100%',
61
62
  boxSizing: 'border-box',
62
63
  // prevent width + padding to overflow
63
64
  display: 'flex',
64
65
  alignItems: 'center',
66
+ gap: theme.spacing(1),
65
67
  cursor: 'pointer',
66
68
  WebkitTapHighlightColor: 'transparent',
67
69
  '&:hover': {
@@ -88,8 +90,7 @@ var StyledTreeItemContent = styled(TreeItemContent, {
88
90
  }, "&.".concat(treeItemClasses.focused), {
89
91
  backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.primary.mainChannel, " / calc(").concat(theme.vars.palette.action.selectedOpacity, " + ").concat(theme.vars.palette.action.focusOpacity, "))") : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity)
90
92
  })), "& .".concat(treeItemClasses.iconContainer), {
91
- marginRight: 4,
92
- width: 15,
93
+ width: 16,
93
94
  display: 'flex',
94
95
  flexShrink: 0,
95
96
  justifyContent: 'center',
@@ -97,7 +98,6 @@ var StyledTreeItemContent = styled(TreeItemContent, {
97
98
  fontSize: 18
98
99
  }
99
100
  }), "& .".concat(treeItemClasses.label), _extends({
100
- paddingLeft: 4,
101
101
  width: '100%',
102
102
  boxSizing: 'border-box',
103
103
  // prevent width + padding to overflow
@@ -115,7 +115,7 @@ var TreeItemGroup = styled(Collapse, {
115
115
  })({
116
116
  margin: 0,
117
117
  padding: 0,
118
- marginLeft: 17
118
+ paddingLeft: 12
119
119
  });
120
120
 
121
121
  /**
@@ -169,7 +169,13 @@ export var TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps, i
169
169
  endIcon: (_inSlots$endIcon = inSlots == null ? void 0 : inSlots.endIcon) != null ? _inSlots$endIcon : contextIcons.slots.endIcon,
170
170
  icon: inSlots == null ? void 0 : inSlots.icon
171
171
  };
172
- var expandable = Boolean(Array.isArray(children) ? children.length : children);
172
+ var isExpandable = function isExpandable(reactChildren) {
173
+ if (Array.isArray(reactChildren)) {
174
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
175
+ }
176
+ return Boolean(reactChildren);
177
+ };
178
+ var expandable = isExpandable(children);
173
179
  var expanded = instance.isNodeExpanded(nodeId);
174
180
  var focused = instance.isNodeFocused(nodeId);
175
181
  var selected = instance.isNodeSelected(nodeId);
@@ -100,24 +100,6 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
100
100
  * Used when the item's expansion is controlled.
101
101
  */
102
102
  expandedNodes: PropTypes.arrayOf(PropTypes.string),
103
- /**
104
- * Used to determine the string label for a given item.
105
- *
106
- * @template R
107
- * @param {R} item The item to check.
108
- * @returns {string} The id of the item.
109
- * @default `(item) => item.id`
110
- */
111
- getItemId: PropTypes.func,
112
- /**
113
- * Used to determine the string label for a given item.
114
- *
115
- * @template R
116
- * @param {R} item The item to check.
117
- * @returns {string} The label of the item.
118
- * @default `(item) => item.label`
119
- */
120
- getItemLabel: PropTypes.func,
121
103
  /**
122
104
  * This prop is used to help implement the accessibility logic.
123
105
  * If you don't provide this prop. It falls back to a randomly generated id.
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.0.0-alpha.9
2
+ * @mui/x-tree-view v7.0.0-beta.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -14,6 +14,9 @@ export var useTreeViewJSXNodes = function useTreeViewJSXNodes(_ref) {
14
14
  setState = _ref.setState;
15
15
  var insertJSXNode = useEventCallback(function (node) {
16
16
  setState(function (prevState) {
17
+ if (prevState.nodeMap[node.id] != null) {
18
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', "Tow items were provided with the same id in the `items` prop: \"".concat(node.id, "\"")].join('\n'));
19
+ }
17
20
  return _extends({}, prevState, {
18
21
  nodeMap: _extends({}, prevState.nodeMap, _defineProperty({}, node.id, node))
19
22
  });
@@ -62,7 +65,13 @@ var useTreeViewJSXNodesItemPlugin = function useTreeViewJSXNodesItemPlugin(_ref2
62
65
  inContentProps = props.ContentProps;
63
66
  var _useTreeViewContext = useTreeViewContext(),
64
67
  instance = _useTreeViewContext.instance;
65
- var expandable = Boolean(Array.isArray(children) ? children.length : children);
68
+ var isExpandable = function isExpandable(reactChildren) {
69
+ if (Array.isArray(reactChildren)) {
70
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
71
+ }
72
+ return Boolean(reactChildren);
73
+ };
74
+ var expandable = isExpandable(children);
66
75
  var _React$useState = React.useState(null),
67
76
  _React$useState2 = _slicedToArray(_React$useState, 2),
68
77
  treeItemElement = _React$useState2[0],
@@ -15,6 +15,9 @@ var updateState = function updateState(_ref) {
15
15
  if (id == null) {
16
16
  throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', 'An item was provided without id in the `items` prop:', JSON.stringify(item)].join('\n'));
17
17
  }
18
+ if (nodeMap[id] != null) {
19
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', "Tow items were provided with the same id in the `items` prop: \"".concat(id, "\"")].join('\n'));
20
+ }
18
21
  var label = getItemLabel ? getItemLabel(item) : item.label;
19
22
  if (label == null) {
20
23
  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'));
@@ -126,24 +126,6 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
126
126
  * Used when the item's expansion is controlled.
127
127
  */
128
128
  expandedNodes: PropTypes.arrayOf(PropTypes.string),
129
- /**
130
- * Used to determine the string label for a given item.
131
- *
132
- * @template R
133
- * @param {R} item The item to check.
134
- * @returns {string} The id of the item.
135
- * @default `(item) => item.id`
136
- */
137
- getItemId: PropTypes.func,
138
- /**
139
- * Used to determine the string label for a given item.
140
- *
141
- * @template R
142
- * @param {R} item The item to check.
143
- * @returns {string} The label of the item.
144
- * @default `(item) => item.label`
145
- */
146
- getItemLabel: PropTypes.func,
147
129
  /**
148
130
  * This prop is used to help implement the accessibility logic.
149
131
  * If you don't provide this prop. It falls back to a randomly generated id.
@@ -59,12 +59,14 @@ const StyledTreeItemContent = styled(TreeItemContent, {
59
59
  })(({
60
60
  theme
61
61
  }) => ({
62
- padding: '0 8px',
62
+ padding: theme.spacing(0.5, 1),
63
+ borderRadius: theme.shape.borderRadius,
63
64
  width: '100%',
64
65
  boxSizing: 'border-box',
65
66
  // prevent width + padding to overflow
66
67
  display: 'flex',
67
68
  alignItems: 'center',
69
+ gap: theme.spacing(1),
68
70
  cursor: 'pointer',
69
71
  WebkitTapHighlightColor: 'transparent',
70
72
  '&:hover': {
@@ -95,8 +97,7 @@ const StyledTreeItemContent = styled(TreeItemContent, {
95
97
  }
96
98
  },
97
99
  [`& .${treeItemClasses.iconContainer}`]: {
98
- marginRight: 4,
99
- width: 15,
100
+ width: 16,
100
101
  display: 'flex',
101
102
  flexShrink: 0,
102
103
  justifyContent: 'center',
@@ -105,7 +106,6 @@ const StyledTreeItemContent = styled(TreeItemContent, {
105
106
  }
106
107
  },
107
108
  [`& .${treeItemClasses.label}`]: _extends({
108
- paddingLeft: 4,
109
109
  width: '100%',
110
110
  boxSizing: 'border-box',
111
111
  // prevent width + padding to overflow
@@ -121,7 +121,7 @@ const TreeItemGroup = styled(Collapse, {
121
121
  })({
122
122
  margin: 0,
123
123
  padding: 0,
124
- marginLeft: 17
124
+ paddingLeft: 12
125
125
  });
126
126
 
127
127
  /**
@@ -178,7 +178,13 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
178
178
  endIcon: inSlots?.endIcon ?? contextIcons.slots.endIcon,
179
179
  icon: inSlots?.icon
180
180
  };
181
- const expandable = Boolean(Array.isArray(children) ? children.length : children);
181
+ const isExpandable = reactChildren => {
182
+ if (Array.isArray(reactChildren)) {
183
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
184
+ }
185
+ return Boolean(reactChildren);
186
+ };
187
+ const expandable = isExpandable(children);
182
188
  const expanded = instance.isNodeExpanded(nodeId);
183
189
  const focused = instance.isNodeFocused(nodeId);
184
190
  const selected = instance.isNodeSelected(nodeId);
@@ -100,24 +100,6 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
100
100
  * Used when the item's expansion is controlled.
101
101
  */
102
102
  expandedNodes: PropTypes.arrayOf(PropTypes.string),
103
- /**
104
- * Used to determine the string label for a given item.
105
- *
106
- * @template R
107
- * @param {R} item The item to check.
108
- * @returns {string} The id of the item.
109
- * @default `(item) => item.id`
110
- */
111
- getItemId: PropTypes.func,
112
- /**
113
- * Used to determine the string label for a given item.
114
- *
115
- * @template R
116
- * @param {R} item The item to check.
117
- * @returns {string} The label of the item.
118
- * @default `(item) => item.label`
119
- */
120
- getItemLabel: PropTypes.func,
121
103
  /**
122
104
  * This prop is used to help implement the accessibility logic.
123
105
  * If you don't provide this prop. It falls back to a randomly generated id.
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.0.0-alpha.9
2
+ * @mui/x-tree-view v7.0.0-beta.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -12,11 +12,16 @@ export const useTreeViewJSXNodes = ({
12
12
  setState
13
13
  }) => {
14
14
  const insertJSXNode = useEventCallback(node => {
15
- setState(prevState => _extends({}, prevState, {
16
- nodeMap: _extends({}, prevState.nodeMap, {
17
- [node.id]: node
18
- })
19
- }));
15
+ setState(prevState => {
16
+ if (prevState.nodeMap[node.id] != null) {
17
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', `Tow items were provided with the same id in the \`items\` prop: "${node.id}"`].join('\n'));
18
+ }
19
+ return _extends({}, prevState, {
20
+ nodeMap: _extends({}, prevState.nodeMap, {
21
+ [node.id]: node
22
+ })
23
+ });
24
+ });
20
25
  });
21
26
  const removeJSXNode = useEventCallback(nodeId => {
22
27
  setState(prevState => {
@@ -64,7 +69,13 @@ const useTreeViewJSXNodesItemPlugin = ({
64
69
  const {
65
70
  instance
66
71
  } = useTreeViewContext();
67
- const expandable = Boolean(Array.isArray(children) ? children.length : children);
72
+ const isExpandable = reactChildren => {
73
+ if (Array.isArray(reactChildren)) {
74
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
75
+ }
76
+ return Boolean(reactChildren);
77
+ };
78
+ const expandable = isExpandable(children);
68
79
  const [treeItemElement, setTreeItemElement] = React.useState(null);
69
80
  const contentRef = React.useRef(null);
70
81
  const handleRef = useForkRef(setTreeItemElement, ref);
@@ -15,6 +15,9 @@ const updateState = ({
15
15
  if (id == null) {
16
16
  throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', 'An item was provided without id in the `items` prop:', JSON.stringify(item)].join('\n'));
17
17
  }
18
+ if (nodeMap[id] != null) {
19
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', `Tow items were provided with the same id in the \`items\` prop: "${id}"`].join('\n'));
20
+ }
18
21
  const label = getItemLabel ? getItemLabel(item) : item.label;
19
22
  if (label == null) {
20
23
  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'));
@@ -135,24 +135,6 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
135
135
  * Used when the item's expansion is controlled.
136
136
  */
137
137
  expandedNodes: _propTypes.default.arrayOf(_propTypes.default.string),
138
- /**
139
- * Used to determine the string label for a given item.
140
- *
141
- * @template R
142
- * @param {R} item The item to check.
143
- * @returns {string} The id of the item.
144
- * @default `(item) => item.id`
145
- */
146
- getItemId: _propTypes.default.func,
147
- /**
148
- * Used to determine the string label for a given item.
149
- *
150
- * @template R
151
- * @param {R} item The item to check.
152
- * @returns {string} The label of the item.
153
- * @default `(item) => item.label`
154
- */
155
- getItemLabel: _propTypes.default.func,
156
138
  /**
157
139
  * This prop is used to help implement the accessibility logic.
158
140
  * If you don't provide this prop. It falls back to a randomly generated id.
@@ -67,12 +67,14 @@ const StyledTreeItemContent = (0, _styles.styled)(_TreeItemContent.TreeItemConte
67
67
  })(({
68
68
  theme
69
69
  }) => ({
70
- padding: '0 8px',
70
+ padding: theme.spacing(0.5, 1),
71
+ borderRadius: theme.shape.borderRadius,
71
72
  width: '100%',
72
73
  boxSizing: 'border-box',
73
74
  // prevent width + padding to overflow
74
75
  display: 'flex',
75
76
  alignItems: 'center',
77
+ gap: theme.spacing(1),
76
78
  cursor: 'pointer',
77
79
  WebkitTapHighlightColor: 'transparent',
78
80
  '&:hover': {
@@ -103,8 +105,7 @@ const StyledTreeItemContent = (0, _styles.styled)(_TreeItemContent.TreeItemConte
103
105
  }
104
106
  },
105
107
  [`& .${_treeItemClasses.treeItemClasses.iconContainer}`]: {
106
- marginRight: 4,
107
- width: 15,
108
+ width: 16,
108
109
  display: 'flex',
109
110
  flexShrink: 0,
110
111
  justifyContent: 'center',
@@ -113,7 +114,6 @@ const StyledTreeItemContent = (0, _styles.styled)(_TreeItemContent.TreeItemConte
113
114
  }
114
115
  },
115
116
  [`& .${_treeItemClasses.treeItemClasses.label}`]: (0, _extends2.default)({
116
- paddingLeft: 4,
117
117
  width: '100%',
118
118
  boxSizing: 'border-box',
119
119
  // prevent width + padding to overflow
@@ -129,7 +129,7 @@ const TreeItemGroup = (0, _styles.styled)(_Collapse.default, {
129
129
  })({
130
130
  margin: 0,
131
131
  padding: 0,
132
- marginLeft: 17
132
+ paddingLeft: 12
133
133
  });
134
134
 
135
135
  /**
@@ -186,7 +186,13 @@ const TreeItem = exports.TreeItem = /*#__PURE__*/React.forwardRef(function TreeI
186
186
  endIcon: inSlots?.endIcon ?? contextIcons.slots.endIcon,
187
187
  icon: inSlots?.icon
188
188
  };
189
- const expandable = Boolean(Array.isArray(children) ? children.length : children);
189
+ const isExpandable = reactChildren => {
190
+ if (Array.isArray(reactChildren)) {
191
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
192
+ }
193
+ return Boolean(reactChildren);
194
+ };
195
+ const expandable = isExpandable(children);
190
196
  const expanded = instance.isNodeExpanded(nodeId);
191
197
  const focused = instance.isNodeFocused(nodeId);
192
198
  const selected = instance.isNodeSelected(nodeId);
@@ -109,24 +109,6 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
109
109
  * Used when the item's expansion is controlled.
110
110
  */
111
111
  expandedNodes: _propTypes.default.arrayOf(_propTypes.default.string),
112
- /**
113
- * Used to determine the string label for a given item.
114
- *
115
- * @template R
116
- * @param {R} item The item to check.
117
- * @returns {string} The id of the item.
118
- * @default `(item) => item.id`
119
- */
120
- getItemId: _propTypes.default.func,
121
- /**
122
- * Used to determine the string label for a given item.
123
- *
124
- * @template R
125
- * @param {R} item The item to check.
126
- * @returns {string} The label of the item.
127
- * @default `(item) => item.label`
128
- */
129
- getItemLabel: _propTypes.default.func,
130
112
  /**
131
113
  * This prop is used to help implement the accessibility logic.
132
114
  * If you don't provide this prop. It falls back to a randomly generated id.
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.0.0-alpha.9
2
+ * @mui/x-tree-view v7.0.0-beta.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -21,11 +21,16 @@ const useTreeViewJSXNodes = ({
21
21
  setState
22
22
  }) => {
23
23
  const insertJSXNode = (0, _useEventCallback.default)(node => {
24
- setState(prevState => (0, _extends2.default)({}, prevState, {
25
- nodeMap: (0, _extends2.default)({}, prevState.nodeMap, {
26
- [node.id]: node
27
- })
28
- }));
24
+ setState(prevState => {
25
+ if (prevState.nodeMap[node.id] != null) {
26
+ throw new Error(['MUI X: The Tree View component requires all items to have a unique `id` property.', 'Alternatively, you can use the `getItemId` prop to specify a custom id for each item.', `Tow items were provided with the same id in the \`items\` prop: "${node.id}"`].join('\n'));
27
+ }
28
+ return (0, _extends2.default)({}, prevState, {
29
+ nodeMap: (0, _extends2.default)({}, prevState.nodeMap, {
30
+ [node.id]: node
31
+ })
32
+ });
33
+ });
29
34
  });
30
35
  const removeJSXNode = (0, _useEventCallback.default)(nodeId => {
31
36
  setState(prevState => {
@@ -74,7 +79,13 @@ const useTreeViewJSXNodesItemPlugin = ({
74
79
  const {
75
80
  instance
76
81
  } = (0, _useTreeViewContext.useTreeViewContext)();
77
- const expandable = Boolean(Array.isArray(children) ? children.length : children);
82
+ const isExpandable = reactChildren => {
83
+ if (Array.isArray(reactChildren)) {
84
+ return reactChildren.length > 0 && reactChildren.some(isExpandable);
85
+ }
86
+ return Boolean(reactChildren);
87
+ };
88
+ const expandable = isExpandable(children);
78
89
  const [treeItemElement, setTreeItemElement] = React.useState(null);
79
90
  const contentRef = React.useRef(null);
80
91
  const handleRef = (0, _useForkRef.default)(setTreeItemElement, ref);