cja-phoenix 1.2.39 → 1.2.41

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 (184) hide show
  1. package/dist/module.d.mts +6 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +29 -16
  4. package/dist/runtime/assets/iconia/fonts/CGG-icomoon.svg +94 -0
  5. package/dist/runtime/assets/iconia/fonts/CGG-icomoon.ttf +0 -0
  6. package/dist/runtime/assets/iconia/fonts/CGG-icomoon.woff +0 -0
  7. package/dist/runtime/assets/iconia/selection.json +1 -0
  8. package/dist/runtime/assets/iconia/style.css +281 -0
  9. package/dist/runtime/assets/scss/main.scss +6 -0
  10. package/dist/runtime/assets/scss/mixins/_funnel.scss +15 -0
  11. package/dist/runtime/assets/scss/mixins/_index.scss +46 -0
  12. package/dist/runtime/assets/scss/mixins/_media-queries.scss +109 -0
  13. package/dist/runtime/assets/scss/mixins/_results.scss +235 -0
  14. package/dist/runtime/assets/scss/tippy.scss +31 -0
  15. package/dist/runtime/assets/scss/variables/_breakpoints.scss +18 -0
  16. package/dist/runtime/assets/scss/variables/_colors.scss +100 -0
  17. package/dist/runtime/assets/scss/variables/_forms.scss +121 -0
  18. package/dist/runtime/assets/scss/variables/_grid.scss +12 -0
  19. package/dist/runtime/assets/scss/variables/_index.scss +6 -0
  20. package/dist/runtime/assets/scss/variables/_shadows.scss +7 -0
  21. package/dist/runtime/assets/scss/variables/_z-index.scss +6 -0
  22. package/dist/runtime/components/CjaButton.d.vue.ts +33 -0
  23. package/dist/runtime/components/CjaButton.vue +437 -0
  24. package/dist/runtime/components/CjaButton.vue.d.ts +33 -0
  25. package/dist/runtime/components/CollapseContainer.d.vue.ts +35 -0
  26. package/dist/runtime/components/CollapseContainer.vue +112 -0
  27. package/dist/runtime/components/CollapseContainer.vue.d.ts +35 -0
  28. package/dist/runtime/components/ContentTabs.d.vue.ts +23 -0
  29. package/dist/runtime/components/ContentTabs.vue +103 -0
  30. package/dist/runtime/components/ContentTabs.vue.d.ts +23 -0
  31. package/dist/runtime/components/Drawer.d.vue.ts +52 -0
  32. package/dist/runtime/components/Drawer.vue +169 -0
  33. package/dist/runtime/components/Drawer.vue.d.ts +52 -0
  34. package/dist/runtime/components/FixedContainer.d.vue.ts +37 -0
  35. package/dist/runtime/components/FixedContainer.vue +95 -0
  36. package/dist/runtime/components/FixedContainer.vue.d.ts +37 -0
  37. package/dist/runtime/components/GridContainer.d.vue.ts +13 -0
  38. package/dist/runtime/components/GridContainer.vue +37 -0
  39. package/dist/runtime/components/GridContainer.vue.d.ts +13 -0
  40. package/dist/runtime/components/GridItem.d.vue.ts +29 -0
  41. package/dist/runtime/components/GridItem.vue +93 -0
  42. package/dist/runtime/components/GridItem.vue.d.ts +29 -0
  43. package/dist/runtime/components/InfoMessage.d.vue.ts +28 -0
  44. package/dist/runtime/components/InfoMessage.vue +141 -0
  45. package/dist/runtime/components/InfoMessage.vue.d.ts +28 -0
  46. package/dist/runtime/components/LoadingSpinner.d.vue.ts +10 -0
  47. package/dist/runtime/components/LoadingSpinner.vue +39 -0
  48. package/dist/runtime/components/LoadingSpinner.vue.d.ts +10 -0
  49. package/dist/runtime/components/Modal.d.vue.ts +39 -0
  50. package/dist/runtime/components/Modal.vue +195 -0
  51. package/dist/runtime/components/Modal.vue.d.ts +39 -0
  52. package/dist/runtime/components/Scaffold.d.vue.ts +13 -0
  53. package/dist/runtime/components/Scaffold.vue +3 -0
  54. package/dist/runtime/components/Scaffold.vue.d.ts +13 -0
  55. package/dist/runtime/components/StickyContainer.d.vue.ts +21 -0
  56. package/dist/runtime/components/StickyContainer.vue +57 -0
  57. package/dist/runtime/components/StickyContainer.vue.d.ts +21 -0
  58. package/dist/runtime/components/form/CheckboxInput.d.vue.ts +42 -0
  59. package/dist/runtime/components/form/CheckboxInput.vue +163 -0
  60. package/dist/runtime/components/form/CheckboxInput.vue.d.ts +42 -0
  61. package/dist/runtime/components/form/CheckboxInputList.d.vue.ts +37 -0
  62. package/dist/runtime/components/form/CheckboxInputList.vue +84 -0
  63. package/dist/runtime/components/form/CheckboxInputList.vue.d.ts +37 -0
  64. package/dist/runtime/components/form/CurrencyInput.d.vue.ts +37 -0
  65. package/dist/runtime/components/form/CurrencyInput.vue +134 -0
  66. package/dist/runtime/components/form/CurrencyInput.vue.d.ts +37 -0
  67. package/dist/runtime/components/form/DateInput.d.vue.ts +40 -0
  68. package/dist/runtime/components/form/DateInput.vue +325 -0
  69. package/dist/runtime/components/form/DateInput.vue.d.ts +40 -0
  70. package/dist/runtime/components/form/FileInput.d.vue.ts +46 -0
  71. package/dist/runtime/components/form/FileInput.vue +202 -0
  72. package/dist/runtime/components/form/FileInput.vue.d.ts +46 -0
  73. package/dist/runtime/components/form/NumberInput.d.vue.ts +41 -0
  74. package/dist/runtime/components/form/NumberInput.vue +162 -0
  75. package/dist/runtime/components/form/NumberInput.vue.d.ts +41 -0
  76. package/dist/runtime/components/form/PhoneInput.d.vue.ts +44 -0
  77. package/dist/runtime/components/form/PhoneInput.vue +143 -0
  78. package/dist/runtime/components/form/PhoneInput.vue.d.ts +44 -0
  79. package/dist/runtime/components/form/RadioInput.d.vue.ts +42 -0
  80. package/dist/runtime/components/form/RadioInput.vue +181 -0
  81. package/dist/runtime/components/form/RadioInput.vue.d.ts +42 -0
  82. package/dist/runtime/components/form/RadioInputList.d.vue.ts +57 -0
  83. package/dist/runtime/components/form/RadioInputList.vue +130 -0
  84. package/dist/runtime/components/form/RadioInputList.vue.d.ts +57 -0
  85. package/dist/runtime/components/form/SelectInput.d.vue.ts +46 -0
  86. package/dist/runtime/components/form/SelectInput.vue +362 -0
  87. package/dist/runtime/components/form/SelectInput.vue.d.ts +46 -0
  88. package/dist/runtime/components/form/SelectionTiles.d.vue.ts +44 -0
  89. package/dist/runtime/components/form/SelectionTiles.vue +329 -0
  90. package/dist/runtime/components/form/SelectionTiles.vue.d.ts +44 -0
  91. package/dist/runtime/components/form/SliderInput.d.vue.ts +51 -0
  92. package/dist/runtime/components/form/SliderInput.vue +175 -0
  93. package/dist/runtime/components/form/SliderInput.vue.d.ts +51 -0
  94. package/dist/runtime/components/form/TextInput.d.vue.ts +56 -0
  95. package/dist/runtime/components/form/TextInput.vue +227 -0
  96. package/dist/runtime/components/form/TextInput.vue.d.ts +56 -0
  97. package/dist/runtime/components/form/TextareaInput.d.vue.ts +37 -0
  98. package/dist/runtime/components/form/TextareaInput.vue +76 -0
  99. package/dist/runtime/components/form/TextareaInput.vue.d.ts +37 -0
  100. package/dist/runtime/components/form/TileCheckboxInput.d.vue.ts +40 -0
  101. package/dist/runtime/components/form/TileCheckboxInput.vue +108 -0
  102. package/dist/runtime/components/form/TileCheckboxInput.vue.d.ts +40 -0
  103. package/dist/runtime/components/form/ToggleInput.d.vue.ts +43 -0
  104. package/dist/runtime/components/form/ToggleInput.vue +119 -0
  105. package/dist/runtime/components/form/ToggleInput.vue.d.ts +43 -0
  106. package/dist/runtime/components/form/structure/Container.d.vue.ts +16 -0
  107. package/dist/runtime/components/form/structure/Container.vue +31 -0
  108. package/dist/runtime/components/form/structure/Container.vue.d.ts +16 -0
  109. package/dist/runtime/components/form/structure/Description.d.vue.ts +9 -0
  110. package/dist/runtime/components/form/structure/Description.vue +26 -0
  111. package/dist/runtime/components/form/structure/Description.vue.d.ts +9 -0
  112. package/dist/runtime/components/form/structure/Error.d.vue.ts +9 -0
  113. package/dist/runtime/components/form/structure/Error.vue +23 -0
  114. package/dist/runtime/components/form/structure/Error.vue.d.ts +9 -0
  115. package/dist/runtime/components/form/structure/Title.d.vue.ts +12 -0
  116. package/dist/runtime/components/form/structure/Title.vue +43 -0
  117. package/dist/runtime/components/form/structure/Title.vue.d.ts +12 -0
  118. package/dist/runtime/components/funnel/Header.d.vue.ts +18 -0
  119. package/dist/runtime/components/funnel/Header.vue +62 -0
  120. package/dist/runtime/components/funnel/Header.vue.d.ts +18 -0
  121. package/dist/runtime/composables/useCjaGtm.d.ts +19 -0
  122. package/dist/runtime/composables/useCjaGtm.js +164 -0
  123. package/dist/runtime/composables/useFunnelConfig.d.ts +11 -0
  124. package/dist/runtime/composables/useFunnelConfig.js +51 -0
  125. package/dist/runtime/composables/useFunnelSummary.d.ts +14 -0
  126. package/dist/runtime/composables/useFunnelSummary.js +16 -0
  127. package/dist/runtime/composables/useHeaderHeight.d.ts +3 -0
  128. package/dist/runtime/composables/useHeaderHeight.js +24 -0
  129. package/dist/runtime/composables/useJourneyConfig.d.ts +11 -0
  130. package/dist/runtime/composables/useJourneyConfig.js +13 -0
  131. package/dist/runtime/composables/useValidateForm.d.ts +11 -0
  132. package/dist/runtime/composables/useValidateForm.js +33 -0
  133. package/dist/runtime/data/dialCodes.d.ts +7 -0
  134. package/dist/runtime/data/dialCodes.js +1466 -0
  135. package/dist/runtime/data/phoneDigits.d.ts +2 -0
  136. package/dist/runtime/data/phoneDigits.js +231 -0
  137. package/dist/runtime/plugins/tippy.d.ts +4 -0
  138. package/dist/runtime/plugins/tippy.js +12 -0
  139. package/dist/runtime/plugins/v-calendar.d.ts +3 -0
  140. package/dist/runtime/plugins/v-calendar.js +6 -0
  141. package/dist/runtime/server/tsconfig.json +3 -0
  142. package/dist/runtime/types/Form.d.ts +34 -0
  143. package/dist/runtime/types/Form.js +20 -0
  144. package/dist/runtime/types/Grid.d.ts +4 -0
  145. package/dist/runtime/types/Grid.js +0 -0
  146. package/dist/runtime/types/Icon.d.ts +2 -0
  147. package/dist/runtime/types/Icon.js +85 -0
  148. package/dist/runtime/types/JourneyConfig.d.ts +9 -0
  149. package/dist/runtime/types/JourneyConfig.js +0 -0
  150. package/dist/runtime/types/index.d.ts +4 -0
  151. package/dist/runtime/types/index.js +4 -0
  152. package/dist/runtime/utils/applyProductData.d.ts +10 -0
  153. package/dist/runtime/utils/applyProductData.js +22 -0
  154. package/dist/runtime/utils/convertDate.d.ts +5 -0
  155. package/dist/runtime/utils/convertDate.js +17 -0
  156. package/dist/runtime/utils/findScrollAncestor.d.ts +1 -0
  157. package/dist/runtime/utils/findScrollAncestor.js +14 -0
  158. package/dist/runtime/utils/formValidations.d.ts +78 -0
  159. package/dist/runtime/utils/formValidations.js +180 -0
  160. package/dist/runtime/utils/formatValue.d.ts +4 -0
  161. package/dist/runtime/utils/formatValue.js +20 -0
  162. package/dist/runtime/utils/getAbTestVersion.d.ts +9 -0
  163. package/dist/runtime/utils/getAbTestVersion.js +48 -0
  164. package/dist/runtime/utils/getCalendarUrl.d.ts +8 -0
  165. package/dist/runtime/utils/getCalendarUrl.js +24 -0
  166. package/dist/runtime/utils/getFromUrl.d.ts +2 -0
  167. package/dist/runtime/utils/getFromUrl.js +25 -0
  168. package/dist/runtime/utils/getStoryblokUrl.d.ts +71 -0
  169. package/dist/runtime/utils/getStoryblokUrl.js +35 -0
  170. package/dist/runtime/utils/jsonReviver.d.ts +1 -0
  171. package/dist/runtime/utils/jsonReviver.js +18 -0
  172. package/dist/runtime/utils/mediaBreakpoints.d.ts +28 -0
  173. package/dist/runtime/utils/mediaBreakpoints.js +28 -0
  174. package/dist/runtime/utils/toggleScroll.d.ts +1 -0
  175. package/dist/runtime/utils/toggleScroll.js +6 -0
  176. package/dist/runtime/utils/updateForm.d.ts +11 -0
  177. package/dist/runtime/utils/updateForm.js +74 -0
  178. package/dist/runtime/utils/updateMarketingConsent.d.ts +4 -0
  179. package/dist/runtime/utils/updateMarketingConsent.js +13 -0
  180. package/dist/runtime/utils/uploadFile.d.ts +8 -0
  181. package/dist/runtime/utils/uploadFile.js +13 -0
  182. package/dist/types.d.mts +6 -10
  183. package/package.json +9 -8
  184. package/dist/module.d.cts +0 -2
