@mui/x-tree-view 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +3682 -0
  2. package/LICENSE +21 -0
  3. package/README.md +34 -0
  4. package/TreeItem/TreeItem.d.ts +13 -0
  5. package/TreeItem/TreeItem.js +392 -0
  6. package/TreeItem/TreeItem.types.d.ts +84 -0
  7. package/TreeItem/TreeItem.types.js +1 -0
  8. package/TreeItem/TreeItemContent.d.ts +52 -0
  9. package/TreeItem/TreeItemContent.js +101 -0
  10. package/TreeItem/index.d.ts +5 -0
  11. package/TreeItem/index.js +4 -0
  12. package/TreeItem/package.json +6 -0
  13. package/TreeItem/treeItemClasses.d.ts +23 -0
  14. package/TreeItem/treeItemClasses.js +6 -0
  15. package/TreeItem/useTreeItem.d.ts +10 -0
  16. package/TreeItem/useTreeItem.js +68 -0
  17. package/TreeView/TreeView.d.ts +14 -0
  18. package/TreeView/TreeView.js +854 -0
  19. package/TreeView/TreeView.types.d.ts +170 -0
  20. package/TreeView/TreeView.types.js +1 -0
  21. package/TreeView/TreeViewContext.d.ts +6 -0
  22. package/TreeView/TreeViewContext.js +31 -0
  23. package/TreeView/descendants.d.ts +42 -0
  24. package/TreeView/descendants.js +186 -0
  25. package/TreeView/index.d.ts +3 -0
  26. package/TreeView/index.js +3 -0
  27. package/TreeView/package.json +6 -0
  28. package/TreeView/treeViewClasses.d.ts +7 -0
  29. package/TreeView/treeViewClasses.js +6 -0
  30. package/index.d.ts +2 -0
  31. package/index.js +9 -0
  32. package/internals/models.d.ts +1 -0
  33. package/internals/models.js +1 -0
  34. package/legacy/TreeItem/TreeItem.js +391 -0
  35. package/legacy/TreeItem/TreeItem.types.js +1 -0
  36. package/legacy/TreeItem/TreeItemContent.js +98 -0
  37. package/legacy/TreeItem/index.js +4 -0
  38. package/legacy/TreeItem/treeItemClasses.js +6 -0
  39. package/legacy/TreeItem/useTreeItem.js +67 -0
  40. package/legacy/TreeView/TreeView.js +907 -0
  41. package/legacy/TreeView/TreeView.types.js +1 -0
  42. package/legacy/TreeView/TreeViewContext.js +41 -0
  43. package/legacy/TreeView/descendants.js +199 -0
  44. package/legacy/TreeView/index.js +3 -0
  45. package/legacy/TreeView/treeViewClasses.js +6 -0
  46. package/legacy/index.js +9 -0
  47. package/legacy/internals/models.js +1 -0
  48. package/modern/TreeItem/TreeItem.js +391 -0
  49. package/modern/TreeItem/TreeItem.types.js +1 -0
  50. package/modern/TreeItem/TreeItemContent.js +101 -0
  51. package/modern/TreeItem/index.js +4 -0
  52. package/modern/TreeItem/treeItemClasses.js +6 -0
  53. package/modern/TreeItem/useTreeItem.js +68 -0
  54. package/modern/TreeView/TreeView.js +853 -0
  55. package/modern/TreeView/TreeView.types.js +1 -0
  56. package/modern/TreeView/TreeViewContext.js +31 -0
  57. package/modern/TreeView/descendants.js +186 -0
  58. package/modern/TreeView/index.js +3 -0
  59. package/modern/TreeView/treeViewClasses.js +6 -0
  60. package/modern/index.js +9 -0
  61. package/modern/internals/models.js +1 -0
  62. package/node/TreeItem/TreeItem.js +400 -0
  63. package/node/TreeItem/TreeItem.types.js +5 -0
  64. package/node/TreeItem/TreeItemContent.js +109 -0
  65. package/node/TreeItem/index.js +38 -0
  66. package/node/TreeItem/treeItemClasses.js +15 -0
  67. package/node/TreeItem/useTreeItem.js +76 -0
  68. package/node/TreeView/TreeView.js +862 -0
  69. package/node/TreeView/TreeView.types.js +5 -0
  70. package/node/TreeView/TreeViewContext.js +40 -0
  71. package/node/TreeView/descendants.js +194 -0
  72. package/node/TreeView/index.js +27 -0
  73. package/node/TreeView/treeViewClasses.js +15 -0
  74. package/node/index.js +34 -0
  75. package/node/internals/models.js +5 -0
  76. package/package.json +59 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Material-UI SAS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @mui/x-tree-view
