import * as React from 'react'; import { FormApi, Config, Decorator, FormState, FormSubscription, FieldState, FieldSubscription, FieldValidator } from 'final-form'; import { Omit } from 'ts-essentials'; type SupportedInputs = 'input' | 'select' | 'textarea'; export interface ReactContext { reactFinalForm: FormApi; } export type FieldMetaState = Omit< FieldState, 'blur' | 'change' | 'focus' | 'name' | 'value' >; interface FieldInputProps { name: string; onBlur: (event?: React.FocusEvent) => void; onChange: (event: React.ChangeEvent | any) => void; onFocus: (event?: React.FocusEvent) => void; type?: string; value: FieldValue; checked?: boolean; multiple?: boolean; [key: string]: any; } interface AnyObject { [key: string]: any; } export interface FieldRenderProps { input: FieldInputProps; meta: FieldMetaState; } export interface FormRenderProps extends FormState { form: FormApi; handleSubmit: ( event?: React.SyntheticEvent ) => Promise | undefined; } export interface FormSpyRenderProps extends FormState { form: FormApi; } export interface RenderableProps { children?: ((props: T) => React.ReactNode) | React.ReactNode; component?: React.ComponentType | SupportedInputs; render?: (props: T) => React.ReactNode; } export interface FormProps extends Config, RenderableProps> { subscription?: FormSubscription; decorators?: Decorator[]; form?: FormApi; initialValuesEqual?: (a?: AnyObject, b?: AnyObject) => boolean; } export interface UseFieldConfig { afterSubmit?: () => void; allowNull?: boolean; beforeSubmit?: () => void | boolean; defaultValue?: FieldValue; format?: (value: FieldValue, name: string) => any; formatOnBlur?: boolean; initialValue?: FieldValue; isEqual?: (a: any, b: any) => boolean; multiple?: boolean; parse?: (value: any, name: string) => FieldValue; subscription?: FieldSubscription; type?: string; validate?: FieldValidator; validateFields?: string[]; value?: FieldValue; } export interface FieldProps extends UseFieldConfig, RenderableProps> { name: string; [otherProp: string]: any; } export interface UseFormStateParams { onChange?: (formState: FormState) => void; subscription?: FormSubscription; } export interface FormSpyProps extends UseFormStateParams, RenderableProps> {} export const Field: ( props: FieldProps ) => React.ReactElement; export const Form: ( props: FormProps ) => React.ReactElement; export const FormSpy: ( props: FormSpyProps ) => React.ReactElement; export function useField( name: string, config?: UseFieldConfig ): FieldRenderProps; export function useForm( componentName?: string ): FormApi; export function useFormState( params?: UseFormStateParams ): FormState; export function withTypes(): { Form: React.FC>; FormSpy: React.FC>; }; export const version: string;