UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

15 lines (14 loc) • 1.04 kB
/** Text of a label-like element as the user reads it: `aria-hidden` marks (required stars, spinners) removed. */ export declare function visibleText(element: Element): string; /** * Visible label text of a field (ErrorSummary links), read from the DOM so it is * whatever the user sees. Group fields are named by their `<fieldset>`'s legend: * - the field's root (the nearest ancestor-or-self carrying `data-field={name}`) is itself a * fieldset (DateRange: the control is an inner "Start date" input) → that legend; * - the control has no name of its own (a radiogroup/group inside a Fieldset) → the nearest * enclosing fieldset's legend; * - otherwise the control's own label. Falls back to `fallback` (the path). */ export declare function readFieldLabel(control: HTMLElement | null, name: string, fallback: string): string; /** The visible text of the first `<legend>` inside `element` (a Repeater's group), or `fallback`. */ export declare function readLegend(element: HTMLElement | null, fallback: string): string;