@gem-sdk/components 2.0.0-dev.274 → 2.0.0-dev.277

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 (148) hide show
  1. package/dist/cjs/article/components/ArticleReadMore.js +2 -4
  2. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +5 -5
  3. package/dist/cjs/builder.js +17 -21
  4. package/dist/cjs/button/components/Button.js +111 -184
  5. package/dist/cjs/button/components/Button.liquid.js +108 -171
  6. package/dist/cjs/button/components/ButtonIcon.js +17 -0
  7. package/dist/cjs/button/components/ButtonIcon.liquid.js +16 -0
  8. package/dist/cjs/button/components/ButtonLabel.js +18 -0
  9. package/dist/cjs/button/components/ButtonLabel.liquid.js +15 -0
  10. package/dist/cjs/button/components/ButtonLoadingIndicator.liquid.js +12 -0
  11. package/dist/cjs/button/components/common/attributes.js +15 -0
  12. package/dist/cjs/button/components/common/classes.js +55 -0
  13. package/dist/cjs/button/components/common/constants.js +26 -0
  14. package/dist/cjs/button/components/common/data.js +76 -0
  15. package/dist/cjs/button/components/common/helpers.js +131 -0
  16. package/dist/cjs/button/components/common/styles.js +157 -0
  17. package/dist/cjs/button/next.js +2 -6
  18. package/dist/cjs/button/setting/configs/settings.js +5 -1
  19. package/dist/cjs/cart/components/CheckoutNow.js +0 -2
  20. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.js +70 -0
  21. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.liquid.js +71 -0
  22. package/dist/cjs/cart/components/ShopPayButton/common/classes.js +18 -0
  23. package/dist/cjs/cart/components/ShopPayButton/common/helpers.js +31 -0
  24. package/dist/cjs/cart/components/ShopPayButton/common/styles.js +12 -0
  25. package/dist/cjs/cart/components/ShopPayButton/hooks/useShopPayButton.js +70 -0
  26. package/dist/cjs/cart/next.js +1 -1
  27. package/dist/cjs/coupon/components/Coupon.js +1 -3
  28. package/dist/cjs/dialog/setting/Dialog.js +7 -580
  29. package/dist/cjs/dialog/setting/configs/settings.js +325 -0
  30. package/dist/cjs/dialog/setting/configs/uiV1.js +288 -0
  31. package/dist/cjs/dialog/setting/configs/uiV2.js +258 -0
  32. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +4 -4
  33. package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
  34. package/dist/cjs/header/components/kind/basic/index.js +1 -1
  35. package/dist/cjs/header/components/kind/modern/index.js +1 -1
  36. package/dist/cjs/index.js +41 -43
  37. package/dist/cjs/index.liquid.js +10 -12
  38. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +25 -0
  39. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.liquid.js +23 -0
  40. package/dist/cjs/product/components/DynamicCheckout/common/classes.js +32 -0
  41. package/dist/cjs/product/components/DynamicCheckout/common/styles.js +181 -0
  42. package/dist/cjs/product/components/DynamicCheckout/components/Button.liquid.js +58 -0
  43. package/dist/cjs/product/components/DynamicCheckout.js +2 -5
  44. package/dist/cjs/product/components/FileUpload/components/common/index.js +2 -2
  45. package/dist/cjs/product/components/ProductButton.js +2 -3
  46. package/dist/cjs/product/components/ProductButton.liquid.js +3 -3
  47. package/dist/cjs/product/components/ProductDescription/common/const.js +9 -0
  48. package/dist/cjs/product/components/ProductDescription/common/getClasses.js +30 -0
  49. package/dist/cjs/product/components/ProductDescription/common/getStyle.js +81 -0
  50. package/dist/cjs/product/components/ProductDescription/hooks/useGpDescription.js +90 -0
  51. package/dist/cjs/product/components/ProductDescription/index.js +115 -0
  52. package/dist/cjs/product/components/ProductDescription/index.liquid.js +85 -0
  53. package/dist/cjs/product/components/ProductViewMore.js +2 -5
  54. package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
  55. package/dist/cjs/product/next.js +1 -1
  56. package/dist/cjs/setting.js +3 -3
  57. package/dist/cjs/text/components/common/getClasses.js +1 -1
  58. package/dist/cjs/third-party/components/PushOwl.js +0 -5
  59. package/dist/esm/article/components/ArticleReadMore.js +1 -3
  60. package/dist/esm/banner/components/HeroBannerItem.liquid.js +5 -5
  61. package/dist/esm/builder.js +4 -8
  62. package/dist/esm/button/components/Button.js +113 -186
  63. package/dist/esm/button/components/Button.liquid.js +109 -172
  64. package/dist/esm/button/components/ButtonIcon.js +13 -0
  65. package/dist/esm/button/components/ButtonIcon.liquid.js +12 -0
  66. package/dist/esm/button/components/ButtonLabel.js +14 -0
  67. package/dist/esm/button/components/ButtonLabel.liquid.js +11 -0
  68. package/dist/esm/button/components/ButtonLoadingIndicator.liquid.js +8 -0
  69. package/dist/esm/button/components/common/attributes.js +13 -0
  70. package/dist/esm/button/components/common/classes.js +49 -0
  71. package/dist/esm/button/components/common/constants.js +24 -0
  72. package/dist/esm/button/components/common/data.js +74 -0
  73. package/dist/esm/button/components/common/helpers.js +118 -0
  74. package/dist/esm/button/components/common/styles.js +148 -0
  75. package/dist/esm/button/next.js +2 -6
  76. package/dist/esm/button/setting/configs/settings.js +5 -1
  77. package/dist/esm/cart/components/CheckoutNow.js +0 -2
  78. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.js +66 -0
  79. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.liquid.js +67 -0
  80. package/dist/esm/cart/components/ShopPayButton/common/classes.js +15 -0
  81. package/dist/esm/cart/components/ShopPayButton/common/helpers.js +27 -0
  82. package/dist/esm/cart/components/ShopPayButton/common/styles.js +10 -0
  83. package/dist/esm/cart/components/ShopPayButton/hooks/useShopPayButton.js +68 -0
  84. package/dist/esm/cart/next.js +1 -1
  85. package/dist/esm/coupon/components/Coupon.js +1 -3
  86. package/dist/esm/dialog/setting/Dialog.js +7 -580
  87. package/dist/esm/dialog/setting/configs/settings.js +323 -0
  88. package/dist/esm/dialog/setting/configs/uiV1.js +286 -0
  89. package/dist/esm/dialog/setting/configs/uiV2.js +256 -0
  90. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +4 -4
  91. package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
  92. package/dist/esm/header/components/kind/basic/index.js +1 -1
  93. package/dist/esm/header/components/kind/modern/index.js +1 -1
  94. package/dist/esm/index.js +4 -5
  95. package/dist/esm/index.liquid.js +4 -5
  96. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +21 -0
  97. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.liquid.js +19 -0
  98. package/dist/esm/product/components/DynamicCheckout/common/classes.js +30 -0
  99. package/dist/esm/product/components/DynamicCheckout/common/styles.js +179 -0
  100. package/dist/esm/product/components/DynamicCheckout/components/Button.liquid.js +54 -0
  101. package/dist/esm/product/components/DynamicCheckout.js +1 -4
  102. package/dist/esm/product/components/FileUpload/components/common/index.js +2 -2
  103. package/dist/esm/product/components/ProductButton.js +1 -2
  104. package/dist/esm/product/components/ProductButton.liquid.js +1 -1
  105. package/dist/esm/product/components/ProductDescription/common/const.js +6 -0
  106. package/dist/esm/product/components/ProductDescription/common/getClasses.js +27 -0
  107. package/dist/esm/product/components/ProductDescription/common/getStyle.js +77 -0
  108. package/dist/esm/product/components/ProductDescription/hooks/useGpDescription.js +88 -0
  109. package/dist/esm/product/components/ProductDescription/index.js +111 -0
  110. package/dist/esm/product/components/ProductDescription/index.liquid.js +81 -0
  111. package/dist/esm/product/components/ProductViewMore.js +1 -4
  112. package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
  113. package/dist/esm/product/next.js +1 -1
  114. package/dist/esm/setting.js +3 -3
  115. package/dist/esm/text/components/common/getClasses.js +1 -1
  116. package/dist/esm/third-party/components/PushOwl.js +0 -5
  117. package/dist/types/index.d.ts +200 -360
  118. package/package.json +2 -2
  119. package/dist/cjs/button/components/v2/ButtonIcon.js +0 -18
  120. package/dist/cjs/button/components/v2/ButtonLabel.js +0 -25
  121. package/dist/cjs/button/components/v2/ButtonV2.js +0 -140
  122. package/dist/cjs/button/components/v2/ButtonV2.liquid.js +0 -181
  123. package/dist/cjs/button/hooks/useButtonCustomCss.js +0 -88
  124. package/dist/cjs/button/hooks/useButtonStyles.js +0 -93
  125. package/dist/cjs/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -20
  126. package/dist/cjs/cart/components/ShopPayButton/index.js +0 -113
  127. package/dist/cjs/cart/components/ShopPayButton/index.liquid.js +0 -51
  128. package/dist/cjs/product/components/DynamicCheckout.liquid.js +0 -250
  129. package/dist/cjs/product/components/ProductDescription/const.js +0 -5
  130. package/dist/cjs/product/components/ProductDescription.js +0 -172
  131. package/dist/cjs/product/components/ProductDescription.liquid.js +0 -120
  132. package/dist/esm/button/components/v2/ButtonIcon.js +0 -14
  133. package/dist/esm/button/components/v2/ButtonLabel.js +0 -21
  134. package/dist/esm/button/components/v2/ButtonV2.js +0 -136
  135. package/dist/esm/button/components/v2/ButtonV2.liquid.js +0 -177
  136. package/dist/esm/button/hooks/useButtonCustomCss.js +0 -84
  137. package/dist/esm/button/hooks/useButtonStyles.js +0 -91
  138. package/dist/esm/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -17
  139. package/dist/esm/cart/components/ShopPayButton/index.js +0 -109
  140. package/dist/esm/cart/components/ShopPayButton/index.liquid.js +0 -47
  141. package/dist/esm/product/components/DynamicCheckout.liquid.js +0 -246
  142. package/dist/esm/product/components/ProductDescription/const.js +0 -3
  143. package/dist/esm/product/components/ProductDescription.js +0 -168
  144. package/dist/esm/product/components/ProductDescription.liquid.js +0 -116
  145. /package/dist/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  146. /package/dist/cjs/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
  147. /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  148. /package/dist/esm/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
