import { AriaAttributes, type RefObject, type SyntheticEvent, type ChangeEvent, type FocusEvent } from 'react'; import { type IntlShape } from 'react-intl'; import { AriaLabelingProps } from '../../../core/types/a11y-props.js'; import type { FormControlState } from '../../../core/types/form-control-state.js'; import type { ValidationState, ValidationTrigger } from '../../validation/types.js'; type FormFieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; /** * Getter function to read the error type form the validity state. * The validity state values are readonly and can't therefore not be iterated but need to accessed directly instead. * https://stackoverflow.com/questions/20891950/html-validation-api-returns-an-empty-object-in-firefox?rq=2 * @internal */ export declare function getErrorType(validityState?: ValidityState): "badInput" | "patternMismatch" | "rangeOverflow" | "rangeUnderflow" | "stepMismatch" | "tooLong" | "tooShort" | "typeMismatch" | "valueMissing" | null; /** * Internal getter function to return the matching formatted message for * each validityStateKey. * @internal */ export declare function getI18nErrorMessage(key: keyof ValidityState, ref?: FormFieldElement | null): import("react").JSX.Element | null; /** * Returns the translated plain-string validation message for a given validity * state key. Mirrors the JSX messages in {@link getI18nErrorMessage} using the * same descriptors so both the UI and `ValidationError.message` stay in sync. * * @internal */ export declare function getI18nValidationMessage(intl: IntlShape, key: keyof ValidityState, ref?: FormFieldElement | null): string; /** * Builds a ValidationState with an i18n message for the current validity of * `element`, bypassing the corrupted `element.validationMessage` that * `setCustomValidity` produces. * @internal */ export declare function getI18nValidationState(intl: IntlShape, element: FormFieldElement | null | undefined, trigger: ValidationTrigger, formControlId?: string | string[]): ValidationState; /** @internal */ interface FormFieldValidationProps { ariaProps: Pick; onInvalid: (event: SyntheticEvent) => void; onChange: (event?: ChangeEvent) => void; onBlur: (event?: FocusEvent) => void; emitValidationState: (state: ValidationState) => ValidationState; } /** * Hook to generate ARIA props based on the form field messages * @param ariaLabelingProps - ARIA labeling properties * @param controlState - Legacy `controlState` override. When set, the shared * `FormFieldMessages` state is ignored entirely so `controlState` fully * isolates the control instead of being mixed with message-driven validation. * @returns ARIA props for the form field * @internal */ export declare function useFormFieldValidationAriaProps(ariaLabelingProps?: AriaLabelingProps, controlState?: FormControlState): { "aria-errormessage"?: string | undefined | undefined; "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined; 'aria-label'?: string; 'aria-labelledby'?: string; 'aria-details'?: string; 'aria-describedby': string | undefined; }; /** @internal */ interface UseFormFieldValidationOptions { /** * Values that trigger re-validation when changed (e.g., required, min, max, pattern). */ validationDeps?: Record; /** * ARIA labeling properties. */ ariaLabelingProps?: AriaLabelingProps; /** * Callback invoked with the current validation state. */ emitValidationState?: (state: ValidationState) => void; /** * Legacy `controlState` override. When set, all automatic dispatches into * the shared `FormFieldMessages` state are skipped so `controlState` fully * isolates the control instead of being mixed with message-driven validation. */ controlState?: FormControlState; /** * Reveals a native error found by the automatic mount validation * immediately instead of waiting for the field to be touched. */ revealOnMount?: boolean; } /** * @param ref - Reference to the input element * @param options - Validation options * @internal */ export declare function useFormFieldValidation(ref: RefObject, { validationDeps, ariaLabelingProps, emitValidationState: emitValidationStateProp, controlState, revealOnMount, }?: UseFormFieldValidationOptions): FormFieldValidationProps; /** * @internal - function to combine aria-labelling and validation aria-props correctly. */ export declare function getCombinedAriaProps(validationAriaProps: Pick, labelingProps: AriaLabelingProps): { "aria-errormessage"?: string | undefined | undefined; "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined; 'aria-label'?: string; 'aria-labelledby'?: string; 'aria-details'?: string; 'aria-describedby': string | undefined; }; export {}; //# sourceMappingURL=useFormFieldValidation.d.ts.map