@gem-sdk/components 12.0.0-dev.98 → 12.0.0-dev.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js"),TooltipHover=require("../../../common/components/TooltipHover.js"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:o,builderProps:t,children:i,setting:s})=>{let c=core.useCurrentVariant(),n=core.useProduct(),l=core.useProductStore(e=>e.selectedSellingPlan),u=core.convertDecimalToNumber(c?.price)??0,a=core.convertDecimalToNumber(c?.salePrice)??0,p=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),{isDynamicProduct:d}=useDynamicProduct.useDynamicProduct(),{t:g}=core.useI18nStore(),{isEditMode:m}=core.useRenderMode(),{priceType:P,source:f}=s??{},x="compare"===P,h="offer"===P,y="price"===f,j="compare-price"===f,R=c?.sellingPlanGroups,b=n?.sellingPlanGroups,N=React.useMemo(()=>{if(!l)return null;let e=c?.sellingPlanGroups??n?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){for(let e of r.sellingPlans)if(e?.baseID===l)return e}return null},[JSON.stringify(R),JSON.stringify(b),l]),D=JSON.stringify(N?.pricingPolicies),v=N?.baseID,T=React.useMemo(()=>!N||u<=0?0:getPrice.calculateSellingPlanDiscount({variantPrice:u,pricingPolicies:N.pricingPolicies}),[D,u]),M=React.useMemo(()=>{if(h&&l&&v){let e=parseFloat(core.shopifyPriceRounding(u-T,2)),r=parseFloat(core.shopifyPriceRounding(e-p,2));return r>0?r:0}let e=parseFloat(core.shopifyPriceRounding(u-p,2));return e>0?e:0},[h,l,v,u,T,p]),S=React.useMemo(()=>x?y?u:a:h?M:u,[x,y,h,u,a,M]),q=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(S)||0,2)),!1),F=n?.baseID?.replace("gid://shopify/Product/",""),k=React.useMemo(()=>x&&(!p&&a<u||j&&!a||y&&u<=0),[x,p,u,a,j,y]);return(!S&&!h||k)&&m?jsxRuntime.jsx(TooltipHover.default,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:jsxRuntime.jsx("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:g("No compare price")})})}):k&&!m?null:jsxRuntime.jsxs("div",{...o,className:core.cls(t?.uid),style:{...r},id:`shopify-text-element-${t?.uid}`,"data-product-id":F,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:d?"$???":q},className:core.cls({"gp-money":h,"gp-product-compare-price":x,"gp-line-through":x&&e?.lineThrough})}),i]})};exports.default=PostPurchaseProductPrice;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js"),TooltipHover=require("../../../common/components/TooltipHover.js"),getPrice=require("../helpers/product-price-breakdown/getPrice.js"),useSubscriptionSellingType=require("../hooks/useSubscriptionSellingType.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:o,builderProps:i,children:s,setting:t})=>{let c=core.useCurrentVariant(),l=core.useProduct(),{isOneTime:n}=useSubscriptionSellingType.useSubscriptionSellingType(),u=core.useProductStore(e=>e.selectedSellingPlan),a=core.convertDecimalToNumber(c?.price)??0,p=core.convertDecimalToNumber(c?.salePrice)??0,d=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),{isDynamicProduct:g}=useDynamicProduct.useDynamicProduct(),{t:m}=core.useI18nStore(),{isEditMode:P}=core.useRenderMode(),{priceType:f,source:y}=t??{},x="compare"===f,h="offer"===f,b="price"===y,j="compare-price"===y,R=c?.sellingPlanGroups,S=l?.sellingPlanGroups,N=React.useMemo(()=>{if(!u||n)return null;let e=c?.sellingPlanGroups??l?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){for(let e of r.sellingPlans)if(e?.baseID===u)return e}return null},[JSON.stringify(R),JSON.stringify(S),u,n]),T=JSON.stringify(N?.pricingPolicies),D=N?.baseID,v=React.useMemo(()=>!N||a<=0||n?0:getPrice.calculateSellingPlanDiscount({variantPrice:a,pricingPolicies:N.pricingPolicies}),[T,a,n]),q=React.useMemo(()=>{let e=h&&!n&&u&&D;if(e){let e=parseFloat(core.shopifyPriceRounding(a-v,2)),r=parseFloat(core.shopifyPriceRounding(e-d,2));return r>0?r:0}let r=parseFloat(core.shopifyPriceRounding(a-d,2));return r>0?r:0},[h,n,u,D,a,v,d]),M=React.useMemo(()=>x?b?a:p:h?q:a,[x,b,h,a,p,q]),k=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(M)||0,2)),!1),F=l?.baseID?.replace("gid://shopify/Product/",""),O=React.useMemo(()=>x&&(!d&&p<a||j&&!p||b&&a<=0),[x,d,a,p,j,b]);return(!M&&!h||O)&&P?jsxRuntime.jsx(TooltipHover.default,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:jsxRuntime.jsx("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:m("No compare price")})})}):O&&!P?null:jsxRuntime.jsxs("div",{...o,className:core.cls(i?.uid),style:{...r},id:`shopify-text-element-${i?.uid}`,"data-product-id":F,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:g?"$???":k},className:core.cls({"gp-money":h,"gp-product-compare-price":x,"gp-line-through":x&&e?.lineThrough})}),s]})};exports.default=PostPurchaseProductPrice;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),React=require("react"),index=require("../../constants/index.js"),classes=require("./common/classes.js"),styles=require("./common/styles.js"),useSellingPlanChange=require("./hooks/useSellingPlanChange.js"),useSellingSubscription=require("./hooks/useSellingSubscription.js"),useSellingPlanOptions=require("./hooks/useSellingPlanOptions.js"),useSubscriptionVisibility=require("./hooks/useSubscriptionVisibility.js"),OneTimePurchaseTooltip=require("./components/OneTimePurchaseTooltip.js"),SellingPlanDropdown=require("./components/SellingPlanDropdown.js"),SellingPlanLabel=require("./components/SellingPlanLabel.js"),SellingPlanRadio=require("./components/SellingPlanRadio.js"),SubscriptionDetail=require("./components/SubscriptionDetail.js"),SubscriptionRadio=require("./components/SubscriptionRadio.js"),useDynamicProduct=require("../../hooks/useDynamicProduct.js");const ProductSubscription=({styles:e,setting:s,builderProps:i,builderAttrs:n,style:t,children:l})=>{let r=core.useProduct(),u=core.usePageStore(e=>e.setSubscriptionVisible),o=core.usePageStore(e=>e.getSubscriptionVisible),{defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d}=useSellingSubscription.useSellingSubscription(s),S=useSellingPlanOptions.useSellingPlanOptions(s),{selectedValue:p,handleSellingPlanChange:m}=useSellingPlanChange.useSellingPlanChange({defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d,sellingPlanOptions:S}),g=React.useRef(null),j=React.useId(),{selectedType:b,shouldShowRadio:x,isOneTimeHidden:P,hasNoSellingPlanOptions:y,setSubscriptionSellingType:R}=useSubscriptionVisibility.useSubscriptionVisibility({setting:s}),h=system.createStyle(styles.getSubscriptionStyles(e)),T=system.createStyle(styles.getSubscriptionWrapperStyles(e?.align)),O=system.createClass(classes.getWrapperClasses()),q=system.createClass(classes.getContainerClasses()),C=system.createStyle({...t}),{isEditMode:E}=core.useRenderMode(),I=`product-subscription-${r?.baseID}`,N=r?.baseID,D=`subscription-type-selection-${j}`,v=s?.sellingType===index.SubscriptionEnum.ONE_TIME,f=s?.sellingType===index.SubscriptionEnum.SUBSCRIPTION,{isDynamicProduct:k}=useDynamicProduct.useDynamicProduct();if(React.useEffect(()=>{if(!r?.id||!f||E)return;let e=r?.id,s=`${i?.uid}-${e}`,n=!(y||k),t=o()??{};if(!n){u({...t,[e]:(t[e]??[]).filter(e=>e!==s)});return}u({...t,[e]:[...t[e]??[],s]})},[i?.uid,o,y,k,E,f,r?.id,u]),P||y||k)return E?jsxRuntime.jsxs("div",{...n,style:C,children:[jsxRuntime.jsx(OneTimePurchaseTooltip.OneTimePurchaseTooltip,{ref:g,setting:s}),core.filterToolbarPreview(l,!0)]}):null;let L=e=>jsxRuntime.jsxs("div",{...n,style:C,children:[jsxRuntime.jsx("div",{ref:g,"data-selling-type":s?.sellingType,id:I,className:O,style:T,children:e}),core.filterToolbarPreview(l,!0)]}),V=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:s?.sellingStyle==="radio"?jsxRuntime.jsx(SellingPlanRadio.SellingPlanRadio,{setting:s,styles:e,builderProps:i,productId:N??"",sellingPlanOptions:S,selectedValue:p,onChange:m}):jsxRuntime.jsx(SellingPlanDropdown.SellingPlanDropdown,{setting:s,sellingPlanOptions:S,selectedValue:p,onChange:m})});return L(v&&x?jsxRuntime.jsx("div",{className:q,style:h,children:jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${N}-one-time-radio`,name:D,value:index.SubscriptionEnum.ONE_TIME,checked:b===index.SubscriptionEnum.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&R(index.SubscriptionEnum.ONE_TIME)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e})})}):f&&x?jsxRuntime.jsxs("div",{className:q,style:h,children:[jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${N}-subscription-radio`,name:D,value:index.SubscriptionEnum.SUBSCRIPTION,checked:b===index.SubscriptionEnum.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&R(index.SubscriptionEnum.SUBSCRIPTION)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e})}),b===index.SubscriptionEnum.SUBSCRIPTION&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"gp-pl-7",children:V()}),jsxRuntime.jsx("div",{className:"gp-pl-7",children:jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:s,styles:e})})]})]}):jsxRuntime.jsxs("div",{className:q,style:h,children:[jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e}),f&&V(),f&&jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:s,styles:e})]}))};exports.default=ProductSubscription;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),React=require("react"),index=require("../../constants/index.js"),classes=require("./common/classes.js"),styles=require("./common/styles.js"),useSellingPlanChange=require("./hooks/useSellingPlanChange.js"),useSellingSubscription=require("./hooks/useSellingSubscription.js"),useSellingPlanOptions=require("./hooks/useSellingPlanOptions.js"),useSubscriptionVisibility=require("./hooks/useSubscriptionVisibility.js"),OneTimePurchaseTooltip=require("./components/OneTimePurchaseTooltip.js"),SellingPlanDropdown=require("./components/SellingPlanDropdown.js"),SellingPlanLabel=require("./components/SellingPlanLabel.js"),SellingPlanRadio=require("./components/SellingPlanRadio.js"),SubscriptionDetail=require("./components/SubscriptionDetail.js"),SubscriptionRadio=require("./components/SubscriptionRadio.js"),useDynamicProduct=require("../../hooks/useDynamicProduct.js");const ProductSubscription=({styles:e,setting:s,builderProps:i,builderAttrs:n,style:t,children:l})=>{let r=core.useProduct(),u=core.usePageStore(e=>e.setSubscriptionVisible),o=core.usePageStore(e=>e.getSubscriptionVisible),{defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d}=useSellingSubscription.useSellingSubscription(s),S=useSellingPlanOptions.useSellingPlanOptions(s),{selectedValue:p,handleSellingPlanChange:m}=useSellingPlanChange.useSellingPlanChange({defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d,sellingPlanOptions:S}),g=React.useRef(null),j=React.useId(),{selectedType:b,shouldShowRadio:x,isOneTimeHidden:P,hasNoSellingPlanOptions:y,setSubscriptionSellingType:R}=useSubscriptionVisibility.useSubscriptionVisibility({setting:s}),h=system.createStyle(styles.getSubscriptionStyles(e)),T=system.createStyle(styles.getSubscriptionWrapperStyles(e?.align)),O=system.createClass(classes.getWrapperClasses()),q=system.createClass(classes.getContainerClasses()),C=system.createStyle({...t}),{isEditMode:E}=core.useRenderMode(),I=`product-subscription-${r?.baseID}`,N=r?.baseID,D=`subscription-type-selection-${j}`,v=s?.sellingType===index.SubscriptionEnum.ONE_TIME,f=s?.sellingType===index.SubscriptionEnum.SUBSCRIPTION,{isDynamicProduct:k}=useDynamicProduct.useDynamicProduct();if(React.useEffect(()=>{if(!r?.id||!f)return;let e=r?.id,s=`${i?.uid}-${e}`,n=!(y||k),t=o()??{};if(!n){u({...t,[e]:(t[e]??[]).filter(e=>e!==s)});return}u({...t,[e]:[...t[e]??[],s]})},[i?.uid,o,y,k,f,r?.id,u]),P||y||k)return E?jsxRuntime.jsxs("div",{...n,style:C,children:[jsxRuntime.jsx(OneTimePurchaseTooltip.OneTimePurchaseTooltip,{ref:g,setting:s}),core.filterToolbarPreview(l,!0)]}):null;let L=e=>jsxRuntime.jsxs("div",{...n,style:C,children:[jsxRuntime.jsx("div",{ref:g,"data-selling-type":s?.sellingType,id:I,className:O,style:T,children:e}),core.filterToolbarPreview(l,!0)]}),V=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:s?.sellingStyle==="radio"?jsxRuntime.jsx(SellingPlanRadio.SellingPlanRadio,{setting:s,styles:e,builderProps:i,productId:N??"",sellingPlanOptions:S,selectedValue:p,onChange:m}):jsxRuntime.jsx(SellingPlanDropdown.SellingPlanDropdown,{setting:s,sellingPlanOptions:S,selectedValue:p,onChange:m})});return L(v&&x?jsxRuntime.jsx("div",{className:q,style:h,children:jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${N}-one-time-radio`,name:D,value:index.SubscriptionEnum.ONE_TIME,checked:b===index.SubscriptionEnum.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&R(index.SubscriptionEnum.ONE_TIME)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e})})}):f&&x?jsxRuntime.jsxs("div",{className:q,style:h,children:[jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${N}-subscription-radio`,name:D,value:index.SubscriptionEnum.SUBSCRIPTION,checked:b===index.SubscriptionEnum.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&R(index.SubscriptionEnum.SUBSCRIPTION)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e})}),b===index.SubscriptionEnum.SUBSCRIPTION&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"gp-pl-7",children:V()}),jsxRuntime.jsx("div",{className:"gp-pl-7",children:jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:s,styles:e})})]})]}):jsxRuntime.jsxs("div",{className:q,style:h,children:[jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e}),f&&V(),f&&jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:s,styles:e})]}))};exports.default=ProductSubscription;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),core=require("@gem-sdk/core"),index=require("../../../constants/index.js"),useSellingPlanOptions=require("./useSellingPlanOptions.js");const useSubscriptionVisibility=({setting:e})=>{let i=core.useProductStore(e=>e.setSubscriptionSellingType),n=core.useProductStore(e=>e.subscriptionSellingType),s=useSellingPlanOptions.useSellingPlanOptions(e),u=core.useProduct(),t=u?.requiresSellingPlan,r=n===index.SubscriptionEnum.ONE_TIME?index.SubscriptionEnum.ONE_TIME:index.SubscriptionEnum.SUBSCRIPTION;React.useEffect(()=>{n||(e?.sellingType===index.SubscriptionEnum.ONE_TIME?i(index.SubscriptionEnum.ONE_TIME):i(e?.sellingType??index.SubscriptionEnum.SUBSCRIPTION))},[i,e?.sellingType,n]);let l=!t&&s&&s.length>0,o=e?.sellingType===index.SubscriptionEnum.SUBSCRIPTION&&(!s||0===s.length),c=e?.sellingType===index.SubscriptionEnum.ONE_TIME&&t;return{selectedType:r,shouldShowRadio:l,isOneTimeHidden:c,hasNoSellingPlanOptions:o,setSubscriptionSellingType:i}};exports.useSubscriptionVisibility=useSubscriptionVisibility;
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),index=require("../../../constants/index.js"),useSellingPlanOptions=require("./useSellingPlanOptions.js"),useSubscriptionSellingType=require("../../../hooks/useSubscriptionSellingType.js");const useSubscriptionVisibility=({setting:e})=>{let i=core.useProductStore(e=>e.setSubscriptionSellingType),{isOneTime:n,subscriptionSellingType:s}=useSubscriptionSellingType.useSubscriptionSellingType(),u=useSellingPlanOptions.useSellingPlanOptions(e),l=core.useProduct(),t=l?.requiresSellingPlan,r=n?index.SubscriptionEnum.ONE_TIME:index.SubscriptionEnum.SUBSCRIPTION;React.useEffect(()=>{s||(e?.sellingType===index.SubscriptionEnum.ONE_TIME?i(index.SubscriptionEnum.ONE_TIME):i(e?.sellingType??index.SubscriptionEnum.SUBSCRIPTION))},[i,e?.sellingType,s]);let S=!t&&u&&u.length>0,o=e?.sellingType===index.SubscriptionEnum.SUBSCRIPTION&&(!u||0===u.length),p=e?.sellingType===index.SubscriptionEnum.ONE_TIME&&t;return{selectedType:r,shouldShowRadio:S,isOneTimeHidden:p,hasNoSellingPlanOptions:o,setSubscriptionSellingType:i}};exports.useSubscriptionVisibility=useSubscriptionVisibility;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("./useDynamicProduct.js"),useRecurringSubtotal=require("./useRecurringSubtotal.js"),useProductPriceBreakdown=require("./useProductPriceBreakdown.js"),index=require("../constants/index.js");const useGetMoneyLines=(e,t)=>{let{isDynamicProduct:u,dynamicPrice:i,dynamicDiscount:o,isEnableDynamicDiscount:s}=useDynamicProduct.useDynamicProduct(),{t:r}=core.useI18nStore(),n=useRecurringSubtotal.useRecurringSubtotal(),l=core.useProductStore(e=>e.subscriptionSellingType),{subTotalMoneyFormatted:a,offerDiscountTotal:c,discountMoneyFormatted:d,totalMoneyFormatted:b}=useProductPriceBreakdown.useProductPriceBreakdown(),p=()=>{let p=[];return!1!==e.isShowSubTotalLabel&&p.push({title:t.subTotalLabel,money:u?i:a,uniqueId:"subTotalLabel"}),!1!==e.isShowDiscountLabel&&p.push({title:t.discountLabel,money:u&&o&&s?`${o.value}%`:c>0?d:"No discount",uniqueId:"discountLabel"}),!1!==e.isShowShippingLabel&&p.push({title:t.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==e.isShowTaxesLabel&&p.push({title:t.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==e.isShowTotalLabel&&p.push({title:t.totalLabel,money:u?i:b,uniqueId:"totalLabel"}),t?.isShowRecurringTotalLabel!==!1&&n&&l!==index.SubscriptionEnum.ONE_TIME&&p.push({title:r("Recurring subtotal"),money:n,uniqueId:"recurringTotalLabel",subTitle:r("Doesn't include shipping, tax or duties")}),p};return{getMoneyLines:p}};exports.useGetMoneyLines=useGetMoneyLines;
1
+ "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("./useDynamicProduct.js"),useRecurringSubtotal=require("./useRecurringSubtotal.js"),useProductPriceBreakdown=require("./useProductPriceBreakdown.js"),useSubscriptionSellingType=require("./useSubscriptionSellingType.js");const useGetMoneyLines=(e,u)=>{let{isDynamicProduct:t,dynamicPrice:i,dynamicDiscount:o,isEnableDynamicDiscount:s}=useDynamicProduct.useDynamicProduct(),{t:l}=core.useI18nStore(),r=useRecurringSubtotal.useRecurringSubtotal(),{isSubscription:n}=useSubscriptionSellingType.useSubscriptionSellingType(),{subTotalMoneyFormatted:a,offerDiscountTotal:c,discountMoneyFormatted:b,totalMoneyFormatted:p}=useProductPriceBreakdown.useProductPriceBreakdown(),d=()=>{let d=[];return!1!==e.isShowSubTotalLabel&&d.push({title:u.subTotalLabel,money:t?i:a,uniqueId:"subTotalLabel"}),!1!==e.isShowDiscountLabel&&d.push({title:u.discountLabel,money:t&&o&&s?`${o.value}%`:c>0?b:"No discount",uniqueId:"discountLabel"}),!1!==e.isShowShippingLabel&&d.push({title:u.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==e.isShowTaxesLabel&&d.push({title:u.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==e.isShowTotalLabel&&d.push({title:u.totalLabel,money:t?i:p,uniqueId:"totalLabel"}),u?.isShowRecurringTotalLabel!==!1&&r&&n&&d.push({title:l("Recurring subtotal"),money:r,uniqueId:"recurringTotalLabel",subTitle:l("Doesn't include shipping, tax or duties")}),d};return{getMoneyLines:d}};exports.useGetMoneyLines=useGetMoneyLines;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js"),index=require("../constants/index.js");const useProductPriceBreakdown=()=>{let e=core.useProductOfferDiscount(),r=core.useCurrentVariant(),o=core.useProduct(),i=core.useProductStore(e=>e.selectedSellingPlan),c=core.useProductStore(e=>e.subscriptionSellingType),{quantity:n}=core.useQuantity(),t=React.useMemo(()=>{if(!i||c===index.SubscriptionEnum.ONE_TIME)return null;let e=r?.sellingPlanGroups??o?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){let e=r.sellingPlans.find(e=>e?.baseID===i);if(e)return e}return null},[r,o,i,c]),s=core.convertDecimalToNumber(r?.price)??0,u=React.useMemo(()=>!t||s<=0?0:getPrice.calculateSellingPlanDiscount({variantPrice:s,pricingPolicies:t.pricingPolicies}),[t,s]),a=Math.max(0,parseFloat(core.shopifyPriceRounding(s-u,2))),l=Math.max(0,parseFloat(core.shopifyPriceRounding(a*(n||1),2))),P=core.useFormatMoney(l,!1),d=e*(n||1),p=parseFloat(core.shopifyPriceRounding(d,2)),g=core.useFormatMoney(p,!1),f=core.shopifyPriceRounding(p,2),m=parseFloat(core.shopifyPriceRounding(l-parseFloat(f),2)),y=core.useFormatMoney(m>0?m:0,!1);return{price:s,sellingPlanDiscountPerUnit:u,priceAfterSellingPlanDiscount:a,subTotal:l,subTotalMoneyFormatted:P,offerDiscountTotal:d,discountWithQuantity:p,discountMoneyFormatted:g,totalMoneyFormatted:y}};exports.useProductPriceBreakdown=useProductPriceBreakdown;
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js"),useSubscriptionSellingType=require("./useSubscriptionSellingType.js");const useProductPriceBreakdown=()=>{let e=core.useProductOfferDiscount(),r=core.useCurrentVariant(),o=core.useProduct(),i=core.useProductStore(e=>e.selectedSellingPlan),{isOneTime:c}=useSubscriptionSellingType.useSubscriptionSellingType(),{quantity:n}=core.useQuantity(),s=React.useMemo(()=>{if(!i||c)return null;let e=r?.sellingPlanGroups??o?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){let e=r.sellingPlans.find(e=>e?.baseID===i);if(e)return e}return null},[r,o,i,c]),u=core.convertDecimalToNumber(r?.price)??0,t=React.useMemo(()=>!s||u<=0?0:getPrice.calculateSellingPlanDiscount({variantPrice:u,pricingPolicies:s.pricingPolicies}),[s,u]),l=Math.max(0,parseFloat(core.shopifyPriceRounding(u-t,2))),a=Math.max(0,parseFloat(core.shopifyPriceRounding(l*(n||1),2))),p=core.useFormatMoney(a,!1),P=e*(n||1),g=parseFloat(core.shopifyPriceRounding(P,2)),d=core.useFormatMoney(g,!1),f=core.shopifyPriceRounding(g,2),y=parseFloat(core.shopifyPriceRounding(a-parseFloat(f),2)),S=core.useFormatMoney(y>0?y:0,!1);return{price:u,sellingPlanDiscountPerUnit:t,priceAfterSellingPlanDiscount:l,subTotal:a,subTotalMoneyFormatted:p,offerDiscountTotal:P,discountWithQuantity:g,discountMoneyFormatted:d,totalMoneyFormatted:S}};exports.useProductPriceBreakdown=useProductPriceBreakdown;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),React=require("react"),index=require("../constants/index.js"),product=require("../../../product/helpers/product.js"),useBuyerConsentChecked=require("../../buyer-consent/hooks/useBuyerConsentChecked.js");const useSubscriptionConsentCheck=()=>{let{checked:e}=useBuyerConsentChecked.useBuyerConsentChecked(),r=core.useProductStore(e=>e.selectedOptions),t=core.useProductStore(e=>e.subscriptionSellingType),n=core.usePageStore(e=>e.getSubscriptionVisible()),s=core.useProduct(),u=core.useVariants(),o=React.useMemo(()=>{let o=t===index.SubscriptionEnum.ONE_TIME,c=!n?.[s?.id??""]?.length;if(e||o||c)return!1;let i=!!s?.sellingPlanGroups?.length||!!s?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!i||!r)return!1;let l=product.checkDefaultVariant(s);if(!l){let e=u.find(e=>e?.selectedOptions.every(e=>r[e.name??""]===e.value)),t=!!e?.sellingPlanGroups?.length;return t}return!0},[r,t,e,s,u]);return{isDisableAccept:o}};exports.useSubscriptionConsentCheck=useSubscriptionConsentCheck;
1
+ "use strict";var core=require("@gem-sdk/core"),React=require("react"),product=require("../../../product/helpers/product.js"),useBuyerConsentChecked=require("../../buyer-consent/hooks/useBuyerConsentChecked.js"),useSubscriptionSellingType=require("./useSubscriptionSellingType.js");const useSubscriptionConsentCheck=()=>{let{checked:e}=useBuyerConsentChecked.useBuyerConsentChecked(),r=core.useProductStore(e=>e.selectedOptions),{isOneTime:s}=useSubscriptionSellingType.useSubscriptionSellingType(),n=core.usePageStore(e=>e.getSubscriptionVisible()),t=core.useProduct(),u=core.useVariants(),i=React.useMemo(()=>{let i=!n?.[t?.id??""]?.length;if(e||s||i)return!1;let o=!!t?.sellingPlanGroups?.length||!!t?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!o||!r)return!1;let c=product.checkDefaultVariant(t);if(!c){let e=u.find(e=>e?.selectedOptions.every(e=>r[e.name??""]===e.value)),s=!!e?.sellingPlanGroups?.length;return s}return!0},[r,s,e,t,u]);return{isDisableAccept:i}};exports.useSubscriptionConsentCheck=useSubscriptionConsentCheck;
@@ -0,0 +1 @@
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),index=require("../constants/index.js");const useSubscriptionSellingType=()=>{let e=core.useProductStore(e=>e.subscriptionSellingType);return React.useMemo(()=>({isOneTime:e===index.SubscriptionEnum.ONE_TIME,isSubscription:e===index.SubscriptionEnum.SUBSCRIPTION,subscriptionSellingType:e}),[e])};exports.useSubscriptionSellingType=useSubscriptionSellingType;
@@ -1 +1 @@
1
- "use strict";require("react/jsx-runtime"),require("@gem-sdk/core"),require("@gem-sdk/system"),require("react"),require("./components/product-subscription/types.js"),require("./components/product-variant/components/variants/VariantItem.js"),require("next/link"),require("./constants/index.js"),require("next/head"),require("next/image"),require("react-youtube"),require("./components/product-subscription/components/OneTimePurchaseTooltip.js"),require("../image/components/Img.js");var ProductTitle$1=require("./settings/product-title/ProductTitle.js"),ProductDescription$1=require("./settings/product-description/ProductDescription.js"),ProductPrice$1=require("./settings/product-price/ProductPrice.js"),ProductVariant$1=require("./settings/product-variants/ProductVariant.js"),index$1=require("./settings/accept-button/index.js"),index$2=require("./settings/product-quantity/index.js"),index$4=require("./settings/product-offer/index.js"),index$3=require("./settings/product-price-breakdown/index.js"),ProductDiscountTag$1=require("./settings/product-discount-tag/ProductDiscountTag.js"),index$5=require("./settings/product-subscription/index.js"),ProductImages=require("./settings/product-image/ProductImages.js");const postPurchaseProductSetting={PostPurchaseProductTitle:ProductTitle$1.default,PostPurchaseProductDescription:ProductDescription$1.default,PostPurchaseProductPrice:ProductPrice$1.default,PostPurchaseProductVariants:ProductVariant$1.default,PostPurchaseAcceptButton:index$1.default,PostPurchaseProductQuantity:index$2.default,PostPurchaseProductPriceBreakdown:index$3.default,PostPurchaseProductOffer:index$4.default,PostPurchaseProductDiscountTag:ProductDiscountTag$1.default,PostPurchaseProductImages:ProductImages.default,PostPurchaseProductSubscription:index$5.default};exports.postPurchaseProductSetting=postPurchaseProductSetting;
1
+ "use strict";require("react/jsx-runtime"),require("@gem-sdk/core"),require("@gem-sdk/system"),require("react"),require("./components/product-subscription/types.js"),require("./constants/index.js"),require("./components/product-variant/components/variants/VariantItem.js"),require("next/link"),require("next/head"),require("next/image"),require("react-youtube"),require("./components/product-subscription/components/OneTimePurchaseTooltip.js"),require("../image/components/Img.js");var ProductTitle$1=require("./settings/product-title/ProductTitle.js"),ProductDescription$1=require("./settings/product-description/ProductDescription.js"),ProductPrice$1=require("./settings/product-price/ProductPrice.js"),ProductVariant$1=require("./settings/product-variants/ProductVariant.js"),index$1=require("./settings/accept-button/index.js"),index$2=require("./settings/product-quantity/index.js"),index$4=require("./settings/product-offer/index.js"),index$3=require("./settings/product-price-breakdown/index.js"),ProductDiscountTag$1=require("./settings/product-discount-tag/ProductDiscountTag.js"),index$5=require("./settings/product-subscription/index.js"),ProductImages=require("./settings/product-image/ProductImages.js");const postPurchaseProductSetting={PostPurchaseProductTitle:ProductTitle$1.default,PostPurchaseProductDescription:ProductDescription$1.default,PostPurchaseProductPrice:ProductPrice$1.default,PostPurchaseProductVariants:ProductVariant$1.default,PostPurchaseAcceptButton:index$1.default,PostPurchaseProductQuantity:index$2.default,PostPurchaseProductPriceBreakdown:index$3.default,PostPurchaseProductOffer:index$4.default,PostPurchaseProductDiscountTag:ProductDiscountTag$1.default,PostPurchaseProductImages:ProductImages.default,PostPurchaseProductSubscription:index$5.default};exports.postPurchaseProductSetting=postPurchaseProductSetting;
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useCurrentVariant as t,useProduct as i,useProductStore as o,convertDecimalToNumber as l,shopifyPriceRounding as s,useProductOfferDiscount as p,useI18nStore as a,useRenderMode as n,useFormatMoney as c,cls as g}from"@gem-sdk/core";import{useMemo as d}from"react";import m from"../../text/components/Text.js";import{useDynamicProduct as u}from"../hooks/useDynamicProduct.js";import f from"../../../common/components/TooltipHover.js";import{calculateSellingPlanDiscount as P}from"../helpers/product-price-breakdown/getPrice.js";let PostPurchaseProductPrice=({styles:h,style:y,builderAttrs:x,builderProps:b,children:N,setting:j})=>{let k=t(),D=i(),F=o(e=>e.selectedSellingPlan),S=l(k?.price)??0,v=l(k?.salePrice)??0,w=parseFloat(s(p(),2)),{isDynamicProduct:G}=u(),{t:I}=a(),{isEditMode:J}=n(),{priceType:O,source:T}=j??{},$="compare"===O,H="offer"===O,q="price"===T,z="compare-price"===T,A=k?.sellingPlanGroups,B=D?.sellingPlanGroups,C=d(()=>{if(!F)return null;let e=k?.sellingPlanGroups??D?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){for(let e of r.sellingPlans)if(e?.baseID===F)return e}return null},[JSON.stringify(A),JSON.stringify(B),F]),E=JSON.stringify(C?.pricingPolicies),K=C?.baseID,L=d(()=>!C||S<=0?0:P({variantPrice:S,pricingPolicies:C.pricingPolicies}),[E,S]),M=d(()=>{if(H&&F&&K){let e=parseFloat(s(S-L,2)),r=parseFloat(s(e-w,2));return r>0?r:0}let e=parseFloat(s(S-w,2));return e>0?e:0},[H,F,K,S,L,w]),Q=d(()=>$?q?S:v:H?M:S,[$,q,H,S,v,M]),R=c(parseFloat(s(Number(Q)||0,2)),!1),U=D?.baseID?.replace("gid://shopify/Product/",""),V=d(()=>$&&(!w&&v<S||z&&!v||q&&S<=0),[$,w,S,v,z,q]);return(!Q&&!H||V)&&J?e(f,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:e("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:e("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:I("No compare price")})})}):V&&!J?null:r("div",{...x,className:g(b?.uid),style:{...y},id:`shopify-text-element-${b?.uid}`,"data-product-id":U,children:[e(m,{styles:h,setting:{text:G?"$???":R},className:g({"gp-money":H,"gp-product-compare-price":$,"gp-line-through":$&&h?.lineThrough})}),N]})};export{PostPurchaseProductPrice as default};
2
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useCurrentVariant as t,useProduct as o,useProductStore as i,convertDecimalToNumber as l,shopifyPriceRounding as s,useProductOfferDiscount as p,useI18nStore as a,useRenderMode as n,useFormatMoney as c,cls as g}from"@gem-sdk/core";import{useMemo as m}from"react";import d from"../../text/components/Text.js";import{useDynamicProduct as u}from"../hooks/useDynamicProduct.js";import f from"../../../common/components/TooltipHover.js";import{calculateSellingPlanDiscount as P}from"../helpers/product-price-breakdown/getPrice.js";import{useSubscriptionSellingType as h}from"../hooks/useSubscriptionSellingType.js";let PostPurchaseProductPrice=({styles:y,style:x,builderAttrs:b,builderProps:N,children:j,setting:S})=>{let k=t(),D=o(),{isOneTime:F}=h(),v=i(e=>e.selectedSellingPlan),w=l(k?.price)??0,G=l(k?.salePrice)??0,T=parseFloat(s(p(),2)),{isDynamicProduct:I}=u(),{t:J}=a(),{isEditMode:O}=n(),{priceType:$,source:H}=S??{},q="compare"===$,z="offer"===$,A="price"===H,B="compare-price"===H,C=k?.sellingPlanGroups,E=D?.sellingPlanGroups,K=m(()=>{if(!v||F)return null;let e=k?.sellingPlanGroups??D?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){for(let e of r.sellingPlans)if(e?.baseID===v)return e}return null},[JSON.stringify(C),JSON.stringify(E),v,F]),L=JSON.stringify(K?.pricingPolicies),M=K?.baseID,Q=m(()=>!K||w<=0||F?0:P({variantPrice:w,pricingPolicies:K.pricingPolicies}),[L,w,F]),R=m(()=>{let e=z&&!F&&v&&M;if(e){let e=parseFloat(s(w-Q,2)),r=parseFloat(s(e-T,2));return r>0?r:0}let r=parseFloat(s(w-T,2));return r>0?r:0},[z,F,v,M,w,Q,T]),U=m(()=>q?A?w:G:z?R:w,[q,A,z,w,G,R]),V=c(parseFloat(s(Number(U)||0,2)),!1),W=D?.baseID?.replace("gid://shopify/Product/",""),X=m(()=>q&&(!T&&G<w||B&&!G||A&&w<=0),[q,T,w,G,B,A]);return(!U&&!z||X)&&O?e(f,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:e("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:e("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:J("No compare price")})})}):X&&!O?null:r("div",{...b,className:g(N?.uid),style:{...x},id:`shopify-text-element-${N?.uid}`,"data-product-id":W,children:[e(d,{styles:y,setting:{text:I?"$???":V},className:g({"gp-money":z,"gp-product-compare-price":q,"gp-line-through":q&&y?.lineThrough})}),j]})};export{PostPurchaseProductPrice as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useProduct as t,usePageStore as o,useRenderMode as l,filterToolbarPreview as n}from"@gem-sdk/core";import{createStyle as r,createClass as m}from"@gem-sdk/system";import{useRef as c,useId as a,useEffect as p}from"react";import{SubscriptionEnum as d}from"../../constants/index.js";import{getWrapperClasses as u,getContainerClasses as g}from"./common/classes.js";import{getSubscriptionStyles as h,getSubscriptionWrapperStyles as f}from"./common/styles.js";import{useSellingPlanChange as S}from"./hooks/useSellingPlanChange.js";import{useSellingSubscription as y}from"./hooks/useSellingSubscription.js";import{useSellingPlanOptions as b}from"./hooks/useSellingPlanOptions.js";import{useSubscriptionVisibility as I}from"./hooks/useSubscriptionVisibility.js";import{OneTimePurchaseTooltip as N}from"./components/OneTimePurchaseTooltip.js";import{SellingPlanDropdown as P}from"./components/SellingPlanDropdown.js";import{SellingPlanLabel as j}from"./components/SellingPlanLabel.js";import{SellingPlanRadio as T}from"./components/SellingPlanRadio.js";import{SubscriptionDetail as O}from"./components/SubscriptionDetail.js";import{SubscriptionRadio as k}from"./components/SubscriptionRadio.js";import{useDynamicProduct as v}from"../../hooks/useDynamicProduct.js";let ProductSubscription=({styles:C,setting:E,builderProps:R,builderAttrs:$,style:B,children:D})=>{let U=t(),V=o(e=>e.setSubscriptionVisible),M=o(e=>e.getSubscriptionVisible),{defaultValue:_,selectedSellingPlan:x,setSelectedSellingPlan:w}=y(E),L=b(E),{selectedValue:q,handleSellingPlanChange:z}=S({defaultValue:_,selectedSellingPlan:x,setSelectedSellingPlan:w,sellingPlanOptions:L}),A=c(null),F=a(),{selectedType:G,shouldShowRadio:H,isOneTimeHidden:J,hasNoSellingPlanOptions:K,setSubscriptionSellingType:Q}=I({setting:E}),W=r(h(C)),X=r(f(C?.align)),Y=m(u()),Z=m(g()),ee=r({...B}),{isEditMode:es}=l(),ei=`product-subscription-${U?.baseID}`,et=U?.baseID,eo=`subscription-type-selection-${F}`,el=E?.sellingType===d.ONE_TIME,en=E?.sellingType===d.SUBSCRIPTION,{isDynamicProduct:er}=v();if(p(()=>{if(!U?.id||!en||es)return;let e=U?.id,s=`${R?.uid}-${e}`,i=!(K||er),t=M()??{};if(!i){V({...t,[e]:(t[e]??[]).filter(e=>e!==s)});return}V({...t,[e]:[...t[e]??[],s]})},[R?.uid,M,K,er,es,en,U?.id,V]),J||K||er)return es?e("div",{...$,style:ee,children:[s(N,{ref:A,setting:E}),n(D,!0)]}):null;let em=i=>e("div",{...$,style:ee,children:[s("div",{ref:A,"data-selling-type":E?.sellingType,id:ei,className:Y,style:X,children:i}),n(D,!0)]}),ec=()=>s(i,{children:E?.sellingStyle==="radio"?s(T,{setting:E,styles:C,builderProps:R,productId:et??"",sellingPlanOptions:L,selectedValue:q,onChange:z}):s(P,{setting:E,sellingPlanOptions:L,selectedValue:q,onChange:z})});return em(el&&H?s("div",{className:Z,style:W,children:s(k,{id:`${et}-one-time-radio`,name:eo,value:d.ONE_TIME,checked:G===d.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&Q(d.ONE_TIME)},children:s(j,{setting:E,styles:C})})}):en&&H?e("div",{className:Z,style:W,children:[s(k,{id:`${et}-subscription-radio`,name:eo,value:d.SUBSCRIPTION,checked:G===d.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&Q(d.SUBSCRIPTION)},children:s(j,{setting:E,styles:C})}),G===d.SUBSCRIPTION&&e(i,{children:[s("div",{className:"gp-pl-7",children:ec()}),s("div",{className:"gp-pl-7",children:s(O,{setting:E,styles:C})})]})]}):e("div",{className:Z,style:W,children:[s(j,{setting:E,styles:C}),en&&ec(),en&&s(O,{setting:E,styles:C})]}))};export{ProductSubscription as default};
1
+ import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useProduct as t,usePageStore as o,useRenderMode as l,filterToolbarPreview as n}from"@gem-sdk/core";import{createStyle as r,createClass as m}from"@gem-sdk/system";import{useRef as c,useId as a,useEffect as p}from"react";import{SubscriptionEnum as d}from"../../constants/index.js";import{getWrapperClasses as u,getContainerClasses as g}from"./common/classes.js";import{getSubscriptionStyles as h,getSubscriptionWrapperStyles as f}from"./common/styles.js";import{useSellingPlanChange as S}from"./hooks/useSellingPlanChange.js";import{useSellingSubscription as y}from"./hooks/useSellingSubscription.js";import{useSellingPlanOptions as b}from"./hooks/useSellingPlanOptions.js";import{useSubscriptionVisibility as I}from"./hooks/useSubscriptionVisibility.js";import{OneTimePurchaseTooltip as N}from"./components/OneTimePurchaseTooltip.js";import{SellingPlanDropdown as P}from"./components/SellingPlanDropdown.js";import{SellingPlanLabel as j}from"./components/SellingPlanLabel.js";import{SellingPlanRadio as T}from"./components/SellingPlanRadio.js";import{SubscriptionDetail as O}from"./components/SubscriptionDetail.js";import{SubscriptionRadio as k}from"./components/SubscriptionRadio.js";import{useDynamicProduct as v}from"../../hooks/useDynamicProduct.js";let ProductSubscription=({styles:C,setting:E,builderProps:R,builderAttrs:$,style:B,children:D})=>{let U=t(),V=o(e=>e.setSubscriptionVisible),M=o(e=>e.getSubscriptionVisible),{defaultValue:_,selectedSellingPlan:x,setSelectedSellingPlan:w}=y(E),L=b(E),{selectedValue:q,handleSellingPlanChange:z}=S({defaultValue:_,selectedSellingPlan:x,setSelectedSellingPlan:w,sellingPlanOptions:L}),A=c(null),F=a(),{selectedType:G,shouldShowRadio:H,isOneTimeHidden:J,hasNoSellingPlanOptions:K,setSubscriptionSellingType:Q}=I({setting:E}),W=r(h(C)),X=r(f(C?.align)),Y=m(u()),Z=m(g()),ee=r({...B}),{isEditMode:es}=l(),ei=`product-subscription-${U?.baseID}`,et=U?.baseID,eo=`subscription-type-selection-${F}`,el=E?.sellingType===d.ONE_TIME,en=E?.sellingType===d.SUBSCRIPTION,{isDynamicProduct:er}=v();if(p(()=>{if(!U?.id||!en)return;let e=U?.id,s=`${R?.uid}-${e}`,i=!(K||er),t=M()??{};if(!i){V({...t,[e]:(t[e]??[]).filter(e=>e!==s)});return}V({...t,[e]:[...t[e]??[],s]})},[R?.uid,M,K,er,en,U?.id,V]),J||K||er)return es?e("div",{...$,style:ee,children:[s(N,{ref:A,setting:E}),n(D,!0)]}):null;let em=i=>e("div",{...$,style:ee,children:[s("div",{ref:A,"data-selling-type":E?.sellingType,id:ei,className:Y,style:X,children:i}),n(D,!0)]}),ec=()=>s(i,{children:E?.sellingStyle==="radio"?s(T,{setting:E,styles:C,builderProps:R,productId:et??"",sellingPlanOptions:L,selectedValue:q,onChange:z}):s(P,{setting:E,sellingPlanOptions:L,selectedValue:q,onChange:z})});return em(el&&H?s("div",{className:Z,style:W,children:s(k,{id:`${et}-one-time-radio`,name:eo,value:d.ONE_TIME,checked:G===d.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&Q(d.ONE_TIME)},children:s(j,{setting:E,styles:C})})}):en&&H?e("div",{className:Z,style:W,children:[s(k,{id:`${et}-subscription-radio`,name:eo,value:d.SUBSCRIPTION,checked:G===d.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&Q(d.SUBSCRIPTION)},children:s(j,{setting:E,styles:C})}),G===d.SUBSCRIPTION&&e(i,{children:[s("div",{className:"gp-pl-7",children:ec()}),s("div",{className:"gp-pl-7",children:s(O,{setting:E,styles:C})})]})]}):e("div",{className:Z,style:W,children:[s(j,{setting:E,styles:C}),en&&ec(),en&&s(O,{setting:E,styles:C})]}))};export{ProductSubscription as default};
@@ -1 +1 @@
1
- import{useEffect as e}from"react";import{useProductStore as i,useProduct as l}from"@gem-sdk/core";import{SubscriptionEnum as s}from"../../../constants/index.js";import{useSellingPlanOptions as n}from"./useSellingPlanOptions.js";let useSubscriptionVisibility=({setting:t})=>{let r=i(e=>e.setSubscriptionSellingType),p=i(e=>e.subscriptionSellingType),o=n(t),T=l(),S=T?.requiresSellingPlan,g=p===s.ONE_TIME?s.ONE_TIME:s.SUBSCRIPTION;e(()=>{p||(t?.sellingType===s.ONE_TIME?r(s.ONE_TIME):r(t?.sellingType??s.SUBSCRIPTION))},[r,t?.sellingType,p]);let I=!S&&o&&o.length>0,E=t?.sellingType===s.SUBSCRIPTION&&(!o||0===o.length),m=t?.sellingType===s.ONE_TIME&&S;return{selectedType:g,shouldShowRadio:I,isOneTimeHidden:m,hasNoSellingPlanOptions:E,setSubscriptionSellingType:r}};export{useSubscriptionVisibility};
1
+ import{useEffect as e}from"react";import{useProductStore as i,useProduct as l}from"@gem-sdk/core";import{SubscriptionEnum as s}from"../../../constants/index.js";import{useSellingPlanOptions as t}from"./useSellingPlanOptions.js";import{useSubscriptionSellingType as n}from"../../../hooks/useSubscriptionSellingType.js";let useSubscriptionVisibility=({setting:r})=>{let o=i(e=>e.setSubscriptionSellingType),{isOneTime:p,subscriptionSellingType:S}=n(),T=t(r),g=l(),m=g?.requiresSellingPlan,u=p?s.ONE_TIME:s.SUBSCRIPTION;e(()=>{S||(r?.sellingType===s.ONE_TIME?o(s.ONE_TIME):o(r?.sellingType??s.SUBSCRIPTION))},[o,r?.sellingType,S]);let I=!m&&T&&T.length>0,y=r?.sellingType===s.SUBSCRIPTION&&(!T||0===T.length),E=r?.sellingType===s.ONE_TIME&&m;return{selectedType:u,shouldShowRadio:I,isOneTimeHidden:E,hasNoSellingPlanOptions:y,setSubscriptionSellingType:o}};export{useSubscriptionVisibility};
@@ -1 +1 @@
1
- import{useI18nStore as e,useProductStore as t}from"@gem-sdk/core";import{useDynamicProduct as i}from"./useDynamicProduct.js";import{useRecurringSubtotal as o}from"./useRecurringSubtotal.js";import{useProductPriceBreakdown as l}from"./useProductPriceBreakdown.js";import{SubscriptionEnum as u}from"../constants/index.js";let useGetMoneyLines=(s,a)=>{let{isDynamicProduct:n,dynamicPrice:r,dynamicDiscount:p,isEnableDynamicDiscount:b}=i(),{t:c}=e(),d=o(),h=t(e=>e.subscriptionSellingType),{subTotalMoneyFormatted:L,offerDiscountTotal:m,discountMoneyFormatted:g,totalMoneyFormatted:w}=l(),S=()=>{let e=[];return!1!==s.isShowSubTotalLabel&&e.push({title:a.subTotalLabel,money:n?r:L,uniqueId:"subTotalLabel"}),!1!==s.isShowDiscountLabel&&e.push({title:a.discountLabel,money:n&&p&&b?`${p.value}%`:m>0?g:"No discount",uniqueId:"discountLabel"}),!1!==s.isShowShippingLabel&&e.push({title:a.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==s.isShowTaxesLabel&&e.push({title:a.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==s.isShowTotalLabel&&e.push({title:a.totalLabel,money:n?r:w,uniqueId:"totalLabel"}),a?.isShowRecurringTotalLabel!==!1&&d&&h!==u.ONE_TIME&&e.push({title:c("Recurring subtotal"),money:d,uniqueId:"recurringTotalLabel",subTitle:c("Doesn't include shipping, tax or duties")}),e};return{getMoneyLines:S}};export{useGetMoneyLines};
1
+ import{useI18nStore as e}from"@gem-sdk/core";import{useDynamicProduct as t}from"./useDynamicProduct.js";import{useRecurringSubtotal as i}from"./useRecurringSubtotal.js";import{useProductPriceBreakdown as o}from"./useProductPriceBreakdown.js";import{useSubscriptionSellingType as l}from"./useSubscriptionSellingType.js";let useGetMoneyLines=(u,a)=>{let{isDynamicProduct:s,dynamicPrice:n,dynamicDiscount:r,isEnableDynamicDiscount:p}=t(),{t:b}=e(),c=i(),{isSubscription:d}=l(),{subTotalMoneyFormatted:h,offerDiscountTotal:L,discountMoneyFormatted:m,totalMoneyFormatted:g}=o(),S=()=>{let e=[];return!1!==u.isShowSubTotalLabel&&e.push({title:a.subTotalLabel,money:s?n:h,uniqueId:"subTotalLabel"}),!1!==u.isShowDiscountLabel&&e.push({title:a.discountLabel,money:s&&r&&p?`${r.value}%`:L>0?m:"No discount",uniqueId:"discountLabel"}),!1!==u.isShowShippingLabel&&e.push({title:a.shippingLabel,uniqueId:"shippingLabel",tooltip:{content:"Shipping fee will be calculated on real offer page",width:"23em"}}),!1!==u.isShowTaxesLabel&&e.push({title:a.taxesLabel,uniqueId:"taxesLabel",tooltip:{content:"Taxes will be calculated on real offer page",width:"20em"}}),!1!==u.isShowTotalLabel&&e.push({title:a.totalLabel,money:s?n:g,uniqueId:"totalLabel"}),a?.isShowRecurringTotalLabel!==!1&&c&&d&&e.push({title:b("Recurring subtotal"),money:c,uniqueId:"recurringTotalLabel",subTitle:b("Doesn't include shipping, tax or duties")}),e};return{getMoneyLines:S}};export{useGetMoneyLines};
@@ -1 +1 @@
1
- import{useMemo as e}from"react";import{useProductOfferDiscount as r,useCurrentVariant as l,useProduct as i,useProductStore as t,useQuantity as o,convertDecimalToNumber as n,shopifyPriceRounding as a,useFormatMoney as s}from"@gem-sdk/core";import{calculateSellingPlanDiscount as p}from"../helpers/product-price-breakdown/getPrice.js";import{SubscriptionEnum as c}from"../constants/index.js";let useProductPriceBreakdown=()=>{let u=r(),P=l(),m=i(),d=t(e=>e.selectedSellingPlan),f=t(e=>e.subscriptionSellingType),{quantity:g}=o(),F=e(()=>{if(!d||f===c.ONE_TIME)return null;let e=P?.sellingPlanGroups??m?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){let e=r.sellingPlans.find(e=>e?.baseID===d);if(e)return e}return null},[P,m,d,f]),k=n(P?.price)??0,x=e(()=>!F||k<=0?0:p({variantPrice:k,pricingPolicies:F.pricingPolicies}),[F,k]),b=Math.max(0,parseFloat(a(k-x,2))),h=Math.max(0,parseFloat(a(b*(g||1),2))),w=s(h,!1),M=u*(g||1),j=parseFloat(a(M,2)),B=s(j,!1),E=a(j,2),G=parseFloat(a(h-parseFloat(E),2)),I=s(G>0?G:0,!1);return{price:k,sellingPlanDiscountPerUnit:x,priceAfterSellingPlanDiscount:b,subTotal:h,subTotalMoneyFormatted:w,offerDiscountTotal:M,discountWithQuantity:j,discountMoneyFormatted:B,totalMoneyFormatted:I}};export{useProductPriceBreakdown};
1
+ import{useMemo as e}from"react";import{useProductOfferDiscount as r,useCurrentVariant as l,useProduct as i,useProductStore as t,useQuantity as o,convertDecimalToNumber as a,shopifyPriceRounding as n,useFormatMoney as s}from"@gem-sdk/core";import{calculateSellingPlanDiscount as p}from"../helpers/product-price-breakdown/getPrice.js";import{useSubscriptionSellingType as c}from"./useSubscriptionSellingType.js";let useProductPriceBreakdown=()=>{let u=r(),P=l(),m=i(),f=t(e=>e.selectedSellingPlan),{isOneTime:g}=c(),{quantity:d}=o(),F=e(()=>{if(!f||g)return null;let e=P?.sellingPlanGroups??m?.sellingPlanGroups??[];for(let r of e)if(r?.sellingPlans){let e=r.sellingPlans.find(e=>e?.baseID===f);if(e)return e}return null},[P,m,f,g]),k=a(P?.price)??0,b=e(()=>!F||k<=0?0:p({variantPrice:k,pricingPolicies:F.pricingPolicies}),[F,k]),h=Math.max(0,parseFloat(n(k-b,2))),w=Math.max(0,parseFloat(n(h*(d||1),2))),x=s(w,!1),S=u*(d||1),j=parseFloat(n(S,2)),B=s(j,!1),G=n(j,2),M=parseFloat(n(w-parseFloat(G),2)),v=s(M>0?M:0,!1);return{price:k,sellingPlanDiscountPerUnit:b,priceAfterSellingPlanDiscount:h,subTotal:w,subTotalMoneyFormatted:x,offerDiscountTotal:S,discountWithQuantity:j,discountMoneyFormatted:B,totalMoneyFormatted:v}};export{useProductPriceBreakdown};
@@ -1 +1 @@
1
- import{useProductStore as e,usePageStore as t,useProduct as n,useVariants as r}from"@gem-sdk/core";import{useMemo as s}from"react";import{SubscriptionEnum as o}from"../constants/index.js";import{checkDefaultVariant as i}from"../../../product/helpers/product.js";import{useBuyerConsentChecked as l}from"../../buyer-consent/hooks/useBuyerConsentChecked.js";let useSubscriptionConsentCheck=()=>{let{checked:u}=l(),p=e(e=>e.selectedOptions),c=e(e=>e.subscriptionSellingType),d=t(e=>e.getSubscriptionVisible()),m=n(),g=r(),f=s(()=>{let e=c===o.ONE_TIME,t=!d?.[m?.id??""]?.length;if(u||e||t)return!1;let n=!!m?.sellingPlanGroups?.length||!!m?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!n||!p)return!1;let r=i(m);if(!r){let e=g.find(e=>e?.selectedOptions.every(e=>p[e.name??""]===e.value)),t=!!e?.sellingPlanGroups?.length;return t}return!0},[p,c,u,m,g]);return{isDisableAccept:f}};export{useSubscriptionConsentCheck};
1
+ import{useProductStore as e,usePageStore as t,useProduct as r,useVariants as n}from"@gem-sdk/core";import{useMemo as s}from"react";import{checkDefaultVariant as i}from"../../../product/helpers/product.js";import{useBuyerConsentChecked as o}from"../../buyer-consent/hooks/useBuyerConsentChecked.js";import{useSubscriptionSellingType as l}from"./useSubscriptionSellingType.js";let useSubscriptionConsentCheck=()=>{let{checked:u}=o(),p=e(e=>e.selectedOptions),{isOneTime:c}=l(),m=t(e=>e.getSubscriptionVisible()),d=r(),g=n(),f=s(()=>{let e=!m?.[d?.id??""]?.length;if(u||c||e)return!1;let t=!!d?.sellingPlanGroups?.length||!!d?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!t||!p)return!1;let r=i(d);if(!r){let e=g.find(e=>e?.selectedOptions.every(e=>p[e.name??""]===e.value)),t=!!e?.sellingPlanGroups?.length;return t}return!0},[p,c,u,d,g]);return{isDisableAccept:f}};export{useSubscriptionConsentCheck};
@@ -0,0 +1 @@
1
+ import{useMemo as e}from"react";import{useProductStore as i}from"@gem-sdk/core";import{SubscriptionEnum as r}from"../constants/index.js";let useSubscriptionSellingType=()=>{let t=i(e=>e.subscriptionSellingType);return e(()=>({isOneTime:t===r.ONE_TIME,isSubscription:t===r.SUBSCRIPTION,subscriptionSellingType:t}),[t])};export{useSubscriptionSellingType};
@@ -1 +1 @@
1
- import"react/jsx-runtime";import"@gem-sdk/core";import"@gem-sdk/system";import"react";import"./components/product-subscription/types.js";import"./components/product-variant/components/variants/VariantItem.js";import"next/link";import"./constants/index.js";import"next/head";import"next/image";import"react-youtube";import"./components/product-subscription/components/OneTimePurchaseTooltip.js";import"../image/components/Img.js";import t from"./settings/product-title/ProductTitle.js";import o from"./settings/product-description/ProductDescription.js";import r from"./settings/product-price/ProductPrice.js";import s from"./settings/product-variants/ProductVariant.js";import i from"./settings/accept-button/index.js";import e from"./settings/product-quantity/index.js";import c from"./settings/product-offer/index.js";import n from"./settings/product-price-breakdown/index.js";import p from"./settings/product-discount-tag/ProductDiscountTag.js";import u from"./settings/product-subscription/index.js";import m from"./settings/product-image/ProductImages.js";let postPurchaseProductSetting={PostPurchaseProductTitle:t,PostPurchaseProductDescription:o,PostPurchaseProductPrice:r,PostPurchaseProductVariants:s,PostPurchaseAcceptButton:i,PostPurchaseProductQuantity:e,PostPurchaseProductPriceBreakdown:n,PostPurchaseProductOffer:c,PostPurchaseProductDiscountTag:p,PostPurchaseProductImages:m,PostPurchaseProductSubscription:u};export{postPurchaseProductSetting};
1
+ import"react/jsx-runtime";import"@gem-sdk/core";import"@gem-sdk/system";import"react";import"./components/product-subscription/types.js";import"./constants/index.js";import"./components/product-variant/components/variants/VariantItem.js";import"next/link";import"next/head";import"next/image";import"react-youtube";import"./components/product-subscription/components/OneTimePurchaseTooltip.js";import"../image/components/Img.js";import t from"./settings/product-title/ProductTitle.js";import o from"./settings/product-description/ProductDescription.js";import r from"./settings/product-price/ProductPrice.js";import s from"./settings/product-variants/ProductVariant.js";import i from"./settings/accept-button/index.js";import e from"./settings/product-quantity/index.js";import c from"./settings/product-offer/index.js";import n from"./settings/product-price-breakdown/index.js";import p from"./settings/product-discount-tag/ProductDiscountTag.js";import u from"./settings/product-subscription/index.js";import m from"./settings/product-image/ProductImages.js";let postPurchaseProductSetting={PostPurchaseProductTitle:t,PostPurchaseProductDescription:o,PostPurchaseProductPrice:r,PostPurchaseProductVariants:s,PostPurchaseAcceptButton:i,PostPurchaseProductQuantity:e,PostPurchaseProductPriceBreakdown:n,PostPurchaseProductOffer:c,PostPurchaseProductDiscountTag:p,PostPurchaseProductImages:m,PostPurchaseProductSubscription:u};export{postPurchaseProductSetting};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "12.0.0-dev.98",
3
+ "version": "12.0.0-dev.99",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",