@nuxt/scripts 0.6.3 → 0.6.5
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/README.md +73 -73
- package/dist/client/200.html +9 -9
- package/dist/client/404.html +9 -9
- package/dist/client/_nuxt/BA8oXX6l.js +31 -0
- package/dist/client/_nuxt/{zTM8DS5E.js → D3k5CjNA.js} +1 -1
- package/dist/client/_nuxt/{Cg8NGlPg.js → D6UD5WyS.js} +1 -1
- package/dist/client/_nuxt/{DZ6siU6J.js → D9Ze639F.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/a5c6ec68-62ae-43af-96d0-bdd9f64f38b1.json +1 -0
- package/dist/client/_nuxt/entry.Cts5wDvr.css +1 -0
- package/dist/client/_nuxt/error-404.-RjlvToe.css +1 -0
- package/dist/client/_nuxt/error-500.Bz7LXgZy.css +1 -0
- package/dist/client/index.html +9 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +84 -279
- package/dist/registry.mjs +33 -0
- package/dist/runtime/components/ScriptCarbonAds.vue +71 -71
- package/dist/runtime/components/ScriptCrisp.vue +84 -84
- package/dist/runtime/components/ScriptGoogleAdsense.vue +69 -69
- package/dist/runtime/components/ScriptGoogleMaps.vue +265 -265
- package/dist/runtime/components/ScriptIntercom.vue +93 -93
- package/dist/runtime/components/ScriptLemonSqueezy.vue +45 -45
- package/dist/runtime/components/ScriptLoadingIndicator.vue +22 -22
- package/dist/runtime/components/ScriptStripePricingTable.vue +68 -68
- package/dist/runtime/components/ScriptVimeoPlayer.vue +256 -256
- package/dist/runtime/components/ScriptYouTubePlayer.vue +171 -170
- package/dist/runtime/composables/useScript.js +3 -3
- package/dist/runtime/composables/useScriptEventPage.d.ts +1 -1
- package/dist/runtime/registry/crisp.d.ts +1 -1
- package/dist/runtime/registry/fathom-analytics.d.ts +1 -1
- package/dist/runtime/registry/google-adsense.d.ts +1 -1
- package/dist/runtime/registry/google-analytics.d.ts +19 -0
- package/dist/runtime/registry/google-analytics.js +40 -0
- package/dist/runtime/registry/google-tag-manager.d.ts +23 -0
- package/dist/runtime/registry/google-tag-manager.js +33 -0
- package/dist/runtime/registry/hotjar.d.ts +1 -1
- package/dist/runtime/registry/intercom.d.ts +1 -1
- package/dist/runtime/registry/matomo-analytics.d.ts +1 -1
- package/dist/runtime/registry/meta-pixel.d.ts +1 -1
- package/dist/runtime/registry/npm.d.ts +1 -1
- package/dist/runtime/registry/x-pixel.d.ts +1 -1
- package/dist/runtime/types.d.ts +41 -9
- package/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.js +20 -4
- package/package.json +12 -11
- package/dist/client/_nuxt/BeuDC-PU.js +0 -31
- package/dist/client/_nuxt/builds/meta/9996546f-d612-4447-9ee7-fc387b136ee4.json +0 -1
- package/dist/client/_nuxt/entry.DvGwvmL9.css +0 -1
- package/dist/client/_nuxt/error-404.DXyehy0d.css +0 -1
- package/dist/client/_nuxt/error-500.a_92Fvyl.css +0 -1
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useScriptIntercom } from '../registry/intercom'
|
|
3
|
-
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
4
|
-
import { ref, onMounted, watch, onBeforeUnmount } from '#imports'
|
|
5
|
-
import type { ElementScriptTrigger } from '#nuxt-scripts'
|
|
6
|
-
|
|
7
|
-
const props = withDefaults(defineProps<{
|
|
8
|
-
appId: string
|
|
9
|
-
apiBase?: string
|
|
10
|
-
name?: string
|
|
11
|
-
email?: string
|
|
12
|
-
userId?: string
|
|
13
|
-
// customizing the messenger
|
|
14
|
-
alignment?: 'left' | 'right'
|
|
15
|
-
horizontalPadding?: number
|
|
16
|
-
verticalPadding?: number
|
|
17
|
-
/**
|
|
18
|
-
* Defines the trigger event to load the script.
|
|
19
|
-
*/
|
|
20
|
-
trigger?: ElementScriptTrigger
|
|
21
|
-
}>(), {
|
|
22
|
-
trigger: 'click',
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const emits = defineEmits<{
|
|
26
|
-
// our emit
|
|
27
|
-
ready: [e: ReturnType<typeof useScriptIntercom>]
|
|
28
|
-
error: []
|
|
29
|
-
}>()
|
|
30
|
-
|
|
31
|
-
const rootEl = ref(null)
|
|
32
|
-
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
|
|
33
|
-
|
|
34
|
-
const isReady = ref(false)
|
|
35
|
-
const intercom = useScriptIntercom({
|
|
36
|
-
app_id: props.appId,
|
|
37
|
-
// @ts-expect-error untyped
|
|
38
|
-
app_base: props.apiBase,
|
|
39
|
-
name: props.name,
|
|
40
|
-
email: props.email,
|
|
41
|
-
user_id: props.userId,
|
|
42
|
-
alignment: props.alignment,
|
|
43
|
-
horizontal_padding: props.horizontalPadding,
|
|
44
|
-
vertical_padding: props.verticalPadding,
|
|
45
|
-
scriptOptions: {
|
|
46
|
-
trigger,
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
if (props.trigger === 'click')
|
|
50
|
-
intercom.Intercom('show')
|
|
51
|
-
const { $script } = intercom
|
|
52
|
-
|
|
53
|
-
defineExpose({
|
|
54
|
-
intercom,
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
let observer: MutationObserver
|
|
58
|
-
onMounted(() => {
|
|
59
|
-
watch($script.status, (status) => {
|
|
60
|
-
if (status === 'loading') {
|
|
61
|
-
observer = new MutationObserver(() => {
|
|
62
|
-
if (document.getElementById('intercom-frame')) {
|
|
63
|
-
isReady.value = true
|
|
64
|
-
emits('ready', intercom)
|
|
65
|
-
observer.disconnect()
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
observer.observe(document.body, { childList: true, subtree: true })
|
|
69
|
-
}
|
|
70
|
-
else if (status === 'error')
|
|
71
|
-
emits('error')
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
onBeforeUnmount(() => {
|
|
75
|
-
observer?.disconnect()
|
|
76
|
-
})
|
|
77
|
-
</script>
|
|
78
|
-
|
|
79
|
-
<template>
|
|
80
|
-
<div
|
|
81
|
-
ref="rootEl"
|
|
82
|
-
:style="{
|
|
83
|
-
display: isReady ? 'none' : 'block',
|
|
84
|
-
bottom: `${verticalPadding || 20}px`,
|
|
85
|
-
[alignment || 'right']: `${horizontalPadding || 20}px`,
|
|
86
|
-
}"
|
|
87
|
-
>
|
|
88
|
-
<slot :ready="isReady" />
|
|
89
|
-
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
90
|
-
<slot v-else-if="$script.status.value === 'loading' || !isReady" name="loading" />
|
|
91
|
-
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
92
|
-
</div>
|
|
93
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useScriptIntercom } from '../registry/intercom'
|
|
3
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
4
|
+
import { ref, onMounted, watch, onBeforeUnmount } from '#imports'
|
|
5
|
+
import type { ElementScriptTrigger } from '#nuxt-scripts'
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(defineProps<{
|
|
8
|
+
appId: string
|
|
9
|
+
apiBase?: string
|
|
10
|
+
name?: string
|
|
11
|
+
email?: string
|
|
12
|
+
userId?: string
|
|
13
|
+
// customizing the messenger
|
|
14
|
+
alignment?: 'left' | 'right'
|
|
15
|
+
horizontalPadding?: number
|
|
16
|
+
verticalPadding?: number
|
|
17
|
+
/**
|
|
18
|
+
* Defines the trigger event to load the script.
|
|
19
|
+
*/
|
|
20
|
+
trigger?: ElementScriptTrigger
|
|
21
|
+
}>(), {
|
|
22
|
+
trigger: 'click',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const emits = defineEmits<{
|
|
26
|
+
// our emit
|
|
27
|
+
ready: [e: ReturnType<typeof useScriptIntercom>]
|
|
28
|
+
error: []
|
|
29
|
+
}>()
|
|
30
|
+
|
|
31
|
+
const rootEl = ref(null)
|
|
32
|
+
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
|
|
33
|
+
|
|
34
|
+
const isReady = ref(false)
|
|
35
|
+
const intercom = useScriptIntercom({
|
|
36
|
+
app_id: props.appId,
|
|
37
|
+
// @ts-expect-error untyped
|
|
38
|
+
app_base: props.apiBase,
|
|
39
|
+
name: props.name,
|
|
40
|
+
email: props.email,
|
|
41
|
+
user_id: props.userId,
|
|
42
|
+
alignment: props.alignment,
|
|
43
|
+
horizontal_padding: props.horizontalPadding,
|
|
44
|
+
vertical_padding: props.verticalPadding,
|
|
45
|
+
scriptOptions: {
|
|
46
|
+
trigger,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
if (props.trigger === 'click')
|
|
50
|
+
intercom.Intercom('show')
|
|
51
|
+
const { $script } = intercom
|
|
52
|
+
|
|
53
|
+
defineExpose({
|
|
54
|
+
intercom,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
let observer: MutationObserver
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
watch($script.status, (status) => {
|
|
60
|
+
if (status === 'loading') {
|
|
61
|
+
observer = new MutationObserver(() => {
|
|
62
|
+
if (document.getElementById('intercom-frame')) {
|
|
63
|
+
isReady.value = true
|
|
64
|
+
emits('ready', intercom)
|
|
65
|
+
observer.disconnect()
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
observer.observe(document.body, { childList: true, subtree: true })
|
|
69
|
+
}
|
|
70
|
+
else if (status === 'error')
|
|
71
|
+
emits('error')
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
onBeforeUnmount(() => {
|
|
75
|
+
observer?.disconnect()
|
|
76
|
+
})
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<div
|
|
81
|
+
ref="rootEl"
|
|
82
|
+
:style="{
|
|
83
|
+
display: isReady ? 'none' : 'block',
|
|
84
|
+
bottom: `${verticalPadding || 20}px`,
|
|
85
|
+
[alignment || 'right']: `${horizontalPadding || 20}px`,
|
|
86
|
+
}"
|
|
87
|
+
>
|
|
88
|
+
<slot :ready="isReady" />
|
|
89
|
+
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
90
|
+
<slot v-else-if="$script.status.value === 'loading' || !isReady" name="loading" />
|
|
91
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { ElementScriptTrigger } from '../types'
|
|
3
|
-
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
4
|
-
import { useScriptLemonSqueezy } from '../registry/lemon-squeezy'
|
|
5
|
-
import type { LemonSqueezyEventPayload } from '../registry/lemon-squeezy'
|
|
6
|
-
import { onMounted, ref } from '#imports'
|
|
7
|
-
|
|
8
|
-
const props = withDefaults(defineProps<{
|
|
9
|
-
trigger?: ElementScriptTrigger
|
|
10
|
-
}>(), {
|
|
11
|
-
trigger: 'visible',
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const emits = defineEmits<{
|
|
15
|
-
ready: [ReturnType<typeof useScriptLemonSqueezy>]
|
|
16
|
-
lemonSqueezyEvent: [LemonSqueezyEventPayload]
|
|
17
|
-
}>()
|
|
18
|
-
|
|
19
|
-
const rootEl = ref<HTMLElement | null>(null)
|
|
20
|
-
const instance = useScriptLemonSqueezy({
|
|
21
|
-
scriptOptions: {
|
|
22
|
-
trigger: useScriptTriggerElement({ trigger: props.trigger, el: rootEl }),
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
onMounted(() => {
|
|
26
|
-
rootEl.value?.querySelectorAll('a[href]').forEach((a) => {
|
|
27
|
-
a.classList.add('lemonsqueezy-button')
|
|
28
|
-
})
|
|
29
|
-
instance.$script.then(({ Setup, Refresh }) => {
|
|
30
|
-
Setup({
|
|
31
|
-
eventHandler(event) {
|
|
32
|
-
emits('lemonSqueezyEvent', event)
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
Refresh()
|
|
36
|
-
emits('ready', instance)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<template>
|
|
42
|
-
<div ref="rootEl">
|
|
43
|
-
<slot />
|
|
44
|
-
</div>
|
|
45
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ElementScriptTrigger } from '../types'
|
|
3
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
4
|
+
import { useScriptLemonSqueezy } from '../registry/lemon-squeezy'
|
|
5
|
+
import type { LemonSqueezyEventPayload } from '../registry/lemon-squeezy'
|
|
6
|
+
import { onMounted, ref } from '#imports'
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(defineProps<{
|
|
9
|
+
trigger?: ElementScriptTrigger
|
|
10
|
+
}>(), {
|
|
11
|
+
trigger: 'visible',
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const emits = defineEmits<{
|
|
15
|
+
ready: [ReturnType<typeof useScriptLemonSqueezy>]
|
|
16
|
+
lemonSqueezyEvent: [LemonSqueezyEventPayload]
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
20
|
+
const instance = useScriptLemonSqueezy({
|
|
21
|
+
scriptOptions: {
|
|
22
|
+
trigger: useScriptTriggerElement({ trigger: props.trigger, el: rootEl }),
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
rootEl.value?.querySelectorAll('a[href]').forEach((a) => {
|
|
27
|
+
a.classList.add('lemonsqueezy-button')
|
|
28
|
+
})
|
|
29
|
+
instance.$script.then(({ Setup, Refresh }) => {
|
|
30
|
+
Setup({
|
|
31
|
+
eventHandler(event) {
|
|
32
|
+
emits('lemonSqueezyEvent', event)
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
Refresh()
|
|
36
|
+
emits('ready', instance)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div ref="rootEl">
|
|
43
|
+
<slot />
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed } from '#imports'
|
|
3
|
-
|
|
4
|
-
const props = withDefaults(defineProps<{
|
|
5
|
-
color?: string
|
|
6
|
-
size?: number
|
|
7
|
-
}>(), {
|
|
8
|
-
color: 'currentColor',
|
|
9
|
-
size: 30,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
const styles = computed(() => ({
|
|
13
|
-
width: `${props.size}px`,
|
|
14
|
-
height: `${props.size}px`,
|
|
15
|
-
}))
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<template>
|
|
19
|
-
<div class="loader" :styles="styles" aria-label="Loading..." role="status" />
|
|
20
|
-
</template>
|
|
21
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from '#imports'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
5
|
+
color?: string
|
|
6
|
+
size?: number
|
|
7
|
+
}>(), {
|
|
8
|
+
color: 'currentColor',
|
|
9
|
+
size: 30,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const styles = computed(() => ({
|
|
13
|
+
width: `${props.size}px`,
|
|
14
|
+
height: `${props.size}px`,
|
|
15
|
+
}))
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<div class="loader" :styles="styles" aria-label="Loading..." role="status" />
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
22
|
<style scoped>
|
|
23
23
|
.loader{animation:rotation 1s linear infinite;border:5px solid v-bind(color);border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;display:inline-block;opacity:.5}@keyframes rotation{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
|
|
24
|
-
</style>
|
|
24
|
+
</style>
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref } from 'vue'
|
|
3
|
-
import type { ElementScriptTrigger } from '../types'
|
|
4
|
-
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
5
|
-
import { useScript } from '../composables/useScript'
|
|
6
|
-
import { onBeforeUnmount, onMounted, watch } from '#imports'
|
|
7
|
-
|
|
8
|
-
const props = withDefaults(defineProps<{
|
|
9
|
-
trigger?: ElementScriptTrigger
|
|
10
|
-
publishableKey: string
|
|
11
|
-
pricingTableId: string
|
|
12
|
-
clientReferenceId?: string
|
|
13
|
-
customerEmail?: string
|
|
14
|
-
customerSessionClientSecret?: string
|
|
15
|
-
}>(), {
|
|
16
|
-
trigger: 'visible',
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const emit = defineEmits<{
|
|
20
|
-
ready: [ReturnType<typeof useScript>]
|
|
21
|
-
error: []
|
|
22
|
-
}>()
|
|
23
|
-
|
|
24
|
-
const rootEl = ref<HTMLDivElement | undefined>()
|
|
25
|
-
const containerEl = ref<HTMLDivElement | undefined>()
|
|
26
|
-
const instance = useScript(`https://js.stripe.com/v3/pricing-table.js`, {
|
|
27
|
-
trigger: useScriptTriggerElement({ trigger: props.trigger, el: rootEl }),
|
|
28
|
-
})
|
|
29
|
-
const { $script } = instance
|
|
30
|
-
|
|
31
|
-
const pricingTable = ref<HTMLElement | undefined>()
|
|
32
|
-
onMounted(() => {
|
|
33
|
-
$script.then(() => {
|
|
34
|
-
const StripePricingTable = window.customElements.get('stripe-pricing-table')!
|
|
35
|
-
const stripePricingTable = new StripePricingTable()
|
|
36
|
-
stripePricingTable.setAttribute('publishable-key', props.publishableKey)
|
|
37
|
-
stripePricingTable.setAttribute('pricing-table-id', props.pricingTableId)
|
|
38
|
-
if (props.clientReferenceId)
|
|
39
|
-
stripePricingTable.setAttribute('client-reference-id', props.clientReferenceId)
|
|
40
|
-
if (props.customerEmail)
|
|
41
|
-
stripePricingTable.setAttribute('customer-email', props.customerEmail)
|
|
42
|
-
if (props.customerSessionClientSecret)
|
|
43
|
-
stripePricingTable.setAttribute('customer-session-client-secret', props.customerSessionClientSecret)
|
|
44
|
-
pricingTable.value = stripePricingTable
|
|
45
|
-
rootEl.value!.appendChild(stripePricingTable)
|
|
46
|
-
emit('ready', instance)
|
|
47
|
-
})
|
|
48
|
-
watch($script.status, (status) => {
|
|
49
|
-
if (status === 'error') {
|
|
50
|
-
emit('error')
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
onBeforeUnmount(() => {
|
|
56
|
-
pricingTable.value?.remove()
|
|
57
|
-
})
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
<template>
|
|
61
|
-
<div ref="rootEl">
|
|
62
|
-
<div ref="containerEl" />
|
|
63
|
-
<slot v-if="$script.status.value === 'loading'" name="loading" />
|
|
64
|
-
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
65
|
-
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
66
|
-
<slot />
|
|
67
|
-
</div>
|
|
68
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import type { ElementScriptTrigger } from '../types'
|
|
4
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
5
|
+
import { useScript } from '../composables/useScript'
|
|
6
|
+
import { onBeforeUnmount, onMounted, watch } from '#imports'
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(defineProps<{
|
|
9
|
+
trigger?: ElementScriptTrigger
|
|
10
|
+
publishableKey: string
|
|
11
|
+
pricingTableId: string
|
|
12
|
+
clientReferenceId?: string
|
|
13
|
+
customerEmail?: string
|
|
14
|
+
customerSessionClientSecret?: string
|
|
15
|
+
}>(), {
|
|
16
|
+
trigger: 'visible',
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits<{
|
|
20
|
+
ready: [ReturnType<typeof useScript>]
|
|
21
|
+
error: []
|
|
22
|
+
}>()
|
|
23
|
+
|
|
24
|
+
const rootEl = ref<HTMLDivElement | undefined>()
|
|
25
|
+
const containerEl = ref<HTMLDivElement | undefined>()
|
|
26
|
+
const instance = useScript(`https://js.stripe.com/v3/pricing-table.js`, {
|
|
27
|
+
trigger: useScriptTriggerElement({ trigger: props.trigger, el: rootEl }),
|
|
28
|
+
})
|
|
29
|
+
const { $script } = instance
|
|
30
|
+
|
|
31
|
+
const pricingTable = ref<HTMLElement | undefined>()
|
|
32
|
+
onMounted(() => {
|
|
33
|
+
$script.then(() => {
|
|
34
|
+
const StripePricingTable = window.customElements.get('stripe-pricing-table')!
|
|
35
|
+
const stripePricingTable = new StripePricingTable()
|
|
36
|
+
stripePricingTable.setAttribute('publishable-key', props.publishableKey)
|
|
37
|
+
stripePricingTable.setAttribute('pricing-table-id', props.pricingTableId)
|
|
38
|
+
if (props.clientReferenceId)
|
|
39
|
+
stripePricingTable.setAttribute('client-reference-id', props.clientReferenceId)
|
|
40
|
+
if (props.customerEmail)
|
|
41
|
+
stripePricingTable.setAttribute('customer-email', props.customerEmail)
|
|
42
|
+
if (props.customerSessionClientSecret)
|
|
43
|
+
stripePricingTable.setAttribute('customer-session-client-secret', props.customerSessionClientSecret)
|
|
44
|
+
pricingTable.value = stripePricingTable
|
|
45
|
+
rootEl.value!.appendChild(stripePricingTable)
|
|
46
|
+
emit('ready', instance)
|
|
47
|
+
})
|
|
48
|
+
watch($script.status, (status) => {
|
|
49
|
+
if (status === 'error') {
|
|
50
|
+
emit('error')
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
onBeforeUnmount(() => {
|
|
56
|
+
pricingTable.value?.remove()
|
|
57
|
+
})
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<div ref="rootEl">
|
|
62
|
+
<div ref="containerEl" />
|
|
63
|
+
<slot v-if="$script.status.value === 'loading'" name="loading" />
|
|
64
|
+
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
65
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
66
|
+
<slot />
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|