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

pentonville

v1.0.518

Published

Pentonville

Downloads

295

Readme

Pentonville

A React component for capturing tab and managing focus events.

<Pentonville>
  <form>
    <input name='one' />
    <input name='two' />
  </form>
</Pentonville>

Once focus enters Pentonville it cannot leave.

On tab flow and focus

Every <form /> input element has an implicit tab index which enables them to accept focus, and be tabbed between, from one to another, in the order they appear in the document. The value of the implicit tab index is 0.

Some other HTML elements can be made to accept focus with an explicit tab index of the same value.

<p tabindex="0">
  This paragraph can accept focus.
</p>

In React the attribute is in camel case but is otherwise the same.

<p tabIndex='0'>
  This paragraph can accept focus.
</p>

(You didn't need a nearly identical second example, but there it is.)

An element can also be given an explicit negative tab index of -1 (to remove it from the tab flow), or an explicit positive tab index of 1 or more (to change its position in the tab flow).

Positive tab indexes are tabbed to in sequence, from the lowest to the highest value, regardless of their order in the document. After reaching the highest value, flow returns to the elements with a zero index, whether implicit and explicit, such that they are tabbed to in sequence, according to their order in the document.

Introducing Pentonville

Sometimes it is desirable to prevent tab flow and focus from moving beyond the boundary of a set of HTML elements. Pentonville is that boundary: once focus has entered, it won't escape.

Tab flow is maintained by moving focus through the order of each element's tab index, from the first to the last, when tab flow is returned to the first element again.

Focus can be put on any element in the sequence, in which case it will proceed according to the tab index. In other words: focus can be put onto an element with a tab index value of 3 and have the next element in the tab flow be the element with a tab index of 4, then 5 and so on, until the positive tab index values have been exhausted and flow proceeds through each element with a tab index of 0, then onto 1 and 2 and back to 3 again.

Focus cannot be put onto any other element. Pentonville won't permit it. Focus will be maintained on whichever element within Pentonville currently has it.

Demonstrating Pentonville

Example Storybooks are available on GitHub.

Clone the repository, then:

npm install
npm run storybook

And with your preferred browser visit http://localhost:6006.

(The Storybooks are not meant to be visually pleasing: they are examples only of the component's behaviour.)