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

@3m5-de/squirrel-select

v0.1.1

Published

SquirrelSelect - a dropdown library

Downloads

110

Readme

Squirrel Select

Exploding Squirrels

npm version Strict TypeScript Checked

Squirrel Select is a dropdown library.

It will initialize a dropdown for every select element present on the page (or added later) that has the CSS class sqs-dropdown-select. The select element itself receives the classes hidden and sqs-dropdown-select__initialized, to prevent it from being initialized multiple times.

Authors & Sponsors

The development and public-releases are generously sponsored by our employer https://www.3m5.de.

Documentation

Installation

npm install @3m5-de/squirrel-select

Getting Started

WIP

Construction of the dropdown.

<select class="sqs-dropdown__initialized hidden">
  <!-- The initialized element -->
</select>
<div class="sqs-dropdown__wrapper">
  <div class="select" tabindex="0">
    <div class="select__trigger">
      <span>The current selected element</span>
    </div>
    <div class="select__options">
      <span class="select__option selected" tabindex="0" data-value="option1">The current selected element</span>
      <span class="select__option" tabindex="0" data-value="option2">Another elemen</span>
      <span class="select__option" tabindex="0" data-value="option3">A third Element</span>
      <!-- etc. -->
    </div>
  </div>
</div>
  • If the dropdown is open, the element with the CSS class select has received the CSS class open.
  • If the dropdown is disabled, the same element has received the CSS class select__disabled.

CSS Class Assignment

With data attributes on the select element, it's possible to add CSS classes to specific parts of the newly created dropdown. These attributes should be handled like the conventional class attribute (i.e., classes are separated by spaces).

The following data attributes are supported:

- data-sqs-wrapper-classes → <div class="sqs-dropdown__wrapper">
- data-sqs-select-classes → <div class="select">
- data-sqs-select-trigger-classes → <div class="select__trigger">
- data-sqs-select-options-classes → <div class="select__options">

Manual Change of the Selected Option

If a change of the selected element is performed programmatically (e.g., by explicitly setting the value), a change event MUST be dispatched immediately afterward (select.dispatchEvent(new Event('change'));), as otherwise, this change will not be reflected in the dropdown.

Contribution

We will gladly accept contributions. Please send us pull requests.

Version highlights

1.0 - WIP

The initial release includes the following features:

  • Keyboard operability

    • Selecting the dropdown or an option using Tab
    • Opening the dropdown and selecting an option using Enter
    • Closing the dropdown using Esc
    • Selecting an option using arrow keys
    • Searching for an option by typing
  • Activation/Deactivation

  • can be activated or deactivated by setting or removing the disabled attribute on the associated select element

  • Class Assignment

    • it's possible to add classes to specific parts of the newly created dropdown