Skip to main content

API Reference

Complete reference of everything exported from the tabster package root (import { ... } from "tabster"), grouped by category. For guided walkthroughs, prefer Getting Started and the feature pages linked throughout.

Lifecycle functions

ExportSignatureDescription
createTabster(win: Window, props?: Types.TabsterCoreProps) => Types.TabsterCreates (or attaches an additional handle to) the Tabster instance for win. See Core.
disposeTabster(tabster: Types.Tabster, allInstances?: boolean) => voidReleases a handle from createTabster().
getTabster(win: Window) => Types.Tabster | nullReturns the existing instance for win, without creating one.
forceCleanup(tabster: Types.Tabster) => voidAsynchronously forgets memorized focus history; use after tearing down the whole app DOM.
makeNoOp(tabster: Types.Tabster, noop: boolean) => voidSwitches a live instance in/out of no-op mode.
isNoOp(tabster: Types.TabsterCore) => booleanReports whether an instance is currently in no-op mode. Takes tabster.core, not the Tabster handle.
getInternal(tabster: Types.Tabster) => Types.InternalAPIAdvanced: returns { stopObserver(), resumeObserver(syncState) } to pause/resume Tabster's DOM mutation observer.
getShadowDOMAPI() => Types.DOMAPIReturns the Shadow-DOM-aware DOMAPI implementation; pass it as createTabster(win, { DOMAPI: getShadowDOMAPI() }). See Shadow DOM.

See Core for narrative documentation and the full TabsterCoreProps table.

Feature accessors (get*)

Each of these lazily creates its feature's API the first time it's called for a given Tabster instance, and enables the matching data-tabster key.

ExportSignatureEnablesDocs
getMover(tabster: Types.Tabster) => Types.MoverAPImoverMover
getGroupper(tabster: Types.Tabster) => Types.GroupperAPIgroupperGroupper
getDeloser(tabster: Types.Tabster) => Types.DeloserAPIdeloserDeloser
getModalizer(tabster: Types.Tabster, alwaysAccessibleSelector?: string, accessibleCheck?: Types.ModalizerElementAccessibleCheck) => Types.ModalizerAPImodalizerModalizer
getRestorer(tabster: Types.Tabster) => Types.RestorerAPIrestorerRestorer
getOutline(tabster: Types.Tabster) => Types.OutlineAPIoutline (call .setup() too)Outline
getObservedElement(tabster: Types.Tabster) => Types.ObservedElementAPIobservedObserved Element
getCrossOrigin(tabster: Types.Tabster) => Types.CrossOriginAPI— (cross-iframe wiring, call .setup() too)Cross-Origin

getModalizer's second parameter, alwaysAccessibleSelector, is deprecated in favor of the third, accessibleCheck. getCrossOrigin() transitively calls getDeloser, getModalizer, getMover, getGroupper, getOutline, and getObservedElement for you.

getDummyInputContainer

function getDummyInputContainer(
element: HTMLElement | null | undefined
): HTMLElement | null;

Given a DOM node, returns the Mover/Groupper/Modalizer/Root container it belongs to if the node is one of Tabster's invisible dummy inputs, or null otherwise. Mostly useful for tests/tooling that need to recognize (and usually ignore) these implementation-detail nodes — see How it works.

Attribute helpers

ExportSignatureDescription
getTabsterAttribute(props: Types.TabsterAttributeProps, plain?: true) => Types.TabsterDOMAttribute | stringBuilds the data-tabster attribute value.
setTabsterAttribute(element: HTMLElement, newProps: Types.TabsterAttributeProps, update?: boolean) => voidSets/updates data-tabster on an existing element.
mergeTabsterProps(props: Types.TabsterAttributeProps, newProps: Types.TabsterAttributeProps) => voidMerges one attribute-props object into another in place.

See Attribute Helpers for full documentation and examples.

Constants

Every constant below is a plain { Name: number } object (not a TypeScript enum), exported both as the value and, in the Types namespace, as the corresponding union type (e.g. the value MoverDirections and the type Types.MoverDirection).

