1 | import * as React from 'react';
|
2 | import { FormikProps, GenericFieldHTMLAttributes, FieldMetaProps, FieldHelperProps, FieldInputProps, FieldValidator } from './types';
|
3 | export interface FieldProps<V = any, FormValues = any> {
|
4 | field: FieldInputProps<V>;
|
5 | form: FormikProps<FormValues>;
|
6 | meta: FieldMetaProps<V>;
|
7 | }
|
8 | export interface FieldConfig<V = any> {
|
9 | |
10 |
|
11 |
|
12 | component?: string | React.ComponentType<FieldProps<V>> | React.ComponentType | React.ForwardRefExoticComponent<any>;
|
13 | |
14 |
|
15 |
|
16 | as?: React.ComponentType<FieldProps<V>['field']> | string | React.ComponentType | React.ForwardRefExoticComponent<any>;
|
17 | |
18 |
|
19 |
|
20 |
|
21 | render?: (props: FieldProps<V>) => React.ReactNode;
|
22 | |
23 |
|
24 |
|
25 | children?: ((props: FieldProps<V>) => React.ReactNode) | React.ReactNode;
|
26 | /**
|
27 | * Validate a single field value independently
|
28 | */
|
29 | validate?: FieldValidator;
|
30 | /**
|
31 | * Field name
|
32 | */
|
33 | name: string;
|
34 | /** HTML input type */
|
35 | type?: string;
|
36 | /** Field value */
|
37 | value?: any;
|
38 | /** Inner ref */
|
39 | innerRef?: (instance: any) => void;
|
40 | }
|
41 | export declare type FieldAttributes<T> = GenericFieldHTMLAttributes & FieldConfig<T> & T & {
|
42 | name: string;
|
43 | };
|
44 | export declare type FieldHookConfig<T> = GenericFieldHTMLAttributes & FieldConfig<T>;
|
45 | export declare function useField<Val = any>(propsOrFieldName: string | FieldHookConfig<Val>): [FieldInputProps<Val>, FieldMetaProps<Val>, FieldHelperProps<Val>];
|
46 | export declare function Field({ validate, name, render, children, as: is,
|
47 | component, ...props }: FieldAttributes<any>): any;
|