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

batchautocomplete

v0.0.38

Published

Batch Custom Search Auto Complete for React Native

Downloads

17

Readme

React Native Batch Autocomplete

Batch Custom Search Auto Complete for React Native

Getting started

Install the latest version:

npm install --save react-native-batch-autocomplete
  or
yarn add react-native-batch-autocomplete

Example

import React from 'react';
import { RNBatchAutoComplete } from 'react-native-batch-autocomplete';

const YourComponent = () => (

const recentSearchData = [
    // List of suggestions to be displayed before any input is provided in search input box.
  ];
  
  const handleError = (e) => {
    // Handle error as you want
    console.log('Error while searching: ',e);
  }

  const onPress = (data) => {
    // Do Your Execution with data
    console.log('Seleted item: ', data)
  }

 return(
    <RNBatchAutoComplete
      apiKey="BATCH_API_KEY" //required
      domainServer="BATCH_DOMAIN_SERVER" //required
      handleError={(e) => handleError(e)}
      onPress={(data) => onPress(data)}
      recentSearchData={recentSearchData}
      textInputProps={{
        placeholderTextColor: '#454545',
      }}
    />
 );
);

export default YourComponent;

Props

| Prop Name | type | description | default value | | ----------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | | debounce | number | used to delay the search API call when a user is start typing | 700 | | | apiKey | string | Batch Data API Key | | | | domainServer | string | Batch Data Domain | | | | numberOfLines | number | number of lines (android - multiline must be set to true) https://reactnative.dev/docs/textinput#numberoflines | 1 |
| minLength | number | minimum length of text to trigger a search | 2 | | take | number | set the number of suggestions to be displayed | 5 |
| showLoader | boolean | show loader indicator when a user is typing the keyword in input box and the search API call in progress | true |
| showNoDataFound | boolean | show view to users when no results are found for the given input | true |
| noDataFoundText | string | set the text to be shown when no results for the given input | No results found |
| showRecentSearch | boolean | show list of recent seaches | false |
| recentSearchesData | object | set some list of recent searches which can be displayed | [ ] | styles | object | See styles section below | |
| placeholder | string | placeholder text https://reactnative.dev/docs/textinput#placeholder | Enter Location or Address... | | textInputProps | object | define props for the textInput, or provide a custom input component | | | handleError | function | returns if an unspecified error comes back from the API | |
| onPress | function | returns when after a suggestion is selected | |
| renderRow | function | custom component to render each result row (use this to show an icon beside each result). data and index will be passed as input parameters | |
| renderLeftButton | function | add a component to the left side of the Text Input | |
| renderRightButton | function | add a component to the right side of the Text Input | | | renderSuggectionLeftButton | function | add a component to the left side of the suggetion Text | | | renderRecentSearchLeftButton | function | add a component to the left side of the recent search Text | |

Styling

RNBatchAutoComplete can be easily customized the styles as per your app requirement. Pass styles props to RNBatchAutoComplete for different elements (check below keys for style object)

| key | type | | ---------------------------------- | ----------------------------------- | | container | object (View style) | | textInputContainer | object (View style) | | textInput | object (Text style) | | listViewContainer | object (View style) | | suggestionContainer | object (View style) | | suggestionRow | object (View style) | | suggestionText | object (Text style) | | separator | object (View style) | | recentSearchContainer | object (View style) | | recentSearcheRow | object (View style) | | recentAddressText | object (Text style) | | noDataFoundContainer | object (View style) | | noDataFoundText | object (Text style) | | loaderContainer | object (View style) |

Reference Methods

| method name | type | description | | -------------------- | ------------------------- | ----------------------------------------------------------------------- | | getAddressText | () => string | return the value of TextInput | | setAddressText | (value: string) => void | set the value of TextInput | | focus | void | makes the TextInput focus | | blur | void | makes the TextInput lose focus | | clear | void | removes all text from the TextInput | | isFocused | () => boolean | returns true if the TextInput is currently focused; false otherwise |

You can access these methods using a ref.