@gem-sdk/components 2.0.0-dev.244 → 2.0.0-dev.247

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 (32) hide show
  1. package/dist/cjs/button/components/Button.liquid.js +3 -3
  2. package/dist/cjs/button/components/v2/ButtonV2.liquid.js +2 -2
  3. package/dist/cjs/post-purchase/product/common/getAttrs.js +10 -0
  4. package/dist/cjs/post-purchase/product/common/getClasses.js +12 -0
  5. package/dist/cjs/post-purchase/product/common/getSettings.js +9 -0
  6. package/dist/cjs/post-purchase/product/common/getStyles.js +10 -0
  7. package/dist/cjs/post-purchase/product/components/ProductDiscountTag.js +34 -13
  8. package/dist/cjs/post-purchase/product/settings/index.js +1 -1
  9. package/dist/cjs/post-purchase/product/settings/{ProductDiscountTag.js → product-discount-tag/ProductDiscountTag.js} +7 -89
  10. package/dist/cjs/post-purchase/product/settings/product-discount-tag/settingV2.js +63 -0
  11. package/dist/cjs/post-purchase/product/settings/product-discount-tag/uiV1.js +52 -0
  12. package/dist/cjs/post-purchase/product/settings/product-discount-tag/uiV2.js +67 -0
  13. package/dist/cjs/product/components/ProductButton.liquid.js +3 -2
  14. package/dist/cjs/tab/hooks/useTabInteraction.js +13 -9
  15. package/dist/cjs/third-party/setting/QikifyUpsell.js +1 -1
  16. package/dist/esm/button/components/Button.liquid.js +3 -3
  17. package/dist/esm/button/components/v2/ButtonV2.liquid.js +2 -2
  18. package/dist/esm/post-purchase/product/common/getAttrs.js +8 -0
  19. package/dist/esm/post-purchase/product/common/getClasses.js +10 -0
  20. package/dist/esm/post-purchase/product/common/getSettings.js +7 -0
  21. package/dist/esm/post-purchase/product/common/getStyles.js +8 -0
  22. package/dist/esm/post-purchase/product/components/ProductDiscountTag.js +35 -14
  23. package/dist/esm/post-purchase/product/settings/index.js +1 -1
  24. package/dist/esm/post-purchase/product/settings/{ProductDiscountTag.js → product-discount-tag/ProductDiscountTag.js} +7 -89
  25. package/dist/esm/post-purchase/product/settings/product-discount-tag/settingV2.js +61 -0
  26. package/dist/esm/post-purchase/product/settings/product-discount-tag/uiV1.js +50 -0
  27. package/dist/esm/post-purchase/product/settings/product-discount-tag/uiV2.js +65 -0
  28. package/dist/esm/product/components/ProductButton.liquid.js +3 -2
  29. package/dist/esm/tab/hooks/useTabInteraction.js +14 -10
  30. package/dist/esm/third-party/setting/QikifyUpsell.js +1 -1
  31. package/dist/types/index.d.ts +20 -16
  32. package/package.json +1 -1
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var core = require('@gem-sdk/core');
6
6
  var helpers = require('../../helpers.js');
7
7
 
8
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId })=>{
8
+ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
9
9
  const { align, size, backgroundColor, textColor, roundedBtn, iconSpacing, globalSize } = styles;
10
10
  const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
11
11
  const [wrapStyle, restStyle] = core.splitStyle([
@@ -70,7 +70,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
70
70
  color: ${core.getSingleColorVariable(styles?.textColor?.hover)};
71
71
  }
72
72
  `;
73
- const labelValDisplay = helpers.getDynamicSourceLocales({
73
+ const labelValDisplay = isForceValue ? label : helpers.getDynamicSourceLocales({
74
74
  val: label,
75
75
  uid: builderProps?.uidTranslate ?? builderProps?.uid,
76
76
  settingId: translate ?? 'label',
@@ -164,7 +164,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
164
164
  >${iconSvg}</span>`)}
165
165
  <span
166
166
  data-gp-text
167
- class="${`gp-button-text-only gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
167
+ class="${`gp-content-product-button gp-button-text-only gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
168
168
  ${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
169
169
  style="${{
170
170
  ...nodePrice && appendTypoStyle,
@@ -6,7 +6,7 @@ var core = require('@gem-sdk/core');
6
6
  var helpers = require('../../../helpers.js');
7
7
  var useButtonCustomCss = require('../../hooks/useButtonCustomCss.js');
8
8
 
9
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId })=>{
9
+ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
10
10
  const { align, size, backgroundImage, backgroundColorV2, textColor, textColorHover, roundedBtnV2, iconSpacing, globalSize } = styles;
11
11
  const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
12
12
  const [wrapStyle, restStyle] = core.splitStyle([
@@ -46,7 +46,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
46
46
  styles,
47
47
  builderProps
48
48
  });
49
- const labelValDisplay = helpers.getDynamicSourceLocales({
49
+ const labelValDisplay = isForceValue ? label : helpers.getDynamicSourceLocales({
50
50
  val: label,
51
51
  uid: builderProps?.uidTranslate ?? builderProps?.uid,
52
52
  settingId: translate ?? 'label',
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const getContainerAttrs = ({ currentProductId, uid })=>{
4
+ return {
5
+ id: `shopify-text-element-${uid}`,
6
+ 'data-product-id': currentProductId || ''
7
+ };
8
+ };
9
+
10
+ exports.getContainerAttrs = getContainerAttrs;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getContainerClasses = ({ uid })=>{
6
+ return {
7
+ ...core.composeClasses(uid),
8
+ ...core.composeClasses('gp-flex gp-w-full')
9
+ };
10
+ };
11
+
12
+ exports.getContainerClasses = getContainerClasses;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const getTextSettings = ({ hasDiscount, message })=>{
4
+ return {
5
+ text: hasDiscount ? message : message?.replace(new RegExp(/\{\{Discount\}\}/, 'gi'), '0%')
6
+ };
7
+ };
8
+
9
+ exports.getTextSettings = getTextSettings;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const getContainerStyles = ({ style, hasDiscount })=>{
4
+ return {
5
+ ...style,
6
+ opacity: hasDiscount ? 1 : 0.2
7
+ };
8
+ };
9
+
10
+ exports.getContainerStyles = getContainerStyles;
@@ -7,31 +7,52 @@ var jsxRuntime = require('react/jsx-runtime');
7
7
  var core = require('@gem-sdk/core');
8
8
  var Text = require('../../text/components/Text.js');
9
9
  var useDynamicProduct = require('../hooks/useDynamicProduct.js');
10
+ var system = require('@gem-sdk/system');
11
+ var getAttrs = require('../common/getAttrs.js');
12
+ var getClasses = require('../common/getClasses.js');
13
+ var getStyles = require('../common/getStyles.js');
14
+ var getSettings = require('../common/getSettings.js');
10
15
 
11
16
  const PostPurchaseProductDiscountTag = ({ setting = {}, styles = {}, style, builderAttrs, builderProps, children })=>{
12
17
  const currentProduct = core.useProduct();
13
18
  const currentProductId = currentProduct?.baseID?.replace('gid://shopify/Product/', '');
14
19
  const currentOfferDiscount = core.useProductOfferDiscount();
15
20
  const { isDynamicProduct, isEnableDynamicDiscount } = useDynamicProduct.useDynamicProduct();
16
- const { typo } = styles;
21
+ const { typo, direction } = styles;
17
22
  const { message } = setting;
18
23
  const hasDiscount = !!currentOfferDiscount || isDynamicProduct && isEnableDynamicDiscount;
24
+ const containerClasses = system.createClass({
25
+ ...getClasses.getContainerClasses({
26
+ uid: builderProps?.uid
27
+ })
28
+ });
29
+ const containerAttrs = system.createAttr({
30
+ ...getAttrs.getContainerAttrs({
31
+ ...builderAttrs,
32
+ currentProductId,
33
+ uid: builderProps?.uid
34
+ })
35
+ });
36
+ const containerStyles = system.createStyle({
37
+ ...getStyles.getContainerStyles({
38
+ style,
39
+ hasDiscount
40
+ })
41
+ });
42
+ const textSettings = getSettings.getTextSettings({
43
+ hasDiscount,
44
+ message
45
+ });
19
46
  return /*#__PURE__*/ jsxRuntime.jsxs("div", {
20
- ...builderAttrs,
21
- className: core.cls(builderProps?.uid, 'gp-flex gp-w-full'),
22
- style: {
23
- ...style,
24
- opacity: hasDiscount ? 1 : 0.2
25
- },
26
- id: `shopify-text-element-${builderProps?.uid}`,
27
- "data-product-id": currentProductId,
47
+ ...containerAttrs,
48
+ className: containerClasses,
49
+ style: containerStyles,
28
50
  children: [
29
51
  /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
30
- setting: {
31
- text: hasDiscount ? message : message?.replace(new RegExp(/\{\{Discount\}\}/, 'gi'), '0%')
32
- },
52
+ setting: textSettings,
33
53
  styles: {
34
- typo
54
+ typo,
55
+ direction
35
56
  }
36
57
  }),
37
58
  children
@@ -10,7 +10,7 @@ var ProductVariant = require('./product-variants/ProductVariant.js');
10
10
  var index$1 = require('./product-quantity/index.js');
11
11
  var ProductOffer = require('./ProductOffer.js');
12
12
  var index$2 = require('./product-price-breakdown/index.js');
13
- var ProductDiscountTag = require('./ProductDiscountTag.js');
13
+ var ProductDiscountTag = require('./product-discount-tag/ProductDiscountTag.js');
14
14
  var ProductImages = require('./product-image/ProductImages.js');
15
15
 
16
16
  var postPurchaseProductSetting = {
@@ -2,99 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var settingV2 = require('./settingV2.js');
6
+ var uiV1 = require('./uiV1.js');
7
+ var uiV2 = require('./uiV2.js');
8
+
5
9
  const config = {
6
10
  tag: 'PostPurchaseProductDiscountTag',
7
11
  label: 'Discount Tag',
8
12
  icon: ``,
9
- settings: [
10
- {
11
- id: 'setting',
12
- controls: [
13
- {
14
- id: 'discountAndShippingFee',
15
- type: 'discount-and-shipping-fee-product-offer',
16
- multiple: false
17
- },
18
- {
19
- id: 'message',
20
- label: '',
21
- type: 'textarea',
22
- autoHeight: true,
23
- default: '(Save {{Discount}})',
24
- suggestContents: [
25
- {
26
- message: '{{Discount}}',
27
- eg: '20%'
28
- }
29
- ]
30
- }
31
- ]
32
- },
33
- {
34
- id: 'style',
35
- controls: [
36
- {
37
- id: 'typo',
38
- label: 'Label',
39
- type: 'typography-post-purchase',
40
- default: {
41
- fontSize: 'default',
42
- textColor: 'critical',
43
- fontWeight: 'bold',
44
- textTransform: 'none'
45
- }
46
- }
47
- ]
48
- }
49
- ],
50
- ui: [
51
- {
52
- type: 'group',
53
- label: {
54
- en: ''
55
- },
56
- controls: [
57
- {
58
- type: 'control',
59
- label: {
60
- en: ''
61
- },
62
- setting: {
63
- id: 'discountAndShippingFee'
64
- },
65
- layout: 'vertical'
66
- }
67
- ]
68
- },
69
- {
70
- type: 'group',
71
- label: {
72
- en: 'Text'
73
- },
74
- controls: [
75
- {
76
- type: 'control',
77
- label: {
78
- en: ''
79
- },
80
- setting: {
81
- id: 'message'
82
- },
83
- layout: 'vertical'
84
- },
85
- {
86
- type: 'control',
87
- label: {
88
- en: ''
89
- },
90
- setting: {
91
- id: 'typo'
92
- },
93
- layout: 'vertical'
94
- }
95
- ]
96
- }
97
- ],
13
+ settings: settingV2.settingV2,
14
+ ui: uiV1.uiV1,
15
+ uiV2: uiV2.uiV2,
98
16
  editorConfigs: {
99
17
  placeholder: {
100
18
  flowTag: [
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ const settingV2 = [
4
+ {
5
+ id: 'setting',
6
+ controls: [
7
+ {
8
+ id: 'discountAndShippingFee',
9
+ type: 'discount-and-shipping-fee-product-offer',
10
+ multiple: false
11
+ },
12
+ {
13
+ id: 'message',
14
+ label: '',
15
+ type: 'textarea',
16
+ defaultRows: 4,
17
+ showPlusBtn: true,
18
+ autoHeight: true,
19
+ default: '(Save {{Discount}})',
20
+ suggestContents: [
21
+ {
22
+ message: '{{Discount}}',
23
+ eg: '20%'
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ },
29
+ {
30
+ id: 'style',
31
+ controls: [
32
+ {
33
+ id: 'direction',
34
+ label: 'Direction',
35
+ type: 'segment',
36
+ options: [
37
+ {
38
+ label: 'LTR',
39
+ value: 'ltr'
40
+ },
41
+ {
42
+ label: 'RTL',
43
+ value: 'rtl'
44
+ }
45
+ ],
46
+ default: 'ltr'
47
+ },
48
+ {
49
+ id: 'typo',
50
+ label: 'Label',
51
+ type: 'typography-post-purchase',
52
+ default: {
53
+ fontSize: 'default',
54
+ textColor: 'critical',
55
+ fontWeight: 'bold',
56
+ textTransform: 'none'
57
+ }
58
+ }
59
+ ]
60
+ }
61
+ ];
62
+
63
+ exports.settingV2 = settingV2;
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ const uiV1 = [
4
+ {
5
+ type: 'group',
6
+ label: {
7
+ en: ''
8
+ },
9
+ controls: [
10
+ {
11
+ type: 'control',
12
+ label: {
13
+ en: ''
14
+ },
15
+ setting: {
16
+ id: 'discountAndShippingFee'
17
+ },
18
+ layout: 'vertical'
19
+ }
20
+ ]
21
+ },
22
+ {
23
+ type: 'group',
24
+ label: {
25
+ en: 'Text'
26
+ },
27
+ controls: [
28
+ {
29
+ type: 'control',
30
+ label: {
31
+ en: ''
32
+ },
33
+ setting: {
34
+ id: 'message'
35
+ },
36
+ layout: 'vertical'
37
+ },
38
+ {
39
+ type: 'control',
40
+ label: {
41
+ en: ''
42
+ },
43
+ setting: {
44
+ id: 'typo'
45
+ },
46
+ layout: 'vertical'
47
+ }
48
+ ]
49
+ }
50
+ ];
51
+
52
+ exports.uiV1 = uiV1;
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ const uiV2 = [
4
+ {
5
+ controls: [
6
+ {
7
+ type: 'control',
8
+ label: {
9
+ en: ''
10
+ },
11
+ setting: {
12
+ id: 'discountAndShippingFee'
13
+ },
14
+ layout: 'vertical'
15
+ }
16
+ ]
17
+ },
18
+ {
19
+ label: {
20
+ en: 'Text'
21
+ },
22
+ controls: [
23
+ {
24
+ type: 'control',
25
+ label: {
26
+ en: 'Direction'
27
+ },
28
+ setting: {
29
+ id: 'direction'
30
+ }
31
+ },
32
+ {
33
+ type: 'combo',
34
+ label: {
35
+ en: 'Content'
36
+ },
37
+ iconName: 'polaris-text-block',
38
+ getValueFromSettingID: 'message',
39
+ isHideClear: true,
40
+ controls: [
41
+ {
42
+ label: {
43
+ en: 'Content'
44
+ },
45
+ setting: {
46
+ id: 'message'
47
+ },
48
+ layout: 'vertical'
49
+ }
50
+ ],
51
+ layout: 'horizontal'
52
+ },
53
+ {
54
+ type: 'control',
55
+ label: {
56
+ en: ''
57
+ },
58
+ setting: {
59
+ id: 'typo'
60
+ },
61
+ layout: 'vertical'
62
+ }
63
+ ]
64
+ }
65
+ ];
66
+
67
+ exports.uiV2 = uiV2;
@@ -353,7 +353,7 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
353
353
  'gp-data-hidden': `{% if variant.available %}true{% endif %}`
354
354
  },
355
355
  setting: {
356
- label: labelOutOfStockTranslate,
356
+ label: `${pageContext?.isPreviewing ? labelOutOfStockTranslate : `{{${labelOutOfStockTranslate}}}`}`,
357
357
  htmlType: 'button',
358
358
  iconAlign: iconAlign,
359
359
  iconSvg: iconSvg,
@@ -372,7 +372,8 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
372
372
  }
373
373
  },
374
374
  pageContext,
375
- nodePrice: composeNodePrice()
375
+ nodePrice: composeNodePrice(),
376
+ isForceValue: true
376
377
  })}
377
378
  </gp-product-button>
378
379
  ${core.RenderIf(core.isLocalEnv, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-button.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-product-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
@@ -4,19 +4,18 @@ var core = require('@gem-sdk/core');
4
4
  var React = require('react');
5
5
 
6
6
  const useTabInteraction = ({ activeKey, setActiveKey, activeTab, refContainer, componentUid })=>{
7
- const [previousTab, setPreviousTab] = React.useState(activeKey || 1);
8
- const { trigger, onListener, interactionListenerLoaded } = core.useInteraction();
7
+ const { trigger, onListener, interactionListenerLoaded, saveToElementInteractionData, findElementIncludingSelf } = core.useInteraction();
9
8
  const mode = core.useEditorMode();
10
9
  const changeOpenTabInteraction = (params)=>{
11
- const { data, isRollback } = params || {};
12
- if (data === undefined && isRollback === undefined) return;
10
+ const { data, isRollback, element, key } = params || {};
11
+ if (data === undefined && isRollback) return;
12
+ const newData = Number(data) + 1;
13
13
  if (isRollback) {
14
- setActiveKey(previousTab);
15
- setPreviousTab(activeTab);
14
+ setActiveKey(newData);
16
15
  return;
17
16
  }
18
- setPreviousTab(activeTab);
19
- setActiveKey(data + 1);
17
+ saveToElementInteractionData(element, key, String(activeKey));
18
+ setActiveKey(newData);
20
19
  };
21
20
  const dispatchEventTabActive = (index)=>{
22
21
  trigger({
@@ -37,11 +36,16 @@ const useTabInteraction = ({ activeKey, setActiveKey, activeTab, refContainer, c
37
36
  dispatchEventTabActive(activeTab - 1);
38
37
  });
39
38
  const selector = `[data-id="${componentUid}"]`;
39
+ const element = findElementIncludingSelf(document, selector);
40
40
  const removeListener = onListener({
41
41
  event: 'gp:change-open-tab',
42
42
  selector
43
43
  }, (params)=>{
44
- changeOpenTabInteraction(params);
44
+ changeOpenTabInteraction({
45
+ ...params,
46
+ element,
47
+ key: params?.uniqueStorageKey
48
+ });
45
49
  });
46
50
  return ()=>{
47
51
  removeListener?.();
@@ -69,7 +69,7 @@ const config = {
69
69
  id: 'widgetType',
70
70
  label: 'Choose widget',
71
71
  type: 'select',
72
- default: 'bogo',
72
+ default: 'bogo_offer',
73
73
  options: QikifyUpsell.WidgetOptions
74
74
  },
75
75
  {
@@ -1,7 +1,7 @@
1
1
  import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClassName, composeTypographyStyle, composeBorderCss, composeCornerCss, getSingleColorVariable, template, cls, getGlobalColorStateClass, getGlobalColorStateStyle, composeRadius, getStyleShadowState, composeSize, getGradientBgrStyleForButton, RenderIf } from '@gem-sdk/core';
2
2
  import { getInsertLinkData, getDynamicSourceLocales } from '../../helpers.js';
3
3
 
4
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId })=>{
4
+ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
5
5
  const { align, size, backgroundColor, textColor, roundedBtn, iconSpacing, globalSize } = styles;
6
6
  const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
7
7
  const [wrapStyle, restStyle] = splitStyle([
@@ -66,7 +66,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
66
66
  color: ${getSingleColorVariable(styles?.textColor?.hover)};
67
67
  }
68
68
  `;
69
- const labelValDisplay = getDynamicSourceLocales({
69
+ const labelValDisplay = isForceValue ? label : getDynamicSourceLocales({
70
70
  val: label,
71
71
  uid: builderProps?.uidTranslate ?? builderProps?.uid,
72
72
  settingId: translate ?? 'label',
@@ -160,7 +160,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
160
160
  >${iconSvg}</span>`)}
161
161
  <span
162
162
  data-gp-text
163
- class="${`gp-button-text-only gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
163
+ class="${`gp-content-product-button gp-button-text-only gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
164
164
  ${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
165
165
  style="${{
166
166
  ...nodePrice && appendTypoStyle,
@@ -2,7 +2,7 @@ import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClass
2
2
  import { getInsertLinkData, getDynamicSourceLocales, getSettingPreloadData } from '../../../helpers.js';
3
3
  import { useButtonCustomCss } from '../../hooks/useButtonCustomCss.js';
4
4
 
5
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId })=>{
5
+ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
6
6
  const { align, size, backgroundImage, backgroundColorV2, textColor, textColorHover, roundedBtnV2, iconSpacing, globalSize } = styles;
7
7
  const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
8
8
  const [wrapStyle, restStyle] = splitStyle([
@@ -42,7 +42,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
42
42
  styles,
43
43
  builderProps
44
44
  });
45
- const labelValDisplay = getDynamicSourceLocales({
45
+ const labelValDisplay = isForceValue ? label : getDynamicSourceLocales({
46
46
  val: label,
47
47
  uid: builderProps?.uidTranslate ?? builderProps?.uid,
48
48
  settingId: translate ?? 'label',
@@ -0,0 +1,8 @@
1
+ const getContainerAttrs = ({ currentProductId, uid })=>{
2
+ return {
3
+ id: `shopify-text-element-${uid}`,
4
+ 'data-product-id': currentProductId || ''
5
+ };
6
+ };
7
+
8
+ export { getContainerAttrs };
@@ -0,0 +1,10 @@
1
+ import { composeClasses } from '@gem-sdk/core';
2
+
3
+ const getContainerClasses = ({ uid })=>{
4
+ return {
5
+ ...composeClasses(uid),
6
+ ...composeClasses('gp-flex gp-w-full')
7
+ };
8
+ };
9
+
10
+ export { getContainerClasses };
@@ -0,0 +1,7 @@
1
+ const getTextSettings = ({ hasDiscount, message })=>{
2
+ return {
3
+ text: hasDiscount ? message : message?.replace(new RegExp(/\{\{Discount\}\}/, 'gi'), '0%')
4
+ };
5
+ };
6
+
7
+ export { getTextSettings };
@@ -0,0 +1,8 @@
1
+ const getContainerStyles = ({ style, hasDiscount })=>{
2
+ return {
3
+ ...style,
4
+ opacity: hasDiscount ? 1 : 0.2
5
+ };
6
+ };
7
+
8
+ export { getContainerStyles };
@@ -1,33 +1,54 @@
1
1
  'use client';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useProduct, useProductOfferDiscount, cls } from '@gem-sdk/core';
3
+ import { useProduct, useProductOfferDiscount } from '@gem-sdk/core';
4
4
  import Text from '../../text/components/Text.js';
5
5
  import { useDynamicProduct } from '../hooks/useDynamicProduct.js';
6
+ import { createClass, createAttr, createStyle } from '@gem-sdk/system';
7
+ import { getContainerAttrs } from '../common/getAttrs.js';
8
+ import { getContainerClasses } from '../common/getClasses.js';
9
+ import { getContainerStyles } from '../common/getStyles.js';
10
+ import { getTextSettings } from '../common/getSettings.js';
6
11
 
7
12
  const PostPurchaseProductDiscountTag = ({ setting = {}, styles = {}, style, builderAttrs, builderProps, children })=>{
8
13
  const currentProduct = useProduct();
9
14
  const currentProductId = currentProduct?.baseID?.replace('gid://shopify/Product/', '');
10
15
  const currentOfferDiscount = useProductOfferDiscount();
11
16
  const { isDynamicProduct, isEnableDynamicDiscount } = useDynamicProduct();
12
- const { typo } = styles;
17
+ const { typo, direction } = styles;
13
18
  const { message } = setting;
14
19
  const hasDiscount = !!currentOfferDiscount || isDynamicProduct && isEnableDynamicDiscount;
20
+ const containerClasses = createClass({
21
+ ...getContainerClasses({
22
+ uid: builderProps?.uid
23
+ })
24
+ });
25
+ const containerAttrs = createAttr({
26
+ ...getContainerAttrs({
27
+ ...builderAttrs,
28
+ currentProductId,
29
+ uid: builderProps?.uid
30
+ })
31
+ });
32
+ const containerStyles = createStyle({
33
+ ...getContainerStyles({
34
+ style,
35
+ hasDiscount
36
+ })
37
+ });
38
+ const textSettings = getTextSettings({
39
+ hasDiscount,
40
+ message
41
+ });
15
42
  return /*#__PURE__*/ jsxs("div", {
16
- ...builderAttrs,
17
- className: cls(builderProps?.uid, 'gp-flex gp-w-full'),
18
- style: {
19
- ...style,
20
- opacity: hasDiscount ? 1 : 0.2
21
- },
22
- id: `shopify-text-element-${builderProps?.uid}`,
23
- "data-product-id": currentProductId,
43
+ ...containerAttrs,
44
+ className: containerClasses,
45
+ style: containerStyles,
24
46
  children: [
25
47
  /*#__PURE__*/ jsx(Text, {
26
- setting: {
27
- text: hasDiscount ? message : message?.replace(new RegExp(/\{\{Discount\}\}/, 'gi'), '0%')
28
- },
48
+ setting: textSettings,
29
49
  styles: {
30
- typo
50
+ typo,
51
+ direction
31
52
  }
32
53
  }),
33
54
  children
@@ -6,7 +6,7 @@ import config$3 from './product-variants/ProductVariant.js';
6
6
  import config$5 from './product-quantity/index.js';
7
7
  import config$7 from './ProductOffer.js';
8
8
  import config$6 from './product-price-breakdown/index.js';
9
- import config$8 from './ProductDiscountTag.js';
9
+ import config$8 from './product-discount-tag/ProductDiscountTag.js';
10
10
  import config$9 from './product-image/ProductImages.js';
11
11
 
12
12
  var postPurchaseProductSetting = {
@@ -1,96 +1,14 @@
1
+ import { settingV2 } from './settingV2.js';
2
+ import { uiV1 } from './uiV1.js';
3
+ import { uiV2 } from './uiV2.js';
4
+
1
5
  const config = {
2
6
  tag: 'PostPurchaseProductDiscountTag',
3
7
  label: 'Discount Tag',
4
8
  icon: ``,
5
- settings: [
6
- {
7
- id: 'setting',
8
- controls: [
9
- {
10
- id: 'discountAndShippingFee',
11
- type: 'discount-and-shipping-fee-product-offer',
12
- multiple: false
13
- },
14
- {
15
- id: 'message',
16
- label: '',
17
- type: 'textarea',
18
- autoHeight: true,
19
- default: '(Save {{Discount}})',
20
- suggestContents: [
21
- {
22
- message: '{{Discount}}',
23
- eg: '20%'
24
- }
25
- ]
26
- }
27
- ]
28
- },
29
- {
30
- id: 'style',
31
- controls: [
32
- {
33
- id: 'typo',
34
- label: 'Label',
35
- type: 'typography-post-purchase',
36
- default: {
37
- fontSize: 'default',
38
- textColor: 'critical',
39
- fontWeight: 'bold',
40
- textTransform: 'none'
41
- }
42
- }
43
- ]
44
- }
45
- ],
46
- ui: [
47
- {
48
- type: 'group',
49
- label: {
50
- en: ''
51
- },
52
- controls: [
53
- {
54
- type: 'control',
55
- label: {
56
- en: ''
57
- },
58
- setting: {
59
- id: 'discountAndShippingFee'
60
- },
61
- layout: 'vertical'
62
- }
63
- ]
64
- },
65
- {
66
- type: 'group',
67
- label: {
68
- en: 'Text'
69
- },
70
- controls: [
71
- {
72
- type: 'control',
73
- label: {
74
- en: ''
75
- },
76
- setting: {
77
- id: 'message'
78
- },
79
- layout: 'vertical'
80
- },
81
- {
82
- type: 'control',
83
- label: {
84
- en: ''
85
- },
86
- setting: {
87
- id: 'typo'
88
- },
89
- layout: 'vertical'
90
- }
91
- ]
92
- }
93
- ],
9
+ settings: settingV2,
10
+ ui: uiV1,
11
+ uiV2: uiV2,
94
12
  editorConfigs: {
95
13
  placeholder: {
96
14
  flowTag: [
@@ -0,0 +1,61 @@
1
+ const settingV2 = [
2
+ {
3
+ id: 'setting',
4
+ controls: [
5
+ {
6
+ id: 'discountAndShippingFee',
7
+ type: 'discount-and-shipping-fee-product-offer',
8
+ multiple: false
9
+ },
10
+ {
11
+ id: 'message',
12
+ label: '',
13
+ type: 'textarea',
14
+ defaultRows: 4,
15
+ showPlusBtn: true,
16
+ autoHeight: true,
17
+ default: '(Save {{Discount}})',
18
+ suggestContents: [
19
+ {
20
+ message: '{{Discount}}',
21
+ eg: '20%'
22
+ }
23
+ ]
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ id: 'style',
29
+ controls: [
30
+ {
31
+ id: 'direction',
32
+ label: 'Direction',
33
+ type: 'segment',
34
+ options: [
35
+ {
36
+ label: 'LTR',
37
+ value: 'ltr'
38
+ },
39
+ {
40
+ label: 'RTL',
41
+ value: 'rtl'
42
+ }
43
+ ],
44
+ default: 'ltr'
45
+ },
46
+ {
47
+ id: 'typo',
48
+ label: 'Label',
49
+ type: 'typography-post-purchase',
50
+ default: {
51
+ fontSize: 'default',
52
+ textColor: 'critical',
53
+ fontWeight: 'bold',
54
+ textTransform: 'none'
55
+ }
56
+ }
57
+ ]
58
+ }
59
+ ];
60
+
61
+ export { settingV2 };
@@ -0,0 +1,50 @@
1
+ const uiV1 = [
2
+ {
3
+ type: 'group',
4
+ label: {
5
+ en: ''
6
+ },
7
+ controls: [
8
+ {
9
+ type: 'control',
10
+ label: {
11
+ en: ''
12
+ },
13
+ setting: {
14
+ id: 'discountAndShippingFee'
15
+ },
16
+ layout: 'vertical'
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ type: 'group',
22
+ label: {
23
+ en: 'Text'
24
+ },
25
+ controls: [
26
+ {
27
+ type: 'control',
28
+ label: {
29
+ en: ''
30
+ },
31
+ setting: {
32
+ id: 'message'
33
+ },
34
+ layout: 'vertical'
35
+ },
36
+ {
37
+ type: 'control',
38
+ label: {
39
+ en: ''
40
+ },
41
+ setting: {
42
+ id: 'typo'
43
+ },
44
+ layout: 'vertical'
45
+ }
46
+ ]
47
+ }
48
+ ];
49
+
50
+ export { uiV1 };
@@ -0,0 +1,65 @@
1
+ const uiV2 = [
2
+ {
3
+ controls: [
4
+ {
5
+ type: 'control',
6
+ label: {
7
+ en: ''
8
+ },
9
+ setting: {
10
+ id: 'discountAndShippingFee'
11
+ },
12
+ layout: 'vertical'
13
+ }
14
+ ]
15
+ },
16
+ {
17
+ label: {
18
+ en: 'Text'
19
+ },
20
+ controls: [
21
+ {
22
+ type: 'control',
23
+ label: {
24
+ en: 'Direction'
25
+ },
26
+ setting: {
27
+ id: 'direction'
28
+ }
29
+ },
30
+ {
31
+ type: 'combo',
32
+ label: {
33
+ en: 'Content'
34
+ },
35
+ iconName: 'polaris-text-block',
36
+ getValueFromSettingID: 'message',
37
+ isHideClear: true,
38
+ controls: [
39
+ {
40
+ label: {
41
+ en: 'Content'
42
+ },
43
+ setting: {
44
+ id: 'message'
45
+ },
46
+ layout: 'vertical'
47
+ }
48
+ ],
49
+ layout: 'horizontal'
50
+ },
51
+ {
52
+ type: 'control',
53
+ label: {
54
+ en: ''
55
+ },
56
+ setting: {
57
+ id: 'typo'
58
+ },
59
+ layout: 'vertical'
60
+ }
61
+ ]
62
+ }
63
+ ];
64
+
65
+ export { uiV2 };
@@ -349,7 +349,7 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
349
349
  'gp-data-hidden': `{% if variant.available %}true{% endif %}`
350
350
  },
351
351
  setting: {
352
- label: labelOutOfStockTranslate,
352
+ label: `${pageContext?.isPreviewing ? labelOutOfStockTranslate : `{{${labelOutOfStockTranslate}}}`}`,
353
353
  htmlType: 'button',
354
354
  iconAlign: iconAlign,
355
355
  iconSvg: iconSvg,
@@ -368,7 +368,8 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
368
368
  }
369
369
  },
370
370
  pageContext,
371
- nodePrice: composeNodePrice()
371
+ nodePrice: composeNodePrice(),
372
+ isForceValue: true
372
373
  })}
373
374
  </gp-product-button>
374
375
  ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-button.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-product-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
@@ -1,20 +1,19 @@
1
1
  import { useInteraction, useEditorMode } from '@gem-sdk/core';
2
- import { useState, useEffect } from 'react';
2
+ import { useEffect } from 'react';
3
3
 
4
4
  const useTabInteraction = ({ activeKey, setActiveKey, activeTab, refContainer, componentUid })=>{
5
- const [previousTab, setPreviousTab] = useState(activeKey || 1);
6
- const { trigger, onListener, interactionListenerLoaded } = useInteraction();
5
+ const { trigger, onListener, interactionListenerLoaded, saveToElementInteractionData, findElementIncludingSelf } = useInteraction();
7
6
  const mode = useEditorMode();
8
7
  const changeOpenTabInteraction = (params)=>{
9
- const { data, isRollback } = params || {};
10
- if (data === undefined && isRollback === undefined) return;
8
+ const { data, isRollback, element, key } = params || {};
9
+ if (data === undefined && isRollback) return;
10
+ const newData = Number(data) + 1;
11
11
  if (isRollback) {
12
- setActiveKey(previousTab);
13
- setPreviousTab(activeTab);
12
+ setActiveKey(newData);
14
13
  return;
15
14
  }
16
- setPreviousTab(activeTab);
17
- setActiveKey(data + 1);
15
+ saveToElementInteractionData(element, key, String(activeKey));
16
+ setActiveKey(newData);
18
17
  };
19
18
  const dispatchEventTabActive = (index)=>{
20
19
  trigger({
@@ -35,11 +34,16 @@ const useTabInteraction = ({ activeKey, setActiveKey, activeTab, refContainer, c
35
34
  dispatchEventTabActive(activeTab - 1);
36
35
  });
37
36
  const selector = `[data-id="${componentUid}"]`;
37
+ const element = findElementIncludingSelf(document, selector);
38
38
  const removeListener = onListener({
39
39
  event: 'gp:change-open-tab',
40
40
  selector
41
41
  }, (params)=>{
42
- changeOpenTabInteraction(params);
42
+ changeOpenTabInteraction({
43
+ ...params,
44
+ element,
45
+ key: params?.uniqueStorageKey
46
+ });
43
47
  });
44
48
  return ()=>{
45
49
  removeListener?.();
@@ -65,7 +65,7 @@ const config = {
65
65
  id: 'widgetType',
66
66
  label: 'Choose widget',
67
67
  type: 'select',
68
- default: 'bogo',
68
+ default: 'bogo_offer',
69
69
  options: WidgetOptions
70
70
  },
71
71
  {
@@ -4748,6 +4748,19 @@ declare const PostPurchaseProductQuantity: React.FC<PostPurchaseProductQuantityP
4748
4748
 
4749
4749
  type PostPurchaseTextColor = 'critical' | 'warning' | 'success' | 'defaultButton' | 'defaultLink' | 'default' | 'boldDefault' | 'info' | undefined;
4750
4750
 
4751
+ type Styles$1 = {
4752
+ typo?: PostPurchaseTypo;
4753
+ direction?: 'ltr' | 'rtl';
4754
+ };
4755
+ type ProductDiscountTagSettings = {
4756
+ message?: string;
4757
+ discountAndShippingFee?: boolean;
4758
+ };
4759
+ type PostPurchaseProductDiscountTagProps = BasePropsWrap<ProductDiscountTagSettings, Styles$1> & {
4760
+ advanced?: AdvancedType;
4761
+ children?: ReactNode;
4762
+ };
4763
+
4751
4764
  type VariantTypeof = 'dropdown' | 'rectangle_list' | 'image_shopify' | 'color' | 'image' | string;
4752
4765
  type VariantBaseSetting = {
4753
4766
  fullWidth?: Partial<Record<NameDevices, boolean>>;
@@ -4787,7 +4800,7 @@ declare const PostPurchaseProductOffer: React.FC<PostPurchaseProductOfferProps>;
4787
4800
 
4788
4801
  type Spacing = 'none' | 'xtight' | 'tight' | 'loose' | 'xloose' | undefined;
4789
4802
 
4790
- type Settings$1 = {
4803
+ type Settings = {
4791
4804
  subTotalLabel?: string;
4792
4805
  discountLabel?: string;
4793
4806
  shippingLabel?: string;
@@ -4797,7 +4810,7 @@ type Settings$1 = {
4797
4810
  contentShow?: string;
4798
4811
  contentHide?: string;
4799
4812
  };
4800
- type Styles$1 = {
4813
+ type Styles = {
4801
4814
  labelStyle?: PostPurchaseTypo;
4802
4815
  moneyStyle?: PostPurchaseTypo;
4803
4816
  align?: 'left' | 'right' | 'center';
@@ -4811,24 +4824,13 @@ type Styles$1 = {
4811
4824
  isShowTotalLabel?: boolean;
4812
4825
  direction?: 'ltr' | 'rtl';
4813
4826
  };
4814
- type PostPurchaseProductPriceBreakdownProps$1 = BasePropsWrap<Settings$1, Styles$1> & {
4827
+ type PostPurchaseProductPriceBreakdownProps$1 = BasePropsWrap<Settings, Styles> & {
4815
4828
  advanced?: AdvancedType;
4816
4829
  children?: ReactNode;
4817
4830
  };
4818
4831
 
4819
4832
  declare const PostPurchaseProductPriceBreakdown: React.FC<PostPurchaseProductPriceBreakdownProps$1>;
4820
4833
 
4821
- type Settings = {
4822
- message?: string;
4823
- discountAndShippingFee?: boolean;
4824
- };
4825
- type Styles = {
4826
- typo?: PostPurchaseTypo;
4827
- };
4828
- type PostPurchaseProductDiscountTagProps = BasePropsWrap<Settings, Styles> & {
4829
- advanced?: AdvancedType;
4830
- children?: ReactNode;
4831
- };
4832
4834
  declare const PostPurchaseProductDiscountTag: React.FC<PostPurchaseProductDiscountTagProps>;
4833
4835
 
4834
4836
  type FeatureImagStyle = {
@@ -5591,10 +5593,11 @@ type ButtonLiquidProps$1 = MixedProps$1 & ButtonProps & {
5591
5593
  advanced?: any;
5592
5594
  pageContext?: PageContext;
5593
5595
  nodePrice?: string | null;
5596
+ isForceValue?: boolean;
5594
5597
  } & {
5595
5598
  dataId?: string;
5596
5599
  };
5597
- declare const Button$1: ({ className, builderProps, customAttrs, pageContext, setting, styles, style, wrapClassName, advanced, nodePrice, dataId, }: ButtonLiquidProps$1) => string;
5600
+ declare const Button$1: ({ className, builderProps, customAttrs, pageContext, setting, styles, style, wrapClassName, advanced, nodePrice, dataId, isForceValue, }: ButtonLiquidProps$1) => string;
5598
5601
 
5599
5602
  type MixedProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'children'> | Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children' | 'href' | 'type'>;
5600
5603
  type ButtonLiquidProps = MixedProps & ButtonProps$1 & {
@@ -5602,10 +5605,11 @@ type ButtonLiquidProps = MixedProps & ButtonProps$1 & {
5602
5605
  advanced?: any;
5603
5606
  pageContext?: PageContext;
5604
5607
  nodePrice?: string | null;
5608
+ isForceValue?: boolean;
5605
5609
  } & {
5606
5610
  dataId?: string;
5607
5611
  };
5608
- declare const Button: ({ className, builderProps, customAttrs, pageContext, setting, styles, style, wrapClassName, advanced, nodePrice, dataId, }: ButtonLiquidProps) => string;
5612
+ declare const Button: ({ className, builderProps, customAttrs, pageContext, setting, styles, style, wrapClassName, advanced, nodePrice, dataId, isForceValue, }: ButtonLiquidProps) => string;
5609
5613
 
5610
5614
  declare const Coupon: ({ setting, builderProps, builderAttrs, style, styles, advanced, pageContext, }: _gem_sdk_core.BaseProps<{
5611
5615
  copyContent?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.244",
3
+ "version": "2.0.0-dev.247",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",