import { useId, type FormHTMLAttributes, type ReactNode } from "react"; import { TextField } from "../components/ui/text-field.jsx"; import { useLocale } from "../i18n/index.js"; import type { FieldErrors, FieldName, FormValues, } from "./form-contracts.js"; export function Form( props: FormHTMLAttributes & Readonly<{ pending?: boolean }>, ) { const { pending = false, children, ...formProps } = props; return (
{children}
); } export function FormField( props: React.ComponentProps, ) { return ; } export function ErrorSummary(props: Readonly<{ fieldErrors: FieldErrors; formErrors?: readonly string[]; fieldLabels: Readonly, string>>; fieldId(name: FieldName): string; onFocusField?(name: FieldName): void; }>) { const { message } = useLocale(); const { fieldErrors, formErrors = [], fieldLabels, fieldId, onFocusField, } = props; const headingId = useId(); const entries = Object.entries(fieldErrors) as [ FieldName, string, ][]; if (entries.length === 0 && formErrors.length === 0) return null; return (

{message("form.errorSummary")}

{entries.length > 0 ? ( ) : null} {formErrors.map((message) => (

{message}

))}
); } export function FormActions(props: Readonly<{ children: ReactNode; sticky?: boolean; }>) { return (
{props.children}
); }