@gem-sdk/core 1.5.15 → 1.5.22
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 +7 -7
- package/dist/cjs/components/ComponentWrapper.js +14 -8
- package/dist/cjs/components/ComponentWrapperPreview.js +55 -46
- package/dist/cjs/components/Empty.js +1 -1
- package/dist/cjs/components/Render.js +50 -13
- package/dist/cjs/components/Render.liquid.js +81 -57
- package/dist/cjs/components/RenderBlock.js +41 -8
- package/dist/cjs/components/RenderPreview.js +51 -13
- package/dist/cjs/components/RenderSection.js +11 -7
- package/dist/cjs/components/constant.js +24 -24
- package/dist/cjs/contexts/AddonContext.js +25 -14
- package/dist/cjs/contexts/BuilderComponent.js +23 -19
- package/dist/cjs/contexts/BuilderContext.js +25 -19
- package/dist/cjs/contexts/BuilderPreviewContext.js +349 -341
- package/dist/cjs/contexts/CartLineContext.js +19 -14
- package/dist/cjs/contexts/CollectionContext.js +21 -13
- package/dist/cjs/contexts/ProductContext.js +136 -115
- package/dist/cjs/contexts/ProductListContext.js +21 -13
- package/dist/cjs/contexts/SectionContext.js +41 -37
- package/dist/cjs/contexts/ShopContext.js +49 -31
- package/dist/cjs/graphql/fragments/analytic.generated.js +1 -1
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +1 -1
- package/dist/cjs/graphql/fragments/collection-product.generated.js +1 -1
- package/dist/cjs/graphql/fragments/custom-code.generated.js +1 -1
- package/dist/cjs/graphql/fragments/data-seo.generated.js +1 -1
- package/dist/cjs/graphql/fragments/media.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product-little.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product-option.generated.js +1 -1
- package/dist/cjs/graphql/fragments/product.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +1 -1
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +1 -1
- package/dist/cjs/graphql/fragments/selected-option.generated.js +1 -1
- package/dist/cjs/graphql/fragments/variant.generated.js +1 -1
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +1 -1
- package/dist/cjs/graphql/queries/products.generated.js +1 -1
- package/dist/cjs/graphql/queries/store-property.generated.js +1 -1
- package/dist/cjs/helpers/GlobalEvent.js +12 -10
- package/dist/cjs/helpers/background.js +96 -96
- package/dist/cjs/helpers/borders.js +123 -127
- package/dist/cjs/helpers/clone-deep.js +1 -1
- package/dist/cjs/helpers/cls.js +11 -15
- package/dist/cjs/helpers/colors.js +121 -156
- package/dist/cjs/helpers/compose-advance-style.js +115 -121
- package/dist/cjs/helpers/constant.js +16 -11
- package/dist/cjs/helpers/css-variable.js +2 -2
- package/dist/cjs/helpers/email.js +3 -3
- package/dist/cjs/helpers/flatten-connection.js +4 -5
- package/dist/cjs/helpers/get-resonsive-value.js +24 -25
- package/dist/cjs/helpers/get-shortname.js +87 -87
- package/dist/cjs/helpers/is-browser.js +2 -2
- package/dist/cjs/helpers/is-defined.js +2 -2
- package/dist/cjs/helpers/is-empty-children.js +2 -2
- package/dist/cjs/helpers/layout.js +9 -10
- package/dist/cjs/helpers/load-script.js +26 -27
- package/dist/cjs/helpers/make-style.js +77 -86
- package/dist/cjs/helpers/normalize-builder-data.js +18 -12
- package/dist/cjs/helpers/prefetch-queries.js +72 -52
- package/dist/cjs/helpers/product.js +25 -29
- package/dist/cjs/helpers/queries/get-collection.js +179 -167
- package/dist/cjs/helpers/queries/get-product-by-slug.js +103 -94
- package/dist/cjs/helpers/queries/get-product.js +121 -106
- package/dist/cjs/helpers/queries/get-products.js +137 -125
- package/dist/cjs/helpers/radius.js +78 -81
- package/dist/cjs/helpers/render.js +56 -56
- package/dist/cjs/helpers/shadow.js +38 -38
- package/dist/cjs/helpers/size.js +12 -13
- package/dist/cjs/helpers/spacing.js +35 -37
- package/dist/cjs/helpers/tracking/fpixel.js +21 -22
- package/dist/cjs/helpers/tracking/gtag.js +84 -90
- package/dist/cjs/helpers/tracking/tiktokpixel.js +12 -12
- package/dist/cjs/helpers/typography.js +2 -2
- package/dist/cjs/hooks/cart/use-add-to-cart.js +10 -10
- package/dist/cjs/hooks/cart/use-cart-data.js +18 -16
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +10 -10
- package/dist/cjs/hooks/cart/use-cart-note-update.js +10 -10
- package/dist/cjs/hooks/cart/use-create-cart.js +12 -12
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +10 -10
- package/dist/cjs/hooks/cart/use-update-cart-item.js +10 -10
- package/dist/cjs/hooks/shop/use-collection-query.js +12 -6
- package/dist/cjs/hooks/shop/use-product-query.js +12 -6
- package/dist/cjs/hooks/shop/use-products-query.js +14 -6
- package/dist/cjs/hooks/shop.js +86 -67
- package/dist/cjs/hooks/use-current-device.js +14 -16
- package/dist/cjs/hooks/use-lazy-video.js +7 -7
- package/dist/cjs/hooks/useCartId.js +35 -27
- package/dist/cjs/hooks/useCartLine.js +2 -2
- package/dist/cjs/hooks/useCartUI.js +37 -31
- package/dist/cjs/hooks/useCollection.js +2 -2
- package/dist/cjs/hooks/useFetchHandle.js +6 -6
- package/dist/cjs/hooks/useFormatMoney.js +11 -7
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useLoadScript.js +22 -20
- package/dist/cjs/hooks/useMoney.js +59 -42
- package/dist/cjs/hooks/usePrevious.js +12 -10
- package/dist/cjs/hooks/useProduct.js +93 -69
- package/dist/cjs/hooks/useProductList.js +11 -11
- package/dist/cjs/hooks/useSuspenseFetch.js +20 -17
- package/dist/cjs/hooks/useSwatchesOptions.js +32 -30
- package/dist/cjs/types/global-style.js +9 -2
- package/dist/esm/components/AddOn.js +7 -7
- package/dist/esm/components/ComponentWrapper.js +14 -8
- package/dist/esm/components/ComponentWrapperPreview.js +55 -46
- package/dist/esm/components/Empty.js +1 -1
- package/dist/esm/components/Render.js +50 -13
- package/dist/esm/components/Render.liquid.js +81 -57
- package/dist/esm/components/RenderBlock.js +41 -8
- package/dist/esm/components/RenderPreview.js +51 -13
- package/dist/esm/components/RenderSection.js +11 -7
- package/dist/esm/components/constant.js +24 -24
- package/dist/esm/contexts/AddonContext.js +26 -15
- package/dist/esm/contexts/BuilderComponent.js +24 -20
- package/dist/esm/contexts/BuilderContext.js +26 -20
- package/dist/esm/contexts/BuilderPreviewContext.js +350 -342
- package/dist/esm/contexts/CartLineContext.js +20 -15
- package/dist/esm/contexts/CollectionContext.js +22 -14
- package/dist/esm/contexts/ProductContext.js +137 -116
- package/dist/esm/contexts/ProductListContext.js +22 -14
- package/dist/esm/contexts/SectionContext.js +42 -38
- package/dist/esm/contexts/ShopContext.js +50 -32
- package/dist/esm/graphql/fragments/analytic.generated.js +1 -1
- package/dist/esm/graphql/fragments/collection-detail.generated.js +1 -1
- package/dist/esm/graphql/fragments/collection-product.generated.js +1 -1
- package/dist/esm/graphql/fragments/custom-code.generated.js +1 -1
- package/dist/esm/graphql/fragments/data-seo.generated.js +1 -1
- package/dist/esm/graphql/fragments/media.generated.js +1 -1
- package/dist/esm/graphql/fragments/product-little.generated.js +1 -1
- package/dist/esm/graphql/fragments/product-option-value.generated.js +1 -1
- package/dist/esm/graphql/fragments/product-option.generated.js +1 -1
- package/dist/esm/graphql/fragments/product.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-page-section.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +1 -1
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +1 -1
- package/dist/esm/graphql/fragments/selected-option.generated.js +1 -1
- package/dist/esm/graphql/fragments/variant.generated.js +1 -1
- package/dist/esm/graphql/mutations/page-view-up.generated.js +1 -1
- package/dist/esm/graphql/queries/products.generated.js +1 -1
- package/dist/esm/graphql/queries/store-property.generated.js +1 -1
- package/dist/esm/helpers/GlobalEvent.js +12 -10
- package/dist/esm/helpers/background.js +96 -96
- package/dist/esm/helpers/borders.js +123 -127
- package/dist/esm/helpers/clone-deep.js +1 -1
- package/dist/esm/helpers/cls.js +11 -15
- package/dist/esm/helpers/colors.js +121 -156
- package/dist/esm/helpers/compose-advance-style.js +115 -121
- package/dist/esm/helpers/constant.js +16 -11
- package/dist/esm/helpers/css-variable.js +2 -2
- package/dist/esm/helpers/email.js +3 -3
- package/dist/esm/helpers/flatten-connection.js +4 -5
- package/dist/esm/helpers/get-resonsive-value.js +24 -25
- package/dist/esm/helpers/get-shortname.js +87 -87
- package/dist/esm/helpers/is-browser.js +2 -2
- package/dist/esm/helpers/is-defined.js +2 -2
- package/dist/esm/helpers/is-empty-children.js +2 -2
- package/dist/esm/helpers/layout.js +9 -10
- package/dist/esm/helpers/load-script.js +26 -27
- package/dist/esm/helpers/make-style.js +77 -86
- package/dist/esm/helpers/normalize-builder-data.js +18 -12
- package/dist/esm/helpers/prefetch-queries.js +72 -52
- package/dist/esm/helpers/product.js +25 -29
- package/dist/esm/helpers/queries/get-collection.js +179 -167
- package/dist/esm/helpers/queries/get-product-by-slug.js +103 -94
- package/dist/esm/helpers/queries/get-product.js +121 -106
- package/dist/esm/helpers/queries/get-products.js +137 -125
- package/dist/esm/helpers/radius.js +78 -81
- package/dist/esm/helpers/render.js +56 -56
- package/dist/esm/helpers/shadow.js +38 -38
- package/dist/esm/helpers/size.js +12 -13
- package/dist/esm/helpers/spacing.js +35 -37
- package/dist/esm/helpers/tracking/fpixel.js +21 -22
- package/dist/esm/helpers/tracking/gtag.js +84 -90
- package/dist/esm/helpers/tracking/tiktokpixel.js +12 -12
- package/dist/esm/helpers/typography.js +2 -2
- package/dist/esm/hooks/cart/use-add-to-cart.js +10 -10
- package/dist/esm/hooks/cart/use-cart-data.js +18 -16
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +10 -10
- package/dist/esm/hooks/cart/use-cart-note-update.js +10 -10
- package/dist/esm/hooks/cart/use-create-cart.js +12 -12
- package/dist/esm/hooks/cart/use-remove-cart-item.js +10 -10
- package/dist/esm/hooks/cart/use-update-cart-item.js +10 -10
- package/dist/esm/hooks/shop/use-collection-query.js +12 -6
- package/dist/esm/hooks/shop/use-product-query.js +12 -6
- package/dist/esm/hooks/shop/use-products-query.js +14 -6
- package/dist/esm/hooks/shop.js +86 -67
- package/dist/esm/hooks/use-current-device.js +14 -16
- package/dist/esm/hooks/use-lazy-video.js +7 -7
- package/dist/esm/hooks/useCartId.js +35 -27
- package/dist/esm/hooks/useCartLine.js +2 -2
- package/dist/esm/hooks/useCartUI.js +37 -31
- package/dist/esm/hooks/useCollection.js +2 -2
- package/dist/esm/hooks/useFetchHandle.js +6 -6
- package/dist/esm/hooks/useFormatMoney.js +11 -7
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/dist/esm/hooks/useLoadScript.js +22 -20
- package/dist/esm/hooks/useMoney.js +59 -42
- package/dist/esm/hooks/usePrevious.js +12 -10
- package/dist/esm/hooks/useProduct.js +93 -70
- package/dist/esm/hooks/useProductList.js +11 -11
- package/dist/esm/hooks/useSuspenseFetch.js +20 -17
- package/dist/esm/hooks/useSwatchesOptions.js +32 -30
- package/dist/esm/types/global-style.js +9 -2
- package/dist/types/index.d.ts +24 -2
- package/package.json +1 -1
|
@@ -3,162 +3,127 @@
|
|
|
3
3
|
var isDefined = require('./is-defined.js');
|
|
4
4
|
var constant = require('./constant.js');
|
|
5
5
|
|
|
6
|
-
const getGlobalColorCSSProp = (color)
|
|
7
|
-
return getSingleColorVariable(color);
|
|
8
|
-
};
|
|
9
|
-
const getGlobalColorClass = (type, color)
|
|
10
|
-
if (typeof color !== 'string' ||
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
const
|
|
38
|
-
if (!data)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (state === 'active')
|
|
128
|
-
return [];
|
|
129
|
-
return [`-${constant.stateMapping[state]}-${type}`, getSingleColorVariable(value)];
|
|
130
|
-
})
|
|
131
|
-
.filter(isDefined.isDefined));
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
return Object.fromEntries(Object.entries(objectState)
|
|
135
|
-
.map(([state, value]) => {
|
|
136
|
-
if (state === 'active')
|
|
137
|
-
return [];
|
|
138
|
-
return [`-${constant.stateMapping[state]}-${type}-${device}`, getSingleColorVariable(value)];
|
|
139
|
-
})
|
|
140
|
-
.filter(isDefined.isDefined));
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
.reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
144
|
-
};
|
|
145
|
-
const getSingleColorVariable = (color) => {
|
|
146
|
-
if (!color)
|
|
147
|
-
return undefined;
|
|
148
|
-
if (isColor(color))
|
|
149
|
-
return color;
|
|
150
|
-
return `var(--g-c-${color}, ${color})`;
|
|
151
|
-
};
|
|
152
|
-
function isColor(color) {
|
|
153
|
-
return (color?.startsWith('#') ||
|
|
154
|
-
color?.startsWith('rgb') ||
|
|
155
|
-
color?.startsWith('hsl') ||
|
|
156
|
-
color?.startsWith('transparent'));
|
|
157
|
-
}
|
|
158
|
-
const getGlobalColorStyle = (data) => {
|
|
159
|
-
if (!data)
|
|
160
|
-
return {};
|
|
161
|
-
return { '--c': getSingleColorVariable(data) };
|
|
6
|
+
const getGlobalColorCSSProp = (color)=>{
|
|
7
|
+
return getSingleColorVariable(color);
|
|
8
|
+
};
|
|
9
|
+
const getGlobalColorClass = (type, color)=>{
|
|
10
|
+
if (typeof color !== 'string' || !color || color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent')) return '';
|
|
11
|
+
return `${type}-g-${color}`;
|
|
12
|
+
};
|
|
13
|
+
const getGlobalColorResponsiveClass = (type, data)=>{
|
|
14
|
+
if (!data) return '';
|
|
15
|
+
return Object.entries(data).map(([device, value])=>{
|
|
16
|
+
const clName = getGlobalColorClass(type, value);
|
|
17
|
+
if (!clName) return undefined;
|
|
18
|
+
if (device === 'desktop') {
|
|
19
|
+
return clName;
|
|
20
|
+
} else {
|
|
21
|
+
return `${device}:${clName}`;
|
|
22
|
+
}
|
|
23
|
+
}).filter(isDefined.isDefined).join(' ');
|
|
24
|
+
};
|
|
25
|
+
const getGlobalColorStateClass = (type, data)=>{
|
|
26
|
+
if (!data) return '';
|
|
27
|
+
return Object.entries(data).map(([state, value])=>{
|
|
28
|
+
const clName = getGlobalColorClass(type, value);
|
|
29
|
+
if (!clName) return undefined;
|
|
30
|
+
if (state === 'normal') {
|
|
31
|
+
return clName;
|
|
32
|
+
} else {
|
|
33
|
+
return `${state}:${clName}`;
|
|
34
|
+
}
|
|
35
|
+
}).filter(isDefined.isDefined).join(' ');
|
|
36
|
+
};
|
|
37
|
+
const getGlobalColorStateResponsiveClass = (type, data)=>{
|
|
38
|
+
if (!data) return '';
|
|
39
|
+
return Object.entries(data).map(([device, objectState])=>{
|
|
40
|
+
if (device === 'desktop') {
|
|
41
|
+
return Object.entries(objectState).map(([state, value])=>{
|
|
42
|
+
const clName = getGlobalColorClass(type, value);
|
|
43
|
+
if (!clName) return undefined;
|
|
44
|
+
if (state === 'normal') {
|
|
45
|
+
return clName;
|
|
46
|
+
} else {
|
|
47
|
+
return `${state}:${clName}`;
|
|
48
|
+
}
|
|
49
|
+
}).filter(isDefined.isDefined).join(' ');
|
|
50
|
+
} else {
|
|
51
|
+
return Object.entries(objectState).map(([state, value])=>{
|
|
52
|
+
const clName = getGlobalColorClass(type, value);
|
|
53
|
+
if (!clName) return undefined;
|
|
54
|
+
if (state === 'normal') {
|
|
55
|
+
return `${device}:${clName}`;
|
|
56
|
+
} else {
|
|
57
|
+
return `${device}:${state}:${clName}`;
|
|
58
|
+
}
|
|
59
|
+
}).filter(isDefined.isDefined).join(' ');
|
|
60
|
+
}
|
|
61
|
+
}).filter(Boolean).join(' ');
|
|
62
|
+
};
|
|
63
|
+
const getGlobalColorResponsiveStyle = (type, data)=>{
|
|
64
|
+
if (!data) return {};
|
|
65
|
+
return Object.fromEntries(Object.entries(data).map(([device, value])=>{
|
|
66
|
+
if (device === 'desktop') {
|
|
67
|
+
return [
|
|
68
|
+
`--${type}`,
|
|
69
|
+
getSingleColorVariable(value)
|
|
70
|
+
];
|
|
71
|
+
} else {
|
|
72
|
+
return [
|
|
73
|
+
`--${type}-${device}`,
|
|
74
|
+
getSingleColorVariable(value)
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
const getGlobalColorStateStyle = (type, data)=>{
|
|
80
|
+
if (!data) return {};
|
|
81
|
+
return Object.fromEntries(Object.entries(data).map(([state, value])=>{
|
|
82
|
+
if (state === 'active') return [];
|
|
83
|
+
return [
|
|
84
|
+
`-${constant.stateMapping?.[state]}-${type}`,
|
|
85
|
+
getSingleColorVariable(value)
|
|
86
|
+
];
|
|
87
|
+
}).filter(isDefined.isDefined));
|
|
88
|
+
};
|
|
89
|
+
const getGlobalColorStateResponsiveStyle = (type, data)=>{
|
|
90
|
+
if (!data) return {};
|
|
91
|
+
return Object.entries(data).map(([device, objectState])=>{
|
|
92
|
+
if (device === 'desktop') {
|
|
93
|
+
return Object.fromEntries(Object.entries(objectState).map(([state, value])=>{
|
|
94
|
+
if (state === 'active') return [];
|
|
95
|
+
return [
|
|
96
|
+
`-${constant.stateMapping[state]}-${type}`,
|
|
97
|
+
getSingleColorVariable(value)
|
|
98
|
+
];
|
|
99
|
+
}).filter(isDefined.isDefined));
|
|
100
|
+
} else {
|
|
101
|
+
return Object.fromEntries(Object.entries(objectState).map(([state, value])=>{
|
|
102
|
+
if (state === 'active') return [];
|
|
103
|
+
return [
|
|
104
|
+
`-${constant.stateMapping[state]}-${type}-${device}`,
|
|
105
|
+
getSingleColorVariable(value)
|
|
106
|
+
];
|
|
107
|
+
}).filter(isDefined.isDefined));
|
|
108
|
+
}
|
|
109
|
+
}).reduce((acc, curr)=>({
|
|
110
|
+
...acc,
|
|
111
|
+
...curr
|
|
112
|
+
}), {});
|
|
113
|
+
};
|
|
114
|
+
const getSingleColorVariable = (color)=>{
|
|
115
|
+
if (!color) return undefined;
|
|
116
|
+
if (isColor(color)) return color;
|
|
117
|
+
return `var(--g-c-${color}, ${color})`;
|
|
118
|
+
};
|
|
119
|
+
function isColor(color) {
|
|
120
|
+
return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent');
|
|
121
|
+
}
|
|
122
|
+
const getGlobalColorStyle = (data)=>{
|
|
123
|
+
if (!data) return {};
|
|
124
|
+
return {
|
|
125
|
+
'--c': getSingleColorVariable(data)
|
|
126
|
+
};
|
|
162
127
|
};
|
|
163
128
|
|
|
164
129
|
exports.getGlobalColorCSSProp = getGlobalColorCSSProp;
|
|
@@ -6,127 +6,121 @@ var constant = require('./constant.js');
|
|
|
6
6
|
var radius = require('./radius.js');
|
|
7
7
|
var shadow = require('./shadow.js');
|
|
8
8
|
|
|
9
|
-
const composeSpacing = ({ source, spacing, type, suffix =
|
|
10
|
-
const { top, left, bottom, right
|
|
11
|
-
if (top)
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (attr === '
|
|
57
|
-
Object.assign(styles,
|
|
58
|
-
}
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
break;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
break;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
styles[`--${attr}`] = getAttrValue(attr, value, tag);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return styles;
|
|
9
|
+
const composeSpacing = ({ source , spacing , type , suffix ='' })=>{
|
|
10
|
+
const { top , left , bottom , right } = spacing;
|
|
11
|
+
if (top) source[`--${type}t${suffix}`] = top;
|
|
12
|
+
if (left) source[`--${type}l${suffix}`] = left;
|
|
13
|
+
if (bottom) source[`--${type}b${suffix}`] = bottom;
|
|
14
|
+
if (right) source[`--${type}r${suffix}`] = right;
|
|
15
|
+
};
|
|
16
|
+
const getAttrValue = (attr, value, tag)=>{
|
|
17
|
+
if (value === undefined || value === null) return undefined;
|
|
18
|
+
switch(attr){
|
|
19
|
+
case 'bgc':
|
|
20
|
+
case 'c':
|
|
21
|
+
return colors.isColor(value.toString()) ? value : `var(--g-c-${value})`;
|
|
22
|
+
case 'd':
|
|
23
|
+
if (!value) return 'none';
|
|
24
|
+
if (value && tag && constant.layoutComponent.includes(tag)) return 'grid';
|
|
25
|
+
return 'inline';
|
|
26
|
+
default:
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function composeAdvanceStyle(data, tag) {
|
|
31
|
+
if (!data) return {};
|
|
32
|
+
const styles = {};
|
|
33
|
+
const devices = [
|
|
34
|
+
'desktop',
|
|
35
|
+
'tablet',
|
|
36
|
+
'mobile'
|
|
37
|
+
];
|
|
38
|
+
const states = [
|
|
39
|
+
'hover',
|
|
40
|
+
'normal'
|
|
41
|
+
];
|
|
42
|
+
Object.keys(data).forEach((attr)=>{
|
|
43
|
+
const value = data[attr];
|
|
44
|
+
if (value === undefined || value === null) return;
|
|
45
|
+
const hasBoxShadow = data.hasBoxShadow ? data.hasBoxShadow : {};
|
|
46
|
+
if (typeof value === 'object') {
|
|
47
|
+
if (Array.isArray(value)) return;
|
|
48
|
+
Object.keys(value).forEach((composeAttr)=>{
|
|
49
|
+
if (devices.includes(composeAttr)) {
|
|
50
|
+
const deviceValue = value[composeAttr];
|
|
51
|
+
if (deviceValue !== undefined) {
|
|
52
|
+
// Responsive border with state
|
|
53
|
+
if (attr === 'border') {
|
|
54
|
+
Object.assign(styles, borders.handleConvertBorderStyle(value), borders.handleConvertBorderWidth(value), borders.handleConvertBorderColor(value));
|
|
55
|
+
}
|
|
56
|
+
if (attr === 'rounded') {
|
|
57
|
+
Object.assign(styles, radius.composeRadius(value));
|
|
58
|
+
}
|
|
59
|
+
if (composeAttr === 'desktop') {
|
|
60
|
+
switch(attr){
|
|
61
|
+
case 'padding':
|
|
62
|
+
composeSpacing({
|
|
63
|
+
source: styles,
|
|
64
|
+
spacing: deviceValue,
|
|
65
|
+
type: 'p'
|
|
66
|
+
});
|
|
67
|
+
break;
|
|
68
|
+
case 'margin':
|
|
69
|
+
composeSpacing({
|
|
70
|
+
source: styles,
|
|
71
|
+
spacing: deviceValue,
|
|
72
|
+
type: 'm'
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case 'm':
|
|
76
|
+
case 'p':
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
styles[`--${attr}`] = getAttrValue(attr, deviceValue, tag);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
switch(attr){
|
|
84
|
+
case 'padding':
|
|
85
|
+
composeSpacing({
|
|
86
|
+
source: styles,
|
|
87
|
+
spacing: deviceValue,
|
|
88
|
+
type: 'p',
|
|
89
|
+
suffix: `-${composeAttr}`
|
|
90
|
+
});
|
|
91
|
+
break;
|
|
92
|
+
case 'margin':
|
|
93
|
+
composeSpacing({
|
|
94
|
+
source: styles,
|
|
95
|
+
spacing: deviceValue,
|
|
96
|
+
type: 'm',
|
|
97
|
+
suffix: `-${composeAttr}`
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
case 'm':
|
|
101
|
+
case 'p':
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
styles[`--${attr}-${composeAttr}`] = getAttrValue(attr, deviceValue, tag);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} else if (states.includes(composeAttr)) {
|
|
110
|
+
switch(attr){
|
|
111
|
+
case 'hasBoxShadow':
|
|
112
|
+
break;
|
|
113
|
+
case 'boxShadow':
|
|
114
|
+
Object.assign(styles, shadow.getStyleShadowState(value, 'box-shadow', hasBoxShadow));
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
styles[`--${attr}`] = getAttrValue(attr, value, tag);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return styles;
|
|
130
124
|
}
|
|
131
125
|
|
|
132
126
|
exports.composeAdvanceStyle = composeAdvanceStyle;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
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 = [
|
|
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 = [
|
|
14
|
+
'Row',
|
|
15
|
+
'Section',
|
|
16
|
+
'Product',
|
|
17
|
+
'HeroBanner'
|
|
18
|
+
];
|
|
14
19
|
|
|
15
20
|
exports.devicesMapping = devicesMapping;
|
|
16
21
|
exports.layoutComponent = layoutComponent;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
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);
|
|
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
8
|
};
|
|
9
9
|
|
|
10
10
|
exports.default = validateEmail;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
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
|
-
|
|
7
|
-
return connection?.edges?.map((edge) => edge.node) ?? [];
|
|
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
|
+
*/ const flattenConnection = (connection)=>{
|
|
6
|
+
return connection?.edges?.map((edge)=>edge.node) ?? [];
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
exports.flattenConnection = flattenConnection;
|