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.
- package/dist/cja-phoenix.es.js +3816 -4306
- package/dist/style.css +1 -0
- package/dist/types/components/composite/CheckoutCrossSell.vue.d.ts +29 -0
- package/dist/types/components/composite/CheckoutLayout.vue.d.ts +23 -0
- package/dist/types/components/composite/CheckoutMilestones.vue.d.ts +16 -0
- package/dist/types/components/composite/CjaFooter.vue.d.ts +34 -0
- package/dist/types/components/composite/CjaMenuBar.vue.d.ts +52 -0
- package/dist/types/components/composite/FunnelLayout.vue.d.ts +35 -0
- package/dist/types/components/composite/FunnelSubmit.vue.d.ts +26 -0
- package/dist/types/components/composite/FunnelSummary.vue.d.ts +77 -0
- package/dist/types/components/composite/FunnelTitle.vue.d.ts +19 -0
- package/dist/types/components/composite/InfoShowcase.vue.d.ts +25 -0
- package/dist/types/components/composite/JourneyMacroSteps.vue.d.ts +16 -0
- package/dist/types/components/composite/ResultsSidebar.vue.d.ts +9 -0
- package/dist/types/components/forms/CheckboxInput.vue.d.ts +41 -0
- package/dist/types/components/forms/CurrencyInput.vue.d.ts +65 -0
- package/dist/types/components/forms/FileInput.vue.d.ts +89 -0
- package/dist/types/components/forms/NumberInput.vue.d.ts +58 -0
- package/dist/types/components/forms/PhoneInput.vue.d.ts +69 -0
- package/dist/types/components/forms/RadioInput.vue.d.ts +43 -0
- package/dist/types/components/forms/RadioInputList.vue.d.ts +65 -0
- package/dist/types/components/forms/SelectInput.vue.d.ts +80 -0
- package/dist/types/components/forms/SelectionTiles.vue.d.ts +51 -0
- package/dist/types/components/forms/TextInput.vue.d.ts +76 -0
- package/dist/types/components/forms/TileCheckboxInput.vue.d.ts +23 -0
- package/dist/types/components/forms/ToggleInput.vue.d.ts +51 -0
- package/dist/types/components/forms/structure/InputContainer.vue.d.ts +22 -0
- package/dist/types/components/forms/structure/InputError.vue.d.ts +15 -0
- package/dist/types/components/forms/structure/InputTitle.vue.d.ts +21 -0
- package/dist/types/components/structural/CjaButton.vue.d.ts +59 -0
- package/dist/types/components/structural/CollapseContainer.vue.d.ts +51 -0
- package/dist/{components → types/components}/structural/ContentTabs.vue.d.ts +17 -20
- package/dist/types/components/structural/FixedContainer.vue.d.ts +68 -0
- package/dist/types/components/structural/GridContainer.vue.d.ts +36 -0
- package/dist/types/components/structural/GridItem.vue.d.ts +26 -0
- package/dist/types/components/structural/InfoMessage.vue.d.ts +30 -0
- package/dist/types/components/structural/LoadingSpinner.vue.d.ts +17 -0
- package/dist/types/components/structural/Modal.vue.d.ts +65 -0
- package/dist/types/components/structural/Scaffold.vue.d.ts +9 -0
- package/dist/types/index.d.ts +16 -7
- package/dist/types/stories/CjaButton.story.vue.d.ts +2 -0
- package/dist/types/stories/ContentTabs.story.vue.d.ts +2 -0
- package/dist/types/stories/Modal.story.vue.d.ts +2 -0
- package/dist/types/stories/RadioInputList.story.vue.d.ts +2 -0
- package/dist/types/{Router.d.ts → types/Router.d.ts} +1 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/{utils → types/utils}/formValidations.d.ts +3 -0
- package/package.json +21 -30
- package/src/assets/backdrop.scss +10 -0
- package/src/assets/breakpoints.scss +12 -0
- package/src/assets/fonts.scss +1 -0
- package/src/assets/forms.scss +97 -0
- package/src/assets/grid.scss +14 -0
- package/src/assets/iconia/Read Me.txt +7 -0
- package/src/assets/iconia/demo-files/demo.css +155 -0
- package/src/assets/iconia/demo-files/demo.js +30 -0
- package/src/assets/iconia/demo.html +7055 -0
- package/src/assets/iconia/fonts/CGG-icomoon.eot +0 -0
- package/src/assets/iconia/fonts/CGG-icomoon.svg +513 -0
- package/src/assets/iconia/fonts/CGG-icomoon.ttf +0 -0
- package/src/assets/iconia/fonts/CGG-icomoon.woff +0 -0
- package/src/assets/iconia/selection.json +1 -0
- package/src/assets/iconia/style.css +1547 -0
- package/src/assets/iconia/style.scss +2556 -0
- package/src/assets/iconia/variables.scss +507 -0
- package/src/assets/main.scss +30 -0
- package/src/assets/radioOld.scss +52 -0
- package/src/assets/shadows.scss +3 -0
- package/src/assets/tippy.scss +45 -0
- package/src/assets/vars/development.scss +4 -0
- package/src/assets/vars/production.scss +4 -0
- package/src/components/composite/CheckoutCrossSell.vue +478 -0
- package/src/components/composite/CheckoutLayout.vue +59 -0
- package/src/components/composite/CheckoutMilestones.vue +161 -0
- package/src/components/composite/CjaFooter.vue +223 -0
- package/src/components/composite/CjaMenuBar.vue +543 -0
- package/src/components/composite/FunnelLayout.vue +197 -0
- package/src/components/composite/FunnelSubmit.vue +53 -0
- package/src/components/composite/FunnelSummary.vue +198 -0
- package/src/components/composite/FunnelTitle.vue +59 -0
- package/src/components/composite/InfoShowcase.vue +87 -0
- package/src/components/composite/JourneyMacroSteps.vue +104 -0
- package/src/components/composite/ProductDetails.vue +149 -0
- package/src/components/composite/ResultsLayout.vue +156 -0
- package/src/components/composite/ResultsSidebar.vue +74 -0
- package/src/components/forms/CheckboxInput.vue +103 -0
- package/src/components/forms/CurrencyInput.vue +126 -0
- package/src/components/forms/FileInput.vue +250 -0
- package/src/components/forms/NumberInput.vue +165 -0
- package/src/components/forms/PhoneInput.vue +122 -0
- package/src/components/forms/RadioInput.vue +98 -0
- package/src/components/forms/RadioInputList.vue +156 -0
- package/src/components/forms/SelectInput.vue +392 -0
- package/src/components/forms/SelectionTiles.vue +196 -0
- package/src/components/forms/TextInput.vue +144 -0
- package/src/components/forms/TileCheckboxInput.vue +96 -0
- package/src/components/forms/ToggleInput.vue +88 -0
- package/src/components/forms/structure/InputContainer.vue +28 -0
- package/src/components/forms/structure/InputError.vue +26 -0
- package/src/components/forms/structure/InputTitle.vue +52 -0
- package/src/components/index.ts +73 -0
- package/src/components/structural/CjaButton.vue +332 -0
- package/src/components/structural/CollapseContainer.vue +141 -0
- package/src/components/structural/ContentTabs.vue +105 -0
- package/src/components/structural/FixedContainer.vue +107 -0
- package/src/components/structural/GridContainer.vue +70 -0
- package/src/components/structural/GridItem.vue +47 -0
- package/src/components/structural/InfoMessage.vue +105 -0
- package/src/components/structural/LoadingSpinner.vue +39 -0
- package/src/components/structural/Modal.vue +209 -0
- package/src/components/structural/Scaffold.vue +3 -0
- package/src/constants/MyConstants.ts +1 -0
- package/src/constants/index.ts +5 -0
- package/src/env.d.ts +11 -0
- package/src/index.ts +31 -0
- package/src/stories/CjaButton.story.vue +192 -0
- package/src/stories/ContentTabs.story.vue +59 -0
- package/src/stories/Modal.story.vue +127 -0
- package/src/stories/RadioInputList.story.vue +61 -0
- package/src/types/CheckoutMilestone.ts +5 -0
- package/src/types/Footer.ts +17 -0
- package/src/types/Menu.ts +19 -0
- package/src/types/RadioOption.ts +7 -0
- package/src/types/Router.ts +19 -0
- package/src/types/SelectOption.ts +6 -0
- package/src/types/StoreDataValue.ts +12 -0
- package/src/types/Storyblok.ts +10 -0
- package/src/types/TileOption.ts +8 -0
- package/src/types/index.ts +19 -0
- package/src/utils/cjaRouter.ts +74 -0
- package/src/utils/cjaStore.ts +43 -0
- package/src/utils/findScrollAncestor.ts +16 -0
- package/src/utils/formValidations.ts +192 -0
- package/src/utils/generateRoutes.ts +36 -0
- package/src/utils/getFromUrl.ts +25 -0
- package/src/utils/getMessages.ts +23 -0
- package/src/utils/gtm.ts +158 -0
- package/src/utils/index.ts +31 -0
- package/src/utils/jsonReviver.ts +20 -0
- package/src/utils/storyblokLink.ts +4 -0
- package/src/utils/updateForm.ts +40 -0
- package/src/utils/uploadFile.ts +25 -0
- package/src/utils/useGlobalProperties.ts +11 -0
- package/src/utils/useViewportDetector.ts +35 -0
- package/dist/cja-phoenix.cjs.js +0 -44
- package/dist/cja-phoenix.d.ts +0 -3
- package/dist/cja-phoenix.umd.js +0 -45
- package/dist/components/composite/CheckoutCrossSell.vue.d.ts +0 -36
- package/dist/components/composite/CheckoutLayout.vue.d.ts +0 -20
- package/dist/components/composite/CheckoutMilestones.vue.d.ts +0 -13
- package/dist/components/composite/CjaFooter.vue.d.ts +0 -29
- package/dist/components/composite/CjaMenuBar.vue.d.ts +0 -53
- package/dist/components/composite/FunnelLayout.vue.d.ts +0 -38
- package/dist/components/composite/FunnelSubmit.vue.d.ts +0 -25
- package/dist/components/composite/FunnelSummary.vue.d.ts +0 -76
- package/dist/components/composite/FunnelTitle.vue.d.ts +0 -24
- package/dist/components/composite/InfoShowcase.vue.d.ts +0 -28
- package/dist/components/composite/JourneyMacroSteps.vue.d.ts +0 -13
- package/dist/components/forms/CheckboxInput.vue.d.ts +0 -38
- package/dist/components/forms/CurrencyInput.vue.d.ts +0 -92
- package/dist/components/forms/FileInput.vue.d.ts +0 -118
- package/dist/components/forms/NumberInput.vue.d.ts +0 -73
- package/dist/components/forms/PhoneInput.vue.d.ts +0 -104
- package/dist/components/forms/RadioInputList.vue.d.ts +0 -96
- package/dist/components/forms/SelectInput.vue.d.ts +0 -121
- package/dist/components/forms/SelectionTiles.vue.d.ts +0 -64
- package/dist/components/forms/TextInput.vue.d.ts +0 -127
- package/dist/components/forms/TileCheckboxInput.vue.d.ts +0 -34
- package/dist/components/forms/ToggleInput.vue.d.ts +0 -70
- package/dist/components/forms/structure/InputContainer.vue.d.ts +0 -17
- package/dist/components/forms/structure/InputError.vue.d.ts +0 -12
- package/dist/components/forms/structure/InputTitle.vue.d.ts +0 -30
- package/dist/components/structural/CjaButton.vue.d.ts +0 -66
- package/dist/components/structural/CollapseContainer.vue.d.ts +0 -40
- package/dist/components/structural/FixedContainer.vue.d.ts +0 -69
- package/dist/components/structural/GridContainer.vue.d.ts +0 -21
- package/dist/components/structural/GridItem.vue.d.ts +0 -29
- package/dist/components/structural/InfoMessage.vue.d.ts +0 -39
- package/dist/components/structural/LoadingSpinner.vue.d.ts +0 -16
- package/dist/components/structural/Modal.vue.d.ts +0 -50
- package/dist/components/structural/Scaffold.vue.d.ts +0 -3
- package/dist/components/structural/Scaffold.vue.d.ts.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/src/components/composite/CheckoutCrossSell.vue.d.ts +0 -5
- package/dist/src/components/composite/CheckoutCrossSell.vue.d.ts.map +0 -1
- package/dist/src/components/composite/CheckoutLayout.vue.d.ts +0 -5
- package/dist/src/components/composite/CheckoutLayout.vue.d.ts.map +0 -1
- package/dist/src/components/composite/CheckoutMilestones.vue.d.ts +0 -5
- package/dist/src/components/composite/CheckoutMilestones.vue.d.ts.map +0 -1
- package/dist/src/components/composite/CjaFooter.vue.d.ts +0 -5
- package/dist/src/components/composite/CjaFooter.vue.d.ts.map +0 -1
- package/dist/src/components/composite/CjaMenuBar.vue.d.ts +0 -5
- package/dist/src/components/composite/CjaMenuBar.vue.d.ts.map +0 -1
- package/dist/src/components/composite/FunnelLayout.vue.d.ts +0 -5
- package/dist/src/components/composite/FunnelLayout.vue.d.ts.map +0 -1
- package/dist/src/components/composite/FunnelSubmit.vue.d.ts +0 -5
- package/dist/src/components/composite/FunnelSubmit.vue.d.ts.map +0 -1
- package/dist/src/components/composite/FunnelSummary.vue.d.ts +0 -5
- package/dist/src/components/composite/FunnelSummary.vue.d.ts.map +0 -1
- package/dist/src/components/composite/FunnelTitle.vue.d.ts +0 -5
- package/dist/src/components/composite/FunnelTitle.vue.d.ts.map +0 -1
- package/dist/src/components/composite/InfoShowcase.vue.d.ts +0 -5
- package/dist/src/components/composite/InfoShowcase.vue.d.ts.map +0 -1
- package/dist/src/components/composite/JourneyMacroSteps.vue.d.ts +0 -5
- package/dist/src/components/composite/JourneyMacroSteps.vue.d.ts.map +0 -1
- package/dist/src/components/composite/ProductDetails.vue.d.ts +0 -5
- package/dist/src/components/composite/ProductDetails.vue.d.ts.map +0 -1
- package/dist/src/components/composite/ResultsLayout.vue.d.ts +0 -5
- package/dist/src/components/composite/ResultsLayout.vue.d.ts.map +0 -1
- package/dist/src/components/forms/CheckboxInput.vue.d.ts +0 -5
- package/dist/src/components/forms/CheckboxInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/CurrencyInput.vue.d.ts +0 -5
- package/dist/src/components/forms/CurrencyInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/FileInput.vue.d.ts +0 -5
- package/dist/src/components/forms/FileInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/NumberInput.vue.d.ts +0 -5
- package/dist/src/components/forms/NumberInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/PhoneInput.vue.d.ts +0 -5
- package/dist/src/components/forms/PhoneInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/RadioInputList.vue.d.ts +0 -5
- package/dist/src/components/forms/RadioInputList.vue.d.ts.map +0 -1
- package/dist/src/components/forms/SelectInput.vue.d.ts +0 -5
- package/dist/src/components/forms/SelectInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/SelectionTiles.vue.d.ts +0 -5
- package/dist/src/components/forms/SelectionTiles.vue.d.ts.map +0 -1
- package/dist/src/components/forms/TextInput.vue.d.ts +0 -5
- package/dist/src/components/forms/TextInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/TileCheckboxInput.vue.d.ts +0 -5
- package/dist/src/components/forms/TileCheckboxInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/ToggleInput.vue.d.ts +0 -5
- package/dist/src/components/forms/ToggleInput.vue.d.ts.map +0 -1
- package/dist/src/components/forms/structure/InputContainer.vue.d.ts +0 -5
- package/dist/src/components/forms/structure/InputContainer.vue.d.ts.map +0 -1
- package/dist/src/components/forms/structure/InputError.vue.d.ts +0 -5
- package/dist/src/components/forms/structure/InputError.vue.d.ts.map +0 -1
- package/dist/src/components/forms/structure/InputTitle.vue.d.ts +0 -5
- package/dist/src/components/forms/structure/InputTitle.vue.d.ts.map +0 -1
- package/dist/src/components/structural/CjaButton.vue.d.ts +0 -5
- package/dist/src/components/structural/CjaButton.vue.d.ts.map +0 -1
- package/dist/src/components/structural/CollapseContainer.vue.d.ts +0 -5
- package/dist/src/components/structural/CollapseContainer.vue.d.ts.map +0 -1
- package/dist/src/components/structural/ContentTabs.vue.d.ts +0 -5
- package/dist/src/components/structural/ContentTabs.vue.d.ts.map +0 -1
- package/dist/src/components/structural/FixedContainer.vue.d.ts +0 -5
- package/dist/src/components/structural/FixedContainer.vue.d.ts.map +0 -1
- package/dist/src/components/structural/GridContainer.vue.d.ts +0 -5
- package/dist/src/components/structural/GridContainer.vue.d.ts.map +0 -1
- package/dist/src/components/structural/GridItem.vue.d.ts +0 -5
- package/dist/src/components/structural/GridItem.vue.d.ts.map +0 -1
- package/dist/src/components/structural/InfoMessage.vue.d.ts +0 -5
- package/dist/src/components/structural/InfoMessage.vue.d.ts.map +0 -1
- package/dist/src/components/structural/LoadingSpinner.vue.d.ts +0 -5
- package/dist/src/components/structural/LoadingSpinner.vue.d.ts.map +0 -1
- package/dist/src/components/structural/Modal.vue.d.ts +0 -5
- package/dist/src/components/structural/Modal.vue.d.ts.map +0 -1
- package/dist/styles.css +0 -1
- /package/dist/{components → types/components}/composite/ProductDetails.vue.d.ts +0 -0
- /package/dist/{components → types/components}/composite/ResultsLayout.vue.d.ts +0 -0
- /package/dist/{components → types/components}/index.d.ts +0 -0
- /package/dist/{constants → types/constants}/MyConstants.d.ts +0 -0
- /package/dist/{constants → types/constants}/index.d.ts +0 -0
- /package/dist/types/{CheckoutMilestone.d.ts → types/CheckoutMilestone.d.ts} +0 -0
- /package/dist/types/{Footer.d.ts → types/Footer.d.ts} +0 -0
- /package/dist/types/{Menu.d.ts → types/Menu.d.ts} +0 -0
- /package/dist/types/{RadioOption.d.ts → types/RadioOption.d.ts} +0 -0
- /package/dist/types/{SelectOption.d.ts → types/SelectOption.d.ts} +0 -0
- /package/dist/types/{StoreDataValue.d.ts → types/StoreDataValue.d.ts} +0 -0
- /package/dist/types/{Storyblok.d.ts → types/Storyblok.d.ts} +0 -0
- /package/dist/types/{TileOption.d.ts → types/TileOption.d.ts} +0 -0
- /package/dist/{utils → types/utils}/cjaRouter.d.ts +0 -0
- /package/dist/{utils → types/utils}/cjaStore.d.ts +0 -0
- /package/dist/{utils → types/utils}/findScrollAncestor.d.ts +0 -0
- /package/dist/{utils → types/utils}/generateRoutes.d.ts +0 -0
- /package/dist/{utils → types/utils}/getFromUrl.d.ts +0 -0
- /package/dist/{utils → types/utils}/getMessages.d.ts +0 -0
- /package/dist/{utils → types/utils}/gtm.d.ts +0 -0
- /package/dist/{utils → types/utils}/index.d.ts +0 -0
- /package/dist/{utils → types/utils}/jsonReviver.d.ts +0 -0
- /package/dist/{utils → types/utils}/storyblokLink.d.ts +0 -0
- /package/dist/{utils → types/utils}/updateForm.d.ts +0 -0
- /package/dist/{utils → types/utils}/uploadFile.d.ts +0 -0
- /package/dist/{utils → types/utils}/useGlobalProperties.d.ts +0 -0
- /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
|
+
};
|
package/src/utils/gtm.ts
ADDED
|
@@ -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,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);
|