@gem-sdk/core 1.0.0
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/AddOn.js +18 -0
- package/dist/cjs/components/ComponentWrapper.js +45 -0
- package/dist/cjs/components/ComponentWrapperPreview.js +58 -0
- package/dist/cjs/components/Empty.js +7 -0
- package/dist/cjs/components/Render.js +28 -0
- package/dist/cjs/components/RenderBlock.js +21 -0
- package/dist/cjs/components/RenderPreview.js +28 -0
- package/dist/cjs/components/RenderSection.js +19 -0
- package/dist/cjs/contexts/AddonContext.js +25 -0
- package/dist/cjs/contexts/BuilderComponent.js +30 -0
- package/dist/cjs/contexts/BuilderContext.js +29 -0
- package/dist/cjs/contexts/BuilderPreviewContext.js +353 -0
- package/dist/cjs/contexts/CartLineContext.js +24 -0
- package/dist/cjs/contexts/CollectionContext.js +24 -0
- package/dist/cjs/contexts/ProductContext.js +126 -0
- package/dist/cjs/contexts/ProductListContext.js +24 -0
- package/dist/cjs/contexts/SectionContext.js +49 -0
- package/dist/cjs/contexts/ShopContext.js +43 -0
- package/dist/cjs/graphql/fragments/analytic.generated.js +11 -0
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +13 -0
- package/dist/cjs/graphql/fragments/collection-product.generated.js +26 -0
- package/dist/cjs/graphql/fragments/data-seo.generated.js +11 -0
- package/dist/cjs/graphql/fragments/media.generated.js +14 -0
- package/dist/cjs/graphql/fragments/product-little.generated.js +25 -0
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +13 -0
- package/dist/cjs/graphql/fragments/product-option.generated.js +14 -0
- package/dist/cjs/graphql/fragments/product.generated.js +33 -0
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +12 -0
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +11 -0
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +27 -0
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +11 -0
- package/dist/cjs/graphql/fragments/selected-option.generated.js +11 -0
- package/dist/cjs/graphql/fragments/variant.generated.js +35 -0
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +34 -0
- package/dist/cjs/graphql/queries/collection.generated.js +52 -0
- package/dist/cjs/graphql/queries/preview-page.generated.js +23 -0
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +24 -0
- package/dist/cjs/graphql/queries/product-medias.generated.js +29 -0
- package/dist/cjs/graphql/queries/product-variants.generated.js +33 -0
- package/dist/cjs/graphql/queries/products.generated.js +41 -0
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +23 -0
- package/dist/cjs/graphql/queries/storeProperty.generated.js +12 -0
- package/dist/cjs/helpers/GlobalEvent.js +17 -0
- package/dist/cjs/helpers/background.js +104 -0
- package/dist/cjs/helpers/borders.js +138 -0
- package/dist/cjs/helpers/clone-deep.js +5 -0
- package/dist/cjs/helpers/cls.js +20 -0
- package/dist/cjs/helpers/colors.js +157 -0
- package/dist/cjs/helpers/compose-advance-style.js +132 -0
- package/dist/cjs/helpers/constant.js +17 -0
- package/dist/cjs/helpers/css-variable.js +7 -0
- package/dist/cjs/helpers/email.js +11 -0
- package/dist/cjs/helpers/flatten-connection.js +10 -0
- package/dist/cjs/helpers/fpixel.js +29 -0
- package/dist/cjs/helpers/get-resonsive-value.js +32 -0
- package/dist/cjs/helpers/get-shortname.js +92 -0
- package/dist/cjs/helpers/gtag.js +48 -0
- package/dist/cjs/helpers/is-browser.js +9 -0
- package/dist/cjs/helpers/is-defined.js +7 -0
- package/dist/cjs/helpers/is-empty-children.js +12 -0
- package/dist/cjs/helpers/layout.js +17 -0
- package/dist/cjs/helpers/load-script.js +32 -0
- package/dist/cjs/helpers/make-style.js +99 -0
- package/dist/cjs/helpers/normalize-builder-data.js +17 -0
- package/dist/cjs/helpers/prefetch-queries.js +68 -0
- package/dist/cjs/helpers/product.js +35 -0
- package/dist/cjs/helpers/queries/get-collection.js +173 -0
- package/dist/cjs/helpers/queries/get-product-by-slug.js +99 -0
- package/dist/cjs/helpers/queries/get-product.js +113 -0
- package/dist/cjs/helpers/queries/get-products.js +135 -0
- package/dist/cjs/helpers/radius.js +91 -0
- package/dist/cjs/helpers/shadow.js +48 -0
- package/dist/cjs/helpers/size.js +20 -0
- package/dist/cjs/helpers/spacing.js +45 -0
- package/dist/cjs/helpers/tiktokpixel.js +17 -0
- package/dist/cjs/helpers/typography.js +7 -0
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -0
- package/dist/cjs/hooks/cart/use-cart-data.js +26 -0
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -0
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -0
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -0
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -0
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -0
- package/dist/cjs/hooks/shop/use-collection-query.js +16 -0
- package/dist/cjs/hooks/shop/use-product-query.js +16 -0
- package/dist/cjs/hooks/shop/use-products-query.js +16 -0
- package/dist/cjs/hooks/shop.js +80 -0
- package/dist/cjs/hooks/use-current-device.js +23 -0
- package/dist/cjs/hooks/use-lazy-video.js +15 -0
- package/dist/cjs/hooks/useCartId.js +36 -0
- package/dist/cjs/hooks/useCartLine.js +11 -0
- package/dist/cjs/hooks/useCartUI.js +42 -0
- package/dist/cjs/hooks/useCollection.js +9 -0
- package/dist/cjs/hooks/useFetchHandle.js +13 -0
- package/dist/cjs/hooks/useFormatMoney.js +17 -0
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -0
- package/dist/cjs/hooks/useLoadScript.js +30 -0
- package/dist/cjs/hooks/useMoney.js +52 -0
- package/dist/cjs/hooks/usePrevious.js +17 -0
- package/dist/cjs/hooks/useProduct.js +90 -0
- package/dist/cjs/hooks/useProductList.js +21 -0
- package/dist/cjs/hooks/useSuspenseFetch.js +24 -0
- package/dist/cjs/hooks/useSwatchesOptions.js +39 -0
- package/dist/cjs/index.js +229 -0
- package/dist/cjs/types/global-style.js +7 -0
- package/dist/cjs/types/shop.js +2 -0
- package/dist/esm/components/AddOn.js +14 -0
- package/dist/esm/components/ComponentWrapper.js +40 -0
- package/dist/esm/components/ComponentWrapperPreview.js +54 -0
- package/dist/esm/components/Empty.js +3 -0
- package/dist/esm/components/Render.js +24 -0
- package/dist/esm/components/RenderBlock.js +17 -0
- package/dist/esm/components/RenderPreview.js +24 -0
- package/dist/esm/components/RenderSection.js +15 -0
- package/dist/esm/contexts/AddonContext.js +21 -0
- package/dist/esm/contexts/BuilderComponent.js +27 -0
- package/dist/esm/contexts/BuilderContext.js +26 -0
- package/dist/esm/contexts/BuilderPreviewContext.js +350 -0
- package/dist/esm/contexts/CartLineContext.js +21 -0
- package/dist/esm/contexts/CollectionContext.js +20 -0
- package/dist/esm/contexts/ProductContext.js +123 -0
- package/dist/esm/contexts/ProductListContext.js +20 -0
- package/dist/esm/contexts/SectionContext.js +45 -0
- package/dist/esm/contexts/ShopContext.js +40 -0
- package/dist/esm/graphql/fragments/analytic.generated.js +9 -0
- package/dist/esm/graphql/fragments/collection-detail.generated.js +11 -0
- package/dist/esm/graphql/fragments/collection-product.generated.js +24 -0
- package/dist/esm/graphql/fragments/data-seo.generated.js +9 -0
- package/dist/esm/graphql/fragments/media.generated.js +12 -0
- package/dist/esm/graphql/fragments/product-little.generated.js +23 -0
- package/dist/esm/graphql/fragments/product-option-value.generated.js +11 -0
- package/dist/esm/graphql/fragments/product-option.generated.js +12 -0
- package/dist/esm/graphql/fragments/product.generated.js +31 -0
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +10 -0
- package/dist/esm/graphql/fragments/published-page-section.generated.js +9 -0
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +25 -0
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +9 -0
- package/dist/esm/graphql/fragments/selected-option.generated.js +9 -0
- package/dist/esm/graphql/fragments/variant.generated.js +33 -0
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +32 -0
- package/dist/esm/graphql/queries/collection.generated.js +50 -0
- package/dist/esm/graphql/queries/preview-page.generated.js +21 -0
- package/dist/esm/graphql/queries/product-little-detail.generated.js +22 -0
- package/dist/esm/graphql/queries/product-medias.generated.js +27 -0
- package/dist/esm/graphql/queries/product-variants.generated.js +31 -0
- package/dist/esm/graphql/queries/products.generated.js +38 -0
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +21 -0
- package/dist/esm/graphql/queries/storeProperty.generated.js +10 -0
- package/dist/esm/helpers/GlobalEvent.js +13 -0
- package/dist/esm/helpers/background.js +102 -0
- package/dist/esm/helpers/borders.js +133 -0
- package/dist/esm/helpers/clone-deep.js +3 -0
- package/dist/esm/helpers/cls.js +18 -0
- package/dist/esm/helpers/colors.js +145 -0
- package/dist/esm/helpers/compose-advance-style.js +130 -0
- package/dist/esm/helpers/constant.js +13 -0
- package/dist/esm/helpers/css-variable.js +5 -0
- package/dist/esm/helpers/email.js +6 -0
- package/dist/esm/helpers/flatten-connection.js +8 -0
- package/dist/esm/helpers/fpixel.js +25 -0
- package/dist/esm/helpers/get-resonsive-value.js +28 -0
- package/dist/esm/helpers/get-shortname.js +90 -0
- package/dist/esm/helpers/gtag.js +45 -0
- package/dist/esm/helpers/is-browser.js +5 -0
- package/dist/esm/helpers/is-defined.js +5 -0
- package/dist/esm/helpers/is-empty-children.js +7 -0
- package/dist/esm/helpers/layout.js +15 -0
- package/dist/esm/helpers/load-script.js +30 -0
- package/dist/esm/helpers/make-style.js +91 -0
- package/dist/esm/helpers/normalize-builder-data.js +15 -0
- package/dist/esm/helpers/prefetch-queries.js +66 -0
- package/dist/esm/helpers/product.js +32 -0
- package/dist/esm/helpers/queries/get-collection.js +170 -0
- package/dist/esm/helpers/queries/get-product-by-slug.js +97 -0
- package/dist/esm/helpers/queries/get-product.js +109 -0
- package/dist/esm/helpers/queries/get-products.js +133 -0
- package/dist/esm/helpers/radius.js +86 -0
- package/dist/esm/helpers/shadow.js +45 -0
- package/dist/esm/helpers/size.js +18 -0
- package/dist/esm/helpers/spacing.js +42 -0
- package/dist/esm/helpers/tiktokpixel.js +15 -0
- package/dist/esm/helpers/typography.js +5 -0
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -0
- package/dist/esm/hooks/cart/use-cart-data.js +24 -0
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -0
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -0
- package/dist/esm/hooks/cart/use-create-cart.js +20 -0
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -0
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -0
- package/dist/esm/hooks/shop/use-collection-query.js +14 -0
- package/dist/esm/hooks/shop/use-product-query.js +14 -0
- package/dist/esm/hooks/shop/use-products-query.js +14 -0
- package/dist/esm/hooks/shop.js +68 -0
- package/dist/esm/hooks/use-current-device.js +21 -0
- package/dist/esm/hooks/use-lazy-video.js +13 -0
- package/dist/esm/hooks/useCartId.js +32 -0
- package/dist/esm/hooks/useCartLine.js +7 -0
- package/dist/esm/hooks/useCartUI.js +38 -0
- package/dist/esm/hooks/useCollection.js +7 -0
- package/dist/esm/hooks/useFetchHandle.js +11 -0
- package/dist/esm/hooks/useFormatMoney.js +13 -0
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -0
- package/dist/esm/hooks/useLoadScript.js +26 -0
- package/dist/esm/hooks/useMoney.js +48 -0
- package/dist/esm/hooks/usePrevious.js +15 -0
- package/dist/esm/hooks/useProduct.js +78 -0
- package/dist/esm/hooks/useProductList.js +16 -0
- package/dist/esm/hooks/useSuspenseFetch.js +20 -0
- package/dist/esm/hooks/useSwatchesOptions.js +35 -0
- package/dist/esm/index.js +82 -0
- package/dist/esm/types/global-style.js +4 -0
- package/dist/esm/types/shop.js +1 -0
- package/dist/types/index.d.ts +7393 -0
- package/package.json +50 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var borders = require('./borders.js');
|
|
4
|
+
var colors = require('./colors.js');
|
|
5
|
+
var constant = require('./constant.js');
|
|
6
|
+
var radius = require('./radius.js');
|
|
7
|
+
var shadow = require('./shadow.js');
|
|
8
|
+
|
|
9
|
+
const composeSpacing = ({ source, spacing, type, suffix = '', }) => {
|
|
10
|
+
const { top, left, bottom, right } = spacing;
|
|
11
|
+
if (top)
|
|
12
|
+
source[`--${type}t${suffix}`] = top;
|
|
13
|
+
if (left)
|
|
14
|
+
source[`--${type}l${suffix}`] = left;
|
|
15
|
+
if (bottom)
|
|
16
|
+
source[`--${type}b${suffix}`] = bottom;
|
|
17
|
+
if (right)
|
|
18
|
+
source[`--${type}r${suffix}`] = right;
|
|
19
|
+
};
|
|
20
|
+
const getAttrValue = (attr, value, tag) => {
|
|
21
|
+
if (value === undefined || value === null)
|
|
22
|
+
return undefined;
|
|
23
|
+
switch (attr) {
|
|
24
|
+
case 'bgc':
|
|
25
|
+
case 'c':
|
|
26
|
+
return colors.isColor(value.toString()) ? value : `var(--g-c-${value})`;
|
|
27
|
+
case 'd':
|
|
28
|
+
if (!value)
|
|
29
|
+
return 'none';
|
|
30
|
+
if (value && tag && constant.layoutComponent.includes(tag))
|
|
31
|
+
return 'grid';
|
|
32
|
+
return 'inline';
|
|
33
|
+
default:
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function composeAdvanceStyle(data, tag) {
|
|
38
|
+
if (!data)
|
|
39
|
+
return {};
|
|
40
|
+
const styles = {};
|
|
41
|
+
const devices = ['desktop', 'tablet', 'mobile'];
|
|
42
|
+
const states = ['hover', 'normal'];
|
|
43
|
+
Object.keys(data).forEach((attr) => {
|
|
44
|
+
const value = data[attr];
|
|
45
|
+
if (value === undefined || value === null)
|
|
46
|
+
return;
|
|
47
|
+
const hasBoxShadow = (data.hasBoxShadow ? data.hasBoxShadow : {});
|
|
48
|
+
if (typeof value === 'object') {
|
|
49
|
+
if (Array.isArray(value))
|
|
50
|
+
return;
|
|
51
|
+
Object.keys(value).forEach((composeAttr) => {
|
|
52
|
+
if (devices.includes(composeAttr)) {
|
|
53
|
+
const deviceValue = value[composeAttr];
|
|
54
|
+
if (deviceValue !== undefined) {
|
|
55
|
+
// Responsive border with state
|
|
56
|
+
if (attr === 'border') {
|
|
57
|
+
Object.assign(styles, borders.handleConvertBorderStyle(value), borders.handleConvertBorderWidth(value), borders.handleConvertBorderColor(value));
|
|
58
|
+
}
|
|
59
|
+
if (attr === 'rounded') {
|
|
60
|
+
Object.assign(styles, radius.composeRadius(value));
|
|
61
|
+
}
|
|
62
|
+
if (composeAttr === 'desktop') {
|
|
63
|
+
switch (attr) {
|
|
64
|
+
case 'padding':
|
|
65
|
+
composeSpacing({
|
|
66
|
+
source: styles,
|
|
67
|
+
spacing: deviceValue,
|
|
68
|
+
type: 'p',
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case 'margin':
|
|
72
|
+
composeSpacing({
|
|
73
|
+
source: styles,
|
|
74
|
+
spacing: deviceValue,
|
|
75
|
+
type: 'm',
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
case 'm':
|
|
79
|
+
case 'p':
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
styles[`--${attr}`] = getAttrValue(attr, deviceValue, tag);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
switch (attr) {
|
|
88
|
+
case 'padding':
|
|
89
|
+
composeSpacing({
|
|
90
|
+
source: styles,
|
|
91
|
+
spacing: deviceValue,
|
|
92
|
+
type: 'p',
|
|
93
|
+
suffix: `-${composeAttr}`,
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
case 'margin':
|
|
97
|
+
composeSpacing({
|
|
98
|
+
source: styles,
|
|
99
|
+
spacing: deviceValue,
|
|
100
|
+
type: 'm',
|
|
101
|
+
suffix: `-${composeAttr}`,
|
|
102
|
+
});
|
|
103
|
+
break;
|
|
104
|
+
case 'm':
|
|
105
|
+
case 'p':
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
styles[`--${attr}-${composeAttr}`] = getAttrValue(attr, deviceValue, tag);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (states.includes(composeAttr)) {
|
|
115
|
+
switch (attr) {
|
|
116
|
+
case 'hasBoxShadow':
|
|
117
|
+
break;
|
|
118
|
+
case 'boxShadow':
|
|
119
|
+
Object.assign(styles, shadow.getStyleShadowState(value, 'box-shadow', hasBoxShadow));
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
styles[`--${attr}`] = getAttrValue(attr, value, tag);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return styles;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exports.composeAdvanceStyle = composeAdvanceStyle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const stateMapping = {
|
|
4
|
+
normal: '',
|
|
5
|
+
hover: '-hvr',
|
|
6
|
+
focus: '-focus',
|
|
7
|
+
};
|
|
8
|
+
const devicesMapping = {
|
|
9
|
+
desktop: '',
|
|
10
|
+
tablet: '-tablet',
|
|
11
|
+
mobile: '-mobile',
|
|
12
|
+
};
|
|
13
|
+
const layoutComponent = ['Row', 'Section', 'Product', 'HeroBanner'];
|
|
14
|
+
|
|
15
|
+
exports.devicesMapping = devicesMapping;
|
|
16
|
+
exports.layoutComponent = layoutComponent;
|
|
17
|
+
exports.stateMapping = stateMapping;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const validateEmail = (email) => {
|
|
6
|
+
const emailRegex = new RegExp(/^(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*|".+")@(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]|(?:[a-zA-Z\-\d]+\.)+[a-zA-Z]{2,})$/);
|
|
7
|
+
return emailRegex.test(email);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
exports.default = validateEmail;
|
|
11
|
+
exports.validateEmail = validateEmail;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](api/storefront/reference/products/product#connections)) into a flat array of nodes.
|
|
5
|
+
*/
|
|
6
|
+
const flattenConnection = (connection) => {
|
|
7
|
+
return connection?.edges?.map((edge) => edge.node) ?? [];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
exports.flattenConnection = flattenConnection;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const pageview = () => {
|
|
4
|
+
if (!window.fbq)
|
|
5
|
+
return;
|
|
6
|
+
window.fbq('track', 'PageView');
|
|
7
|
+
};
|
|
8
|
+
// https://developers.facebook.com/docs/facebook-pixel/advanced/
|
|
9
|
+
const event = (name, options = {}) => {
|
|
10
|
+
if (!window.fbq)
|
|
11
|
+
return;
|
|
12
|
+
window.fbq('track', name, options);
|
|
13
|
+
};
|
|
14
|
+
const addToCart = (product) => {
|
|
15
|
+
if (!window.fbq)
|
|
16
|
+
return;
|
|
17
|
+
window.fbq('track', 'AddToCart', {
|
|
18
|
+
content_ids: [product.id],
|
|
19
|
+
content_name: product.name,
|
|
20
|
+
content_category: product.category,
|
|
21
|
+
content_type: 'product',
|
|
22
|
+
value: product.price,
|
|
23
|
+
currency: product.currency,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.addToCart = addToCart;
|
|
28
|
+
exports.event = event;
|
|
29
|
+
exports.pageview = pageview;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getResponsiveValue = (input, k) => {
|
|
4
|
+
if (!k)
|
|
5
|
+
return {};
|
|
6
|
+
return {
|
|
7
|
+
desktop: input?.desktop?.[k],
|
|
8
|
+
tablet: input?.tablet?.[k],
|
|
9
|
+
mobile: input?.mobile?.[k],
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const getResponsiveStateValue = (k, input) => {
|
|
13
|
+
return {
|
|
14
|
+
desktop: input?.desktop?.[k],
|
|
15
|
+
tablet: input?.tablet?.[k],
|
|
16
|
+
mobile: input?.mobile?.[k],
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const getResponsiveValueByScreen = (value, breakpoint, defaultValue) => {
|
|
20
|
+
switch (breakpoint) {
|
|
21
|
+
case 'tablet':
|
|
22
|
+
return value?.tablet ?? value?.desktop ?? defaultValue;
|
|
23
|
+
case 'mobile':
|
|
24
|
+
return value?.mobile ?? value?.tablet ?? value?.desktop ?? defaultValue;
|
|
25
|
+
default:
|
|
26
|
+
return value?.desktop ?? defaultValue;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.getResponsiveStateValue = getResponsiveStateValue;
|
|
31
|
+
exports.getResponsiveValue = getResponsiveValue;
|
|
32
|
+
exports.getResponsiveValueByScreen = getResponsiveValueByScreen;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const globalSortNameMapping = {
|
|
4
|
+
'typography-heading-1-fontFamily': 'h1-ff',
|
|
5
|
+
'typography-heading-1-fontSize': 'h1-size',
|
|
6
|
+
'typography-heading-1-fontWeight': 'h1-weight',
|
|
7
|
+
'typography-heading-1-lineHeight': 'h1-lh',
|
|
8
|
+
'typography-heading-1-letterSpacing': 'h1-ls',
|
|
9
|
+
'typography-heading-1-fontStyle': 'h1-fs',
|
|
10
|
+
'typography-heading-2-fontFamily': 'h2-ff',
|
|
11
|
+
'typography-heading-2-fontSize': 'h2-size',
|
|
12
|
+
'typography-heading-2-fontWeight': 'h2-weight',
|
|
13
|
+
'typography-heading-2-lineHeight': 'h2-lh',
|
|
14
|
+
'typography-heading-2-letterSpacing': 'h2-ls',
|
|
15
|
+
'typography-heading-2-fontStyle': 'h2-fs',
|
|
16
|
+
'typography-heading-3-fontFamily': 'h3-ff',
|
|
17
|
+
'typography-heading-3-fontSize': 'h3-size',
|
|
18
|
+
'typography-heading-3-fontWeight': 'h3-weight',
|
|
19
|
+
'typography-heading-3-lineHeight': 'h3-lh',
|
|
20
|
+
'typography-heading-3-letterSpacing': 'h3-ls',
|
|
21
|
+
'typography-heading-3-fontStyle': 'h3-fs',
|
|
22
|
+
'typography-subheading-1-fontFamily': 'sh1-ff',
|
|
23
|
+
'typography-subheading-1-fontSize': 'sh1-size',
|
|
24
|
+
'typography-subheading-1-fontWeight': 'sh1-weight',
|
|
25
|
+
'typography-subheading-1-lineHeight': 'sh1-lh',
|
|
26
|
+
'typography-subheading-1-letterSpacing': 'sh1-ls',
|
|
27
|
+
'typography-subheading-1-fontStyle': 'sh1-fs',
|
|
28
|
+
'typography-subheading-2-fontFamily': 'sh2-ff',
|
|
29
|
+
'typography-subheading-2-fontSize': 'sh2-size',
|
|
30
|
+
'typography-subheading-2-fontWeight': 'sh2-weight',
|
|
31
|
+
'typography-subheading-2-lineHeight': 'sh2-lh',
|
|
32
|
+
'typography-subheading-2-letterSpacing': 'sh2-ls',
|
|
33
|
+
'typography-subheading-2-fontStyle': 'sh2-fs',
|
|
34
|
+
'typography-subheading-3-fontFamily': 'sh3-ff',
|
|
35
|
+
'typography-subheading-3-fontSize': 'sh3-size',
|
|
36
|
+
'typography-subheading-3-fontWeight': 'sh3-weight',
|
|
37
|
+
'typography-subheading-3-lineHeight': 'sh3-lh',
|
|
38
|
+
'typography-subheading-3-letterSpacing': 'sh3-ls',
|
|
39
|
+
'typography-subheading-3-fontStyle': 'sh3-fs',
|
|
40
|
+
'typography-paragraph-1-fontFamily': 'p1-ff',
|
|
41
|
+
'typography-paragraph-1-fontSize': 'p1-size',
|
|
42
|
+
'typography-paragraph-1-fontWeight': 'p1-weight',
|
|
43
|
+
'typography-paragraph-1-lineHeight': 'p1-lh',
|
|
44
|
+
'typography-paragraph-1-letterSpacing': 'p1-ls',
|
|
45
|
+
'typography-paragraph-1-fontStyle': 'p1-fs',
|
|
46
|
+
'typography-paragraph-2-fontFamily': 'p2-ff',
|
|
47
|
+
'typography-paragraph-2-fontSize': 'p2-size',
|
|
48
|
+
'typography-paragraph-2-fontWeight': 'p2-weight',
|
|
49
|
+
'typography-paragraph-2-lineHeight': 'p2-lh',
|
|
50
|
+
'typography-paragraph-2-letterSpacing': 'p2-ls',
|
|
51
|
+
'typography-paragraph-2-fontStyle': 'p2-fs',
|
|
52
|
+
'typography-paragraph-3-fontFamily': 'p3-ff',
|
|
53
|
+
'typography-paragraph-3-fontSize': 'p3-size',
|
|
54
|
+
'typography-paragraph-3-fontWeight': 'p3-weight',
|
|
55
|
+
'typography-paragraph-3-lineHeight': 'p3-lh',
|
|
56
|
+
'typography-paragraph-3-letterSpacing': 'p3-ls',
|
|
57
|
+
'typography-paragraph-3-fontStyle': 'p3-fs',
|
|
58
|
+
'color-brand': 'c-brand',
|
|
59
|
+
'color-highlight': 'c-highlight',
|
|
60
|
+
'color-text-1': 'c-text-1',
|
|
61
|
+
'color-text-2': 'c-text-2',
|
|
62
|
+
'color-text-3': 'c-text-3',
|
|
63
|
+
'color-bg-1': 'c-bg-1',
|
|
64
|
+
'color-bg-2': 'c-bg-2',
|
|
65
|
+
'color-bg-3': 'c-bg-3',
|
|
66
|
+
'color-line-1': 'c-line-1',
|
|
67
|
+
'color-line-2': 'c-line-2',
|
|
68
|
+
'color-line-3': 'c-line-3',
|
|
69
|
+
'color-success': 'c-success',
|
|
70
|
+
'color-info': 'c-info',
|
|
71
|
+
'color-warning': 'c-warning',
|
|
72
|
+
'color-error': 'c-error',
|
|
73
|
+
'spacing-xxs': 's-xxs',
|
|
74
|
+
'spacing-xs': 's-xs',
|
|
75
|
+
'spacing-s': 's-s',
|
|
76
|
+
'spacing-m': 's-m',
|
|
77
|
+
'spacing-l': 's-l',
|
|
78
|
+
'spacing-xl': 's-xl',
|
|
79
|
+
'spacing-2xl': 's-2xl',
|
|
80
|
+
'spacing-3xl': 's-3xl',
|
|
81
|
+
'spacing-4xl': 's-4xl',
|
|
82
|
+
'spacing-5xl': 's-5xl',
|
|
83
|
+
'container-width': 'ct-w',
|
|
84
|
+
'container-padding': 'ct-p',
|
|
85
|
+
'text-shadow': 'ts',
|
|
86
|
+
'box-shadow': 'shadow',
|
|
87
|
+
};
|
|
88
|
+
function getShortName(name) {
|
|
89
|
+
return globalSortNameMapping[name] || name;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.getShortName = getShortName;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
|
|
4
|
+
const pageview = (url, trackingId) => {
|
|
5
|
+
// GA 4
|
|
6
|
+
if (window.gtag && trackingId) {
|
|
7
|
+
window.gtag('config', trackingId, {
|
|
8
|
+
page_path: url,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
// GA 3
|
|
12
|
+
if (window.ga) {
|
|
13
|
+
window.ga('send', 'pageview', url);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const addToCart = (product) => {
|
|
17
|
+
// GA 3
|
|
18
|
+
if (window.ga) {
|
|
19
|
+
window.ga('ec:addProduct', product);
|
|
20
|
+
window.ga('send', 'event', {
|
|
21
|
+
eventCategory: 'EnhancedEcommerce',
|
|
22
|
+
eventAction: 'Added Product',
|
|
23
|
+
eventLabel: undefined,
|
|
24
|
+
nonInteraction: true,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// GA 4
|
|
28
|
+
if (window.gtag) {
|
|
29
|
+
window.gtag('event', 'add_to_cart', {
|
|
30
|
+
currency: product.currency,
|
|
31
|
+
value: product.price,
|
|
32
|
+
items: [
|
|
33
|
+
{
|
|
34
|
+
currency: product.currency,
|
|
35
|
+
item_brand: product.brand,
|
|
36
|
+
item_id: product.id,
|
|
37
|
+
item_name: product.name,
|
|
38
|
+
item_variant: product.variant,
|
|
39
|
+
item_category: product.category,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
debug_mode: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.addToCart = addToCart;
|
|
48
|
+
exports.pageview = pageview;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const isEmptyChildren = (children) => {
|
|
8
|
+
return react.Children.count(children) < 1 || !children;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.default = isEmptyChildren;
|
|
12
|
+
exports.isEmptyChildren = isEmptyChildren;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constant = require('./constant.js');
|
|
4
|
+
|
|
5
|
+
const optionLayoutStyle = (column) => {
|
|
6
|
+
if (!column)
|
|
7
|
+
return {};
|
|
8
|
+
const style = {};
|
|
9
|
+
for (const [key, value] of Object.entries(column)) {
|
|
10
|
+
Object.assign(style, {
|
|
11
|
+
[`--gtc${constant.devicesMapping?.[key]}`]: `repeat(${parseFloat(value + '') || 1}, minmax(0, 1fr))`,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return style;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.optionLayoutStyle = optionLayoutStyle;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SCRIPTS_LOADED = {};
|
|
4
|
+
function loadScript(src, options) {
|
|
5
|
+
const isScriptLoaded = SCRIPTS_LOADED[src];
|
|
6
|
+
if (isScriptLoaded) {
|
|
7
|
+
return isScriptLoaded;
|
|
8
|
+
}
|
|
9
|
+
const promise = new Promise((resolve, reject) => {
|
|
10
|
+
const script = document.createElement('script');
|
|
11
|
+
if (options?.module) {
|
|
12
|
+
script.type = 'module';
|
|
13
|
+
}
|
|
14
|
+
script.src = src;
|
|
15
|
+
script.onload = () => {
|
|
16
|
+
resolve(true);
|
|
17
|
+
};
|
|
18
|
+
script.onerror = () => {
|
|
19
|
+
reject(false);
|
|
20
|
+
};
|
|
21
|
+
if (options?.in === 'head') {
|
|
22
|
+
document.head.appendChild(script);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
document.body.appendChild(script);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
SCRIPTS_LOADED[src] = promise;
|
|
29
|
+
return promise;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.loadScript = loadScript;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getResonsiveValue = require('./get-resonsive-value.js');
|
|
4
|
+
|
|
5
|
+
const makeStyle = (style) => {
|
|
6
|
+
return Object.fromEntries(Object.entries(style).map(([key, value]) => [`--${key}`, value]));
|
|
7
|
+
};
|
|
8
|
+
const makeStyleState = (name, value) => {
|
|
9
|
+
if (!value)
|
|
10
|
+
return {};
|
|
11
|
+
return {
|
|
12
|
+
[`--${name}`]: value?.normal,
|
|
13
|
+
[`--hvr-${name}`]: value?.hover,
|
|
14
|
+
[`--focus-${name}`]: value?.focus,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const makeStyleResponsiveState = (name, value) => {
|
|
18
|
+
if (!value)
|
|
19
|
+
return {};
|
|
20
|
+
return {
|
|
21
|
+
[`--${name}`]: value?.desktop?.normal,
|
|
22
|
+
[`--hvr-${name}`]: value?.desktop?.hover,
|
|
23
|
+
[`--focus-${name}`]: value?.desktop?.focus,
|
|
24
|
+
[`--${name}-tablet`]: value?.tablet?.normal,
|
|
25
|
+
[`--hvr-${name}-tablet`]: value?.tablet?.hover,
|
|
26
|
+
[`--focus-${name}-tablet`]: value?.tablet?.focus,
|
|
27
|
+
[`--${name}-mobile`]: value?.mobile?.normal,
|
|
28
|
+
[`--hvr-${name}-mobile`]: value?.mobile?.hover,
|
|
29
|
+
[`--focus-${name}-mobile`]: value?.mobile?.focus,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const makeStyleResponsive = (name, value) => {
|
|
33
|
+
return {
|
|
34
|
+
[`--${name}`]: value?.desktop,
|
|
35
|
+
[`--${name}-tablet`]: value?.tablet,
|
|
36
|
+
[`--${name}-mobile`]: value?.mobile,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const makeWidth = (widthValue, fullWidthValue) => {
|
|
40
|
+
const getVal = (deviceValue, widthValue, fullWidthValue) => {
|
|
41
|
+
const widthVal = widthValue?.[deviceValue];
|
|
42
|
+
const fullWidthVal = fullWidthValue?.[deviceValue];
|
|
43
|
+
if (fullWidthVal) {
|
|
44
|
+
return '100%';
|
|
45
|
+
}
|
|
46
|
+
else if (fullWidthVal === false) {
|
|
47
|
+
return widthVal ?? widthVal;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return widthVal;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
desktop: getVal('desktop', widthValue, fullWidthValue),
|
|
55
|
+
tablet: getVal('tablet', widthValue, fullWidthValue),
|
|
56
|
+
mobile: getVal('mobile', widthValue, fullWidthValue),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const makeHeight = (heighValue, autoHeight) => {
|
|
60
|
+
const getVal = (deviceValue, heighValue, autoHeight) => {
|
|
61
|
+
const heightVal = heighValue?.[deviceValue];
|
|
62
|
+
const isAuto = autoHeight?.[deviceValue];
|
|
63
|
+
if (isAuto) {
|
|
64
|
+
return 'auto';
|
|
65
|
+
}
|
|
66
|
+
else if (isAuto === false) {
|
|
67
|
+
return heightVal ?? heightVal;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return heightVal;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
desktop: getVal('desktop', heighValue, autoHeight),
|
|
75
|
+
tablet: getVal('tablet', heighValue, autoHeight),
|
|
76
|
+
mobile: getVal('mobile', heighValue, autoHeight),
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight) => {
|
|
80
|
+
return {
|
|
81
|
+
desktop: aspectRatio?.desktop === 'custom'
|
|
82
|
+
? `${getResonsiveValue.getResponsiveValueByScreen(aspectWidth, 'desktop')}/${getResonsiveValue.getResponsiveValueByScreen(aspectHeight, 'desktop')}`
|
|
83
|
+
: aspectRatio?.desktop,
|
|
84
|
+
tablet: aspectRatio?.tablet === 'custom'
|
|
85
|
+
? `${getResonsiveValue.getResponsiveValueByScreen(aspectWidth, 'tablet')}/${getResonsiveValue.getResponsiveValueByScreen(aspectHeight, 'tablet')}`
|
|
86
|
+
: aspectRatio?.tablet,
|
|
87
|
+
mobile: aspectRatio?.mobile === 'custom'
|
|
88
|
+
? `${getResonsiveValue.getResponsiveValueByScreen(aspectWidth, 'mobile')}/${getResonsiveValue.getResponsiveValueByScreen(aspectHeight, 'mobile')}`
|
|
89
|
+
: aspectRatio?.mobile,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
exports.makeAspectRatio = makeAspectRatio;
|
|
94
|
+
exports.makeHeight = makeHeight;
|
|
95
|
+
exports.makeStyle = makeStyle;
|
|
96
|
+
exports.makeStyleResponsive = makeStyleResponsive;
|
|
97
|
+
exports.makeStyleResponsiveState = makeStyleResponsiveState;
|
|
98
|
+
exports.makeStyleState = makeStyleState;
|
|
99
|
+
exports.makeWidth = makeWidth;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function normalizeBuilderData(data) {
|
|
4
|
+
const result = {};
|
|
5
|
+
function compose(data, res = {}) {
|
|
6
|
+
const childrens = data.childrens;
|
|
7
|
+
const items = childrens?.map((child) => child.uid) ?? [];
|
|
8
|
+
res[data.uid] = { ...data, childrens: items, type: 'component' };
|
|
9
|
+
if (childrens) {
|
|
10
|
+
childrens.map((child) => compose(child, res));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
compose(data, result);
|
|
14
|
+
return { ...result };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.normalizeBuilderData = normalizeBuilderData;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useSWR = require('swr');
|
|
4
|
+
var getCollection = require('./queries/get-collection.js');
|
|
5
|
+
var getProduct = require('./queries/get-product.js');
|
|
6
|
+
var getProducts = require('./queries/get-products.js');
|
|
7
|
+
|
|
8
|
+
const prefetchQueries = (input, isSample) => {
|
|
9
|
+
const queries = [];
|
|
10
|
+
Object.keys(input).forEach((key) => {
|
|
11
|
+
const item = input[key];
|
|
12
|
+
let data = undefined;
|
|
13
|
+
switch (item.tag) {
|
|
14
|
+
case 'Product': {
|
|
15
|
+
if (item.settings?.isAuto)
|
|
16
|
+
break;
|
|
17
|
+
data = {
|
|
18
|
+
key: useSWR.unstable_serialize([
|
|
19
|
+
'query/product',
|
|
20
|
+
{ id: item.settings?.productSetting?.productId ?? 'latest', isSample },
|
|
21
|
+
]),
|
|
22
|
+
func: getProduct.getProduct,
|
|
23
|
+
variables: { id: item.settings?.productSetting?.productId ?? 'latest', isSample },
|
|
24
|
+
};
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case 'ProductList': {
|
|
28
|
+
if (item?.settings?.productSrc === 'Collection') {
|
|
29
|
+
data = {
|
|
30
|
+
key: useSWR.unstable_serialize([
|
|
31
|
+
'query/collection',
|
|
32
|
+
{
|
|
33
|
+
id: item.settings?.collectionId ?? 'latest',
|
|
34
|
+
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
35
|
+
orderBy: item.settings?.orderBy,
|
|
36
|
+
isSample,
|
|
37
|
+
},
|
|
38
|
+
]),
|
|
39
|
+
func: getCollection.getCollection,
|
|
40
|
+
variables: {
|
|
41
|
+
id: item.settings?.collectionId ?? 'latest',
|
|
42
|
+
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
43
|
+
orderBy: item.settings?.orderBy,
|
|
44
|
+
isSample,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
data = {
|
|
50
|
+
key: useSWR.unstable_serialize([
|
|
51
|
+
'query/products',
|
|
52
|
+
{ ids: item?.settings?.productIds?.sort(), isSample },
|
|
53
|
+
]),
|
|
54
|
+
func: getProducts.getProducts,
|
|
55
|
+
variables: { ids: item?.settings?.productIds?.sort(), isSample },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (data) {
|
|
62
|
+
queries.push(data);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return queries;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.prefetchQueries = prefetchQueries;
|