@gem-sdk/pages 1.53.0-dev.0 → 1.53.0-dev.139

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.
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+ var core = require('@gem-sdk/core');
8
+ var CollectionGlobalProvider = require('../../pages/CollectionGlobalProvider.js');
9
+
10
+ const Body = ({ pageType, isThemeSectionEditor })=>{
11
+ const interactionData = core.usePageStore((s)=>s.interactionData);
12
+ const isInteractionSelectModeClass = react.useMemo(()=>interactionData?.isSelectOnPage ? 'interaction-select-mode' : '', [
13
+ interactionData?.isSelectOnPage
14
+ ]);
15
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
16
+ id: "storefront",
17
+ className: `${isThemeSectionEditor ? 'theme-section-editor' : ''} ${pageType === 'POST_PURCHASE' ? 'post-purchase-page' : ''} ${isInteractionSelectModeClass}`,
18
+ children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
19
+ children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
20
+ uid: "ROOT"
21
+ })
22
+ }) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
23
+ uid: "ROOT"
24
+ })
25
+ });
26
+ };
27
+
28
+ exports.default = Body;
@@ -25,7 +25,6 @@ const Header = (props)=>{
25
25
  const isSelectOnPage = core.usePageStore((s)=>s.interactionData?.isSelectOnPage);
26
26
  const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
27
27
  const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
28
- console.log('isSelectOnPage', isSelectOnPage);
29
28
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
30
29
  children: [
31
30
  /*#__PURE__*/ jsxRuntime.jsx(SwitchView.default, {}),
@@ -4,62 +4,183 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var core = require('@gem-sdk/core');
7
+ var useSelectModeInteraction = require('../../libs/hooks/useSelectModeInteraction.js');
8
+ var react = require('react');
7
9
 
8
10
  const InteractionSelectOnPageHeader = ()=>{
9
11
  const selectType = core.usePageStore((s)=>s.interactionData?.selectType);
12
+ const settingType = core.usePageStore((s)=>s.interactionData?.settingType);
10
13
  const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
11
14
  const { closeSelectOnPage } = core.useInteraction();
15
+ const { changeSelectMode } = useSelectModeInteraction.useSelectModeInteraction();
16
+ const [hoverOption, setHoverOption] = react.useState(null);
17
+ const [openDropdown, setOpenDropdown] = react.useState(false);
18
+ const popupRef = react.useRef(null);
19
+ const handleSetInteraction = (type)=>{
20
+ setOpenDropdown(false);
21
+ setInteractionSelectType(type);
22
+ changeSelectMode(type);
23
+ if (type == 'PAGE') closeSelectOnPage();
24
+ };
25
+ const handleClickOutside = react.useCallback((event)=>{
26
+ if (!openDropdown) return;
27
+ if (popupRef.current && !popupRef.current.contains(event.target)) {
28
+ setOpenDropdown(false);
29
+ }
30
+ }, [
31
+ openDropdown
32
+ ]);
33
+ react.useEffect(()=>{
34
+ document.addEventListener('mousedown', handleClickOutside);
35
+ return ()=>{
36
+ document.removeEventListener('mousedown', handleClickOutside);
37
+ };
38
+ }, [
39
+ handleClickOutside
40
+ ]);
41
+ const isShowOverlay = react.useMemo(()=>{
42
+ return hoverOption !== 'ELEMENT' && (selectType === 'PAGE' || selectType === 'ELEMENT' && hoverOption === 'PAGE');
43
+ }, [
44
+ hoverOption,
45
+ selectType
46
+ ]);
47
+ const title = react.useMemo(()=>{
48
+ const type = selectType === 'ELEMENT' ? 'an element' : 'entire page';
49
+ if (settingType === 'TRIGGER') return `Start with triggering ${type}`;
50
+ return `Set ${selectType === 'ELEMENT' ? 'an element' : 'entire page'} as target`;
51
+ }, [
52
+ selectType,
53
+ settingType
54
+ ]);
55
+ const renderIconCheckSvg = ()=>{
56
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
57
+ className: "gp-w-[21px]",
58
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
59
+ width: "21",
60
+ height: "20",
61
+ viewBox: "0 0 21 20",
62
+ fill: "none",
63
+ xmlns: "http://www.w3.org/2000/svg",
64
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
65
+ "fill-rule": "evenodd",
66
+ "clip-rule": "evenodd",
67
+ d: "M16.3415 5.1766C16.5528 5.41207 16.5528 5.79383 16.3415 6.0293L8.45016 14.8234C8.34869 14.9365 8.21107 15 8.06757 15C7.92408 15 7.78645 14.9365 7.68499 14.8234L4.65846 11.4505C4.44717 11.215 4.44718 10.8333 4.65848 10.5978C4.86978 10.3623 5.21236 10.3623 5.42365 10.5978L8.06759 13.5443L15.5764 5.1766C15.7877 4.94113 16.1302 4.94113 16.3415 5.1766Z",
68
+ fill: "#00C853"
69
+ })
70
+ })
71
+ });
72
+ };
12
73
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
13
74
  children: [
14
- /*#__PURE__*/ jsxRuntime.jsxs("header", {
15
- className: "gp-flex gp-justify-between gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-100 gp-bg-black gp-text-white",
16
- children: [
17
- /*#__PURE__*/ jsxRuntime.jsx("div", {
18
- className: "gp-ml-4 gp-text-xs gp-mt-1",
19
- children: "Select mode enabled"
20
- }),
21
- /*#__PURE__*/ jsxRuntime.jsxs("section", {
22
- className: "gp-flex gp-bg-[#3C67FF]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-1",
23
- children: [
24
- /*#__PURE__*/ jsxRuntime.jsx("button", {
25
- "data-interaction-mode": "element",
26
- onClick: ()=>setInteractionSelectType('element'),
27
- className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'element' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
28
- style: {
29
- cursor: "url('https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-45eb24ff-a9ee-48ac-af8b-eac35e11918d.png?v=1724038301'), auto"
30
- },
31
- children: "Choose an element on page"
32
- }),
33
- /*#__PURE__*/ jsxRuntime.jsx("button", {
34
- "data-interaction-mode": "page",
35
- onClick: ()=>setInteractionSelectType('page'),
36
- className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'page' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
37
- style: {
38
- cursor: "url('https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-45eb24ff-a9ee-48ac-af8b-eac35e11918d.png?v=1724038301'), auto"
39
- },
40
- children: "Use entire page"
41
- })
42
- ]
43
- }),
44
- /*#__PURE__*/ jsxRuntime.jsx("button", {
45
- onClick: closeSelectOnPage,
46
- className: "gp-h-10 gp-w-10 gp-flex gp-items-center gp-justify-center gp-rounded-bl-lg",
47
- children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
48
- width: "12",
49
- height: "12",
50
- viewBox: "0 0 12 12",
51
- fill: "none",
52
- xmlns: "http://www.w3.org/2000/svg",
53
- children: /*#__PURE__*/ jsxRuntime.jsx("path", {
54
- d: "M9.96967 11.0303C10.2626 11.3232 10.7374 11.3232 11.0303 11.0303C11.3232 10.7374 11.3232 10.2626 11.0303 9.96967L7.06066 6L11.0303 2.03033C11.3232 1.73744 11.3232 1.26256 11.0303 0.96967C10.7374 0.676777 10.2626 0.676777 9.96967 0.96967L6 4.93934L2.03033 0.96967C1.73744 0.676777 1.26256 0.676777 0.96967 0.96967C0.676777 1.26256 0.676777 1.73744 0.96967 2.03033L4.93934 6L0.96967 9.96967C0.676777 10.2626 0.676777 10.7374 0.96967 11.0303C1.26256 11.3232 1.73744 11.3232 2.03033 11.0303L6 7.06066L9.96967 11.0303Z",
55
- fill: "#F9F9F9"
56
- })
75
+ /*#__PURE__*/ jsxRuntime.jsx("header", {
76
+ className: "gp-flex gp-text-[12px] gp-justify-center gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-[1000] gp-bg-[#151515] gp-text-white interaction-select-mode-header",
77
+ children: /*#__PURE__*/ jsxRuntime.jsxs("section", {
78
+ className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-2",
79
+ children: [
80
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
81
+ className: "gp-relative",
82
+ children: [
83
+ /*#__PURE__*/ jsxRuntime.jsxs("button", {
84
+ className: `gp-h-full gp-w-[280px] gp-gap-2 gp-py-2 gp-px-4 gp-items-center gp-justify-center gp-leading-5 gp-font-medium gp-flex gp-rounded-b-[8px] gp-bg-[#3C67FF] gp-text-[#F9F9F9]`,
85
+ onClick: ()=>setOpenDropdown((prev)=>!prev),
86
+ children: [
87
+ /*#__PURE__*/ jsxRuntime.jsx("p", {
88
+ className: "gp-grow",
89
+ children: title
90
+ }),
91
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
92
+ className: "gp-w-[21px]",
93
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
94
+ width: "16",
95
+ height: "16",
96
+ viewBox: "0 0 16 16",
97
+ fill: "currentColor",
98
+ xmlns: "http://www.w3.org/2000/svg",
99
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
100
+ "fill-rule": "evenodd",
101
+ "clip-rule": "evenodd",
102
+ d: "M4.13017 6.11716C4.30374 5.96095 4.58515 5.96095 4.75871 6.11716L8 9.03431L11.2413 6.11716C11.4149 5.96095 11.6963 5.96095 11.8698 6.11716C12.0434 6.27337 12.0434 6.52663 11.8698 6.68284L8.31427 9.88284C8.1407 10.0391 7.8593 10.0391 7.68573 9.88284L4.13017 6.68284C3.95661 6.52663 3.95661 6.27337 4.13017 6.11716Z",
103
+ fill: "currentColor"
104
+ })
105
+ })
106
+ })
107
+ ]
108
+ }),
109
+ openDropdown && /*#__PURE__*/ jsxRuntime.jsxs("div", {
110
+ ref: popupRef,
111
+ className: "gp-p-2 gp-flex gp-flex-col gp-absolute gp-top-[calc(100%_+_4px)] gp-w-[280px] gp-bg-[#151515] gp-rounded-xl gp-text-white",
112
+ children: [
113
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
114
+ className: "gp-p-2 gp-flex gp-gap-2 gp-cursor-pointer hover:gp-bg-[#3b3b3b] gp-rounded-lg",
115
+ "aria-hidden": true,
116
+ onClick: ()=>handleSetInteraction('ELEMENT'),
117
+ onMouseOver: ()=>setHoverOption('ELEMENT'),
118
+ onFocus: ()=>setHoverOption('ELEMENT'),
119
+ onMouseLeave: ()=>setHoverOption(null),
120
+ children: [
121
+ selectType === 'ELEMENT' ? renderIconCheckSvg() : /*#__PURE__*/ jsxRuntime.jsx("div", {
122
+ className: "gp-w-[21px]",
123
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
124
+ width: "18",
125
+ height: "18",
126
+ viewBox: "0 0 18 18",
127
+ fill: "none",
128
+ xmlns: "http://www.w3.org/2000/svg",
129
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
130
+ "fill-rule": "evenodd",
131
+ "clip-rule": "evenodd",
132
+ d: "M8.99983 0.351562C9.34501 0.351562 9.62483 0.631385 9.62483 0.976562V2.15278C12.923 2.45 15.5496 5.07654 15.8468 8.37476H17.0233C17.3684 8.37476 17.6483 8.65458 17.6483 8.99976C17.6483 9.34493 17.3684 9.62476 17.0233 9.62476H15.8468C15.5496 12.923 12.923 15.5495 9.62483 15.8467V17.0232C9.62483 17.3683 9.34501 17.6482 8.99983 17.6482C8.65465 17.6482 8.37483 17.3683 8.37483 17.0232V15.8467C5.07662 15.5495 2.45007 12.923 2.15286 9.62476H0.976562C0.631385 9.62476 0.351562 9.34493 0.351562 8.99976C0.351562 8.65458 0.631385 8.37476 0.976562 8.37476H2.15286C2.45007 5.07654 5.07662 2.45 8.37483 2.15278V0.976562C8.37483 0.631385 8.65465 0.351562 8.99983 0.351562ZM3.40916 9.62476H5.97656C6.32174 9.62476 6.60156 9.34493 6.60156 8.99976C6.60156 8.65458 6.32174 8.37476 5.97656 8.37476H3.40916C3.69738 5.7675 5.76757 3.6973 8.37483 3.40909V5.97656C8.37483 6.32174 8.65465 6.60156 8.99983 6.60156C9.34501 6.60156 9.62483 6.32174 9.62483 5.97656V3.40909C12.2321 3.6973 14.3023 5.7675 14.5905 8.37476H12.0233C11.6781 8.37476 11.3983 8.65458 11.3983 8.99976C11.3983 9.34493 11.6781 9.62476 12.0233 9.62476H14.5905C14.3023 12.232 12.2321 14.3022 9.62483 14.5904V12.0232C9.62483 11.678 9.34501 11.3982 8.99983 11.3982C8.65465 11.3982 8.37483 11.678 8.37483 12.0232V14.5904C5.76757 14.3022 3.69738 12.232 3.40916 9.62476Z",
133
+ fill: "#AAAAAA"
134
+ })
135
+ })
136
+ }),
137
+ /*#__PURE__*/ jsxRuntime.jsx("p", {
138
+ className: "gp-h-[21px]",
139
+ children: "An element"
140
+ })
141
+ ]
142
+ }),
143
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
144
+ className: "gp-p-2 gp-flex gp-gap-2 gp-cursor-pointer hover:gp-bg-[#3b3b3b] gp-rounded-lg",
145
+ onClick: ()=>handleSetInteraction('PAGE'),
146
+ onMouseOver: ()=>setHoverOption('PAGE'),
147
+ onFocus: ()=>setHoverOption('PAGE'),
148
+ onMouseLeave: ()=>setHoverOption(null),
149
+ "aria-hidden": true,
150
+ children: [
151
+ selectType === 'PAGE' ? renderIconCheckSvg() : /*#__PURE__*/ jsxRuntime.jsx("svg", {
152
+ width: "21",
153
+ height: "20",
154
+ viewBox: "0 0 21 20",
155
+ fill: "none",
156
+ xmlns: "http://www.w3.org/2000/svg",
157
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
158
+ "fill-rule": "evenodd",
159
+ "clip-rule": "evenodd",
160
+ d: "M7.25 4.5C6.55964 4.5 6 5.05964 6 5.75V14.25C6 14.9404 6.55964 15.5 7.25 15.5H13.75C14.4404 15.5 15 14.9404 15 14.25V9.5H11.75C10.7835 9.5 10 8.7165 10 7.75V4.5H7.25ZM11.5 5.56066L13.9393 8H11.75C11.6119 8 11.5 7.88807 11.5 7.75V5.56066ZM4.5 5.75C4.5 4.23122 5.73122 3 7.25 3H10.75C10.9489 3 11.1397 3.07902 11.2803 3.21967L16.2803 8.21967C16.421 8.36032 16.5 8.55109 16.5 8.75V14.25C16.5 15.7688 15.2688 17 13.75 17H7.25C5.73122 17 4.5 15.7688 4.5 14.25V5.75Z",
161
+ fill: "#AAAAAA"
162
+ })
163
+ }),
164
+ /*#__PURE__*/ jsxRuntime.jsx("p", {
165
+ className: "gp-h-[21px]",
166
+ children: "Entire page"
167
+ })
168
+ ]
169
+ })
170
+ ]
171
+ })
172
+ ]
173
+ }),
174
+ /*#__PURE__*/ jsxRuntime.jsx("button", {
175
+ className: "",
176
+ onClick: closeSelectOnPage,
177
+ children: "Cancel"
57
178
  })
