/** * Everything a form field derives from its content and its current value. * * The value itself, and the "has it been touched" flag, stay with the framework * binding — they are the only genuinely stateful parts of a field. * * @module */ import { type Validator } from '../../forms/validation.js'; /** The element properties a field reads. Every form field content type has them. */ export type FormFieldContent = { SubmissionFieldName?: string | null; Label?: string | null; Validators?: unknown; PredefinedValue?: string | null; }; export type DefineFormFieldOptions = { /** The element's content. Name, validators and initial value are read from it. */ content?: FormFieldContent & Record; /** Overrides the name derived from `SubmissionFieldName` / `Label`. */ name?: string; /** Overrides the validators read from `Validators`. */ validators?: Validator[]; /** Overrides the initial value read from `PredefinedValue`. */ defaultValue?: string; }; export type FormFieldDefinition = { name: string; validators: Validator[]; initialValue: string; /** Every id dependency rules may target this field by. */ elementIds: string[]; }; /** Reads a field's identity out of its content, applying any overrides. */ export declare function defineFormField({ content, name: nameOverride, validators: validatorsOverride, defaultValue, }: DefineFormFieldOptions): FormFieldDefinition; export type FormFieldState = { errors: string[]; hasErrors: boolean; showErrors: boolean; isRequired: boolean; errorId: string | undefined; }; /** * Validates the current value and decides whether the visitor should see the result. * * Errors stay hidden until the field has been touched or the form has been * submitted, and a field hidden by a dependency rule never shows any. */ export declare function computeFieldState(definition: FormFieldDefinition, context: { value: string; isTouched: boolean; attemptedSubmit: boolean; isVisible: boolean; }): FormFieldState; /** * The attributes for the `` / `