View as Markdown

API reference: @salmonui/inputs/form

FieldStateinterface

import type { FieldState } from '@salmonui/inputs/form';
interface FieldState {
    readonly inputId: string;
    readonly labelId: string;
    readonly descriptionId: string;
    readonly errorId: string;
    readonly errors: readonly string[];
    readonly invalid: boolean;
    readonly validating: boolean;
    readonly hasDescription: boolean;
    readonly inputProps: {
        readonly id: string;
        readonly 'aria-describedby': string | undefined;
        readonly 'aria-invalid': true | undefined;
        readonly 'aria-errormessage': string | undefined;
    };
    readonly rootProps: {
        readonly 'data-invalid': '' | undefined;
        readonly 'data-disabled': '' | undefined;
        readonly 'data-validating': '' | undefined;
    };
    readonly onBlur: () => void;
    readonly validate: () => readonly string[] | Promise<readonly string[]>;
    readonly errorMessage: ReactNode | ((ctx: {
        readonly errors: readonly string[];
    }) => ReactNode) | undefined;
}
FieldState members (13)
NameSignatureDescription
inputIdreadonly inputId: string;
labelIdreadonly labelId: string;
descriptionIdreadonly descriptionId: string;
errorIdreadonly errorId: string;
errorsreadonly errors: readonly string[];

Errors currently shown (rules, native constraints, server).

invalidreadonly invalid: boolean;

True while an error is shown or invalid is set.

validatingreadonly validating: boolean;
hasDescriptionreadonly hasDescription: boolean;
inputPropsreadonly inputProps: { readonly id: string; readonly 'aria-describedby': string | undefined; readonly 'aria-invalid': true | undefined; readonly 'aria-errormessage': string | undefined; };

ARIA wiring for the element that owns the value.

rootPropsreadonly rootProps: { readonly 'data-invalid': '' | undefined; readonly 'data-disabled': '' | undefined; readonly 'data-validating': '' | undefined; };

data-* state hooks for the root.

onBlurreadonly onBlur: () => void;

Call from the control's blur handler.

validatereadonly validate: () => readonly string[] | Promise<readonly string[]>;

Runs every rule now and reveals the result (e.g. on commit).

errorMessagereadonly errorMessage: ReactNode | ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | undefined;