/** * Imperative live-region handle, complementing the singleton * {@link announceToScreenReader}. Use `createLiveRegion()` when you need * multiple independent live regions, or want fine-grained control over the * region's `role`/`aria-live`/`aria-atomic` attributes and lifecycle. * * @module bquery/a11y * @since 1.14.0 */ import type { AnnouncePriority } from './types'; /** * Options for {@link createLiveRegion}. * * @since 1.14.0 */ export type CreateLiveRegionOptions = { /** `'polite'` (default) or `'assertive'`. */ priority?: AnnouncePriority; /** * Explicit ARIA role. Defaults to `'status'` for polite regions and * `'alert'` for assertive ones. */ role?: string; /** * `aria-atomic` value. Defaults to `'true'`. */ atomic?: 'true' | 'false' | boolean; /** * Parent element to append the region into. Defaults to `document.body`. */ container?: HTMLElement; /** * Delay in ms before writing the text content after clearing the region. * Defaults to `50` (matches `announceToScreenReader`). */ delay?: number; /** * Optional `id` for the region. Useful for `aria-describedby` references. */ id?: string; /** * Optional CSS class to apply to the region. The region is visually hidden * by default via inline styles; classes are additive. */ className?: string; }; /** * Imperative handle returned by {@link createLiveRegion}. * * @since 1.14.0 */ export type LiveRegionHandle = { /** The underlying DOM element. */ element: HTMLElement; /** Announce a message; clears first to force a mutation event. */ announce: (message: string) => void; /** Clears the region without removing it. */ clear: () => void; /** Removes the region from the DOM and releases pending timers. */ destroy: () => void; }; /** * Creates a dedicated, off-screen ARIA live region and returns an imperative * handle for announcing messages through it. * * Unlike the singleton {@link announceToScreenReader}, each call creates a * fresh region — useful when several independent components need to announce * unrelated state changes without interleaving. * * @since 1.14.0 * * @example * ```ts * import { createLiveRegion } from '@bquery/bquery/a11y'; * * const region = createLiveRegion({ priority: 'assertive' }); * region.announce('Connection lost'); * // ...later * region.destroy(); * ``` */ export declare const createLiveRegion: (options?: CreateLiveRegionOptions) => LiveRegionHandle; //# sourceMappingURL=live-region.d.ts.map