mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 03:02:04 +08:00
Merge pull request #26555 from MrLuje/react-native-dialog
Add type definitions for react-native-dialog
This commit is contained in:
72
types/react-native-dialog/index.d.ts
vendored
Normal file
72
types/react-native-dialog/index.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Type definitions for react-native-dialog 4.0
|
||||
// Project: https://github.com/mmazzarolo/react-native-dialog
|
||||
// Definitions by: MrLuje <https://github.com/MrLuje>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import { Ref, PureComponent, ReactNode } from "react";
|
||||
import {
|
||||
ViewProps,
|
||||
TextProps,
|
||||
StyleProp,
|
||||
TextInputProps,
|
||||
ViewStyle
|
||||
} from "react-native";
|
||||
|
||||
interface ButtonProps {
|
||||
label: string;
|
||||
/**
|
||||
* default:
|
||||
* ios #007ff9
|
||||
* android #169689
|
||||
*/
|
||||
color?: string;
|
||||
bold?: boolean;
|
||||
/**
|
||||
* default: false
|
||||
*/
|
||||
|
||||
disabled?: boolean;
|
||||
onPress: () => void;
|
||||
}
|
||||
|
||||
interface ContainerProps {
|
||||
blurComponentIOS?: ReactNode;
|
||||
children: JSX.Element[];
|
||||
/**
|
||||
* default: false
|
||||
*/
|
||||
visible?: boolean;
|
||||
}
|
||||
|
||||
interface TitleProps {
|
||||
children: string;
|
||||
}
|
||||
|
||||
interface InputProps<T> {
|
||||
label?: string;
|
||||
textInputRef?: Ref<T>;
|
||||
wrapperStyle?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
interface DescriptionProps {
|
||||
children: string;
|
||||
}
|
||||
|
||||
export namespace Dialog {
|
||||
class Button extends PureComponent<
|
||||
ButtonProps & ViewProps & TextProps
|
||||
> {}
|
||||
class Container extends PureComponent<ContainerProps & ViewProps> {}
|
||||
class Title extends PureComponent<
|
||||
TitleProps & ViewProps & TextProps
|
||||
> {}
|
||||
class Input<T> extends PureComponent<
|
||||
InputProps<T> & ViewProps & TextInputProps
|
||||
> {}
|
||||
class Description extends PureComponent<
|
||||
DescriptionProps & ViewProps & TextProps
|
||||
> {}
|
||||
}
|
||||
|
||||
export default Dialog;
|
||||
29
types/react-native-dialog/react-native-dialog-tests.tsx
Normal file
29
types/react-native-dialog/react-native-dialog-tests.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import Dialog from "react-native-dialog";
|
||||
import { createRef, Component } from "react";
|
||||
|
||||
class Example extends Component {
|
||||
render() {
|
||||
const ref = createRef();
|
||||
|
||||
return (
|
||||
<Dialog.Container
|
||||
visible={true}
|
||||
style={{ marginLeft: 20, marginRight: 20 }}
|
||||
>
|
||||
<Dialog.Title style={{ marginLeft: 20, marginRight: 20 }}>
|
||||
A nice title
|
||||
</Dialog.Title>
|
||||
<Dialog.Description>A good descr</Dialog.Description>
|
||||
<Dialog.Input textInputRef={ref} label="Cancel" />
|
||||
<Dialog.Button
|
||||
label="Cancel"
|
||||
onPress={() => console.log("test")}
|
||||
/>
|
||||
<Dialog.Button
|
||||
label="Validate"
|
||||
onPress={() => console.log("test")}
|
||||
/>
|
||||
</Dialog.Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-native-dialog/tsconfig.json
Normal file
24
types/react-native-dialog/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react-native"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-dialog-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-native-dialog/tslint.json
Normal file
1
types/react-native-dialog/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user