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-paper-autocomplete

v0.12.0

Published

Great autocomplete package for React Native Paper

Downloads

115

Readme

Great autocomplete package for React Native Paper with great web support.

  • Uses re-animated to be smooth on iOS/Android/Web
  • Keyboard support (Arrow down/up/end/start)
  • Single + multiple
  • Async connect with backend
  • Grouped results
  • Great web support (scrollable while open)

Installation

yarn add react-native-paper-autocomplete

or

npm install react-native-paper-autocomplete

Simple

const options = [
  { value: 1, label: 'Ruben von der Vein' },
  { value: 2, label: 'Pjotr Versjuurre' },
  { value: 3, label: 'Bjart von Klef' },
  { value: 4, label: 'Riesjard Lindhoe' }
]
function Single() {
  return (
    <AutocompleteScrollView>
      <Autocomplete
        onChange={(newValue)=>{
          console.log({ newValue })
        }}
        value={options[0]}
        options={options}
        inputProps={{
          placeholder: 'Select user',
          // ...all other props which are available in react native paper
        }}
      />
  </AutocompleteScrollView>
  )
}

function Multi() {
  return (
    <AutocompleteScrollView>
      <Autocomplete
        multiple={true}
        onChange={(newValue)=>{
          console.log({ newValue })
        }}
        value={[options[0], options[1]]}
        options={options}
        inputProps={{
          placeholder: 'Select user',
          // ...all other props which are available in react native paper
        }}
      />
    </AutocompleteScrollView>
  )
}

Advanced



function Multi() {
  const [options, setOptions] = React.useState([
    { id: 1, name: 'Ruben von der Vein', gender: 'girl' },
    { id: 2, name: 'Pjotr Versjuurre', gender: 'boy' },
    { id: 3, name: 'Bjart von Klef', gender: 'boy' },
    { id: 4, name: 'Riesjard Lindhoe', gender: 'boy' }
  ])
  const onEndReached = () => {
    // fetch more items (paginated) e.g:
    const response = api.fetch(...)
    setOptions(prev => [...prev, response.data])
  }

  return (
    <AutocompleteScrollView>
      <Autocomplete
        multiple={true}
        getOptionLabel={(item) => item.name}
        getOptionValue={(item) => item.id}
        onChange={(newValue)=>{
          console.log({ newValue })
        }}
        value={[options[0], options[1]]}
        options={options}
        // if you want to group on something
        groupBy={(option) => option.gender}
        inputProps={{
          placeholder: 'Select user',
          // ...all other props which are available in react native paper
          onChangeText: (search) => {
           // Load from your backend
          },
        }}

        listProps={{
            onEndReached
              // + other FlatList props or SectionList if you specify groupBy
        }}
      />
    </AutocompleteScrollView>
  )
}

Custom scrollable containers

  • If your autocomplete is inside a ScrollView use AutocompleteScrollView instead of the native ScrollView

  • If your autocomplete is inside a FlatList use AutocompleteFlatList instead of the native FlatList

  • If you're using another scrollable component, make sure it has te same api as the scrollView and supports the following properties: ref, scrollEventThrottle, keyboardShouldPersistTaps, onScroll

Example of custom scrollable container with autocomplete support

import CustomScrollView from '../CustomScrollView'
import { createAutocompleteScrollable } from 'react-native-paper-autocomplete'
const AnimatedCustomScrollView = createAutocompleteScrollable(CustomScrollView)

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT