@gem-sdk/components 7.0.1-dev.11 → 7.0.1-dev.13

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.
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:c,builderProps:t,children:o})=>{let s=core.useCurrentVariant(),u=core.useProduct(),i=s?.price??0,p=s?.salePrice??0,a=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),{isDynamicProduct:d}=useDynamicProduct.useDynamicProduct(),n=React.useMemo(()=>a?e?.priceType==="compare"?i:i-a:e?.priceType==="compare"?p:i,[a,e?.priceType,i,p]),m=core.useFormatMoney(parseFloat(n.toFixed(2)),!1),l=u?.baseID?.replace("gid://shopify/Product/",""),y=React.useMemo(()=>e?.priceType==="compare"&&(!a&&p<i||i<=0),[a,i,p,e?.priceType]);return y?null:jsxRuntime.jsxs("div",{...c,className:core.cls(t?.uid),style:{...r},id:`shopify-text-element-${t?.uid}`,"data-product-id":l,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:d?"$???":m},className:core.cls({"gp-money":e?.priceType==="regular","gp-product-compare-price":e?.priceType==="compare","gp-line-through":e?.priceType==="compare"&&e?.lineThrough})}),o]})};exports.default=PostPurchaseProductPrice;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:c,builderProps:o,children:t})=>{let s=core.useCurrentVariant(),u=core.useProduct(),i=core.convertDecimalToNumber(s?.price)??0,a=core.convertDecimalToNumber(s?.salePrice)??0,p=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),{isDynamicProduct:n}=useDynamicProduct.useDynamicProduct(),m=React.useMemo(()=>p?e?.priceType==="compare"?i:i-p:e?.priceType==="compare"?a:i,[p,e?.priceType,i,a]),d=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(m)||0,2)),!1),l=u?.baseID?.replace("gid://shopify/Product/",""),y=React.useMemo(()=>e?.priceType==="compare"&&(!p&&a<i||i<=0),[p,i,a,e?.priceType]);return y?null:jsxRuntime.jsxs("div",{...c,className:core.cls(o?.uid),style:{...r},id:`shopify-text-element-${o?.uid}`,"data-product-id":l,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:n?"$???":d},className:core.cls({"gp-money":e?.priceType==="regular","gp-product-compare-price":e?.priceType==="compare","gp-line-through":e?.priceType==="compare"&&e?.lineThrough})}),t]})};exports.default=PostPurchaseProductPrice;
@@ -1 +1 @@
1
- "use strict";const productOfferPlaceholder={id:"",title:"Dynamic product",description:"This is a dynamic product. The actual product will appear here based on your setup",descriptionHtml:'<p class="QN2lPu">This is a dynamic product. The actual product will</p>\n<p class="QN2lPu">appear here based on your setup</p>',createdAt:"2024-07-01T04:19:51.286753Z",handle:"dynamic-product",averageRating:0,isStorefront:!0,isSample:!1,baseID:"",sku:"",options:[{id:"1",name:"Variant",optionType:"",values:[{id:"1",label:"Variant option",isDefault:!0,baseID:""}]}],vendor:"",featuredImage:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""},collections:{edges:[{node:{id:"502321959132988135",title:"Home page"}},{node:{id:"539286505089204764",title:"b"}},{node:{id:"539286505089401372",title:"e"}}]},tags:[],medias:{edges:[{cursor:"gqFpzweGNIc/AALZoXYB",node:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""}}],pageInfo:{endCursor:"gqFpzweGNIc/AALZoXYB",hasNextPage:!0}},variants:{edges:[{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:88,height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:88,salePrice:88,sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}},{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:88,height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:88,salePrice:88,sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}}],pageInfo:{hasNextPage:!1,endCursor:"gaFpzwc5ZqRtDAMI"}}};exports.productOfferPlaceholder=productOfferPlaceholder;
1
+ "use strict";const productOfferPlaceholder={id:"",title:"Dynamic product",description:"This is a dynamic product. The actual product will appear here based on your setup",descriptionHtml:'<p class="QN2lPu">This is a dynamic product. The actual product will</p>\n<p class="QN2lPu">appear here based on your setup</p>',createdAt:"2024-07-01T04:19:51.286753Z",handle:"dynamic-product",averageRating:0,isStorefront:!0,isSample:!1,baseID:"",sku:"",options:[{id:"1",name:"Variant",optionType:"",values:[{id:"1",label:"Variant option",isDefault:!0,baseID:""}]}],vendor:"",featuredImage:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""},collections:{edges:[{node:{id:"502321959132988135",title:"Home page"}},{node:{id:"539286505089204764",title:"b"}},{node:{id:"539286505089401372",title:"e"}}]},tags:[],medias:{edges:[{cursor:"gqFpzweGNIc/AALZoXYB",node:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""}}],pageInfo:{endCursor:"gqFpzweGNIc/AALZoXYB",hasNextPage:!0}},variants:{edges:[{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:"88",height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:"88",salePrice:"88",sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}},{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:"88",height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:"88",salePrice:"88",sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}}],pageInfo:{hasNextPage:!1,endCursor:"gaFpzwc5ZqRtDAMI"}}};exports.productOfferPlaceholder=productOfferPlaceholder;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("./useDynamicProduct.js");const useGetMoneyLines=(e,t)=>{let{isDynamicProduct:o,dynamicPrice:u,dynamicDiscount:i,isEnableDynamicDiscount:a}=useDynamicProduct.useDynamicProduct(),s=core.useProductOfferDiscount(),n=core.useCurrentVariant(),{quantity:l}=core.useQuantity(),r=s*(l||1),c=core.useFormatMoney(r,!1),p=n?.price??0,b=p*(l||1),d=core.useFormatMoney(b,!1),L=core.shopifyPriceRounding(r,2),h=core.useFormatMoney(b-parseFloat(L),!1),y=()=>{let n=[];return!1!==e.isShowSubTotalLabel&&n.push({title:t.subTotalLabel,money:o?u:d,uniqueId:"subTotalLabel"}),!1!==e.isShowDiscountLabel&&n.push({title:t.discountLabel,money:o&&i&&a?`${i.value}%`:s>0?c:"No discount",uniqueId:"discountLabel"}),!1!==e.isShowShippingLabel&&n.push({title:t.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==e.isShowTaxesLabel&&n.push({title:t.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==e.isShowTotalLabel&&n.push({title:t.totalLabel,money:o?u:h,uniqueId:"totalLabel"}),n};return{getMoneyLines:y}};exports.useGetMoneyLines=useGetMoneyLines;
1
+ "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("./useDynamicProduct.js");const useGetMoneyLines=(e,t)=>{let{isDynamicProduct:o,dynamicPrice:u,dynamicDiscount:i,isEnableDynamicDiscount:a}=useDynamicProduct.useDynamicProduct(),s=core.useProductOfferDiscount(),n=core.useCurrentVariant(),{quantity:l}=core.useQuantity(),r=s*(l||1),c=core.useFormatMoney(r,!1),b=core.convertDecimalToNumber(n?.price)??0,p=b*(l||1),d=core.useFormatMoney(p,!1),L=core.shopifyPriceRounding(r,2),h=core.useFormatMoney(p-parseFloat(L),!1),m=()=>{let n=[];return!1!==e.isShowSubTotalLabel&&n.push({title:t.subTotalLabel,money:o?u:d,uniqueId:"subTotalLabel"}),!1!==e.isShowDiscountLabel&&n.push({title:t.discountLabel,money:o&&i&&a?`${i.value}%`:s>0?c:"No discount",uniqueId:"discountLabel"}),!1!==e.isShowShippingLabel&&n.push({title:t.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==e.isShowTaxesLabel&&n.push({title:t.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==e.isShowTotalLabel&&n.push({title:t.totalLabel,money:o?u:h,uniqueId:"totalLabel"}),n};return{getMoneyLines:m}};exports.useGetMoneyLines=useGetMoneyLines;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),common=require("../utils/common.js"),getShapePosition=require("../utils/getShapePosition.js"),getRotateShape=require("../utils/getRotateShape.js"),getStyleAdvanced=require("../utils/getStyleAdvanced.js"),getWhiteSpace=require("../utils/getWhiteSpace.js"),stylesV2=require("../utils/stylesV2.js"),shape=require("../utils/shape.js"),renderBadgeILP=require("../utils/renderBadgeILP.js");const getSizeStyles=e=>{let{setting:t,styles:o}=e,r=shape.getShape(t?.shape),a=t?.contentType==="text",i=a?o?.textSizeV2:o?.imageSizeV2;return a?common.getSize(r,i):common.getSize(void 0,i)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:a,navigationPosition:i,imageData:s,dotData:n}=e,g=o?.positionWithImage==="outside",l=common.getWrapperStyle(t),p=getShapePosition.getShapePosition({positionType:r?.position,isLiquid:!1,navigationPosition:i,dataImage:{...s,...n}}),S=getSizeStyles(e),d=getStyleAdvanced.getStyleAdvanced(g?{}:{...p,...S},a);return{...!g&&{"--pos":"absolute"},...l,...d}},getTextContentStyle=({styles:e,setting:t})=>{let o=core.makeGlobalSize(e?.textSizeV2).padding,r=shape.getShape(t?.shape),a=t?.positionWithImage==="outside";return{...getWhiteSpace.getWhiteSpaceStyle(e?.textSizeV2),...common.convertToStyle(r?.textStyle),...getRotateShape.composeTextStyleByPosition(r,e?.position,a),...core.composeTypographyStyle(e?.typo),...core.getStyleShadow({value:e?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:e?.typo?.custom?.hasShadowText}),...stylesV2.getStyleBackground(!!r?.backgroundColorInText,e?.badgeColorV2),...o}},getBorderStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?stylesV2.getStyleBorder(e?.textBadgeBorder):stylesV2.getStyleBorder(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?stylesV2.getStyleCornerRadius(e?.textBadgeCorner,o?.shapeRadius):stylesV2.getStyleCornerRadius(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=getBorderStyles({setting:t,styles:e}),a=t?.positionWithImage==="outside",i=getCornerStyles({setting:t,styles:e}),s=common.getShapeWrapperPadding(o?.ratio);return{...r,...i,...getRotateShape.composeShapeStyleByPosition(o,e?.position,a),...stylesV2.getStyleBackground(!o?.backgroundColorInText,e?.badgeColorV2),...s,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:e,setting:t})=>{let o=getBorderStyles({setting:t,styles:e}),r=getCornerStyles({setting:t,styles:e}),a=core.makeGlobalSize(e?.imageSizeV2).padding;return{...o,...r,...a}},getOpacityProductBadge=(e,t,o,r)=>{let{"bundle-item":a,setting:i}=e;if(a)return 1;let s=common.checkDiscountContentProductBadge(i?.displayContent)&&i?.contentType==="text";if(!s)return 1;let n=t?.price??0,g=t?.salePrice??0,l=g-n>0,p=renderBadgeILP.checkShowBadge(i?.displayTrigger,o,t);return l&&p?1:"edit"===r?.2:0},getSubWrapperStyle=(e,t,o,r)=>{let{setting:a}=e,i=a?.positionWithImage==="outside",s=getSizeStyles(e),n=r&&o?getOpacityProductBadge(e,o,t,r):1;return{...i?{...s,"--mb":0}:{},opacity:n}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,a=o?.contentType==="text";return stylesV2.generateShadowCSS(`[id="${r?.uid}"] .product-badge-item`,a?t?.textBadgeShadow:t?.imageBadgeShadow)};exports.getContainerStyle=getContainerStyle,exports.getContentStyleInternal=getContentStyleInternal,exports.getImageContainerStyles=getImageContainerStyles,exports.getSubWrapperStyle=getSubWrapperStyle,exports.getTextBadgeWrapperStyles=getTextBadgeWrapperStyles,exports.getTextContentStyle=getTextContentStyle;
1
+ "use strict";var core=require("@gem-sdk/core"),common=require("../utils/common.js"),getShapePosition=require("../utils/getShapePosition.js"),getRotateShape=require("../utils/getRotateShape.js"),getStyleAdvanced=require("../utils/getStyleAdvanced.js"),getWhiteSpace=require("../utils/getWhiteSpace.js"),stylesV2=require("../utils/stylesV2.js"),shape=require("../utils/shape.js"),renderBadgeILP=require("../utils/renderBadgeILP.js");const getSizeStyles=e=>{let{setting:t,styles:o}=e,r=shape.getShape(t?.shape),a=t?.contentType==="text",i=a?o?.textSizeV2:o?.imageSizeV2;return a?common.getSize(r,i):common.getSize(void 0,i)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:a,navigationPosition:i,imageData:s,dotData:n}=e,g=o?.positionWithImage==="outside",l=common.getWrapperStyle(t),p=getShapePosition.getShapePosition({positionType:r?.position,isLiquid:!1,navigationPosition:i,dataImage:{...s,...n}}),S=getSizeStyles(e),d=getStyleAdvanced.getStyleAdvanced(g?{}:{...p,...S},a);return{...!g&&{"--pos":"absolute"},...l,...d}},getTextContentStyle=({styles:e,setting:t})=>{let o=core.makeGlobalSize(e?.textSizeV2).padding,r=shape.getShape(t?.shape),a=t?.positionWithImage==="outside";return{...getWhiteSpace.getWhiteSpaceStyle(e?.textSizeV2),...common.convertToStyle(r?.textStyle),...getRotateShape.composeTextStyleByPosition(r,e?.position,a),...core.composeTypographyStyle(e?.typo),...core.getStyleShadow({value:e?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:e?.typo?.custom?.hasShadowText}),...stylesV2.getStyleBackground(!!r?.backgroundColorInText,e?.badgeColorV2),...o}},getBorderStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?stylesV2.getStyleBorder(e?.textBadgeBorder):stylesV2.getStyleBorder(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?stylesV2.getStyleCornerRadius(e?.textBadgeCorner,o?.shapeRadius):stylesV2.getStyleCornerRadius(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=getBorderStyles({setting:t,styles:e}),a=t?.positionWithImage==="outside",i=getCornerStyles({setting:t,styles:e}),s=common.getShapeWrapperPadding(o?.ratio);return{...r,...i,...getRotateShape.composeShapeStyleByPosition(o,e?.position,a),...stylesV2.getStyleBackground(!o?.backgroundColorInText,e?.badgeColorV2),...s,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:e,setting:t})=>{let o=getBorderStyles({setting:t,styles:e}),r=getCornerStyles({setting:t,styles:e}),a=core.makeGlobalSize(e?.imageSizeV2).padding;return{...o,...r,...a}},getOpacityProductBadge=(e,t,o,r)=>{let{"bundle-item":a,setting:i}=e;if(a)return 1;let s=common.checkDiscountContentProductBadge(i?.displayContent)&&i?.contentType==="text";if(!s)return 1;let n=core.convertDecimalToNumber(t?.price)??0,g=core.convertDecimalToNumber(t?.salePrice)??0,l=g-n>0,p=renderBadgeILP.checkShowBadge(i?.displayTrigger,o,t);return l&&p?1:"edit"===r?.2:0},getSubWrapperStyle=(e,t,o,r)=>{let{setting:a}=e,i=a?.positionWithImage==="outside",s=getSizeStyles(e),n=r&&o?getOpacityProductBadge(e,o,t,r):1;return{...i?{...s,"--mb":0}:{},opacity:n}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,a=o?.contentType==="text";return stylesV2.generateShadowCSS(`[id="${r?.uid}"] .product-badge-item`,a?t?.textBadgeShadow:t?.imageBadgeShadow)};exports.getContainerStyle=getContainerStyle,exports.getContentStyleInternal=getContentStyleInternal,exports.getImageContainerStyles=getImageContainerStyles,exports.getSubWrapperStyle=getSubWrapperStyle,exports.getTextBadgeWrapperStyles=getTextBadgeWrapperStyles,exports.getTextContentStyle=getTextContentStyle;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),productBundle=require("../../../helpers/product-bundle.js"),productBundle$1=require("../../constants/product-bundle.js");const removeTrailingZeros=e=>e.replace(/\.00$/,""),getPriceDiffByPercent=(e,t)=>{if(!t)return"0";let r=1e3*t-1e3*e;return Math.round(100*r/(1e3*t))},getPriceDiffByValue=(e,t,r)=>removeTrailingZeros(core.formatMoney(t?(t-e).toFixed(2):"0",r)),getMinPrice=(e,t)=>{let r=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let t=e?.price;void 0!==t&&t<r&&(r=t)}),removeTrailingZeros(core.formatMoney(r.toString(),t))},checkNoDiscountState=(e,t)=>{let{discountPercentAmount:r}=productBundle.applyBundleDiscountAmount({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===productBundle$1.DiscountType.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},getBadgeContent=(e,t,r)=>{if(!e.detail||!t?.trim()?.length)return t;let{detail:i,currentVariant:o}=e,{discountPercentAmount:n,discountAmount:c}=productBundle.applyBundleDiscountAmount({currentVariant:o,bundleItem:e?.bundleItem,options:{moneyFormat:r,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),u=()=>e?.bundleItem?.discountType!==productBundle$1.DiscountType.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${n}%`:`${getPriceDiffByPercent(o?.price||0,o?.salePrice||0)||0}%`:"0%",l=()=>e?.bundleItem?.discountType!==productBundle$1.DiscountType.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?c:getPriceDiffByValue(o?.price||0,o?.salePrice||0,r):core.formatMoney("0",r),a=new Map([["{percent_discount}",u],["{amount_discount}",l],["{min_price}",()=>getMinPrice(i.variants,r)||0],["{inventory_quantity}",()=>o?.inventoryQuantity||0]]);return[...a.entries()].reduce((e,[t,r])=>e.replaceAll(t,r()),t)},checkDiscountContentProductBadge=e=>{if(!e)return!1;let t=/\{percent_discount\}|\{amount_discount\}/;return t.test(e)},getShapePlacementClass=(e,t,r="desktop")=>e?t?.[`--pos${deviceWithSurfix(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${deviceWithSurfix(r)}`]?"":"!gp-inline-block gp-w-fit",getAlignShape=(e,t)=>t?"":core.cls("gp-flex",{"gp-justify-start":e?.desktop==="left","gp-justify-center":e?.desktop==="center","gp-justify-end":e?.desktop==="right","tablet:gp-justify-start":e?.tablet==="left","tablet:gp-justify-center":e?.tablet==="center","tablet:gp-justify-end":e?.tablet==="right","mobile:gp-justify-start":e?.mobile==="left","mobile:gp-justify-center":e?.mobile==="center","mobile:gp-justify-end":e?.mobile==="right"}),convertToStyle=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),o=i.get(t)||t;return{...e,[o]:r}},{}),getWrapperStyle=e=>({[e?"z-index":"zIndex"]:2}),getWidthByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=core.getResponsiveValueByScreen(e,i,null),n=o?.width||t?.wrapperWidth;n&&(r={...r,[i]:n})}),r},getHeightByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=core.getResponsiveValueByScreen(e,i,null);r={...r,[i]:o?.height||t?.wrapperHeight}}),r},getSize=(e,t)=>{let r=core.makeStyleResponsive("w",getWidthByShapeSize(t,e)),i=core.makeStyleResponsive("h",getHeightByShapeSize(t,e));return{...r,...i}},getShapeWrapperPadding=e=>{let t={};if(1!==e)return t;let r=["desktop","mobile","tablet"];return r.forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},deviceWithSurfix=e=>"desktop"===e?"":`-${e}`,getDeviceSpecificStyle=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},getIsNoDiscountState=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:o})=>{let{setting:n,"bundle-item":c}=e,u=checkDiscountContentProductBadge(n?.displayContent);return u&&checkNoDiscountState({detail:t,currentVariant:r,bundleItem:c,useProductCompareAtPrice:o},i)};exports.checkDiscountContentProductBadge=checkDiscountContentProductBadge,exports.checkNoDiscountState=checkNoDiscountState,exports.convertToStyle=convertToStyle,exports.deviceWithSurfix=deviceWithSurfix,exports.getAlignShape=getAlignShape,exports.getBadgeContent=getBadgeContent,exports.getDeviceSpecificStyle=getDeviceSpecificStyle,exports.getIsNoDiscountState=getIsNoDiscountState,exports.getShapePlacementClass=getShapePlacementClass,exports.getShapeWrapperPadding=getShapeWrapperPadding,exports.getSize=getSize,exports.getWidthByShapeSize=getWidthByShapeSize,exports.getWrapperStyle=getWrapperStyle;
1
+ "use strict";var core=require("@gem-sdk/core"),productBundle=require("../../../helpers/product-bundle.js"),productBundle$1=require("../../constants/product-bundle.js");const removeTrailingZeros=e=>e.replace(/\.00$/,""),getPriceDiffByPercent=(e,t)=>{if(!t)return"0";let r=1e3*t-1e3*e;return Math.round(100*r/(1e3*t))},getPriceDiffByValue=(e,t,r)=>removeTrailingZeros(core.formatMoney(t?(t-e).toFixed(2):"0",r)),getMinPrice=(e,t)=>{let r=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let t=core.convertDecimalToNumber(e?.price);void 0!==t&&t<r&&(r=t)}),removeTrailingZeros(core.formatMoney(r.toString(),t))},checkNoDiscountState=(e,t)=>{let{discountPercentAmount:r}=productBundle.applyBundleDiscountAmount({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===productBundle$1.DiscountType.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},getBadgeContent=(e,t,r)=>{if(!e.detail||!t?.trim()?.length)return t;let{detail:i,currentVariant:o}=e,{discountPercentAmount:n,discountAmount:c}=productBundle.applyBundleDiscountAmount({currentVariant:o,bundleItem:e?.bundleItem,options:{moneyFormat:r,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),u=()=>e?.bundleItem?.discountType!==productBundle$1.DiscountType.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${n}%`:`${getPriceDiffByPercent(core.convertDecimalToNumber(o?.price)??0,core.convertDecimalToNumber(o?.salePrice)??0)||0}%`:"0%",l=()=>e?.bundleItem?.discountType!==productBundle$1.DiscountType.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?c:getPriceDiffByValue(core.convertDecimalToNumber(o?.price)??0,core.convertDecimalToNumber(o?.salePrice)??0,r):core.formatMoney("0",r),a=new Map([["{percent_discount}",u],["{amount_discount}",l],["{min_price}",()=>getMinPrice(i.variants,r)||0],["{inventory_quantity}",()=>o?.inventoryQuantity||0]]);return[...a.entries()].reduce((e,[t,r])=>e.replaceAll(t,r()),t)},checkDiscountContentProductBadge=e=>{if(!e)return!1;let t=/\{percent_discount\}|\{amount_discount\}/;return t.test(e)},getShapePlacementClass=(e,t,r="desktop")=>e?t?.[`--pos${deviceWithSurfix(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${deviceWithSurfix(r)}`]?"":"!gp-inline-block gp-w-fit",getAlignShape=(e,t)=>t?"":core.cls("gp-flex",{"gp-justify-start":e?.desktop==="left","gp-justify-center":e?.desktop==="center","gp-justify-end":e?.desktop==="right","tablet:gp-justify-start":e?.tablet==="left","tablet:gp-justify-center":e?.tablet==="center","tablet:gp-justify-end":e?.tablet==="right","mobile:gp-justify-start":e?.mobile==="left","mobile:gp-justify-center":e?.mobile==="center","mobile:gp-justify-end":e?.mobile==="right"}),convertToStyle=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),o=i.get(t)||t;return{...e,[o]:r}},{}),getWrapperStyle=e=>({[e?"z-index":"zIndex"]:2}),getWidthByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=core.getResponsiveValueByScreen(e,i,null),n=o?.width||t?.wrapperWidth;n&&(r={...r,[i]:n})}),r},getHeightByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=core.getResponsiveValueByScreen(e,i,null);r={...r,[i]:o?.height||t?.wrapperHeight}}),r},getSize=(e,t)=>{let r=core.makeStyleResponsive("w",getWidthByShapeSize(t,e)),i=core.makeStyleResponsive("h",getHeightByShapeSize(t,e));return{...r,...i}},getShapeWrapperPadding=e=>{let t={};if(1!==e)return t;let r=["desktop","mobile","tablet"];return r.forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},deviceWithSurfix=e=>"desktop"===e?"":`-${e}`,getDeviceSpecificStyle=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},getIsNoDiscountState=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:o})=>{let{setting:n,"bundle-item":c}=e,u=checkDiscountContentProductBadge(n?.displayContent);return u&&checkNoDiscountState({detail:t,currentVariant:r,bundleItem:c,useProductCompareAtPrice:o},i)};exports.checkDiscountContentProductBadge=checkDiscountContentProductBadge,exports.checkNoDiscountState=checkNoDiscountState,exports.convertToStyle=convertToStyle,exports.deviceWithSurfix=deviceWithSurfix,exports.getAlignShape=getAlignShape,exports.getBadgeContent=getBadgeContent,exports.getDeviceSpecificStyle=getDeviceSpecificStyle,exports.getIsNoDiscountState=getIsNoDiscountState,exports.getShapePlacementClass=getShapePlacementClass,exports.getShapeWrapperPadding=getShapeWrapperPadding,exports.getSize=getSize,exports.getWidthByShapeSize=getWidthByShapeSize,exports.getWrapperStyle=getWrapperStyle;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),React=require("react"),tracking=require("../../../helpers/tracking.js"),useDispatchAfterSubmitEvent=require("./useDispatchAfterSubmitEvent.js"),useCartMessage=require("./useCartMessage.js"),useCartOperations=require("./useCartOperations.js");const useBtnAddToCart=({styles:e,setting:r,builderProps:t})=>{let s=React.useRef(null),{isEditMode:u,isPreviewSharePageMode:a}=core.useRenderMode(),i=core.useProduct(),{currency:c}=core.useCurrency(),{quantity:n}=core.useQuantity(),o=core.useProductProperties(),l=core.useCurrentVariant(),{hasPreSelected:d}=core.useHasPreSelected(),b=core.useStickyStore(e=>e.setStickyVisible),C=core.useProductStore(e=>e.updateIsSubmit),v=useDispatchAfterSubmitEvent.useDispatchAfterSubmitEvent(t?.uid),{showMessage:g,notiComponent:p}=useCartMessage.useCartMessage(e,r),{handleSuccess:f,handleError:k,cartId:S}=useCartOperations.useCartOperations(r,g,v),{isMutating:I,trigger:m}=core.useCreateCart({onSuccess:f,onError:k}),{isMutating:D,trigger:E}=core.useAddToCart({onSuccess:f,onError:k});React.useEffect(()=>{let e=new IntersectionObserver(e=>{let r=e[0];b(r?.isIntersecting)},{threshold:.1}),r=s.current;return s.current&&e.observe(s.current),()=>{r&&e.unobserve(r)}},[b]);let A=React.useCallback(()=>{if(!l?.baseID||!n||!i?.baseID||void 0!==d&&!d||u||a)return;let e=o?.some(e=>e.required&&!e.value);if(C(!0),e)return;let t=o?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));tracking.addToCartTracking({quantity:n,currency:c,id:i?.baseID,name:i?.title,brand:i?.vendor,sku:l.sku,price:l?.price,variant:l.title});let s={quantity:n,attributes:t,variantId:l.baseID};r?.actionEffect!=="buy-now"&&S?E({cartId:S,lines:[s]}):m({items:[s]})},[u,a,S,c,n,o,d,i?.title,i?.vendor,i?.baseID,l?.sku,l?.price,l?.title,l?.baseID,r?.actionEffect,m,E,C]),h=core.useCurrentVariantInStock(),q=I||D,y=l?r?.outOfStockLabel:"Unavailable";return{addToCartRef:s,isLoading:q,isInStock:h,notiComponent:p,outOfStockLabel:y,addToCart:A}};exports.useBtnAddToCart=useBtnAddToCart;
1
+ "use strict";var core=require("@gem-sdk/core"),React=require("react"),tracking=require("../../../helpers/tracking.js"),useDispatchAfterSubmitEvent=require("./useDispatchAfterSubmitEvent.js"),useCartMessage=require("./useCartMessage.js"),useCartOperations=require("./useCartOperations.js");const useBtnAddToCart=({styles:e,setting:r,builderProps:t})=>{let s=React.useRef(null),{isEditMode:u,isPreviewSharePageMode:a}=core.useRenderMode(),i=core.useProduct(),{currency:c}=core.useCurrency(),{quantity:n}=core.useQuantity(),o=core.useProductProperties(),l=core.useCurrentVariant(),{hasPreSelected:d}=core.useHasPreSelected(),b=core.useStickyStore(e=>e.setStickyVisible),v=core.useProductStore(e=>e.updateIsSubmit),C=useDispatchAfterSubmitEvent.useDispatchAfterSubmitEvent(t?.uid),{showMessage:g,notiComponent:p}=useCartMessage.useCartMessage(e,r),{handleSuccess:f,handleError:k,cartId:S}=useCartOperations.useCartOperations(r,g,C),{isMutating:m,trigger:D}=core.useCreateCart({onSuccess:f,onError:k}),{isMutating:I,trigger:E}=core.useAddToCart({onSuccess:f,onError:k});React.useEffect(()=>{let e=new IntersectionObserver(e=>{let r=e[0];b(r?.isIntersecting)},{threshold:.1}),r=s.current;return s.current&&e.observe(s.current),()=>{r&&e.unobserve(r)}},[b]);let A=React.useCallback(()=>{if(!l?.baseID||!n||!i?.baseID||void 0!==d&&!d||u||a)return;let e=o?.some(e=>e.required&&!e.value);if(v(!0),e)return;let t=o?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));tracking.addToCartTracking({quantity:n,currency:c,id:i?.baseID,name:i?.title,brand:i?.vendor,sku:l.sku,price:core.convertDecimalToNumber(l?.price),variant:l.title});let s={quantity:n,attributes:t,variantId:l.baseID};r?.actionEffect!=="buy-now"&&S?E({cartId:S,lines:[s]}):D({items:[s]})},[u,a,S,c,n,o,d,i?.title,i?.vendor,i?.baseID,l?.sku,l?.price,l?.title,l?.baseID,r?.actionEffect,D,E,v]),h=core.useCurrentVariantInStock(),q=m||I,y=l?r?.outOfStockLabel:"Unavailable";return{addToCartRef:s,isLoading:q,isInStock:h,notiComponent:p,outOfStockLabel:y,addToCart:A}};exports.useBtnAddToCart=useBtnAddToCart;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),React=require("react"),productBundle=require("../../../helpers/product-bundle.js"),productBundle$1=require("../../constants/product-bundle.js");const useGpDiscountTag=e=>{let{setting:t,...u}=e,{customContent:r}=t??{},o=u["bundle-item"],{moneyFormat:n}=core.useMoneyFormat(),c=core.useEditorMode(),s=core.useProduct(),i=core.useCurrentVariant(),{quantity:a,hasUpdatePrice:d}=core.useQuantity(),p=React.useMemo(()=>d&&r?.unit!=="percentage"?a??1:1,[d,r?.unit,a]),l=i?.price??0,m=i?.salePrice??0,g=(m-l)*p,M=core.useFormatMoney(g<0?0:g,t?.moneyWithCurrentFormat||!1),y=React.useMemo(()=>{if(!m&&0!==m||!l&&0!==l)return`${r?.unit==="percentage"?"0%":M}`;if(r?.unit==="percentage"){let e=Math.round(g/(m/100));return`${e<0?0:e}%`}return`${M}`},[r?.unit,M,l,g,m]),{useProductCompareAtPrice:D}=core.useProductBundleDiscount(),{discountPercentAmount:B}=productBundle.applyBundleDiscountAmount({currentVariant:i,bundleItem:o,options:{moneyFormat:n,useProductCompareAtPrice:D}}),R=React.useMemo(()=>{if(!o)return 0;let{discountPercentAmount:e,discountAmount:t}=productBundle.applyBundleDiscountAmount({currentVariant:i,bundleItem:o,options:{moneyFormat:n,useProductCompareAtPrice:D}}),{discountType:u}=o,{unit:c}=r||{};return u!==productBundle$1.DiscountType.NoDiscount||D?"percentage"===c?`${e}%`:t:"percentage"===c?"0%":core.formatMoney("0",n)},[o,i,n,D,r]),$=React.useMemo(()=>o?R:y,[R,o,y]),f=s?.baseID?.replace("gid://shopify/Product/",""),b=React.useMemo(()=>{let e=o?B<=0:g<=0;return"edit"===c&&e},[o,B,c,g]);return{mode:c,product:s,salePrice:m,priceSave:g,currentProductId:f,unitCustomDisplay:$,shouldPlaceholderNoDiscount:b}};exports.useGpDiscountTag=useGpDiscountTag;
1
+ "use strict";var core=require("@gem-sdk/core"),React=require("react"),productBundle=require("../../../helpers/product-bundle.js"),productBundle$1=require("../../constants/product-bundle.js");const useGpDiscountTag=e=>{let{setting:r,...t}=e,{customContent:u}=r??{},o=t["bundle-item"],{moneyFormat:n}=core.useMoneyFormat(),c=core.useEditorMode(),s=core.useProduct(),i=core.useCurrentVariant(),{quantity:a,hasUpdatePrice:d}=core.useQuantity(),p=React.useMemo(()=>d&&u?.unit!=="percentage"?a??1:1,[d,u?.unit,a]),l=core.convertDecimalToNumber(i?.price)??0,m=core.convertDecimalToNumber(i?.salePrice)??0,D=(m-l)*p,g=core.useFormatMoney(D<0?0:D,r?.moneyWithCurrentFormat||!1),M=React.useMemo(()=>{if(!m&&0!==m||!l&&0!==l)return`${u?.unit==="percentage"?"0%":g}`;if(u?.unit==="percentage"){let e=Math.round(D/(m/100));return`${e<0?0:e}%`}return`${g}`},[u?.unit,g,l,D,m]),{useProductCompareAtPrice:y}=core.useProductBundleDiscount(),{discountPercentAmount:B}=productBundle.applyBundleDiscountAmount({currentVariant:i,bundleItem:o,options:{moneyFormat:n,useProductCompareAtPrice:y}}),b=React.useMemo(()=>{if(!o)return 0;let{discountPercentAmount:e,discountAmount:r}=productBundle.applyBundleDiscountAmount({currentVariant:i,bundleItem:o,options:{moneyFormat:n,useProductCompareAtPrice:y}}),{discountType:t}=o,{unit:c}=u||{};return t!==productBundle$1.DiscountType.NoDiscount||y?"percentage"===c?`${e}%`:r:"percentage"===c?"0%":core.formatMoney("0",n)},[o,i,n,y,u]),R=React.useMemo(()=>o?b:M,[b,o,M]),T=s?.baseID?.replace("gid://shopify/Product/",""),$=React.useMemo(()=>{let e=o?B<=0:D<=0;return"edit"===c&&e},[o,B,c,D]);return{mode:c,product:s,salePrice:m,priceSave:D,currentProductId:T,unitCustomDisplay:R,shouldPlaceholderNoDiscount:$}};exports.useGpDiscountTag=useGpDiscountTag;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),common=require("../../product-variants/common/common.js"),core=require("@gem-sdk/core");const useGpPrice=e=>{let{setting:r,builderProps:t}=e,c=React.useRef(null),o=core.useEditorMode(),{quantity:u,hasUpdatePrice:i}=core.useQuantity(),a=core.useCurrentVariant(),{useProductCompareAtPrice:n}=core.useProductBundleDiscount(),s=e["bundle-item"],d=a?.price??0,p=a?.salePrice??0,l=r?.priceType==="compare",{trigger:m}=core.useInteraction(),g=core.useProduct(),y=g?.baseID?.replace("gid://shopify/Product/",""),P=core.useShopStore(e=>e.showPriceCurrency),h=React.useMemo(()=>s?.quantity?s.quantity:i&&u||1,[u,i,s?.quantity]),b=React.useMemo(()=>{let e=Number(s?.discountValue);return s?.discountType==="percentage"?d*h*e/100:e},[s?.discountType,s?.discountValue,d,h]),v=React.useMemo(()=>s?.discountValue?n?(p||d)*h:d*h:p*h,[s?.discountValue,d,h,p,n]),M=React.useMemo(()=>{let e=d*h;return l?v:b?Math.max(0,e-b):e},[d,h,b,v,l]),R=(e,r)=>{m({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${t?.uid}"]`,element:c.current}),m({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${t?.uid}"]`,element:c.current})};common.useTransition(e=>{e!==d&&R(d,"price")},[d]),common.useTransition(e=>{e!==p&&R(p,"compare")},[p]);let q=()=>{if("edit"!==o)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:t?.uid,value:!M&&l,tag:"ProductPrice"}});window.dispatchEvent(e)},w=core.useFormatMoney(M??0,P||!1),T=l&&!M,V="edit"!==o&&T;return{elementRef:c,moneyFormatted:w,currentProductId:y,isNoComparePrice:T,isNoComparePriceILP:V,emitNoDataSignal:q}};exports.useGpPrice=useGpPrice;
1
+ "use strict";var React=require("react"),common=require("../../product-variants/common/common.js"),core=require("@gem-sdk/core");const useGpPrice=e=>{let{setting:r,builderProps:c}=e,t=React.useRef(null),o=core.useEditorMode(),{quantity:u,hasUpdatePrice:i}=core.useQuantity(),a=core.useCurrentVariant(),{useProductCompareAtPrice:n}=core.useProductBundleDiscount(),s=e["bundle-item"],d=core.convertDecimalToNumber(a?.price)??0,p=core.convertDecimalToNumber(a?.salePrice)??0,m=r?.priceType==="compare",{trigger:l}=core.useInteraction(),g=core.useProduct(),b=g?.baseID?.replace("gid://shopify/Product/",""),y=core.useShopStore(e=>e.showPriceCurrency),P=React.useMemo(()=>s?.quantity?s.quantity:i&&u||1,[u,i,s?.quantity]),h=React.useMemo(()=>{let e=Number(s?.discountValue);return s?.discountType==="percentage"?d*P*e/100:e},[s?.discountType,s?.discountValue,d,P]),v=React.useMemo(()=>s?.discountValue?n?(p||d)*P:d*P:p*P,[s?.discountValue,d,P,p,n]),M=React.useMemo(()=>{let e=d*P;return m?v:h?Math.max(0,e-h):e},[d,P,h,v,m]),R=(e,r)=>{l({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${c?.uid}"]`,element:t.current}),l({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${c?.uid}"]`,element:t.current})};common.useTransition(e=>{e!==d&&R(d,"price")},[d]),common.useTransition(e=>{e!==p&&R(p,"compare")},[p]);let T=()=>{if("edit"!==o)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:c?.uid,value:!M&&m,tag:"ProductPrice"}});window.dispatchEvent(e)},q=core.useFormatMoney(M??0,y||!1),w=m&&!M,V="edit"!==o&&w;return{elementRef:t,moneyFormatted:q,currentProductId:b,isNoComparePrice:w,isNoComparePriceILP:V,emitNoDataSignal:T}};exports.useGpPrice=useGpPrice;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),productBundle=require("../components/constants/product-bundle.js");const noDiscount=e=>({discountPercentAmount:0,discountAmount:core.formatMoney("0",e)}),applyBundleDiscountAmount=e=>{let{currentVariant:t,bundleItem:n,options:o}=e;if(!o?.useProductCompareAtPrice&&n?.discountType===productBundle.DiscountType.NoDiscount||!n||!t?.price)return noDiscount(o?.moneyFormat||"${{amount}}");let u=Number(t?.price),c=Number(t?.salePrice)||u,r=Number(n?.quantity),i=calculateBundleFixedDiscount(u,n),a=discountPercentAmount(i,r*u),d=u*r-i,s=c*r;return c<=u&&i<=0?noDiscount(o?.moneyFormat||"${{amount}}"):{discountPercentAmount:o?.useProductCompareAtPrice?calculateDiffPercentPrice(d,s):a,discountAmount:o?.useProductCompareAtPrice?calculateDiffFixedPrice(d,s,o?.moneyFormat):core.formatMoney(i.toString(),o?.moneyFormat)}},calculateDiffPercentPrice=(e,t)=>{let n=(t-e)/t*100;return Math.round(n)},calculateDiffFixedPrice=(e,t,n)=>core.formatMoney((t-e).toString(),n),calculateBundleFixedDiscount=(e,t)=>{let n=parseInt(t?.discountValue);return t?.discountType===productBundle.DiscountType.Percentage?e*t.quantity*n/100:t?.discountType===productBundle.DiscountType.FixedAmount?n:0},discountPercentAmount=(e,t)=>Math.round(e/t*100);exports.applyBundleDiscountAmount=applyBundleDiscountAmount;
1
+ "use strict";var core=require("@gem-sdk/core"),productBundle=require("../components/constants/product-bundle.js");const noDiscount=e=>({discountPercentAmount:0,discountAmount:core.formatMoney("0",e)}),applyBundleDiscountAmount=e=>{let{currentVariant:t,bundleItem:o,options:n}=e;if(!n?.useProductCompareAtPrice&&o?.discountType===productBundle.DiscountType.NoDiscount||!o||!t?.price)return noDiscount(n?.moneyFormat||"${{amount}}");let u=core.convertDecimalToNumber(t?.price)??0,c=core.convertDecimalToNumber(t?.salePrice)??u,r=Number(o?.quantity),i=calculateBundleFixedDiscount(u,o),a=discountPercentAmount(i,r*u),d=u*r-i,s=c*r;return c<=u&&i<=0?noDiscount(n?.moneyFormat||"${{amount}}"):{discountPercentAmount:n?.useProductCompareAtPrice?calculateDiffPercentPrice(d,s):a,discountAmount:n?.useProductCompareAtPrice?calculateDiffFixedPrice(d,s,n?.moneyFormat):core.formatMoney(i.toString(),n?.moneyFormat)}},calculateDiffPercentPrice=(e,t)=>{let o=(t-e)/t*100;return Math.round(o)},calculateDiffFixedPrice=(e,t,o)=>core.formatMoney((t-e).toString(),o),calculateBundleFixedDiscount=(e,t)=>{let o=parseInt(t?.discountValue);return t?.discountType===productBundle.DiscountType.Percentage?e*t.quantity*o/100:t?.discountType===productBundle.DiscountType.FixedAmount?o:0},discountPercentAmount=(e,t)=>Math.round(e/t*100);exports.applyBundleDiscountAmount=applyBundleDiscountAmount;
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useCurrentVariant as p,useProduct as t,shopifyPriceRounding as o,useProductOfferDiscount as c,useFormatMoney as i,cls as a}from"@gem-sdk/core";import{useMemo as s}from"react";import m from"../../text/components/Text.js";import{useDynamicProduct as l}from"../hooks/useDynamicProduct.js";let PostPurchaseProductPrice=({styles:u,style:d,builderAttrs:y,builderProps:n,children:P})=>{let h=p(),T=t(),g=h?.price??0,f=h?.salePrice??0,x=parseFloat(o(c(),2)),{isDynamicProduct:j}=l(),F=s(()=>x?u?.priceType==="compare"?g:g-x:u?.priceType==="compare"?f:g,[x,u?.priceType,g,f]),k=i(parseFloat(F.toFixed(2)),!1),D=T?.baseID?.replace("gid://shopify/Product/",""),N=s(()=>u?.priceType==="compare"&&(!x&&f<g||g<=0),[x,g,f,u?.priceType]);return N?null:e("div",{...y,className:a(n?.uid),style:{...d},id:`shopify-text-element-${n?.uid}`,"data-product-id":D,children:[r(m,{styles:u,setting:{text:j?"$???":k},className:a({"gp-money":u?.priceType==="regular","gp-product-compare-price":u?.priceType==="compare","gp-line-through":u?.priceType==="compare"&&u?.lineThrough})}),P]})};export{PostPurchaseProductPrice as default};
2
+ import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useCurrentVariant as p,useProduct as t,convertDecimalToNumber as o,shopifyPriceRounding as c,useProductOfferDiscount as i,useFormatMoney as a,cls as s}from"@gem-sdk/core";import{useMemo as m}from"react";import u from"../../text/components/Text.js";import{useDynamicProduct as l}from"../hooks/useDynamicProduct.js";let PostPurchaseProductPrice=({styles:d,style:y,builderAttrs:n,builderProps:P,children:h})=>{let T=p(),g=t(),f=o(T?.price)??0,x=o(T?.salePrice)??0,j=parseFloat(c(i(),2)),{isDynamicProduct:N}=l(),b=m(()=>j?d?.priceType==="compare"?f:f-j:d?.priceType==="compare"?x:f,[j,d?.priceType,f,x]),k=a(parseFloat(c(Number(b)||0,2)),!1),D=g?.baseID?.replace("gid://shopify/Product/",""),F=m(()=>d?.priceType==="compare"&&(!j&&x<f||f<=0),[j,f,x,d?.priceType]);return F?null:e("div",{...n,className:s(P?.uid),style:{...y},id:`shopify-text-element-${P?.uid}`,"data-product-id":D,children:[r(u,{styles:d,setting:{text:N?"$???":k},className:s({"gp-money":d?.priceType==="regular","gp-product-compare-price":d?.priceType==="compare","gp-line-through":d?.priceType==="compare"&&d?.lineThrough})}),h]})};export{PostPurchaseProductPrice as default};
@@ -1 +1 @@
1
- let productOfferPlaceholder={id:"",title:"Dynamic product",description:"This is a dynamic product. The actual product will appear here based on your setup",descriptionHtml:'<p class="QN2lPu">This is a dynamic product. The actual product will</p>\n<p class="QN2lPu">appear here based on your setup</p>',createdAt:"2024-07-01T04:19:51.286753Z",handle:"dynamic-product",averageRating:0,isStorefront:!0,isSample:!1,baseID:"",sku:"",options:[{id:"1",name:"Variant",optionType:"",values:[{id:"1",label:"Variant option",isDefault:!0,baseID:""}]}],vendor:"",featuredImage:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""},collections:{edges:[{node:{id:"502321959132988135",title:"Home page"}},{node:{id:"539286505089204764",title:"b"}},{node:{id:"539286505089401372",title:"e"}}]},tags:[],medias:{edges:[{cursor:"gqFpzweGNIc/AALZoXYB",node:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""}}],pageInfo:{endCursor:"gqFpzweGNIc/AALZoXYB",hasNextPage:!0}},variants:{edges:[{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:88,height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:88,salePrice:88,sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}},{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:88,height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:88,salePrice:88,sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}}],pageInfo:{hasNextPage:!1,endCursor:"gaFpzwc5ZqRtDAMI"}}};export{productOfferPlaceholder};
1
+ let productOfferPlaceholder={id:"",title:"Dynamic product",description:"This is a dynamic product. The actual product will appear here based on your setup",descriptionHtml:'<p class="QN2lPu">This is a dynamic product. The actual product will</p>\n<p class="QN2lPu">appear here based on your setup</p>',createdAt:"2024-07-01T04:19:51.286753Z",handle:"dynamic-product",averageRating:0,isStorefront:!0,isSample:!1,baseID:"",sku:"",options:[{id:"1",name:"Variant",optionType:"",values:[{id:"1",label:"Variant option",isDefault:!0,baseID:""}]}],vendor:"",featuredImage:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""},collections:{edges:[{node:{id:"502321959132988135",title:"Home page"}},{node:{id:"539286505089204764",title:"b"}},{node:{id:"539286505089401372",title:"e"}}]},tags:[],medias:{edges:[{cursor:"gqFpzweGNIc/AALZoXYB",node:{id:"542178560626918105",contentType:"IMAGE",previewImage:"",src:"https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png",width:449,height:449,alt:""}}],pageInfo:{endCursor:"gqFpzweGNIc/AALZoXYB",hasNextPage:!0}},variants:{edges:[{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:"88",height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:"88",salePrice:"88",sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}},{cursor:"gqFpzwc5ZqRtDAMIoXYC",node:{id:"520560088328176392",title:"Default Title",barcode:"",baseID:"gid://shopify/ProductVariant/49298248925463",costPrice:"88",height:0,inventoryPolicy:"DENY",inventoryQuantity:211,inventoryStatus:"",isDigital:!0,length:0,lowInventoryAmount:0,manageInventory:!1,mediaId:"0",platform:"SHOPIFY",price:"88",salePrice:"88",sku:"",soldIndividually:!1,weight:0,width:0,selectedOptions:[],media:void 0}}],pageInfo:{hasNextPage:!1,endCursor:"gaFpzwc5ZqRtDAMI"}}};export{productOfferPlaceholder};
@@ -1 +1 @@
1
- import{useProductOfferDiscount as e,useCurrentVariant as t,useQuantity as l,useFormatMoney as i,shopifyPriceRounding as o}from"@gem-sdk/core";import{useDynamicProduct as a}from"./useDynamicProduct.js";let useGetMoneyLines=(u,s)=>{let{isDynamicProduct:n,dynamicPrice:p,dynamicDiscount:b,isEnableDynamicDiscount:r}=a(),L=e(),h=t(),{quantity:c}=l(),d=L*(c||1),m=i(d,!1),w=h?.price??0,S=w*(c||1),f=i(S,!1),g=o(d,2),y=i(S-parseFloat(g),!1),T=()=>{let e=[];return!1!==u.isShowSubTotalLabel&&e.push({title:s.subTotalLabel,money:n?p:f,uniqueId:"subTotalLabel"}),!1!==u.isShowDiscountLabel&&e.push({title:s.discountLabel,money:n&&b&&r?`${b.value}%`:L>0?m:"No discount",uniqueId:"discountLabel"}),!1!==u.isShowShippingLabel&&e.push({title:s.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==u.isShowTaxesLabel&&e.push({title:s.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==u.isShowTotalLabel&&e.push({title:s.totalLabel,money:n?p:y,uniqueId:"totalLabel"}),e};return{getMoneyLines:T}};export{useGetMoneyLines};
1
+ import{useProductOfferDiscount as e,useCurrentVariant as t,useQuantity as l,useFormatMoney as i,convertDecimalToNumber as o,shopifyPriceRounding as a}from"@gem-sdk/core";import{useDynamicProduct as u}from"./useDynamicProduct.js";let useGetMoneyLines=(s,n)=>{let{isDynamicProduct:p,dynamicPrice:b,dynamicDiscount:r,isEnableDynamicDiscount:L}=u(),h=e(),c=t(),{quantity:d}=l(),m=h*(d||1),w=i(m,!1),S=o(c?.price)??0,f=S*(d||1),g=i(f,!1),y=a(m,2),T=i(f-parseFloat(y),!1),q=()=>{let e=[];return!1!==s.isShowSubTotalLabel&&e.push({title:n.subTotalLabel,money:p?b:g,uniqueId:"subTotalLabel"}),!1!==s.isShowDiscountLabel&&e.push({title:n.discountLabel,money:p&&r&&L?`${r.value}%`:h>0?w:"No discount",uniqueId:"discountLabel"}),!1!==s.isShowShippingLabel&&e.push({title:n.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==s.isShowTaxesLabel&&e.push({title:n.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==s.isShowTotalLabel&&e.push({title:n.totalLabel,money:p?b:T,uniqueId:"totalLabel"}),e};return{getMoneyLines:q}};export{useGetMoneyLines};
@@ -1 +1 @@
1
- import{makeGlobalSize as e,composeTypographyStyle as t,getStyleShadow as o}from"@gem-sdk/core";import{convertToStyle as r,getSize as i,getWrapperStyle as a,getShapeWrapperPadding as n,checkDiscountContentProductBadge as s}from"../utils/common.js";import{getShapePosition as p}from"../utils/getShapePosition.js";import{composeTextStyleByPosition as g,composeShapeStyleByPosition as l}from"../utils/getRotateShape.js";import{getStyleAdvanced as d}from"../utils/getStyleAdvanced.js";import{getWhiteSpaceStyle as u}from"../utils/getWhiteSpace.js";import{getStyleBackground as S,generateShadowCSS as y,getStyleBorder as m,getStyleCornerRadius as h}from"../utils/stylesV2.js";import{getShape as x}from"../utils/shape.js";import{checkShowBadge as c}from"../utils/renderBadgeILP.js";let getSizeStyles=e=>{let{setting:t,styles:o}=e,r=x(t?.shape),a=t?.contentType==="text",n=a?o?.textSizeV2:o?.imageSizeV2;return a?i(r,n):i(void 0,n)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:i,navigationPosition:n,imageData:s,dotData:g}=e,l=o?.positionWithImage==="outside",u=a(t),S=p({positionType:r?.position,isLiquid:!1,navigationPosition:n,dataImage:{...s,...g}}),y=getSizeStyles(e),m=d(l?{}:{...S,...y},i);return{...!l&&{"--pos":"absolute"},...u,...m}},getTextContentStyle=({styles:i,setting:a})=>{let n=e(i?.textSizeV2).padding,s=x(a?.shape),p=a?.positionWithImage==="outside";return{...u(i?.textSizeV2),...r(s?.textStyle),...g(s,i?.position,p),...t(i?.typo),...o({value:i?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:i?.typo?.custom?.hasShadowText}),...S(!!s?.backgroundColorInText,i?.badgeColorV2),...n}},getBorderStyles=({styles:e,setting:t})=>{let o=x(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?m(e?.textBadgeBorder):m(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=x(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?h(e?.textBadgeCorner,o?.shapeRadius):h(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=x(t?.shape),r=getBorderStyles({setting:t,styles:e}),i=t?.positionWithImage==="outside",a=getCornerStyles({setting:t,styles:e}),s=n(o?.ratio);return{...r,...a,...l(o,e?.position,i),...S(!o?.backgroundColorInText,e?.badgeColorV2),...s,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:t,setting:o})=>{let r=getBorderStyles({setting:o,styles:t}),i=getCornerStyles({setting:o,styles:t}),a=e(t?.imageSizeV2).padding;return{...r,...i,...a}},getOpacityProductBadge=(e,t,o,r)=>{let{"bundle-item":i,setting:a}=e;if(i)return 1;let n=s(a?.displayContent)&&a?.contentType==="text";if(!n)return 1;let p=t?.price??0,g=t?.salePrice??0,l=g-p>0,d=c(a?.displayTrigger,o,t);return l&&d?1:"edit"===r?.2:0},getSubWrapperStyle=(e,t,o,r)=>{let{setting:i}=e,a=i?.positionWithImage==="outside",n=getSizeStyles(e),s=r&&o?getOpacityProductBadge(e,o,t,r):1;return{...a?{...n,"--mb":0}:{},opacity:s}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,i=o?.contentType==="text";return y(`[id="${r?.uid}"] .product-badge-item`,i?t?.textBadgeShadow:t?.imageBadgeShadow)};export{getContainerStyle,getContentStyleInternal,getImageContainerStyles,getSubWrapperStyle,getTextBadgeWrapperStyles,getTextContentStyle};
1
+ import{makeGlobalSize as e,composeTypographyStyle as t,getStyleShadow as o,convertDecimalToNumber as r}from"@gem-sdk/core";import{convertToStyle as i,getSize as a,getWrapperStyle as n,getShapeWrapperPadding as s,checkDiscountContentProductBadge as p}from"../utils/common.js";import{getShapePosition as g}from"../utils/getShapePosition.js";import{composeTextStyleByPosition as l,composeShapeStyleByPosition as d}from"../utils/getRotateShape.js";import{getStyleAdvanced as u}from"../utils/getStyleAdvanced.js";import{getWhiteSpaceStyle as S}from"../utils/getWhiteSpace.js";import{getStyleBackground as y,generateShadowCSS as m,getStyleBorder as h,getStyleCornerRadius as x}from"../utils/stylesV2.js";import{getShape as c}from"../utils/shape.js";import{checkShowBadge as C}from"../utils/renderBadgeILP.js";let getSizeStyles=e=>{let{setting:t,styles:o}=e,r=c(t?.shape),i=t?.contentType==="text",n=i?o?.textSizeV2:o?.imageSizeV2;return i?a(r,n):a(void 0,n)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:i,navigationPosition:a,imageData:s,dotData:p}=e,l=o?.positionWithImage==="outside",d=n(t),S=g({positionType:r?.position,isLiquid:!1,navigationPosition:a,dataImage:{...s,...p}}),y=getSizeStyles(e),m=u(l?{}:{...S,...y},i);return{...!l&&{"--pos":"absolute"},...d,...m}},getTextContentStyle=({styles:r,setting:a})=>{let n=e(r?.textSizeV2).padding,s=c(a?.shape),p=a?.positionWithImage==="outside";return{...S(r?.textSizeV2),...i(s?.textStyle),...l(s,r?.position,p),...t(r?.typo),...o({value:r?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:r?.typo?.custom?.hasShadowText}),...y(!!s?.backgroundColorInText,r?.badgeColorV2),...n}},getBorderStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?h(e?.textBadgeBorder):h(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?x(e?.textBadgeCorner,o?.shapeRadius):x(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=getBorderStyles({setting:t,styles:e}),i=t?.positionWithImage==="outside",a=getCornerStyles({setting:t,styles:e}),n=s(o?.ratio);return{...r,...a,...d(o,e?.position,i),...y(!o?.backgroundColorInText,e?.badgeColorV2),...n,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:t,setting:o})=>{let r=getBorderStyles({setting:o,styles:t}),i=getCornerStyles({setting:o,styles:t}),a=e(t?.imageSizeV2).padding;return{...r,...i,...a}},getOpacityProductBadge=(e,t,o,i)=>{let{"bundle-item":a,setting:n}=e;if(a)return 1;let s=p(n?.displayContent)&&n?.contentType==="text";if(!s)return 1;let g=r(t?.price)??0,l=r(t?.salePrice)??0,d=l-g>0,u=C(n?.displayTrigger,o,t);return d&&u?1:"edit"===i?.2:0},getSubWrapperStyle=(e,t,o,r)=>{let{setting:i}=e,a=i?.positionWithImage==="outside",n=getSizeStyles(e),s=r&&o?getOpacityProductBadge(e,o,t,r):1;return{...a?{...n,"--mb":0}:{},opacity:s}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,i=o?.contentType==="text";return m(`[id="${r?.uid}"] .product-badge-item`,i?t?.textBadgeShadow:t?.imageBadgeShadow)};export{getContainerStyle,getContentStyleInternal,getImageContainerStyles,getSubWrapperStyle,getTextBadgeWrapperStyles,getTextContentStyle};
@@ -1 +1 @@
1
- import{cls as e,formatMoney as t,makeStyleResponsive as r,getResponsiveValueByScreen as i}from"@gem-sdk/core";import{applyBundleDiscountAmount as n}from"../../../helpers/product-bundle.js";import{DiscountType as o}from"../../constants/product-bundle.js";let removeTrailingZeros=e=>e.replace(/\.00$/,""),getPriceDiffByPercent=(e,t)=>{if(!t)return"0";let r=1e3*t-1e3*e;return Math.round(100*r/(1e3*t))},getPriceDiffByValue=(e,r,i)=>removeTrailingZeros(t(r?(r-e).toFixed(2):"0",i)),getMinPrice=(e,r)=>{let i=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let t=e?.price;void 0!==t&&t<i&&(i=t)}),removeTrailingZeros(t(i.toString(),r))},checkNoDiscountState=(e,t)=>{let{discountPercentAmount:r}=n({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===o.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},getBadgeContent=(e,r,i)=>{if(!e.detail||!r?.trim()?.length)return r;let{detail:u,currentVariant:c}=e,{discountPercentAmount:l,discountAmount:a}=n({currentVariant:c,bundleItem:e?.bundleItem,options:{moneyFormat:i,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),d=()=>e?.bundleItem?.discountType!==o.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${l}%`:`${getPriceDiffByPercent(c?.price||0,c?.salePrice||0)||0}%`:"0%",s=()=>e?.bundleItem?.discountType!==o.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?a:getPriceDiffByValue(c?.price||0,c?.salePrice||0,i):t("0",i),p=new Map([["{percent_discount}",d],["{amount_discount}",s],["{min_price}",()=>getMinPrice(u.variants,i)||0],["{inventory_quantity}",()=>c?.inventoryQuantity||0]]);return[...p.entries()].reduce((e,[t,r])=>e.replaceAll(t,r()),r)},checkDiscountContentProductBadge=e=>{if(!e)return!1;let t=/\{percent_discount\}|\{amount_discount\}/;return t.test(e)},getShapePlacementClass=(e,t,r="desktop")=>e?t?.[`--pos${deviceWithSurfix(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${deviceWithSurfix(r)}`]?"":"!gp-inline-block gp-w-fit",getAlignShape=(t,r)=>r?"":e("gp-flex",{"gp-justify-start":t?.desktop==="left","gp-justify-center":t?.desktop==="center","gp-justify-end":t?.desktop==="right","tablet:gp-justify-start":t?.tablet==="left","tablet:gp-justify-center":t?.tablet==="center","tablet:gp-justify-end":t?.tablet==="right","mobile:gp-justify-start":t?.mobile==="left","mobile:gp-justify-center":t?.mobile==="center","mobile:gp-justify-end":t?.mobile==="right"}),convertToStyle=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),n=i.get(t)||t;return{...e,[n]:r}},{}),getWrapperStyle=e=>({[e?"z-index":"zIndex"]:2}),getWidthByShapeSize=(e,t)=>{let r={},n=["desktop","mobile","tablet"];return n.forEach(n=>{let o=i(e,n,null),u=o?.width||t?.wrapperWidth;u&&(r={...r,[n]:u})}),r},getHeightByShapeSize=(e,t)=>{let r={},n=["desktop","mobile","tablet"];return n.forEach(n=>{let o=i(e,n,null);r={...r,[n]:o?.height||t?.wrapperHeight}}),r},getSize=(e,t)=>{let i=r("w",getWidthByShapeSize(t,e)),n=r("h",getHeightByShapeSize(t,e));return{...i,...n}},getShapeWrapperPadding=e=>{let t={};if(1!==e)return t;let r=["desktop","mobile","tablet"];return r.forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},deviceWithSurfix=e=>"desktop"===e?"":`-${e}`,getDeviceSpecificStyle=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},getIsNoDiscountState=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:n})=>{let{setting:o,"bundle-item":u}=e,c=checkDiscountContentProductBadge(o?.displayContent);return c&&checkNoDiscountState({detail:t,currentVariant:r,bundleItem:u,useProductCompareAtPrice:n},i)};export{checkDiscountContentProductBadge,checkNoDiscountState,convertToStyle,deviceWithSurfix,getAlignShape,getBadgeContent,getDeviceSpecificStyle,getIsNoDiscountState,getShapePlacementClass,getShapeWrapperPadding,getSize,getWidthByShapeSize,getWrapperStyle};
1
+ import{cls as e,convertDecimalToNumber as t,formatMoney as r,makeStyleResponsive as i,getResponsiveValueByScreen as n}from"@gem-sdk/core";import{applyBundleDiscountAmount as o}from"../../../helpers/product-bundle.js";import{DiscountType as u}from"../../constants/product-bundle.js";let removeTrailingZeros=e=>e.replace(/\.00$/,""),getPriceDiffByPercent=(e,t)=>{if(!t)return"0";let r=1e3*t-1e3*e;return Math.round(100*r/(1e3*t))},getPriceDiffByValue=(e,t,i)=>removeTrailingZeros(r(t?(t-e).toFixed(2):"0",i)),getMinPrice=(e,i)=>{let n=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let r=t(e?.price);void 0!==r&&r<n&&(n=r)}),removeTrailingZeros(r(n.toString(),i))},checkNoDiscountState=(e,t)=>{let{discountPercentAmount:r}=o({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===u.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},getBadgeContent=(e,i,n)=>{if(!e.detail||!i?.trim()?.length)return i;let{detail:c,currentVariant:l}=e,{discountPercentAmount:a,discountAmount:d}=o({currentVariant:l,bundleItem:e?.bundleItem,options:{moneyFormat:n,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),s=()=>e?.bundleItem?.discountType!==u.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${a}%`:`${getPriceDiffByPercent(t(l?.price)??0,t(l?.salePrice)??0)||0}%`:"0%",p=()=>e?.bundleItem?.discountType!==u.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?d:getPriceDiffByValue(t(l?.price)??0,t(l?.salePrice)??0,n):r("0",n),g=new Map([["{percent_discount}",s],["{amount_discount}",p],["{min_price}",()=>getMinPrice(c.variants,n)||0],["{inventory_quantity}",()=>l?.inventoryQuantity||0]]);return[...g.entries()].reduce((e,[t,r])=>e.replaceAll(t,r()),i)},checkDiscountContentProductBadge=e=>{if(!e)return!1;let t=/\{percent_discount\}|\{amount_discount\}/;return t.test(e)},getShapePlacementClass=(e,t,r="desktop")=>e?t?.[`--pos${deviceWithSurfix(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${deviceWithSurfix(r)}`]?"":"!gp-inline-block gp-w-fit",getAlignShape=(t,r)=>r?"":e("gp-flex",{"gp-justify-start":t?.desktop==="left","gp-justify-center":t?.desktop==="center","gp-justify-end":t?.desktop==="right","tablet:gp-justify-start":t?.tablet==="left","tablet:gp-justify-center":t?.tablet==="center","tablet:gp-justify-end":t?.tablet==="right","mobile:gp-justify-start":t?.mobile==="left","mobile:gp-justify-center":t?.mobile==="center","mobile:gp-justify-end":t?.mobile==="right"}),convertToStyle=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),n=i.get(t)||t;return{...e,[n]:r}},{}),getWrapperStyle=e=>({[e?"z-index":"zIndex"]:2}),getWidthByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=n(e,i,null),u=o?.width||t?.wrapperWidth;u&&(r={...r,[i]:u})}),r},getHeightByShapeSize=(e,t)=>{let r={},i=["desktop","mobile","tablet"];return i.forEach(i=>{let o=n(e,i,null);r={...r,[i]:o?.height||t?.wrapperHeight}}),r},getSize=(e,t)=>{let r=i("w",getWidthByShapeSize(t,e)),n=i("h",getHeightByShapeSize(t,e));return{...r,...n}},getShapeWrapperPadding=e=>{let t={};if(1!==e)return t;let r=["desktop","mobile","tablet"];return r.forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},deviceWithSurfix=e=>"desktop"===e?"":`-${e}`,getDeviceSpecificStyle=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},getIsNoDiscountState=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:n})=>{let{setting:o,"bundle-item":u}=e,c=checkDiscountContentProductBadge(o?.displayContent);return c&&checkNoDiscountState({detail:t,currentVariant:r,bundleItem:u,useProductCompareAtPrice:n},i)};export{checkDiscountContentProductBadge,checkNoDiscountState,convertToStyle,deviceWithSurfix,getAlignShape,getBadgeContent,getDeviceSpecificStyle,getIsNoDiscountState,getShapePlacementClass,getShapeWrapperPadding,getSize,getWidthByShapeSize,getWrapperStyle};
@@ -1 +1 @@
1
- import{useRenderMode as e,useProduct as t,useCurrency as r,useQuantity as i,useProductProperties as s,useCurrentVariant as n,useHasPreSelected as o,useStickyStore as a,useProductStore as u,useCreateCart as l,useAddToCart as c,useCurrentVariantInStock as m}from"@gem-sdk/core";import{useRef as b,useEffect as d,useCallback as f}from"react";import{addToCartTracking as p}from"../../../helpers/tracking.js";import{useDispatchAfterSubmitEvent as v}from"./useDispatchAfterSubmitEvent.js";import{useCartMessage as g}from"./useCartMessage.js";import{useCartOperations as I}from"./useCartOperations.js";let useBtnAddToCart=({styles:k,setting:D,builderProps:S})=>{let E=b(null),{isEditMode:h,isPreviewSharePageMode:j}=e(),y=t(),{currency:C}=r(),{quantity:A}=i(),M=s(),O=n(),{hasPreSelected:w}=o(),B=a(e=>e.setStickyVisible),T=u(e=>e.updateIsSubmit),q=v(S?.uid),{showMessage:x,notiComponent:L}=g(k,D),{handleSuccess:U,handleError:V,cartId:z}=I(D,x,q),{isMutating:F,trigger:G}=l({onSuccess:U,onError:V}),{isMutating:H,trigger:J}=c({onSuccess:U,onError:V});d(()=>{let e=new IntersectionObserver(e=>{let t=e[0];B(t?.isIntersecting)},{threshold:.1}),t=E.current;return E.current&&e.observe(E.current),()=>{t&&e.unobserve(t)}},[B]);let K=f(()=>{if(!O?.baseID||!A||!y?.baseID||void 0!==w&&!w||h||j)return;let e=M?.some(e=>e.required&&!e.value);if(T(!0),e)return;let t=M?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));p({quantity:A,currency:C,id:y?.baseID,name:y?.title,brand:y?.vendor,sku:O.sku,price:O?.price,variant:O.title});let r={quantity:A,attributes:t,variantId:O.baseID};D?.actionEffect!=="buy-now"&&z?J({cartId:z,lines:[r]}):G({items:[r]})},[h,j,z,C,A,M,w,y?.title,y?.vendor,y?.baseID,O?.sku,O?.price,O?.title,O?.baseID,D?.actionEffect,G,J,T]),N=m(),P=F||H,Q=O?D?.outOfStockLabel:"Unavailable";return{addToCartRef:E,isLoading:P,isInStock:N,notiComponent:L,outOfStockLabel:Q,addToCart:K}};export{useBtnAddToCart};
1
+ import{useRenderMode as e,useProduct as t,useCurrency as r,useQuantity as i,useProductProperties as s,useCurrentVariant as n,useHasPreSelected as o,useStickyStore as a,useProductStore as u,useCreateCart as l,useAddToCart as c,convertDecimalToNumber as m,useCurrentVariantInStock as b}from"@gem-sdk/core";import{useRef as d,useEffect as f,useCallback as p}from"react";import{addToCartTracking as v}from"../../../helpers/tracking.js";import{useDispatchAfterSubmitEvent as g}from"./useDispatchAfterSubmitEvent.js";import{useCartMessage as I}from"./useCartMessage.js";import{useCartOperations as k}from"./useCartOperations.js";let useBtnAddToCart=({styles:D,setting:S,builderProps:E})=>{let h=d(null),{isEditMode:j,isPreviewSharePageMode:y}=e(),C=t(),{currency:A}=r(),{quantity:M}=i(),O=s(),w=n(),{hasPreSelected:B}=o(),T=a(e=>e.setStickyVisible),q=u(e=>e.updateIsSubmit),x=g(E?.uid),{showMessage:L,notiComponent:U}=I(D,S),{handleSuccess:V,handleError:z,cartId:F}=k(S,L,x),{isMutating:G,trigger:H}=l({onSuccess:V,onError:z}),{isMutating:J,trigger:K}=c({onSuccess:V,onError:z});f(()=>{let e=new IntersectionObserver(e=>{let t=e[0];T(t?.isIntersecting)},{threshold:.1}),t=h.current;return h.current&&e.observe(h.current),()=>{t&&e.unobserve(t)}},[T]);let N=p(()=>{if(!w?.baseID||!M||!C?.baseID||void 0!==B&&!B||j||y)return;let e=O?.some(e=>e.required&&!e.value);if(q(!0),e)return;let t=O?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));v({quantity:M,currency:A,id:C?.baseID,name:C?.title,brand:C?.vendor,sku:w.sku,price:m(w?.price),variant:w.title});let r={quantity:M,attributes:t,variantId:w.baseID};S?.actionEffect!=="buy-now"&&F?K({cartId:F,lines:[r]}):H({items:[r]})},[j,y,F,A,M,O,B,C?.title,C?.vendor,C?.baseID,w?.sku,w?.price,w?.title,w?.baseID,S?.actionEffect,H,K,q]),P=b(),Q=G||J,R=w?S?.outOfStockLabel:"Unavailable";return{addToCartRef:h,isLoading:Q,isInStock:P,notiComponent:U,outOfStockLabel:R,addToCart:N}};export{useBtnAddToCart};
@@ -1 +1 @@
1
- import{useMoneyFormat as e,useEditorMode as t,useProduct as r,useCurrentVariant as n,useQuantity as o,useFormatMoney as u,useProductBundleDiscount as i,formatMoney as p}from"@gem-sdk/core";import{useMemo as c}from"react";import{applyBundleDiscountAmount as s}from"../../../helpers/product-bundle.js";import{DiscountType as a}from"../../constants/product-bundle.js";let useGpDiscountTag=m=>{let{setting:l,...d}=m,{customContent:g}=l??{},f=d["bundle-item"],{moneyFormat:b}=e(),h=t(),D=r(),$=n(),{quantity:j,hasUpdatePrice:y}=o(),G=c(()=>y&&g?.unit!=="percentage"?j??1:1,[y,g?.unit,j]),P=$?.price??0,T=$?.salePrice??0,k=(T-P)*G,x=u(k<0?0:k,l?.moneyWithCurrentFormat||!1),C=c(()=>{if(!T&&0!==T||!P&&0!==P)return`${g?.unit==="percentage"?"0%":x}`;if(g?.unit==="percentage"){let e=Math.round(k/(T/100));return`${e<0?0:e}%`}return`${x}`},[g?.unit,x,P,k,T]),{useProductCompareAtPrice:F}=i(),{discountPercentAmount:I}=s({currentVariant:$,bundleItem:f,options:{moneyFormat:b,useProductCompareAtPrice:F}}),M=c(()=>{if(!f)return 0;let{discountPercentAmount:e,discountAmount:t}=s({currentVariant:$,bundleItem:f,options:{moneyFormat:b,useProductCompareAtPrice:F}}),{discountType:r}=f,{unit:n}=g||{};return r!==a.NoDiscount||F?"percentage"===n?`${e}%`:t:"percentage"===n?"0%":p("0",b)},[f,$,b,F,g]),N=c(()=>f?M:C,[M,f,C]),W=D?.baseID?.replace("gid://shopify/Product/",""),q=c(()=>{let e=f?I<=0:k<=0;return"edit"===h&&e},[f,I,h,k]);return{mode:h,product:D,salePrice:T,priceSave:k,currentProductId:W,unitCustomDisplay:N,shouldPlaceholderNoDiscount:q}};export{useGpDiscountTag};
1
+ import{useMoneyFormat as e,useEditorMode as t,useProduct as r,useCurrentVariant as n,useQuantity as o,convertDecimalToNumber as u,useFormatMoney as i,useProductBundleDiscount as p,formatMoney as c}from"@gem-sdk/core";import{useMemo as s}from"react";import{applyBundleDiscountAmount as a}from"../../../helpers/product-bundle.js";import{DiscountType as m}from"../../constants/product-bundle.js";let useGpDiscountTag=l=>{let{setting:d,...g}=l,{customContent:f}=d??{},b=g["bundle-item"],{moneyFormat:h}=e(),D=t(),$=r(),j=n(),{quantity:y,hasUpdatePrice:G}=o(),P=s(()=>G&&f?.unit!=="percentage"?y??1:1,[G,f?.unit,y]),T=u(j?.price)??0,k=u(j?.salePrice)??0,x=(k-T)*P,C=i(x<0?0:x,d?.moneyWithCurrentFormat||!1),F=s(()=>{if(!k&&0!==k||!T&&0!==T)return`${f?.unit==="percentage"?"0%":C}`;if(f?.unit==="percentage"){let e=Math.round(x/(k/100));return`${e<0?0:e}%`}return`${C}`},[f?.unit,C,T,x,k]),{useProductCompareAtPrice:I}=p(),{discountPercentAmount:M}=a({currentVariant:j,bundleItem:b,options:{moneyFormat:h,useProductCompareAtPrice:I}}),N=s(()=>{if(!b)return 0;let{discountPercentAmount:e,discountAmount:t}=a({currentVariant:j,bundleItem:b,options:{moneyFormat:h,useProductCompareAtPrice:I}}),{discountType:r}=b,{unit:n}=f||{};return r!==m.NoDiscount||I?"percentage"===n?`${e}%`:t:"percentage"===n?"0%":c("0",h)},[b,j,h,I,f]),W=s(()=>b?N:F,[N,b,F]),q=$?.baseID?.replace("gid://shopify/Product/",""),v=s(()=>{let e=b?M<=0:x<=0;return"edit"===D&&e},[b,M,D,x]);return{mode:D,product:$,salePrice:k,priceSave:x,currentProductId:q,unitCustomDisplay:W,shouldPlaceholderNoDiscount:v}};export{useGpDiscountTag};
@@ -1 +1 @@
1
- import{useRef as e,useMemo as r}from"react";import{useTransition as t}from"../../product-variants/common/common.js";import{useEditorMode as c,useQuantity as i,useCurrentVariant as a,useProductBundleDiscount as n,useInteraction as o,useProduct as u,useShopStore as p,useFormatMoney as d}from"@gem-sdk/core";let useGpPrice=l=>{let{setting:m,builderProps:s}=l,g=e(null),b=c(),{quantity:h,hasUpdatePrice:y}=i(),P=a(),{useProductCompareAtPrice:v}=n(),f=l["bundle-item"],w=P?.price??0,V=P?.salePrice??0,k=m?.priceType==="compare",{trigger:q}=o(),T=u(),x=T?.baseID?.replace("gid://shopify/Product/",""),C=p(e=>e.showPriceCurrency),E=r(()=>f?.quantity?f.quantity:y&&h||1,[h,y,f?.quantity]),G=r(()=>{let e=Number(f?.discountValue);return f?.discountType==="percentage"?w*E*e/100:e},[f?.discountType,f?.discountValue,w,E]),$=r(()=>f?.discountValue?v?(V||w)*E:w*E:V*E,[f?.discountValue,w,E,V,v]),j=r(()=>{let e=w*E;return k?$:G?Math.max(0,e-G):e},[w,E,G,$,k]),D=(e,r)=>{q({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${s?.uid}"]`,element:g.current}),q({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${s?.uid}"]`,element:g.current})};t(e=>{e!==w&&D(w,"price")},[w]),t(e=>{e!==V&&D(V,"compare")},[V]);let I=()=>{if("edit"!==b)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:s?.uid,value:!j&&k,tag:"ProductPrice"}});window.dispatchEvent(e)},M=d(j??0,C||!1),N=k&&!j,z="edit"!==b&&N;return{elementRef:g,moneyFormatted:M,currentProductId:x,isNoComparePrice:N,isNoComparePriceILP:z,emitNoDataSignal:I}};export{useGpPrice};
1
+ import{useRef as e,useMemo as r}from"react";import{useTransition as t}from"../../product-variants/common/common.js";import{useEditorMode as c,useQuantity as i,useCurrentVariant as a,useProductBundleDiscount as n,convertDecimalToNumber as o,useInteraction as u,useProduct as p,useShopStore as d,useFormatMoney as l}from"@gem-sdk/core";let useGpPrice=m=>{let{setting:s,builderProps:g}=m,b=e(null),h=c(),{quantity:y,hasUpdatePrice:P}=i(),v=a(),{useProductCompareAtPrice:f}=n(),w=m["bundle-item"],V=o(v?.price)??0,k=o(v?.salePrice)??0,q=s?.priceType==="compare",{trigger:T}=u(),x=p(),C=x?.baseID?.replace("gid://shopify/Product/",""),E=d(e=>e.showPriceCurrency),G=r(()=>w?.quantity?w.quantity:P&&y||1,[y,P,w?.quantity]),$=r(()=>{let e=Number(w?.discountValue);return w?.discountType==="percentage"?V*G*e/100:e},[w?.discountType,w?.discountValue,V,G]),j=r(()=>w?.discountValue?f?(k||V)*G:V*G:k*G,[w?.discountValue,V,G,k,f]),D=r(()=>{let e=V*G;return q?j:$?Math.max(0,e-$):e},[V,G,$,j,q]),I=(e,r)=>{T({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${g?.uid}"]`,element:b.current}),T({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${g?.uid}"]`,element:b.current})};t(e=>{e!==V&&I(V,"price")},[V]),t(e=>{e!==k&&I(k,"compare")},[k]);let M=()=>{if("edit"!==h)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:g?.uid,value:!D&&q,tag:"ProductPrice"}});window.dispatchEvent(e)},N=l(D??0,E||!1),z=q&&!D,A="edit"!==h&&z;return{elementRef:b,moneyFormatted:N,currentProductId:C,isNoComparePrice:z,isNoComparePriceILP:A,emitNoDataSignal:M}};export{useGpPrice};
@@ -1 +1 @@
1
- import{formatMoney as t}from"@gem-sdk/core";import{DiscountType as e}from"../components/constants/product-bundle.js";let noDiscount=e=>({discountPercentAmount:0,discountAmount:t("0",e)}),applyBundleDiscountAmount=n=>{let{currentVariant:o,bundleItem:u,options:c}=n;if(!c?.useProductCompareAtPrice&&u?.discountType===e.NoDiscount||!u||!o?.price)return noDiscount(c?.moneyFormat||"${{amount}}");let r=Number(o?.price),i=Number(o?.salePrice)||r,a=Number(u?.quantity),m=calculateBundleFixedDiscount(r,u),s=discountPercentAmount(m,a*r),d=r*a-m,l=i*a;return i<=r&&m<=0?noDiscount(c?.moneyFormat||"${{amount}}"):{discountPercentAmount:c?.useProductCompareAtPrice?calculateDiffPercentPrice(d,l):s,discountAmount:c?.useProductCompareAtPrice?calculateDiffFixedPrice(d,l,c?.moneyFormat):t(m.toString(),c?.moneyFormat)}},calculateDiffPercentPrice=(t,e)=>{let n=(e-t)/e*100;return Math.round(n)},calculateDiffFixedPrice=(e,n,o)=>t((n-e).toString(),o),calculateBundleFixedDiscount=(t,n)=>{let o=parseInt(n?.discountValue);return n?.discountType===e.Percentage?t*n.quantity*o/100:n?.discountType===e.FixedAmount?o:0},discountPercentAmount=(t,e)=>Math.round(t/e*100);export{applyBundleDiscountAmount};
1
+ import{convertDecimalToNumber as t,formatMoney as e}from"@gem-sdk/core";import{DiscountType as n}from"../components/constants/product-bundle.js";let noDiscount=t=>({discountPercentAmount:0,discountAmount:e("0",t)}),applyBundleDiscountAmount=o=>{let{currentVariant:u,bundleItem:c,options:r}=o;if(!r?.useProductCompareAtPrice&&c?.discountType===n.NoDiscount||!c||!u?.price)return noDiscount(r?.moneyFormat||"${{amount}}");let i=t(u?.price)??0,a=t(u?.salePrice)??i,m=Number(c?.quantity),s=calculateBundleFixedDiscount(i,c),d=discountPercentAmount(s,m*i),l=i*m-s,p=a*m;return a<=i&&s<=0?noDiscount(r?.moneyFormat||"${{amount}}"):{discountPercentAmount:r?.useProductCompareAtPrice?calculateDiffPercentPrice(l,p):d,discountAmount:r?.useProductCompareAtPrice?calculateDiffFixedPrice(l,p,r?.moneyFormat):e(s.toString(),r?.moneyFormat)}},calculateDiffPercentPrice=(t,e)=>{let n=(e-t)/e*100;return Math.round(n)},calculateDiffFixedPrice=(t,n,o)=>e((n-t).toString(),o),calculateBundleFixedDiscount=(t,e)=>{let o=parseInt(e?.discountValue);return e?.discountType===n.Percentage?t*e.quantity*o/100:e?.discountType===n.FixedAmount?o:0},discountPercentAmount=(t,e)=>Math.round(t/e*100);export{applyBundleDiscountAmount};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "7.0.1-dev.11",
3
+ "version": "7.0.1-dev.13",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -26,7 +26,7 @@
26
26
  "scan-all-text": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/scan-all-text && node ./scripts/scan-all-text"
27
27
  },
28
28
  "devDependencies": {
29
- "@gem-sdk/core": "7.0.1-dev.9",
29
+ "@gem-sdk/core": "7.0.1-dev.13",
30
30
  "@gem-sdk/styles": "7.0.1-dev.6",
31
31
  "@gem-sdk/system": "7.0.1-dev.6",
32
32
  "@types/react-transition-group": "^4.4.12",