@gem-sdk/components 2.0.0-dev.350 → 2.0.0-dev.352
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/article/setting/configs/ArticleAuthor/uiV2.js +9 -2
- package/dist/cjs/article/setting/configs/ArticleDate/uiV2.js +13 -6
- package/dist/cjs/article/setting/configs/ArticleExcerpt/settings.js +1 -1
- package/dist/cjs/article/setting/configs/ArticleExcerpt/uiV2.js +11 -1
- package/dist/cjs/article/setting/configs/ArticleReadMore/presets.js +9 -9
- package/dist/cjs/article/setting/configs/ArticleReadMore/settings.js +4 -4
- package/dist/cjs/article/setting/configs/ArticleReadMore/uiV2.js +16 -12
- package/dist/cjs/banner/components/HeroBanner.liquid.js +1 -1
- package/dist/cjs/banner/setting/presets/heroBanner1Col.js +0 -9
- package/dist/cjs/banner/setting/presets/heroBannerContentLeft.js +0 -9
- package/dist/cjs/banner/setting/presets/heroBannerContentRight.js +0 -9
- package/dist/cjs/banner/setting/presets/heroBannerParallax.js +0 -9
- package/dist/cjs/banner/setting/presets/heroBannerVideo.js +6 -0
- package/dist/cjs/banner/setting/setting.js +9 -5
- package/dist/cjs/stock-counter/components/StockCounter.js +104 -112
- package/dist/cjs/stock-counter/components/StockCounter.liquid.js +116 -141
- package/dist/cjs/stock-counter/components/common/getAttrs.js +44 -0
- package/dist/cjs/stock-counter/components/common/getClasses.js +68 -0
- package/dist/cjs/stock-counter/components/common/getContent.js +71 -0
- package/dist/cjs/stock-counter/components/common/getInlineCss.js +39 -0
- package/dist/cjs/stock-counter/components/common/getStyles.js +73 -0
- package/dist/cjs/stock-counter/components/hook/useStockCounter.js +37 -0
- package/dist/cjs/stock-counter/const.js +0 -6
- package/dist/cjs/stock-counter/helpers.js +0 -14
- package/dist/cjs/stock-counter/index.js +3 -1
- package/dist/cjs/stock-counter/setting/StockCounter.js +2 -2
- package/dist/cjs/stock-counter/setting/configs/presets.js +3 -0
- package/dist/cjs/stock-counter/setting/configs/{settings.js → settingsV2.js} +211 -42
- package/dist/cjs/stock-counter/setting/configs/uiV2.js +228 -41
- package/dist/esm/article/setting/configs/ArticleAuthor/uiV2.js +9 -2
- package/dist/esm/article/setting/configs/ArticleDate/uiV2.js +13 -6
- package/dist/esm/article/setting/configs/ArticleExcerpt/settings.js +1 -1
- package/dist/esm/article/setting/configs/ArticleExcerpt/uiV2.js +11 -1
- package/dist/esm/article/setting/configs/ArticleReadMore/presets.js +9 -9
- package/dist/esm/article/setting/configs/ArticleReadMore/settings.js +4 -4
- package/dist/esm/article/setting/configs/ArticleReadMore/uiV2.js +16 -12
- package/dist/esm/banner/components/HeroBanner.liquid.js +1 -1
- package/dist/esm/banner/setting/presets/heroBanner1Col.js +0 -9
- package/dist/esm/banner/setting/presets/heroBannerContentLeft.js +0 -9
- package/dist/esm/banner/setting/presets/heroBannerContentRight.js +0 -9
- package/dist/esm/banner/setting/presets/heroBannerParallax.js +0 -9
- package/dist/esm/banner/setting/presets/heroBannerVideo.js +6 -0
- package/dist/esm/banner/setting/setting.js +9 -5
- package/dist/esm/stock-counter/components/StockCounter.js +106 -114
- package/dist/esm/stock-counter/components/StockCounter.liquid.js +116 -141
- package/dist/esm/stock-counter/components/common/getAttrs.js +39 -0
- package/dist/esm/stock-counter/components/common/getClasses.js +60 -0
- package/dist/esm/stock-counter/components/common/getContent.js +68 -0
- package/dist/esm/stock-counter/components/common/getInlineCss.js +37 -0
- package/dist/esm/stock-counter/components/common/getStyles.js +67 -0
- package/dist/esm/stock-counter/components/hook/useStockCounter.js +35 -0
- package/dist/esm/stock-counter/const.js +1 -4
- package/dist/esm/stock-counter/helpers.js +1 -14
- package/dist/esm/stock-counter/index.js +3 -1
- package/dist/esm/stock-counter/setting/StockCounter.js +2 -2
- package/dist/esm/stock-counter/setting/configs/presets.js +3 -0
- package/dist/esm/stock-counter/setting/configs/settingsV2.js +438 -0
- package/dist/esm/stock-counter/setting/configs/uiV2.js +228 -41
- package/dist/types/index.d.ts +13 -5
- package/package.json +1 -1
- package/dist/esm/stock-counter/setting/configs/settings.js +0 -269
|
@@ -53,15 +53,6 @@ const heroBannerParallax = {
|
|
|
53
53
|
width: '1200px',
|
|
54
54
|
height: '600px'
|
|
55
55
|
}
|
|
56
|
-
},
|
|
57
|
-
background: {
|
|
58
|
-
desktop: {
|
|
59
|
-
image: {
|
|
60
|
-
src: 'https://cdn.shopify.com/s/files/1/0703/5214/2562/files/gempages_518090459516502570-3ecdd107-d16d-4cc1-a5f1-00e38afef3eb.png'
|
|
61
|
-
},
|
|
62
|
-
loop: true,
|
|
63
|
-
lazyLoad: false
|
|
64
|
-
}
|
|
65
56
|
}
|
|
66
57
|
},
|
|
67
58
|
childrens: [
|
|
@@ -40,6 +40,12 @@ const heroBannerVideo = {
|
|
|
40
40
|
background: {
|
|
41
41
|
desktop: {
|
|
42
42
|
type: 'video',
|
|
43
|
+
image: {
|
|
44
|
+
src: '',
|
|
45
|
+
width: 1920,
|
|
46
|
+
height: 900
|
|
47
|
+
},
|
|
48
|
+
videoType: 'html5',
|
|
43
49
|
video: 'https://youtu.be/KOxfzBp72uk',
|
|
44
50
|
videoHtml5: 'https://media.w3.org/2010/05/sintel/trailer.mp4'
|
|
45
51
|
}
|
|
@@ -412,14 +412,14 @@ const SettingsV2 = [
|
|
|
412
412
|
id: 'background',
|
|
413
413
|
type: 'background-media',
|
|
414
414
|
label: 'Background Color & Image',
|
|
415
|
+
ignoreReRender: true,
|
|
415
416
|
showVideo: true,
|
|
416
417
|
devices: {
|
|
417
418
|
desktop: {
|
|
418
419
|
default: {
|
|
419
420
|
type: 'image',
|
|
420
|
-
color: 'bg-2',
|
|
421
421
|
image: {
|
|
422
|
-
src: 'https://cdn.shopify.com/s/files/1/0703/5214/2562/files/gempages_518090459516502570-
|
|
422
|
+
src: 'https://cdn.shopify.com/s/files/1/0703/5214/2562/files/gempages_518090459516502570-c9f109ee-2adf-4ec4-8d26-11a891c50a13.png',
|
|
423
423
|
width: 1920,
|
|
424
424
|
height: 900
|
|
425
425
|
},
|
|
@@ -430,8 +430,8 @@ const SettingsV2 = [
|
|
|
430
430
|
},
|
|
431
431
|
repeat: 'no-repeat',
|
|
432
432
|
attachment: 'scroll',
|
|
433
|
-
video: '
|
|
434
|
-
videoHtml5: '
|
|
433
|
+
video: '',
|
|
434
|
+
videoHtml5: '',
|
|
435
435
|
videoType: 'youtube',
|
|
436
436
|
loop: true,
|
|
437
437
|
lazyLoad: false
|
|
@@ -652,12 +652,16 @@ const SettingsV2 = [
|
|
|
652
652
|
],
|
|
653
653
|
step: 1,
|
|
654
654
|
default: {
|
|
655
|
-
normal: '
|
|
655
|
+
normal: '20%',
|
|
656
656
|
hover: '20%'
|
|
657
657
|
},
|
|
658
658
|
state: {
|
|
659
659
|
normal: true,
|
|
660
660
|
hover: true
|
|
661
|
+
},
|
|
662
|
+
compoDefaultValue: {
|
|
663
|
+
normal: '20%',
|
|
664
|
+
hover: '20%'
|
|
661
665
|
}
|
|
662
666
|
},
|
|
663
667
|
{
|
|
@@ -1,135 +1,127 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useRef, useMemo, useEffect } from 'react';
|
|
5
|
-
import { NO_PRODUCT_LEFT, CONTINUE_SELLING_WHEN_OUT_OF_STOCK } from '../const.js';
|
|
6
|
-
import { convertSizeToWidth, transformHighlighTag, transformNumberTag } from '../helpers.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
7
4
|
import { useStockCounterInteraction } from '../hooks/useStockCounterInteraction.js';
|
|
5
|
+
import { getInlineCss } from './common/getInlineCss.js';
|
|
6
|
+
import { getProgressBarClasses, getContainerClasses, getWrapperIconClasses, getIconClasses, getWrapperClasses, getTextClasses } from './common/getClasses.js';
|
|
7
|
+
import { getProgressBarStyles, getContainerStyles, getWrapperStyles, getIconStyles, getTextStyles } from './common/getStyles.js';
|
|
8
|
+
import 'next/link';
|
|
9
|
+
import '@gem-sdk/core';
|
|
10
|
+
import { getWrapperAttrs } from './common/getAttrs.js';
|
|
11
|
+
import { createClass, createStyle, createAttr } from '@gem-sdk/system';
|
|
12
|
+
import { useStockCounter } from './hook/useStockCounter.js';
|
|
8
13
|
|
|
9
14
|
const StockCounter = ({ setting, styles, builderProps })=>{
|
|
10
|
-
const {
|
|
11
|
-
const {
|
|
12
|
-
const
|
|
15
|
+
const { displayProgressBar, borderRadius } = styles ?? {};
|
|
16
|
+
const { showIcon, icon, layout = 'full', oosIcon } = setting ?? {};
|
|
17
|
+
const { getMessage, isOutOfStock, inventoryQuantity } = useStockCounter(setting, styles);
|
|
13
18
|
const elementRef = useRef(null);
|
|
14
|
-
const inventoryQuantity = useMemo(()=>{
|
|
15
|
-
return Number(variant ? variant.inventoryQuantity : 0);
|
|
16
|
-
}, [
|
|
17
|
-
variant
|
|
18
|
-
]);
|
|
19
|
-
const manageInventory = variant ? variant.manageInventory : true;
|
|
20
|
-
const inventoryPolicy = variant ? variant.inventoryPolicy : 'deny';
|
|
21
|
-
const mainColor = textColor || 'brand';
|
|
22
19
|
const { dispatchStockCounterInteraction } = useStockCounterInteraction({
|
|
23
20
|
element: elementRef,
|
|
24
21
|
uid: builderProps?.uid
|
|
25
22
|
});
|
|
26
|
-
const
|
|
27
|
-
return `var(--g-${variableName})`;
|
|
28
|
-
};
|
|
29
|
-
const isOutOfStock = manageInventory && inventoryQuantity <= NO_PRODUCT_LEFT && inventoryPolicy !== CONTINUE_SELLING_WHEN_OUT_OF_STOCK;
|
|
30
|
-
const isContinueShopping = inventoryPolicy === CONTINUE_SELLING_WHEN_OUT_OF_STOCK && inventoryQuantity <= NO_PRODUCT_LEFT;
|
|
31
|
-
const isUnlimitedQuantity = !manageInventory && unlimitedQuantityMessage;
|
|
23
|
+
const inlineCss = getInlineCss(builderProps?.uid, borderRadius);
|
|
32
24
|
const showProgressBar = displayProgressBar !== false && !isOutOfStock;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
25
|
+
const showText = layout !== 'progress-bar';
|
|
26
|
+
const progressBarClasses = createClass({
|
|
27
|
+
...getProgressBarClasses(styles)
|
|
28
|
+
});
|
|
29
|
+
const progressBarStyles = createStyle({
|
|
30
|
+
...getProgressBarStyles(styles, setting)
|
|
31
|
+
});
|
|
32
|
+
const containerStyles = createStyle({
|
|
33
|
+
...getContainerStyles(styles)
|
|
34
|
+
});
|
|
35
|
+
const containerClasses = createClass({
|
|
36
|
+
...getContainerClasses(setting)
|
|
37
|
+
});
|
|
38
|
+
const wrapperStyles = createStyle({
|
|
39
|
+
...getWrapperStyles(styles)
|
|
40
|
+
});
|
|
41
|
+
const wrapperIconClasses = createClass({
|
|
42
|
+
...getWrapperIconClasses(setting)
|
|
43
|
+
});
|
|
44
|
+
const iconClasses = createClass({
|
|
45
|
+
...getIconClasses()
|
|
46
|
+
});
|
|
47
|
+
const iconStyles = (isOutOfStock)=>{
|
|
48
|
+
return createStyle({
|
|
49
|
+
...getIconStyles(styles, setting, isOutOfStock)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const textClasses = (isOutOfStock)=>{
|
|
53
|
+
return createClass({
|
|
54
|
+
...getTextClasses(styles, isOutOfStock)
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const textStyles = (isOutOfStock)=>{
|
|
58
|
+
return createStyle({
|
|
59
|
+
...getTextStyles(styles, isOutOfStock)
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const wrapperClasses = createClass({
|
|
63
|
+
...getWrapperClasses(setting, isOutOfStock)
|
|
64
|
+
});
|
|
65
|
+
const wrapperAttrs = createAttr({
|
|
66
|
+
...getWrapperAttrs(builderProps)
|
|
67
|
+
});
|
|
59
68
|
useEffect(()=>{
|
|
60
69
|
dispatchStockCounterInteraction(inventoryQuantity);
|
|
61
70
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
71
|
}, [
|
|
63
72
|
inventoryQuantity
|
|
64
73
|
]);
|
|
65
|
-
return /*#__PURE__*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
74
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
75
|
+
...wrapperAttrs,
|
|
76
|
+
style: wrapperStyles,
|
|
69
77
|
ref: elementRef,
|
|
70
|
-
className:
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
]
|
|
114
|
-
}),
|
|
115
|
-
showProgressBar && /*#__PURE__*/ jsx("div", {
|
|
116
|
-
style: {
|
|
117
|
-
...makeStyleResponsive('h', progressBarHeight),
|
|
118
|
-
...makeStyle({
|
|
119
|
-
bg: 'linear-gradient(90deg, #eee 50%, transparent 50%)',
|
|
120
|
-
bgc: getSingleColorVariable(color),
|
|
121
|
-
bgp: `${remainingPercentage}% center`
|
|
122
|
-
})
|
|
123
|
-
},
|
|
124
|
-
className: cls('gp-relative gp-mt-2 gp-w-full -gp-scale-100 !gp-bg-[length:200%]', {
|
|
125
|
-
'gp-rounded-md': roundedBorder,
|
|
126
|
-
"before:gp-absolute before:gp-eft-0 before:gp-h-full before:gp-w-full before:gp-animate-shift before:gp-content-['']": effect,
|
|
127
|
-
'before:gp-bg-stock-counter-animate before:gp-bg-[length:60px_100%] before:gp-shadow-stock-counter': effect,
|
|
128
|
-
'before:gp-rounded-md': effect && roundedBorder
|
|
78
|
+
className: wrapperClasses,
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ jsx("style", {
|
|
81
|
+
children: inlineCss
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ jsxs("div", {
|
|
84
|
+
className: containerClasses,
|
|
85
|
+
style: containerStyles,
|
|
86
|
+
children: [
|
|
87
|
+
/*#__PURE__*/ jsxs("div", {
|
|
88
|
+
className: wrapperIconClasses,
|
|
89
|
+
children: [
|
|
90
|
+
showIcon && (isOutOfStock ? /*#__PURE__*/ jsx("div", {
|
|
91
|
+
dangerouslySetInnerHTML: {
|
|
92
|
+
__html: oosIcon || ''
|
|
93
|
+
},
|
|
94
|
+
className: iconClasses,
|
|
95
|
+
style: iconStyles(true)
|
|
96
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
97
|
+
dangerouslySetInnerHTML: {
|
|
98
|
+
__html: icon || ''
|
|
99
|
+
},
|
|
100
|
+
className: iconClasses,
|
|
101
|
+
style: iconStyles(false)
|
|
102
|
+
})),
|
|
103
|
+
showText && (isOutOfStock ? /*#__PURE__*/ jsx("p", {
|
|
104
|
+
dangerouslySetInnerHTML: {
|
|
105
|
+
__html: getMessage()
|
|
106
|
+
},
|
|
107
|
+
className: textClasses(true),
|
|
108
|
+
style: textStyles(true)
|
|
109
|
+
}) : /*#__PURE__*/ jsx("p", {
|
|
110
|
+
dangerouslySetInnerHTML: {
|
|
111
|
+
__html: getMessage()
|
|
112
|
+
},
|
|
113
|
+
className: textClasses(false),
|
|
114
|
+
style: textStyles(false)
|
|
115
|
+
}))
|
|
116
|
+
]
|
|
117
|
+
}),
|
|
118
|
+
showProgressBar && /*#__PURE__*/ jsx("div", {
|
|
119
|
+
style: progressBarStyles,
|
|
120
|
+
className: progressBarClasses
|
|
129
121
|
})
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
]
|
|
133
125
|
});
|
|
134
126
|
};
|
|
135
127
|
|
|
@@ -1,157 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { composeClasses, template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
|
+
import { getSettingPreloadData } from '../../helpers.js';
|
|
3
|
+
import { getInlineCss } from './common/getInlineCss.js';
|
|
4
|
+
import { getProgressBarClasses, getContainerClasses, getLiquidTagClasses, getWrapperIconClasses, getIconClasses, getTextClasses } from './common/getClasses.js';
|
|
5
|
+
import { getProgressBarStyles, getContainerStyles, getWrapperStyles, getIconStyles, getTextStyles } from './common/getStyles.js';
|
|
6
|
+
import { getLiquidTextContent, getLiquidInitData } from './common/getContent.js';
|
|
7
|
+
import { getLiquidTagAttrs, getLiquidProgressBarAttrs, getLiquidTextAttrs } from './common/getAttrs.js';
|
|
8
|
+
import { createAttr, createClass, createStyle } from '@gem-sdk/system';
|
|
5
9
|
|
|
6
10
|
const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
7
|
-
const {
|
|
8
|
-
const {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const { borderRadius } = styles ?? {};
|
|
12
|
+
const { showIcon, icon, oosIcon, layout = 'full' } = setting ?? {};
|
|
13
|
+
const inlineCss = getInlineCss(builderProps?.uid, borderRadius);
|
|
14
|
+
const showText = layout !== 'progress-bar';
|
|
15
|
+
const liquidTagAttrs = createAttr({
|
|
16
|
+
...getLiquidTagAttrs(builderProps, setting, styles)
|
|
17
|
+
});
|
|
18
|
+
const progressBarClasses = createClass({
|
|
19
|
+
...composeClasses('gp-stock-counter-progress gp-mt-2 data-[visible=true]:gp-block data-[visible=false]:gp-hidden'),
|
|
20
|
+
...getProgressBarClasses(styles)
|
|
21
|
+
});
|
|
22
|
+
const progressBarStyles = createStyle({
|
|
23
|
+
...getProgressBarStyles(styles, setting)
|
|
24
|
+
});
|
|
25
|
+
const containerStyles = createStyle({
|
|
26
|
+
...getContainerStyles(styles)
|
|
27
|
+
});
|
|
28
|
+
const containerClasses = createClass({
|
|
29
|
+
...getContainerClasses(setting)
|
|
30
|
+
});
|
|
31
|
+
const liquidTagClasses = createClass({
|
|
32
|
+
...getLiquidTagClasses(advanced)
|
|
33
|
+
});
|
|
34
|
+
const liquidTagStyles = createStyle({
|
|
35
|
+
...style,
|
|
36
|
+
...getWrapperStyles(styles)
|
|
37
|
+
});
|
|
38
|
+
const liquidInitData = getLiquidInitData(setting, styles);
|
|
39
|
+
const liquidTextContent = getLiquidTextContent(setting, styles);
|
|
40
|
+
const wrapperIconClasses = createClass({
|
|
41
|
+
...getWrapperIconClasses(setting)
|
|
42
|
+
});
|
|
43
|
+
const iconClasses = createClass({
|
|
44
|
+
...composeClasses('gp-stock-counter-icon'),
|
|
45
|
+
...getIconClasses()
|
|
46
|
+
});
|
|
47
|
+
const iconStyles = (isOutOfStock)=>{
|
|
48
|
+
return createStyle({
|
|
49
|
+
...getIconStyles(styles, setting, isOutOfStock)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const progressBarAttrs = createAttr({
|
|
53
|
+
...getLiquidProgressBarAttrs()
|
|
54
|
+
});
|
|
55
|
+
const textClasses = (isOutOfStock)=>{
|
|
56
|
+
return createClass({
|
|
57
|
+
...getTextClasses(styles, isOutOfStock),
|
|
58
|
+
...composeClasses('gp-stock-counter-mark')
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const textStyles = (isOutOfStock)=>{
|
|
62
|
+
return createStyle({
|
|
63
|
+
...getTextStyles(styles, isOutOfStock)
|
|
64
|
+
});
|
|
13
65
|
};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return typo && typo.custom ? convertSizeToWidth(composeTypographyV2(typo.custom)) : {};
|
|
18
|
-
}
|
|
19
|
-
return typography && typography.custom ? convertSizeToWidth(composeTypography(typography.custom)) : {};
|
|
20
|
-
}, [
|
|
21
|
-
typo,
|
|
22
|
-
typography
|
|
23
|
-
]);
|
|
24
|
-
const typoWidth = composeMemo(()=>{
|
|
25
|
-
if (typo) {
|
|
26
|
-
return typo && !typo.custom ? genVariable(getShortName(`typography-${typo.type}-fontSize`)) : undefined;
|
|
27
|
-
}
|
|
28
|
-
return typography && !typography.custom ? genVariable(getShortName(`typography-${typography.type}-fontSize`)) : undefined;
|
|
29
|
-
}, [
|
|
30
|
-
typo,
|
|
31
|
-
typography
|
|
32
|
-
]);
|
|
33
|
-
const appendTypoClass = composeTypographyClassName(styles?.typo, styles?.typography);
|
|
34
|
-
const appendTypoStyle = composeTypographyStyle(styles?.typo, styles?.typography);
|
|
66
|
+
const textAttrs = createAttr({
|
|
67
|
+
...getLiquidTextAttrs()
|
|
68
|
+
});
|
|
35
69
|
return template /* liquid */ `
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
assign scarcityThreshold = ${isScarcityThreshold}
|
|
43
|
-
assign check_display = ${checkDisplay()}
|
|
44
|
-
|
|
45
|
-
if check_display == true
|
|
46
|
-
assign should_display = true
|
|
47
|
-
elsif ${isScarcityThreshold} and inventory_quantity >= 0 and inventory_quantity < ${scarcityThreshold}
|
|
48
|
-
assign should_display = true
|
|
49
|
-
else
|
|
50
|
-
assign should_display = false
|
|
51
|
-
endif
|
|
52
|
-
|
|
53
|
-
if ${hiddenCounterWhenOutOfStock === true} and available == false
|
|
54
|
-
assign should_display = false
|
|
55
|
-
endif
|
|
56
|
-
|
|
57
|
-
if ${displayProgressBar === true} and available
|
|
58
|
-
assign show_progress_bar = true
|
|
59
|
-
else
|
|
60
|
-
assign show_progress_bar = false
|
|
61
|
-
endif
|
|
62
|
-
-%}
|
|
63
|
-
{% capture variant_policy_list %}
|
|
64
|
-
{
|
|
65
|
-
{% for variant in product.variants %}
|
|
66
|
-
"{{ variant.id }}":"{{ variant.inventory_policy }}",
|
|
67
|
-
"{{ variant.id }}_management":"{{ variant.inventory_management }}"{% if forloop.last == false %},{% endif %}
|
|
68
|
-
{% endfor %}
|
|
69
|
-
}
|
|
70
|
-
{% endcapture %}
|
|
71
|
-
<gp-product-stock-counter
|
|
72
|
-
data-id="${builderProps?.uid}"
|
|
73
|
-
data-visible="{{ should_display }}"
|
|
74
|
-
data-policy='{{ variant_policy_list }}'
|
|
75
|
-
gp-setting='${JSON.stringify({
|
|
76
|
-
displayByDefault,
|
|
77
|
-
displayProgressBar,
|
|
78
|
-
scarcityThreshold,
|
|
79
|
-
template: templateString,
|
|
80
|
-
outOfStockMessage,
|
|
81
|
-
continueSelling,
|
|
82
|
-
unlimitedQuantityMessage,
|
|
83
|
-
color: mainColor,
|
|
84
|
-
hiddenCounterWhenOutOfStock
|
|
85
|
-
}).replaceAll("'", ''')}'
|
|
86
|
-
class="gp-product-stock-counter data-[visible=true]:gp-block data-[visible=false]:gp-hidden ${advanced?.cssClass}"
|
|
87
|
-
style="${{
|
|
88
|
-
...style,
|
|
89
|
-
...makeStyleResponsive('ta', alignment)
|
|
90
|
-
}}">
|
|
70
|
+
${liquidInitData}
|
|
71
|
+
<gp-product-stock-counter ${{
|
|
72
|
+
...liquidTagAttrs
|
|
73
|
+
}} class="${liquidTagClasses}"
|
|
74
|
+
style="${liquidTagStyles}">
|
|
75
|
+
<style>${inlineCss}</style>
|
|
91
76
|
<div
|
|
92
|
-
class="
|
|
93
|
-
style="${
|
|
94
|
-
...makeStyleResponsive('w', makeWidth(width)),
|
|
95
|
-
...makeStyle({
|
|
96
|
-
c: getSingleColorVariable(textColor)
|
|
97
|
-
})
|
|
98
|
-
}}"
|
|
77
|
+
class="${containerClasses}"
|
|
78
|
+
style="${containerStyles}"
|
|
99
79
|
>
|
|
100
|
-
<div class="
|
|
80
|
+
<div class="${wrapperIconClasses}">
|
|
101
81
|
${RenderIf(showIcon, template /* liquid */ `
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
82
|
+
{% if is_out_of_stock %}
|
|
83
|
+
<div
|
|
84
|
+
class="${iconClasses}"
|
|
85
|
+
style="${iconStyles(true)}"
|
|
86
|
+
>
|
|
87
|
+
${oosIcon}
|
|
88
|
+
</div>
|
|
89
|
+
{% else %}
|
|
90
|
+
<div
|
|
91
|
+
class="${iconClasses}"
|
|
92
|
+
style="${iconStyles(false)}"
|
|
93
|
+
>
|
|
94
|
+
${icon}
|
|
95
|
+
</div>
|
|
96
|
+
{% endif %}
|
|
113
97
|
`)}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
...
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
>
|
|
126
|
-
{% if inventory_management == null or inventory_management != "shopify" and inventory_quantity <= 0 %}
|
|
127
|
-
${transformHighlighTag(unlimitedQuantityMessage ?? getStaticLocale('StockCounter', 'let_buy_now'), mainColor)}
|
|
128
|
-
{% elsif available == false %}
|
|
129
|
-
${transformHighlighTag(outOfStockMessage ?? '', mainColor)}
|
|
130
|
-
{% elsif available and inventory_policy == '${CONTINUE_SELLING_WHEN_OUT_OF_STOCK.toLowerCase()}' and inventory_quantity <= 0 %}
|
|
131
|
-
${transformHighlighTag(continueSelling ?? '', mainColor)}
|
|
98
|
+
${RenderIf(showText, template`
|
|
99
|
+
{% if is_out_of_stock %}
|
|
100
|
+
<p
|
|
101
|
+
${{
|
|
102
|
+
...textAttrs
|
|
103
|
+
}}
|
|
104
|
+
class="${textClasses(true)}"
|
|
105
|
+
style="${textStyles(true)}"
|
|
106
|
+
>
|
|
107
|
+
${liquidTextContent}
|
|
108
|
+
</p>
|
|
132
109
|
{% else %}
|
|
133
|
-
|
|
110
|
+
<p
|
|
111
|
+
${{
|
|
112
|
+
...textAttrs
|
|
113
|
+
}}
|
|
114
|
+
class="${textClasses(false)}"
|
|
115
|
+
style="${textStyles(false)}"
|
|
116
|
+
>
|
|
117
|
+
${liquidTextContent}
|
|
118
|
+
</p>
|
|
134
119
|
{% endif %}
|
|
135
|
-
|
|
120
|
+
`)}
|
|
121
|
+
|
|
136
122
|
</div>
|
|
137
123
|
|
|
138
124
|
<div
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
bg: 'linear-gradient(90deg, #eee 50%, transparent 50%)',
|
|
145
|
-
bgc: getSingleColorVariable(color),
|
|
146
|
-
bgp: `${remainingPercentage}% center`
|
|
147
|
-
})
|
|
148
|
-
}}"
|
|
149
|
-
class="${cls('gp-stock-counter-progress gp-relative gp-mt-2 gp-w-full -gp-scale-100 data-[visible=true]:gp-block data-[visible=false]:gp-hidden !gp-bg-[length:200%]', {
|
|
150
|
-
'gp-rounded-md ': roundedBorder,
|
|
151
|
-
"before:gp-absolute before:gp-left-0 before:gp-h-full before:gp-w-full before:gp-animate-shift before:gp-content-['']": effect,
|
|
152
|
-
'before:gp-bg-stock-counter-animate before:gp-bg-[length:60px_100%] before:gp-shadow-stock-counter': effect,
|
|
153
|
-
'before:gp-rounded-md': effect && roundedBorder
|
|
154
|
-
})}"
|
|
125
|
+
${{
|
|
126
|
+
...progressBarAttrs
|
|
127
|
+
}}
|
|
128
|
+
style="${progressBarStyles}"
|
|
129
|
+
class="${progressBarClasses}"
|
|
155
130
|
></div>
|
|
156
131
|
</div>
|
|
157
132
|
</gp-product-stock-counter>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const getLiquidTagAttrs = (builderProps, setting, styles)=>{
|
|
2
|
+
const { displayByDefault, scarcityThreshold = 0, template: templateString, outOfStockMessage, continueSelling, unlimitedQuantityMessage, hiddenCounterWhenOutOfStock } = setting ?? {};
|
|
3
|
+
const { displayProgressBar, textColor } = styles ?? {};
|
|
4
|
+
const mainColor = textColor || 'brand';
|
|
5
|
+
return {
|
|
6
|
+
'data-id': builderProps?.uid ?? '',
|
|
7
|
+
'data-visible': '{{ should_display }}',
|
|
8
|
+
'data-policy': '{{ variant_policy_list | escape }}',
|
|
9
|
+
'gp-setting': JSON.stringify({
|
|
10
|
+
displayByDefault,
|
|
11
|
+
displayProgressBar,
|
|
12
|
+
scarcityThreshold,
|
|
13
|
+
template: templateString,
|
|
14
|
+
outOfStockMessage,
|
|
15
|
+
continueSelling,
|
|
16
|
+
unlimitedQuantityMessage,
|
|
17
|
+
color: mainColor,
|
|
18
|
+
hiddenCounterWhenOutOfStock
|
|
19
|
+
}).replaceAll(`"`, '"')
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const getLiquidProgressBarAttrs = ()=>{
|
|
23
|
+
return {
|
|
24
|
+
'data-slot-type': 'progress-bar',
|
|
25
|
+
'data-visible': '{{ show_progress_bar }}'
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const getLiquidTextAttrs = ()=>{
|
|
29
|
+
return {
|
|
30
|
+
'data-slot-type': 'message'
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getWrapperAttrs = (builderProps)=>{
|
|
34
|
+
return {
|
|
35
|
+
'data-id': builderProps?.uid ?? ''
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { getLiquidProgressBarAttrs, getLiquidTagAttrs, getLiquidTextAttrs, getWrapperAttrs };
|