import type { ReactNode } from 'react'; import type { MessageTarget } from '../../validation/message-routing.js'; import { type ValidationError, type ValidationErrorSource } from '../../validation/types.js'; import type { FormFieldMessageContextState } from '../types/formfield-messages.types.js'; export declare const enum FormFieldMessagesAction { ADDMESSAGE = "addmessage", REMOVEMESSAGE = "removemessage", DISABLEMESSAGE = "disablemessage", SETISTOUCHED = "setistouched", SETFORMCONTROLID = "setformcontrolid", SETMESSAGETARGET = "setmessagetarget", ADDMEMBERFORMCONTROLID = "addmemberformcontrolid", REMOVEMEMBERFORMCONTROLID = "removememberformcontrolid" } type AddMessageBasePayload = { /** Entry identity — used for dedup/replace and as the React key. */ id: string; /** * Reveals the message immediately, bypassing the touched-gate. Only actions * that are meant to surface right away (e.g. `form.setError()`) set this. */ showError?: boolean; }; type AddErrorPayload = AddMessageBasePayload & { error: ValidationError; hint?: never; }; type AddHintPayload = AddMessageBasePayload & { hint: ReactNode; /** Who is registering this hint — a Strato control (`'strato'`) or the consumer (`'custom'`). */ source?: ValidationErrorSource; /** * Native input the hint belongs to. Errors don't need this — they carry * their own target(s) via `ValidationError.formControlId`, which * `updateValidity()` reads directly to decide which input(s) receive * `setCustomValidity()`. */ controlId?: string; error?: never; }; export type AddMessagePayload = AddErrorPayload | AddHintPayload; export type FormFieldMessagesReducerAction = { type: FormFieldMessagesAction.ADDMESSAGE; payload: AddMessagePayload; } | { type: FormFieldMessagesAction.REMOVEMESSAGE; payload: { id: string; /** Must match the `source` (for hints) or the error's `source` (for errors) used when adding, so a consumer `Item` can't remove an internal entry that coincidentally shares its id. */ source?: ValidationErrorSource; }; } | { type: FormFieldMessagesAction.DISABLEMESSAGE; payload: { isDisabled: boolean | undefined; }; } | { type: FormFieldMessagesAction.SETISTOUCHED; payload: { isTouched: boolean; resetShowError?: boolean; }; } | { type: FormFieldMessagesAction.SETFORMCONTROLID; payload: { formControlId: string | undefined; }; } | { type: FormFieldMessagesAction.SETMESSAGETARGET; payload: { messageTarget: MessageTarget[] | undefined; }; } | { type: FormFieldMessagesAction.ADDMEMBERFORMCONTROLID; payload: { formControlId: string; }; } | { type: FormFieldMessagesAction.REMOVEMEMBERFORMCONTROLID; payload: { formControlId: string; }; }; /** FormFieldMessage reducer function used for managing form field errors and hints. */ export declare function formFieldMessagesReducer(state: FormFieldMessageContextState, action: FormFieldMessagesReducerAction): FormFieldMessageContextState; export {}; //# sourceMappingURL=formfield-messages-state-reducer.d.ts.map