/** * ARIA Compiler -- `BoundaryDef` to accessibility attribute maps. * * Takes a boundary definition and state-specific ARIA attribute maps, * returns both the full `state -> attributes` mapping and the attributes * for the current active state. * * @module */ import type { Boundary, StateUnion } from '@czap/core'; /** * Output of {@link ARIACompiler.compile}. * * `stateAttributes` is the full lookup keyed by state, ready for direct * spreading when the boundary transitions. `currentAttributes` is a * convenience pre-resolved for the active state so SSR can emit it * immediately without duplicating the lookup. */ export interface ARIACompileResult { /** Validated per-state ARIA attribute maps. */ readonly stateAttributes: Record>; /** Attributes for the active state at compile time. */ readonly currentAttributes: Record; } /** * Compile a boundary definition and per-state ARIA attribute maps into a * validated result containing the full state-to-attributes mapping and the * attributes for the current active state. * * Only valid ARIA attributes (`aria-*`) and `role` are retained; all other * keys are dropped and trigger a diagnostic warning. * * @example * ```ts * import { Boundary } from '@czap/core'; * import { ARIACompiler } from '@czap/compiler'; * * const boundary = Boundary.make({ * input: 'width', * at: [[0, 'collapsed'], [768, 'expanded']], * }); * const result = ARIACompiler.compile(boundary, { * collapsed: { 'aria-expanded': 'false', 'aria-label': 'Show more' }, * expanded: { 'aria-expanded': 'true', 'aria-label': 'Show less' }, * }, 'collapsed'); * console.log(result.currentAttributes); * // { 'aria-expanded': 'false', 'aria-label': 'Show more' } * ``` * * @param boundary - The boundary definition with states * @param states - Per-state ARIA attribute maps * @param currentState - The currently active state * @returns An {@link ARIACompileResult} with validated state attributes */ declare function compile(boundary: B, states: { [S in StateUnion & string]: Record; }, currentState: StateUnion): ARIACompileResult & string>; /** * ARIA compiler namespace. * * Compiles boundary definitions into validated ARIA attribute maps keyed by * state. Invalid attribute keys (not `aria-*` or `role`) are filtered and * trigger a diagnostic warning. Returns both the full state mapping and the * attributes for the current active state. * * @example * ```ts * import { Boundary } from '@czap/core'; * import { ARIACompiler } from '@czap/compiler'; * * const boundary = Boundary.make({ * input: 'width', * at: [[0, 'sm'], [768, 'lg']], * }); * const result = ARIACompiler.compile(boundary, { * sm: { 'aria-hidden': 'true' }, * lg: { 'aria-hidden': 'false' }, * }, 'sm'); * const attrs = result.currentAttributes; * // { 'aria-hidden': 'true' } * ``` */ export declare const ARIACompiler: { readonly compile: typeof compile; }; export {}; //# sourceMappingURL=aria.d.ts.map