/** * Accessibility projection for option-based field widgets (radio / segmented). */ import type { MdyFieldError } from "@modyra/core"; import type { MdyPartContract } from "../contract.js"; import type { MdyOptionFieldState, MdyOptionFieldVariant } from "./option-field-types.js"; export interface MdyOptionFieldA11yOptions { /** * Whether the error container is on the page, whether or not it holds a message. * * Defaults to {@link errorsVisible}, so a renderer that draws it only when it has something to say * is unaffected. A renderer that reserves it gets a reference that never changes. */ readonly errorsReserved?: boolean; /** Whether the supporting text is on the page. Named unconditionally it would point at nothing. */ readonly descriptionVisible?: boolean; readonly widgetId: string; readonly variant: MdyOptionFieldVariant; /** How many options the group renders. The segmented theme sizes its tick gutter from it. */ readonly optionCount: number; /** * What the field is called, for the case where nothing was written for a person. * * A group is named by its label where there is one. A document may declare no label — the * published corpus does — and a `radiogroup` with no name is announced as "group" and nothing * else. `fieldAccessibleName` holds the order: what a host wrote, then the label, then the * field's own name, which is the last thing left to say. */ readonly label?: string | null; readonly ariaLabel?: string | null; readonly fieldName?: string | null; /** * Whether the error list is actually in the document. * * The caller owns this because only the caller knows when it renders one. A renderer that defers * the list until the field is touched has errors long before it shows them, and deriving this * from `errors.length` makes `aria-describedby` name an element that is not in the document. * * Defaults to "there are errors", which is correct for a renderer that always shows them. */ readonly errorsVisible?: boolean; } /** Builds the static IDs used by an option field widget view. */ export declare function optionFieldPartIds(widgetId: string): { readonly labelId: string; readonly groupId: string; readonly descriptionId: string; readonly errorId: string; }; /** Computes the public state classes for the option field root. */ export declare function optionFieldRootClasses(state: MdyOptionFieldState): readonly string[]; /** Projects ARIA attributes and classes for the option field parts. */ export declare function projectOptionFieldA11y(state: MdyOptionFieldState, errors: ReadonlyArray, options: MdyOptionFieldA11yOptions): { readonly root: MdyPartContract; readonly label: MdyPartContract; readonly group: MdyPartContract; readonly description: MdyPartContract; readonly error: MdyPartContract; };