UNPKG

@arteneo/forge

Version:
41 lines (40 loc) 3.25 kB
import React from "react"; import { FormikValues, FormikTouched, FormikErrors } from "formik"; import { AxiosResponse } from "axios"; import FieldHelpType from "../../../components/Form/definitions/FieldHelpType"; import FieldLabelType from "../../../components/Form/definitions/FieldLabelType"; import FieldLabelVariablesType from "../../../components/Form/definitions/FieldLabelVariablesType"; import FieldPlaceholderType from "../../../components/Form/definitions/FieldPlaceholderType"; import FieldsInterface from "../../../components/Form/definitions/FieldsInterface"; import FieldResolveInterface from "../../../components/Form/definitions/FieldResolveInterface"; import FieldResolvedInterface from "../../../components/Form/definitions/FieldResolvedInterface"; import FieldPlaceholderResolveInterface from "../../../components/Form/definitions/FieldPlaceholderResolveInterface"; import FieldPlaceholderResolvedInterface from "../../../components/Form/definitions/FieldPlaceholderResolvedInterface"; import EndpointType from "../../../definitions/EndpointType"; interface FormContextProps { initialValues?: FormikValues; initializedValuesResponse?: AxiosResponse; formikInitialValues: FormikValues; hasError: (path: string, touched: FormikTouched<FormikValues>, errors: FormikErrors<FormikValues>, submitCount: number) => boolean; getError: (path: string, touched: FormikTouched<FormikValues>, errors: FormikErrors<FormikValues>, submitCount: number) => undefined | string; getLabel: (label: FieldLabelType, values: FormikValues, touched: FormikTouched<FormikValues>, errors: FormikErrors<FormikValues>, name: string, labelVariables?: FieldLabelVariablesType, disableAutoLabel?: boolean, disableTranslateLabel?: boolean) => undefined | React.ReactNode; getPlaceholder: (placeholder: FieldPlaceholderType, values: FormikValues, touched: FormikTouched<FormikValues>, errors: FormikErrors<FormikValues>, name: string, enableAutoPlaceholder?: boolean, disableTranslatePlaceholder?: boolean) => string | undefined; getHelp: (values: FormikValues, touched: FormikTouched<FormikValues>, errors: FormikErrors<FormikValues>, name: string, help?: FieldHelpType, disableTranslateHelp?: boolean) => undefined | React.ReactNode; resolveField: (props: FieldResolveInterface) => FieldResolvedInterface; resolvePlaceholderField: (props: FieldPlaceholderResolveInterface) => FieldPlaceholderResolvedInterface; } interface FormProviderProps { children: React.ReactNode; fields: FieldsInterface; initialValues?: FormikValues; initializeEndpoint?: EndpointType; /** * Processing initial values by default will remove any non-field related initialValue * It will also transform values according to fields requirements */ processInitialValues?: (fields: FieldsInterface, initialValues?: FormikValues, response?: AxiosResponse) => FormikValues; } declare const FormContext: React.Context<FormContextProps>; declare const FormProvider: ({ children, fields, initialValues, initializeEndpoint, processInitialValues, }: FormProviderProps) => React.JSX.Element; declare const useForm: () => FormContextProps; export { FormContext, FormContextProps, FormProvider, FormProviderProps, useForm };