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

omega-react-js-search

v0.3.0

Published

Really simple search component, plug and play where you define two callbacks that are triggered when the search text has changed or when the user clicks on the search button. It will trigger back the defined function with the typed String as param so you

Downloads

4

Readme

npm npm npm

React-js-search

React JS Search

Description

Really simple search component, plug and play where you define two callbacks that are triggered when the search text has changed or when the user clicks on the search button. It will trigger back the defined function with the typed String and found objects (optional) as param so you can filter a table, call your backend, etc.

How it looks

alt text

How to thank me? Just click on ⭐️ button :)

Installation

Install it from npm and include it in your React build process (using Webpack, Browserify, etc).

npm i react-js-search

Usage

Import SearchBar in your react component.

import SearchBar from 'react-js-search';

You can pass an array of objects where you want to look data for, for instance:

[ 
  {number: 12, name:"Buffon", position: "ST", success: true},
  {number: 21, name: "Pirlo", position: "MC", success: false},
  {number: 10, name: "Ruiz", position: "MDI"},
  {number: 7, name: "Nesta", position: "RB", success: true},
  {number: 4, name: "Cannavaro", position: "CB"},
  {number: 2, name: "Puyol", position: "CB", success: false},
  {number: 15, name: "Abate", position: "LB"},
  {number: 16, name: "Locatelli", position: "MDI"},
  {number: 1, name: "Buffon", position: "GK"},
  {number: 21, name: "Pirlo", position: "MC"},
  {number: 10, name: "Ruiz", position: "MDI"},
  {number: 7, name: "Nesta", position: "RB"}
]

When the user do a search of a term the string typed will be used as haystack and data passed as prop will be used for the search. The search will be done looking at all values in object and will return the term search used and an array of objects that had a hit.

For example:

<SearchBar 
	onSearchTextChange={ (term,hits) => {this.onSearchChange(term,hits)}}
	onSearchButtonClick={this.onSearchClick}
	placeHolderText={"Search here..."}
data={this.state.dataObjects}
/>

Props

| Name | Type | Mandatory | Description | ------------- |:-------------:| -----:|:-----| | onSearchTextChange | function | Y | Function to call back when the input text change | | onSearchButtonClick | function | Y| Function to call back when the search button is pressed | | placeholder | String |N | Default: 'Search...', Place holder text for the textfield | | data | object[] |N| An array of objects that will be used to search stuff (if not passed, function will trigger back the term searched)| | caseInsensitive | boolean |N| do searches without casing| | keys | string[] | Y | keys of object which include in search

What's new

Next

  • Ability to pass icon as prop
  • Customizable style
  • Default style updates

v0.3.0

  • Libraries updated
  • Overall package size optimized
  • Search icon updated

v0.2.4

  • New case insensitve search

v0.2.1

  • Search CSS isolation

v0.2.0

  • Search bar searches through an array of objects and returns the ones that were found.