@@ -0,0 +1,180 @@
1
+ import phoneDigits from "../data/phoneDigits.js";
2
+ import * as yup from "yup";
3
+ const string = (messages, options) => {
4
+ let validation = yup.string().transform((value) => value || void 0);
5
+ if (messages.required) {
6
+ validation = validation.required(messages.required);
7
+ }
8
+ if (options?.minLength && messages.minLength) {
9
+ validation = validation.min(options.minLength, messages.minLength);
10
+ }
11
+ if (options?.maxLength && messages.maxLength) {
12
+ validation = validation.max(options.maxLength, messages.maxLength);
13
+ }
14
+ return validation;
15
+ };
16
+ const boolean = (messages, options) => {
17
+ let validation = yup.boolean();
18
+ if (messages.required) {
19
+ validation = validation.required(messages.required);
20
+ }
21
+ if (options?.strictValue && messages.strictValue) {
22
+ validation = validation.oneOf([options.strictValue], messages.strictValue);
23
+ }
24
+ return validation;
25
+ };
26
+ const email = (messages) => {
27
+ let validation = yup.string().transform((value) => value || void 0).test(
28
+ "emailTest",
29
+ messages.email,
30
+ (v) => v ? /^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i.test(v) : true
31
+ ).email(messages.email);
32
+ if (messages.required) {
33
+ validation = validation.required(messages.required);
34
+ }
35
+ return validation;
36
+ };
37
+ const number = (messages, options) => {
38
+ let validation = yup.number().transform((value) => Number.isNaN(value) ? void 0 : value);
39
+ if (messages.required) {
40
+ validation = validation.required(messages.required);
41
+ }
42
+ if (options?.min != void 0 && messages.min) {
43
+ validation = validation.min(options.min, messages.min);
44
+ }
45
+ if (options?.max != void 0 && messages.max) {
46
+ validation = validation.max(options.max, messages.max);
47
+ }
48
+ if (options?.lessThan != void 0 && messages.lessThan) {
49
+ validation = validation.lessThan(options.lessThan, messages.lessThan);
50
+ }
51
+ if (options?.moreThan != void 0 && messages.moreThan) {
52
+ validation = validation.moreThan(options.moreThan, messages.moreThan);
53
+ }
54
+ return validation;
55
+ };
56
+ const phone = (messages, options) => yup.lazy(() => {
57
+ let validation = yup.string().transform((value) => value || void 0).test(
58
+ "phoneTest",
59
+ messages.phone,
60
+ (v) => v && options.countryCode.value == "351" ? /^2\d|9[1236]\d{7}/.test(v) : true
61
+ ).length(phoneDigits[options.countryCode.value], messages.phone);
62
+ if (messages.required) {
63
+ validation = validation.required(messages.required);
64
+ }
65
+ return validation;
66
+ });
67
+ const zipcode = (messages) => {
68
+ let validation = yup.string().transform((value) => value || void 0).min(8, messages.zipcode);
69
+ if (messages.required) {
70
+ validation = validation.required(messages.required);
71
+ }
72
+ return validation;
73
+ };
74
+ const file = (messages, options) => {
75
+ let validation = yup.object({
76
+ extension: yup.string().matches(options?.extension || /(png|jpg|pdf)/g, messages.extension)
77
+ });
78
+ if (messages.required) {
79
+ validation = validation.test(
80
+ "fileRequired",
81
+ messages.required,
82
+ (v) => v ? !v.src ? v.file ? true : false : true : false
83
+ );
84
+ }
85
+ if (messages.size && options?.size) {
86
+ const byteSize = {
87
+ kb: 1e3,
88
+ mb: 1048576
89
+ };
90
+ validation = validation.test(
91
+ "fileSize",
92
+ messages.size,
93
+ (v) => v?.file && options.size?.collectionType ? v.file?.size < byteSize[options.size?.collectionType] * options.size.value : false
94
+ );
95
+ }
96
+ return validation;
97
+ };
98
+ const date = (messages, options) => {
99
+ let validation = yup.date().transform(
100
+ (v, ogV) => (
101
+ // ogV as "phone_number" is still as of yet unexplained
102
+ ogV == "phone_number" || ogV instanceof Date ? v : ogV
103
+ )
104
+ ).test("dateTest", messages.invalid, (v, context) => {
105
+ const formatRegex = (() => {
106
+ switch (options.format) {
107
+ case "DD/MM/YYYY":
108
+ return /^\d{2}\/\d{2}\/\d{4}$/g;
109
+ case "MM/YYYY":
110
+ return /^\d{2}\/\d{4}$/g;
111
+ case "YYYY":
112
+ return /^\d{4}$/g;
113
+ case "YYYY/MM/DD":
114
+ return /^\d{4}\/\d{2}\/\d{2}$/g;
115
+ case "YYYY/MM":
116
+ return /^\d{4}\/\d{2}$/g;
117
+ }
118
+ })();
119
+ return formatRegex.test(context.originalValue);
120
+ }).transform((v) => {
121
+ if (v.split) {
122
+ const vArr = v.split("/");
123
+ switch (options.format) {
124
+ case "DD/MM/YYYY":
125
+ case "MM/YYYY":
126
+ vArr.reverse();
127
+ break;
128
+ }
129
+ return new Date(vArr.join("-"));
130
+ }
131
+ return v;
132
+ }).typeError(messages.invalid);
133
+ if (messages.required) {
134
+ validation = validation.required(messages.required);
135
+ }
136
+ if (options?.minDate && messages.minDate) {
137
+ validation = validation.min(options.minDate, messages.minDate);
138
+ }
139
+ if (options?.maxDate && messages.maxDate) {
140
+ validation = validation.max(options.maxDate, messages.maxDate);
141
+ }
142
+ return validation;
143
+ };
144
+ const nif = (messages) => {
145
+ let validation = yup.string().transform((value) => value || void 0).min(9, messages.invalid).test("nifTest", messages.invalid, (v) => {
146
+ if (!v) return false;
147
+ const nif2 = v.toString().split("");
148
+ const mod = (Number(nif2[7]) * 2 + Number(nif2[6]) * 3 + Number(nif2[5]) * 4 + Number(nif2[4]) * 5 + Number(nif2[3]) * 6 + Number(nif2[2]) * 7 + Number(nif2[1]) * 8 + Number(nif2[0]) * 9) % 11;
149
+ return Number(nif2[8]) == (mod == 0 || mod == 1 ? 0 : 11 - mod);
150
+ });
151
+ if (messages.required) {
152
+ validation = validation.required(messages.required);
153
+ }
154
+ return validation;
155
+ };
156
+ const array = (messages, options) => {
157
+ let validation = yup.array();
158
+ if (messages.required) {
159
+ validation = validation.required(messages.required).min(1, messages.required);
160
+ }
161
+ if (options?.minLength && messages.minLength) {
162
+ validation = validation.min(options.minLength, messages.minLength);
163
+ }
164
+ if (options?.maxLength && messages.maxLength) {
165
+ validation = validation.max(options.maxLength, messages.maxLength);
166
+ }
167
+ return validation;
168
+ };
169
+ export const formValidation = {
170
+ string,
171
+ boolean,
172
+ email,
173
+ number,
174
+ phone,
175
+ zipcode,
176
+ file,
177
+ date,
178
+ nif,
179
+ array
180
+ };
@@ -0,0 +1,4 @@
1
+ export declare const formatCurrency: (n: number | undefined, maxDigits?: number, minDigits?: number) => string;
2
+ export declare const formatPercent: (n: number | undefined, maxDigits?: number, minDigits?: number) => string;
3
+ export declare const formatDateString: (d: string, format?: "DD/MM/YYYY" | "MM/YYYY") => string;
4
+ export declare const formatPositiveNumber: (n: number) => number;
@@ -0,0 +1,20 @@
1
+ export const formatCurrency = (n, maxDigits = 2, minDigits = 0) => {
2
+ const { format } = new Intl.NumberFormat("de-DE", {
3
+ style: "currency",
4
+ currency: "EUR",
5
+ maximumFractionDigits: maxDigits,
6
+ minimumFractionDigits: minDigits > maxDigits ? maxDigits : minDigits,
7
+ trailingZeroDisplay: minDigits == 0 ? "stripIfInteger" : void 0
8
+ });
9
+ return format(n || 0);
10
+ };
11
+ export const formatPercent = (n, maxDigits = 2, minDigits = 2) => `${n ? n.toLocaleString("de-DE", {
12
+ maximumFractionDigits: maxDigits,
13
+ minimumFractionDigits: minDigits > maxDigits ? maxDigits : minDigits,
14
+ trailingZeroDisplay: minDigits == 0 ? "stripIfInteger" : void 0
15
+ }) : 0}%`;
16
+ export const formatDateString = (d, format) => {
17
+ const date = new Date(d).toLocaleDateString("pt");
18
+ return format == "MM/YYYY" ? date.slice(3) : date;
19
+ };
20
+ export const formatPositiveNumber = (n) => n < 0 ? n * -1 : n;
@@ -0,0 +1,9 @@
1
+ export declare const getAbTestVersion: (journeyId: string | undefined, config: {
2
+ formType: "FUNNEL" | "LANDING" | "RESULTS_PAGE";
3
+ enabled: boolean;
4
+ experiment: string;
5
+ condition?: {
6
+ type: "utmSource";
7
+ utmSource: string;
8
+ };
9
+ }) => Promise<any>;
@@ -0,0 +1,48 @@
1
+ import {
2
+ useRuntimeConfig,
3
+ useCookie,
4
+ updateForm,
5
+ useRequestFetch
6
+ } from "#imports";
7
+ export const getAbTestVersion = async (journeyId, config) => {
8
+ const { apiURL } = useRuntimeConfig().public;
9
+ const requestFetch = useRequestFetch();
10
+ const abTestCookie = useCookie(`abTestVersion_${config.experiment}`);
11
+ const fetchAbTestVersion = async () => requestFetch("/core/apis/data/abTestServiceLookup", {
12
+ baseURL: apiURL,
13
+ method: "post",
14
+ body: {
15
+ experimentName: config.experiment,
16
+ journeyId
17
+ }
18
+ }).then(async (d) => {
19
+ const abTestVersion = d.version || "control";
20
+ abTestCookie.value = abTestVersion;
21
+ await updateForm({
22
+ journeyId,
23
+ step: 0,
24
+ stepName: "AB Test Version",
25
+ formType: config.formType,
26
+ eventType: "STEP_CHANGED",
27
+ payload: {
28
+ abTestName: config.experiment,
29
+ abTestVersion
30
+ }
31
+ });
32
+ return abTestVersion;
33
+ });
34
+ if (!abTestCookie.value && journeyId && config.enabled) {
35
+ if (config.condition) {
36
+ switch (config.condition.type) {
37
+ case "utmSource":
38
+ const url = new URL(location.href);
39
+ if (url.searchParams.get("utm_source") == config.condition.utmSource) {
40
+ return fetchAbTestVersion();
41
+ }
42
+ }
43
+ } else {
44
+ return fetchAbTestVersion();
45
+ }
46
+ }
47
+ return abTestCookie.value || "control";
48
+ };
@@ -0,0 +1,8 @@
1
+ export declare const getCalendarUrl: (options: {
2
+ title: string;
3
+ description?: string;
4
+ location?: string;
5
+ dateStart: Date;
6
+ dateEnd: Date;
7
+ allDay?: boolean;
8
+ }) => string;
@@ -0,0 +1,24 @@
1
+ export const getCalendarUrl = (options) => {
2
+ const url = new URL("calendar/render", "https://www.google.com");
3
+ const formatText = (text) => text.trim();
4
+ const formatDate = (date) => {
5
+ const targetDate = new Date(date).toISOString().replaceAll(/:/g, "").replaceAll(/-/g, "").replaceAll(/\.\d{3}(?=Z)/g, "");
6
+ if (options.allDay) {
7
+ targetDate.replaceAll(/T\d{6}(?=Z)/g, "");
8
+ }
9
+ return targetDate;
10
+ };
11
+ url.searchParams.set("action", "TEMPLATE");
12
+ url.searchParams.set("text", formatText(options.title));
13
+ if (options.description) {
14
+ url.searchParams.set("details", formatText(options.description));
15
+ }
16
+ if (options.location) {
17
+ url.searchParams.set("location", formatText(options.location));
18
+ }
19
+ url.searchParams.set(
20
+ "dates",
21
+ `${formatDate(options.dateStart)}/${formatDate(options.dateEnd)}`
22
+ );
23
+ return url.toString();
24
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getFromUrl: (searchParam: string, removeFromUrl?: boolean) => string | string[] | undefined;
2
+ export declare const removeFromUrl: (searchParam: string) => void;
@@ -0,0 +1,25 @@
1
+ export const getFromUrl = (searchParam, removeFromUrl2) => {
2
+ const url = new URL(window.location.href);
3
+ return url.searchParams.has(searchParam) ? (() => {
4
+ const param = url.searchParams.getAll(searchParam).map((p) => decodeURIComponent(p));
5
+ if (removeFromUrl2) {
6
+ url.searchParams.delete(searchParam);
7
+ history.replaceState(history.state, "", url.toString());
8
+ }
9
+ switch (param.length) {
10
+ case 0:
11
+ return void 0;
12
+ case 1:
13
+ return param[0];
14
+ default:
15
+ return param;
16
+ }
17
+ })() : void 0;
18
+ };
19
+ export const removeFromUrl = (searchParam) => {
20
+ const url = new URL(window.location.href);
21
+ if (url.searchParams.has(searchParam)) {
22
+ url.searchParams.delete(searchParam);
23
+ history.replaceState(history.state, "", url.toString());
24
+ }
25
+ };
@@ -0,0 +1,71 @@
1
+ type MultilinkStoryblok = {
2
+ fieldtype: 'multilink';
3
+ id: string;
4
+ url: string;
5
+ cached_url: string;
6
+ target?: '_blank' | '_self';
7
+ anchor?: string;
8
+ rel?: string;
9
+ title?: string;
10
+ prep?: string;
11
+ linktype: 'story';
12
+ story?: {
13
+ name: string;
14
+ created_at?: string;
15
+ published_at?: string;
16
+ id: number;
17
+ uuid: string;
18
+ content?: {
19
+ [k: string]: any;
20
+ };
21
+ slug: string;
22
+ full_slug: string;
23
+ sort_by_date?: null | string;
24
+ position?: number;
25
+ tag_list?: string[];
26
+ is_startpage?: boolean;
27
+ parent_id?: null | number;
28
+ meta_data?: null | {
29
+ [k: string]: any;
30
+ };
31
+ group_id?: string;
32
+ first_published_at?: string;
33
+ release_id?: null | number;
34
+ lang?: string;
35
+ path?: null | string;
36
+ alternates?: any[];
37
+ default_full_slug?: null | string;
38
+ translated_slugs?: null | any[];
39
+ [k: string]: any;
40
+ };
41
+ [k: string]: any;
42
+ } | {
43
+ fieldtype: 'multilink';
44
+ id: string;
45
+ url: string;
46
+ cached_url: string;
47
+ target?: '_blank' | '_self';
48
+ linktype: 'url';
49
+ rel?: string;
50
+ title?: string;
51
+ [k: string]: any;
52
+ } | {
53
+ fieldtype: 'multilink';
54
+ id: string;
55
+ url: string;
56
+ cached_url: string;
57
+ target?: '_blank' | '_self';
58
+ email?: string;
59
+ linktype: 'email';
60
+ [k: string]: any;
61
+ } | {
62
+ fieldtype: 'multilink';
63
+ id: string;
64
+ url: string;
65
+ cached_url: string;
66
+ target?: '_blank' | '_self';
67
+ linktype: 'asset';
68
+ [k: string]: any;
69
+ };
70
+ export declare const getStoryblokUrl: (link: MultilinkStoryblok | undefined) => string | undefined;
71
+ export {};
@@ -0,0 +1,35 @@
1
+ const parametersList = ["category"];
2
+ export const getStoryblokUrl = (link) => {
3
+ if (link) {
4
+ const url = link.url || link.cached_url;
5
+ const parameters = [];
6
+ if (url) {
7
+ let finalUrl = (() => {
8
+ switch (link.linktype) {
9
+ case "story":
10
+ if (url === "/") {
11
+ return "/";
12
+ }
13
+ return `/${url.replace(/\/$/g, "")}`;
14
+ case "url":
15
+ return url.replace(/\/$/g, "");
16
+ case "asset":
17
+ return url;
18
+ }
19
+ })();
20
+ if (Object.keys(link).filter((k) => parametersList.includes(k)).length) {
21
+ parametersList.forEach((p) => {
22
+ if (link[p]) {
23
+ parameters.push([p, link[p]]);
24
+ }
25
+ });
26
+ finalUrl += `?${new URLSearchParams(parameters)}`;
27
+ }
28
+ if (link.anchor) {
29
+ finalUrl += `#${link.anchor}`;
30
+ }
31
+ return finalUrl;
32
+ }
33
+ }
34
+ return void 0;
35
+ };
@@ -0,0 +1 @@
1
+ export declare const jsonReviver: (data: any) => any;
@@ -0,0 +1,18 @@
1
+ export const jsonReviver = (data) => JSON.parse(data, (_, v) => {
2
+ if (typeof v == "string" && v.includes(",")) {
3
+ return v.split(",");
4
+ }
5
+ if (v === "true" || v === "false") {
6
+ return v === "true";
7
+ }
8
+ if ((Number(v) || v === "0") && typeof v != "boolean") {
9
+ return Number(v);
10
+ }
11
+ if (v === "undefined") {
12
+ return void 0;
13
+ }
14
+ if (v === "null") {
15
+ return null;
16
+ }
17
+ return v;
18
+ });
@@ -0,0 +1,28 @@
1
+ export declare const mediaBreakpoints: {
2
+ xxs: {
3
+ max: number;
4
+ };
5
+ xs: {
6
+ min: number;
7
+ max: number;
8
+ };
9
+ sm: {
10
+ min: number;
11
+ max: number;
12
+ };
13
+ md: {
14
+ min: number;
15
+ max: number;
16
+ };
17
+ lg: {
18
+ min: number;
19
+ max: number;
20
+ };
21
+ xl: {
22
+ min: number;
23
+ max: number;
24
+ };
25
+ xxl: {
26
+ min: number;
27
+ };
28
+ };
@@ -0,0 +1,28 @@
1
+ export const mediaBreakpoints = {
2
+ xxs: {
3
+ max: 419
4
+ },
5
+ xs: {
6
+ min: 420,
7
+ max: 559
8
+ },
9
+ sm: {
10
+ min: 560,
11
+ max: 767
12
+ },
13
+ md: {
14
+ min: 768,
15
+ max: 1023
16
+ },
17
+ lg: {
18
+ min: 1024,
19
+ max: 1199
20
+ },
21
+ xl: {
22
+ min: 1200,
23
+ max: 1439
24
+ },
25
+ xxl: {
26
+ min: 1440
27
+ }
28
+ };
@@ -0,0 +1 @@
1
+ export declare const toggleScroll: () => void;
@@ -0,0 +1,6 @@
1
+ export const toggleScroll = () => {
2
+ const el = document.querySelector("html");
3
+ const scrollDisabled = el.getAttribute("scroll-disabled") === "true";
4
+ el.style.overflow = scrollDisabled ? "" : "clip";
5
+ el.setAttribute("scroll-disabled", `${!scrollDisabled}`);
6
+ };
@@ -0,0 +1,11 @@
1
+ export declare const updateForm: (options: {
2
+ journeyId: string | undefined;
3
+ nucleusJourneyId?: string | null;
4
+ step: number;
5
+ payload: Record<string, any>;
6
+ stepName: string;
7
+ isCompleted?: boolean;
8
+ sentToDialer?: boolean;
9
+ eventType?: string;
10
+ formType: string;
11
+ }) => Promise<void>;
@@ -0,0 +1,74 @@
1
+ import { useCookie, useRoute, useRuntimeConfig } from "#imports";
2
+ export const updateForm = async (options) => {
3
+ const { apiURL, nucleusURL } = useRuntimeConfig().public;
4
+ const { fullPath } = useRoute();
5
+ let legacyOk = false;
6
+ let nucleusOk = false;
7
+ const errors = [];
8
+ try {
9
+ const res = await $fetch("/core/apis/data/updateForm", {
10
+ method: "PUT",
11
+ baseURL: apiURL,
12
+ body: {
13
+ eventType: options.eventType || "STEP_CHANGED",
14
+ isActionEvent: true,
15
+ journeyId: options.journeyId,
16
+ stepName: options.stepName,
17
+ isCompleted: options.isCompleted || false,
18
+ sentToDialer: options.sentToDialer || true,
19
+ lastStepNumber: options.step,
20
+ lastStepType: options.formType,
21
+ lastStepUrl: fullPath,
22
+ data: JSON.stringify({
23
+ ...options.payload,
24
+ formType: options.formType
25
+ })
26
+ }
27
+ });
28
+ if (res.status != "OK") {
29
+ throw new Error(`HTTP ${res.status}`);
30
+ }
31
+ legacyOk = true;
32
+ } catch (err) {
33
+ errors.push(`[OLD] ${String(err)}`);
34
+ }
35
+ if (options.nucleusJourneyId) {
36
+ try {
37
+ const deviceIdCookie = useCookie("device_id");
38
+ if (!deviceIdCookie.value) {
39
+ throw new Error("deviceId missing");
40
+ }
41
+ await $fetch(`/journeys/${options.nucleusJourneyId}`, {
42
+ method: "PUT",
43
+ baseURL: nucleusURL,
44
+ body: {
45
+ journey_id: options.nucleusJourneyId,
46
+ device_id: deviceIdCookie.value,
47
+ form_data_json: {
48
+ ...options.payload,
49
+ formType: options.formType,
50
+ eventType: options.eventType || "STEP_CHANGED"
51
+ },
52
+ last_step_url: fullPath,
53
+ last_step_type: options.formType,
54
+ last_step_number: options.step,
55
+ last_step_name: options.stepName,
56
+ last_activity_at: (/* @__PURE__ */ new Date()).toISOString(),
57
+ is_completed: options.isCompleted ?? false
58
+ }
59
+ }).then(() => {
60
+ nucleusOk = true;
61
+ }).catch((err) => {
62
+ throw new Error(`HTTP ${err}`);
63
+ });
64
+ } catch (err) {
65
+ errors.push(`[NEW] ${String(err)}`);
66
+ }
67
+ } else {
68
+ nucleusOk = true;
69
+ }
70
+ if (legacyOk || nucleusOk) {
71
+ return;
72
+ }
73
+ throw new Error(`updateForm failed in BOTH systems. ${errors.join(" | ")}`);
74
+ };
@@ -0,0 +1,4 @@
1
+ export declare const updateMarketingConsent: (options: {
2
+ email: string;
3
+ journeyId?: string;
4
+ }) => Promise<unknown>;
@@ -0,0 +1,13 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ export const updateMarketingConsent = (options) => {
3
+ const { apiURL } = useRuntimeConfig().public;
4
+ return $fetch("/core/apis/data/verifyConsent", {
5
+ baseURL: apiURL,
6
+ method: "POST",
7
+ body: {
8
+ email: options.email,
9
+ currentPageUrl: location.origin + location.pathname,
10
+ journeyId: options.journeyId
11
+ }
12
+ });
13
+ };
@@ -0,0 +1,8 @@
1
+ export declare const uploadFile: (options: {
2
+ basePath: string;
3
+ journeyId: string;
4
+ file: Blob;
5
+ fileName: string;
6
+ extension: string;
7
+ bucketName: string;
8
+ }) => Promise<unknown>;
@@ -0,0 +1,13 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ export const uploadFile = (options) => {
3
+ const { apiURL } = useRuntimeConfig().public;
4
+ return $fetch("/core/apis/data/saveFileToS3", {
5
+ baseURL: apiURL,
6
+ method: "POST",
7
+ body: {
8
+ path: `${options.basePath}/${options.journeyId}/${options.fileName}.${options.extension}`,
9
+ file: options.file,
10
+ bucketName: options.bucketName
11
+ }
12
+ });
13
+ };
package/dist/types.d.mts CHANGED
@@ -1,13 +1,9 @@
1
- import type { ModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module.mjs'
1
+ import type { NuxtModule } from '@nuxt/schema'
2
2
 
3
- declare module '#app' {
4
- interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
5
- }
3
+ import type { default as Module } from './module.mjs'
6
4
 
7
- declare module '@nuxt/schema' {
8
- interface NuxtHooks extends ModuleHooks {}
9
- interface RuntimeConfig extends ModuleRuntimeConfig {}
10
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
11
- }
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
12
6
 
13
- export * from "./module.mjs"
7
+ export { default } from './module.mjs'
8
+
9
+ export * from '../dist/runtime/types/index.js'