1.0.8 • Published 5 years ago

react-native-autocomplete-multiple-commaseprated-tags v1.0.8

Weekly downloads
11
License
ISC
Repository
github
Last release
5 years ago

react-native-tag-autocomplete

Tag autocomplete component for contacts, groups, etc.

Example

Up and Running

$ npm install --save react-native-tag-autocomplete

Example

//...
import AutoTags from 'react-native-tag-autocomplete';
// ...
state = {
    suggestions : [ {name:'Mickey Mouse'}, ],
    tagsSelected : []
}

handleDelete = index => {
   let tagsSelected = this.state.tagsSelected;
   tagsSelected.splice(index, 1);
   this.setState({ tagsSelected });
}

handleAddition = suggestion => {
   this.setState({ tagsSelected: this.state.tagsSelected.concat([suggestion]) });
}

render() {
  return (
      <AutoTags
            suggestions={this.state.suggestions}
            tagsSelected={this.state.tagsSelected}
            handleAddition={this.handleAddition}
            handleDelete={this.handleDelete}
            placeholder="Add a contact.." />
    );
}
// ...

Props

PropTypeRequiredDescription
suggestionsarrayyesArray of suggestion objects. They must have a 'name' prop if not overriding filter && renderTags
tagsSelectedarrayyesList of tags that have already been selected
handleAdditionfunctionyesHandler for when suggestion is selected (normally just push to tagsSelected)
handleDeletefunctionyesHandler called with index when tag is clicked
placeholderstringnoInput placeholder
renderTagsfunctionnoOverride the render tags and it's styles
renderSuggestionfunctionnoOverride the suggestions dropdown items
filterDatafunctionnoOverride the search function, allows you to filter by props other than name
onCustomTagCreatedfunctionnoFunction called with user input when user presses enter
createTagOnSpacebooleannocalls onCustomTagCreated when user presses space
tagStylesobjectnoOverride the default tag styling
tagsOrientedBelowbooleannoMove tags below the input instead of above (default).

Android

This repository wraps react-native-autocomplete-input, so their limitations will also apply here.

As such:

"Android does not support overflows (#20), for that reason it is necessary to wrap the autocomplete into a absolute positioned view on Android. This will allow the suggestion list to overlap other views inside your component."

//...

render() {
  return(
    <View>
      <View style={styles.autocompleteContainer}>
        <AutoTags {/* your props */} />
      </View>
      <View>
        <Text>Some content</Text>
      </View>
    </View>
  );
}

//...

const styles = StyleSheet.create({
  autocompleteContainer: {
    flex: 1,
    left: 0,
    position: 'absolute',
    right: 0,
    top: 0,
    zIndex: 1
  }
});

Pull Requests

I'm a dummy, so any PR's are wholly appreciated <3.