@nuxt/scripts 0.11.5 → 0.11.7

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/client/200.html +9 -9
  3. package/dist/client/404.html +9 -9
  4. package/dist/client/_nuxt/D3ZVEC_8.js +1 -0
  5. package/dist/client/_nuxt/DmiqYg4r.js +21 -0
  6. package/dist/client/_nuxt/_5UZfQdF.js +1 -0
  7. package/dist/client/_nuxt/builds/latest.json +1 -1
  8. package/dist/client/_nuxt/builds/meta/93bac187-07c5-4a76-83a2-cefcf05c0b88.json +1 -0
  9. package/dist/client/_nuxt/{entry.CJckMUzn.css → entry.DExDtQtx.css} +1 -1
  10. package/dist/client/_nuxt/error-404.CpID9NZX.css +1 -0
  11. package/dist/client/_nuxt/error-500.BzWA0Bp3.css +1 -0
  12. package/dist/client/_nuxt/{Bo1SWr6k.js → z8Iwlb2L.js} +1 -1
  13. package/dist/client/index.html +9 -9
  14. package/dist/module.json +3 -3
  15. package/dist/registry.mjs +27 -0
  16. package/dist/runtime/components/ScriptAriaLoadingIndicator.vue.d.ts +2 -0
  17. package/dist/runtime/components/ScriptCarbonAds.vue +41 -57
  18. package/dist/runtime/components/ScriptCarbonAds.vue.d.ts +32 -0
  19. package/dist/runtime/components/ScriptCrisp.vue +43 -63
  20. package/dist/runtime/components/ScriptCrisp.vue.d.ts +44 -0
  21. package/dist/runtime/components/ScriptGoogleAdsense.vue +37 -60
  22. package/dist/runtime/components/ScriptGoogleAdsense.vue.d.ts +37 -0
  23. package/dist/runtime/components/ScriptGoogleMaps.vue +220 -366
  24. package/dist/runtime/components/ScriptGoogleMaps.vue.d.ts +144 -0
  25. package/dist/runtime/components/ScriptIntercom.vue +48 -67
  26. package/dist/runtime/components/ScriptIntercom.vue.d.ts +45 -0
  27. package/dist/runtime/components/ScriptLemonSqueezy.vue +26 -37
  28. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +24 -0
  29. package/dist/runtime/components/ScriptLoadingIndicator.vue +8 -13
  30. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +9 -0
  31. package/dist/runtime/components/ScriptStripePricingTable.vue +41 -53
  32. package/dist/runtime/components/ScriptStripePricingTable.vue.d.ts +35 -0
  33. package/dist/runtime/components/ScriptVimeoPlayer.vue +121 -218
  34. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +127 -0
  35. package/dist/runtime/components/ScriptYouTubePlayer.vue +105 -163
  36. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +66 -0
  37. package/dist/runtime/registry/clarity.d.ts +1 -1
  38. package/dist/runtime/registry/clarity.js +7 -1
  39. package/dist/runtime/registry/rybbit-analytics.d.ts +20 -0
  40. package/dist/runtime/registry/rybbit-analytics.js +32 -0
  41. package/dist/runtime/registry/snapchat-pixel.js +1 -1
  42. package/dist/runtime/types.d.ts +2 -0
  43. package/dist/types.d.mts +2 -2
  44. package/package.json +53 -48
  45. package/dist/client/_nuxt/BojlM8av.js +0 -21
  46. package/dist/client/_nuxt/BwFnCI0m.js +0 -1
  47. package/dist/client/_nuxt/builds/meta/0bd5f801-ad22-4b04-821c-25f180195d78.json +0 -1
  48. package/dist/client/_nuxt/error-404.BiTeRF3j.css +0 -1
  49. package/dist/client/_nuxt/error-500.Be1AE5oK.css +0 -1
  50. package/dist/client/_nuxt/yRslIvSb.js +0 -1
  51. package/dist/module.cjs +0 -5
  52. package/dist/module.d.ts +0 -60
  53. package/dist/registry.d.ts +0 -6
  54. package/dist/types.d.ts +0 -7
