react-forminate
Version:
React.js + Typescript package that creates dynamic UI forms based on the JSON schema
21 lines (20 loc) • 1.5 kB
TypeScript
import { FormContextType, SupportedTypes } from '../types';
export type FormContextMap = {
[formId: string]: {
actions: Pick<FormContextType, "setValue" | "validateField" | "validateForm" | "setTouched" | "setBlurred" | "fetchDynamicOptions" | "getFieldSchema" | "shouldShowField" | "observer" | "resetForm">;
values: Record<string, SupportedTypes>;
errors: Record<string, string>;
meta: Pick<FormContextType, "dynamicOptions" | "formSchema" | "formOptions" | "touched" | "blurred">;
};
};
export declare const FormRegistryContext: import('react').Context<{
forms: FormContextMap;
registerForm: (formId: string, context: FormContextMap[string]) => void;
unregisterForm: (formId: string) => void;
}>;
export declare const useFormReg: () => FormContextMap;
export declare const FormActionsContext: import('react').Context<Pick<FormContextType, "setValue" | "validateField" | "validateForm" | "setTouched" | "setBlurred" | "fetchDynamicOptions" | "getFieldSchema" | "shouldShowField" | "observer" | "resetForm">>;
export declare const FormValuesContext: import('react').Context<Record<string, SupportedTypes>>;
export declare const FormErrorsContext: import('react').Context<Record<string, string>>;
export declare const FormMetaContext: import('react').Context<Pick<FormContextType, "dynamicOptions" | "formSchema" | "formOptions" | "touched" | "blurred">>;
export declare const FormContext: import('react').Context<FormContextType | undefined>;