@gem-sdk/components 2.0.0-dev.486 → 2.0.0-dev.487
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/stock-counter/components/StockCounter.js +13 -0
- package/dist/cjs/stock-counter/components/StockCounter.liquid.js +43 -5
- package/dist/cjs/stock-counter/components/common/getAttrs.js +7 -0
- package/dist/cjs/stock-counter/components/common/getContent.js +2 -0
- package/dist/esm/stock-counter/components/StockCounter.js +14 -1
- package/dist/esm/stock-counter/components/StockCounter.liquid.js +45 -7
- package/dist/esm/stock-counter/components/common/getAttrs.js +7 -1
- package/dist/esm/stock-counter/components/common/getContent.js +2 -0
- package/package.json +1 -1
|
@@ -53,6 +53,11 @@ const StockCounter = ({ setting, styles, builderProps })=>{
|
|
|
53
53
|
...getStyles.getIconStyles(styles, setting, isOutOfStock)
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
+
const iconAttrs = ({ isOutOfStockIcon, isVisible })=>{
|
|
57
|
+
return system.createStyle({
|
|
58
|
+
...getAttrs.getIconAttrs(isOutOfStockIcon, isVisible)
|
|
59
|
+
});
|
|
60
|
+
};
|
|
56
61
|
const textClasses = (isOutOfStock)=>{
|
|
57
62
|
return system.createClass({
|
|
58
63
|
...getClasses.getTextClasses(styles, isOutOfStock)
|
|
@@ -92,12 +97,20 @@ const StockCounter = ({ setting, styles, builderProps })=>{
|
|
|
92
97
|
className: wrapperIconClasses,
|
|
93
98
|
children: [
|
|
94
99
|
showIcon && (isOutOfStock ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
100
|
+
...iconAttrs({
|
|
101
|
+
isOutOfStockIcon: isOutOfStock,
|
|
102
|
+
isVisible: isOutOfStock
|
|
103
|
+
}),
|
|
95
104
|
dangerouslySetInnerHTML: {
|
|
96
105
|
__html: oosIcon || ''
|
|
97
106
|
},
|
|
98
107
|
className: iconClasses,
|
|
99
108
|
style: iconStyles(true)
|
|
100
109
|
}) : /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
110
|
+
...iconAttrs({
|
|
111
|
+
isOutOfStockIcon: !isOutOfStock,
|
|
112
|
+
isVisible: !isOutOfStock
|
|
113
|
+
}),
|
|
101
114
|
dangerouslySetInnerHTML: {
|
|
102
115
|
__html: icon || ''
|
|
103
116
|
},
|
|
@@ -45,7 +45,7 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
|
45
45
|
...getClasses.getWrapperIconClasses(setting)
|
|
46
46
|
});
|
|
47
47
|
const iconClasses = system.createClass({
|
|
48
|
-
...core.composeClasses('gp-stock-counter-icon'),
|
|
48
|
+
...core.composeClasses('gp-stock-counter-icon data-[visible=true]:gp-block data-[visible=false]:gp-hidden'),
|
|
49
49
|
...getClasses.getIconClasses()
|
|
50
50
|
});
|
|
51
51
|
const iconStyles = (isOutOfStock)=>{
|
|
@@ -53,6 +53,11 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
|
53
53
|
...getStyles.getIconStyles(styles, setting, isOutOfStock)
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
+
const iconAttrs = ({ isOutOfStockIcon, isVisible })=>{
|
|
57
|
+
return system.createStyle({
|
|
58
|
+
...getAttrs.getIconAttrs(isOutOfStockIcon, isVisible)
|
|
59
|
+
});
|
|
60
|
+
};
|
|
56
61
|
const progressBarAttrs = system.createAttr({
|
|
57
62
|
...getAttrs.getLiquidProgressBarAttrs()
|
|
58
63
|
});
|
|
@@ -83,21 +88,54 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
|
83
88
|
>
|
|
84
89
|
<div class="${wrapperIconClasses}">
|
|
85
90
|
${core.RenderIf(showIcon, core.template /* liquid */ `
|
|
86
|
-
{
|
|
91
|
+
${(system.LiquidIf('is_out_of_stock', core.template`<div
|
|
92
|
+
${{
|
|
93
|
+
...iconAttrs({
|
|
94
|
+
isOutOfStockIcon: true,
|
|
95
|
+
isVisible: true
|
|
96
|
+
})
|
|
97
|
+
}}
|
|
98
|
+
class="${iconClasses}"
|
|
99
|
+
style="${iconStyles(true)}"
|
|
100
|
+
>
|
|
101
|
+
${oosIcon}
|
|
102
|
+
</div>
|
|
87
103
|
<div
|
|
104
|
+
${{
|
|
105
|
+
...iconAttrs({
|
|
106
|
+
isOutOfStockIcon: false,
|
|
107
|
+
isVisible: false
|
|
108
|
+
})
|
|
109
|
+
}}
|
|
110
|
+
data-slot-type="false"
|
|
111
|
+
class="${iconClasses}"
|
|
112
|
+
style="${iconStyles(false)}"
|
|
113
|
+
>
|
|
114
|
+
${icon}
|
|
115
|
+
</div>`), core.template` <div
|
|
116
|
+
${{
|
|
117
|
+
...iconAttrs({
|
|
118
|
+
isOutOfStockIcon: true,
|
|
119
|
+
isVisible: false
|
|
120
|
+
})
|
|
121
|
+
}}
|
|
88
122
|
class="${iconClasses}"
|
|
89
123
|
style="${iconStyles(true)}"
|
|
90
124
|
>
|
|
91
125
|
${oosIcon}
|
|
92
126
|
</div>
|
|
93
|
-
{% else %}
|
|
94
127
|
<div
|
|
128
|
+
${{
|
|
129
|
+
...iconAttrs({
|
|
130
|
+
isOutOfStockIcon: false,
|
|
131
|
+
isVisible: true
|
|
132
|
+
})
|
|
133
|
+
}}
|
|
95
134
|
class="${iconClasses}"
|
|
96
135
|
style="${iconStyles(false)}"
|
|
97
136
|
>
|
|
98
137
|
${icon}
|
|
99
|
-
</div
|
|
100
|
-
{% endif %}
|
|
138
|
+
</div>`)}
|
|
101
139
|
`)}
|
|
102
140
|
${core.RenderIf(showText, core.template`
|
|
103
141
|
{% if is_out_of_stock %}
|
|
@@ -37,7 +37,14 @@ const getWrapperAttrs = (builderProps)=>{
|
|
|
37
37
|
'data-id': builderProps?.uid ?? ''
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
const getIconAttrs = (isOutOfStockIcon, isVisible)=>{
|
|
41
|
+
return {
|
|
42
|
+
'data-slot-type': isOutOfStockIcon ? 'oos-icon' : 'has-stock-icon',
|
|
43
|
+
'data-visible': isVisible ? 'true' : 'false'
|
|
44
|
+
};
|
|
45
|
+
};
|
|
40
46
|
|
|
47
|
+
exports.getIconAttrs = getIconAttrs;
|
|
41
48
|
exports.getLiquidProgressBarAttrs = getLiquidProgressBarAttrs;
|
|
42
49
|
exports.getLiquidTagAttrs = getLiquidTagAttrs;
|
|
43
50
|
exports.getLiquidTextAttrs = getLiquidTextAttrs;
|
|
@@ -37,6 +37,8 @@ const getLiquidInitData = (setting, styles)=>{
|
|
|
37
37
|
|
|
38
38
|
if inventory_management != null and available == false and inventory_quantity <= 0 and inventory_policy != '${_const.CONTINUE_SELLING_WHEN_OUT_OF_STOCK.toLowerCase()}'
|
|
39
39
|
assign is_out_of_stock = true
|
|
40
|
+
else
|
|
41
|
+
assign is_out_of_stock = false
|
|
40
42
|
endif
|
|
41
43
|
|
|
42
44
|
if check_display == true
|
|
@@ -7,7 +7,7 @@ import { getProgressBarClasses, getContainerClasses, getWrapperIconClasses, getI
|
|
|
7
7
|
import { getProgressBarStyles, getContainerStyles, getWrapperStyles, getIconStyles, getTextStyles } from './common/getStyles.js';
|
|
8
8
|
import 'next/link';
|
|
9
9
|
import '@gem-sdk/core';
|
|
10
|
-
import { getWrapperAttrs } from './common/getAttrs.js';
|
|
10
|
+
import { getWrapperAttrs, getIconAttrs } from './common/getAttrs.js';
|
|
11
11
|
import { createClass, createStyle, createAttr } from '@gem-sdk/system';
|
|
12
12
|
import { useStockCounter } from './hook/useStockCounter.js';
|
|
13
13
|
|
|
@@ -49,6 +49,11 @@ const StockCounter = ({ setting, styles, builderProps })=>{
|
|
|
49
49
|
...getIconStyles(styles, setting, isOutOfStock)
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
+
const iconAttrs = ({ isOutOfStockIcon, isVisible })=>{
|
|
53
|
+
return createStyle({
|
|
54
|
+
...getIconAttrs(isOutOfStockIcon, isVisible)
|
|
55
|
+
});
|
|
56
|
+
};
|
|
52
57
|
const textClasses = (isOutOfStock)=>{
|
|
53
58
|
return createClass({
|
|
54
59
|
...getTextClasses(styles, isOutOfStock)
|
|
@@ -88,12 +93,20 @@ const StockCounter = ({ setting, styles, builderProps })=>{
|
|
|
88
93
|
className: wrapperIconClasses,
|
|
89
94
|
children: [
|
|
90
95
|
showIcon && (isOutOfStock ? /*#__PURE__*/ jsx("div", {
|
|
96
|
+
...iconAttrs({
|
|
97
|
+
isOutOfStockIcon: isOutOfStock,
|
|
98
|
+
isVisible: isOutOfStock
|
|
99
|
+
}),
|
|
91
100
|
dangerouslySetInnerHTML: {
|
|
92
101
|
__html: oosIcon || ''
|
|
93
102
|
},
|
|
94
103
|
className: iconClasses,
|
|
95
104
|
style: iconStyles(true)
|
|
96
105
|
}) : /*#__PURE__*/ jsx("div", {
|
|
106
|
+
...iconAttrs({
|
|
107
|
+
isOutOfStockIcon: !isOutOfStock,
|
|
108
|
+
isVisible: !isOutOfStock
|
|
109
|
+
}),
|
|
97
110
|
dangerouslySetInnerHTML: {
|
|
98
111
|
__html: icon || ''
|
|
99
112
|
},
|
|
@@ -4,8 +4,8 @@ import { getInlineCss } from './common/getInlineCss.js';
|
|
|
4
4
|
import { getProgressBarClasses, getContainerClasses, getLiquidTagClasses, getWrapperIconClasses, getIconClasses, getTextClasses } from './common/getClasses.js';
|
|
5
5
|
import { getProgressBarStyles, getContainerStyles, getWrapperStyles, getIconStyles, getTextStyles } from './common/getStyles.js';
|
|
6
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';
|
|
7
|
+
import { getLiquidTagAttrs, getLiquidProgressBarAttrs, getLiquidTextAttrs, getIconAttrs } from './common/getAttrs.js';
|
|
8
|
+
import { createAttr, createClass, createStyle, LiquidIf } from '@gem-sdk/system';
|
|
9
9
|
|
|
10
10
|
const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
11
11
|
const { borderRadius } = styles ?? {};
|
|
@@ -41,7 +41,7 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
|
41
41
|
...getWrapperIconClasses(setting)
|
|
42
42
|
});
|
|
43
43
|
const iconClasses = createClass({
|
|
44
|
-
...composeClasses('gp-stock-counter-icon'),
|
|
44
|
+
...composeClasses('gp-stock-counter-icon data-[visible=true]:gp-block data-[visible=false]:gp-hidden'),
|
|
45
45
|
...getIconClasses()
|
|
46
46
|
});
|
|
47
47
|
const iconStyles = (isOutOfStock)=>{
|
|
@@ -49,6 +49,11 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
|
49
49
|
...getIconStyles(styles, setting, isOutOfStock)
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
+
const iconAttrs = ({ isOutOfStockIcon, isVisible })=>{
|
|
53
|
+
return createStyle({
|
|
54
|
+
...getIconAttrs(isOutOfStockIcon, isVisible)
|
|
55
|
+
});
|
|
56
|
+
};
|
|
52
57
|
const progressBarAttrs = createAttr({
|
|
53
58
|
...getLiquidProgressBarAttrs()
|
|
54
59
|
});
|
|
@@ -79,21 +84,54 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps })=>{
|
|
|
79
84
|
>
|
|
80
85
|
<div class="${wrapperIconClasses}">
|
|
81
86
|
${RenderIf(showIcon, template /* liquid */ `
|
|
82
|
-
{
|
|
87
|
+
${(LiquidIf('is_out_of_stock', template`<div
|
|
88
|
+
${{
|
|
89
|
+
...iconAttrs({
|
|
90
|
+
isOutOfStockIcon: true,
|
|
91
|
+
isVisible: true
|
|
92
|
+
})
|
|
93
|
+
}}
|
|
94
|
+
class="${iconClasses}"
|
|
95
|
+
style="${iconStyles(true)}"
|
|
96
|
+
>
|
|
97
|
+
${oosIcon}
|
|
98
|
+
</div>
|
|
83
99
|
<div
|
|
100
|
+
${{
|
|
101
|
+
...iconAttrs({
|
|
102
|
+
isOutOfStockIcon: false,
|
|
103
|
+
isVisible: false
|
|
104
|
+
})
|
|
105
|
+
}}
|
|
106
|
+
data-slot-type="false"
|
|
107
|
+
class="${iconClasses}"
|
|
108
|
+
style="${iconStyles(false)}"
|
|
109
|
+
>
|
|
110
|
+
${icon}
|
|
111
|
+
</div>`), template` <div
|
|
112
|
+
${{
|
|
113
|
+
...iconAttrs({
|
|
114
|
+
isOutOfStockIcon: true,
|
|
115
|
+
isVisible: false
|
|
116
|
+
})
|
|
117
|
+
}}
|
|
84
118
|
class="${iconClasses}"
|
|
85
119
|
style="${iconStyles(true)}"
|
|
86
120
|
>
|
|
87
121
|
${oosIcon}
|
|
88
122
|
</div>
|
|
89
|
-
{% else %}
|
|
90
123
|
<div
|
|
124
|
+
${{
|
|
125
|
+
...iconAttrs({
|
|
126
|
+
isOutOfStockIcon: false,
|
|
127
|
+
isVisible: true
|
|
128
|
+
})
|
|
129
|
+
}}
|
|
91
130
|
class="${iconClasses}"
|
|
92
131
|
style="${iconStyles(false)}"
|
|
93
132
|
>
|
|
94
133
|
${icon}
|
|
95
|
-
</div
|
|
96
|
-
{% endif %}
|
|
134
|
+
</div>`)}
|
|
97
135
|
`)}
|
|
98
136
|
${RenderIf(showText, template`
|
|
99
137
|
{% if is_out_of_stock %}
|
|
@@ -35,5 +35,11 @@ const getWrapperAttrs = (builderProps)=>{
|
|
|
35
35
|
'data-id': builderProps?.uid ?? ''
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
+
const getIconAttrs = (isOutOfStockIcon, isVisible)=>{
|
|
39
|
+
return {
|
|
40
|
+
'data-slot-type': isOutOfStockIcon ? 'oos-icon' : 'has-stock-icon',
|
|
41
|
+
'data-visible': isVisible ? 'true' : 'false'
|
|
42
|
+
};
|
|
43
|
+
};
|
|
38
44
|
|
|
39
|
-
export { getLiquidProgressBarAttrs, getLiquidTagAttrs, getLiquidTextAttrs, getWrapperAttrs };
|
|
45
|
+
export { getIconAttrs, getLiquidProgressBarAttrs, getLiquidTagAttrs, getLiquidTextAttrs, getWrapperAttrs };
|
|
@@ -35,6 +35,8 @@ const getLiquidInitData = (setting, styles)=>{
|
|
|
35
35
|
|
|
36
36
|
if inventory_management != null and available == false and inventory_quantity <= 0 and inventory_policy != '${CONTINUE_SELLING_WHEN_OUT_OF_STOCK.toLowerCase()}'
|
|
37
37
|
assign is_out_of_stock = true
|
|
38
|
+
else
|
|
39
|
+
assign is_out_of_stock = false
|
|
38
40
|
endif
|
|
39
41
|
|
|
40
42
|
if check_display == true
|