cja-phoenix 0.2.6 → 0.2.8

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 (32) hide show
  1. package/dist/cja-phoenix.es.js +5772 -3030
  2. package/dist/style.css +1 -1
  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/ResultsSidebar.vue.d.ts +36 -0
  7. package/dist/types/components/forms/InputToggle.vue.d.ts +1 -1
  8. package/dist/types/components/forms/NumberInput.vue.d.ts +1 -1
  9. package/dist/types/components/forms/SelectInput.vue.d.ts +1 -1
  10. package/dist/types/components/index.d.ts +4 -1
  11. package/dist/types/components/structural/FixedContainer.vue.d.ts +5 -0
  12. package/dist/types/types/CheckoutMilestone.d.ts +5 -0
  13. package/dist/types/types/index.d.ts +2 -1
  14. package/dist/types/utils/JsonReviver.d.ts +1 -0
  15. package/dist/types/utils/index.d.ts +2 -1
  16. package/package.json +4 -1
  17. package/src/assets/grid.scss +2 -1
  18. package/src/components/composite/CheckoutCrossSell.vue +460 -0
  19. package/src/components/composite/CheckoutLayout.vue +57 -0
  20. package/src/components/composite/CheckoutMilestones.vue +132 -0
  21. package/src/components/composite/ResultsLayout.vue +27 -14
  22. package/src/components/composite/ResultsSidebar.vue +100 -0
  23. package/src/components/forms/FileInput.vue +1 -1
  24. package/src/components/index.ts +7 -1
  25. package/src/components/structural/CollapseContainer.vue +21 -31
  26. package/src/components/structural/FixedContainer.vue +22 -4
  27. package/src/components/structural/GridContainer.vue +5 -0
  28. package/src/index.ts +0 -1
  29. package/src/types/CheckoutMilestone.ts +5 -0
  30. package/src/types/index.ts +2 -1
  31. package/src/utils/JsonReviver.ts +20 -0
  32. package/src/utils/index.ts +2 -1
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <FixedContainer
3
+ ref="fixedContainer"
4
+ :scrollThreshold="-16"
5
+ :position="{ top: '16px', bottom: '16px' }"
6
+ >
7
+ <div
8
+ ref="sidebarContainer"
9
+ class="sidebar-container"
10
+ :class="{ 'position-fixed': fixedContainer?.positionFixed }"
11
+ :style="{
12
+ maxHeight: !fixedContainer?.positionFixed ? sidebarMaxHeight : '',
13
+ }"
14
+ >
15
+ <div class="sidebar-title">
16
+ <span class="m-cgg-icon--filtros"></span>
17
+ <span>{{ title }}</span>
18
+ </div>
19
+ <div class="sidebar-body">
20
+ <div class="sidebar-body-wrapper">
21
+ <slot></slot>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </FixedContainer>
26
+ </template>
27
+
28
+ <script lang="ts" setup>
29
+ import { ref } from "vue";
30
+ import { onMounted } from "vue";
31
+ import { onUnmounted } from "vue";
32
+ import FixedContainer from "../structural/FixedContainer.vue";
33
+
34
+ const fixedContainer = ref();
35
+ const sidebarContainer = ref();
36
+ const sidebarMaxHeight = ref();
37
+
38
+ withDefaults(
39
+ defineProps<{
40
+ title?: string;
41
+ }>(),
42
+ {
43
+ title: "Filtros",
44
+ }
45
+ );
46
+
47
+ const setSidebarHeight = () => {
48
+ sidebarMaxHeight.value = `${
49
+ window.innerHeight - sidebarContainer.value.offsetTop - 24 + window.scrollY
50
+ }px`;
51
+ };
52
+
53
+ onMounted(() => {
54
+ setSidebarHeight();
55
+ window.addEventListener("scroll", setSidebarHeight);
56
+ });
57
+
58
+ onUnmounted(() => {
59
+ window.removeEventListener("scroll", setSidebarHeight);
60
+ });
61
+ </script>
62
+
63
+ <style lang="scss" scoped>
64
+ .sidebar-container {
65
+ display: flex;
66
+ flex-direction: column;
67
+ gap: 16px;
68
+ padding: 24px 16px;
69
+ background: #ffffff;
70
+ border: 1px solid #dedede;
71
+ box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
72
+ border-radius: 16px;
73
+
74
+ &.position-fixed {
75
+ max-height: 100%;
76
+ }
77
+
78
+ .sidebar-title {
79
+ display: flex;
80
+ align-items: center;
81
+ gap: 16px;
82
+ border-bottom: 1px solid #dedede;
83
+ padding-bottom: 16px;
84
+ font-weight: 700;
85
+ font-size: 18px;
86
+ line-height: 22px;
87
+
88
+ .m-cgg-icon--filtros {
89
+ color: #076b9c;
90
+ font-weight: 700;
91
+ }
92
+ }
93
+
94
+ .sidebar-body {
95
+ overflow-y: auto;
96
+ overflow-x: hidden;
97
+ flex-grow: 1;
98
+ }
99
+ }
100
+ </style>
@@ -50,7 +50,7 @@
50
50
  </template>
