Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Created November 11, 2015 17:16
Show Gist options
  • Save iamdustan/8b24394b7614e20b1aae to your computer and use it in GitHub Desktop.
Save iamdustan/8b24394b7614e20b1aae to your computer and use it in GitHub Desktop.
/** @flow */
import type {Action} from '../redux';
type Errors = Object;
type ValidationPromise = Promise<?Errors>;
type MapPropsToValues = (props:Object) => Object;
type ReduxFormProps = {
active: string;
asyncValidate: Function;
asyncValidating: boolean;
destroyForm: Function;
dirty: boolean;
error: string;
fields: {[key:string]: FieldProps};
handleSubmit(eventOrValue:any): ?ValidationPromise|any;
initializeForm(data:Object): void;
invalid: boolean;
pristine: boolean;
resetForm(): void;
formKey: string;
submitting: boolean;
touch(...field:Array<string>): void;
touchAll(): void;
untouch(...field:Array<string>): void;
untouchAll(): void;
valid: boolean;
values: Object;
};
export type FieldProps = {
active: boolean;
checked: boolean;
className: string;
dirty: boolean;
error: string;
invalid: boolean;
name: string;
onBlur(eventOrValue:any): void;
onChange(eventOrValue:any): void;
onDragStart(): void;
onDrop(): void;
onFocus(): void;
onUpdate: Function;
pristine: boolean;
touched: boolean;
valid: boolean;
value: boolean|string;
visited: boolean;
};
export type AsyncValidate = (values:Object, dispatch:Function) => ValidationPromise;
export type ReduxFormOptions = {
fields: Array<string>;
form: string;
asyncBlurFields?: Array<string>;
asyncValidate?: AsyncValidate;
destroyOnUnmount?: boolean;
formKey?: string;
initialValues?: Object | MapPropsToValues;
onSubmit?: Function;
readonly?: boolean;
reduxMountPoint?: string;
touchOnBlur?: boolean;
touchOnChange?: boolean;
validate?: (values:Object, props:Object) => Errors;
};
declare module "redux-form" {
declare function reduxForm(
options: ReduxFormOptions
): (comp: ReactClass|Function) => ReactClass;
declare function reducer<U>(
action: Action,
state: U
):U;
declare var actionTypes: {[key:string]: string};
declare var blur: () => any;
declare var change: () => any;
declare var destroy: () => any;
declare var focus: () => any;
declare var initialize: () => any;
declare var initializeWithKey: () => any;
declare var reset: () => any;
declare var startAsyncValidation: () => any;
declare var startSubmit: () => any;
declare var stopAsyncValidation: () => any;
declare var stopSubmit: () => any;
declare var touch: () => any;
declare var untouch: () => any;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment