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