@gem-sdk/components 2.0.0-dev.559 → 2.0.0-dev.560
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 +3 -3
- package/dist/cjs/stock-counter/components/common/getClasses.js +2 -1
- package/dist/cjs/stock-counter/components/common/getStyles.js +1 -1
- package/dist/cjs/stock-counter/components/hook/useStockCounter.js +6 -1
- package/dist/esm/stock-counter/components/StockCounter.js +3 -3
- package/dist/esm/stock-counter/components/common/getClasses.js +2 -1
- package/dist/esm/stock-counter/components/common/getStyles.js +1 -1
- package/dist/esm/stock-counter/components/hook/useStockCounter.js +6 -1
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ var useStockCounter = require('./hook/useStockCounter.js');
|
|
|
18
18
|
const StockCounter = ({ setting, styles, builderProps })=>{
|
|
19
19
|
const { displayProgressBar, borderRadius } = styles ?? {};
|
|
20
20
|
const { showIcon, icon, layout = 'full', oosIcon } = setting ?? {};
|
|
21
|
-
const {
|
|
21
|
+
const { outputMessage, isOutOfStock, inventoryQuantity } = useStockCounter.useStockCounter(setting, styles);
|
|
22
22
|
const elementRef = React.useRef(null);
|
|
23
23
|
const { dispatchStockCounterInteraction } = useStockCounterInteraction.useStockCounterInteraction({
|
|
24
24
|
element: elementRef,
|
|
@@ -117,13 +117,13 @@ const StockCounter = ({ setting, styles, builderProps })=>{
|
|
|
117
117
|
})),
|
|
118
118
|
showText && (isOutOfStock ? /*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
119
119
|
dangerouslySetInnerHTML: {
|
|
120
|
-
__html:
|
|
120
|
+
__html: outputMessage()
|
|
121
121
|
},
|
|
122
122
|
className: textClasses,
|
|
123
123
|
style: textStyles(true)
|
|
124
124
|
}) : /*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
125
125
|
dangerouslySetInnerHTML: {
|
|
126
|
-
__html:
|
|
126
|
+
__html: outputMessage()
|
|
127
127
|
},
|
|
128
128
|
className: textClasses,
|
|
129
129
|
style: textStyles(false)
|
|
@@ -14,7 +14,7 @@ const getContainerClasses = (setting)=>{
|
|
|
14
14
|
const { progressBarPosition = 'bottom' } = setting ?? {};
|
|
15
15
|
const isProgressBarBottom = progressBarPosition === 'bottom';
|
|
16
16
|
return {
|
|
17
|
-
...core.composeClasses('gp-inline-block gp-flex gp-
|
|
17
|
+
...core.composeClasses('gp-inline-block gp-flex gp-gap-y-1.5'),
|
|
18
18
|
'gp-flex-col': isProgressBarBottom,
|
|
19
19
|
'gp-flex-col-reverse': !isProgressBarBottom
|
|
20
20
|
};
|
|
@@ -48,6 +48,7 @@ const getTextClasses = (styles)=>{
|
|
|
48
48
|
const getWrapperClasses = (setting, isOutOfStock)=>{
|
|
49
49
|
const { hiddenCounterWhenOutOfStock } = setting ?? {};
|
|
50
50
|
return {
|
|
51
|
+
...core.composeClasses('gp-flex'),
|
|
51
52
|
'gp-opacity-50': isOutOfStock && hiddenCounterWhenOutOfStock
|
|
52
53
|
};
|
|
53
54
|
};
|
|
@@ -33,7 +33,7 @@ const getContainerStyles = (styles)=>{
|
|
|
33
33
|
const getWrapperStyles = (styles)=>{
|
|
34
34
|
const { alignment } = styles ?? {};
|
|
35
35
|
return {
|
|
36
|
-
...core.makeStyleResponsive('
|
|
36
|
+
...core.makeStyleResponsive('jc', alignment)
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
const getIconStyles = (styles, setting, isOutOfStock)=>{
|
|
@@ -26,8 +26,13 @@ const useStockCounter = (setting, styles)=>{
|
|
|
26
26
|
if (isContinueShopping) return helpers.transformHighlighTag(continueSelling || '', mainColor);
|
|
27
27
|
return helpers.transformHighlighTag(helpers.transformNumberTag(template || '', mainColor, inventoryQuantity), mainColor);
|
|
28
28
|
}
|
|
29
|
+
const outputMessage = ()=>{
|
|
30
|
+
const isCapitalize = styles?.typo?.attrs?.transform === 'capitalize';
|
|
31
|
+
if (isCapitalize) return getMessage()?.toLocaleLowerCase();
|
|
32
|
+
return getMessage();
|
|
33
|
+
};
|
|
29
34
|
return {
|
|
30
|
-
|
|
35
|
+
outputMessage,
|
|
31
36
|
isOutOfStock,
|
|
32
37
|
inventoryQuantity
|
|
33
38
|
};
|
|
@@ -14,7 +14,7 @@ import { useStockCounter } from './hook/useStockCounter.js';
|
|
|
14
14
|
const StockCounter = ({ setting, styles, builderProps })=>{
|
|
15
15
|
const { displayProgressBar, borderRadius } = styles ?? {};
|
|
16
16
|
const { showIcon, icon, layout = 'full', oosIcon } = setting ?? {};
|
|
17
|
-
const {
|
|
17
|
+
const { outputMessage, isOutOfStock, inventoryQuantity } = useStockCounter(setting, styles);
|
|
18
18
|
const elementRef = useRef(null);
|
|
19
19
|
const { dispatchStockCounterInteraction } = useStockCounterInteraction({
|
|
20
20
|
element: elementRef,
|
|
@@ -113,13 +113,13 @@ const StockCounter = ({ setting, styles, builderProps })=>{
|
|
|
113
113
|
})),
|
|
114
114
|
showText && (isOutOfStock ? /*#__PURE__*/ jsx("p", {
|
|
115
115
|
dangerouslySetInnerHTML: {
|
|
116
|
-
__html:
|
|
116
|
+
__html: outputMessage()
|
|
117
117
|
},
|
|
118
118
|
className: textClasses,
|
|
119
119
|
style: textStyles(true)
|
|
120
120
|
}) : /*#__PURE__*/ jsx("p", {
|
|
121
121
|
dangerouslySetInnerHTML: {
|
|
122
|
-
__html:
|
|
122
|
+
__html: outputMessage()
|
|
123
123
|
},
|
|
124
124
|
className: textClasses,
|
|
125
125
|
style: textStyles(false)
|
|
@@ -12,7 +12,7 @@ const getContainerClasses = (setting)=>{
|
|
|
12
12
|
const { progressBarPosition = 'bottom' } = setting ?? {};
|
|
13
13
|
const isProgressBarBottom = progressBarPosition === 'bottom';
|
|
14
14
|
return {
|
|
15
|
-
...composeClasses('gp-inline-block gp-flex gp-
|
|
15
|
+
...composeClasses('gp-inline-block gp-flex gp-gap-y-1.5'),
|
|
16
16
|
'gp-flex-col': isProgressBarBottom,
|
|
17
17
|
'gp-flex-col-reverse': !isProgressBarBottom
|
|
18
18
|
};
|
|
@@ -46,6 +46,7 @@ const getTextClasses = (styles)=>{
|
|
|
46
46
|
const getWrapperClasses = (setting, isOutOfStock)=>{
|
|
47
47
|
const { hiddenCounterWhenOutOfStock } = setting ?? {};
|
|
48
48
|
return {
|
|
49
|
+
...composeClasses('gp-flex'),
|
|
49
50
|
'gp-opacity-50': isOutOfStock && hiddenCounterWhenOutOfStock
|
|
50
51
|
};
|
|
51
52
|
};
|
|
@@ -31,7 +31,7 @@ const getContainerStyles = (styles)=>{
|
|
|
31
31
|
const getWrapperStyles = (styles)=>{
|
|
32
32
|
const { alignment } = styles ?? {};
|
|
33
33
|
return {
|
|
34
|
-
...makeStyleResponsive('
|
|
34
|
+
...makeStyleResponsive('jc', alignment)
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
const getIconStyles = (styles, setting, isOutOfStock)=>{
|
|
@@ -24,8 +24,13 @@ const useStockCounter = (setting, styles)=>{
|
|
|
24
24
|
if (isContinueShopping) return transformHighlighTag(continueSelling || '', mainColor);
|
|
25
25
|
return transformHighlighTag(transformNumberTag(template || '', mainColor, inventoryQuantity), mainColor);
|
|
26
26
|
}
|
|
27
|
+
const outputMessage = ()=>{
|
|
28
|
+
const isCapitalize = styles?.typo?.attrs?.transform === 'capitalize';
|
|
29
|
+
if (isCapitalize) return getMessage()?.toLocaleLowerCase();
|
|
30
|
+
return getMessage();
|
|
31
|
+
};
|
|
27
32
|
return {
|
|
28
|
-
|
|
33
|
+
outputMessage,
|
|
29
34
|
isOutOfStock,
|
|
30
35
|
inventoryQuantity
|
|
31
36
|
};
|