1.3.4 • Published 3 years ago

@fliptask/react-search-dropdown v1.3.4

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

@fliptask/react-search-dropdown

React-Search-Dropdown React-Search-Dropdown Searchable autocomplete dropdown for React.

See fliptask.github.io/react-search-dropdown for live demo.

Installation and usage

The easiest way to use react-search-dropdown is to install it from npm and build it into your app with Webpack.

yarn add @fliptask/react-search-drodown

OR

npm install @fliptask/react-search-dropdown

Then use it in your app :

import React, { Component } from "react";
import SelectableSearch from "react-search-dropdown";

const data = [
    {
        id : "123-s2-546",
        name : "John Jacobs",
        items : [
            "bucket", "bottle"
        ],
        address : "1st Cross, 9th Main, abc Apartment",
        pincode : "5xx012"
    }, {
        id : "123-s3-146",
        name : "David Mire",
        items : ["Bedroom Set"],
        address : "2nd Cross, BTI Apartment",
        pincode : "4xx012"
    }, {
        id : "223-a1-234",
        name : "Soloman Marshall",
        items : ["bottle"],
        address : "Riverbed Apartment",
        pincode : "4xx032"
    }, {
        id : "121-s2-111",
        name : "Ricky Beno",
        items : ["Mobile Set"],
        address : "Sunshine City",
        pincode : "5xx072"
    }, {
        id : "123-p2-246",
        name : "Sikander Singh",
        items : ["Air Conditioner"],
        address : "Riverbed Apartment",
        pincode : "4xx032"
    }
];

class ProductList extends Component{
    state = {
        products: data
    }
    render(){
        return(
            <div className="product-list row">
                <SelectableSearch
                    value={"abc"}
                    onSelected={this.onClick}
                    options={searchData}
                    searchKeys={["name","items"]}
                />
            </div>
        )
    }
}

Props

PropNameDefault value(s)Description
listHeight250Height of the option list
searchKeysall keys in the collectionssearch will be applied on the options if provided otherwise on all the list options.
valuenullset this value if want to show prefilled value in the search box
openfalsetrue/false for opening and closing option list
selected{}selected option from the list
list[]
classNamenullprovided className will be added in the searchbox node.
placeholderdefault stringPass custom placeholder otherwise default will be shown.

Methods

Method NameReturn value
onChange(event)
onBlur(event)
onFocus(event)
onKeyUp(event)
onSelect(event, selectedOption)

License


MIT Licensed. Copyright (c) Fliptask 2020.