@mui/x-tree-view 7.5.0 → 7.5.1
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 +61 -5417
- package/RichTreeView/RichTreeView.js +1 -1
- package/SimpleTreeView/SimpleTreeView.js +1 -1
- package/TreeItem/TreeItem.js +1 -1
- package/TreeItem/TreeItemContent.js +1 -1
- package/TreeItem2/TreeItem2.js +1 -1
- package/TreeItem2Icon/TreeItem2Icon.js +1 -1
- package/TreeItem2Provider/TreeItem2Provider.js +1 -1
- package/TreeView/TreeView.js +1 -1
- package/hooks/useTreeItem2Utils/useTreeItem2Utils.js +7 -1
- package/index.js +1 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +1 -0
- package/internals/useTreeView/useTreeViewModels.d.ts +1 -1
- package/internals/useTreeView/useTreeViewModels.js +1 -1
- package/modern/RichTreeView/RichTreeView.js +1 -1
- package/modern/SimpleTreeView/SimpleTreeView.js +1 -1
- package/modern/TreeItem/TreeItem.js +1 -1
- package/modern/TreeItem/TreeItemContent.js +1 -1
- package/modern/TreeItem2/TreeItem2.js +1 -1
- package/modern/TreeItem2Icon/TreeItem2Icon.js +1 -1
- package/modern/TreeItem2Provider/TreeItem2Provider.js +1 -1
- package/modern/TreeView/TreeView.js +1 -1
- package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +7 -1
- package/modern/index.js +1 -1
- package/modern/internals/useTreeView/useTreeViewModels.js +1 -1
- package/node/RichTreeView/RichTreeView.js +1 -1
- package/node/SimpleTreeView/SimpleTreeView.js +1 -1
- package/node/TreeItem/TreeItem.js +1 -1
- package/node/TreeItem/TreeItemContent.js +1 -1
- package/node/TreeItem2/TreeItem2.js +1 -1
- package/node/TreeItem2Icon/TreeItem2Icon.js +1 -1
- package/node/TreeItem2Provider/TreeItem2Provider.js +1 -1
- package/node/TreeView/TreeView.js +1 -1
- package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +7 -1
- package/node/index.js +1 -1
- package/node/internals/useTreeView/useTreeViewModels.js +1 -1
- package/package.json +1 -1
|
@@ -131,7 +131,7 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
|
|
|
131
131
|
process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
132
132
|
// ----------------------------- Warning --------------------------------
|
|
133
133
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
134
|
-
// | To update them edit the TypeScript types and run "
|
|
134
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
135
135
|
// ----------------------------------------------------------------------
|
|
136
136
|
/**
|
|
137
137
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -89,7 +89,7 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
|
|
|
89
89
|
process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
90
90
|
// ----------------------------- Warning --------------------------------
|
|
91
91
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
92
|
-
// | To update them edit the TypeScript types and run "
|
|
92
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
93
93
|
// ----------------------------------------------------------------------
|
|
94
94
|
/**
|
|
95
95
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
package/TreeItem/TreeItem.js
CHANGED
|
@@ -324,7 +324,7 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
324
324
|
process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
|
|
325
325
|
// ----------------------------- Warning --------------------------------
|
|
326
326
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
327
|
-
// | To update them edit the TypeScript types and run "
|
|
327
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
328
328
|
// ----------------------------------------------------------------------
|
|
329
329
|
/**
|
|
330
330
|
* The content of the component.
|
|
@@ -83,7 +83,7 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
|
|
|
83
83
|
process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
|
|
84
84
|
// ----------------------------- Warning --------------------------------
|
|
85
85
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
86
|
-
// | To update them edit the TypeScript types and run "
|
|
86
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
87
87
|
// ----------------------------------------------------------------------
|
|
88
88
|
/**
|
|
89
89
|
* Override or extend the styles applied to the component.
|
package/TreeItem2/TreeItem2.js
CHANGED
|
@@ -281,7 +281,7 @@ export const TreeItem2 = /*#__PURE__*/React.forwardRef(function TreeItem2(inProp
|
|
|
281
281
|
process.env.NODE_ENV !== "production" ? TreeItem2.propTypes = {
|
|
282
282
|
// ----------------------------- Warning --------------------------------
|
|
283
283
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
284
|
-
// | To update them edit the TypeScript types and run "
|
|
284
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
285
285
|
// ----------------------------------------------------------------------
|
|
286
286
|
/**
|
|
287
287
|
* The content of the component.
|
|
@@ -44,7 +44,7 @@ function TreeItem2Icon(props) {
|
|
|
44
44
|
process.env.NODE_ENV !== "production" ? TreeItem2Icon.propTypes = {
|
|
45
45
|
// ----------------------------- Warning --------------------------------
|
|
46
46
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
47
|
-
// | To update them edit the TypeScript types and run "
|
|
47
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
48
48
|
// ----------------------------------------------------------------------
|
|
49
49
|
/**
|
|
50
50
|
* The props used for each component slot.
|
|
@@ -16,7 +16,7 @@ function TreeItem2Provider(props) {
|
|
|
16
16
|
TreeItem2Provider.propTypes = {
|
|
17
17
|
// ----------------------------- Warning --------------------------------
|
|
18
18
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
19
|
-
// | To update them edit the TypeScript types and run "
|
|
19
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
20
20
|
// ----------------------------------------------------------------------
|
|
21
21
|
children: PropTypes.node,
|
|
22
22
|
itemId: PropTypes.string.isRequired
|
package/TreeView/TreeView.js
CHANGED
|
@@ -62,7 +62,7 @@ const TreeView = /*#__PURE__*/React.forwardRef(function TreeView(inProps, ref) {
|
|
|
62
62
|
process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
63
63
|
// ----------------------------- Warning --------------------------------
|
|
64
64
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
|
-
// | To update them edit the TypeScript types and run "
|
|
65
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
66
66
|
// ----------------------------------------------------------------------
|
|
67
67
|
/**
|
|
68
68
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { useTreeViewContext } from '../../internals/TreeViewProvider/useTreeViewContext';
|
|
2
|
+
const isItemExpandable = reactChildren => {
|
|
3
|
+
if (Array.isArray(reactChildren)) {
|
|
4
|
+
return reactChildren.length > 0 && reactChildren.some(isItemExpandable);
|
|
5
|
+
}
|
|
6
|
+
return Boolean(reactChildren);
|
|
7
|
+
};
|
|
2
8
|
export const useTreeItem2Utils = ({
|
|
3
9
|
itemId,
|
|
4
10
|
children
|
|
@@ -10,7 +16,7 @@ export const useTreeItem2Utils = ({
|
|
|
10
16
|
}
|
|
11
17
|
} = useTreeViewContext();
|
|
12
18
|
const status = {
|
|
13
|
-
expandable:
|
|
19
|
+
expandable: isItemExpandable(children),
|
|
14
20
|
expanded: instance.isItemExpanded(itemId),
|
|
15
21
|
focused: instance.isItemFocused(itemId),
|
|
16
22
|
selected: instance.isItemSelected(itemId),
|
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ interface TreeViewItemProps {
|
|
|
9
9
|
export interface UseTreeViewItemsPublicAPI<R extends {}> {
|
|
10
10
|
/**
|
|
11
11
|
* Get the item with the given id.
|
|
12
|
+
* When used in the `SimpleTreeView`, it returns an object with the `id` and `label` properties.
|
|
12
13
|
* @param {string} itemId The id of the item to return.
|
|
13
14
|
* @returns {R} The item with the given id.
|
|
14
15
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TreeViewAnyPluginSignature, TreeViewPlugin, ConvertPluginsIntoSignatures, MergePluginsProperty } from '../models';
|
|
2
2
|
/**
|
|
3
3
|
* Implements the same behavior as `useControlled` but for several models.
|
|
4
|
-
* The controlled models are never stored in the state and the state is only updated if the model is not controlled.
|
|
4
|
+
* The controlled models are never stored in the state, and the state is only updated if the model is not controlled.
|
|
5
5
|
*/
|
|
6
6
|
export declare const useTreeViewModels: <TPlugins extends readonly TreeViewPlugin<TreeViewAnyPluginSignature>[]>(plugins: TPlugins, props: MergePluginsProperty<ConvertPluginsIntoSignatures<TPlugins>, 'defaultizedParams'>) => MergePluginsProperty<ConvertPluginsIntoSignatures<TPlugins>, "models">;
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Implements the same behavior as `useControlled` but for several models.
|
|
5
|
-
* The controlled models are never stored in the state and the state is only updated if the model is not controlled.
|
|
5
|
+
* The controlled models are never stored in the state, and the state is only updated if the model is not controlled.
|
|
6
6
|
*/
|
|
7
7
|
export const useTreeViewModels = (plugins, props) => {
|
|
8
8
|
const modelsRef = React.useRef({});
|
|
@@ -131,7 +131,7 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
|
|
|
131
131
|
process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
132
132
|
// ----------------------------- Warning --------------------------------
|
|
133
133
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
134
|
-
// | To update them edit the TypeScript types and run "
|
|
134
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
135
135
|
// ----------------------------------------------------------------------
|
|
136
136
|
/**
|
|
137
137
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -89,7 +89,7 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
|
|
|
89
89
|
process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
90
90
|
// ----------------------------- Warning --------------------------------
|
|
91
91
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
92
|
-
// | To update them edit the TypeScript types and run "
|
|
92
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
93
93
|
// ----------------------------------------------------------------------
|
|
94
94
|
/**
|
|
95
95
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -324,7 +324,7 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
324
324
|
process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
|
|
325
325
|
// ----------------------------- Warning --------------------------------
|
|
326
326
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
327
|
-
// | To update them edit the TypeScript types and run "
|
|
327
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
328
328
|
// ----------------------------------------------------------------------
|
|
329
329
|
/**
|
|
330
330
|
* The content of the component.
|
|
@@ -83,7 +83,7 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
|
|
|
83
83
|
process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
|
|
84
84
|
// ----------------------------- Warning --------------------------------
|
|
85
85
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
86
|
-
// | To update them edit the TypeScript types and run "
|
|
86
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
87
87
|
// ----------------------------------------------------------------------
|
|
88
88
|
/**
|
|
89
89
|
* Override or extend the styles applied to the component.
|
|
@@ -281,7 +281,7 @@ export const TreeItem2 = /*#__PURE__*/React.forwardRef(function TreeItem2(inProp
|
|
|
281
281
|
process.env.NODE_ENV !== "production" ? TreeItem2.propTypes = {
|
|
282
282
|
// ----------------------------- Warning --------------------------------
|
|
283
283
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
284
|
-
// | To update them edit the TypeScript types and run "
|
|
284
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
285
285
|
// ----------------------------------------------------------------------
|
|
286
286
|
/**
|
|
287
287
|
* The content of the component.
|
|
@@ -44,7 +44,7 @@ function TreeItem2Icon(props) {
|
|
|
44
44
|
process.env.NODE_ENV !== "production" ? TreeItem2Icon.propTypes = {
|
|
45
45
|
// ----------------------------- Warning --------------------------------
|
|
46
46
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
47
|
-
// | To update them edit the TypeScript types and run "
|
|
47
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
48
48
|
// ----------------------------------------------------------------------
|
|
49
49
|
/**
|
|
50
50
|
* The props used for each component slot.
|
|
@@ -16,7 +16,7 @@ function TreeItem2Provider(props) {
|
|
|
16
16
|
TreeItem2Provider.propTypes = {
|
|
17
17
|
// ----------------------------- Warning --------------------------------
|
|
18
18
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
19
|
-
// | To update them edit the TypeScript types and run "
|
|
19
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
20
20
|
// ----------------------------------------------------------------------
|
|
21
21
|
children: PropTypes.node,
|
|
22
22
|
itemId: PropTypes.string.isRequired
|
|
@@ -62,7 +62,7 @@ const TreeView = /*#__PURE__*/React.forwardRef(function TreeView(inProps, ref) {
|
|
|
62
62
|
process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
63
63
|
// ----------------------------- Warning --------------------------------
|
|
64
64
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
|
-
// | To update them edit the TypeScript types and run "
|
|
65
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
66
66
|
// ----------------------------------------------------------------------
|
|
67
67
|
/**
|
|
68
68
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { useTreeViewContext } from '../../internals/TreeViewProvider/useTreeViewContext';
|
|
2
|
+
const isItemExpandable = reactChildren => {
|
|
3
|
+
if (Array.isArray(reactChildren)) {
|
|
4
|
+
return reactChildren.length > 0 && reactChildren.some(isItemExpandable);
|
|
5
|
+
}
|
|
6
|
+
return Boolean(reactChildren);
|
|
7
|
+
};
|
|
2
8
|
export const useTreeItem2Utils = ({
|
|
3
9
|
itemId,
|
|
4
10
|
children
|
|
@@ -10,7 +16,7 @@ export const useTreeItem2Utils = ({
|
|
|
10
16
|
}
|
|
11
17
|
} = useTreeViewContext();
|
|
12
18
|
const status = {
|
|
13
|
-
expandable:
|
|
19
|
+
expandable: isItemExpandable(children),
|
|
14
20
|
expanded: instance.isItemExpanded(itemId),
|
|
15
21
|
focused: instance.isItemFocused(itemId),
|
|
16
22
|
selected: instance.isItemSelected(itemId),
|
package/modern/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Implements the same behavior as `useControlled` but for several models.
|
|
5
|
-
* The controlled models are never stored in the state and the state is only updated if the model is not controlled.
|
|
5
|
+
* The controlled models are never stored in the state, and the state is only updated if the model is not controlled.
|
|
6
6
|
*/
|
|
7
7
|
export const useTreeViewModels = (plugins, props) => {
|
|
8
8
|
const modelsRef = React.useRef({});
|
|
@@ -140,7 +140,7 @@ const RichTreeView = exports.RichTreeView = /*#__PURE__*/React.forwardRef(functi
|
|
|
140
140
|
process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
141
141
|
// ----------------------------- Warning --------------------------------
|
|
142
142
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
143
|
-
// | To update them edit the TypeScript types and run "
|
|
143
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
144
144
|
// ----------------------------------------------------------------------
|
|
145
145
|
/**
|
|
146
146
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -98,7 +98,7 @@ const SimpleTreeView = exports.SimpleTreeView = /*#__PURE__*/React.forwardRef(fu
|
|
|
98
98
|
process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
99
99
|
// ----------------------------- Warning --------------------------------
|
|
100
100
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
101
|
-
// | To update them edit the TypeScript types and run "
|
|
101
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
102
102
|
// ----------------------------------------------------------------------
|
|
103
103
|
/**
|
|
104
104
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -333,7 +333,7 @@ const TreeItem = exports.TreeItem = /*#__PURE__*/React.forwardRef(function TreeI
|
|
|
333
333
|
process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
|
|
334
334
|
// ----------------------------- Warning --------------------------------
|
|
335
335
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
336
|
-
// | To update them edit the TypeScript types and run "
|
|
336
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
337
337
|
// ----------------------------------------------------------------------
|
|
338
338
|
/**
|
|
339
339
|
* The content of the component.
|
|
@@ -92,7 +92,7 @@ const TreeItemContent = exports.TreeItemContent = /*#__PURE__*/React.forwardRef(
|
|
|
92
92
|
process.env.NODE_ENV !== "production" ? TreeItemContent.propTypes = {
|
|
93
93
|
// ----------------------------- Warning --------------------------------
|
|
94
94
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
95
|
-
// | To update them edit the TypeScript types and run "
|
|
95
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
96
96
|
// ----------------------------------------------------------------------
|
|
97
97
|
/**
|
|
98
98
|
* Override or extend the styles applied to the component.
|
|
@@ -290,7 +290,7 @@ const TreeItem2 = exports.TreeItem2 = /*#__PURE__*/React.forwardRef(function Tre
|
|
|
290
290
|
process.env.NODE_ENV !== "production" ? TreeItem2.propTypes = {
|
|
291
291
|
// ----------------------------- Warning --------------------------------
|
|
292
292
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
293
|
-
// | To update them edit the TypeScript types and run "
|
|
293
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
294
294
|
// ----------------------------------------------------------------------
|
|
295
295
|
/**
|
|
296
296
|
* The content of the component.
|
|
@@ -53,7 +53,7 @@ function TreeItem2Icon(props) {
|
|
|
53
53
|
process.env.NODE_ENV !== "production" ? TreeItem2Icon.propTypes = {
|
|
54
54
|
// ----------------------------- Warning --------------------------------
|
|
55
55
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
56
|
-
// | To update them edit the TypeScript types and run "
|
|
56
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
57
57
|
// ----------------------------------------------------------------------
|
|
58
58
|
/**
|
|
59
59
|
* The props used for each component slot.
|
|
@@ -23,7 +23,7 @@ function TreeItem2Provider(props) {
|
|
|
23
23
|
TreeItem2Provider.propTypes = {
|
|
24
24
|
// ----------------------------- Warning --------------------------------
|
|
25
25
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
26
|
-
// | To update them edit the TypeScript types and run "
|
|
26
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
27
27
|
// ----------------------------------------------------------------------
|
|
28
28
|
children: _propTypes.default.node,
|
|
29
29
|
itemId: _propTypes.default.string.isRequired
|
|
@@ -71,7 +71,7 @@ const TreeView = exports.TreeView = /*#__PURE__*/React.forwardRef(function TreeV
|
|
|
71
71
|
process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
72
72
|
// ----------------------------- Warning --------------------------------
|
|
73
73
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
74
|
-
// | To update them edit the TypeScript types and run "
|
|
74
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
75
75
|
// ----------------------------------------------------------------------
|
|
76
76
|
/**
|
|
77
77
|
* The ref object that allows Tree View manipulation. Can be instantiated with `useTreeViewApiRef()`.
|
|
@@ -5,6 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useTreeItem2Utils = void 0;
|
|
7
7
|
var _useTreeViewContext = require("../../internals/TreeViewProvider/useTreeViewContext");
|
|
8
|
+
const isItemExpandable = reactChildren => {
|
|
9
|
+
if (Array.isArray(reactChildren)) {
|
|
10
|
+
return reactChildren.length > 0 && reactChildren.some(isItemExpandable);
|
|
11
|
+
}
|
|
12
|
+
return Boolean(reactChildren);
|
|
13
|
+
};
|
|
8
14
|
const useTreeItem2Utils = ({
|
|
9
15
|
itemId,
|
|
10
16
|
children
|
|
@@ -16,7 +22,7 @@ const useTreeItem2Utils = ({
|
|
|
16
22
|
}
|
|
17
23
|
} = (0, _useTreeViewContext.useTreeViewContext)();
|
|
18
24
|
const status = {
|
|
19
|
-
expandable:
|
|
25
|
+
expandable: isItemExpandable(children),
|
|
20
26
|
expanded: instance.isItemExpanded(itemId),
|
|
21
27
|
focused: instance.isItemFocused(itemId),
|
|
22
28
|
selected: instance.isItemSelected(itemId),
|
package/node/index.js
CHANGED
|
@@ -11,7 +11,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
11
11
|
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 && {}.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; }
|
|
12
12
|
/**
|
|
13
13
|
* Implements the same behavior as `useControlled` but for several models.
|
|
14
|
-
* The controlled models are never stored in the state and the state is only updated if the model is not controlled.
|
|
14
|
+
* The controlled models are never stored in the state, and the state is only updated if the model is not controlled.
|
|
15
15
|
*/
|
|
16
16
|
const useTreeViewModels = (plugins, props) => {
|
|
17
17
|
const modelsRef = React.useRef({});
|