@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
@@ -1,100 +1,134 @@
1
1
  <template>
2
- <div class="gm-single-location" id="gm-single-location"></div>
2
+ <div class="gm-single-location" id="gm-single-location" ref="mapElement"></div>
3
3
  </template>
4
4
 
5
- <script>
5
+ <script setup>
6
+ import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
7
+ import { useMq } from '../../composables/globals'
6
8
  import '../../utils/custom-event-bus'
7
- import gmaps from '../../utils/gmaps'
9
+ import gmaps from '../../utils/google/gmaps'
8
10
  import { Address } from '../../api'
9
11
 
10
- export default {
11
- name: 'GmapsSingleLocation',
12
- props: {
13
- location: {
14
- type: Object,
15
- default: function () {
16
- return {
17
- lat: 0,
18
- lng: 0
19
- }
20
- }
21
- },
22
- zoomLevel: {
23
- type: Number,
24
- default: 14
25
- },
26
- mapId: {
27
- type: String,
28
- default: ''
29
- },
30
- mapStyles: {
31
- type: Array,
32
- default: function () {
33
- return []
34
- }
35
- }
12
+ const props = defineProps({
13
+ location: {
14
+ type: Object,
15
+ default: () => ({
16
+ coordinates: { lat: 0, lng: 0 },
17
+ name: '',
18
+ address: {},
19
+ status: 0
20
+ })
36
21
  },
37
- data() {
38
- return {
39
- map: null,
40
- infowindow: null
41
- }
22
+ zoomLevel: {
23
+ type: Number,
24
+ default: 14
42
25
  },
43
- methods: {
44
- init() {
45
- let vm = this
46
-
47
- if (this.$mq === 'mobile') {
48
- gmaps.MAP_OPTIONS.disableDefaultUI = true
49
- gmaps.MAP_OPTIONS.scrollwheel = true
50
- gmaps.MAP_OPTIONS.gestureHandling = 'greedy'
51
- }
52
-
53
- if (this.mapId) {
54
- gmaps.MAP_OPTIONS.mapId = this.mapId
55
- } else {
56
- if (this.mapStyles.length > 0) {
57
- gmaps.MAP_OPTIONS.styles = this.mapStyles
58
- }
59
- }
60
- //console.log('gmaps single location init', gmaps.MAP_OPTIONS)
61
- let map = new google.maps.Map(document.getElementById('gm-single-location'), gmaps.MAP_OPTIONS)
62
-
63
- this.map = map
64
- this.infowindow = new google.maps.InfoWindow()
65
-
66
- let markerColor = 'red'
67
- if(vm.location.status === 2) {
68
- markerColor = 'yellow'
69
- }
70
- let marker = gmaps.createMarker(this.map, vm.location.coordinates.lat, vm.location.coordinates.lng, markerColor)
71
-
72
- this.map.setCenter(vm.location.coordinates)
73
- this.map.setZoom(this.zoomLevel)
74
-
75
- google.maps.event.addListener(
76
- marker,
77
- 'click',
78
- (function (marker) {
79
- return function () {
80
- vm.infowindow.setContent(`
81
- <div class="gmaps-locations-infowindow">
82
- <div><strong>${vm.location.name}</strong></div>
83
- <div>${Address.getFormatted(vm.location.address)}</div>
84
- </div>
85
- `)
86
- vm.infowindow.open(map, marker)
87
- }
88
- })(marker)
89
- )
90
- }
26
+ mapId: {
27
+ type: String,
28
+ default: ''
91
29
  },
92
- mounted() {
93
- customEventBus.addEventListener('gmapsLoaded', () => {
94
- this.init()
95
- })
30
+ mapStyles: {
31
+ type: Array,
32
+ default: () => []
33
+ }
34
+ })
35
+
36
+ const mapElement = ref(null)
37
+ const mapInstance = ref(null)
38
+ const infoWindow = ref(null)
39
+
40
+ const mq = useMq()
41
+ const isMobile = computed(() => mq.value === 'mobile')
42
+
43
+ const buildMapOptions = () => {
44
+ const options = { ...gmaps.MAP_OPTIONS }
45
+
46
+ if (isMobile.value) {
47
+ options.disableDefaultUI = true
48
+ options.scrollwheel = true
49
+ options.gestureHandling = 'greedy'
50
+ }
51
+
52
+ if (props.mapId) {
53
+ options.mapId = props.mapId
54
+ delete options.styles
55
+ } else if (props.mapStyles.length > 0) {
56
+ options.styles = props.mapStyles
57
+ delete options.mapId
58
+ } else {
59
+ delete options.mapId
60
+ delete options.styles
61
+ }
62
+
63
+ return options
64
+ }
65
+
66
+ const openInfoWindow = (marker) => {
67
+ if (!infoWindow.value || !mapInstance.value) {
68
+ return
69
+ }
70
+
71
+ const name = props.location?.name || ''
72
+ const addressHtml = Address.getFormatted(props.location?.address || {})
73
+
74
+ infoWindow.value.setContent(`
75
+ <div class="gmaps-locations-infowindow">
76
+ <div><strong>${name}</strong></div>
77
+ <div>${addressHtml}</div>
78
+ </div>
79
+ `)
80
+ infoWindow.value.open(mapInstance.value, marker)
81
+ }
82
+
83
+ const initMap = () => {
84
+ const hasGoogle = window?.google && window.google.maps && typeof window.google.maps.Map === 'function'
85
+ if (!mapElement.value || !hasGoogle || !props.location?.coordinates) {
86
+ return
96
87
  }
88
+
89
+ const options = buildMapOptions()
90
+ const map = new window.google.maps.Map(mapElement.value, options)
91
+
92
+ mapInstance.value = map
93
+ infoWindow.value = new window.google.maps.InfoWindow()
94
+
95
+ const { lat, lng } = props.location.coordinates
96
+ const markerColor = props.location.status === 2 ? 'yellow' : 'red'
97
+ const marker = gmaps.createMarker(map, lat, lng, markerColor)
98
+
99
+ map.setCenter(props.location.coordinates)
100
+ map.setZoom(props.zoomLevel)
101
+
102
+ window.google.maps.event.addListener(marker, 'click', () => {
103
+ openInfoWindow(marker)
104
+ })
105
+ }
106
+
107
+ const handleGmapsLoaded = () => {
108
+ initMap()
97
109
  }
110
+
111
+ onMounted(() => {
112
+ if (window.google?.maps?.Map) {
113
+ initMap()
114
+ }
115
+
116
+ if (window.customEventBus) {
117
+ window.customEventBus.addEventListener('gmapsLoaded', handleGmapsLoaded)
118
+ }
119
+ })
120
+
121
+ onBeforeUnmount(() => {
122
+ if (window.customEventBus?.bus) {
123
+ window.customEventBus.bus.removeEventListener('gmapsLoaded', handleGmapsLoaded)
124
+ }
125
+ })
98
126
  </script>
99
127
 
100
- <style scoped></style>
128
+ <style scoped>
129
+ .gm-single-location {
130
+ width: 100%;
131
+ height: 100%;
132
+ min-height: 320px;
133
+ }
134
+ </style>
@@ -3,7 +3,7 @@
3
3
  <div v-if="isActive" class="modal is-active" :class="classObject">
4
4
  <div class="modal-background" @click="cancel('outside')" />
5
5
  <div class="animation-content" :class="{ 'modal-content': !hasModalCard }" :style="customStyle">
6
- <component v-if="component" v-bind="props" v-on="events" :is="injectedComponent" @close="close" />
6
+ <component v-if="component" v-bind="props" v-on="events || {}" :is="injectedComponent" @close="close" />
7
7
  <div v-else-if="content" v-html="content" />
8
8
  <button type="button" v-if="showX" class="modal-close is-large" @click="cancel('x')" />
9
9
  </div>
@@ -12,11 +12,12 @@
12
12
  </template>
13
13
 
14
14
  <script>
15
- import { removeElement } from 'buefy/src/utils/helpers'
15
+ import { markRaw } from 'vue'
16
16
  import config from 'buefy/src/utils/config'
17
17
 
18
18
  export default {
19
19
  name: 'ModalContainer',
20
+ emits: ['close', 'update:active', 'destroy'],
20
21
  props: {
21
22
  active: Boolean,
22
23
  customClasses: [Array, String],
@@ -101,7 +102,7 @@ export default {
101
102
  },
102
103
  methods: {
103
104
  swapComponent(newInjectedComponent) {
104
- this.injectedComponent = newInjectedComponent
105
+ this.injectedComponent = markRaw(newInjectedComponent)
105
106
  },
106
107
 
107
108
  handleScroll() {
@@ -152,12 +153,11 @@ export default {
152
153
  this.$emit('close')
153
154
  this.$emit('update:active', false)
154
155
 
155
- // Timeout for the animation complete before destroying
156
+ // Timeout for the animation complete before destroying; the plugin unmounts the modal's app
156
157
  if (this.programmatic) {
157
158
  this.isActive = false
158
159
  setTimeout(() => {
159
- this.$destroy()
160
- removeElement(this.$el)
160
+ this.$emit('destroy')
161
161
  }, 150)
162
162
  }
163
163
  },
@@ -178,7 +178,9 @@ export default {
178
178
  beforeMount() {
179
179
  // Insert the Modal component in body tag
180
180
  // only if it's programmatic
181
- this.programmatic && document.body.appendChild(this.$el)
181
+ if (this.programmatic && this.$el) {
182
+ document.body.appendChild(this.$el)
183
+ }
182
184
  },
183
185
  mounted() {
184
186
  if (this.programmatic) {
@@ -187,10 +189,11 @@ export default {
187
189
  this.handleScroll()
188
190
  }
189
191
  if (this.component) {
190
- this.injectedComponent = this.component
192
+ // markRaw: a component definition must not be made reactive
193
+ this.injectedComponent = markRaw(this.component)
191
194
  }
192
195
  },
193
- beforeDestroy() {
196
+ beforeUnmount() {
194
197
  if (typeof window !== 'undefined') {
195
198
  document.removeEventListener('keyup', this.keyPress)
196
199
  // reset scroll
@@ -1,16 +1,21 @@
1
- import Modal from './ModalContainer'
2
-
3
- import { registerComponentProgrammatic } from 'buefy/src/utils/plugins'
1
+ /**
2
+ * ModalContainer Plugin for Vue 3
3
+ *
4
+ * Migrated from Vue 2's Vue.extend() pattern to Vue 3's createApp/h pattern.
5
+ */
6
+ import { createApp, h, ref } from 'vue'
7
+ import Modal from './ModalContainer.vue'
8
+ import Buefy, { copyAppContext } from 'buefy'
4
9
 
5
10
  const ModalContainer = {
6
11
  instance: null,
7
12
  injectedComponent: null,
13
+ containerParams: null,
14
+ parentApp: null,
8
15
 
9
16
  open(params) {
10
17
  let content, parent
11
18
 
12
- //console.log('opening mc ', this.containerParams, this.isOpened)
13
-
14
19
  if (typeof params === 'string') {
15
20
  content = params
16
21
  }
@@ -27,32 +32,70 @@ const ModalContainer = {
27
32
 
28
33
  const propsData = Object.assign(defaultParams, params)
29
34
 
30
- const vm = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue
31
-
32
- const ModalComponent = vm.extend(Modal)
33
-
34
- if (this.instance && this.instance.$el.nodeName === 'DIV') {
35
+ if (this.instance && this.instance.$el && this.instance.$el.nodeName === 'DIV') {
35
36
  if (this.injectedComponent) {
36
37
  this.instance.swapComponent(this.injectedComponent)
37
38
  }
39
+ return this.instance
38
40
  } else {
39
- return new ModalComponent({
40
- parent,
41
- el: document.createElement('div'),
42
- propsData
41
+ // Vue 3: Create app instance and mount
42
+ const container = document.createElement('div')
43
+ document.body.appendChild(container)
44
+
45
+ const modal = ref(null)
46
+ const app = createApp({
47
+ render() {
48
+ // A programmatic modal asks to be destroyed once its close animation is done
49
+ return h(Modal, { ...propsData, ref: modal, onDestroy: () => destroy() })
50
+ }
43
51
  })
52
+ const destroy = () => {
53
+ // Read before unmounting: unmount sets the ref to null
54
+ if (this.instance === modal.value) {
55
+ this.instance = null
56
+ }
57
+ app.unmount()
58
+ container.remove()
59
+ }
60
+
61
+ // Share the parent app's context, as Buefy's programmatic modal does: its components
62
+ // (Buefy, the theme's overrides), directives, provides (store, i18n) and global
63
+ // properties, getters included. Copying values would freeze reactive getters like $mq.
64
+ if (this.parentApp) {
65
+ copyAppContext(this.parentApp, app)
66
+ } else {
67
+ // Install Buefy in the modal app instance so components like b-autocomplete work
68
+ app.use(Buefy)
69
+ }
70
+
71
+ app.mount(container)
72
+
73
+ // The modal itself, not the app's root, as Vue 2's new ModalComponent() returned:
74
+ // callers swap its component and close() it
75
+ return modal.value
76
+ }
77
+ },
78
+
79
+ close() {
80
+ if (this.instance) {
81
+ this.instance.close()
44
82
  }
45
83
  }
46
84
  }
47
85
 
48
86
  const Plugin = {
49
- install(Vue, options) {
87
+ install(app, options) {
50
88
  if (options) {
51
89
  ModalContainer.containerParams = options
52
90
  }
53
- if (!Vue.prototype.$modalContainer) {
54
- Vue.prototype.$modalContainer = ModalContainer
55
- }
91
+ // Store reference to parent app for plugin inheritance
92
+ ModalContainer.parentApp = app
93
+
94
+ // Vue 3: use app.config.globalProperties instead of Vue.prototype
95
+ app.config.globalProperties.$modalContainer = ModalContainer
96
+
97
+ // Also provide for Composition API usage
98
+ app.provide('modalContainer', ModalContainer)
56
99
  }
57
100
  }
58
101