@@ -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 };
@@ -1,9 +1,6 @@
1
1
  'use client';
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
- import Button from '../../button/components/v2/ButtonV2.js';
4
- import '@gem-sdk/core';
5
- import 'next/link';
6
- import 'react';
3
+ import Button from '../../button/components/Button.js';
7
4
 
8
5
  const DynamicCheckout = ({ builderProps, builderAttrs, style, styles, advanced, setting })=>{
9
6
  const { ...buttonStyles } = styles ?? {};
@@ -4,14 +4,14 @@ import 'react';
4
4
  import '@gem-sdk/core';
5
5
  import '@gem-sdk/system';
6
6
  import { getDynamicSourceLocales } from '../../../../../helpers.js';
7
- import 'next/head';
8
7
  import 'next/link';
9
8
  import '@gem-sdk/keen-slider/react';
10
9
  import '../../../ProductVariants/variants/index.js';
10
+ import 'next/head';
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';
@@ -2,8 +2,7 @@
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { useStoreFront, useCurrency, useEditorMode, useCartId, useCartUI, useInteraction, useCreateCart, useAddToCart, useCurrentVariant, useQuantity, useProduct, useProductProperties, useProductStore, useHasPreSelected, useCurrentVariantInStock, getGlobalColorStateStyle, makeStyle, cls } from '@gem-sdk/core';
4
4
  import { useCallback, useMemo } from 'react';
5
- import Button from '../../button/components/v2/ButtonV2.js';
6
- import 'next/link';
5
+ import Button from '../../button/components/Button.js';
7
6
  import useNotification from '../../notification/hooks/use-notification.js';
8
7
  import '../../notification/components/Notice.js';
9
8
  import Text from '../../text/components/Text.js';
@@ -1,6 +1,6 @@
1
1
  import { splitStyle, template, makeStyleResponsive, RenderIf, isLocalEnv, baseAssetURL, makeStyle } from '@gem-sdk/core';
2
+ import Button from '../../button/components/Button.liquid.js';
2
3
  import { getInsertLinkData, getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
3
- import Button from '../../button/components/v2/ButtonV2.liquid.js';
4
4
  import { ProductPrice } from './ProductPrice.liquid.js';
5
5
 
6
6
  const NODE_PRICE_EMPTY = null;
@@ -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,81 @@
1
+ import { makeStyleResponsive, makeLineClamp, template, dataStringify, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { getSettingPreloadData } from '../../../helpers.js';
3
+ import { createClass, createStyle, createAttr, createStateOrContext, LiquidIf, Liquid, LiquidUnless, If } 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 { 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
+ ${LiquidUnless('product', `<p>Product not found</p>`, template`<${Tag} ${textAttr} class="${textClasses}" style="${textStyle}">
67
+ {{product.description}}
68
+ </${Tag}>
69
+ ${LiquidUnless(noDescriptionHtml, template`<button type="button" class="${buttonClasses}" style="${buttonStyle}">
70
+ <span class="${showMoreTextClasses}">
71
+ ${If(false, setting?.viewLessText || '', setting?.viewMoreText)}
72
+ </span>
73
+ ${If(setting?.enableViewMoreIcon, template`<span class="${showMoreIconClasses}">${ICON_SVG}</span>`, ' ')}
74
+ </button>`)}`)}
75
+ </gp-product-description-v2>
76
+
77
+ ${renderScript()}
78
+ `));
79
+ };
80
+
81
+ export { ProductDescription as default };
@@ -1,9 +1,6 @@
1
1
  'use client';
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
- import Button from '../../button/components/v2/ButtonV2.js';
4
- import '@gem-sdk/core';
5
- import 'next/link';
6
- import 'react';
3
+ import Button from '../../button/components/Button.js';
7
4
 
8
5
  const ProductViewMore = ({ setting, builderProps, builderAttrs, style, styles, advanced, children })=>{
9
6
  const { ...buttonStyles } = styles ?? {};
@@ -1,6 +1,6 @@
1
1
  import { template, makeStyleResponsive, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import Button from '../../button/components/Button.liquid.js';
2
3
  import { getSettingPreloadData } from '../../helpers.js';
3
- import Button from '../../button/components/v2/ButtonV2.liquid.js';
4
4
 
5
5
  const ProductViewMore = ({ setting, builderProps, builderAttrs, style, styles, advanced, pageContext })=>{
6
6
  const { ...buttonStyles } = styles ?? {};
@@ -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'), {
@@ -5,21 +5,21 @@ import '@gem-sdk/core';
5
5
  import textSetting from './text/setting/index.js';
6
6
  import '@gem-sdk/system';
7
7
  import breadcrumbSetting from './breadcrumb/setting/index.js';
8
- import buttonSetting from './button/setting/index.js';
9
- import 'next/head';
10
8
  import linkSetting from './link/setting/index.js';
11
9
  import 'next/link';
10
+ import buttonSetting from './button/setting/index.js';
12
11
  import couponSetting from './coupon/setting/index.js';
13
12
  import carouselSetting from './carousel/setting/index.js';
14
13
  import '@gem-sdk/keen-slider/react';
15
14
  import './product/components/ProductVariants/variants/index.js';
16
15
  import cartSetting from './cart/setting/index.js';
17
16
  import gridSetting from './grid/setting/index.js';
17
+ import 'next/head';
18
18
  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';
@@ -26,7 +26,7 @@ const getTextClasses = ({ styles, setting, className, mode })=>{
26
26
  const { text, options } = setting ?? {};
27
27
  let classList = '';
28
28
  if (!text) {
29
- classList += `gp-relative empty:gp-pl-[2px] after:gp-content-['Your_custom_text_goes_here'] after:gp-absolute after:gp-select-none after:gp-top-0 after:gp-left-[2px] after:gp-w-full after:gp-truncate after:gp-text-black after:gp-opacity-20`;
29
+ classList += `gp-relative empty:gp-pl-[2px] after:gp-content-['Your_custom_text_goes_here'] after:gp-absolute after:gp-select-none after:gp-top-0 after:gp-left-[2px] after:gp-w-full after:gp-truncate after:gp-text-black after:gp-opacity-20 `;
30
30
  }
31
31
  if (styles?.underlineLink) {
32
32
  classList += `${styles.underlineLink.hover ? 'hover:gp-underline' : ''} ${styles.underlineLink.normal ? 'gp-underline' : ''}`;
@@ -1,9 +1,4 @@
1
1
  'use client';
2
- import 'react/jsx-runtime';
3
- import '@gem-sdk/core';
4
- import 'next/head';
5
- import 'react';
6
- import 'next/link';
7
2
  import Button from '../../button/components/Button.js';
8
3
 
9
4
  const PushOwl = Button;