import * as React from 'react'; import { FormProviderProps, Mode, Path, RegisterOptions, SubmitErrorHandler, SubmitHandler, UseFormProps } from 'react-hook-form'; import { FormProps } from '../Form/elements/Form'; import { FormValues } from '../Form/types'; export interface FormContextProps { /** * If fields should be disabled while form is being submitted and after successful submission. */ disableFieldsOnSubmit?: boolean; /** * Solo fields should always be required and have no optional/required text */ isSoloField?: boolean; /** * If fields should be reset after successful submission. */ resetOnSubmit?: boolean; /** * Validation rules form fields. Fields with validation rules must have a defaultValue listed in the defaultValue prop. */ validationRules?: { string?: RegisterOptions; }; /** * Sets if form submission was successful - if `undefined` will fall back to react-hook-forms native formState.isSubmitSuccessful. */ wasSubmitSuccessful?: boolean; } export interface ConnectedFormProps extends Omit, Omit { children?: React.ReactNode; /** * Function called with field values on submit, if all validations have passed. */ onSubmit: SubmitHandler; /** * Function called with field errors on submit, if validations have failed. */ onError?: SubmitErrorHandler; /** * Default values are highly recommended for reliable form behavior, particularly resets. */ defaultValues?: UseFormProps['defaultValues']; /** * Validation rules form fields. Fields with validation rules must have a defaultValue listed in the defaultValue prop. */ validationRules?: { [Key in keyof Values]?: RegisterOptions; }; /** * Which react hook form mode we are going to use for validation. * If you use the onChange mode the submit button will be disabled until all * required fields are completed. */ validation?: Mode; /** * An object that accepts an array of field names and a watchHandler that accepts a function, to be run onChange, that takes in an object of key/value pairs. The key is the field name and the value is the current value of the watched field. */ watchedFields?: { fields: Path[]; watchHandler: (arg0: Path[]) => void; }; } export type FormProviderCustomProps = FormProviderProps & FormContextProps; export declare const FormPropsContext: React.Context>; export declare const ConnectedForm: >(props: ConnectedFormProps, ref: React.ForwardedRef) => React.ReactElement;