import { ObjectSchema, Schema } from 'yup'; export type formStateType = { isPreFillingForm: boolean; isSubmittingForm: boolean; isSubmitionError: boolean; isSubmitionSuccess: boolean; hasError: boolean; submitionError: any; hasChanges: boolean; }; export interface ISandBoxObject { setValues: React.Dispatch>>; setErrors: React.Dispatch>>; setTouchedErrors: React.Dispatch>>; setTouchedControls: React.Dispatch>>; setControlEnable: React.Dispatch>>; setFormState: React.Dispatch>; setControlFilling: React.Dispatch>>; resetForm: () => void; parcel: any | null; } export interface IRegisterOutputProps { id: string; touchederror: any; error: any; haserror: boolean; touched: boolean; enable: boolean; value: any; onTouchHandler: () => void; onChange: (e: any) => void; controlname: string; controlfilling: boolean; } type SetEnableInputProps = { bindValue: any; values: any; }; export type RegisterParamProps = { setCustomValue?: (value: any, sandBoxObject: ISandBoxObject) => any; setEnable?: ((props: SetEnableInputProps) => boolean) | boolean; }; export type formContextStateType = { state: formStateType; values: Record; errors: Record; touchedErrors: Record; sandBoxObject?: ISandBoxObject; }; export type UseFormOutputType = { values: Record; setValues: React.Dispatch>>; errors: Record; touchedErrors: Record; setErrors: React.Dispatch>>; formState: formStateType; register: (controlName: string, registerParamProps?: RegisterParamProps) => IRegisterOutputProps; onSubmitHandler: (e?: React.FormEvent | React.MouseEvent) => Promise; setFormState: React.Dispatch>; resetForm: () => void; }; export type UpdateFormStateProps = { formName: string; update: Partial; }; export type UpdateFormDataProps = { formName: string; update: Record; }; export type UpdateFormErrorsProps = { formName: string; update: Record; }; export type UpdateFormTouchedErrorsProps = { formName: string; update: Record; }; export type UpdateFormSandBoxObjectProps = { formName: string; sandBoxObject: ISandBoxObject; }; export type SettingsType = { DEBOUNCE_TIME?: number; SCROLL_DELAY?: number; parcel?: any | null; preventUnload?: boolean; }; export type ContextValueType = { formContextData: Record; initializeFormToContext: (formName: string) => void; updateFormState: ({ formName, update }: UpdateFormStateProps) => void; updateFormValues: ({ formName, update }: UpdateFormDataProps) => void; updateFormErrors: ({ formName, update }: UpdateFormErrorsProps) => void; updateFormTouchedErrors: ({ formName, update }: UpdateFormTouchedErrorsProps) => void; setFormSandBoxObject: ({ formName, sandBoxObject }: UpdateFormSandBoxObjectProps) => void; settings: SettingsType; metaData: Record; setMetaData: (key: string, value: Record) => void; }; export type useFormContextDataOutput = Record; export type SubmitHandlerInputProps = { currentPacket: Record; differencePacket: Record; initialPacket: Record; }; export type AsyncFunction = (values: Record) => Promise; export type SyncSubmitHandlerFunction = (props: SubmitHandlerInputProps, sandBoxObject: ISandBoxObject) => void; export type AsyncSubmitHandlerFunction = (props: SubmitHandlerInputProps, sandBoxObject: ISandBoxObject) => Promise; export type SyncPrefillerFunction = () => Record; export type AsyncPrefillerFunction = () => Promise>; export type FormProviderPropsType = { children?: React.ReactNode; settings?: SettingsType; }; export interface IRegisterProps extends Omit, 'onChange' | 'onFocus' | 'onAbort'> { value: any; onFocus: (e?: any) => void; onChange: (e: any) => void; touched: boolean; error: string; pretoucherror: any; controlleddisabled: boolean | undefined; uniquename: string; } export interface IOnChangeInterceptorInput { values: Record; touchedControls: Record; errors: Record; touchedErrors: Record; } export interface IYupError { message: string; path: string; } type FillerObjectType = { fn: SyncPrefillerFunction | AsyncPrefillerFunction; enable?: boolean; }; type ControlFillerType = { fn: (() => Promise) | (() => any); enable?: boolean; }; type PrefillType = { formPreFiller: FillerObjectType; controlFiller: Record; }; export interface IUseFormInputProps { formName: string; initialValues: Record; validationSchema?: ObjectSchema | Schema | ((values: Record) => Record); onChangeInterceptor?: (props: IOnChangeInterceptorInput, sandBoxObject: ISandBoxObject) => Record; onSubmitDataInterceptor?: (data: Record, sandBoxObject: ISandBoxObject) => Record; isNestedForm?: boolean; validateOnSubmit?: boolean; settings?: SettingsType; touchOnChange?: boolean; submitHandler?: SyncSubmitHandlerFunction | AsyncSubmitHandlerFunction; scrollToErrorControl?: boolean; preFill?: PrefillType; parcel?: any | null; persistValues?: boolean; preventUnload?: boolean; } type YupValidatorType = (validationSchema: Schema, values: Record) => Promise>; export type ValidateFormValuesProps = { validationSchema: Schema | ((props: Record) => Record) | ((props: Record, yupValidator?: YupValidatorType) => Promise>); values: Record; }; export {};