Skip to content

@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

typescript
this.getAria().setRole("grid");
row.getAria().setSelected(true);
header.getAria().setSort("ascending");

Constructors

new Aria()

ts
new Aria(component: Component): Aria

Defined in: src/typescript/lib/core/Aria.ts:70

Parameters

component

Component

The component this helper manages ARIA state for.

Returns

Aria

Methods

applyToElement()

ts
applyToElement(element: HTMLElement): void

Defined 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()

ts
getActiveDescendant(): null | string

Defined 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()

ts
getAutoComplete(): null | string

Defined 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()

ts
getColCount(): null | number

Defined 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()

ts
getColIndex(): null | number

Defined 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()

ts
getControls(): null | string

Defined 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()

ts
getDisabled(): null | boolean

Defined 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()

ts
getExpanded(): null | boolean

Defined 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()

ts
getHasPopup(): null | string

Defined 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()

ts
getHidden(): null | boolean

Defined 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()

ts
getLabel(): null | string

Defined 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()

ts
getLabelledBy(): null | string

Defined 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()

ts
getLevel(): null | number

Defined 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()

ts
getPosInSet(): null | number

Defined 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()

ts
getPressed(): null | boolean

Defined 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()

ts
getRole(): null | AriaRole

Defined 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()

ts
getRowCount(): null | number

Defined 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()

ts
getRowIndex(): null | number

Defined 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()

ts
getSelected(): null | boolean

Defined 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()

ts
getSetSize(): null | number

Defined 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()

ts
getSort(): null | AriaSort

Defined 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()

ts
getTabIndex(): null | number

Defined 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()

ts
getValueMax(): null | number

Defined 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()

ts
getValueMin(): null | number

Defined 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()

ts
getValueNow(): null | number

Defined 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()

ts
setActiveDescendant(id: string): this

Defined 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()

ts
setAutoComplete(value: "inline" | "none" | "both" | "list"): this

Defined 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()

ts
setColCount(value: number): this

Defined 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()

ts
setColIndex(value: number): this

Defined 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()

ts
setControls(id: string): this

Defined 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()

ts
setDisabled(value: boolean): this

Defined in: src/typescript/lib/core/Aria.ts:495

Sets aria-disabled.

Parameters

value

boolean

Whether the element is disabled.

Returns

this


setExpanded()

ts
setExpanded(value: null | boolean): this

Defined 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()

ts
setHasPopup(value: "false" | "true" | "grid" | "dialog" | "menu" | "tree" | "listbox"): this

Defined 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()

ts
setHidden(value: boolean): this

Defined 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()

ts
setLabel(value: string): this

Defined 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()

ts
setLabelledBy(id: string): this

Defined 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()

ts
setLevel(value: number): this

Defined 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()

ts
setPosInSet(value: number): this

Defined 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()

ts
setPressed(value: boolean): this

Defined 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()

ts
setRole(role: AriaRole): this

Defined in: src/typescript/lib/core/Aria.ts:79

Sets the WAI-ARIA role attribute.

Parameters

role

AriaRole

The ARIA role to assign.

Returns

this


setRowCount()

ts
setRowCount(value: number): this

Defined 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()

ts
setRowIndex(value: number): this

Defined 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()

ts
setSelected(value: boolean): this

Defined in: src/typescript/lib/core/Aria.ts:141

Sets aria-selected.

Parameters

value

boolean

Whether the element is selected.

Returns

this


setSetSize()

ts
setSetSize(value: number): this

Defined 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()

ts
setSort(value: AriaSort): this

Defined in: src/typescript/lib/core/Aria.ts:121

Sets aria-sort on a column header.

Parameters

value

AriaSort

The sort direction.

Returns

this


setTabIndex()

ts
setTabIndex(value: null | number): this

Defined 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()

ts
setValueMax(value: null | number): this

Defined 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()

ts
setValueMin(value: null | number): this

Defined 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()

ts
setValueNow(value: number): this

Defined 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