1.2.7 • Published 6 years ago

react-dropdown-autocomplete v1.2.7

Weekly downloads
28
License
MIT
Repository
github
Last release
6 years ago

React Dropdown AutoComplete

npm version npm downloads GitHub issues GitHub license

Example

class App extends React.Component {
  render() {
    const { editFields } = this.state; // you can get your input value by other ways
    const { product } = this.props; // get data where you have, or combine from redux

    return (
      <ReactDropDownAutoComplete
        getItemValue={item => item.name}
        className="form-control"
        id="name"
        name="name"
        placeholder="Product Name"
        data={product.list || []}
        renderItem={item => (
          <div
            role="button"
            tabIndex="-1"
            onClick={(val) => { editFields.name = val; }}
          >{item.id} - {item.name}</div>
        )}
        icon="search"
        iconColor="#ff000"
        iconClick={() => { /* TODO */ }}
        value={editFields.name}
        onChange={(val) => { editFields.name = val; }}
        onEnter={() => { /* TODO */ }}
      />
    );
  }
}

Data Seclection

You can use these ways to select value

  • Type the whole correct value
  • Mouse click the value
  • Press arrow up/down to change selection and press enter or arrow right to select value

Params

  • getItemValue
    • required
    • get value in single item
  • renderItem

    • optional
    • custom list menu item you want to show

    • onClick

      • bind menu item onClick method
  • className

    • optional
  • id
    • optional
    • is the key for the list render
  • name
    • optional
    • the name of the input field
  • placeholder
    • optional
    • the placeholder of the input field
  • data
    • required
    • your data list
    • must be array
    • default: []
  • value
    • required
    • value for auto-complete field check with old value
  • onChange
    • optional
    • get value from autocomplete field as params in func
  • onEnter
    • optional
    • do what ever you want after press enter key
  • icon
    • optional
    • icon for the input at the right side
    • only support font-awesome
  • iconColor
    • optional
    • the icon color
    • support format: HEX, RGB, RGBA
  • iconClick
    • optional
    • do what ever you want after click the icon
1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago