forked from diogofcunha/react-virtualized-tree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
131 lines (104 loc) · 3.15 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Type definitions for react-virtualzed-tree
// Definitions by: Diogo Cunha
import * as React from 'react';
interface BasicNode {
id: number | string;
name: string;
state?: {[stateKey: string]: any};
}
export interface Node extends BasicNode {
children?: BasicNode[];
}
export interface FlattenedNode extends Node {
deepness: number;
parents: number[];
}
interface NodeAction {
type: string;
node: FlattenedNode;
}
type onChange = (nodes: Node[], node: Node) => Node[];
export interface Extensions {
updateTypeHandlers: {[type: number]: onChange};
}
export interface TreeProps {
extensions?: Extensions;
nodes: Node[];
onChange: (nodes: Node[]) => void;
children: (props: RendererProps) => JSX.Element;
nodeMarginLeft?: number;
width?: number;
scrollToId?: number;
}
export default class Tree extends React.Component<TreeProps> {}
export interface RendererProps<T> {
measure: () => void;
onChange: (updateParams: NodeAction) => void;
node: FlattenedNode;
iconsClassNameMap?: T;
}
type DeletableRenderProps = RendererProps<{delete?: string}>;
type ExpandableRenderProps = RendererProps<{
expanded?: string;
collapsed?: string;
lastChild?: string;
}>;
type FavoriteRenderProps = RendererProps<{
favorite?: string;
notFavorite?: string;
}>;
declare const Deletable: React.SFC<DeletableRenderProps>;
declare const Expandable: React.SFC<ExpandableRenderProps>;
declare const Favorite: React.SFC<FavoriteRenderProps>;
interface Renderers {
Deletable: React.SFC<DeletableRenderProps>;
Expandable: React.SFC<ExpandableRenderProps>;
Favorite: React.SFC<FavoriteRenderProps>;
}
export const renderers: Renderers;
export interface Group {
filter: (node: Node) => boolean;
name: string;
}
interface GroupRendererProps {
onChange: (c: string) => void;
groups: {[g: string]: Group};
selectedGroup: string;
}
export interface FilteringContainerProps {
children: (nodes: Node[]) => JSX.Element;
debouncer?: (func: (...p: any[]) => any, timeout: number) => void;
groups?: {[g: string]: Group};
selectedGroup?: string;
groupRenderer?: React.StatelessComponent<GroupRendererProps> | React.Component<GroupRendererProps>;
onSelectedGroupChange?: (c: string) => void;
}
export class FilteringContainer extends React.Component<FilteringContainerProps> {}
export enum UPDATE_TYPE {
ADD = 0,
DELETE = 1,
UPDATE = 2,
}
interface Constants {
UPDATE_TYPE: UPDATE_TYPE;
}
export const constants: Constants;
interface NodeRenderOptions {
hasChildren: boolean;
isExpanded: boolean;
isFavorite: boolean;
isDeletable: boolean;
}
export enum NODE_CHANGE_OPERATIONS {
CHANGE_NODE = 'CHANGE_NODE',
DELETE_NODE = 'DELETE_NODE',
}
interface Selectors {
getNodeRenderOptions: (node: FlattenedNode) => NodeRenderOptions;
replaceNodeFromTree: (nodes: Node[], updatedNode: FlattenedNode, operation?: NODE_CHANGE_OPERATIONS) => Node[];
deleteNodeFromTree: (nodes: Node[], nodeToDelete: FlattenedNode) => Node[];
deleteNode: (node: FlattenedNode[]) => NodeAction;
addNode: (node: FlattenedNode[]) => NodeAction;
updateNode: (node: FlattenedNode, state: {[stateKey: string]: any}) => NodeAction;
}
export const selectors: Selectors;