@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
@@ -1,47 +0,0 @@
1
- import { template, makeStyleResponsive, cls, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import DynamicCheckoutBlack from './icons/DynamicCheckoutBlack.liquid.js';
3
- import DynamicCheckoutPurple from './icons/DynamicCheckoutPurple.liquid.js';
4
- import DynamicCheckoutWhite from './icons/DynamicCheckoutWhite.liquid.js';
5
- import ExpressCheckoutBlack from './icons/ExpressCheckoutBlack.liquid.js';
6
- import ExpressCheckoutPurple from './icons/ExpressCheckoutPurple.liquid.js';
7
- import ExpressCheckoutWhite from './icons/ExpressCheckoutWhite.liquid.js';
8
- import { getSettingPreloadData } from '../../../helpers.js';
9
-
10
- /**
11
- * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
12
- */ const ShopPayButton = ({ className, setting, builderAttrs, style, styles, advanced })=>{
13
- const SPButton = ()=>{
14
- if (styles?.type === 'dynamic') {
15
- if (styles.color === 'black') return DynamicCheckoutBlack;
16
- if (styles.color === 'purple') return DynamicCheckoutPurple;
17
- return DynamicCheckoutWhite;
18
- } else {
19
- if (styles?.color === 'black') return ExpressCheckoutBlack;
20
- if (styles?.color === 'purple') return ExpressCheckoutPurple;
21
- return ExpressCheckoutWhite;
22
- }
23
- };
24
- return template`
25
- <gp-shop-pay-button
26
- ${{
27
- ...builderAttrs
28
- }}
29
- style="${{
30
- ...style,
31
- ...makeStyleResponsive('jc', styles?.align)
32
- }}"
33
- class="${cls(className, 'gp-flex', advanced?.cssClass)}"
34
- gp-data='{"setting":${JSON.stringify(setting)}, "shop_url": "{{shop.url}}" }'
35
- >
36
- <button
37
- class="disabled:gp-cursor-not-allowed disabled:gp-pacity-50 gp-shop-button"
38
- aria-label="Buy with Shop Pay"
39
- >
40
- ${SPButton()({})}
41
- </button>
42
- </gp-shop-pay-button>
43
- ${RenderIf(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>`)}
44
- `;
45
- };
46
-
47
- export { ShopPayButton as default };
@@ -1,246 +0,0 @@
1
- import { getWidthHeightGlobalSize, getPaddingGlobalSize, template, cls, genTypoClass, genSizeClass, getGlobalColorStateClassDynamicBtn, composeTypographyV2Css, composeShadowCss, composeCornerCss, composeBorderCss, composeBackgroundCss, composeBackgroundImageCss, composeTextHoverColorCss, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import { getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
3
-
4
- const DynamicCheckout = ({ builderProps, styles, advanced, setting, pageContext })=>{
5
- const composeGlobalSize = {
6
- width: getWidthHeightGlobalSize('width', styles?.globalSize),
7
- height: getWidthHeightGlobalSize('height', styles?.globalSize),
8
- padding: getPaddingGlobalSize(styles?.globalSize)
9
- };
10
- const composeSize = (width, height, important = true)=>{
11
- return `
12
- ${width ? `width: ${width}${important ? '!important;' : ''};` : ''}
13
- ${height ? `height: ${height}${important ? '!important;' : ''};` : ''}
14
- `;
15
- };
16
- const composeSpacing = (device)=>{
17
- const suffix = device && device !== 'desktop' ? `-${device}` : '';
18
- const spacingDevice = {
19
- top: composeGlobalSize.padding[`--pt${suffix}`],
20
- bottom: composeGlobalSize.padding[`--pb${suffix}`],
21
- left: composeGlobalSize.padding[`--pl${suffix}`],
22
- right: composeGlobalSize.padding[`--pr${suffix}`]
23
- };
24
- return `padding-top: ${spacingDevice.top ? `${spacingDevice.top} !important;` : ''};
25
- padding-bottom: ${spacingDevice.bottom ? `${spacingDevice.bottom} !important;` : ''};
26
- padding-left: ${spacingDevice.left ? `${spacingDevice.left} !important;` : ''};
27
- padding-right: ${spacingDevice.right ? `${spacingDevice.right} !important;` : ''};
28
- `;
29
- };
30
- const composeFontSize = (fontSize)=>{
31
- return fontSize ? `font-size: ${fontSize} !important;` : '';
32
- };
33
- const composeLineHeight = (lineHeight)=>{
34
- return lineHeight ? `line-height: ${lineHeight} !important;` : '';
35
- };
36
- const composeTextAlign = (align)=>{
37
- return `${align ? `text-align: ${align} !important;` : ''}`;
38
- };
39
- const translatedLabel = getDynamicSourceLocales({
40
- val: setting?.label,
41
- uid: builderProps?.uid,
42
- settingId: 'label',
43
- pageContext,
44
- translate: setting?.translate
45
- });
46
- return template /* liquid */ `
47
- {%- liquid
48
- assign inventory_quantity = variant.inventory_quantity | default: 0
49
- assign supported_payment_methods = shop.enabled_payment_types
50
- -%}
51
- <gp-product-dynamic data-id="${builderProps?.uid}" data-translate-label="${translatedLabel}" class="${advanced?.cssClass}" gp-data='${JSON.stringify({
52
- setting: {
53
- label: setting?.label
54
- },
55
- totalVariant: '{{product.variants.size}}'
56
- }).replaceAll("'", '&#039;')}
57
- '>
58
- <div class="${cls('gp-block', `${'wrap__button--unbranded__' + builderProps?.uid}`, String.raw`[&_.shopify-payment-button\_\_button--unbranded]:gp-min-h-fit`, String.raw`disabled:[&_.shopify-payment-button\_\_button--unbranded]:gp-pointer-events-none`, styles?.typo?.type ? String.raw`[&_.shopify-payment-button\_\_button--unbranded]:!${genTypoClass(styles?.typo?.type)}` : '', styles?.btnSpacing?.type ? String.raw`[&_.shopify-payment-button\_\_button--unbranded]:!${genSizeClass(styles?.btnSpacing?.type)}` : '', getGlobalColorStateClassDynamicBtn('text', styles?.textColor))}">
59
- {{ form | payment_button }}
60
- </div>
61
- {% style %}
62
- .wrap__button--unbranded__${builderProps?.uid} {
63
- ${composeTextAlign(styles?.align?.desktop)}
64
- }
65
-
66
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button {
67
- display: inline-block;
68
- min-height: unset !important;
69
- ${composeSize(composeGlobalSize.width.desktop ?? 'auto', composeGlobalSize.height.desktop ?? 'auto', false)}
70
- }
71
-
72
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button div {
73
- width: 100%;
74
- margin-top: 0px !important;
75
- }
76
-
77
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__more-options {
78
- display: none;
79
- }
80
-
81
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
82
- max-width: 100%;
83
- min-width: unset;
84
- min-height: unset !important;
85
- background-color: unset !important;
86
- position: relative;
87
- border: none !important;
88
- margin: 0;
89
- z-index: 0;
90
- border-radius: unset;
91
- width: 100%;
92
- display: inline-flex;
93
- justify-content: center;
94
- align-items: center;
95
- ${composeTypographyV2Css(styles?.typo, true)}
96
- ${composeShadowCss({
97
- boxShadowValue: styles?.boxShadowBtnV2?.desktop?.normal,
98
- hasBoxShadow: styles?.boxShadowBtnV2?.desktop?.normal?.type !== 'none'
99
- })}
100
- ${composeSpacing('desktop')}
101
- ${composeCornerCss(styles?.roundedBtnV2?.desktop?.normal, true)}
102
- ${composeSize(undefined, composeGlobalSize.height.desktop ?? 'auto', false)}
103
- }
104
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
105
- content: "";
106
- height: 100%;
107
- width: 100%;
108
- position: absolute;
109
- top: 0;
110
- left: 0;
111
- pointer-events: none;
112
- z-index: -1;
113
- ${composeBorderCss(styles?.borderBtnV2?.desktop?.normal)}
114
- ${composeCornerCss(styles?.roundedBtnV2?.desktop?.normal)}
115
- ${composeBackgroundCss(styles?.backgroundColorV2?.desktop?.normal)}
116
- ${composeBackgroundImageCss(styles?.backgroundImage, {
117
- device: 'desktop',
118
- state: 'normal'
119
- })}
120
- }
121
-
122
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
123
- ${composeShadowCss({
124
- boxShadowValue: styles?.boxShadowBtnV2?.desktop?.hover,
125
- hasBoxShadow: styles?.boxShadowBtnV2?.desktop?.hover?.type !== 'none',
126
- important: true
127
- })}
128
- ${composeTextHoverColorCss('desktop', styles?.textColorHover, true)}
129
- }
130
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
131
- ${composeBorderCss(styles?.borderBtnV2?.desktop?.hover)}
132
- ${composeCornerCss(styles?.roundedBtnV2?.desktop?.hover)}
133
- ${composeBackgroundCss(styles?.backgroundColorV2?.desktop?.hover)}
134
- }
135
-
136
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::after {
137
- border-radius: 0;
138
- box-shadow: none;
139
- }
140
-
141
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::after:hover {
142
- border-radius: 0;
143
- box-shadow: none;
144
- }
145
-
146
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button > div {
147
- max-width: 100%;
148
- }
149
-
150
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button > div > div {
151
- max-width: 100%;
152
- }
153
-
154
- @media only screen and (max-width: 1024px) and (min-width: 768px) {
155
- .wrap__button--unbranded__${builderProps?.uid} {
156
- ${composeTextAlign(styles?.align?.tablet)}
157
- }
158
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button {
159
- ${composeSize(composeGlobalSize.width.tablet, composeGlobalSize.height.tablet)}
160
- }
161
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
162
- ${composeShadowCss({
163
- boxShadowValue: styles?.boxShadowBtnV2?.tablet?.hover,
164
- hasBoxShadow: styles?.boxShadowBtnV2?.tablet?.hover?.type !== 'none',
165
- important: true
166
- })}
167
- ${composeTextHoverColorCss('tablet', styles?.textColorHover, true)}
168
- }
169
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
170
- width: 100%;
171
-
172
- ${composeSpacing('tablet')}
173
- ${composeLineHeight(styles?.typo?.custom?.lineHeight?.tablet)}
174
- ${composeFontSize(styles?.typo?.custom?.fontSize?.tablet)}
175
- ${composeSize(composeGlobalSize.width.tablet ?? 'auto', composeGlobalSize.height.tablet ?? 'auto', false)}
176
- ${composeShadowCss({
177
- boxShadowValue: styles?.boxShadowBtnV2?.tablet?.normal,
178
- hasBoxShadow: styles?.boxShadowBtnV2?.tablet?.normal?.type !== 'none'
179
- })}
180
- ${composeCornerCss(styles?.roundedBtnV2?.tablet?.normal, true)}
181
- }
182
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
183
- ${composeBorderCss(styles?.borderBtnV2?.tablet?.hover)}
184
- ${composeCornerCss(styles?.roundedBtnV2?.tablet?.hover)}
185
- ${composeBackgroundCss(styles?.backgroundColorV2?.tablet?.hover)}
186
- }
187
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
188
- ${composeBorderCss(styles?.borderBtnV2?.tablet?.normal)}
189
- ${composeCornerCss(styles?.roundedBtnV2?.tablet?.normal)}
190
- ${composeBackgroundImageCss(styles?.backgroundImage, {
191
- device: 'tablet',
192
- state: 'normal'
193
- })}
194
- }
195
- }
196
-
197
- @media only screen and (max-width: 767px) {
198
- .wrap__button--unbranded__${builderProps?.uid} {
199
- ${composeTextAlign(styles?.align?.mobile)}
200
- }
201
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button {
202
- ${composeSize(composeGlobalSize.width.mobile, composeGlobalSize.height.mobile)}
203
- }
204
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
205
- ${composeShadowCss({
206
- boxShadowValue: styles?.boxShadowBtnV2?.mobile?.hover,
207
- hasBoxShadow: styles?.boxShadowBtnV2?.mobile?.hover?.type !== 'none',
208
- important: true
209
- })}
210
- ${composeTextHoverColorCss('mobile', styles?.textColorHover, true)}
211
- }
212
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
213
- width: 100%;
214
- ${composeSpacing('mobile')}
215
- ${composeLineHeight(styles?.typo?.custom?.lineHeight?.mobile)}
216
- ${composeFontSize(styles?.typo?.custom?.fontSize?.mobile)}
217
- ${composeSize(composeGlobalSize.width.mobile ?? 'auto', composeGlobalSize.height.mobile ?? 'auto', false)}
218
- ${composeShadowCss({
219
- boxShadowValue: styles?.boxShadowBtnV2?.mobile?.normal,
220
- hasBoxShadow: styles?.boxShadowBtnV2?.mobile?.normal?.type !== 'none'
221
- })}
222
- ${composeCornerCss(styles?.roundedBtnV2?.mobile?.normal, true)}
223
- }
224
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
225
- ${composeBorderCss(styles?.borderBtnV2?.mobile?.hover)}
226
- ${composeCornerCss(styles?.roundedBtnV2?.mobile?.hover)}
227
- ${composeBackgroundCss(styles?.backgroundColorV2?.mobile?.hover)}
228
- }
229
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
230
- ${composeBorderCss(styles?.borderBtnV2?.mobile?.normal)}
231
- ${composeCornerCss(styles?.roundedBtnV2?.mobile?.normal)}
232
- ${composeBackgroundImageCss(styles?.backgroundImage, {
233
- device: 'mobile',
234
- state: 'normal'
235
- })}
236
- ${composeBackgroundCss(styles?.backgroundColorV2?.mobile?.normal)}
237
- }
238
- }
239
-
240
- {% endstyle %}
241
- </gp-product-dynamic>
242
- ${RenderIf(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>`)}
243
- `;
244
- };
245
-
246
- export { DynamicCheckout as default };
@@ -1,3 +0,0 @@
1
- const DESCRIPTION_LINE_HEIGHT_DEFAULT = 21;
2
-
3
- export { DESCRIPTION_LINE_HEIGHT_DEFAULT };
@@ -1,168 +0,0 @@
1
- 'use client';
2
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
- import { useProduct, useCurrentDevice, getResponsiveValueByScreen, useProductShopifyEditLink, useEditorMode, isBrowser, composeTypographyClassName, composeTypographyStyle, cls, getGlobalColorClass, getStyleShadow, makeStyleResponsive, makeStyle, getGlobalColorStyle } from '@gem-sdk/core';
4
- import { useState, useRef, useEffect } from 'react';
5
- import NoDataState from '../../common/components/NoDataState.js';
6
- import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
7
- import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from './ProductDescription/const.js';
8
-
9
- const ProductDescription = ({ setting, builderProps })=>{
10
- const [open, setOpen] = useState(false);
11
- const [isShowViewMore, allowShowViewMore] = useState(false);
12
- const product = useProduct();
13
- const { htmlTag } = setting ?? {};
14
- const ref = useRef(null);
15
- const currentDevice = useCurrentDevice();
16
- const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
17
- const lineClamp = getResponsiveValueByScreen(setting?.lineClamp, currentDevice);
18
- const { redirectProductShopifyLink } = useProductShopifyEditLink();
19
- const mode = useEditorMode();
20
- const isSafari = isBrowser() ? navigator?.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 : false;
21
- useEffect(()=>{
22
- const dom = ref.current;
23
- setOpen(false);
24
- if (!dom) return;
25
- const enableShowMore = hasLineClamp && product?.descriptionHtml;
26
- if (!enableShowMore) dom.style.maxHeight = 'none';
27
- else {
28
- const value = lineClamp;
29
- setTimeout(()=>{
30
- const scrollHeight = dom?.scrollHeight ?? 0;
31
- const clientHeight = dom?.clientHeight ?? 0;
32
- const lineHeight = getLineHeightFromDom();
33
- const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
34
- dom.style.maxHeight = getMaxHeight(lineHeight);
35
- const conditionCheckLine = value && value < lineText || clientHeight < scrollHeight;
36
- if (value && conditionCheckLine) {
37
- allowShowViewMore(()=>true);
38
- } else {
39
- allowShowViewMore(()=>false);
40
- }
41
- }, 100);
42
- }
43
- }, [
44
- hasLineClamp,
45
- lineClamp,
46
- product?.description,
47
- isSafari
48
- ]);
49
- const getLineHeightFromDom = ()=>{
50
- if (!ref.current) return DESCRIPTION_LINE_HEIGHT_DEFAULT;
51
- const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
52
- return parseInt(lineHeight);
53
- };
54
- const getMaxHeight = (lineHeight)=>{
55
- if (!hasLineClamp || !lineClamp) return 'auto';
56
- if (lineHeight) return `${lineClamp * lineHeight}px`;
57
- return 'auto';
58
- };
59
- const Tag = htmlTag === 'html' ? 'div' : 'p';
60
- const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
61
- const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
62
- const css = `
63
- .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script) {
64
- display: inline !important;
65
- }
66
- .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script)::after {
67
- content: "\\A";
68
- white-space: pre;
69
- }
70
- .gp-p-description-text > table {
71
- box-shadow: none;
72
- }
73
- `;
74
- const noDescriptionHtml = !product?.descriptionHtml;
75
- if (noDescriptionHtml && mode === 'edit') {
76
- return /*#__PURE__*/ jsx(NoDataState, {
77
- elementType: "secondary",
78
- description: "Highlight key benefits with product description.",
79
- descriptionActions: [
80
- {
81
- text: 'Add description',
82
- callback: redirectProductShopifyLink
83
- },
84
- {
85
- text: 'sync data',
86
- callback: 'syncProduct'
87
- }
88
- ]
89
- });
90
- }
91
- const handleToggleShowMore = ()=>{
92
- if (!ref.current) return;
93
- const lineHeight = getLineHeightFromDom();
94
- if (open) {
95
- ref.current.style.maxHeight = getMaxHeight(lineHeight);
96
- } else {
97
- ref.current.style.maxHeight = 'none';
98
- }
99
- setOpen((prev)=>!prev);
100
- };
101
- return /*#__PURE__*/ jsx(Fragment, {
102
- children: noDescriptionHtml ? null : /*#__PURE__*/ jsxs("div", {
103
- "data-id": builderProps?.uid,
104
- children: [
105
- !isSafari && /*#__PURE__*/ jsx("style", {
106
- type: "text/css",
107
- dangerouslySetInnerHTML: {
108
- __html: css
109
- }
110
- }),
111
- /*#__PURE__*/ jsx(Tag, {
112
- ref: ref,
113
- "data-gp-text": true,
114
- className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, getGlobalColorClass('text', setting?.color)),
115
- style: {
116
- ...getStyleShadow({
117
- value: setting?.typo?.custom?.textShadow,
118
- styleAppliedFor: 'text-shadow',
119
- isEnableShadow: setting?.typo?.custom?.textShadow?.type !== 'none'
120
- }),
121
- ...makeStyleResponsive('ta', setting?.textAlign),
122
- ...hasLineClamp && !open ? makeStyleResponsive('line-clamp', setting?.lineClamp) : {},
123
- ...makeStyle({
124
- tt: setting?.transform
125
- }),
126
- ...appendTypoStyle,
127
- ...getMaxHeightStyleDefault(setting)
128
- },
129
- dangerouslySetInnerHTML: {
130
- __html: product?.descriptionHtml || ''
131
- }
132
- }),
133
- hasLineClamp && isShowViewMore && /*#__PURE__*/ jsxs("button", {
134
- className: cls(appendTypoClass, getGlobalColorClass('text', setting?.showMoreColor), 'gp-mt-4 gp-w-full gp-transition-all hover:gp-opacity-80'),
135
- style: {
136
- ...makeStyleResponsive('ta', setting?.textAlign),
137
- ...makeStyle({
138
- tt: setting?.transform
139
- }),
140
- ...appendTypoStyle,
141
- ...getGlobalColorStyle(setting?.showMoreColor)
142
- },
143
- onClick: handleToggleShowMore,
144
- children: [
145
- !open ? setting?.viewMoreText : setting?.viewLessText,
146
- setting?.enableViewMoreIcon && /*#__PURE__*/ jsx("svg", {
147
- className: "gp-ml-1 gp-inline-block",
148
- height: "1em",
149
- width: "1em",
150
- viewBox: "0 0 22 12",
151
- fill: "none",
152
- xmlns: "http://www.w3.org/2000/svg",
153
- children: !open ? /*#__PURE__*/ jsx("path", {
154
- 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",
155
- fill: "currentColor"
156
- }) : /*#__PURE__*/ jsx("path", {
157
- d: "M0.292893 10.2929C-0.0976311 10.6834 -0.0976311 11.3166 0.292893 11.7071C0.683417 12.0976 1.31658 12.0976 1.70711 11.7071L0.292893 10.2929ZM11 1L11.7071 0.292893C11.3166 -0.0976311 10.6834 -0.0976311 10.2929 0.292893L11 1ZM20.2929 11.7071C20.6834 12.0976 21.3166 12.0976 21.7071 11.7071C22.0976 11.3166 22.0976 10.6834 21.7071 10.2929L20.2929 11.7071ZM1.70711 11.7071L11.7071 1.70711L10.2929 0.292893L0.292893 10.2929L1.70711 11.7071ZM10.2929 1.70711L20.2929 11.7071L21.7071 10.2929L11.7071 0.292893L10.2929 1.70711Z",
158
- fill: "currentColor"
159
- })
160
- })
161
- ]
162
- })
163
- ]
164
- })
165
- });
166
- };
167
-
168
- export { ProductDescription as default };
@@ -1,116 +0,0 @@
1
- import { composeTypographyClassName, composeTypographyStyle, getStyleShadow, makeStyleResponsive, getGlobalColorStyle, makeStyle, makeLineClamp, template, cls, getGlobalColorClass, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import { getSettingPreloadData } from '../../helpers.js';
3
- import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
4
-
5
- const devices = [
6
- 'desktop',
7
- 'mobile',
8
- 'tablet'
9
- ];
10
- const getDisplayStyle = (fnCondition, defaultValue)=>{
11
- let result = {};
12
- devices.forEach((device)=>{
13
- result = {
14
- ...result,
15
- [`--d${device === 'desktop' ? '' : `-${device}`}`]: `${fnCondition(device) ? 'none' : defaultValue}`
16
- };
17
- });
18
- return result;
19
- };
20
- const ProductDescription = ({ setting, advanced, builderProps })=>{
21
- const { htmlTag } = setting ?? {};
22
- const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
23
- const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
24
- const defaultStyle = {
25
- ...getStyleShadow({
26
- value: setting?.typo?.custom?.textShadow,
27
- styleAppliedFor: 'text-shadow',
28
- isEnableShadow: setting?.typo?.custom?.textShadow?.type !== 'none'
29
- }),
30
- ...makeStyleResponsive('ta', setting?.textAlign),
31
- ...getGlobalColorStyle(setting?.color),
32
- ...makeStyle({
33
- tt: setting?.transform
34
- }),
35
- ...appendTypoStyle,
36
- ...getMaxHeightStyleDefault(setting)
37
- };
38
- const collapseStyle = {
39
- ...defaultStyle,
40
- ...makeStyleResponsive('line-clamp', makeLineClamp(setting?.lineClamp, setting?.hasLineClamp))
41
- };
42
- const getDisplayCollapse = ()=>{
43
- return getDisplayStyle((device)=>!!setting?.hasLineClamp && setting.hasLineClamp[device] !== undefined && !setting.hasLineClamp[device], 'block');
44
- };
45
- const Tag = htmlTag === 'html' ? 'div' : 'p';
46
- return template`
47
- <gp-product-description data-id="${builderProps?.uid}" class="${advanced?.cssClass} gp-product-description" gp-data='${JSON.stringify({
48
- setting: {
49
- lineClamp: setting?.lineClamp,
50
- hasLineClamp: setting?.hasLineClamp,
51
- viewMoreText: setting?.viewMoreText,
52
- viewLessText: setting?.viewLessText,
53
- enableViewMoreIcon: setting?.enableViewMoreIcon
54
- },
55
- defaultStyle,
56
- collapseStyle
57
- }).replaceAll("'", '&#039;')}'>
58
- {%- unless product -%}
59
- <p>Product not found</p>
60
- {%- else -%}
61
- <${Tag}
62
- data-gp-text
63
- class="${cls('gp-relative p-description-wrapper gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, getGlobalColorClass('text', setting?.color), "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")}"
64
- data-gp-text
65
- style="${collapseStyle}"
66
- >
67
- ${htmlTag === 'html' ? `{{product.description}}` : `{{product.description | strip_html}}`}
68
- </${Tag}>
69
- {% if product.description != blank -%}
70
- <button
71
- type="button"
72
- class="p-description-show-more ${cls(appendTypoClass, getGlobalColorClass('text', setting?.showMoreColor), 'gp-mt-4 hover:gp-opacity-80 gp-transition-all gp-w-full')}"
73
- style="${{
74
- ...makeStyle({
75
- tt: setting?.transform
76
- }),
77
- ...makeStyleResponsive('ta', setting?.textAlign),
78
- ...appendTypoStyle,
79
- ...getGlobalColorStyle(setting?.showMoreColor),
80
- ...getDisplayCollapse(),
81
- position: 'absolute',
82
- visibility: 'hidden'
83
- }}"
84
- >
85
-
86
- ${setting?.viewMoreText}
87
- ${setting?.enableViewMoreIcon ? `<svg
88
- class="gp-ml-1 gp-inline-block"
89
- style="display: inline-block; margin-left: 1px;"
90
- height="1em"
91
- width="1em"
92
- viewBox="0 0 22 12"
93
- fill="none"
94
- xmlns="http://www.w3.org/2000/svg"
95
- >
96
- <path
97
- 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"
98
- fill="currentColor"
99
- />
100
- </svg>` : ''}
101
- </button>
102
- {%- endif -%}
103
-
104
- {%- endunless -%}
105
- {% style %}
106
- .p-description-wrapper.gp-p-description-text * {
107
- color: inherit;
108
- line-height: inherit !important;
109
- }
110
- {% endstyle %}
111
- </gp-product-description>
112
- ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-description.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-product-description.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
113
- `;
114
- };
115
-
116
- export { ProductDescription as default };