@gem-sdk/core 1.14.0-next.91 → 1.14.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 -1
- package/dist/cjs/components/ComponentWrapper.js +28 -1
- package/dist/cjs/components/ComponentWrapperPreview.js +72 -1
- package/dist/cjs/components/Empty.js +7 -1
- package/dist/cjs/components/Render.js +65 -1
- package/dist/cjs/components/Render.liquid.js +158 -3
- package/dist/cjs/components/RenderBlock.js +54 -1
- package/dist/cjs/components/RenderPreview.js +66 -1
- package/dist/cjs/components/RenderSection.js +23 -1
- package/dist/cjs/components/constant.js +39 -1
- package/dist/cjs/contexts/AddonContext.js +36 -1
- package/dist/cjs/contexts/BuilderComponent.js +34 -1
- package/dist/cjs/contexts/BuilderContext.js +35 -1
- package/dist/cjs/contexts/BuilderPreviewContext.js +370 -1
- package/dist/cjs/contexts/CartLineContext.js +29 -1
- package/dist/cjs/contexts/CollectionContext.js +38 -1
- package/dist/cjs/contexts/ModalContext.js +47 -1
- package/dist/cjs/contexts/ProductContext.js +149 -1
- package/dist/cjs/contexts/ProductListContext.js +32 -1
- package/dist/cjs/contexts/SectionContext.js +53 -1
- package/dist/cjs/contexts/ShopContext.js +70 -1
- package/dist/cjs/graphql/fragments/analytic.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-code.generated.js +6 -2
- package/dist/cjs/graphql/fragments/data-seo.generated.js +6 -2
- package/dist/cjs/graphql/fragments/media.generated.js +6 -3
- package/dist/cjs/graphql/fragments/product-little.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +6 -2
- package/dist/cjs/graphql/fragments/selected-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/variant.generated.js +6 -2
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +7 -3
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +16 -2
- package/dist/cjs/graphql/queries/collection.generated.js +14 -2
- package/dist/cjs/graphql/queries/collections.generated.js +9 -2
- package/dist/cjs/graphql/queries/preview-page.generated.js +14 -2
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +11 -2
- package/dist/cjs/graphql/queries/product-medias.generated.js +8 -2
- package/dist/cjs/graphql/queries/product-variants.generated.js +10 -2
- package/dist/cjs/graphql/queries/products.generated.js +17 -3
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +14 -2
- package/dist/cjs/graphql/queries/store-property.generated.js +6 -2
- package/dist/cjs/helpers/GlobalEvent.js +19 -1
- package/dist/cjs/helpers/background.js +109 -1
- package/dist/cjs/helpers/borders.js +183 -4
- package/dist/cjs/helpers/clone-deep.js +5 -1
- package/dist/cjs/helpers/cls.js +16 -1
- package/dist/cjs/helpers/colors.js +183 -1
- package/dist/cjs/helpers/compose-advance-style.js +188 -1
- package/dist/cjs/helpers/constant.js +23 -1
- package/dist/cjs/helpers/convert.js +7 -1
- package/dist/cjs/helpers/css-variable.js +7 -1
- package/dist/cjs/helpers/email.js +11 -1
- package/dist/cjs/helpers/flatten-connection.js +9 -1
- package/dist/cjs/helpers/get-resonsive-value.js +31 -1
- package/dist/cjs/helpers/get-shortname.js +92 -1
- package/dist/cjs/helpers/is-browser.js +9 -1
- package/dist/cjs/helpers/is-defined.js +7 -1
- package/dist/cjs/helpers/is-empty-children.js +12 -1
- package/dist/cjs/helpers/is-safari.js +9 -1
- package/dist/cjs/helpers/layout.js +59 -1
- package/dist/cjs/helpers/load-script.js +31 -1
- package/dist/cjs/helpers/make-style.js +128 -1
- package/dist/cjs/helpers/normalize-builder-data.js +23 -1
- package/dist/cjs/helpers/prefetch-queries.js +78 -1
- package/dist/cjs/helpers/product.js +45 -1
- package/dist/cjs/helpers/queries/get-collection.js +220 -1
- package/dist/cjs/helpers/queries/get-collections.js +21 -1
- package/dist/cjs/helpers/queries/get-product-by-slug.js +125 -1
- package/dist/cjs/helpers/queries/get-product.js +154 -1
- package/dist/cjs/helpers/queries/get-products.js +161 -1
- package/dist/cjs/helpers/query.js +29 -1
- package/dist/cjs/helpers/radius.js +131 -6
- package/dist/cjs/helpers/render.js +71 -1
- package/dist/cjs/helpers/shadow.js +56 -1
- package/dist/cjs/helpers/size.js +35 -4
- package/dist/cjs/helpers/spacing.js +43 -1
- package/dist/cjs/helpers/tracking/fpixel.js +28 -1
- package/dist/cjs/helpers/tracking/gtag.js +93 -1
- package/dist/cjs/helpers/tracking/tiktokpixel.js +17 -1
- package/dist/cjs/helpers/typography.js +105 -17
- package/dist/cjs/helpers/variant.js +8 -1
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-data.js +28 -1
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -1
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -1
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -1
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -1
- package/dist/cjs/hooks/shop/use-collection-query.js +22 -1
- package/dist/cjs/hooks/shop/use-collections-query.js +17 -1
- package/dist/cjs/hooks/shop/use-product-query.js +22 -1
- package/dist/cjs/hooks/shop/use-products-query.js +22 -1
- package/dist/cjs/hooks/shop.js +126 -1
- package/dist/cjs/hooks/use-current-device.js +21 -1
- package/dist/cjs/hooks/use-lazy-video.js +15 -1
- package/dist/cjs/hooks/useCartId.js +44 -1
- package/dist/cjs/hooks/useCartLine.js +11 -1
- package/dist/cjs/hooks/useCartUI.js +48 -1
- package/dist/cjs/hooks/useCollection.js +9 -1
- package/dist/cjs/hooks/useFetchHandle.js +13 -1
- package/dist/cjs/hooks/useFormatMoney.js +58 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -1
- package/dist/cjs/hooks/useLoadScript.js +32 -1
- package/dist/cjs/hooks/useMoney.js +84 -1
- package/dist/cjs/hooks/usePrevious.js +19 -1
- package/dist/cjs/hooks/useProduct.js +124 -1
- package/dist/cjs/hooks/useProductList.js +21 -1
- package/dist/cjs/hooks/useSuspenseFetch.js +27 -1
- package/dist/cjs/hooks/useSwatchesOptions.js +41 -1
- package/dist/cjs/index.js +291 -1
- package/dist/cjs/types/global-style.js +14 -1
- package/dist/cjs/types/shop.js +2 -1
- package/dist/esm/components/AddOn.js +14 -1
- package/dist/esm/components/ComponentWrapper.js +24 -1
- package/dist/esm/components/ComponentWrapperPreview.js +68 -1
- package/dist/esm/components/Empty.js +3 -1
- package/dist/esm/components/Render.js +61 -1
- package/dist/esm/components/Render.liquid.js +153 -3
- package/dist/esm/components/RenderBlock.js +50 -1
- package/dist/esm/components/RenderPreview.js +62 -1
- package/dist/esm/components/RenderSection.js +19 -1
- package/dist/esm/components/constant.js +37 -1
- package/dist/esm/contexts/AddonContext.js +32 -1
- package/dist/esm/contexts/BuilderComponent.js +31 -1
- package/dist/esm/contexts/BuilderContext.js +32 -1
- package/dist/esm/contexts/BuilderPreviewContext.js +367 -1
- package/dist/esm/contexts/CartLineContext.js +26 -1
- package/dist/esm/contexts/CollectionContext.js +35 -1
- package/dist/esm/contexts/ModalContext.js +44 -1
- package/dist/esm/contexts/ProductContext.js +146 -1
- package/dist/esm/contexts/ProductListContext.js +28 -1
- package/dist/esm/contexts/SectionContext.js +49 -1
- package/dist/esm/contexts/ShopContext.js +67 -1
- package/dist/esm/graphql/fragments/analytic.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-detail.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-product.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-code.generated.js +4 -2
- package/dist/esm/graphql/fragments/data-seo.generated.js +4 -2
- package/dist/esm/graphql/fragments/media.generated.js +4 -3
- package/dist/esm/graphql/fragments/product-little.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option-value.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/product.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-page-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +4 -2
- package/dist/esm/graphql/fragments/selected-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/variant.generated.js +4 -2
- package/dist/esm/graphql/mutations/page-view-up.generated.js +5 -3
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +22 -10
- package/dist/esm/graphql/queries/collection.generated.js +18 -8
- package/dist/esm/graphql/queries/collections.generated.js +8 -3
- package/dist/esm/graphql/queries/preview-page.generated.js +18 -8
- package/dist/esm/graphql/queries/product-little-detail.generated.js +12 -5
- package/dist/esm/graphql/queries/product-medias.generated.js +6 -2
- package/dist/esm/graphql/queries/product-variants.generated.js +10 -4
- package/dist/esm/graphql/queries/products.generated.js +20 -9
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +18 -8
- package/dist/esm/graphql/queries/store-property.generated.js +4 -2
- package/dist/esm/helpers/GlobalEvent.js +15 -1
- package/dist/esm/helpers/background.js +106 -1
- package/dist/esm/helpers/borders.js +175 -4
- package/dist/esm/helpers/clone-deep.js +3 -1
- package/dist/esm/helpers/cls.js +14 -1
- package/dist/esm/helpers/colors.js +168 -1
- package/dist/esm/helpers/compose-advance-style.js +185 -1
- package/dist/esm/helpers/constant.js +19 -1
- package/dist/esm/helpers/convert.js +4 -1
- package/dist/esm/helpers/css-variable.js +5 -1
- package/dist/esm/helpers/email.js +6 -1
- package/dist/esm/helpers/flatten-connection.js +7 -1
- package/dist/esm/helpers/get-resonsive-value.js +27 -1
- package/dist/esm/helpers/get-shortname.js +90 -1
- package/dist/esm/helpers/is-browser.js +5 -1
- package/dist/esm/helpers/is-defined.js +5 -1
- package/dist/esm/helpers/is-empty-children.js +7 -1
- package/dist/esm/helpers/is-safari.js +5 -1
- package/dist/esm/helpers/layout.js +54 -1
- package/dist/esm/helpers/load-script.js +29 -1
- package/dist/esm/helpers/make-style.js +117 -1
- package/dist/esm/helpers/normalize-builder-data.js +21 -1
- package/dist/esm/helpers/prefetch-queries.js +76 -1
- package/dist/esm/helpers/product.js +41 -1
- package/dist/esm/helpers/queries/get-collection.js +217 -1
- package/dist/esm/helpers/queries/get-collections.js +19 -1
- package/dist/esm/helpers/queries/get-product-by-slug.js +123 -1
- package/dist/esm/helpers/queries/get-product.js +150 -1
- package/dist/esm/helpers/queries/get-products.js +159 -1
- package/dist/esm/helpers/query.js +25 -1
- package/dist/esm/helpers/radius.js +124 -6
- package/dist/esm/helpers/render.js +64 -1
- package/dist/esm/helpers/shadow.js +51 -1
- package/dist/esm/helpers/size.js +31 -4
- package/dist/esm/helpers/spacing.js +40 -1
- package/dist/esm/helpers/tracking/fpixel.js +24 -1
- package/dist/esm/helpers/tracking/gtag.js +87 -1
- package/dist/esm/helpers/tracking/tiktokpixel.js +15 -1
- package/dist/esm/helpers/typography.js +96 -17
- package/dist/esm/helpers/variant.js +6 -1
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -1
- package/dist/esm/hooks/cart/use-cart-data.js +26 -1
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -1
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -1
- package/dist/esm/hooks/cart/use-create-cart.js +20 -1
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -1
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -1
- package/dist/esm/hooks/shop/use-collection-query.js +20 -1
- package/dist/esm/hooks/shop/use-collections-query.js +15 -1
- package/dist/esm/hooks/shop/use-product-query.js +20 -1
- package/dist/esm/hooks/shop/use-products-query.js +20 -1
- package/dist/esm/hooks/shop.js +111 -1
- package/dist/esm/hooks/use-current-device.js +19 -1
- package/dist/esm/hooks/use-lazy-video.js +13 -1
- package/dist/esm/hooks/useCartId.js +40 -1
- package/dist/esm/hooks/useCartLine.js +7 -1
- package/dist/esm/hooks/useCartUI.js +44 -1
- package/dist/esm/hooks/useCollection.js +7 -1
- package/dist/esm/hooks/useFetchHandle.js +11 -1
- package/dist/esm/hooks/useFormatMoney.js +56 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -1
- package/dist/esm/hooks/useLoadScript.js +28 -1
- package/dist/esm/hooks/useMoney.js +80 -1
- package/dist/esm/hooks/usePrevious.js +17 -1
- package/dist/esm/hooks/useProduct.js +111 -1
- package/dist/esm/hooks/useProductList.js +16 -1
- package/dist/esm/hooks/useSuspenseFetch.js +23 -1
- package/dist/esm/hooks/useSwatchesOptions.js +37 -1
- package/dist/esm/index.js +92 -1
- package/dist/esm/types/global-style.js +11 -1
- package/dist/types/index.d.ts +27 -28
- package/package.json +2 -2
|
@@ -1 +1,185 @@
|
|
|
1
|
-
import{handleConvertBorderStyle
|
|
1
|
+
import { handleConvertBorderStyle, handleConvertBorderWidth, handleConvertBorderColor, getBorderStyle } from './borders.js';
|
|
2
|
+
import { isColor } from './colors.js';
|
|
3
|
+
import { layoutComponent } from './constant.js';
|
|
4
|
+
import { makeStyleKey } from './make-style.js';
|
|
5
|
+
import { composeRadius, getCornerCSSFromGlobal } from './radius.js';
|
|
6
|
+
import { getStyleShadowState, getStyleShadow } from './shadow.js';
|
|
7
|
+
|
|
8
|
+
const composeSpacing = ({ source, spacing, type, suffix = '' })=>{
|
|
9
|
+
const { top, left, bottom, right } = spacing;
|
|
10
|
+
if (top) source[`--${type}t${suffix}`] = top;
|
|
11
|
+
if (left) source[`--${type}l${suffix}`] = left;
|
|
12
|
+
if (bottom) source[`--${type}b${suffix}`] = bottom;
|
|
13
|
+
if (right) source[`--${type}r${suffix}`] = right;
|
|
14
|
+
};
|
|
15
|
+
const getAttrValue = (attr, value, tag)=>{
|
|
16
|
+
if (value === undefined || value === null) return undefined;
|
|
17
|
+
switch(attr){
|
|
18
|
+
case 'bgc':
|
|
19
|
+
case 'c':
|
|
20
|
+
return isColor(value.toString()) ? value : `var(--g-c-${value})`;
|
|
21
|
+
case 'd':
|
|
22
|
+
if (!value) return 'none';
|
|
23
|
+
if (value && tag && layoutComponent.includes(tag)) return 'grid';
|
|
24
|
+
return 'block';
|
|
25
|
+
default:
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function composeAdvanceStyle(data, tag) {
|
|
30
|
+
if (!data) return {};
|
|
31
|
+
const styles = {};
|
|
32
|
+
const devices = [
|
|
33
|
+
'desktop',
|
|
34
|
+
'tablet',
|
|
35
|
+
'mobile'
|
|
36
|
+
];
|
|
37
|
+
const states = [
|
|
38
|
+
'hover',
|
|
39
|
+
'normal'
|
|
40
|
+
];
|
|
41
|
+
Object.keys(data).forEach((attr)=>{
|
|
42
|
+
const value = data[attr];
|
|
43
|
+
if (value === undefined || value === null) return;
|
|
44
|
+
const hasBoxShadow = data.hasBoxShadow ? data.hasBoxShadow : {};
|
|
45
|
+
if (typeof value === 'object') {
|
|
46
|
+
if (Array.isArray(value)) return;
|
|
47
|
+
Object.keys(value).forEach((composeAttr)=>{
|
|
48
|
+
if (devices.includes(composeAttr)) {
|
|
49
|
+
const deviceValue = value[composeAttr];
|
|
50
|
+
if (deviceValue !== undefined) {
|
|
51
|
+
// Responsive border with state
|
|
52
|
+
if (attr === 'border') {
|
|
53
|
+
Object.assign(styles, handleConvertBorderStyle(value), handleConvertBorderWidth(value), handleConvertBorderColor(value));
|
|
54
|
+
}
|
|
55
|
+
if (attr === 'rounded') {
|
|
56
|
+
Object.assign(styles, composeRadius(value));
|
|
57
|
+
}
|
|
58
|
+
if (composeAttr === 'desktop') {
|
|
59
|
+
switch(attr){
|
|
60
|
+
case 'padding':
|
|
61
|
+
composeSpacing({
|
|
62
|
+
source: styles,
|
|
63
|
+
spacing: deviceValue,
|
|
64
|
+
type: 'p'
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
case 'margin':
|
|
68
|
+
composeSpacing({
|
|
69
|
+
source: styles,
|
|
70
|
+
spacing: deviceValue,
|
|
71
|
+
type: 'm'
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
case 'm':
|
|
75
|
+
case 'p':
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
styles[`--${attr}`] = getAttrValue(attr, deviceValue, tag);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
switch(attr){
|
|
83
|
+
case 'padding':
|
|
84
|
+
composeSpacing({
|
|
85
|
+
source: styles,
|
|
86
|
+
spacing: deviceValue,
|
|
87
|
+
type: 'p',
|
|
88
|
+
suffix: `-${composeAttr}`
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
91
|
+
case 'margin':
|
|
92
|
+
composeSpacing({
|
|
93
|
+
source: styles,
|
|
94
|
+
spacing: deviceValue,
|
|
95
|
+
type: 'm',
|
|
96
|
+
suffix: `-${composeAttr}`
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case 'm':
|
|
100
|
+
case 'p':
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
styles[`--${attr}-${composeAttr}`] = getAttrValue(attr, deviceValue, tag);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} else if (states.includes(composeAttr)) {
|
|
109
|
+
switch(attr){
|
|
110
|
+
case 'hasBoxShadow':
|
|
111
|
+
break;
|
|
112
|
+
case 'boxShadow':
|
|
113
|
+
Object.assign(styles, getStyleShadowState(value, 'box-shadow', hasBoxShadow));
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
if (attr === 'border') {
|
|
118
|
+
const borderStyle = value;
|
|
119
|
+
if (borderStyle.border === 'none') {
|
|
120
|
+
borderStyle.border = 'solid';
|
|
121
|
+
borderStyle.color = '#121212';
|
|
122
|
+
borderStyle.isCustom = true;
|
|
123
|
+
borderStyle.width = '0px';
|
|
124
|
+
borderStyle.position = 'all';
|
|
125
|
+
}
|
|
126
|
+
Object.assign(styles, getBorderStyle(borderStyle));
|
|
127
|
+
}
|
|
128
|
+
if (attr === 'rounded') {
|
|
129
|
+
Object.assign(styles, getCornerCSSFromGlobal(value));
|
|
130
|
+
}
|
|
131
|
+
if (attr === 'hasBoxShadow') {
|
|
132
|
+
Object.assign(styles, getStyleShadow({
|
|
133
|
+
value: data.boxShadow,
|
|
134
|
+
styleAppliedFor: 'box-shadow',
|
|
135
|
+
isEnableShadow: data.hasBoxShadow
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
if (attr === 'boxShadow') {
|
|
139
|
+
Object.assign(styles, getStyleShadow({
|
|
140
|
+
value: value,
|
|
141
|
+
styleAppliedFor: 'box-shadow',
|
|
142
|
+
isEnableShadow: data.hasBoxShadow
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
148
|
+
styles[`--${attr}`] = getAttrValue(attr, value, tag);
|
|
149
|
+
if (attr === 'hasBoxShadow' && data.boxShadow) {
|
|
150
|
+
Object.assign(styles, getStyleShadow({
|
|
151
|
+
value: data.boxShadow,
|
|
152
|
+
styleAppliedFor: 'box-shadow',
|
|
153
|
+
isEnableShadow: data.hasBoxShadow
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return styles;
|
|
159
|
+
}
|
|
160
|
+
const splitStyle = (keys, style = {})=>{
|
|
161
|
+
const fullKeys = keys.map((key)=>makeStyleKey(key)).flat();
|
|
162
|
+
const splitKeys = Object.keys(style).filter((key)=>{
|
|
163
|
+
return fullKeys.includes(key);
|
|
164
|
+
});
|
|
165
|
+
const splitStyle = splitKeys.reduce((curr, key)=>{
|
|
166
|
+
return {
|
|
167
|
+
...curr,
|
|
168
|
+
[key]: style[key]
|
|
169
|
+
};
|
|
170
|
+
}, {});
|
|
171
|
+
const restStyle = Object.keys(style).filter((key)=>{
|
|
172
|
+
return !splitKeys.includes(key);
|
|
173
|
+
}).reduce((curr, key)=>{
|
|
174
|
+
return {
|
|
175
|
+
...curr,
|
|
176
|
+
[key]: style[key]
|
|
177
|
+
};
|
|
178
|
+
}, {});
|
|
179
|
+
return [
|
|
180
|
+
splitStyle,
|
|
181
|
+
restStyle
|
|
182
|
+
];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { composeAdvanceStyle, splitStyle };
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
const stateMapping = {
|
|
2
|
+
normal: '',
|
|
3
|
+
hover: '-hvr',
|
|
4
|
+
focus: '-focus'
|
|
5
|
+
};
|
|
6
|
+
const devicesMapping = {
|
|
7
|
+
desktop: '',
|
|
8
|
+
tablet: '-tablet',
|
|
9
|
+
mobile: '-mobile'
|
|
10
|
+
};
|
|
11
|
+
const layoutComponent = [
|
|
12
|
+
'Row',
|
|
13
|
+
'Section',
|
|
14
|
+
'Product',
|
|
15
|
+
'HeroBanner',
|
|
16
|
+
'CollectionBanner'
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export { devicesMapping, layoutComponent, stateMapping };
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const isLocalEnv = process.env.NEXT_CONVERT_ENV === 'local';
|
|
2
|
+
const baseAssetURL = process.env.GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
3
|
+
|
|
4
|
+
export { baseAssetURL, isLocalEnv };
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const validateEmail = (email)=>{
|
|
2
|
+
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,})$/);
|
|
3
|
+
return emailRegex.test(email);
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export { validateEmail as default, validateEmail };
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 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.
|
|
3
|
+
*/ const flattenConnection = (connection)=>{
|
|
4
|
+
return connection?.edges?.map((edge)=>edge.node) ?? [];
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { flattenConnection };
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
const getResponsiveValue = (input, k)=>{
|
|
2
|
+
if (!k) return {};
|
|
3
|
+
return {
|
|
4
|
+
desktop: input?.desktop?.[k],
|
|
5
|
+
tablet: input?.tablet?.[k],
|
|
6
|
+
mobile: input?.mobile?.[k]
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const getResponsiveStateValue = (k, input)=>{
|
|
10
|
+
return {
|
|
11
|
+
desktop: input?.desktop?.[k],
|
|
12
|
+
tablet: input?.tablet?.[k],
|
|
13
|
+
mobile: input?.mobile?.[k]
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const getResponsiveValueByScreen = (value, breakpoint, defaultValue)=>{
|
|
17
|
+
switch(breakpoint){
|
|
18
|
+
case 'tablet':
|
|
19
|
+
return value?.tablet ?? value?.desktop ?? defaultValue;
|
|
20
|
+
case 'mobile':
|
|
21
|
+
return value?.mobile ?? value?.tablet ?? value?.desktop ?? defaultValue;
|
|
22
|
+
default:
|
|
23
|
+
return value?.desktop ?? defaultValue;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen };
|
|
@@ -1 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
const globalSortNameMapping = {
|
|
2
|
+
'typography-heading-1-fontFamily': 'h1-ff',
|
|
3
|
+
'typography-heading-1-fontSize': 'h1-size',
|
|
4
|
+
'typography-heading-1-fontWeight': 'h1-weight',
|
|
5
|
+
'typography-heading-1-lineHeight': 'h1-lh',
|
|
6
|
+
'typography-heading-1-letterSpacing': 'h1-ls',
|
|
7
|
+
'typography-heading-1-fontStyle': 'h1-fs',
|
|
8
|
+
'typography-heading-2-fontFamily': 'h2-ff',
|
|
9
|
+
'typography-heading-2-fontSize': 'h2-size',
|
|
10
|
+
'typography-heading-2-fontWeight': 'h2-weight',
|
|
11
|
+
'typography-heading-2-lineHeight': 'h2-lh',
|
|
12
|
+
'typography-heading-2-letterSpacing': 'h2-ls',
|
|
13
|
+
'typography-heading-2-fontStyle': 'h2-fs',
|
|
14
|
+
'typography-heading-3-fontFamily': 'h3-ff',
|
|
15
|
+
'typography-heading-3-fontSize': 'h3-size',
|
|
16
|
+
'typography-heading-3-fontWeight': 'h3-weight',
|
|
17
|
+
'typography-heading-3-lineHeight': 'h3-lh',
|
|
18
|
+
'typography-heading-3-letterSpacing': 'h3-ls',
|
|
19
|
+
'typography-heading-3-fontStyle': 'h3-fs',
|
|
20
|
+
'typography-subheading-1-fontFamily': 'sh1-ff',
|
|
21
|
+
'typography-subheading-1-fontSize': 'sh1-size',
|
|
22
|
+
'typography-subheading-1-fontWeight': 'sh1-weight',
|
|
23
|
+
'typography-subheading-1-lineHeight': 'sh1-lh',
|
|
24
|
+
'typography-subheading-1-letterSpacing': 'sh1-ls',
|
|
25
|
+
'typography-subheading-1-fontStyle': 'sh1-fs',
|
|
26
|
+
'typography-subheading-2-fontFamily': 'sh2-ff',
|
|
27
|
+
'typography-subheading-2-fontSize': 'sh2-size',
|
|
28
|
+
'typography-subheading-2-fontWeight': 'sh2-weight',
|
|
29
|
+
'typography-subheading-2-lineHeight': 'sh2-lh',
|
|
30
|
+
'typography-subheading-2-letterSpacing': 'sh2-ls',
|
|
31
|
+
'typography-subheading-2-fontStyle': 'sh2-fs',
|
|
32
|
+
'typography-subheading-3-fontFamily': 'sh3-ff',
|
|
33
|
+
'typography-subheading-3-fontSize': 'sh3-size',
|
|
34
|
+
'typography-subheading-3-fontWeight': 'sh3-weight',
|
|
35
|
+
'typography-subheading-3-lineHeight': 'sh3-lh',
|
|
36
|
+
'typography-subheading-3-letterSpacing': 'sh3-ls',
|
|
37
|
+
'typography-subheading-3-fontStyle': 'sh3-fs',
|
|
38
|
+
'typography-paragraph-1-fontFamily': 'p1-ff',
|
|
39
|
+
'typography-paragraph-1-fontSize': 'p1-size',
|
|
40
|
+
'typography-paragraph-1-fontWeight': 'p1-weight',
|
|
41
|
+
'typography-paragraph-1-lineHeight': 'p1-lh',
|
|
42
|
+
'typography-paragraph-1-letterSpacing': 'p1-ls',
|
|
43
|
+
'typography-paragraph-1-fontStyle': 'p1-fs',
|
|
44
|
+
'typography-paragraph-2-fontFamily': 'p2-ff',
|
|
45
|
+
'typography-paragraph-2-fontSize': 'p2-size',
|
|
46
|
+
'typography-paragraph-2-fontWeight': 'p2-weight',
|
|
47
|
+
'typography-paragraph-2-lineHeight': 'p2-lh',
|
|
48
|
+
'typography-paragraph-2-letterSpacing': 'p2-ls',
|
|
49
|
+
'typography-paragraph-2-fontStyle': 'p2-fs',
|
|
50
|
+
'typography-paragraph-3-fontFamily': 'p3-ff',
|
|
51
|
+
'typography-paragraph-3-fontSize': 'p3-size',
|
|
52
|
+
'typography-paragraph-3-fontWeight': 'p3-weight',
|
|
53
|
+
'typography-paragraph-3-lineHeight': 'p3-lh',
|
|
54
|
+
'typography-paragraph-3-letterSpacing': 'p3-ls',
|
|
55
|
+
'typography-paragraph-3-fontStyle': 'p3-fs',
|
|
56
|
+
'color-brand': 'c-brand',
|
|
57
|
+
'color-highlight': 'c-highlight',
|
|
58
|
+
'color-text-1': 'c-text-1',
|
|
59
|
+
'color-text-2': 'c-text-2',
|
|
60
|
+
'color-text-3': 'c-text-3',
|
|
61
|
+
'color-bg-1': 'c-bg-1',
|
|
62
|
+
'color-bg-2': 'c-bg-2',
|
|
63
|
+
'color-bg-3': 'c-bg-3',
|
|
64
|
+
'color-line-1': 'c-line-1',
|
|
65
|
+
'color-line-2': 'c-line-2',
|
|
66
|
+
'color-line-3': 'c-line-3',
|
|
67
|
+
'color-success': 'c-success',
|
|
68
|
+
'color-info': 'c-info',
|
|
69
|
+
'color-warning': 'c-warning',
|
|
70
|
+
'color-error': 'c-error',
|
|
71
|
+
'spacing-xxs': 's-xxs',
|
|
72
|
+
'spacing-xs': 's-xs',
|
|
73
|
+
'spacing-s': 's-s',
|
|
74
|
+
'spacing-m': 's-m',
|
|
75
|
+
'spacing-l': 's-l',
|
|
76
|
+
'spacing-xl': 's-xl',
|
|
77
|
+
'spacing-2xl': 's-2xl',
|
|
78
|
+
'spacing-3xl': 's-3xl',
|
|
79
|
+
'spacing-4xl': 's-4xl',
|
|
80
|
+
'spacing-5xl': 's-5xl',
|
|
81
|
+
'container-width': 'ct-w',
|
|
82
|
+
'container-padding': 'ct-p',
|
|
83
|
+
'text-shadow': 'ts',
|
|
84
|
+
'box-shadow': 'shadow'
|
|
85
|
+
};
|
|
86
|
+
function getShortName(name) {
|
|
87
|
+
return globalSortNameMapping[name] || name;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { getShortName };
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{Children
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
|
|
3
|
+
const isEmptyChildren = (children)=>{
|
|
4
|
+
return Children.count(children) < 1 || !children;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { isEmptyChildren as default, isEmptyChildren };
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
function isSafari()
|
|
1
|
+
function isSafari() {
|
|
2
|
+
return navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export { isSafari as default };
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
import{devicesMapping
|
|
1
|
+
import { devicesMapping } from './constant.js';
|
|
2
|
+
import { getResponsiveValueByScreen, getResponsiveValue } from './get-resonsive-value.js';
|
|
3
|
+
|
|
4
|
+
const gridToArrayRegex = // eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
5
|
+
/[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g; // Regex convert css grid to array
|
|
6
|
+
const optionLayoutStyle = (column)=>{
|
|
7
|
+
if (!column) return {};
|
|
8
|
+
const style = {};
|
|
9
|
+
for (const [key, value] of Object.entries(column)){
|
|
10
|
+
Object.assign(style, {
|
|
11
|
+
[`--gtc${devicesMapping?.[key]}`]: `repeat(${parseFloat(value + '') || 1}, minmax(0, 1fr))`
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return style;
|
|
15
|
+
};
|
|
16
|
+
const composeGridLayout = (layout)=>{
|
|
17
|
+
const display = getResponsiveValue(layout, 'display');
|
|
18
|
+
const desktop = (getResponsiveValueByScreen(display, 'desktop') === 'fit' ? layout?.desktop?.cols?.map(()=>`minmax(0, auto)`) : layout?.desktop?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
19
|
+
const tablet = (getResponsiveValueByScreen(display, 'tablet') === 'fit' ? layout?.tablet?.cols?.map(()=>`minmax(0, auto)`) : layout?.tablet?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
20
|
+
const mobile = (getResponsiveValueByScreen(display, 'mobile') === 'fit' ? layout?.mobile?.cols?.map(()=>`minmax(0, auto)`) : layout?.mobile?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
21
|
+
return {
|
|
22
|
+
[`--gtc`]: desktop,
|
|
23
|
+
[`--gtc-tablet`]: tablet,
|
|
24
|
+
[`--gtc-mobile`]: mobile
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const gridToArray = (layout)=>{
|
|
28
|
+
return layout ? layout.match(gridToArrayRegex) ?? [] : [];
|
|
29
|
+
};
|
|
30
|
+
const convertOldLayout = (layout)=>{
|
|
31
|
+
const desktopCol = gridToArray(layout?.desktop).length;
|
|
32
|
+
const tabletCol = gridToArray(layout?.tablet).length;
|
|
33
|
+
const mobileCol = gridToArray(layout?.mobile).length;
|
|
34
|
+
return {
|
|
35
|
+
desktop: {
|
|
36
|
+
cols: desktopCol ? Array.from({
|
|
37
|
+
length: desktopCol
|
|
38
|
+
}, ()=>12 / desktopCol) : undefined,
|
|
39
|
+
display: 'fill'
|
|
40
|
+
},
|
|
41
|
+
tablet: {
|
|
42
|
+
cols: tabletCol ? Array.from({
|
|
43
|
+
length: tabletCol
|
|
44
|
+
}, ()=>12 / tabletCol) : undefined
|
|
45
|
+
},
|
|
46
|
+
mobile: {
|
|
47
|
+
cols: mobileCol ? Array.from({
|
|
48
|
+
length: mobileCol
|
|
49
|
+
}, ()=>12 / mobileCol) : undefined
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle };
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
const SCRIPTS_LOADED = {};
|
|
2
|
+
function loadScript(src, options) {
|
|
3
|
+
const isScriptLoaded = SCRIPTS_LOADED[src];
|
|
4
|
+
if (isScriptLoaded) {
|
|
5
|
+
return isScriptLoaded;
|
|
6
|
+
}
|
|
7
|
+
const promise = new Promise((resolve, reject)=>{
|
|
8
|
+
const script = document.createElement('script');
|
|
9
|
+
if (options?.module) {
|
|
10
|
+
script.type = 'module';
|
|
11
|
+
}
|
|
12
|
+
script.src = src;
|
|
13
|
+
script.onload = ()=>{
|
|
14
|
+
resolve(true);
|
|
15
|
+
};
|
|
16
|
+
script.onerror = ()=>{
|
|
17
|
+
reject(false);
|
|
18
|
+
};
|
|
19
|
+
if (options?.in === 'head') {
|
|
20
|
+
document.head.appendChild(script);
|
|
21
|
+
} else {
|
|
22
|
+
document.body.appendChild(script);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
SCRIPTS_LOADED[src] = promise;
|
|
26
|
+
return promise;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { loadScript };
|
|
@@ -1 +1,117 @@
|
|
|
1
|
-
import{getResponsiveValueByScreen
|
|
1
|
+
import { getResponsiveValueByScreen } from './get-resonsive-value.js';
|
|
2
|
+
|
|
3
|
+
const removeNullUndefined = (obj)=>Object.entries(obj).reduce((a, [k, v])=>{
|
|
4
|
+
if (v === null || v === undefined) return a;
|
|
5
|
+
return {
|
|
6
|
+
...a,
|
|
7
|
+
[k]: v
|
|
8
|
+
};
|
|
9
|
+
}, {});
|
|
10
|
+
const makeStyleKey = (name)=>{
|
|
11
|
+
return [
|
|
12
|
+
name,
|
|
13
|
+
`hvr-${name}`,
|
|
14
|
+
`focus-${name}`,
|
|
15
|
+
`${name}-tablet`,
|
|
16
|
+
`hvr-${name}-tablet`,
|
|
17
|
+
`focus-${name}-tablet`,
|
|
18
|
+
`${name}-mobile`,
|
|
19
|
+
`hvr-${name}-mobile`,
|
|
20
|
+
`focus-${name}-mobile`
|
|
21
|
+
].map((key)=>`--${key}`);
|
|
22
|
+
};
|
|
23
|
+
const makeStyle = (style)=>{
|
|
24
|
+
return removeNullUndefined(Object.fromEntries(Object.entries(style).map(([key, value])=>[
|
|
25
|
+
`--${key}`,
|
|
26
|
+
value
|
|
27
|
+
])));
|
|
28
|
+
};
|
|
29
|
+
const makeStyleState = (name, value)=>{
|
|
30
|
+
if (!value) return {};
|
|
31
|
+
return {
|
|
32
|
+
[`--${name}`]: value?.normal,
|
|
33
|
+
[`--hvr-${name}`]: value?.hover,
|
|
34
|
+
[`--focus-${name}`]: value?.focus
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const makeStyleResponsiveState = (name, value)=>{
|
|
38
|
+
if (!value) return {};
|
|
39
|
+
return {
|
|
40
|
+
[`--${name}`]: value?.desktop?.normal,
|
|
41
|
+
[`--hvr-${name}`]: value?.desktop?.hover,
|
|
42
|
+
[`--focus-${name}`]: value?.desktop?.focus,
|
|
43
|
+
[`--${name}-tablet`]: value?.tablet?.normal,
|
|
44
|
+
[`--hvr-${name}-tablet`]: value?.tablet?.hover,
|
|
45
|
+
[`--focus-${name}-tablet`]: value?.tablet?.focus,
|
|
46
|
+
[`--${name}-mobile`]: value?.mobile?.normal,
|
|
47
|
+
[`--hvr-${name}-mobile`]: value?.mobile?.hover,
|
|
48
|
+
[`--focus-${name}-mobile`]: value?.mobile?.focus
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const makeStyleResponsive = (name, value)=>{
|
|
52
|
+
return {
|
|
53
|
+
[`--${name}`]: value?.desktop,
|
|
54
|
+
[`--${name}-tablet`]: value?.tablet,
|
|
55
|
+
[`--${name}-mobile`]: value?.mobile
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const makeWidth = (widthValue, fullWidthValue)=>{
|
|
59
|
+
const getVal = (deviceValue, widthValue, fullWidthValue)=>{
|
|
60
|
+
const widthVal = widthValue?.[deviceValue] === undefined ? widthValue?.['desktop'] : widthValue?.[deviceValue];
|
|
61
|
+
const fullWidthVal = fullWidthValue?.[deviceValue] === undefined ? fullWidthValue?.['desktop'] : fullWidthValue?.[deviceValue];
|
|
62
|
+
if (fullWidthVal) {
|
|
63
|
+
return '100%';
|
|
64
|
+
} else if (fullWidthVal === false) {
|
|
65
|
+
return widthVal ?? widthVal;
|
|
66
|
+
} else {
|
|
67
|
+
return widthVal || 'auto';
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
desktop: getVal('desktop', widthValue, fullWidthValue),
|
|
72
|
+
tablet: getVal('tablet', widthValue, fullWidthValue),
|
|
73
|
+
mobile: getVal('mobile', widthValue, fullWidthValue)
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const makeHeight = (heighValue, autoHeight)=>{
|
|
77
|
+
const getVal = (deviceValue, heighValue, autoHeight)=>{
|
|
78
|
+
const heightVal = heighValue?.[deviceValue];
|
|
79
|
+
const isAuto = autoHeight?.[deviceValue];
|
|
80
|
+
if (isAuto) {
|
|
81
|
+
return 'auto';
|
|
82
|
+
} else if (isAuto === false) {
|
|
83
|
+
return heightVal ?? heightVal;
|
|
84
|
+
} else {
|
|
85
|
+
return heightVal;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
desktop: getVal('desktop', heighValue, autoHeight),
|
|
90
|
+
tablet: getVal('tablet', heighValue, autoHeight),
|
|
91
|
+
mobile: getVal('mobile', heighValue, autoHeight)
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight)=>{
|
|
95
|
+
return {
|
|
96
|
+
desktop: aspectRatio?.desktop === 'custom' ? `${getResponsiveValueByScreen(aspectWidth, 'desktop')}/${getResponsiveValueByScreen(aspectHeight, 'desktop')}` : aspectRatio?.desktop,
|
|
97
|
+
tablet: aspectRatio?.tablet === 'custom' ? `${getResponsiveValueByScreen(aspectWidth, 'tablet')}/${getResponsiveValueByScreen(aspectHeight, 'tablet')}` : aspectRatio?.tablet,
|
|
98
|
+
mobile: aspectRatio?.mobile === 'custom' ? `${getResponsiveValueByScreen(aspectWidth, 'mobile')}/${getResponsiveValueByScreen(aspectHeight, 'mobile')}` : aspectRatio?.mobile
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
|
|
102
|
+
const getVal = (deviceValue, lineClampValue, hasLineClampValue)=>{
|
|
103
|
+
const lineClamp = lineClampValue?.[deviceValue];
|
|
104
|
+
const hasLineClamp = hasLineClampValue?.[deviceValue] || hasLineClampValue?.['desktop'];
|
|
105
|
+
if (hasLineClamp || hasLineClamp === undefined) {
|
|
106
|
+
return lineClamp;
|
|
107
|
+
}
|
|
108
|
+
return 'unset';
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
desktop: getVal('desktop', lineClampValue, hasLineClampValue),
|
|
112
|
+
tablet: getVal('tablet', lineClampValue, hasLineClampValue),
|
|
113
|
+
mobile: getVal('mobile', lineClampValue, hasLineClampValue)
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export { makeAspectRatio, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
function normalizeBuilderData(
|
|
1
|
+
function normalizeBuilderData(data) {
|
|
2
|
+
const result = {};
|
|
3
|
+
function compose(data, res = {}) {
|
|
4
|
+
const childrens = data.childrens;
|
|
5
|
+
const items = childrens?.map((child)=>child.uid) ?? [];
|
|
6
|
+
res[data.uid] = {
|
|
7
|
+
...data,
|
|
8
|
+
childrens: items,
|
|
9
|
+
type: 'component'
|
|
10
|
+
};
|
|
11
|
+
if (childrens) {
|
|
12
|
+
childrens.map((child)=>compose(child, res));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
compose(data, result);
|
|
16
|
+
return {
|
|
17
|
+
...result
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { normalizeBuilderData };
|