@wikala/spmkt 2.31.1 → 3.0.0-beta.1

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 (132) hide show
  1. package/MIGRATION_GUIDE.md +310 -0
  2. package/api/product.js +1 -0
  3. package/api/request.js +12 -6
  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 +9 -7
  49. package/components/Cart/Store/state.js +2 -2
  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 +24 -24
  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/MobileMenu/icons/LeftArrowIcon.vue +1 -1
  61. package/components/MobileMenu/icons/MenuIcon.vue +1 -1
  62. package/components/MobileMenu/icons/RightArrowIcon.vue +1 -1
  63. package/components/ModalContainer/ModalContainer.vue +20 -13
  64. package/components/ModalContainer/index.js +62 -18
  65. package/components/Product/AddToCart.vue +237 -221
  66. package/components/Product/BoxAddToCart.vue +114 -86
  67. package/components/Product/Compare.vue +91 -49
  68. package/components/Product/CompareBox.vue +128 -123
  69. package/components/Product/Lookup.vue +92 -65
  70. package/components/Product/Photo.vue +105 -66
  71. package/components/Product/Price.vue +64 -43
  72. package/components/Product/ProductAutocomplete.vue +52 -57
  73. package/components/Product/ProductBox.vue +61 -38
  74. package/components/Product/ProductImages.vue +83 -86
  75. package/components/Product/Quantity.vue +115 -53
  76. package/components/Product/QuickView.vue +52 -45
  77. package/components/Product/RelatedProducts.vue +88 -23
  78. package/components/Product/SKU.vue +27 -8
  79. package/components/Product/Variants.vue +336 -342
  80. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  81. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  82. package/components/Product/reviews-questions/Review.vue +54 -59
  83. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  84. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  85. package/components/Product/reviews-questions/Vote.vue +83 -57
  86. package/components/QuantityInput.vue +18 -8
  87. package/components/RangeInput.vue +15 -8
  88. package/components/Recaptcha.vue +8 -1
  89. package/components/SelectShippingCountry.vue +81 -62
  90. package/components/TimedOffer.vue +59 -74
  91. package/composables/globals.js +53 -0
  92. package/config.js +5 -2
  93. package/index.js +41 -10
  94. package/install.js +88 -0
  95. package/locales/en.json +2 -1
  96. package/locales/sr.json +2 -1
  97. package/package.json +49 -37
  98. package/utils/animate.css +50 -0
  99. package/utils/animate.js +1 -1
  100. package/utils/buefy.js +62 -0
  101. package/utils/directives.js +28 -45
  102. package/utils/event-bus.js +56 -0
  103. package/utils/filters.js +24 -7
  104. package/utils/format-date.js +17 -0
  105. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  106. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  107. package/utils/random-id.js +10 -0
  108. package/babel.config.js +0 -5
  109. package/components/Account/ChangeEmail.vue +0 -133
  110. package/components/Account/ChangeName.vue +0 -92
  111. package/components/Account/ChangePassword.vue +0 -94
  112. package/components/Account/CreditCards.vue +0 -18
  113. package/components/Account/Orders.vue +0 -110
  114. package/components/Account/Settings.vue +0 -18
  115. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  116. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  117. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  118. package/components/Instagram.vue +0 -49
  119. package/components/ProductImageModal.vue +0 -41
  120. package/jest.config.js +0 -16
  121. package/test/e2e/.babelrc.js +0 -8
  122. package/test/e2e/.eslintrc.js +0 -11
  123. package/test/e2e/accAuth.spec.js +0 -64
  124. package/test/e2e/ageGate.spec.js +0 -26
  125. package/test/e2e/checkout.spec.js +0 -106
  126. package/test/e2e/compare.spec.js +0 -52
  127. package/test/e2e/config/data.js +0 -21
  128. package/test/e2e/config/routes.js +0 -11
  129. package/test/e2e/region.spec.js +0 -46
  130. package/test/e2e/search.spec.js +0 -32
  131. package/tests/vueBuefy.js +0 -4
  132. 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>
