@wikala/spmkt 2.31.1 → 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 (123) 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/CreditCard/Everyware.vue +10 -10
  30. package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
  31. package/components/Cart/CreditCard/SquarePay.vue +18 -16
  32. package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
  33. package/components/Cart/Delivery/Delivery.vue +16 -12
  34. package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
  35. package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
  36. package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
  37. package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
  38. package/components/Cart/Delivery/ReservationSlots.vue +14 -8
  39. package/components/Cart/Disclaimer.vue +1 -1
  40. package/components/Cart/OrderConfirmation.vue +1 -1
  41. package/components/Cart/Payment/Payment.vue +37 -33
  42. package/components/Cart/Payment/PaymentMethods.vue +6 -4
  43. package/components/Cart/ReviewAndSubmit.vue +9 -7
  44. package/components/Cart/ShoppingCart.vue +42 -31
  45. package/components/Cart/Store/actions.js +1 -1
  46. package/components/Cart/Store/getters.js +2 -1
  47. package/components/Cart/Store/index.js +1 -1
  48. package/components/Cart/Store/mutations.js +7 -5
  49. package/components/Cart/UserIdentity.vue +1 -1
  50. package/components/Category/CategoryFilter.vue +128 -114
  51. package/components/Category/CategorySort.vue +44 -32
  52. package/components/Category/LoadMore.vue +39 -23
  53. package/components/DeliverTo.vue +10 -15
  54. package/components/DeliveryNotice.vue +72 -68
  55. package/components/DobInput.vue +23 -23
  56. package/components/Gmaps/GmapsAutocomplete.vue +139 -78
  57. package/components/Gmaps/GmapsLocations.vue +1 -1
  58. package/components/Gmaps/GmapsSingleLocation.vue +121 -87
  59. package/components/ModalContainer/ModalContainer.vue +12 -9
  60. package/components/ModalContainer/index.js +61 -18
  61. package/components/Product/AddToCart.vue +237 -221
  62. package/components/Product/BoxAddToCart.vue +114 -86
  63. package/components/Product/Compare.vue +68 -48
  64. package/components/Product/CompareBox.vue +128 -123
  65. package/components/Product/Lookup.vue +92 -65
  66. package/components/Product/Photo.vue +105 -66
  67. package/components/Product/Price.vue +64 -43
  68. package/components/Product/ProductAutocomplete.vue +52 -57
  69. package/components/Product/ProductBox.vue +61 -38
  70. package/components/Product/ProductImages.vue +83 -86
  71. package/components/Product/Quantity.vue +115 -53
  72. package/components/Product/QuickView.vue +52 -45
  73. package/components/Product/RelatedProducts.vue +88 -23
  74. package/components/Product/SKU.vue +27 -8
  75. package/components/Product/Variants.vue +335 -341
  76. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  77. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  78. package/components/Product/reviews-questions/Review.vue +54 -59
  79. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  80. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  81. package/components/Product/reviews-questions/Vote.vue +83 -57
  82. package/components/QuantityInput.vue +18 -8
  83. package/components/RangeInput.vue +15 -8
  84. package/components/Recaptcha.vue +8 -1
  85. package/components/SelectShippingCountry.vue +81 -62
  86. package/components/TimedOffer.vue +59 -74
  87. package/composables/globals.js +53 -0
  88. package/config.js +5 -2
  89. package/index.js +41 -10
  90. package/install.js +75 -0
  91. package/locales/en.json +2 -1
  92. package/locales/sr.json +2 -1
  93. package/package.json +43 -30
  94. package/utils/directives.js +28 -45
  95. package/utils/event-bus.js +56 -0
  96. package/utils/filters.js +24 -7
  97. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  98. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  99. package/babel.config.js +0 -5
  100. package/components/Account/ChangeEmail.vue +0 -133
  101. package/components/Account/ChangeName.vue +0 -92
  102. package/components/Account/ChangePassword.vue +0 -94
  103. package/components/Account/CreditCards.vue +0 -18
  104. package/components/Account/Orders.vue +0 -110
  105. package/components/Account/Settings.vue +0 -18
  106. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  107. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  108. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  109. package/components/Instagram.vue +0 -49
  110. package/components/ProductImageModal.vue +0 -41
  111. package/jest.config.js +0 -16
  112. package/test/e2e/.babelrc.js +0 -8
  113. package/test/e2e/.eslintrc.js +0 -11
  114. package/test/e2e/accAuth.spec.js +0 -64
  115. package/test/e2e/ageGate.spec.js +0 -26
  116. package/test/e2e/checkout.spec.js +0 -106
  117. package/test/e2e/compare.spec.js +0 -52
  118. package/test/e2e/config/data.js +0 -21
  119. package/test/e2e/config/routes.js +0 -11
  120. package/test/e2e/region.spec.js +0 -46
  121. package/test/e2e/search.spec.js +0 -32
  122. package/tests/vueBuefy.js +0 -4
  123. package/tsconfig.json +0 -8