2
+
3
+ This package is the community edition of the tree view components.
4
+ It's part of MUI X, an open-core extension of MUI, with advanced components.
5
+
6
+ ## Installation
7
+
8
+ Install the package in your project directory with:
9
+
10
+ ```bash
11
+ npm install @mui/x-tree-view
12
+ ```
13
+
14
+ or
15
+
16
+ ```bash
17
+ yarn add @mui/x-tree-view
18
+ ```
19
+
20
+ This component has the following peer dependencies that you will need to install as well.
21
+
22
+ ```json
23
+ "peerDependencies": {
24
+ "@mui/base": "^5.0.0-alpha.87",
25
+ "@mui/material": "^5.8.6",
26
+ "@mui/system": "^5.8.0",
27
+ "react": "^17.0.0 || ^18.0.0",
28
+ "react-dom": "^17.0.0 || ^18.0.0"
29
+ },
30
+ ```
31
+
32
+ ## Documentation
33
+
34
+ WIP
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { TreeItemProps } from './TreeItem.types';
3
+ /**
4
+ *
5
+ * Demos:
6
+ *
7
+ * - [Tree View](https://mui.com/material-ui/react-tree-view/)
8
+ *
9
+ * API:
10
+ *
11
+ * - [TreeItem API](https://mui.com/material-ui/api/tree-item/)
12
+ */
13
+ export declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLLIElement>>;
@@ -0,0 +1,392 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["children", "className", "collapseIcon", "ContentComponent", "ContentProps", "endIcon", "expandIcon", "disabled", "icon", "id", "label", "nodeId", "onClick", "onMouseDown", "TransitionComponent", "TransitionProps"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import clsx from 'clsx';
7
+ import Collapse from '@mui/material/Collapse';
8
+ import { alpha, styled, useThemeProps } from '@mui/material/styles';
9
+ import ownerDocument from '@mui/utils/ownerDocument';
10
+ import useForkRef from '@mui/utils/useForkRef';
11
+ import unsupportedProp from '@mui/utils/unsupportedProp';
12
+ import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
13
+ import { unstable_composeClasses as composeClasses } from '@mui/base';
14
+ import { TreeViewContext } from '../TreeView/TreeViewContext';
15
+ import { DescendantProvider, useDescendant } from '../TreeView/descendants';
16
+ import { TreeItemContent } from './TreeItemContent';
17
+ import { treeItemClasses, getTreeItemUtilityClass } from './treeItemClasses';
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ const useUtilityClasses = ownerState => {
21
+ const {
22
+ classes
23
+ } = ownerState;
24
+ const slots = {
25
+ root: ['root'],
26
+ content: ['content'],
27
+ expanded: ['expanded'],
28
+ selected: ['selected'],
29
+ focused: ['focused'],
30
+ disabled: ['disabled'],
31
+ iconContainer: ['iconContainer'],
32
+ label: ['label'],
33
+ group: ['group']
34
+ };
35
+ return composeClasses(slots, getTreeItemUtilityClass, classes);
36
+ };
37
+ const TreeItemRoot = styled('li', {
38
+ name: 'MuiTreeItem',
39
+ slot: 'Root',
40
+ overridesResolver: (props, styles) => styles.root
41
+ })({
42
+ listStyle: 'none',
43
+ margin: 0,
44
+ padding: 0,
45
+ outline: 0
46
+ });
47
+ const StyledTreeItemContent = styled(TreeItemContent, {
48
+ name: 'MuiTreeItem',
49
+ slot: 'Content',
50
+ overridesResolver: (props, styles) => {
51
+ return [styles.content, styles.iconContainer && {
52
+ [`& .${treeItemClasses.iconContainer}`]: styles.iconContainer
53
+ }, styles.label && {
54
+ [`& .${treeItemClasses.label}`]: styles.label
55
+ }];
56
+ }
57
+ })(({
58
+ theme
59
+ }) => ({
60
+ padding: '0 8px',
61
+ width: '100%',
62
+ display: 'flex',
63
+ alignItems: 'center',
64
+ cursor: 'pointer',
65
+ WebkitTapHighlightColor: 'transparent',
66
+ '&:hover': {
67
+ backgroundColor: (theme.vars || theme).palette.action.hover,
68
+ // Reset on touch devices, it doesn't add specificity
69
+ '@media (hover: none)': {
70
+ backgroundColor: 'transparent'
71
+ }
72
+ },
73
+ [`&.${treeItemClasses.disabled}`]: {
74
+ opacity: (theme.vars || theme).palette.action.disabledOpacity,
75
+ backgroundColor: 'transparent'
76
+ },
77
+ [`&.${treeItemClasses.focused}`]: {
78
+ backgroundColor: (theme.vars || theme).palette.action.focus
79
+ },
80
+ [`&.${treeItemClasses.selected}`]: {
81
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.selectedOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
82
+ '&:hover': {
83
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.hoverOpacity}))` : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity),
84
+ // Reset on touch devices, it doesn't add specificity
85
+ '@media (hover: none)': {
86
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.selectedOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity)
87
+ }
88
+ },
89
+ [`&.${treeItemClasses.focused}`]: {
90
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.focusOpacity}))` : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity)
91
+ }
92
+ },
93
+ [`& .${treeItemClasses.iconContainer}`]: {
94
+ marginRight: 4,
95
+ width: 15,
96
+ display: 'flex',
97
+ flexShrink: 0,
98
+ justifyContent: 'center',
99
+ '& svg': {
100
+ fontSize: 18
101
+ }
102
+ },
103
+ [`& .${treeItemClasses.label}`]: _extends({
104
+ width: '100%',
105
+ // fixes overflow - see https://github.com/mui/material-ui/issues/27372
106
+ minWidth: 0,
107
+ paddingLeft: 4,
108
+ position: 'relative'
109
+ }, theme.typography.body1)
110
+ }));
111
+ const TreeItemGroup = styled(Collapse, {
112
+ name: 'MuiTreeItem',
113
+ slot: 'Group',
114
+ overridesResolver: (props, styles) => styles.group
115
+ })({
116
+ margin: 0,
117
+ padding: 0,
118
+ marginLeft: 17
119
+ });
120
+
121
+ /**
122
+ *
123
+ * Demos:
124
+ *
125
+ * - [Tree View](https://mui.com/material-ui/react-tree-view/)
126
+ *
127
+ * API:
128
+ *
129
+ * - [TreeItem API](https://mui.com/material-ui/api/tree-item/)
130
+ */
131
+ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps, ref) {
132
+ const props = useThemeProps({
133
+ props: inProps,
134
+ name: 'MuiTreeItem'
135
+ });
136
+ const {
137
+ children,
138
+ className,
139
+ collapseIcon,
140
+ ContentComponent = TreeItemContent,
141
+ ContentProps,
142
+ endIcon,
143
+ expandIcon,
144
+ disabled: disabledProp,
145
+ icon,
146
+ id: idProp,
147
+ label,
148
+ nodeId,
149
+ onClick,
150
+ onMouseDown,
151
+ TransitionComponent = Collapse,
152
+ TransitionProps
153
+ } = props,
154
+ other = _objectWithoutPropertiesLoose(props, _excluded);
155
+ const {
156
+ icons: contextIcons,
157
+ focus,
158
+ isExpanded,
159
+ isFocused,
160
+ isSelected,
161
+ isDisabled,
162
+ multiSelect,
163
+ disabledItemsFocusable,
164
+ mapFirstChar,
165
+ unMapFirstChar,
166
+ registerNode,
167
+ unregisterNode,
168
+ treeId
169
+ } = React.useContext(TreeViewContext);
170
+ let id;
171
+ if (idProp != null) {
172
+ id = idProp;
173
+ } else if (treeId && nodeId) {
174
+ id = `${treeId}-${nodeId}`;
175
+ }
176
+ const [treeItemElement, setTreeItemElement] = React.useState(null);
177
+ const contentRef = React.useRef(null);
178
+ const handleRef = useForkRef(setTreeItemElement, ref);
179
+ const descendant = React.useMemo(() => ({
180
+ element: treeItemElement,
181
+ id: nodeId
182
+ }), [nodeId, treeItemElement]);
183
+ const {
184
+ index,
185
+ parentId
186
+ } = useDescendant(descendant);
187
+ const expandable = Boolean(Array.isArray(children) ? children.length : children);
188
+ const expanded = isExpanded ? isExpanded(nodeId) : false;
189
+ const focused = isFocused ? isFocused(nodeId) : false;
190
+ const selected = isSelected ? isSelected(nodeId) : false;
191
+ const disabled = isDisabled ? isDisabled(nodeId) : false;
192
+ const ownerState = _extends({}, props, {
193
+ expanded,
194
+ focused,
195
+ selected,
196
+ disabled
197
+ });
198
+ const classes = useUtilityClasses(ownerState);
199
+ let displayIcon;
200
+ let expansionIcon;
201
+ if (expandable) {
202
+ if (!expanded) {
203
+ expansionIcon = expandIcon || contextIcons.defaultExpandIcon;
204
+ } else {
205
+ expansionIcon = collapseIcon || contextIcons.defaultCollapseIcon;
206
+ }
207
+ }
208
+ if (expandable) {
209
+ displayIcon = contextIcons.defaultParentIcon;
210
+ } else {
211
+ displayIcon = endIcon || contextIcons.defaultEndIcon;
212
+ }
213
+ React.useEffect(() => {
214
+ // On the first render a node's index will be -1. We want to wait for the real index.
215
+ if (registerNode && unregisterNode && index !== -1) {
216
+ registerNode({
217
+ id: nodeId,
218
+ idAttribute: id,
219
+ index,
220
+ parentId,
221
+ expandable,
222
+ disabled: disabledProp
223
+ });
224
+ return () => {
225
+ unregisterNode(nodeId);
226
+ };
227
+ }
228
+ return undefined;
229
+ }, [registerNode, unregisterNode, parentId, index, nodeId, expandable, disabledProp, id]);
230
+ React.useEffect(() => {
231
+ if (mapFirstChar && unMapFirstChar && label) {
232
+ var _contentRef$current$t, _contentRef$current;
233
+ mapFirstChar(nodeId, ((_contentRef$current$t = (_contentRef$current = contentRef.current) == null ? void 0 : _contentRef$current.textContent) != null ? _contentRef$current$t : '').substring(0, 1).toLowerCase());
234
+ return () => {
235
+ unMapFirstChar(nodeId);
236
+ };
237
+ }
238
+ return undefined;
239
+ }, [mapFirstChar, unMapFirstChar, nodeId, label]);
240
+ let ariaSelected;
241
+ if (multiSelect) {
242
+ ariaSelected = selected;
243
+ } else if (selected) {
244
+ /* single-selection trees unset aria-selected on un-selected items.
245
+ *
246
+ * If the tree does not support multiple selection, aria-selected
247
+ * is set to true for the selected node and it is not present on any other node in the tree.
248
+ * Source: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/
249
+ */
250
+ ariaSelected = true;
251
+ }
252
+ function handleFocus(event) {
253
+ // DOM focus stays on the tree which manages focus with aria-activedescendant
254
+ if (event.target === event.currentTarget) {
255
+ let rootElement;
256
+ if (typeof event.target.getRootNode === 'function') {
257
+ rootElement = event.target.getRootNode();
258
+ } else {
259
+ rootElement = ownerDocument(event.target);
260
+ }
261
+ rootElement.getElementById(treeId).focus({
262
+ preventScroll: true
263
+ });
264
+ }
265
+ const unfocusable = !disabledItemsFocusable && disabled;
266
+ if (!focused && event.currentTarget === event.target && !unfocusable) {
267
+ focus(event, nodeId);
268
+ }
269
+ }
270
+ return /*#__PURE__*/_jsxs(TreeItemRoot, _extends({
271
+ className: clsx(classes.root, className),
272
+ role: "treeitem",
273
+ "aria-expanded": expandable ? expanded : undefined,
274
+ "aria-selected": ariaSelected,
275
+ "aria-disabled": disabled || undefined,
276
+ id: id,
277
+ tabIndex: -1
278
+ }, other, {
279
+ ownerState: ownerState,
280
+ onFocus: handleFocus,
281
+ ref: handleRef,
282
+ children: [/*#__PURE__*/_jsx(StyledTreeItemContent, _extends({
283
+ as: ContentComponent,
284
+ ref: contentRef,
285
+ classes: {
286
+ root: classes.content,
287
+ expanded: classes.expanded,
288
+ selected: classes.selected,
289
+ focused: classes.focused,
290
+ disabled: classes.disabled,
291
+ iconContainer: classes.iconContainer,
292
+ label: classes.label
293
+ },
294
+ label: label,
295
+ nodeId: nodeId,
296
+ onClick: onClick,
297
+ onMouseDown: onMouseDown,
298
+ icon: icon,
299
+ expansionIcon: expansionIcon,
300
+ displayIcon: displayIcon,
301
+ ownerState: ownerState
302
+ }, ContentProps)), children && /*#__PURE__*/_jsx(DescendantProvider, {
303
+ id: nodeId,
304
+ children: /*#__PURE__*/_jsx(TreeItemGroup, _extends({
305
+ as: TransitionComponent,
306
+ unmountOnExit: true,
307
+ className: classes.group,
308
+ in: expanded,
309
+ component: "ul",
310
+ role: "group"
311
+ }, TransitionProps, {
312
+ children: children
313
+ }))
314
+ })]
315
+ }));
316
+ });
317
+ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
318
+ // ----------------------------- Warning --------------------------------
319
+ // | These PropTypes are generated from the TypeScript type definitions |
320
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
321
+ // ----------------------------------------------------------------------
322
+ /**
323
+ * The content of the component.
324
+ */
325
+ children: PropTypes.node,
326
+ /**
327
+ * Override or extend the styles applied to the component.
328
+ */
329
+ classes: PropTypes.object,
330
+ /**
331
+ * className applied to the root element.
332
+ */
333
+ className: PropTypes.string,
334
+ /**
335
+ * The icon used to collapse the node.
336
+ */
337
+ collapseIcon: PropTypes.node,
338
+ /**
339
+ * The component used for the content node.
340
+ * @default TreeItemContent
341
+ */
342
+ ContentComponent: elementTypeAcceptingRef,
343
+ /**
344
+ * Props applied to ContentComponent.
345
+ */
346
+ ContentProps: PropTypes.object,
347
+ /**
348
+ * If `true`, the node is disabled.
349
+ * @default false
350
+ */
351
+ disabled: PropTypes.bool,
352
+ /**
353
+ * The icon displayed next to an end node.
354
+ */
355
+ endIcon: PropTypes.node,
356
+ /**
357
+ * The icon used to expand the node.
358
+ */
359
+ expandIcon: PropTypes.node,
360
+ /**
361
+ * The icon to display next to the tree node's label.
362
+ */
363
+ icon: PropTypes.node,
364
+ /**
365
+ * The tree node label.
366
+ */
367
+ label: PropTypes.node,
368
+ /**
369
+ * The id of the node.
370
+ */
371
+ nodeId: PropTypes.string.isRequired,
372
+ /**
373
+ * This prop isn't supported.
374
+ * Use the `onNodeFocus` callback on the tree if you need to monitor a node's focus.
375
+ */
376
+ onFocus: unsupportedProp,
377
+ /**
378
+ * The system prop that allows defining system overrides as well as additional CSS styles.
379
+ */
380
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
381
+ /**
382
+ * The component used for the transition.
383
+ * [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
384
+ * @default Collapse
385
+ */
386
+ TransitionComponent: PropTypes.elementType,
387
+ /**
388
+ * Props applied to the transition element.
389
+ * By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
390
+ */
391
+ TransitionProps: PropTypes.object
392
+ } : void 0;
@@ -0,0 +1,84 @@
1
+ import * as React from 'react';
2
+ import { Theme } from '@mui/material/styles';
3
+ import { TransitionProps } from '@mui/material/transitions';
4
+ import { SxProps } from '@mui/system';
5
+ import { TreeItemContentProps } from './TreeItemContent';
6
+ import { TreeItemClasses } from './treeItemClasses';
7
+ export interface TreeItemProps extends Omit<React.HTMLAttributes<HTMLLIElement>, 'onFocus'> {
8
+ /**
9
+ * The content of the component.
10
+ */
11
+ children?: React.ReactNode;
12
+ /**
13
+ * className applied to the root element.
14
+ */
15
+ className?: string;
16
+ /**
17
+ * Override or extend the styles applied to the component.
18
+ */
19
+ classes?: Partial<TreeItemClasses>;
20
+ /**
21
+ * The icon used to collapse the node.
22
+ */
23
+ collapseIcon?: React.ReactNode;
24
+ /**
25
+ * The component used for the content node.
26
+ * @default TreeItemContent
27
+ */
28
+ ContentComponent?: React.JSXElementConstructor<TreeItemContentProps>;
29
+ /**
30
+ * Props applied to ContentComponent.
31
+ */
32
+ ContentProps?: React.HTMLAttributes<HTMLElement>;
33
+ /**
34
+ * If `true`, the node is disabled.
35
+ * @default false
36
+ */
37
+ disabled?: boolean;
38
+ /**
39
+ * The icon displayed next to an end node.
40
+ */
41
+ endIcon?: React.ReactNode;
42
+ /**
43
+ * The icon used to expand the node.
44
+ */
45
+ expandIcon?: React.ReactNode;
46
+ /**
47
+ * The icon to display next to the tree node's label.
48
+ */
49
+ icon?: React.ReactNode;
50
+ /**
51
+ * This prop isn't supported.
52
+ * Use the `onNodeFocus` callback on the tree if you need to monitor a node's focus.
53
+ */
54
+ onFocus?: null;
55
+ /**
56
+ * The tree node label.
57
+ */
58
+ label?: React.ReactNode;
59
+ /**
60
+ * The id of the node.
61
+ */
62
+ nodeId: string;
63
+ /**
64
+ * The component used for the transition.
65
+ * [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
66
+ * @default Collapse
67
+ */
68
+ TransitionComponent?: React.JSXElementConstructor<TransitionProps>;
69
+ /**
70
+ * Props applied to the transition element.
71
+ * By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
72
+ */
73
+ TransitionProps?: TransitionProps;
74
+ /**
75
+ * The system prop that allows defining system overrides as well as additional CSS styles.
76
+ */
77
+ sx?: SxProps<Theme>;
78
+ }
79
+ export interface TreeItemOwnerState extends TreeItemProps {
80
+ expanded: boolean;
81
+ focused: boolean;
82
+ selected: boolean;
83
+ disabled: boolean;
84
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ export interface TreeItemContentProps extends React.HTMLAttributes<HTMLElement> {
3
+ /**
4
+ * className applied to the root element.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * Override or extend the styles applied to the component.
9
+ */
10
+ classes: {
11
+ /** Styles applied to the root element. */
12
+ root: string;
13
+ /** State class applied to the content element when expanded. */
14
+ expanded: string;
15
+ /** State class applied to the content element when selected. */
16
+ selected: string;
17
+ /** State class applied to the content element when focused. */
18
+ focused: string;
19
+ /** State class applied to the element when disabled. */
20
+ disabled: string;
21
+ /** Styles applied to the tree node icon and collapse/expand icon. */
22
+ iconContainer: string;
23
+ /** Styles applied to the label element. */
24
+ label: string;
25
+ };
26
+ /**
27
+ * The tree node label.
28
+ */
29
+ label?: React.ReactNode;
30
+ /**
31
+ * The id of the node.
32
+ */
33
+ nodeId: string;
34
+ /**
35
+ * The icon to display next to the tree node's label.
36
+ */
37
+ icon?: React.ReactNode;
38
+ /**
39
+ * The icon to display next to the tree node's label. Either an expansion or collapse icon.
40
+ */
41
+ expansionIcon?: React.ReactNode;
42
+ /**
43
+ * The icon to display next to the tree node's label. Either a parent or end icon.
44
+ */
45
+ displayIcon?: React.ReactNode;
46
+ }
47
+ export type TreeItemContentClassKey = keyof NonNullable<TreeItemContentProps['classes']>;
48
+ /**
49
+ * @ignore - internal component.
50
+ */
51
+ declare const TreeItemContent: React.ForwardRefExoticComponent<TreeItemContentProps & React.RefAttributes<HTMLDivElement>>;
52
+ export { TreeItemContent };