import type { ReactNode } from "react"; import type { Control, FieldValues } from "react-hook-form"; import { View } from "../primitives/View"; import { Form, type FormProps } from "./Form"; import { FormSubmitButton } from "./FormSubmitButton"; export interface SimpleVFormProps< TFieldValues extends FieldValues, > extends Omit, "render"> { submitLabel: string; /** Forwarded to FormSubmitButton — see its errorToMessage doc. */ submitErrorToMessage: (error: unknown) => string; className?: string; render: (params: { control: Control; submit: () => Promise; }) => ReactNode; } /** * Standardizes the common case: a Form laid out as a vertical stack with * a trailing FormSubmitButton. */ export function SimpleVForm({ submitLabel, submitErrorToMessage, className, render, ...formProps }: SimpleVFormProps): ReactNode { return (
( {render({ control, submit })} )} /> ); }