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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/cjs/article/components/ArticleReadMore.js +2 -4
  2. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +5 -5
  3. package/dist/cjs/builder.js +17 -21
  4. package/dist/cjs/button/components/Button.js +111 -184
  5. package/dist/cjs/button/components/Button.liquid.js +108 -171
  6. package/dist/cjs/button/components/ButtonIcon.js +17 -0
  7. package/dist/cjs/button/components/ButtonIcon.liquid.js +16 -0
  8. package/dist/cjs/button/components/ButtonLabel.js +18 -0
  9. package/dist/cjs/button/components/ButtonLabel.liquid.js +15 -0
  10. package/dist/cjs/button/components/ButtonLoadingIndicator.liquid.js +12 -0
  11. package/dist/cjs/button/components/common/attributes.js +15 -0
  12. package/dist/cjs/button/components/common/classes.js +55 -0
  13. package/dist/cjs/button/components/common/constants.js +26 -0
  14. package/dist/cjs/button/components/common/data.js +76 -0
  15. package/dist/cjs/button/components/common/helpers.js +131 -0
  16. package/dist/cjs/button/components/common/styles.js +157 -0
  17. package/dist/cjs/button/next.js +2 -6
  18. package/dist/cjs/button/setting/configs/settings.js +5 -1
  19. package/dist/cjs/cart/components/CheckoutNow.js +0 -2
  20. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.js +70 -0
  21. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.liquid.js +71 -0
  22. package/dist/cjs/cart/components/ShopPayButton/common/classes.js +18 -0
  23. package/dist/cjs/cart/components/ShopPayButton/common/helpers.js +31 -0
  24. package/dist/cjs/cart/components/ShopPayButton/common/styles.js +12 -0
  25. package/dist/cjs/cart/components/ShopPayButton/hooks/useShopPayButton.js +70 -0
  26. package/dist/cjs/cart/next.js +1 -1
  27. package/dist/cjs/coupon/components/Coupon.js +1 -3
  28. package/dist/cjs/dialog/setting/Dialog.js +7 -580
  29. package/dist/cjs/dialog/setting/configs/settings.js +325 -0
  30. package/dist/cjs/dialog/setting/configs/uiV1.js +288 -0
  31. package/dist/cjs/dialog/setting/configs/uiV2.js +258 -0
  32. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +4 -4
  33. package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
  34. package/dist/cjs/header/components/kind/basic/index.js +1 -1
  35. package/dist/cjs/header/components/kind/modern/index.js +1 -1
  36. package/dist/cjs/index.js +41 -43
  37. package/dist/cjs/index.liquid.js +10 -12
  38. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +25 -0
  39. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.liquid.js +23 -0
  40. package/dist/cjs/product/components/DynamicCheckout/common/classes.js +32 -0
  41. package/dist/cjs/product/components/DynamicCheckout/common/styles.js +181 -0
  42. package/dist/cjs/product/components/DynamicCheckout/components/Button.liquid.js +58 -0
  43. package/dist/cjs/product/components/DynamicCheckout.js +2 -5
  44. package/dist/cjs/product/components/FileUpload/components/common/index.js +2 -2
  45. package/dist/cjs/product/components/ProductButton.js +2 -3
  46. package/dist/cjs/product/components/ProductButton.liquid.js +3 -3
  47. package/dist/cjs/product/components/ProductDescription/common/const.js +9 -0
  48. package/dist/cjs/product/components/ProductDescription/common/getClasses.js +30 -0
  49. package/dist/cjs/product/components/ProductDescription/common/getStyle.js +81 -0
  50. package/dist/cjs/product/components/ProductDescription/hooks/useGpDescription.js +90 -0
  51. package/dist/cjs/product/components/ProductDescription/index.js +115 -0
  52. package/dist/cjs/product/components/ProductDescription/index.liquid.js +85 -0
  53. package/dist/cjs/product/components/ProductViewMore.js +2 -5
  54. package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
  55. package/dist/cjs/product/next.js +1 -1
  56. package/dist/cjs/setting.js +3 -3
  57. package/dist/cjs/text/components/common/getClasses.js +1 -1
  58. package/dist/cjs/third-party/components/PushOwl.js +0 -5
  59. package/dist/esm/article/components/ArticleReadMore.js +1 -3
  60. package/dist/esm/banner/components/HeroBannerItem.liquid.js +5 -5
  61. package/dist/esm/builder.js +4 -8
  62. package/dist/esm/button/components/Button.js +113 -186
  63. package/dist/esm/button/components/Button.liquid.js +109 -172
  64. package/dist/esm/button/components/ButtonIcon.js +13 -0
  65. package/dist/esm/button/components/ButtonIcon.liquid.js +12 -0
  66. package/dist/esm/button/components/ButtonLabel.js +14 -0
  67. package/dist/esm/button/components/ButtonLabel.liquid.js +11 -0
  68. package/dist/esm/button/components/ButtonLoadingIndicator.liquid.js +8 -0
  69. package/dist/esm/button/components/common/attributes.js +13 -0
  70. package/dist/esm/button/components/common/classes.js +49 -0
  71. package/dist/esm/button/components/common/constants.js +24 -0
  72. package/dist/esm/button/components/common/data.js +74 -0
  73. package/dist/esm/button/components/common/helpers.js +118 -0
  74. package/dist/esm/button/components/common/styles.js +148 -0
  75. package/dist/esm/button/next.js +2 -6
  76. package/dist/esm/button/setting/configs/settings.js +5 -1
  77. package/dist/esm/cart/components/CheckoutNow.js +0 -2
  78. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.js +66 -0
  79. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.liquid.js +67 -0
  80. package/dist/esm/cart/components/ShopPayButton/common/classes.js +15 -0
  81. package/dist/esm/cart/components/ShopPayButton/common/helpers.js +27 -0
  82. package/dist/esm/cart/components/ShopPayButton/common/styles.js +10 -0
  83. package/dist/esm/cart/components/ShopPayButton/hooks/useShopPayButton.js +68 -0
  84. package/dist/esm/cart/next.js +1 -1
  85. package/dist/esm/coupon/components/Coupon.js +1 -3
  86. package/dist/esm/dialog/setting/Dialog.js +7 -580
  87. package/dist/esm/dialog/setting/configs/settings.js +323 -0
  88. package/dist/esm/dialog/setting/configs/uiV1.js +286 -0
  89. package/dist/esm/dialog/setting/configs/uiV2.js +256 -0
  90. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +4 -4
  91. package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
  92. package/dist/esm/header/components/kind/basic/index.js +1 -1
  93. package/dist/esm/header/components/kind/modern/index.js +1 -1
  94. package/dist/esm/index.js +4 -5
  95. package/dist/esm/index.liquid.js +4 -5
  96. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +21 -0
  97. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.liquid.js +19 -0
  98. package/dist/esm/product/components/DynamicCheckout/common/classes.js +30 -0
  99. package/dist/esm/product/components/DynamicCheckout/common/styles.js +179 -0
  100. package/dist/esm/product/components/DynamicCheckout/components/Button.liquid.js +54 -0
  101. package/dist/esm/product/components/DynamicCheckout.js +1 -4
  102. package/dist/esm/product/components/FileUpload/components/common/index.js +2 -2
  103. package/dist/esm/product/components/ProductButton.js +1 -2
  104. package/dist/esm/product/components/ProductButton.liquid.js +1 -1
  105. package/dist/esm/product/components/ProductDescription/common/const.js +6 -0
  106. package/dist/esm/product/components/ProductDescription/common/getClasses.js +27 -0
  107. package/dist/esm/product/components/ProductDescription/common/getStyle.js +77 -0
  108. package/dist/esm/product/components/ProductDescription/hooks/useGpDescription.js +88 -0
  109. package/dist/esm/product/components/ProductDescription/index.js +111 -0
  110. package/dist/esm/product/components/ProductDescription/index.liquid.js +81 -0
  111. package/dist/esm/product/components/ProductViewMore.js +1 -4
  112. package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
  113. package/dist/esm/product/next.js +1 -1
  114. package/dist/esm/setting.js +3 -3
  115. package/dist/esm/text/components/common/getClasses.js +1 -1
  116. package/dist/esm/third-party/components/PushOwl.js +0 -5
  117. package/dist/types/index.d.ts +200 -360
  118. package/package.json +2 -2
  119. package/dist/cjs/button/components/v2/ButtonIcon.js +0 -18
  120. package/dist/cjs/button/components/v2/ButtonLabel.js +0 -25
  121. package/dist/cjs/button/components/v2/ButtonV2.js +0 -140
  122. package/dist/cjs/button/components/v2/ButtonV2.liquid.js +0 -181
  123. package/dist/cjs/button/hooks/useButtonCustomCss.js +0 -88
  124. package/dist/cjs/button/hooks/useButtonStyles.js +0 -93
  125. package/dist/cjs/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -20
  126. package/dist/cjs/cart/components/ShopPayButton/index.js +0 -113
  127. package/dist/cjs/cart/components/ShopPayButton/index.liquid.js +0 -51
  128. package/dist/cjs/product/components/DynamicCheckout.liquid.js +0 -250
  129. package/dist/cjs/product/components/ProductDescription/const.js +0 -5
  130. package/dist/cjs/product/components/ProductDescription.js +0 -172
  131. package/dist/cjs/product/components/ProductDescription.liquid.js +0 -120
  132. package/dist/esm/button/components/v2/ButtonIcon.js +0 -14
  133. package/dist/esm/button/components/v2/ButtonLabel.js +0 -21
  134. package/dist/esm/button/components/v2/ButtonV2.js +0 -136
  135. package/dist/esm/button/components/v2/ButtonV2.liquid.js +0 -177
  136. package/dist/esm/button/hooks/useButtonCustomCss.js +0 -84
  137. package/dist/esm/button/hooks/useButtonStyles.js +0 -91
  138. package/dist/esm/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -17
  139. package/dist/esm/cart/components/ShopPayButton/index.js +0 -109
  140. package/dist/esm/cart/components/ShopPayButton/index.liquid.js +0 -47
  141. package/dist/esm/product/components/DynamicCheckout.liquid.js +0 -246
  142. package/dist/esm/product/components/ProductDescription/const.js +0 -3
  143. package/dist/esm/product/components/ProductDescription.js +0 -168
  144. package/dist/esm/product/components/ProductDescription.liquid.js +0 -116
  145. /package/dist/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  146. /package/dist/cjs/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
  147. /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  148. /package/dist/esm/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+ var helpers = require('../../../helpers.js');
