@gem-sdk/components 2.0.0-dev.271 → 2.0.0-dev.275

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.
Files changed (104) hide show
  1. package/dist/cjs/article/components/ArticleImage.js +0 -5
  2. package/dist/cjs/article/components/ArticleList.js +1 -1
  3. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +1 -1
  4. package/dist/cjs/builder.js +13 -13
  5. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.js +70 -0
  6. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.liquid.js +71 -0
  7. package/dist/cjs/cart/components/ShopPayButton/common/classes.js +18 -0
  8. package/dist/cjs/cart/components/ShopPayButton/common/helpers.js +31 -0
  9. package/dist/cjs/cart/components/ShopPayButton/common/styles.js +12 -0
  10. package/dist/cjs/cart/components/ShopPayButton/hooks/useShopPayButton.js +70 -0
  11. package/dist/cjs/cart/next.js +1 -1
  12. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +1 -1
  13. package/dist/cjs/form/setting/submit-button/configs/settings.js +2 -2
  14. package/dist/cjs/header/components/kind/basic/index.js +1 -1
  15. package/dist/cjs/header/components/kind/modern/index.js +1 -1
  16. package/dist/cjs/index.js +39 -39
  17. package/dist/cjs/index.liquid.js +9 -9
  18. package/dist/cjs/marquee/setting/configs/childImageTemplate.js +1 -1
  19. package/dist/cjs/post-purchase/advanced-list/components/common/getClasses.js +1 -1
  20. package/dist/cjs/post-purchase/advanced-list/setting/configs/presets.js +3 -1
  21. package/dist/cjs/post-purchase/advanced-list/setting/configs/settings.js +2 -1
  22. package/dist/cjs/post-purchase/advanced-list/setting/template.js +8 -3
  23. package/dist/cjs/post-purchase/callout-banner/setting/config/callout-text/setting.js +0 -7
  24. package/dist/cjs/post-purchase/callout-banner/setting/config/callout-text/uiV2.js +1 -1
  25. package/dist/cjs/post-purchase/image/setting/Image.js +2 -2
  26. package/dist/cjs/post-purchase/image/setting/setting-v2.js +25 -13
  27. package/dist/cjs/post-purchase/image/setting/ui-v2.js +1 -1
  28. package/dist/cjs/post-purchase/link/setting/configs/settings.js +7 -2
  29. package/dist/cjs/post-purchase/product/settings/product-variants/configs/uiV2.js +4 -2
  30. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +28 -0
  31. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.liquid.js +23 -0
  32. package/dist/cjs/product/components/DynamicCheckout/common/classes.js +32 -0
  33. package/dist/cjs/product/components/DynamicCheckout/common/styles.js +181 -0
  34. package/dist/cjs/product/components/DynamicCheckout/components/Button.liquid.js +58 -0
  35. package/dist/cjs/product/components/FileUpload/components/common/index.js +1 -1
  36. package/dist/cjs/product/components/ProductDescription/common/const.js +9 -0
  37. package/dist/cjs/product/components/ProductDescription/common/getClasses.js +30 -0
  38. package/dist/cjs/product/components/ProductDescription/common/getStyle.js +81 -0
  39. package/dist/cjs/product/components/ProductDescription/hooks/useGpDescription.js +90 -0
  40. package/dist/cjs/product/components/ProductDescription/index.js +115 -0
  41. package/dist/cjs/product/components/ProductDescription/index.liquid.js +86 -0
  42. package/dist/cjs/product/next.js +1 -1
  43. package/dist/cjs/setting.js +1 -1
  44. package/dist/esm/article/components/ArticleImage.js +0 -5
  45. package/dist/esm/article/components/ArticleList.js +1 -1
  46. package/dist/esm/banner/components/HeroBannerItem.liquid.js +1 -1
  47. package/dist/esm/builder.js +3 -3
  48. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.js +66 -0
  49. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.liquid.js +67 -0
  50. package/dist/esm/cart/components/ShopPayButton/common/classes.js +15 -0
  51. package/dist/esm/cart/components/ShopPayButton/common/helpers.js +27 -0
  52. package/dist/esm/cart/components/ShopPayButton/common/styles.js +10 -0
  53. package/dist/esm/cart/components/ShopPayButton/hooks/useShopPayButton.js +68 -0
  54. package/dist/esm/cart/next.js +1 -1
  55. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +1 -1
  56. package/dist/esm/form/setting/submit-button/configs/settings.js +2 -2
  57. package/dist/esm/header/components/kind/basic/index.js +1 -1
  58. package/dist/esm/header/components/kind/modern/index.js +1 -1
  59. package/dist/esm/index.js +3 -3
  60. package/dist/esm/index.liquid.js +3 -3
  61. package/dist/esm/marquee/setting/configs/childImageTemplate.js +1 -1
  62. package/dist/esm/post-purchase/advanced-list/components/common/getClasses.js +1 -1
  63. package/dist/esm/post-purchase/advanced-list/setting/configs/presets.js +3 -1
  64. package/dist/esm/post-purchase/advanced-list/setting/configs/settings.js +2 -1
  65. package/dist/esm/post-purchase/advanced-list/setting/template.js +8 -3
  66. package/dist/esm/post-purchase/callout-banner/setting/config/callout-text/setting.js +0 -7
  67. package/dist/esm/post-purchase/callout-banner/setting/config/callout-text/uiV2.js +1 -1
  68. package/dist/esm/post-purchase/image/setting/Image.js +2 -2
  69. package/dist/esm/post-purchase/image/setting/setting-v2.js +25 -13
  70. package/dist/esm/post-purchase/image/setting/ui-v2.js +1 -1
  71. package/dist/esm/post-purchase/link/setting/configs/settings.js +7 -2
  72. package/dist/esm/post-purchase/product/settings/product-variants/configs/uiV2.js +4 -2
  73. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +24 -0
  74. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.liquid.js +19 -0
  75. package/dist/esm/product/components/DynamicCheckout/common/classes.js +30 -0
  76. package/dist/esm/product/components/DynamicCheckout/common/styles.js +179 -0
  77. package/dist/esm/product/components/DynamicCheckout/components/Button.liquid.js +54 -0
  78. package/dist/esm/product/components/FileUpload/components/common/index.js +1 -1
  79. package/dist/esm/product/components/ProductDescription/common/const.js +6 -0
  80. package/dist/esm/product/components/ProductDescription/common/getClasses.js +27 -0
  81. package/dist/esm/product/components/ProductDescription/common/getStyle.js +77 -0
  82. package/dist/esm/product/components/ProductDescription/hooks/useGpDescription.js +88 -0
  83. package/dist/esm/product/components/ProductDescription/index.js +111 -0
  84. package/dist/esm/product/components/ProductDescription/index.liquid.js +82 -0
  85. package/dist/esm/product/next.js +1 -1
  86. package/dist/esm/setting.js +1 -1
  87. package/dist/types/index.d.ts +29 -97
  88. package/package.json +1 -1
  89. package/dist/cjs/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -20
  90. package/dist/cjs/cart/components/ShopPayButton/index.js +0 -113
  91. package/dist/cjs/cart/components/ShopPayButton/index.liquid.js +0 -51
  92. package/dist/cjs/product/components/DynamicCheckout.liquid.js +0 -250
  93. package/dist/cjs/product/components/ProductDescription/const.js +0 -5
  94. package/dist/cjs/product/components/ProductDescription.js +0 -172
  95. package/dist/cjs/product/components/ProductDescription.liquid.js +0 -120
  96. package/dist/esm/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -17
  97. package/dist/esm/cart/components/ShopPayButton/index.js +0 -109
  98. package/dist/esm/cart/components/ShopPayButton/index.liquid.js +0 -47
  99. package/dist/esm/product/components/DynamicCheckout.liquid.js +0 -246
  100. package/dist/esm/product/components/ProductDescription/const.js +0 -3
  101. package/dist/esm/product/components/ProductDescription.js +0 -168
  102. package/dist/esm/product/components/ProductDescription.liquid.js +0 -116
  103. /package/dist/cjs/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
  104. /package/dist/esm/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
