0.0.38 • Published 1 year ago

batchautocomplete v0.0.38

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

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 Nametypedescriptiondefault value
debouncenumberused to delay the search API call when a user is start typing700
apiKeystringBatch Data API Key
domainServerstringBatch Data Domain
numberOfLinesnumbernumber of lines (android - multiline must be set to true) https://reactnative.dev/docs/textinput#numberoflines1
minLengthnumberminimum length of text to trigger a search2
takenumberset the number of suggestions to be displayed5
showLoaderbooleanshow loader indicator when a user is typing the keyword in input box and the search API call in progresstrue
showNoDataFoundbooleanshow view to users when no results are found for the given inputtrue
noDataFoundTextstringset the text to be shown when no results for the given inputNo results found
showRecentSearchbooleanshow list of recent seachesfalse
recentSearchesDataobjectset some list of recent searches which can be displayed
stylesobjectSee styles section below
placeholderstringplaceholder text https://reactnative.dev/docs/textinput#placeholderEnter Location or Address...
textInputPropsobjectdefine props for the textInput, or provide a custom input component
handleErrorfunctionreturns if an unspecified error comes back from the API
onPressfunctionreturns when after a suggestion is selected
renderRowfunctioncustom component to render each result row (use this to show an icon beside each result). data and index will be passed as input parameters
renderLeftButtonfunctionadd a component to the left side of the Text Input
renderRightButtonfunctionadd a component to the right side of the Text InputrenderSuggectionLeftButtonfunctionadd a component to the left side of the suggetion Text
renderRecentSearchLeftButtonfunctionadd 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)

keytype
containerobject (View style)
textInputContainerobject (View style)
textInputobject (Text style)
listViewContainerobject (View style)
suggestionContainerobject (View style)
suggestionRowobject (View style)
suggestionTextobject (Text style)
separatorobject (View style)
recentSearchContainerobject (View style)
recentSearcheRowobject (View style)
recentAddressTextobject (Text style)
noDataFoundContainerobject (View style)
noDataFoundTextobject (Text style)
loaderContainerobject (View style)

Reference Methods

method nametypedescription
getAddressText() => stringreturn the value of TextInput
setAddressText(value: string) => voidset the value of TextInput
focusvoidmakes the TextInput focus
blurvoidmakes the TextInput lose focus
clearvoidremoves all text from the TextInput
isFocused() => booleanreturns true if the TextInput is currently focused; false otherwise

You can access these methods using a ref.

0.0.38

1 year ago

0.0.37

1 year ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.34

1 year ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago