@dative-gpi/foundation-shared-components 1.0.139-editablerefacto-3 → 1.0.139-editablerefacto-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.
@@ -23,7 +23,7 @@
23
23
  v-bind="{ color: $props.color, colors }"
24
24
  >
25
25
  <v-btn
26
- v-if="!$props.removeDisabled"
26
+ v-if="$props.showRemove"
27
27
  class="fs-tag-button"
28
28
  :ripple="false"
29
29
  @click="$emit('remove')"
@@ -81,10 +81,10 @@ export default defineComponent({
81
81
  required: false,
82
82
  default: ColorEnum.Light
83
83
  },
84
- removeDisabled: {
84
+ showRemove: {
85
85
  type: Boolean,
86
86
  required: false,
87
- default: false
87
+ default: true
88
88
  }
89
89
  },
90
90
  emits: ["remove"],
@@ -6,7 +6,7 @@
6
6
  <FSTag
7
7
  v-for="(tag, index) in $props.tags"
8
8
  :variant="$props.tagVariant"
9
- :removeDisabled="$props.removeDisabled"
9
+ :showRemove="$props.showRemove"
10
10
  :color="$props.color"
11
11
  :label="tag"
12
12
  :key="index"
@@ -21,7 +21,7 @@
21
21
  <FSTag
22
22
  v-for="(tag, index) in $props.tags"
23
23
  :variant="$props.tagVariant"
24
- :removeDisabled="$props.removeDisabled"
24
+ :showRemove="$props.showRemove"
25
25
  :color="$props.color"
26
26
  :label="tag"
27
27
  :key="index"
@@ -66,10 +66,10 @@ export default defineComponent({
66
66
  required: false,
67
67
  default: ColorEnum.Light
68
68
  },
69
- removeDisabled: {
69
+ showRemove: {
70
70
  type: Boolean,
71
71
  required: false,
72
- default: false
72
+ default: true
73
73
  }
74
74
  }
75
75
  });
@@ -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"
@@ -501,11 +501,11 @@ export default defineComponent({
501
501
  return;
502
502
  }
503
503
  const editorModelValue = JSON.stringify(editorState.toJSON());
504
- if(editorModelValue === emptyLexicalState) {
504
+ if(editorModelValue === emptyLexicalState && props.modelValue !== null) {
505
505
  emit("update:modelValue", null);
506
506
  return;
507
507
  }
508
- if(editorModelValue !== props.modelValue) {
508
+ if(editorModelValue !== emptyLexicalState && editorModelValue !== props.modelValue) {
509
509
  emit("update:modelValue", editorModelValue);
510
510
  }
511
511
  });
@@ -674,21 +674,16 @@ export default defineComponent({
674
674
  return;
675
675
  }
676
676
  if (props.modelValue != null) {
677
- editor.update(() => {
678
- if (typeof props.modelValue === "string") {
679
- if (props.modelValue !== "") {
680
- editor.setEditorState(editor.parseEditorState(props.modelValue!));
681
- }
682
- }
683
- else {
684
- editor.setEditorState(editor.parseEditorState(JSON.stringify(props.modelValue)));
685
- }
686
- });
687
- return;
677
+ if (typeof props.modelValue === "string" && props.modelValue !== "") {
678
+ editor.setEditorState(editor.parseEditorState(props.modelValue!));
679
+ return;
680
+ }
681
+ if (typeof props.modelValue === "object") {
682
+ editor.setEditorState(editor.parseEditorState(JSON.stringify(props.modelValue)));
683
+ return;
684
+ }
688
685
  }
689
- editor.update(() => {
690
- editor.setEditorState(editor.parseEditorState(emptyLexicalState));
691
- });
686
+ editor.setEditorState(editor.parseEditorState(emptyLexicalState));
692
687
  }
693
688
 
694
689
  watch(() => props.modelValue, () => {
@@ -40,7 +40,7 @@
40
40
  </FSTextField>
41
41
  <FSTagGroup
42
42
  :tagVariant="$props.tagVariant"
43
- :removeDisabled="$props.disabled"
43
+ :showRemove="!$props.disabled"
44
44
  :tags="$props.modelValue"
45
45
  :color="$props.tagColor"
46
46
  @remove="onRemove"
@@ -14,7 +14,6 @@
14
14
  height="100%"
15
15
  :to="$props.to"
16
16
  :style="style"
17
- :disabled="$props.disableClick"
18
17
  v-bind="$attrs"
19
18
  >
20
19
  <slot />
@@ -139,11 +138,6 @@ export default defineComponent({
139
138
  required: false,
140
139
  default: true
141
140
  },
142
- disableClick: {
143
- type: Boolean,
144
- required: false,
145
- default: false
146
- },
147
141
  singleSelect: {
148
142
  type: Boolean,
149
143
  required: false,
@@ -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.getElementById("places") as HTMLDivElement
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
- return _search(search).then(result => {
29
- return _.map(result, r => ({ id: r.place_id, label: r.description }));
30
- }).catch(() => {
31
- return [];
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
- sessionToken: sessionId!
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-editablerefacto-3",
4
+ "version": "1.0.139-editablerefacto-4",
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-editablerefacto-3",
14
- "@dative-gpi/foundation-shared-services": "1.0.139-editablerefacto-3"
13
+ "@dative-gpi/foundation-shared-domain": "1.0.139-editablerefacto-4",
14
+ "@dative-gpi/foundation-shared-services": "1.0.139-editablerefacto-4"
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": "cae71411b15b7e5a6abe56ac763693c88e1117e2"
38
+ "gitHead": "cd38992d9fabf5ae89b6a4606c97a9b8a8032d72"
39
39
  }