import * as React from "react"; import { type FieldPath, type FieldValues, get, useFormContext, } from "react-hook-form"; import { FormMessage } from "~/components/FormMessage"; import { Label } from "~/components/Label"; import { type FormFieldSize, formFieldSizeToClassName } from "./form-utils"; export function InputFormField({ label, name, bottomText, placeholder, required, size = "small", type, }: { label: string; name: FieldPath; bottomText?: string; placeholder?: string; required?: boolean; size?: FormFieldSize; type?: React.HTMLInputTypeAttribute; }) { const methods = useFormContext(); const id = React.useId(); const error = get(methods.formState.errors, name); return (
{error && ( {error.message as string} )} {bottomText && !error ? ( {bottomText} ) : null}
); }