@gem-sdk/components 7.0.1-dev.11 → 7.0.1-dev.15
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/components/product-variants/OptionVariantsNewFormat.liquid.js +41 -0
- package/dist/cjs/product/components/product-variants/OptionVariantsOldFormat.liquid.js +66 -0
- package/dist/cjs/product/components/product-variants/ProductVariants.liquid.js +25 -77
- package/dist/cjs/product/components/product-variants/common/const.js +1 -0
- package/dist/cjs/product/components/product-variants/components/color/color.liquid.js +3 -3
- 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/components/product-variants/OptionVariantsNewFormat.liquid.js +41 -0
- package/dist/esm/product/components/product-variants/OptionVariantsOldFormat.liquid.js +66 -0
- package/dist/esm/product/components/product-variants/ProductVariants.liquid.js +41 -93
- package/dist/esm/product/components/product-variants/common/const.js +1 -0
- package/dist/esm/product/components/product-variants/components/color/color.liquid.js +3 -3
- 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;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),_const=require("./common/const.js");const renderOptionValuesNewFormatSwatches=e=>{let{renderVariantItem:s,variantPresetsLiquid:i}=e;return core.template`
|
|
2
|
+
${system.Liquid("{%- assign optionRendered = false -%}")}
|
|
3
|
+
${system.Liquid("{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}")}
|
|
4
|
+
|
|
5
|
+
${system.Liquid(`{% for swatch in swatches %}
|
|
6
|
+
{%- assign optionTitle = swatch.optionTitle -%}
|
|
7
|
+
{%- assign optionType = swatch.optionType -%}
|
|
8
|
+
{%- assign labelsString = "" -%}
|
|
9
|
+
{%- assign colorArraysString = "" -%}
|
|
10
|
+
{%- assign imageUrlsString = "" -%}
|
|
11
|
+
|
|
12
|
+
{% for optionValue in swatch.optionValues %}
|
|
13
|
+
{%- assign labelsString = labelsString | append: optionValue.label | append: '${_const.OPTION_VALUES_DELIMITER}' -%}
|
|
14
|
+
{%- assign colorsJoined = optionValue.colors | join: '${_const.OPTION_VALUES_DELIMITER}' -%}
|
|
15
|
+
{%- assign colorArraysString = colorArraysString | append: colorsJoined | append: '${_const.OPTION_VALUES_DELIMITER}' -%}
|
|
16
|
+
{%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: '${_const.OPTION_VALUES_DELIMITER}' -%}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
|
|
19
|
+
{%- assign labels = labelsString | split: '${_const.OPTION_VALUES_DELIMITER}' | slice: 0, labelsString.size -%}
|
|
20
|
+
{%- assign colorStrings = colorArraysString | split: '${_const.OPTION_VALUES_DELIMITER}' | slice: 0, colorArraysString.size -%}
|
|
21
|
+
{%- assign imageUrls = imageUrlsString | split: '${_const.OPTION_VALUES_DELIMITER}' | slice: 0, imageUrlsString.size -%}
|
|
22
|
+
|
|
23
|
+
{% if optionTitle == option.name %}
|
|
24
|
+
{%- assign variantPresetString = "${i}" -%}
|
|
25
|
+
{%- assign optionName = option.name | replace: "'", "'" | replace: '"', '"' -%}
|
|
26
|
+
{%- assign items = variantPresetString | split: '($2)' -%}
|
|
27
|
+
{%- assign type = 'dropdown' -%}
|
|
28
|
+
|
|
29
|
+
{% for item in items %}
|
|
30
|
+
{%- assign itemPreset = item | split: '($1)' -%}
|
|
31
|
+
{% if itemPreset[0] == optionName %}{%- assign type = itemPreset[1] -%}{% endif %}
|
|
32
|
+
{% if itemPreset[0] == 'base' %}{%- assign type = itemPreset[1] -%}{% endif %}
|
|
33
|
+
{% endfor %}
|
|
34
|
+
{%- assign optionRendered = true -%}
|
|
35
|
+
|
|
36
|
+
${s(!0)}
|
|
37
|
+
{% endif %}
|
|
38
|
+
{% endfor %}`)}
|
|
39
|
+
|
|
40
|
+
${system.LiquidIf("optionRendered == false",s(!1,!0))}
|
|
41
|
+
`};exports.renderOptionValuesNewFormatSwatches=renderOptionValuesNewFormatSwatches;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";var system=require("@gem-sdk/system"),core=require("@gem-sdk/core");const renderOptionValuesOld=s=>{let{renderVariantItem:i,variantPresetsLiquid:e}=s;return core.template`
|
|
2
|
+
${system.Liquid("{%- assign optionRendered = false -%}")}
|
|
3
|
+
${system.Liquid("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
|
|
4
|
+
${system.Liquid("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
|
|
5
|
+
|
|
6
|
+
${system.LiquidFor("swatchesItem in swatchesItems",`
|
|
7
|
+
${system.Liquid('{%- assign colorArraysString = "" -%}')}
|
|
8
|
+
${system.Liquid('{%- assign labelsString = "" -%}')}
|
|
9
|
+
${system.Liquid('{%- assign imageUrlsString = "" -%}')}
|
|
10
|
+
${system.Liquid("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
|
|
11
|
+
|
|
12
|
+
${system.LiquidFor("attrItem in attrItems",`
|
|
13
|
+
${system.Liquid("{%- assign attrs = attrItem | split: '($2)' -%}")}
|
|
14
|
+
${system.Liquid("{%- assign optionKey = attrs[0] -%}")}
|
|
15
|
+
${system.Liquid("{%- assign optionValue = attrs[1] -%}")}
|
|
16
|
+
${system.Liquid(`
|
|
17
|
+
{% if optionKey == 'optionTitle' %}
|
|
18
|
+
{% assign optionTitle = optionValue %}
|
|
19
|
+
{% elsif optionKey == 'optionType' %}
|
|
20
|
+
{% assign optionType = optionValue %}
|
|
21
|
+
{% endif %}
|
|
22
|
+
`)}
|
|
23
|
+
|
|
24
|
+
${system.LiquidIf('optionKey == "optionValues"',`
|
|
25
|
+
${system.Liquid("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
|
|
26
|
+
${system.LiquidFor("opValueItem in opValueItems",`
|
|
27
|
+
${system.Liquid("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
|
|
28
|
+
${system.LiquidFor("opValueItemAttr in opValueItemAttrs",`
|
|
29
|
+
${system.Liquid("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
|
|
30
|
+
${system.Liquid("{%- assign opValueItemKey = attrs[0] -%}")}
|
|
31
|
+
${system.Liquid("{%- assign opValueItemValue = attrs[1] -%}")}
|
|
32
|
+
|
|
33
|
+
${system.LiquidIf('opValueItemKey == "label"',`${system.Liquid("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}
|
|
34
|
+
${system.Liquid('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
|
|
35
|
+
|
|
36
|
+
${system.LiquidIf('opValueItemKey == "colors"',`${system.Liquid("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}
|
|
37
|
+
${system.Liquid('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
|
|
38
|
+
|
|
39
|
+
${system.LiquidIf('opValueItemKey == "imageUrl"',`${system.Liquid("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}
|
|
40
|
+
${system.Liquid('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}
|
|
41
|
+
`)}
|
|
42
|
+
`)}
|
|
43
|
+
`)}
|
|
44
|
+
`)}
|
|
45
|
+
|
|
46
|
+
${system.Liquid("{%- assign labels = labelsString | split: '($8)' -%}")}
|
|
47
|
+
${system.Liquid("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
|
|
48
|
+
${system.Liquid("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
|
|
49
|
+
|
|
50
|
+
${system.LiquidIf("optionTitle == option.name",`
|
|
51
|
+
${system.Liquid(`{%- assign variantPresetString = "${e}" -%}`)}
|
|
52
|
+
${system.Liquid('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
53
|
+
${system.Liquid("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
54
|
+
${system.Liquid("{%- assign type = 'dropdown' -%}")}
|
|
55
|
+
${system.LiquidFor("item in items",`
|
|
56
|
+
${system.Liquid("{%- assign itemPreset = item | split:'($1)' -%}")}
|
|
57
|
+
${system.LiquidIf("itemPreset[0] == optionName",system.Liquid("{%- assign type = itemPreset[1] -%}"))}
|
|
58
|
+
${system.LiquidIf('itemPreset[0] == "base"',system.Liquid("{%- assign type = itemPreset[1] -%}"))}
|
|
59
|
+
`)}
|
|
60
|
+
${system.Liquid("{%- assign optionRendered = true -%}")}
|
|
61
|
+
${i(!0)}
|
|
62
|
+
`)}
|
|
63
|
+
`)}
|
|
64
|
+
|
|
65
|
+
${system.LiquidIf("optionRendered == false",i(!1,!0))}
|
|
66
|
+
`};exports.renderOptionValuesOld=renderOptionValuesOld;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Text_liquid=require("../../../text/components/Text.liquid.js"),index_liquid=require("./components/variants/index.liquid.js"),Dropdown_liquid=require("./components/dropdown-swatches/Dropdown.liquid.js"),DropdownGroup_liquid=require("./components/dropdown-group/DropdownGroup.liquid.js"),helpers=require("../../../helpers.js"),mappingVariantStyles=require("./utils/mappingVariantStyles.js"),system=require("@gem-sdk/system"),getAttr=require("./common/main/getAttr.js"),styles=require("./common/main/styles.js"),classes=require("./common/main/classes.js"),getData=require("./common/main/getData.js"),classes$1=require("./common/variants/classes.js"),_function=require("../../helpers/function.js"),styles$1=require("./common/variants/styles.js");const DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=e=>{let{builderProps:
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Text_liquid=require("../../../text/components/Text.liquid.js"),index_liquid=require("./components/variants/index.liquid.js"),Dropdown_liquid=require("./components/dropdown-swatches/Dropdown.liquid.js"),DropdownGroup_liquid=require("./components/dropdown-group/DropdownGroup.liquid.js"),helpers=require("../../../helpers.js"),mappingVariantStyles=require("./utils/mappingVariantStyles.js"),system=require("@gem-sdk/system"),getAttr=require("./common/main/getAttr.js"),styles=require("./common/main/styles.js"),classes=require("./common/main/classes.js"),getData=require("./common/main/getData.js"),classes$1=require("./common/variants/classes.js"),_function=require("../../helpers/function.js"),styles$1=require("./common/variants/styles.js"),OptionVariantsNewFormat_liquid=require("./OptionVariantsNewFormat.liquid.js"),OptionVariantsOldFormat_liquid=require("./OptionVariantsOldFormat.liquid.js");const DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=e=>{let{builderProps:t,styles:s,setting:i,advanced:a}=e,{align:o,swatchItemWidth:n,dropdownItemWidth:r,swatchSpacing:l,optionTypo:p,marginBottom:d}=s??{},{label:u,optionType:m,showAsSwatches:c,layout:y,hasPreSelected:v}=i??{},g=a?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:_}=t??{},f="groupOption"===m,q=()=>{let e={};return core.DEVICES.forEach(t=>{let s=core.getResponsiveValueByScreen(n,t);e[t]="auto"===s}),e},$=()=>{let e={};return core.DEVICES.forEach(t=>{e[t]=r?.[t]==="fill"}),e},h=core.composeMemo(()=>{let e=mappingVariantStyles.mappingVariantStyles(i?.variantPresets,s);return{...i,variantPresets:e}},[i?.variantPresets,s]),S=e=>{let t={"'":"'",'"':"""},s=e;for(let i in t)e.indexOf(i)>=0&&(s=s.replaceAll(i,t[i]));return s},L=()=>i?.variantPresets?.map(e=>`${S(e.optionName)}($2)${e.optionType}`).join("($1)"),j=()=>i?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),V=(e,t)=>core.template`
|
|
2
|
+
${system.LiquidFor("value in values",index_liquid.default({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:c,uid:_,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:v?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:v?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...s,...h,swatchAutoWidth:q(),optionTypo:p,isRenderDefault:t}))}
|
|
3
|
+
${system.LiquidIf(e?'type == "dropdown"':"false",Dropdown_liquid.default({...s,...h,swatchAutoWidth:$(),optionTypo:p}))}`,w=i?.variantPresets?.map(e=>({name:S(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),O={renderVariantItem:V,variantPresetsLiquid:w??""},D=system.createClass(classes.getVariantOptionGroupClass(o)),A=system.createStyle(styles.getVariantOptionGroupStyle(l,l)),b=getData.getTextVariantTitleData(e,"Liquid"),E=system.createClass(classes$1.getWrapVariantOptionClass(y,o)),P=()=>core.template`
|
|
4
|
+
${system.Liquid(`{%- assign presets = "${L()}" | split: '($1)' -%}`)}
|
|
5
|
+
${system.Liquid(`{% assign hiddenPresetOptions = "${j()}" | split: ',' %}`)}
|
|
4
6
|
|
|
5
7
|
${system.Liquid(`{% assign all_option_names = options | map: 'name' %}
|
|
6
8
|
{% assign filtered_options_string = '' %}
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
${system.LiquidFor("option in options",`
|
|
31
33
|
<div
|
|
32
34
|
option-name="{{option.name | escape}}"
|
|
33
|
-
class="${
|
|
35
|
+
class="${E} ${system.LiquidIf("hiddenPresetOptions contains option.name","gp-hidden")}"
|
|
34
36
|
style="${_function.getStyleOfObject(styles$1.getMarginBottomStyle(d))}${system.Liquid("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
|
|
35
37
|
>
|
|
36
38
|
${system.Liquid("{%- assign showVariantClass = 'variant-display' -%}")}
|
|
@@ -39,11 +41,11 @@
|
|
|
39
41
|
${system.Liquid("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
40
42
|
${system.LiquidIf("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${system.Liquid("{%- assign showVariantClass = '' -%}")} ${system.Liquid("{%- break -%}")}`)}
|
|
41
43
|
`)}
|
|
42
|
-
${system.If(u,Text_liquid.default(
|
|
44
|
+
${system.If(u,Text_liquid.default(b)," ")}
|
|
43
45
|
<div
|
|
44
46
|
variant-option-name="{{option.name | escape}}"
|
|
45
|
-
class="${
|
|
46
|
-
style="${_function.getStyleOfObject(
|
|
47
|
+
class="${D}"
|
|
48
|
+
style="${_function.getStyleOfObject(A)}"
|
|
47
49
|
>
|
|
48
50
|
${system.Liquid("{%- assign values = option.values -%}")}
|
|
49
51
|
${system.Liquid("{%- assign rootForloop = forloop.index0 -%}")}
|
|
@@ -56,78 +58,24 @@
|
|
|
56
58
|
{%- assign selectedValue = variant.option3 -%}
|
|
57
59
|
{%- endif -%}
|
|
58
60
|
`)}
|
|
59
|
-
${system.If(!
|
|
60
|
-
${system.If(c,
|
|
61
|
+
${system.If(!v,system.Liquid("{%- assign selectedValue = null -%}"),"")}
|
|
62
|
+
${system.If(c,x(),V(!1,!0))}
|
|
61
63
|
</div>
|
|
62
64
|
</div>`)}
|
|
63
|
-
`,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
${system.LiquidFor("swatchesItem in swatchesItems",`
|
|
69
|
-
${system.Liquid('{%- assign colorArraysString = "" -%}')}
|
|
70
|
-
${system.Liquid('{%- assign labelsString = "" -%}')}
|
|
71
|
-
${system.Liquid('{%- assign imageUrlsString = "" -%}')}
|
|
72
|
-
${system.Liquid("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
|
|
73
|
-
|
|
74
|
-
${system.LiquidFor("attrItem in attrItems",`${system.Liquid("{%- assign attrs = attrItem | split: '($2)' -%}")}
|
|
75
|
-
${system.Liquid("{%- assign optionKey = attrs[0] -%}")}
|
|
76
|
-
${system.Liquid("{%- assign optionValue = attrs[1] -%}")}
|
|
77
|
-
${system.Liquid(`
|
|
78
|
-
{% if optionKey == 'optionTitle' %}
|
|
79
|
-
{% assign optionTitle = optionValue %}
|
|
80
|
-
{% elsif optionKey == 'optionType' %}
|
|
81
|
-
{% assign optionType = optionValue %}
|
|
82
|
-
{% endif %}
|
|
83
|
-
`)}
|
|
84
|
-
|
|
85
|
-
${system.LiquidIf("optionKey == 'optionValues'",`${system.Liquid("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
|
|
86
|
-
${system.LiquidFor("opValueItem in opValueItems",`${system.Liquid("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
|
|
87
|
-
${system.LiquidFor("opValueItemAttr in opValueItemAttrs",`${system.Liquid("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
|
|
88
|
-
${system.Liquid("{%- assign opValueItemKey = attrs[0] -%}")}
|
|
89
|
-
${system.Liquid("{%- assign opValueItemValue = attrs[1] -%}")}
|
|
90
|
-
|
|
91
|
-
${system.LiquidIf("opValueItemKey == 'label'",`${system.Liquid("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}${system.Liquid('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
|
|
92
|
-
|
|
93
|
-
${system.LiquidIf("opValueItemKey == 'colors'",`${system.Liquid("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}${system.Liquid('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
|
|
94
|
-
|
|
95
|
-
${system.LiquidIf("opValueItemKey == 'imageUrl'",`${system.Liquid("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}${system.Liquid('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}`)}`)}`)}
|
|
96
|
-
`)}
|
|
97
|
-
|
|
98
|
-
${system.Liquid("{%- assign labels = labelsString | split: '($8)' -%}")}
|
|
99
|
-
${system.Liquid("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
|
|
100
|
-
${system.Liquid("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
|
|
101
|
-
|
|
102
|
-
${system.LiquidIf("optionTitle == option.name",`
|
|
103
|
-
${system.Liquid(`{%- assign variantPresetString = "${D}" -%}`)}
|
|
104
|
-
${system.Liquid('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
105
|
-
${system.Liquid("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
106
|
-
${system.Liquid("{%- assign type = 'dropdown' -%}")}
|
|
107
|
-
${system.LiquidFor("item in items",`
|
|
108
|
-
${system.Liquid("{%- assign itemPreset = item | split:'($1)' -%}")}
|
|
109
|
-
${system.LiquidIf("itemPreset[0] == optionName",system.Liquid("{%- assign type = itemPreset[1] -%}"))}
|
|
110
|
-
${system.LiquidIf('itemPreset[0] == "base"',system.Liquid("{%- assign type = itemPreset[1] -%}"))}
|
|
111
|
-
`)}
|
|
112
|
-
${system.Liquid("{%- assign optionRendered = true -%}")}
|
|
113
|
-
${system.LiquidFor("value in values",index_liquid.default({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:c,uid:v,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:g?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",optionType:"optionType",activeClass:g?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...t,...L,swatchAutoWidth:f(),optionTypo:p}))}
|
|
114
|
-
${system.LiquidIf("type == 'dropdown'",Dropdown_liquid.default({...t,...L,swatchAutoWidth:_(),optionTypo:p}))}
|
|
115
|
-
`)}
|
|
116
|
-
`)}
|
|
117
|
-
|
|
118
|
-
${system.LiquidIf("optionRendered == false",T())}
|
|
119
|
-
`,T=()=>system.LiquidFor("value in values",index_liquid.default({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:c,uid:v,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:g?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:g?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...t,...L,swatchAutoWidth:f(),optionTypo:p,isRenderDefault:!0})),x=system.createClass(classes.getWrapDropdownClass(o)),O=getData.getDropdownGroupData(e),C=()=>`
|
|
120
|
-
<div className="${x}">
|
|
121
|
-
${DropdownGroup_liquid.default(O)}
|
|
65
|
+
`,x=()=>core.template`
|
|
66
|
+
${system.LiquidIf(" shop.metafields.GEMPAGES.swatches and shop.metafields.GEMPAGES.swatchesJSONFormat != blank",OptionVariantsNewFormat_liquid.renderOptionValuesNewFormatSwatches(O),OptionVariantsOldFormat_liquid.renderOptionValuesOld(O))}
|
|
67
|
+
`,I=system.createClass(classes.getWrapDropdownClass(o)),N=getData.getDropdownGroupData(e),T=()=>`
|
|
68
|
+
<div className="${I}">
|
|
69
|
+
${DropdownGroup_liquid.default(N)}
|
|
122
70
|
</div>
|
|
123
|
-
|
|
71
|
+
`,C=system.createAttr(getAttr.getAttrs({uid:_,hasPreSelected:v,cssClass:a?.cssClass})),F=system.createStyle(styles.getWrapperStyle(e)),G=system.createClass({"gp-flex gp-flex-col !gp-ml-0":!0}),k=()=>{let e=core.isLocalEnv?"{{ 'gp-product-variant-v7-5.js' | asset_url }}":`${core.baseAssetURL}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return core.template`
|
|
124
72
|
${system.Liquid("{%- assign total_combinations = 1 -%}")}
|
|
125
73
|
${system.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
126
74
|
<gp-product-variants
|
|
127
|
-
${
|
|
75
|
+
${C}
|
|
128
76
|
gp-data='{
|
|
129
|
-
"setting":${JSON.stringify(
|
|
130
|
-
"styles":${JSON.stringify(
|
|
77
|
+
"setting":${JSON.stringify(h)?.replaceAll("'","'")},
|
|
78
|
+
"styles":${JSON.stringify(s)},
|
|
131
79
|
"variants":{{product.variants | json | escape}},
|
|
132
80
|
"optionsWithValues": {{product.options_with_values | json | escape}},
|
|
133
81
|
"variantSelected": {{ variant | json | escape }},
|
|
@@ -137,7 +85,7 @@
|
|
|
137
85
|
"productId": {{product.id | json | escape}},
|
|
138
86
|
"productUrl": {{product.url | json | escape}},
|
|
139
87
|
"productHandle": {{product.handle | json | escape}},
|
|
140
|
-
"displayState": ${JSON.stringify(
|
|
88
|
+
"displayState": ${JSON.stringify(g)},
|
|
141
89
|
"totalVariantCombinations": {{total_combinations}},
|
|
142
90
|
"firstAvailableVariant": {{product.selected_or_first_available_variant | json | escape}}
|
|
143
91
|
}
|
|
@@ -146,12 +94,12 @@
|
|
|
146
94
|
${system.Liquid("{%- assign options = product.options_with_values -%}")}
|
|
147
95
|
${system.Liquid("{%- assign variants = product.variants -%}")}
|
|
148
96
|
${system.LiquidIf("options.size == 0 or options.size == 1 and variants.size == 1 and variants[0].title == 'Default Title' and variants[0].option1 == 'Default Title'","<div></div>",core.template`<div
|
|
149
|
-
class="${
|
|
150
|
-
style="${
|
|
97
|
+
class="${G}"
|
|
98
|
+
style="${F}"
|
|
151
99
|
>
|
|
152
|
-
${system.If(
|
|
100
|
+
${system.If(f,T(),P())}
|
|
153
101
|
</div>`)}
|
|
154
102
|
</gp-product-variants>
|
|
155
103
|
|
|
156
|
-
${
|
|
104
|
+
${k()}
|
|
157
105
|
`};exports.default=ProductVariants;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const OPTION_VALUES_DELIMITER="|||";exports.OPTION_VALUES_DELIMITER="|||";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),base_liquid=require("../base/base.liquid.js"),mappingVariantStyles=require("../../utils/mappingVariantStyles.js");const ColorVariant=({isVariantOutStock:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),base_liquid=require("../base/base.liquid.js"),mappingVariantStyles=require("../../utils/mappingVariantStyles.js"),_const=require("../../common/const.js");const ColorVariant=({isVariantOutStock:o,swatchValue:e,...r})=>core.template`
|
|
2
2
|
{% assign colorsString = null %}
|
|
3
3
|
{% assign colors = null %}
|
|
4
4
|
{% for label in labels %}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{% endif %}
|
|
8
8
|
{% endfor %}
|
|
9
9
|
{% if colorsString != null %}
|
|
10
|
-
{% assign colors = colorsString | split: '
|
|
10
|
+
{% assign colors = colorsString | split: '${_const.OPTION_VALUES_DELIMITER}' %}
|
|
11
11
|
{% endif %}
|
|
12
|
-
${base_liquid.default({...
|
|
12
|
+
${base_liquid.default({...r,typeOfOption:"color",optionRounded:mappingVariantStyles.optionRoundedColorDefault})}
|
|
13
13
|
`;exports.default=ColorVariant;
|
|
@@ -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};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{template as e}from"@gem-sdk/core";import{Liquid as s,LiquidIf as i}from"@gem-sdk/system";import{OPTION_VALUES_DELIMITER as n}from"./common/const.js";let renderOptionValuesNewFormatSwatches=t=>{let{renderVariantItem:r,variantPresetsLiquid:a}=t;return e`
|
|
2
|
+
${s("{%- assign optionRendered = false -%}")}
|
|
3
|
+
${s("{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}")}
|
|
4
|
+
|
|
5
|
+
${s(`{% for swatch in swatches %}
|
|
6
|
+
{%- assign optionTitle = swatch.optionTitle -%}
|
|
7
|
+
{%- assign optionType = swatch.optionType -%}
|
|
8
|
+
{%- assign labelsString = "" -%}
|
|
9
|
+
{%- assign colorArraysString = "" -%}
|
|
10
|
+
{%- assign imageUrlsString = "" -%}
|
|
11
|
+
|
|
12
|
+
{% for optionValue in swatch.optionValues %}
|
|
13
|
+
{%- assign labelsString = labelsString | append: optionValue.label | append: '${n}' -%}
|
|
14
|
+
{%- assign colorsJoined = optionValue.colors | join: '${n}' -%}
|
|
15
|
+
{%- assign colorArraysString = colorArraysString | append: colorsJoined | append: '${n}' -%}
|
|
16
|
+
{%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: '${n}' -%}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
|
|
19
|
+
{%- assign labels = labelsString | split: '${n}' | slice: 0, labelsString.size -%}
|
|
20
|
+
{%- assign colorStrings = colorArraysString | split: '${n}' | slice: 0, colorArraysString.size -%}
|
|
21
|
+
{%- assign imageUrls = imageUrlsString | split: '${n}' | slice: 0, imageUrlsString.size -%}
|
|
22
|
+
|
|
23
|
+
{% if optionTitle == option.name %}
|
|
24
|
+
{%- assign variantPresetString = "${a}" -%}
|
|
25
|
+
{%- assign optionName = option.name | replace: "'", "'" | replace: '"', '"' -%}
|
|
26
|
+
{%- assign items = variantPresetString | split: '($2)' -%}
|
|
27
|
+
{%- assign type = 'dropdown' -%}
|
|
28
|
+
|
|
29
|
+
{% for item in items %}
|
|
30
|
+
{%- assign itemPreset = item | split: '($1)' -%}
|
|
31
|
+
{% if itemPreset[0] == optionName %}{%- assign type = itemPreset[1] -%}{% endif %}
|
|
32
|
+
{% if itemPreset[0] == 'base' %}{%- assign type = itemPreset[1] -%}{% endif %}
|
|
33
|
+
{% endfor %}
|
|
34
|
+
{%- assign optionRendered = true -%}
|
|
35
|
+
|
|
36
|
+
${r(!0)}
|
|
37
|
+
{% endif %}
|
|
38
|
+
{% endfor %}`)}
|
|
39
|
+
|
|
40
|
+
${i("optionRendered == false",r(!1,!0))}
|
|
41
|
+
`};export{renderOptionValuesNewFormatSwatches};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import{Liquid as e,LiquidFor as s,LiquidIf as t}from"@gem-sdk/system";import{template as i}from"@gem-sdk/core";let renderOptionValuesOld=a=>{let{renderVariantItem:n,variantPresetsLiquid:r}=a;return i`
|
|
2
|
+
${e("{%- assign optionRendered = false -%}")}
|
|
3
|
+
${e("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
|
|
4
|
+
${e("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
|
|
5
|
+
|
|
6
|
+
${s("swatchesItem in swatchesItems",`
|
|
7
|
+
${e('{%- assign colorArraysString = "" -%}')}
|
|
8
|
+
${e('{%- assign labelsString = "" -%}')}
|
|
9
|
+
${e('{%- assign imageUrlsString = "" -%}')}
|
|
10
|
+
${e("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
|
|
11
|
+
|
|
12
|
+
${s("attrItem in attrItems",`
|
|
13
|
+
${e("{%- assign attrs = attrItem | split: '($2)' -%}")}
|
|
14
|
+
${e("{%- assign optionKey = attrs[0] -%}")}
|
|
15
|
+
${e("{%- assign optionValue = attrs[1] -%}")}
|
|
16
|
+
${e(`
|
|
17
|
+
{% if optionKey == 'optionTitle' %}
|
|
18
|
+
{% assign optionTitle = optionValue %}
|
|
19
|
+
{% elsif optionKey == 'optionType' %}
|
|
20
|
+
{% assign optionType = optionValue %}
|
|
21
|
+
{% endif %}
|
|
22
|
+
`)}
|
|
23
|
+
|
|
24
|
+
${t('optionKey == "optionValues"',`
|
|
25
|
+
${e("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
|
|
26
|
+
${s("opValueItem in opValueItems",`
|
|
27
|
+
${e("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
|
|
28
|
+
${s("opValueItemAttr in opValueItemAttrs",`
|
|
29
|
+
${e("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
|
|
30
|
+
${e("{%- assign opValueItemKey = attrs[0] -%}")}
|
|
31
|
+
${e("{%- assign opValueItemValue = attrs[1] -%}")}
|
|
32
|
+
|
|
33
|
+
${t('opValueItemKey == "label"',`${e("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}
|
|
34
|
+
${e('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
|
|
35
|
+
|
|
36
|
+
${t('opValueItemKey == "colors"',`${e("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}
|
|
37
|
+
${e('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
|
|
38
|
+
|
|
39
|
+
${t('opValueItemKey == "imageUrl"',`${e("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}
|
|
40
|
+
${e('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}
|
|
41
|
+
`)}
|
|
42
|
+
`)}
|
|
43
|
+
`)}
|
|
44
|
+
`)}
|
|
45
|
+
|
|
46
|
+
${e("{%- assign labels = labelsString | split: '($8)' -%}")}
|
|
47
|
+
${e("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
|
|
48
|
+
${e("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
|
|
49
|
+
|
|
50
|
+
${t("optionTitle == option.name",`
|
|
51
|
+
${e(`{%- assign variantPresetString = "${r}" -%}`)}
|
|
52
|
+
${e('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
53
|
+
${e("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
54
|
+
${e("{%- assign type = 'dropdown' -%}")}
|
|
55
|
+
${s("item in items",`
|
|
56
|
+
${e("{%- assign itemPreset = item | split:'($1)' -%}")}
|
|
57
|
+
${t("itemPreset[0] == optionName",e("{%- assign type = itemPreset[1] -%}"))}
|
|
58
|
+
${t('itemPreset[0] == "base"',e("{%- assign type = itemPreset[1] -%}"))}
|
|
59
|
+
`)}
|
|
60
|
+
${e("{%- assign optionRendered = true -%}")}
|
|
61
|
+
${n(!0)}
|
|
62
|
+
`)}
|
|
63
|
+
`)}
|
|
64
|
+
|
|
65
|
+
${t("optionRendered == false",n(!1,!0))}
|
|
66
|
+
`};export{renderOptionValuesOld};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import{composeMemo as e,template as t,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import{composeMemo as e,template as t,isLocalEnv as i,baseAssetURL as s,DEVICES as o,getResponsiveValueByScreen as a}from"@gem-sdk/core";import n from"../../../text/components/Text.liquid.js";import r from"./components/variants/index.liquid.js";import p from"./components/dropdown-swatches/Dropdown.liquid.js";import l from"./components/dropdown-group/DropdownGroup.liquid.js";import{getSettingPreloadData as d}from"../../../helpers.js";import{mappingVariantStyles as m}from"./utils/mappingVariantStyles.js";import{createClass as c,createStyle as u,createAttr as v,Liquid as f,LiquidFor as _,LiquidIf as $,If as g}from"@gem-sdk/system";import{getAttrs as h}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as y,getWrapperStyle as j}from"./common/main/styles.js";import{getVariantOptionGroupClass as w,getWrapDropdownClass as S}from"./common/main/classes.js";import{getTextVariantTitleData as b,getDropdownGroupData as A}from"./common/main/getData.js";import{getWrapVariantOptionClass as P}from"./common/variants/classes.js";import{getStyleOfObject as V}from"../../helpers/function.js";import{getMarginBottomStyle as D}from"./common/variants/styles.js";import{renderOptionValuesNewFormatSwatches as E}from"./OptionVariantsNewFormat.liquid.js";import{renderOptionValuesOld as N}from"./OptionVariantsOldFormat.liquid.js";let DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=O=>{let{builderProps:x,styles:T,setting:q,advanced:G}=O,{align:C,swatchItemWidth:F,dropdownItemWidth:I,swatchSpacing:k,optionTypo:L,marginBottom:z}=T??{},{label:J,optionType:M,showAsSwatches:U,layout:W,hasPreSelected:Y}=q??{},H=G?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:K}=x??{},Q="groupOption"===M,R=()=>{let e={};return o.forEach(t=>{let i=a(F,t);e[t]="auto"===i}),e},B=()=>{let e={};return o.forEach(t=>{e[t]=I?.[t]==="fill"}),e},X=e(()=>{let e=m(q?.variantPresets,T);return{...q,variantPresets:e}},[q?.variantPresets,T]),Z=e=>{let t={"'":"'",'"':"""},i=e;for(let s in t)e.indexOf(s)>=0&&(i=i.replaceAll(s,t[s]));return i},ee=()=>q?.variantPresets?.map(e=>`${Z(e.optionName)}($2)${e.optionType}`).join("($1)"),et=()=>q?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),ei=(e,i)=>t`
|
|
2
|
+
${_("value in values",r({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:U,uid:K,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:Y?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:Y?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...T,...X,swatchAutoWidth:R(),optionTypo:L,isRenderDefault:i}))}
|
|
3
|
+
${$(e?'type == "dropdown"':"false",p({...T,...X,swatchAutoWidth:B(),optionTypo:L}))}`,es=q?.variantPresets?.map(e=>({name:Z(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),eo={renderVariantItem:ei,variantPresetsLiquid:es??""},ea=c(w(C)),en=u(y(k,k)),er=b(O,"Liquid"),ep=c(P(W,C)),el=()=>t`
|
|
4
|
+
${f(`{%- assign presets = "${ee()}" | split: '($1)' -%}`)}
|
|
5
|
+
${f(`{% assign hiddenPresetOptions = "${et()}" | split: ',' %}`)}
|
|
4
6
|
|
|
5
|
-
${
|
|
7
|
+
${f(`{% assign all_option_names = options | map: 'name' %}
|
|
6
8
|
{% assign filtered_options_string = '' %}
|
|
7
9
|
{% assign delimiter = '||' %}
|
|
8
10
|
|
|
@@ -25,29 +27,29 @@ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as
|
|
|
25
27
|
|
|
26
28
|
{% assign filtered_options_array = filtered_options_string | split: delimiter %}`)}
|
|
27
29
|
|
|
28
|
-
${
|
|
30
|
+
${f("{% assign last_option_name = filtered_options_array | last %}")}
|
|
29
31
|
|
|
30
|
-
${
|
|
32
|
+
${_("option in options",`
|
|
31
33
|
<div
|
|
32
34
|
option-name="{{option.name | escape}}"
|
|
33
|
-
class="${
|
|
34
|
-
style="${
|
|
35
|
+
class="${ep} ${$("hiddenPresetOptions contains option.name","gp-hidden")}"
|
|
36
|
+
style="${V(D(z))}${f("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
|
|
35
37
|
>
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
38
|
+
${f("{%- assign showVariantClass = 'variant-display' -%}")}
|
|
39
|
+
${f("{%- assign optionName = option.name -%}")}
|
|
40
|
+
${_("preset in presets",`
|
|
41
|
+
${f("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
42
|
+
${$("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${f("{%- assign showVariantClass = '' -%}")} ${f("{%- break -%}")}`)}
|
|
41
43
|
`)}
|
|
42
|
-
${
|
|
44
|
+
${g(J,n(er)," ")}
|
|
43
45
|
<div
|
|
44
46
|
variant-option-name="{{option.name | escape}}"
|
|
45
|
-
class="${
|
|
46
|
-
style="${
|
|
47
|
+
class="${ea}"
|
|
48
|
+
style="${V(en)}"
|
|
47
49
|
>
|
|
48
|
-
${
|
|
49
|
-
${
|
|
50
|
-
${
|
|
50
|
+
${f("{%- assign values = option.values -%}")}
|
|
51
|
+
${f("{%- assign rootForloop = forloop.index0 -%}")}
|
|
52
|
+
${f(`
|
|
51
53
|
{%- if option.position == 1 -%}
|
|
52
54
|
{%- assign selectedValue = variant.option1 -%}
|
|
53
55
|
{%- elsif option.position == 2 -%}
|
|
@@ -56,78 +58,24 @@ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as
|
|
|
56
58
|
{%- assign selectedValue = variant.option3 -%}
|
|
57
59
|
{%- endif -%}
|
|
58
60
|
`)}
|
|
59
|
-
${
|
|
60
|
-
${
|
|
61
|
+
${g(!Y,f("{%- assign selectedValue = null -%}"),"")}
|
|
62
|
+
${g(U,ed(),ei(!1,!0))}
|
|
61
63
|
</div>
|
|
62
64
|
</div>`)}
|
|
63
|
-
`,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
${f("swatchesItem in swatchesItems",`
|
|
69
|
-
${v('{%- assign colorArraysString = "" -%}')}
|
|
70
|
-
${v('{%- assign labelsString = "" -%}')}
|
|
71
|
-
${v('{%- assign imageUrlsString = "" -%}')}
|
|
72
|
-
${v("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
|
|
73
|
-
|
|
74
|
-
${f("attrItem in attrItems",`${v("{%- assign attrs = attrItem | split: '($2)' -%}")}
|
|
75
|
-
${v("{%- assign optionKey = attrs[0] -%}")}
|
|
76
|
-
${v("{%- assign optionValue = attrs[1] -%}")}
|
|
77
|
-
${v(`
|
|
78
|
-
{% if optionKey == 'optionTitle' %}
|
|
79
|
-
{% assign optionTitle = optionValue %}
|
|
80
|
-
{% elsif optionKey == 'optionType' %}
|
|
81
|
-
{% assign optionType = optionValue %}
|
|
82
|
-
{% endif %}
|
|
83
|
-
`)}
|
|
84
|
-
|
|
85
|
-
${y("optionKey == 'optionValues'",`${v("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
|
|
86
|
-
${f("opValueItem in opValueItems",`${v("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
|
|
87
|
-
${f("opValueItemAttr in opValueItemAttrs",`${v("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
|
|
88
|
-
${v("{%- assign opValueItemKey = attrs[0] -%}")}
|
|
89
|
-
${v("{%- assign opValueItemValue = attrs[1] -%}")}
|
|
90
|
-
|
|
91
|
-
${y("opValueItemKey == 'label'",`${v("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}${v('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
|
|
92
|
-
|
|
93
|
-
${y("opValueItemKey == 'colors'",`${v("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}${v('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
|
|
94
|
-
|
|
95
|
-
${y("opValueItemKey == 'imageUrl'",`${v("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}${v('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}`)}`)}`)}
|
|
96
|
-
`)}
|
|
97
|
-
|
|
98
|
-
${v("{%- assign labels = labelsString | split: '($8)' -%}")}
|
|
99
|
-
${v("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
|
|
100
|
-
${v("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
|
|
101
|
-
|
|
102
|
-
${y("optionTitle == option.name",`
|
|
103
|
-
${v(`{%- assign variantPresetString = "${en}" -%}`)}
|
|
104
|
-
${v('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
105
|
-
${v("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
106
|
-
${v("{%- assign type = 'dropdown' -%}")}
|
|
107
|
-
${f("item in items",`
|
|
108
|
-
${v("{%- assign itemPreset = item | split:'($1)' -%}")}
|
|
109
|
-
${y("itemPreset[0] == optionName",v("{%- assign type = itemPreset[1] -%}"))}
|
|
110
|
-
${y('itemPreset[0] == "base"',v("{%- assign type = itemPreset[1] -%}"))}
|
|
111
|
-
`)}
|
|
112
|
-
${v("{%- assign optionRendered = true -%}")}
|
|
113
|
-
${f("value in values",r({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:L,uid:H,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",optionType:"optionType",activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...x,...B,swatchAutoWidth:Q(),optionTypo:k}))}
|
|
114
|
-
${y("type == 'dropdown'",p({...x,...B,swatchAutoWidth:Y(),optionTypo:k}))}
|
|
115
|
-
`)}
|
|
116
|
-
`)}
|
|
117
|
-
|
|
118
|
-
${y("optionRendered == false",ep())}
|
|
119
|
-
`,ep=()=>f("value in values",r({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:L,uid:H,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...x,...B,swatchAutoWidth:Q(),optionTypo:k,isRenderDefault:!0})),el=c(I(U)),em=w(N),ed=()=>`
|
|
120
|
-
<div className="${el}">
|
|
121
|
-
${l(em)}
|
|
65
|
+
`,ed=()=>t`
|
|
66
|
+
${$(" shop.metafields.GEMPAGES.swatches and shop.metafields.GEMPAGES.swatchesJSONFormat != blank",E(eo),N(eo))}
|
|
67
|
+
`,em=c(S(C)),ec=A(O),eu=()=>`
|
|
68
|
+
<div className="${em}">
|
|
69
|
+
${l(ec)}
|
|
122
70
|
</div>
|
|
123
|
-
|
|
124
|
-
${
|
|
125
|
-
${
|
|
71
|
+
`,ev=v(h({uid:K,hasPreSelected:Y,cssClass:G?.cssClass})),ef=u(j(O)),e_=c({"gp-flex gp-flex-col !gp-ml-0":!0}),e$=()=>{let e=i?"{{ 'gp-product-variant-v7-5.js' | asset_url }}":`${s}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${d('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return t`
|
|
72
|
+
${f("{%- assign total_combinations = 1 -%}")}
|
|
73
|
+
${_("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
126
74
|
<gp-product-variants
|
|
127
|
-
${
|
|
75
|
+
${ev}
|
|
128
76
|
gp-data='{
|
|
129
|
-
"setting":${JSON.stringify(
|
|
130
|
-
"styles":${JSON.stringify(
|
|
77
|
+
"setting":${JSON.stringify(X)?.replaceAll("'","'")},
|
|
78
|
+
"styles":${JSON.stringify(T)},
|
|
131
79
|
"variants":{{product.variants | json | escape}},
|
|
132
80
|
"optionsWithValues": {{product.options_with_values | json | escape}},
|
|
133
81
|
"variantSelected": {{ variant | json | escape }},
|
|
@@ -137,19 +85,19 @@ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as
|
|
|
137
85
|
"productId": {{product.id | json | escape}},
|
|
138
86
|
"productUrl": {{product.url | json | escape}},
|
|
139
87
|
"productHandle": {{product.handle | json | escape}},
|
|
140
|
-
"displayState": ${JSON.stringify(
|
|
88
|
+
"displayState": ${JSON.stringify(H)},
|
|
141
89
|
"totalVariantCombinations": {{total_combinations}},
|
|
142
90
|
"firstAvailableVariant": {{product.selected_or_first_available_variant | json | escape}}
|
|
143
91
|
}
|
|
144
92
|
'>
|
|
145
93
|
<div class="gp-hidden" style="--hvr-shadow: none; --hvr-shadow-tablet: none; --hvr-shadow-mobile: none"></div>
|
|
146
|
-
${
|
|
147
|
-
${
|
|
148
|
-
${
|
|
149
|
-
class="${
|
|
150
|
-
style="${
|
|
94
|
+
${f("{%- assign options = product.options_with_values -%}")}
|
|
95
|
+
${f("{%- assign variants = product.variants -%}")}
|
|
96
|
+
${$("options.size == 0 or options.size == 1 and variants.size == 1 and variants[0].title == 'Default Title' and variants[0].option1 == 'Default Title'","<div></div>",t`<div
|
|
97
|
+
class="${e_}"
|
|
98
|
+
style="${ef}"
|
|
151
99
|
>
|
|
152
|
-
${
|
|
100
|
+
${g(Q,eu(),el())}
|
|
153
101
|
</div>`)}
|
|
154
102
|
</gp-product-variants>
|
|
155
103
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let OPTION_VALUES_DELIMITER="|||";export{OPTION_VALUES_DELIMITER};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{template as o}from"@gem-sdk/core";import
|
|
1
|
+
import{template as o}from"@gem-sdk/core";import r from"../base/base.liquid.js";import{optionRoundedColorDefault as l}from"../../utils/mappingVariantStyles.js";import{OPTION_VALUES_DELIMITER as i}from"../../common/const.js";let ColorVariant=({isVariantOutStock:s,swatchValue:n,...t})=>o`
|
|
2
2
|
{% assign colorsString = null %}
|
|
3
3
|
{% assign colors = null %}
|
|
4
4
|
{% for label in labels %}
|
|
@@ -7,7 +7,7 @@ import{template as o}from"@gem-sdk/core";import l from"../base/base.liquid.js";i
|
|
|
7
7
|
{% endif %}
|
|
8
8
|
{% endfor %}
|
|
9
9
|
{% if colorsString != null %}
|
|
10
|
-
{% assign colors = colorsString | split: '
|
|
10
|
+
{% assign colors = colorsString | split: '${i}' %}
|
|
11
11
|
{% endif %}
|
|
12
|
-
${
|
|
12
|
+
${r({...t,typeOfOption:"color",optionRounded:l})}
|
|
13
13
|
`;export{ColorVariant as default};
|
|
@@ -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.15",
|
|
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",
|