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

select-typeahead

v0.8.0

Published

A configurable, super simple and extremely fast typeahead solution for `<select>` elements.

Downloads

12

Readme

select-typeahead

A configurable, super simple and extremely fast typeahead solution for <select> elements.

Features:

  • Configurable
  • Extremely fast
  • Normalizes strings so you don't have to query with special characters (ex: strøm is the same as strom)
  • Works with form tab-ing
  • Written for IE9+
  • Vanilla JS

Demo: https://andersevenrud.github.io/projects/select-typeahead/examples/index.html

Options:

{String|Node}   el                        The <SELECT> to use
{Object}        [opts]                    Options
{Object}        [opts.data]               A key/value paired object instead of select data
{Function}      [opts.fnDataFilter]       A function that filters the dropdown values
{Function}      [opts.fnInputFilter]      A function that filters the input value
{Function}      [opts.fnMatch]            A function that performs A->B matching
{Number}        [opts.keyTimeout=100]     A timeout for key presses
{String}        [opts.buttonLabel='>']    A label for the button
{Array|String}  [opts.className]          A className to give the instance (or array)
{Boolean}       [opts.calcWidth=true]     Set the width of the widget
{Boolean}       [opts.autoSelect=false]   Automatically select the "best" result
{String}        [opts.placeholder=true]   Placeholder string (or true for autodetect)

Usage:

// Create with vanilla

SelectTypeahead(el, {});

// Create with jQuery

$('el').SelectTypeahead({});

// Methods:

.setSelectedIndex(idx)

.setSelectedValue(val)

.getSelectedIndex()

.getSelectedValue()

.focus()

.blur()

.destroy()

// Options:

fnDataFilter: function(str) {
  return str;
}
fnInputFilter: function(str) {
  return str;
}
fnMatch: function(input, entry) {
  return entry.indexOf(input) !== -1;
}

Installation

Use the included files in dist/.

Available via npm.

Changelog

  • 0.8.0 - Now bundled
  • 0.7.3 - Added 'tabSelect' option
  • 0.7.2 - Added '_update' event for refreshing current selection
  • 0.7.1 - If using placeholder ignore empty default value
  • 0.7.0 - Updated some external triggers
  • 0.6.9 - Added 'selected' event and 'setSelectedIndex' trigger
  • 0.6.8 - Added placeholder support
  • 0.6.7 - Fixed usage with string values/keys
  • 0.6.6 - Updated locale scrubbing
  • 0.6.5 - Cleanup of scoring in most significant behaviour
  • 0.6.4 - Changed behaviour in most significant selector
  • 0.6.3 - Better matching of multiple words
  • 0.6.2 - Prevent raising error on backspace when input is empty
  • 0.6.1 - Better autoSelect
  • 0.6.0 - Added blocking of autocomplete etc.
  • 0.5.9 - Added autoSelect parameter
  • 0.5.8 - Better scrollIntoView behaviour
  • 0.5.7 - Fixed filter not working when no initial value is selected
  • 0.5.6 - Close dropdown when open and click button
  • 0.5.5 - Updated removeLocale() and CSS
  • 0.5.4 - Bugfixes
  • 0.5.3 - Bugfixes
  • 0.5.2 - Added module export support
  • 0.5.1 - Fixed normalized text showing up in input
  • 0.5.0 - Initial release