@@ -0,0 +1,179 @@
1
+ import { getWidthHeightGlobalSize, getPaddingGlobalSize, composeShadowCss, composeCornerCss, composeTypographyV2Css, composeTextHoverColorCss, composeBorderCss, composeBackgroundImageCss, composeBackgroundCss } from '@gem-sdk/core';
2
+
3
+ const composeSize = (width, height, important = true)=>{
4
+ return `
5
+ ${width ? `width: ${width}${important ? '!important;' : ''};` : ''}
6
+ ${height ? `height: ${height}${important ? '!important;' : ''};` : ''}
7
+ `;
8
+ };
9
+ const composeSpacing = (device, padding)=>{
10
+ const suffix = device && device !== 'desktop' ? `-${device}` : '';
11
+ const spacingDevice = {
12
+ top: padding[`--pt${suffix}`],
13
+ bottom: padding[`--pb${suffix}`],
14
+ left: padding[`--pl${suffix}`],
15
+ right: padding[`--pr${suffix}`]
16
+ };
17
+ return `
18
+ padding-top: ${spacingDevice.top ? `${spacingDevice.top} !important;` : ''};
19
+ padding-bottom: ${spacingDevice.bottom ? `${spacingDevice.bottom} !important;` : ''};
20
+ padding-left: ${spacingDevice.left ? `${spacingDevice.left} !important;` : ''};
21
+ padding-right: ${spacingDevice.right ? `${spacingDevice.right} !important;` : ''};
22
+ `;
23
+ };
24
+ const composeFontSize = (fontSize)=>{
25
+ return fontSize ? `font-size: ${fontSize} !important;` : '';
26
+ };
27
+ const composeLineHeight = (lineHeight)=>{
28
+ return lineHeight ? `line-height: ${lineHeight} !important;` : '';
29
+ };
30
+ const composeTextAlign = (align)=>{
31
+ return `${align ? `text-align: ${align} !important;` : ''}`;
32
+ };
33
+ const getDeviceStyles = ({ uid, device, styles, composeGlobalSize })=>{
34
+ return `
35
+ .wrap__button--unbranded__${uid} {
36
+ ${composeTextAlign(styles?.align?.[device])}
37
+ }
38
+
39
+ .wrap__button--unbranded__${uid} .shopify-payment-button {
40
+ ${composeSize(composeGlobalSize.width[device], composeGlobalSize.height[device], device !== 'desktop')}
41
+ }
42
+
43
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
44
+ width: 100%;
45
+ ${device !== 'desktop' ? `
46
+ ${composeLineHeight(styles?.typo?.custom?.lineHeight?.[device])}
47
+ ${composeFontSize(styles?.typo?.custom?.fontSize?.[device])}
48
+ ` : ''}
49
+ ${composeSpacing(device, composeGlobalSize.padding)}
50
+ ${composeSize(composeGlobalSize.width[device] ?? 'auto', composeGlobalSize.height[device] ?? 'auto', false)}
51
+ ${composeShadowCss({
52
+ boxShadowValue: styles?.boxShadowBtnV2?.[device]?.normal,
53
+ hasBoxShadow: styles?.boxShadowBtnV2?.[device]?.normal?.type !== 'none'
54
+ })}
55
+ ${composeCornerCss(styles?.roundedBtnV2?.[device]?.normal, true)}
56
+ ${device === 'desktop' ? composeTypographyV2Css(styles?.typo, true) : ''}
57
+ }
58
+
59
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
60
+ ${composeShadowCss({
61
+ boxShadowValue: styles?.boxShadowBtnV2?.[device]?.hover,
62
+ hasBoxShadow: styles?.boxShadowBtnV2?.[device]?.hover?.type !== 'none',
63
+ important: true
64
+ })}
65
+ ${composeTextHoverColorCss(device, styles?.textColorHover, true)}
66
+ }
67
+
68
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
69
+ ${composeBorderCss(styles?.borderBtnV2?.[device]?.normal)}
70
+ ${composeCornerCss(styles?.roundedBtnV2?.[device]?.normal)}
71
+ ${composeBackgroundImageCss(styles?.backgroundImage, {
72
+ device,
73
+ state: 'normal'
74
+ })}
75
+ ${composeBackgroundCss(styles?.backgroundColorV2?.[device]?.normal)}
76
+ }
77
+
78
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
79
+ ${composeBorderCss(styles?.borderBtnV2?.[device]?.hover)}
80
+ ${composeCornerCss(styles?.roundedBtnV2?.[device]?.hover)}
81
+ ${composeBackgroundCss(styles?.backgroundColorV2?.[device]?.hover)}
82
+ }
83
+ `;
84
+ };
85
+ const getButtonStyles = ({ styles, uid })=>{
86
+ const composeGlobalSize = {
87
+ width: getWidthHeightGlobalSize('width', styles?.globalSize),
88
+ height: getWidthHeightGlobalSize('height', styles?.globalSize),
89
+ padding: getPaddingGlobalSize(styles?.globalSize)
90
+ };
91
+ const baseStyles = `
92
+ .wrap__button--unbranded__${uid} .shopify-payment-button {
93
+ display: inline-block;
94
+ min-height: unset !important;
95
+ }
96
+
97
+ .wrap__button--unbranded__${uid} .shopify-payment-button div {
98
+ width: 100%;
99
+ margin-top: 0px !important;
100
+ }
101
+
102
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__more-options {
103
+ display: none;
104
+ }
105
+
106
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
107
+ max-width: 100%;
108
+ min-width: unset;
109
+ min-height: unset !important;
110
+ background-color: unset !important;
111
+ position: relative;
112
+ border: none !important;
113
+ margin: 0;
114
+ z-index: 0;
115
+ border-radius: unset;
116
+ width: 100%;
117
+ display: inline-flex;
118
+ justify-content: center;
119
+ align-items: center;
120
+ }
121
+
122
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
123
+ content: "";
124
+ height: 100%;
125
+ width: 100%;
126
+ position: absolute;
127
+ top: 0;
128
+ left: 0;
129
+ pointer-events: none;
130
+ z-index: -1;
131
+ }
132
+
133
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded::after {
134
+ border-radius: 0;
135
+ box-shadow: none;
136
+ }
137
+
138
+ .wrap__button--unbranded__${uid} .shopify-payment-button .shopify-payment-button__button--unbranded::after:hover {
139
+ border-radius: 0;
140
+ box-shadow: none;
141
+ }
142
+
143
+ .wrap__button--unbranded__${uid} .shopify-payment-button > div {
144
+ max-width: 100%;
145
+ }
146
+
147
+ .wrap__button--unbranded__${uid} .shopify-payment-button > div > div {
148
+ max-width: 100%;
149
+ }
150
+
151
+ ${getDeviceStyles({
152
+ device: 'desktop',
153
+ uid,
154
+ styles,
155
+ composeGlobalSize
156
+ })}
157
+
158
+ @media only screen and (max-width: 1024px) and (min-width: 768px) {
159
+ ${getDeviceStyles({
160
+ device: 'tablet',
161
+ uid,
162
+ styles,
163
+ composeGlobalSize
164
+ })}
165
+ }
166
+
167
+ @media only screen and (max-width: 767px) {
168
+ ${getDeviceStyles({
169
+ device: 'mobile',
170
+ uid,
171
+ styles,
172
+ composeGlobalSize
173
+ })}
174
+ }
175
+ `;
176
+ return baseStyles;
177
+ };
178
+
179
+ export { getButtonStyles };
@@ -0,0 +1,54 @@
1
+ import { template, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { createClass, createStateOrContext, Liquid, If } from '@gem-sdk/system';
3
+ import { getDynamicSourceLocales, getSettingPreloadData } from '../../../../helpers.js';
4
+ import { getButtonClasses } from '../common/classes.js';
5
+ import { getButtonStyles } from '../common/styles.js';
6
+
7
+ const Button = ({ setting, advanced, styles, pageContext, builderProps, className = '' })=>{
8
+ const translatedLabel = getDynamicSourceLocales({
9
+ pageContext,
10
+ settingId: 'label',
11
+ val: setting?.label,
12
+ uid: builderProps?.uid,
13
+ translate: setting?.translate
14
+ });
15
+ const buttonClass = createClass({
16
+ ...!!className && {
17
+ [className]: true
18
+ },
19
+ ...getButtonClasses({
20
+ styles,
21
+ uid: builderProps?.uid
22
+ })
23
+ });
24
+ const buttonStyles = getButtonStyles({
25
+ styles,
26
+ uid: builderProps?.uid
27
+ });
28
+ const buttonState = createStateOrContext({
29
+ setting: {
30
+ label: setting?.label
31
+ },
32
+ totalVariant: '{{product.variants.size}}'
33
+ });
34
+ return template`
35
+ ${Liquid(`
36
+ {%- liquid
37
+ assign inventory_quantity = variant.inventory_quantity | default: 0
38
+ assign supported_payment_methods = shop.enabled_payment_types
39
+ -%}
40
+ `)}
41
+ <gp-product-dynamic data-id="${builderProps?.uid}" data-translate-label="${translatedLabel}" class="${advanced?.cssClass}" gp-data='${JSON.stringify(buttonState).replaceAll("'", '&#039;')}
42
+ '>
43
+ <div class="${buttonClass}">
44
+ {{ form | payment_button }}
45
+ </div>
46
+ {% style %}
47
+ ${buttonStyles}
48
+ {% endstyle %}
49
+ </gp-product-dynamic>
50
+ ${If(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-dynamic.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-product-dynamic.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
51
+ `;
52
+ };
53
+
54
+ export { Button as default };
@@ -11,7 +11,7 @@ import '../../../ProductVariants/variants/index.js';
11
11
  import 'next/image';
12
12
  import 'react-youtube';
13
13
  import '../../../../../image/components/AdaptiveImage.js';
14
- import '../../../../../cart/components/ShopPayButton/index.js';
14
+ import '../../../../../cart/components/ShopPayButton/ShopPayButton.js';
15
15
  import '../../../../../countdown-timer/setting/configs/settings.js';
16
16
  import '../../../../../header/components/Header.js';
17
17
  import '../../../../../header/components/kind/basic/index.js';
@@ -0,0 +1,6 @@
1
+ const DESCRIPTION_LINE_HEIGHT_DEFAULT = 21;
2
+ const ICON_SVG = `<svg height="1em" width="1em" viewBox="0 0 22 12" fill="none" xmlns="http://www.w3.org/2000/svg" ><path d="M1.70711 0.292893C1.31658 -0.0976311 0.683417 -0.0976311 0.292893 0.292893C-0.0976311 0.683417 -0.0976311 1.31658 0.292893 1.70711L1.70711 0.292893ZM11 11L10.2929 11.7071C10.6834 12.0976 11.3166 12.0976 11.7071 11.7071L11 11ZM21.7071 1.70711C22.0976 1.31658 22.0976 0.683417 21.7071 0.292893C21.3166 -0.0976311 20.6834 -0.0976311 20.2929 0.292893L21.7071 1.70711ZM0.292893 1.70711L10.2929 11.7071L11.7071 10.2929L1.70711 0.292893L0.292893 1.70711ZM11.7071 11.7071L21.7071 1.70711L20.2929 0.292893L10.2929 10.2929L11.7071 11.7071Z"
3
+ fill="currentColor"/>
4
+ </svg>`;
5
+
6
+ export { DESCRIPTION_LINE_HEIGHT_DEFAULT, ICON_SVG };
@@ -0,0 +1,27 @@
1
+ import { composeTypographyClassName, getGlobalColorClass } from '@gem-sdk/core';
2
+
3
+ const getClasses = ({ setting })=>{
4
+ const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
5
+ const globalColorClass = getGlobalColorClass('text', setting?.color);
6
+ return {
7
+ 'gp-relative p-description-wrapper gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre': true,
8
+ ...appendTypoClass && {
9
+ [appendTypoClass]: true
10
+ },
11
+ [globalColorClass]: true,
12
+ "data-[browser=safari]:after:gp-content-[' '] data-[browser=safari]:after:gp-absolute data-[browser=safari]:after:gp-left-0 data-[browser=safari]:after:gp-right-0 data-[browser=safari]:after:gp-bottom-0 data-[browser=safari]:after:gp-w-full data-[browser=safari]:after:gp-h-1/2 data-[browser=safari]:after:gp-bg-gradient-to-t data-[browser=safari]:after:gp-from-white": true
13
+ };
14
+ };
15
+ const getButtonClasses = ({ setting })=>{
16
+ const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
17
+ const globalColorClass = getGlobalColorClass('text', setting?.showMoreColor);
18
+ return {
19
+ 'p-description-show-more gp-items-center gp-mt-4 gp-w-full gp-transition-all hover:gp-opacity-80': true,
20
+ ...appendTypoClass && {
21
+ [appendTypoClass]: true
22
+ },
23
+ [globalColorClass]: true
24
+ };
25
+ };
26
+
27
+ export { getButtonClasses, getClasses };
@@ -0,0 +1,77 @@
1
+ import { composeTypographyStyle, getStyleShadow, makeStyleResponsive, getGlobalColorStyle, makeStyle, filterTruthyStyles } from '@gem-sdk/core';
2
+ import { getMaxHeightStyleDefault } from './getMaxHeight.js';
3
+
4
+ const devices = [
5
+ 'desktop',
6
+ 'mobile',
7
+ 'tablet'
8
+ ];
9
+ const getDisplayStyle = (fnCondition, defaultValue)=>{
10
+ let result = {};
11
+ devices.forEach((device)=>{
12
+ result = {
13
+ ...result,
14
+ [`--d${device === 'desktop' ? '' : `-${device}`}`]: `${fnCondition(device) ? 'none' : defaultValue}`
15
+ };
16
+ });
17
+ return result;
18
+ };
19
+ const getTextStyle = ({ setting, renderMaxHeight })=>{
20
+ const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
21
+ const composeStyles = {
22
+ ...getStyleShadow({
23
+ value: setting?.typo?.custom?.textShadow,
24
+ styleAppliedFor: 'text-shadow',
25
+ isEnableShadow: setting?.typo?.custom?.textShadow?.type !== 'none'
26
+ }),
27
+ ...makeStyleResponsive('ta', setting?.textAlign),
28
+ ...getGlobalColorStyle(setting?.color),
29
+ ...makeStyle({
30
+ tt: setting?.transform
31
+ }),
32
+ ...appendTypoStyle,
33
+ ...renderMaxHeight && getMaxHeightStyleDefault(setting)
34
+ };
35
+ return filterTruthyStyles(composeStyles);
36
+ };
37
+ const getButtonStyle = ({ setting })=>{
38
+ const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
39
+ const getDisplayCollapse = ()=>{
40
+ return getDisplayStyle((device)=>!!setting?.hasLineClamp && setting.hasLineClamp[device] !== undefined && !setting.hasLineClamp[device], 'inline-flex');
41
+ };
42
+ const composeStyles = {
43
+ ...makeStyleResponsive('jc', setting?.textAlign),
44
+ ...makeStyle({
45
+ tt: setting?.transform
46
+ }),
47
+ ...appendTypoStyle,
48
+ ...getGlobalColorStyle(setting?.showMoreColor),
49
+ ...getDisplayCollapse()
50
+ };
51
+ return filterTruthyStyles(composeStyles);
52
+ };
53
+ const getStaticCss = ()=>{
54
+ const gpDescriptionCss = `
55
+ .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script) {
56
+ display: inline !important;
57
+ }
58
+ .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script)::after {
59
+ content: "\\A";
60
+ white-space: pre;
61
+ }
62
+ .gp-p-description-text > table {
63
+ box-shadow: none;
64
+ }
65
+ `;
66
+ const textDescriptionCss = `
67
+ .p-description-wrapper.gp-p-description-text * {
68
+ color: inherit;
69
+ line-height: inherit !important;
70
+ }`;
71
+ return {
72
+ gpDescriptionCss,
73
+ textDescriptionCss
74
+ };
75
+ };
76
+
77
+ export { getButtonStyle, getStaticCss, getTextStyle };
@@ -0,0 +1,88 @@
1
+ import { useRef, useState, useCallback, useEffect } from 'react';
2
+ import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from '../common/const.js';
3
+ import { useProduct, useCurrentDevice, getResponsiveValueByScreen, useProductShopifyEditLink, useEditorMode } from '@gem-sdk/core';
4
+
5
+ const useGpDescription = (setting)=>{
6
+ const ref = useRef(null);
7
+ const [open, setOpen] = useState(false);
8
+ const [isShowViewMore, setIsShowViewMore] = useState(false);
9
+ const product = useProduct();
10
+ const currentDevice = useCurrentDevice();
11
+ const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
12
+ const lineClamp = getResponsiveValueByScreen(setting?.lineClamp, currentDevice);
13
+ const { redirectProductShopifyLink } = useProductShopifyEditLink();
14
+ const mode = useEditorMode();
15
+ const getLineHeightFromDom = useCallback(()=>{
16
+ if (!ref.current) return DESCRIPTION_LINE_HEIGHT_DEFAULT;
17
+ const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
18
+ return Math.ceil(parseFloat(lineHeight));
19
+ }, []);
20
+ const getMaxHeight = useCallback((lineHeight)=>{
21
+ if (!hasLineClamp || !lineClamp) return 'auto';
22
+ if (lineHeight) return `${lineClamp * lineHeight}px`;
23
+ return 'auto';
24
+ }, [
25
+ hasLineClamp,
26
+ lineClamp
27
+ ]);
28
+ const handleToggleShowMore = ()=>{
29
+ if (!ref.current) return;
30
+ const lineHeight = getLineHeightFromDom();
31
+ if (open) {
32
+ ref.current.style.maxHeight = getMaxHeight(lineHeight);
33
+ } else {
34
+ ref.current.style.maxHeight = 'none';
35
+ }
36
+ setOpen((prev)=>!prev);
37
+ };
38
+ useEffect(()=>{
39
+ const lineHeight = getLineHeightFromDom();
40
+ getMaxHeight(lineHeight);
41
+ }, [
42
+ setting?.typo?.custom,
43
+ getMaxHeight,
44
+ getLineHeightFromDom
45
+ ]);
46
+ useEffect(()=>{
47
+ const dom = ref.current;
48
+ setOpen(false);
49
+ if (!dom) return;
50
+ const enableShowMore = hasLineClamp && product?.descriptionHtml;
51
+ if (!enableShowMore) dom.style.maxHeight = 'none';
52
+ else {
53
+ const value = lineClamp;
54
+ setTimeout(()=>{
55
+ const scrollHeight = dom?.scrollHeight ?? 0;
56
+ const clientHeight = dom?.clientHeight ?? 0;
57
+ const lineHeight = getLineHeightFromDom();
58
+ const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
59
+ dom.style.maxHeight = getMaxHeight(lineHeight);
60
+ const conditionCheckLine = value && value < lineText || clientHeight < scrollHeight;
61
+ if (value && conditionCheckLine) {
62
+ setIsShowViewMore(()=>true);
63
+ } else {
64
+ setIsShowViewMore(()=>false);
65
+ }
66
+ }, 100);
67
+ }
68
+ }, [
69
+ hasLineClamp,
70
+ lineClamp,
71
+ product?.description,
72
+ product?.descriptionHtml,
73
+ getLineHeightFromDom,
74
+ getMaxHeight,
75
+ setOpen,
76
+ setIsShowViewMore
77
+ ]);
78
+ return {
79
+ ref,
80
+ open,
81
+ isShowViewMore,
82
+ handleToggleShowMore,
83
+ mode,
84
+ redirectProductShopifyLink
85
+ };
86
+ };
87
+
88
+ export { useGpDescription };
@@ -0,0 +1,111 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useProduct, useCurrentDevice, getResponsiveValueByScreen, makeStyleResponsive, makeLineClamp, isSafari } from '@gem-sdk/core';
4
+ import NoDataState from '../../../common/components/NoDataState.js';
5
+ import { ICON_SVG } from './common/const.js';
6
+ import { createClass, createStyle, createAttr, If } from '@gem-sdk/system';
7
+ import { getClasses, getButtonClasses } from './common/getClasses.js';
8
+ import { getTextStyle, getButtonStyle, getStaticCss } from './common/getStyle.js';
9
+ import { useGpDescription } from './hooks/useGpDescription.js';
10
+
11
+ const ProductDescription = (props)=>{
12
+ const { setting, advanced, builderProps } = props;
13
+ const { htmlTag } = setting ?? {};
14
+ const Tag = htmlTag === 'html' ? 'div' : 'p';
15
+ const product = useProduct();
16
+ const currentDevice = useCurrentDevice();
17
+ const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
18
+ const { ref, open, isShowViewMore, handleToggleShowMore, mode, redirectProductShopifyLink } = useGpDescription(setting);
19
+ const gpDescriptionClasses = createClass({
20
+ 'gp-product-description': true,
21
+ [advanced?.cssClass]: true
22
+ });
23
+ const textClasses = createClass(getClasses({
24
+ setting
25
+ }));
26
+ const buttonClasses = createClass(getButtonClasses({
27
+ setting
28
+ }));
29
+ const showMoreTextClasses = createClass({
30
+ 'gp-show-more-text': true
31
+ });
32
+ const showMoreIconClasses = createClass({
33
+ 'gp-show-more-icon gp-ml-1': true,
34
+ ...open ? {
35
+ 'gp-rotate-180': true
36
+ } : {}
37
+ });
38
+ const textStyle = createStyle({
39
+ ...getTextStyle({
40
+ setting
41
+ }),
42
+ ...!open ? makeStyleResponsive('line-clamp', makeLineClamp(setting?.lineClamp, setting?.hasLineClamp)) : {}
43
+ });
44
+ const buttonStyle = createStyle(getButtonStyle({
45
+ setting
46
+ }));
47
+ const attr = createAttr({
48
+ 'data-id': `${builderProps?.uid}`
49
+ });
50
+ const textAttr = createAttr({
51
+ 'data-gp-text': ''
52
+ });
53
+ const { gpDescriptionCss, textDescriptionCss } = getStaticCss();
54
+ const noDescriptionHtml = !product?.descriptionHtml;
55
+ if (noDescriptionHtml && mode === 'edit') {
56
+ return /*#__PURE__*/ jsx(NoDataState, {
57
+ elementType: "secondary",
58
+ description: "Highlight key benefits with product description.",
59
+ descriptionActions: [
60
+ {
61
+ text: 'Add description',
62
+ callback: redirectProductShopifyLink
63
+ },
64
+ {
65
+ text: 'sync data',
66
+ callback: 'syncProduct'
67
+ }
68
+ ]
69
+ });
70
+ }
71
+ return If(noDescriptionHtml, '', /*#__PURE__*/ jsxs("div", {
72
+ ...attr,
73
+ className: gpDescriptionClasses,
74
+ children: [
75
+ /*#__PURE__*/ jsx("style", {
76
+ children: textDescriptionCss
77
+ }),
78
+ If(!isSafari(), /*#__PURE__*/ jsx("style", {
79
+ children: gpDescriptionCss
80
+ }), ' '),
81
+ /*#__PURE__*/ jsx(Tag, {
82
+ ref: ref,
83
+ ...textAttr,
84
+ className: textClasses,
85
+ style: textStyle,
86
+ dangerouslySetInnerHTML: {
87
+ __html: product?.descriptionHtml || ''
88
+ }
89
+ }),
90
+ If(hasLineClamp && isShowViewMore, /*#__PURE__*/ jsxs("button", {
91
+ className: buttonClasses,
92
+ style: buttonStyle,
93
+ onClick: handleToggleShowMore,
94
+ children: [
95
+ /*#__PURE__*/ jsx("span", {
96
+ className: showMoreTextClasses,
97
+ children: If(open, setting?.viewLessText || '', setting?.viewMoreText)
98
+ }),
99
+ If(setting?.enableViewMoreIcon, /*#__PURE__*/ jsx("span", {
100
+ className: showMoreIconClasses,
101
+ dangerouslySetInnerHTML: {
102
+ __html: ICON_SVG
103
+ }
104
+ }))
105
+ ]
106
+ }), ' ')
107
+ ]
108
+ }));
109
+ };
110
+
111
+ export { ProductDescription as default };
@@ -0,0 +1,82 @@
1
+ import { makeStyleResponsive, makeLineClamp, template, dataStringify, isSafari, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { getSettingPreloadData } from '../../../helpers.js';
3
+ import { createClass, createStyle, createAttr, createStateOrContext, LiquidIf, Liquid, If, LiquidUnless } from '@gem-sdk/system';
4
+ import { getClasses, getButtonClasses } from './common/getClasses.js';
5
+ import { getTextStyle, getButtonStyle, getStaticCss } from './common/getStyle.js';
6
+ import { ICON_SVG } from './common/const.js';
7
+
8
+ const ProductDescription = (props)=>{
9
+ const { setting, advanced, builderProps } = props;
10
+ const { htmlTag } = setting ?? {};
11
+ const Tag = htmlTag === 'html' ? 'div' : 'p';
12
+ const gpDescriptionClasses = createClass({
13
+ 'gp-product-description': true,
14
+ [advanced?.cssClass]: true
15
+ });
16
+ const textClasses = createClass(getClasses({
17
+ setting
18
+ }));
19
+ const buttonClasses = createClass(getButtonClasses({
20
+ setting
21
+ }));
22
+ const showMoreTextClasses = createClass({
23
+ 'gp-show-more-text': true
24
+ });
25
+ const showMoreIconClasses = createClass({
26
+ 'gp-show-more-icon gp-ml-1': true
27
+ });
28
+ const textStyle = createStyle({
29
+ ...getTextStyle({
30
+ setting,
31
+ renderMaxHeight: true
32
+ }),
33
+ ...makeStyleResponsive('line-clamp', makeLineClamp(setting?.lineClamp, setting?.hasLineClamp))
34
+ });
35
+ const buttonStyle = createStyle(getButtonStyle({
36
+ setting
37
+ }));
38
+ const attr = createAttr({
39
+ 'data-id': `${builderProps?.uid}`
40
+ });
41
+ const textAttr = createAttr({
42
+ 'data-gp-text': ''
43
+ });
44
+ const { gpDescriptionCss, textDescriptionCss } = getStaticCss();
45
+ const noDescriptionHtml = 'product.description == blank';
46
+ const renderScript = ()=>{
47
+ const jsURL = isLocalEnv ? `{{ 'gp-product-description-v2.js' | asset_url }}` : `${baseAssetURL}/assets-v2/gp-product-description-v2.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;
48
+ return `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${jsURL}" defer="defer"></script>`;
49
+ };
50
+ const stateData = createStateOrContext({
51
+ setting: {
52
+ lineClamp: setting?.lineClamp,
53
+ hasLineClamp: setting?.hasLineClamp,
54
+ viewMoreText: setting?.viewMoreText,
55
+ viewLessText: setting?.viewLessText,
56
+ enableViewMoreIcon: setting?.enableViewMoreIcon
57
+ },
58
+ textStyle
59
+ });
60
+ return LiquidIf(noDescriptionHtml, '', Liquid(template`
61
+ <gp-product-description-v2
62
+ ${attr}
63
+ class="${gpDescriptionClasses}"
64
+ gp-data='${dataStringify(stateData).replaceAll("'", '&#039;')}'>
65
+ <style>${textDescriptionCss}</style>
66
+ ${If(!isSafari(), `<style>${gpDescriptionCss}</style>`, ' ')}
67
+ ${LiquidUnless('product', `<p>Product not found</p>`, template`<${Tag} ${textAttr} class="${textClasses}" style="${textStyle}">
68
+ {{product.description}}
69
+ </${Tag}>
70
+ ${LiquidUnless(noDescriptionHtml, template`<button type="button" class="${buttonClasses}" style="${buttonStyle}">
71
+ <span class="${showMoreTextClasses}">
72
+ ${If(false, setting?.viewLessText || '', setting?.viewMoreText)}
73
+ </span>
74
+ ${If(setting?.enableViewMoreIcon, template`<span class="${showMoreIconClasses}">${ICON_SVG}</span>`, ' ')}
75
+ </button>`)}`)}
76
+ </gp-product-description-v2>
77
+
78
+ ${renderScript()}
79
+ `));
80
+ };
81
+
82
+ export { ProductDescription as default };
@@ -13,7 +13,7 @@ const ProductTitle = dynamic(()=>import('./components/ProductTitle/index.js'), {
13
13
  const ProductQuantity = dynamic(()=>import('./components/ProductQuantity.js'), {
14
14
  loading: Loading
15
15
  });
16
- const ProductDescription = dynamic(()=>import('./components/ProductDescription.js'), {
16
+ const ProductDescription = dynamic(()=>import('./components/ProductDescription/index.js'), {
17
17
  loading: Loading
18
18
  });
19
19
  const ProductPrice = dynamic(()=>import('./components/ProductPrice.js'), {
@@ -19,7 +19,7 @@ import 'next/image';
19
19
  import 'react-youtube';
20
20
  import imageSetting from './image/setting/index.js';
21
21
  import './image/components/AdaptiveImage.js';
22
- import './cart/components/ShopPayButton/index.js';
22
+ import './cart/components/ShopPayButton/ShopPayButton.js';
23
23
  import collectionSetting from './collection/setting/index.js';
24
24
  import countdownSetting from './countdown-timer/setting/index.js';
25
25
  import headingSetting from './heading/setting/index.js';