@gem-sdk/pages 2.0.0-dev.890 → 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.
- package/dist/cjs/components/ErrorBoundary.js +41 -1
- package/dist/cjs/components/ErrorFallback.js +27 -1
- package/dist/cjs/components/FacebookPixel.js +34 -3
- package/dist/cjs/components/FooterForPostPurchase.js +35 -1
- package/dist/cjs/components/GoogleAnalytic.js +66 -5
- package/dist/cjs/components/TikTokPixel.js +20 -3
- package/dist/cjs/components/builder/Body.js +37 -0
- package/dist/cjs/components/builder/Footer.js +155 -0
- package/dist/cjs/components/builder/Header.js +188 -0
- package/dist/cjs/components/builder/PopupManager.js +64 -1
- package/dist/cjs/components/builder/SwitchView.js +185 -0
- package/dist/cjs/components/builder/Toolbar.js +701 -1
- package/dist/cjs/components/builder/Toolbox.js +485 -1
- package/dist/cjs/components/builder/const.js +56 -0
- package/dist/cjs/components/builder/toolbar/const.js +7 -0
- package/dist/cjs/components/builder/toolbar/utils/findDOMClosest.js +41 -0
- package/dist/cjs/components/builder/toolbar/utils/findOverflowParent.js +20 -0
- package/dist/cjs/components/builder/toolbar/utils/getChildrenByAttrSelector.js +18 -0
- package/dist/cjs/components/builder/toolbar/utils/getDOMElementParents.js +32 -0
- package/dist/cjs/components/builder/toolbar/utils/isOverParent.js +16 -0
- package/dist/cjs/components/builder/toolbar/utils/isOverToolbarPosition.js +12 -0
- package/dist/cjs/components/builder/toolbar/utils/isSection.js +8 -0
- package/dist/cjs/components/builder/toolbar/utils/notVisible.js +8 -0
- package/dist/cjs/components/builder/toolbar/utils/waitForElementToExist.js +27 -0
- package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +151 -1
- package/dist/cjs/components/image-to-layout/DropElement.js +167 -1
- package/dist/cjs/components/image-to-layout/ImageToLayout.js +42 -1
- package/dist/cjs/index.js +80 -1
- package/dist/cjs/layouts/main.js +31 -1
- package/dist/cjs/libs/api/get-builder-props.js +46 -1
- package/dist/cjs/libs/api/get-collection-props.js +68 -1
- package/dist/cjs/libs/api/get-home-page-props-v2.js +145 -1
- package/dist/cjs/libs/api/get-home-page-props.js +151 -1
- package/dist/cjs/libs/api/get-post-purchase-props-preview.js +268 -1
- package/dist/cjs/libs/api/get-preview-props.js +18 -1
- package/dist/cjs/libs/api/get-product-props.js +73 -1
- package/dist/cjs/libs/api/get-static-page-props-preview.js +155 -1
- package/dist/cjs/libs/api/get-static-page-props-v2.js +164 -1
- package/dist/cjs/libs/api/get-static-page-props.js +148 -1
- package/dist/cjs/libs/custom-fonts.js +60 -6
- package/dist/cjs/libs/fetcher.js +100 -1
- package/dist/cjs/libs/get-layout.js +13 -1
- package/dist/cjs/libs/get-storefront-api.js +12 -1
- package/dist/cjs/libs/getStaticPaths.js +10 -1
- package/dist/cjs/libs/google-fonts.js +118 -1
- package/dist/cjs/libs/helpers/check-option-font.js +65 -0
- package/dist/cjs/libs/helpers/common.js +27 -1
- package/dist/cjs/libs/helpers/gen-css.js +135 -1
- package/dist/cjs/libs/helpers/gen-fonts.js +90 -1
- package/dist/cjs/libs/helpers/generate-manifres.js +5 -1
- package/dist/cjs/libs/helpers/get-fallback.js +34 -1
- package/dist/cjs/libs/helpers/normalize.js +111 -1
- package/dist/cjs/libs/helpers/parse-json.js +16 -1
- package/dist/cjs/libs/helpers/user-agent.js +7 -1
- package/dist/cjs/libs/hooks/use-tracking-view.js +43 -1
- package/dist/cjs/libs/hooks/usePagePreview.js +92 -1
- package/dist/cjs/libs/parse-html.js +34 -1
- package/dist/cjs/libs/shopify-cdn-with-google-fonts.js +1845 -1
- package/dist/cjs/pages/404.js +43 -1
- package/dist/cjs/pages/500.js +74 -1
- package/dist/cjs/pages/CollectionGlobalProvider.js +59 -1
- package/dist/cjs/pages/builder.js +115 -1
- package/dist/cjs/pages/collection-detail.js +64 -1
- package/dist/cjs/pages/preview.js +26 -1
- package/dist/cjs/pages/product-detail.js +69 -1
- package/dist/cjs/pages/static-v2.js +139 -1
- package/dist/cjs/pages/static.js +75 -1
- package/dist/cjs/store/libs-store.js +14 -0
- package/dist/esm/components/ErrorBoundary.js +39 -1
- package/dist/esm/components/ErrorFallback.js +25 -1
- package/dist/esm/components/FacebookPixel.js +32 -3
- package/dist/esm/components/FooterForPostPurchase.js +31 -1
- package/dist/esm/components/GoogleAnalytic.js +64 -5
- package/dist/esm/components/TikTokPixel.js +18 -3
- package/dist/esm/components/builder/Body.js +33 -0
- package/dist/esm/components/builder/Footer.js +151 -0
- package/dist/esm/components/builder/Header.js +184 -0
- package/dist/esm/components/builder/PopupManager.js +60 -1
- package/dist/esm/components/builder/SwitchView.js +181 -0
- package/dist/esm/components/builder/Toolbar.js +697 -1
- package/dist/esm/components/builder/Toolbox.js +481 -1
- package/dist/esm/components/builder/const.js +54 -0
- package/dist/esm/components/builder/toolbar/const.js +4 -0
- package/dist/esm/components/builder/toolbar/utils/findDOMClosest.js +39 -0
- package/dist/esm/components/builder/toolbar/utils/findOverflowParent.js +18 -0
- package/dist/esm/components/builder/toolbar/utils/getChildrenByAttrSelector.js +16 -0
- package/dist/esm/components/builder/toolbar/utils/getDOMElementParents.js +30 -0
- package/dist/esm/components/builder/toolbar/utils/isOverParent.js +14 -0
- package/dist/esm/components/builder/toolbar/utils/isOverToolbarPosition.js +10 -0
- package/dist/esm/components/builder/toolbar/utils/isSection.js +6 -0
- package/dist/esm/components/builder/toolbar/utils/notVisible.js +6 -0
- package/dist/esm/components/builder/toolbar/utils/waitForElementToExist.js +25 -0
- package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +147 -1
- package/dist/esm/components/image-to-layout/DropElement.js +165 -1
- package/dist/esm/components/image-to-layout/ImageToLayout.js +38 -1
- package/dist/esm/index.js +35 -1
- package/dist/esm/layouts/main.js +27 -1
- package/dist/esm/libs/api/get-builder-props.js +44 -1
- package/dist/esm/libs/api/get-collection-props.js +66 -1
- package/dist/esm/libs/api/get-home-page-props-v2.js +143 -1
- package/dist/esm/libs/api/get-home-page-props.js +149 -1
- package/dist/esm/libs/api/get-post-purchase-props-preview.js +260 -1
- package/dist/esm/libs/api/get-preview-props.js +16 -1
- package/dist/esm/libs/api/get-product-props.js +71 -1
- package/dist/esm/libs/api/get-static-page-props-preview.js +153 -1
- package/dist/esm/libs/api/get-static-page-props-v2.js +162 -1
- package/dist/esm/libs/api/get-static-page-props.js +146 -1
- package/dist/esm/libs/custom-fonts.js +55 -6
- package/dist/esm/libs/fetcher.js +96 -1
- package/dist/esm/libs/get-layout.js +11 -1
- package/dist/esm/libs/get-storefront-api.js +10 -1
- package/dist/esm/libs/getStaticPaths.js +8 -1
- package/dist/esm/libs/google-fonts.js +112 -1
- package/dist/esm/libs/helpers/check-option-font.js +63 -0
- package/dist/esm/libs/helpers/common.js +24 -1
- package/dist/esm/libs/helpers/gen-css.js +133 -1
- package/dist/esm/libs/helpers/gen-fonts.js +87 -1
- package/dist/esm/libs/helpers/generate-manifres.js +3 -1
- package/dist/esm/libs/helpers/get-fallback.js +32 -1
- package/dist/esm/libs/helpers/normalize.js +103 -1
- package/dist/esm/libs/helpers/parse-json.js +13 -1
- package/dist/esm/libs/helpers/user-agent.js +5 -1
- package/dist/esm/libs/hooks/use-tracking-view.js +41 -1
- package/dist/esm/libs/hooks/usePagePreview.js +90 -1
- package/dist/esm/libs/parse-html.js +32 -1
- package/dist/esm/libs/shopify-cdn-with-google-fonts.js +1843 -1
- package/dist/esm/pages/404.js +41 -1
- package/dist/esm/pages/500.js +72 -1
- package/dist/esm/pages/CollectionGlobalProvider.js +55 -1
- package/dist/esm/pages/builder.js +113 -1
- package/dist/esm/pages/collection-detail.js +60 -1
- package/dist/esm/pages/preview.js +24 -1
- package/dist/esm/pages/product-detail.js +65 -1
- package/dist/esm/pages/static-v2.js +137 -1
- package/dist/esm/pages/static.js +71 -1
- package/dist/esm/store/libs-store.js +12 -0
- package/dist/types/index.d.ts +50 -34
- package/package.json +8 -5
- package/dist/cjs/components/Footer.js +0 -1
- package/dist/cjs/components/Header.js +0 -1
- package/dist/cjs/components/builder/toolbar/Onboarding.js +0 -1
- package/dist/esm/components/Footer.js +0 -1
- package/dist/esm/components/Header.js +0 -1
- package/dist/esm/components/builder/toolbar/Onboarding.js +0 -1
|
@@ -1 +1,485 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var core = require('@gem-sdk/core');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var getStorefrontApi = require('../../libs/get-storefront-api.js');
|
|
10
|
+
var googleFonts = require('../../libs/google-fonts.js');
|
|
11
|
+
var genCss = require('../../libs/helpers/gen-css.js');
|
|
12
|
+
var genFonts = require('../../libs/helpers/gen-fonts.js');
|
|
13
|
+
var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
|
|
14
|
+
var libsStore = require('../../store/libs-store.js');
|
|
15
|
+
var checkOptionFont = require('../../libs/helpers/check-option-font.js');
|
|
16
|
+
|
|
17
|
+
const globalStyleId = 'global-style';
|
|
18
|
+
const Toolbox = ()=>{
|
|
19
|
+
const matchMutate = core.useMatchMutate();
|
|
20
|
+
const provider = core.useShopStore((s)=>s.provider);
|
|
21
|
+
const changeStorefrontInfo = core.useShopStore((s)=>s.changeStorefrontInfo);
|
|
22
|
+
const setDynamicProduct = core.usePageStore((s)=>s.setDynamicProduct);
|
|
23
|
+
const setPostPurchaseProductOffers = core.usePageStore((s)=>s.setPostPurchaseProductOffers);
|
|
24
|
+
const setSalePageProductId = core.usePageStore((s)=>s.setSalePageProductId);
|
|
25
|
+
const setDynamicCollection = core.usePageStore((s)=>s.setDynamicCollection);
|
|
26
|
+
const initState = core.useBuilderPreviewStore((s)=>s.initState);
|
|
27
|
+
const state = core.useBuilderPreviewStore((s)=>s.state);
|
|
28
|
+
const initNormalizeState = core.useBuilderPreviewStore((s)=>s.forceChangeState);
|
|
29
|
+
const forceChangeItemProp = core.useBuilderPreviewStore((s)=>s.forceChangeItemProp);
|
|
30
|
+
const changeItemPropByKey = core.useBuilderPreviewStore((s)=>s.changeItemPropByKey);
|
|
31
|
+
const addItem = core.useBuilderPreviewStore((s)=>s.addItem);
|
|
32
|
+
const moveItem = core.useBuilderPreviewStore((s)=>s.moveItem);
|
|
33
|
+
const removeItem = core.useBuilderPreviewStore((s)=>s.removeItem);
|
|
34
|
+
const addSection = core.useSectionStore((s)=>s.addSection);
|
|
35
|
+
const changeSwatches = core.useShopStore((s)=>s.changeSwatches);
|
|
36
|
+
const updateItemName = core.useBuilderPreviewStore((s)=>s.updateItemName);
|
|
37
|
+
const updateItemAttribute = core.useBuilderPreviewStore((s)=>s.updateItemAttribute);
|
|
38
|
+
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
39
|
+
const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
40
|
+
const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
|
|
41
|
+
const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
|
|
42
|
+
const fontType = libsStore.libsStore((s)=>s.fontType);
|
|
43
|
+
const clearModal = core.useModalStore((s)=>s.clearModal);
|
|
44
|
+
const changeLimitCreateThemeSection = core.useShopStore((s)=>s.changeLimitCreateThemeSection);
|
|
45
|
+
const setInteractionIsSelectOnPage = core.usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
46
|
+
const setInteractionItem = core.usePageStore((s)=>s.setInteractionItem);
|
|
47
|
+
const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
|
|
48
|
+
const setInteractionSettingType = core.usePageStore((s)=>s.setInteractionSettingType);
|
|
49
|
+
const setSidebarMode = core.usePageStore((s)=>s.setSidebarMode);
|
|
50
|
+
const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
|
|
51
|
+
state
|
|
52
|
+
]);
|
|
53
|
+
const setFontsToHead = (className, fonts)=>{
|
|
54
|
+
// clear fonts
|
|
55
|
+
if (!fonts?.length) {
|
|
56
|
+
const googleFonts = document.querySelectorAll(`.${className}`);
|
|
57
|
+
googleFonts.forEach((googleFont)=>{
|
|
58
|
+
googleFont.remove();
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// clear fonts not use
|
|
63
|
+
const googleFonts$1 = document.querySelectorAll(`.${className}`);
|
|
64
|
+
googleFonts$1.forEach((googleFont)=>{
|
|
65
|
+
const fontName = googleFont.getAttribute('data-font');
|
|
66
|
+
const variantName = googleFont.getAttribute('data-font-variant');
|
|
67
|
+
if (!fontName || !variantName) {
|
|
68
|
+
googleFont.remove();
|
|
69
|
+
} else {
|
|
70
|
+
const isUse = fonts.find((font)=>font.family == fontName && font.variants.includes(variantName));
|
|
71
|
+
if (!isUse) {
|
|
72
|
+
googleFont.remove();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// append new fonts
|
|
77
|
+
for (const font of fonts){
|
|
78
|
+
if ([
|
|
79
|
+
'bunny',
|
|
80
|
+
'google'
|
|
81
|
+
].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (font.type !== 'custom') {
|
|
85
|
+
if (font.variants?.length) {
|
|
86
|
+
for (const variant of font.variants){
|
|
87
|
+
const cloneFont = JSON.parse(JSON.stringify(font));
|
|
88
|
+
cloneFont.variants = [
|
|
89
|
+
variant
|
|
90
|
+
]; // set single variant. Fix error reload font when change href other variant
|
|
91
|
+
const fontName = cloneFont.family;
|
|
92
|
+
const variantName = variant;
|
|
93
|
+
const url = googleFonts.createFontUrl([
|
|
94
|
+
cloneFont
|
|
95
|
+
], undefined, fontType);
|
|
96
|
+
if (url) {
|
|
97
|
+
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
98
|
+
if (googleFont) {
|
|
99
|
+
continue;
|
|
100
|
+
} else {
|
|
101
|
+
const link = document.createElement('link');
|
|
102
|
+
link.className = className;
|
|
103
|
+
link.dataset.font = fontName;
|
|
104
|
+
link.dataset.fontVariant = variantName;
|
|
105
|
+
link.href = url;
|
|
106
|
+
link.rel = 'stylesheet';
|
|
107
|
+
document.head.appendChild(link);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
// Revalidate all query with key match query/
|
|
116
|
+
const onRevalidateQuery = react.useCallback(()=>{
|
|
117
|
+
matchMutate(/query\//, {
|
|
118
|
+
revalidate: true
|
|
119
|
+
});
|
|
120
|
+
}, [
|
|
121
|
+
matchMutate
|
|
122
|
+
]);
|
|
123
|
+
// Update shop info
|
|
124
|
+
const onChangeShopInfo = react.useCallback((e)=>{
|
|
125
|
+
const detail = e.detail;
|
|
126
|
+
changeStorefrontInfo({
|
|
127
|
+
url: detail.shopHandle ? getStorefrontApi.getStorefrontApi(detail.shopHandle, provider) : undefined,
|
|
128
|
+
token: detail.shopToken
|
|
129
|
+
});
|
|
130
|
+
}, [
|
|
131
|
+
changeStorefrontInfo,
|
|
132
|
+
provider
|
|
133
|
+
]);
|
|
134
|
+
const onChangeGlobalStyle = react.useCallback((e)=>{
|
|
135
|
+
const detail = e.detail;
|
|
136
|
+
try {
|
|
137
|
+
if (detail.data) {
|
|
138
|
+
const themeStyle = genCss.genCSS(detail.data, detail.mobileOnly);
|
|
139
|
+
const font = Object.entries(detail.data?.font).map(([, value])=>{
|
|
140
|
+
return value;
|
|
141
|
+
}).map((item)=>{
|
|
142
|
+
if (item.type == 'custom') {
|
|
143
|
+
const isGoogleFont = shopifyCdnWithGoogleFonts.shopifyCdnWithGoogleFonts.find((ggFont)=>ggFont.family == item.family);
|
|
144
|
+
if (isGoogleFont) {
|
|
145
|
+
return isGoogleFont;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return item;
|
|
149
|
+
});
|
|
150
|
+
const globalStyle = document.getElementById(globalStyleId);
|
|
151
|
+
setFontsToHead('google-font-builder', font);
|
|
152
|
+
if (globalStyle) {
|
|
153
|
+
globalStyle.innerHTML = themeStyle;
|
|
154
|
+
} else {
|
|
155
|
+
const style = document.createElement('style');
|
|
156
|
+
style.id = globalStyleId;
|
|
157
|
+
style.innerHTML = themeStyle;
|
|
158
|
+
document.head.appendChild(style);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
//
|
|
163
|
+
}
|
|
164
|
+
}, []);
|
|
165
|
+
// Init builder data
|
|
166
|
+
const onInitBuilder = react.useCallback((e)=>{
|
|
167
|
+
clearModal();
|
|
168
|
+
try {
|
|
169
|
+
const detail = e.detail;
|
|
170
|
+
if (detail.data) {
|
|
171
|
+
if (detail.type === 'flat') {
|
|
172
|
+
initNormalizeState(detail.data);
|
|
173
|
+
} else {
|
|
174
|
+
initState(detail.data);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} catch {
|
|
178
|
+
//
|
|
179
|
+
}
|
|
180
|
+
}, [
|
|
181
|
+
initNormalizeState,
|
|
182
|
+
initState,
|
|
183
|
+
clearModal
|
|
184
|
+
]);
|
|
185
|
+
// Add new entity
|
|
186
|
+
const onAddEntity = react.useCallback((e)=>{
|
|
187
|
+
try {
|
|
188
|
+
const detail = e.detail;
|
|
189
|
+
if (detail.entity) {
|
|
190
|
+
addItem({
|
|
191
|
+
data: detail.entity,
|
|
192
|
+
id: detail.id,
|
|
193
|
+
position: detail.position,
|
|
194
|
+
type: detail.type ?? 'component'
|
|
195
|
+
});
|
|
196
|
+
if (detail?.type === 'section' && !Array.isArray(detail.entity)) {
|
|
197
|
+
addSection(detail.entity.uid, detail.entity);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
//
|
|
202
|
+
}
|
|
203
|
+
}, [
|
|
204
|
+
addItem,
|
|
205
|
+
addSection
|
|
206
|
+
]);
|
|
207
|
+
// Update props of entity
|
|
208
|
+
const onUpdateEntityProp = react.useCallback((e)=>{
|
|
209
|
+
try {
|
|
210
|
+
const detail = e.detail;
|
|
211
|
+
if (detail.uid && detail.propName) {
|
|
212
|
+
changeItemPropByKey({
|
|
213
|
+
id: detail.uid,
|
|
214
|
+
key: detail.propName,
|
|
215
|
+
data: detail.propValue,
|
|
216
|
+
group: detail.group
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
} catch {
|
|
220
|
+
//
|
|
221
|
+
}
|
|
222
|
+
}, [
|
|
223
|
+
changeItemPropByKey
|
|
224
|
+
]);
|
|
225
|
+
// Update props of entity
|
|
226
|
+
const onForceUpdateEntityProps = react.useCallback((e)=>{
|
|
227
|
+
try {
|
|
228
|
+
const detail = e.detail;
|
|
229
|
+
if (detail.uid) {
|
|
230
|
+
forceChangeItemProp(detail.uid, detail.data, detail.group);
|
|
231
|
+
}
|
|
232
|
+
} catch {
|
|
233
|
+
//
|
|
234
|
+
}
|
|
235
|
+
}, [
|
|
236
|
+
forceChangeItemProp
|
|
237
|
+
]);
|
|
238
|
+
// Move entity
|
|
239
|
+
const onMoveEntity = react.useCallback((e)=>{
|
|
240
|
+
try {
|
|
241
|
+
const detail = e.detail;
|
|
242
|
+
if (detail.to && detail.uid) {
|
|
243
|
+
moveItem(detail.uid, detail.to, Number(detail.position) ?? 0);
|
|
244
|
+
}
|
|
245
|
+
} catch {
|
|
246
|
+
//
|
|
247
|
+
}
|
|
248
|
+
}, [
|
|
249
|
+
moveItem
|
|
250
|
+
]);
|
|
251
|
+
// Remove entity
|
|
252
|
+
const onRemoveEntity = react.useCallback((e)=>{
|
|
253
|
+
try {
|
|
254
|
+
const detail = e.detail;
|
|
255
|
+
if (detail.uid) {
|
|
256
|
+
removeItem(detail.uid);
|
|
257
|
+
}
|
|
258
|
+
} catch {
|
|
259
|
+
//
|
|
260
|
+
}
|
|
261
|
+
}, [
|
|
262
|
+
removeItem
|
|
263
|
+
]);
|
|
264
|
+
// Change Swatches Data
|
|
265
|
+
const onChangeSwatchesData = react.useCallback((e)=>{
|
|
266
|
+
const detail = e.detail;
|
|
267
|
+
try {
|
|
268
|
+
if (detail.data) {
|
|
269
|
+
changeSwatches(detail.data);
|
|
270
|
+
}
|
|
271
|
+
} catch {
|
|
272
|
+
//
|
|
273
|
+
}
|
|
274
|
+
}, [
|
|
275
|
+
changeSwatches
|
|
276
|
+
]);
|
|
277
|
+
const onChangeLayoutSettingData = react.useCallback((e)=>{
|
|
278
|
+
const detail = e.detail;
|
|
279
|
+
if (!detail) return;
|
|
280
|
+
changeLayoutSettings(detail);
|
|
281
|
+
}, [
|
|
282
|
+
changeLayoutSettings
|
|
283
|
+
]);
|
|
284
|
+
const onUpdateCreateThemeSectionCount = react.useCallback((e)=>{
|
|
285
|
+
const count = e.detail;
|
|
286
|
+
if (!count) return;
|
|
287
|
+
changeCreateThemeSectionCount(count);
|
|
288
|
+
}, [
|
|
289
|
+
changeCreateThemeSectionCount
|
|
290
|
+
]);
|
|
291
|
+
const onUpdateShopPlan = react.useCallback((e)=>{
|
|
292
|
+
const shopPlan = e.detail;
|
|
293
|
+
if (!shopPlan) return;
|
|
294
|
+
changeShopPlan(shopPlan);
|
|
295
|
+
}, [
|
|
296
|
+
changeShopPlan
|
|
297
|
+
]);
|
|
298
|
+
const onUpdateFontType = react.useCallback((e)=>{
|
|
299
|
+
const fontType = e.detail;
|
|
300
|
+
if (!fontType) return;
|
|
301
|
+
changeFontType(fontType);
|
|
302
|
+
}, [
|
|
303
|
+
changeFontType
|
|
304
|
+
]);
|
|
305
|
+
const onUpdateDynamicProduct = react.useCallback((e)=>{
|
|
306
|
+
const product = e.detail;
|
|
307
|
+
if (!product) return;
|
|
308
|
+
setDynamicProduct(product);
|
|
309
|
+
}, [
|
|
310
|
+
setDynamicProduct
|
|
311
|
+
]);
|
|
312
|
+
const onUpdateDynamicCollection = react.useCallback((e)=>{
|
|
313
|
+
const collection = e.detail;
|
|
314
|
+
if (!collection) return;
|
|
315
|
+
setDynamicCollection(collection);
|
|
316
|
+
}, [
|
|
317
|
+
setDynamicCollection
|
|
318
|
+
]);
|
|
319
|
+
react.useEffect(()=>{
|
|
320
|
+
if (fonts) {
|
|
321
|
+
setFontsToHead('google-font-element', fonts);
|
|
322
|
+
}
|
|
323
|
+
}, [
|
|
324
|
+
fonts
|
|
325
|
+
]);
|
|
326
|
+
const onUpdateItemName = react.useCallback((e)=>{
|
|
327
|
+
const detail = e.detail;
|
|
328
|
+
if (detail.uid) {
|
|
329
|
+
updateItemName(detail.uid, detail.name || '');
|
|
330
|
+
}
|
|
331
|
+
}, [
|
|
332
|
+
updateItemName
|
|
333
|
+
]);
|
|
334
|
+
const onUpdateItemAttribute = react.useCallback((e)=>{
|
|
335
|
+
const detail = e.detail;
|
|
336
|
+
if (detail.uid) {
|
|
337
|
+
updateItemAttribute(detail.uid, detail.value || '', detail.attr || '');
|
|
338
|
+
}
|
|
339
|
+
}, [
|
|
340
|
+
updateItemAttribute
|
|
341
|
+
]);
|
|
342
|
+
const onUpdateProductOffers = react.useCallback((e)=>{
|
|
343
|
+
const productOffers = e.detail;
|
|
344
|
+
if (!productOffers?.length) return;
|
|
345
|
+
setPostPurchaseProductOffers(productOffers);
|
|
346
|
+
}, [
|
|
347
|
+
setPostPurchaseProductOffers
|
|
348
|
+
]);
|
|
349
|
+
const onUpdateSalePageProductId = react.useCallback((e)=>{
|
|
350
|
+
const id = e.detail;
|
|
351
|
+
if (!id) return;
|
|
352
|
+
setSalePageProductId(id);
|
|
353
|
+
}, [
|
|
354
|
+
setSalePageProductId
|
|
355
|
+
]);
|
|
356
|
+
const onLimitCreateThemeSection = react.useCallback((e)=>{
|
|
357
|
+
const data = e.detail;
|
|
358
|
+
if (!data) return;
|
|
359
|
+
changeLimitCreateThemeSection(data);
|
|
360
|
+
}, [
|
|
361
|
+
changeLimitCreateThemeSection
|
|
362
|
+
]);
|
|
363
|
+
const onUpdateInteractionIsSelectOnPage = react.useCallback((e)=>{
|
|
364
|
+
const isSelectOnPage = e.detail.value;
|
|
365
|
+
const mode = e.detail.mode;
|
|
366
|
+
const settingType = e.detail.settingType;
|
|
367
|
+
setInteractionIsSelectOnPage(isSelectOnPage);
|
|
368
|
+
setInteractionSelectType(mode);
|
|
369
|
+
setInteractionSettingType(settingType);
|
|
370
|
+
}, [
|
|
371
|
+
setInteractionIsSelectOnPage,
|
|
372
|
+
setInteractionSelectType,
|
|
373
|
+
setInteractionSettingType
|
|
374
|
+
]);
|
|
375
|
+
const onUpdateInteractionSettingType = react.useCallback((e)=>{
|
|
376
|
+
const settingType = e.detail.settingType;
|
|
377
|
+
setInteractionSettingType(settingType);
|
|
378
|
+
}, [
|
|
379
|
+
setInteractionSettingType
|
|
380
|
+
]);
|
|
381
|
+
const onChangeSidebarMode = react.useCallback((e)=>{
|
|
382
|
+
const mode = e.detail.mode;
|
|
383
|
+
console.log(mode);
|
|
384
|
+
setSidebarMode(mode);
|
|
385
|
+
}, [
|
|
386
|
+
setSidebarMode
|
|
387
|
+
]);
|
|
388
|
+
const onUpdateInteractionItem = react.useCallback((e)=>{
|
|
389
|
+
const interactionItem = e.detail;
|
|
390
|
+
setInteractionItem(interactionItem);
|
|
391
|
+
}, [
|
|
392
|
+
setInteractionItem
|
|
393
|
+
]);
|
|
394
|
+
react.useEffect(()=>{
|
|
395
|
+
if (fonts) {
|
|
396
|
+
setFontsToHead('google-font-element', fonts);
|
|
397
|
+
}
|
|
398
|
+
}, [
|
|
399
|
+
fonts
|
|
400
|
+
]);
|
|
401
|
+
react.useEffect(()=>{
|
|
402
|
+
window.addEventListener('update-shop-info', onChangeShopInfo);
|
|
403
|
+
window.addEventListener('revalidate-query', onRevalidateQuery);
|
|
404
|
+
window.addEventListener('init-builder', onInitBuilder);
|
|
405
|
+
window.addEventListener('add-entity', onAddEntity);
|
|
406
|
+
window.addEventListener('remove-entity', onRemoveEntity);
|
|
407
|
+
window.addEventListener('move-entity', onMoveEntity);
|
|
408
|
+
window.addEventListener('force-update-entity-props', onForceUpdateEntityProps);
|
|
409
|
+
window.addEventListener('update-entity-prop', onUpdateEntityProp);
|
|
410
|
+
window.addEventListener('set-global-style', onChangeGlobalStyle);
|
|
411
|
+
window.addEventListener('update-global-swatches-data', onChangeSwatchesData);
|
|
412
|
+
window.addEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
413
|
+
window.addEventListener('update-create-theme-section-count', onUpdateCreateThemeSectionCount);
|
|
414
|
+
window.addEventListener('update-shop-plan', onUpdateShopPlan);
|
|
415
|
+
window.addEventListener('set-dynamic-product', onUpdateDynamicProduct);
|
|
416
|
+
window.addEventListener('set-dynamic-collection', onUpdateDynamicCollection);
|
|
417
|
+
window.addEventListener('update-item-name', onUpdateItemName);
|
|
418
|
+
window.addEventListener('update-item-attribute', onUpdateItemAttribute);
|
|
419
|
+
window.addEventListener('set-product-offer', onUpdateProductOffers);
|
|
420
|
+
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
421
|
+
window.addEventListener('limit-create-theme-section', onLimitCreateThemeSection);
|
|
422
|
+
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
423
|
+
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
424
|
+
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
425
|
+
window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
|
|
426
|
+
window.addEventListener('update-font-type', onUpdateFontType);
|
|
427
|
+
return ()=>{
|
|
428
|
+
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
429
|
+
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
430
|
+
window.removeEventListener('init-builder', onInitBuilder);
|
|
431
|
+
window.removeEventListener('add-entity', onAddEntity);
|
|
432
|
+
window.removeEventListener('remove-entity', onRemoveEntity);
|
|
433
|
+
window.removeEventListener('move-entity', onMoveEntity);
|
|
434
|
+
window.removeEventListener('update-entity-prop', onUpdateEntityProp);
|
|
435
|
+
window.removeEventListener('set-global-style', onChangeGlobalStyle);
|
|
436
|
+
window.removeEventListener('update-global-swatches-data', onChangeSwatchesData);
|
|
437
|
+
window.removeEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
438
|
+
window.removeEventListener('update-create-theme-section-count', onUpdateCreateThemeSectionCount);
|
|
439
|
+
window.removeEventListener('update-shop-plan', onUpdateShopPlan);
|
|
440
|
+
window.removeEventListener('set-dynamic-product', onUpdateDynamicProduct);
|
|
441
|
+
window.removeEventListener('set-dynamic-collection', onUpdateDynamicCollection);
|
|
442
|
+
window.removeEventListener('update-item-name', onUpdateItemName);
|
|
443
|
+
window.removeEventListener('update-item-attribute', onUpdateItemAttribute);
|
|
444
|
+
window.removeEventListener('set-product-offer', onUpdateProductOffers);
|
|
445
|
+
window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
446
|
+
window.removeEventListener('limit-create-theme-section', onLimitCreateThemeSection);
|
|
447
|
+
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
448
|
+
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
449
|
+
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
450
|
+
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
451
|
+
};
|
|
452
|
+
}, [
|
|
453
|
+
onAddEntity,
|
|
454
|
+
onUpdateShopPlan,
|
|
455
|
+
onForceUpdateEntityProps,
|
|
456
|
+
onUpdateEntityProp,
|
|
457
|
+
onInitBuilder,
|
|
458
|
+
onMoveEntity,
|
|
459
|
+
onRemoveEntity,
|
|
460
|
+
onChangeGlobalStyle,
|
|
461
|
+
onChangeSwatchesData,
|
|
462
|
+
onRevalidateQuery,
|
|
463
|
+
onChangeShopInfo,
|
|
464
|
+
onChangeLayoutSettingData,
|
|
465
|
+
onUpdateCreateThemeSectionCount,
|
|
466
|
+
onUpdateDynamicProduct,
|
|
467
|
+
onUpdateDynamicCollection,
|
|
468
|
+
onUpdateItemName,
|
|
469
|
+
onUpdateItemAttribute,
|
|
470
|
+
onUpdateProductOffers,
|
|
471
|
+
onUpdateSalePageProductId,
|
|
472
|
+
onLimitCreateThemeSection,
|
|
473
|
+
onUpdateInteractionItem,
|
|
474
|
+
onUpdateInteractionIsSelectOnPage,
|
|
475
|
+
onUpdateInteractionSettingType,
|
|
476
|
+
onUpdateFontType,
|
|
477
|
+
onChangeSidebarMode
|
|
478
|
+
]);
|
|
479
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
480
|
+
className: "toolbox"
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
var Toolbox$1 = /*#__PURE__*/ react.memo(Toolbox);
|
|
484
|
+
|
|
485
|
+
exports.default = Toolbox$1;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const devices = [
|
|
4
|
+
{
|
|
5
|
+
id: 'iphone-13-mini',
|
|
6
|
+
name: 'iPhone 13 Mini',
|
|
7
|
+
width: 375
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: 'iphone-13-pro',
|
|
11
|
+
name: 'iPhone 13 Pro',
|
|
12
|
+
width: 390
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'iphone-11-pro-max',
|
|
16
|
+
name: 'iPhone 11 Pro Max',
|
|
17
|
+
width: 414
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'iphone-15-pro-max',
|
|
21
|
+
name: 'iPhone 15 Pro Max',
|
|
22
|
+
width: 430
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'pixel-7',
|
|
26
|
+
name: 'Pixel 7',
|
|
27
|
+
width: 412
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'galaxy-s8-plus',
|
|
31
|
+
name: 'Galaxy S8+',
|
|
32
|
+
width: 360
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'galaxy-s20-ultra',
|
|
36
|
+
name: 'Galaxy S20 Ultra',
|
|
37
|
+
width: 412
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'ipad-mini',
|
|
41
|
+
name: 'iPad Mini',
|
|
42
|
+
width: 768
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'ipad-air',
|
|
46
|
+
name: 'iPad Air',
|
|
47
|
+
width: 820
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'ipad-pro',
|
|
51
|
+
name: 'iPad Pro',
|
|
52
|
+
width: 1024
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
exports.devices = devices;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const findDOMClosest = ($target, selectors)=>{
|
|
4
|
+
const closestElements = {
|
|
5
|
+
$childrenSlot: null,
|
|
6
|
+
$productFeatureImg: null,
|
|
7
|
+
$section: null,
|
|
8
|
+
$component: null,
|
|
9
|
+
$disableIframeClick: null,
|
|
10
|
+
$stickyMinimize: null,
|
|
11
|
+
$toolbar: null,
|
|
12
|
+
$gpText: null,
|
|
13
|
+
$imageDetection: null,
|
|
14
|
+
$popupTriggerButton: null
|
|
15
|
+
};
|
|
16
|
+
let currentElement = $target;
|
|
17
|
+
while(currentElement){
|
|
18
|
+
// Check for stop conditions
|
|
19
|
+
if (currentElement.matches('[data-uid="ROOT"], .builder, #storefront')) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
// Check if currentElement matches any of the selectors
|
|
23
|
+
for (const [key, selector] of Object.entries(selectors)){
|
|
24
|
+
if (!closestElements[key] && currentElement.matches(selector)) {
|
|
25
|
+
closestElements[key] = currentElement;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// If all closest elements are found, break the loop
|
|
29
|
+
if (Object.values(closestElements).every((el)=>el !== null)) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
// Move up to the parent element
|
|
33
|
+
currentElement = currentElement.parentElement;
|
|
34
|
+
}
|
|
35
|
+
// Reset ram
|
|
36
|
+
currentElement = null;
|
|
37
|
+
// Return
|
|
38
|
+
return closestElements;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.findDOMClosest = findDOMClosest;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isOverToolbarPosition = require('./isOverToolbarPosition.js');
|
|
4
|
+
var isSection = require('./isSection.js');
|
|
5
|
+
var notVisible = require('./notVisible.js');
|
|
6
|
+
|
|
7
|
+
const findOverflowParent = (element, initEl)=>{
|
|
8
|
+
const thisEl = element;
|
|
9
|
+
const origEl = initEl || thisEl;
|
|
10
|
+
if (!thisEl) return;
|
|
11
|
+
if (isSection.isSection(thisEl)) return;
|
|
12
|
+
if (notVisible.notVisible(thisEl) && isOverToolbarPosition.isOverToolbarPosition(initEl, thisEl)) return thisEl;
|
|
13
|
+
if (thisEl.parentElement) {
|
|
14
|
+
return findOverflowParent(thisEl.parentElement, origEl);
|
|
15
|
+
} else {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.findOverflowParent = findOverflowParent;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getChildrenByAttrSelector = ($el, attrSelector)=>{
|
|
4
|
+
const childLen = $el.children.length;
|
|
5
|
+
if (childLen) {
|
|
6
|
+
for(let i = 0; i < childLen; i++){
|
|
7
|
+
const children = $el.children[i];
|
|
8
|
+
if (children) {
|
|
9
|
+
const is = children.getAttribute(attrSelector);
|
|
10
|
+
if (is) {
|
|
11
|
+
return children;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.getChildrenByAttrSelector = getChildrenByAttrSelector;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getDOMElementParents = ($el, selector, limit)=>{
|
|
4
|
+
// Set up a parent array
|
|
5
|
+
const parents = [];
|
|
6
|
+
// Push each parent $elms to the array
|
|
7
|
+
while($el){
|
|
8
|
+
$el = $el.parentElement ?? undefined;
|
|
9
|
+
if ($el) {
|
|
10
|
+
if ($el.tagName === 'BODY' || $el.getAttribute('data-uid') === 'ROOT') {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
if (selector) {
|
|
14
|
+
if ($el.matches(selector)) {
|
|
15
|
+
parents.push($el);
|
|
16
|
+
if (limit && parents.length == limit) {
|
|
17
|
+
return parents;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
parents.push($el);
|
|
23
|
+
if (limit && parents.length == limit) {
|
|
24
|
+
return parents;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Return our parent array
|
|
29
|
+
return parents;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getDOMElementParents = getDOMElementParents;
|