All Projects → sickdyd → react-search-autocomplete

sickdyd / react-search-autocomplete

Licence: MIT license
A search box that filters the provided array of objects

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-search-autocomplete

raptor
A fast and space-efficient pre-filter for querying very large collections of nucleotide sequences.
Stars: ✭ 37 (-75.66%)
Mutual labels:  filter
MacOSX-VFS-redirector
Mac OS X file system filter to redirect file operations
Stars: ✭ 38 (-75%)
Mutual labels:  filter
django-admin-search
Modal filter for django admin
Stars: ✭ 60 (-60.53%)
Mutual labels:  filter
rtss
Relative TimeStamps for Stuff
Stars: ✭ 42 (-72.37%)
Mutual labels:  filter
modjpeg-nginx
NGINX filter module for adding overlays and logos to JPEGs on-the-fly without degrading the quality of the image.
Stars: ✭ 18 (-88.16%)
Mutual labels:  filter
combobox-nav
Attach combobox navigation behavior to <input> or <textarea>.
Stars: ✭ 76 (-50%)
Mutual labels:  autocomplete
Inquirer Autocomplete Prompt
Autocomplete prompt for inquirer
Stars: ✭ 250 (+64.47%)
Mutual labels:  autocomplete
vim-stylus
A better vim plugin for stylus, including proper and up-to-date syntax highligting, indentation and autocomplete
Stars: ✭ 49 (-67.76%)
Mutual labels:  autocomplete
svelte-mapbox
MapBox Map and Autocomplete components for Svelte (or Vanilla JS)
Stars: ✭ 267 (+75.66%)
Mutual labels:  autocomplete
sparkar-pixelate-shader
simple script-only pixelate shader with Facebook SparkAR.
Stars: ✭ 35 (-76.97%)
Mutual labels:  filter
zsh-yarn-completions
Yarn completions for Z-shell that supports yarn workspaces
Stars: ✭ 35 (-76.97%)
Mutual labels:  autocomplete
amino-bot
Bot for aminoapps.com
Stars: ✭ 21 (-86.18%)
Mutual labels:  filter
porn-domains
A collection of domains used for explicit adult content like porn websites.
Stars: ✭ 97 (-36.18%)
Mutual labels:  filter
AdBlock-Acceleration
Accelerated subscription for international/China region ad filtering rules(国际/中国地区广告过滤规则的加速订阅)
Stars: ✭ 327 (+115.13%)
Mutual labels:  filter
esa-httpclient
An asynchronous event-driven HTTP client based on netty.
Stars: ✭ 82 (-46.05%)
Mutual labels:  filter
S2s
Coding time Compile. A tool to write code fastest.
Stars: ✭ 254 (+67.11%)
Mutual labels:  autocomplete
Elements-of-Functional-Programming-in-Python
Learn how to how to use the lambda, map, filter and reduce functions in Python to transform data structures.
Stars: ✭ 14 (-90.79%)
Mutual labels:  filter
scotty
java proxy
Stars: ✭ 44 (-71.05%)
Mutual labels:  filter
MedianFilter
A fast one-dimensional median filter algorithm
Stars: ✭ 43 (-71.71%)
Mutual labels:  filter
vembrane
vembrane filters VCF records using python expressions
Stars: ✭ 46 (-69.74%)
Mutual labels:  filter

travis

<ReactSearchAutocomplete>

A <ReactSearchAutocomplete> is a fully customizable search box where the user can type text and filter the results. It relies on Fuse.js v6.5.3 for the fuzzy search. Check out their website to see the options (you can pass them to this component).

Click here to see a demo.

Demo source.

Installing

$ npm install react-search-autocomplete
or
$ yarn add react-search-autocomplete

Exports

The default export is <ReactSearchAutocomplete>. To use it:

import { ReactSearchAutocomplete } from 'react-search-autocomplete'

React Search Autocomplete Usage

import React from 'react'
import './App.css'
import { ReactSearchAutocomplete } from 'react-search-autocomplete'

function App() {
  // note: the id field is mandatory
  const items = [
    {
      id: 0,
      name: 'Cobol'
    },
    {
      id: 1,
      name: 'JavaScript'
    },
    {
      id: 2,
      name: 'Basic'
    },
    {
      id: 3,
      name: 'PHP'
    },
    {
      id: 4,
      name: 'Java'
    }
  ]

  const handleOnSearch = (string, results) => {
    // onSearch will have as the first callback parameter
    // the string searched and for the second the results.
    console.log(string, results)
  }

  const handleOnHover = (result) => {
    // the item hovered
    console.log(result)
  }

  const handleOnSelect = (item) => {
    // the item selected
    console.log(item)
  }

  const handleOnFocus = () => {
    console.log('Focused')
  }

  const formatResult = (item) => {
    return (
      <>
        <span style={{ display: 'block', textAlign: 'left' }}>id: {item.id}</span>
        <span style={{ display: 'block', textAlign: 'left' }}>name: {item.name}</span>
      </>
    )
  }

  return (
    <div className="App">
      <header className="App-header">
        <div style={{ width: 400 }}>
          <ReactSearchAutocomplete
            items={items}
            onSearch={handleOnSearch}
            onHover={handleOnHover}
            onSelect={handleOnSelect}
            onFocus={handleOnFocus}
            autoFocus
            formatResult={formatResult}
          />
        </div>
      </header>
    </div>
  )
}

