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

react-select-quick-score

v0.0.5

Published

Supercharge react-select with QuickScore's smart autocomplete.

Downloads

6

Readme

react-select + quick-score

react-select-quick-score adds smart autocomplete to react-select using QuickScore.

Instead of the limited type-ahead available in react-select components, where the user has to type an exact substring to match a menu item, QuickScore lets users type just a few letters to quickly display a list of sensible results, sorted by how well the query matches. See a demo

QuickScore is fast, dependency-free, and is just 2KB when minified and gzipped, so it adds only a little weight to react-select.

Install

npm install react-select-quick-score

The project must also include react-select v5 and React v16.8 or later.

Usage

To create a select element with smart autocomplete, import the SelectQS component from the package:

import React from 'react';
import { SelectQS } from 'react-select-quick-score';

const options = [
  { value: 'chocolate', label: 'Chocolate' },
  { value: 'strawberry', label: 'Strawberry' },
  { value: 'vanilla', label: 'Vanilla' }
];

const MyComponent = () => (
  <SelectQS options={options} />
);

SelectQS is a drop-in replacement for Select from react-select, and it supports all of the same props. The difference comes when the user starts typing to find an item in the menu.

Unlike the default react-select behavior, the SelectQS items are sorted by how well they match the user's query, making it easier to find the desired item. The query also doesn't have to be an exact substring of an item. Matches against capital letters and the beginnings of words score higher, so the user could type gh, for example, to match items that include GitHub. That query would not match the same items in the Select element.

If the select options are organized into groups, each group is sorted and filtered independently, separated by the group labels. Groups with no matching items are hidden.

Differences with react-select

When the query is empty, QuickScore sorts its list of items alphabetically and case-insensitively. So the options displayed in a SelectQS component will be listed alphabetically by default, regardless of their order in the options prop.

The filterOption prop is ignored, since QuickScore manages the sorting and filtering of options.

If the options list includes both grouped and ungrouped items (which is not a typical use case), the ungrouped items will all appear before the first group, regardless of where they appear in the options prop. This is done so the ungrouped options can be filtered and sorted together. (In the default Select component, ungrouped options can appear between or after grouped ones.)

License

MIT © John Dunning