react-native-google-places-autocomplete 2.6.1 → 2.6.4
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/.husky/pre-commit +4 -0
- package/GooglePlacesAutocomplete.js +30 -6
- package/package.json +12 -10
|
@@ -166,6 +166,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
166
166
|
const [listViewDisplayed, setListViewDisplayed] = useState(
|
|
167
167
|
listViewDisplayedProp === 'auto' ? false : listViewDisplayedProp,
|
|
168
168
|
);
|
|
169
|
+
const [listWasDismissed, setListWasDismissed] = useState(false);
|
|
169
170
|
const [url, setUrl] = useState('');
|
|
170
171
|
const [listLoaderDisplayed, setListLoaderDisplayed] = useState(false);
|
|
171
172
|
const [sessionToken, setSessionToken] = useState(uuid.v4());
|
|
@@ -395,6 +396,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
395
396
|
listViewDisplayedProp === 'auto' &&
|
|
396
397
|
newDataSource.length > 0
|
|
397
398
|
) {
|
|
399
|
+
setListWasDismissed(false);
|
|
398
400
|
setListViewDisplayed(true);
|
|
399
401
|
}
|
|
400
402
|
}
|
|
@@ -499,6 +501,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
499
501
|
setDataSource(newDataSource);
|
|
500
502
|
// Auto-show list when results arrive if in 'auto' mode
|
|
501
503
|
if (listViewDisplayedProp === 'auto' && newDataSource.length > 0) {
|
|
504
|
+
setListWasDismissed(false);
|
|
502
505
|
setListViewDisplayed(true);
|
|
503
506
|
}
|
|
504
507
|
}
|
|
@@ -512,6 +515,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
512
515
|
setDataSource(newDataSource);
|
|
513
516
|
// Auto-show list when results arrive if in 'auto' mode
|
|
514
517
|
if (listViewDisplayedProp === 'auto' && newDataSource.length > 0) {
|
|
518
|
+
setListWasDismissed(false);
|
|
515
519
|
setListViewDisplayed(true);
|
|
516
520
|
}
|
|
517
521
|
}
|
|
@@ -663,6 +667,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
663
667
|
return;
|
|
664
668
|
}
|
|
665
669
|
|
|
670
|
+
hideListView(true);
|
|
666
671
|
Keyboard.dismiss();
|
|
667
672
|
|
|
668
673
|
_abortRequests();
|
|
@@ -750,6 +755,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
750
755
|
|
|
751
756
|
request.send();
|
|
752
757
|
} else if (rowData.isCurrentLocation === true) {
|
|
758
|
+
hideListView(true);
|
|
753
759
|
// display loader
|
|
754
760
|
_enableRowLoader(rowData);
|
|
755
761
|
|
|
@@ -758,6 +764,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
758
764
|
delete rowData.isLoading;
|
|
759
765
|
getCurrentLocation();
|
|
760
766
|
} else {
|
|
767
|
+
hideListView(true);
|
|
761
768
|
setStateText(_renderDescription(rowData));
|
|
762
769
|
|
|
763
770
|
_onBlur();
|
|
@@ -770,6 +777,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
770
777
|
};
|
|
771
778
|
|
|
772
779
|
const _onChangeText = (text) => {
|
|
780
|
+
setListWasDismissed(false);
|
|
773
781
|
setStateText(text);
|
|
774
782
|
debounceData(text);
|
|
775
783
|
};
|
|
@@ -784,6 +792,16 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
784
792
|
}
|
|
785
793
|
};
|
|
786
794
|
|
|
795
|
+
const hideListView = useCallback(
|
|
796
|
+
(force = false) => {
|
|
797
|
+
if (!keepResultsAfterBlur || force) {
|
|
798
|
+
setListWasDismissed(true);
|
|
799
|
+
setListViewDisplayed(false);
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
[keepResultsAfterBlur],
|
|
803
|
+
);
|
|
804
|
+
|
|
787
805
|
const isNewFocusInAutocompleteResultList = ({
|
|
788
806
|
relatedTarget,
|
|
789
807
|
currentTarget,
|
|
@@ -803,13 +821,12 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
803
821
|
const _onBlur = (e) => {
|
|
804
822
|
if (e && isNewFocusInAutocompleteResultList(e)) return;
|
|
805
823
|
|
|
806
|
-
|
|
807
|
-
setListViewDisplayed(false);
|
|
808
|
-
}
|
|
824
|
+
hideListView();
|
|
809
825
|
inputRef?.current?.blur();
|
|
810
826
|
};
|
|
811
827
|
|
|
812
828
|
const _onFocus = () => {
|
|
829
|
+
setListWasDismissed(false);
|
|
813
830
|
setListViewDisplayed(true);
|
|
814
831
|
};
|
|
815
832
|
|
|
@@ -1002,7 +1019,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
1002
1019
|
const shouldShowList =
|
|
1003
1020
|
supportedPlatform() &&
|
|
1004
1021
|
dataSource.length > 0 &&
|
|
1005
|
-
(listViewDisplayed === true || isAutoMode);
|
|
1022
|
+
(listViewDisplayed === true || (isAutoMode && !listWasDismissed));
|
|
1006
1023
|
|
|
1007
1024
|
if (shouldShowList) {
|
|
1008
1025
|
return (
|
|
@@ -1010,6 +1027,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
1010
1027
|
nativeID='result-list-id'
|
|
1011
1028
|
scrollEnabled={!disableScroll}
|
|
1012
1029
|
nestedScrollEnabled={true}
|
|
1030
|
+
keyboardShouldPersistTaps={keyboardShouldPersistTaps}
|
|
1013
1031
|
style={[
|
|
1014
1032
|
suppressDefaultStyles ? {} : defaultStyles.listView,
|
|
1015
1033
|
styles?.listView,
|
|
@@ -1095,11 +1113,17 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
|
|
|
1095
1113
|
if (
|
|
1096
1114
|
listViewDisplayedProp === 'auto' &&
|
|
1097
1115
|
dataSource.length > 0 &&
|
|
1098
|
-
!listViewDisplayed
|
|
1116
|
+
!listViewDisplayed &&
|
|
1117
|
+
!listWasDismissed
|
|
1099
1118
|
) {
|
|
1100
1119
|
setListViewDisplayed(true);
|
|
1101
1120
|
}
|
|
1102
|
-
}, [
|
|
1121
|
+
}, [
|
|
1122
|
+
dataSource.length,
|
|
1123
|
+
listViewDisplayedProp,
|
|
1124
|
+
listViewDisplayed,
|
|
1125
|
+
listWasDismissed,
|
|
1126
|
+
]);
|
|
1103
1127
|
|
|
1104
1128
|
// ==========================================================================
|
|
1105
1129
|
// IMPERATIVE HANDLE
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-google-places-autocomplete",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint . && prettier --write .",
|
|
9
9
|
"release": "npx release-it",
|
|
10
|
-
"prettier": "prettier --write ."
|
|
10
|
+
"prettier": "prettier --write .",
|
|
11
|
+
"prepare": "husky install"
|
|
11
12
|
},
|
|
12
13
|
"author": "Farid from Safi",
|
|
13
14
|
"license": "MIT",
|
|
@@ -30,14 +31,14 @@
|
|
|
30
31
|
"homepage": "https://github.com/FaridSafi/react-native-google-places-autocomplete#readme",
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"lodash.debounce": "^4.0.8",
|
|
33
|
-
"qs": "
|
|
34
|
+
"qs": "^6.14.1",
|
|
34
35
|
"react-native-uuid": "^2.0.3"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@react-native-community/eslint-config": "2.0.0",
|
|
38
39
|
"eslint": "7.10.0",
|
|
39
40
|
"eslint-plugin-prettier": "^3.1.2",
|
|
40
|
-
"husky": "
|
|
41
|
+
"husky": "^8.0.3",
|
|
41
42
|
"lint-staged": "10.4.0",
|
|
42
43
|
"prettier": "2.1.2",
|
|
43
44
|
"typescript": "^3.8.3"
|
|
@@ -45,12 +46,13 @@
|
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"react-native": ">= 0.59"
|
|
47
48
|
},
|
|
48
|
-
"husky": {
|
|
49
|
-
"hooks": {
|
|
50
|
-
"pre-commit": "lint-staged"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
49
|
"lint-staged": {
|
|
54
|
-
"
|
|
50
|
+
"*.{js,jsx,ts,tsx}": [
|
|
51
|
+
"eslint --fix",
|
|
52
|
+
"prettier --write"
|
|
53
|
+
],
|
|
54
|
+
"*.{json,md,yml,yaml}": [
|
|
55
|
+
"prettier --write"
|
|
56
|
+
]
|
|
55
57
|
}
|
|
56
58
|
}
|