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

search-select-react

v1.0.3

Published

A React component that accepts data Array of Objects and headers to search on multiple conditions and perform actions on select using click and keyboard events

Downloads

505

Readme

search-select-react

A React component that accepts data Array of Objects and headers to search on multiple conditions and perform actions on select using click and keyboard events

Installation

npm install search-select-react
yarn add search-select-react

Usage

import React from 'react';
import {SearchSelect} from 'search-select-react';

const data = [
                {
                id: 1,
                name: 'John Doe',
                email: '[email protected]',
                phone: '1234567890',
              },
              {
                id: 2,
                name: 'Jane Doe',
                email: '[email protected]',
                phone: '0987654321',
              },
];

const searchBy = ['name', 'email', 'phone'];

const display = ['name', 'email'];

const onSelectAction = (selected) => {
  console.log(selected);
};

const onNoResultAction = () => {
  console.log('No result found');
};

const App = () => {
  return (
    <div>
      <SearchSelect
        data={data}
        search={searchBy}
        display={display}
        select={onSelectAction}
        noResults={onNoResultAction}
        noResultsText='No Results Found! Click to Add New.'
        placeholder='Search'
        label='Search'
        name={'search'}
        helperText='Search for a user'
      />
    </div>
  );
};

export default App;

Styling

The component by default has no styling. You can style it using your own CSS or any css library like tailwindcss using the different class props available.

List of styling class props

| Prop Name | Description | Default | Notes | | --- | --- | --- | --- | | wrapperClass | Class for the wrapper div | '' | | | labelClass | Class for the label | '' | | | inputClass | Class for the input | '' | | | helperTextClass | Class for the helper text | '' | | | resultContainerClass | Class for the result container | '' | | | resultItemClass | Class for the result item | '' | | | resultItemActiveClass | Class for the active result item | '' | Active State should be handled in the CSS | | resultItemHoverClass | Class for the hovered result item | '' | Hover State should be handled in the CSS |

All Props

| Prop Name | Type | Description | Required | Default | | --- | --- | --- | --- | --- | | data | Array | Array of Objects to search on | Yes | [ ] | | search | Array | Array of keys to search on | Yes | [ ] | | display | Array | Array of keys to display in the list | Yes | [ ] | | select | Function | Function to perform on select | Yes | () => {} | | noResults | Function | Function to perform on no results | No | () => {} | | noResultsText | String | Text to display on no results | No | 'No Results Found! Click to Add New' | | placeholder | String | Placeholder for the input | No | --- | | label | String | Label for the input | No | --- | | showLabel | Boolean | Show label for the input | No | true | | name | String | Name for the input | No | --- | | helperText | String | Helper text for the input | No | --- | | showHelperText | Boolean | Show helper text | No | true | | disabled | Boolean | Disable the input | No | false | | required | Boolean | Make the input required | No | false | | readOnly | Boolean | Make the input read only | No | false | | wrapperClass | String | Class for the wrapper | No | --- | | labelClass | String | Class for the label | No | --- | | inputClass | String | Class for the input | No | --- | | helperTextClass | String | Class for the helper text | No | --- | | resultContainerClass | String | Class for the result container | No | --- | | resultItemClass | String | Class for the result item | No | --- | | resultItemActiveClass | String | Class for the active result item | No | --- | | resultItemHoverClass | String | Class for the hover result item | No | --- | | enterToSelect | Boolean | Select on enter key press | No | false | | onChange | Function | Function to perform on change in the input box | No | () => {} | | ...props | --- | Props for the input | No | --- |

License

MIT © trehansangpriya

Author

👤 Trehan Sangpriya

Website LinkedIn Twitter GitHub

Show your support

Give a ⭐️ if this project helped you!