@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
@@ -13,7 +13,7 @@ require('../../../ProductVariants/variants/index.js');
13
13
  require('next/image');
14
14
  require('react-youtube');
15
15
  require('../../../../../image/components/AdaptiveImage.js');
16
- require('../../../../../cart/components/ShopPayButton/index.js');
16
+ require('../../../../../cart/components/ShopPayButton/ShopPayButton.js');
17
17
  require('../../../../../countdown-timer/setting/configs/settings.js');
18
18
  require('../../../../../header/components/Header.js');
19
19
  require('../../../../../header/components/kind/basic/index.js');
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const DESCRIPTION_LINE_HEIGHT_DEFAULT = 21;
4
+ 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"
5
+ fill="currentColor"/>
6
+ </svg>`;
7
+
8
+ exports.DESCRIPTION_LINE_HEIGHT_DEFAULT = DESCRIPTION_LINE_HEIGHT_DEFAULT;
9
+ exports.ICON_SVG = ICON_SVG;
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getClasses = ({ setting })=>{
6
+ const appendTypoClass = core.composeTypographyClassName(setting?.typo, setting?.typography);
7
+ const globalColorClass = core.getGlobalColorClass('text', setting?.color);
8
+ return {
9
+ 'gp-relative p-description-wrapper gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre': true,
10
+ ...appendTypoClass && {
11
+ [appendTypoClass]: true
12
+ },
13
+ [globalColorClass]: true,
14
+ "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
15
+ };
16
+ };
17
+ const getButtonClasses = ({ setting })=>{
18
+ const appendTypoClass = core.composeTypographyClassName(setting?.typo, setting?.typography);
19
+ const globalColorClass = core.getGlobalColorClass('text', setting?.showMoreColor);
20
+ return {
21
+ 'p-description-show-more gp-items-center gp-mt-4 gp-w-full gp-transition-all hover:gp-opacity-80': true,
22
+ ...appendTypoClass && {
23
+ [appendTypoClass]: true
24
+ },
25
+ [globalColorClass]: true
26
+ };
27
+ };
28
+
29
+ exports.getButtonClasses = getButtonClasses;
30
+ exports.getClasses = getClasses;
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+ var getMaxHeight = require('./getMaxHeight.js');
5
+
6
+ const devices = [
7
+ 'desktop',
8
+ 'mobile',
9
+ 'tablet'
10
+ ];
11
+ const getDisplayStyle = (fnCondition, defaultValue)=>{
12
+ let result = {};
13
+ devices.forEach((device)=>{
14
+ result = {
15
+ ...result,
16
+ [`--d${device === 'desktop' ? '' : `-${device}`}`]: `${fnCondition(device) ? 'none' : defaultValue}`
17
+ };
18
+ });
19
+ return result;
20
+ };
21
+ const getTextStyle = ({ setting, renderMaxHeight })=>{
22
+ const appendTypoStyle = core.composeTypographyStyle(setting?.typo, setting?.typography);
23
+ const composeStyles = {
24
+ ...core.getStyleShadow({
25
+ value: setting?.typo?.custom?.textShadow,
26
+ styleAppliedFor: 'text-shadow',
27
+ isEnableShadow: setting?.typo?.custom?.textShadow?.type !== 'none'
28
+ }),
29
+ ...core.makeStyleResponsive('ta', setting?.textAlign),
30
+ ...core.getGlobalColorStyle(setting?.color),
31
+ ...core.makeStyle({
32
+ tt: setting?.transform
33
+ }),
34
+ ...appendTypoStyle,
35
+ ...renderMaxHeight && getMaxHeight.getMaxHeightStyleDefault(setting)
36
+ };
37
+ return core.filterTruthyStyles(composeStyles);
38
+ };
39
+ const getButtonStyle = ({ setting })=>{
40
+ const appendTypoStyle = core.composeTypographyStyle(setting?.typo, setting?.typography);
41
+ const getDisplayCollapse = ()=>{
42
+ return getDisplayStyle((device)=>!!setting?.hasLineClamp && setting.hasLineClamp[device] !== undefined && !setting.hasLineClamp[device], 'inline-flex');
43
+ };
44
+ const composeStyles = {
45
+ ...core.makeStyleResponsive('jc', setting?.textAlign),
46
+ ...core.makeStyle({
47
+ tt: setting?.transform
48
+ }),
49
+ ...appendTypoStyle,
50
+ ...core.getGlobalColorStyle(setting?.showMoreColor),
51
+ ...getDisplayCollapse()
52
+ };
53
+ return core.filterTruthyStyles(composeStyles);
54
+ };
55
+ const getStaticCss = ()=>{
56
+ const gpDescriptionCss = `
57
+ .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script) {
58
+ display: inline !important;
59
+ }
60
+ .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script)::after {
61
+ content: "\\A";
62
+ white-space: pre;
63
+ }
64
+ .gp-p-description-text > table {
65
+ box-shadow: none;
66
+ }
67
+ `;
68
+ const textDescriptionCss = `
69
+ .p-description-wrapper.gp-p-description-text * {
70
+ color: inherit;
71
+ line-height: inherit !important;
72
+ }`;
73
+ return {
74
+ gpDescriptionCss,
75
+ textDescriptionCss
76
+ };
77
+ };
78
+
79
+ exports.getButtonStyle = getButtonStyle;
80
+ exports.getStaticCss = getStaticCss;
81
+ exports.getTextStyle = getTextStyle;
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var _const = require('../common/const.js');
5
+ var core = require('@gem-sdk/core');
6
+
7
+ const useGpDescription = (setting)=>{
8
+ const ref = React.useRef(null);
9
+ const [open, setOpen] = React.useState(false);
10
+ const [isShowViewMore, setIsShowViewMore] = React.useState(false);
11
+ const product = core.useProduct();
12
+ const currentDevice = core.useCurrentDevice();
13
+ const hasLineClamp = core.getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
14
+ const lineClamp = core.getResponsiveValueByScreen(setting?.lineClamp, currentDevice);
15
+ const { redirectProductShopifyLink } = core.useProductShopifyEditLink();
16
+ const mode = core.useEditorMode();
17
+ const getLineHeightFromDom = React.useCallback(()=>{
18
+ if (!ref.current) return _const.DESCRIPTION_LINE_HEIGHT_DEFAULT;
19
+ const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
20
+ return Math.ceil(parseFloat(lineHeight));
21
+ }, []);
22
+ const getMaxHeight = React.useCallback((lineHeight)=>{
23
+ if (!hasLineClamp || !lineClamp) return 'auto';
24
+ if (lineHeight) return `${lineClamp * lineHeight}px`;
25
+ return 'auto';
26
+ }, [
27
+ hasLineClamp,
28
+ lineClamp
29
+ ]);
30
+ const handleToggleShowMore = ()=>{
31
+ if (!ref.current) return;
32
+ const lineHeight = getLineHeightFromDom();
33
+ if (open) {
34
+ ref.current.style.maxHeight = getMaxHeight(lineHeight);
35
+ } else {
36
+ ref.current.style.maxHeight = 'none';
37
+ }
38
+ setOpen((prev)=>!prev);
39
+ };
40
+ React.useEffect(()=>{
41
+ const lineHeight = getLineHeightFromDom();
42
+ getMaxHeight(lineHeight);
43
+ }, [
44
+ setting?.typo?.custom,
45
+ getMaxHeight,
46
+ getLineHeightFromDom
47
+ ]);
48
+ React.useEffect(()=>{
49
+ const dom = ref.current;
50
+ setOpen(false);
51
+ if (!dom) return;
52
+ const enableShowMore = hasLineClamp && product?.descriptionHtml;
53
+ if (!enableShowMore) dom.style.maxHeight = 'none';
54
+ else {
55
+ const value = lineClamp;
56
+ setTimeout(()=>{
57
+ const scrollHeight = dom?.scrollHeight ?? 0;
58
+ const clientHeight = dom?.clientHeight ?? 0;
59
+ const lineHeight = getLineHeightFromDom();
60
+ const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
61
+ dom.style.maxHeight = getMaxHeight(lineHeight);
62
+ const conditionCheckLine = value && value < lineText || clientHeight < scrollHeight;
63
+ if (value && conditionCheckLine) {
64
+ setIsShowViewMore(()=>true);
65
+ } else {
66
+ setIsShowViewMore(()=>false);
67
+ }
68
+ }, 100);
69
+ }
70
+ }, [
71
+ hasLineClamp,
72
+ lineClamp,
73
+ product?.description,
74
+ product?.descriptionHtml,
75
+ getLineHeightFromDom,
76
+ getMaxHeight,
77
+ setOpen,
78
+ setIsShowViewMore
79
+ ]);
80
+ return {
81
+ ref,
82
+ open,
83
+ isShowViewMore,
84
+ handleToggleShowMore,
85
+ mode,
86
+ redirectProductShopifyLink
87
+ };
88
+ };
89
+
90
+ exports.useGpDescription = useGpDescription;
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var core = require('@gem-sdk/core');
8
+ var NoDataState = require('../../../common/components/NoDataState.js');
9
+ var _const = require('./common/const.js');
10
+ var system = require('@gem-sdk/system');
11
+ var getClasses = require('./common/getClasses.js');
12
+ var getStyle = require('./common/getStyle.js');
13
+ var useGpDescription = require('./hooks/useGpDescription.js');
14
+
15
+ const ProductDescription = (props)=>{
16
+ const { setting, advanced, builderProps } = props;
17
+ const { htmlTag } = setting ?? {};
18
+ const Tag = htmlTag === 'html' ? 'div' : 'p';
19
+ const product = core.useProduct();
20
+ const currentDevice = core.useCurrentDevice();
21
+ const hasLineClamp = core.getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
22
+ const { ref, open, isShowViewMore, handleToggleShowMore, mode, redirectProductShopifyLink } = useGpDescription.useGpDescription(setting);
23
+ const gpDescriptionClasses = system.createClass({
24
+ 'gp-product-description': true,
25
+ [advanced?.cssClass]: true
26
+ });
27
+ const textClasses = system.createClass(getClasses.getClasses({
28
+ setting
29
+ }));
30
+ const buttonClasses = system.createClass(getClasses.getButtonClasses({
31
+ setting
32
+ }));
33
+ const showMoreTextClasses = system.createClass({
34
+ 'gp-show-more-text': true
35
+ });
36
+ const showMoreIconClasses = system.createClass({
37
+ 'gp-show-more-icon gp-ml-1': true,
38
+ ...open ? {
39
+ 'gp-rotate-180': true
40
+ } : {}
41
+ });
42
+ const textStyle = system.createStyle({
43
+ ...getStyle.getTextStyle({
44
+ setting
45
+ }),
46
+ ...!open ? core.makeStyleResponsive('line-clamp', core.makeLineClamp(setting?.lineClamp, setting?.hasLineClamp)) : {}
47
+ });
48
+ const buttonStyle = system.createStyle(getStyle.getButtonStyle({
49
+ setting
50
+ }));
51
+ const attr = system.createAttr({
52
+ 'data-id': `${builderProps?.uid}`
53
+ });
54
+ const textAttr = system.createAttr({
55
+ 'data-gp-text': ''
56
+ });
57
+ const { gpDescriptionCss, textDescriptionCss } = getStyle.getStaticCss();
58
+ const noDescriptionHtml = !product?.descriptionHtml;
59
+ if (noDescriptionHtml && mode === 'edit') {
60
+ return /*#__PURE__*/ jsxRuntime.jsx(NoDataState.default, {
61
+ elementType: "secondary",
62
+ description: "Highlight key benefits with product description.",
63
+ descriptionActions: [
64
+ {
65
+ text: 'Add description',
66
+ callback: redirectProductShopifyLink
67
+ },
68
+ {
69
+ text: 'sync data',
70
+ callback: 'syncProduct'
71
+ }
72
+ ]
73
+ });
74
+ }
75
+ return system.If(noDescriptionHtml, '', /*#__PURE__*/ jsxRuntime.jsxs("div", {
76
+ ...attr,
77
+ className: gpDescriptionClasses,
78
+ children: [
79
+ /*#__PURE__*/ jsxRuntime.jsx("style", {
80
+ children: textDescriptionCss
81
+ }),
82
+ system.If(!core.isSafari(), /*#__PURE__*/ jsxRuntime.jsx("style", {
83
+ children: gpDescriptionCss
84
+ }), ' '),
85
+ /*#__PURE__*/ jsxRuntime.jsx(Tag, {
86
+ ref: ref,
87
+ ...textAttr,
88
+ className: textClasses,
89
+ style: textStyle,
90
+ dangerouslySetInnerHTML: {
91
+ __html: product?.descriptionHtml || ''
92
+ }
93
+ }),
94
+ system.If(hasLineClamp && isShowViewMore, /*#__PURE__*/ jsxRuntime.jsxs("button", {
95
+ className: buttonClasses,
96
+ style: buttonStyle,
97
+ onClick: handleToggleShowMore,
98
+ children: [
99
+ /*#__PURE__*/ jsxRuntime.jsx("span", {
100
+ className: showMoreTextClasses,
101
+ children: system.If(open, setting?.viewLessText || '', setting?.viewMoreText)
102
+ }),
103
+ system.If(setting?.enableViewMoreIcon, /*#__PURE__*/ jsxRuntime.jsx("span", {
104
+ className: showMoreIconClasses,
105
+ dangerouslySetInnerHTML: {
106
+ __html: _const.ICON_SVG
107
+ }
108
+ }))
109
+ ]
110
+ }), ' ')
111
+ ]
112
+ }));
113
+ };
114
+
115
+ exports.default = ProductDescription;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@gem-sdk/core');
6
+ var helpers = require('../../../helpers.js');
7
+ var system = require('@gem-sdk/system');
8
+ var getClasses = require('./common/getClasses.js');
9
+ var getStyle = require('./common/getStyle.js');
10
+ var _const = require('./common/const.js');
11
+
12
+ const ProductDescription = (props)=>{
13
+ const { setting, advanced, builderProps } = props;
14
+ const { htmlTag } = setting ?? {};
15
+ const Tag = htmlTag === 'html' ? 'div' : 'p';
16
+ const gpDescriptionClasses = system.createClass({
17
+ 'gp-product-description': true,
18
+ [advanced?.cssClass]: true
19
+ });
20
+ const textClasses = system.createClass(getClasses.getClasses({
21
+ setting
22
+ }));
23
+ const buttonClasses = system.createClass(getClasses.getButtonClasses({
24
+ setting
25
+ }));
26
+ const showMoreTextClasses = system.createClass({
27
+ 'gp-show-more-text': true
28
+ });
29
+ const showMoreIconClasses = system.createClass({
30
+ 'gp-show-more-icon gp-ml-1': true
31
+ });
32
+ const textStyle = system.createStyle({
33
+ ...getStyle.getTextStyle({
34
+ setting,
35
+ renderMaxHeight: true
36
+ }),
37
+ ...core.makeStyleResponsive('line-clamp', core.makeLineClamp(setting?.lineClamp, setting?.hasLineClamp))
38
+ });
39
+ const buttonStyle = system.createStyle(getStyle.getButtonStyle({
40
+ setting
41
+ }));
42
+ const attr = system.createAttr({
43
+ 'data-id': `${builderProps?.uid}`
44
+ });
45
+ const textAttr = system.createAttr({
46
+ 'data-gp-text': ''
47
+ });
48
+ const { gpDescriptionCss, textDescriptionCss } = getStyle.getStaticCss();
49
+ const noDescriptionHtml = 'product.description == blank';
50
+ const renderScript = ()=>{
51
+ const jsURL = core.isLocalEnv ? `{{ 'gp-product-description-v2.js' | asset_url }}` : `${core.baseAssetURL}/assets-v2/gp-product-description-v2.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;
52
+ return `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${jsURL}" defer="defer"></script>`;
53
+ };
54
+ const stateData = system.createStateOrContext({
55
+ setting: {
56
+ lineClamp: setting?.lineClamp,
57
+ hasLineClamp: setting?.hasLineClamp,
58
+ viewMoreText: setting?.viewMoreText,
59
+ viewLessText: setting?.viewLessText,
60
+ enableViewMoreIcon: setting?.enableViewMoreIcon
61
+ },
62
+ textStyle
63
+ });
64
+ return system.LiquidIf(noDescriptionHtml, '', system.Liquid(core.template`
65
+ <gp-product-description-v2
66
+ ${attr}
67
+ class="${gpDescriptionClasses}"
68
+ gp-data='${core.dataStringify(stateData).replaceAll("'", '&#039;')}'>
69
+ <style>${textDescriptionCss}</style>
70
+ ${system.If(!core.isSafari(), `<style>${gpDescriptionCss}</style>`, ' ')}
71
+ ${system.LiquidUnless('product', `<p>Product not found</p>`, core.template`<${Tag} ${textAttr} class="${textClasses}" style="${textStyle}">
72
+ {{product.description}}
73
+ </${Tag}>
74
+ ${system.LiquidUnless(noDescriptionHtml, core.template`<button type="button" class="${buttonClasses}" style="${buttonStyle}">
75
+ <span class="${showMoreTextClasses}">
76
+ ${system.If(false, setting?.viewLessText || '', setting?.viewMoreText)}
77
+ </span>
78
+ ${system.If(setting?.enableViewMoreIcon, core.template`<span class="${showMoreIconClasses}">${_const.ICON_SVG}</span>`, ' ')}
79
+ </button>`)}`)}
80
+ </gp-product-description-v2>
81
+
82
+ ${renderScript()}
83
+ `));
84
+ };
85
+
86
+ exports.default = ProductDescription;
@@ -17,7 +17,7 @@ const ProductTitle = dynamic(()=>Promise.resolve().then(function () { return req
17
17
  const ProductQuantity = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductQuantity.js'); }), {
18
18
  loading: Loading.default
19
19
  });
20
- const ProductDescription = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductDescription.js'); }), {
20
+ const ProductDescription = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductDescription/index.js'); }), {
21
21
  loading: Loading.default
22
22
  });
