react-native-google-places-autocomplete 2.5.1 → 2.5.2
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.
- package/GooglePlacesAutocomplete.d.ts +1 -0
- package/GooglePlacesAutocomplete.js +21 -10
- package/README.md +1 -0
- package/package.json +1 -1
|
@@ -395,6 +395,7 @@ 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
|
+
listHoverColor?: string;
|
|
398
399
|
listUnderlayColor?: string;
|
|
399
400
|
listViewDisplayed?: 'auto' | boolean;
|
|
400
401
|
/** minimum length of text to search */
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
Image,
|
|
17
17
|
Keyboard,
|
|
18
18
|
Platform,
|
|
19
|
+
Pressable,
|
|
19
20
|
ScrollView,
|
|
20
21
|
StyleSheet,
|
|
21
22
|
Text,
|
|
22
23
|
TextInput,
|
|
23
|
-
TouchableHighlight,
|
|
24
24
|
View,
|
|
25
25
|
} from 'react-native';
|
|
26
26
|
|
|
@@ -144,14 +144,13 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
144
144
|
const inputRef = useRef();
|
|
145
145
|
|
|
146
146
|
useEffect(() => {
|
|
147
|
-
// This will load the
|
|
148
|
-
// been rendered
|
|
147
|
+
// This will load the search results after the query object ref gets changed
|
|
149
148
|
_handleChangeText(stateText);
|
|
150
149
|
return () => {
|
|
151
150
|
_abortRequests();
|
|
152
151
|
};
|
|
153
152
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
154
|
-
}, []);
|
|
153
|
+
}, [props.query]);
|
|
155
154
|
useEffect(() => {
|
|
156
155
|
// Update dataSource if props.predefinedPlaces changed
|
|
157
156
|
setDataSource(buildRowsFromResults([]));
|
|
@@ -481,6 +480,9 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
481
480
|
|
|
482
481
|
const _request = (text) => {
|
|
483
482
|
_abortRequests();
|
|
483
|
+
if (!url) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
484
486
|
if (supportedPlatform() && text && text.length >= props.minLength) {
|
|
485
487
|
const request = new XMLHttpRequest();
|
|
486
488
|
_requests.push(request);
|
|
@@ -625,12 +627,19 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
625
627
|
showsHorizontalScrollIndicator={false}
|
|
626
628
|
showsVerticalScrollIndicator={false}
|
|
627
629
|
>
|
|
628
|
-
<
|
|
629
|
-
style={
|
|
630
|
-
props.isRowScrollable ? { minWidth: '100%' } : { width: '100%' }
|
|
631
|
-
|
|
630
|
+
<Pressable
|
|
631
|
+
style={({ hovered, pressed }) => [
|
|
632
|
+
props.isRowScrollable ? { minWidth: '100%' } : { width: '100%' },
|
|
633
|
+
{
|
|
634
|
+
backgroundColor: pressed
|
|
635
|
+
? props.listUnderlayColor
|
|
636
|
+
: hovered
|
|
637
|
+
? props.listHoverColor
|
|
638
|
+
: undefined,
|
|
639
|
+
},
|
|
640
|
+
]}
|
|
632
641
|
onPress={() => _onPress(rowData)}
|
|
633
|
-
|
|
642
|
+
onBlur={_onBlur}
|
|
634
643
|
>
|
|
635
644
|
<View
|
|
636
645
|
style={[
|
|
@@ -642,7 +651,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
642
651
|
{_renderLoader(rowData)}
|
|
643
652
|
{_renderRowData(rowData, index)}
|
|
644
653
|
</View>
|
|
645
|
-
</
|
|
654
|
+
</Pressable>
|
|
646
655
|
</ScrollView>
|
|
647
656
|
);
|
|
648
657
|
};
|
|
@@ -865,6 +874,7 @@ GooglePlacesAutocomplete.propTypes = {
|
|
|
865
874
|
isRowScrollable: PropTypes.bool,
|
|
866
875
|
keyboardShouldPersistTaps: PropTypes.oneOf(['never', 'always', 'handled']),
|
|
867
876
|
listEmptyComponent: PropTypes.func,
|
|
877
|
+
listHoverColor: PropTypes.string,
|
|
868
878
|
listUnderlayColor: PropTypes.string,
|
|
869
879
|
// Must write it this way: https://stackoverflow.com/a/54290946/7180620
|
|
870
880
|
listViewDisplayed: PropTypes.oneOfType([
|
|
@@ -919,6 +929,7 @@ GooglePlacesAutocomplete.defaultProps = {
|
|
|
919
929
|
GoogleReverseGeocodingQuery: {},
|
|
920
930
|
isRowScrollable: true,
|
|
921
931
|
keyboardShouldPersistTaps: 'always',
|
|
932
|
+
listHoverColor: '#ececec',
|
|
922
933
|
listUnderlayColor: '#c8c7cc',
|
|
923
934
|
listViewDisplayed: 'auto',
|
|
924
935
|
keepResultsAfterBlur: false,
|
package/README.md
CHANGED
|
@@ -240,6 +240,7 @@ _This list is a work in progress. PRs welcome!_
|
|
|
240
240
|
| keepResultsAfterBlur | boolean | show list of results after blur | false | true \| false |
|
|
241
241
|
| keyboardShouldPersistTaps | string | Determines when the keyboard should stay visible after a tap https://reactnative.dev/docs/scrollview#keyboardshouldpersisttaps | 'always' | 'never' \| 'always' \| 'handled' |
|
|
242
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' | |
|
|
243
244
|
| listUnderlayColor | string | underlay color of the list result when pressed https://reactnative.dev/docs/touchablehighlight#underlaycolor | '#c8c7cc' | |
|
|
244
245
|
| listViewDisplayed | string | override the default behavior of showing the list (results) view | 'auto' | 'auto' \| true \| false |
|
|
245
246
|
| minLength | number | minimum length of text to trigger a search | 0 | |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-google-places-autocomplete",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
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",
|