@@ -16,7 +16,7 @@ export default {
16
16
  };
17
17
  </script>
18
18
 
19
- <style lang="scss" scoped>
19
+ <style scoped>
20
20
 
21
21
  .svg {
22
22
  width: 100%;
@@ -18,7 +18,7 @@ export default {
18
18
  };
19
19
  </script>
20
20
 
21
- <style lang="scss" scoped>
21
+ <style scoped>
22
22
 
23
23
  .svg {
24
24
  width: 100%;
@@ -16,7 +16,7 @@ export default {
16
16
  };
17
17
  </script>
18
18
 
19
- <style lang="scss" scoped>
19
+ <style scoped>
20
20
 
21
21
  .svg {
22
22
  width: 100%;
@@ -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,16 @@
12
12
  </template>
13
13
 
14
14
  <script>
15
- import { removeElement } from 'buefy/src/utils/helpers'
16
- import config from 'buefy/src/utils/config'
15
+ import { markRaw } from 'vue'
16
+ import { ConfigProgrammatic } from 'buefy'
17
+
18
+ // Buefy's own config, which installSpmkt's buefy options set. Read it on each use:
19
+ // setOptions() replaces the object rather than mutating it.
20
+ const config = () => ConfigProgrammatic.getOptions()
17
21
 
18
22
  export default {
19
23
  name: 'ModalContainer',
24
+ emits: ['close', 'update:active', 'destroy'],
20
25
  props: {
21
26
  active: Boolean,
22
27
  customClasses: [Array, String],
@@ -37,7 +42,7 @@ export default {
37
42
  canCancel: {
38
43
  type: [Array, Boolean],
39
44
  default: () => {
40
- return config.defaultModalCanCancel
45
+ return config().defaultModalCanCancel
41
46
  }
42
47
  },
43
48
  onCancel: {
@@ -47,7 +52,7 @@ export default {
47
52
  scroll: {
48
53
  type: String,
49
54
  default: () => {
50
- return config.defaultModalScroll ? config.defaultModalScroll : 'clip'
55
+ return config().defaultModalScroll ? config().defaultModalScroll : 'clip'
51
56
  },
52
57
  validator: (value) => {
53
58
  return ['clip', 'keep'].indexOf(value) >= 0
@@ -65,7 +70,7 @@ export default {
65
70
  },
66
71
  computed: {
67
72
  cancelOptions() {
68
- return typeof this.canCancel === 'boolean' ? (this.canCancel ? config.defaultModalCanCancel : []) : this.canCancel
73
+ return typeof this.canCancel === 'boolean' ? (this.canCancel ? config().defaultModalCanCancel : []) : this.canCancel
69
74
  },
70
75
  showX() {
71
76
  return this.cancelOptions.indexOf('x') >= 0
@@ -101,7 +106,7 @@ export default {
101
106
  },
102
107
  methods: {
103
108
  swapComponent(newInjectedComponent) {
104
- this.injectedComponent = newInjectedComponent
109
+ this.injectedComponent = markRaw(newInjectedComponent)
105
110
  },
106
111
 
107
112
  handleScroll() {
@@ -152,12 +157,11 @@ export default {
152
157
  this.$emit('close')
153
158
  this.$emit('update:active', false)
154
159
 
155
- // Timeout for the animation complete before destroying
160
+ // Timeout for the animation complete before destroying; the plugin unmounts the modal's app
156
161
  if (this.programmatic) {
157
162
  this.isActive = false
158
163
  setTimeout(() => {
159
- this.$destroy()
160
- removeElement(this.$el)
164
+ this.$emit('destroy')
161
165
  }, 150)
162
166
  }
163
167
  },
@@ -178,7 +182,9 @@ export default {
178
182
  beforeMount() {
179
183
  // Insert the Modal component in body tag
180
184
  // only if it's programmatic
181
- this.programmatic && document.body.appendChild(this.$el)
185
+ if (this.programmatic && this.$el) {
186
+ document.body.appendChild(this.$el)
187
+ }
182
188
  },
183
189
  mounted() {
184
190
  if (this.programmatic) {
@@ -187,10 +193,11 @@ export default {
187
193
  this.handleScroll()
188
194
  }
189
195
  if (this.component) {
190
- this.injectedComponent = this.component
196
+ // markRaw: a component definition must not be made reactive
197
+ this.injectedComponent = markRaw(this.component)
191
198
  }
192
199
  },
193
- beforeDestroy() {
200
+ beforeUnmount() {
194
201
  if (typeof window !== 'undefined') {
195
202
  document.removeEventListener('keyup', this.keyPress)
196
203
  // reset scroll
@@ -1,16 +1,22 @@
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 { copyAppContext } from 'buefy'
9
+ import { installBuefy } from '../../utils/buefy'
4
10
 
5
11
  const ModalContainer = {
6
12
  instance: null,
7
13
  injectedComponent: null,
14
+ containerParams: null,
15
+ parentApp: null,
8
16
 
9
17
  open(params) {
10
18
  let content, parent
11
19
 
12
- //console.log('opening mc ', this.containerParams, this.isOpened)
13
-
14
20
  if (typeof params === 'string') {
15
21
  content = params
16
22
  }
@@ -27,32 +33,70 @@ const ModalContainer = {
27
33
 
28
34
  const propsData = Object.assign(defaultParams, params)
29
35
 
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') {
36
+ if (this.instance && this.instance.$el && this.instance.$el.nodeName === 'DIV') {
35
37
  if (this.injectedComponent) {
36
38
  this.instance.swapComponent(this.injectedComponent)
37
39
  }
40
+ return this.instance
38
41
  } else {
39
- return new ModalComponent({
40
- parent,
41
- el: document.createElement('div'),
42
- propsData
42
+ // Vue 3: Create app instance and mount
43
+ const container = document.createElement('div')
44
+ document.body.appendChild(container)
45
+
46
+ const modal = ref(null)
47
+ const app = createApp({
48
+ render() {
49
+ // A programmatic modal asks to be destroyed once its close animation is done
50
+ return h(Modal, { ...propsData, ref: modal, onDestroy: () => destroy() })
51
+ }
43
52
  })
53
+ const destroy = () => {
54
+ // Read before unmounting: unmount sets the ref to null
55
+ if (this.instance === modal.value) {
56
+ this.instance = null
57
+ }
58
+ app.unmount()
59
+ container.remove()
60
+ }
61
+
62
+ // Share the parent app's context, as Buefy's programmatic modal does: its components
63
+ // (Buefy, the theme's overrides), directives, provides (store, i18n) and global
64
+ // properties, getters included. Copying values would freeze reactive getters like $mq.
65
+ if (this.parentApp) {
66
+ copyAppContext(this.parentApp, app)
67
+ } else {
68
+ // Install Buefy in the modal app instance so components like b-autocomplete work
69
+ installBuefy(app)
70
+ }
71
+
72
+ app.mount(container)
73
+
74
+ // The modal itself, not the app's root, as Vue 2's new ModalComponent() returned:
75
+ // callers swap its component and close() it
76
+ return modal.value
77
+ }
78
+ },
79
+
80
+ close() {
81
+ if (this.instance) {
82
+ this.instance.close()
44
83
  }
45
84
  }
46
85
  }
47
86
 
48
87
  const Plugin = {
49
- install(Vue, options) {
88
+ install(app, options) {
50
89
  if (options) {
51
90
  ModalContainer.containerParams = options
52
91
  }
53
- if (!Vue.prototype.$modalContainer) {
54
- Vue.prototype.$modalContainer = ModalContainer
55
- }
92
+ // Store reference to parent app for plugin inheritance
93
+ ModalContainer.parentApp = app
94
+
95
+ // Vue 3: use app.config.globalProperties instead of Vue.prototype
96
+ app.config.globalProperties.$modalContainer = ModalContainer
97
+
98
+ // Also provide for Composition API usage
99
+ app.provide('modalContainer', ModalContainer)
56
100
  }
57
101
  }
58
102