@gem-sdk/components 2.0.0-dev.393 → 2.0.0-dev.394

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 (30) hide show
  1. package/dist/cjs/builder.js +4 -4
  2. package/dist/cjs/index.js +30 -30
  3. package/dist/cjs/index.liquid.js +4 -4
  4. package/dist/cjs/product/components/ProductDiscountTag/common/getClasses.js +38 -0
  5. package/dist/cjs/product/components/ProductDiscountTag/common/getStyle.js +42 -0
  6. package/dist/cjs/product/components/ProductDiscountTag/hooks/useGpDiscountTag.js +108 -0
  7. package/dist/cjs/product/components/ProductDiscountTag/index.js +110 -0
  8. package/dist/cjs/product/components/ProductDiscountTag/index.liquid.js +91 -0
  9. package/dist/cjs/product/index.js +4 -4
  10. package/dist/cjs/product/next.js +1 -1
  11. package/dist/cjs/product/setting/ProductTag.js +7 -299
  12. package/dist/cjs/product/setting/product-discount-tag/configs/settings.js +191 -0
  13. package/dist/cjs/product/setting/product-discount-tag/configs/uiV2.js +190 -0
  14. package/dist/esm/builder.js +1 -1
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/index.liquid.js +1 -1
  17. package/dist/esm/product/components/ProductDiscountTag/common/getClasses.js +33 -0
  18. package/dist/esm/product/components/ProductDiscountTag/common/getStyle.js +38 -0
  19. package/dist/esm/product/components/ProductDiscountTag/hooks/useGpDiscountTag.js +106 -0
  20. package/dist/esm/product/components/ProductDiscountTag/index.js +106 -0
  21. package/dist/esm/product/components/ProductDiscountTag/index.liquid.js +87 -0
  22. package/dist/esm/product/next.js +1 -1
  23. package/dist/esm/product/setting/ProductTag.js +7 -299
  24. package/dist/esm/product/setting/product-discount-tag/configs/settings.js +189 -0
  25. package/dist/esm/product/setting/product-discount-tag/configs/uiV2.js +188 -0
  26. package/package.json +1 -1
  27. package/dist/cjs/product/components/ProductTag/ProductTag.js +0 -200
  28. package/dist/cjs/product/components/ProductTag/ProductTag.liquid.js +0 -107
  29. package/dist/esm/product/components/ProductTag/ProductTag.js +0 -196
  30. package/dist/esm/product/components/ProductTag/ProductTag.liquid.js +0 -103
@@ -233,14 +233,14 @@ var ProductImages = require('./product/components/ProductImages.js');
233
233
  var index$9 = require('./product/components/ProductImagesV2/index.js');
234
234
  var ProductProperties = require('./product/components/ProductProperties/ProductProperties.js');
235
235
  var index$a = require('./product/components/ProductQuickView/index.js');
236
- var ProductTag = require('./product/components/ProductTag/ProductTag.js');
236
+ var index$b = require('./product/components/ProductDiscountTag/index.js');
237
237
  var ProductList = require('./product/components/ProductList/ProductList.js');
238
238
  var DynamicCheckout = require('./product/components/DynamicCheckout/DynamicCheckout.js');
239
239
  var ProductBundleDiscount = require('./product/components/ProductBundle/components/ProductBundleDiscount.js');
240
240
  var Vendor = require('./product/components/ProductVendor/Vendor.js');
241
241
  var Sku = require('./product/components/ProductSKU/Sku.js');
242
242
  var ProductViewMore = require('./product/components/ProductViewMore/ProductViewMore.js');
243
- var index$b = require('./product/components/ProductBadge/index.js');
243
+ var index$c = require('./product/components/ProductBadge/index.js');
244
244
  var UploadFile = require('./product/components/FileUpload/components/UploadFile.js');
245
245
  var ProductBundleDiscountItem = require('./product/components/ProductBundle/components/ProductBundleDiscountItem.js');
246
246
  var Radio = require('./radio/Radio.js');
