import type { InputHTMLAttributes } from "react"; /** * @remarks \@since 2.5.0 */ export declare type TextConstraints = Pick, "pattern" | "required" | "minLength" | "maxLength">; /** * Since the default validation messages can be verbose, this type is used to * configure when/how to display the native browser messages when the validation * state changes during the `change` event phase. The validation message will * always be shown on blur. * * When this is: * * - `true` -> always show the browser message when it exists * - `false` -> never show the browser message * - `"recommended"` -> only shows the browser message if it is not one of the * `RECOMMENDED_IGNORED_KEYS` validation errors * - `keyof ValidityState` -> only shows the browser message if it is not the * specific validation error * - `(keyof ValidityState)[]` -> only shows the browser message if it is not * the specific validation errors * * @remarks \@since 2.5.0 */ export declare type ChangeValidationBehavior = boolean | "recommended" | "number-recommended" | keyof ValidityState | readonly (keyof ValidityState)[]; /** * @remarks \@since 2.5.0 */ export interface ErrorMessageOptions extends TextConstraints { /** * The current input or textarea's validity state. */ validity: ValidityState; /** * The browser defined validation message based on the validity state. This * will be the empty string when there are no errors. */ validationMessage: string; /** * The current `TextField` or `TextArea` value. */ value: string; /** * Boolean if this is triggered from a blur event instead of a change event. */ isBlurEvent: boolean; /** * The change event validation behavior that is specified in the hook. */ validateOnChange: ChangeValidationBehavior; } /** * A function to get a custom error message for specific errors. This is really * useful when using the `pattern` attribute to give additional information or * changing the native "language translated" error message. * * @param options - An object containing metadata that can be used to create an * error message for your `TextField` or `TextArea`. * @returns An error message to display or an empty string. * @remarks \@since 2.5.0 */ export declare type GetErrorMessage = (options: ErrorMessageOptions) => string; /** * @internal * @remarks \@since 2.5.0 */ export declare const RECOMMENDED_STATE_KEYS: readonly (keyof ValidityState)[]; /** * @internal * @remarks \@since 2.5.0 */ export declare const RECOMMENDED_NUMBER_STATE_KEYS: readonly (keyof ValidityState)[]; /** * The default implementation for getting an error message for the `TextField` * or `TextArea` components that relies on the behavior of the * {@link ChangeValidationBehavior} * * @remarks \@since 2.5.0 */ export declare const defaultGetErrorMessage: GetErrorMessage;