@gem-sdk/components 2.0.0-staging.150 → 2.0.0-staging.154
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/helpers.js +4 -1
- package/dist/cjs/product/components/FileUpload/components/common/index.js +2 -2
- package/dist/cjs/product/components/FileUpload.liquid.js +3 -3
- package/dist/cjs/product/components/ProductDescription/common.js +28 -0
- package/dist/cjs/product/components/ProductDescription/const.js +5 -0
- package/dist/cjs/product/components/ProductDescription.js +37 -10
- package/dist/cjs/product/components/ProductDescription.liquid.js +3 -1
- package/dist/cjs/product/setting/FileUpload.js +1 -1
- package/dist/esm/helpers.js +4 -1
- package/dist/esm/product/components/FileUpload/components/common/index.js +2 -2
- package/dist/esm/product/components/FileUpload.liquid.js +3 -3
- package/dist/esm/product/components/ProductDescription/common.js +26 -0
- package/dist/esm/product/components/ProductDescription/const.js +3 -0
- package/dist/esm/product/components/ProductDescription.js +37 -10
- package/dist/esm/product/components/ProductDescription.liquid.js +3 -1
- package/dist/esm/product/setting/FileUpload.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +3 -3
package/dist/cjs/helpers.js
CHANGED
|
@@ -34,7 +34,7 @@ const isHexTransparent = (hex)=>{
|
|
|
34
34
|
return Boolean(a);
|
|
35
35
|
};
|
|
36
36
|
const youtubeShortsRegex = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^"&?/\s]{11})$/i;
|
|
37
|
-
const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin })=>{
|
|
37
|
+
const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin, isReplaceMaxSize })=>{
|
|
38
38
|
const hasLiquidInValue = new RegExp(/\{\{.*?\}\}|\{%.*?%\}/).test(val?.toString() ?? '');
|
|
39
39
|
const translateLimit = pageContext?.isTranslateWithLocale ? 1000 : 5000;
|
|
40
40
|
if (!translate || !val?.toString().trim() || val.toString().length > translateLimit || hasLiquidInValue || pageContext?.isPreviewing) return val ?? defaultVal;
|
|
@@ -46,6 +46,9 @@ const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, i
|
|
|
46
46
|
if (isReplaceLocationOrigin) {
|
|
47
47
|
locale += ` | replace: '$locationOrigin', locationOrigin`;
|
|
48
48
|
}
|
|
49
|
+
if (isReplaceMaxSize) {
|
|
50
|
+
locale += ` | replace: '$max_size', '10MB'`;
|
|
51
|
+
}
|
|
49
52
|
if (isCapitalize) {
|
|
50
53
|
locale = `${locale} | downcase`;
|
|
51
54
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const getTextDropContent = (textContent)=>{
|
|
4
|
-
if (textContent?.includes('
|
|
5
|
-
return textContent?.replace('
|
|
4
|
+
if (textContent?.includes('$max_size')) {
|
|
5
|
+
return textContent?.replace('$max_size', '10MB');
|
|
6
6
|
}
|
|
7
7
|
return textContent;
|
|
8
8
|
};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@gem-sdk/core');
|
|
6
6
|
var helpers = require('../../helpers.js');
|
|
7
|
-
var index = require('./FileUpload/components/common/index.js');
|
|
8
7
|
|
|
9
8
|
const FileUpload = ({ setting, styles, builderProps, pageContext })=>{
|
|
10
9
|
const appendTypoClass = core.composeTypographyClassName(styles?.typo);
|
|
@@ -12,12 +11,13 @@ const FileUpload = ({ setting, styles, builderProps, pageContext })=>{
|
|
|
12
11
|
const composeGlobalSize = core.makeGlobalSize(setting?.size);
|
|
13
12
|
const composePaddingSize = core.makeGlobalSize(setting?.paddingSize);
|
|
14
13
|
const displayText = helpers.getDynamicSourceLocales({
|
|
15
|
-
val:
|
|
14
|
+
val: setting?.textContent,
|
|
16
15
|
uid: builderProps?.uid,
|
|
17
16
|
settingId: 'textContent',
|
|
18
17
|
pageContext,
|
|
19
18
|
isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
|
|
20
|
-
translate: setting?.translate
|
|
19
|
+
translate: setting?.translate,
|
|
20
|
+
isReplaceMaxSize: true
|
|
21
21
|
});
|
|
22
22
|
const cssInLine = `
|
|
23
23
|
.${builderProps?.uid}:hover .gp-file-upload__icon {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var _const = require('./const.js');
|
|
5
|
+
|
|
6
|
+
const getMaxHeightStyleDefault = (setting)=>{
|
|
7
|
+
let result = {
|
|
8
|
+
desktop: 'none'
|
|
9
|
+
};
|
|
10
|
+
const devices = [
|
|
11
|
+
'desktop',
|
|
12
|
+
'mobile',
|
|
13
|
+
'tablet'
|
|
14
|
+
];
|
|
15
|
+
devices.forEach((device)=>{
|
|
16
|
+
const lineClamp = core.getResponsiveValueByScreen(setting?.lineClamp, device);
|
|
17
|
+
const hasLineClamp = core.getResponsiveValueByScreen(setting?.hasLineClamp, device);
|
|
18
|
+
const maxHeight = hasLineClamp && lineClamp ? `${lineClamp * _const.DESCRIPTION_LINE_HEIGHT_DEFAULT}px` : 'none';
|
|
19
|
+
result = {
|
|
20
|
+
...result,
|
|
21
|
+
[device]: maxHeight
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const style = core.makeStyleResponsive('maxh', result);
|
|
25
|
+
return style;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.getMaxHeightStyleDefault = getMaxHeightStyleDefault;
|
|
@@ -7,6 +7,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var core = require('@gem-sdk/core');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var NoDataState = require('../../common/components/NoDataState.js');
|
|
10
|
+
var common = require('./ProductDescription/common.js');
|
|
11
|
+
var _const = require('./ProductDescription/const.js');
|
|
10
12
|
|
|
11
13
|
const ProductDescription = ({ setting, builderProps })=>{
|
|
12
14
|
const [open, setOpen] = React.useState(false);
|
|
@@ -23,13 +25,17 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
23
25
|
React.useEffect(()=>{
|
|
24
26
|
const dom = ref.current;
|
|
25
27
|
setOpen(false);
|
|
26
|
-
if (dom
|
|
28
|
+
if (!dom) return;
|
|
29
|
+
const enableShowMore = hasLineClamp && product?.descriptionHtml;
|
|
30
|
+
if (!enableShowMore) dom.style.maxHeight = 'none';
|
|
31
|
+
else {
|
|
27
32
|
const value = lineClamp;
|
|
28
33
|
setTimeout(()=>{
|
|
29
34
|
const scrollHeight = dom?.scrollHeight ?? 0;
|
|
30
35
|
const clientHeight = dom?.clientHeight ?? 0;
|
|
31
|
-
const lineHeight =
|
|
32
|
-
const lineText = Math.round((scrollHeight ?? 0) /
|
|
36
|
+
const lineHeight = getLineHeightFromDom();
|
|
37
|
+
const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
|
|
38
|
+
dom.style.maxHeight = getMaxHeight(lineHeight);
|
|
33
39
|
const conditionCheckLine = isSafari ? value && value < lineText : clientHeight < scrollHeight;
|
|
34
40
|
if (value && conditionCheckLine) {
|
|
35
41
|
allowShowViewMore(()=>true);
|
|
@@ -44,6 +50,16 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
44
50
|
product?.description,
|
|
45
51
|
isSafari
|
|
46
52
|
]);
|
|
53
|
+
const getLineHeightFromDom = ()=>{
|
|
54
|
+
if (!ref.current) return _const.DESCRIPTION_LINE_HEIGHT_DEFAULT;
|
|
55
|
+
const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
|
|
56
|
+
return parseInt(lineHeight);
|
|
57
|
+
};
|
|
58
|
+
const getMaxHeight = (lineHeight)=>{
|
|
59
|
+
if (!hasLineClamp || !lineClamp) return 'auto';
|
|
60
|
+
if (lineHeight) return `${lineClamp * lineHeight}px`;
|
|
61
|
+
return 'auto';
|
|
62
|
+
};
|
|
47
63
|
const Tag = htmlTag === 'html' ? 'div' : 'p';
|
|
48
64
|
const appendTypoClass = core.composeTypographyClassName(setting?.typo, setting?.typography);
|
|
49
65
|
const appendTypoStyle = core.composeTypographyStyle(setting?.typo, setting?.typography);
|
|
@@ -59,8 +75,8 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
59
75
|
box-shadow: none;
|
|
60
76
|
}
|
|
61
77
|
`;
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
78
|
+
const noDescriptionHtml = !product?.descriptionHtml;
|
|
79
|
+
if (noDescriptionHtml && mode === 'edit') {
|
|
64
80
|
return /*#__PURE__*/ jsxRuntime.jsx(NoDataState.default, {
|
|
65
81
|
elementType: "secondary",
|
|
66
82
|
description: "Highlight key benefits with product description.",
|
|
@@ -76,8 +92,18 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
76
92
|
]
|
|
77
93
|
});
|
|
78
94
|
}
|
|
95
|
+
const handleToggleShowMore = ()=>{
|
|
96
|
+
if (!ref.current) return;
|
|
97
|
+
const lineHeight = getLineHeightFromDom();
|
|
98
|
+
if (open) {
|
|
99
|
+
ref.current.style.maxHeight = getMaxHeight(lineHeight);
|
|
100
|
+
} else {
|
|
101
|
+
ref.current.style.maxHeight = 'none';
|
|
102
|
+
}
|
|
103
|
+
setOpen((prev)=>!prev);
|
|
104
|
+
};
|
|
79
105
|
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
80
|
-
children:
|
|
106
|
+
children: noDescriptionHtml ? null : /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
81
107
|
"data-id": builderProps?.uid,
|
|
82
108
|
children: [
|
|
83
109
|
!isSafari && /*#__PURE__*/ jsxRuntime.jsx("style", {
|
|
@@ -89,7 +115,7 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
89
115
|
/*#__PURE__*/ jsxRuntime.jsx(Tag, {
|
|
90
116
|
ref: ref,
|
|
91
117
|
"data-gp-text": true,
|
|
92
|
-
className: core.cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass,
|
|
118
|
+
className: core.cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, core.getGlobalColorClass('text', setting?.color)),
|
|
93
119
|
style: {
|
|
94
120
|
...core.getStyleShadow({
|
|
95
121
|
value: setting?.textShadow,
|
|
@@ -101,10 +127,11 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
101
127
|
...core.makeStyle({
|
|
102
128
|
tt: setting?.transform
|
|
103
129
|
}),
|
|
104
|
-
...appendTypoStyle
|
|
130
|
+
...appendTypoStyle,
|
|
131
|
+
...common.getMaxHeightStyleDefault(setting)
|
|
105
132
|
},
|
|
106
133
|
dangerouslySetInnerHTML: {
|
|
107
|
-
__html: product?.descriptionHtml
|
|
134
|
+
__html: product?.descriptionHtml || ''
|
|
108
135
|
}
|
|
109
136
|
}),
|
|
110
137
|
hasLineClamp && isShowViewMore && /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
@@ -117,7 +144,7 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
117
144
|
...appendTypoStyle,
|
|
118
145
|
...core.getGlobalColorStyle(setting?.showMoreColor)
|
|
119
146
|
},
|
|
120
|
-
onClick:
|
|
147
|
+
onClick: handleToggleShowMore,
|
|
121
148
|
children: [
|
|
122
149
|
!open ? setting?.viewMoreText : setting?.viewLessText,
|
|
123
150
|
setting?.enableViewMoreIcon && /*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@gem-sdk/core');
|
|
6
6
|
var helpers = require('../../helpers.js');
|
|
7
|
+
var common = require('./ProductDescription/common.js');
|
|
7
8
|
|
|
8
9
|
const devices = [
|
|
9
10
|
'desktop',
|
|
@@ -35,7 +36,8 @@ const ProductDescription = ({ setting, advanced, builderProps })=>{
|
|
|
35
36
|
...core.makeStyle({
|
|
36
37
|
tt: setting?.transform
|
|
37
38
|
}),
|
|
38
|
-
...appendTypoStyle
|
|
39
|
+
...appendTypoStyle,
|
|
40
|
+
...common.getMaxHeightStyleDefault(setting)
|
|
39
41
|
};
|
|
40
42
|
const collapseStyle = {
|
|
41
43
|
...defaultStyle,
|
package/dist/esm/helpers.js
CHANGED
|
@@ -32,7 +32,7 @@ const isHexTransparent = (hex)=>{
|
|
|
32
32
|
return Boolean(a);
|
|
33
33
|
};
|
|
34
34
|
const youtubeShortsRegex = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^"&?/\s]{11})$/i;
|
|
35
|
-
const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin })=>{
|
|
35
|
+
const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin, isReplaceMaxSize })=>{
|
|
36
36
|
const hasLiquidInValue = new RegExp(/\{\{.*?\}\}|\{%.*?%\}/).test(val?.toString() ?? '');
|
|
37
37
|
const translateLimit = pageContext?.isTranslateWithLocale ? 1000 : 5000;
|
|
38
38
|
if (!translate || !val?.toString().trim() || val.toString().length > translateLimit || hasLiquidInValue || pageContext?.isPreviewing) return val ?? defaultVal;
|
|
@@ -44,6 +44,9 @@ const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, i
|
|
|
44
44
|
if (isReplaceLocationOrigin) {
|
|
45
45
|
locale += ` | replace: '$locationOrigin', locationOrigin`;
|
|
46
46
|
}
|
|
47
|
+
if (isReplaceMaxSize) {
|
|
48
|
+
locale += ` | replace: '$max_size', '10MB'`;
|
|
49
|
+
}
|
|
47
50
|
if (isCapitalize) {
|
|
48
51
|
locale = `${locale} | downcase`;
|
|
49
52
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const getTextDropContent = (textContent)=>{
|
|
2
|
-
if (textContent?.includes('
|
|
3
|
-
return textContent?.replace('
|
|
2
|
+
if (textContent?.includes('$max_size')) {
|
|
3
|
+
return textContent?.replace('$max_size', '10MB');
|
|
4
4
|
}
|
|
5
5
|
return textContent;
|
|
6
6
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { composeTypographyClassName, composeTypographyStyle, makeGlobalSize, template, makeStyleResponsive, makeStyle, makeStyleState, composeRadius, handleConvertBorderWidth, handleConvertBorderStyle, handleConvertBorderColor, getStyleShadowState, cls, getGlobalColorStateStyle, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
2
|
import { getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
|
|
3
|
-
import { getTextDropContent } from './FileUpload/components/common/index.js';
|
|
4
3
|
|
|
5
4
|
const FileUpload = ({ setting, styles, builderProps, pageContext })=>{
|
|
6
5
|
const appendTypoClass = composeTypographyClassName(styles?.typo);
|
|
@@ -8,12 +7,13 @@ const FileUpload = ({ setting, styles, builderProps, pageContext })=>{
|
|
|
8
7
|
const composeGlobalSize = makeGlobalSize(setting?.size);
|
|
9
8
|
const composePaddingSize = makeGlobalSize(setting?.paddingSize);
|
|
10
9
|
const displayText = getDynamicSourceLocales({
|
|
11
|
-
val:
|
|
10
|
+
val: setting?.textContent,
|
|
12
11
|
uid: builderProps?.uid,
|
|
13
12
|
settingId: 'textContent',
|
|
14
13
|
pageContext,
|
|
15
14
|
isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
|
|
16
|
-
translate: setting?.translate
|
|
15
|
+
translate: setting?.translate,
|
|
16
|
+
isReplaceMaxSize: true
|
|
17
17
|
});
|
|
18
18
|
const cssInLine = `
|
|
19
19
|
.${builderProps?.uid}:hover .gp-file-upload__icon {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen, makeStyleResponsive } from '@gem-sdk/core';
|
|
2
|
+
import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from './const.js';
|
|
3
|
+
|
|
4
|
+
const getMaxHeightStyleDefault = (setting)=>{
|
|
5
|
+
let result = {
|
|
6
|
+
desktop: 'none'
|
|
7
|
+
};
|
|
8
|
+
const devices = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'mobile',
|
|
11
|
+
'tablet'
|
|
12
|
+
];
|
|
13
|
+
devices.forEach((device)=>{
|
|
14
|
+
const lineClamp = getResponsiveValueByScreen(setting?.lineClamp, device);
|
|
15
|
+
const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, device);
|
|
16
|
+
const maxHeight = hasLineClamp && lineClamp ? `${lineClamp * DESCRIPTION_LINE_HEIGHT_DEFAULT}px` : 'none';
|
|
17
|
+
result = {
|
|
18
|
+
...result,
|
|
19
|
+
[device]: maxHeight
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
const style = makeStyleResponsive('maxh', result);
|
|
23
|
+
return style;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { getMaxHeightStyleDefault };
|
|
@@ -3,6 +3,8 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useProduct, useCurrentDevice, getResponsiveValueByScreen, useProductShopifyEditLink, useEditorMode, isBrowser, composeTypographyClassName, composeTypographyStyle, cls, getGlobalColorClass, getStyleShadow, makeStyleResponsive, makeStyle, getGlobalColorStyle } from '@gem-sdk/core';
|
|
4
4
|
import { useState, useRef, useEffect } from 'react';
|
|
5
5
|
import NoDataState from '../../common/components/NoDataState.js';
|
|
6
|
+
import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
|
|
7
|
+
import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from './ProductDescription/const.js';
|
|
6
8
|
|
|
7
9
|
const ProductDescription = ({ setting, builderProps })=>{
|
|
8
10
|
const [open, setOpen] = useState(false);
|
|
@@ -19,13 +21,17 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
19
21
|
useEffect(()=>{
|
|
20
22
|
const dom = ref.current;
|
|
21
23
|
setOpen(false);
|
|
22
|
-
if (dom
|
|
24
|
+
if (!dom) return;
|
|
25
|
+
const enableShowMore = hasLineClamp && product?.descriptionHtml;
|
|
26
|
+
if (!enableShowMore) dom.style.maxHeight = 'none';
|
|
27
|
+
else {
|
|
23
28
|
const value = lineClamp;
|
|
24
29
|
setTimeout(()=>{
|
|
25
30
|
const scrollHeight = dom?.scrollHeight ?? 0;
|
|
26
31
|
const clientHeight = dom?.clientHeight ?? 0;
|
|
27
|
-
const lineHeight =
|
|
28
|
-
const lineText = Math.round((scrollHeight ?? 0) /
|
|
32
|
+
const lineHeight = getLineHeightFromDom();
|
|
33
|
+
const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
|
|
34
|
+
dom.style.maxHeight = getMaxHeight(lineHeight);
|
|
29
35
|
const conditionCheckLine = isSafari ? value && value < lineText : clientHeight < scrollHeight;
|
|
30
36
|
if (value && conditionCheckLine) {
|
|
31
37
|
allowShowViewMore(()=>true);
|
|
@@ -40,6 +46,16 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
40
46
|
product?.description,
|
|
41
47
|
isSafari
|
|
42
48
|
]);
|
|
49
|
+
const getLineHeightFromDom = ()=>{
|
|
50
|
+
if (!ref.current) return DESCRIPTION_LINE_HEIGHT_DEFAULT;
|
|
51
|
+
const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
|
|
52
|
+
return parseInt(lineHeight);
|
|
53
|
+
};
|
|
54
|
+
const getMaxHeight = (lineHeight)=>{
|
|
55
|
+
if (!hasLineClamp || !lineClamp) return 'auto';
|
|
56
|
+
if (lineHeight) return `${lineClamp * lineHeight}px`;
|
|
57
|
+
return 'auto';
|
|
58
|
+
};
|
|
43
59
|
const Tag = htmlTag === 'html' ? 'div' : 'p';
|
|
44
60
|
const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
|
|
45
61
|
const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
|
|
@@ -55,8 +71,8 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
55
71
|
box-shadow: none;
|
|
56
72
|
}
|
|
57
73
|
`;
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
74
|
+
const noDescriptionHtml = !product?.descriptionHtml;
|
|
75
|
+
if (noDescriptionHtml && mode === 'edit') {
|
|
60
76
|
return /*#__PURE__*/ jsx(NoDataState, {
|
|
61
77
|
elementType: "secondary",
|
|
62
78
|
description: "Highlight key benefits with product description.",
|
|
@@ -72,8 +88,18 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
72
88
|
]
|
|
73
89
|
});
|
|
74
90
|
}
|
|
91
|
+
const handleToggleShowMore = ()=>{
|
|
92
|
+
if (!ref.current) return;
|
|
93
|
+
const lineHeight = getLineHeightFromDom();
|
|
94
|
+
if (open) {
|
|
95
|
+
ref.current.style.maxHeight = getMaxHeight(lineHeight);
|
|
96
|
+
} else {
|
|
97
|
+
ref.current.style.maxHeight = 'none';
|
|
98
|
+
}
|
|
99
|
+
setOpen((prev)=>!prev);
|
|
100
|
+
};
|
|
75
101
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
76
|
-
children:
|
|
102
|
+
children: noDescriptionHtml ? null : /*#__PURE__*/ jsxs("div", {
|
|
77
103
|
"data-id": builderProps?.uid,
|
|
78
104
|
children: [
|
|
79
105
|
!isSafari && /*#__PURE__*/ jsx("style", {
|
|
@@ -85,7 +111,7 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
85
111
|
/*#__PURE__*/ jsx(Tag, {
|
|
86
112
|
ref: ref,
|
|
87
113
|
"data-gp-text": true,
|
|
88
|
-
className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass,
|
|
114
|
+
className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, getGlobalColorClass('text', setting?.color)),
|
|
89
115
|
style: {
|
|
90
116
|
...getStyleShadow({
|
|
91
117
|
value: setting?.textShadow,
|
|
@@ -97,10 +123,11 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
97
123
|
...makeStyle({
|
|
98
124
|
tt: setting?.transform
|
|
99
125
|
}),
|
|
100
|
-
...appendTypoStyle
|
|
126
|
+
...appendTypoStyle,
|
|
127
|
+
...getMaxHeightStyleDefault(setting)
|
|
101
128
|
},
|
|
102
129
|
dangerouslySetInnerHTML: {
|
|
103
|
-
__html: product?.descriptionHtml
|
|
130
|
+
__html: product?.descriptionHtml || ''
|
|
104
131
|
}
|
|
105
132
|
}),
|
|
106
133
|
hasLineClamp && isShowViewMore && /*#__PURE__*/ jsxs("button", {
|
|
@@ -113,7 +140,7 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
113
140
|
...appendTypoStyle,
|
|
114
141
|
...getGlobalColorStyle(setting?.showMoreColor)
|
|
115
142
|
},
|
|
116
|
-
onClick:
|
|
143
|
+
onClick: handleToggleShowMore,
|
|
117
144
|
children: [
|
|
118
145
|
!open ? setting?.viewMoreText : setting?.viewLessText,
|
|
119
146
|
setting?.enableViewMoreIcon && /*#__PURE__*/ jsx("svg", {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { composeTypographyClassName, composeTypographyStyle, getStyleShadow, makeStyleResponsive, getGlobalColorStyle, makeStyle, makeLineClamp, template, cls, getGlobalColorClass, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
2
|
import { getSettingPreloadData } from '../../helpers.js';
|
|
3
|
+
import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
|
|
3
4
|
|
|
4
5
|
const devices = [
|
|
5
6
|
'desktop',
|
|
@@ -31,7 +32,8 @@ const ProductDescription = ({ setting, advanced, builderProps })=>{
|
|
|
31
32
|
...makeStyle({
|
|
32
33
|
tt: setting?.transform
|
|
33
34
|
}),
|
|
34
|
-
...appendTypoStyle
|
|
35
|
+
...appendTypoStyle,
|
|
36
|
+
...getMaxHeightStyleDefault(setting)
|
|
35
37
|
};
|
|
36
38
|
const collapseStyle = {
|
|
37
39
|
...defaultStyle,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7833,12 +7833,13 @@ type DynamicSource = {
|
|
|
7833
7833
|
defaultVal?: string;
|
|
7834
7834
|
translate?: string;
|
|
7835
7835
|
isReplaceLocationOrigin?: boolean;
|
|
7836
|
+
isReplaceMaxSize?: boolean;
|
|
7836
7837
|
};
|
|
7837
7838
|
declare const isTransparentColor: (str?: string) => boolean;
|
|
7838
7839
|
declare const isTransparentRGBA: (rgbStr: string) => boolean;
|
|
7839
7840
|
declare const isHexTransparent: (hex: string) => boolean;
|
|
7840
7841
|
declare const youtubeShortsRegex: RegExp;
|
|
7841
|
-
declare const getDynamicSourceLocales: ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal, translate, isReplaceLocationOrigin, }: DynamicSource) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>;
|
|
7842
|
+
declare const getDynamicSourceLocales: ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal, translate, isReplaceLocationOrigin, isReplaceMaxSize, }: DynamicSource) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>;
|
|
7842
7843
|
declare const getStaticLocale: (tag: string, key: string) => string;
|
|
7843
7844
|
declare const getSettingPreloadData: (disabledValue: string, enabledValue?: string) => string;
|
|
7844
7845
|
declare const getInsertLinkData: (defaultWrap: string, setting?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "2.0.0-staging.
|
|
3
|
+
"version": "2.0.0-staging.154",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"relationship": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/get-control-relationship.js && node ./scripts/get-element-relationship.js"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@gem-sdk/core": "2.0.0-staging.
|
|
26
|
-
"@gem-sdk/styles": "2.0.0-staging.
|
|
25
|
+
"@gem-sdk/core": "2.0.0-staging.153",
|
|
26
|
+
"@gem-sdk/styles": "2.0.0-staging.153",
|
|
27
27
|
"@types/react-transition-group": "^4.4.5"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|