51
51
 
52
52
  <script lang="ts" setup>
53
- import { ref, watch } from "vue";
53
+ import { ref } from "vue";
54
54
  import Scaffold from "../structural/Scaffold.vue";
55
55
  import InputContainer from "./structure/InputContainer.vue";
56
56
  import InputError from "./structure/InputError.vue";
@@ -26,6 +26,9 @@ import FunnelSubmit from "./composite/FunnelSubmit.vue";
26
26
  import FunnelSummary from "./composite/FunnelSummary.vue";
27
27
  import FunnelTitle from "./composite/FunnelTitle.vue";
28
28
  import ResultsLayout from "./composite/ResultsLayout.vue";
29
+ import CheckoutCrossSell from "./composite/CheckoutCrossSell.vue";
30
+ import CheckoutLayout from "./composite/CheckoutLayout.vue";
31
+ import CheckoutMilestones from "./composite/CheckoutMilestones.vue";
29
32
  import ProductDetails from "./composite/ProductDetails.vue";
30
33
  import CjaMenuBar from "./composite/CjaMenuBar.vue";
31
34
 
@@ -53,9 +56,12 @@ export {
53
56
  FunnelSubmit,
54
57
  FunnelSummary,
55
58
  FunnelTitle,
59
+ ResultsLayout,
60
+ CheckoutCrossSell,
61
+ CheckoutLayout,
62
+ CheckoutMilestones,
56
63
  JourneyMacroSteps,
57
64
  CjaMenuBar,
58
65
  FixedContainer,
59
- ResultsLayout,
60
66
  InfoMessage,
61
67
  };
@@ -6,18 +6,12 @@
6
6
  </div>
7
7
  <span class="m-cgg-icon--chevron-down"></span>
8
8
  </div>
9
- <Transition
10
- name="slide"
11
- @before-enter="setHeightZero"
12
- @enter="setHeightSize"
13
- @after-enter="clearHeight"
14
- @leave="setHeightZero"
15
- >
9
+ <Transition name="slide" @enter="slideEnter" @leave="slideLeave">
16
10
  <div
17
11
  v-show="active"
18
12
  ref="contentContainer"
19
13
  class="content-container"
20
- :style="{ height: containerHeight, overflow: containerOverflow }"
14
+ :style="{ height: containerHeight }"
21
15
  >
22
16
  <div ref="contentWrapper" class="content-wrapper">
23
17
  <slot name="content"></slot>
@@ -41,13 +35,18 @@ const active = ref(props.defaultActive);
41
35
  const contentContainer = ref();
42
36
  const contentWrapper = ref();
43
37
  const containerHeight = ref();
44
- const containerOverflow = ref();
45
38
 
