npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aria-voyager

v0.0.4

Published

A framework agnostic / universal package that implements navigation patterns for various aria roles and features

Downloads

1,459

Readme

aria-voyager

Test Coverage Maintainability

Canoe vessel that navigates your aria.

A framework agnostic / universal package that implements navigation patterns for various aria roles and features.

BYOM: Bring Your Own Markup

... and this library will make it interactive, according to applicable ARIA patterns. This library does not apply styling, it will operate on the accessibility tree.

Supported Features

See hokulea/aria-voyager for a full list of supported features.

Installation

pnpm add aria-voyager

Usage

Controls

Listbox

Bring your own markup in at first, here is an example markup for a list:

<ul role="listbox">
  <li role="option">Banana</li>
  <li role="option" aria-selected="true">Apple</li>
  <li role="option">Mango</li>
</ul>

To make it interactive, create a new Listbox instance pointing it at your element.

import { Listbox } from 'aria-voyager';

const listElement = document.querySelector('[role="listbox"]');
new Listbox(listElement);

That is already enough to start making your listbox interactive. It will read the options from the provided HTML.

Listbox accepts options as second parameter:

import type { EmitStrategy, UpdateStrategy } from 'aria-voyager';

interface ListboxOptions {
  updater?: UpdateStrategy;
  emitter?: EmitStrategy;
}

See updater and emitter.

Menu

Bring your own markup in at first, here is an example markup for a menu:

<div role="menu">
  <button role="menuitem">Version Info</button>
  <a role="menuitem" href="https://github.com/hokulea/aria-voyager" target="_blank">Github</a>
  <button role="menuitem" popovertarget="authormenu">Author</button>
  <div role="menu" id="authormenu" popover>
    <a role="menuitem" href="https://gos.si" target="_blank">Homepage</a>
    <a role="menuitem" href="https://github.com" target="_blank">Github</a>
  </div>
</div>

To make it interactive, create a new Menu instance pointing it at your element.

import { Menu } from 'aria-voyager';

const menuElement = document.querySelector('[role="menu"]');
new Menu(menuElement);

Menu accepts options as second parameter:

import type { EmitStrategy, UpdateStrategy } from 'aria-voyager';

interface MenuOptions {
  updater?: UpdateStrategy;
  emitter?: EmitStrategy;
}

See updater and emitter.

Strategies

aria-voyager supports the concept of input (updater) and output (emitter) through exchangeable strategies.

Updater

The job of an updater is to tell the controls, when new updates are available, such as selection has changed, new elements were added or existing ones removed from the DOM.

By default, aria-voyager uses the DOMOberserverUpdateStrategy which - as the name suggests - observes the DOM for changes. So the controls stay updated from your changes to the DOM.

That might be inefficient given different rendering strategies in the various frontend frameworks flush changes more frequent than what seems the right dosis for such a DOMObserver.

To optimize this, there is a blank ReactiveUpdateStrategy, which you can extend to write a framework integration. With that you can hook into the reactivity system of your framework and tell aria-voyager when updates are available.

Emitter

Controls are interactive elements, so you also want to know when things are happening to react on user interactions.

Emitters are the way to receive those events. aria-voyager ships with two strategies, that emit changes:

  1. IndexEmitStrategy which tells you the indexes of the elements, based on the index of an elements amongst its children in the DOM.

  2. ItemEmitStrategy which tells you which elements are changed.

Both are suited to write a framework integration to bridge between DOM and your application code.