|
1 | 1 | import * as React from 'react' |
2 | | -import { FormApi, Config, Decorator, FormState, FormSubscription, FieldSubscription } from 'final-form' |
| 2 | +import { |
| 3 | + FormApi, |
| 4 | + Config, |
| 5 | + Decorator, |
| 6 | + FormState, |
| 7 | + FormSubscription, |
| 8 | + FieldSubscription |
| 9 | +} from 'final-form' |
3 | 10 |
|
4 | 11 | export type ReactContext = { |
5 | 12 | reactFinalForm: FormApi |
6 | 13 | } |
7 | 14 |
|
8 | 15 | export type FieldRenderProps = { |
9 | 16 | input: { |
10 | | - name: string, |
11 | | - onBlur: <T>(event?: React.FocusEvent<T>) => void, |
12 | | - onChange: <T>(event: React.ChangeEvent<T> | any) => void, |
13 | | - onFocus: <T>(event?: React.FocusEvent<T>) => void, |
| 17 | + name: string |
| 18 | + onBlur: <T>(event?: React.FocusEvent<T>) => void |
| 19 | + onChange: <T>(event: React.ChangeEvent<T> | any) => void |
| 20 | + onFocus: <T>(event?: React.FocusEvent<T>) => void |
14 | 21 | value: any |
15 | | - }, |
| 22 | + } |
16 | 23 | meta: Partial<{ |
17 | 24 | // TODO: Make a diff of `FieldState` without all the functions |
18 | | - active: boolean, |
19 | | - dirty: boolean, |
20 | | - error: boolean, |
21 | | - initial: boolean, |
22 | | - invalid: boolean, |
23 | | - pristine: boolean, |
24 | | - submitError: boolean, |
25 | | - submitFailed: boolean, |
26 | | - submitSucceeded: boolean, |
27 | | - touched: boolean, |
28 | | - valid: boolean, |
| 25 | + active: boolean |
| 26 | + dirty: boolean |
| 27 | + error: boolean |
| 28 | + initial: boolean |
| 29 | + invalid: boolean |
| 30 | + pristine: boolean |
| 31 | + submitError: boolean |
| 32 | + submitFailed: boolean |
| 33 | + submitSucceeded: boolean |
| 34 | + touched: boolean |
| 35 | + valid: boolean |
29 | 36 | visited: boolean |
30 | 37 | }> |
31 | 38 | } |
32 | 39 |
|
33 | 40 | export type FormRenderProps = { |
34 | | - blur: (name: string) => void, |
35 | | - change: (name: string, value: any) => void, |
36 | | - focus: (name: string) => void, |
37 | | - handleSubmit: (event: React.SyntheticEvent<HTMLFormElement>) => void, |
38 | | - initialize: (values: object) => void, |
| 41 | + blur: (name: string) => void |
| 42 | + change: (name: string, value: any) => void |
| 43 | + focus: (name: string) => void |
| 44 | + handleSubmit: (event: React.SyntheticEvent<HTMLFormElement>) => void |
| 45 | + initialize: (values: object) => void |
39 | 46 | reset: () => void |
40 | 47 | } & FormState |
41 | 48 |
|
42 | 49 | export type FormSpyRenderProps = FormState |
43 | 50 |
|
44 | 51 | export type RenderableProps<T> = Partial<{ |
45 | | - children: ((props: T) => React.ReactNode) | React.ReactNode, |
46 | | - component: React.ComponentType, |
| 52 | + children: ((props: T) => React.ReactNode) | React.ReactNode |
| 53 | + component: React.ComponentType |
47 | 54 | render: (props: T) => React.ReactNode |
48 | 55 | }> |
49 | 56 |
|
50 | 57 | export type FormProps = { |
51 | | - subscription?: FormSubscription, |
| 58 | + subscription?: FormSubscription |
52 | 59 | decorators?: Decorator[] |
53 | 60 | } & Config & |
54 | 61 | RenderableProps<FormRenderProps> |
55 | 62 |
|
56 | 63 | export type FieldProps = { |
57 | | - allowNull?: boolean, |
58 | | - name: string, |
59 | | - subscription?: FieldSubscription, |
60 | | - validate?: (value: any, allValues: object) => any, |
| 64 | + allowNull?: boolean |
| 65 | + name: string |
| 66 | + subscription?: FieldSubscription |
| 67 | + validate?: (value: any, allValues: object) => any |
61 | 68 | value?: any |
62 | 69 | } & RenderableProps<FieldRenderProps> |
63 | 70 |
|
64 | 71 | export type FormSpyProps = { |
65 | | - onChange?: (formState: FormState) => void, |
| 72 | + onChange?: (formState: FormState) => void |
66 | 73 | subscription?: FormSubscription |
67 | 74 | } & RenderableProps<FormSpyRenderProps> |
68 | 75 |
|
|
0 commit comments