ExportMembers
TABSTER_ATTRIBUTE_NAME"data-tabster" (string constant, not an object)
TABSTER_DUMMY_INPUT_ATTRIBUTE_NAME"data-tabster-dummy" (string constant)
FOCUSABLE_SELECTORThe CSS selector Tabster uses to find natively-focusable elements (string constant)
AsyncFocusSourcesEscapeGroupper, Restorer, Deloser
ObservedElementAccessibilitiesAny, Accessible, Focusable
ObservedElementRequestStatusesWaiting, Succeeded, Canceled, TimedOut
ObservedElementFailureReasonsCanceledFocusChange, TimeoutElementNotInDOM, TimeoutElementNotAccessible, TimeoutElementNotFocusable, TimeoutElementNotReady, SupersededByNewRequest, FocusCallFailed
RestoreFocusOrdersHistory, DeloserDefault, RootDefault, DeloserFirst, RootFirst
DeloserStrategiesAuto, Manual
VisibilitiesInvisible, PartiallyVisible, Visible
RestorerTypesSource, Target
MoverDirectionsBoth, Vertical, Horizontal, Grid, GridLinear
MoverKeysArrowUp, ArrowDown, ArrowLeft, ArrowRight, PageUp, PageDown, Home, End
GroupperTabbabilitiesUnlimited, Limited, LimitedTrapFocus
GroupperMoveFocusActionsEnter, Escape
SysDummyInputsPositionsAuto, Inside, Outside

Related feature pages document what each member means in context: Observed Element, Deloser, Restorer, Mover, Groupper.

Events

All event name constants and event classes are exported from the package root — see Events for the full table of names, classes, detail shapes, and usage examples. Quick index:

  • Core: TabsterFocusInEventName/TabsterFocusInEvent, TabsterFocusOutEventName/TabsterFocusOutEvent, TabsterMoveFocusEventName/TabsterMoveFocusEvent.
  • Mover: MoverStateEventName/MoverStateEvent, MoverMoveFocusEventName/MoverMoveFocusEvent, MoverMemorizedElementEventName/MoverMemorizedElementEvent.
  • Groupper: GroupperMoveFocusEventName/GroupperMoveFocusEvent.
  • Modalizer: ModalizerActiveEventName/ModalizerActiveEvent, ModalizerInactiveEventName/ModalizerInactiveEvent, ModalizerFocusInEventName, ModalizerFocusOutEventName (reserved name constants only — not currently dispatched, no event class exists).
  • Deloser: DeloserFocusLostEventName/DeloserFocusLostEvent, DeloserRestoreFocusEventName/DeloserRestoreFocusEvent.
  • Restorer: RestorerRestoreFocusEventName/RestorerRestoreFocusEvent.
  • Root: RootFocusEventName/RootFocusEvent, RootBlurEventName/RootBlurEvent.
  • Base class: TabsterCustomEvent<D> (abstract, extended by all of the above).

Types namespace

import type { Types } from "tabster";

A namespace holding every TypeScript type Tabster's API surface uses — props interfaces (MoverProps, GroupperProps, ModalizerProps, DeloserProps, RestorerProps, OutlineProps, ObservedElementProps, UncontrolledProps, FocusableProps, RootProps, SysProps, TabsterAttributeProps), API interfaces (Tabster, TabsterCore, MoverAPI, GroupperAPI, ModalizerAPI, DeloserAPI, RestorerAPI, OutlineAPI, ObservedElementAPI, CrossOriginAPI, FocusableAPI, UncontrolledAPI, FocusedElementState, KeyboardNavigationState), the find*() options types (FindFirstProps, FindNextProps, FindAllProps, FindFocusableOutputProps, ...), and the type aliases derived from each constant object above (e.g. Types.MoverDirection for the MoverDirections values). These members are TypeScript types and are erased from emitted application code; use the package-root constants for runtime values.

The Tabster instance's uncontrolled member and its isUncontrolledCompletely() method are documented in the Uncontrolled guide.

EventsTypes namespace

import type { EventsTypes } from "tabster";

Compile-time-only detail-payload types for the events documented on the Events page: TabsterMoveFocusEventDetail, MoverMoveFocusEventDetail, MoverMemorizedElementEventDetail, GroupperMoveFocusEventDetail, ModalizerEventDetail, RootFocusEventDetail.

Deprecated exports

ExportUse instead
dispatchMoverMoveFocusEvent(target, key)target.dispatchEvent(new MoverMoveFocusEvent({ key }))
dispatchMoverMemorizedElementEvent(target, el)target.dispatchEvent(new MoverMemorizedElementEvent({ memorizedElement: el }))
dispatchGroupperMoveFocusEvent(target, action)target.dispatchEvent(new GroupperMoveFocusEvent({ action }))
TabsterCoreProps.checkUncontrolledTrappingFocusTabsterCoreProps.checkUncontrolledCompletely
getModalizer(tabster, alwaysAccessibleSelector)getModalizer(tabster, undefined, accessibleCheck)
TabsterCustomEvent.detailsevent.detail (standard CustomEvent property)

See Events for the dispatch-helper equivalents in context.