23
23
  const ProductPrice = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductPrice.js'); }), {
@@ -23,7 +23,7 @@ require('next/image');
23
23
  require('react-youtube');
24
24
  var index$c = require('./image/setting/index.js');
25
25
  require('./image/components/AdaptiveImage.js');
26
- require('./cart/components/ShopPayButton/index.js');
26
+ require('./cart/components/ShopPayButton/ShopPayButton.js');
27
27
  var index$6 = require('./collection/setting/index.js');
28
28
  var index$7 = require('./countdown-timer/setting/index.js');
29
29
  var index$9 = require('./heading/setting/index.js');
@@ -27,11 +27,6 @@ const ArticleImage = ({ className, setting = {}, styles = {}, advanced, builderP
27
27
  ...setting,
28
28
  alt: image.alt,
29
29
  image,
30
- srcSet: {
31
- desktop: {
32
- src: image.src ?? ''
33
- }
34
- },
35
30
  disableNoDataState: true
36
31
  },
37
32
  styles: styles,
@@ -11,7 +11,7 @@ const ArticleList = ({ styles, setting, className, children, builderProps })=>{
11
11
  const { articleSetting, numberOfArticle } = setting ?? {};
12
12
  const { articleIds, articlePickType } = articleSetting ?? {};
13
13
  const articlesQuery = {
14
- first: 10,
14
+ first: articleIds?.length ?? 50,
15
15
  where: {
16
16
  baseIDIn: [
17
17
  ...articleSetting?.articleIds ?? []
@@ -19,7 +19,7 @@ import { DEVICES, getImageSrc } from '../../image/helpers/getSrcSet.js';
19
19
  import { getYoutubeVideoId, youtubeVideoRegex } from '../../video/helpers/common.js';
20
20
  import 'react-youtube';
21
21
  import '../../image/components/AdaptiveImage.js';
22
- import '../../cart/components/ShopPayButton/index.js';
22
+ import '../../cart/components/ShopPayButton/ShopPayButton.js';
23
23
  import '../../countdown-timer/setting/configs/settings.js';
24
24
  import '../../header/components/Header.js';
25
25
  import '../../header/components/kind/basic/index.js';
@@ -136,7 +136,7 @@ import CartDiscount from './cart/components/CartDiscount.js';
136
136
  import CartOrderNote from './cart/components/CartOrderNote.js';
137
137
  import CartLineAttribute from './cart/components/CartLineAttribute.js';
138
138
  import CouponList from './cart/components/CouponList.js';
139
- import ShopPayButton from './cart/components/ShopPayButton/index.js';
139
+ import ShopPayButton from './cart/components/ShopPayButton/ShopPayButton.js';
140
140
  import CheckoutNow from './cart/components/CheckoutNow.js';
141
141
  import CollectionTitle from './collection/components/CollectionTitle.js';
142
142
  import CollectionBanner from './collection/components/CollectionBanner.js';
@@ -180,7 +180,7 @@ import PostPurchaseProductVariants from './post-purchase/product/components/prod
180
180
  import Product from './product/components/Product.js';
181
181
  import ProductTitle from './product/components/ProductTitle/index.js';
182
182
  import ProductQuantity from './product/components/ProductQuantity.js';
183
- import ProductDescription from './product/components/ProductDescription.js';
183
+ import ProductDescription from './product/components/ProductDescription/index.js';
184
184
  import ProductPrice from './product/components/ProductPrice.js';
185
185
  import ProductButton from './product/components/ProductButton.js';
186
186
  import ProductVariants from './product/components/ProductVariants/index.js';
@@ -190,7 +190,7 @@ import ProductProperties from './product/components/ProductProperties.js';
190
190
  import QuickView from './product/components/ProductQuickView/index.js';
191
191
  import ProductTag from './product/components/ProductTag.js';
192
192
  import ProductList from './product/components/ProductList.js';
193
- import DynamicCheckout from './product/components/DynamicCheckout.js';
193
+ import DynamicCheckout from './product/components/DynamicCheckout/DynamicCheckout.js';
194
194
  import ProductBundleDiscount from './product/components/ProductBundleDiscount.js';
195
195
  import ProductBundleDiscountItem from './product/components/ProductBundleDiscountItem.js';
196
196
  import ProductVendor from './product/components/Vendor.js';
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { createStyle, createClass, createAttr } from '@gem-sdk/system';
4
+ import dynamic from 'next/dynamic';
5
+ import { getButtonClasses, getButtonWrapperClasses } from './common/classes.js';
6
+ import { getSPButton } from './common/helpers.js';
7
+ import { getButtonWrapperStyles } from './common/styles.js';
8
+ import { useShopPayButton } from './hooks/useShopPayButton.js';
9
+
10
+ const DynamicCheckoutBlack = dynamic(()=>import('./icons/DynamicCheckoutBlack.js'));
11
+ const DynamicCheckoutPurple = dynamic(()=>import('./icons/DynamicCheckoutPurple.js'));
12
+ const DynamicCheckoutWhite = dynamic(()=>import('./icons/DynamicCheckoutWhite.js'));
13
+ const ExpressCheckoutBlack = dynamic(()=>import('./icons/ExpressCheckoutBlack.js'));
14
+ const ExpressCheckoutPurple = dynamic(()=>import('./icons/ExpressCheckoutPurple.js'));
15
+ const ExpressCheckoutWhite = dynamic(()=>import('./icons/ExpressCheckoutWhite.js'));
16
+ /**
17
+ * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
18
+ */ const ShopPayButton = ({ style, styles, setting, className, builderAttrs })=>{
19
+ const { variants, storeUrl, handleOnPay } = useShopPayButton(setting);
20
+ if (!storeUrl) {
21
+ return /*#__PURE__*/ jsx("div", {
22
+ ...builderAttrs,
23
+ children: "URL Not Found"
24
+ });
25
+ }
26
+ const SPButton = getSPButton({
27
+ styles,
28
+ buttons: {
29
+ DynamicCheckoutBlack,
30
+ DynamicCheckoutPurple,
31
+ DynamicCheckoutWhite,
32
+ ExpressCheckoutBlack,
33
+ ExpressCheckoutPurple,
34
+ ExpressCheckoutWhite
35
+ }
36
+ });
37
+ const buttonWrapperStyles = createStyle({
38
+ ...getButtonWrapperStyles(style, styles)
39
+ });
40
+ const buttonClasses = createClass({
41
+ ...getButtonClasses()
42
+ });
43
+ const buttonWrapperClasses = createClass({
44
+ ...getButtonWrapperClasses(className)
45
+ });
46
+ const buttonAttributes = createAttr({
47
+ disabled: !variants?.length,
48
+ 'aria-label': 'Buy with Shop Pay'
49
+ });
50
+ return /*#__PURE__*/ jsx("div", {
51
+ ...builderAttrs,
52
+ style: buttonWrapperStyles,
53
+ className: buttonWrapperClasses,
54
+ children: /*#__PURE__*/ jsx("button", {
55
+ ...buttonAttributes,
56
+ className: buttonClasses,
57
+ onClick: ()=>handleOnPay({
58
+ inputWidth: 600,
59
+ inputHeight: 600
60
+ }),
61
+ children: /*#__PURE__*/ jsx(SPButton, {})
62
+ })
63
+ });
64
+ };
65
+
66
+ export { ShopPayButton as default };
@@ -0,0 +1,67 @@
1
+ import { template, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { createStyle, createClass, createAttr, createStateOrContext, If } from '@gem-sdk/system';
3
+ import { getSettingPreloadData } from '../../../helpers.js';
4
+ import { getButtonClasses, getButtonWrapperClasses } from './common/classes.js';
5
+ import { getSPButton } from './common/helpers.js';
6
+ import { getButtonWrapperStyles } from './common/styles.js';
7
+ import DynamicCheckoutBlack from './icons/DynamicCheckoutBlack.liquid.js';
8
+ import DynamicCheckoutPurple from './icons/DynamicCheckoutPurple.liquid.js';
9
+ import DynamicCheckoutWhite from './icons/DynamicCheckoutWhite.liquid.js';
10
+ import ExpressCheckoutBlack from './icons/ExpressCheckoutBlack.liquid.js';
11
+ import ExpressCheckoutPurple from './icons/ExpressCheckoutPurple.liquid.js';
12
+ import ExpressCheckoutWhite from './icons/ExpressCheckoutWhite.liquid.js';
13
+
14
+ /**
15
+ * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
16
+ */ const ShopPayButton = ({ style, styles, setting, className, builderAttrs })=>{
17
+ const SPButton = getSPButton({
18
+ styles,
19
+ buttons: {
20
+ DynamicCheckoutBlack: DynamicCheckoutBlack({}),
21
+ DynamicCheckoutPurple: DynamicCheckoutPurple({}),
22
+ DynamicCheckoutWhite: DynamicCheckoutWhite({}),
23
+ ExpressCheckoutBlack: ExpressCheckoutBlack({}),
24
+ ExpressCheckoutPurple: ExpressCheckoutPurple({}),
25
+ ExpressCheckoutWhite: ExpressCheckoutWhite({})
26
+ }
27
+ });
28
+ const buttonWrapperStyles = createStyle({
29
+ ...getButtonWrapperStyles(style, styles)
30
+ });
31
+ const buttonClasses = createClass({
32
+ ...getButtonClasses()
33
+ });
34
+ const buttonWrapperClasses = createClass({
35
+ ...getButtonWrapperClasses(className)
36
+ });
37
+ const buttonAttributes = createAttr({
38
+ disabled: false,
39
+ 'aria-label': 'Buy with Shop Pay'
40
+ });
41
+ const buttonState = createStateOrContext({
42
+ setting: JSON.stringify(setting),
43
+ shop_url: '{{shop.url}}'
44
+ });
45
+ return template`
46
+ <gp-shop-pay-button
47
+ ${{
48
+ ...builderAttrs
49
+ }}
50
+ style="${buttonWrapperStyles}"
51
+ class="${buttonWrapperClasses}"
52
+ gp-data='${buttonState}'
53
+ >
54
+ <button
55
+ ${{
56
+ ...buttonAttributes
57
+ }}
58
+ class="${buttonClasses}"
59
+ >
60
+ ${SPButton}
61
+ </button>
62
+ </gp-shop-pay-button>
63
+ ${If(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-shop-pay-button.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-shop-pay-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
64
+ `;
65
+ };
66
+
67
+ export { ShopPayButton as default };
@@ -0,0 +1,15 @@
1
+ const getButtonWrapperClasses = (className)=>{
2
+ return {
3
+ ...className && {
4
+ [className]: true
5
+ },
6
+ 'gp-flex': true
7
+ };
8
+ };
9
+ const getButtonClasses = ()=>{
10
+ return {
11
+ 'disabled:gp-cursor-not-allowed disabled:gp-opacity-50 gp-shop-button': true
12
+ };
13
+ };
14
+
15
+ export { getButtonClasses, getButtonWrapperClasses };