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;
}
| Name | Signature | Description |
|---|---|---|
inputId | readonly inputId: string; | |
labelId | readonly labelId: string; | |
descriptionId | readonly descriptionId: string; | |
errorId | readonly errorId: string; | |
errors | readonly errors: readonly string[]; | Errors currently shown (rules, native constraints, server). |
invalid | readonly invalid: boolean; | True while an error is shown or |
validating | readonly validating: boolean; | |
hasDescription | readonly hasDescription: boolean; | |
inputProps | readonly 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. |
rootProps | readonly rootProps: {
readonly 'data-invalid': '' | undefined;
readonly 'data-disabled': '' | undefined;
readonly 'data-validating': '' | undefined;
}; |
|
onBlur | readonly onBlur: () => void; | Call from the control's blur handler. |
validate | readonly validate: () => readonly string[] | Promise<readonly string[]>; | Runs every rule now and reveals the result (e.g. on commit). |
errorMessage | readonly errorMessage: ReactNode | ((ctx: {
readonly errors: readonly string[];
}) => ReactNode) | undefined; |