@@ -6,7 +6,7 @@
6
6
  <GmapsAutocomplete
7
7
  :label="$t('address.findStreetAddress')"
8
8
  @input="gmapsPlaceInput"
9
- :restrict-to-countries="[initialState.localized_version.current.country_iso]"
9
+ :restrict-to-countries="[initialState?.localized_version?.current?.country_iso]"
10
10
  />
11
11
  <div v-if="!editAutocompleteAddress">
12
12
  <Address :address-data="autocompleteAddress" :actions-enabled="[]"/>
@@ -80,7 +80,7 @@
80
80
  @select="onSelectCountry($event)"
81
81
  :disabled="countryInputDisabled"
82
82
  >
83
- <template slot="empty">No results found</template>
83
+ <template #empty>No results found</template>
84
84
  </b-autocomplete>
85
85
  </b-field>
86
86
  </div>
@@ -99,7 +99,7 @@
99
99
  @blur="onBlurState"
100
100
  @select="onSelectState($event)"
101
101
  >
102
- <template slot="empty">No results found</template>
102
+ <template #empty>No results found</template>
103
103
  </b-autocomplete>
104
104
  </b-field>
105
105
  </div>
@@ -155,7 +155,8 @@
155
155
  </div>
156
156
  <div class="column" v-if="!hiddenFields.postcode">
157
157
  <PostalCode
158
- v-model="addressData.postcode"
158
+ :modelValue="addressData.postcode"
159
+ @update:modelValue="addressData.postcode = $event"
159
160
  :error="errors.postcode"
160
161
  :country="addressData && addressData.country ? addressData.country.iso : ''"
161
162
  @error="errors.postcode = $event"
@@ -172,7 +173,7 @@
172
173
  :message="errors.phone"
173
174
  >
174
175
  <b-input
175
- v-mask="initialState.phoneNumberMask"
176
+ v-mask="initialState?.phoneNumberMask"
176
177
  native-value="inside"
177
178
  v-model="addressData.phone"
178
179
  name="phone"
@@ -186,7 +187,7 @@
186
187
  <div class="columns" v-if="showBusiness">
187
188
  <div class="column">
188
189
  <b-field>
189
- <b-checkbox v-model="businessAddress" @input="onChangeIsBusiness($event)">{{ $t('address.isBusiness') }} </b-checkbox>
190
+ <b-checkbox v-model="businessAddress" @update:model-value="onChangeIsBusiness($event)">{{ $t('address.isBusiness') }} </b-checkbox>
190
191
  </b-field>
191
192
  </div>
192
193
  </div>
@@ -246,294 +247,281 @@
246
247
  </div>
247
248
  </template>
248
249
 
249
- <script>
250
+ <script setup>
251
+ import { ref, computed, watch, onMounted } from 'vue'
252
+ import { useInitialState, useLocale, useT } from '../../composables/globals'
250
253
  import _ from 'underscore'
251
- import gmaps from '../../utils/gmaps'
252
- import GmapsAutocomplete from '../Gmaps/GmapsAutocomplete'
254
+ import gmaps from '../../utils/google/gmaps'
255
+ import GmapsAutocomplete from '../Gmaps/GmapsAutocomplete.vue'
253
256
  import { addressSchema } from './address.schema'
254
257
 
