UNPKG

1.94 kBTypeScriptView Raw
1import * as React from 'react';
2import { StandardProps } from '@material-ui/core';
3import { TransitionProps } from '@material-ui/core/transitions';
4
5export interface TreeItemProps
6 extends StandardProps<React.HTMLAttributes<HTMLLIElement>, TreeItemClassKey> {
7 /**
8 * The content of the component.
9 */
10 children?: React.ReactNode;
11 /**
12 * The icon used to collapse the node.
13 */
14 collapseIcon?: React.ReactNode;
15 /**
16 * The icon displayed next to a end node.
17 */
18 endIcon?: React.ReactNode;
19 /**
20 * The icon used to expand the node.
21 */
22 expandIcon?: React.ReactNode;
23 /**
24 * The icon to display next to the tree node's label.
25 */
26 icon?: React.ReactNode;
27 /**
28 * `onClick` handler for the icon container. Call `event.preventDefault()` to prevent `onNodeToggle` from being called.
29 */
30 onIconClick?: React.MouseEventHandler;
31 /**
32 * The tree node label.
33 */
34 label?: React.ReactNode;
35 /**
36 * `onClick` handler for the label container. Call `event.preventDefault()` to prevent `onNodeToggle` from being called.
37 */
38 onLabelClick?: React.MouseEventHandler;
39 /**
40 * The id of the node.
41 */
42 nodeId: string;
43 /**
44 * The component used for the transition.
45 * [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
46 */
47 TransitionComponent?: React.ComponentType<TransitionProps>;
48 /**
49 * Props applied to the [`Transition`](http://reactcommunity.org/react-transition-group/transition#Transition-props) element.
50 */
51 TransitionProps?: TransitionProps;
52}
53
54export type TreeItemClassKey =
55 | 'root'
56 | 'expanded'
57 | 'selected'
58 | 'group'
59 | 'content'
60 | 'iconContainer'
61 | 'label';
62
63/**
64 *
65 * Demos:
66 *
67 * - [Tree View](https://mui.com/components/tree-view/)
68 *
69 * API:
70 *
71 * - [TreeItem API](https://mui.com/api/tree-item/)
72 */
73export default function TreeItem(props: TreeItemProps): JSX.Element;