@jimka/typescript-ui / core / Aria
Class: Aria
Defined in: src/typescript/lib/core/Aria.ts:60
Typed accessor for WAI-ARIA attributes on a Component.
Obtained via Component.getAria. Each attribute has its own getter/setter with a proper TypeScript type so that attribute names and values cannot be misspelled. State is stored internally and flushed to the DOM element by applyToElement, which Component calls during initialisation.
Example
this.getAria().setRole("grid");
row.getAria().setSelected(true);
header.getAria().setSort("ascending");Constructors
new Aria()
new Aria(component: Component): AriaDefined in: src/typescript/lib/core/Aria.ts:70
Parameters
component
The component this helper manages ARIA state for.
Returns
Methods
applyToElement()
applyToElement(element: HTMLElement): voidDefined in: src/typescript/lib/core/Aria.ts:615
Flushes all stored ARIA state to the given DOM element.
Parameters
element
HTMLElement
The component's root DOM element.
Returns
void
Remarks
Called by Component during element initialisation, ensuring attributes set before render are applied to the real DOM node.
getActiveDescendant()
getActiveDescendant(): null | stringDefined in: src/typescript/lib/core/Aria.ts:356
Returns the current aria-activedescendant value, or null if not set.
Returns
null | string
The active descendant ID, or null.
getAutoComplete()
getAutoComplete(): null | stringDefined in: src/typescript/lib/core/Aria.ts:329
Returns the current aria-autocomplete value, or null if not set.
Returns
null | string
The autocomplete hint, or null.
getColCount()
getColCount(): null | numberDefined in: src/typescript/lib/core/Aria.ts:398
Returns the current aria-colcount, or null if not set.
Returns
null | number
The column count, or null.
getColIndex()
getColIndex(): null | numberDefined in: src/typescript/lib/core/Aria.ts:376
Returns the current aria-colindex, or null if not set.
Returns
null | number
The column index, or null.
getControls()
getControls(): null | stringDefined in: src/typescript/lib/core/Aria.ts:309
Returns the current aria-controls value, or null if not set.
Returns
null | string
The controlled element ID, or null.
getDisabled()
getDisabled(): null | booleanDefined in: src/typescript/lib/core/Aria.ts:506
Returns the current aria-disabled value, or null if not set.
Returns
null | boolean
The disabled state, or null.
getExpanded()
getExpanded(): null | booleanDefined in: src/typescript/lib/core/Aria.ts:245
Returns the current aria-expanded value, or null if not set.
Returns
null | boolean
The expanded state, or null.
getHasPopup()
getHasPopup(): null | stringDefined in: src/typescript/lib/core/Aria.ts:486
Returns the current aria-haspopup value, or null if not set.
Returns
null | string
The popup type string, or null.
getHidden()
getHidden(): null | booleanDefined in: src/typescript/lib/core/Aria.ts:174
Returns the current aria-hidden value, or null if not set.
Returns
null | boolean
The hidden state, or null.
getLabel()
getLabel(): null | stringDefined in: src/typescript/lib/core/Aria.ts:604
Returns the current aria-label value, or null if not set.
Returns
null | string
The label text, or null.
getLabelledBy()
getLabelledBy(): null | stringDefined in: src/typescript/lib/core/Aria.ts:289
Returns the current aria-labelledby value, or null if not set.
Returns
null | string
The labelling element ID, or null.
getLevel()
getLevel(): null | numberDefined in: src/typescript/lib/core/Aria.ts:267
Returns the current aria-level, or null if not set.
Returns
null | number
The level number, or null.
getPosInSet()
getPosInSet(): null | numberDefined in: src/typescript/lib/core/Aria.ts:442
Returns the current aria-posinset, or null if not set.
Returns
null | number
The position in set, or null.
getPressed()
getPressed(): null | booleanDefined in: src/typescript/lib/core/Aria.ts:464
Returns the current aria-pressed value, or null if not set.
Returns
null | boolean
The pressed state, or null.
getRole()
getRole(): null | AriaRoleDefined in: src/typescript/lib/core/Aria.ts:91
Returns the current ARIA role, or null if none has been set.
Returns
null | AriaRole
The role, or null.
getRowCount()
getRowCount(): null | numberDefined in: src/typescript/lib/core/Aria.ts:218
Returns the current aria-rowcount, or null if not set.
Returns
null | number
The row count, or null.
getRowIndex()
getRowIndex(): null | numberDefined in: src/typescript/lib/core/Aria.ts:196
Returns the current aria-rowindex, or null if not set.
Returns
null | number
The row index, or null.
getSelected()
getSelected(): null | booleanDefined in: src/typescript/lib/core/Aria.ts:152
Returns the current aria-selected value, or null if not set.
Returns
null | boolean
The selected state, or null.
getSetSize()
getSetSize(): null | numberDefined in: src/typescript/lib/core/Aria.ts:420
Returns the current aria-setsize, or null if not set.
Returns
null | number
The set size, or null.
getSort()
getSort(): null | AriaSortDefined in: src/typescript/lib/core/Aria.ts:132
Returns the current aria-sort value, or null if not set.
Returns
null | AriaSort
The sort direction, or null.
getTabIndex()
getTabIndex(): null | numberDefined in: src/typescript/lib/core/Aria.ts:112
Returns the current tabindex, or null if not set.
Returns
null | number
The tabindex value, or null.
getValueMax()
getValueMax(): null | numberDefined in: src/typescript/lib/core/Aria.ts:582
Returns the current aria-valuemax, or null if not set.
Returns
null | number
The maximum value, or null.
getValueMin()
getValueMin(): null | numberDefined in: src/typescript/lib/core/Aria.ts:555
Returns the current aria-valuemin, or null if not set.
Returns
null | number
The minimum value, or null.
getValueNow()
getValueNow(): null | numberDefined in: src/typescript/lib/core/Aria.ts:528
Returns the current aria-valuenow, or null if not set.
Returns
null | number
The current value, or null.
setActiveDescendant()
setActiveDescendant(id: string): thisDefined in: src/typescript/lib/core/Aria.ts:340
Sets aria-activedescendant to the ID of the currently active descendant element.
Pass an empty string to clear the attribute.
Parameters
id
string
The element ID of the active descendant, or "" to clear.
Returns
this
setAutoComplete()
setAutoComplete(value: "inline" | "none" | "both" | "list"): thisDefined in: src/typescript/lib/core/Aria.ts:318
Sets aria-autocomplete, describing the kind of inline completion the field offers.
Parameters
value
'none', 'list', 'inline', or 'both'.
"inline" | "none" | "both" | "list"
Returns
this
setColCount()
setColCount(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:387
Sets aria-colcount (total number of columns in a grid).
Parameters
value
number
The total column count.
Returns
this
setColIndex()
setColIndex(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:365
Sets aria-colindex (1-based column position of a cell within a grid row).
Parameters
value
number
The 1-based column index.
Returns
this
setControls()
setControls(id: string): thisDefined in: src/typescript/lib/core/Aria.ts:298
Sets aria-controls to the ID of the element this one controls.
Parameters
id
string
The ID of the controlled element.
Returns
this
setDisabled()
setDisabled(value: boolean): thisDefined in: src/typescript/lib/core/Aria.ts:495
Sets aria-disabled.
Parameters
value
boolean
Whether the element is disabled.
Returns
this
setExpanded()
setExpanded(value: null | boolean): thisDefined in: src/typescript/lib/core/Aria.ts:229
Sets aria-expanded.
Parameters
value
true if the element is expanded, false if collapsed, null to remove the attribute (e.g. for leaf nodes).
null | boolean
Returns
this
setHasPopup()
setHasPopup(value: "false" | "true" | "grid" | "dialog" | "menu" | "tree" | "listbox"): thisDefined in: src/typescript/lib/core/Aria.ts:475
Sets aria-haspopup, indicating the element opens a popup.
Parameters
value
The popup type, or false to indicate no popup.
"false" | "true" | "grid" | "dialog" | "menu" | "tree" | "listbox"
Returns
this
setHidden()
setHidden(value: boolean): thisDefined in: src/typescript/lib/core/Aria.ts:163
Sets aria-hidden.
Parameters
value
boolean
Whether the element is hidden from assistive technology.
Returns
this
setLabel()
setLabel(value: string): thisDefined in: src/typescript/lib/core/Aria.ts:593
Sets aria-label, providing an accessible label for the element.
Parameters
value
string
The label text.
Returns
this
setLabelledBy()
setLabelledBy(id: string): thisDefined in: src/typescript/lib/core/Aria.ts:278
Sets aria-labelledby to the ID of the element that labels this one.
Parameters
id
string
The ID of the labelling element.
Returns
this
setLevel()
setLevel(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:256
Sets aria-level (1-based nesting depth of a tree item).
Parameters
value
number
The 1-based level number.
Returns
this
setPosInSet()
setPosInSet(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:431
Sets aria-posinset (1-based position of this element within its set).
Parameters
value
number
The 1-based position.
Returns
this
setPressed()
setPressed(value: boolean): thisDefined in: src/typescript/lib/core/Aria.ts:453
Sets aria-pressed on a toggle button.
Parameters
value
boolean
Whether the button is currently pressed.
Returns
this
setRole()
setRole(role: AriaRole): thisDefined in: src/typescript/lib/core/Aria.ts:79
Sets the WAI-ARIA role attribute.
Parameters
role
The ARIA role to assign.
Returns
this
setRowCount()
setRowCount(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:207
Sets aria-rowcount (total number of rows in a grid, used for virtual scrolling).
Parameters
value
number
The total row count.
Returns
this
setRowIndex()
setRowIndex(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:185
Sets aria-rowindex (1-based position of a row within a grid).
Parameters
value
number
The 1-based row index.
Returns
this
setSelected()
setSelected(value: boolean): thisDefined in: src/typescript/lib/core/Aria.ts:141
Sets aria-selected.
Parameters
value
boolean
Whether the element is selected.
Returns
this
setSetSize()
setSetSize(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:409
Sets aria-setsize (total number of items in the set this element belongs to).
Parameters
value
number
The total set size.
Returns
this
setSort()
setSort(value: AriaSort): thisDefined in: src/typescript/lib/core/Aria.ts:121
Sets aria-sort on a column header.
Parameters
value
The sort direction.
Returns
this
setTabIndex()
setTabIndex(value: null | number): thisDefined in: src/typescript/lib/core/Aria.ts:100
Sets the tabindex attribute, controlling keyboard focus order.
Parameters
value
0 = focusable in document order, -1 = focusable by script only, null removes the attribute.
null | number
Returns
this
setValueMax()
setValueMax(value: null | number): thisDefined in: src/typescript/lib/core/Aria.ts:566
Sets or clears aria-valuemax (the maximum value of a range or spinbutton widget).
Parameters
value
The maximum numeric value, or null to remove the attribute.
null | number
Returns
this
setValueMin()
setValueMin(value: null | number): thisDefined in: src/typescript/lib/core/Aria.ts:539
Sets or clears aria-valuemin (the minimum value of a range or spinbutton widget).
Parameters
value
The minimum numeric value, or null to remove the attribute.
null | number
Returns
this
setValueNow()
setValueNow(value: number): thisDefined in: src/typescript/lib/core/Aria.ts:517
Sets aria-valuenow (the current value of a range or spinbutton widget).
Parameters
value
number
The current numeric value.
Returns
this