export default App

With TypeScript

  type Item = {
    id: number;
    name: string;
  }

  <ReactSearchAutocomplete<Item> ... />

<ReactSearchAutocomplete> Props:

{
  items,
  // The list of items that can be filtered, it can be an array of
  // any type of object. Note: the id field is mandatory.
  // By default the search will be done on the
  // property "name", to change this behaviour, change the `fuseOptions`
  // prop. Remember that the component uses the key "name" in your
  // items list to display the result. If your list of items does not
  // have a "name" key, use `resultStringKeyName` to tell what key
  // (string) to use to display in the results.
  fuseOptions,
  // To know more about fuse params, visit https://fusejs.io/
  //
  // By default set to:
  // {
  //   shouldSort: true,
  //   threshold: 0.6,
  //   location: 0,
  //   distance: 100,
  //   maxPatternLength: 32,
  //   minMatchCharLength: 1,
  //   keys: [
  //     "name",
  //   ]
  // }
  //
  // `keys` represent the keys in `items` where the search will be
  // performed.
  //
  // Imagine for example that I want to search in `items` by `title`
  // and `description` in the following items, and display the `title`;
  // this is how to do it:
  //
  //   const items = [
  //     {
  //       id: 0,
  //       title: 'Titanic',
  //       description: 'A movie about love'
  //     },
  //     {
  //       id: 1,
  //       title: 'Dead Poets Society',
  //       description: 'A movie about poetry and the meaning of life'
  //     }
  //   ]
  //
  // I can pass the fuseOptions prop as follows:
  //
  //   <ReactSearchAutocomplete
  //     items={items}
  //     fuseOptions={{ keys: ["title", "description"] }}
  //     // necessary, otherwise the results will be blank
  //     resultStringKeyName="title"
  //   />
  //
  resultStringKeyName,
  // The key in `items` that contains the string to display in the
  // results
  inputSearchString,
  // By changing this prop, you can manually set the search string.
  inputDebounce,
  // Default value: 200. When the user is typing, before
  // calling onSearch wait this amount of ms.
  onSearch,
  // The callback function called when the user is searching
  onHover,
  // THe callback function called when the user hovers a result
  onSelect,
  // The callback function called when the user selects an item
  // from the filtered list.
  onFocus,
  // The callback function called when the user focuses the input.
  onClear,
  // The callback called when the user clears the input box by clicking
  // on the clear icon.
  showIcon,
  // Default value: true. If set to false, the icon is hidden.
  showClear,
  // Default value: true. If set to false, the clear icon is hidden.
  maxResults,
  // Default value: 10. The max number of results to show at once.
  placeholder,
  // Default value: "". The placeholder of the search box.
  autoFocus,
  // Default value: false. If set to true, automatically
  // set focus on the input.
  styling,
  // The styling prop allows you to customize the
  // look of the searchbox
  // Default values:
  // {
  //   height: "44px",
  //   border: "1px solid #dfe1e5",
  //   borderRadius: "24px",
  //   backgroundColor: "white",
  //   boxShadow: "rgba(32, 33, 36, 0.28) 0px 1px 6px 0px",
  //   hoverBackgroundColor: "#eee",
  //   color: "#212121",
  //   fontSize: "16px",
  //   fontFamily: "Arial",
  //   iconColor: "grey",
  //   lineColor: "rgb(232, 234, 237)",
  //   placeholderColor: "grey",
  //   clearIconMargin: '3px 14px 0 0',
  //   searchIconMargin: '0 0 0 16px'
  // };
  //
  // For example, if you want to change the background
  // color you can pass it in the props:
  // styling={
  //   {
  //     backgroundColor: "black"
  //   }
  // }
  formatResult,
  // The callback function used to format how the results are displayed.
  showNoResults,
  // Optional, default value: true, it will display "No results" or showNoResultsText
  // if no results are found
  showNoResultsText,
  // Optional, default value: "No results", the text to display when no results
  // are found,
  showItemsOnFocus,
  // Optional, default value: false, it will automatically show N (maxResults) number of items
  // when focusing the input element
}

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].