/** * Accessibility projection for primitive field widgets. */ import type { MdyFieldError } from "@modyra/core"; import type { MdyPartContract } from "../contract.js"; import type { MdyFieldState } from "./field-types.js"; import type { MdyFieldConstraints } from "@modyra/core"; import { type MdyWidgetKind } from "../catalog.js"; export interface MdyTextFieldA11yOptions { readonly widgetId: string; readonly inputType?: string; readonly inputMode?: string; readonly autocomplete?: string; /** * The kind whose control this is, so the projection can decide which native constraints it can * carry — a `maxlength` on a number input is ignored by the platform, and a `pattern` on a * textarea likewise. */ readonly kind?: MdyWidgetKind | string; /** * What the field's rules state, already narrowed by anything the control itself asks for. * * The projection is where a control's attributes are decided — `type`, `inputmode`, the ARIA set * — so this is where the rules become attributes too. A renderer that had to place them itself * would be a renderer that could forget one, and two of them did. */ readonly constraints?: MdyFieldConstraints; /** * Whether a description element is rendered at all. * * The reference is only worth making when there is something at the other end: a control naming an * empty description sends a reader somewhere to hear nothing. Defaults to true, for a renderer that * always draws the element. */ readonly descriptionVisible?: boolean; /** * Whether the error container is on the page, whether or not it holds a message. * * Defaults to whether errors are being shown, so a renderer that draws it only when it has * something to say is unaffected. */ readonly errorsReserved?: boolean; /** * 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: the id carries a per-form scope so two forms on one page do * not collide, and a scope in a payload is a key the receiving end never asked for. Two forms send * the same key and stay apart, because a payload belongs to its form. * * Absent for a renderer that has no path to give, which leaves the control unserialised — the * state every kind was in before this existed. */ readonly submitName?: string; } /** Builds the static IDs used by a field widget view. */ export declare function textFieldPartIds(widgetId: string): { readonly inputId: string; readonly labelId: string; readonly descriptionId: string; readonly errorId: string; }; /** Computes the public state classes for the field root. */ export declare function textFieldRootClasses(state: MdyFieldState): readonly string[]; /** Projects ARIA attributes and classes for the field parts. */ export declare function projectTextFieldA11y(state: MdyFieldState, errors: ReadonlyArray, options: MdyTextFieldA11yOptions): { readonly root: MdyPartContract; readonly label: MdyPartContract; readonly input: MdyPartContract; readonly description: MdyPartContract; readonly error: MdyPartContract; };