UNPKG

ponchojs

Version:

Poncho

49 lines (48 loc) 1.45 kB
import React, { Dispatch } from 'react'; import { CommonInputProps } from '../components/form/Form'; import { FormRefMethods } from '../components/form/FormContainer'; import { InputVals } from '../hooks/useFormContext'; export declare type ExternalProvider = { loading?: boolean; }; declare type GlobalProviderProps = { innerRef?: React.ForwardedRef<FormRefMethods>; } & ExternalProvider; export declare type FormikHelpers<T = any> = { values: T; setValues: (values: T) => void; }; export interface FormState<T = any> extends GlobalProviderProps { actualStep: number; steps: string[]; initialValues: Record<string, T>; fieldsProps: Record<string, CommonInputProps<InputVals>>; validationSchema: Record<string, any>; formik: FormikHelpers<T>; } declare type Context = [FormState, Dispatch<FormActions>]; export declare const FormContext: React.Context<Context>; export declare type FormActions = { type: 'CLEAR'; } | { type: 'LOADING'; loading?: boolean; } | { type: 'FORMIK'; formik: FormikHelpers; } | { type: 'STEP'; id: string; } | { type: 'NEXT_STEP'; } | { type: 'PREV_STEP'; } | { type: 'PREPARE'; input: CommonInputProps<InputVals>; }; declare type ProviderProps = { children: React.ReactChild; } & GlobalProviderProps; export declare const FormProvider: (props: ProviderProps) => JSX.Element; export {};