@gem-sdk/pages 1.9.52 → 1.10.16
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/builder/Toolbox.js +2 -6
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/libs/helpers/normalize.js +1 -0
- package/dist/cjs/pages/builder.js +8 -8
- package/dist/esm/components/builder/Toolbox.js +4 -8
- package/dist/esm/index.js +2 -0
- package/dist/esm/libs/helpers/normalize.js +1 -1
- package/dist/esm/pages/builder.js +9 -9
- package/dist/types/index.d.ts +26 -4
- package/package.json +1 -1
|
@@ -24,7 +24,6 @@ const Toolbox = ()=>{
|
|
|
24
24
|
const addSection = core.useSectionStore((s)=>s.addSection);
|
|
25
25
|
const changeSwatches = core.useShopStore((s)=>s.changeSwatches);
|
|
26
26
|
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
27
|
-
const [initEventSuccess, setInitEventSuccess] = react.useState(false);
|
|
28
27
|
const clearModal = core.useModalStore((s)=>s.clearModal);
|
|
29
28
|
// Revalidate all query with key match query/
|
|
30
29
|
const onRevalidateQuery = react.useCallback(()=>{
|
|
@@ -199,7 +198,6 @@ const Toolbox = ()=>{
|
|
|
199
198
|
window.addEventListener('set-global-style', onChangeGlobalStyle);
|
|
200
199
|
window.addEventListener('update-global-swatches-data', onChangeSwatchesData);
|
|
201
200
|
window.addEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
202
|
-
setInitEventSuccess(true);
|
|
203
201
|
return ()=>{
|
|
204
202
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
205
203
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -210,7 +208,7 @@ const Toolbox = ()=>{
|
|
|
210
208
|
window.removeEventListener('update-entity-prop', onUpdateEntityProp);
|
|
211
209
|
window.removeEventListener('set-global-style', onChangeGlobalStyle);
|
|
212
210
|
window.removeEventListener('update-global-swatches-data', onChangeSwatchesData);
|
|
213
|
-
window.
|
|
211
|
+
window.removeEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
214
212
|
};
|
|
215
213
|
}, [
|
|
216
214
|
onAddEntity,
|
|
@@ -225,9 +223,7 @@ const Toolbox = ()=>{
|
|
|
225
223
|
onChangeLayoutSettingData
|
|
226
224
|
]);
|
|
227
225
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
228
|
-
className:
|
|
229
|
-
toolbox: initEventSuccess
|
|
230
|
-
})
|
|
226
|
+
className: "toolbox"
|
|
231
227
|
});
|
|
232
228
|
};
|
|
233
229
|
var Toolbox$1 = /*#__PURE__*/ react.memo(Toolbox);
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,6 +14,8 @@ var getLayout = require('./libs/get-layout.js');
|
|
|
14
14
|
var genCss = require('./libs/helpers/gen-css.js');
|
|
15
15
|
var useTrackingView = require('./libs/hooks/use-tracking-view.js');
|
|
16
16
|
var userAgent = require('./libs/helpers/user-agent.js');
|
|
17
|
+
var normalize = require('./libs/helpers/normalize.js');
|
|
18
|
+
var getFallback = require('./libs/helpers/get-fallback.js');
|
|
17
19
|
var collectionDetail = require('./pages/collection-detail.js');
|
|
18
20
|
var preview = require('./pages/preview.js');
|
|
19
21
|
var productDetail = require('./pages/product-detail.js');
|
|
@@ -48,6 +50,9 @@ exports.getLayout = getLayout.getLayout;
|
|
|
48
50
|
exports.genCSS = genCss.genCSS;
|
|
49
51
|
exports.useTrackingView = useTrackingView.useTrackingView;
|
|
50
52
|
exports.isBot = userAgent.isBot;
|
|
53
|
+
exports.normalizePageSectionResponseV2 = normalize.normalizePageSectionResponseV2;
|
|
54
|
+
exports.parseBuilderTemplateV2 = normalize.parseBuilderTemplateV2;
|
|
55
|
+
exports.getFallbackV2 = getFallback.getFallbackV2;
|
|
51
56
|
exports.CollectionDetailPage = collectionDetail.default;
|
|
52
57
|
exports.PreviewPage = preview.PreviewPage;
|
|
53
58
|
exports.ProductDetailPage = productDetail.default;
|
|
@@ -85,5 +85,6 @@ const parseBuilderTemplate = (data)=>{
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
exports.normalizeBuilderData = normalizeBuilderData;
|
|
88
|
+
exports.normalizePageSectionResponseV2 = normalizePageSectionResponseV2;
|
|
88
89
|
exports.parseBuilderTemplate = parseBuilderTemplate;
|
|
89
90
|
exports.parseBuilderTemplateV2 = parseBuilderTemplateV2;
|
|
@@ -13,14 +13,14 @@ var PopupManager = require('../components/builder/PopupManager.js');
|
|
|
13
13
|
|
|
14
14
|
const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData , pageType })=>{
|
|
15
15
|
const [loadSuccess, setLoadSuccess] = react.useState(false);
|
|
16
|
-
const initState = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const initState = react.useMemo(()=>({
|
|
17
|
+
ROOT: {
|
|
18
|
+
uid: 'ROOT',
|
|
19
|
+
tag: 'Root',
|
|
20
|
+
label: 'Root',
|
|
21
|
+
childrens: []
|
|
22
|
+
}
|
|
23
|
+
}), []);
|
|
24
24
|
react.useEffect(()=>{
|
|
25
25
|
setLoadSuccess(true);
|
|
26
26
|
}, []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useMatchMutate, useShopStore, useBuilderPreviewStore, useSectionStore, useModalStore
|
|
3
|
-
import { memo,
|
|
2
|
+
import { useMatchMutate, useShopStore, useBuilderPreviewStore, useSectionStore, useModalStore } from '@gem-sdk/core';
|
|
3
|
+
import { memo, useCallback, useEffect } from 'react';
|
|
4
4
|
import { createFontUrl } from '../../libs/google-fonts.js';
|
|
5
5
|
import { genCSS } from '../../libs/helpers/gen-css.js';
|
|
6
6
|
import { getStorefrontApi } from '../../libs/get-storefront-api.js';
|
|
@@ -20,7 +20,6 @@ const Toolbox = ()=>{
|
|
|
20
20
|
const addSection = useSectionStore((s)=>s.addSection);
|
|
21
21
|
const changeSwatches = useShopStore((s)=>s.changeSwatches);
|
|
22
22
|
const changeLayoutSettings = useShopStore((s)=>s.changeLayoutSettings);
|
|
23
|
-
const [initEventSuccess, setInitEventSuccess] = useState(false);
|
|
24
23
|
const clearModal = useModalStore((s)=>s.clearModal);
|
|
25
24
|
// Revalidate all query with key match query/
|
|
26
25
|
const onRevalidateQuery = useCallback(()=>{
|
|
@@ -195,7 +194,6 @@ const Toolbox = ()=>{
|
|
|
195
194
|
window.addEventListener('set-global-style', onChangeGlobalStyle);
|
|
196
195
|
window.addEventListener('update-global-swatches-data', onChangeSwatchesData);
|
|
197
196
|
window.addEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
198
|
-
setInitEventSuccess(true);
|
|
199
197
|
return ()=>{
|
|
200
198
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
201
199
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -206,7 +204,7 @@ const Toolbox = ()=>{
|
|
|
206
204
|
window.removeEventListener('update-entity-prop', onUpdateEntityProp);
|
|
207
205
|
window.removeEventListener('set-global-style', onChangeGlobalStyle);
|
|
208
206
|
window.removeEventListener('update-global-swatches-data', onChangeSwatchesData);
|
|
209
|
-
window.
|
|
207
|
+
window.removeEventListener('on-off-header-footer', onChangeLayoutSettingData);
|
|
210
208
|
};
|
|
211
209
|
}, [
|
|
212
210
|
onAddEntity,
|
|
@@ -221,9 +219,7 @@ const Toolbox = ()=>{
|
|
|
221
219
|
onChangeLayoutSettingData
|
|
222
220
|
]);
|
|
223
221
|
return /*#__PURE__*/ jsx("div", {
|
|
224
|
-
className:
|
|
225
|
-
toolbox: initEventSuccess
|
|
226
|
-
})
|
|
222
|
+
className: "toolbox"
|
|
227
223
|
});
|
|
228
224
|
};
|
|
229
225
|
var Toolbox$1 = /*#__PURE__*/ memo(Toolbox);
|
package/dist/esm/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export { getLayout } from './libs/get-layout.js';
|
|
|
12
12
|
export { genCSS } from './libs/helpers/gen-css.js';
|
|
13
13
|
export { useTrackingView } from './libs/hooks/use-tracking-view.js';
|
|
14
14
|
export { isBot } from './libs/helpers/user-agent.js';
|
|
15
|
+
export { normalizePageSectionResponseV2, parseBuilderTemplateV2 } from './libs/helpers/normalize.js';
|
|
16
|
+
export { getFallbackV2 } from './libs/helpers/get-fallback.js';
|
|
15
17
|
export { default as CollectionDetailPage } from './pages/collection-detail.js';
|
|
16
18
|
export { PreviewPage } from './pages/preview.js';
|
|
17
19
|
export { default as ProductDetailPage } from './pages/product-detail.js';
|
|
@@ -82,4 +82,4 @@ const parseBuilderTemplate = (data)=>{
|
|
|
82
82
|
], data?.sectionPosition);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export { normalizeBuilderData, parseBuilderTemplate, parseBuilderTemplateV2 };
|
|
85
|
+
export { normalizeBuilderData, normalizePageSectionResponseV2, parseBuilderTemplate, parseBuilderTemplateV2 };
|
|
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { BuilderComponentProvider, SectionProvider, BuilderPreviewProvider, RenderPreview } from '@gem-sdk/core';
|
|
3
3
|
import { NextSeo } from 'next-seo';
|
|
4
4
|
import Head from 'next/head';
|
|
5
|
-
import { useState, useEffect } from 'react';
|
|
5
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
6
6
|
import Toolbox from '../components/builder/Toolbox.js';
|
|
7
7
|
import Header from '../components/Header.js';
|
|
8
8
|
import Footer from '../components/Footer.js';
|
|
@@ -11,14 +11,14 @@ import PopupManager from '../components/builder/PopupManager.js';
|
|
|
11
11
|
|
|
12
12
|
const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData , pageType })=>{
|
|
13
13
|
const [loadSuccess, setLoadSuccess] = useState(false);
|
|
14
|
-
const initState = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const initState = useMemo(()=>({
|
|
15
|
+
ROOT: {
|
|
16
|
+
uid: 'ROOT',
|
|
17
|
+
tag: 'Root',
|
|
18
|
+
label: 'Root',
|
|
19
|
+
childrens: []
|
|
20
|
+
}
|
|
21
|
+
}), []);
|
|
22
22
|
useEffect(()=>{
|
|
23
23
|
setLoadSuccess(true);
|
|
24
24
|
}, []);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuilderState, SectionData, ShopType, RenderMode, CollectionQueryResponse, FetchFunc, ProductSelectFragment } from '@gem-sdk/core';
|
|
1
|
+
import { BuilderState, SectionData as SectionData$1, ShopType, RenderMode, CollectionQueryResponse, FetchFunc, ProductSelectFragment, PublishedThemePageSelectFragment } from '@gem-sdk/core';
|
|
2
2
|
import { NextPage, GetStaticPaths } from 'next';
|
|
3
3
|
import { NextSeoProps } from 'next-seo';
|
|
4
4
|
import { AppProps } from 'next/app';
|
|
@@ -9,7 +9,7 @@ import { Component } from 'react';
|
|
|
9
9
|
type PageBuilderProps = {
|
|
10
10
|
seo?: NextSeoProps;
|
|
11
11
|
builderData?: BuilderState;
|
|
12
|
-
sectionData?: Record<string, SectionData>;
|
|
12
|
+
sectionData?: Record<string, SectionData$1>;
|
|
13
13
|
themeStyle?: string | null;
|
|
14
14
|
fontStyle?: string | null;
|
|
15
15
|
swr?: React.ComponentProps<typeof SWRConfig>['value'];
|
|
@@ -92,6 +92,28 @@ declare const useTrackingView: (token?: string | null, handle?: string | null, i
|
|
|
92
92
|
|
|
93
93
|
declare function isBot(input: string): boolean;
|
|
94
94
|
|
|
95
|
+
type SectionData = {
|
|
96
|
+
id: string;
|
|
97
|
+
component?: string;
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
};
|
|
100
|
+
declare function normalizePageSectionResponseV2(sections?: ShopType.Maybe<SectionData>[], orders?: string[]): {
|
|
101
|
+
uid: string;
|
|
102
|
+
lazy: boolean;
|
|
103
|
+
priority: boolean;
|
|
104
|
+
data: any;
|
|
105
|
+
}[];
|
|
106
|
+
declare const parseBuilderTemplateV2: (data?: PublishedThemePageSelectFragment) => {
|
|
107
|
+
uid: string;
|
|
108
|
+
lazy: boolean;
|
|
109
|
+
priority: boolean;
|
|
110
|
+
data: any;
|
|
111
|
+
}[];
|
|
112
|
+
|
|
113
|
+
declare const getFallbackV2: (fetcher: FetchFunc, data: {
|
|
114
|
+
data: any;
|
|
115
|
+
}[]) => Promise<{}>;
|
|
116
|
+
|
|
95
117
|
type PreviewPageProps = {
|
|
96
118
|
components: Record<string, React.ComponentType<any>>;
|
|
97
119
|
pageType: ShopType.PublishedThemePageType;
|
|
@@ -108,7 +130,7 @@ type BuilderPageProps = {
|
|
|
108
130
|
fontStyle?: string | null;
|
|
109
131
|
header?: BuilderState;
|
|
110
132
|
footer?: BuilderState;
|
|
111
|
-
sectionData?: Record<string, SectionData>;
|
|
133
|
+
sectionData?: Record<string, SectionData$1>;
|
|
112
134
|
storefrontToken?: string | null;
|
|
113
135
|
storefrontHandle?: string | null;
|
|
114
136
|
shopToken?: string | null;
|
|
@@ -183,4 +205,4 @@ type Props = {
|
|
|
183
205
|
};
|
|
184
206
|
declare const TikTokPixel: ({ pixelId }: Props) => JSX.Element | null;
|
|
185
207
|
|
|
186
|
-
export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, CollectionPageProps, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps, PreviewPage, ProductDetailPage, ProductPageProps, StaticPage, StaticPageProps, StaticPagePropsV2, StaticPageV2, TikTokPixel, createFetcher, createShopifyFetcher, genCSS, getBuilderProps, getCollectionProps, getFontFromGlobalStyle, getFonts, getHomePageProps, getHomePagePropsV2, getLayout, getPreviewProps, getProductProps, getStaticPageProps, getStaticPagePropsPreview, getStaticPagePropsV2, getStaticPaths, getStorefrontApi, isBot, useTrackingView };
|
|
208
|
+
export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, CollectionPageProps, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps, PreviewPage, ProductDetailPage, ProductPageProps, StaticPage, StaticPageProps, StaticPagePropsV2, StaticPageV2, TikTokPixel, createFetcher, createShopifyFetcher, genCSS, getBuilderProps, getCollectionProps, getFallbackV2, getFontFromGlobalStyle, getFonts, getHomePageProps, getHomePagePropsV2, getLayout, getPreviewProps, getProductProps, getStaticPageProps, getStaticPagePropsPreview, getStaticPagePropsV2, getStaticPaths, getStorefrontApi, isBot, normalizePageSectionResponseV2, parseBuilderTemplateV2, useTrackingView };
|