npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-autotags

v0.0.1

Published

Autocomplete text input with tags

Downloads

2

Readme

This package is a quick fix for a project. All rights reserved to Andreas Raduege. Github: https://github.com/Eldjotnar

react-native-autocomplete-tags

A quick and easy solutions for projects that need an input with both autocomplete and tags

Features

  • custom tag and suggestions
  • fully style-able
  • extractors for tags and for suggestions
  • easy to integrate and use
  • controlled text input

Installation

yarn add react-native-autocomplete-tags

or

npm install react-native-autocomplete-tags --save

Dependency

Requires RN >= 0.59

Useage

Also see the demo projects

const suggestions = [
  { name: "Boris Yeltsin", email: "[email protected]" },
  { name: "Tom Boboby", email: "[email protected]" }
];

const Demo = () => {
  const [text, setText] = useState("");
  const [tags, setTags] = useState([
    { name: "Fred Hendriks", email: "[email protected]" }
  ]);

  const onChangeText = text => {
    setText(text);

    const lastTyped = text.charAt(text.length - 1);
    const parseWhen = [",", " ", ";", "\n"];

    if (parseWhen.indexOf(lastTyped) > -1) {
      setTags(tags => [...tags, { name: text, email: text }]);
      setText("");
    }
  };

  const handleSuggestionPress = suggestion => {
    setText("");
    setTags(tags => [...tags, suggestion]);
  };

  return (
    <SafeAreaView style={styles.container}>
      <View style={styles.rowContainer}>
        <Text>To: </Text>
        <AutocompleteTags
          tags={tags}
          labelExtractor={item => item.name}
          text={text}
          onChangeText={onChangeText}
          onChangeTags={tags => setTags(tags)}
          suggestions={suggestions}
          suggestionExtractor={item => item.email}
          onSuggestionPress={handleSuggestionPress}
        />
      </View>
    </SafeAreaView>
  );
};

Props

| Prop | type | Description | required | default | | ------------------------- | ----------------- | -------------------------------------------------------------------- | -------- | ------------------------ | | tags | array of any | The current tags to be rendered | true | | | labelExtractor | function | Determines what property of tags is displayed | true | | | text | string | value of TextInput | true | | | onChangeText | function | called when text changes, should also handle tag creation | true | | | onChangeTags | function | called when tags change (i.e. by deleting), should just write tags | true | | | minInputWidth | number | minimum width of TextInput before jumping to new line | false | 100 | | suggestions | array of any | All possible suggestions | false | [] | | suggestionExtractor | function | determines which property of suggestions is displayed | false | same as labelExtractor | | onSuggestionPress | function | called when suggestion is pressed | false | null | | onTagPress | function | called when tag is pressed | false | null | | renderSuggestion | function | renders a custom suggestion item | false | null | | renderTag | function | renders a custom tag | false | null | | filterSuggestions | function | filters suggestions based on text (receives text as parameter) | false | null | | inputProps | TextInput props | any additional props for TextInput | false | null | | flatListProps | FlatList props | any additional props for FlatList | false | null |

Style Props

No style props are required.

| Prop | Description | | ------------------------------ | ---------------------------------------------------------------------------------------- | | containerStyle | The outmost container which contains the TextInput and the FlatList of suggestions | | tagContainerStyle | Container for the tags and the TextInput | | inputContainerStyle | Container around the TextInput | | inputStyle | Applied to the TextInput directly | | tagStyle | Applied to each tag | | tagTextStyle | Applied to the tag label | | suggestionStyle | Applied to each suggestion | | suggestionContainerStyle | Applied to the FlatList which renders suggestions | | suggestionTextStyle | Applied to the suggestion label |

Contributing

PRs and issues welcome!