add react-better-password (#29278)

* add react-better-password

* resolve CI errors

* enable strictFunctionTypes

* changed onChange type from any to function

* mark onChange as optional
This commit is contained in:
mhuynh1
2018-10-09 12:07:10 -07:00
committed by Andy
parent 7bc89a263f
commit ab64ce72e8
4 changed files with 72 additions and 0 deletions

17
types/react-better-password/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for react-better-password 1.0
// Project: https://github.com/karaggeorge/react-better-password
// Definitions by: Mary Huynh <https://github.com/mhuynh1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
export interface PasswordProps {
className?: string;
mask?: '•' | string;
onChange?: (value: string) => void;
placeholder?: string;
show?: boolean;
timeout?: number;
value?: string;
}
export default class Password extends React.Component<PasswordProps> { }

View File

@@ -0,0 +1,29 @@
import * as React from 'react';
import Password from 'react-better-password';
interface PasswordState {
password: string;
}
class ReactBetterPasswordTest extends React.Component<{}, PasswordState> {
state = {
password: "",
};
handlePw = (password: string) => {
this.setState({ password });
}
render() {
const { password } = this.state;
return (
<Password
className="password"
value={password}
onChange={this.handlePw}
placeholder="set a password"
/>
);
}
}
export default ReactBetterPasswordTest;

View File

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

View File

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