import { Controller, type FieldValues, type Path, type RegisterOptions, useFormContext, } from "react-hook-form"; import { FileDropZone } from "../FileDropZone.tsx"; interface FileFieldProps { name: Path; label?: string; hint?: string; showLimit?: boolean; disabled?: boolean; rules?: RegisterOptions>; } /** `Controller`-wrapped {@link FileDropZone} bound to react-hook-form. */ export function FileField({ name, label, hint, showLimit, disabled, rules, }: FileFieldProps) { const { control, formState: { errors } } = useFormContext(); const error = errors[name]; return (
( )} /> {error?.message && ( {String(error.message)} )}
); }