import { type ErrorItem, type ErrorType } from '../../state/error-store'; export interface ErrorsResult extends ReadonlyArray { byType(type: ErrorType, opts?: { field?: string; }): ReadonlyArray; byField(field: string, opts?: { type?: ErrorType; }): ReadonlyArray; } export interface UseErrorOptions { includeDevErrors?: boolean; } export interface UseErrorsResult { errors: ErrorsResult; hasError: boolean; dismiss: (id: string) => void; dismissAll: () => void; } /** * React hook for reading and managing errors in ACUL (Advanced Customization of Universal Login). * With all validation and server-side errors. It groups errors into three types: * - `auth0` — errors returned by Auth0 or your own backend. * - `validation` — errors from client-side validation (e.g., invalid form input). * - `configuration` — errors caused by incorrect integration or SDK misuse. * * @supportedScreens * - The `useErrors` hook is available on every ACUL screen. * * @param options.includeDevErrors - When `true`, configuration errors are included in * the returned list. Defaults to `false`. * * @returns An object of type {@link UseErrorsResult}, containing: * - `errors` — the full error list of type {@link ErrorsResult}, with helpers: * - `errors.byType(type, filter?)` — filter by error type and optionally by field. * - `errors.byField(field, filter?)` — filter by field and optionally by type. * - `hasError` — `true` if any error is currently present. * - `dismiss(id)` — remove a specific error by its ID. * - `dismissAll()` — clear all tracked errors. * * Typical usage is inside a form or screen component where you need to * reactively display errors and provide ways to dismiss them: * * @example * ```tsx * import { useErrors } from "@auth0/auth0-acul-react"; * * export function SignupForm() { * const { errors, hasError, dismiss, dismissAll } = useErrors(); * * return ( *
* {hasError && ( *
* {errors.byType("auth0").map(err => ( *
* {err.message} * *
* ))} *
* )} * * *
* ); * } * ``` * * In addition to rendering messages, you can filter by field or type: * ```ts * console.log(errors.byType('validation')); // all validation errors * console.log(errors.byType('validation', { field: 'username' })); // validation errors for field 'username' * console.log(errors.byField('username')); // all errors for field 'username' * console.log(errors.byField('username', { type: 'auth0' })); // auth0 errors for field 'username' * ``` */ export declare function useErrors(options?: UseErrorOptions): UseErrorsResult; declare function withError(actionOrPromise: (() => T | Promise) | Promise): T | Promise; /** * @hidden * Internal error manager for use by SDK methods. * Use the `useErrors` hook in React components instead. */ export declare const errorManager: { withError: typeof withError; replaceValidationErrors(list: Array>, opts?: { byField?: string; }): void; clearValidationErrors(): void; pushValidationErrors(list: Omit | Array>): void; replaceDeveloperErrors(list: Array>, opts?: { byField?: string; }): void; clearDeveloperErrors(): void; pushDeveloperErrors(list: Omit | Array>): void; replaceServerErrors(list: Array>, opts?: { byField?: string; }): void; clearServerErrors(): void; pushServerErrors(list: Omit | Array>): void; syncServerErrors(): void; }; export { ErrorItem, ErrorType };