@@ -0,0 +1,144 @@
1
+ import type { HTMLAttributes, ImgHTMLAttributes, Ref, ReservedProps } from 'vue';
2
+ import type { ElementScriptTrigger } from '../types.js';
3
+ interface PlaceholderOptions {
4
+ width?: string | number;
5
+ height?: string | number;
6
+ center?: string;
7
+ zoom?: number;
8
+ size?: string;
9
+ scale?: number;
10
+ format?: 'png' | 'jpg' | 'gif' | 'png8' | 'png32' | 'jpg-baseline';
11
+ maptype?: 'roadmap' | 'satellite' | 'terrain' | 'hybrid';
12
+ language?: string;
13
+ region?: string;
14
+ markers?: string;
15
+ path?: string;
16
+ visible?: string;
17
+ style?: string;
18
+ map_id?: string;
19
+ key?: string;
20
+ signature?: string;
21
+ }
22
+ type __VLS_Props = {
23
+ /**
24
+ * Defines the trigger event to load the script.
25
+ */
26
+ trigger?: ElementScriptTrigger;
27
+ /**
28
+ * Is Google Maps being rendered above the fold?
29
+ * This will load the placeholder image with higher priority.
30
+ */
31
+ aboveTheFold?: boolean;
32
+ /**
33
+ * Defines the Google Maps API key. Must have access to the Static Maps API as well.
34
+ */
35
+ apiKey?: string;
36
+ /**
37
+ * A latitude / longitude of where to focus the map.
38
+ */
39
+ center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
40
+ /**
41
+ * Should a marker be displayed on the map where the centre is.
42
+ */
43
+ centerMarker?: boolean;
44
+ /**
45
+ * Options for the map.
46
+ */
47
+ mapOptions?: google.maps.MapOptions;
48
+ /**
49
+ * Defines the region of the map.
50
+ */
51
+ region?: string;
52
+ /**
53
+ * Defines the language of the map
54
+ */
55
+ language?: string;
56
+ /**
57
+ * Defines the version of google maps js API
58
+ */
59
+ version?: string;
60
+ /**
61
+ * Defines the width of the map.
62
+ */
63
+ width?: number | string;
64
+ /**
65
+ * Defines the height of the map
66
+ */
67
+ height?: number | string;
68
+ /**
69
+ * Customize the placeholder image attributes.
70
+ *
71
+ * @see https://developers.google.com/maps/documentation/maps-static/start.
72
+ */
73
+ placeholderOptions?: PlaceholderOptions;
74
+ /**
75
+ * Customize the placeholder image attributes.
76
+ */
77
+ placeholderAttrs?: ImgHTMLAttributes & ReservedProps & Record<string, unknown>;
78
+ /**
79
+ * Customize the root element attributes.
80
+ */
81
+ rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>;
82
+ /**
83
+ * Extra Markers to add to the map.
84
+ */
85
+ markers?: (`${string},${string}` | google.maps.marker.AdvancedMarkerElementOptions)[];
86
+ };
87
+ declare function createAdvancedMapMarker(_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`): Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
88
+ declare function resolveQueryToLatLang(query: string): Promise<google.maps.LatLng | undefined>;
89
+ declare function importLibrary(key: 'marker'): Promise<google.maps.MarkerLibrary>;
90
+ declare function importLibrary(key: 'places'): Promise<google.maps.PlacesLibrary>;
91
+ declare function importLibrary(key: 'geometry'): Promise<google.maps.GeometryLibrary>;
92
+ declare function importLibrary(key: 'drawing'): Promise<google.maps.DrawingLibrary>;
93
+ declare function importLibrary(key: 'visualization'): Promise<google.maps.VisualizationLibrary>;
94
+ declare function importLibrary(key: string): Promise<any>;
95
+ declare var __VLS_1: {
96
+ placeholder: any;
97
+ }, __VLS_3: {}, __VLS_8: {}, __VLS_10: {}, __VLS_12: {};
98
+ type __VLS_Slots = {} & {
99
+ placeholder?: (props: typeof __VLS_1) => any;
100
+ } & {
101
+ loading?: (props: typeof __VLS_3) => any;
102
+ } & {
103
+ awaitingLoad?: (props: typeof __VLS_8) => any;
104
+ } & {
105
+ error?: (props: typeof __VLS_10) => any;
106
+ } & {
107
+ default?: (props: typeof __VLS_12) => any;
108
+ };
109
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
110
+ googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
111
+ map: Ref<google.maps.Map | undefined, google.maps.Map | undefined>;
112
+ createAdvancedMapMarker: typeof createAdvancedMapMarker;
113
+ resolveQueryToLatLang: typeof resolveQueryToLatLang;
114
+ importLibrary: typeof importLibrary;
115
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
116
+ error: () => any;
117
+ ready: (e: {
118
+ readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
119
+ readonly map: Ref<google.maps.Map | undefined, google.maps.Map | undefined>;
120
+ readonly createAdvancedMapMarker: typeof createAdvancedMapMarker;
121
+ readonly resolveQueryToLatLang: typeof resolveQueryToLatLang;
122
+ readonly importLibrary: typeof importLibrary;
123
+ }) => any;
124
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
125
+ onError?: (() => any) | undefined;
126
+ onReady?: ((e: {
127
+ readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
128
+ readonly map: Ref<google.maps.Map | undefined, google.maps.Map | undefined>;
129
+ readonly createAdvancedMapMarker: typeof createAdvancedMapMarker;
130
+ readonly resolveQueryToLatLang: typeof resolveQueryToLatLang;
131
+ readonly importLibrary: typeof importLibrary;
132
+ }) => any) | undefined;
133
+ }>, {
134
+ trigger: ElementScriptTrigger;
135
+ width: number | string;
136
+ height: number | string;
137
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
138
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
139
+ export default _default;
140
+ type __VLS_WithSlots<T, S> = T & {
141
+ new (): {
142
+ $slots: S;
143
+ };
144
+ };
@@ -1,37 +1,22 @@
1
- <script setup lang="ts">
2
- import { ref, onMounted, watch, onBeforeUnmount, computed } from 'vue'
3
- import { useScriptIntercom } from '../registry/intercom'
4
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
- import type { ElementScriptTrigger } from '#nuxt-scripts/types'
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)
1
+ <script setup>
2
+ import { ref, onMounted, watch, onBeforeUnmount, computed } from "vue";
3
+ import { useScriptIntercom } from "../registry/intercom";
4
+ import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
5
+ const props = defineProps({
6
+ appId: { type: String, required: true },
7
+ apiBase: { type: String, required: false },
8
+ name: { type: String, required: false },
9
+ email: { type: String, required: false },
10
+ userId: { type: String, required: false },
11
+ alignment: { type: String, required: false },
12
+ horizontalPadding: { type: Number, required: false },
13
+ verticalPadding: { type: Number, required: false },
14
+ trigger: { type: [String, Array, Boolean], required: false, default: "click" }
15
+ });
16
+ const emits = defineEmits(["ready", "error"]);
17
+ const rootEl = ref(null);
18
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
19
+ const isReady = ref(false);
35
20
  const intercom = useScriptIntercom({
36
21
  app_id: props.appId,
37
22
  // @ts-expect-error untyped
@@ -43,51 +28,47 @@ const intercom = useScriptIntercom({
43
28
  horizontal_padding: props.horizontalPadding,
44
29
  vertical_padding: props.verticalPadding,
45
30
  scriptOptions: {
46
- trigger,
47
- },
48
- })
49
- const { status, onLoaded } = intercom
50
- if (props.trigger === 'click') {
31
+ trigger
32
+ }
33
+ });
34
+ const { status, onLoaded } = intercom;
35
+ if (props.trigger === "click") {
51
36
  onLoaded((instance) => {
52
- instance.Intercom('show')
53
- })
37
+ instance.Intercom("show");
38
+ });
54
39
  }
55
-
56
40
  defineExpose({
57
- intercom,
58
- })
59
-
60
- let observer: MutationObserver
41
+ intercom
42
+ });
43
+ let observer;
61
44
  onMounted(() => {
62
- watch(status, (status) => {
63
- if (status === 'loading') {
45
+ watch(status, (status2) => {
46
+ if (status2 === "loading") {
64
47
  observer = new MutationObserver(() => {
65
- if (document.getElementById('intercom-frame')) {
66
- isReady.value = true
67
- emits('ready', intercom)
68
- observer.disconnect()
48
+ if (document.getElementById("intercom-frame")) {
49
+ isReady.value = true;
50
+ emits("ready", intercom);
51
+ observer.disconnect();
69
52
  }
70
- })
71
- observer.observe(document.body, { childList: true, subtree: true })
72
- }
73
- else if (status === 'error')
74
- emits('error')
75
- })
76
- })
53
+ });
54
+ observer.observe(document.body, { childList: true, subtree: true });
55
+ } else if (status2 === "error")
56
+ emits("error");
57
+ });
58
+ });
77
59
  onBeforeUnmount(() => {
78
- observer?.disconnect()
79
- })
80
-
60
+ observer?.disconnect();
61
+ });
81
62
  const rootAttrs = computed(() => {
82
63
  return {
83
64
  style: {
84
- display: isReady.value ? 'none' : 'block',
65
+ display: isReady.value ? "none" : "block",
85
66
  bottom: `${props.verticalPadding || 20}px`,
86
- [props.alignment || 'right']: `${props.horizontalPadding || 20}px`,
67
+ [props.alignment || "right"]: `${props.horizontalPadding || 20}px`
87
68
  },
88
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
89
- }
90
- })
69
+ ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
70
+ };
71
+ });
91
72
  </script>
92
73
 
93
74
  <template>
@@ -0,0 +1,45 @@
1
+ import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ type __VLS_Props = {
3
+ appId: string;
4
+ apiBase?: string;
5
+ name?: string;
6
+ email?: string;
7
+ userId?: string;
8
+ alignment?: 'left' | 'right';
9
+ horizontalPadding?: number;
10
+ verticalPadding?: number;
11
+ /**
12
+ * Defines the trigger event to load the script.
13
+ */
14
+ trigger?: ElementScriptTrigger;
15
+ };
16
+ declare var __VLS_1: {
17
+ ready: any;
18
+ }, __VLS_3: {}, __VLS_5: {}, __VLS_7: {};
19
+ type __VLS_Slots = {} & {
20
+ default?: (props: typeof __VLS_1) => any;
21
+ } & {
22
+ awaitingLoad?: (props: typeof __VLS_3) => any;
23
+ } & {
24
+ loading?: (props: typeof __VLS_5) => any;
25
+ } & {
26
+ error?: (props: typeof __VLS_7) => any;
27
+ };
28
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
29
+ intercom: import("#nuxt-scripts/types").UseScriptContext<import("../registry/intercom.js").IntercomApi>;
30
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
31
+ error: () => any;
32
+ ready: (e: import("#nuxt-scripts/types").UseScriptContext<import("../registry/intercom.js").IntercomApi>) => any;
33
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
34
+ onError?: (() => any) | undefined;
35
+ onReady?: ((e: import("#nuxt-scripts/types").UseScriptContext<import("../registry/intercom.js").IntercomApi>) => any) | undefined;
36
+ }>, {
37
+ trigger: ElementScriptTrigger;
38
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
39
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
40
+ export default _default;
41
+ type __VLS_WithSlots<T, S> = T & {
42
+ new (): {
43
+ $slots: S;
44
+ };
45
+ };
@@ -1,48 +1,37 @@
1
- <script lang="ts" setup>
2
- import { computed, onMounted, ref } from 'vue'
3
- import type { ElementScriptTrigger } from '../types'
4
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
- import { useScriptLemonSqueezy } from '../registry/lemon-squeezy'
6
- import type { LemonSqueezyEventPayload } from '../registry/lemon-squeezy'
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 trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
1
+ <script setup>
2
+ import { computed, onMounted, ref } from "vue";
3
+ import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
4
+ import { useScriptLemonSqueezy } from "../registry/lemon-squeezy";
5
+ const props = defineProps({
6
+ trigger: { type: [String, Array, Boolean], required: false, default: "visible" }
7
+ });
8
+ const emits = defineEmits(["ready", "lemonSqueezyEvent"]);
9
+ const rootEl = ref(null);
10
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
21
11
  const instance = useScriptLemonSqueezy({
22
12
  scriptOptions: {
23
- trigger,
24
- },
25
- })
13
+ trigger
14
+ }
15
+ });
26
16
  onMounted(() => {
27
- rootEl.value?.querySelectorAll('a[href]').forEach((a) => {
28
- a.classList.add('lemonsqueezy-button')
29
- })
17
+ rootEl.value?.querySelectorAll("a[href]").forEach((a) => {
18
+ a.classList.add("lemonsqueezy-button");
19
+ });
30
20
  instance.onLoaded(({ Setup, Refresh }) => {
31
21
  Setup({
32
22
  eventHandler(event) {
33
- emits('lemonSqueezyEvent', event)
34
- },
35
- })
36
- Refresh()
37
- emits('ready', instance)
38
- })
39
- })
40
-
23
+ emits("lemonSqueezyEvent", event);
24
+ }
25
+ });
26
+ Refresh();
27
+ emits("ready", instance);
28
+ });
29
+ });
41
30
  const rootAttrs = computed(() => {
42
31
  return {
43
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
44
- }
45
- })
32
+ ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
33
+ };
34
+ });
46
35
  </script>
47
36
 
48
37
  <template>
@@ -0,0 +1,24 @@
1
+ import type { ElementScriptTrigger } from '../types.js';
2
+ type __VLS_Props = {
3
+ trigger?: ElementScriptTrigger;
4
+ };
5
+ declare var __VLS_1: {};
6
+ type __VLS_Slots = {} & {
7
+ default?: (props: typeof __VLS_1) => any;
8
+ };
9
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ ready: (args_0: import("../types.js").UseScriptContext<import("../registry/lemon-squeezy.js").LemonSqueezyApi>) => any;
11
+ lemonSqueezyEvent: (args_0: never) => any;
12
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
+ onReady?: ((args_0: import("../types.js").UseScriptContext<import("../registry/lemon-squeezy.js").LemonSqueezyApi>) => any) | undefined;
14
+ onLemonSqueezyEvent?: ((args_0: never) => any) | undefined;
15
+ }>, {
16
+ trigger: ElementScriptTrigger;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
19
+ export default _default;
20
+ type __VLS_WithSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
@@ -1,18 +1,13 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue'
3
-
4
- const props = withDefaults(defineProps<{
5
- color?: string
6
- size?: number
7
- }>(), {
8
- color: 'currentColor',
9
- size: 30,
10
- })
11
-
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ const props = defineProps({
4
+ color: { type: String, required: false, default: "currentColor" },
5
+ size: { type: Number, required: false, default: 30 }
6
+ });
12
7
  const styles = computed(() => ({
13
8
  width: `${props.size}px`,
14
- height: `${props.size}px`,
15
- }))
9
+ height: `${props.size}px`
10
+ }));
16
11
  </script>
17
12
 
18
13
  <template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ color?: string;
3
+ size?: number;
4
+ };
5
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ color: string;
7
+ size: number;
8
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ export default _default;
@@ -1,66 +1,54 @@
1
- <script setup lang="ts">
2
- import { ref, computed, onBeforeUnmount, onMounted, watch } from 'vue'
3
- import type { ElementScriptTrigger } from '../types'
4
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
- import { useScript } from '#imports'
6
-
7
- const props = withDefaults(defineProps<{
8
- trigger?: ElementScriptTrigger
9
- publishableKey: string
10
- pricingTableId: string
11
- clientReferenceId?: string
12
- customerEmail?: string
13
- customerSessionClientSecret?: string
14
- }>(), {
15
- trigger: 'visible',
16
- })
17
-
18
- const emit = defineEmits<{
19
- ready: [ReturnType<typeof useScript>]
20
- error: []
21
- }>()
22
-
23
- const rootEl = ref<HTMLDivElement | undefined>()
24
- const containerEl = ref<HTMLDivElement | undefined>()
25
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
1
+ <script setup>
2
+ import { ref, computed, onBeforeUnmount, onMounted, watch } from "vue";
3
+ import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
4
+ import { useScript } from "#imports";
5
+ const props = defineProps({
6
+ trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
7
+ publishableKey: { type: String, required: true },
8
+ pricingTableId: { type: String, required: true },
9
+ clientReferenceId: { type: String, required: false },
10
+ customerEmail: { type: String, required: false },
11
+ customerSessionClientSecret: { type: String, required: false }
12
+ });
13
+ const emit = defineEmits(["ready", "error"]);
14
+ const rootEl = ref();
15
+ const containerEl = ref();
16
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
26
17
  const instance = useScript(`https://js.stripe.com/v3/pricing-table.js`, {
27
- trigger,
28
- })
29
- const { onLoaded, status } = instance
30
-
31
- const pricingTable = ref<HTMLElement | undefined>()
18
+ trigger
19
+ });
20
+ const { onLoaded, status } = instance;
21
+ const pricingTable = ref();
32
22
  onMounted(() => {
33
23
  onLoaded(() => {
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)
24
+ const StripePricingTable = window.customElements.get("stripe-pricing-table");
25
+ const stripePricingTable = new StripePricingTable();
26
+ stripePricingTable.setAttribute("publishable-key", props.publishableKey);
27
+ stripePricingTable.setAttribute("pricing-table-id", props.pricingTableId);
38
28
  if (props.clientReferenceId)
39
- stripePricingTable.setAttribute('client-reference-id', props.clientReferenceId)
29
+ stripePricingTable.setAttribute("client-reference-id", props.clientReferenceId);
40
30
  if (props.customerEmail)
41
- stripePricingTable.setAttribute('customer-email', props.customerEmail)
31
+ stripePricingTable.setAttribute("customer-email", props.customerEmail);
42
32
  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(status, (status) => {
49
- if (status === 'error') {
50
- emit('error')
33
+ stripePricingTable.setAttribute("customer-session-client-secret", props.customerSessionClientSecret);
34
+ pricingTable.value = stripePricingTable;
35
+ rootEl.value.appendChild(stripePricingTable);
36
+ emit("ready", instance);
37
+ });
38
+ watch(status, (status2) => {
39
+ if (status2 === "error") {
40
+ emit("error");
51
41
  }
52
- })
53
- })
54
-
42
+ });
43
+ });
55
44
  onBeforeUnmount(() => {
56
- pricingTable.value?.remove()
57
- })
58
-
45
+ pricingTable.value?.remove();
46
+ });
59
47
  const rootAttrs = computed(() => {
60
48
  return {
61
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
62
- }
63
- })
49
+ ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
50
+ };
51
+ });
64
52
  </script>
