# react-tag-autosuggest-dropdown-menu

> A tagging component that has an autosuggest dropdown menu that highlights the matching characters.

Latest version **1.2.0** (published 2018-03-09) · 0 weekly downloads

## Install

```sh
npm install react-tag-autosuggest-dropdown-menu
pnpm add react-tag-autosuggest-dropdown-menu
yarn add react-tag-autosuggest-dropdown-menu
bun add react-tag-autosuggest-dropdown-menu
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2018-03-09 |
| First published | 2018-03-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 81.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Luke Mwila |
| Maintainers | lukemwila |

## Links

- npm: https://www.npmjs.com/package/react-tag-autosuggest-dropdown-menu
- Repository: https://github.com/LukeMwila/react-tag-autosuggest-dropdown-menu
- Issues: https://github.com/LukeMwila/react-tag-autosuggest-dropdown-menu/issues
- npm.io page: https://npm.io/package/react-tag-autosuggest-dropdown-menu

## Dependencies (9)

- [react](https://npm.io/package/react.md) ^15.5.4
- [moment](https://npm.io/package/moment.md) ^2.20.1
- [webpack](https://npm.io/package/webpack.md) ^2.6.1
- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [css-loader](https://npm.io/package/css-loader.md) ^0.28.9
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0
- [style-loader](https://npm.io/package/style-loader.md) ^0.19.1
- [styled-components](https://npm.io/package/styled-components.md) ^2.4.0
- [extract-text-webpack-plugin](https://npm.io/package/extract-text-webpack-plugin.md) ^3.0.2

## Recent versions

- 1.2.0 (latest) — 2018-03-09
- 1.1.0 — 2018-03-09
- 1.0.0 — 2018-03-09

## README

# react-tag-autosuggest-dropdown-menu

A tagging component that has an autosuggest dropdown menu that highlights the matching characters.

## Installation

  ```bash
  npm install react-tag-autosuggest-dropdown-menu --save
  ```
  or
  ```bash
  yarn add react-tag-autosuggest-dropdown-menu
  ```

## Usage

```js
import ReactTagAutoSuggestDropdown from 'react-tag-autosuggest-dropdown-menu'

class App extends Component {
  constructor () {
    super()
    this.state = {
      chosenValue: '',
      searchValue: '',
      showDropdown: false,
      list: [
        {
          id: 1,
          valueToSearch: "Wezi Amanda"
        },
        {
          id: 2,
          valueToSearch: "Mikayu Chindongo"
        },
        {
          id: 3,
          valueToSearch: "Suzuki Kelvin Mwila"
        },
        {
          id: 4,
          valueToSearch: "Maya Thundu"
        },
        {
          id: 5,
          valueToSearch: "Tinta Mwila"
        },
        {
          id: 6,
          valueToSearch: "Franco Lubinda"
        },
        {
          id: 7,
          valueToSearch: "Tchalla Brown"
        },
        {
          id: 8,
          valueToSearch: "Chanda Rose Mwila"
        }
      ],
      chosenItems: []
    }
    this.chooseDropdownItem = this.chooseDropdownItem.bind(this)
    this.updateSearchValue = this.updateSearchValue.bind(this)
    this.showDropdown = this.showDropdown.bind(this)
    this.detectBackSpace = this.detectBackSpace.bind(this)
    this.removeTag = this.removeTag.bind(this)
  }

  chooseDropdownItem (e, valueSelected, valueObject) {
    e.preventDefault()
    this.setState({ showDropdown: false, searchValue: '', chosenItems: [...this.state.chosenItems, valueObject ] })
  }

  detectBackSpace(e){
    e.preventDefault()
    if (e.keyCode === 8 && this.state.searchValue === '' && this.state.chosenItems.length > 0) {
      // backspace key has been hit
      let chosenItems = this.state.chosenItems
      chosenItems.pop()
      this.setState({ chosenItems: chosenItems })
    }
  }

  removeTag(e, tagID){
    e.preventDefault()
    const tags = this.state.chosenItems.filter(tag => tag.id !== tagID)
    this.setState({ chosenItems: tags })
  }

  updateSearchValue(e){
    e.preventDefault()
    this.setState({ searchValue: e.target.value })
  }

  showDropdown(){
    this.setState({ showDropdown: true })
  }

  render() {
    return (
      <div className='App'>
       <ReactTagAutoSuggestDropdown 
          list={this.state.list} 
          showDropdown={this.showDropdown} 
          displayDropdownMenu={this.state.showDropdown}
          chosenValue={this.state.chosenValue} 
          chooseDropdownItem={this.chooseDropdownItem} 
          updateSearchValue={this.updateSearchValue}
          searchValue={this.state.searchValue}
          highlightColour={"#ff9966"}
          chosenItems={this.state.chosenItems}
          detectBackSpace={this.detectBackSpace}
          removeTag={this.removeTag}
        />
       </div>
    );
  }
}

export default App;
```

#### ReactTagAutoSuggestDropdown props

| Props              | Default values | Possible values                          |
| -------------------| --------------| ------------------------------------------|
| list               | none          | array                                     |
| chosenItems        | none          | array                                     |
| showDropdown       | none          | function                                  |
| displayDropdownMenu| false         | bool                                      |
| chosenValue        | none          | any                                       |
| searchValue        | none          | any                                       |
| chooseDropdownItem | none          | function                                  |
| updateSearchValue  | none          | function                                  |
| detectBackSpace    | none          | function                                  |
| removeTag          | none          | function                                  |
| highlightColour    | "#00cc99"     | string                                    |

---
_Source: https://npm.io/package/react-tag-autosuggest-dropdown-menu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
