@wikala/spmkt 2.31.0 → 3.0.0-beta.0

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.
Files changed (124) hide show
  1. package/MIGRATION_GUIDE.md +261 -0
  2. package/api/product.js +1 -0
  3. package/api/request.js +9 -4
  4. package/api/user.js +1 -1
  5. package/components/Account/AccountDashboard.vue +101 -101
  6. package/components/Account/AccountStore.js +57 -31
  7. package/components/Account/AffiliateReport.vue +56 -60
  8. package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
  9. package/components/Account/Orders/Orders.vue +124 -0
  10. package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
  11. package/components/Account/Settings/ChangeEmail.vue +136 -0
  12. package/components/Account/Settings/ChangeName.vue +82 -0
  13. package/components/Account/Settings/ChangePassword.vue +91 -0
  14. package/components/Address/Address.vue +38 -57
  15. package/components/Address/AddressBook.vue +77 -57
  16. package/components/Address/AddressSelect.vue +94 -87
  17. package/components/Address/Edit.vue +253 -265
  18. package/components/Address/PostalCode.vue +22 -21
  19. package/components/AgeGate.vue +11 -5
  20. package/components/Auth/Login.vue +62 -44
  21. package/components/Auth/Register.vue +82 -60
  22. package/components/Auth/ResetPassword.vue +45 -30
  23. package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
  24. package/components/Cart/CartBadge.vue +15 -4
  25. package/components/Cart/CartBox.vue +19 -11
  26. package/components/Cart/CartItem.vue +3 -3
  27. package/components/Cart/CartMode.vue +6 -5
  28. package/components/Cart/CartPreview.vue +24 -18
  29. package/components/Cart/Coupon.vue +4 -5
  30. package/components/Cart/CreditCard/Everyware.vue +10 -10
  31. package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
  32. package/components/Cart/CreditCard/SquarePay.vue +18 -16
  33. package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
  34. package/components/Cart/Delivery/Delivery.vue +16 -12
  35. package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
  36. package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
  37. package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
  38. package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
  39. package/components/Cart/Delivery/ReservationSlots.vue +14 -8
  40. package/components/Cart/Disclaimer.vue +1 -1
  41. package/components/Cart/OrderConfirmation.vue +1 -1
  42. package/components/Cart/Payment/Payment.vue +37 -33
  43. package/components/Cart/Payment/PaymentMethods.vue +6 -4
  44. package/components/Cart/ReviewAndSubmit.vue +9 -7
  45. package/components/Cart/ShoppingCart.vue +42 -31
  46. package/components/Cart/Store/actions.js +1 -1
  47. package/components/Cart/Store/getters.js +2 -1
  48. package/components/Cart/Store/index.js +1 -1
  49. package/components/Cart/Store/mutations.js +7 -5
  50. package/components/Cart/UserIdentity.vue +1 -1
  51. package/components/Category/CategoryFilter.vue +128 -114
  52. package/components/Category/CategorySort.vue +44 -32
  53. package/components/Category/LoadMore.vue +39 -23
  54. package/components/DeliverTo.vue +10 -15
  55. package/components/DeliveryNotice.vue +72 -68
  56. package/components/DobInput.vue +23 -23
  57. package/components/Gmaps/GmapsAutocomplete.vue +139 -78
  58. package/components/Gmaps/GmapsLocations.vue +1 -1
  59. package/components/Gmaps/GmapsSingleLocation.vue +121 -87
  60. package/components/ModalContainer/ModalContainer.vue +12 -9
  61. package/components/ModalContainer/index.js +61 -18
  62. package/components/Product/AddToCart.vue +237 -221
  63. package/components/Product/BoxAddToCart.vue +114 -86
  64. package/components/Product/Compare.vue +68 -48
  65. package/components/Product/CompareBox.vue +128 -123
  66. package/components/Product/Lookup.vue +92 -65
  67. package/components/Product/Photo.vue +105 -66
  68. package/components/Product/Price.vue +64 -43
  69. package/components/Product/ProductAutocomplete.vue +52 -57
  70. package/components/Product/ProductBox.vue +61 -38
  71. package/components/Product/ProductImages.vue +83 -86
  72. package/components/Product/Quantity.vue +115 -53
  73. package/components/Product/QuickView.vue +52 -45
  74. package/components/Product/RelatedProducts.vue +88 -23
  75. package/components/Product/SKU.vue +27 -8
  76. package/components/Product/Variants.vue +335 -341
  77. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  78. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  79. package/components/Product/reviews-questions/Review.vue +54 -59
  80. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  81. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  82. package/components/Product/reviews-questions/Vote.vue +83 -57
  83. package/components/QuantityInput.vue +18 -8
  84. package/components/RangeInput.vue +15 -8
  85. package/components/Recaptcha.vue +8 -1
  86. package/components/SelectShippingCountry.vue +81 -62
  87. package/components/TimedOffer.vue +59 -74
  88. package/composables/globals.js +53 -0
  89. package/config.js +5 -2
  90. package/index.js +41 -10
  91. package/install.js +75 -0
  92. package/locales/en.json +2 -1
  93. package/locales/sr.json +2 -1
  94. package/package.json +43 -30
  95. package/utils/directives.js +28 -45
  96. package/utils/event-bus.js +56 -0
  97. package/utils/filters.js +24 -7
  98. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  99. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  100. package/babel.config.js +0 -5
  101. package/components/Account/ChangeEmail.vue +0 -133
  102. package/components/Account/ChangeName.vue +0 -92
  103. package/components/Account/ChangePassword.vue +0 -94
  104. package/components/Account/CreditCards.vue +0 -18
  105. package/components/Account/Orders.vue +0 -110
  106. package/components/Account/Settings.vue +0 -18
  107. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  108. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  109. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  110. package/components/Instagram.vue +0 -49
  111. package/components/ProductImageModal.vue +0 -41
  112. package/jest.config.js +0 -16
  113. package/test/e2e/.babelrc.js +0 -8
  114. package/test/e2e/.eslintrc.js +0 -11
  115. package/test/e2e/accAuth.spec.js +0 -64
  116. package/test/e2e/ageGate.spec.js +0 -26
  117. package/test/e2e/checkout.spec.js +0 -106
  118. package/test/e2e/compare.spec.js +0 -52
  119. package/test/e2e/config/data.js +0 -21
  120. package/test/e2e/config/routes.js +0 -11
  121. package/test/e2e/region.spec.js +0 -46
  122. package/test/e2e/search.spec.js +0 -32
  123. package/tests/vueBuefy.js +0 -4
  124. package/tsconfig.json +0 -8
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <b-modal :can-cancel="false" :active="showModal" has-modal-card>
2
+ <b-modal v-model="showModal" :can-cancel="false" has-modal-card>
3
3
  <div class="modal-card" v-if="locale">