65
53
 
66
54
  <template>
@@ -0,0 +1,35 @@
1
+ import type { ElementScriptTrigger } from '../types.js';
2
+ type __VLS_Props = {
3
+ trigger?: ElementScriptTrigger;
4
+ publishableKey: string;
5
+ pricingTableId: string;
6
+ clientReferenceId?: string;
7
+ customerEmail?: string;
8
+ customerSessionClientSecret?: string;
9
+ };
10
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {};
11
+ type __VLS_Slots = {} & {
12
+ loading?: (props: typeof __VLS_1) => any;
13
+ } & {
14
+ awaitingLoad?: (props: typeof __VLS_3) => any;
15
+ } & {
16
+ error?: (props: typeof __VLS_5) => any;
17
+ } & {
18
+ default?: (props: typeof __VLS_7) => any;
19
+ };
20
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
21
+ error: () => any;
22
+ ready: (args_0: import("../types.js").UseScriptContext<Record<string | symbol, any>>) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
24
+ onError?: (() => any) | undefined;
25
+ onReady?: ((args_0: import("../types.js").UseScriptContext<Record<string | symbol, any>>) => any) | undefined;
26
+ }>, {
27
+ trigger: ElementScriptTrigger;
28
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
30
+ export default _default;
31
+ type __VLS_WithSlots<T, S> = T & {
32
+ new (): {
33
+ $slots: S;
34
+ };
35
+ };