UNPKG

4.17 kBTypeScriptView Raw
1import * as React from 'react';
2import RcTree, { TreeNode, TreeProps as RcTreeProps } from 'rc-tree';
3import { DataNode, Key } from 'rc-tree/lib/interface';
4import DirectoryTree from './DirectoryTree';
5export interface AntdTreeNodeAttribute {
6 eventKey: string;
7 prefixCls: string;
8 className: string;
9 expanded: boolean;
10 selected: boolean;
11 checked: boolean;
12 halfChecked: boolean;
13 children: React.ReactNode;
14 title: React.ReactNode;
15 pos: string;
16 dragOver: boolean;
17 dragOverGapTop: boolean;
18 dragOverGapBottom: boolean;
19 isLeaf: boolean;
20 selectable: boolean;
21 disabled: boolean;
22 disableCheckbox: boolean;
23}
24export interface AntTreeNodeProps {
25 className?: string;
26 checkable?: boolean;
27 disabled?: boolean;
28 disableCheckbox?: boolean;
29 title?: string | React.ReactNode;
30 key?: Key;
31 eventKey?: string;
32 isLeaf?: boolean;
33 checked?: boolean;
34 expanded?: boolean;
35 loading?: boolean;
36 selected?: boolean;
37 selectable?: boolean;
38 icon?: ((treeNode: AntdTreeNodeAttribute) => React.ReactNode) | React.ReactNode;
39 children?: React.ReactNode;
40 [customProp: string]: any;
41}
42export interface AntTreeNode extends React.Component<AntTreeNodeProps, {}> {
43}
44export interface AntTreeNodeBaseEvent {
45 node: AntTreeNode;
46 nativeEvent: MouseEvent;
47}
48export interface AntTreeNodeCheckedEvent extends AntTreeNodeBaseEvent {
49 event: 'check';
50 checked?: boolean;
51 checkedNodes?: AntTreeNode[];
52}
53export interface AntTreeNodeSelectedEvent extends AntTreeNodeBaseEvent {
54 event: 'select';
55 selected?: boolean;
56 selectedNodes?: DataNode[];
57}
58export interface AntTreeNodeExpandedEvent extends AntTreeNodeBaseEvent {
59 expanded?: boolean;
60}
61export interface AntTreeNodeMouseEvent {
62 node: AntTreeNode;
63 event: React.DragEvent<HTMLElement>;
64}
65export interface AntTreeNodeDragEnterEvent extends AntTreeNodeMouseEvent {
66 expandedKeys: Key[];
67}
68export interface AntTreeNodeDropEvent {
69 node: AntTreeNode;
70 dragNode: AntTreeNode;
71 dragNodesKeys: Key[];
72 dropPosition: number;
73 dropToGap?: boolean;
74 event: React.MouseEvent<HTMLElement>;
75}
76export declare type TreeNodeNormal = DataNode;
77export interface TreeProps extends Omit<RcTreeProps, 'prefixCls' | 'showLine' | 'direction'> {
78 showLine?: boolean | {
79 showLeafIcon: boolean;
80 };
81 className?: string;
82 /** 是否支持多选 */
83 multiple?: boolean;
84 /** 是否自动展开父节点 */
85 autoExpandParent?: boolean;
86 /** Checkable状态下节点选择完全受控(父子节点选中状态不再关联) */
87 checkStrictly?: boolean;
88 /** 是否支持选中 */
89 checkable?: boolean;
90 /** 是否禁用树 */
91 disabled?: boolean;
92 /** 默认展开所有树节点 */
93 defaultExpandAll?: boolean;
94 /** 默认展开对应树节点 */
95 defaultExpandParent?: boolean;
96 /** 默认展开指定的树节点 */
97 defaultExpandedKeys?: Key[];
98 /** (受控)展开指定的树节点 */
99 expandedKeys?: Key[];
100 /** (受控)选中复选框的树节点 */
101 checkedKeys?: Key[] | {
102 checked: Key[];
103 halfChecked: Key[];
104 };
105 /** 默认选中复选框的树节点 */
106 defaultCheckedKeys?: Key[];
107 /** (受控)设置选中的树节点 */
108 selectedKeys?: Key[];
109 /** 默认选中的树节点 */
110 defaultSelectedKeys?: Key[];
111 selectable?: boolean;
112 /** 点击树节点触发 */
113 filterAntTreeNode?: (node: AntTreeNode) => boolean;
114 loadedKeys?: Key[];
115 /** 设置节点可拖拽(IE>8) */
116 draggable?: ((node: DataNode) => boolean) | boolean;
117 style?: React.CSSProperties;
118 showIcon?: boolean;
119 icon?: ((nodeProps: AntdTreeNodeAttribute) => React.ReactNode) | React.ReactNode;
120 switcherIcon?: React.ReactElement<any>;
121 prefixCls?: string;
122 children?: React.ReactNode;
123 blockNode?: boolean;
124}
125interface CompoundedComponent extends React.ForwardRefExoticComponent<TreeProps & React.RefAttributes<RcTree>> {
126 TreeNode: typeof TreeNode;
127 DirectoryTree: typeof DirectoryTree;
128}
129declare const Tree: CompoundedComponent;
130export default Tree;
131
\No newline at end of file