"use client"; import { ReactNode } from "react"; import { Controller, ControllerFieldState, ControllerRenderProps, FieldValues, Path, UseFormReturn, } from "react-hook-form"; import { Field, FieldDescription, FieldError, FieldLabel } from "../../shadcnui"; type FormFieldWrapperProps = { form: UseFormReturn; name: Path; label?: string; description?: string; isRequired?: boolean; orientation?: "vertical" | "horizontal" | "responsive"; className?: string; children: (field: ControllerRenderProps>, fieldState: ControllerFieldState) => ReactNode; testId?: string; }; export function FormFieldWrapper({ form, name, label, description, isRequired, orientation = "vertical", className, children, testId, }: FormFieldWrapperProps) { return ( ( {label && ( {label} {isRequired && *} )} {children(field, fieldState)} {description && {description}} {fieldState.error && {fieldState.error.message}} )} /> ); }