cja-phoenix 0.6.0 → 0.6.2

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 (283) hide show
  1. package/dist/cja-phoenix.es.js +3816 -4306
  2. package/dist/style.css +1 -0
  3. package/dist/types/components/composite/CheckoutCrossSell.vue.d.ts +29 -0
  4. package/dist/types/components/composite/CheckoutLayout.vue.d.ts +23 -0
  5. package/dist/types/components/composite/CheckoutMilestones.vue.d.ts +16 -0
  6. package/dist/types/components/composite/CjaFooter.vue.d.ts +34 -0
  7. package/dist/types/components/composite/CjaMenuBar.vue.d.ts +52 -0
  8. package/dist/types/components/composite/FunnelLayout.vue.d.ts +35 -0
  9. package/dist/types/components/composite/FunnelSubmit.vue.d.ts +26 -0
  10. package/dist/types/components/composite/FunnelSummary.vue.d.ts +77 -0
  11. package/dist/types/components/composite/FunnelTitle.vue.d.ts +19 -0
  12. package/dist/types/components/composite/InfoShowcase.vue.d.ts +25 -0
  13. package/dist/types/components/composite/JourneyMacroSteps.vue.d.ts +16 -0
  14. package/dist/types/components/composite/ResultsSidebar.vue.d.ts +9 -0
  15. package/dist/types/components/forms/CheckboxInput.vue.d.ts +41 -0
  16. package/dist/types/components/forms/CurrencyInput.vue.d.ts +65 -0
  17. package/dist/types/components/forms/FileInput.vue.d.ts +89 -0
  18. package/dist/types/components/forms/NumberInput.vue.d.ts +58 -0
  19. package/dist/types/components/forms/PhoneInput.vue.d.ts +69 -0
  20. package/dist/types/components/forms/RadioInput.vue.d.ts +43 -0
  21. package/dist/types/components/forms/RadioInputList.vue.d.ts +65 -0
  22. package/dist/types/components/forms/SelectInput.vue.d.ts +80 -0
  23. package/dist/types/components/forms/SelectionTiles.vue.d.ts +51 -0
  24. package/dist/types/components/forms/TextInput.vue.d.ts +76 -0
  25. package/dist/types/components/forms/TileCheckboxInput.vue.d.ts +23 -0
  26. package/dist/types/components/forms/ToggleInput.vue.d.ts +51 -0
  27. package/dist/types/components/forms/structure/InputContainer.vue.d.ts +22 -0
  28. package/dist/types/components/forms/structure/InputError.vue.d.ts +15 -0
  29. package/dist/types/components/forms/structure/InputTitle.vue.d.ts +21 -0
  30. package/dist/types/components/structural/CjaButton.vue.d.ts +59 -0
  31. package/dist/types/components/structural/CollapseContainer.vue.d.ts +51 -0
  32. package/dist/{components → types/components}/structural/ContentTabs.vue.d.ts +17 -20
  33. package/dist/types/components/structural/FixedContainer.vue.d.ts +68 -0
  34. package/dist/types/components/structural/GridContainer.vue.d.ts +36 -0
  35. package/dist/types/components/structural/GridItem.vue.d.ts +26 -0
  36. package/dist/types/components/structural/InfoMessage.vue.d.ts +30 -0
  37. package/dist/types/components/structural/LoadingSpinner.vue.d.ts +17 -0
  38. package/dist/types/components/structural/Modal.vue.d.ts +65 -0
  39. package/dist/types/components/structural/Scaffold.vue.d.ts +9 -0
  40. package/dist/types/index.d.ts +16 -7
  41. package/dist/types/stories/CjaButton.story.vue.d.ts +2 -0
  42. package/dist/types/stories/ContentTabs.story.vue.d.ts +2 -0
  43. package/dist/types/stories/Modal.story.vue.d.ts +2 -0
  44. package/dist/types/stories/RadioInputList.story.vue.d.ts +2 -0
  45. package/dist/types/{Router.d.ts → types/Router.d.ts} +1 -0
  46. package/dist/types/types/index.d.ts +7 -0
  47. package/dist/{utils → types/utils}/formValidations.d.ts +3 -0
  48. package/package.json +21 -30
  49. package/src/assets/backdrop.scss +10 -0
  50. package/src/assets/breakpoints.scss +12 -0
  51. package/src/assets/fonts.scss +1 -0
  52. package/src/assets/forms.scss +97 -0
  53. package/src/assets/grid.scss +14 -0
  54. package/src/assets/iconia/Read Me.txt +7 -0
  55. package/src/assets/iconia/demo-files/demo.css +155 -0
  56. package/src/assets/iconia/demo-files/demo.js +30 -0
  57. package/src/assets/iconia/demo.html +7055 -0
  58. package/src/assets/iconia/fonts/CGG-icomoon.eot +0 -0
  59. package/src/assets/iconia/fonts/CGG-icomoon.svg +513 -0
  60. package/src/assets/iconia/fonts/CGG-icomoon.ttf +0 -0
  61. package/src/assets/iconia/fonts/CGG-icomoon.woff +0 -0
  62. package/src/assets/iconia/selection.json +1 -0
  63. package/src/assets/iconia/style.css +1547 -0
  64. package/src/assets/iconia/style.scss +2556 -0
  65. package/src/assets/iconia/variables.scss +507 -0
  66. package/src/assets/main.scss +30 -0
  67. package/src/assets/radioOld.scss +52 -0
  68. package/src/assets/shadows.scss +3 -0
  69. package/src/assets/tippy.scss +45 -0
  70. package/src/assets/vars/development.scss +4 -0
  71. package/src/assets/vars/production.scss +4 -0
  72. package/src/components/composite/CheckoutCrossSell.vue +478 -0
  73. package/src/components/composite/CheckoutLayout.vue +59 -0
  74. package/src/components/composite/CheckoutMilestones.vue +161 -0
  75. package/src/components/composite/CjaFooter.vue +223 -0
  76. package/src/components/composite/CjaMenuBar.vue +543 -0
  77. package/src/components/composite/FunnelLayout.vue +197 -0
  78. package/src/components/composite/FunnelSubmit.vue +53 -0
  79. package/src/components/composite/FunnelSummary.vue +198 -0
  80. package/src/components/composite/FunnelTitle.vue +59 -0
  81. package/src/components/composite/InfoShowcase.vue +87 -0
  82. package/src/components/composite/JourneyMacroSteps.vue +104 -0
  83. package/src/components/composite/ProductDetails.vue +149 -0
  84. package/src/components/composite/ResultsLayout.vue +156 -0
  85. package/src/components/composite/ResultsSidebar.vue +74 -0
  86. package/src/components/forms/CheckboxInput.vue +103 -0
  87. package/src/components/forms/CurrencyInput.vue +126 -0
  88. package/src/components/forms/FileInput.vue +250 -0
  89. package/src/components/forms/NumberInput.vue +165 -0
  90. package/src/components/forms/PhoneInput.vue +122 -0
  91. package/src/components/forms/RadioInput.vue +98 -0
  92. package/src/components/forms/RadioInputList.vue +156 -0
  93. package/src/components/forms/SelectInput.vue +392 -0
  94. package/src/components/forms/SelectionTiles.vue +196 -0
  95. package/src/components/forms/TextInput.vue +144 -0
  96. package/src/components/forms/TileCheckboxInput.vue +96 -0
  97. package/src/components/forms/ToggleInput.vue +88 -0
  98. package/src/components/forms/structure/InputContainer.vue +28 -0
  99. package/src/components/forms/structure/InputError.vue +26 -0
  100. package/src/components/forms/structure/InputTitle.vue +52 -0
  101. package/src/components/index.ts +73 -0
  102. package/src/components/structural/CjaButton.vue +332 -0
  103. package/src/components/structural/CollapseContainer.vue +141 -0
  104. package/src/components/structural/ContentTabs.vue +105 -0
  105. package/src/components/structural/FixedContainer.vue +107 -0
  106. package/src/components/structural/GridContainer.vue +70 -0
  107. package/src/components/structural/GridItem.vue +47 -0
  108. package/src/components/structural/InfoMessage.vue +105 -0
  109. package/src/components/structural/LoadingSpinner.vue +39 -0
  110. package/src/components/structural/Modal.vue +209 -0
  111. package/src/components/structural/Scaffold.vue +3 -0
  112. package/src/constants/MyConstants.ts +1 -0
  113. package/src/constants/index.ts +5 -0
  114. package/src/env.d.ts +11 -0
  115. package/src/index.ts +31 -0
  116. package/src/stories/CjaButton.story.vue +192 -0
  117. package/src/stories/ContentTabs.story.vue +59 -0
  118. package/src/stories/Modal.story.vue +127 -0
  119. package/src/stories/RadioInputList.story.vue +61 -0
  120. package/src/types/CheckoutMilestone.ts +5 -0
  121. package/src/types/Footer.ts +17 -0
  122. package/src/types/Menu.ts +19 -0
  123. package/src/types/RadioOption.ts +7 -0
  124. package/src/types/Router.ts +19 -0
  125. package/src/types/SelectOption.ts +6 -0
  126. package/src/types/StoreDataValue.ts +12 -0
  127. package/src/types/Storyblok.ts +10 -0
  128. package/src/types/TileOption.ts +8 -0
  129. package/src/types/index.ts +19 -0
  130. package/src/utils/cjaRouter.ts +74 -0
  131. package/src/utils/cjaStore.ts +43 -0
  132. package/src/utils/findScrollAncestor.ts +16 -0
  133. package/src/utils/formValidations.ts +192 -0
  134. package/src/utils/generateRoutes.ts +36 -0
  135. package/src/utils/getFromUrl.ts +25 -0
  136. package/src/utils/getMessages.ts +23 -0
  137. package/src/utils/gtm.ts +158 -0
  138. package/src/utils/index.ts +31 -0
  139. package/src/utils/jsonReviver.ts +20 -0
  140. package/src/utils/storyblokLink.ts +4 -0
  141. package/src/utils/updateForm.ts +40 -0
  142. package/src/utils/uploadFile.ts +25 -0
  143. package/src/utils/useGlobalProperties.ts +11 -0
  144. package/src/utils/useViewportDetector.ts +35 -0
  145. package/dist/cja-phoenix.cjs.js +0 -44
  146. package/dist/cja-phoenix.d.ts +0 -3
  147. package/dist/cja-phoenix.umd.js +0 -45
  148. package/dist/components/composite/CheckoutCrossSell.vue.d.ts +0 -36
  149. package/dist/components/composite/CheckoutLayout.vue.d.ts +0 -20
  150. package/dist/components/composite/CheckoutMilestones.vue.d.ts +0 -13
  151. package/dist/components/composite/CjaFooter.vue.d.ts +0 -29
  152. package/dist/components/composite/CjaMenuBar.vue.d.ts +0 -53
  153. package/dist/components/composite/FunnelLayout.vue.d.ts +0 -38
  154. package/dist/components/composite/FunnelSubmit.vue.d.ts +0 -25
  155. package/dist/components/composite/FunnelSummary.vue.d.ts +0 -76
  156. package/dist/components/composite/FunnelTitle.vue.d.ts +0 -24
  157. package/dist/components/composite/InfoShowcase.vue.d.ts +0 -28
  158. package/dist/components/composite/JourneyMacroSteps.vue.d.ts +0 -13
  159. package/dist/components/forms/CheckboxInput.vue.d.ts +0 -38
  160. package/dist/components/forms/CurrencyInput.vue.d.ts +0 -92
  161. package/dist/components/forms/FileInput.vue.d.ts +0 -118
  162. package/dist/components/forms/NumberInput.vue.d.ts +0 -73
  163. package/dist/components/forms/PhoneInput.vue.d.ts +0 -104
  164. package/dist/components/forms/RadioInputList.vue.d.ts +0 -96
  165. package/dist/components/forms/SelectInput.vue.d.ts +0 -121
  166. package/dist/components/forms/SelectionTiles.vue.d.ts +0 -64
  167. package/dist/components/forms/TextInput.vue.d.ts +0 -127
  168. package/dist/components/forms/TileCheckboxInput.vue.d.ts +0 -34
  169. package/dist/components/forms/ToggleInput.vue.d.ts +0 -70
  170. package/dist/components/forms/structure/InputContainer.vue.d.ts +0 -17
  171. package/dist/components/forms/structure/InputError.vue.d.ts +0 -12
  172. package/dist/components/forms/structure/InputTitle.vue.d.ts +0 -30
  173. package/dist/components/structural/CjaButton.vue.d.ts +0 -66
  174. package/dist/components/structural/CollapseContainer.vue.d.ts +0 -40
  175. package/dist/components/structural/FixedContainer.vue.d.ts +0 -69
  176. package/dist/components/structural/GridContainer.vue.d.ts +0 -21
  177. package/dist/components/structural/GridItem.vue.d.ts +0 -29
  178. package/dist/components/structural/InfoMessage.vue.d.ts +0 -39
  179. package/dist/components/structural/LoadingSpinner.vue.d.ts +0 -16
  180. package/dist/components/structural/Modal.vue.d.ts +0 -50
  181. package/dist/components/structural/Scaffold.vue.d.ts +0 -3
  182. package/dist/components/structural/Scaffold.vue.d.ts.map +0 -1
  183. package/dist/index.d.ts +0 -14
  184. package/dist/src/components/composite/CheckoutCrossSell.vue.d.ts +0 -5
  185. package/dist/src/components/composite/CheckoutCrossSell.vue.d.ts.map +0 -1
  186. package/dist/src/components/composite/CheckoutLayout.vue.d.ts +0 -5
  187. package/dist/src/components/composite/CheckoutLayout.vue.d.ts.map +0 -1
  188. package/dist/src/components/composite/CheckoutMilestones.vue.d.ts +0 -5
  189. package/dist/src/components/composite/CheckoutMilestones.vue.d.ts.map +0 -1
  190. package/dist/src/components/composite/CjaFooter.vue.d.ts +0 -5
  191. package/dist/src/components/composite/CjaFooter.vue.d.ts.map +0 -1
  192. package/dist/src/components/composite/CjaMenuBar.vue.d.ts +0 -5
  193. package/dist/src/components/composite/CjaMenuBar.vue.d.ts.map +0 -1
  194. package/dist/src/components/composite/FunnelLayout.vue.d.ts +0 -5
  195. package/dist/src/components/composite/FunnelLayout.vue.d.ts.map +0 -1
  196. package/dist/src/components/composite/FunnelSubmit.vue.d.ts +0 -5
  197. package/dist/src/components/composite/FunnelSubmit.vue.d.ts.map +0 -1
  198. package/dist/src/components/composite/FunnelSummary.vue.d.ts +0 -5
  199. package/dist/src/components/composite/FunnelSummary.vue.d.ts.map +0 -1
  200. package/dist/src/components/composite/FunnelTitle.vue.d.ts +0 -5
  201. package/dist/src/components/composite/FunnelTitle.vue.d.ts.map +0 -1
  202. package/dist/src/components/composite/InfoShowcase.vue.d.ts +0 -5
  203. package/dist/src/components/composite/InfoShowcase.vue.d.ts.map +0 -1
  204. package/dist/src/components/composite/JourneyMacroSteps.vue.d.ts +0 -5
  205. package/dist/src/components/composite/JourneyMacroSteps.vue.d.ts.map +0 -1
  206. package/dist/src/components/composite/ProductDetails.vue.d.ts +0 -5
  207. package/dist/src/components/composite/ProductDetails.vue.d.ts.map +0 -1
  208. package/dist/src/components/composite/ResultsLayout.vue.d.ts +0 -5
  209. package/dist/src/components/composite/ResultsLayout.vue.d.ts.map +0 -1
  210. package/dist/src/components/forms/CheckboxInput.vue.d.ts +0 -5
  211. package/dist/src/components/forms/CheckboxInput.vue.d.ts.map +0 -1
  212. package/dist/src/components/forms/CurrencyInput.vue.d.ts +0 -5
  213. package/dist/src/components/forms/CurrencyInput.vue.d.ts.map +0 -1
  214. package/dist/src/components/forms/FileInput.vue.d.ts +0 -5
  215. package/dist/src/components/forms/FileInput.vue.d.ts.map +0 -1
  216. package/dist/src/components/forms/NumberInput.vue.d.ts +0 -5
  217. package/dist/src/components/forms/NumberInput.vue.d.ts.map +0 -1
  218. package/dist/src/components/forms/PhoneInput.vue.d.ts +0 -5
  219. package/dist/src/components/forms/PhoneInput.vue.d.ts.map +0 -1
  220. package/dist/src/components/forms/RadioInputList.vue.d.ts +0 -5
  221. package/dist/src/components/forms/RadioInputList.vue.d.ts.map +0 -1
  222. package/dist/src/components/forms/SelectInput.vue.d.ts +0 -5
  223. package/dist/src/components/forms/SelectInput.vue.d.ts.map +0 -1
  224. package/dist/src/components/forms/SelectionTiles.vue.d.ts +0 -5
  225. package/dist/src/components/forms/SelectionTiles.vue.d.ts.map +0 -1
  226. package/dist/src/components/forms/TextInput.vue.d.ts +0 -5
  227. package/dist/src/components/forms/TextInput.vue.d.ts.map +0 -1
  228. package/dist/src/components/forms/TileCheckboxInput.vue.d.ts +0 -5
  229. package/dist/src/components/forms/TileCheckboxInput.vue.d.ts.map +0 -1
  230. package/dist/src/components/forms/ToggleInput.vue.d.ts +0 -5
  231. package/dist/src/components/forms/ToggleInput.vue.d.ts.map +0 -1
  232. package/dist/src/components/forms/structure/InputContainer.vue.d.ts +0 -5
  233. package/dist/src/components/forms/structure/InputContainer.vue.d.ts.map +0 -1
  234. package/dist/src/components/forms/structure/InputError.vue.d.ts +0 -5
  235. package/dist/src/components/forms/structure/InputError.vue.d.ts.map +0 -1
  236. package/dist/src/components/forms/structure/InputTitle.vue.d.ts +0 -5
  237. package/dist/src/components/forms/structure/InputTitle.vue.d.ts.map +0 -1
  238. package/dist/src/components/structural/CjaButton.vue.d.ts +0 -5
  239. package/dist/src/components/structural/CjaButton.vue.d.ts.map +0 -1
  240. package/dist/src/components/structural/CollapseContainer.vue.d.ts +0 -5
  241. package/dist/src/components/structural/CollapseContainer.vue.d.ts.map +0 -1
  242. package/dist/src/components/structural/ContentTabs.vue.d.ts +0 -5
  243. package/dist/src/components/structural/ContentTabs.vue.d.ts.map +0 -1
  244. package/dist/src/components/structural/FixedContainer.vue.d.ts +0 -5
  245. package/dist/src/components/structural/FixedContainer.vue.d.ts.map +0 -1
  246. package/dist/src/components/structural/GridContainer.vue.d.ts +0 -5
  247. package/dist/src/components/structural/GridContainer.vue.d.ts.map +0 -1
  248. package/dist/src/components/structural/GridItem.vue.d.ts +0 -5
  249. package/dist/src/components/structural/GridItem.vue.d.ts.map +0 -1
  250. package/dist/src/components/structural/InfoMessage.vue.d.ts +0 -5
  251. package/dist/src/components/structural/InfoMessage.vue.d.ts.map +0 -1
  252. package/dist/src/components/structural/LoadingSpinner.vue.d.ts +0 -5
  253. package/dist/src/components/structural/LoadingSpinner.vue.d.ts.map +0 -1
  254. package/dist/src/components/structural/Modal.vue.d.ts +0 -5
  255. package/dist/src/components/structural/Modal.vue.d.ts.map +0 -1
  256. package/dist/styles.css +0 -1
  257. /package/dist/{components → types/components}/composite/ProductDetails.vue.d.ts +0 -0
  258. /package/dist/{components → types/components}/composite/ResultsLayout.vue.d.ts +0 -0
  259. /package/dist/{components → types/components}/index.d.ts +0 -0
  260. /package/dist/{constants → types/constants}/MyConstants.d.ts +0 -0
  261. /package/dist/{constants → types/constants}/index.d.ts +0 -0
  262. /package/dist/types/{CheckoutMilestone.d.ts → types/CheckoutMilestone.d.ts} +0 -0
  263. /package/dist/types/{Footer.d.ts → types/Footer.d.ts} +0 -0
  264. /package/dist/types/{Menu.d.ts → types/Menu.d.ts} +0 -0
  265. /package/dist/types/{RadioOption.d.ts → types/RadioOption.d.ts} +0 -0
  266. /package/dist/types/{SelectOption.d.ts → types/SelectOption.d.ts} +0 -0
  267. /package/dist/types/{StoreDataValue.d.ts → types/StoreDataValue.d.ts} +0 -0
  268. /package/dist/types/{Storyblok.d.ts → types/Storyblok.d.ts} +0 -0
  269. /package/dist/types/{TileOption.d.ts → types/TileOption.d.ts} +0 -0
  270. /package/dist/{utils → types/utils}/cjaRouter.d.ts +0 -0
  271. /package/dist/{utils → types/utils}/cjaStore.d.ts +0 -0
  272. /package/dist/{utils → types/utils}/findScrollAncestor.d.ts +0 -0
  273. /package/dist/{utils → types/utils}/generateRoutes.d.ts +0 -0
  274. /package/dist/{utils → types/utils}/getFromUrl.d.ts +0 -0
  275. /package/dist/{utils → types/utils}/getMessages.d.ts +0 -0
  276. /package/dist/{utils → types/utils}/gtm.d.ts +0 -0
  277. /package/dist/{utils → types/utils}/index.d.ts +0 -0
  278. /package/dist/{utils → types/utils}/jsonReviver.d.ts +0 -0
  279. /package/dist/{utils → types/utils}/storyblokLink.d.ts +0 -0
  280. /package/dist/{utils → types/utils}/updateForm.d.ts +0 -0
  281. /package/dist/{utils → types/utils}/uploadFile.d.ts +0 -0
  282. /package/dist/{utils → types/utils}/useGlobalProperties.d.ts +0 -0
  283. /package/dist/{utils → types/utils}/useViewportDetector.d.ts +0 -0
