add: type definition for react-native-check-box (#41400)

This commit is contained in:
Rodolphe Lemasquerier
2020-01-10 20:38:12 +01:00
committed by Armando Aguirre
parent c83e56ca90
commit 863519d139
4 changed files with 69 additions and 0 deletions

29
types/react-native-check-box/index.d.ts vendored Normal file
View File

@@ -0,0 +1,29 @@
// Type definitions for react-native-check-box 2.1
// Project: https://github.com/crazycodeboy/react-native-check-box#readme
// Definitions by: Rodolphe Lemasquerier <https://github.com/rlemasquerier>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from 'react';
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
export interface CheckBoxProps {
style?: StyleProp<ViewStyle>;
leftText?: string;
leftTextStyle?: StyleProp<TextStyle>;
leftTextView?: React.ReactNode;
rightText?: string;
rightTextStyle?: StyleProp<TextStyle>;
rightTextView?: React.ReactNode;
checkedImage?: React.ReactElement;
uncheckedImage?: React.ReactElement;
isChecked: boolean;
onClick: () => void;
disabled?: boolean;
checkBoxColor?: string;
checkedCheckBoxColor?: string;
uncheckedCheckBoxColor?: string;
}
declare class CheckBox extends React.Component<CheckBoxProps> {}
export default CheckBox;

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import CheckBox from 'react-native-check-box';
import { View, Image } from 'react-native';
export default class MyCheckBox extends React.Component {
render() {
return (
<CheckBox
style={{ margin: 20 }}
onClick={() => {
console.log('clicked');
}}
checkBoxColor={'#000'}
isChecked={true}
leftTextStyle={{ color: 'red', fontSize: 10 }}
leftText={'Check me!'}
checkedImage={<Image source={{ uri: 'path/to/image.webp' }} />}
rightTextView={<View />}
/>
);
}
}

View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "es2017"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-native"
},
"files": ["index.d.ts", "react-native-check-box-tests.tsx"]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }