/** * Accessibility projection for boolean field widgets (checkbox / switch). */ import type { MdyFieldError } from "@modyra/core"; import type { MdyPartContract } from "../contract.js"; import type { MdyBooleanFieldState, MdyBooleanFieldVariant } from "./boolean-field-types.js"; export interface MdyBooleanFieldA11yOptions { /** * Whether the supporting text is on the page. * * Named unconditionally, the description points at an element a renderer may not have drawn — the * reference resolves to nothing and the control is described by an id rather than by words. * Defaults to true, which is what every caller relied on before it could say otherwise. */ readonly descriptionVisible?: boolean; /** * Whether the error container is on the page, whether or not it holds a message. * * A renderer that keeps it under every field that can fail a rule passes this, and the control's * description then names one element that never changes — no moment at which the reference can * point at something not yet drawn, or already gone. * * Defaults to whether there are errors to show, so a renderer that draws the container only when it * has something to say is unaffected. */ readonly errorsReserved?: boolean; readonly widgetId: string; readonly variant: MdyBooleanFieldVariant; /** * The key this control sends its value under when the browser submits the form it sits in. * * The field's path, not its widget id: a scope in a payload is a key the receiving end never asked * for, and two forms send the same key while staying apart, because a payload belongs to its form. */ readonly submitName?: string; } /** Builds the static IDs used by a boolean field widget view. */ export declare function booleanFieldPartIds(widgetId: string): { readonly inputId: string; readonly labelId: string; readonly descriptionId: string; readonly errorId: string; }; /** * Computes the public state classes for the boolean field root. * * Through the shared vocabulary rather than as literals: these were nine hand-written `mdy-field--*` * names, and no theme styled a single one of them. */ /** The root's classes, from the shared table every kind reads. */ export declare function booleanFieldRootClasses(state: MdyBooleanFieldState): readonly string[]; /** Projects ARIA attributes and classes for the boolean field parts. */ export declare function projectBooleanFieldA11y(state: MdyBooleanFieldState, errors: ReadonlyArray, options: MdyBooleanFieldA11yOptions): { readonly root: MdyPartContract; readonly label: MdyPartContract; readonly input: MdyPartContract; /** * The false half of the value, which HTML cannot express on its own. * * An unchecked box is **absent** from a form's payload — that is the rule — so `false` and "this * field was never sent" arrive identical, and a receiver cannot tell a person who said no from a * form that did not carry the question. This carries `false` under the same key, ahead of the box, * so the key is always present; when the box is checked it sends `true` after this one, and the * later value is the answer. * * Rendered only when the field has a submit name. Without one nothing here is serialised anyway, * and a hidden input in a form that cannot submit is a node with no reader. */ readonly submitFalse: MdyPartContract; /** The drawn control: a checkbox's box, decorative because the native input carries the state. */ readonly indicator: MdyPartContract; readonly description: MdyPartContract; readonly error: MdyPartContract; };