@mui/x-tree-view 7.0.0-beta.3 → 7.0.0-beta.5
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 +357 -22
- package/RichTreeView/RichTreeView.js +8 -0
- package/RichTreeView/RichTreeView.types.d.ts +7 -1
- package/SimpleTreeView/SimpleTreeView.js +8 -0
- package/SimpleTreeView/SimpleTreeView.types.d.ts +7 -1
- package/TreeItem/TreeItem.js +1 -1
- package/TreeItem/TreeItem.types.d.ts +1 -1
- package/TreeView/TreeView.js +8 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/package.json +6 -0
- package/hooks/useTreeViewApiRef.d.ts +6 -0
- package/hooks/useTreeViewApiRef.js +5 -0
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/TreeViewProvider/DescendantProvider.js +1 -11
- package/internals/hooks/useTimeout.d.ts +5 -3
- package/internals/hooks/useTimeout.js +13 -5
- package/internals/models/helpers.d.ts +1 -0
- package/internals/models/plugin.d.ts +12 -0
- package/internals/models/treeView.d.ts +1 -0
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +40 -22
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.d.ts +5 -0
- package/internals/useTreeView/useTreeView.d.ts +2 -0
- package/internals/useTreeView/useTreeView.js +12 -0
- package/internals/useTreeView/useTreeView.types.d.ts +2 -1
- package/internals/useTreeView/useTreeView.utils.d.ts +2 -1
- package/internals/useTreeView/useTreeView.utils.js +3 -0
- package/internals/utils/extractPluginParamsFromProps.d.ts +3 -2
- package/internals/utils/extractPluginParamsFromProps.js +5 -3
- package/internals/utils/utils.d.ts +1 -0
- package/internals/utils/utils.js +10 -0
- package/modern/RichTreeView/RichTreeView.js +8 -0
- package/modern/SimpleTreeView/SimpleTreeView.js +8 -0
- package/modern/TreeItem/TreeItem.js +1 -1
- package/modern/TreeView/TreeView.js +8 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/useTreeViewApiRef.js +5 -0
- package/modern/index.js +3 -2
- package/modern/internals/TreeViewProvider/DescendantProvider.js +1 -11
- package/modern/internals/hooks/useTimeout.js +13 -5
- package/modern/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +40 -22
- package/modern/internals/useTreeView/useTreeView.js +12 -0
- package/modern/internals/useTreeView/useTreeView.utils.js +3 -0
- package/modern/internals/utils/extractPluginParamsFromProps.js +5 -3
- package/modern/internals/utils/utils.js +10 -0
- package/node/RichTreeView/RichTreeView.js +8 -0
- package/node/SimpleTreeView/SimpleTreeView.js +8 -0
- package/node/TreeItem/TreeItem.js +1 -1
- package/node/TreeView/TreeView.js +8 -0
- package/node/hooks/index.js +12 -0
- package/node/hooks/useTreeViewApiRef.js +14 -0
- package/node/index.js +13 -1
- package/node/internals/TreeViewProvider/DescendantProvider.js +1 -10
- package/node/internals/hooks/useTimeout.js +13 -4
- package/node/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +39 -21
- package/node/internals/useTreeView/useTreeView.js +13 -0
- package/node/internals/useTreeView/useTreeView.utils.js +6 -2
- package/node/internals/utils/extractPluginParamsFromProps.js +5 -3
- package/node/internals/utils/utils.js +17 -0
- package/package.json +1 -1
- package/legacy/RichTreeView/RichTreeView.js +0 -255
- package/legacy/RichTreeView/RichTreeView.types.js +0 -1
- package/legacy/RichTreeView/index.js +0 -3
- package/legacy/RichTreeView/richTreeViewClasses.js +0 -6
- package/legacy/SimpleTreeView/SimpleTreeView.js +0 -190
- package/legacy/SimpleTreeView/SimpleTreeView.plugins.js +0 -6
- package/legacy/SimpleTreeView/SimpleTreeView.types.js +0 -1
- package/legacy/SimpleTreeView/index.js +0 -3
- package/legacy/SimpleTreeView/simpleTreeViewClasses.js +0 -6
- package/legacy/TreeItem/TreeItem.js +0 -360
- package/legacy/TreeItem/TreeItem.types.js +0 -1
- package/legacy/TreeItem/TreeItemContent.js +0 -95
- package/legacy/TreeItem/index.js +0 -4
- package/legacy/TreeItem/treeItemClasses.js +0 -6
- package/legacy/TreeItem/useTreeItemState.js +0 -58
- package/legacy/TreeView/TreeView.js +0 -165
- package/legacy/TreeView/TreeView.types.js +0 -1
- package/legacy/TreeView/index.js +0 -3
- package/legacy/TreeView/treeViewClasses.js +0 -6
- package/legacy/icons/icons.js +0 -9
- package/legacy/icons/index.js +0 -1
- package/legacy/index.js +0 -14
- package/legacy/internals/TreeViewProvider/DescendantProvider.js +0 -199
- package/legacy/internals/TreeViewProvider/TreeViewContext.js +0 -8
- package/legacy/internals/TreeViewProvider/TreeViewProvider.js +0 -19
- package/legacy/internals/TreeViewProvider/TreeViewProvider.types.js +0 -1
- package/legacy/internals/TreeViewProvider/index.js +0 -1
- package/legacy/internals/TreeViewProvider/useTreeViewContext.js +0 -9
- package/legacy/internals/corePlugins/corePlugins.js +0 -6
- package/legacy/internals/corePlugins/index.js +0 -1
- package/legacy/internals/corePlugins/useTreeViewInstanceEvents/index.js +0 -1
- package/legacy/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +0 -40
- package/legacy/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types.js +0 -1
- package/legacy/internals/hooks/useInstanceEventHandler.js +0 -87
- package/legacy/internals/hooks/useLazyRef.js +0 -11
- package/legacy/internals/hooks/useOnMount.js +0 -7
- package/legacy/internals/hooks/useTimeout.js +0 -38
- package/legacy/internals/index.js +0 -4
- package/legacy/internals/models/MuiCancellableEvent.js +0 -1
- package/legacy/internals/models/events.js +0 -1
- package/legacy/internals/models/helpers.js +0 -1
- package/legacy/internals/models/index.js +0 -3
- package/legacy/internals/models/plugin.js +0 -1
- package/legacy/internals/models/treeView.js +0 -1
- package/legacy/internals/plugins/defaultPlugins.js +0 -10
- package/legacy/internals/plugins/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewExpansion/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +0 -81
- package/legacy/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewFocus/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +0 -103
- package/legacy/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewIcons/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewIcons/useTreeViewIcons.js +0 -21
- package/legacy/internals/plugins/useTreeViewIcons/useTreeViewIcons.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewId/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewId/useTreeViewId.js +0 -24
- package/legacy/internals/plugins/useTreeViewId/useTreeViewId.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewJSXNodes/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewJSXNodes/useTreeViewJSXNodes.js +0 -130
- package/legacy/internals/plugins/useTreeViewJSXNodes/useTreeViewJSXNodes.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewKeyboardNavigation/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +0 -284
- package/legacy/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewNodes/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewNodes/useTreeViewNodes.js +0 -161
- package/legacy/internals/plugins/useTreeViewNodes/useTreeViewNodes.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewSelection/index.js +0 -1
- package/legacy/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +0 -219
- package/legacy/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.js +0 -1
- package/legacy/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +0 -55
- package/legacy/internals/useTreeView/index.js +0 -1
- package/legacy/internals/useTreeView/useTreeView.js +0 -111
- package/legacy/internals/useTreeView/useTreeView.types.js +0 -1
- package/legacy/internals/useTreeView/useTreeView.utils.js +0 -46
- package/legacy/internals/useTreeView/useTreeViewModels.js +0 -75
- package/legacy/internals/utils/EventManager.js +0 -91
- package/legacy/internals/utils/cleanupTracking/CleanupTracking.js +0 -1
- package/legacy/internals/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +0 -29
- package/legacy/internals/utils/cleanupTracking/TimerBasedCleanupTracking.js +0 -52
- package/legacy/internals/utils/extractPluginParamsFromProps.js +0 -36
- package/legacy/internals/utils/publishTreeViewEvent.js +0 -3
- package/legacy/internals/utils/warning.js +0 -15
- package/legacy/models/index.js +0 -1
- package/legacy/models/items.js +0 -1
- package/legacy/themeAugmentation/index.js +0 -3
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { styled, useThemeProps } from '@mui/material/styles';
|
|
5
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
6
|
-
import { getTreeViewUtilityClass } from './treeViewClasses';
|
|
7
|
-
import { SimpleTreeView, SimpleTreeViewRoot } from '../SimpleTreeView';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
10
|
-
var classes = ownerState.classes;
|
|
11
|
-
var slots = {
|
|
12
|
-
root: ['root']
|
|
13
|
-
};
|
|
14
|
-
return composeClasses(slots, getTreeViewUtilityClass, classes);
|
|
15
|
-
};
|
|
16
|
-
var TreeViewRoot = styled(SimpleTreeViewRoot, {
|
|
17
|
-
name: 'MuiTreeView',
|
|
18
|
-
slot: 'Root',
|
|
19
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
20
|
-
return styles.root;
|
|
21
|
-
}
|
|
22
|
-
})({});
|
|
23
|
-
var warnedOnce = false;
|
|
24
|
-
var warn = function warn() {
|
|
25
|
-
if (!warnedOnce) {
|
|
26
|
-
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'));
|
|
27
|
-
warnedOnce = true;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* This component has been deprecated in favor of the new `SimpleTreeView` component.
|
|
33
|
-
* You can have a look at how to migrate to the new component in the v7 [migration guide](https://next.mui.com/x/migration/migration-tree-view-v6/#use-simpletreeview-instead-of-treeview)
|
|
34
|
-
*
|
|
35
|
-
* Demos:
|
|
36
|
-
*
|
|
37
|
-
* - [Tree View](https://mui.com/x/react-tree-view/)
|
|
38
|
-
*
|
|
39
|
-
* API:
|
|
40
|
-
*
|
|
41
|
-
* - [TreeView API](https://mui.com/x/api/tree-view/tree-view/)
|
|
42
|
-
*
|
|
43
|
-
* @deprecated
|
|
44
|
-
*/
|
|
45
|
-
var TreeView = /*#__PURE__*/React.forwardRef(function TreeView(inProps, ref) {
|
|
46
|
-
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
|
47
|
-
warn();
|
|
48
|
-
}
|
|
49
|
-
var props = useThemeProps({
|
|
50
|
-
props: inProps,
|
|
51
|
-
name: 'MuiTreeView'
|
|
52
|
-
});
|
|
53
|
-
var classes = useUtilityClasses(props);
|
|
54
|
-
return /*#__PURE__*/_jsx(SimpleTreeView, _extends({}, props, {
|
|
55
|
-
ref: ref,
|
|
56
|
-
classes: classes,
|
|
57
|
-
slots: _extends({
|
|
58
|
-
root: TreeViewRoot
|
|
59
|
-
}, props.slots)
|
|
60
|
-
}));
|
|
61
|
-
});
|
|
62
|
-
process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
63
|
-
// ----------------------------- Warning --------------------------------
|
|
64
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
66
|
-
// ----------------------------------------------------------------------
|
|
67
|
-
/**
|
|
68
|
-
* The content of the component.
|
|
69
|
-
*/
|
|
70
|
-
children: PropTypes.node,
|
|
71
|
-
/**
|
|
72
|
-
* Override or extend the styles applied to the component.
|
|
73
|
-
*/
|
|
74
|
-
classes: PropTypes.object,
|
|
75
|
-
className: PropTypes.string,
|
|
76
|
-
/**
|
|
77
|
-
* Expanded node ids.
|
|
78
|
-
* Used when the item's expansion is not controlled.
|
|
79
|
-
* @default []
|
|
80
|
-
*/
|
|
81
|
-
defaultExpandedNodes: PropTypes.arrayOf(PropTypes.string),
|
|
82
|
-
/**
|
|
83
|
-
* Selected node ids. (Uncontrolled)
|
|
84
|
-
* When `multiSelect` is true this takes an array of strings; when false (default) a string.
|
|
85
|
-
* @default []
|
|
86
|
-
*/
|
|
87
|
-
defaultSelectedNodes: PropTypes.any,
|
|
88
|
-
/**
|
|
89
|
-
* If `true`, will allow focus on disabled items.
|
|
90
|
-
* @default false
|
|
91
|
-
*/
|
|
92
|
-
disabledItemsFocusable: PropTypes.bool,
|
|
93
|
-
/**
|
|
94
|
-
* If `true` selection is disabled.
|
|
95
|
-
* @default false
|
|
96
|
-
*/
|
|
97
|
-
disableSelection: PropTypes.bool,
|
|
98
|
-
/**
|
|
99
|
-
* Expanded node ids.
|
|
100
|
-
* Used when the item's expansion is controlled.
|
|
101
|
-
*/
|
|
102
|
-
expandedNodes: PropTypes.arrayOf(PropTypes.string),
|
|
103
|
-
/**
|
|
104
|
-
* This prop is used to help implement the accessibility logic.
|
|
105
|
-
* If you don't provide this prop. It falls back to a randomly generated id.
|
|
106
|
-
*/
|
|
107
|
-
id: PropTypes.string,
|
|
108
|
-
/**
|
|
109
|
-
* If true `ctrl` and `shift` will trigger multiselect.
|
|
110
|
-
* @default false
|
|
111
|
-
*/
|
|
112
|
-
multiSelect: PropTypes.bool,
|
|
113
|
-
/**
|
|
114
|
-
* Callback fired when tree items are expanded/collapsed.
|
|
115
|
-
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
116
|
-
* @param {array} nodeIds The ids of the expanded nodes.
|
|
117
|
-
*/
|
|
118
|
-
onExpandedNodesChange: PropTypes.func,
|
|
119
|
-
/**
|
|
120
|
-
* Callback fired when a tree item is expanded or collapsed.
|
|
121
|
-
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
122
|
-
* @param {array} nodeId The nodeId of the modified node.
|
|
123
|
-
* @param {array} isExpanded `true` if the node has just been expanded, `false` if it has just been collapsed.
|
|
124
|
-
*/
|
|
125
|
-
onNodeExpansionToggle: PropTypes.func,
|
|
126
|
-
/**
|
|
127
|
-
* Callback fired when tree items are focused.
|
|
128
|
-
* @param {React.SyntheticEvent} event The event source of the callback **Warning**: This is a generic event not a focus event.
|
|
129
|
-
* @param {string} nodeId The id of the node focused.
|
|
130
|
-
* @param {string} value of the focused node.
|
|
131
|
-
*/
|
|
132
|
-
onNodeFocus: PropTypes.func,
|
|
133
|
-
/**
|
|
134
|
-
* Callback fired when a tree item is selected or deselected.
|
|
135
|
-
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
136
|
-
* @param {array} nodeId The nodeId of the modified node.
|
|
137
|
-
* @param {array} isSelected `true` if the node has just been selected, `false` if it has just been deselected.
|
|
138
|
-
*/
|
|
139
|
-
onNodeSelectionToggle: PropTypes.func,
|
|
140
|
-
/**
|
|
141
|
-
* Callback fired when tree items are selected/deselected.
|
|
142
|
-
* @param {React.SyntheticEvent} event The event source of the callback
|
|
143
|
-
* @param {string[] | string} nodeIds The ids of the selected nodes.
|
|
144
|
-
* When `multiSelect` is `true`, this is an array of strings; when false (default) a string.
|
|
145
|
-
*/
|
|
146
|
-
onSelectedNodesChange: PropTypes.func,
|
|
147
|
-
/**
|
|
148
|
-
* Selected node ids. (Controlled)
|
|
149
|
-
* When `multiSelect` is true this takes an array of strings; when false (default) a string.
|
|
150
|
-
*/
|
|
151
|
-
selectedNodes: PropTypes.any,
|
|
152
|
-
/**
|
|
153
|
-
* The props used for each component slot.
|
|
154
|
-
*/
|
|
155
|
-
slotProps: PropTypes.object,
|
|
156
|
-
/**
|
|
157
|
-
* Overridable component slots.
|
|
158
|
-
*/
|
|
159
|
-
slots: PropTypes.object,
|
|
160
|
-
/**
|
|
161
|
-
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
162
|
-
*/
|
|
163
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
164
|
-
} : void 0;
|
|
165
|
-
export { TreeView };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/legacy/TreeView/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
-
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
-
export function getTreeViewUtilityClass(slot) {
|
|
4
|
-
return generateUtilityClass('MuiTreeView', slot);
|
|
5
|
-
}
|
|
6
|
-
export var treeViewClasses = generateUtilityClasses('MuiTreeView', ['root']);
|
package/legacy/icons/icons.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createSvgIcon } from '@mui/material/utils';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
export var TreeViewExpandIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
5
|
-
d: "M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
|
|
6
|
-
}), 'TreeViewExpandIcon');
|
|
7
|
-
export var TreeViewCollapseIcon = createSvgIcon( /*#__PURE__*/_jsx("path", {
|
|
8
|
-
d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"
|
|
9
|
-
}), 'TreeViewCollapseIcon');
|
package/legacy/icons/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './icons';
|
package/legacy/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @mui/x-tree-view v7.0.0-beta.3
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
export * from './TreeItem';
|
|
9
|
-
export * from './TreeView';
|
|
10
|
-
export * from './SimpleTreeView';
|
|
11
|
-
export * from './RichTreeView';
|
|
12
|
-
export { unstable_resetCleanupTracking } from './internals/hooks/useInstanceEventHandler';
|
|
13
|
-
export * from './models';
|
|
14
|
-
export * from './icons';
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
var _excluded = ["element"];
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
|
-
|
|
9
|
-
/** Credit: https://github.com/reach/reach-ui/blob/86a046f54d53b6420e392b3fa56dd991d9d4e458/packages/descendants/README.md
|
|
10
|
-
* Modified slightly to suit our purposes.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// To replace with .findIndex() once we stop IE11 support.
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
function findIndex(array, comp) {
|
|
16
|
-
for (var i = 0; i < array.length; i += 1) {
|
|
17
|
-
if (comp(array[i])) {
|
|
18
|
-
return i;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return -1;
|
|
22
|
-
}
|
|
23
|
-
function binaryFindElement(array, element) {
|
|
24
|
-
var start = 0;
|
|
25
|
-
var end = array.length - 1;
|
|
26
|
-
while (start <= end) {
|
|
27
|
-
var middle = Math.floor((start + end) / 2);
|
|
28
|
-
if (array[middle].element === element) {
|
|
29
|
-
return middle;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line no-bitwise
|
|
33
|
-
if (array[middle].element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
34
|
-
end = middle - 1;
|
|
35
|
-
} else {
|
|
36
|
-
start = middle + 1;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return start;
|
|
40
|
-
}
|
|
41
|
-
var DescendantContext = /*#__PURE__*/React.createContext({});
|
|
42
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
43
|
-
DescendantContext.displayName = 'DescendantContext';
|
|
44
|
-
}
|
|
45
|
-
function usePrevious(value) {
|
|
46
|
-
var ref = React.useRef(null);
|
|
47
|
-
React.useEffect(function () {
|
|
48
|
-
ref.current = value;
|
|
49
|
-
}, [value]);
|
|
50
|
-
return ref.current;
|
|
51
|
-
}
|
|
52
|
-
var noop = function noop() {};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* This hook registers our descendant by passing it into an array. We can then
|
|
56
|
-
* search that array by to find its index when registering it in the component.
|
|
57
|
-
* We use this for focus management, keyboard navigation, and typeahead
|
|
58
|
-
* functionality for some components.
|
|
59
|
-
*
|
|
60
|
-
* The hook accepts the element node
|
|
61
|
-
*
|
|
62
|
-
* Our main goals with this are:
|
|
63
|
-
* 1) maximum composability,
|
|
64
|
-
* 2) minimal API friction
|
|
65
|
-
* 3) SSR compatibility*
|
|
66
|
-
* 4) concurrent safe
|
|
67
|
-
* 5) index always up-to-date with the tree despite changes
|
|
68
|
-
* 6) works with memoization of any component in the tree (hopefully)
|
|
69
|
-
*
|
|
70
|
-
* * As for SSR, the good news is that we don't actually need the index on the
|
|
71
|
-
* server for most use-cases, as we are only using it to determine the order of
|
|
72
|
-
* composed descendants for keyboard navigation.
|
|
73
|
-
*/
|
|
74
|
-
export function useDescendant(descendant) {
|
|
75
|
-
var _React$useState = React.useState(),
|
|
76
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
77
|
-
forceUpdate = _React$useState2[1];
|
|
78
|
-
var _React$useContext = React.useContext(DescendantContext),
|
|
79
|
-
_React$useContext$reg = _React$useContext.registerDescendant,
|
|
80
|
-
registerDescendant = _React$useContext$reg === void 0 ? noop : _React$useContext$reg,
|
|
81
|
-
_React$useContext$unr = _React$useContext.unregisterDescendant,
|
|
82
|
-
unregisterDescendant = _React$useContext$unr === void 0 ? noop : _React$useContext$unr,
|
|
83
|
-
_React$useContext$des = _React$useContext.descendants,
|
|
84
|
-
descendants = _React$useContext$des === void 0 ? [] : _React$useContext$des,
|
|
85
|
-
_React$useContext$par = _React$useContext.parentId,
|
|
86
|
-
parentId = _React$useContext$par === void 0 ? null : _React$useContext$par;
|
|
87
|
-
|
|
88
|
-
// This will initially return -1 because we haven't registered the descendant
|
|
89
|
-
// on the first render. After we register, this will then return the correct
|
|
90
|
-
// index on the following render, and we will re-register descendants
|
|
91
|
-
// so that everything is up-to-date before the user interacts with a
|
|
92
|
-
// collection.
|
|
93
|
-
var index = findIndex(descendants, function (item) {
|
|
94
|
-
return item.element === descendant.element;
|
|
95
|
-
});
|
|
96
|
-
var previousDescendants = usePrevious(descendants);
|
|
97
|
-
|
|
98
|
-
// We also need to re-register descendants any time ANY of the other
|
|
99
|
-
// descendants have changed. My brain was melting when I wrote this and it
|
|
100
|
-
// feels a little off, but checking in render and using the result in the
|
|
101
|
-
// effect's dependency array works well enough.
|
|
102
|
-
var someDescendantsHaveChanged = descendants.some(function (newDescendant, position) {
|
|
103
|
-
return previousDescendants && previousDescendants[position] && previousDescendants[position].element !== newDescendant.element;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Prevent any flashing
|
|
107
|
-
useEnhancedEffect(function () {
|
|
108
|
-
if (descendant.element) {
|
|
109
|
-
registerDescendant(_extends({}, descendant, {
|
|
110
|
-
index: index
|
|
111
|
-
}));
|
|
112
|
-
return function () {
|
|
113
|
-
unregisterDescendant(descendant.element);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
forceUpdate({});
|
|
117
|
-
return undefined;
|
|
118
|
-
}, [registerDescendant, unregisterDescendant, index, someDescendantsHaveChanged, descendant]);
|
|
119
|
-
return {
|
|
120
|
-
parentId: parentId,
|
|
121
|
-
index: index
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
export function DescendantProvider(props) {
|
|
125
|
-
var children = props.children,
|
|
126
|
-
id = props.id;
|
|
127
|
-
var _React$useState3 = React.useState([]),
|
|
128
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
129
|
-
items = _React$useState4[0],
|
|
130
|
-
set = _React$useState4[1];
|
|
131
|
-
var registerDescendant = React.useCallback(function (_ref) {
|
|
132
|
-
var element = _ref.element,
|
|
133
|
-
other = _objectWithoutProperties(_ref, _excluded);
|
|
134
|
-
set(function (oldItems) {
|
|
135
|
-
if (oldItems.length === 0) {
|
|
136
|
-
// If there are no items, register at index 0 and bail.
|
|
137
|
-
return [_extends({}, other, {
|
|
138
|
-
element: element,
|
|
139
|
-
index: 0
|
|
140
|
-
})];
|
|
141
|
-
}
|
|
142
|
-
var index = binaryFindElement(oldItems, element);
|
|
143
|
-
var newItems;
|
|
144
|
-
if (oldItems[index] && oldItems[index].element === element) {
|
|
145
|
-
// If the element is already registered, just use the same array
|
|
146
|
-
newItems = oldItems;
|
|
147
|
-
} else {
|
|
148
|
-
// When registering a descendant, we need to make sure we insert in
|
|
149
|
-
// into the array in the same order that it appears in the DOM. So as
|
|
150
|
-
// new descendants are added or maybe some are removed, we always know
|
|
151
|
-
// that the array is up-to-date and correct.
|
|
152
|
-
//
|
|
153
|
-
// So here we look at our registered descendants and see if the new
|
|
154
|
-
// element we are adding appears earlier than an existing descendant's
|
|
155
|
-
// DOM node via `node.compareDocumentPosition`. If it does, we insert
|
|
156
|
-
// the new element at this index. Because `registerDescendant` will be
|
|
157
|
-
// called in an effect every time the descendants state value changes,
|
|
158
|
-
// we should be sure that this index is accurate when descendent
|
|
159
|
-
// elements come or go from our component.
|
|
160
|
-
|
|
161
|
-
var newItem = _extends({}, other, {
|
|
162
|
-
element: element,
|
|
163
|
-
index: index
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// If an index is not found we will push the element to the end.
|
|
167
|
-
newItems = oldItems.slice();
|
|
168
|
-
newItems.splice(index, 0, newItem);
|
|
169
|
-
}
|
|
170
|
-
newItems.forEach(function (item, position) {
|
|
171
|
-
item.index = position;
|
|
172
|
-
});
|
|
173
|
-
return newItems;
|
|
174
|
-
});
|
|
175
|
-
}, []);
|
|
176
|
-
var unregisterDescendant = React.useCallback(function (element) {
|
|
177
|
-
set(function (oldItems) {
|
|
178
|
-
return oldItems.filter(function (item) {
|
|
179
|
-
return element !== item.element;
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}, []);
|
|
183
|
-
var value = React.useMemo(function () {
|
|
184
|
-
return {
|
|
185
|
-
descendants: items,
|
|
186
|
-
registerDescendant: registerDescendant,
|
|
187
|
-
unregisterDescendant: unregisterDescendant,
|
|
188
|
-
parentId: id
|
|
189
|
-
};
|
|
190
|
-
}, [items, registerDescendant, unregisterDescendant, id]);
|
|
191
|
-
return /*#__PURE__*/_jsx(DescendantContext.Provider, {
|
|
192
|
-
value: value,
|
|
193
|
-
children: children
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
process.env.NODE_ENV !== "production" ? DescendantProvider.propTypes = {
|
|
197
|
-
children: PropTypes.node,
|
|
198
|
-
id: PropTypes.string
|
|
199
|
-
} : void 0;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { TreeViewContext } from './TreeViewContext';
|
|
3
|
-
import { DescendantProvider } from './DescendantProvider';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
/**
|
|
6
|
-
* Sets up the contexts for the underlying TreeItem components.
|
|
7
|
-
*
|
|
8
|
-
* @ignore - do not document.
|
|
9
|
-
*/
|
|
10
|
-
export function TreeViewProvider(props) {
|
|
11
|
-
var value = props.value,
|
|
12
|
-
children = props.children;
|
|
13
|
-
return /*#__PURE__*/_jsx(TreeViewContext.Provider, {
|
|
14
|
-
value: value,
|
|
15
|
-
children: /*#__PURE__*/_jsx(DescendantProvider, {
|
|
16
|
-
children: children
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TreeViewProvider } from './TreeViewProvider';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { TreeViewContext } from './TreeViewContext';
|
|
3
|
-
export var useTreeViewContext = function useTreeViewContext() {
|
|
4
|
-
var context = React.useContext(TreeViewContext);
|
|
5
|
-
if (context == null) {
|
|
6
|
-
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'));
|
|
7
|
-
}
|
|
8
|
-
return context;
|
|
9
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { useTreeViewInstanceEvents } from './useTreeViewInstanceEvents';
|
|
2
|
-
/**
|
|
3
|
-
* Internal plugins that create the tools used by the other plugins.
|
|
4
|
-
* These plugins are used by the tree view components.
|
|
5
|
-
*/
|
|
6
|
-
export var TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TREE_VIEW_CORE_PLUGINS } from './corePlugins';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useTreeViewInstanceEvents } from './useTreeViewInstanceEvents';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { EventManager } from '../../utils/EventManager';
|
|
4
|
-
import { populateInstance } from '../../useTreeView/useTreeView.utils';
|
|
5
|
-
var isSyntheticEvent = function isSyntheticEvent(event) {
|
|
6
|
-
return event.isPropagationStopped !== undefined;
|
|
7
|
-
};
|
|
8
|
-
export var useTreeViewInstanceEvents = function useTreeViewInstanceEvents(_ref) {
|
|
9
|
-
var instance = _ref.instance;
|
|
10
|
-
var _React$useState = React.useState(function () {
|
|
11
|
-
return new EventManager();
|
|
12
|
-
}),
|
|
13
|
-
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
14
|
-
eventManager = _React$useState2[0];
|
|
15
|
-
var publishEvent = React.useCallback(function () {
|
|
16
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
-
args[_key] = arguments[_key];
|
|
18
|
-
}
|
|
19
|
-
var name = args[0],
|
|
20
|
-
params = args[1],
|
|
21
|
-
_args$ = args[2],
|
|
22
|
-
event = _args$ === void 0 ? {} : _args$;
|
|
23
|
-
event.defaultMuiPrevented = false;
|
|
24
|
-
if (isSyntheticEvent(event) && event.isPropagationStopped()) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
eventManager.emit(name, params, event);
|
|
28
|
-
}, [eventManager]);
|
|
29
|
-
var subscribeEvent = React.useCallback(function (event, handler) {
|
|
30
|
-
eventManager.on(event, handler);
|
|
31
|
-
return function () {
|
|
32
|
-
eventManager.removeListener(event, handler);
|
|
33
|
-
};
|
|
34
|
-
}, [eventManager]);
|
|
35
|
-
populateInstance(instance, {
|
|
36
|
-
$$publishEvent: publishEvent,
|
|
37
|
-
$$subscribeEvent: subscribeEvent
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
useTreeViewInstanceEvents.params = {};
|
package/legacy/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { TimerBasedCleanupTracking } from '../utils/cleanupTracking/TimerBasedCleanupTracking';
|
|
6
|
-
import { FinalizationRegistryBasedCleanupTracking } from '../utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking';
|
|
7
|
-
// We use class to make it easier to detect in heap snapshots by name
|
|
8
|
-
var ObjectToBeRetainedByReact = /*#__PURE__*/_createClass(function ObjectToBeRetainedByReact() {
|
|
9
|
-
_classCallCheck(this, ObjectToBeRetainedByReact);
|
|
10
|
-
}); // Based on https://github.com/Bnaya/use-dispose-uncommitted/blob/main/src/finalization-registry-based-impl.ts
|
|
11
|
-
// Check https://github.com/facebook/react/issues/15317 to get more information
|
|
12
|
-
export function createUseInstanceEventHandler(registryContainer) {
|
|
13
|
-
var cleanupTokensCounter = 0;
|
|
14
|
-
return function useInstanceEventHandler(instance, eventName, handler) {
|
|
15
|
-
if (registryContainer.registry === null) {
|
|
16
|
-
registryContainer.registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistryBasedCleanupTracking() : new TimerBasedCleanupTracking();
|
|
17
|
-
}
|
|
18
|
-
var _React$useState = React.useState(new ObjectToBeRetainedByReact()),
|
|
19
|
-
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
20
|
-
objectRetainedByReact = _React$useState2[0];
|
|
21
|
-
var subscription = React.useRef(null);
|
|
22
|
-
var handlerRef = React.useRef();
|
|
23
|
-
handlerRef.current = handler;
|
|
24
|
-
var cleanupTokenRef = React.useRef(null);
|
|
25
|
-
if (!subscription.current && handlerRef.current) {
|
|
26
|
-
var enhancedHandler = function enhancedHandler(params, event) {
|
|
27
|
-
if (!event.defaultMuiPrevented) {
|
|
28
|
-
var _handlerRef$current;
|
|
29
|
-
(_handlerRef$current = handlerRef.current) == null || _handlerRef$current.call(handlerRef, params, event);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
subscription.current = instance.$$subscribeEvent(eventName, enhancedHandler);
|
|
33
|
-
cleanupTokensCounter += 1;
|
|
34
|
-
cleanupTokenRef.current = {
|
|
35
|
-
cleanupToken: cleanupTokensCounter
|
|
36
|
-
};
|
|
37
|
-
registryContainer.registry.register(objectRetainedByReact,
|
|
38
|
-
// The callback below will be called once this reference stops being retained
|
|
39
|
-
function () {
|
|
40
|
-
var _subscription$current;
|
|
41
|
-
(_subscription$current = subscription.current) == null || _subscription$current.call(subscription);
|
|
42
|
-
subscription.current = null;
|
|
43
|
-
cleanupTokenRef.current = null;
|
|
44
|
-
}, cleanupTokenRef.current);
|
|
45
|
-
} else if (!handlerRef.current && subscription.current) {
|
|
46
|
-
subscription.current();
|
|
47
|
-
subscription.current = null;
|
|
48
|
-
if (cleanupTokenRef.current) {
|
|
49
|
-
registryContainer.registry.unregister(cleanupTokenRef.current);
|
|
50
|
-
cleanupTokenRef.current = null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
React.useEffect(function () {
|
|
54
|
-
if (!subscription.current && handlerRef.current) {
|
|
55
|
-
var _enhancedHandler = function _enhancedHandler(params, event) {
|
|
56
|
-
if (!event.defaultMuiPrevented) {
|
|
57
|
-
var _handlerRef$current2;
|
|
58
|
-
(_handlerRef$current2 = handlerRef.current) == null || _handlerRef$current2.call(handlerRef, params, event);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
subscription.current = instance.$$subscribeEvent(eventName, _enhancedHandler);
|
|
62
|
-
}
|
|
63
|
-
if (cleanupTokenRef.current && registryContainer.registry) {
|
|
64
|
-
// If the effect was called, it means that this render was committed
|
|
65
|
-
// so we can trust the cleanup function to remove the listener.
|
|
66
|
-
registryContainer.registry.unregister(cleanupTokenRef.current);
|
|
67
|
-
cleanupTokenRef.current = null;
|
|
68
|
-
}
|
|
69
|
-
return function () {
|
|
70
|
-
var _subscription$current2;
|
|
71
|
-
(_subscription$current2 = subscription.current) == null || _subscription$current2.call(subscription);
|
|
72
|
-
subscription.current = null;
|
|
73
|
-
};
|
|
74
|
-
}, [instance, eventName]);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
var registryContainer = {
|
|
78
|
-
registry: null
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
82
|
-
export var unstable_resetCleanupTracking = function unstable_resetCleanupTracking() {
|
|
83
|
-
var _registryContainer$re;
|
|
84
|
-
(_registryContainer$re = registryContainer.registry) == null || _registryContainer$re.reset();
|
|
85
|
-
registryContainer.registry = null;
|
|
86
|
-
};
|
|
87
|
-
export var useInstanceEventHandler = createUseInstanceEventHandler(registryContainer);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
var UNINITIALIZED = {};
|
|
3
|
-
|
|
4
|
-
// See https://github.com/facebook/react/issues/14490 for when to use this.
|
|
5
|
-
export function useLazyRef(init, initArg) {
|
|
6
|
-
var ref = React.useRef(UNINITIALIZED);
|
|
7
|
-
if (ref.current === UNINITIALIZED) {
|
|
8
|
-
ref.current = init(initArg);
|
|
9
|
-
}
|
|
10
|
-
return ref;
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { useLazyRef } from './useLazyRef';
|
|
4
|
-
import { useOnMount } from './useOnMount';
|
|
5
|
-
var Timeout = /*#__PURE__*/function () {
|
|
6
|
-
function Timeout() {
|
|
7
|
-
var _this = this;
|
|
8
|
-
_classCallCheck(this, Timeout);
|
|
9
|
-
this.currentId = 0;
|
|
10
|
-
this.clear = function () {
|
|
11
|
-
if (_this.currentId !== 0) {
|
|
12
|
-
clearTimeout(_this.currentId);
|
|
13
|
-
_this.currentId = 0;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
this.disposeEffect = function () {
|
|
17
|
-
return _this.clear;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
_createClass(Timeout, [{
|
|
21
|
-
key: "start",
|
|
22
|
-
value: function start(delay, fn) {
|
|
23
|
-
this.clear();
|
|
24
|
-
this.currentId = setTimeout(fn, delay);
|
|
25
|
-
}
|
|
26
|
-
}], [{
|
|
27
|
-
key: "create",
|
|
28
|
-
value: function create() {
|
|
29
|
-
return new Timeout();
|
|
30
|
-
}
|
|
31
|
-
}]);
|
|
32
|
-
return Timeout;
|
|
33
|
-
}();
|
|
34
|
-
export function useTimeout() {
|
|
35
|
-
var timeout = useLazyRef(Timeout.create).current;
|
|
36
|
-
useOnMount(timeout.disposeEffect);
|
|
37
|
-
return timeout;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|