4
4
  <header class="modal-card-head">
5
5
  <p v-if="availableLocalSite" class="modal-card-title">
@@ -12,14 +12,14 @@
12
12
  <div class="modal-card-body delivery-notice">
13
13
  <div>
14
14
  <div v-if="availableLocalSite">
15
- <div style="margin-bottom:1rem">
15
+ <div style="margin-bottom: 1rem">
16
16
  We are showing you items that might not be available in your current location. To see items that ship to
17
17
  <strong>{{ locale.country }}</strong
18
18
  >, please visit <a :href="availableLocalSite[2]">{{ availableLocalSite[3] }}</a>
19
19
  </div>
20
20
  </div>
21
21
  <div v-else>
22
- <div style="margin-bottom:1rem">
22
+ <div style="margin-bottom: 1rem">
23
23
  Unfortunately, we do not ship to your current location. Feel free to stick around and explore.
24
24
  </div>
25
25
  </div>
@@ -28,12 +28,14 @@
28
28
  <footer class="modal-card-foot">
29
29
  <div>
30
30
  <div v-if="availableLocalSite">
31
- <button class="button is-primary" @click="gotoAvailableLocalSite">Go to {{ initialState.site_name }} {{ availableLocalSite[1] }}</button>
31
+ <button class="button is-primary" @click="gotoAvailableLocalSite">
32
+ Go to {{ initialState.site_name }} {{ availableLocalSite[1] }}
33
+ </button>
32
34
  <button class="button is-outlined" @click="accept">Stay on {{ currentSite }}</button>
33
35
  </div>
34
36
  <div v-else>
35
37
  <div>
36
- <button class="button is-primary" style="width: 10rem;" @click="accept">OK</button>
38
+ <button class="button is-primary" style="width: 10rem" @click="accept">OK</button>
37
39
  </div>
38
40
  </div>
39
41
  </div>
