1 | import * as React from 'react';
|
2 | export { ScrollTo } from 'rc-virtual-list/lib/List';
|
3 | export interface TreeNodeProps<TreeDataType extends BasicDataNode = DataNode> {
|
4 | eventKey?: Key;
|
5 | prefixCls?: string;
|
6 | className?: string;
|
7 | style?: React.CSSProperties;
|
8 | id?: string;
|
9 | expanded?: boolean;
|
10 | selected?: boolean;
|
11 | checked?: boolean;
|
12 | loaded?: boolean;
|
13 | loading?: boolean;
|
14 | halfChecked?: boolean;
|
15 | title?: React.ReactNode | ((data: TreeDataType) => React.ReactNode);
|
16 | dragOver?: boolean;
|
17 | dragOverGapTop?: boolean;
|
18 | dragOverGapBottom?: boolean;
|
19 | pos?: string;
|
20 | domRef?: React.Ref<HTMLDivElement>;
|
21 | /** New added in Tree for easy data access */
|
22 | data?: TreeDataType;
|
23 | isStart?: boolean[];
|
24 | isEnd?: boolean[];
|
25 | active?: boolean;
|
26 | onMouseMove?: React.MouseEventHandler<HTMLDivElement>;
|
27 | isLeaf?: boolean;
|
28 | checkable?: boolean;
|
29 | selectable?: boolean;
|
30 | disabled?: boolean;
|
31 | disableCheckbox?: boolean;
|
32 | icon?: IconType;
|
33 | switcherIcon?: IconType;
|
34 | children?: React.ReactNode;
|
35 | }
|
36 | /** For fieldNames, we provides a abstract interface */
|
37 | export interface BasicDataNode {
|
38 | checkable?: boolean;
|
39 | disabled?: boolean;
|
40 | disableCheckbox?: boolean;
|
41 | icon?: IconType;
|
42 | isLeaf?: boolean;
|
43 | selectable?: boolean;
|
44 | switcherIcon?: IconType;
|
45 | /** Set style of TreeNode. This is not recommend if you don't have any force requirement */
|
46 | className?: string;
|
47 | style?: React.CSSProperties;
|
48 | }
|
49 | /** Provide a wrap type define for developer to wrap with customize fieldNames data type */
|
50 | export type FieldDataNode<T, ChildFieldName extends string = 'children'> = BasicDataNode & T & Partial<Record<ChildFieldName, FieldDataNode<T, ChildFieldName>[]>>;
|
51 | export type DataNode = FieldDataNode<{
|
52 | key: string | number;
|
53 | title?: React.ReactNode | ((data: DataNode) => React.ReactNode);
|
54 | }>;
|
55 | export type EventDataNode<TreeDataType> = {
|
56 | key: React.Key;
|
57 | expanded: boolean;
|
58 | selected: boolean;
|
59 | checked: boolean;
|
60 | loaded: boolean;
|
61 | loading: boolean;
|
62 | halfChecked: boolean;
|
63 | dragOver: boolean;
|
64 | dragOverGapTop: boolean;
|
65 | dragOverGapBottom: boolean;
|
66 | pos: string;
|
67 | active: boolean;
|
68 | } & TreeDataType & BasicDataNode;
|
69 | export type IconType = React.ReactNode | ((props: TreeNodeProps) => React.ReactNode);
|
70 | export type Key = string | number;
|
71 | export type NodeElement = React.ReactElement<TreeNodeProps> & {
|
72 | selectHandle?: HTMLSpanElement;
|
73 | type: {
|
74 | isTreeNode: boolean;
|
75 | };
|
76 | };
|
77 | export type NodeInstance<TreeDataType extends BasicDataNode = DataNode> = React.Component<TreeNodeProps<TreeDataType>> & {
|
78 | selectHandle?: HTMLSpanElement;
|
79 | };
|
80 | export interface Entity {
|
81 | node: NodeElement;
|
82 | index: number;
|
83 | key: Key;
|
84 | pos: string;
|
85 | parent?: Entity;
|
86 | children?: Entity[];
|
87 | }
|
88 | export interface DataEntity<TreeDataType extends BasicDataNode = DataNode> extends Omit<Entity, 'node' | 'parent' | 'children'> {
|
89 | node: TreeDataType;
|
90 | nodes: TreeDataType[];
|
91 | parent?: DataEntity<TreeDataType>;
|
92 | children?: DataEntity<TreeDataType>[];
|
93 | level: number;
|
94 | }
|
95 | export interface FlattenNode<TreeDataType extends BasicDataNode = DataNode> {
|
96 | parent: FlattenNode<TreeDataType> | null;
|
97 | children: FlattenNode<TreeDataType>[];
|
98 | pos: string;
|
99 | data: TreeDataType;
|
100 | title: React.ReactNode;
|
101 | key: Key;
|
102 | isStart: boolean[];
|
103 | isEnd: boolean[];
|
104 | }
|
105 | export type GetKey<RecordType> = (record: RecordType, index?: number) => Key;
|
106 | export type GetCheckDisabled<RecordType> = (record: RecordType) => boolean;
|
107 | export type Direction = 'ltr' | 'rtl' | undefined;
|
108 | export interface FieldNames {
|
109 | title?: string;
|
110 |
|
111 | _title?: string[];
|
112 | key?: string;
|
113 | children?: string;
|
114 | }
|