mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-07 18:50:14 +00:00
Merge pull request #33012 from FrankBrullo/react-material-ui-form-validator
Added type definitions for react-material-ui-form-validator
This commit is contained in:
32
types/react-material-ui-form-validator/index.d.ts
vendored
Normal file
32
types/react-material-ui-form-validator/index.d.ts
vendored
Normal file
@@ -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 <https://github.com/FrankBrullo>
|
||||
// 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<ValidatorFormProps> {
|
||||
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<ValidatorComponentProps & TextFieldProps> {}
|
||||
export class TextValidator extends ValidatorComponent {}
|
||||
@@ -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 (
|
||||
<ValidatorForm
|
||||
instantValidate={true}
|
||||
debounceTime={10}
|
||||
onSubmit={this.onSubmitted}
|
||||
onError={this.onError}
|
||||
>
|
||||
<ValidatorComponent
|
||||
errorMessages={['Field is required']}
|
||||
validators={['required']}
|
||||
name={'Field'}
|
||||
value={'value'}
|
||||
validatorListener={this.onValidate}
|
||||
withRequiredValidator={true}
|
||||
/>
|
||||
<TextValidator
|
||||
name="textValidator"
|
||||
value="value"
|
||||
validatorListener={this.onValidate}
|
||||
validators={['required']}
|
||||
errorMessages={['Field is required']}
|
||||
withRequiredValidator={true}
|
||||
/>
|
||||
</ValidatorForm>
|
||||
);
|
||||
}
|
||||
}
|
||||
25
types/react-material-ui-form-validator/tsconfig.json
Normal file
25
types/react-material-ui-form-validator/tsconfig.json
Normal 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-material-ui-form-validator-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-material-ui-form-validator/tslint.json
Normal file
1
types/react-material-ui-form-validator/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user