5
+ var Link = require('../../../link/components/Link.js');
6
+
7
+ const getCleanedStyles = (styles, disabled)=>{
8
+ if (!disabled) return styles;
9
+ const cleanedStyles = {
10
+ ...styles
11
+ };
12
+ const states = [
13
+ 'hover',
14
+ 'focus'
15
+ ];
16
+ const devices = [
17
+ 'tablet',
18
+ 'mobile',
19
+ 'desktop'
20
+ ];
21
+ devices.forEach((device)=>{
22
+ states.forEach((state)=>{
23
+ delete cleanedStyles?.backgroundColorV2?.[device]?.[state];
24
+ });
25
+ });
26
+ return cleanedStyles;
27
+ };
28
+ const handleGetLabelToDisplay = ({ label, styles, translate, pageContext, isForceValue, builderProps, isLiquid = false })=>{
29
+ const liquidLabel = isForceValue ? label : helpers.getDynamicSourceLocales({
30
+ translate,
31
+ val: label,
32
+ pageContext,
33
+ settingId: translate ?? 'label',
34
+ uid: builderProps?.uidTranslate ?? builderProps?.uid,
35
+ isCapitalize: styles?.typo?.attrs?.transform === 'capitalize'
36
+ });
37
+ return isLiquid ? liquidLabel?.toString() ?? '' : core.convertHTML(label);
38
+ };
39
+ const checkIsShowIcon = (iconSvg, iconVisible)=>{
40
+ return !!iconSvg && iconVisible;
41
+ };
42
+ const handleCheckIsShowLabel = (labelToDisplay, shouldClearSpace)=>{
43
+ return !!labelToDisplay || !shouldClearSpace;
44
+ };
45
+ const handleCheckIsEditableLabel = ({ mode, options, isLiquid = false })=>{
46
+ return isLiquid ? !options?.isCannotEditing : mode === 'edit' && !options?.isCannotEditing;
47
+ };
48
+ const checkIsScrollToElement = (btnLink)=>{
49
+ return btnLink?.link?.startsWith('#') && btnLink?.target === '_self';
50
+ };
51
+ const getButtonWrapper = (Wrap, isScrollToElement)=>{
52
+ return isScrollToElement ? 'button' : Wrap;
53
+ };
54
+ const getSplitStyles = (style)=>{
55
+ return core.splitStyle([
56
+ 'pos',
57
+ 'top',
58
+ 'left',
59
+ 'bottom',
60
+ 'right',
61
+ 'z'
62
+ ], style);
63
+ };
64
+ const getDataState = (isLoading)=>{
65
+ return isLoading ? 'loading' : 'idle';
66
+ };
67
+ const getDataId = (uidInteraction, dataId, uid)=>{
68
+ return uidInteraction ?? (dataId || uid) ?? '';
69
+ };
70
+ const handleGetArialLabel = ({ label, isLiquid = false })=>{
71
+ return isLiquid ? label?.toString().replaceAll("'", ''').replaceAll('"', "'") ?? '' : label?.toString() ?? '';
72
+ };
73
+ const getInsertLinkData = ({ setting, htmlType, defaultTag, isLiquid = false })=>{
74
+ const URL_INCLUDES = [
75
+ 'product.url'
76
+ ];
77
+ const URL_START_WITH = [
78
+ '#',
79
+ 'mailto:',
80
+ 'tel:'
81
+ ];
82
+ const urlHref = setting?.link ?? '';
83
+ const isHomePageHref = urlHref === '/';
84
+ const isHyperlink = setting?.link !== undefined && setting.link !== '';
85
+ const regexHttp = new RegExp(/^https?:\/\//i);
86
+ const isDomain = isHyperlink && regexHttp.test(urlHref);
87
+ const regexPageType = new RegExp(/^\/?(?:collections|pages|products|blogs|checkout|cart)\/?/i);
88
+ const isShopifyDomain = isHyperlink && !regexHttp.test(urlHref) && regexPageType.test(urlHref);
89
+ const isLink = ()=>{
90
+ if (URL_INCLUDES.find((el)=>urlHref.includes(el))) return true;
91
+ if (URL_START_WITH.find((el)=>urlHref.startsWith(el))) return true;
92
+ return false;
93
+ };
94
+ const shouldRenderLink = isDomain || isShopifyDomain || isLink() || isHomePageHref;
95
+ let transformedUrl = urlHref;
96
+ if (isLiquid && (isShopifyDomain || isHomePageHref)) {
97
+ transformedUrl = setting?.isTranslate ? '$locationOrigin' + urlHref : "{{ request.origin }}{{ routes.root_url | split: '/' | join: '/' }}" + urlHref;
98
+ }
99
+ const HTMLTag = shouldRenderLink ? isLiquid ? 'a' : Link.default : defaultTag;
100
+ const baseUrlData = {
101
+ href: transformedUrl,
102
+ target: setting?.target,
103
+ ...setting?.noFollow && {
104
+ rel: 'nofollow'
105
+ }
106
+ };
107
+ const urlData = shouldRenderLink ? baseUrlData : isHyperlink ? {
108
+ ...baseUrlData,
109
+ type: htmlType
110
+ } : {
111
+ type: htmlType
112
+ };
113
+ return {
114
+ HTMLTag,
115
+ urlData,
116
+ shouldRenderLink
117
+ };
118
+ };
119
+
120
+ exports.checkIsScrollToElement = checkIsScrollToElement;
121
+ exports.checkIsShowIcon = checkIsShowIcon;
122
+ exports.getButtonWrapper = getButtonWrapper;
123
+ exports.getCleanedStyles = getCleanedStyles;
124
+ exports.getDataId = getDataId;
125
+ exports.getDataState = getDataState;
126
+ exports.getInsertLinkData = getInsertLinkData;
127
+ exports.getSplitStyles = getSplitStyles;
128
+ exports.handleCheckIsEditableLabel = handleCheckIsEditableLabel;
129
+ exports.handleCheckIsShowLabel = handleCheckIsShowLabel;
130
+ exports.handleGetArialLabel = handleGetArialLabel;
131
+ exports.handleGetLabelToDisplay = handleGetLabelToDisplay;
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const MEDIA_QUERIES = {
6
+ TABLET: '@media only screen and (max-width: 1024px) and (min-width: 768px)',
7
+ MOBILE: '@media only screen and (max-width: 767px)'
8
+ };
9
+ const getButtonWrapperStyles = (style, styles)=>({
10
+ ...style,
11
+ ...core.makeStyleResponsive('ta', styles?.align)
12
+ });
13
+ const getButtonStyles = (styles, nodePrice)=>({
14
+ ...getSizeStyles(styles),
15
+ ...getRadiusStyles(styles),
16
+ ...getShadowStyles(styles),
17
+ ...getBackgroundStyles(styles),
18
+ ...getTypoStyles(styles, nodePrice)
19
+ });
20
+ const getButtonIconStyles = (styles, settings)=>({
21
+ ...getIconSpacingStyle(styles, settings),
22
+ '--height-desktop': `${styles?.size?.desktop}`,
23
+ '--height-tablet': `${styles?.size?.desktop || styles?.size?.tablet}`,
24
+ '--height-mobile': `${styles?.size?.mobile || styles?.size?.tablet || styles?.size?.desktop}`
25
+ });
26
+ const isEnableShadowStateForDevice = (deviceStyles)=>({
27
+ normal: deviceStyles?.normal?.type !== 'none',
28
+ hover: deviceStyles?.hover?.type !== 'none'
29
+ });
30
+ const getShadowStyles = (styles)=>{
31
+ const { boxShadowBtnV2 } = styles || {};
32
+ return {
33
+ ...core.getStyleShadowState(boxShadowBtnV2?.desktop, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.desktop)),
34
+ ...core.getStyleShadowState(boxShadowBtnV2?.tablet, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.tablet), 'tablet'),
35
+ ...core.getStyleShadowState(boxShadowBtnV2?.mobile, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.mobile), 'mobile')
36
+ };
37
+ };
38
+ const getRadiusStyles = (styles)=>core.composeRadius(styles?.roundedBtnV2);
39
+ const getIconSpacingStyle = (styles, settings)=>{
40
+ const spacing = styles?.iconSpacing || {
41
+ desktop: '8px'
42
+ };
43
+ return settings?.iconAlign === 'left' ? core.makeStyleResponsive('mr', spacing) : core.makeStyleResponsive('ml', spacing);
44
+ };
45
+ const getSizeStyles = (styles)=>{
46
+ const composeGlobalSize = core.makeGlobalSize(styles?.globalSize);
47
+ return {
48
+ ...composeGlobalSize.width,
49
+ ...composeGlobalSize.height,
50
+ ...composeGlobalSize.padding
51
+ };
52
+ };
53
+ const getTypoStyles = (styles, nodePrice)=>{
54
+ const appendTypoStyle = {
55
+ ...core.makeStyleResponsiveState('c', styles?.textColorHover),
56
+ ...core.composeTypographyStyle(styles?.typo, styles?.typography)
57
+ };
58
+ return {
59
+ ...!nodePrice && appendTypoStyle,
60
+ ...core.getGlobalColorStateStyle('c', styles?.textColor),
61
+ ...core.getStyleShadow({
62
+ styleAppliedFor: 'text-shadow',
63
+ value: styles?.typo?.custom?.textShadow,
64
+ isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
65
+ })
66
+ };
67
+ };
68
+ const getBackgroundStyles = (styles)=>{
69
+ return {
70
+ ...core.getStyleBackgroundImageByDevice(styles?.backgroundImage),
71
+ ...core.getGlobalColorStateResponsiveStyle('bg', styles?.backgroundColorV2)
72
+ };
73
+ };
74
+ const getCustomCssStyles = ({ styles, uid })=>{
75
+ if (!uid) return '';
76
+ const { borderBtnV2, roundedBtnV2, textColor } = styles ?? {};
77
+ const borderCornerStyles = {
78
+ desktop: generateBorderCornerStyles({
79
+ uid,
80
+ device: 'desktop',
81
+ borderBtn: borderBtnV2,
82
+ roundedBtn: roundedBtnV2
83
+ }),
84
+ tablet: generateBorderCornerStyles({
85
+ uid,
86
+ device: 'tablet',
87
+ borderBtn: borderBtnV2,
88
+ roundedBtn: roundedBtnV2
89
+ }),
90
+ mobile: generateBorderCornerStyles({
91
+ uid,
92
+ device: 'mobile',
93
+ borderBtn: borderBtnV2,
94
+ roundedBtn: roundedBtnV2
95
+ })
96
+ };
97
+ const colorStyles = generateColorStyles(uid, textColor);
98
+ return `
99
+ ${borderCornerStyles.desktop.normalStyles}
100
+ ${borderCornerStyles.desktop.hoverStyles}
101
+
102
+ ${MEDIA_QUERIES.TABLET} {
103
+ ${borderCornerStyles.tablet.normalStyles}
104
+ ${borderCornerStyles.tablet.hoverStyles}
105
+ }
106
+
107
+ ${MEDIA_QUERIES.MOBILE} {
108
+ ${borderCornerStyles.mobile.normalStyles}
109
+ ${borderCornerStyles.mobile.hoverStyles}
110
+ }
111
+
112
+ ${colorStyles}
113
+ `.trim();
114
+ };
115
+ const generateBorderCornerStyles = ({ uid, device, borderBtn, roundedBtn })=>{
116
+ const normalStyles = `
117
+ .${uid}.gp-button-base::before {
118
+ content: "";
119
+ height: 100%;
120
+ width: 100%;
121
+ position: absolute;
122
+ pointer-events: none;
123
+ ${core.composeBorderCss(borderBtn?.[device]?.normal)}
124
+ ${core.composeCornerCss(roundedBtn?.[device]?.normal)}
125
+ }
126
+ `;
127
+ const hoverStyles = `
128
+ .${uid}:hover::before {
129
+ ${core.composeBorderCss(borderBtn?.[device]?.hover)}
130
+ ${core.composeCornerCss(roundedBtn?.[device]?.hover)}
131
+ }
132
+ `;
133
+ return {
134
+ normalStyles,
135
+ hoverStyles
136
+ };
137
+ };
138
+ const generateColorStyles = (uid, textColor)=>`
139
+ .${uid}:hover .gp-button-price,
140
+ .${uid}:hover .gp-product-dot-price {
141
+ color: ${core.getSingleColorVariable(textColor?.hover)};
142
+ }
143
+
144
+ .${uid} .gp-button-price,
145
+ .${uid} .gp-product-dot-price {
146
+ color: ${core.getSingleColorVariable(textColor?.normal)};
147
+ }
148
+ `;
149
+
150
+ exports.generateBorderCornerStyles = generateBorderCornerStyles;
151
+ exports.generateColorStyles = generateColorStyles;
152
+ exports.getButtonIconStyles = getButtonIconStyles;
153
+ exports.getButtonStyles = getButtonStyles;
154
+ exports.getButtonWrapperStyles = getButtonWrapperStyles;
155
+ exports.getCustomCssStyles = getCustomCssStyles;
156
+ exports.getRadiusStyles = getRadiusStyles;
157
+ exports.getShadowStyles = getShadowStyles;
@@ -8,15 +8,11 @@ require('react/jsx-runtime');
8
8
  require('react');
9
9
  require('@gem-sdk/core');
10
10
 
11
- const Button = dynamic(()=>Promise.resolve().then(function () { return require('./components/v2/ButtonV2.js'); }), {
12
- loading: Loading.default
13
- });
14
- const ButtonV1 = dynamic(()=>Promise.resolve().then(function () { return require('./components/Button.js'); }), {
11
+ const Button = dynamic(()=>Promise.resolve().then(function () { return require('./components/Button.js'); }), {
15
12
  loading: Loading.default
16
13
  });
17
14
  var button = {
18
- Button,
19
- ButtonV1
15
+ Button
20
16
  };
21
17
 
22
18
  exports.default = button;
@@ -44,7 +44,11 @@ const ButtonSettings = [
44
44
  id: 'iconSvg',
45
45
  label: 'SVG Icon',
46
46
  type: 'icon',
47
- default: '<svg style="width: 100%; height: 100%" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M10.1149 4.21421C9.91455 4.02414 9.58977 4.02414 9.38946 4.21421C9.18915 4.40429 9.18915 4.71246 9.38946 4.90254L12.1268 7.5L2.35236 7.5C2.07622 7.5 1.85236 7.72385 1.85236 8C1.85236 8.27614 2.07622 8.5 2.35236 8.5L12.1269 8.5L9.38946 11.0975C9.18915 11.2876 9.18915 11.5957 9.38946 11.7858C9.58977 11.9759 9.91454 11.9759 10.1149 11.7858L13.7419 8.34418C13.9422 8.15411 13.9422 7.84593 13.7419 7.65585L10.1149 4.21421Z" fill="currentColor"/></svg>'
47
+ default: `
48
+ <svg width="100%" height="100%" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
49
+ <path d="M8.90239 3.29786C8.54015 2.53874 7.45959 2.53873 7.09736 3.29786L5.98572 5.62747L3.42662 5.96481C2.59271 6.07473 2.2588 7.1024 2.86883 7.68149L4.74091 9.45861L4.27093 11.9967C4.11778 12.8238 4.99198 13.4589 5.73123 13.0577L7.99987 11.8264L10.2685 13.0577C11.0078 13.4589 11.882 12.8238 11.7288 11.9967L11.2588 9.45861L13.1309 7.68149C13.7409 7.1024 13.407 6.07473 12.5731 5.96481L10.014 5.62747L8.90239 3.29786Z" fill="currentColor"/>
50
+ </svg>
51
+ `
48
52
  },
49
53
  {
50
54
  id: 'iconAlign',
@@ -6,8 +6,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var core = require('@gem-sdk/core');
8
8
  var React = require('react');
9
- require('next/head');
10
- require('next/link');
11
9
  var Button = require('../../button/components/Button.js');
12
10
 
13
11
  const CheckoutNow = ({ setting, builderAttrs, builderProps, style, styles, className })=>{
@@ -0,0 +1,70 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var system = require('@gem-sdk/system');
8
+ var dynamic = require('next/dynamic');
9
+ var classes = require('./common/classes.js');
10
+ var helpers = require('./common/helpers.js');
11
+ var styles = require('./common/styles.js');
12
+ var useShopPayButton = require('./hooks/useShopPayButton.js');
13
+
14
+ const DynamicCheckoutBlack = dynamic(()=>Promise.resolve().then(function () { return require('./icons/DynamicCheckoutBlack.js'); }));
15
+ const DynamicCheckoutPurple = dynamic(()=>Promise.resolve().then(function () { return require('./icons/DynamicCheckoutPurple.js'); }));
16
+ const DynamicCheckoutWhite = dynamic(()=>Promise.resolve().then(function () { return require('./icons/DynamicCheckoutWhite.js'); }));
17
+ const ExpressCheckoutBlack = dynamic(()=>Promise.resolve().then(function () { return require('./icons/ExpressCheckoutBlack.js'); }));
18
+ const ExpressCheckoutPurple = dynamic(()=>Promise.resolve().then(function () { return require('./icons/ExpressCheckoutPurple.js'); }));
19
+ const ExpressCheckoutWhite = dynamic(()=>Promise.resolve().then(function () { return require('./icons/ExpressCheckoutWhite.js'); }));
20
+ /**
21
+ * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
22
+ */ const ShopPayButton = ({ style, styles: styles$1, setting, className, builderAttrs })=>{
23
+ const { variants, storeUrl, handleOnPay } = useShopPayButton.useShopPayButton(setting);
24
+ if (!storeUrl) {
25
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
26
+ ...builderAttrs,
27
+ children: "URL Not Found"
28
+ });
29
+ }
30
+ const SPButton = helpers.getSPButton({
31
+ styles: styles$1,
32
+ buttons: {
33
+ DynamicCheckoutBlack,
34
+ DynamicCheckoutPurple,
35
+ DynamicCheckoutWhite,
36
+ ExpressCheckoutBlack,
37
+ ExpressCheckoutPurple,
38
+ ExpressCheckoutWhite
39
+ }
40
+ });
41
+ const buttonWrapperStyles = system.createStyle({
42
+ ...styles.getButtonWrapperStyles(style, styles$1)
43
+ });
44
+ const buttonClasses = system.createClass({
45
+ ...classes.getButtonClasses()
46
+ });
47
+ const buttonWrapperClasses = system.createClass({
48
+ ...classes.getButtonWrapperClasses(className)
49
+ });
50
+ const buttonAttributes = system.createAttr({
51
+ disabled: !variants?.length,
52
+ 'aria-label': 'Buy with Shop Pay'
53
+ });
54
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
55
+ ...builderAttrs,
56
+ style: buttonWrapperStyles,
57
+ className: buttonWrapperClasses,
58
+ children: /*#__PURE__*/ jsxRuntime.jsx("button", {
59
+ ...buttonAttributes,
60
+ className: buttonClasses,
61
+ onClick: ()=>handleOnPay({
62
+ inputWidth: 600,
63
+ inputHeight: 600
64
+ }),
65
+ children: /*#__PURE__*/ jsxRuntime.jsx(SPButton, {})
66
+ })
67
+ });
68
+ };
69
+
70
+ exports.default = ShopPayButton;
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@gem-sdk/core');
6
+ var system = require('@gem-sdk/system');
7
+ var helpers$1 = require('../../../helpers.js');
8
+ var classes = require('./common/classes.js');
9
+ var helpers = require('./common/helpers.js');
10
+ var styles = require('./common/styles.js');
11
+ var DynamicCheckoutBlack_liquid = require('./icons/DynamicCheckoutBlack.liquid.js');
12
+ var DynamicCheckoutPurple_liquid = require('./icons/DynamicCheckoutPurple.liquid.js');
13
+ var DynamicCheckoutWhite_liquid = require('./icons/DynamicCheckoutWhite.liquid.js');
14
+ var ExpressCheckoutBlack_liquid = require('./icons/ExpressCheckoutBlack.liquid.js');
15
+ var ExpressCheckoutPurple_liquid = require('./icons/ExpressCheckoutPurple.liquid.js');
16
+ var ExpressCheckoutWhite_liquid = require('./icons/ExpressCheckoutWhite.liquid.js');
17
+
18
+ /**
19
+ * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
20
+ */ const ShopPayButton = ({ style, styles: styles$1, setting, className, builderAttrs })=>{
21
+ const SPButton = helpers.getSPButton({
22
+ styles: styles$1,
23
+ buttons: {
24
+ DynamicCheckoutBlack: DynamicCheckoutBlack_liquid.default({}),
25
+ DynamicCheckoutPurple: DynamicCheckoutPurple_liquid.default({}),
26
+ DynamicCheckoutWhite: DynamicCheckoutWhite_liquid.default({}),
27
+ ExpressCheckoutBlack: ExpressCheckoutBlack_liquid.default({}),
28
+ ExpressCheckoutPurple: ExpressCheckoutPurple_liquid.default({}),
29
+ ExpressCheckoutWhite: ExpressCheckoutWhite_liquid.default({})
30
+ }
31
+ });
32
+ const buttonWrapperStyles = system.createStyle({
33
+ ...styles.getButtonWrapperStyles(style, styles$1)
34
+ });
35
+ const buttonClasses = system.createClass({
36
+ ...classes.getButtonClasses()
37
+ });
38
+ const buttonWrapperClasses = system.createClass({
39
+ ...classes.getButtonWrapperClasses(className)
40
+ });
41
+ const buttonAttributes = system.createAttr({
42
+ disabled: false,
43
+ 'aria-label': 'Buy with Shop Pay'
44
+ });
45
+ const buttonState = system.createStateOrContext({
46
+ setting: JSON.stringify(setting),
47
+ shop_url: '{{shop.url}}'
48
+ });
49
+ return core.template`
50
+ <gp-shop-pay-button
51
+ ${{
52
+ ...builderAttrs
53
+ }}
54
+ style="${buttonWrapperStyles}"
55
+ class="${buttonWrapperClasses}"
56
+ gp-data='${buttonState}'
57
+ >
58
+ <button
59
+ ${{
60
+ ...buttonAttributes
61
+ }}
62
+ class="${buttonClasses}"
63
+ >
64
+ ${SPButton}
65
+ </button>
66
+ </gp-shop-pay-button>
67
+ ${system.If(core.isLocalEnv, `<script ${helpers$1.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-shop-pay-button.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers$1.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-shop-pay-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
68
+ `;
69
+ };
70
+
71
+ exports.default = ShopPayButton;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ const getButtonWrapperClasses = (className)=>{
4
+ return {
5
+ ...className && {
6
+ [className]: true
7
+ },
8
+ 'gp-flex': true
9
+ };
10
+ };
11
+ const getButtonClasses = ()=>{
12
+ return {
13
+ 'disabled:gp-cursor-not-allowed disabled:gp-opacity-50 gp-shop-button': true
14
+ };
15
+ };
16
+
17
+ exports.getButtonClasses = getButtonClasses;
18
+ exports.getButtonWrapperClasses = getButtonWrapperClasses;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const getSPButton = ({ styles, buttons })=>{
4
+ const { DynamicCheckoutBlack, DynamicCheckoutWhite, DynamicCheckoutPurple, ExpressCheckoutBlack, ExpressCheckoutWhite, ExpressCheckoutPurple } = buttons;
5
+ if (styles?.type === 'dynamic') {
6
+ if (styles.color === 'black') return DynamicCheckoutBlack;
7
+ if (styles.color === 'purple') return DynamicCheckoutPurple;
8
+ return DynamicCheckoutWhite;
9
+ } else {
10
+ if (styles?.color === 'black') return ExpressCheckoutBlack;
11
+ if (styles?.color === 'purple') return ExpressCheckoutPurple;
12
+ return ExpressCheckoutWhite;
13
+ }
14
+ };
15
+ const getIdFromGid = (id)=>{
16
+ if (!id) return;
17
+ return id.split('/').at(-1);
18
+ };
19
+ const getStoreUrl = (url)=>{
20
+ if (!url) return;
21
+ try {
22
+ const data = new URL(url);
23
+ return data.origin;
24
+ } catch {
25
+ return;
26
+ }
27
+ };
28
+
29
+ exports.getIdFromGid = getIdFromGid;
30
+ exports.getSPButton = getSPButton;
31
+ exports.getStoreUrl = getStoreUrl;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getButtonWrapperStyles = (style, styles)=>{
6
+ return {
7
+ ...style,
8
+ ...core.makeStyleResponsive('jc', styles?.align)
9
+ };
10
+ };
11
+
12
+ exports.getButtonWrapperStyles = getButtonWrapperStyles;
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+ var React = require('react');
5
+ var helpers = require('../common/helpers.js');
6
+
7
+ const useShopPayButton = (setting)=>{
8
+ const mode = core.useEditorMode();
9
+ const { quantity } = core.useQuantity();
10
+ const { data: cartData } = core.useCartData();
11
+ const currentVariant = core.useCurrentVariant();
12
+ const storefrontUrl = core.useShopStore((s)=>s.storefrontUrl);
13
+ const isCurrentVariantInStock = core.useCurrentVariantInStock();
14
+ const storeUrl = helpers.getStoreUrl(storefrontUrl);
15
+ const idsInCart = React.useMemo(()=>{
16
+ const items = cartData?.lineItems.map((v)=>({
17
+ id: v.variantId,
18
+ quantity: v.quantity
19
+ }))?.reduce((prev, curr)=>{
20
+ const bareId = helpers.getIdFromGid(curr?.id);
21
+ if (bareId) {
22
+ prev.push(`${bareId}:${curr?.quantity ?? 1}`);
23
+ }
24
+ return prev;
25
+ }, []);
26
+ return items;
27
+ }, [
28
+ cartData?.lineItems
29
+ ]);
30
+ const variants = React.useMemo(()=>{
31
+ if (setting?.kind === 'cart-buy') {
32
+ return idsInCart;
33
+ }
34
+ if (currentVariant?.baseID && isCurrentVariantInStock && quantity) {
35
+ return [
36
+ `${helpers.getIdFromGid(currentVariant.baseID)}:${quantity}`
37
+ ];
38
+ }
39
+ return undefined;
40
+ }, [
41
+ setting?.kind,
42
+ currentVariant?.baseID,
43
+ isCurrentVariantInStock,
44
+ quantity,
45
+ idsInCart
46
+ ]);
47
+ const payUrl = `${storeUrl}/cart/${variants?.join(',')}?payment=shop_pay`;
48
+ const handleOnPay = ({ inputWidth = 600, inputHeight = 600 })=>{
49
+ if (mode === 'edit') return;
50
+ if (setting?.openMode === 'popup') {
51
+ const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
52
+ const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
53
+ const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
54
+ const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
55
+ const systemZoom = width / window.screen.availWidth;
56
+ const left = (width - inputWidth) / 2 / systemZoom + dualScreenLeft;
57
+ const top = (height - inputHeight) / 2 / systemZoom + dualScreenTop;
58
+ window.open(payUrl, 'shop_pay', `scrollbars=yes, width=${inputWidth / systemZoom}, height=${inputHeight / systemZoom}, top=${top}, left=${left}`);
59
+ } else {
60
+ !!payUrl && window.open(payUrl);
61
+ }
62
+ };
63
+ return {
64
+ storeUrl,
65
+ variants,
66
+ handleOnPay
67
+ };
68
+ };
69
+
70
+ exports.useShopPayButton = useShopPayButton;
@@ -51,7 +51,7 @@ const CouponList = dynamic(()=>Promise.resolve().then(function () { return requi
51
51
  const CheckoutNow = dynamic(()=>Promise.resolve().then(function () { return require('./components/CheckoutNow.js'); }), {
52
52
  loading: Loading.default
53
53
  });
54
- const ShopPayButton = dynamic(()=>Promise.resolve().then(function () { return require('./components/ShopPayButton/index.js'); }), {
54
+ const ShopPayButton = dynamic(()=>Promise.resolve().then(function () { return require('./components/ShopPayButton/ShopPayButton.js'); }), {
55
55
  ssr: false,
56
56
  loading: Loading.default
57
57
  });
@@ -5,10 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var core = require('@gem-sdk/core');
8
- require('next/head');
9
- var React = require('react');
10
- require('next/link');
11
8
  var Button = require('../../button/components/Button.js');
9
+ var React = require('react');
12
10
 
13
11
  const Coupon = ({ setting, builderProps, builderAttrs, style, styles, advanced, children })=>{
14
12
  const mode = core.useEditorMode();