Skip to content

Commit 0f3f214

Browse files
committed
Update TypeScript definitions
Also add `@types/react` to resolve IDE errors.
1 parent 0a74505 commit 0f3f214

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features
66

77
* [#79]: Add `showExpandAll` property to give the user the ability to expand or collapse all nodes in the tree
8+
* [#96]: Add TypeScript definitions
89
* [#102]: Add `icons` property to allow specification of icon components
910
* [#103]: Add `title` node property and `showNodeTitle` tree property
1011
* [#108]: Add `lang` property for language customization

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@babel/preset-env": "^7.0.0",
3535
"@babel/preset-react": "^7.0.0",
3636
"@babel/register": "^7.0.0",
37+
"@types/react": "^16.4.13",
3738
"babel-eslint": "^9.0.0",
3839
"babel-loader": "^8.0.0",
3940
"browser-sync": "^2.18.6",

src/index.d.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as React from 'react';
2+
13
declare module "react-checkbox-tree" {
24
interface Node {
35
label: string;
@@ -9,6 +11,22 @@ declare module "react-checkbox-tree" {
911
showCheckbox?: boolean;
1012
}
1113

14+
interface Icons {
15+
check?: JSX.Element;
16+
uncheck?: JSX.Element;
17+
halfCheck?: JSX.Element;
18+
expandClose?: JSX.Element;
19+
parentClose?: JSX.Element;
20+
parentOpen?: JSX.Element;
21+
leaf?: JSX.Element;
22+
}
23+
24+
interface Language {
25+
collapseAll: string;
26+
expandAll: string;
27+
toggle: string;
28+
}
29+
1230
interface CheckboxProps {
1331
nodes: Array<Node>;
1432
checked: Array<string>;
@@ -19,15 +37,19 @@ declare module "react-checkbox-tree" {
1937
disabled?: boolean;
2038
expandDisabled?: boolean;
2139
expandOnClick?: boolean;
40+
icons?: Icons;
41+
lang?: Language;
2242
name?: string;
2343
nameAsArray?: boolean;
2444
nativeCheckboxes?: boolean;
2545
noCascade?: boolean;
2646
onlyLeafCheckboxes?: boolean;
2747
optimisticToggle?: boolean;
48+
showExpandAll?: boolean;
2849
showNodeIcon?: boolean;
50+
showNodeTitles?: boolean;
2951
onClick?: (event: { checked: boolean, value: any }) => void;
3052
}
3153

3254
export default class CheckboxTree extends React.Component<CheckboxProps> { }
33-
}
55+
}

0 commit comments

Comments
 (0)