import { ReactNode } from "react"; import { FieldPathByValue, FieldValues, RegisterOptions, } from "react-hook-form"; import { ControlledFormInput } from "./ControlledFormInput.js"; import { FieldLayout, FormFieldLayoutProps } from "./FormFieldLayout.js"; import { PatchedControllerRenderProps } from "./types.js"; export type ControlledFormFieldProps< TValues extends FieldValues, TValueType = unknown, TName extends FieldPathByValue = FieldPathByValue< TValues, TValueType >, > = FormFieldLayoutProps & { name: TName; rules?: RegisterOptions; children: ( props: PatchedControllerRenderProps ) => ReactNode; }; export function ControlledFormField< TValues extends FieldValues, TValueType, TName extends FieldPathByValue = FieldPathByValue< TValues, TValueType >, >({ name, rules, children, ...layoutProps }: ControlledFormFieldProps) { return ( {children} ); } /* * Usage example: * * { * props => * } */