All Projects → yury-dymov → React Autocomplete Input

yury-dymov / React Autocomplete Input

Licence: mit
Autocomplete input field for React

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Autocomplete Input

Autocomplete
Blazing fast and lightweight autocomplete widget without dependencies. Only 1KB gzipped. Demo:
Stars: ✭ 244 (+144%)
Mutual labels:  component, widget, autocomplete
Tagger
Zero Dependency, Vanilla JavaScript Tag Editor
Stars: ✭ 135 (+35%)
Mutual labels:  component, widget
Ka Table
Lightweight MIT React Table component for both TS and JS with Sorting, Filtering, Grouping, Virtualization, Editing and many more
Stars: ✭ 117 (+17%)
Mutual labels:  component, widget
Horsey
🐴 Progressive and customizable autocomplete component
Stars: ✭ 1,146 (+1046%)
Mutual labels:  component, autocomplete
Insignia
🔖 Customizable tag input. Progressive. No non-sense!
Stars: ✭ 665 (+565%)
Mutual labels:  component, autocomplete
React Input Tags
React component for tagging inputs.
Stars: ✭ 10 (-90%)
Mutual labels:  component, autocomplete
React Places Autocomplete
React component for Google Maps Places Autocomplete
Stars: ✭ 1,265 (+1165%)
Mutual labels:  component, autocomplete
Animatedpieview
// 一个好吃的甜甜圈?
Stars: ✭ 1,319 (+1219%)
Mutual labels:  widget
React Native Sketch View
A React Native component for touch based drawing supporting iOS and Android.
Stars: ✭ 97 (-3%)
Mutual labels:  component
React Native Skeleton Content Nonexpo
A customizable skeleton-like loading placeholder for react native projects not using expo.
Stars: ✭ 92 (-8%)
Mutual labels:  component
Gaphas
Gaphas is the diagramming widget library for Python.
Stars: ✭ 91 (-9%)
Mutual labels:  widget
Xmui
基于vue2,为公司产品打(zao)造(lun)的(zi)可复用UI组件,文档:
Stars: ✭ 94 (-6%)
Mutual labels:  component
Quark
Quark.js is a microscopic atomic CSS polyfill in JS just 140 bytes
Stars: ✭ 97 (-3%)
Mutual labels:  component
Polyfill Php54
This component provides functions unavailable in releases prior to PHP 5.4.
Stars: ✭ 93 (-7%)
Mutual labels:  component
Evntouchiddemo
🆔 iOS fingerprint login process implementation
Stars: ✭ 98 (-2%)
Mutual labels:  widget
Multiselect
Vue 3 multiselect component with single select, multiselect and tagging options.
Stars: ✭ 92 (-8%)
Mutual labels:  autocomplete
Downshift
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
Stars: ✭ 10,183 (+10083%)
Mutual labels:  autocomplete
Vue Truncate Collapsed
A simple component that truncates your text and adds a 'Read More/Show Less' clickable.
Stars: ✭ 98 (-2%)
Mutual labels:  component
Polyfill
PHP polyfills
Stars: ✭ 1,333 (+1233%)
Mutual labels:  component
Hallelujahim
hallelujahIM(哈利路亚 英文输入法) is an intelligent English input method with auto-suggestions and spell check features, Mac only.
Stars: ✭ 1,334 (+1234%)
Mutual labels:  autocomplete

react-autocomplete-input

Autocomplete input field for React

react-autocomplete-input

npm version Downloads Build Status Coverage Status

Demo

Demo and playground are available here

Usage Example

import TextInput from 'react-autocomplete-input';
import 'react-autocomplete-input/dist/bundle.css';

<TextInput options={["apple", "apricot", "banana", "carrot"]} />

Multiple Triggers and Options Example

import TextInput from 'react-autocomplete-input';
import 'react-autocomplete-input/dist/bundle.css';

<TextField trigger={["@", "@@"]} options={{"@": ["aa", "ab", "abc", "abcd"], "@@": ["az", "ar"]}} />

Here for trigger @ first set of options will resolve and for @@ — second set.

