diff --git a/types/react-material-ui-form-validator/index.d.ts b/types/react-material-ui-form-validator/index.d.ts new file mode 100644 index 0000000000..209f3f5a36 --- /dev/null +++ b/types/react-material-ui-form-validator/index.d.ts @@ -0,0 +1,32 @@ +// Type definitions for react-material-ui-form-validator 2.0 +// Project: https://github.com/NewOldMax/react-material-ui-form-validator +// Definitions by: Frank Brullo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + +import * as React from "react"; +import { TextFieldProps } from "material-ui"; + +export interface ValidatorFormProps { + className?: string; + onSubmit: (event: React.FormEventHandler) => void; + instantValidate?: boolean; + onError?: (errors: any[]) => void; + debounceTime?: number; +} +export class ValidatorForm extends React.Component { + static addValidationRule(name: string, callback: (value: any) => boolean): void; + isFormValid(dryRun: boolean): boolean; + resetValidations(): void; +} + +export interface ValidatorComponentProps { + errorMessages?: any[] | string; + validators?: any[]; + name: string; + value: any; + validatorListener?: (isValid: boolean) => void; + withRequiredValidator?: boolean; +} +export class ValidatorComponent extends React.Component {} +export class TextValidator extends ValidatorComponent {} diff --git a/types/react-material-ui-form-validator/react-material-ui-form-validator-tests.tsx b/types/react-material-ui-form-validator/react-material-ui-form-validator-tests.tsx new file mode 100644 index 0000000000..31f79a0695 --- /dev/null +++ b/types/react-material-ui-form-validator/react-material-ui-form-validator-tests.tsx @@ -0,0 +1,40 @@ +import * as React from 'react'; +import { + TextValidator, + ValidatorComponent, + ValidatorForm +} from 'react-material-ui-form-validator'; + +class Test extends React.Component { + onSubmitted = (event: React.FormEventHandler) => {}; + onError = (errors: any[]) => {}; + onValidate = (isValid: boolean) => {}; + + render() { + return ( + + + + + ); + } +} diff --git a/types/react-material-ui-form-validator/tsconfig.json b/types/react-material-ui-form-validator/tsconfig.json new file mode 100644 index 0000000000..95b0ef47ad --- /dev/null +++ b/types/react-material-ui-form-validator/tsconfig.json @@ -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-material-ui-form-validator-tests.tsx" + ] +} diff --git a/types/react-material-ui-form-validator/tslint.json b/types/react-material-ui-form-validator/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-material-ui-form-validator/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }