ui/form_state.svelte.ts view source
import {FormState} from '@fuzdev/fuz_app/ui/form_state.svelte.js'; generics
FormState<TField extends string = string>TField
stringstringform
Creates a form attachment that handles the Enter key (advance focus to
the next input, or submit from the last one) and tracks field touched
state via delegated focusout.
Fields are identified by their name attribute.
type (): Attachment<HTMLFormElement>
Attachment<HTMLFormElement>throws
Error- in DEV when called while already attached, or when an input loses focus without a `name` attribute
is_touched
Whether a field has been blurred at least once.
type (field: TField): boolean
field
TFieldbooleanshow
Whether to show validation errors for a field.
Returns true if the field has been blurred or a submit attempt was made.
type (field: TField): boolean
field
TFieldbooleantouch
Programmatically marks a field as touched without requiring a blur event.
type (field: TField): void
field
TFieldvoidmutates
this
focus
Focuses the named input within the form.
type (field: TField): void
field
TFieldvoidattempt
Marks the form as having been submitted, causing all field errors to show.
type (): void
voidmutates
this
reset
Resets all touched and attempted state.
type (): void
voidmutates
this
attempted
Whether a submit attempt has been made.
type boolean