@gem-sdk/pages 2.0.0-dev.884 → 2.0.0-staging.118

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 (144) hide show
  1. package/dist/cjs/components/ErrorBoundary.js +41 -1
  2. package/dist/cjs/components/ErrorFallback.js +27 -1
  3. package/dist/cjs/components/FacebookPixel.js +34 -3
  4. package/dist/cjs/components/FooterForPostPurchase.js +35 -1
  5. package/dist/cjs/components/GoogleAnalytic.js +66 -5
  6. package/dist/cjs/components/TikTokPixel.js +20 -3
  7. package/dist/cjs/components/builder/Body.js +37 -0
  8. package/dist/cjs/components/builder/Footer.js +155 -0
  9. package/dist/cjs/components/builder/Header.js +188 -0
  10. package/dist/cjs/components/builder/PopupManager.js +64 -1
  11. package/dist/cjs/components/builder/SwitchView.js +185 -0
  12. package/dist/cjs/components/builder/Toolbar.js +701 -1
  13. package/dist/cjs/components/builder/Toolbox.js +485 -1
  14. package/dist/cjs/components/builder/const.js +56 -0
  15. package/dist/cjs/components/builder/toolbar/const.js +7 -0
  16. package/dist/cjs/components/builder/toolbar/utils/findDOMClosest.js +41 -0
  17. package/dist/cjs/components/builder/toolbar/utils/findOverflowParent.js +20 -0
  18. package/dist/cjs/components/builder/toolbar/utils/getChildrenByAttrSelector.js +18 -0
  19. package/dist/cjs/components/builder/toolbar/utils/getDOMElementParents.js +32 -0
  20. package/dist/cjs/components/builder/toolbar/utils/isOverParent.js +16 -0
  21. package/dist/cjs/components/builder/toolbar/utils/isOverToolbarPosition.js +12 -0
  22. package/dist/cjs/components/builder/toolbar/utils/isSection.js +8 -0
  23. package/dist/cjs/components/builder/toolbar/utils/notVisible.js +8 -0
  24. package/dist/cjs/components/builder/toolbar/utils/waitForElementToExist.js +27 -0
  25. package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +151 -1
  26. package/dist/cjs/components/image-to-layout/DropElement.js +167 -1
  27. package/dist/cjs/components/image-to-layout/ImageToLayout.js +42 -1
  28. package/dist/cjs/index.js +80 -1
  29. package/dist/cjs/layouts/main.js +31 -1
  30. package/dist/cjs/libs/api/get-builder-props.js +46 -1
  31. package/dist/cjs/libs/api/get-collection-props.js +68 -1
  32. package/dist/cjs/libs/api/get-home-page-props-v2.js +145 -1
  33. package/dist/cjs/libs/api/get-home-page-props.js +151 -1
  34. package/dist/cjs/libs/api/get-post-purchase-props-preview.js +268 -1
  35. package/dist/cjs/libs/api/get-preview-props.js +18 -1
  36. package/dist/cjs/libs/api/get-product-props.js +73 -1
  37. package/dist/cjs/libs/api/get-static-page-props-preview.js +155 -1
  38. package/dist/cjs/libs/api/get-static-page-props-v2.js +164 -1
  39. package/dist/cjs/libs/api/get-static-page-props.js +148 -1
  40. package/dist/cjs/libs/custom-fonts.js +60 -6
  41. package/dist/cjs/libs/fetcher.js +100 -1
  42. package/dist/cjs/libs/get-layout.js +13 -1
  43. package/dist/cjs/libs/get-storefront-api.js +12 -1
  44. package/dist/cjs/libs/getStaticPaths.js +10 -1
  45. package/dist/cjs/libs/google-fonts.js +118 -1
  46. package/dist/cjs/libs/helpers/check-option-font.js +65 -0
  47. package/dist/cjs/libs/helpers/common.js +27 -1
  48. package/dist/cjs/libs/helpers/gen-css.js +135 -1
  49. package/dist/cjs/libs/helpers/gen-fonts.js +90 -1
  50. package/dist/cjs/libs/helpers/generate-manifres.js +5 -1
  51. package/dist/cjs/libs/helpers/get-fallback.js +34 -1
  52. package/dist/cjs/libs/helpers/normalize.js +111 -1
  53. package/dist/cjs/libs/helpers/parse-json.js +16 -1
  54. package/dist/cjs/libs/helpers/user-agent.js +7 -1
  55. package/dist/cjs/libs/hooks/use-tracking-view.js +43 -1
  56. package/dist/cjs/libs/hooks/usePagePreview.js +92 -1
  57. package/dist/cjs/libs/parse-html.js +34 -1
  58. package/dist/cjs/libs/shopify-cdn-with-google-fonts.js +1845 -1
  59. package/dist/cjs/pages/404.js +43 -1
  60. package/dist/cjs/pages/500.js +74 -1
  61. package/dist/cjs/pages/CollectionGlobalProvider.js +59 -1
  62. package/dist/cjs/pages/builder.js +115 -1
  63. package/dist/cjs/pages/collection-detail.js +64 -1
  64. package/dist/cjs/pages/preview.js +26 -1
  65. package/dist/cjs/pages/product-detail.js +69 -1
  66. package/dist/cjs/pages/static-v2.js +139 -1
  67. package/dist/cjs/pages/static.js +75 -1
  68. package/dist/cjs/store/libs-store.js +14 -0
  69. package/dist/esm/components/ErrorBoundary.js +39 -1
  70. package/dist/esm/components/ErrorFallback.js +25 -1
  71. package/dist/esm/components/FacebookPixel.js +32 -3
  72. package/dist/esm/components/FooterForPostPurchase.js +31 -1
  73. package/dist/esm/components/GoogleAnalytic.js +64 -5
  74. package/dist/esm/components/TikTokPixel.js +18 -3
  75. package/dist/esm/components/builder/Body.js +33 -0
  76. package/dist/esm/components/builder/Footer.js +151 -0
  77. package/dist/esm/components/builder/Header.js +184 -0
  78. package/dist/esm/components/builder/PopupManager.js +60 -1
  79. package/dist/esm/components/builder/SwitchView.js +181 -0
  80. package/dist/esm/components/builder/Toolbar.js +697 -1
  81. package/dist/esm/components/builder/Toolbox.js +481 -1
  82. package/dist/esm/components/builder/const.js +54 -0
  83. package/dist/esm/components/builder/toolbar/const.js +4 -0
  84. package/dist/esm/components/builder/toolbar/utils/findDOMClosest.js +39 -0
  85. package/dist/esm/components/builder/toolbar/utils/findOverflowParent.js +18 -0
  86. package/dist/esm/components/builder/toolbar/utils/getChildrenByAttrSelector.js +16 -0
  87. package/dist/esm/components/builder/toolbar/utils/getDOMElementParents.js +30 -0
  88. package/dist/esm/components/builder/toolbar/utils/isOverParent.js +14 -0
  89. package/dist/esm/components/builder/toolbar/utils/isOverToolbarPosition.js +10 -0
  90. package/dist/esm/components/builder/toolbar/utils/isSection.js +6 -0
  91. package/dist/esm/components/builder/toolbar/utils/notVisible.js +6 -0
  92. package/dist/esm/components/builder/toolbar/utils/waitForElementToExist.js +25 -0
  93. package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +147 -1
  94. package/dist/esm/components/image-to-layout/DropElement.js +165 -1
  95. package/dist/esm/components/image-to-layout/ImageToLayout.js +38 -1
  96. package/dist/esm/index.js +35 -1
  97. package/dist/esm/layouts/main.js +27 -1
  98. package/dist/esm/libs/api/get-builder-props.js +44 -1
  99. package/dist/esm/libs/api/get-collection-props.js +66 -1
  100. package/dist/esm/libs/api/get-home-page-props-v2.js +143 -1
  101. package/dist/esm/libs/api/get-home-page-props.js +149 -1
  102. package/dist/esm/libs/api/get-post-purchase-props-preview.js +260 -1
  103. package/dist/esm/libs/api/get-preview-props.js +16 -1
  104. package/dist/esm/libs/api/get-product-props.js +71 -1
  105. package/dist/esm/libs/api/get-static-page-props-preview.js +153 -1
  106. package/dist/esm/libs/api/get-static-page-props-v2.js +162 -1
  107. package/dist/esm/libs/api/get-static-page-props.js +146 -1
  108. package/dist/esm/libs/custom-fonts.js +55 -6
  109. package/dist/esm/libs/fetcher.js +96 -1
  110. package/dist/esm/libs/get-layout.js +11 -1
  111. package/dist/esm/libs/get-storefront-api.js +10 -1
  112. package/dist/esm/libs/getStaticPaths.js +8 -1
  113. package/dist/esm/libs/google-fonts.js +112 -1
  114. package/dist/esm/libs/helpers/check-option-font.js +63 -0
  115. package/dist/esm/libs/helpers/common.js +24 -1
  116. package/dist/esm/libs/helpers/gen-css.js +133 -1
  117. package/dist/esm/libs/helpers/gen-fonts.js +87 -1
  118. package/dist/esm/libs/helpers/generate-manifres.js +3 -1
  119. package/dist/esm/libs/helpers/get-fallback.js +32 -1
  120. package/dist/esm/libs/helpers/normalize.js +103 -1
  121. package/dist/esm/libs/helpers/parse-json.js +13 -1
  122. package/dist/esm/libs/helpers/user-agent.js +5 -1
  123. package/dist/esm/libs/hooks/use-tracking-view.js +41 -1
  124. package/dist/esm/libs/hooks/usePagePreview.js +90 -1
  125. package/dist/esm/libs/parse-html.js +32 -1
  126. package/dist/esm/libs/shopify-cdn-with-google-fonts.js +1843 -1
  127. package/dist/esm/pages/404.js +41 -1
  128. package/dist/esm/pages/500.js +72 -1
  129. package/dist/esm/pages/CollectionGlobalProvider.js +55 -1
  130. package/dist/esm/pages/builder.js +113 -1
  131. package/dist/esm/pages/collection-detail.js +60 -1
  132. package/dist/esm/pages/preview.js +24 -1
  133. package/dist/esm/pages/product-detail.js +65 -1
  134. package/dist/esm/pages/static-v2.js +137 -1
  135. package/dist/esm/pages/static.js +71 -1
  136. package/dist/esm/store/libs-store.js +12 -0
  137. package/dist/types/index.d.ts +50 -34
  138. package/package.json +8 -5
  139. package/dist/cjs/components/Footer.js +0 -1
  140. package/dist/cjs/components/Header.js +0 -1
  141. package/dist/cjs/components/builder/toolbar/Onboarding.js +0 -1
  142. package/dist/esm/components/Footer.js +0 -1
  143. package/dist/esm/components/Header.js +0 -1
  144. package/dist/esm/components/builder/toolbar/Onboarding.js +0 -1