58
- })
59
- ]
179
+ ]
180
+ })
60
181
  }),
61
182
  /*#__PURE__*/ jsxRuntime.jsx("div", {
62
- className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-border-[#3C67FF] gp-border-[4px] gp-mt-[40px] ${selectType === 'page' ? 'gp-z-90 gp-bg-[#3c67ff]/[0.25]' : ''}`,
183
+ className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] ${isShowOverlay ? 'gp-z-[999] gp-bg-[#3c67ff]/[0.25]' : 'gp-pointer-events-none'}`,
63
184
  style: {
64
185
  height: 'calc(100% - 40px)'
65
186
  }
@@ -33,7 +33,7 @@ const PopupManager = ()=>{
33
33
  onSetActiveModal
34
34
  ]);
35
35
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
36
- 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",
36
+ 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",
37
37
  children: popups?.map((item)=>{
38
38
  const display = item?.advanced?.d;
39
39
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -10,6 +10,8 @@ var googleFonts = require('../../libs/google-fonts.js');
10
10
  var genCss = require('../../libs/helpers/gen-css.js');
11
11
  var genFonts = require('../../libs/helpers/gen-fonts.js');
12
12
  var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
13
+ var libsStore = require('../../store/libs-store.js');
14
+ var checkOptionFont = require('../../libs/helpers/check-option-font.js');
13
15
 
14
16
  const globalStyleId = 'global-style';
15
17
  const Toolbox = ()=>{
@@ -35,10 +37,13 @@ const Toolbox = ()=>{
35
37
  const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
36
38
  const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
37
39
  const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
40
+ const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
41
+ const fontType = libsStore.libsStore((s)=>s.fontType);
38
42
  const clearModal = core.useModalStore((s)=>s.clearModal);
39
43
  const setInteractionIsSelectOnPage = core.usePageStore((s)=>s.setInteractionIsSelectOnPage);
40
44
  const setInteractionItem = core.usePageStore((s)=>s.setInteractionItem);
41
45
  const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
46
+ const setInteractionSettingType = core.usePageStore((s)=>s.setInteractionSettingType);
42
47
  const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
43
48
  state
44
49
  ]);
@@ -67,6 +72,12 @@ const Toolbox = ()=>{
67
72
  });
68
73
  // append new fonts
69
74
  for (const font of fonts){
75
+ if ([
76
+ 'bunny',
77
+ 'google'
78
+ ].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType)) {
79
+ return;
80
+ }
70
81
  if (font.type !== 'custom') {
71
82
  if (font.variants?.length) {
72
83
  for (const variant of font.variants){
@@ -78,7 +89,7 @@ const Toolbox = ()=>{
78
89
  const variantName = variant;
79
90
  const url = googleFonts.createFontUrl([
80
91
  cloneFont
81
- ]);
92
+ ], undefined, fontType);
82
93
  if (url) {
83
94
  const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
84
95
  if (googleFont) {
@@ -281,6 +292,13 @@ const Toolbox = ()=>{
281
292
  }, [
282
293
  changeShopPlan
283
294
  ]);
295
+ const onUpdateFontType = react.useCallback((e)=>{
296
+ const fontType = e.detail;
297
+ if (!fontType) return;
298
+ changeFontType(fontType);
299
+ }, [
300
+ changeFontType
301
+ ]);
284
302
  const onUpdateDynamicProduct = react.useCallback((e)=>{
285
303
  const product = e.detail;
286
304
  if (!product) return;
@@ -335,11 +353,20 @@ const Toolbox = ()=>{
335
353
  const onUpdateInteractionIsSelectOnPage = react.useCallback((e)=>{
336
354
  const isSelectOnPage = e.detail.value;
337
355
  const mode = e.detail.mode;
356
+ const settingType = e.detail.settingType;
338
357
  setInteractionIsSelectOnPage(isSelectOnPage);
339
358
  setInteractionSelectType(mode);
359
+ setInteractionSettingType(settingType);
340
360
  }, [
341
361
  setInteractionIsSelectOnPage,
342
- setInteractionSelectType
362
+ setInteractionSelectType,
363
+ setInteractionSettingType
364
+ ]);
365
+ const onUpdateInteractionSettingType = react.useCallback((e)=>{
366
+ const settingType = e.detail.settingType;
367
+ setInteractionSettingType(settingType);
368
+ }, [
369
+ setInteractionSettingType
343
370
  ]);
344
371
  const onUpdateInteractionItem = react.useCallback((e)=>{
345
372
  const interactionItem = e.detail;
@@ -376,6 +403,8 @@ const Toolbox = ()=>{
376
403
  window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
377
404
  window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
378
405
  window.addEventListener('update-interaction-item', onUpdateInteractionItem);
406
+ window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
407
+ window.addEventListener('update-font-type', onUpdateFontType);
379
408
  return ()=>{
380
409
  window.removeEventListener('update-shop-info', onChangeShopInfo);
381
410
  window.removeEventListener('revalidate-query', onRevalidateQuery);
@@ -397,6 +426,8 @@ const Toolbox = ()=>{
397
426
  window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
398
427
  window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
399
428
  window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
429
+ window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
430
+ window.removeEventListener('update-font-type', onUpdateFontType);
400
431
  };
401
432
  }, [
402
433
  onAddEntity,
@@ -419,7 +450,9 @@ const Toolbox = ()=>{
419
450
  onUpdateProductOffers,
420
451
  onUpdateSalePageProductId,
421
452
  onUpdateInteractionItem,
422
- onUpdateInteractionIsSelectOnPage
453
+ onUpdateInteractionIsSelectOnPage,
454
+ onUpdateInteractionSettingType,
455
+ onUpdateFontType
423
456
  ]);
424
457
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
425
458
  className: "toolbox"
@@ -18,7 +18,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
18
18
  slug,
19
19
  slugType: pageType
20
20
  };
21
- const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
21
+ const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
22
22
  fetcher([
23
23
  core.PublishedThemePagesDocument,
24
24
  variables
@@ -28,11 +28,21 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
28
28
  ]),
29
29
  shopifyFetcher([
30
30
  adapterShopify.ShopMetaDocument
31
+ ]),
32
+ fetcher([
33
+ core.PublishedShopMetasDocument,
34
+ {
35
+ keys: [
36
+ 'source_font'
37
+ ]
38
+ }
31
39
  ])
32
40
  ]);
33
41
  if (theme.status === 'rejected') {
34
42
  throw new Error(theme.reason?.[0]);
35
43
  }
44
+ const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
45
+ const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
36
46
  const dataBuilder = theme.value.publishedThemePages?.[0];
37
47
  const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
38
48
  if (!dataBuilder) {
@@ -40,8 +50,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
40
50
  }
41
51
  const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
42
52
  const [elementFontStyle, fontStyle, fallback, customFonts$1] = await Promise.all([
43
- googleFonts.getFontStyleFromPageTemplate(pageTemplate),
44
- googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
53
+ googleFonts.getFontStyleFromPageTemplate(pageTemplate, sourceFont?.value),
54
+ googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data, sourceFont?.value),
45
55
  getFallback.getFallbackV2(fetcher, pageTemplate),
46
56
  customFonts.getCustomFonts(themePageCustomFonts)
47
57
  ]);
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var checkOptionFont = require('./helpers/check-option-font.js');
3
4
  var genFonts = require('./helpers/gen-fonts.js');
4
5
 
5
6
  const CHROME_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36';
@@ -35,12 +36,17 @@ const composeFonts = (fonts)=>{
35
36
  };
36
37
  });
37
38
  };
38
- const createFontUrl = (fonts, option)=>{
39
- const googleFonts = fonts.filter((font)=>font.type === 'google' || !font.type);
40
- if (!googleFonts.length) return;
39
+ const createFontUrl = (fonts, option, fontType)=>{
40
+ const mainFonts = fonts.filter((font)=>{
41
+ return !([
42
+ 'bunny',
43
+ 'google'
44
+ ].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType || 'google')) && (font.type === 'google' || font.type === 'bunny' || !font.type);
45
+ });
46
+ if (!mainFonts.length) return;
41
47
  const params = new URLSearchParams();
42
48
  const display = option?.display || 'swap';
43
- const uniqFonts = googleFonts.filter((font, index, arr)=>{
49
+ const uniqFonts = mainFonts.filter((font, index, arr)=>{
44
50
  return index === arr.findIndex((t)=>t.family === font.family);
45
51
  });
46
52
  const family = composeFonts(uniqFonts).map((font)=>{
@@ -54,13 +60,16 @@ const createFontUrl = (fonts, option)=>{
54
60
  if (option?.effect) {
55
61
  params.append('effect', option.effect);
56
62
  }
57
- return `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
63
+ const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
64
+ const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
65
+ return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
58
66
  };
59
- async function getFonts(fonts, option, isImportFontByUrl = true) {
67
+ // eslint-disable-next-line max-params
68
+ async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
60
69
  /**
61
70
  * The order of IE -> Chrome is important, other wise chrome starts loading woff1.
62
71
  * CSS cascading 🤷‍♂️.
63
- */ const url = createFontUrl(fonts, option);
72
+ */ const url = createFontUrl(fonts, option, fontType);
64
73
  if (!url) return '';
65
74
  try {
66
75
  if (isImportFontByUrl) return `@import url('${url}');`;
@@ -82,7 +91,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true) {
82
91
  return '';
83
92
  }
84
93
  }
85
- const getFontFromGlobalStyle = (data)=>{
94
+ const getFontFromGlobalStyle = (data, sourceFont)=>{
86
95
  if (!data) return '';
87
96
  try {
88
97
  const globalStyle = JSON.parse(data);
@@ -90,14 +99,14 @@ const getFontFromGlobalStyle = (data)=>{
90
99
  const fonts = Object.entries(fontData).map(([, value])=>{
91
100
  return value;
92
101
  });
93
- return getFonts(fonts);
102
+ return getFonts(fonts, undefined, undefined, sourceFont);
94
103
  } catch {
95
104
  return '';
96
105
  }
97
106
  };
98
- async function getFontStyleFromPageTemplate(pageTemplate) {
107
+ async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
99
108
  const fontStyle = pageTemplate.map((sectionData)=>{
100
- return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data));
109
+ return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
101
110
  });
102
111
  return await Promise.all(fontStyle);
103
112
  }
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ const listFontsNotInBunny = [
4
+ 'Anton SC',
5
+ 'Arsenal SC',
6
+ 'Baskervville SC',
7
+ 'Beiruti',
8
+ 'Bodoni Moda SC',
9
+ 'Bona Nova SC',
10
+ 'Bungee Tint',
11
+ 'Edu AU VIC WA NT Hand',
12
+ 'Fustat',
13
+ 'Ga Maamli',
14
+ 'Kalnia Glaze',
15
+ 'Maname',
16
+ 'Matemasie',
17
+ 'Material Icons',
18
+ 'Material Icons Outlined',
19
+ 'Material Icons Round',
20
+ 'Material Icons Sharp',
21
+ 'Material Icons Two Tone',
22
+ 'Material Symbols Outlined',
23
+ 'Material Symbols Rounded',
24
+ 'Material Symbols Sharp',
25
+ 'Moderustic',
26
+ 'New Amsterdam',
27
+ 'Playwrite AR',
28
+ 'Playwrite AT',
29
+ 'Playwrite BE VLG',
30
+ 'Playwrite BE WAL',
31
+ 'Playwrite CL',
32
+ 'Playwrite CU',
33
+ 'Playwrite CZ',
34
+ 'Playwrite DK Loopet',
35
+ 'Playwrite DK Uloopet',
36
+ 'Playwrite HR',
37
+ 'Playwrite HR Lijeva',
38
+ 'Playwrite HU',
39
+ 'Playwrite PE',
40
+ 'SUSE',
41
+ 'Sankofa Display',
42
+ 'Wittgenstein',
43
+ 'Zain'
44
+ ];
45
+ const listFontsNotInGoogle = [
46
+ 'Arima Madurai',
47
+ 'Coda Caption',
48
+ 'Fredoka One',
49
+ 'Gentium Book Basic',
50
+ 'Kantumruy',
51
+ 'Merienda One',
52
+ 'Source Sans Pro',
53
+ 'Source Serif Pro',
54
+ 'Briem Hand',
55
+ 'Pushster'
56
+ ];
57
+ const objectFont = {
58
+ bunny: listFontsNotInBunny,
59
+ google: listFontsNotInGoogle
60
+ };
61
+ const checkNotInOptionFont = (currentfont, type)=>{
62
+ return objectFont?.[type]?.includes(currentfont);
63
+ };
64
+
65
+ exports.checkNotInOptionFont = checkNotInOptionFont;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const useSelectModeInteraction = ()=>{
4
+ const changeSelectMode = (mode)=>{
5
+ const event = new CustomEvent('editor:interaction:change-select-mode', {
6
+ bubbles: true,
7
+ detail: mode
8
+ });
9
+ window.dispatchEvent(event);
10
+ };
11
+ return {
12
+ changeSelectMode
13
+ };
14
+ };
15
+
16
+ exports.useSelectModeInteraction = useSelectModeInteraction;
@@ -8,12 +8,12 @@ var react = require('react');
8
8
  var Toolbox = require('../components/builder/Toolbox.js');
9
9
  var Header = require('../components/builder/Header.js');
10
10
  var Footer = require('../components/builder/Footer.js');
11
- var CollectionGlobalProvider = require('./CollectionGlobalProvider.js');
12
11
  var PopupManager = require('../components/builder/PopupManager.js');
13
12
  var ImageToLayout = require('../components/image-to-layout/ImageToLayout.js');
14
13
  var AddSectionImageToLayout = require('../components/image-to-layout/AddSectionImageToLayout.js');
15
14
  var Toolbar = require('../components/builder/Toolbar.js');
16
15
  var SwitchView = require('../components/builder/SwitchView.js');
16
+ var Body = require('../components/builder/Body.js');
17
17
 
18
18
  const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, pageType, editorImageToLayout, isThemeSectionEditor, hiddenToolbar, pageName, isOriginTemplate })=>{
19
19
  const [loadSuccess, setLoadSuccess] = react.useState(false);
@@ -77,16 +77,9 @@ const BuilderPage = ({ components, seo, themeStyle, fontStyle, sectionData, page
77
77
  pageType: pageType,
78
78
  isOriginTemplate: isOriginTemplate
79
79
  })),
80
- /*#__PURE__*/ jsxRuntime.jsx("div", {
81
- id: "storefront",
82
- className: `${isThemeSectionEditor ? 'theme-section-editor' : ''} ${pageType === 'POST_PURCHASE' ? 'post-purchase-page' : ''}`,
83
- children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
84
- children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
85
- uid: "ROOT"
86
- })
87
- }) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
88
- uid: "ROOT"
89
- })
80
+ /*#__PURE__*/ jsxRuntime.jsx(Body.default, {
81
+ pageType: pageType,
82
+ isThemeSectionEditor: isThemeSectionEditor
90
83
  }),
91
84
  /*#__PURE__*/ jsxRuntime.jsx(ImageToLayout.default, {
92
85
  editorImageToLayout: editorImageToLayout || false
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var zustand = require('zustand');
4
+
5
+ const libsStore = zustand.create((set)=>({
6
+ fontType: 'google',
7
+ changeFontType: (fontType)=>{
8
+ set({
9
+ fontType
10
+ });
11
+ }
12
+ }));
13
+
14
+ exports.libsStore = libsStore;