@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.
- package/dist/cjs/post-purchase/product/components/ProductPrice.js +1 -1
- package/dist/cjs/post-purchase/product/constants/ProductOfferPlaceholder.js +1 -1
- package/dist/cjs/post-purchase/product/hooks/useGetMoneyLines.js +1 -1
- package/dist/cjs/product/components/product-badge/common/styles.js +1 -1
- package/dist/cjs/product/components/product-badge/utils/common.js +1 -1
- package/dist/cjs/product/components/product-button/hooks/useAddToCart.js +1 -1
- package/dist/cjs/product/components/product-discount-tag/hooks/useGpDiscountTag.js +1 -1
- package/dist/cjs/product/components/product-price/hooks/useGpPrice.js +1 -1
- package/dist/cjs/product/helpers/product-bundle.js +1 -1
- package/dist/esm/post-purchase/product/components/ProductPrice.js +1 -1
- package/dist/esm/post-purchase/product/constants/ProductOfferPlaceholder.js +1 -1
- package/dist/esm/post-purchase/product/hooks/useGetMoneyLines.js +1 -1
- package/dist/esm/product/components/product-badge/common/styles.js +1 -1
- package/dist/esm/product/components/product-badge/utils/common.js +1 -1
- package/dist/esm/product/components/product-button/hooks/useAddToCart.js +1 -1
- package/dist/esm/product/components/product-discount-tag/hooks/useGpDiscountTag.js +1 -1
- package/dist/esm/product/components/product-price/hooks/useGpPrice.js +1 -1
- package/dist/esm/product/helpers/product-bundle.js +1 -1
- package/package.json +2 -2
|
@@ -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:
|
|
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),
|
|
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
|
|
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),
|
|
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
|
|
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:
|
|
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:
|
|
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,
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
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.
|
|
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.
|
|
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",
|