@dative-gpi/foundation-shared-components 1.0.139-richtextfield → 1.0.139-widgethiddencode
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.
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
:toggleSet="false"
|
|
6
6
|
:multiple="false"
|
|
7
7
|
:items="items"
|
|
8
|
+
:customFilter="(_label: string, _query: string, item: any) => {
|
|
9
|
+
return item.value !== $props.modelValue?.placeId;
|
|
10
|
+
}"
|
|
8
11
|
:modelValue="$props.modelValue?.placeId"
|
|
9
12
|
@update:modelValue="onUpdate"
|
|
10
13
|
v-model:search="search"
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
+
/// <reference types="@types/google.maps" />
|
|
1
2
|
import _ from "lodash";
|
|
2
3
|
|
|
3
4
|
import { Address, type Place } from "@dative-gpi/foundation-shared-domain/models";
|
|
5
|
+
import { useAppLanguageCode } from '@dative-gpi/foundation-shared-services/composables';
|
|
4
6
|
|
|
5
7
|
export const useAddress = () => {
|
|
6
8
|
const enabled = true;
|
|
9
|
+
const { languageCode } = useAppLanguageCode();
|
|
10
|
+
|
|
7
11
|
let initialized = false;
|
|
12
|
+
let userLocation: google.maps.LatLngLiteral | null;
|
|
8
13
|
let searchService: google.maps.places.AutocompleteService;
|
|
9
14
|
let placeService: google.maps.places.PlacesService;
|
|
10
15
|
let sessionId: google.maps.places.AutocompleteSessionToken;
|
|
11
|
-
|
|
12
16
|
|
|
13
17
|
const init = async () => {
|
|
14
18
|
await window.initMap;
|
|
19
|
+
userLocation = await getCurrentLocation();
|
|
15
20
|
searchService = new google.maps.places.AutocompleteService();
|
|
16
21
|
placeService = new google.maps.places.PlacesService(
|
|
17
|
-
document.
|
|
22
|
+
document.createElement("div")
|
|
18
23
|
);
|
|
19
24
|
sessionId = new google.maps.places.AutocompleteSessionToken();
|
|
20
25
|
initialized = true;
|
|
@@ -25,11 +30,12 @@ export const useAddress = () => {
|
|
|
25
30
|
await init();
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const mapsResults = await _search(search);
|
|
34
|
+
|
|
35
|
+
return mapsResults.map((result) => ({
|
|
36
|
+
id: result.place_id,
|
|
37
|
+
label: result.description
|
|
38
|
+
}));
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
const get = async (place: Place): Promise<Address> => {
|
|
@@ -78,16 +84,42 @@ export const useAddress = () => {
|
|
|
78
84
|
});
|
|
79
85
|
}
|
|
80
86
|
|
|
87
|
+
const getCurrentLocation = async (): Promise<google.maps.LatLngLiteral | null> => {
|
|
88
|
+
if (!navigator.geolocation) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
navigator.geolocation.getCurrentPosition(
|
|
94
|
+
(position) => {
|
|
95
|
+
resolve({
|
|
96
|
+
lat: position.coords.latitude,
|
|
97
|
+
lng: position.coords.longitude
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
() => resolve(null)
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
81
105
|
const _search = (search: string) => {
|
|
82
106
|
if (!enabled) {
|
|
83
107
|
throw new Error("offline mode, do not call this method");
|
|
84
108
|
}
|
|
85
109
|
return new Promise<google.maps.places.AutocompletePrediction[]>(
|
|
86
110
|
(resolve, reject) => {
|
|
111
|
+
/**
|
|
112
|
+
* ISO 3166 language code
|
|
113
|
+
*/
|
|
114
|
+
const isoLanguageCode = languageCode.value?.split("-")[0];
|
|
115
|
+
|
|
87
116
|
searchService!.getPlacePredictions(
|
|
88
117
|
{
|
|
89
118
|
input: search,
|
|
90
|
-
|
|
119
|
+
region: isoLanguageCode,
|
|
120
|
+
language: isoLanguageCode,
|
|
121
|
+
sessionToken: sessionId,
|
|
122
|
+
locationBias: userLocation,
|
|
91
123
|
},
|
|
92
124
|
function (result, status) {
|
|
93
125
|
if (status != google.maps.places.PlacesServiceStatus.OK || !result) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.139-
|
|
4
|
+
"version": "1.0.139-widgethiddencode",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "1.0.139-
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.139-
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.139-widgethiddencode",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.139-widgethiddencode"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "431f23c7e498b616485cc66cf38ff70378b99552"
|
|
39
39
|
}
|