1 | import * as React from 'react';
|
2 | import { StandardProps } from '@material-ui/core';
|
3 |
|
4 | export interface TreeViewPropsBase
|
5 | extends StandardProps<React.HTMLAttributes<HTMLUListElement>, TreeViewClassKey> {
|
6 | /**
|
7 | * The content of the component.
|
8 | */
|
9 | children?: React.ReactNode;
|
10 | /**
|
11 | * The default icon used to collapse the node.
|
12 | */
|
13 | defaultCollapseIcon?: React.ReactNode;
|
14 | /**
|
15 | * The default icon displayed next to a end node. This is applied to all
|
16 | * tree nodes and can be overridden by the TreeItem `icon` prop.
|
17 | */
|
18 | defaultEndIcon?: React.ReactNode;
|
19 | /**
|
20 | * Expanded node ids. (Uncontrolled)
|
21 | */
|
22 | defaultExpanded?: string[];
|
23 | /**
|
24 | * The default icon used to expand the node.
|
25 | */
|
26 | defaultExpandIcon?: React.ReactNode;
|
27 | /**
|
28 | * The default icon displayed next to a parent node. This is applied to all
|
29 | * parent nodes and can be overridden by the TreeItem `icon` prop.
|
30 | */
|
31 | defaultParentIcon?: React.ReactNode;
|
32 | /**
|
33 | * If `true` selection is disabled.
|
34 | */
|
35 | disableSelection?: boolean;
|
36 | /**
|
37 | * Expanded node ids. (Controlled)
|
38 | */
|
39 | expanded?: string[];
|
40 | /**
|
41 | * Callback fired when tree items are expanded/collapsed.
|
42 | *
|
43 | * @param {object} event The event source of the callback.
|
44 | * @param {array} nodeIds The ids of the expanded nodes.
|
45 | */
|
46 | onNodeToggle?: (event: React.ChangeEvent<{}>, nodeIds: string[]) => void;
|
47 | }
|
48 |
|
49 | export interface MultiSelectTreeViewProps extends TreeViewPropsBase {
|
50 | /**
|
51 | * Selected node ids. (Uncontrolled)
|
52 | * When `multiSelect` is true this takes an array of strings; when false (default) a string.
|
53 | */
|
54 | defaultSelected?: string[];
|
55 | /**
|
56 | * Selected node ids. (Controlled)
|
57 | * When `multiSelect` is true this takes an array of strings; when false (default) a string.
|
58 | */
|
59 | selected?: string[];
|
60 | /**
|
61 | * If true `ctrl` and `shift` will trigger multiselect.
|
62 | */
|
63 | multiSelect?: true;
|
64 | /**
|
65 | * Callback fired when tree items are selected/unselected.
|
66 | *
|
67 | * @param {object} event The event source of the callback
|
68 | * @param {(array|string)} value of the selected nodes. When `multiSelect` is true
|
69 | * this is an array of strings; when false (default) a string.
|
70 | */
|
71 | onNodeSelect?: (event: React.ChangeEvent<{}>, nodeIds: string[]) => void;
|
72 | }
|
73 |
|
74 | export interface SingleSelectTreeViewProps extends TreeViewPropsBase {
|
75 | /**
|
76 | * Selected node ids. (Uncontrolled)
|
77 | * When `multiSelect` is true this takes an array of strings; when false (default) a string.
|
78 | */
|
79 | defaultSelected?: string;
|
80 | /**
|
81 | * Selected node ids. (Controlled)
|
82 | * When `multiSelect` is true this takes an array of strings; when false (default) a string.
|
83 | */
|
84 | selected?: string;
|
85 | /**
|
86 | * If true `ctrl` and `shift` will trigger multiselect.
|
87 | */
|
88 | multiSelect?: false;
|
89 | /**
|
90 | * Callback fired when tree items are selected/unselected.
|
91 | *
|
92 | * @param {object} event The event source of the callback
|
93 | * @param {(array|string)} value of the selected nodes. When `multiSelect` is true
|
94 | * this is an array of strings; when false (default) a string.
|
95 | */
|
96 | onNodeSelect?: (event: React.ChangeEvent<{}>, nodeIds: string) => void;
|
97 | }
|
98 |
|
99 | export type TreeViewProps = SingleSelectTreeViewProps | MultiSelectTreeViewProps;
|
100 |
|
101 | export type TreeViewClassKey = 'root';
|
102 |
|
103 | /**
|
104 | *
|
105 | * Demos:
|
106 | *
|
107 | * - [Tree View](https://mui.com/components/tree-view/)
|
108 | *
|
109 | * API:
|
110 | *
|
111 | * - [TreeView API](https://mui.com/api/tree-view/)
|
112 | */
|
113 | export default function TreeView(props: TreeViewProps): JSX.Element;
|