@gem-sdk/pages 1.23.0-staging.358 → 1.23.0-staging.384

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.
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useShopStore, cls, makeStyleResponsive } from '@gem-sdk/core';
3
3
 
4
4
  const defaultMargin = {
@@ -7,84 +7,159 @@ const defaultMargin = {
7
7
  mobile: '40px'
8
8
  };
9
9
  const HEADER_OFF_COLOR = '#F4F4F4';
10
- const Header = ()=>{
10
+ const sizeCheck = {
11
+ desktop: '24px',
12
+ tablet: '36px',
13
+ mobile: '36px'
14
+ };
15
+ const Header = (props)=>{
16
+ const { pageType } = props;
11
17
  const layoutSetting = useShopStore((s)=>s.layoutSettings);
12
18
  return /*#__PURE__*/ jsx("div", {
13
19
  className: cls('gp-header-container gp-border-1 gp-group gp-relative gp-flex gp-justify-center gp-border-b gp-border-[#EEEEEE] gp-font-sans'),
14
- children: /*#__PURE__*/ jsxs("div", {
20
+ children: pageType === 'POST_PURCHASE' ? /*#__PURE__*/ jsx("div", {
21
+ className: "gp-flex gp-flex-1 gp-items-center gp-justify-between",
22
+ style: {
23
+ maxWidth: `var(--g-ct-w)`,
24
+ ...makeStyleResponsive('ml', defaultMargin),
25
+ ...makeStyleResponsive('mr', defaultMargin)
26
+ },
27
+ children: /*#__PURE__*/ jsxs("div", {
28
+ className: "tablet:gp-items-center gp-flex gp-py-3",
29
+ children: [
30
+ /*#__PURE__*/ jsxs("svg", {
31
+ style: {
32
+ ...makeStyleResponsive('w', sizeCheck),
33
+ ...makeStyleResponsive('h', sizeCheck)
34
+ },
35
+ viewBox: "0 0 24 24",
36
+ fill: "none",
37
+ xmlns: "http://www.w3.org/2000/svg",
38
+ children: [
39
+ /*#__PURE__*/ jsx("path", {
40
+ d: "M15.7244 10.6242C15.9587 10.3899 15.9587 10.01 15.7244 9.77571C15.49 9.5414 15.1101 9.5414 14.8758 9.77571L11.1001 13.5514L9.42436 11.8757C9.19005 11.6414 8.81015 11.6414 8.57583 11.8757C8.34152 12.11 8.34152 12.4899 8.57583 12.7242L10.6758 14.8242C10.9101 15.0586 11.29 15.0586 11.5244 14.8242L15.7244 10.6242Z",
41
+ fill: "#197BBD"
42
+ }),
43
+ /*#__PURE__*/ jsx("path", {
44
+ fillRule: "evenodd",
45
+ clipRule: "evenodd",
46
+ d: "M20.4001 12C20.4001 16.6392 16.6393 20.4 12.0001 20.4C7.36091 20.4 3.6001 16.6392 3.6001 12C3.6001 7.36078 7.36091 3.59998 12.0001 3.59998C16.6393 3.59998 20.4001 7.36078 20.4001 12ZM19.2001 12C19.2001 15.9764 15.9765 19.2 12.0001 19.2C8.02365 19.2 4.8001 15.9764 4.8001 12C4.8001 8.02352 8.02365 4.79998 12.0001 4.79998C15.9765 4.79998 19.2001 8.02352 19.2001 12Z",
47
+ fill: "#197BBD"
48
+ })
49
+ ]
50
+ }),
51
+ /*#__PURE__*/ jsxs("div", {
52
+ className: "gp-ml-4",
53
+ children: [
54
+ /*#__PURE__*/ jsx("p", {
55
+ className: "gp-text-sm",
56
+ children: "Order #1001"
57
+ }),
58
+ /*#__PURE__*/ jsx("p", {
59
+ children: "You’ve paid for your order."
60
+ }),
61
+ /*#__PURE__*/ jsxs("div", {
62
+ className: "gp-mt-1 gp-flex gp-items-center gp-text-[#197BBD]",
63
+ children: [
64
+ /*#__PURE__*/ jsx("div", {
65
+ className: "gp-text-sm",
66
+ children: "View order confirmation"
67
+ }),
68
+ /*#__PURE__*/ jsx("svg", {
69
+ width: "12",
70
+ height: "13",
71
+ viewBox: "0 0 12 13",
72
+ fill: "none",
73
+ xmlns: "http://www.w3.org/2000/svg",
74
+ children: /*#__PURE__*/ jsx("path", {
75
+ fillRule: "evenodd",
76
+ clipRule: "evenodd",
77
+ d: "M4.6318 9.21817C4.45607 9.04244 4.45607 8.75751 4.6318 8.58178L6.7136 6.49998L4.6318 4.41817C4.45607 4.24244 4.45607 3.95751 4.6318 3.78178C4.80754 3.60604 5.09246 3.60604 5.2682 3.78178L7.6682 6.18178C7.84393 6.35751 7.84393 6.64244 7.6682 6.81817L5.2682 9.21817C5.09246 9.39391 4.80754 9.39391 4.6318 9.21817Z",
78
+ fill: "#197BBD"
79
+ })
80
+ })
81
+ ]
82
+ })
83
+ ]
84
+ })
85
+ ]
86
+ })
87
+ }) : /*#__PURE__*/ jsx("div", {
15
88
  className: "gp-flex gp-h-[40px] gp-flex-1 gp-items-center gp-justify-between",
16
89
  style: {
17
90
  maxWidth: `var(--g-ct-w)`,
18
91
  ...makeStyleResponsive('ml', defaultMargin),
19
92
  ...makeStyleResponsive('mr', defaultMargin)
20
93
  },
21
- children: [
22
- /*#__PURE__*/ jsxs("svg", {
23
- width: "84",
24
- height: "8",
25
- viewBox: "0 0 84 8",
26
- fill: "none",
27
- xmlns: "http://www.w3.org/2000/svg",
28
- children: [
29
- /*#__PURE__*/ jsx("path", {
30
- d: "M0 4C0 1.79086 1.79086 0 4 0H18C20.2091 0 22 1.79086 22 4C22 6.20914 20.2091 8 18 8H4C1.79086 8 0 6.20914 0 4Z",
31
- fill: layoutSetting?.showHeader ? '#9E9E9E' : HEADER_OFF_COLOR
32
- }),
33
- /*#__PURE__*/ jsx("path", {
34
- d: "M28 4C28 1.79086 29.7909 0 32 0H80C82.2091 0 84 1.79086 84 4C84 6.20914 82.2091 8 80 8H32C29.7909 8 28 6.20914 28 4Z",
35
- fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
36
- })
37
- ]
38
- }),
39
- /*#__PURE__*/ jsx("div", {
40
- className: "gp-header gp-invisible gp-absolute gp-left-[8px] gp-flex gp-h-[24px] gp-w-[24px] gp-cursor-pointer gp-items-center gp-justify-center gp-rounded gp-bg-[#EEEEEE] gp-p-[4px] hover:gp-bg-[#0000001a] group-hover:gp-visible",
41
- children: /*#__PURE__*/ jsx("div", {
42
- className: "gp-flex gp-h-[24px] gp-w-[24px] gp-items-center gp-justify-center",
43
- children: /*#__PURE__*/ jsxs("svg", {
44
- width: "14",
45
- height: "14",
46
- viewBox: "0 0 14 14",
47
- fill: "none",
48
- xmlns: "http://www.w3.org/2000/svg",
49
- children: [
50
- /*#__PURE__*/ jsx("path", {
51
- fillRule: "evenodd",
52
- clipRule: "evenodd",
53
- d: "M6.99985 4.08501C5.38983 4.08501 4.08465 5.39019 4.08465 7.00021C4.08465 8.61023 5.38983 9.9154 6.99985 9.9154C8.60987 9.9154 9.91504 8.61023 9.91504 7.00021C9.91504 5.39019 8.60987 4.08501 6.99985 4.08501ZM5.08465 7.00021C5.08465 5.94247 5.94211 5.08501 6.99985 5.08501C8.05758 5.08501 8.91504 5.94247 8.91504 7.00021C8.91504 8.05794 8.05758 8.9154 6.99985 8.9154C5.94211 8.9154 5.08465 8.05794 5.08465 7.00021Z",
54
- fill: "#212121"
55
- }),
56
- /*#__PURE__*/ jsx("path", {
57
- fillRule: "evenodd",
58
- clipRule: "evenodd",
59
- d: "M5.52351 0.00390625C5.28138 0.00390625 5.07405 0.177388 5.03135 0.415715L4.7415 2.03321C4.40346 2.18248 4.08346 2.36419 3.78558 2.57432L2.18557 2.00147C1.95684 1.91958 1.70235 2.01395 1.58232 2.22517L0.122204 4.79451C0.00217064 5.00572 0.0513362 5.27266 0.238747 5.42725L1.50086 6.46836C1.48358 6.64355 1.47474 6.82106 1.47474 7.00047C1.47474 7.17981 1.48357 7.35726 1.50084 7.53238L0.238747 8.57347C0.0513362 8.72806 0.00217064 8.995 0.122203 9.20622L1.58232 11.7756C1.70235 11.9868 1.95684 12.0811 2.18557 11.9993L3.78537 11.4265C4.08332 11.6367 4.40341 11.8185 4.74155 11.9678L5.03135 13.585C5.07405 13.8233 5.28138 13.9968 5.52351 13.9968H8.47647C8.7186 13.9968 8.92593 13.8233 8.96863 13.585L9.25846 11.9676C9.5965 11.8183 9.91649 11.6365 10.2144 11.4264L11.8144 11.9993C12.0431 12.0811 12.2976 11.9868 12.4177 11.7756L13.8778 9.20622C13.9978 8.995 13.9486 8.72806 13.7612 8.57347L12.4988 7.5321C12.516 7.35706 12.5249 7.17971 12.5249 7.00047C12.5249 6.82116 12.516 6.64375 12.4988 6.46864L13.7612 5.42725C13.9486 5.27266 13.9978 5.00572 13.8778 4.79451L12.4177 2.22517C12.2976 2.01395 12.0431 1.91958 11.8144 2.00147L10.2141 2.57441C9.91636 2.36433 9.59645 2.18264 9.25851 2.0334L8.96863 0.415715C8.92593 0.177389 8.7186 0.00390625 8.47647 0.00390625H5.52351ZM5.67747 2.47943L5.94187 1.00391H8.0581L8.32253 2.47958C8.35348 2.6523 8.47271 2.79616 8.63668 2.85863C9.06768 3.02283 9.46674 3.25007 9.82215 3.5288C9.95734 3.63483 10.1375 3.66402 10.2993 3.6061L11.7559 3.08459L12.8007 4.92323L11.6503 5.8722C11.5145 5.98427 11.4476 6.15956 11.4743 6.33366C11.5076 6.55089 11.5249 6.77354 11.5249 7.00047C11.5249 7.22735 11.5076 7.44993 11.4743 7.66711C11.4476 7.8412 11.5145 8.01648 11.6504 8.12855L12.8007 9.07749L11.7559 10.9161L10.2994 10.3947C10.1377 10.3368 9.95752 10.366 9.82233 10.472C9.46686 10.7508 9.06773 10.9781 8.63664 11.1423C8.47267 11.2048 8.35344 11.3487 8.32249 11.5214L8.0581 12.9968H5.94187L5.67752 11.5215C5.64656 11.3488 5.52732 11.2049 5.36333 11.1425C4.93215 10.9782 4.53292 10.7509 4.17738 10.4721C4.04219 10.3661 3.86203 10.3369 3.70027 10.3948L2.24412 10.9161L1.19924 9.07749L2.34929 8.12883C2.48516 8.01675 2.55204 7.84146 2.52535 7.66736C2.49205 7.4501 2.47474 7.22743 2.47474 7.00047C2.47474 6.77345 2.49206 6.55072 2.52538 6.33341C2.55207 6.15931 2.48519 5.984 2.34932 5.87192L1.19924 4.92323L2.24412 3.08459L3.70047 3.60601C3.86221 3.66392 4.04236 3.63474 4.17755 3.52872C4.53304 3.24994 4.93219 3.02269 5.36329 2.85849C5.52728 2.79603 5.64652 2.65216 5.67747 2.47943Z",
60
- fill: "#212121"
61
- })
62
- ]
94
+ children: /*#__PURE__*/ jsxs(Fragment, {
95
+ children: [
96
+ /*#__PURE__*/ jsxs("svg", {
97
+ width: "84",
98
+ height: "8",
99
+ viewBox: "0 0 84 8",
100
+ fill: "none",
101
+ xmlns: "http://www.w3.org/2000/svg",
102
+ children: [
103
+ /*#__PURE__*/ jsx("path", {
104
+ d: "M0 4C0 1.79086 1.79086 0 4 0H18C20.2091 0 22 1.79086 22 4C22 6.20914 20.2091 8 18 8H4C1.79086 8 0 6.20914 0 4Z",
105
+ fill: layoutSetting?.showHeader ? '#9E9E9E' : HEADER_OFF_COLOR
106
+ }),
107
+ /*#__PURE__*/ jsx("path", {
108
+ d: "M28 4C28 1.79086 29.7909 0 32 0H80C82.2091 0 84 1.79086 84 4C84 6.20914 82.2091 8 80 8H32C29.7909 8 28 6.20914 28 4Z",
109
+ fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
110
+ })
111
+ ]
112
+ }),
113
+ /*#__PURE__*/ jsx("div", {
114
+ className: "gp-header gp-invisible gp-absolute gp-left-[8px] gp-flex gp-h-[24px] gp-w-[24px] gp-cursor-pointer gp-items-center gp-justify-center gp-rounded gp-bg-[#EEEEEE] gp-p-[4px] hover:gp-bg-[#0000001a] group-hover:gp-visible",
115
+ children: /*#__PURE__*/ jsx("div", {
116
+ className: "gp-flex gp-h-[24px] gp-w-[24px] gp-items-center gp-justify-center",
117
+ children: /*#__PURE__*/ jsxs("svg", {
118
+ width: "14",
119
+ height: "14",
120
+ viewBox: "0 0 14 14",
121
+ fill: "none",
122
+ xmlns: "http://www.w3.org/2000/svg",
123
+ children: [
124
+ /*#__PURE__*/ jsx("path", {
125
+ fillRule: "evenodd",
126
+ clipRule: "evenodd",
127
+ d: "M6.99985 4.08501C5.38983 4.08501 4.08465 5.39019 4.08465 7.00021C4.08465 8.61023 5.38983 9.9154 6.99985 9.9154C8.60987 9.9154 9.91504 8.61023 9.91504 7.00021C9.91504 5.39019 8.60987 4.08501 6.99985 4.08501ZM5.08465 7.00021C5.08465 5.94247 5.94211 5.08501 6.99985 5.08501C8.05758 5.08501 8.91504 5.94247 8.91504 7.00021C8.91504 8.05794 8.05758 8.9154 6.99985 8.9154C5.94211 8.9154 5.08465 8.05794 5.08465 7.00021Z",
128
+ fill: "#212121"
129
+ }),
130
+ /*#__PURE__*/ jsx("path", {
131
+ fillRule: "evenodd",
132
+ clipRule: "evenodd",
133
+ d: "M5.52351 0.00390625C5.28138 0.00390625 5.07405 0.177388 5.03135 0.415715L4.7415 2.03321C4.40346 2.18248 4.08346 2.36419 3.78558 2.57432L2.18557 2.00147C1.95684 1.91958 1.70235 2.01395 1.58232 2.22517L0.122204 4.79451C0.00217064 5.00572 0.0513362 5.27266 0.238747 5.42725L1.50086 6.46836C1.48358 6.64355 1.47474 6.82106 1.47474 7.00047C1.47474 7.17981 1.48357 7.35726 1.50084 7.53238L0.238747 8.57347C0.0513362 8.72806 0.00217064 8.995 0.122203 9.20622L1.58232 11.7756C1.70235 11.9868 1.95684 12.0811 2.18557 11.9993L3.78537 11.4265C4.08332 11.6367 4.40341 11.8185 4.74155 11.9678L5.03135 13.585C5.07405 13.8233 5.28138 13.9968 5.52351 13.9968H8.47647C8.7186 13.9968 8.92593 13.8233 8.96863 13.585L9.25846 11.9676C9.5965 11.8183 9.91649 11.6365 10.2144 11.4264L11.8144 11.9993C12.0431 12.0811 12.2976 11.9868 12.4177 11.7756L13.8778 9.20622C13.9978 8.995 13.9486 8.72806 13.7612 8.57347L12.4988 7.5321C12.516 7.35706 12.5249 7.17971 12.5249 7.00047C12.5249 6.82116 12.516 6.64375 12.4988 6.46864L13.7612 5.42725C13.9486 5.27266 13.9978 5.00572 13.8778 4.79451L12.4177 2.22517C12.2976 2.01395 12.0431 1.91958 11.8144 2.00147L10.2141 2.57441C9.91636 2.36433 9.59645 2.18264 9.25851 2.0334L8.96863 0.415715C8.92593 0.177389 8.7186 0.00390625 8.47647 0.00390625H5.52351ZM5.67747 2.47943L5.94187 1.00391H8.0581L8.32253 2.47958C8.35348 2.6523 8.47271 2.79616 8.63668 2.85863C9.06768 3.02283 9.46674 3.25007 9.82215 3.5288C9.95734 3.63483 10.1375 3.66402 10.2993 3.6061L11.7559 3.08459L12.8007 4.92323L11.6503 5.8722C11.5145 5.98427 11.4476 6.15956 11.4743 6.33366C11.5076 6.55089 11.5249 6.77354 11.5249 7.00047C11.5249 7.22735 11.5076 7.44993 11.4743 7.66711C11.4476 7.8412 11.5145 8.01648 11.6504 8.12855L12.8007 9.07749L11.7559 10.9161L10.2994 10.3947C10.1377 10.3368 9.95752 10.366 9.82233 10.472C9.46686 10.7508 9.06773 10.9781 8.63664 11.1423C8.47267 11.2048 8.35344 11.3487 8.32249 11.5214L8.0581 12.9968H5.94187L5.67752 11.5215C5.64656 11.3488 5.52732 11.2049 5.36333 11.1425C4.93215 10.9782 4.53292 10.7509 4.17738 10.4721C4.04219 10.3661 3.86203 10.3369 3.70027 10.3948L2.24412 10.9161L1.19924 9.07749L2.34929 8.12883C2.48516 8.01675 2.55204 7.84146 2.52535 7.66736C2.49205 7.4501 2.47474 7.22743 2.47474 7.00047C2.47474 6.77345 2.49206 6.55072 2.52538 6.33341C2.55207 6.15931 2.48519 5.984 2.34932 5.87192L1.19924 4.92323L2.24412 3.08459L3.70047 3.60601C3.86221 3.66392 4.04236 3.63474 4.17755 3.52872C4.53304 3.24994 4.93219 3.02269 5.36329 2.85849C5.52728 2.79603 5.64652 2.65216 5.67747 2.47943Z",
134
+ fill: "#212121"
135
+ })
136
+ ]
137
+ })
63
138
  })
139
+ }),
140
+ /*#__PURE__*/ jsxs("svg", {
141
+ width: "192",
142
+ height: "8",
143
+ viewBox: "0 0 192 8",
144
+ fill: "none",
145
+ xmlns: "http://www.w3.org/2000/svg",
146
+ children: [
147
+ /*#__PURE__*/ jsx("path", {
148
+ d: "M0 4C0 1.79086 1.79086 0 4 0H52C54.2091 0 56 1.79086 56 4C56 6.20914 54.2091 8 52 8H4C1.79086 8 0 6.20914 0 4Z",
149
+ fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
150
+ }),
151
+ /*#__PURE__*/ jsx("path", {
152
+ d: "M68 4C68 1.79086 69.7909 0 72 0H120C122.209 0 124 1.79086 124 4C124 6.20914 122.209 8 120 8H72C69.7909 8 68 6.20914 68 4Z",
153
+ fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
154
+ }),
155
+ /*#__PURE__*/ jsx("path", {
156
+ d: "M136 4C136 1.79086 137.791 0 140 0H188C190.209 0 192 1.79086 192 4C192 6.20914 190.209 8 188 8H140C137.791 8 136 6.20914 136 4Z",
157
+ fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
158
+ })
159
+ ]
64
160
  })
65
- }),
66
- /*#__PURE__*/ jsxs("svg", {
67
- width: "192",
68
- height: "8",
69
- viewBox: "0 0 192 8",
70
- fill: "none",
71
- xmlns: "http://www.w3.org/2000/svg",
72
- children: [
73
- /*#__PURE__*/ jsx("path", {
74
- d: "M0 4C0 1.79086 1.79086 0 4 0H52C54.2091 0 56 1.79086 56 4C56 6.20914 54.2091 8 52 8H4C1.79086 8 0 6.20914 0 4Z",
75
- fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
76
- }),
77
- /*#__PURE__*/ jsx("path", {
78
- d: "M68 4C68 1.79086 69.7909 0 72 0H120C122.209 0 124 1.79086 124 4C124 6.20914 122.209 8 120 8H72C69.7909 8 68 6.20914 68 4Z",
79
- fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
80
- }),
81
- /*#__PURE__*/ jsx("path", {
82
- d: "M136 4C136 1.79086 137.791 0 140 0H188C190.209 0 192 1.79086 192 4C192 6.20914 190.209 8 188 8H140C137.791 8 136 6.20914 136 4Z",
83
- fill: layoutSetting?.showHeader ? '#D6D6D6' : HEADER_OFF_COLOR
84
- })
85
- ]
86
- })
87
- ]
161
+ ]
162
+ })
88
163
  })
89
164
  });
90
165
  };
@@ -93,6 +93,27 @@ const isSticky = (el)=>{
93
93
  const tag = el.getAttribute('data-component-tag');
94
94
  return tag === 'Sticky';
95
95
  };
96
+ const isOverToolbarPosition = (el, parent1)=>{
97
+ const rect = el.getBoundingClientRect();
98
+ const rectP = parent1.getBoundingClientRect();
99
+ // 32px = toolbar active height
100
+ return rect.top - rectP.top < TOOLBAR_ACTIVE_HEIGHT + 1;
101
+ };
102
+ const findOverflowParent = (element, initEl)=>{
103
+ const thisEl = element;
104
+ const origEl = initEl || thisEl;
105
+ if (!thisEl) return;
106
+ if (isSection(thisEl)) return;
107
+ if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
108
+ if (thisEl.parentElement) {
109
+ return findOverflowParent(thisEl.parentElement, origEl);
110
+ } else {
111
+ return;
112
+ }
113
+ };
114
+ const COMPONENTS_TAG_NOT_LOAD_IMAGES = [
115
+ 'PostPurchaseProductImages'
116
+ ];
96
117
  const Toolbar = ()=>{
97
118
  const currentComponentActive = useRef(null);
98
119
  const isDragging = useRef(false);
@@ -351,13 +372,17 @@ const Toolbar = ()=>{
351
372
  };
352
373
  window.removeEventListener('editor:component:render', onComponentReRender);
353
374
  window.addEventListener('editor:component:render', onComponentReRender);
354
- const $images = $el.querySelectorAll('img');
355
- if ($images?.length) {
356
- $images.forEach(($img)=>{
357
- $img.addEventListener('load', ()=>{
358
- callback();
375
+ const componentTag = $el.getAttribute('data-component-tag');
376
+ // hotfix cho sale funnel release, nhưng cần tìm solution cho phần này
377
+ if (componentTag && !COMPONENTS_TAG_NOT_LOAD_IMAGES.includes(componentTag)) {
378
+ const $images = $el.querySelectorAll('img');
379
+ if ($images?.length) {
380
+ $images.forEach(($img)=>{
381
+ $img.addEventListener('load', ()=>{
382
+ callback();
383
+ });
359
384
  });
360
- });
385
+ }
361
386
  }
362
387
  stopWatchReRenderComponent.current = ()=>{
363
388
  window.removeEventListener('editor:component:render', onComponentReRender);
@@ -872,24 +897,6 @@ const Toolbar = ()=>{
872
897
  onCloseOnboarding: onCloseOnboarding
873
898
  });
874
899
  };
875
- const isOverToolbarPosition = (el, parent1)=>{
876
- const rect = el.getBoundingClientRect();
877
- const rectP = parent1.getBoundingClientRect();
878
- // 32px = toolbar active height
879
- return rect.top - rectP.top < TOOLBAR_ACTIVE_HEIGHT + 1;
880
- };
881
- const findOverflowParent = (element, initEl)=>{
882
- const thisEl = element;
883
- const origEl = initEl || thisEl;
884
- if (!thisEl) return;
885
- if (isSection(thisEl)) return;
886
- if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
887
- if (thisEl.parentElement) {
888
- return findOverflowParent(thisEl.parentElement, origEl);
889
- } else {
890
- return;
891
- }
892
- };
893
900
  var Toolbar$1 = /*#__PURE__*/ memo(Toolbar);
894
901
 
895
902
  export { Toolbar$1 as default };
@@ -13,6 +13,8 @@ const Toolbox = ()=>{
13
13
  const provider = useShopStore((s)=>s.provider);
14
14
  const changeStorefrontInfo = useShopStore((s)=>s.changeStorefrontInfo);
15
15
  const setDynamicProduct = usePageStore((s)=>s.setDynamicProduct);
16
+ const setPostPurchaseProductOffers = usePageStore((s)=>s.setPostPurchaseProductOffers);
17
+ const setSalePageProductId = usePageStore((s)=>s.setSalePageProductId);
16
18
  const setDynamicCollection = usePageStore((s)=>s.setDynamicCollection);
17
19
  const initState = useBuilderPreviewStore((s)=>s.initState);
18
20
  const state = useBuilderPreviewStore((s)=>s.state);
@@ -309,6 +311,20 @@ const Toolbox = ()=>{
309
311
  }, [
310
312
  updateItemAttribute
311
313
  ]);
314
+ const onUpdateProductOffers = useCallback((e)=>{
315
+ const productOffers = e.detail;
316
+ if (!productOffers?.length) return;
317
+ setPostPurchaseProductOffers(productOffers);
318
+ }, [
319
+ setPostPurchaseProductOffers
320
+ ]);
321
+ const onUpdateSalePageProductId = useCallback((e)=>{
322
+ const id = e.detail;
323
+ if (!id) return;
324
+ setSalePageProductId(id);
325
+ }, [
326
+ setSalePageProductId
327
+ ]);
312
328
  useEffect(()=>{
313
329
  if (fonts) {
314
330
  setFontsToHead('google-font-element', fonts);
@@ -334,6 +350,8 @@ const Toolbox = ()=>{
334
350
  window.addEventListener('set-dynamic-collection', onUpdateDynamicCollection);
335
351
  window.addEventListener('update-item-name', onUpdateItemName);
336
352
  window.addEventListener('update-item-attribute', onUpdateItemAttribute);
353
+ window.addEventListener('set-product-offer', onUpdateProductOffers);
354
+ window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
337
355
  return ()=>{
338
356
  window.removeEventListener('update-shop-info', onChangeShopInfo);
339
357
  window.removeEventListener('revalidate-query', onRevalidateQuery);
@@ -351,6 +369,8 @@ const Toolbox = ()=>{
351
369
  window.removeEventListener('set-dynamic-collection', onUpdateDynamicCollection);
352
370
  window.removeEventListener('update-item-name', onUpdateItemName);
353
371
  window.removeEventListener('update-item-attribute', onUpdateItemAttribute);
372
+ window.removeEventListener('set-product-offer', onUpdateProductOffers);
373
+ window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
354
374
  };
355
375
  }, [
356
376
  onAddEntity,
@@ -369,7 +389,9 @@ const Toolbox = ()=>{
369
389
  onUpdateDynamicProduct,
370
390
  onUpdateDynamicCollection,
371
391
  onUpdateItemName,
372
- onUpdateItemAttribute
392
+ onUpdateItemAttribute,
393
+ onUpdateProductOffers,
394
+ onUpdateSalePageProductId
373
395
  ]);
374
396
  return /*#__PURE__*/ jsx("div", {
375
397
  className: "toolbox"
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useEffect, useMemo } from 'react';
3
3
  import { useShopStore, useBuilderPreviewStore, makeStyleResponsive } from '@gem-sdk/core';
4
4
 
5
- const ACTIONS_DATA = [
5
+ const BASE_DATA = [
6
6
  {
7
7
  title: 'Choose templates',
8
8
  content: 'inspired by CRO experts',
@@ -22,6 +22,14 @@ const ACTIONS_DATA = [
22
22
  id: 'gps-add-section-bottom-from-image'
23
23
  }
24
24
  ];
25
+ const POST_PURCHASE_PAGE_DATA = [
26
+ {
27
+ title: 'Blank section',
28
+ content: 'to start from scratch',
29
+ hasAILogo: false,
30
+ id: 'gps-add-section-blank'
31
+ }
32
+ ];
25
33
  const FOOTER_HEIGHT = 48;
26
34
  const defaultPadding = {
27
35
  desktop: 'var(--g-ct-p)',
@@ -33,6 +41,14 @@ const AddSectionImageToLayout = ({ editorImageToLayout })=>{
33
41
  const totalSection = useBuilderPreviewStore((state)=>state.state.ROOT.childrens?.length);
34
42
  const [link, setLink] = useState('');
35
43
  const [isInput, setIsInput] = useState(false);
44
+ const editingPageType = useShopStore((s)=>s.pageType);
45
+ let ACTIONS_DATA = BASE_DATA;
46
+ if (editingPageType === 'POST_PURCHASE') {
47
+ ACTIONS_DATA = [
48
+ ...POST_PURCHASE_PAGE_DATA,
49
+ ...BASE_DATA
50
+ ].filter((item)=>item.id !== 'gps-add-section-bottom-from-url' && item.id !== 'gps-add-section-bottom-from-image');
51
+ }
36
52
  useEffect(()=>{
37
53
  if (!isInput || totalSection === 0) {
38
54
  setLink('');
package/dist/esm/index.js CHANGED
@@ -5,11 +5,13 @@ export { getPreviewProps } from './libs/api/get-preview-props.js';
5
5
  export { getBuilderProps } from './libs/api/get-builder-props.js';
6
6
  export { getProductProps } from './libs/api/get-product-props.js';
7
7
  export { getStaticPagePropsV2 } from './libs/api/get-static-page-props-v2.js';
8
+ export { getPostPurchasePropsPreview } from './libs/api/get-post-purchase-props-preview.js';
8
9
  export { getStaticPagePropsPreview } from './libs/api/get-static-page-props-preview.js';
9
- export { createFetcher, createShopifyFetcher } from './libs/fetcher.js';
10
+ export { createAppAPIFetcher, createFetcher, createShopifyFetcher } from './libs/fetcher.js';
10
11
  export { getLayout } from './libs/get-layout.js';
11
12
  export { genCSS } from './libs/helpers/gen-css.js';
12
13
  export { useTrackingView } from './libs/hooks/use-tracking-view.js';
14
+ export { usePagePreview } from './libs/hooks/usePagePreview.js';
13
15
  export { isBot } from './libs/helpers/user-agent.js';
14
16
  export { normalizePageSectionResponseV2, parseBuilderTemplateV2 } from './libs/helpers/normalize.js';
15
17
  export { getFallbackV2 } from './libs/helpers/get-fallback.js';
@@ -0,0 +1,88 @@
1
+ import { ThemePageDocument, StorePropertyDocument, LibraryTemplateDocument } from '@gem-sdk/core';
2
+ import { ShopMetaDocument } from '@gem-sdk/adapter-shopify';
3
+ import { captureException } from '@sentry/nextjs';
4
+ import { getFontStyleFromPageTemplate } from '../google-fonts.js';
5
+ import { getFallbackV2 } from '../helpers/get-fallback.js';
6
+ import { parseBuilderTemplateV2 } from '../helpers/normalize.js';
7
+ import { usePagePreview } from '../hooks/usePagePreview.js';
8
+ import { serializableJson } from '../helpers/parse-json.js';
9
+
10
+ const fetchThemePageDataByID = async (themePageId, fetcher, shopifyFetcher)=>{
11
+ const variables = {
12
+ themePageId
13
+ };
14
+ const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
15
+ fetcher([
16
+ ThemePageDocument,
17
+ variables
18
+ ]),
19
+ fetcher([
20
+ StorePropertyDocument
21
+ ]),
22
+ shopifyFetcher([
23
+ ShopMetaDocument
24
+ ])
25
+ ]);
26
+ if (theme.status === 'rejected') {
27
+ throw new Error(theme.reason?.[0]);
28
+ }
29
+ return {
30
+ dataBuilder: theme.value.themePage,
31
+ storeProperty,
32
+ shopifyMeta
33
+ };
34
+ };
35
+ const fetchThemePageDataByTemplateID = async (libraryTemplateId, fetcher, shopifyFetcher)=>{
36
+ const variables = {
37
+ libraryTemplateId
38
+ };
39
+ const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
40
+ fetcher([
41
+ LibraryTemplateDocument,
42
+ variables
43
+ ]),
44
+ fetcher([
45
+ StorePropertyDocument
46
+ ]),
47
+ shopifyFetcher([
48
+ ShopMetaDocument
49
+ ])
50
+ ]);
51
+ if (theme.status === 'rejected') {
52
+ throw new Error(theme.reason?.[0]);
53
+ }
54
+ return {
55
+ dataBuilder: theme.value.libraryTemplate,
56
+ storeProperty,
57
+ shopifyMeta
58
+ };
59
+ };
60
+ const getPostPurchasePropsPreview = (fetcher, shopifyFetcher, isTemplate)=>async (id)=>{
61
+ try {
62
+ const { dataBuilder, storeProperty, shopifyMeta } = isTemplate ? await fetchThemePageDataByTemplateID(id, fetcher, shopifyFetcher) : await fetchThemePageDataByID(id, fetcher, shopifyFetcher);
63
+ if (!dataBuilder) {
64
+ throw new Error(`No data builder found for slug: /preview/${id}`);
65
+ }
66
+ const pageTemplate = parseBuilderTemplateV2(dataBuilder);
67
+ const [elementFontStyle, fallback] = await Promise.all([
68
+ getFontStyleFromPageTemplate(pageTemplate),
69
+ getFallbackV2(fetcher, pageTemplate)
70
+ ]);
71
+ const { seo, pageConfig } = usePagePreview(dataBuilder, storeProperty, shopifyMeta);
72
+ return serializableJson({
73
+ seo,
74
+ ...pageConfig,
75
+ elementFontStyle,
76
+ builderData: pageTemplate,
77
+ pageType: 'POST_PURCHASE',
78
+ swr: {
79
+ fallback
80
+ }
81
+ });
82
+ } catch (err) {
83
+ captureException(err);
84
+ throw err;
85
+ }
86
+ };
87
+
88
+ export { fetchThemePageDataByID, fetchThemePageDataByTemplateID, getPostPurchasePropsPreview };
@@ -30,6 +30,38 @@ const createFetcher = (token)=>{
30
30
  });
31
31
  };
32
32
  };
33
+ const createAppAPIFetcher = (token, shopID)=>{
34
+ const shopToken = token;
35
+ const endPoint = process.env.NEXT_APP_API_URL;
36
+ return async (args)=>{
37
+ const [query, variables, operationName] = args;
38
+ if (!shopToken) {
39
+ throw new Error('shopToken is not defined');
40
+ }
41
+ if (!endPoint) {
42
+ throw new Error('NEXT_APP_API_URL is not defined');
43
+ }
44
+ const headers = {
45
+ 'Content-Type': 'application/json',
46
+ Authorization: `Token ${shopToken}`,
47
+ 'X-GemX-Shop-ID': shopID || ''
48
+ };
49
+ return fetch(endPoint, {
50
+ method: 'POST',
51
+ headers,
52
+ body: JSON.stringify({
53
+ query,
54
+ variables,
55
+ operationName
56
+ })
57
+ }).then((res)=>res.json()).then((res)=>{
58
+ if (res.errors) {
59
+ return Promise.reject(res.errors);
60
+ }
61
+ return res.data;
62
+ });
63
+ };
64
+ };
33
65
  const createShopifyFetcher = (storefrontToken, handle)=>{
34
66
  const token = storefrontToken ?? process.env.NEXT_PUBLIC_STOREFRONT_TOKEN;
35
67
  const storefrontHandle = handle ?? process.env.NEXT_PUBLIC_STOREFRONT_HANDLE;
@@ -61,4 +93,4 @@ const createShopifyFetcher = (storefrontToken, handle)=>{
61
93
  };
62
94
  };
63
95
 
64
- export { createFetcher, createShopifyFetcher };
96
+ export { createAppAPIFetcher, createFetcher, createShopifyFetcher };
@@ -0,0 +1,90 @@
1
+ import { generateManifest } from '../helpers/generate-manifres.js';
2
+ import { parseJson } from '../helpers/parse-json.js';
3
+
4
+ const usePagePreview = (dataBuilder, storeProperty, shopifyMeta)=>{
5
+ const mobileOnly = dataBuilder?.isMobile ?? false;
6
+ const shopMeta = shopifyMeta.status === 'fulfilled' ? shopifyMeta.value : undefined;
7
+ const shopData = storeProperty.status === 'fulfilled' ? storeProperty.value : undefined;
8
+ const favicon = shopData?.storeProperty?.favicon ?? '/favicon/favicon-32x32.png';
9
+ const languageIsoCode = shopMeta?.localization.language.isoCode ?? null;
10
+ const countryIsoCode = shopMeta?.localization.country.isoCode ?? null;
11
+ const moneyFormat = shopMeta?.shop.moneyFormat ?? null;
12
+ const currency = shopMeta?.localization.country.currency.isoCode ?? null;
13
+ const swatches = parseJson(shopData?.storeProperty?.swatchesConfig);
14
+ const locale = !languageIsoCode || !countryIsoCode ? null : `${languageIsoCode}-${countryIsoCode}`;
15
+ const seo = {
16
+ defaultTitle: shopMeta?.shop.name,
17
+ title: dataBuilder?.name,
18
+ openGraph: {
19
+ site_name: shopMeta?.shop.name,
20
+ locale: shopMeta?.localization.country.isoCode,
21
+ title: dataBuilder?.name ?? shopMeta?.shop.name
22
+ },
23
+ nofollow: true,
24
+ noindex: true,
25
+ canonical: `/preview/${dataBuilder?.id}`,
26
+ additionalMetaTags: [
27
+ {
28
+ name: 'theme-color',
29
+ content: '#000000'
30
+ }
31
+ ],
32
+ additionalLinkTags: [
33
+ {
34
+ rel: 'icon',
35
+ sizes: '32x32',
36
+ href: `${favicon}-/crop/1:1/center/-/smart_resize/32x32/`
37
+ },
38
+ {
39
+ rel: 'icon',
40
+ sizes: '16x16',
41
+ href: `${favicon}-/crop/1:1/center/-/smart_resize/16x16/`
42
+ },
43
+ {
44
+ rel: 'apple-touch-icon',
45
+ sizes: '180x180',
46
+ href: `${favicon}-/crop/1:1/center/-/smart_resize/180x180/`
47
+ },
48
+ {
49
+ rel: 'manifest',
50
+ href: generateManifest({
51
+ theme_color: '#000000',
52
+ background_color: '#ffffff',
53
+ display: 'standalone',
54
+ scope: '/',
55
+ start_url: '/',
56
+ name: shopMeta?.shop.name,
57
+ short_name: shopMeta?.shop.name,
58
+ description: shopMeta?.shop.description,
59
+ icons: [
60
+ {
61
+ src: `${favicon}-/crop/1:1/center/-/smart_resize/192x192/`,
62
+ sizes: '192x192',
63
+ type: 'image/png',
64
+ purpose: 'any maskable'
65
+ },
66
+ {
67
+ src: `${favicon}-/crop/1:1/center/-/smart_resize/512x512/`,
68
+ sizes: '512x512',
69
+ type: 'image/png'
70
+ }
71
+ ]
72
+ })
73
+ }
74
+ ]
75
+ };
76
+ return {
77
+ seo,
78
+ pageConfig: {
79
+ mobileOnly,
80
+ locale,
81
+ languageIsoCode,
82
+ countryIsoCode,
83
+ moneyFormat,
84
+ currency,
85
+ swatches
86
+ }
87
+ };
88
+ };
89
+
90
+ export { usePagePreview };