react-hook-form-builder
Version:
light weight schema Form builder for react-hook-form
26 lines • 1.06 kB
TypeScript
/// <reference types="react" />
import { FieldPathValue, RegisterOptions, SubmitHandler, UnpackNestedValue, UseFormReturn } from "react-hook-form";
export declare type IFormBuilderProvider = (args: {
children: React.ReactElement;
elements: any[];
}) => React.ReactElement;
export declare type IFormBuilder<TFormValues> = {
onSubmit?: SubmitHandler<TFormValues>;
children?: React.ReactNode;
schema: ISchemaProps<TFormValues>[];
methods: UseFormReturn<TFormValues>;
};
export interface IElementParser<TFormValues> {
schema: ISchemaProps<TFormValues>;
}
export interface ISchemaProps<TFormValues extends Record<string, any> = Record<string, any>> {
key: string;
elementType: string;
props: any;
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
defaultValue?: UnpackNestedValue<FieldPathValue<TFormValues, any>>;
ignoreController?: boolean;
onDidMount?: (args: UseFormReturn) => void;
onDidUnMount?: (args: UseFormReturn) => void;
}
//# sourceMappingURL=index.d.ts.map