1 | import * as React from 'react';
|
2 | import { FormikHelpers, FormikProps, FormikSharedConfig, FormikValues, FormikTouched, FormikErrors } from './types';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export declare type InjectedFormikProps<Props, Values> = Props & FormikProps<Values>;
|
10 |
|
11 |
|
12 |
|
13 | export declare type FormikBag<P, V> = {
|
14 | props: P;
|
15 | } & FormikHelpers<V>;
|
16 |
|
17 |
|
18 |
|
19 | export interface WithFormikConfig<Props, Values extends FormikValues = FormikValues, DeprecatedPayload = Values> extends FormikSharedConfig<Props> {
|
20 | |
21 |
|
22 |
|
23 | displayName?: string;
|
24 | |
25 |
|
26 |
|
27 | handleSubmit: (values: Values, formikBag: FormikBag<Props, Values>) => void;
|
28 | |
29 |
|
30 |
|
31 | mapPropsToValues?: (props: Props) => Values;
|
32 | |
33 |
|
34 |
|
35 | mapPropsToStatus?: (props: Props) => any;
|
36 | |
37 |
|
38 |
|
39 | mapPropsToTouched?: (props: Props) => FormikTouched<Values>;
|
40 | |
41 |
|
42 |
|
43 | mapPropsToErrors?: (props: Props) => FormikErrors<Values>;
|
44 | |
45 |
|
46 |
|
47 | mapValuesToPayload?: (values: Values) => DeprecatedPayload;
|
48 | |
49 |
|
50 |
|
51 | validationSchema?: any | ((props: Props) => any);
|
52 | /**
|
53 | * Validation function. Must return an error object or promise that
|
54 | * throws an error object where that object keys map to corresponding value.
|
55 | */
|
56 | validate?: (values: Values, props: Props) => void | object | Promise<any>;
|
57 | }
|
58 | export declare type CompositeComponent<P> = React.ComponentClass<P> | React.StatelessComponent<P>;
|
59 | export interface ComponentDecorator<TOwnProps, TMergedProps> {
|
60 | (component: CompositeComponent<TMergedProps>): React.ComponentType<TOwnProps>;
|
61 | }
|
62 | export interface InferableComponentDecorator<TOwnProps> {
|
63 | <T extends CompositeComponent<TOwnProps>>(component: T): T;
|
64 | }
|
65 |
|
66 |
|
67 |
|
68 | export declare function withFormik<OuterProps extends object, Values extends FormikValues, Payload = Values>({ mapPropsToValues, ...config }: WithFormikConfig<OuterProps, Values, Payload>): ComponentDecorator<OuterProps, OuterProps & FormikProps<Values>>;
|