@gem-sdk/components 12.0.0-dev.53 → 12.0.0-dev.54

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 +1 @@
1
- "use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const useRecurringSubtotal=()=>{let e=core.useCurrentVariant(),r=core.useProduct(),i=core.useProductStore(e=>e.selectedSellingPlan),{quantity:l}=core.useQuantity(),t=e?.sellingPlanGroups,n=r?.sellingPlanGroups,u=core.convertDecimalToNumber(e?.price)??0,c=React.useMemo(()=>{if(!i)return null;let l=e?.sellingPlanGroups??r?.sellingPlanGroups??[];for(let e of l)if(e?.sellingPlans){for(let r of e.sellingPlans)if(r?.baseID===i)return r}return null},[JSON.stringify(t),JSON.stringify(n),i]),o=JSON.stringify(c?.pricingPolicies),s=JSON.stringify(c?.billingPolicy),a=c?.baseID,g=React.useMemo(()=>{if(!a||!e||u<=0||!c)return 0;let r=getPrice.calculateRecurringPrice({variantPrice:u,pricingPolicies:c.pricingPolicies}),i=r*(l||1);return parseFloat(core.shopifyPriceRounding(i,2))},[o,u,l,a]),P=React.useMemo(()=>{if(!a||!c)return null;let e=c.billingPolicy;return getPrice.formatInterval({billingPolicy:e})},[s,a]),f=core.useFormatMoney(g,!1),p=React.useMemo(()=>a&&!(g<=0)&&P?`${f} ${P}`:null,[a,g,P,f]);return p};exports.useRecurringSubtotal=useRecurringSubtotal;
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),getPrice=require("../helpers/product-price-breakdown/getPrice.js");const useRecurringSubtotal=()=>{let e=core.useCurrentVariant(),r=core.useProduct(),i=core.useProductStore(e=>e.selectedSellingPlan),{quantity:l}=core.useQuantity(),t=e?.sellingPlanGroups,n=r?.sellingPlanGroups,u=core.convertDecimalToNumber(e?.price)??0,c=React.useMemo(()=>{if(!i)return null;let l=e?.sellingPlanGroups??r?.sellingPlanGroups??[];for(let e of l)if(e?.sellingPlans){for(let r of e.sellingPlans)if(r?.baseID===i)return r}return null},[JSON.stringify(t),JSON.stringify(n),i]),o=JSON.stringify(c?.pricingPolicies),s=JSON.stringify(c?.billingPolicy),a=c?.baseID,g=React.useMemo(()=>{if(!a||!e||u<=0||!c)return 0;let r=getPrice.calculateRecurringPrice({variantPrice:u,pricingPolicies:c.pricingPolicies}),i=r*(l||1);return parseFloat(core.shopifyPriceRounding(i,2))},[o,u,l,a]),P=React.useMemo(()=>{if(!a||!c)return null;let e=c.billingPolicy;return getPrice.formatInterval({billingPolicy:e})},[s,a]),f=core.useFormatMoney(Math.max(g,0),!1),p=React.useMemo(()=>a&&P?`${f} ${P}`:null,[a,P,f]);return p};exports.useRecurringSubtotal=useRecurringSubtotal;
@@ -1 +1 @@
1
- import{useMemo as l}from"react";import{useCurrentVariant as r,useProduct as e,useProductStore as i,useQuantity as n,convertDecimalToNumber as t,shopifyPriceRounding as s,useFormatMoney as o}from"@gem-sdk/core";import{calculateRecurringPrice as u,formatInterval as g}from"../helpers/product-price-breakdown/getPrice.js";let useRecurringSubtotal=()=>{let c=r(),f=e(),p=i(l=>l.selectedSellingPlan),{quantity:a}=n(),P=c?.sellingPlanGroups,b=f?.sellingPlanGroups,m=t(c?.price)??0,S=l(()=>{if(!p)return null;let l=c?.sellingPlanGroups??f?.sellingPlanGroups??[];for(let r of l)if(r?.sellingPlans){for(let l of r.sellingPlans)if(l?.baseID===p)return l}return null},[JSON.stringify(P),JSON.stringify(b),p]),y=JSON.stringify(S?.pricingPolicies),d=JSON.stringify(S?.billingPolicy),G=S?.baseID,J=l(()=>{if(!G||!c||m<=0||!S)return 0;let l=u({variantPrice:m,pricingPolicies:S.pricingPolicies}),r=l*(a||1);return parseFloat(s(r,2))},[y,m,a,G]),N=l(()=>{if(!G||!S)return null;let l=S.billingPolicy;return g({billingPolicy:l})},[d,G]),O=o(J,!1),k=l(()=>G&&!(J<=0)&&N?`${O} ${N}`:null,[G,J,N,O]);return k};export{useRecurringSubtotal};
1
+ import{useMemo as l}from"react";import{useCurrentVariant as r,useProduct as e,useProductStore as i,useQuantity as n,convertDecimalToNumber as t,shopifyPriceRounding as s,useFormatMoney as o}from"@gem-sdk/core";import{calculateRecurringPrice as u,formatInterval as g}from"../helpers/product-price-breakdown/getPrice.js";let useRecurringSubtotal=()=>{let a=r(),c=e(),f=i(l=>l.selectedSellingPlan),{quantity:p}=n(),P=a?.sellingPlanGroups,m=c?.sellingPlanGroups,b=t(a?.price)??0,S=l(()=>{if(!f)return null;let l=a?.sellingPlanGroups??c?.sellingPlanGroups??[];for(let r of l)if(r?.sellingPlans){for(let l of r.sellingPlans)if(l?.baseID===f)return l}return null},[JSON.stringify(P),JSON.stringify(m),f]),y=JSON.stringify(S?.pricingPolicies),d=JSON.stringify(S?.billingPolicy),G=S?.baseID,J=l(()=>{if(!G||!a||b<=0||!S)return 0;let l=u({variantPrice:b,pricingPolicies:S.pricingPolicies}),r=l*(p||1);return parseFloat(s(r,2))},[y,b,p,G]),N=l(()=>{if(!G||!S)return null;let l=S.billingPolicy;return g({billingPolicy:l})},[d,G]),O=o(Math.max(J,0),!1),h=l(()=>G&&N?`${O} ${N}`:null,[G,N,O]);return h};export{useRecurringSubtotal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "12.0.0-dev.53",
3
+ "version": "12.0.0-dev.54",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",