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

fuzzy-searchbox

v1.1.5

Published

An accessible, screen reader friendly combobox with fuzzy searching

Downloads

51

Readme

fuzzy-searchbox

This component creates an accessible screen-reader-friendly autocomplete combobox with fuzzy searching.

Dev Dependencies:

  • Fuse.js
  • Lodash
  • node-sass
  • Vue

Notes:

  • This component expects a list of objects as input. ('items')
  • A future update should allow items to be a list of strings as well in cases with simpler dropdown options
  • An array of keys needs to be passed in so the component knows what keys to filter on. ('itemKeys')
  • There are two options for specifying the labels for the items
    1. 'itemLabels' can be passed in as an array of keys (just like 'itemKeys'). The label will be the concatenation of the key values. The delimiter can be passed in as 'labelDelimiter', otherwise the default is a single space.
    2. 'createLabelFunction' can be passed in as a function that accepts an item and returns a string label.
  • 'searchByLabel' is an optional flag to use the label string for search instead of using the itemKeys, useful when used with 'createLabelFunction'
    • 'searchByLabelRuleFunction' is an optional parameter that can be passed in as a function that modifies the underlying search string
  • 'preSelectedItem' should be set if there are events that pass an item selection into the FuzzySearchbox module from outside
  • This compenent requires an aria-label to be set
  • Optionally set 'placeholder' as text when the input box is empty
  • Optional: set 'max-items-displayed' to limit the number of search results
  • Optional: set 'show-default-results' to false to prevent the search results box from opening when the input is empty
  • Optional: set 'persist-search' to false reset the search string after the user makes a selection, showing the default results next time they click
  • Optional: set 'show-dropdown-arrow' to true to display an svg arrow at the right of the searchbox
  • Optional: set 'show-dropdown-arrow-sharp' to true to display a pseudo-element with a sharp arrow at the right of the searchbox

#Github

https://github.com/GregOSP/fuzzy-searchbox

#Installation

$ npm i fuzzy-searchbox

#Sample usage

import FuzzySearchbox from fuzzy-searchbox
<FuzzySearchbox
  id="my-select"
  aria-label="select an option"
  placeholder="Type here to search for an option"
  v-model="selectedOption"
  :preSelectedItem="defaultItem"
  @change="optionChanged"
  :items="selectList"
  :item-keys="['name', 'type', 'category']"
  :searchByLabel = "true"
  :searchByLabelRuleFunction = "labelModificationFunction"
  :create-label-function="displayStringForLabel"
  :max-items-displayed = 10
  :show-default-results = "true">
</FuzzySearchbox>