@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.
- package/MIGRATION_GUIDE.md +310 -0
- package/api/product.js +1 -0
- package/api/request.js +12 -6
- package/api/user.js +1 -1
- package/components/Account/AccountDashboard.vue +101 -101
- package/components/Account/AccountStore.js +57 -31
- package/components/Account/AffiliateReport.vue +56 -60
- package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
- package/components/Account/Orders/Orders.vue +124 -0
- package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
- package/components/Account/Settings/ChangeEmail.vue +136 -0
- package/components/Account/Settings/ChangeName.vue +82 -0
- package/components/Account/Settings/ChangePassword.vue +91 -0
- package/components/Address/Address.vue +38 -57
- package/components/Address/AddressBook.vue +77 -57
- package/components/Address/AddressSelect.vue +94 -87
- package/components/Address/Edit.vue +253 -265
- package/components/Address/PostalCode.vue +22 -21
- package/components/AgeGate.vue +11 -5
- package/components/Auth/Login.vue +62 -44
- package/components/Auth/Register.vue +82 -60
- package/components/Auth/ResetPassword.vue +45 -30
- package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
- package/components/Cart/CartBadge.vue +15 -4
- package/components/Cart/CartBox.vue +19 -11
- package/components/Cart/CartItem.vue +3 -3
- package/components/Cart/CartMode.vue +6 -5
- package/components/Cart/CartPreview.vue +24 -18
- package/components/Cart/CreditCard/Everyware.vue +10 -10
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
- package/components/Cart/CreditCard/SquarePay.vue +18 -16
- package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
- package/components/Cart/Delivery/Delivery.vue +16 -12
- package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
- package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
- package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
- package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
- package/components/Cart/Delivery/ReservationSlots.vue +14 -8
- package/components/Cart/Disclaimer.vue +1 -1
- package/components/Cart/OrderConfirmation.vue +1 -1
- package/components/Cart/Payment/Payment.vue +37 -33
- package/components/Cart/Payment/PaymentMethods.vue +6 -4
- package/components/Cart/ReviewAndSubmit.vue +9 -7
- package/components/Cart/ShoppingCart.vue +42 -31
- package/components/Cart/Store/actions.js +1 -1
- package/components/Cart/Store/getters.js +2 -1
- package/components/Cart/Store/index.js +1 -1
- package/components/Cart/Store/mutations.js +9 -7
- package/components/Cart/Store/state.js +2 -2
- package/components/Cart/UserIdentity.vue +1 -1
- package/components/Category/CategoryFilter.vue +128 -114
- package/components/Category/CategorySort.vue +44 -32
- package/components/Category/LoadMore.vue +39 -23
- package/components/DeliverTo.vue +10 -15
- package/components/DeliveryNotice.vue +72 -68
- package/components/DobInput.vue +24 -24
- package/components/Gmaps/GmapsAutocomplete.vue +139 -78
- package/components/Gmaps/GmapsLocations.vue +1 -1
- package/components/Gmaps/GmapsSingleLocation.vue +121 -87
- package/components/MobileMenu/icons/LeftArrowIcon.vue +1 -1
- package/components/MobileMenu/icons/MenuIcon.vue +1 -1
- package/components/MobileMenu/icons/RightArrowIcon.vue +1 -1
- package/components/ModalContainer/ModalContainer.vue +20 -13
- package/components/ModalContainer/index.js +62 -18
- package/components/Product/AddToCart.vue +237 -221
- package/components/Product/BoxAddToCart.vue +114 -86
- package/components/Product/Compare.vue +91 -49
- package/components/Product/CompareBox.vue +128 -123
- package/components/Product/Lookup.vue +92 -65
- package/components/Product/Photo.vue +105 -66
- package/components/Product/Price.vue +64 -43
- package/components/Product/ProductAutocomplete.vue +52 -57
- package/components/Product/ProductBox.vue +61 -38
- package/components/Product/ProductImages.vue +83 -86
- package/components/Product/Quantity.vue +115 -53
- package/components/Product/QuickView.vue +52 -45
- package/components/Product/RelatedProducts.vue +88 -23
- package/components/Product/SKU.vue +27 -8
- package/components/Product/Variants.vue +336 -342
- package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
- package/components/Product/reviews-questions/ProductReviews.vue +122 -107
- package/components/Product/reviews-questions/Review.vue +54 -59
- package/components/Product/reviews-questions/ReviewForm.vue +222 -170
- package/components/Product/reviews-questions/ReviewImages.vue +197 -216
- package/components/Product/reviews-questions/Vote.vue +83 -57
- package/components/QuantityInput.vue +18 -8
- package/components/RangeInput.vue +15 -8
- package/components/Recaptcha.vue +8 -1
- package/components/SelectShippingCountry.vue +81 -62
- package/components/TimedOffer.vue +59 -74
- package/composables/globals.js +53 -0
- package/config.js +5 -2
- package/index.js +41 -10
- package/install.js +88 -0
- package/locales/en.json +2 -1
- package/locales/sr.json +2 -1
- package/package.json +49 -37
- package/utils/animate.css +50 -0
- package/utils/animate.js +1 -1
- package/utils/buefy.js +62 -0
- package/utils/directives.js +28 -45
- package/utils/event-bus.js +56 -0
- package/utils/filters.js +24 -7
- package/utils/format-date.js +17 -0
- package/utils/{gmaps.js → google/gmaps.js} +43 -10
- package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
- package/utils/random-id.js +10 -0
- package/babel.config.js +0 -5
- package/components/Account/ChangeEmail.vue +0 -133
- package/components/Account/ChangeName.vue +0 -92
- package/components/Account/ChangePassword.vue +0 -94
- package/components/Account/CreditCards.vue +0 -18
- package/components/Account/Orders.vue +0 -110
- package/components/Account/Settings.vue +0 -18
- package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
- package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
- package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
- package/components/Instagram.vue +0 -49
- package/components/ProductImageModal.vue +0 -41
- package/jest.config.js +0 -16
- package/test/e2e/.babelrc.js +0 -8
- package/test/e2e/.eslintrc.js +0 -11
- package/test/e2e/accAuth.spec.js +0 -64
- package/test/e2e/ageGate.spec.js +0 -26
- package/test/e2e/checkout.spec.js +0 -106
- package/test/e2e/compare.spec.js +0 -52
- package/test/e2e/config/data.js +0 -21
- package/test/e2e/config/routes.js +0 -11
- package/test/e2e/region.spec.js +0 -46
- package/test/e2e/search.spec.js +0 -32
- package/tests/vueBuefy.js +0 -4
- 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
infowindow: null
|
|
41
|
-
}
|
|
22
|
+
zoomLevel: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 14
|
|
42
25
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
|
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,16 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
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 &&
|
|
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
|
-
|
|
196
|
+
// markRaw: a component definition must not be made reactive
|
|
197
|
+
this.injectedComponent = markRaw(this.component)
|
|
191
198
|
}
|
|
192
199
|
},
|
|
193
|
-
|
|
200
|
+
beforeUnmount() {
|
|
194
201
|
if (typeof window !== 'undefined') {
|
|
195
202
|
document.removeEventListener('keyup', this.keyPress)
|
|
196
203
|
// reset scroll
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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(
|
|
88
|
+
install(app, options) {
|
|
50
89
|
if (options) {
|
|
51
90
|
ModalContainer.containerParams = options
|
|
52
91
|
}
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|