Add Types for package react-otp-input (#47108)

* Add Types for package react-otp-input

* ReactOTPInput -New line added and extra lines removed

* Add react-otp-input to package.json

* Add react-otp-input test import modified

* Change in export OTPInput

* Change in import OTPInput

* Remove path from tsconfig.json

* Change types for style props

* Remove minor version from top definitions

* Revert package.json
This commit is contained in:
Anup Bhatkhande 2020-08-30 14:26:54 +05:30 committed by GitHub
parent 6a47fa33ad
commit 537d3c1655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 0 deletions

23
types/react-otp-input/index.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
// Type definitions for react-otp-input 2.0
// Project: https://github.com/devfolioco/react-otp-input
// Definitions by: Anup Bhatkhande <https://github.com/anupbui>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from 'react';
export interface OTPInputProps {
value: number | string;
onChange: any;
numInputs: number;
separator?: JSX.Element;
isDisabled?: boolean;
shouldAutoFocus?: boolean;
hasErrored?: boolean;
isInputNum?: boolean;
containerStyle?: string | React.CSSProperties;
inputStyle?: string | React.CSSProperties;
focusStyle?: string | React.CSSProperties;
disabledStyle?: string | React.CSSProperties;
errorStyle?: string | React.CSSProperties;
}
export default class extends React.Component<OTPInputProps> { }

View File

@ -0,0 +1,35 @@
import * as React from "react";
import OTPInput from "react-otp-input";
interface InputOtpProps {
inputCount: number;
}
interface OtpInputState {
otp: number;
}
class OtpInputPage extends React.Component<InputOtpProps, OtpInputState> {
state = {
otp: 123456
};
handleChange = (otp: number) => {
this.setState({ otp });
}
render() {
const { otp } = this.state;
return (
<>
<OTPInput
value={otp}
onChange={this.handleChange}
numInputs={6}
separator={<span>-</span>}
/>
</>
);
}
}

View File

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

View File

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