All Projects → enkidevs → React Search Input

enkidevs / React Search Input

🔍 Simple react.js component for a search input, providing a filter function.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Search Input

Lara Eye
Filter your Query\Builder using a structured query language
Stars: ✭ 39 (-87%)
Mutual labels:  search, filter
Searchobjectgraphql
GraphQL plugin for SearchObject gem
Stars: ✭ 118 (-60.67%)
Mutual labels:  search, filter
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (-79.67%)
Mutual labels:  search, component
Aura.filter
Validate and sanitize arrays and objects.
Stars: ✭ 134 (-55.33%)
Mutual labels:  component, filter
Laravel Api Handler
Package providing helper functions for a Laravel REST-API
Stars: ✭ 150 (-50%)
Mutual labels:  search, filter
Ngx Mat Select Search
Angular component providing an input field for searching / filtering MatSelect options of the Angular Material library.
Stars: ✭ 416 (+38.67%)
Mutual labels:  search, filter
Searchable
Search/filter functionality for Laravel's Eloquent models
Stars: ✭ 113 (-62.33%)
Mutual labels:  search, filter
React Select Search
⚡️ Lightweight select component for React
Stars: ✭ 379 (+26.33%)
Mutual labels:  search, component
Jquery Searchable
Tiny, fast jQuery plugin to search through elements as you type.
Stars: ✭ 142 (-52.67%)
Mutual labels:  search, filter
Ng2 Search Filter
Angular 2 / Angular 4 / Angular 5 custom pipe npm module to make a search filter on any input, 🔥 100K+ downloads
Stars: ✭ 137 (-54.33%)
Mutual labels:  search, filter
Faltu
Search sort, filter, limit an array of objects in Mongo-style.
Stars: ✭ 112 (-62.67%)
Mutual labels:  search, filter
Search
CakePHP: Easy model searching
Stars: ✭ 153 (-49%)
Mutual labels:  search, filter
Holmes
Fast and easy searching inside a page
Stars: ✭ 1,679 (+459.67%)
Mutual labels:  search, filter
Searchobject
Search object DSL
Stars: ✭ 152 (-49.33%)
Mutual labels:  search, filter
Fuzzysort
Fast SublimeText-like fuzzy search for JavaScript.
Stars: ✭ 2,569 (+756.33%)
Mutual labels:  search, filter
Mint Ui
Mobile UI elements for Vue.js
Stars: ✭ 16,471 (+5390.33%)
Mutual labels:  component
React Tabulator
React Tabulator is based on tabulator - a JS table library with many advanced features.
Stars: ✭ 295 (-1.67%)
Mutual labels:  component
Linux Command
Linux命令大全搜索工具,内容包含Linux命令手册、详解、学习、搜集。https://git.io/linux
Stars: ✭ 17,481 (+5727%)
Mutual labels:  search
Angular Filter
Bunch of useful filters for AngularJS (with no external dependencies!)
Stars: ✭ 2,962 (+887.33%)
Mutual labels:  filter
Lock
Creates and manages locks, a mechanism to provide exclusive access to a shared resource.
Stars: ✭ 299 (-0.33%)
Mutual labels:  component

react-search-input

build status npm version Dependency Status devDependency Status

Simple React component for a search input, providing a filter function.

Demo

Install

npm install react-search-input --save

Example

import React, {Component} from 'react'
import SearchInput, {createFilter} from 'react-search-input'

import emails from './mails'

const KEYS_TO_FILTERS = ['user.name', 'subject', 'dest.name']

class App extends Component {
  constructor (props) {
    super(props)
    this.state = {
      searchTerm: ''
    }
    this.searchUpdated = this.searchUpdated.bind(this)
  }

  render () {
    const filteredEmails = emails.filter(createFilter(this.state.searchTerm, KEYS_TO_FILTERS))

    return (
      <div>
        <SearchInput className="search-input" onChange={this.searchUpdated} />
        {filteredEmails.map(email => {
          return (
            <div className="mail" key={email.id}>
              <div className="from">{email.user.name}</div>
              <div className="subject">{email.subject}</div>
            </div>
          )
        })}
      </div>
    )
  }

  searchUpdated (term) {
    this.setState({searchTerm: term})
  }
}

API

Props

All props are optional. All other props will be passed to the DOM input.

className

Class of the Component (in addition of search-input).

onChange

Function called when the search term is changed (will be passed as an argument).

filterKeys

Either an [String] or a String. Will be use by the filter method if no argument is passed there.

throttle

Reduce call frequency to the onChange function (in ms). Default is 200.

caseSensitive

Define if the search should be case sensitive. Default is false

fuzzy

Define if the search should be fuzzy. Default is false

sortResults

Define if search results should be sorted by relevance (only works with fuzzy search). Default is false

value

Define the value of the input.

Methods

filter([keys])

Return a function which can be used to filter an array. keys can be String, [String] or null.

If an array keys is an array, the function will return true if at least one of the keys of the item matches the search term.

Static Methods

filter(searchTerm, [keys], [{caseSensitive, fuzzy, sortResults}])

Return a function which can be used to filter an array. searchTerm can be a regex or a String. keys can be String, [String] or null.

If an array keys is an array, the function will return true if at least one of the keys of the item matches the search term.

Styles

Look at react-search-input.css for an idea on how to style this component.


MIT Licensed

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].