Coder Social home page Coder Social logo

liesislukas / react-dropdown-autocomplete-with-search Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 11 KB

ReactJs component to make autocomplete dropdown with search field used at

Home Page: https://www.geekystats.com/

JavaScript 100.00%
reactjs blueprint autocomplete-component autocomplete-search

react-dropdown-autocomplete-with-search's Introduction

image

Features

  1. dropdown
  2. search with value coming back via prop
  3. navigate the list up/down with arrow up/down
  4. select any item with Enter
  5. select / navigate with mouse
  6. selected item is returned via prop

Properties

  1. height = pixels, just enter the number
  2. items = array of objects that must have jsx property: [{jsx: <div>some text</div>, yourCustom: 123}, {...}]
  3. onInputChange = function to get new value of the search field
  4. onSelected = function to get selected item back. It will return original item like: {jsx: <div>some text</div>, yourCustom: 123}

Sample usage

import AutoComplete from 'components/AutoComplete';

...

let items = [];

for (let index = 1; index <= 20; index++) {
  items.push({
    value: `some value ${index}`,
    jsx: <div>Item <strong>strong!</strong> {index}</div>
  });
}

...

<AutoComplete
  items={items}
  onSelected={(selected) => console.log('selected: ', selected)}
  onInputChange={(item) => console.log('item: ', item)}
/>

...

It has dependency on:

  1. npm i prop-types --save From official ReactJs docs: React.PropTypes is deprecated link
  2. npm i react --save
  3. npm i @blueprintjs/core --save

You can easily modify and remove 3rd, but while i was using this lib while building https://www.geekystats.com/ it's there.

I needed auto complete field and blueprint doesn't have it yet. I've created my own, you can use it for whatever needed.

react-dropdown-autocomplete-with-search's People

Contributors

liesislukas avatar

Watchers

 avatar

Forkers

thepureinx000

react-dropdown-autocomplete-with-search's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.