@gem-sdk/core 1.42.7 → 1.43.0-dev.100
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/ComponentToolbarPreview.js +126 -7
- package/dist/cjs/components/ComponentWrapperPreview.js +44 -1
- package/dist/cjs/components/Render.liquid.js +3 -0
- package/dist/cjs/components/RenderCustomCode.js +3 -0
- package/dist/cjs/components/RenderPreview.js +1 -0
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +252 -0
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +85 -0
- package/dist/cjs/components/ai-generator/components/PickProduct.js +219 -0
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +77 -0
- package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +47 -0
- package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +110 -0
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +37 -0
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +70 -0
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +67 -0
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +19 -0
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +37 -0
- package/dist/cjs/components/ai-generator/icons/SearchIcon.js +21 -0
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +21 -0
- package/dist/cjs/components/ai-generator/icons/UpgradeIcon.js +27 -0
- package/dist/cjs/components/ai-generator/icons/WarningIcon.js +31 -0
- package/dist/cjs/components/constant.js +19 -2
- package/dist/cjs/components/resize/Spacing.js +21 -11
- package/dist/cjs/components/theme-section/CreateThemeSection.js +3 -0
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +14 -5
- package/dist/cjs/contexts/ArticleContext.js +39 -0
- package/dist/cjs/contexts/ArticleListContext.js +31 -0
- package/dist/cjs/contexts/BuilderPreviewContext.js +17 -10
- package/dist/cjs/contexts/SectionContext.js +1 -0
- package/dist/cjs/contexts/ShopContext.js +18 -0
- package/dist/cjs/graphql/queries/articles.generated.js +55 -0
- package/dist/cjs/graphql/queries/blogs.generated.js +63 -0
- package/dist/cjs/helpers/align.js +19 -0
- package/dist/cjs/helpers/background.js +6 -3
- package/dist/cjs/helpers/carousel.js +7 -10
- package/dist/cjs/helpers/colors.js +2 -2
- package/dist/cjs/helpers/queries/get-products.js +23 -0
- package/dist/cjs/helpers/shadow.js +1 -1
- package/dist/cjs/helpers/typography.js +43 -8
- package/dist/cjs/hooks/articles/useArticlesQuery.js +32 -0
- package/dist/cjs/hooks/shop/use-products-query.js +29 -0
- package/dist/cjs/hooks/useAnimations.js +3 -0
- package/dist/cjs/hooks/useFormatMoney.js +61 -60
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +3 -0
- package/dist/cjs/hooks/useProduct.js +3 -0
- package/dist/cjs/index.js +14 -0
- package/dist/esm/components/ComponentToolbarPreview.js +127 -8
- package/dist/esm/components/ComponentWrapperPreview.js +44 -1
- package/dist/esm/components/Render.liquid.js +3 -0
- package/dist/esm/components/RenderCustomCode.js +3 -0
- package/dist/esm/components/RenderPreview.js +1 -0
- package/dist/esm/components/ai-generator/AIContentGenerator.js +250 -0
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +83 -0
- package/dist/esm/components/ai-generator/components/PickProduct.js +217 -0
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +75 -0
- package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +45 -0
- package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +108 -0
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +35 -0
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +68 -0
- package/dist/esm/components/ai-generator/icons/AIIcon.js +65 -0
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +17 -0
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +34 -0
- package/dist/esm/components/ai-generator/icons/SearchIcon.js +19 -0
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +19 -0
- package/dist/esm/components/ai-generator/icons/UpgradeIcon.js +25 -0
- package/dist/esm/components/ai-generator/icons/WarningIcon.js +29 -0
- package/dist/esm/components/constant.js +19 -3
- package/dist/esm/components/resize/Spacing.js +21 -11
- package/dist/esm/components/theme-section/CreateThemeSection.js +3 -0
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +14 -5
- package/dist/esm/contexts/ArticleContext.js +36 -0
- package/dist/esm/contexts/ArticleListContext.js +27 -0
- package/dist/esm/contexts/BuilderPreviewContext.js +17 -10
- package/dist/esm/contexts/SectionContext.js +1 -0
- package/dist/esm/contexts/ShopContext.js +19 -1
- package/dist/esm/graphql/queries/articles.generated.js +53 -0
- package/dist/esm/graphql/queries/blogs.generated.js +61 -0
- package/dist/esm/helpers/align.js +17 -0
- package/dist/esm/helpers/background.js +6 -4
- package/dist/esm/helpers/carousel.js +7 -10
- package/dist/esm/helpers/colors.js +2 -2
- package/dist/esm/helpers/queries/get-products.js +23 -1
- package/dist/esm/helpers/shadow.js +1 -1
- package/dist/esm/helpers/typography.js +43 -9
- package/dist/esm/hooks/articles/useArticlesQuery.js +29 -0
- package/dist/esm/hooks/shop/use-products-query.js +30 -2
- package/dist/esm/hooks/useAnimations.js +3 -0
- package/dist/esm/hooks/useFormatMoney.js +61 -61
- package/dist/esm/hooks/useInitialSwatchesOptions.js +3 -0
- package/dist/esm/hooks/useProduct.js +3 -0
- package/dist/esm/index.js +7 -3
- package/dist/types/index.d.ts +263 -51
- package/package.json +6 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const BlogsDocument = `
|
|
4
|
+
query blogs($after: Cursor, $before: Cursor, $first: Int, $last: Int, $orderBy: BlogOrder, $where: BlogWhereInput) {
|
|
5
|
+
blogs(
|
|
6
|
+
after: $after
|
|
7
|
+
before: $before
|
|
8
|
+
first: $first
|
|
9
|
+
last: $last
|
|
10
|
+
orderBy: $orderBy
|
|
11
|
+
where: $where
|
|
12
|
+
) {
|
|
13
|
+
edges {
|
|
14
|
+
cursor
|
|
15
|
+
node {
|
|
16
|
+
baseID
|
|
17
|
+
description
|
|
18
|
+
descriptionMeta
|
|
19
|
+
handle
|
|
20
|
+
articles {
|
|
21
|
+
edges {
|
|
22
|
+
node {
|
|
23
|
+
id
|
|
24
|
+
title
|
|
25
|
+
handle
|
|
26
|
+
description
|
|
27
|
+
templateSuffix
|
|
28
|
+
titleMeta
|
|
29
|
+
descriptionMeta
|
|
30
|
+
baseID
|
|
31
|
+
tags
|
|
32
|
+
isSample
|
|
33
|
+
platformCreatedAt
|
|
34
|
+
author
|
|
35
|
+
media {
|
|
36
|
+
width
|
|
37
|
+
src
|
|
38
|
+
height
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
totalCount
|
|
43
|
+
}
|
|
44
|
+
id
|
|
45
|
+
platform
|
|
46
|
+
tags
|
|
47
|
+
templateSuffix
|
|
48
|
+
title
|
|
49
|
+
titleMeta
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
pageInfo {
|
|
53
|
+
endCursor
|
|
54
|
+
hasNextPage
|
|
55
|
+
hasPreviousPage
|
|
56
|
+
startCursor
|
|
57
|
+
}
|
|
58
|
+
totalCount
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
exports.BlogsDocument = BlogsDocument;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const convertTextAlignToJustify = (align)=>{
|
|
4
|
+
const devices = [
|
|
5
|
+
'desktop',
|
|
6
|
+
'tablet',
|
|
7
|
+
'mobile'
|
|
8
|
+
];
|
|
9
|
+
const result = {};
|
|
10
|
+
devices.forEach((device)=>{
|
|
11
|
+
const deviceType = device === 'desktop' ? '' : `${device}:`;
|
|
12
|
+
result[`${deviceType}gp-justify-start`] = align?.[device] === 'left';
|
|
13
|
+
result[`${deviceType}gp-justify-center`] = align?.[device] === 'center';
|
|
14
|
+
result[`${deviceType}gp-justify-end`] = align?.[device] === 'right';
|
|
15
|
+
});
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.convertTextAlignToJustify = convertTextAlignToJustify;
|
|
@@ -9,7 +9,9 @@ const getStyleBackgroundByDevice = (background, options)=>{
|
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
11
11
|
return {
|
|
12
|
-
|
|
12
|
+
...!options?.ignoreBackgroundColor ? {
|
|
13
|
+
...getStyleBgColor(background)
|
|
14
|
+
} : {},
|
|
13
15
|
...!options?.ignoreBackgroundImage ? {
|
|
14
16
|
...getStyleBgImage(background, options),
|
|
15
17
|
...getStyleBgPosition(background),
|
|
@@ -203,7 +205,7 @@ const getGradientBgrStyleForButton = (backgroundStyle)=>{
|
|
|
203
205
|
});
|
|
204
206
|
return bgrStyle;
|
|
205
207
|
};
|
|
206
|
-
const getGradientBgrStyleByDevice = (backgroundStyle)=>{
|
|
208
|
+
const getGradientBgrStyleByDevice = (backgroundStyle, ignoreBackgroundImage = false)=>{
|
|
207
209
|
if (!backgroundStyle) return;
|
|
208
210
|
const bgrStyle = {};
|
|
209
211
|
[
|
|
@@ -214,7 +216,7 @@ const getGradientBgrStyleByDevice = (backgroundStyle)=>{
|
|
|
214
216
|
if (backgroundStyle[device]?.color?.includes(GRADIENT_BGR_KEY)) {
|
|
215
217
|
Object.assign(bgrStyle, {
|
|
216
218
|
[`--bgc${device !== 'desktop' ? '-' + device : ''}`]: 'transparent',
|
|
217
|
-
[`--bgi${device !== 'desktop' ? '-' + device : ''}`]: `${getBgImageByDevice(backgroundStyle, device) || 'url()'}, ${backgroundStyle[device]?.color}`
|
|
219
|
+
[`--bgi${device !== 'desktop' ? '-' + device : ''}`]: ignoreBackgroundImage ? `${backgroundStyle[device]?.color}` : `${getBgImageByDevice(backgroundStyle, device) || 'url()'}, ${backgroundStyle[device]?.color}`
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
222
|
});
|
|
@@ -227,4 +229,5 @@ exports.getBgImageByDevice = getBgImageByDevice;
|
|
|
227
229
|
exports.getGradientBgrStyleByDevice = getGradientBgrStyleByDevice;
|
|
228
230
|
exports.getGradientBgrStyleForButton = getGradientBgrStyleForButton;
|
|
229
231
|
exports.getStyleBackgroundByDevice = getStyleBackgroundByDevice;
|
|
232
|
+
exports.getStyleBgColor = getStyleBgColor;
|
|
230
233
|
exports.makeFixedBgAttachment = makeFixedBgAttachment;
|
|
@@ -2,24 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
var getResonsiveValue = require('./get-resonsive-value.js');
|
|
4
4
|
|
|
5
|
-
const getCarouselContainerHeight = (dotStyle
|
|
6
|
-
const getVal = (dotStyle
|
|
7
|
-
|
|
8
|
-
return `calc(100% - ${dotSize ?? '0'}px - ${!dotGapToCarousel || dotGapToCarousel === 'Auto' ? '0' : dotGapToCarousel}px)`;
|
|
9
|
-
}
|
|
10
|
-
return '100%';
|
|
5
|
+
const getCarouselContainerHeight = (dotStyle)=>{
|
|
6
|
+
const getVal = (dotStyle)=>{
|
|
7
|
+
return dotStyle === 'outside' ? 'auto' : '100%';
|
|
11
8
|
};
|
|
12
9
|
return {
|
|
13
|
-
desktop: getVal(getResonsiveValue.getResponsiveValueByScreen(dotStyle, 'desktop')
|
|
14
|
-
tablet: getVal(getResonsiveValue.getResponsiveValueByScreen(dotStyle, 'tablet')
|
|
15
|
-
mobile: getVal(getResonsiveValue.getResponsiveValueByScreen(dotStyle, 'mobile')
|
|
10
|
+
desktop: getVal(getResonsiveValue.getResponsiveValueByScreen(dotStyle, 'desktop')),
|
|
11
|
+
tablet: getVal(getResonsiveValue.getResponsiveValueByScreen(dotStyle, 'tablet')),
|
|
12
|
+
mobile: getVal(getResonsiveValue.getResponsiveValueByScreen(dotStyle, 'mobile'))
|
|
16
13
|
};
|
|
17
14
|
};
|
|
18
15
|
const makeContainerWidthOrHeight = (setting)=>{
|
|
19
16
|
const getStyleName = (vertical)=>{
|
|
20
17
|
return vertical ? 'w' : 'h';
|
|
21
18
|
};
|
|
22
|
-
const result = getCarouselContainerHeight(setting.dotStyle
|
|
19
|
+
const result = getCarouselContainerHeight(setting.dotStyle);
|
|
23
20
|
return {
|
|
24
21
|
[`--${getStyleName(getResonsiveValue.getResponsiveValueByScreen(setting?.vertical, 'desktop'))}`]: result.desktop,
|
|
25
22
|
[`--${getStyleName(getResonsiveValue.getResponsiveValueByScreen(setting?.vertical, 'tablet'))}-tablet`]: result.tablet,
|
|
@@ -119,7 +119,7 @@ const getGlobalColorStateStyle = (type, data)=>{
|
|
|
119
119
|
return Object.fromEntries(Object.entries(data).map(([state, value])=>{
|
|
120
120
|
if (state === 'active') return [];
|
|
121
121
|
return [
|
|
122
|
-
`-${constant.stateMapping?.[state]}-${type}`,
|
|
122
|
+
`-${constant.stateMapping?.[state] || ''}-${type}`,
|
|
123
123
|
getSingleColorVariable(value)
|
|
124
124
|
];
|
|
125
125
|
}).filter(isDefined.isDefined));
|
|
@@ -156,7 +156,7 @@ const getSingleColorVariable = (color)=>{
|
|
|
156
156
|
};
|
|
157
157
|
function isColor(color) {
|
|
158
158
|
if (!color || typeof color !== 'string') return false;
|
|
159
|
-
return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent');
|
|
159
|
+
return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent') || color?.startsWith('linear-gradient');
|
|
160
160
|
}
|
|
161
161
|
const getGlobalColorStyle = (data)=>{
|
|
162
162
|
if (!data) return {};
|
|
@@ -80,6 +80,28 @@ const getProductQueryAll = async (fetcher, arg)=>{
|
|
|
80
80
|
const pageData = await fetchProducts(fetcher, variables);
|
|
81
81
|
return pageData;
|
|
82
82
|
};
|
|
83
|
+
const getListProductByVariables = async (fetcher, arg)=>{
|
|
84
|
+
const variables = {
|
|
85
|
+
first: arg.first || 8,
|
|
86
|
+
firstMedia: 1,
|
|
87
|
+
firstVariant: 1,
|
|
88
|
+
orderBy: {
|
|
89
|
+
field: 'PLATFORM_CREATED_AT',
|
|
90
|
+
direction: 'DESC'
|
|
91
|
+
},
|
|
92
|
+
orderByMedia: {
|
|
93
|
+
field: 'POSITION',
|
|
94
|
+
direction: 'ASC'
|
|
95
|
+
},
|
|
96
|
+
where: {
|
|
97
|
+
status: 'ACTIVE',
|
|
98
|
+
...arg.where
|
|
99
|
+
},
|
|
100
|
+
after: arg.after
|
|
101
|
+
};
|
|
102
|
+
const pageData = await fetchProducts(fetcher, variables);
|
|
103
|
+
return pageData;
|
|
104
|
+
};
|
|
83
105
|
const fetchProducts = async (fetcher, variables)=>{
|
|
84
106
|
return fetcher([
|
|
85
107
|
products_generated.ProductsDocument,
|
|
@@ -187,5 +209,6 @@ const mergeMediasToProducts = async ({ fetcher, products, isSample, isStorefront
|
|
|
187
209
|
// );
|
|
188
210
|
// };
|
|
189
211
|
|
|
212
|
+
exports.getListProductByVariables = getListProductByVariables;
|
|
190
213
|
exports.getProductQueryAll = getProductQueryAll;
|
|
191
214
|
exports.getProducts = getProducts;
|
|
@@ -27,7 +27,7 @@ const getStyleShadow = (shadowStyle, isActiveState = false)=>{
|
|
|
27
27
|
if (typeof value.distance == 'undefined') return {};
|
|
28
28
|
const { value: distance, unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
|
|
29
29
|
return {
|
|
30
|
-
[`-${!isActiveState ? constant.stateMapping?.[state] : ''}-${getShortname.getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${colors.getSingleColorVariable(value?.color)}` : 'none'
|
|
30
|
+
[`-${!isActiveState ? constant.stateMapping?.[state] || '' : ''}-${getShortname.getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${colors.getSingleColorVariable(value?.color)}` : 'none'
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
|
|
@@ -10,7 +10,9 @@ const composeTypographyCss = (typography)=>{
|
|
|
10
10
|
const typographyCustom = typography?.custom;
|
|
11
11
|
const { fontFamily, fontSize, fontStyle, fontWeight, lineHeight, letterSpacing } = typographyCustom?.desktop ?? {};
|
|
12
12
|
return `
|
|
13
|
-
${fontFamily ? `
|
|
13
|
+
${fontFamily ? `fontFamily: ${composeFontFamilyTypographyV2({
|
|
14
|
+
fontFamily
|
|
15
|
+
})};` : ''}
|
|
14
16
|
${fontSize ? `font-size: ${fontSize};` : ''}
|
|
15
17
|
${fontStyle ? `font-style: ${fontStyle};` : ''}
|
|
16
18
|
${fontWeight ? `font-weight: ${fontWeight};` : ''}
|
|
@@ -25,11 +27,13 @@ const composeTypographyV2Css = (typography, isImportant)=>{
|
|
|
25
27
|
const { bold, italic, underline, transform } = typographyAttrs ?? {};
|
|
26
28
|
const composeImportant = isImportant ? '!important' : '';
|
|
27
29
|
return `
|
|
28
|
-
${fontFamily ?
|
|
30
|
+
${fontFamily ? composeFontFamilyTypographyV2({
|
|
31
|
+
fontFamily
|
|
32
|
+
}) : ''}
|
|
29
33
|
${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant};` : ''}
|
|
30
34
|
${bold ? `font-weight: bold ${composeImportant};` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant};` : ''}
|
|
31
35
|
${letterSpacing ? `letter-spacing: ${letterSpacing} ${composeImportant};` : ''}
|
|
32
|
-
${lineHeight ? `line-height: ${lineHeight} ${composeImportant};` : ''}
|
|
36
|
+
${lineHeight?.desktop ? `line-height: ${lineHeight?.desktop} ${composeImportant};` : ''}
|
|
33
37
|
${italic ? `font-style: italic ${composeImportant};` : ''}
|
|
34
38
|
${underline ? `text-decoration-line: underline ${composeImportant};` : ''}
|
|
35
39
|
${transform ? `text-transform: ${transform} ${composeImportant};` : ''}
|
|
@@ -43,7 +47,9 @@ function getCustomCSSByDevice(typography, device) {
|
|
|
43
47
|
[`--size${suffix}`]: typography?.[device]?.fontSize,
|
|
44
48
|
[`--lh${suffix}`]: typography?.[device]?.lineHeight,
|
|
45
49
|
[`--fs${suffix}`]: typography?.[device]?.fontStyle,
|
|
46
|
-
[`--ff${suffix}`]:
|
|
50
|
+
[`--ff${suffix}`]: composeFontFamilyTypographyV2({
|
|
51
|
+
fontFamily
|
|
52
|
+
}),
|
|
47
53
|
[`--weight${suffix}`]: typography?.[device]?.fontWeight,
|
|
48
54
|
[`--ls${suffix}`]: typography?.[device]?.letterSpacing
|
|
49
55
|
};
|
|
@@ -61,14 +67,42 @@ const composeTypographyV2 = (value, attrs)=>{
|
|
|
61
67
|
return makeStyle.removeNullUndefined({
|
|
62
68
|
...makeStyle.makeStyle({
|
|
63
69
|
fs: !attrs?.italic ? value?.fontStyle : undefined,
|
|
64
|
-
ff:
|
|
70
|
+
ff: composeFontFamilyTypographyV2(value),
|
|
65
71
|
weight: !attrs?.bold ? value?.fontWeight : undefined,
|
|
66
|
-
ls: value?.letterSpacing
|
|
67
|
-
lh: value?.lineHeight
|
|
72
|
+
ls: value?.letterSpacing
|
|
68
73
|
}),
|
|
69
|
-
...makeStyle.makeStyleResponsive('size', value?.fontSize)
|
|
74
|
+
...makeStyle.makeStyleResponsive('size', value?.fontSize),
|
|
75
|
+
...makeStyle.makeStyleResponsive('lh', value?.lineHeight)
|
|
70
76
|
});
|
|
71
77
|
};
|
|
78
|
+
const composeFontFamilyTypographyV2 = (value)=>{
|
|
79
|
+
const fontFamily = value?.fontFamily;
|
|
80
|
+
if (!fontFamily) return;
|
|
81
|
+
if (typeof fontFamily === 'string') {
|
|
82
|
+
return getFontUsedByTypographyV2({
|
|
83
|
+
fontFamily,
|
|
84
|
+
fallbackFontFamily: value?.fallbackFontFamily
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (typeof fontFamily === 'object' && typeof fontFamily?.value === 'string') {
|
|
88
|
+
switch(fontFamily.type){
|
|
89
|
+
case 'theme':
|
|
90
|
+
return `var(${fontFamily?.value}), var(--g-font-body)`;
|
|
91
|
+
default:
|
|
92
|
+
return getFontUsedByTypographyV2({
|
|
93
|
+
fontFamily: fontFamily.value,
|
|
94
|
+
fallbackFontFamily: value?.fallbackFontFamily
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
};
|
|
100
|
+
const getFontUsedByTypographyV2 = ({ fontFamily, fallbackFontFamily })=>{
|
|
101
|
+
if (fontFamily) {
|
|
102
|
+
return `var(--g-font-${fontFamily?.replace(/ /g, '-')}, '${fontFamily}'), ${fallbackFontFamily}`;
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
};
|
|
72
106
|
const composeTypographyAttr = (attrs)=>{
|
|
73
107
|
if (!attrs) return {};
|
|
74
108
|
return makeStyle.removeNullUndefined({
|
|
@@ -116,6 +150,7 @@ const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
|
116
150
|
};
|
|
117
151
|
|
|
118
152
|
exports.composeFallbackTypographyStyle = composeFallbackTypographyStyle;
|
|
153
|
+
exports.composeFontFamilyTypographyV2 = composeFontFamilyTypographyV2;
|
|
119
154
|
exports.composeTypography = composeTypography;
|
|
120
155
|
exports.composeTypographyAttr = composeTypographyAttr;
|
|
121
156
|
exports.composeTypographyClassName = composeTypographyClassName;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var articles_generated = require('../../graphql/queries/articles.generated.js');
|
|
4
|
+
var useFetchHandle = require('../useFetchHandle.js');
|
|
5
|
+
var useSWR = require('swr');
|
|
6
|
+
var blogs_generated = require('../../graphql/queries/blogs.generated.js');
|
|
7
|
+
|
|
8
|
+
const useArticlesQuery = (variables, options)=>{
|
|
9
|
+
const fetcher = useFetchHandle.useFetchHandle();
|
|
10
|
+
const fetchArticles = ()=>fetcher([
|
|
11
|
+
articles_generated.ArticlesDocument,
|
|
12
|
+
variables ?? {}
|
|
13
|
+
]);
|
|
14
|
+
return useSWR(variables ? [
|
|
15
|
+
'query/articles',
|
|
16
|
+
variables
|
|
17
|
+
] : null, fetchArticles, options);
|
|
18
|
+
};
|
|
19
|
+
const useBlogsQuery = (variables, options)=>{
|
|
20
|
+
const fetcher = useFetchHandle.useFetchHandle();
|
|
21
|
+
const fetchBlogs = ()=>fetcher([
|
|
22
|
+
blogs_generated.BlogsDocument,
|
|
23
|
+
variables ?? {}
|
|
24
|
+
]);
|
|
25
|
+
return useSWR(variables ? [
|
|
26
|
+
'query/blogs',
|
|
27
|
+
variables
|
|
28
|
+
] : null, fetchBlogs, options);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.useArticlesQuery = useArticlesQuery;
|
|
32
|
+
exports.useBlogsQuery = useBlogsQuery;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var useSWR = require('swr');
|
|
4
|
+
var useSWRInfinite = require('swr/infinite');
|
|
4
5
|
var getProducts = require('../../helpers/queries/get-products.js');
|
|
5
6
|
var query = require('../../helpers/query.js');
|
|
6
7
|
var shop = require('../shop.js');
|
|
@@ -20,6 +21,33 @@ const useProductsQuery = (ids, options, params)=>{
|
|
|
20
21
|
return getProducts.getProducts(params?.fetcher || fetcher, arg);
|
|
21
22
|
}, options);
|
|
22
23
|
};
|
|
24
|
+
const getKey = (variable)=>{
|
|
25
|
+
return (pageIndex, previousPageData)=>{
|
|
26
|
+
if (!variable || previousPageData && !previousPageData.products?.pageInfo?.hasNextPage) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (pageIndex === 0) {
|
|
30
|
+
return [
|
|
31
|
+
'query/products',
|
|
32
|
+
variable
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
return [
|
|
36
|
+
'query/products',
|
|
37
|
+
{
|
|
38
|
+
...variable,
|
|
39
|
+
after: previousPageData.products?.pageInfo?.endCursor
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const useListProductQuery = (variable, options)=>{
|
|
45
|
+
const fetcher = useFetchHandle.useFetchHandle();
|
|
46
|
+
const data = useSWRInfinite(getKey(variable), async ([, arg])=>{
|
|
47
|
+
return getProducts.getListProductByVariables(fetcher, arg);
|
|
48
|
+
}, options);
|
|
49
|
+
return data;
|
|
50
|
+
};
|
|
23
51
|
const useProductsQueryAll = (variable, options)=>{
|
|
24
52
|
const fetcher = useFetchHandle.useFetchHandle();
|
|
25
53
|
return useSWR(variable ? [
|
|
@@ -30,5 +58,6 @@ const useProductsQueryAll = (variable, options)=>{
|
|
|
30
58
|
}, options);
|
|
31
59
|
};
|
|
32
60
|
|
|
61
|
+
exports.useListProductQuery = useListProductQuery;
|
|
33
62
|
exports.useProductsQuery = useProductsQuery;
|
|
34
63
|
exports.useProductsQueryAll = useProductsQueryAll;
|
|
@@ -7,10 +7,13 @@ require('zustand');
|
|
|
7
7
|
require('swr');
|
|
8
8
|
require('@gem-sdk/adapter-shopify');
|
|
9
9
|
require('swr/mutation');
|
|
10
|
+
require('swr/infinite');
|
|
10
11
|
require('vanilla-lazyload');
|
|
11
12
|
require('./useCartUI.js');
|
|
12
13
|
require('react-transition-group');
|
|
13
14
|
require('@gem-sdk/core');
|
|
15
|
+
require('classnames');
|
|
16
|
+
require('dayjs');
|
|
14
17
|
require('../helpers/convert.js');
|
|
15
18
|
|
|
16
19
|
const useAnimations = ()=>{
|
|
@@ -5,70 +5,71 @@ var shop = require('./shop.js');
|
|
|
5
5
|
const shopifyPriceRounding = (amount, precision)=>{
|
|
6
6
|
return parseFloat(`${amount}`).toFixed(Number(precision) + 1).slice(0, -1);
|
|
7
7
|
};
|
|
8
|
+
const formatMoney = function(cents, format) {
|
|
9
|
+
let value = '';
|
|
10
|
+
const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
|
|
11
|
+
const formatString = format || '${{amount}}';
|
|
12
|
+
/**
|
|
13
|
+
* check default
|
|
14
|
+
* @param opt opt
|
|
15
|
+
* @param def def
|
|
16
|
+
* @returns any
|
|
17
|
+
*/ function defaultOption(opt, def) {
|
|
18
|
+
return typeof opt == 'undefined' ? def : opt;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* formatWithDelimiters
|
|
22
|
+
* @param number number
|
|
23
|
+
* @param precision precision
|
|
24
|
+
* @param thousands thousands
|
|
25
|
+
* @param decimal decimal
|
|
26
|
+
* @returns any
|
|
27
|
+
*/ // eslint-disable-next-line max-params
|
|
28
|
+
function formatWithDelimiters(number, precision, thousands, decimal) {
|
|
29
|
+
precision = defaultOption(precision, 2);
|
|
30
|
+
thousands = defaultOption(thousands, ',');
|
|
31
|
+
decimal = defaultOption(decimal, '.');
|
|
32
|
+
if (isNaN(number) || number == null) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
// shopify làm tròn bằng cách cắt đi các số ở đằng sau chứ không sử dụng toFixed để làm tròn như toán học
|
|
36
|
+
number = shopifyPriceRounding(number, Number(precision));
|
|
37
|
+
const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
|
|
38
|
+
return dollars + cents;
|
|
39
|
+
}
|
|
40
|
+
switch(formatString.match(placeholderRegex)[1]){
|
|
41
|
+
case 'amount':
|
|
42
|
+
value = formatWithDelimiters(cents, 2);
|
|
43
|
+
break;
|
|
44
|
+
case 'amount_no_decimals':
|
|
45
|
+
value = formatWithDelimiters(cents, 0);
|
|
46
|
+
break;
|
|
47
|
+
case 'amount_with_comma_separator':
|
|
48
|
+
value = formatWithDelimiters(cents, 2, '.', ',');
|
|
49
|
+
break;
|
|
50
|
+
case 'amount_no_decimals_with_comma_separator':
|
|
51
|
+
value = formatWithDelimiters(cents, 0, '.', ',');
|
|
52
|
+
break;
|
|
53
|
+
case 'amount_with_apostrophe_separator':
|
|
54
|
+
value = formatWithDelimiters(cents, 2, "'", '.');
|
|
55
|
+
break;
|
|
56
|
+
case 'amount_no_decimals_with_space_separator':
|
|
57
|
+
value = formatWithDelimiters(cents, 0, ' ');
|
|
58
|
+
break;
|
|
59
|
+
case 'amount_with_space_separator':
|
|
60
|
+
value = formatWithDelimiters(cents, 2, ' ', ',');
|
|
61
|
+
break;
|
|
62
|
+
case 'amount_with_period_and_space_separator':
|
|
63
|
+
value = formatWithDelimiters(cents, 2, ' ', '.');
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return formatString.replace(placeholderRegex, value);
|
|
67
|
+
};
|
|
8
68
|
const useFormatMoney = (amount, withCurrency)=>{
|
|
9
69
|
const { moneyFormat, moneyWithCurrencyFormat } = shop.useMoneyFormat();
|
|
10
|
-
const formatMoney = function(cents, format) {
|
|
11
|
-
let value = '';
|
|
12
|
-
const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
|
|
13
|
-
const formatString = format || '${{amount}}';
|
|
14
|
-
/**
|
|
15
|
-
* check default
|
|
16
|
-
* @param opt opt
|
|
17
|
-
* @param def def
|
|
18
|
-
* @returns any
|
|
19
|
-
*/ function defaultOption(opt, def) {
|
|
20
|
-
return typeof opt == 'undefined' ? def : opt;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* formatWithDelimiters
|
|
24
|
-
* @param number number
|
|
25
|
-
* @param precision precision
|
|
26
|
-
* @param thousands thousands
|
|
27
|
-
* @param decimal decimal
|
|
28
|
-
* @returns any
|
|
29
|
-
*/ // eslint-disable-next-line max-params
|
|
30
|
-
function formatWithDelimiters(number, precision, thousands, decimal) {
|
|
31
|
-
precision = defaultOption(precision, 2);
|
|
32
|
-
thousands = defaultOption(thousands, ',');
|
|
33
|
-
decimal = defaultOption(decimal, '.');
|
|
34
|
-
if (isNaN(number) || number == null) {
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
// shopify làm tròn bằng cách cắt đi các số ở đằng sau chứ không sử dụng toFixed để làm tròn như toán học
|
|
38
|
-
number = shopifyPriceRounding(number, Number(precision));
|
|
39
|
-
const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
|
|
40
|
-
return dollars + cents;
|
|
41
|
-
}
|
|
42
|
-
switch(formatString.match(placeholderRegex)[1]){
|
|
43
|
-
case 'amount':
|
|
44
|
-
value = formatWithDelimiters(cents, 2);
|
|
45
|
-
break;
|
|
46
|
-
case 'amount_no_decimals':
|
|
47
|
-
value = formatWithDelimiters(cents, 0);
|
|
48
|
-
break;
|
|
49
|
-
case 'amount_with_comma_separator':
|
|
50
|
-
value = formatWithDelimiters(cents, 2, '.', ',');
|
|
51
|
-
break;
|
|
52
|
-
case 'amount_no_decimals_with_comma_separator':
|
|
53
|
-
value = formatWithDelimiters(cents, 0, '.', ',');
|
|
54
|
-
break;
|
|
55
|
-
case 'amount_with_apostrophe_separator':
|
|
56
|
-
value = formatWithDelimiters(cents, 2, "'", '.');
|
|
57
|
-
break;
|
|
58
|
-
case 'amount_no_decimals_with_space_separator':
|
|
59
|
-
value = formatWithDelimiters(cents, 0, ' ');
|
|
60
|
-
break;
|
|
61
|
-
case 'amount_with_space_separator':
|
|
62
|
-
value = formatWithDelimiters(cents, 2, ' ', ',');
|
|
63
|
-
break;
|
|
64
|
-
case 'amount_with_period_and_space_separator':
|
|
65
|
-
value = formatWithDelimiters(cents, 2, ' ', '.');
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
return formatString.replace(placeholderRegex, value);
|
|
69
|
-
};
|
|
70
70
|
return withCurrency ? formatMoney(`${amount}`, moneyWithCurrencyFormat || moneyFormat) : formatMoney(`${amount}`, moneyFormat);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
exports.formatMoney = formatMoney;
|
|
73
74
|
exports.shopifyPriceRounding = shopifyPriceRounding;
|
|
74
75
|
exports.useFormatMoney = useFormatMoney;
|
|
@@ -13,10 +13,13 @@ require('react/jsx-runtime');
|
|
|
13
13
|
require('zustand');
|
|
14
14
|
require('@gem-sdk/adapter-shopify');
|
|
15
15
|
require('swr/mutation');
|
|
16
|
+
require('swr/infinite');
|
|
16
17
|
require('vanilla-lazyload');
|
|
17
18
|
require('./useCartUI.js');
|
|
18
19
|
require('react-transition-group');
|
|
19
20
|
require('@gem-sdk/core');
|
|
21
|
+
require('classnames');
|
|
22
|
+
require('dayjs');
|
|
20
23
|
var isBrowser = require('../helpers/is-browser.js');
|
|
21
24
|
require('../helpers/convert.js');
|
|
22
25
|
|
|
@@ -8,11 +8,14 @@ require('swr');
|
|
|
8
8
|
var PageContext = require('../contexts/PageContext.js');
|
|
9
9
|
require('@gem-sdk/adapter-shopify');
|
|
10
10
|
require('swr/mutation');
|
|
11
|
+
require('swr/infinite');
|
|
11
12
|
require('vanilla-lazyload');
|
|
12
13
|
require('./useCartUI.js');
|
|
13
14
|
var variant = require('../helpers/variant.js');
|
|
14
15
|
require('react-transition-group');
|
|
15
16
|
require('@gem-sdk/core');
|
|
17
|
+
require('classnames');
|
|
18
|
+
require('dayjs');
|
|
16
19
|
var flattenConnection = require('../helpers/flatten-connection.js');
|
|
17
20
|
require('../helpers/convert.js');
|
|
18
21
|
var product = require('../helpers/product.js');
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var ShopContext = require('./contexts/ShopContext.js');
|
|
|
16
16
|
var PageContext = require('./contexts/PageContext.js');
|
|
17
17
|
var CollectionContext = require('./contexts/CollectionContext.js');
|
|
18
18
|
var ModalContext = require('./contexts/ModalContext.js');
|
|
19
|
+
var ArticleListContext = require('./contexts/ArticleListContext.js');
|
|
20
|
+
var ArticleContext = require('./contexts/ArticleContext.js');
|
|
19
21
|
var pageViewUp_generated = require('./graphql/mutations/page-view-up.generated.js');
|
|
20
22
|
var collectionDetailFilter_generated = require('./graphql/queries/collection-detail-filter.generated.js');
|
|
21
23
|
var collection_generated = require('./graphql/queries/collection.generated.js');
|
|
@@ -58,6 +60,7 @@ var iconList = require('./helpers/icon-list.js');
|
|
|
58
60
|
var isDefined = require('./helpers/is-defined.js');
|
|
59
61
|
var layout = require('./helpers/layout.js');
|
|
60
62
|
var makeStyle = require('./helpers/make-style.js');
|
|
63
|
+
var align = require('./helpers/align.js');
|
|
61
64
|
var product = require('./helpers/product.js');
|
|
62
65
|
var query = require('./helpers/query.js');
|
|
63
66
|
var radius = require('./helpers/radius.js');
|
|
@@ -89,6 +92,7 @@ var useIsomorphicLayoutEffect = require('./hooks/useIsomorphicLayoutEffect.js');
|
|
|
89
92
|
var useLoadScript = require('./hooks/useLoadScript.js');
|
|
90
93
|
var useMoney = require('./hooks/useMoney.js');
|
|
91
94
|
var usePrevious = require('./hooks/usePrevious.js');
|
|
95
|
+
var useArticlesQuery = require('./hooks/articles/useArticlesQuery.js');
|
|
92
96
|
var useProduct = require('./hooks/useProduct.js');
|
|
93
97
|
var useProductList = require('./hooks/useProductList.js');
|
|
94
98
|
var useSuspenseFetch = require('./hooks/useSuspenseFetch.js');
|
|
@@ -136,6 +140,10 @@ exports.CollectionProvider = CollectionContext.CollectionProvider;
|
|
|
136
140
|
exports.useCollectionStore = CollectionContext.useCollectionStore;
|
|
137
141
|
exports.ModalProvider = ModalContext.ModalProvider;
|
|
138
142
|
exports.useModalStore = ModalContext.useModalStore;
|
|
143
|
+
exports.ArticleListProvider = ArticleListContext.ArticleListProvider;
|
|
144
|
+
exports.useArticleListStore = ArticleListContext.useArticleListStore;
|
|
145
|
+
exports.ArticleProvider = ArticleContext.ArticleProvider;
|
|
146
|
+
exports.useArticleStore = ArticleContext.useArticleStore;
|
|
139
147
|
exports.PageViewUpDocument = pageViewUp_generated.PageViewUpDocument;
|
|
140
148
|
exports.CollectionDetailFilterDocument = collectionDetailFilter_generated.CollectionDetailFilterDocument;
|
|
141
149
|
exports.CollectionDocument = collection_generated.CollectionDocument;
|
|
@@ -187,6 +195,7 @@ exports.getBgImageByDevice = background.getBgImageByDevice;
|
|
|
187
195
|
exports.getGradientBgrStyleByDevice = background.getGradientBgrStyleByDevice;
|
|
188
196
|
exports.getGradientBgrStyleForButton = background.getGradientBgrStyleForButton;
|
|
189
197
|
exports.getStyleBackgroundByDevice = background.getStyleBackgroundByDevice;
|
|
198
|
+
exports.getStyleBgColor = background.getStyleBgColor;
|
|
190
199
|
exports.makeFixedBgAttachment = background.makeFixedBgAttachment;
|
|
191
200
|
exports.composeTextColorCss = colors.composeTextColorCss;
|
|
192
201
|
exports.getGlobalColorCSSProp = colors.getGlobalColorCSSProp;
|
|
@@ -232,6 +241,7 @@ exports.makeStyleResponsiveState = makeStyle.makeStyleResponsiveState;
|
|
|
232
241
|
exports.makeStyleState = makeStyle.makeStyleState;
|
|
233
242
|
exports.makeWidth = makeStyle.makeWidth;
|
|
234
243
|
exports.removeNullUndefined = makeStyle.removeNullUndefined;
|
|
244
|
+
exports.convertTextAlignToJustify = align.convertTextAlignToJustify;
|
|
235
245
|
exports.checkAvailableVariantInStock = product.checkAvailableVariantInStock;
|
|
236
246
|
exports.getSelectedVariant = product.getSelectedVariant;
|
|
237
247
|
exports.parseSelectedOption = product.parseSelectedOption;
|
|
@@ -269,6 +279,7 @@ exports.makeGlobalSize = size.makeGlobalSize;
|
|
|
269
279
|
exports.makeGlobalSizeIcon = size.makeGlobalSizeIcon;
|
|
270
280
|
exports.makeStyleWithDefault = size.makeStyleWithDefault;
|
|
271
281
|
exports.composeFallbackTypographyStyle = typography.composeFallbackTypographyStyle;
|
|
282
|
+
exports.composeFontFamilyTypographyV2 = typography.composeFontFamilyTypographyV2;
|
|
272
283
|
exports.composeTypography = typography.composeTypography;
|
|
273
284
|
exports.composeTypographyAttr = typography.composeTypographyAttr;
|
|
274
285
|
exports.composeTypographyClassName = typography.composeTypographyClassName;
|
|
@@ -304,6 +315,7 @@ exports.useProductQuery = useProductQuery.useProductQuery;
|
|
|
304
315
|
exports.useProductsQuery = useProductsQuery.useProductsQuery;
|
|
305
316
|
exports.useProductsQueryAll = useProductsQuery.useProductsQueryAll;
|
|
306
317
|
exports.useCurrentDevice = useCurrentDevice.useCurrentDevice;
|
|
318
|
+
exports.formatMoney = useFormatMoney.formatMoney;
|
|
307
319
|
exports.shopifyPriceRounding = useFormatMoney.shopifyPriceRounding;
|
|
308
320
|
exports.useFormatMoney = useFormatMoney.useFormatMoney;
|
|
309
321
|
exports.useLazyVideo = useLazyVideo.useLazyVideo;
|
|
@@ -319,6 +331,8 @@ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect.default;
|
|
|
319
331
|
exports.useLoadScript = useLoadScript.default;
|
|
320
332
|
exports.useMoney = useMoney.default;
|
|
321
333
|
exports.usePrevious = usePrevious.usePrevious;
|
|
334
|
+
exports.useArticlesQuery = useArticlesQuery.useArticlesQuery;
|
|
335
|
+
exports.useBlogsQuery = useArticlesQuery.useBlogsQuery;
|
|
322
336
|
exports.useCheckAvailableVariantInStock = useProduct.useCheckAvailableVariantInStock;
|
|
323
337
|
exports.useCurrentVariant = useProduct.useCurrentVariant;
|
|
324
338
|
exports.useCurrentVariantInStock = useProduct.useCurrentVariantInStock;
|