@@ -439,7 +439,7 @@ var builder = {
439
439
  ProductImagesV2: index$9.default,
440
440
  ProductProperties: ProductProperties.default,
441
441
  ProductQuickView: index$a.default,
442
- ProductTag: ProductTag.default,
442
+ ProductTag: index$b.default,
443
443
  ProductList: ProductList.default,
444
444
  Radio: Radio.default,
445
445
  Select: Select.default,
@@ -504,7 +504,7 @@ var builder = {
504
504
  ProductVendor: Vendor.default,
505
505
  KingProductOptions: KingProductOptions.default,
506
506
  ProductViewMore: ProductViewMore.default,
507
- ProductBadge: index$b.default,
507
+ ProductBadge: index$c.default,
508
508
  HextomCountdownTimerBar: HextomCountdownTimerBar.default,
509
509
  TrustBadgesBear: TrustBadgesBear.default,
510
510
  TrustedsiteTrustBadges: TrustedsiteTrustBadges.default,
package/dist/cjs/index.js CHANGED
@@ -42,20 +42,20 @@ var index$C = require('./post-purchase/line/index.js');
42
42
  var index$D = require('./post-purchase/link/index.js');
43
43
  var index$E = require('./post-purchase/text/index.js');
44
44
  var index$G = require('./post-purchase/product/index.js');
45
- var index$P = require('./product/index.js');
46
- var index$Q = require('./radio/index.js');
47
- var index$R = require('./select/index.js');
48
- var index$S = require('./tab/index.js');
49
- var index$T = require('./text/index.js');
50
- var index$U = require('./textarea/index.js');
51
- var index$V = require('./video/index.js');
45
+ var index$Q = require('./product/index.js');
46
+ var index$R = require('./radio/index.js');
47
+ var index$S = require('./select/index.js');
48
+ var index$T = require('./tab/index.js');
49
+ var index$U = require('./text/index.js');
50
+ var index$V = require('./textarea/index.js');
51
+ var index$W = require('./video/index.js');
52
52
  var useInView = require('./intersection-observer/useInView.js');
53
- var index$W = require('./third-party/index.js');
54
- var index$X = require('./third-party-instant/index.js');
55
- var index$Y = require('./stock-counter/index.js');
56
- var index$Z = require('./third-party-slot/index.js');
57
- var index$_ = require('./shop-pay-installment/index.js');
58
- var index$$ = require('./sticky/index.js');
53
+ var index$X = require('./third-party/index.js');
54
+ var index$Y = require('./third-party-instant/index.js');
55
+ var index$Z = require('./stock-counter/index.js');
56
+ var index$_ = require('./third-party-slot/index.js');
57
+ var index$$ = require('./shop-pay-installment/index.js');
58
+ var index$10 = require('./sticky/index.js');
59
59
  var next = require('./next.js');
60
60
  var index_liquid = require('./index.liquid.js');
61
61
  var builder = require('./builder.js');
@@ -179,12 +179,12 @@ var ProductImages = require('./product/components/ProductImages.js');
179
179
  var index$M = require('./product/components/ProductImagesV2/index.js');
180
180
  var ProductProperties = require('./product/components/ProductProperties/ProductProperties.js');
181
181
  var index$N = require('./product/components/ProductQuickView/index.js');
182
- var ProductTag = require('./product/components/ProductTag/ProductTag.js');
182
+ var index$O = require('./product/components/ProductDiscountTag/index.js');
183
183
  var ProductList = require('./product/components/ProductList/ProductList.js');
184
184
  var Vendor = require('./product/components/ProductVendor/Vendor.js');
185
185
  var DynamicCheckout = require('./product/components/DynamicCheckout/DynamicCheckout.js');
186
186
  var ProductViewMore = require('./product/components/ProductViewMore/ProductViewMore.js');
187
- var index$O = require('./product/components/ProductBadge/index.js');
187
+ var index$P = require('./product/components/ProductBadge/index.js');
188
188
  var ProductBundleDiscount = require('./product/components/ProductBundle/components/ProductBundleDiscount.js');
189
189
  var ProductBundleDiscountItem = require('./product/components/ProductBundle/components/ProductBundleDiscountItem.js');
190
190
  var Sku = require('./product/components/ProductSKU/Sku.js');
@@ -365,20 +365,20 @@ exports.postPurchaseLinkSetting = index$D.postPurchaseLinkSetting;
365
365
  exports.PostPurchaseHeading = index$E.PostPurchaseHeading;
366
366
  exports.postPurchaseTextSetting = index$E.postPurchaseTextSetting;
367
367
  exports.postPurchaseProductSetting = index$G.postPurchaseProductSetting;
368
- exports.productSetting = index$P.productSetting;
369
- exports.radioSetting = index$Q.radioSetting;
370
- exports.selectSetting = index$R.selectSetting;
371
- exports.tabSetting = index$S.tabSetting;
372
- exports.textSetting = index$T.textSetting;
373
- exports.textareaSetting = index$U.textareaSetting;
374
- exports.videoSetting = index$V.videoSetting;
368
+ exports.productSetting = index$Q.productSetting;
369
+ exports.radioSetting = index$R.radioSetting;
370
+ exports.selectSetting = index$S.selectSetting;
371
+ exports.tabSetting = index$T.tabSetting;
372
+ exports.textSetting = index$U.textSetting;
373
+ exports.textareaSetting = index$V.textareaSetting;
374
+ exports.videoSetting = index$W.videoSetting;
375
375
  exports.useInView = useInView.useInView;
376
- exports.thirdPartySetting = index$W.thirdPartySetting;
377
- exports.thirdPartyInstantSetting = index$X.thirdPartyInstantSetting;
378
- exports.stockCounterSetting = index$Y.stockCounterSetting;
379
- exports.thirdPartySlotSetting = index$Z.thirdPartySlotSetting;
380
- exports.shopPayInstallmentSetting = index$_.shopPayInstallmentSetting;
381
- exports.stickySetting = index$$.stickySetting;
376
+ exports.thirdPartySetting = index$X.thirdPartySetting;
377
+ exports.thirdPartyInstantSetting = index$Y.thirdPartyInstantSetting;
378
+ exports.stockCounterSetting = index$Z.stockCounterSetting;
379
+ exports.thirdPartySlotSetting = index$_.thirdPartySlotSetting;
380
+ exports.shopPayInstallmentSetting = index$$.shopPayInstallmentSetting;
381
+ exports.stickySetting = index$10.stickySetting;
382
382
  exports.nextComponent = next.default;
383
383
  exports.liquidComponents = index_liquid;
384
384
  exports.builderComponent = builder.default;
@@ -513,12 +513,12 @@ exports.ProductImages = ProductImages.default;
513
513
  exports.ProductImagesV2 = index$M.default;
514
514
  exports.ProductPropertyInput = ProductProperties.default;
515
515
  exports.ProductQuickView = index$N.default;
516
- exports.ProductTag = ProductTag.default;
516
+ exports.ProductTag = index$O.default;
517
517
  exports.ProductList = ProductList.default;
518
518
  exports.ProductVendor = Vendor.default;
519
519
  exports.DynamicCheckout = DynamicCheckout.default;
520
520
  exports.ProductViewMore = ProductViewMore.default;
521
- exports.ProductBadge = index$O.default;
521
+ exports.ProductBadge = index$P.default;
522
522
  exports.ProductBundleDiscount = ProductBundleDiscount.default;
523
523
  exports.ProductBundleDiscountItem = ProductBundleDiscountItem.default;
524
524
  exports.ProductSku = Sku.default;
@@ -62,7 +62,7 @@ var Marquee_liquid = require('./marquee/components/Marquee.liquid.js');
62
62
  var DynamicCheckout_liquid = require('./product/components/DynamicCheckout/DynamicCheckout.liquid.js');
63
63
  var UploadFile_liquid = require('./product/components/FileUpload/components/UploadFile.liquid.js');
64
64
  var Product_liquid = require('./product/components/ProductWrap/Product.liquid.js');
65
- var index_liquid$6 = require('./product/components/ProductBadge/index.liquid.js');
65
+ var index_liquid$7 = require('./product/components/ProductBadge/index.liquid.js');
66
66
  var ProductBundleDiscount_liquid = require('./product/components/ProductBundle/components/ProductBundleDiscount.liquid.js');
67
67
  var ProductBundleDiscountItem_liquid = require('./product/components/ProductBundle/components/ProductBundleDiscountItem.liquid.js');
68
68
  var ProductButton_liquid = require('./product/components/ProductButton/ProductButton.liquid.js');
@@ -70,7 +70,7 @@ var index_liquid$1 = require('./product/components/ProductDescription/index.liqu
70
70
  var ProductImages_liquid = require('./product/components/ProductImages.liquid.js');
71
71
  var index_liquid$4 = require('./product/components/ProductQuantity/index.liquid.js');
72
72
  var index_liquid$5 = require('./product/components/ProductVariants/index.liquid.js');
73
- var ProductTag_liquid = require('./product/components/ProductTag/ProductTag.liquid.js');
73
+ var index_liquid$6 = require('./product/components/ProductDiscountTag/index.liquid.js');
74
74
  var index_liquid$2 = require('./product/components/ProductImagesV2/index.liquid.js');
75
75
  var ProductList_liquid = require('./product/components/ProductList/ProductList.liquid.js');
76
76
  var index_liquid$3 = require('./product/components/ProductPrice/index.liquid.js');
@@ -261,7 +261,7 @@ exports.Marquee = Marquee_liquid.default;
261
261
  exports.DynamicCheckout = DynamicCheckout_liquid.default;
262
262
  exports.FileUpload = UploadFile_liquid.default;
263
263
  exports.Product = Product_liquid.default;
264
- exports.ProductBadge = index_liquid$6.default;
264
+ exports.ProductBadge = index_liquid$7.default;
265
265
  exports.ProductBundleDiscount = ProductBundleDiscount_liquid.default;
266
266
  exports.ProductBundleDiscountItem = ProductBundleDiscountItem_liquid.default;
267
267
  exports.ProductButton = ProductButton_liquid.default;
@@ -269,7 +269,7 @@ exports.ProductDescription = index_liquid$1.default;
269
269
  exports.ProductImages = ProductImages_liquid.default;
270
270
  exports.ProductQuantity = index_liquid$4.default;
271
271
  exports.ProductVariants = index_liquid$5.default;
272
- exports.ProductTag = ProductTag_liquid.default;
272
+ exports.ProductTag = index_liquid$6.default;
273
273
  exports.ProductImagesV2 = index_liquid$2.default;
274
274
  exports.ProductList = ProductList_liquid.default;
275
275
  exports.ProductPrice = index_liquid$3.ProductPrice;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getRootClass = ({ mode, salePrice, priceSave, bundleItem })=>{
6
+ return {
7
+ 'gp-opacity-0 ': mode !== 'edit' && (salePrice <= 0 || Math.ceil(priceSave / (salePrice / 100)) <= 0),
8
+ 'gp-opacity-20 ': mode === 'edit' && (salePrice <= 0 || Math.ceil(priceSave / (salePrice / 100)) <= 0) && !bundleItem
9
+ };
10
+ };
11
+ const getProductTagClass = (advanced)=>{
12
+ return {
13
+ 'gp-block data-[disabled=true]:gp-hidden ${advanced?.cssClass}': true,
14
+ [advanced?.cssClass]: true
15
+ };
16
+ };
17
+ const getContainerClass = ()=>{
18
+ return {
19
+ 'gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3': true
20
+ };
21
+ };
22
+ const getWrapperTextClass = (styles)=>{
23
+ const { backgroundColor, borderTag, textColor } = styles ?? {};
24
+ const borderColorClass = core.getGlobalColorClass('border', borderTag?.color);
25
+ const textColorClass = core.getGlobalColorClass('text', textColor);
26
+ const backgroundColorClass = core.getGlobalColorClass('bg', backgroundColor);
27
+ return {
28
+ ...core.composeClasses('gp-flex gp-items-center gp-w-full gp-h-full'),
29
+ [borderColorClass]: true,
30
+ [textColorClass]: true,
31
+ [backgroundColorClass]: true
32
+ };
33
+ };
34
+
35
+ exports.getContainerClass = getContainerClass;
36
+ exports.getProductTagClass = getProductTagClass;
37
+ exports.getRootClass = getRootClass;
38
+ exports.getWrapperTextClass = getWrapperTextClass;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getRootClass = (styles)=>{
6
+ const composeStyles = {
7
+ ...core.makeStyleResponsive('ta', styles?.textAlign)
8
+ };
9
+ return core.filterTruthyStyles(composeStyles);
10
+ };
11
+ const getWrapperTextStyle = (styles)=>{
12
+ const { backgroundColor, roundedTag, borderTag, textColor } = styles ?? {};
13
+ const composeGlobalSize = core.makeGlobalSize(styles?.size);
14
+ const borderColorClass = core.getGlobalColorClass('border', borderTag?.color);
15
+ const textColorClass = core.getGlobalColorClass('text', textColor);
16
+ const backgroundColorClass = core.getGlobalColorClass('bg', backgroundColor);
17
+ const composeStyles = {
18
+ ...core.makeStyleResponsive('jc', styles?.textContentAlign),
19
+ ...composeGlobalSize.padding,
20
+ ...core.makeStyle({
21
+ bs: borderTag?.border,
22
+ bw: borderTag?.width,
23
+ bc: borderColorClass === '' ? borderTag?.color : undefined,
24
+ c: textColorClass === '' ? textColor : undefined,
25
+ bg: backgroundColorClass === '' ? backgroundColor : undefined
26
+ }),
27
+ ...roundedTag?.radiusType !== 'custom' ? core.getRadiusCSSFromGlobal('normal', roundedTag?.radiusType) : {},
28
+ ...core.getCustomRadius('normal', roundedTag)
29
+ };
30
+ return core.filterTruthyStyles(composeStyles);
31
+ };
32
+ const getContainerStyle = (styles)=>{
33
+ const composeGlobalSize = core.makeGlobalSize(styles?.size);
34
+ return {
35
+ ...composeGlobalSize.width,
36
+ ...composeGlobalSize.height
37
+ };
38
+ };
39
+
40
+ exports.getContainerStyle = getContainerStyle;
41
+ exports.getRootClass = getRootClass;
42
+ exports.getWrapperTextStyle = getWrapperTextStyle;
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+ var React = require('react');
5
+ var productBundle = require('../../../helpers/product-bundle.js');
6
+ var productBundle$1 = require('../../constants/product-bundle.js');
7
+
8
+ const useGpDiscountTag = (props)=>{
9
+ const { setting, styles, builderProps, ...passProps } = props;
10
+ const { customContent } = setting ?? {};
11
+ const bundleItem = passProps['bundle-item'];
12
+ const { moneyFormat } = core.useMoneyFormat();
13
+ const mode = core.useEditorMode();
14
+ const product = core.useProduct();
15
+ const currentVariant = core.useCurrentVariant();
16
+ const { quantity, hasUpdatePrice } = core.useQuantity();
17
+ const quantityProduct = React.useMemo(()=>{
18
+ return hasUpdatePrice && customContent?.unit !== 'percentage' ? quantity ?? 1 : 1;
19
+ }, [
20
+ hasUpdatePrice,
21
+ customContent?.unit,
22
+ quantity
23
+ ]);
24
+ const price = currentVariant?.price ?? 0;
25
+ const salePrice = currentVariant?.salePrice ?? 0;
26
+ const priceSave = (salePrice - price) * quantityProduct;
27
+ const moneyFormatted = core.useFormatMoney(priceSave < 0 ? 0 : priceSave, setting?.moneyWithCurrentFormat || false);
28
+ const customDisplayWithUnit = React.useMemo(()=>{
29
+ if (!salePrice && salePrice !== 0 || !price && price !== 0) return `${customContent?.unit === 'percentage' ? '0%' : moneyFormatted}`;
30
+ if (customContent?.unit === 'percentage') {
31
+ const salePercent = Math.round(priceSave / (salePrice / 100));
32
+ return `${salePercent < 0 ? 0 : salePercent}%`;
33
+ }
34
+ return `${moneyFormatted}`;
35
+ }, [
36
+ customContent?.unit,
37
+ moneyFormatted,
38
+ price,
39
+ priceSave,
40
+ salePrice
41
+ ]);
42
+ const { useProductCompareAtPrice } = core.useProductBundleDiscount();
43
+ const { discountPercentAmount } = productBundle.applyBundleDiscountAmount({
44
+ currentVariant,
45
+ bundleItem,
46
+ options: {
47
+ moneyFormat,
48
+ useProductCompareAtPrice
49
+ }
50
+ });
51
+ const bundleDiscountDisplay = React.useMemo(()=>{
52
+ if (!bundleItem) return 0;
53
+ const { discountPercentAmount, discountAmount } = productBundle.applyBundleDiscountAmount({
54
+ currentVariant,
55
+ bundleItem,
56
+ options: {
57
+ moneyFormat,
58
+ useProductCompareAtPrice
59
+ }
60
+ });
61
+ const { discountType } = bundleItem;
62
+ const { unit } = customContent || {};
63
+ if (discountType === productBundle$1.DiscountType.NoDiscount && !useProductCompareAtPrice) {
64
+ return unit === 'percentage' ? '0%' : core.formatMoney('0', moneyFormat);
65
+ }
66
+ if (unit === 'percentage') {
67
+ return `${discountPercentAmount}%`;
68
+ }
69
+ return discountAmount;
70
+ }, [
71
+ bundleItem,
72
+ currentVariant,
73
+ moneyFormat,
74
+ useProductCompareAtPrice,
75
+ customContent
76
+ ]);
77
+ const unitCustomDisplay = React.useMemo(()=>{
78
+ if (!bundleItem) {
79
+ return customDisplayWithUnit;
80
+ }
81
+ return bundleDiscountDisplay;
82
+ }, [
83
+ bundleDiscountDisplay,
84
+ bundleItem,
85
+ customDisplayWithUnit
86
+ ]);
87
+ const currentProductId = product?.baseID?.replace('gid://shopify/Product/', '');
88
+ const shouldPlaceholderNoDiscount = React.useMemo(()=>{
89
+ const noDiscount = !bundleItem ? priceSave <= 0 : discountPercentAmount <= 0;
90
+ return mode === 'edit' && noDiscount;
91
+ }, [
92
+ bundleItem,
93
+ discountPercentAmount,
94
+ mode,
95
+ priceSave
96
+ ]);
97
+ return {
98
+ mode,
99
+ product,
100
+ salePrice,
101
+ priceSave,
102
+ currentProductId,
103
+ unitCustomDisplay,
104
+ shouldPlaceholderNoDiscount
105
+ };
106
+ };
107
+
108
+ exports.useGpDiscountTag = useGpDiscountTag;
@@ -0,0 +1,110 @@
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 NoDataState = require('../../../common/components/NoDataState.js');
9
+ var TooltipHover = require('../../../common/components/TooltipHover.js');
10
+ var Text = require('../../../text/components/Text.js');
11
+ var system = require('@gem-sdk/system');
12
+ var getStyle = require('./common/getStyle.js');
13
+ var getClasses = require('./common/getClasses.js');
14
+ var useGpDiscountTag = require('./hooks/useGpDiscountTag.js');
15
+
16
+ const ProductTag = ({ setting, styles, builderProps, ...passProps })=>{
17
+ const { customContent } = setting ?? {};
18
+ const bundleItem = passProps['bundle-item'];
19
+ const { textAlign } = styles ?? {};
20
+ const { mode, product, salePrice, priceSave, currentProductId, unitCustomDisplay, shouldPlaceholderNoDiscount } = useGpDiscountTag.useGpDiscountTag({
21
+ setting,
22
+ styles,
23
+ builderProps,
24
+ ...passProps
25
+ });
26
+ if (shouldPlaceholderNoDiscount) {
27
+ return /*#__PURE__*/ jsxRuntime.jsx(TooltipHover.default, {
28
+ enable: true,
29
+ text: 'Not be displayed when published',
30
+ position: 'bottom',
31
+ width: '205px',
32
+ children: /*#__PURE__*/ jsxRuntime.jsx(NoDataState.default, {
33
+ builderAttrs: builderProps?.builderData,
34
+ elementType: "secondary",
35
+ description: "No discount",
36
+ rawMode: true
37
+ })
38
+ });
39
+ }
40
+ const wrapperTextStyle = system.createStyle(getStyle.getWrapperTextStyle(styles));
41
+ const containerStyle = system.createStyle(getStyle.getContainerStyle(styles));
42
+ const wrapperTextClass = system.createClass(getClasses.getWrapperTextClass(styles));
43
+ const containerClass = system.createClass(getClasses.getContainerClass());
44
+ const rootClass = system.createClass(getClasses.getRootClass({
45
+ mode,
46
+ salePrice,
47
+ priceSave,
48
+ bundleItem
49
+ }));
50
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
51
+ className: rootClass,
52
+ style: {
53
+ ...core.makeStyleResponsive('ta', textAlign)
54
+ },
55
+ id: `shopify-text-element-${builderProps?.uid}`,
56
+ "data-id": builderProps?.uid,
57
+ "data-product-id": currentProductId,
58
+ "gp-data-hidden": "false",
59
+ children: system.If(!product, ' ', /*#__PURE__*/ jsxRuntime.jsx("div", {
60
+ className: containerClass,
61
+ style: containerStyle,
62
+ children: /*#__PURE__*/ jsxRuntime.jsx("div", {
63
+ className: wrapperTextClass,
64
+ style: wrapperTextStyle,
65
+ children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
66
+ className: "gp-flex gp-break-all",
67
+ children: [
68
+ /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
69
+ styles: styles,
70
+ setting: {
71
+ ...setting,
72
+ text: customContent?.prefix?.replaceAll(' ', '&nbsp;'),
73
+ options: {
74
+ useState: true,
75
+ uniqueId: `${builderProps?.uid}-prefix`
76
+ },
77
+ excludeFlex: true
78
+ }
79
+ }),
80
+ /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
81
+ styles: styles,
82
+ setting: {
83
+ ...setting,
84
+ text: unitCustomDisplay,
85
+ options: {
86
+ isCannotEditing: true
87
+ },
88
+ excludeFlex: true
89
+ }
90
+ }),
91
+ /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
92
+ styles: styles,
93
+ setting: {
94
+ ...setting,
95
+ text: customContent?.suffix?.replaceAll(' ', '&nbsp;'),
96
+ excludeFlex: true,
97
+ options: {
98
+ useState: true,
99
+ uniqueId: `${builderProps?.uid}-suffix`
100
+ }
101
+ }
102
+ })
103
+ ]
104
+ })
105
+ })
106
+ }))
107
+ });
108
+ };
109
+
110
+ exports.default = ProductTag;
@@ -0,0 +1,91 @@
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 Text_liquid = require('../../../text/components/Text.liquid.js');
8
+ var system = require('@gem-sdk/system');
9
+ var getClasses = require('./common/getClasses.js');
10
+ var getStyle = require('./common/getStyle.js');
11
+
12
+ const ProductTag = ({ setting, styles, builderProps, advanced, pageContext })=>{
13
+ const { customContent, translate } = setting ?? {};
14
+ const moneyFormat = setting?.moneyWithCurrentFormat ? `money_with_currency` : `money`;
15
+ const prefixVal = helpers.getDynamicSourceLocales({
16
+ val: customContent?.prefix,
17
+ uid: builderProps?.uid,
18
+ settingId: 'customContent_prefix',
19
+ isLiquid: true,
20
+ pageContext,
21
+ translate
22
+ });
23
+ const suffixVal = helpers.getDynamicSourceLocales({
24
+ val: customContent?.suffix,
25
+ uid: builderProps?.uid,
26
+ settingId: 'customContent_suffix',
27
+ isLiquid: true,
28
+ pageContext,
29
+ translate
30
+ });
31
+ const rootStyle = system.createStyle(getStyle.getRootClass(styles));
32
+ const wrapperTextStyle = system.createStyle(getStyle.getWrapperTextStyle(styles));
33
+ const containerStyle = system.createStyle(getStyle.getContainerStyle(styles));
34
+ const wrapperTextClass = system.createClass(getClasses.getWrapperTextClass(styles));
35
+ const containerClass = system.createClass(getClasses.getContainerClass());
36
+ const productTagClass = system.createClass(getClasses.getProductTagClass(advanced));
37
+ const renderScript = ()=>{
38
+ const jsURL = core.isLocalEnv ? `{{ 'gp-product-tag.js' | asset_url }}` : `${core.baseAssetURL}/assets-v2/gp-product-tag.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;
39
+ return `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${jsURL}" defer="defer"></script>`;
40
+ };
41
+ const stateData = system.createStateOrContext({
42
+ setting: JSON.stringify(setting).replaceAll("'", '&#039;'),
43
+ id: builderProps?.uid,
44
+ locale: '{{shop.locale}}',
45
+ currency: '{{shop.currency}}',
46
+ moneyFormat: `{{ ${setting?.moneyWithCurrentFormat ? 'shop.money_with_currency_format' : 'shop.money_format'} | replace: '"', '\\"' | escape }}`
47
+ });
48
+ return core.template`
49
+ {% liquid
50
+ assign price = variant.price | times: 1.0
51
+ assign salePrice = variant.compare_at_price | times: 1.0
52
+ assign priceSave = salePrice | minus: price
53
+ assign prefixVal = ${pageContext?.isPreviewing ? JSON.stringify(prefixVal) : prefixVal}
54
+ assign suffixVal = ${pageContext?.isPreviewing ? JSON.stringify(suffixVal) : suffixVal}
55
+ %}
56
+ ${system.LiquidIf('salePrice == null or price == null', system.Liquid(`{% assign pricePercentage = prefixVal ${system.If(customContent?.unit === 'percentage', `| append: ' 0% '`, `| ${moneyFormat} | append: ' '`)} | append: suffixVal %}`), `${system.If(customContent?.unit === 'percentage', `{% assign salePercent = priceSave | divided_by: salePrice | times: 100 | round %}
57
+ {% assign pricePercentage = prefixVal | append: ' ' | append: salePercent | append: '% ' | append: suffixVal %}`, system.LiquidIf('priceSave > 0', `{% assign priceSaveMoney = priceSave | ${moneyFormat} %}
58
+ {% assign pricePercentage = prefixVal | append: ' ' | append: priceSaveMoney | append: ' ' | append: suffixVal %}`, `{% assign priceSaveMoney = 0 | ${moneyFormat} %}
59
+ {% assign pricePercentage = prefixVal | append: ' ' | append: priceSaveMoney | append: ' ' | append: suffixVal %}`))}`)}
60
+
61
+ <gp-product-tag
62
+ data-id="${builderProps?.uid}"
63
+ data-disabled="{%- if priceSave > 0 -%} false {%- else -%} true {%- endif -%}"
64
+ gp-data="${core.dataStringify(stateData)}"
65
+ price-save="{{priceSave}}"
66
+ data-prefix="${pageContext?.isPreviewing ? prefixVal : `{{${prefixVal}}}`}"
67
+ data-suffix="${pageContext?.isPreviewing ? suffixVal : `{{${suffixVal}}}`}"
68
+ class="${productTagClass}"
69
+ style="${rootStyle}"
70
+ >
71
+ <div class="${containerClass}" style="${containerStyle}">
72
+ <div class="${wrapperTextClass}" style="${wrapperTextStyle}">
73
+ ${Text_liquid.default({
74
+ styles,
75
+ id: `p-tag-${builderProps?.uid}`,
76
+ setting: {
77
+ ...setting,
78
+ translate: '',
79
+ text: '{{ pricePercentage }}',
80
+ excludeFlex: true
81
+ }
82
+ })}
83
+ </div>
84
+ </div>
85
+
86
+ </gp-product-tag>
87
+ ${renderScript()}
88
+ `;
89
+ };
90
+
91
+ exports.default = ProductTag;
@@ -33,7 +33,7 @@ var ProductImages$1 = require('./setting/ProductImages.js');
33
33
  var ProductImages$2 = require('./setting/product-image-v2/ProductImages.js');
