Skip to content

Commit a70a8dd

Browse files
authored
Merge pull request #77 from IanStorm/master
Add typings
2 parents cae3e2f + bf443e9 commit a70a8dd

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

index.d.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type React from 'react';
2+
3+
type Checked = 0 | 0.5 | 1;
4+
5+
type CheckedStatus = 'checked' | 'custom' | 'unchecked';
6+
7+
export interface FolderTreeProps {
8+
data: NodeData;
9+
iconComponents?: IconComponents;
10+
indentPixels?: number;
11+
initCheckedStatus?: CheckedStatus;
12+
initOpenStatus?: OpenStatus;
13+
onChange?: OnChange;
14+
onNameClick?: OnNameClick;
15+
readOnly?: boolean;
16+
showCheckbox?: boolean;
17+
}
18+
19+
export type Icon = React.FunctionComponent<IconProps>;
20+
21+
export interface IconComponents {
22+
CancelIcon?: Icon;
23+
CaretRightIcon?: Icon;
24+
CaretDownIcon?: Icon;
25+
DeleteIcon?: Icon;
26+
EditIcon?: Icon;
27+
FileIcon?: Icon;
28+
FolderIcon?: Icon;
29+
FolderOpenIcon?: Icon;
30+
OKIcon?: Icon;
31+
}
32+
33+
export interface IconProps {
34+
nodeData: NodeData;
35+
onClick: () => void;
36+
}
37+
38+
export interface NodeData {
39+
checked?: Checked;
40+
children?: Array<NodeData>;
41+
isOpen?: boolean;
42+
name: string;
43+
[key: string]: any;
44+
}
45+
46+
type OnChange = (state: NodeData, event: unknown) => void;
47+
48+
type OnNameClick = (opts: {
49+
defaultOnClick: () => void;
50+
nodeData: NodeData;
51+
}) => void;
52+
53+
type OpenStatus = 'closed' | 'custom' | 'open';
54+
55+
declare const FolderTree: React.FunctionComponent<FolderTreeProps>;
56+
57+
export const testData: NodeData;
58+
59+
export default FolderTree;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"version": "5.0.3",
44
"description": "customizable react folder tree library",
55
"main": "dist/react-folder-tree.bundle.js",
6+
"typings": "index.d.ts",
67
"files": [
78
"dist/react-folder-tree.bundle.js",
8-
"dist/style.css"
9+
"dist/style.css",
10+
"index.d.ts"
911
],
1012
"author": "Shunji Zhan <shunhahaha@live.com>",
1113
"keywords": [

0 commit comments

Comments
 (0)