Members

(constant) returnFocusTargetsByTrapId :Map.<(string|symbol), HTMLElement>

Global map of trap ID to element that should receive focus when the trap closes. Used by setReturnFocusTarget, markForFocusLater, and returnFocus.

Type:
  • Map.<(string|symbol), HTMLElement>

Methods

addCurrentToMenuItem(item)

Add the current class and attributes to a menu item.

Parameters:
NameTypeDescription
itemHTMLElement

The menu item to add the current class and attributes to.

Since
  • 4.0.2

buildCacheKey(prefix, paramKeys, params) → {string}

Build a cache key.

Parameters:
NameTypeDescription
prefixstring

The prefix for the cache key.

paramKeysArray

The keys of the parameters to build the cache key.

paramsobject

The parameters to build the cache key.

Since
  • 4.0.2
Returns:

The cache key.

Type: 
string

getReturnFocusTarget(id) → {HTMLElement|undefined}

Returns the element currently stored as the return-focus target for the given trap ID.

Parameters:
NameTypeDescription
idstring | symbol

Focus trap ID.

Since
  • 5.2.1
Returns:

The element to return focus to, or undefined if none is set.

Type: 
HTMLElement | undefined

removeCurrentFromMenuItem(item)

Remove the current class and attributes from a menu item.

Parameters:
NameTypeDescription
itemHTMLElement

The menu item to remove the current class and attributes from.

Since
  • 4.0.2

setReturnFocusTarget(element, id) → {void}

Sets the element to return focus to when the focus trap with the given ID closes. Call from outside the trap to override the default; pass null for element to clear.

Parameters:
NameTypeDescription
elementHTMLElement | null

Element to focus when the trap closes, or null to clear.

idstring | symbol

Focus trap ID (must match the focusTrapId passed to useFocusTrap).

Since
  • 5.2.1
Returns:
Type: 
void

useCache(initialState) → {object}

A hook to manage a cache.

Parameters:
NameTypeDescription
initialStateobject

The initial state of the cache.

Since
  • 4.0.2
Returns:

The cache state and actions.

Type: 
object

useId(defaultId) → {string}

Generates a unique ID if default ID is not provided.

Parameters:
NameTypeDescription
defaultIdstring

The default ID.

Since
  • 3.2.2
Returns:

The ID.

Type: 
string

usePhoneInputFormatUtils(args) → {object}

Custom hook to access the phone input format utils.

Parameters:
NameTypeDescription
argsobject

The arguments.

Properties
NameTypeDescription
onErrorfunction

The function to call when an error occurs.

Since
  • 1.0.0
Returns:

The return value of the hook.

Type: 
object