UNPKG

1.19 kBTypeScriptView Raw
1import { Reducer } from "redux";
2import { FieldType } from "../index";
3
4export interface FormReducer extends Reducer<FormStateMap> {
5 plugin(reducers: FormReducerMapObject): Reducer<FormStateMap>;
6}
7
8export const reducer: FormReducer;
9
10export interface FormReducerMapObject {
11 // and `<any>` to make it compatible with redux@3
12 // tslint:disable-next-line use-default-type-parameter
13 [formName: string]: Reducer<any>;
14}
15
16export interface FormStateMap {
17 [formName: string]: FormState;
18}
19
20export interface FormState {
21 registeredFields: RegisteredFieldState[];
22 fields?: { [name: string]: FieldState } | undefined;
23 values?: { [fieldName: string]: any } | undefined;
24 active?: string | undefined;
25 anyTouched?: boolean | undefined;
26 error?: any;
27 submitting?: boolean | undefined;
28 submitErrors?: { [fieldName: string]: string } | undefined;
29 submitFailed?: boolean | undefined;
30}
31
32export interface RegisteredFieldState {
33 name: string;
34 type: FieldType;
35 count: number;
36}
37
38export interface FieldState {
39 active?: boolean | undefined;
40 touched?: boolean | undefined;
41 visited?: boolean | undefined;
42}
43
44export default reducer;