react-native-google-places-autocomplete 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -395,6 +395,8 @@ interface GooglePlacesAutocompleteProps {
395
395
  keyboardShouldPersistTaps?: 'never' | 'always' | 'handled';
396
396
  /** use the ListEmptyComponent prop when no autocomplete results are found. */
397
397
  listEmptyComponent?: JSX.Element | React.ComponentType<{}>;
398
+ /** use the ListLoaderComponent prop when no results are loading. */
399
+ listLoaderComponent?: JSX.Element | React.ComponentType<{}>;
398
400
  listHoverColor?: string;
399
401
  listUnderlayColor?: string;
400
402
  listViewDisplayed?: 'auto' | boolean;
@@ -140,6 +140,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
140
140
  props.listViewDisplayed === 'auto' ? false : props.listViewDisplayed,
141
141
  );
142
142
  const [url] = useState(getRequestUrl(props.requestUrl));
143
+ const [listLoaderDisplayed, setListLoaderDisplayed] = useState(false);
143
144
 
144
145
  const inputRef = useRef();
145
146
 
@@ -409,9 +410,11 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
409
410
  request.ontimeout = props.onTimeout;
410
411
  request.onreadystatechange = () => {
411
412
  if (request.readyState !== 4) {
413
+ setListLoaderDisplayed(true);
412
414
  return;
413
415
  }
414
416
 
417
+ setListLoaderDisplayed(false);
415
418
  if (request.status === 200) {
416
419
  const responseJSON = JSON.parse(request.responseText);
417
420
 
@@ -490,9 +493,11 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
490
493
  request.ontimeout = props.onTimeout;
491
494
  request.onreadystatechange = () => {
492
495
  if (request.readyState !== 4) {
496
+ setListLoaderDisplayed(true);
493
497
  return;
494
498
  }
495
499
 
500
+ setListLoaderDisplayed(false);
496
501
  if (request.status === 200) {
497
502
  const responseJSON = JSON.parse(request.responseText);
498
503
  if (typeof responseJSON.predictions !== 'undefined') {
@@ -779,7 +784,9 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
779
784
  ItemSeparatorComponent={_renderSeparator}
780
785
  renderItem={({ item, index }) => _renderRow(item, index)}
781
786
  ListEmptyComponent={
782
- stateText.length > props.minLength && props.listEmptyComponent
787
+ listLoaderDisplayed
788
+ ? props.listLoaderComponent
789
+ : stateText.length > props.minLength && props.listEmptyComponent
783
790
  }
784
791
  ListHeaderComponent={
785
792
  props.renderHeaderComponent &&
@@ -874,6 +881,7 @@ GooglePlacesAutocomplete.propTypes = {
874
881
  isRowScrollable: PropTypes.bool,
875
882
  keyboardShouldPersistTaps: PropTypes.oneOf(['never', 'always', 'handled']),
876
883
  listEmptyComponent: PropTypes.func,
884
+ listLoaderComponent: PropTypes.func,
877
885
  listHoverColor: PropTypes.string,
878
886
  listUnderlayColor: PropTypes.string,
879
887
  // Must write it this way: https://stackoverflow.com/a/54290946/7180620
@@ -955,4 +963,6 @@ GooglePlacesAutocomplete.defaultProps = {
955
963
  timeout: 20000,
956
964
  };
957
965
 
966
+ GooglePlacesAutocomplete.displayName = 'GooglePlacesAutocomplete';
967
+
958
968
  export default { GooglePlacesAutocomplete };
package/README.md CHANGED
@@ -6,10 +6,23 @@
6
6
 
7
7
  **Customizable Google Places autocomplete component for iOS and Android React-Native apps**
8
8
 
9
- Version 2 of this library is now available. See more in the [releases](https://github.com/FaridSafi/react-native-google-places-autocomplete/releases/tag/v2.0.0) section.
10
-
11
- # :warning: Maintainers Wanted ![Maintainers Wanted](https://img.shields.io/badge/Maintainers-Wanted-green)
12
- We are in need of more people or companies willing to help. If you have enough time and knowledge, and want to become a maintainer, please open a new issue.
9
+ ## Sponsor
10
+
11
+ <p align="center">
12
+ <br/>
13
+ <a href="https://bit.ly/3rneTTI" target="_blank">
14
+ <img src="https://raw.githubusercontent.com/FaridSafi/react-native-google-places-autocomplete/master/Assets/expensify-logo.png">
15
+ </a>
16
+ <br>
17
+ <p align="center">
18
+ The financial management super app for expenses, corporate cards, and more.
19
+ </p>
20
+ <a href="https://bit.ly/3rneTTI" target="_blank">
21
+ <p align="center">
22
+ Click to learn more
23
+ </p>
24
+ </a>
25
+ </p>
13
26
 
14
27
  ## Preview
15
28
 
@@ -221,52 +234,53 @@ export default GooglePlacesInput;
221
234
 
222
235
  _This list is a work in progress. PRs welcome!_
223
236
 
224
- | Prop Name | type | description | default value | Options |
225
- | ----------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------- |
226
- | autoFillOnNotFound | boolean | displays the result from autocomplete if the place details api return not found | false | true \| false |
227
- | currentLocation | boolean | Will add a 'Current location' button at the top of the predefined places list | false | true \| false |
228
- | currentLocationLabel | string | change the display label for the current location button | Current Location | Any string |
229
- | debounce | number | debounce the requests (in ms) | 0 | |
230
- | disableScroll | boolean | disable scroll on the results list | | |
231
- | enableHighAccuracyLocation | boolean | use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested. use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested. | true | |
232
- | enablePoweredByContainer | boolean | show "powered by Google" at the bottom of the search results list | true | |
233
- | fetchDetails | boolean | get more place details about the selected option from the Place Details API | false | |
234
- | filterReverseGeocodingByTypes | array | filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities | | |
235
- | GooglePlacesDetailsQuery | object | "query" object for the Google Place Details API (when you press on a suggestion) | | |
236
- | GooglePlacesSearchQuery | object | "query" object for the Google Places Nearby API (when you use current location to find nearby places) | `{ rankby: 'distance', type: 'restaurant' }` | |
237
- | GoogleReverseGeocodingQuery | object | "query" object for the Google Geocode API (when you use current location to get the current address) | | |
238
- | isRowScrollable | boolean | enable/disable horizontal scrolling of a list result https://reactnative.dev/docs/scrollview#scrollenabled | true |
239
- |inbetweenCompo|React.ReactNode|Insert a ReactNode in between the search bar and the search results Flatlist
240
- | keepResultsAfterBlur | boolean | show list of results after blur | false | true \| false |
241
- | keyboardShouldPersistTaps | string | Determines when the keyboard should stay visible after a tap https://reactnative.dev/docs/scrollview#keyboardshouldpersisttaps | 'always' | 'never' \| 'always' \| 'handled' |
242
- | listEmptyComponent | function | use FlatList's ListEmptyComponent prop when no autocomplete results are found. | | |
243
- | listHoverColor | string | underlay color of the list result when hovered (web only) | '#ececec' | |
244
- | listUnderlayColor | string | underlay color of the list result when pressed https://reactnative.dev/docs/touchablehighlight#underlaycolor | '#c8c7cc' | |
245
- | listViewDisplayed | string | override the default behavior of showing the list (results) view | 'auto' | 'auto' \| true \| false |
246
- | minLength | number | minimum length of text to trigger a search | 0 | |
247
- | nearbyPlacesAPI | string | which API to use for current location | 'GooglePlacesSearch' | 'none' \| 'GooglePlacesSearch' \| 'GoogleReverseGeocoding' |
248
- | numberOfLines | number | number of lines (android - multiline must be set to true) https://reactnative.dev/docs/textinput#numberoflines | 1 | |
249
- | onFail | function | returns if an unspecified error comes back from the API | | |
250
- | onNotFound | function | returns if the Google Places Details API returns a 'not found' code (when you press a suggestion). | | |
251
- | onPress | function | returns when after a suggestion is selected | | |
252
- | onTimeout | function | callback when a request timeout | `()=>console.warn('google places autocomplete: request timeout')` | |
253
- | placeholder | string | placeholder text https://reactnative.dev/docs/textinput#placeholder | 'Search' | |
254
- | predefinedPlaces | array | Allows you to show pre-defined places (e.g. home, work) | | |
255
- | predefinedPlacesAlwaysVisible | boolean | Shows predefined places at the top of the search results | false | |
256
- | preProcess | function | do something to the text of the search input before a search request is sent | | |
257
- | query | object | "query" object for the Google Places Autocomplete API (link) | `{ key: 'missing api key', language: 'en', types: 'geocode' }` | |
258
- | renderDescription | function | determines the data passed to each renderRow (search result) | | |
259
- | renderHeaderComponent | function | use the `ListHeaderComponent` from `FlatList` when showing autocomplete results | | |
260
- | renderLeftButton | function | add a component to the left side of the Text Input | | |
261
- | renderRightButton | function | add a component to the right side of the Text Input | | |
262
- | 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 | | |
263
- | requestUrl | object | used to set the request url for the library | | |
264
- | returnKeyType | string | the return key text https://reactnative.dev/docs/textinput#returnkeytype | 'search' | |
265
- | styles | object | See styles section below | | |
266
- | suppressDefaultStyles | boolean | removes all default styling from the library | false | true \| false |
267
- | textInputHide | boolean | Hide the Search input | false | true \| false |
268
- | textInputProps | object | define props for the [textInput](https://reactnative.dev/docs/textinput), or provide a custom input component | | |
269
- | timeout | number | how many ms until the request will timeout | 20000 | |
237
+ | Prop Name | type | description | default value | Options |
238
+ | ----------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------- |
239
+ | autoFillOnNotFound | boolean | displays the result from autocomplete if the place details api return not found | false | true \| false |
240
+ | currentLocation | boolean | Will add a 'Current location' button at the top of the predefined places list | false | true \| false |
241
+ | currentLocationLabel | string | change the display label for the current location button | Current Location | Any string |
242
+ | debounce | number | debounce the requests (in ms) | 0 | |
243
+ | disableScroll | boolean | disable scroll on the results list | | |
244
+ | enableHighAccuracyLocation | boolean | use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested. use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested. | true | |
245
+ | enablePoweredByContainer | boolean | show "powered by Google" at the bottom of the search results list | true | |
246
+ | fetchDetails | boolean | get more place details about the selected option from the Place Details API | false | |
247
+ | filterReverseGeocodingByTypes | array | filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities | | |
248
+ | GooglePlacesDetailsQuery | object | "query" object for the Google Place Details API (when you press on a suggestion) | | |
249
+ | GooglePlacesSearchQuery | object | "query" object for the Google Places Nearby API (when you use current location to find nearby places) | `{ rankby: 'distance', type: 'restaurant' }` | |
250
+ | GoogleReverseGeocodingQuery | object | "query" object for the Google Geocode API (when you use current location to get the current address) | | |
251
+ | isRowScrollable | boolean | enable/disable horizontal scrolling of a list result https://reactnative.dev/docs/scrollview#scrollenabled | true |
252
+ | inbetweenCompo | React.ReactNode | Insert a ReactNode in between the search bar and the search results Flatlist |
253
+ | keepResultsAfterBlur | boolean | show list of results after blur | false | true \| false |
254
+ | keyboardShouldPersistTaps | string | Determines when the keyboard should stay visible after a tap https://reactnative.dev/docs/scrollview#keyboardshouldpersisttaps | 'always' | 'never' \| 'always' \| 'handled' |
255
+ | listEmptyComponent | function | use FlatList's ListEmptyComponent prop when no autocomplete results are found. | | |
256
+ | listLoaderComponent | function | show this component while results are loading. | | |
257
+ | listHoverColor | string | underlay color of the list result when hovered (web only) | '#ececec' | |
258
+ | listUnderlayColor | string | underlay color of the list result when pressed https://reactnative.dev/docs/touchablehighlight#underlaycolor | '#c8c7cc' | |
259
+ | listViewDisplayed | string | override the default behavior of showing the list (results) view | 'auto' | 'auto' \| true \| false |
260
+ | minLength | number | minimum length of text to trigger a search | 0 | |
261
+ | nearbyPlacesAPI | string | which API to use for current location | 'GooglePlacesSearch' | 'none' \| 'GooglePlacesSearch' \| 'GoogleReverseGeocoding' |
262
+ | numberOfLines | number | number of lines (android - multiline must be set to true) https://reactnative.dev/docs/textinput#numberoflines | 1 | |
263
+ | onFail | function | returns if an unspecified error comes back from the API | | |
264
+ | onNotFound | function | returns if the Google Places Details API returns a 'not found' code (when you press a suggestion). | | |
265
+ | onPress | function | returns when after a suggestion is selected | | |
266
+ | onTimeout | function | callback when a request timeout | `()=>console.warn('google places autocomplete: request timeout')` | |
267
+ | placeholder | string | placeholder text https://reactnative.dev/docs/textinput#placeholder | 'Search' | |
268
+ | predefinedPlaces | array | Allows you to show pre-defined places (e.g. home, work) | | |
269
+ | predefinedPlacesAlwaysVisible | boolean | Shows predefined places at the top of the search results | false | |
270
+ | preProcess | function | do something to the text of the search input before a search request is sent | | |
271
+ | query | object | "query" object for the Google Places Autocomplete API (link) | `{ key: 'missing api key', language: 'en', types: 'geocode' }` | |
272
+ | renderDescription | function | determines the data passed to each renderRow (search result) | | |
273
+ | renderHeaderComponent | function | use the `ListHeaderComponent` from `FlatList` when showing autocomplete results | | |
274
+ | renderLeftButton | function | add a component to the left side of the Text Input | | |
275
+ | renderRightButton | function | add a component to the right side of the Text Input | | |
276
+ | 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 | | |
277
+ | requestUrl | object | used to set the request url for the library | | |
278
+ | returnKeyType | string | the return key text https://reactnative.dev/docs/textinput#returnkeytype | 'search' | |
279
+ | styles | object | See styles section below | | |
280
+ | suppressDefaultStyles | boolean | removes all default styling from the library | false | true \| false |
281
+ | textInputHide | boolean | Hide the Search input | false | true \| false |
282
+ | textInputProps | object | define props for the [textInput](https://reactnative.dev/docs/textinput), or provide a custom input component | | |
283
+ | timeout | number | how many ms until the request will timeout | 20000 | |
270
284
 
271
285
  ## Methods
272
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-places-autocomplete",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Customizable Google Places autocomplete component for iOS and Android React-Native apps",
5
5
  "main": "GooglePlacesAutocomplete.js",
6
6
  "types": "GooglePlacesAutocomplete.d.ts",