@mui/x-tree-view 7.0.0-alpha.7 → 7.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +175 -49
- package/RichTreeView/RichTreeView.js +18 -57
- package/SimpleTreeView/SimpleTreeView.js +20 -53
- package/TreeView/TreeView.js +1 -1
- package/index.js +1 -1
- package/internals/TreeViewProvider/useTreeViewContext.js +1 -1
- package/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +2 -1
- package/internals/models/MuiCancellableEvent.d.ts +4 -0
- package/internals/models/MuiCancellableEvent.js +1 -0
- package/internals/models/plugin.d.ts +1 -0
- package/internals/plugins/useTreeViewContextValueBuilder/useTreeViewContextValueBuilder.js +6 -0
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +6 -0
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +3 -0
- package/internals/plugins/useTreeViewId/useTreeViewId.js +3 -0
- package/internals/plugins/useTreeViewJSXNodes/useTreeViewJSXNodes.js +2 -1
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +155 -112
- package/internals/plugins/useTreeViewNodes/useTreeViewNodes.js +10 -3
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +8 -0
- package/internals/useTreeView/useTreeViewModels.js +2 -2
- package/internals/utils/extractPluginParamsFromProps.d.ts +13 -0
- package/internals/utils/extractPluginParamsFromProps.js +27 -0
- package/legacy/RichTreeView/RichTreeView.js +17 -55
- package/legacy/SimpleTreeView/SimpleTreeView.js +15 -47
- package/legacy/TreeView/TreeView.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/TreeViewProvider/useTreeViewContext.js +1 -1
- package/legacy/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +2 -1
- package/legacy/internals/models/MuiCancellableEvent.js +1 -0
- package/legacy/internals/plugins/useTreeViewContextValueBuilder/useTreeViewContextValueBuilder.js +6 -0
- package/legacy/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +6 -0
- package/legacy/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +3 -0
- package/legacy/internals/plugins/useTreeViewId/useTreeViewId.js +3 -0
- package/legacy/internals/plugins/useTreeViewJSXNodes/useTreeViewJSXNodes.js +2 -1
- package/legacy/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +157 -110
- package/legacy/internals/plugins/useTreeViewNodes/useTreeViewNodes.js +9 -2
- package/legacy/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +8 -0
- package/legacy/internals/useTreeView/useTreeViewModels.js +2 -2
- package/legacy/internals/utils/extractPluginParamsFromProps.js +27 -0
- package/modern/RichTreeView/RichTreeView.js +18 -57
- package/modern/SimpleTreeView/SimpleTreeView.js +20 -53
- package/modern/TreeView/TreeView.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/TreeViewProvider/useTreeViewContext.js +1 -1
- package/modern/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +2 -1
- package/modern/internals/models/MuiCancellableEvent.js +1 -0
- package/modern/internals/plugins/useTreeViewContextValueBuilder/useTreeViewContextValueBuilder.js +6 -0
- package/modern/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +7 -1
- package/modern/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +4 -1
- package/modern/internals/plugins/useTreeViewId/useTreeViewId.js +3 -0
- package/modern/internals/plugins/useTreeViewJSXNodes/useTreeViewJSXNodes.js +2 -1
- package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +155 -112
- package/modern/internals/plugins/useTreeViewNodes/useTreeViewNodes.js +10 -3
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +9 -1
- package/modern/internals/useTreeView/useTreeViewModels.js +2 -2
- package/modern/internals/utils/extractPluginParamsFromProps.js +27 -0
- package/node/RichTreeView/RichTreeView.js +18 -57
- package/node/SimpleTreeView/SimpleTreeView.js +20 -53
- package/node/TreeView/TreeView.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/TreeViewProvider/useTreeViewContext.js +1 -1
- package/node/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +2 -1
- package/node/internals/models/MuiCancellableEvent.js +5 -0
- package/node/internals/plugins/useTreeViewContextValueBuilder/useTreeViewContextValueBuilder.js +7 -1
- package/node/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +7 -1
- package/node/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +4 -1
- package/node/internals/plugins/useTreeViewId/useTreeViewId.js +4 -1
- package/node/internals/plugins/useTreeViewJSXNodes/useTreeViewJSXNodes.js +2 -1
- package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +155 -112
- package/node/internals/plugins/useTreeViewNodes/useTreeViewNodes.js +10 -3
- package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +9 -1
- package/node/internals/useTreeView/useTreeViewModels.js +2 -2
- package/node/internals/utils/extractPluginParamsFromProps.js +34 -0
- package/package.json +1 -1
|
@@ -13,11 +13,11 @@ const updateState = ({
|
|
|
13
13
|
const processItem = (item, index, parentId) => {
|
|
14
14
|
const id = getItemId ? getItemId(item) : item.id;
|
|
15
15
|
if (id == null) {
|
|
16
|
-
throw new Error(['MUI: 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'));
|
|
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
18
|
const label = getItemLabel ? getItemLabel(item) : item.label;
|
|
19
19
|
if (label == null) {
|
|
20
|
-
throw new Error(['MUI: 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'));
|
|
20
|
+
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'));
|
|
21
21
|
}
|
|
22
22
|
nodeMap[id] = {
|
|
23
23
|
id,
|
|
@@ -121,4 +121,11 @@ useTreeViewNodes.getInitialState = params => updateState({
|
|
|
121
121
|
isItemDisabled: params.isItemDisabled,
|
|
122
122
|
getItemId: params.getItemId,
|
|
123
123
|
getItemLabel: params.getItemLabel
|
|
124
|
-
});
|
|
124
|
+
});
|
|
125
|
+
useTreeViewNodes.params = {
|
|
126
|
+
disabledItemsFocusable: true,
|
|
127
|
+
items: true,
|
|
128
|
+
isItemDisabled: true,
|
|
129
|
+
getItemLabel: true,
|
|
130
|
+
getItemId: true
|
|
131
|
+
};
|
|
@@ -179,4 +179,12 @@ useTreeViewSelection.getDefaultizedParams = params => _extends({}, params, {
|
|
|
179
179
|
disableSelection: params.disableSelection ?? false,
|
|
180
180
|
multiSelect: params.multiSelect ?? false,
|
|
181
181
|
defaultSelectedNodes: params.defaultSelectedNodes ?? (params.multiSelect ? DEFAULT_SELECTED_NODES : null)
|
|
182
|
-
});
|
|
182
|
+
});
|
|
183
|
+
useTreeViewSelection.params = {
|
|
184
|
+
disableSelection: true,
|
|
185
|
+
multiSelect: true,
|
|
186
|
+
defaultSelectedNodes: true,
|
|
187
|
+
selectedNodes: true,
|
|
188
|
+
onSelectedNodesChange: true,
|
|
189
|
+
onNodeSelectionToggle: true
|
|
190
|
+
};
|
|
@@ -44,7 +44,7 @@ export const useTreeViewModels = (plugins, props) => {
|
|
|
44
44
|
const defaultProp = props[model.defaultProp];
|
|
45
45
|
React.useEffect(() => {
|
|
46
46
|
if (model.isControlled !== (controlled !== undefined)) {
|
|
47
|
-
console.error([`MUI: A component is changing the ${model.isControlled ? '' : 'un'}controlled ${modelName} state of TreeView to be ${model.isControlled ? 'un' : ''}controlled.`, 'Elements should not switch from uncontrolled to controlled (or vice versa).', `Decide between using a controlled or uncontrolled ${modelName} ` + 'element for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
47
|
+
console.error([`MUI X: A component is changing the ${model.isControlled ? '' : 'un'}controlled ${modelName} state of TreeView to be ${model.isControlled ? 'un' : ''}controlled.`, 'Elements should not switch from uncontrolled to controlled (or vice versa).', `Decide between using a controlled or uncontrolled ${modelName} ` + 'element for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
48
48
|
}
|
|
49
49
|
}, [controlled]);
|
|
50
50
|
const {
|
|
@@ -52,7 +52,7 @@ export const useTreeViewModels = (plugins, props) => {
|
|
|
52
52
|
} = React.useRef(defaultProp);
|
|
53
53
|
React.useEffect(() => {
|
|
54
54
|
if (!model.isControlled && defaultValue !== defaultProp) {
|
|
55
|
-
console.error([`MUI: A component is changing the default ${modelName} state of an uncontrolled TreeView after being initialized. ` + `To suppress this warning opt to use a controlled TreeView.`].join('\n'));
|
|
55
|
+
console.error([`MUI X: A component is changing the default ${modelName} state of an uncontrolled TreeView after being initialized. ` + `To suppress this warning opt to use a controlled TreeView.`].join('\n'));
|
|
56
56
|
}
|
|
57
57
|
}, [JSON.stringify(defaultValue)]);
|
|
58
58
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const extractPluginParamsFromProps = ({
|
|
2
|
+
props,
|
|
3
|
+
plugins,
|
|
4
|
+
rootRef
|
|
5
|
+
}) => {
|
|
6
|
+
const paramsLookup = {};
|
|
7
|
+
plugins.forEach(plugin => {
|
|
8
|
+
Object.assign(paramsLookup, plugin.params);
|
|
9
|
+
});
|
|
10
|
+
const pluginParams = {
|
|
11
|
+
plugins,
|
|
12
|
+
rootRef
|
|
13
|
+
};
|
|
14
|
+
const otherProps = {};
|
|
15
|
+
Object.keys(props).forEach(propName => {
|
|
16
|
+
const prop = props[propName];
|
|
17
|
+
if (paramsLookup[propName]) {
|
|
18
|
+
pluginParams[propName] = prop;
|
|
19
|
+
} else {
|
|
20
|
+
otherProps[propName] = prop;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
pluginParams,
|
|
25
|
+
otherProps
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -18,8 +18,9 @@ var _TreeViewProvider = require("../internals/TreeViewProvider");
|
|
|
18
18
|
var _plugins = require("../internals/plugins");
|
|
19
19
|
var _TreeItem = require("../TreeItem");
|
|
20
20
|
var _warning = require("../internals/utils/warning");
|
|
21
|
+
var _extractPluginParamsFromProps = require("../internals/utils/extractPluginParamsFromProps");
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["
|
|
23
|
+
const _excluded = ["slots", "slotProps"];
|
|
23
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
26
|
const useUtilityClasses = ownerState => {
|
|
@@ -67,7 +68,7 @@ function WrappedTreeItem({
|
|
|
67
68
|
children: children
|
|
68
69
|
}));
|
|
69
70
|
}
|
|
70
|
-
const childrenWarning = (0, _warning.buildWarning)(['MUI: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop', 'Check the documentation for more details: https://next.mui.com/x/react-tree-view/rich-tree-view/items/']);
|
|
71
|
+
const childrenWarning = (0, _warning.buildWarning)(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop', 'Check the documentation for more details: https://next.mui.com/x/react-tree-view/rich-tree-view/items/']);
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
74
|
*
|
|
@@ -84,75 +85,35 @@ const RichTreeView = exports.RichTreeView = /*#__PURE__*/React.forwardRef(functi
|
|
|
84
85
|
props: inProps,
|
|
85
86
|
name: 'MuiRichTreeView'
|
|
86
87
|
});
|
|
87
|
-
const _ref = props,
|
|
88
|
-
{
|
|
89
|
-
// Headless implementation
|
|
90
|
-
disabledItemsFocusable,
|
|
91
|
-
expandedNodes,
|
|
92
|
-
defaultExpandedNodes,
|
|
93
|
-
onExpandedNodesChange,
|
|
94
|
-
onNodeExpansionToggle,
|
|
95
|
-
onNodeFocus,
|
|
96
|
-
disableSelection,
|
|
97
|
-
defaultSelectedNodes,
|
|
98
|
-
selectedNodes,
|
|
99
|
-
multiSelect,
|
|
100
|
-
onSelectedNodesChange,
|
|
101
|
-
onNodeSelectionToggle,
|
|
102
|
-
id: treeId,
|
|
103
|
-
defaultCollapseIcon,
|
|
104
|
-
defaultEndIcon,
|
|
105
|
-
defaultExpandIcon,
|
|
106
|
-
defaultParentIcon,
|
|
107
|
-
items,
|
|
108
|
-
getItemId,
|
|
109
|
-
getItemLabel,
|
|
110
|
-
isItemDisabled,
|
|
111
|
-
// Component implementation
|
|
112
|
-
slots,
|
|
113
|
-
slotProps
|
|
114
|
-
} = _ref,
|
|
115
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
116
88
|
if (process.env.NODE_ENV !== 'production') {
|
|
117
89
|
if (props.children != null) {
|
|
118
90
|
childrenWarning();
|
|
119
91
|
}
|
|
120
92
|
}
|
|
93
|
+
const _extractPluginParamsF = (0, _extractPluginParamsFromProps.extractPluginParamsFromProps)({
|
|
94
|
+
props,
|
|
95
|
+
plugins: _plugins.DEFAULT_TREE_VIEW_PLUGINS,
|
|
96
|
+
rootRef: ref
|
|
97
|
+
}),
|
|
98
|
+
{
|
|
99
|
+
pluginParams,
|
|
100
|
+
otherProps: {
|
|
101
|
+
slots,
|
|
102
|
+
slotProps
|
|
103
|
+
}
|
|
104
|
+
} = _extractPluginParamsF,
|
|
105
|
+
otherProps = (0, _objectWithoutPropertiesLoose2.default)(_extractPluginParamsF.otherProps, _excluded);
|
|
121
106
|
const {
|
|
122
107
|
getRootProps,
|
|
123
108
|
contextValue,
|
|
124
109
|
instance
|
|
125
|
-
} = (0, _useTreeView.useTreeView)(
|
|
126
|
-
disabledItemsFocusable,
|
|
127
|
-
expandedNodes,
|
|
128
|
-
defaultExpandedNodes,
|
|
129
|
-
onExpandedNodesChange,
|
|
130
|
-
onNodeExpansionToggle,
|
|
131
|
-
onNodeFocus,
|
|
132
|
-
disableSelection,
|
|
133
|
-
defaultSelectedNodes,
|
|
134
|
-
selectedNodes,
|
|
135
|
-
multiSelect,
|
|
136
|
-
onSelectedNodesChange,
|
|
137
|
-
onNodeSelectionToggle,
|
|
138
|
-
id: treeId,
|
|
139
|
-
defaultCollapseIcon,
|
|
140
|
-
defaultEndIcon,
|
|
141
|
-
defaultExpandIcon,
|
|
142
|
-
defaultParentIcon,
|
|
143
|
-
items,
|
|
144
|
-
getItemId,
|
|
145
|
-
getItemLabel,
|
|
146
|
-
isItemDisabled,
|
|
147
|
-
plugins: _plugins.DEFAULT_TREE_VIEW_PLUGINS,
|
|
148
|
-
rootRef: ref
|
|
149
|
-
});
|
|
110
|
+
} = (0, _useTreeView.useTreeView)(pluginParams);
|
|
150
111
|
const classes = useUtilityClasses(props);
|
|
151
112
|
const Root = slots?.root ?? RichTreeViewRoot;
|
|
152
113
|
const rootProps = (0, _utils.useSlotProps)({
|
|
153
114
|
elementType: Root,
|
|
154
115
|
externalSlotProps: slotProps?.root,
|
|
155
|
-
externalForwardedProps:
|
|
116
|
+
externalForwardedProps: otherProps,
|
|
156
117
|
className: classes.root,
|
|
157
118
|
getSlotProps: getRootProps,
|
|
158
119
|
ownerState: props
|
|
@@ -17,8 +17,9 @@ var _useTreeView = require("../internals/useTreeView");
|
|
|
17
17
|
var _TreeViewProvider = require("../internals/TreeViewProvider");
|
|
18
18
|
var _SimpleTreeView = require("./SimpleTreeView.plugins");
|
|
19
19
|
var _warning = require("../internals/utils/warning");
|
|
20
|
+
var _extractPluginParamsFromProps = require("../internals/utils/extractPluginParamsFromProps");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
const _excluded = ["
|
|
22
|
+
const _excluded = ["slots", "slotProps"];
|
|
22
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
25
|
const useUtilityClasses = ownerState => {
|
|
@@ -41,7 +42,7 @@ const SimpleTreeViewRoot = exports.SimpleTreeViewRoot = (0, _styles.styled)('ul'
|
|
|
41
42
|
outline: 0
|
|
42
43
|
});
|
|
43
44
|
const EMPTY_ITEMS = [];
|
|
44
|
-
const itemsPropWarning = (0, _warning.buildWarning)(['MUI: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://next.mui.com/x/react-tree-view/simple-tree-view/items/']);
|
|
45
|
+
const itemsPropWarning = (0, _warning.buildWarning)(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://next.mui.com/x/react-tree-view/simple-tree-view/items/']);
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
*
|
|
@@ -59,76 +60,42 @@ const SimpleTreeView = exports.SimpleTreeView = /*#__PURE__*/React.forwardRef(fu
|
|
|
59
60
|
name: 'MuiSimpleTreeView'
|
|
60
61
|
});
|
|
61
62
|
const ownerState = props;
|
|
62
|
-
const _ref = props,
|
|
63
|
-
{
|
|
64
|
-
// Headless implementation
|
|
65
|
-
disabledItemsFocusable,
|
|
66
|
-
expandedNodes,
|
|
67
|
-
defaultExpandedNodes,
|
|
68
|
-
onExpandedNodesChange,
|
|
69
|
-
onNodeExpansionToggle,
|
|
70
|
-
onNodeFocus,
|
|
71
|
-
disableSelection,
|
|
72
|
-
defaultSelectedNodes,
|
|
73
|
-
selectedNodes,
|
|
74
|
-
multiSelect,
|
|
75
|
-
onSelectedNodesChange,
|
|
76
|
-
onNodeSelectionToggle,
|
|
77
|
-
id,
|
|
78
|
-
defaultCollapseIcon,
|
|
79
|
-
defaultEndIcon,
|
|
80
|
-
defaultExpandIcon,
|
|
81
|
-
defaultParentIcon,
|
|
82
|
-
// Component implementation
|
|
83
|
-
children,
|
|
84
|
-
slots
|
|
85
|
-
} = _ref,
|
|
86
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
87
63
|
if (process.env.NODE_ENV !== 'production') {
|
|
88
64
|
if (props.items != null) {
|
|
89
65
|
itemsPropWarning();
|
|
90
66
|
}
|
|
91
67
|
}
|
|
68
|
+
const _extractPluginParamsF = (0, _extractPluginParamsFromProps.extractPluginParamsFromProps)({
|
|
69
|
+
props: (0, _extends2.default)({}, props, {
|
|
70
|
+
items: EMPTY_ITEMS
|
|
71
|
+
}),
|
|
72
|
+
plugins: _SimpleTreeView.SIMPLE_TREE_VIEW_PLUGINS,
|
|
73
|
+
rootRef: ref
|
|
74
|
+
}),
|
|
75
|
+
{
|
|
76
|
+
pluginParams,
|
|
77
|
+
otherProps: {
|
|
78
|
+
slots
|
|
79
|
+
}
|
|
80
|
+
} = _extractPluginParamsF,
|
|
81
|
+
otherProps = (0, _objectWithoutPropertiesLoose2.default)(_extractPluginParamsF.otherProps, _excluded);
|
|
92
82
|
const {
|
|
93
83
|
getRootProps,
|
|
94
84
|
contextValue
|
|
95
|
-
} = (0, _useTreeView.useTreeView)(
|
|
96
|
-
disabledItemsFocusable,
|
|
97
|
-
expandedNodes,
|
|
98
|
-
defaultExpandedNodes,
|
|
99
|
-
onExpandedNodesChange,
|
|
100
|
-
onNodeExpansionToggle,
|
|
101
|
-
onNodeFocus,
|
|
102
|
-
disableSelection,
|
|
103
|
-
defaultSelectedNodes,
|
|
104
|
-
selectedNodes,
|
|
105
|
-
multiSelect,
|
|
106
|
-
onSelectedNodesChange,
|
|
107
|
-
onNodeSelectionToggle,
|
|
108
|
-
id,
|
|
109
|
-
defaultCollapseIcon,
|
|
110
|
-
defaultEndIcon,
|
|
111
|
-
defaultExpandIcon,
|
|
112
|
-
defaultParentIcon,
|
|
113
|
-
items: EMPTY_ITEMS,
|
|
114
|
-
plugins: _SimpleTreeView.SIMPLE_TREE_VIEW_PLUGINS,
|
|
115
|
-
rootRef: ref
|
|
116
|
-
});
|
|
85
|
+
} = (0, _useTreeView.useTreeView)(pluginParams);
|
|
117
86
|
const classes = useUtilityClasses(props);
|
|
118
87
|
const Root = slots?.root ?? SimpleTreeViewRoot;
|
|
119
88
|
const rootProps = (0, _utils.useSlotProps)({
|
|
120
89
|
elementType: Root,
|
|
121
90
|
externalSlotProps: {},
|
|
122
|
-
externalForwardedProps:
|
|
91
|
+
externalForwardedProps: otherProps,
|
|
123
92
|
className: classes.root,
|
|
124
93
|
getSlotProps: getRootProps,
|
|
125
94
|
ownerState
|
|
126
95
|
});
|
|
127
96
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeViewProvider.TreeViewProvider, {
|
|
128
97
|
value: contextValue,
|
|
129
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({}, rootProps
|
|
130
|
-
children: children
|
|
131
|
-
}))
|
|
98
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, (0, _extends2.default)({}, rootProps))
|
|
132
99
|
});
|
|
133
100
|
});
|
|
134
101
|
process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
@@ -32,7 +32,7 @@ const TreeViewRoot = (0, _styles.styled)(_SimpleTreeView.SimpleTreeViewRoot, {
|
|
|
32
32
|
let warnedOnce = false;
|
|
33
33
|
const warn = () => {
|
|
34
34
|
if (!warnedOnce) {
|
|
35
|
-
console.warn(['MUI: The TreeView component was renamed SimpleTreeView.', 'The component with the old naming will be removed in the version v8.0.0.', '', "You should use `import { SimpleTreeView } from '@mui/x-tree-view'`", "or `import { SimpleTreeView } from '@mui/x-tree-view/TreeView'`"].join('\n'));
|
|
35
|
+
console.warn(['MUI X: The TreeView component was renamed SimpleTreeView.', 'The component with the old naming will be removed in the version v8.0.0.', '', "You should use `import { SimpleTreeView } from '@mui/x-tree-view'`", "or `import { SimpleTreeView } from '@mui/x-tree-view/TreeView'`"].join('\n'));
|
|
36
36
|
warnedOnce = true;
|
|
37
37
|
}
|
|
38
38
|
};
|
package/node/index.js
CHANGED
|
@@ -11,7 +11,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
11
11
|
const useTreeViewContext = () => {
|
|
12
12
|
const context = React.useContext(_TreeViewContext.TreeViewContext);
|
|
13
13
|
if (context == null) {
|
|
14
|
-
throw new Error(['MUI: Could not find the Tree View context.', 'It looks like you rendered your component outside of a SimpleTreeView or RichTreeView parent component.', 'This can also happen if you are bundling multiple versions of the Tree View.'].join('\n'));
|
|
14
|
+
throw new Error(['MUI X: Could not find the Tree View context.', 'It looks like you rendered your component outside of a SimpleTreeView or RichTreeView parent component.', 'This can also happen if you are bundling multiple versions of the Tree View.'].join('\n'));
|
|
15
15
|
}
|
|
16
16
|
return context;
|
|
17
17
|
};
|
package/node/internals/plugins/useTreeViewContextValueBuilder/useTreeViewContextValueBuilder.js
CHANGED
|
@@ -30,4 +30,10 @@ const useTreeViewContextValueBuilder = ({
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
exports.useTreeViewContextValueBuilder = useTreeViewContextValueBuilder;
|
|
33
|
+
exports.useTreeViewContextValueBuilder = useTreeViewContextValueBuilder;
|
|
34
|
+
useTreeViewContextValueBuilder.params = {
|
|
35
|
+
defaultCollapseIcon: true,
|
|
36
|
+
defaultEndIcon: true,
|
|
37
|
+
defaultExpandIcon: true,
|
|
38
|
+
defaultParentIcon: true
|
|
39
|
+
};
|
|
@@ -73,4 +73,10 @@ useTreeViewExpansion.models = {
|
|
|
73
73
|
const DEFAULT_EXPANDED_NODES = [];
|
|
74
74
|
useTreeViewExpansion.getDefaultizedParams = params => (0, _extends2.default)({}, params, {
|
|
75
75
|
defaultExpandedNodes: params.defaultExpandedNodes ?? DEFAULT_EXPANDED_NODES
|
|
76
|
-
});
|
|
76
|
+
});
|
|
77
|
+
useTreeViewExpansion.params = {
|
|
78
|
+
expandedNodes: true,
|
|
79
|
+
defaultExpandedNodes: true,
|
|
80
|
+
onExpandedNodesChange: true,
|
|
81
|
+
onNodeExpansionToggle: true
|
|
82
|
+
};
|
|
@@ -97,4 +97,7 @@ useTreeViewFocus.getInitialState = () => ({
|
|
|
97
97
|
});
|
|
98
98
|
useTreeViewFocus.getDefaultizedParams = params => (0, _extends2.default)({}, params, {
|
|
99
99
|
disabledItemsFocusable: params.disabledItemsFocusable ?? false
|
|
100
|
-
});
|
|
100
|
+
});
|
|
101
|
+
useTreeViewFocus.params = {
|
|
102
|
+
onNodeFocus: true
|
|
103
|
+
};
|