34
34
  var ProductDescription = require('./setting/ProductDescription.js');
35
35
  var ProductProperties$1 = require('./setting/ProductProperties.js');
36
- var ProductTag$1 = require('./setting/ProductTag.js');
36
+ var ProductTag = require('./setting/ProductTag.js');
37
37
  var ProductList$1 = require('./setting/ProductList.js');
38
38
  var DynamicCheckout$1 = require('./setting/DynamicCheckout.js');
39
39
  var Vendor$1 = require('./setting/Vendor.js');
@@ -42,7 +42,7 @@ var ProductBundleDiscount$1 = require('./components/ProductBundle/setting/Produc
42
42
  var ProductBundleDiscountItem$1 = require('./components/ProductBundle/setting/ProductBundleDiscountItem.js');
43
43
  var ProductViewMore$1 = require('./setting/ProductViewMore.js');
44
44
  var ProductBadge = require('./setting/ProductBadge.js');
45
- var index$8 = require('./components/FileUpload/components/setting/index.js');
45
+ var index$9 = require('./components/FileUpload/components/setting/index.js');
46
46
 
47
47
  const productSetting = {
48
48
  Product: Product$1.default,
@@ -55,7 +55,7 @@ const productSetting = {
55
55
  ProductImagesV2: ProductImages$2.default,
56
56
  ProductDescription: ProductDescription.default,
57
57
  ProductProperties: ProductProperties$1.default,
58
- ProductTag: ProductTag$1.default,
58
+ ProductTag: ProductTag.default,
59
59
  ProductList: ProductList$1.default,
60
60
  DynamicCheckout: DynamicCheckout$1.default,
61
61
  ProductVendor: Vendor$1.default,
@@ -64,7 +64,7 @@ const productSetting = {
64
64
  ProductBundleDiscountItem: ProductBundleDiscountItem$1.default,
65
65
  ProductViewMore: ProductViewMore$1.default,
66
66
  ProductBadge: ProductBadge.default,
67
- FileUpload: index$8.default
67
+ FileUpload: index$9.default
68
68
  };
69
69
 
70
70
  exports.Product = Product.default;
@@ -41,7 +41,7 @@ const ProductProperties = dynamic(()=>Promise.resolve().then(function () { retur
41
41
  const ProductQuickView = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductQuickView/index.js'); }), {
42
42
  ssr: false
43
43
  });
44
- const ProductTag = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductTag/ProductTag.js'); }), {
44
+ const ProductTag = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductDiscountTag/index.js'); }), {
45
45
  loading: Loading.default
46
46
  });
47
47
  const ProductList = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductList/ProductList.js'); }), {