import { FormOptions, FormState } from './form.types'; /** * Headless form/field orchestrator. Attaches to an existing `
` (progressive * enhancement), discovers fields via `[data-c42-field]`, runs validation, wires * ARIA (`aria-invalid`, `aria-describedby`) and reflects `data-state="valid|invalid"` * on each field wrapper so CSS can react — it never applies visual styles itself. * * Markup: * ```html * *
* * * *
* *
* ``` */ export declare class Form { private readonly root; private readonly mode; private readonly messages; private readonly customValidators; private fields; private errors; private submitted; private cleanups; constructor(root: HTMLElement, options?: FormOptions); private collectFields; private fieldByName; private valueOf; private messageFor; private constraint; private patternFor; private validateValue; private applyFieldState; private runField; private onInteraction; private emit; /** Current `name` → value map for every discovered field. */ getValues(): Record; /** Set values by field name. Radios/checkboxes are toggled to match. */ setValues(values: Record): void; /** Validate every field. Returns `true` when all pass. */ validate(): boolean; /** Validate a single field by name. Returns its error message or `null`. */ validateField(name: string): string | null; /** Programmatically set an error on a field (e.g. server-side validation). */ setError(name: string, message: string): void; /** Clear all error state without touching values. */ clearErrors(): void; /** Reset the underlying form and clear all error/touched state. */ reset(): void; /** * Validate everything and emit `form:submit` (valid) or `form:invalid`. * Focuses the first invalid control. Returns whether the form was valid. */ submit(): boolean; /** Read the current state (values + errors + validity). */ getState(): FormState; /** Subscribe to a DOM event on the root element. Returns an unsubscribe fn. */ on(event: string, handler: (event: E) => void): () => void; destroy(): void; }