255
- import PostalCode from './PostalCode'
256
- import Address from './Address'
258
+ import PostalCode from './PostalCode.vue'
259
+ import Address from './Address.vue'
257
260
 
258
- export default {
259
- name: 'EditAddress',
260
-
261
- components: { Address, PostalCode, GmapsAutocomplete },
262
-
263
- props: {
264
- countries: {
265
- type: Array,
266
- default: () => {
267
- return []
268
- }
269
- },
270
- gmapsAutocomplete: {
271
- type: Boolean,
272
- default: false
273
- },
274
- editAutocompleteAddress: {
275
- type: Boolean,
276
- default: false
277
- },
278
- addressData: {
279
- type: Object
280
- },
281
- hiddenFields: {
282
- type: Object,
283
- default: function () {
284
- return { ...addressSchema }
285
- }
286
- },
287
- showBusiness: {
288
- type: Boolean,
289
- default: true
290
- },
291
- errors: {
292
- type: Object,
293
- default: function () {
294
- return { ...addressSchema }
295
- }
296
- }
261
+ const props = defineProps({
262
+ countries: {
263
+ type: Array,
264
+ default: () => []
297
265
  },
298
-
299
- data() {
300
- return {
301
- businessAddress: false,
302
- states: [],
303
- selected: '',
304
- selectedCountry: null,
305
- selectedCountryLabel: '',
306
- selectedState: null,
307
- selectedStateLabel: '',
308
- fStateLabel: 'State',
309
- fStateVisible: false,
310
- countryInputDisabled: false,
311
- autocompleteAddress: {},
312
- showEditAutocompleteAddress: true
313
- }
266
+ gmapsAutocomplete: {
267
+ type: Boolean,
268
+ default: false
314
269
  },
315
-
316
- watch: {
317
- editAutocompleteAddress: function (v) {
318
- this.showEditAutocompleteAddress = false
319
- }
270
+ editAutocompleteAddress: {
271
+ type: Boolean,
272
+ default: false
273
+ },
274
+ addressData: {
275
+ type: Object
276
+ },
277
+ hiddenFields: {
278
+ type: Object,
279
+ default: () => ({ ...addressSchema })
320
280
  },
281
+ showBusiness: {
282
+ type: Boolean,
283
+ default: true
284
+ },
285
+ errors: {
286
+ type: Object,
287
+ default: () => ({ ...addressSchema })
288
+ }
289
+ })
290
+
291
+ const emit = defineEmits(['editAutocompleteAddress', 'gmapsPlaceInput', 'provinceChanged'])
292
+
293
+ const { t: $t } = useT()
294
+ const initialState = useInitialState()
295
+ const $LC = useLocale()
296
+
297
+ // Reactive state
298
+ const businessAddress = ref(false)
299
+ const states = ref([])
300
+ const selected = ref('')
301
+ const selectedCountry = ref(null)
302
+ const selectedCountryLabel = ref('')
303
+ const selectedState = ref(null)
304
+ const selectedStateLabel = ref('')
305
+ const fStateLabel = ref('State')
306
+ const fStateVisible = ref(false)
307
+ const countryInputDisabled = ref(false)
308
+ const autocompleteAddress = ref({})
309
+ const showEditAutocompleteAddress = ref(true)
310
+
311
+ // Watchers
312
+ watch(() => props.editAutocompleteAddress, (v) => {
313
+ showEditAutocompleteAddress.value = false
314
+ })
315
+
316
+ // Computed properties
317
+ const filteredCountry = computed(() => {
318
+ if (!selectedCountryLabel.value) {
319
+ selectedState.value = null
320
+ selectedStateLabel.value = ''
321
+ return props.countries
322
+ }
323
+ return props.countries
324
+ .filter((option) => {
325
+ return option.name.toString().toLowerCase().indexOf(selectedCountryLabel.value.toLowerCase()) >= 0
326
+ })
327
+ .slice(0, 5)
328
+ })
329
+
330
+ const filteredState = computed(() => {
331
+ if (!selectedStateLabel.value) {
332
+ return states.value
333
+ }
334
+ return states.value.filter((option) => {
335
+ return option.name.toString().toLowerCase().indexOf(selectedStateLabel.value.toLowerCase()) >= 0
336
+ }).slice(0, 5)
337
+ })
338
+
339
+ // Methods
340
+ const onEditAutocompleteAddress = () => {
341
+ emit('editAutocompleteAddress', true)
342
+ showEditAutocompleteAddress.value = false
343
+ }
321
344
 
322
- computed: {
323
- filteredCountry() {
324
- if (!this.selectedCountryLabel) {
325
- this.selectedState = null
326
- this.selectedStateLabel = ''
327
- return this.countries //.slice(0, 50)
328
- }
329
- return this.countries
330
- .filter((option) => {
331
- //console.log('filter opt ', option.name.toString().toLowerCase())
332
- return option.name.toString().toLowerCase().indexOf(this.selectedCountryLabel.toLowerCase()) >= 0
333
- })
334
- .slice(0, 5)
335
- },
336
-
337
- filteredState() {
338
- if (!this.selectedStateLabel) {
339
- return this.states
340
- }
341
- return this.states.filter((option) => {
342
- //console.log('filter opt ', option.name.toString().toLowerCase())
343
- return option.name.toString().toLowerCase().indexOf(this.selectedStateLabel.toLowerCase()) >= 0
344
- }).slice(0, 5)
345
+ const gmapsPlaceInput = (pl) => {
346
+ showEditAutocompleteAddress.value = true
347
+ autocompleteAddress.value = pl.address
348
+ let country = findCountry(autocompleteAddress.value.country_iso)
349
+ if(country) {
350
+ autocompleteAddress.value.country_id = country.id
351
+ let province = findProvince(autocompleteAddress.value.state_abbr, country.states)
352
+ if(province) {
353
+ autocompleteAddress.value.state_id = province.id
345
354
  }
346
- },
355
+ }
356
+ emit('gmapsPlaceInput', autocompleteAddress.value)
357
+ }
347
358
 
348
- methods: {
349
-
350
- onEditAutocompleteAddress() {
351
- this.$emit('editAutocompleteAddress', true)
352
- this.showEditAutocompleteAddress = false
353
- },
354
-
355
- gmapsPlaceInput(pl) {
356
- this.showEditAutocompleteAddress = true
357
- this.autocompleteAddress = pl.address
358
- let country = this.findCountry(this.autocompleteAddress.country_iso)
359
- if(country) {
360
- this.autocompleteAddress.country_id = country.id
361
- let province = this.findProvince(this.autocompleteAddress.state_abbr, country.states)
362
- if(province) {
363
- this.autocompleteAddress.state_id = province.id
364
- }
365
- }
366
- this.$emit('gmapsPlaceInput', this.autocompleteAddress)
367
- },
368
-
369
- onFocusCountry() {
370
- this.selectedCountryLabel = ''
371
- },
372
-
373
- onBlurCountry() {
374
- setTimeout(() => {
375
- if (this.selectedCountry && !this.selectedCountryLabel) {
376
- this.selectedCountryLabel = this.selectedCountry.name
377
- }
378
- }, 200)
379
- },
380
-
381
- onSelectCountry(selected) {
382
- //console.log('onSelectCountry called', selected, this.addressData)
383
- if (!selected) {
384
- return false
385
- }
359
+ const onFocusCountry = () => {
360
+ selectedCountryLabel.value = ''
361
+ }
362
+
363
+ const onBlurCountry = () => {
364
+ setTimeout(() => {
365
+ if (selectedCountry.value && !selectedCountryLabel.value) {
366
+ selectedCountryLabel.value = selectedCountry.value.name
367
+ }
368
+ }, 200)
369
+ }
386
370
 
387
- this.errors.country_id = ''
388
- this.selectedState = null
389
- this.selectedStateLabel = ''
390
- this.addressData.country_id = null
391
- this.addressData.country = null
392
- this.states = []
393
- this.fStateLabel = this.$t('address.lState')
394
- this.fStateVisible = false
371
+ const onSelectCountry = (selected) => {
372
+ if (!selected) {
373
+ return false
374
+ }
395
375
 
396
- this.addressData.state_id = null
397
- this.addressData.state = null
376
+ props.errors.country_id = ''
377
+ selectedState.value = null
378
+ selectedStateLabel.value = ''
379
+ props.addressData.country_id = null
380
+ props.addressData.country = null
381
+ states.value = []
382
+ fStateLabel.value = $t('address.state')
383
+ fStateVisible.value = false
398
384
 
399
- this.selectedCountry = selected
385
+ props.addressData.state_id = null
386
+ props.addressData.state = null
400
387
 
401
- if (!this.selectedCountryLabel) {
402
- this.selectedCountryLabel = selected.name
403
- }
404
- if (selected.iso == 'CA') {
405
- this.fStateLabel = this.$t('address.stateCanada')
406
- }
407
- if (_.contains(['US', 'CA'], selected.iso)) {
408
- this.fStateVisible = true
409
- }
410
- this.addressData.country_id = selected.id
411
- this.addressData.country = selected
412
- this.states = selected.states
413
- },
414
-
415
- onFocusState() {
416
- this.selectedStateLabel = ''
417
- },
418
-
419
- onBlurState() {
420
- setTimeout(() => {
421
- if (this.selectedState && !this.selectedStateLabel) {
422
- this.selectedStateLabel = this.selectedState.name
423
- }
424
- }, 200)
425
- },
426
-
427
- onSelectState(selected) {
428
- if (!selected) {
429
- return false
430
- }
431
- this.errors['state_id'] = ''
432
- this.addressData.state_id = null
433
- this.addressData.state = null
434
- if (selected) {
435
- this.selectedStateLabel = selected.name
436
- this.addressData.state_id = selected.id
437
- this.addressData.state = selected
438
- this.selectedState = selected
439
- }
440
- this.$emit('provinceChanged', selected)
441
- },
388
+ selectedCountry.value = selected
442
389
 
443
- frmChange($event) {
444
- //console.log('frm change ', $event.target.name)
445
- if(!(this.addressData?.country?.iso === 'CA' && $event.target.name === 'postcode')) {
446
- this.errors[$event.target.name] = ''
447
- }
448
- },
390
+ if (!selectedCountryLabel.value) {
391
+ selectedCountryLabel.value = selected.name
392
+ }
393
+ if (selected.iso == 'CA') {
394
+ fStateLabel.value = $t('address.stateCanada')
395
+ }
396
+ if (_.contains(['US', 'CA'], selected.iso)) {
397
+ fStateVisible.value = true
398
+ }
399
+ props.addressData.country_id = selected.id
400
+ props.addressData.country = selected
401
+ states.value = selected.states
402
+ }
449
403
 
450
- async setCoordinates() {
451
- this.addressData.coordinates = await gmaps.geocodeAddress(Address.getFormatted(this.addressData))
452
- },
404
+ const onFocusState = () => {
405
+ selectedStateLabel.value = ''
406
+ }
453
407
 
454
- findCountry(query) {
455
- let field = 'iso'
456
- if(Number.isInteger(query)) {
457
- field = 'id'
458
- }
459
- return _.findWhere(this.countries, {
460
- [field]: query
461
- })
462
- },
463
-
464
- findProvince(query, states) {
465
- let field = 'abbr'
466
- if(Number.isInteger(query)) {
467
- field = 'id'
468
- }
469
- return _.findWhere(states, {
470
- [field]: query
471
- })
472
- },
473
-
474
- onChangeIsBusiness(e) {
475
- if(e) {
476
- this.addressData.type = 'business'
477
- } else {
478
- this.addressData.type = 'personal'
479
- }
408
+ const onBlurState = () => {
409
+ setTimeout(() => {
410
+ if (selectedState.value && !selectedStateLabel.value) {
411
+ selectedStateLabel.value = selectedState.value.name
480
412
  }
413
+ }, 200)
414
+ }
481
415
 
482
- },
416
+ const onSelectState = (selected) => {
417
+ if (!selected) {
418
+ return false
419
+ }
420
+ props.errors['state_id'] = ''
421
+ props.addressData.state_id = null
422
+ props.addressData.state = null
423
+ if (selected) {
424
+ selectedStateLabel.value = selected.name
425
+ props.addressData.state_id = selected.id
426
+ props.addressData.state = selected
427
+ selectedState.value = selected
428
+ }
429
+ emit('provinceChanged', selected)
430
+ }
483
431
 
484
- async mounted() {
432
+ const frmChange = ($event) => {
433
+ if(!(props.addressData?.country?.iso === 'CA' && $event.target.name === 'postcode')) {
434
+ props.errors[$event.target.name] = ''
435
+ }
436
+ }
485
437
 
486
- let initialCountry = null
487
- let initialProvince = null
488
- let internationalShipping = parseInt(this.initialState.localized_version.current.international_shipping)
489
- let localizedVersionCountryISO = this.initialState.localized_version.current.country_iso
490
- let localizedVersionStateAbbr = this.initialState.localized_version.current.state_abbr
438
+ const setCoordinates = async () => {
439
+ props.addressData.coordinates = await gmaps.geocodeAddress(Address.getFormatted(props.addressData))
440
+ }
491
441
 
492
- if (internationalShipping === 0) {
493
- if(this.addressData.country_id) {
494
- initialCountry = this.findCountry(this.addressData.country_id)
495
- } else {
496
- initialCountry = this.findCountry(localizedVersionCountryISO)
497
- }
498
- this.countryInputDisabled = true
442
+ const findCountry = (query) => {
443
+ let field = 'iso'
444
+ if(Number.isInteger(query)) {
445
+ field = 'id'
446
+ }
447
+ return _.findWhere(props.countries, {
448
+ [field]: query
449
+ })
450
+ }
451
+
452
+ const findProvince = (query, states) => {
453
+ let field = 'abbr'
454
+ if(Number.isInteger(query)) {
455
+ field = 'id'
456
+ }
457
+ return _.findWhere(states, {
458
+ [field]: query
459
+ })
460
+ }
461
+
462
+ const onChangeIsBusiness = (e) => {
463
+ if(e) {
464
+ props.addressData.type = 'business'
465
+ } else {
466
+ props.addressData.type = 'personal'
467
+ }
468
+ }
469
+
470
+ // Lifecycle
471
+ onMounted(async () => {
472
+ let initialCountry = null
473
+ let initialProvince = null
474
+ let internationalShipping = parseInt(initialState?.localized_version?.current?.international_shipping || 1)
475
+ let localizedVersionCountryISO = initialState?.localized_version?.current?.country_iso
476
+ let localizedVersionStateAbbr = initialState?.localized_version?.current?.state_abbr
477
+
478
+ if (internationalShipping === 0) {
479
+ if(props.addressData.country_id) {
480
+ initialCountry = findCountry(props.addressData.country_id)
499
481
  } else {
500
- if (this.addressData.country_id) {
501
- initialCountry = this.findCountry(this.addressData.country_id)
502
- } else {
503
- initialCountry = this.findCountry(this.$LC.country_iso)
504
- }
482
+ initialCountry = findCountry(localizedVersionCountryISO)
505
483
  }
506
-
507
- if(this.addressData.state_id) {
508
- initialProvince = this.addressData.state
484
+ countryInputDisabled.value = true
485
+ } else {
486
+ if (props.addressData.country_id) {
487
+ initialCountry = findCountry(props.addressData.country_id)
488
+ } else {
489
+ initialCountry = findCountry($LC?.country_iso)
509
490
  }
491
+ }
510
492
 
511
- if (initialCountry) {
512
- this.selectedCountry = initialCountry
513
- this.selectedCountryLabel = initialCountry.name
514
- this.addressData.country_id = initialCountry.id
515
- this.addressData.country = initialCountry
516
- if (initialCountry.states) {
517
- this.states = initialCountry.states
518
- this.fStateVisible = true
519
- if (localizedVersionStateAbbr && !this.addressData.state_id) {
520
- initialProvince = this.findProvince(localizedVersionStateAbbr, initialCountry.states)
521
- }
522
- if (initialProvince) {
523
- this.selectedState = initialProvince
524
- this.selectedStateLabel = initialProvince.name
525
- this.addressData.state_id = initialProvince.id
526
- this.addressData.state = initialProvince
527
- }
528
- }
529
- }
493
+ if(props.addressData.state_id) {
494
+ initialProvince = props.addressData.state
495
+ }
530
496
 
531
- if(this.addressData.type === 'business') {
532
- this.businessAddress = true
533
- this.onChangeIsBusiness(true)
497
+ if (initialCountry) {
498
+ selectedCountry.value = initialCountry
499
+ selectedCountryLabel.value = initialCountry.name
500
+ props.addressData.country_id = initialCountry.id
501
+ props.addressData.country = initialCountry
502
+ if (initialCountry.states) {
503
+ states.value = initialCountry.states
504
+ fStateVisible.value = true
505
+ if (localizedVersionStateAbbr && !props.addressData.state_id) {
506
+ initialProvince = findProvince(localizedVersionStateAbbr, initialCountry.states)
507
+ }
508
+ if (initialProvince) {
509
+ selectedState.value = initialProvince
510
+ selectedStateLabel.value = initialProvince.name
511
+ props.addressData.state_id = initialProvince.id
512
+ props.addressData.state = initialProvince
513
+ }
534
514
  }
515
+ }
535
516
 
517
+ if(props.addressData.type === 'business') {
518
+ businessAddress.value = true
519
+ onChangeIsBusiness(true)
536
520
  }
521
+ })
537
522
 
538
- }
523
+ // Expose methods that might be called from parent
524
+ defineExpose({
525
+ setCoordinates
526
+ })
539
527
  </script>
@@ -6,9 +6,8 @@
6
6
  label-position="inside"
7
7
  >
8
8
  <b-input
9
- @input="onPostCodeInput"
10
- native-value="inside"
11
- :value="value"
9
+ :model-value="modelValue"
10
+ @update:model-value="onPostCodeInput"
12
11
  name="postcode"
13
12
  data-test="address-postcode"
14
13
  autocomplete="postal-code"
@@ -21,7 +20,7 @@ export default {
21
20
  name: 'PostalCode',
22
21
 
23
22
  props: {
24
- value: {
23
+ modelValue: {
25
24
  type: String,
26
25
  default: ''
27
26
  },
@@ -35,28 +34,30 @@ export default {
35
34
  }
36
35
  },
37
36
 
38
- methods: {
39
- validateCanadianPostCode(postcode) {
40
- let postalRegExp = new RegExp(/^(?!.*[DFIOQU])[A-VXY][0-9][A-Z][\s]*[0-9][A-Z][0-9]$/i)
37
+ emits: ['update:modelValue', 'error'],
38
+
39
+ setup(props, { emit }) {
40
+ const validateCanadianPostCode = (postcode) => {
41
+ const postalRegExp = new RegExp(/^(?!.*[DFIOQU])[A-VXY][0-9][A-Z][\s]*[0-9][A-Z][0-9]$/i)
41
42
  return postalRegExp.test(postcode)
42
- },
43
+ }
43
44
 
44
- onPostCodeInput(payload) {
45
- //this.$bus.$emit('postalCodeChange', this.addressData.postcode)
46
- //console.log('onPostCodeInput', 'c:', this.country, 'v:', this.value, 'pl:', payload)
47
- this.$emit('error', '')
48
- payload = payload.trim()
49
- if(this.country === 'CA') {
50
- if(!this.validateCanadianPostCode(payload)) {
51
- this.$emit('error', 'Invalid postal code')
52
- } else {
53
- this.$emit('input', payload)
54
- }
55
- } else {
56
- this.$emit('input', payload)
45
+ const onPostCodeInput = (value) => {
46
+ emit('error', '')
47
+
48
+ // Always emit the value update without trimming during typing
49
+ emit('update:modelValue', value)
50
+
51
+ // For Canadian postal codes, validate the trimmed value
52
+ const trimmedValue = value.trim()
53
+ if (props.country === 'CA' && trimmedValue && !validateCanadianPostCode(trimmedValue)) {
54
+ emit('error', 'Invalid postal code')
57
55
  }
58
56
  }
59
57
 
58
+ return {
59
+ onPostCodeInput
60
+ }
60
61
  }
61
62
  }
62
63
  </script>