@@ -0,0 +1,16 @@
1
+ export const findScrollAncestor = (element) => {
2
+ if (!element) {
3
+ return undefined;
4
+ }
5
+
6
+ let parent = element.parentElement;
7
+ while (parent) {
8
+ const { overflowY } = window.getComputedStyle(parent);
9
+ if (overflowY === "auto" || overflowY === "scroll") {
10
+ return parent;
11
+ }
12
+ parent = parent.parentElement;
13
+ }
14
+
15
+ return document.documentElement;
16
+ };
@@ -0,0 +1,192 @@
1
+ import * as yup from "yup";
2
+
3
+ export const stringRequired = (
4
+ messages: { required: string; minLength?: string; maxLength?: string },
5
+ options?: { minLength?: number; maxLength?: number }
6
+ ) => {
7
+ let validation = yup
8
+ .string()
9
+ .typeError(messages.required)
10
+ .required(messages.required);
11
+
12
+ if (options?.minLength && messages.minLength) {
13
+ validation = validation.min(options.minLength, messages.minLength);
14
+ }
15
+
16
+ if (options?.maxLength && messages.maxLength) {
17
+ validation = validation.min(options.maxLength, messages.maxLength);
18
+ }
19
+
20
+ return validation;
21
+ };
22
+
23
+ export const booleanRequired = (
24
+ messages: { required: string; strictValue?: string },
25
+ options?: { strictValue?: boolean }
26
+ ) => {
27
+ let validation = yup
28
+ .boolean()
29
+ .typeError(messages.required)
30
+ .required(messages.required);
31
+
32
+ if (options?.strictValue && messages.strictValue) {
33
+ validation = validation.oneOf([options.strictValue], messages.strictValue);
34
+ }
35
+
36
+ return validation;
37
+ };
38
+
39
+ export const emailRequired = (messages: { required: string; email: string }) =>
40
+ yup
41
+ .string()
42
+ .typeError(messages.required)
43
+ .required(messages.required)
44
+ .email(messages.email);
45
+
46
+ export const numberRequired = (
47
+ messages: { required: string; min?: string; max?: string },
48
+ options?: {
49
+ min?: number;
50
+ max?: number;
51
+ }
52
+ ) => {
53
+ let validation = yup
54
+ .number()
55
+ .typeError(messages.required)
56
+ .required(messages.required);
57
+
58
+ if (options?.min && messages.min) {
59
+ validation = validation.min(options.min, messages.min);
60
+ }
61
+
62
+ if (options?.max && messages.max) {
63
+ validation = validation.max(options.max, messages.max);
64
+ }
65
+
66
+ return validation;
67
+ };
68
+
69
+ export const phoneRequired = (messages: { required: string; phone: string }) =>
70
+ yup
71
+ .string()
72
+ .typeError(messages.required)
73
+ .required(messages.required)
74
+ .min(9, messages.phone);
75
+
76
+ export const postalCodeRequired = (messages: {
77
+ required: string;
78
+ postalCode: string;
79
+ }) =>
80
+ yup
81
+ .string()
82
+ .typeError(messages.required)
83
+ .required(messages.required)
84
+ .min(8, messages.postalCode);
85
+
86
+ export const fileDocumentRequired = (
87
+ messages: {
88
+ required: string;
89
+ extension: string;
90
+ },
91
+ options?: {
92
+ validExtensions?: RegExp;
93
+ }
94
+ ) =>
95
+ yup.object({
96
+ name: yup.string(),
97
+ extension: yup
98
+ .string()
99
+ .matches(
100
+ options?.validExtensions || /(png|jpg|pdf)/g,
101
+ messages.extension
102
+ ),
103
+ file: yup.lazy(() => yup.mixed().required(messages.required)),
104
+ });
105
+
106
+ export const dateRequired = (
107
+ messages: {
108
+ required: string;
109
+ invalid: string;
110
+ minDate?: string;
111
+ maxDate?: string;
112
+ },
113
+ options?: {
114
+ format?: "mm/yyyy" | "dd/mm/yyyy";
115
+ maxDate?: Date;
116
+ minDate?: Date;
117
+ }
118
+ ) => {
119
+ const totalSplitLength = options?.format == "mm/yyyy" ? 2 : 3;
120
+ const yearPosition = options?.format == "mm/yyyy" ? 1 : 2;
121
+
122
+ let validation = yup
123
+ .date()
124
+ .transform((v, ogV) =>
125
+ !(ogV instanceof Date) &&
126
+ ogV.split("/").length == 3 &&
127
+ ogV.split("/")[2].length == 4
128
+ ? new Date(ogV.split("/").reverse().join("-"))
129
+ : v
130
+ )
131
+ .typeError(messages.invalid)
132
+ .required(messages.required)
133
+ .test(
134
+ "dateTest",
135
+ messages.invalid,
136
+ (v, context) =>
137
+ context.originalValue.split("/").length == totalSplitLength &&
138
+ context.originalValue.split("/")[yearPosition].length == 4
139
+ );
140
+
141
+ if (options?.minDate && messages.minDate) {
142
+ validation = validation.min(options.minDate, messages.minDate);
143
+ }
144
+
145
+ if (options?.maxDate && messages.maxDate) {
146
+ validation = validation.max(options.maxDate, messages.maxDate);
147
+ }
148
+
149
+ return validation;
150
+ };
151
+
152
+ export const nifRequired = (messages: { required: string; invalid: string }) =>
153
+ yup
154
+ .string()
155
+ .typeError(messages.required)
156
+ .required(messages.required)
157
+ .min(9, messages.invalid)
158
+ .test("nifTest", messages.invalid, (v) => {
159
+ if (!v) return false;
160
+ var nif = v!.toString().split("");
161
+ var mod =
162
+ (Number(nif[7]) * 2 +
163
+ Number(nif[6]) * 3 +
164
+ Number(nif[5]) * 4 +
165
+ Number(nif[4]) * 5 +
166
+ Number(nif[3]) * 6 +
167
+ Number(nif[2]) * 7 +
168
+ Number(nif[1]) * 8 +
169
+ Number(nif[0]) * 9) %
170
+ 11;
171
+ return Number(nif[8]) == (mod == 0 || mod == 1 ? 0 : 11 - mod);
172
+ });
173
+
174
+ export const arrayRequired = (
175
+ messages: { required: string; minLength?: string; maxLength?: string },
176
+ options?: { minLength?: number; maxLength?: number }
177
+ ) => {
178
+ let validation = yup
179
+ .array()
180
+ .typeError(messages.required)
181
+ .min(1, messages.required);
182
+
183
+ if (options?.minLength && messages.minLength) {
184
+ validation = validation.min(options.minLength, messages.minLength);
185
+ }
186
+
187
+ if (options?.maxLength && messages.maxLength) {
188
+ validation = validation.min(options.maxLength, messages.maxLength);
189
+ }
190
+
191
+ return validation;
192
+ };
@@ -0,0 +1,36 @@
1
+ import { RouteRecordRaw } from "vue-router";
2
+
3
+ export const generateRoutes = (routes: any[]) => {
4
+ let assembledRoutes: RouteRecordRaw[] = [
5
+ {
6
+ path: "/",
7
+ redirect: "/step1",
8
+ name: "Redirect",
9
+ },
10
+ ];
11
+
12
+ let step = 1;
13
+ let stepDisplay = 1;
14
+ const routesNavLength = routes.filter((r) => !r.redirect).length;
15
+
16
+ routes.forEach((route) => {
17
+ if (!route.redirect) {
18
+ assembledRoutes.push({
19
+ ...route,
20
+ path: `/step${stepDisplay}`,
21
+ meta: {
22
+ ...route.meta,
23
+ step: step,
24
+ displayStep: stepDisplay,
25
+ displayTotalSteps: routesNavLength,
26
+ },
27
+ });
28
+
29
+ step++, stepDisplay++;
30
+ } else {
31
+ assembledRoutes.push(route);
32
+ }
33
+ });
34
+
35
+ return assembledRoutes;
36
+ };
@@ -0,0 +1,25 @@
1
+ export const getFromUrl = (searchParam: string, removeFromUrl?: boolean) => {
2
+ const url = new URL(window.location.href);
3
+
4
+ return url.searchParams.has(searchParam)
5
+ ? (() => {
6
+ const param = url.searchParams
7
+ .getAll(searchParam)
8
+ .map((p) => decodeURIComponent(p));
9
+
10
+ if (removeFromUrl) {
11
+ url.searchParams.delete(searchParam);
12
+ history.replaceState(history.state, "", url.toString());
13
+ }
14
+
15
+ switch (param.length) {
16
+ case 0:
17
+ return undefined;
18
+ case 1:
19
+ return param[0];
20
+ default:
21
+ return param;
22
+ }
23
+ })()
24
+ : undefined;
25
+ };
@@ -0,0 +1,23 @@
1
+ import { I18nOptions, createI18n } from "vue-i18n";
2
+ import { useGlobalProperties } from "./useGlobalProperties";
3
+
4
+ export const getI18nMessages = async (queryMessages: string) => {
5
+ const i18n = createI18n({
6
+ locale: "PT",
7
+ fallbackLocale: "PT",
8
+ messages: undefined,
9
+ legacy: false,
10
+ missingWarn: false,
11
+ fallbackWarn: false,
12
+ warnHtmlMessage: false,
13
+ });
14
+ const { apiURL } = useGlobalProperties();
15
+
16
+ await fetch(`${apiURL}/Internationalization?contains=${queryMessages}`)
17
+ .then((response) => response.json())
18
+ .then((data: I18nOptions["messages"]) =>
19
+ i18n.global.setLocaleMessage("PT", data || {})
20
+ );
21
+
22
+ return i18n;
23
+ };
@@ -0,0 +1,158 @@
1
+ import { GtmSupport, useGtm } from "@gtm-support/vue-gtm";
2
+
3
+ export const useCjaGtm = (
4
+ gtm: GtmSupport | undefined,
5
+ gtmOptions: {
6
+ category: string;
7
+ formType: string;
8
+ location: string;
9
+ }
10
+ ) => {
11
+ if (gtm === undefined) {
12
+ console.error("GTM instance is undefined");
13
+ }
14
+
15
+ const trackStepEvent = (options: {
16
+ stepName: string;
17
+ stepNumber: number;
18
+ stepDetails?: any;
19
+ action?: string;
20
+ }) => {
21
+ gtm?.trackEvent({
22
+ event: `${gtmOptions.location} Step`,
23
+ eventDetails: {
24
+ category: gtmOptions.category,
25
+ value: options.stepName,
26
+ noninteraction: false,
27
+ location: gtmOptions.location,
28
+ action: options.action,
29
+ properties: {
30
+ stepName: options.stepName,
31
+ stepNumber: options.stepNumber,
32
+ stepDetails: options.stepDetails,
33
+ formType: gtmOptions.formType,
34
+ },
35
+ },
36
+ });
37
+ };
38
+
39
+ const trackResultsLoad = (options: {
40
+ time: number;
41
+ products: any[];
42
+ listing: string | undefined;
43
+ }) => {
44
+ gtm?.trackEvent({
45
+ event: "Impressions",
46
+ eventDetails: {
47
+ category: gtmOptions.category,
48
+ location: gtmOptions.location,
49
+ action: "Results Impressions",
50
+ loadTime: options.time || 0,
51
+ properties: {
52
+ list: options.listing,
53
+ },
54
+ ecommerce: {
55
+ impressions: options.products.map((p: any, i: number) => ({
56
+ name: p.cardTitle,
57
+ id: p.productId,
58
+ brand: p.provider,
59
+ position: i + 1,
60
+ category: gtmOptions.category,
61
+ list: options.listing,
62
+ price: "5.00",
63
+ quantity: 1,
64
+ })),
65
+ },
66
+ },
67
+ });
68
+ };
69
+
70
+ const trackPurchase = (options: {
71
+ source: string;
72
+ product: any;
73
+ listing: string | undefined;
74
+ }) => {
75
+ gtm?.trackEvent({
76
+ event: "purchase",
77
+ eventDetails: {
78
+ label: options.product.cardTitle,
79
+ source: `Conversion - ${options.source}`,
80
+ category: gtmOptions.category,
81
+ location: gtmOptions.location,
82
+ action: "Results Purchase",
83
+ properties: {
84
+ list: options.listing,
85
+ },
86
+ ecommerce: {
87
+ purchase: {
88
+ actionField: {
89
+ id: Math.floor(
90
+ Math.random() * (999999999999 - Math.pow(10, 11)) +
91
+ Math.pow(10, 11)
92
+ ),
93
+ revenue: "5.00",
94
+ action: "purchase",
95
+ },
96
+ products: [
97
+ {
98
+ name: options.product.cardTitle,
99
+ id: options.product.productId,
100
+ brand: options.product.provider,
101
+ position: options.product.index + 1,
102
+ dimension3: options.source,
103
+ category: "energy",
104
+ list: options.listing,
105
+ price: "5.00",
106
+ quantity: 1,
107
+ },
108
+ ],
109
+ },
110
+ },
111
+ },
112
+ });
113
+ };
114
+
115
+ const trackDetail = (options: {
116
+ product: any;
117
+ listing: string | undefined;
118
+ }) => {
119
+ gtm?.trackEvent({
120
+ event: "productDetail",
121
+ eventDetails: {
122
+ category: gtmOptions.category,
123
+ location: gtmOptions.location,
124
+ action: "Results Detail",
125
+ properties: {
126
+ list: options.listing,
127
+ },
128
+ ecommerce: {
129
+ detail: {
130
+ actionField: {
131
+ list: options.listing,
132
+ action: "detail",
133
+ },
134
+ products: [
135
+ {
136
+ name: options.product.cardTitle,
137
+ id: options.product.productId,
138
+ brand: options.product.provider,
139
+ position: options.product.index + 1,
140
+ category: gtmOptions.category,
141
+ list: options.listing,
142
+ price: "5.00",
143
+ quantity: 1,
144
+ },
145
+ ],
146
+ },
147
+ },
148
+ },
149
+ });
150
+ };
151
+
152
+ return {
153
+ trackStepEvent,
154
+ trackResultsLoad,
155
+ trackPurchase,
156
+ trackDetail,
157
+ };
158
+ };
@@ -0,0 +1,31 @@
1
+ import * as formValidation from "./formValidations";
2
+ import { generateRoutes } from "./generateRoutes";
3
+ import { useViewportDetector } from "./useViewportDetector";
4
+ import { useGlobalProperties } from "./useGlobalProperties";
5
+ import { jsonReviver } from "./jsonReviver";
6
+ import { getI18nMessages } from "./getMessages";
7
+ import { findScrollAncestor } from "./findScrollAncestor";
8
+ import { updateForm } from "./updateForm";
9
+ import { getFromUrl } from "./getFromUrl";
10
+ import { uploadFile } from "./uploadFile";
11
+ import { useCjaGtm } from "./gtm";
12
+ import { getCjaRouter } from "./cjaRouter";
13
+ import { getCjaStore } from "./cjaStore";
14
+ import { getStoryblokUrl } from "./storyblokLink";
15
+
16
+ export {
17
+ formValidation,
18
+ generateRoutes,
19
+ useViewportDetector,
20
+ useGlobalProperties,
21
+ jsonReviver,
22
+ getI18nMessages,
23
+ findScrollAncestor,
24
+ updateForm,
25
+ getFromUrl,
26
+ uploadFile,
27
+ useCjaGtm,
28
+ getCjaRouter,
29
+ getCjaStore,
30
+ getStoryblokUrl,
31
+ };
@@ -0,0 +1,20 @@
1
+ export const jsonReviver = (data: any) =>
2
+ JSON.parse(data, (k, v) => {
3
+ if (v === "true" || v === "false") {
4
+ return v === "true";
5
+ }
6
+
7
+ if (Number(v) || v === "0") {
8
+ return Number(v);
9
+ }
10
+
11
+ if (v === "undefined") {
12
+ return undefined;
13
+ }
14
+
15
+ if (v === "null") {
16
+ return null;
17
+ }
18
+
19
+ return v;
20
+ });
@@ -0,0 +1,4 @@
1
+ import { StoryLink } from "../types/Storyblok";
2
+
3
+ export const getStoryblokUrl = (link: StoryLink) =>
4
+ link.linktype == "story" ? `/${link.story?.url}` : link.url;
@@ -0,0 +1,40 @@
1
+ import { useGlobalProperties } from "./useGlobalProperties";
2
+
3
+ export const updateForm = (options: {
4
+ journeyId: string | undefined;
5
+ step: number;
6
+ payload: any;
7
+ stepName: string;
8
+ isCompleted?: boolean;
9
+ sentToDialer?: boolean;
10
+ eventType?: string;
11
+ formType: string;
12
+ }) => {
13
+ const { apiURL } = useGlobalProperties();
14
+
15
+ return fetch(`${apiURL}/core/apis/data/updateForm`, {
16
+ method: "PUT",
17
+ body: JSON.stringify(
18
+ Object.fromEntries(
19
+ Object.entries({
20
+ eventType: options.eventType || "STEP_CHANGED",
21
+ isActionEvent: true,
22
+ journeyId: options.journeyId,
23
+ stepName: options.stepName,
24
+ isCompleted: options.isCompleted || false,
25
+ sentToDialer: options.sentToDialer || true,
26
+ lastStepNumber: options.step,
27
+ lastStepType: options.formType,
28
+ lastStepUrl:
29
+ window.location.pathname +
30
+ window.location.search +
31
+ window.location.hash,
32
+ data: JSON.stringify({
33
+ ...options.payload,
34
+ formType: options.formType,
35
+ }),
36
+ }).filter(([_, v]) => v != null)
37
+ )
38
+ ),
39
+ });
40
+ };
@@ -0,0 +1,25 @@
1
+ import { useGlobalProperties } from "./useGlobalProperties";
2
+
3
+ export const uploadFile = (options: {
4
+ basePath: string;
5
+ journeyId: string;
6
+ file: any;
7
+ fileName: string;
8
+ extension: string;
9
+ bucketName: string;
10
+ }) => {
11
+ const data = new FormData();
12
+ const { apiURL } = useGlobalProperties();
13
+
14
+ data.append(
15
+ "path",
16
+ `${options.basePath}/${options.journeyId}/${options.fileName}.${options.extension}`
17
+ );
18
+ data.append("file", options.file);
19
+ data.append("bucketName", options.bucketName);
20
+
21
+ return fetch(`${apiURL}/core/apis/data/saveFileToS3`, {
22
+ method: "POST",
23
+ body: data,
24
+ });
25
+ };
@@ -0,0 +1,11 @@
1
+ import { getCurrentInstance } from "vue";
2
+
3
+ export const useGlobalProperties = () => {
4
+ const props = getCurrentInstance()?.appContext.config.globalProperties;
5
+
6
+ return {
7
+ apiURL: props?.apiURL,
8
+ imageURL: props?.imageURL,
9
+ providerImageURL: props?.providerImageURL,
10
+ };
11
+ };
@@ -0,0 +1,35 @@
1
+ import { createSharedComposable } from "@vueuse/core";
2
+ import { onMounted, onUnmounted, ref } from "vue";
3
+
4
+ const viewportDetector = (
5
+ breakpoints: Record<string, number> = {
6
+ xs: 0,
7
+ sm: 420,
8
+ md: 768,
9
+ lg: 1024,
10
+ xl: 1200,
11
+ }
12
+ ) => {
13
+ const activeViewport = ref<Record<string, boolean>>({});
14
+
15
+ const setViewports = () => {
16
+ for (const key in breakpoints) {
17
+ activeViewport.value[key] = window
18
+ ? window.matchMedia(`(min-width: ${breakpoints[key]}px)`).matches
19
+ : false;
20
+ }
21
+ };
22
+
23
+ onMounted(() => {
24
+ window.addEventListener("resize", setViewports);
25
+ setViewports();
26
+ });
27
+
28
+ onUnmounted(() => {
29
+ window.removeEventListener("resize", setViewports);
30
+ });
31
+
32
+ return { activeViewport };
33
+ };
34
+
35
+ export const useViewportDetector = createSharedComposable(viewportDetector);