@@ -0,0 +1,184 @@
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useShopStore, usePageStore, cls, makeStyleResponsive } from '@gem-sdk/core';
4
+ import Devices from './SwitchView.js';
5
+
6
+ const defaultMargin = {
7
+ desktop: '16px',
8
+ tablet: '16px',
9
+ mobile: '16px'
10
+ };
11
+ const HEADER_ON_COLOR = '#E2E2E2';
12
+ const HEADER_OFF_COLOR = '#F4F4F4';
13
+ const sizeCheck = {
14
+ desktop: '24px',
15
+ tablet: '36px',
16
+ mobile: '36px'
17
+ };
18
+ const Header = (props)=>{
19
+ const { pageType, isOriginTemplate, openPageSetting } = props;
20
+ const layoutSetting = useShopStore((s)=>s.layoutSettings);
21
+ usePageStore((s)=>s.sidebarMode);
22
+ const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
23
+ const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
24
+ return /*#__PURE__*/ jsxs(Fragment, {
25
+ children: [
26
+ /*#__PURE__*/ jsx(Devices, {}),
27
+ /*#__PURE__*/ jsx("div", {
28
+ 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'),
29
+ children: pageType === 'POST_PURCHASE' ? /*#__PURE__*/ jsx("div", {
30
+ className: "gp-flex gp-flex-1 gp-items-center gp-justify-between",
31
+ style: {
32
+ maxWidth: `var(--g-ct-w, 1200px)`,
33
+ ...makeStyleResponsive('ml', defaultMargin),
34
+ ...makeStyleResponsive('mr', defaultMargin)
35
+ },
36
+ children: /*#__PURE__*/ jsxs("div", {
37
+ className: "tablet:gp-items-center gp-flex gp-py-3",
38
+ children: [
39
+ /*#__PURE__*/ jsxs("svg", {
40
+ style: {
41
+ ...makeStyleResponsive('w', sizeCheck),
42
+ ...makeStyleResponsive('h', sizeCheck)
43
+ },
44
+ viewBox: "0 0 24 24",
45
+ fill: "none",
46
+ xmlns: "http://www.w3.org/2000/svg",
47
+ children: [
48
+ /*#__PURE__*/ jsx("path", {
49
+ 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",
50
+ fill: "#197BBD"
51
+ }),
52
+ /*#__PURE__*/ jsx("path", {
53
+ fillRule: "evenodd",
54
+ clipRule: "evenodd",
55
+ 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",
56
+ fill: "#197BBD"
57
+ })
58
+ ]
59
+ }),
60
+ /*#__PURE__*/ jsxs("div", {
61
+ className: "gp-ml-4",
62
+ children: [
63
+ /*#__PURE__*/ jsx("p", {
64
+ className: "gp-text-sm",
65
+ children: "Order #1001"
66
+ }),
67
+ /*#__PURE__*/ jsx("p", {
68
+ children: "You’ve paid for your order."
69
+ }),
70
+ /*#__PURE__*/ jsxs("div", {
71
+ className: "gp-mt-1 gp-flex gp-items-center gp-text-[#197BBD]",
72
+ children: [
73
+ /*#__PURE__*/ jsx("div", {
74
+ className: "gp-text-sm",
75
+ children: "View order confirmation"
76
+ }),
77
+ /*#__PURE__*/ jsx("svg", {
78
+ width: "12",
79
+ height: "13",
80
+ viewBox: "0 0 12 13",
81
+ fill: "none",
82
+ xmlns: "http://www.w3.org/2000/svg",
83
+ children: /*#__PURE__*/ jsx("path", {
84
+ fillRule: "evenodd",
85
+ clipRule: "evenodd",
86
+ 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",
87
+ fill: "#197BBD"
88
+ })
89
+ })
90
+ ]
91
+ })
92
+ ]
93
+ })
94
+ ]
95
+ })
96
+ }) : /*#__PURE__*/ jsxs("div", {
97
+ className: "gp-flex gp-h-[40px] gp-flex-1 gp-items-center gp-justify-between",
98
+ style: {
99
+ maxWidth: `var(--g-ct-w)`,
100
+ ...makeStyleResponsive('ml', defaultMargin),
101
+ ...makeStyleResponsive('mr', defaultMargin)
102
+ },
103
+ children: [
104
+ /*#__PURE__*/ jsxs("svg", {
105
+ width: "60",
106
+ height: "8",
107
+ viewBox: "0 0 60 8",
108
+ fill: "none",
109
+ xmlns: "http://www.w3.org/2000/svg",
110
+ children: [
111
+ /*#__PURE__*/ jsx("path", {
112
+ d: "M0 4C0 1.79086 1.79086 0 4 0H20C22.2091 0 24 1.79086 24 4C24 6.20914 22.2091 8 20 8H4C1.79086 8 0 6.20914 0 4Z",
113
+ fill: "#9E9E9E"
114
+ }),
115
+ /*#__PURE__*/ jsx("path", {
116
+ d: "M28 4C28 1.79086 29.7909 0 32 0H56C58.2091 0 60 1.79086 60 4C60 6.20914 58.2091 8 56 8H32C29.7909 8 28 6.20914 28 4Z",
117
+ fill: headerColor
118
+ })
119
+ ]
120
+ }),
121
+ !(isOriginTemplate || pageType === 'STATIC') && /*#__PURE__*/ jsx("button", {
122
+ className: "gp-header gp-invisible gp-absolute gp-left-[8px] gp-flex gp-h-[24px] gp-cursor-pointer gp-items-center gp-justify-center gp-rounded gp-bg-[#EEEEEE] gp-p-[4px] hover:gp-bg-[#f4f4f4] group-hover:gp-visible",
123
+ onClick: openPageSetting,
124
+ children: /*#__PURE__*/ jsxs("div", {
125
+ className: "gp-gap-2 gp-flex gp-px-1 gp-h-[24px] gp-items-center gp-justify-center gp-leading-5 gp-text-xs gp-font-medium gp-text-[#212121]",
126
+ children: [
127
+ /*#__PURE__*/ jsx("span", {
128
+ children: /*#__PURE__*/ jsxs("svg", {
129
+ width: "14",
130
+ height: "14",
131
+ viewBox: "0 0 14 14",
132
+ fill: "none",
133
+ xmlns: "http://www.w3.org/2000/svg",
134
+ children: [
135
+ /*#__PURE__*/ jsx("path", {
136
+ fillRule: "evenodd",
137
+ clipRule: "evenodd",
138
+ 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",
139
+ fill: "#212121"
140
+ }),
141
+ /*#__PURE__*/ jsx("path", {
142
+ fillRule: "evenodd",
143
+ clipRule: "evenodd",
144
+ 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",
145
+ fill: "#212121"
146
+ })
147
+ ]
148
+ })
149
+ }),
150
+ /*#__PURE__*/ jsx("span", {
151
+ children: "Header"
152
+ })
153
+ ]
154
+ })
155
+ }),
156
+ /*#__PURE__*/ jsxs("svg", {
157
+ width: "80",
158
+ height: "8",
159
+ viewBox: "0 0 80 8",
160
+ fill: "none",
161
+ xmlns: "http://www.w3.org/2000/svg",
162
+ children: [
163
+ /*#__PURE__*/ jsx("path", {
164
+ d: "M0 4C0 1.79086 1.79086 0 4 0H20C22.2091 0 24 1.79086 24 4C24 6.20914 22.2091 8 20 8H4C1.79086 8 0 6.20914 0 4Z",
165
+ fill: headerColor
166
+ }),
167
+ /*#__PURE__*/ jsx("path", {
168
+ d: "M28 4C28 1.79086 29.7909 0 32 0H48C50.2091 0 52 1.79086 52 4C52 6.20914 50.2091 8 48 8H32C29.7909 8 28 6.20914 28 4Z",
169
+ fill: headerColor
170
+ }),
171
+ /*#__PURE__*/ jsx("path", {
172
+ d: "M56 4C56 1.79086 57.7909 0 60 0H76C78.2091 0 80 1.79086 80 4C80 6.20914 78.2091 8 76 8H60C57.7909 8 56 6.20914 56 4Z",
173
+ fill: headerColor
174
+ })
175
+ ]
176
+ })
177
+ ]
178
+ })
179
+ })
180
+ ]
181
+ });
182
+ };
183
+
184
+ export { Header as default };
@@ -1 +1,60 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useBuilderPreviewStore as t,useModalStore as i,cls as p}from"@gem-sdk/core";import{memo as n,useMemo as a,useCallback as o,useEffect as r}from"react";let isDialog=e=>!!e&&e?.tag==="Dialog"&&"component"===e.type,PopupManager=()=>{let n=t(e=>e.state),l=i(e=>e.setModalActive),g=i(e=>e.activeId),s=a(()=>n.ROOT.childrens?.map(e=>n?.[e]).filter(isDialog),[n]),d=o(e=>{let t=e.detail;l(t?.modalId)},[l]);return r(()=>(window.addEventListener("set-active-modal",d),()=>{window.removeEventListener("set-active-modal",d)}),[d]),e("div",{className:"gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",children:s?.map(t=>{let i=t?.advanced?.d;return e("div",{className:p("gp-pointer-events-auto gp-w-full gp-shrink gp-cursor-pointer gp-select-none gp-items-center gp-justify-center gp-whitespace-nowrap gp-py-2 gp-text-white [writing-mode:vertical-lr]",{"gp-bg-blue-500":g===t.uid,"gp-bg-blue-700":g!==t.uid}),role:"button","aria-hidden":"true",onClick:()=>l(t?.uid),style:{"--d":i?.desktop?"inline-flex":"none","--d-tablet":i?.tablet?"inline-flex":"none","--d-mobile":i?.mobile?"inline-flex":"none"},children:e("span",{className:"gp-text-ellipsis gp-whitespace-nowrap",children:t?.settings?.name||"Popup Name"})},t?.uid)})})};var PopupManager$1=n(PopupManager);export{PopupManager$1 as default};
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useBuilderPreviewStore, useModalStore, useInteraction, cls } from '@gem-sdk/core';
4
+ import { memo, useMemo, useCallback, useEffect } from 'react';
5
+
6
+ const isDialog = (item)=>!!item && item?.tag === 'Dialog' && item.type === 'component';
7
+ const PopupManager = ()=>{
8
+ const state = useBuilderPreviewStore((s)=>s.state);
9
+ const setModalActive = useModalStore((s)=>s.setModalActive);
10
+ const activeModalId = useModalStore((s)=>s.activeId);
11
+ const { isInteractionMode } = useInteraction();
12
+ const popups = useMemo(()=>{
13
+ return state.ROOT.childrens?.map((id)=>{
14
+ return state?.[id];
15
+ }).filter(isDialog);
16
+ }, [
17
+ state
18
+ ]);
19
+ const onSetActiveModal = useCallback((e)=>{
20
+ const detail = e.detail;
21
+ setModalActive(detail?.modalId);
22
+ }, [
23
+ setModalActive
24
+ ]);
25
+ useEffect(()=>{
26
+ window.addEventListener('set-active-modal', onSetActiveModal);
27
+ return ()=>{
28
+ window.removeEventListener('set-active-modal', onSetActiveModal);
29
+ };
30
+ }, [
31
+ onSetActiveModal
32
+ ]);
33
+ return /*#__PURE__*/ jsx("div", {
34
+ className: "gp-popup-trigger-button gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
35
+ children: popups?.map((item)=>{
36
+ const display = item?.advanced?.d;
37
+ return /*#__PURE__*/ jsx("div", {
38
+ className: cls('gp-w-full gp-shrink gp-cursor-pointer gp-select-none gp-items-center gp-justify-center gp-whitespace-nowrap gp-py-2 gp-text-white [writing-mode:vertical-lr]', {
39
+ 'gp-bg-blue-500': activeModalId === item.uid,
40
+ 'gp-bg-blue-700': activeModalId !== item.uid
41
+ }, isInteractionMode ? 'gp-pointer-events-none' : 'gp-pointer-events-auto'),
42
+ role: "button",
43
+ "aria-hidden": "true",
44
+ onClick: ()=>setModalActive(item?.uid, true),
45
+ style: {
46
+ '--d': display?.desktop ? 'inline-flex' : 'none',
47
+ '--d-tablet': display?.tablet ? 'inline-flex' : 'none',
48
+ '--d-mobile': display?.mobile ? 'inline-flex' : 'none'
49
+ },
50
+ children: /*#__PURE__*/ jsx("span", {
51
+ className: "gp-text-ellipsis gp-whitespace-nowrap",
52
+ children: item?.settings?.name || 'Popup Name'
53
+ })
54
+ }, item?.uid);
55
+ })
56
+ });
57
+ };
58
+ var PopupManager$1 = /*#__PURE__*/ memo(PopupManager);
59
+
60
+ export { PopupManager$1 as default };
@@ -0,0 +1,181 @@
1
+ 'use client';
2
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
+ import { useState, useCallback, useEffect, useRef } from 'react';
4
+ import { devices } from './const.js';
5
+
6
+ const Devices = ()=>{
7
+ const [isOpen, setIsOpen] = useState(false);
8
+ const initialDeviceState = {
9
+ width: 0,
10
+ name: '',
11
+ activeId: null
12
+ };
13
+ const [deviceState, setDeviceState] = useState(initialDeviceState);
14
+ const [isShowSwitchView, setIsShowSwitchView] = useState(false);
15
+ const updateDeviceState = useCallback((updates)=>{
16
+ setDeviceState((prevState)=>({
17
+ ...prevState,
18
+ ...updates
19
+ }));
20
+ }, [
21
+ setDeviceState
22
+ ]);
23
+ useEffect(()=>{
24
+ if (!deviceState) {
25
+ const activeDevice = devices[0];
26
+ if (activeDevice) {
27
+ updateDeviceState({
28
+ width: activeDevice.width,
29
+ name: activeDevice.name,
30
+ activeId: activeDevice.id
31
+ });
32
+ }
33
+ setIsShowSwitchView(false);
34
+ } else {
35
+ setIsShowSwitchView(deviceState.width > 0 && deviceState.width <= 1024);
36
+ }
37
+ }, [
38
+ deviceState,
39
+ updateDeviceState
40
+ ]);
41
+ const onHandleClick = (id)=>{
42
+ const activeDevice = devices.find((v)=>v.id === id);
43
+ if (activeDevice) {
44
+ updateDeviceState({
45
+ width: activeDevice.width,
46
+ name: activeDevice.name,
47
+ activeId: activeDevice.id
48
+ });
49
+ emitChangeDevice(activeDevice.id);
50
+ }
51
+ setIsOpen(!isOpen);
52
+ };
53
+ const emitChangeDevice = (id)=>{
54
+ const event = new CustomEvent('editor:change-device', {
55
+ bubbles: true,
56
+ detail: {
57
+ id
58
+ }
59
+ });
60
+ window.dispatchEvent(event);
61
+ };
62
+ const switchViewRef = useRef(null);
63
+ const onClickOutside = (event)=>{
64
+ if (switchViewRef.current && !switchViewRef.current.contains(event.target)) {
65
+ setIsOpen(false);
66
+ }
67
+ };
68
+ const getDisplayName = (width)=>{
69
+ const activeDevice = devices.find((v)=>v.width === width);
70
+ if (activeDevice) return activeDevice.name;
71
+ let displayName = 'Desktop';
72
+ if (width <= 768) return displayName = 'Mobile';
73
+ if (width <= 1024) return displayName = 'Tablet';
74
+ return displayName;
75
+ };
76
+ const onResizePreviewScreen = useCallback((e)=>{
77
+ const detail = e.detail;
78
+ if (!detail) return;
79
+ updateDeviceState({
80
+ width: detail.width,
81
+ name: getDisplayName(detail.width),
82
+ activeId: null
83
+ });
84
+ }, [
85
+ updateDeviceState
86
+ ]);
87
+ useEffect(()=>{
88
+ window.addEventListener('mousedown', onClickOutside);
89
+ window.addEventListener('editor:resize-preview-screen', onResizePreviewScreen);
90
+ return ()=>{
91
+ window.removeEventListener('mousedown', onClickOutside);
92
+ window.removeEventListener('editor:resize-preview-screen', onResizePreviewScreen);
93
+ };
94
+ }, [
95
+ onResizePreviewScreen
96
+ ]);
97
+ const isActiveDevice = (device)=>{
98
+ return device.id === deviceState.activeId || deviceState.name === device.name;
99
+ };
100
+ const handleToggleDropdown = ()=>setIsOpen(!isOpen);
101
+ if (isShowSwitchView) return /*#__PURE__*/ jsx(Fragment, {
102
+ children: /*#__PURE__*/ jsxs("div", {
103
+ ref: switchViewRef,
104
+ className: `gp-switch-view gp-font-sans gp-flex gp-h-[40px] gp-absolute gp-top-[2px] gp-transform -gp-translate-x-1/2 gp-left-1/2 gp-gap-2 gp-items-center gp-justify-center gp-cursor-pointer ${isOpen ? 'gp-z-50' : 'gp-z-1'}`,
105
+ children: [
106
+ /*#__PURE__*/ jsxs("div", {
107
+ className: `gp-flex gp-gap-1 gp-py-1 gp-px-2 gp-transform -gp-translate-y-[2px] gp-border-[1px] gp-justify-between gp-items-center gp-min-w-[194px] gp-bg-[#F4F4F4] hover:gp-bg-[#E2E2E2] gp-rounded-md gp-leading-5 gp-text-xs gp-font-medium gp-text-[#212121] ${isOpen ? 'gp-border-[#3C67FF]' : 'gp-border-transparent'}`,
108
+ onClick: (e)=>{
109
+ e.preventDefault();
110
+ handleToggleDropdown();
111
+ },
112
+ role: "presentation",
113
+ children: [
114
+ /*#__PURE__*/ jsxs("span", {
115
+ children: [
116
+ deviceState.name,
117
+ " (",
118
+ deviceState.width,
119
+ "px)"
120
+ ]
121
+ }),
122
+ /*#__PURE__*/ jsx("span", {
123
+ children: /*#__PURE__*/ jsx("svg", {
124
+ width: "9",
125
+ height: "5",
126
+ viewBox: "0 0 9 5",
127
+ fill: "none",
128
+ xmlns: "http://www.w3.org/2000/svg",
129
+ children: /*#__PURE__*/ jsx("path", {
130
+ fillRule: "evenodd",
131
+ clipRule: "evenodd",
132
+ d: "M1.07564 0.775834C1.30995 0.541519 1.68985 0.541519 1.92417 0.775834L4.6999 3.55157L7.47564 0.775834C7.70995 0.541519 8.08985 0.541519 8.32417 0.775834C8.55848 1.01015 8.55848 1.39005 8.32417 1.62436L5.12417 4.82436C4.88985 5.05868 4.50995 5.05868 4.27564 4.82436L1.07564 1.62436C0.841324 1.39005 0.841324 1.01015 1.07564 0.775834Z",
133
+ fill: "#212121"
134
+ })
135
+ })
136
+ })
137
+ ]
138
+ }),
139
+ /*#__PURE__*/ jsx("div", {
140
+ className: `gp-absolute gp-top-9 gp-transform -gp-translate-x-1/2 gp-left-1/2 gp-bg-[#212121] gp-rounded-xl gp-p-2 gp-text-[#F9F9F9] gp-w-[176px] gp-z-50 ${!isOpen ? 'gp-hidden' : ''}`,
141
+ children: devices.map((device)=>/*#__PURE__*/ jsx("div", {
142
+ className: "gp-p-2 hover:gp-bg-[#3E3E3E] gp-rounded-md",
143
+ onClick: (e)=>{
144
+ e.preventDefault();
145
+ e.stopPropagation();
146
+ onHandleClick(device.id);
147
+ },
148
+ role: "presentation",
149
+ children: /*#__PURE__*/ jsxs("div", {
150
+ className: 'gp-flex gp-gap-2 gp-w-full gp-text-left gp-justify-space-between gp-cursor-pointer gp-leading-5 gp-text-xs gp-font-regular gp-text-[#212121]"',
151
+ children: [
152
+ /*#__PURE__*/ jsx("span", {
153
+ className: "gp-min-w-[16px]",
154
+ children: isActiveDevice(device) && /*#__PURE__*/ jsx("svg", {
155
+ width: "16",
156
+ height: "17",
157
+ viewBox: "0 0 16 17",
158
+ fill: "none",
159
+ xmlns: "http://www.w3.org/2000/svg",
160
+ children: /*#__PURE__*/ jsx("path", {
161
+ fillRule: "evenodd",
162
+ clipRule: "evenodd",
163
+ d: "M12.6348 4.89265C12.792 5.07861 12.7878 5.37537 12.6255 5.55547L6.71176 12.118C6.55312 12.294 6.30118 12.294 6.14255 12.118L3.87448 9.60098C3.71219 9.42088 3.70805 9.12412 3.86523 8.93815C4.02241 8.75219 4.2814 8.74744 4.4437 8.92755L6.42716 11.1287L12.0563 4.88203C12.2186 4.70192 12.4776 4.70668 12.6348 4.89265Z",
164
+ fill: "#00C853"
165
+ })
166
+ })
167
+ }),
168
+ /*#__PURE__*/ jsx("span", {
169
+ children: device.name
170
+ })
171
+ ]
172
+ })
173
+ }, device.id))
174
+ })
175
+ ]
176
+ })
177
+ });
178
+ return null;
179
+ };
180
+
181
+ export { Devices as default };