@@ -42,78 +44,80 @@
42
44
  </b-modal>
43
45
  </template>
44
46
 
45
- <script>
47
+ <script setup>
48
+ import { ref, computed, onMounted } from 'vue'
49
+ import { useInitialState } from '../composables/globals'
46
50
  import Cookie from 'js-cookie'
51
+ import { eventBus } from '../utils/event-bus'
47
52
 
48
- export default {
49
- name: 'DeliveryNotice',
50
- data() {
51
- return {
52
- showModal: false,
53
- remember: true,
54
- locale: null,
55
- cookieName: 'delivery-notice',
56
- currentSite: window.location.host,
57
- }
58
- },
53
+ const initialState = useInitialState()
59
54
 
60
- computed: {
61
- notice() {
62
- if (this.initialState && this.notices[this.locale.country_iso]) {
63
- return this.notices[this.locale.country_iso]
64
- } else {
65
- return this.notices['DEFAULT']
66
- }
67
- },
55
+ const showModal = ref(false)
56
+ const locale = ref(null)
57
+ const cookieName = 'delivery-notice'
58
+ const currentSite = ref(typeof window !== 'undefined' ? window.location.host : '')
68
59
 
69
- availableLocalSite() {
70
- let availableSites = this.initialState.localized_version.available
71
- if (availableSites && availableSites.length > 0) {
72
- for (let i = 0; i < availableSites.length; i++) {
73
- if (this.locale && availableSites[i][0] === this.locale.country_iso) {
74
- availableSites[i].push(new URL(availableSites[i][2]).host)
75
- return availableSites[i]
76
- }
77
- }
78
- } else {
79
- return null
80
- }
81
- },
60
+ const notice = computed(() => {
61
+ // This would need notices object from initialState
62
+ if (initialState && initialState.notices && locale.value?.country_iso) {
63
+ return initialState.notices[locale.value.country_iso]
64
+ }
65
+ return initialState.notices?.['DEFAULT'] || null
66
+ })
82
67
 
83
- randomTitle() {
84
- return this.titles[Math.floor(Math.random() * items.length)]
85
- },
86
- },
87
-
88
- methods: {
89
- gotoAvailableLocalSite() {
90
- if (!this.availableLocalSite) {
91
- return false
68
+ const availableLocalSite = computed(() => {
69
+ const availableSites = initialState.localized_version?.available
70
+ if (availableSites && availableSites.length > 0) {
71
+ for (let i = 0; i < availableSites.length; i++) {
72
+ if (locale.value && availableSites[i][0] === locale.value.country_iso) {
73
+ const siteCopy = [...availableSites[i]]
74
+ siteCopy.push(new URL(siteCopy[2]).host)
75
+ return siteCopy
92
76
  }
93
- window.location.href = this.availableLocalSite[2]
94
- },
77
+ }
78
+ }
79
+ return null
80
+ })
95
81
 
96
- accept() {
97
- Cookie.set(this.cookieName, 'yes')
98
- this.showModal = false
99
- this.$bus.$emit('showAgeGate')
100
- },
101
- },
82
+ const gotoAvailableLocalSite = () => {
83
+ if (!availableLocalSite.value) {
84
+ return false
85
+ }
86
+ window.location.href = availableLocalSite.value[2]
87
+ }
102
88
 
103
- mounted() {
104
- this.locale = this.initialState.lc
105
- let isAccepted = Cookie.get(this.cookieName)
89
+ const accept = () => {
90
+ Cookie.set(cookieName, 'yes')
91
+ showModal.value = false
92
+ eventBus.emit('showAgeGate')
93
+ }
106
94
 
107
- if (
108
- isAccepted !== 'yes' &&
109
- this.initialState.localized_version &&
110
- this.initialState.localized_version.current &&
111
- this.locale.country_iso !== this.initialState.localized_version.current.country_iso &&
112
- window.location.href.indexOf('terms-of-use') === -1 &&
113
- window.location.href.indexOf('privacy-policy') === -1
114
- ) {
115
- this.showModal = true
95
+ const attachShowModalEvent = () => {
96
+ eventBus.on('showDeliveryNotice', (pl) => {
97
+ if(pl === null) {
98
+ locale.value = null
99
+ showModal.value = false
100
+ return
116
101
  }
117
- },
102
+ locale.value = pl;
103
+ showModal.value = true
104
+ })
118
105
  }
106
+
107
+ onMounted(() => {
108
+ attachShowModalEvent()
109
+ locale.value = initialState.lc
110
+ const isAccepted = Cookie.get(cookieName)
111
+
112
+ if (
113
+ isAccepted !== 'yes' &&
114
+ initialState.localized_version &&
115
+ initialState.localized_version.current &&
116
+ locale.value?.country_iso !== initialState.localized_version.current.country_iso &&
117
+ window.location.href.indexOf('terms-of-use') === -1 &&
118
+ window.location.href.indexOf('privacy-policy') === -1
119
+ ) {
120
+ showModal.value = true
121
+ }
122
+ })
119
123
  </script>
@@ -2,7 +2,7 @@
2
2
  <div class="dob-container">
3
3
  <div :class="['dob-field', { 'dob-field-focus': fieldFocusActive }, { 'dob-field-error': error }]">
4
4
  <label class="label">{{ label }}</label>
5
- <div class="control is-clearfix dob-date">
5
+ <div class="control is-flex is-clearfix dob-date">
6
6
  <div>
7
7
  <input
8
8
  ref="mm"
@@ -91,7 +91,7 @@ export default {
91
91
  type: String,
92
92
  default: ''
93
93
  },
94
- value: {
94
+ modelValue: {
95
95
  type: String,
96
96
  default: ''
97
97
  },
@@ -101,6 +101,8 @@ export default {
101
101
  }
102
102
  },
103
103
 
104
+ emits: ['update:modelValue'],
105
+
104
106
  data() {
105
107
  return {
106
108
  fieldFocusActive: false,
@@ -112,9 +114,11 @@ export default {
112
114
  },
113
115
 
114
116
  watch: {
115
- value: function (oldv, newv) {
116
- console.log('value changed', oldv, newv)
117
- this.initValue()
117
+ modelValue: {
118
+ handler() {
119
+ this.initValue()
120
+ },
121
+ immediate: true
118
122
  }
119
123
  },
120
124
 
@@ -157,14 +161,19 @@ export default {
157
161
 
158
162
  methods: {
159
163
  initValue() {
160
- //console.log('value', this.value, typeof this.value)
161
- if (this.value) {
162
- let dob = new Date(this.value)
163
- this.yyyy = dob.getUTCFullYear()
164
- this.mm = dob.getUTCMonth() + 1
165
- this.dd = dob.getUTCDate()
166
- //console.log(dob, this.yyyy, this.mm, this.dd)
164
+ if (this.modelValue) {
165
+ const dob = new Date(this.modelValue)
166
+ if (!Number.isNaN(dob.getTime())) {
167
+ this.yyyy = dob.getUTCFullYear()
168
+ this.mm = dob.getUTCMonth() + 1
169
+ this.dd = dob.getUTCDate()
170
+ return
171
+ }
167
172
  }
173
+
174
+ this.yyyy = ''
175
+ this.mm = ''
176
+ this.dd = ''
168
177
  },
169
178
 
170
179
  onFocus(e) {
@@ -179,10 +188,6 @@ export default {
179
188
 
180
189
  onKeyUp(e, field) {
181
190
  //console.log('KEYUP', field, e)
182
- if(e.keyCode === 13) {
183
- this.$emit('input', formatDate(this.date_of_birth, 'YYYY-MM-DD'), this.age, true)
184
- return true
185
- }
186
191
  let value = ''
187
192
  if (typeof e === 'object') {
188
193
  value = e.target.value.replace(/\D/g, '')
@@ -193,9 +198,9 @@ export default {
193
198
  this[field] = value
194
199
 
195
200
  if (this.day && this.month && this.year) {
196
- this.$emit('input', formatDate(this.date_of_birth, 'YYYY-MM-DD'), this.age)
201
+ this.$emit('update:modelValue', formatDate(this.date_of_birth, 'YYYY-MM-DD'))
197
202
  } else {
198
- this.$emit('input', '', this.age)
203
+ this.$emit('update:modelValue', '')
199
204
  }
200
205
 
201
206
  if (['Backspace', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
@@ -284,11 +289,6 @@ export default {
284
289
  }
285
290
  this[field] = value
286
291
  }
287
- },
288
-
289
- mounted() {
290
- //console.log(this.value)
291
- this.initValue()
292
292
  }
293
293
  }
294
294
  </script>
@@ -7,99 +7,160 @@
7
7
  <b-field
8
8
  :label="label"
9
9
  label-position="inside"
10
+ :type="fetchFailed ? 'is-danger' : ''"
11
+ :message="fetchFailed ? $t('address.autocompleteUnavailable') : ''"
10
12
  >
11
- <b-input v-model="pacInput" id="pac-input" type="text" :placeholder="placeholderText" />
13
+ <!-- append-to-body: the address modal's body scrolls and would clip the dropdown -->
14
+ <b-autocomplete
15
+ v-model="pacInput"
16
+ append-to-body
17
+ :data="suggestions"
18
+ :loading="isFetching"
19
+ :placeholder="placeholderText"
20
+ :custom-formatter="formatSuggestion"
21
+ @typing="fetchSuggestions"
22
+ @select="selectSuggestion"
23
+ >
24
+ <template #default="{ option }">
25
+ <strong>{{ option.mainText?.toString() }}</strong>
26
+ <small v-if="option.secondaryText" class="ml-1">{{ option.secondaryText.toString() }}</small>
27
+ </template>
28
+ </b-autocomplete>
12
29
  </b-field>
13
30
  </template>
14
31
  </div>
15
32
  </template>
16
33
 
17
- <script>
34
+ <script setup>
35
+ import { ref } from 'vue'
36
+ import _ from 'underscore'
37
+ // Defines window.customEventBus, which hosts call to announce that Maps has loaded
18
38
  import '../../utils/custom-event-bus'
19
- import gmaps from '../../utils/gmaps'
20
-
21
- import addressSchema from '../Address/address.schema'
22
-
23
- export default {
24
- name: 'GmapsAutocomplete',
25
-
26
- props: {
27
- label: {
28
- type: String,
29
- default: 'Enter a street address'
30
- },
31
- placeholderText: {
32
- type: String,
33
- default: ''
34
- },
35
- restrictToCountries: {
36
- type: Array,
37
- default: function () {
38
- return []
39
- }
40
- }
41
- },
39
+ import gmaps from '../../utils/google/gmaps'
40
+ import { addressSchema } from '../Address/address.schema'
42
41
 
43
- data() {
44
- return {
45
- loading: false,
46
- loaderFailed: false,
47
- msg: '',
48
- pacInput: ''
49
- }
42
+ const props = defineProps({
43
+ label: {
44
+ type: String,
45
+ default: 'Enter a street address'
50
46
  },
47
+ placeholderText: {
48
+ type: String,
49
+ default: ''
50
+ },
51
+ restrictToCountries: {
52
+ type: Array,
53
+ default: () => []
54
+ },
55
+ inputId: {
56
+ type: String,
57
+ default: 'pac-input'
58
+ }
59
+ })
51
60
 
52
- watch: {
53
- gmapsLoading: function (nv, ov) {
54
- console.log('gmapsLoading watcher', nv, ov)
55
- if (nv) {
56
- this.init()
57
- }
61
+ const emit = defineEmits(['update:modelValue', 'input'])
62
+
63
+ const loading = ref(false)
64
+ const loaderFailed = ref(false)
65
+ const msg = ref('')
66
+ const pacInput = ref('')
67
+ const suggestions = ref([])
68
+ const isFetching = ref(false)
69
+ const fetchFailed = ref(false)
70
+ // Only the latest request may clear the spinner
71
+ let latestFetch = 0
72
+
73
+ // One token per typing-and-select session, so Google bills it as one session
74
+ let sessionToken = null
75
+
76
+ // The Maps script loads after the page module, so look the library up when it is needed
77
+ const placesApi = () => window.google?.maps?.places
78
+
79
+ const formatSuggestion = (prediction) => prediction.text.toString()
80
+
81
+ const countryCodes = () => props.restrictToCountries.filter(c => typeof c === 'string' && c.length > 0)
82
+
83
+ const fetchSuggestions = _.debounce(async (query) => {
84
+ const places = placesApi()
85
+ if (!query || !places?.AutocompleteSuggestion) {
86
+ suggestions.value = []
87
+ return
88
+ }
89
+
90
+ sessionToken ??= new places.AutocompleteSessionToken()
91
+ const request = { input: query, sessionToken }
92
+ const countries = countryCodes()
93
+ if (countries.length > 0) {
94
+ request.includedRegionCodes = countries
95
+ }
96
+
97
+ const fetchId = ++latestFetch
98
+ isFetching.value = true
99
+ try {
100
+ const response = await places.AutocompleteSuggestion.fetchAutocompleteSuggestions(request)
101
+ // Drop responses for text the user has already moved past
102
+ if (pacInput.value === query) {
103
+ suggestions.value = response.suggestions
104
+ .map(suggestion => suggestion.placePrediction)
105
+ .filter(Boolean)
58
106
  }
59
- },
107
+ fetchFailed.value = false
108
+ } catch (error) {
109
+ // Most often the key lacks the Places API (New), which AutocompleteSuggestion needs
110
+ console.error('Google Places autocomplete failed. Is the Places API (New) enabled for this key?', error)
111
+ suggestions.value = []
112
+ fetchFailed.value = true
113
+ } finally {
114
+ if (fetchId === latestFetch) {
115
+ isFetching.value = false
116
+ }
117
+ }
118
+ }, 250)
60
119
 
61
- methods: {
62
- init() {
63
- let vm = this
64
- if (!google) {
65
- console.log('Gmaps is not loaded')
66
- return false
67
- }
68
- let address = { ...addressSchema }
69
- let input = document.getElementById('pac-input')
70
-
71
- let autocomplete = new google.maps.places.Autocomplete(input)
72
- if (this.restrictToCountries.length > 0) {
73
- autocomplete.setComponentRestrictions({
74
- country: this.restrictToCountries
75
- })
120
+ // Place (New) uses longText/shortText; the shared parser expects the legacy names
121
+ const toLegacyComponents = (components) => components.map(component => ({
122
+ long_name: component.longText,
123
+ short_name: component.shortText,
124
+ types: component.types
125
+ }))
126
+
127
+ const selectSuggestion = async (prediction) => {
128
+ if (!prediction) {
129
+ return
130
+ }
131
+
132
+ const place = prediction.toPlace()
133
+ // A keystroke still waiting on the debounce would open a new, separately billed session
134
+ fetchSuggestions.cancel()
135
+ // fetchFields ends the session; the next keystroke starts a new one
136
+ sessionToken = null
137
+ suggestions.value = []
138
+
139
+ try {
140
+ await place.fetchFields({ fields: ['addressComponents', 'location', 'displayName'] })
141
+ } catch (error) {
142
+ console.error('Google Places details request failed', error)
143
+ return
144
+ }
145
+
146
+ if (!place.location) {
147
+ window.alert("No details available for input: '" + place.displayName + "'")
148
+ return
149
+ }
150
+
151
+ if (place.addressComponents) {
152
+ const parsedAddress = gmaps.getAddressFromComponents({ ...addressSchema }, toLegacyComponents(place.addressComponents))
153
+ const result = {
154
+ address: parsedAddress,
155
+ coordinates: {
156
+ lat: place.location.lat(),
157
+ lng: place.location.lng()
76
158
  }
77
- autocomplete.setFields(['address_components', 'geometry', 'icon', 'name'])
78
-
79
- autocomplete.addListener('place_changed', function () {
80
- let place = autocomplete.getPlace()
81
- if (!place.geometry) {
82
- window.alert("No details available for input: '" + place.name + "'")
83
- return
84
- }
85
-
86
- if (place.address_components) {
87
- address = gmaps.getAddressFromComponents(address, place.address_components)
88
- vm.$emit('input', { address: address, coordinates: { lat: place.geometry.location.lat(), lng: place.geometry.location.lng() } })
89
- }
90
- })
91
159
  }
92
- },
93
160
 
94
- mounted() {
95
- customEventBus.addEventListener('gmapsLoaded', () => {
96
- console.log('gmapsLoaded received')
97
- this.loading = false
98
- this.init()
99
- })
100
- if(window.google) {
101
- this.init()
102
- }
161
+ // Emit both for backwards compatibility and Vue 3 v-model
162
+ emit('input', result)
163
+ emit('update:modelValue', result)
103
164
  }
104
165
  }
105
166
  </script>
@@ -35,7 +35,7 @@ import _ from 'underscore'
35
35
 
36
36
  import { formatNumber } from '../../utils/filters'
37
37
  import '../../utils/custom-event-bus'
38
- import gmaps from '../../utils/gmaps'
38
+ import gmaps from '../../utils/google/gmaps'
39
39
  import { Address } from '../../api'
40
40
 
41
41
  import GmapsAutocomplete from './GmapsAutocomplete'