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-fuse-picker-fixed

v1.0.0

Published

react-fuse-picker React component (fixed fork)

Downloads

6

Readme

react-fuse-picker

Travis npm package Coveralls license

react-fuse-picker is a ready to use Fuzzy Search (using fuse.js) Picker.

This component was inspired by react-fuzzy-picker

For the fuzzy search part this component uses Fuse.js

If all you need is a straight out of the box solution for fuzzy search, this is a great choice.

Installation

Add react-fuse-picker to your project

yarn add react-fuse-picker

Table of Contents

Usage

Embedded Picker (fixed input)

<FusePicker
    isOpen={true}
    items={yourItems}
    renderItem={item => item.title}
    onChange={item => alert(`Chose: ${item.title}`)}
    fuseOptions={yourfuseOptions}
/>

Callable Picker (using ctrl+s command)

<FuseBox
    isKeyPressed={() => event.keyCode === 83 && event.ctrlKey}
    popup={(isOpen, onClose) => (
        <FusePicker
        isOpen={isOpen}
        onClose={onClose}
        renderItem={item => item.title}
        onChange={item => alert(`Chose: ${item.title}`)}
        items={yourItems}
        fuseOptions={yourFuseOptions}
        />
    )}
/>

Demo

You can also try out the demo

Importing styles

@import "node_modules/react-fuse-picker/umd/main.css";

API

<FusePicker />

<FusePicker /> is the component that controls the picker behaviour

FusePicker props

items: array

The items on which the fuzzy search will be applied.

maxDisplay: integer

The maximum number of results displayed by the picker.

cycleToTop: boolean

If true when the user goes to the last result and navigates further down, it goes back to the first result.

fuseOptions: object

The object containing all Fuse.js configuration. For more info visit Fuse.js

onChange: function

Callback for when the user selects an option. It receives the item as param.

onClose: function

Callback for when the user closes the picker.

renderItem: function

Function that will render each single result item.

renderInfo: function

Function that will render the info/instructions of the picker on top of the input. Create your own and return null if you don't want any info.

itemValue: function

Function that allows you to customize the return value of the picker. By default it returns the whole item (object) but you can customize it if you so desire.

<FuseBox />

<FuseBox /> is the component that will wrap a <FusePicker /> in order to show it on command press.

FuseBox props

isKeyPress: function

Function that will check if the right command was pressed in order to show the picker.

You can define any kind of combination of key events you want.

popup: function

Function in which you must render out your <FusePicker />. Check the demo above to see how!