46
- const setHeightSize = () => {
39
+ const slideEnter = () => {
40
+ containerHeight.value = "0";
41
+
47
42
  requestAnimationFrame(() => {
48
43
  if (contentContainer.value && contentWrapper.value) {
49
44
  containerHeight.value = `${contentWrapper.value.clientHeight}px`;
50
45
 
46
+ setTimeout(() => {
47
+ containerHeight.value = "";
48
+ }, 200);
49
+
51
50
  if (active.value && props.scrollToContent) {
52
51
  setTimeout(() => {
53
52
  props.scrollToContent?.element.scrollTo({
@@ -61,31 +60,13 @@ const setHeightSize = () => {
61
60
  });
62
61
  };
63
62
 
64
- const setHeightZero = () => {
63
+ const slideLeave = () => {
65
64
  containerHeight.value = `${contentWrapper.value.clientHeight}px`;
66
65
 
67
66
  requestAnimationFrame(() => {
68
67
  containerHeight.value = "0";
69
- containerOverflow.value = "";
70
68
  });
71
69
  };
72
-
73
- const clearHeight = () => {
74
- containerHeight.value = "";
75
- containerOverflow.value = "visible";
76
- };
77
-
78
- onMounted(() => {
79
- if (props.defaultActive) {
80
- setHeightSize();
81
- }
82
-
83
- window.addEventListener("resize", setHeightSize);
84
- });
85
-
86
- onUnmounted(() => {
87
- window.removeEventListener("resize", setHeightSize);
88
- });
89
70
  </script>
90
71
 
91
72
  <style lang="scss" scoped>
@@ -104,9 +85,12 @@ onUnmounted(() => {
104
85
  }
105
86
 
106
87
  .content-container {
107
- box-sizing: border-box;
108
- overflow: hidden;
109
88
  transition: all 0.2s linear;
89
+
90
+ &.slide-leave-active,
91
+ &.slide-enter-active {
92
+ overflow: hidden;
93
+ }
110
94
  }
111
95
 
112
96
  &.active {
@@ -114,5 +98,11 @@ onUnmounted(() => {
114
98
  transform: rotate(180deg);
115
99
  }
116
100
  }
101
+
102
+ &:not(.active) {
103
+ .content-container {
104
+ overflow: hidden;
105
+ }
106
+ }
117
107
  }
118
108
  </style>
@@ -7,7 +7,7 @@
7
7
  <div
8
8
  class="fixed-wrapper"
9
9
  :class="{ 'position-fixed': positionFixed }"
10
- :style="{ ...size, ...position }"
10
+ :style="{ ...size, ...position, maxWidth: fixedWrapperWidth }"
11
11
  ref="fixedWrapper"
12
12
  >
13
13
  <slot></slot>
@@ -16,11 +16,12 @@
16
16
  </template>
17
17
 
18
18
  <script lang="ts" setup>
19
- import { onUnmounted, onMounted } from "vue";
19
+ import { onUnmounted, onMounted, watch } from "vue";
20
20
  import { ref } from "vue";
21
21
 
22
22
  const props = withDefaults(
23
23
  defineProps<{
24
+ active?: boolean;
24
25
  scrollThreshold?: number;
25
26
  fixWidth?: boolean;
26
27
  size?: {
@@ -35,6 +36,7 @@ const props = withDefaults(
35
36
  };
36
37
  }>(),
37
38
  {
39
+ active: true,
38
40
  scrollThreshold: 0,
39
41
  fixWidth: true,
40
42
  }
@@ -44,22 +46,38 @@ const positionFixed = ref(false);
44
46
  const fixedContainer = ref();
45
47
  const fixedContainerHeight = ref("");
46
48
  const fixedWrapper = ref();
49
+ const fixedWrapperWidth = ref("");
47
50
 
48
51
  const fixPosition = () => {
49
- if (fixedContainer.value) {
52
+ if (fixedContainer.value && props.active) {
50
53
  positionFixed.value =
51
54
  window.scrollY > fixedContainer.value.offsetTop + props.scrollThreshold;
52
55
 
53
56
  fixedContainerHeight.value = positionFixed.value
54
57
  ? `${fixedWrapper.value.clientHeight}px`
55
58
  : "";
59
+ } else {
60
+ positionFixed.value = false;
61
+ fixedContainerHeight.value = "";
56
62
  }
57
63
  };
58
64
 
59
65
  const setWidth = () => {
60
- fixedWrapper.value.style.maxWidth = `${fixedContainer.value.offsetWidth}px`;
66
+ fixedWrapperWidth.value =
67
+ props.active && fixedContainer.value
68
+ ? `${fixedContainer.value.offsetWidth}px`
69
+ : "";
61
70
  };
62
71
 
72
+ watch(
73
+ () => props.active,
74
+ () => {
75
+ if (props.fixWidth) {
76
+ setWidth();
77
+ }
78
+ }
79
+ );
80
+
63
81
  onMounted(() => {
64
82
  window.addEventListener("scroll", fixPosition);
65
83
  fixPosition();
@@ -38,6 +38,11 @@ withDefaults(
38
38
  column-gap: $grid-column-gap-lg;
39
39
  padding-left: $grid-side-padding-lg;
40
40
  padding-right: $grid-side-padding-lg;
41
+ }
42
+
43
+ @media screen and (min-width: 1200px) {
44
+ padding-left: $grid-side-padding-xl;
45
+ padding-right: $grid-side-padding-xl;
41
46
  max-width: 1440px;
42
47
  margin-left: auto;
43
48
  margin-right: auto;
package/src/index.ts CHANGED
@@ -4,7 +4,6 @@ import VueTippy from "vue-tippy";
4
4
 
5
5
  function install(app: App) {
6
6
  for (const key in components) {
7
- // @ts-expect-error
8
7
  app.component(key, components[key]);
9
8
  }
10
9
 
@@ -0,0 +1,5 @@
1
+ export interface CheckoutMilestone {
2
+ status: "past" | "current" | "future";
3
+ title: string;
4
+ description?: string;
5
+ }
@@ -2,5 +2,6 @@ import { MacroStep } from "./MacroStep";
2
2
  import { Tab } from "./Tab";
3
3
  import { SelectOption } from "./SelectOption";
4
4
  import { TileOption } from "./TileOption";
5
+ import { CheckoutMilestone } from "./CheckoutMilestone";
5
6
 
6
- export type { MacroStep, Tab, SelectOption, TileOption };
7
+ export type { MacroStep, Tab, SelectOption, TileOption, CheckoutMilestone };
@@ -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
+ });
@@ -1,4 +1,5 @@
1
1
  import { generateRoutes } from "./RouteGenerator";
2
2
  import { useViewportDetector } from "./ViewportDetector";
3
+ import { JsonReviver } from "./JsonReviver";
3
4
 
4
- export { generateRoutes, useViewportDetector };
5
+ export { generateRoutes, useViewportDetector, JsonReviver };