@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
26 lines (25 loc) • 1.58 kB
TypeScript
import type { AnyFormApi } from '@tanstack/react-form';
import { type VisibilityMeta } from './visibility.js';
import type { FormRuntime } from './formRuntime.js';
/** Whether a field meta carries the "errors revealed" mark set by `revealFieldErrors`. */
export declare function isRevealedMeta(meta: unknown): boolean;
/** Whether the reveal was a scoped attempt that announces once itself (no per-field alerts). */
export declare function isQuietMeta(meta: unknown): boolean;
export interface RevealOptions {
/**
* A scoped submit attempt (a step's Next): like a submit, the fields' errors render without
* `role="alert"` — the attempt moves focus to the first invalid field / announces
* once itself, so N simultaneous alerts would only bury it. Default `false`: a reveal in
* response to one field's own event (a rejected file) announces as usual.
*/
quiet?: boolean;
}
/**
* Makes these fields' errors visible regardless of the visibility policy — a scoped submit
* attempt (a step's Next), or an immediate response to the user's action (a rejected file).
* Marks them touched + blurred and sets a meta flag that bindings OR into `submitted`;
* `form.reset()` clears it with the rest of the meta.
*/
export declare function revealFieldErrors(form: AnyFormApi, names: readonly string[], options?: RevealOptions): void;
/** Whether a field's errors show: revealed, or allowed by the form's `errorVisibility` policy. */
export declare function areErrorsVisible(runtime: FormRuntime, meta: VisibilityMeta, submitted: boolean): boolean;