Features

  • Supports both keyboard and mouse for option selection
  • Supports responsiveness and works on every device
  • Supports lazy-loading and dynamic option list updates
  • Supports all major browsers including IE 8+

Configurable Props

Note: All props are optional.

Component : string or func

Default value: "textarea"

Widget for rendering input field

defaultValue : string

Default value: ""

Initial text for input

disabled : boolean

Default value: false

Disables widget, i.e. during form submission

maxOptions : number

Default value: 6

Defines how many options can be listed simultaneously. Show all matched options if maxOptions equals 0.

onSelect : func

Default value: () => {}

Callback invoked upon selecting an option. Receives selection value as a parameter.

onRequestOptions : func

Default value: () => {}

Callback for requesting new options to support lazy-loading. If requestOnlyIfNoOptions is true, then onRequestOptions called only if no options are currently available. Otherwise onRequestOptions is called every time text is changed and trigger is found.

import React from 'react';
import TextInput from 'react-autocomplete-input';

class MyComponent extends React.Component {
  constructor(props) {
    super(props);

    this.handleRequestOptions = this.handleRequestOptions.bind(this);

    this.state = { options: ["apple", "apricot", "banana", "carror"] };
  }

  // text in input is "I want @ap"
  handleRequestOptions(part) {
    console.log(part);          // -> "ap", which is part after trigger "@"
    this.setState({ options: SOME_NEW_OPTION_ARRAY });
  }

  render() {
    return <TextInput onRequestOptions={this.handleRequestOptions} options={this.state.options} />;
  }
}

matchAny: boolean

Default value: false

If true, will match options in the middle of the word as well

offsetX: number

Default value: 0

Popup horizontal offset

offsetY: number

Default value: 0

Popup vertical offset

options : array

Default value: []

List of available options for autocomplete

regex : string

Default value: ^[a-zA-Z0-9_\-]+$

This regular expression checks if text after trigger can be autocompleted or not. I.e. "@ap" matches the default regex as "ap" matches the regex, therefore library will try to find appropriate option. "@a$p" fails to match the regex as there is not "$" character in it, therefore library considering this string as irrelevant.

requestOnlyIfNoOptions : boolean

Default value: true

If requestOnlyIfNoOptions is true, then onRequestOptions called only if no options are currently available. Otherwise onRequestOptions is called every time text is changed and trigger is found.

spaceRemovers : array

Default value: [',', '.', '!', '?']

By default, after option is selected, it is inserted with following spacer. If user inputs one of the characters from spaceRemovers array, then spacer is automatically removed. I.e. @apple ,| is automatically changed to @apple, |, where | represents caret.

spacer : string

Default value: ' '

Character which is inserted along with the selected option.

trigger : string

Default value: '@'

Character or string, which triggers showing autocompletion option list. '' and '@@' are both valid triggers. Keep in mind that user have to input at least one extra character to make option list available if empty trigger is used.

minChars: number

Default value: 0

Only show autocompletion option list after this many characters have been typed after the trigger character.

value : string

Default value: ''

Widget supports both controlling options: by value and by state. If you explicitly pass value prop, you have to update it manually every time onChange event is emitted. If you don't pass value prop, then widget uses internal state for value manipulation.

passThroughEnter: boolean

Default value: false

If true, then an enter / return keypress is passed on (after being used to autocomplete). Useful if you want to have the form submit as soon as a single value is chosen.

Styles Customization

By default styles are defined in "react-autocomplete-input/dist/bundle.css", however, you may define your custom styles instead for following entities:

  • ul.react-autocomplete-input
  • ul.react-autocomplete-input > li
  • ul.react-autocomplete-input > li.active

Design Considerations

  1. Native "Undo" action is not fully supported. It might be changed in the future but currently there is no out-of-the-box solution, which solves this issue for all browsers at once.
  2. It is considered that list of options will be always small, lets say up to 2000 items. Therefore, options are stored internally as array. If your use-case requires to work with huge lists, I would recommend to reimplement option internal representation as binary search tree instead.

License

MIT (c) Yury Dymov

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].