0.3.8 • Published 3 years ago

typeahead-dropdown v0.3.8

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

TypeAhead Dropdown

npm.io

TypeAhead Dropdown is a ReactJS UI component that allows you to search based on the text that you give in the input and also you have options Previous and Next to see all results based on the query that you have made.

Getting Started

These instructions will help you how to implement and use this UI component.

Prerequisites

You should install this component in ReactJS application otherwise will not work.

If you don't specify (data) prop when you use TypeAheadDropdown then in the dropdown you will see the default list that I have implemented for testing.

You must declare these methods in the component otherwise will not work:

NOTE: In case that list is not updated when you call your API and you are trying to change data={data} then in the method handleChange add this line at the end this.forceUpdate();

getFullName(fullName) {
  console.log(fullName);
}
handleChange(textInput) {
  console.log(textInput);
}
btnPrevious() {
  console.log("previous button clicked");
}
btnNext() {
  console.log("next button clicked");
}

Installing

To install this package you should run:

npm install TypeAheadDropdown --save

After installing you are ready to use it by importing:

import TypeAheadDropdown from "typeahead-dropdown";

Now you can use it in component

class TypeAhead extends React.Component {
  getFullName(fullName) {
    console.log(fullName);
  }
  handleChange(textInput) {
    console.log(textInput);
  }
  btnPrevious() {
    console.log("previous button clicked");
  }
  btnNext() {
    console.log("next button clicked");
  }
  render() {
    return (
      <TypeAheadDropdown
        displayProperties={["name", "surname"]}
        selectedObjectToReturn={["id", "name", "surname"]}
        onChange={this.handleChange}
        data={data}
        getFullName={this.getFullName}
        btnPrevious={this.btnPrevious}
        btnNext={this.btnNext}
        firstButton="Previous"
        secondButton="Next"
      />
    );
  }
}

User guide

Prop nameDescriptionRequired
getFullNameThis function will return object with with props that you specify in selectedObjectToReturnYes
btnPreviousFunction to manipulate listYes
btnNextFunction to manipulate listYes
onChangeFunction that returns text which you write in text-inputYes
displayPropertiesSpecify props of the object inside array NOTE: No more than 2 'name','surname'Yes
selectedObjectToReturnSpecify props that you want to be returned as object in getFullName method NOTE: No more than 3 'id','name','surname'Yes
dataArray with object'sNo
defaultNameSet default value in the text-inputNo
placeholderSet placeholder of the text-inputNo
firstButtonTitle of the first buttonNo
secondButtonTitle of the second buttonNo
btnBackgroundColorBackground-color of the button's, example 'red'No
btnTextColorText color of the button'sNo
btnfFooterBackgroundBackground-color of the div where button's are placedNo
ulBackgroundColorBackground-color of the unordered listNo
liColorList item colorNo
heightHeight of the text inputNo
widthWidth of the text inputNo

Data prop example

[
  {
    id:1,
    name: "Imce",
    surname: "Elezi",
    age: 25
  },
  {
    id:2,
    name: "Shqipe",
    surname: "Salii",
    age: 22
  },
  {
    id:3,
    name: "Neim",
    surname: "Elezi",
    age: 24
  },
  {
    id:3,
    name: "Aldion",
    surname: "Ambari",
    age: 23
  },
  {
    id:4,
    name: "Brian",
    surname: "Haas",
    age: 25
  },
  {
    id:5,
    name: "Arian",
    surname: "Derdo",
    age: 25
  }
];

Author

License

This project is licensed under the MIT License - see the LICENSE file for details

0.3.8

3 years ago

0.3.6

3 years ago

0.3.7

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.9

4 years ago

0.2.7

4 years ago

0.2.8

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago