@gem-sdk/components 12.0.0-dev.103 → 12.0.0-dev.104
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/buyer-consent/components/BuyerConsent.js +1 -1
- package/dist/cjs/post-purchase/buyer-consent/hooks/useBuyerConsentVisibility.js +1 -0
- package/dist/cjs/post-purchase/product/components/product-subscription/ProductSubscription.js +1 -1
- package/dist/cjs/post-purchase/product/hooks/useSubscriptionConsentCheck.js +1 -1
- package/dist/esm/post-purchase/buyer-consent/components/BuyerConsent.js +1 -1
- package/dist/esm/post-purchase/buyer-consent/hooks/useBuyerConsentVisibility.js +1 -0
- package/dist/esm/post-purchase/product/components/product-subscription/ProductSubscription.js +1 -1
- package/dist/esm/post-purchase/product/hooks/useSubscriptionConsentCheck.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),system=require("@gem-sdk/system"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),helpers=require("../common/helpers.js"),core=require("@gem-sdk/core"),PostPurchaseCheckbox=require("./PostPurchaseCheckbox.js"),useBuyerConsentChecked=require("../hooks/useBuyerConsentChecked.js");const COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:e,builderProps:s,setting:t,builderAttrs:r,style:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),system=require("@gem-sdk/system"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),helpers=require("../common/helpers.js"),core=require("@gem-sdk/core"),useBuyerConsentVisibility=require("../hooks/useBuyerConsentVisibility.js"),PostPurchaseCheckbox=require("./PostPurchaseCheckbox.js"),useBuyerConsentChecked=require("../hooks/useBuyerConsentChecked.js");const COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:e,builderProps:s,setting:t,builderAttrs:r,style:i,children:l})=>{let{isEditMode:n}=core.useRenderMode(),o=core.useProduct(),{checked:c,setChecked:u}=useBuyerConsentChecked.useBuyerConsentChecked(),{isHide:a}=useBuyerConsentVisibility.useBuyerConsentVisibility(),{description:y,policyLabel:d,policyLink:m,align:C}=t??{},h=o?.id?`buyer-consent-product-${s?.uid}-${o.id}`:void 0,x=helpers.getComponentTag(m),j=system.createStyle(styles.getWrapperStyles({styles:e})),k=system.createClass(classes.getWrapperClassName({align:C,uid:s?.uid})),b=system.createStyle(styles.getContainerStyles({styles:e})),p=system.createClass(classes.getCheckboxContainerClassName()),g=system.createStyle(styles.getTextStyle({styles:e})),P=system.createClass(classes.getLinkComponentClassName()),B=system.createStyle(classes.getLinkComponentStyles()),q=e=>{u(e.target.checked)},R=!n&&a;return R?null:jsxRuntime.jsxs("div",{...r,style:{...i},children:[jsxRuntime.jsx("div",{"data-id":s?.uid,style:j,className:k,children:jsxRuntime.jsxs("label",{htmlFor:h,dir:e?.direction??"ltr",style:b,className:p,children:[jsxRuntime.jsx(PostPurchaseCheckbox.default,{id:h,name:h,type:"checkbox",checked:c,onChange:q}),jsxRuntime.jsxs("bdo",{dir:e?.direction??"ltr",style:g,children:[y," ",jsxRuntime.jsx(x,{target:"_blank",rel:"noreferrer",href:m,className:P,style:B,children:d})]})]})}),core.filterToolbarPreview(l,!0)]})};exports.default=BuyerConsent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),React=require("react");const useBuyerConsentVisibility=()=>{let e=core.useProduct(),i=core.useProductStore(e=>e.uid),r=core.usePageStore(e=>e.subscriptionVisible),t=({productId:e,subscriptionVisibility:i})=>{if(!e)return!1;let r=i?.[e];return!r?.length},s=({productId:e,productOfferUid:i,subscriptionVisibility:r})=>{if(!e)return!1;let t=r?.[e];return!t?.includes(`${i??""}-${e}`)},u=React.useMemo(()=>{let u=e?.id??"",n=!!e?.requiresSellingPlan,l=n?t({productId:u,subscriptionVisibility:r}):s({productId:u,productOfferUid:i,subscriptionVisibility:r});return l},[e?.id,e?.requiresSellingPlan,i,r]);return{isHide:u}};exports.useBuyerConsentVisibility=useBuyerConsentVisibility;
|
package/dist/cjs/post-purchase/product/components/product-subscription/ProductSubscription.js
CHANGED
|
@@ -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:i,builderProps:s,builderAttrs:n,style:t,children:l})=>{let r=core.useProduct(),o=core.usePageStore(e=>e.setSubscriptionVisible),u=core.usePageStore(e=>e.getSubscriptionVisible),{defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d}=useSellingSubscription.useSellingSubscription(i),S=useSellingPlanOptions.useSellingPlanOptions(i),{selectedValue:
|
|
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:i,builderProps:s,builderAttrs:n,style:t,children:l})=>{let r=core.useProduct(),o=core.usePageStore(e=>e.setSubscriptionVisible),u=core.usePageStore(e=>e.getSubscriptionVisible),{defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d}=useSellingSubscription.useSellingSubscription(i),S=useSellingPlanOptions.useSellingPlanOptions(i),p=core.useProductStore(e=>e.uid),{selectedValue:m,handleSellingPlanChange:g}=useSellingPlanChange.useSellingPlanChange({defaultValue:a,selectedSellingPlan:c,setSelectedSellingPlan:d,sellingPlanOptions:S}),j=React.useRef(null),b=React.useId(),{selectedType:x,shouldShowRadio:P,isOneTimeHidden:R,hasNoSellingPlanOptions:y,setSubscriptionSellingType:h}=useSubscriptionVisibility.useSubscriptionVisibility({setting:i}),T=system.createStyle(styles.getSubscriptionStyles(e,P)),O=system.createStyle(styles.getSubscriptionWrapperStyles(e?.align)),q=system.createClass(classes.getWrapperClasses()),C=system.createClass(classes.getContainerClasses()),E=system.createStyle({...t}),{isEditMode:I}=core.useRenderMode(),N=`product-subscription-${r?.baseID}`,D=r?.baseID,v=`subscription-type-selection-${b}`,f=i?.sellingType===index.SubscriptionEnum.ONE_TIME,k=i?.sellingType===index.SubscriptionEnum.SUBSCRIPTION,{isDynamicProduct:w}=useDynamicProduct.useDynamicProduct();if(React.useEffect(()=>{if(!r?.id||!k)return;let e=r?.id,i=`${p}-${e}`,s=!(y||w),n=u()??{};if(!s){o({...n,[e]:(n[e]??[]).filter(e=>e!==i)});return}o({...n,[e]:[...n[e]??[],i]})},[p,u,y,w,k,r?.id,o]),R||y||w)return I?jsxRuntime.jsxs("div",{...n,style:E,children:[jsxRuntime.jsx(OneTimePurchaseTooltip.OneTimePurchaseTooltip,{ref:j,setting:i}),core.filterToolbarPreview(l,!0)]}):null;let L=e=>jsxRuntime.jsxs("div",{...n,style:E,children:[jsxRuntime.jsx("div",{ref:j,"data-selling-type":i?.sellingType,id:N,className:q,style:O,children:e}),core.filterToolbarPreview(l,!0)]}),V=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:i?.sellingStyle==="radio"?jsxRuntime.jsx(SellingPlanRadio.SellingPlanRadio,{setting:i,styles:e,builderProps:s,productId:D??"",sellingPlanOptions:S,selectedValue:m,isShowRadio:P,onChange:g}):jsxRuntime.jsx(SellingPlanDropdown.SellingPlanDropdown,{setting:i,styles:e,sellingPlanOptions:S,selectedValue:m,isShowRadio:P,onChange:g})});return L(f&&P?jsxRuntime.jsx("div",{className:C,style:T,children:jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${D}-one-time-radio`,name:v,value:index.SubscriptionEnum.ONE_TIME,checked:x===index.SubscriptionEnum.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&h(index.SubscriptionEnum.ONE_TIME)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:i,styles:e,isShowRadio:P})})}):k&&P?jsxRuntime.jsxs("div",{className:C,style:T,children:[jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${D}-subscription-radio`,name:v,value:index.SubscriptionEnum.SUBSCRIPTION,checked:x===index.SubscriptionEnum.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&h(index.SubscriptionEnum.SUBSCRIPTION)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:i,styles:e,isShowRadio:P})}),x===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:i,styles:e})})]})]}):jsxRuntime.jsxs("div",{className:C,style:T,children:[jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:i,styles:e,isShowRadio:P}),k&&V(),k&&jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:i,styles:e})]}))};exports.default=ProductSubscription;
|
|
@@ -1 +1 @@
|
|
|
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(),
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),React=require("react"),product=require("../../../product/helpers/product.js"),useBuyerConsentVisibility=require("../../buyer-consent/hooks/useBuyerConsentVisibility.js"),useBuyerConsentChecked=require("../../buyer-consent/hooks/useBuyerConsentChecked.js"),useSubscriptionSellingType=require("./useSubscriptionSellingType.js");const useSubscriptionConsentCheck=()=>{let{checked:e}=useBuyerConsentChecked.useBuyerConsentChecked(),s=core.useProductStore(e=>e.selectedOptions),{isOneTime:r}=useSubscriptionSellingType.useSubscriptionSellingType(),n=core.useProduct(),u=core.useVariants(),{isHide:i}=useBuyerConsentVisibility.useBuyerConsentVisibility(),t=React.useMemo(()=>{if(e||r||i)return!1;let t=!!n?.sellingPlanGroups?.length||!!n?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!t||!s)return!1;let o=product.checkDefaultVariant(n);if(!o){let e=u.find(e=>e?.selectedOptions.every(e=>s[e.name??""]===e.value)),r=!!e?.sellingPlanGroups?.length;return r}return!0},[s,r,e,i,n,u]);return{isDisableAccept:t}};exports.useSubscriptionConsentCheck=useSubscriptionConsentCheck;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{createStyle as o,createClass as t}from"@gem-sdk/system";import{getWrapperStyles as s,getContainerStyles as i,getTextStyle as
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{createStyle as o,createClass as t}from"@gem-sdk/system";import{getWrapperStyles as s,getContainerStyles as i,getTextStyle as m}from"../common/styles.js";import{getWrapperClassName as d,getCheckboxContainerClassName as n,getLinkComponentClassName as c,getLinkComponentStyles as l}from"../common/classes.js";import{getComponentTag as a}from"../common/helpers.js";import{useRenderMode as u,useProduct as h,filterToolbarPreview as y}from"@gem-sdk/core";import{useBuyerConsentVisibility as p}from"../hooks/useBuyerConsentVisibility.js";import f from"./PostPurchaseCheckbox.js";import{useBuyerConsentChecked as k}from"../hooks/useBuyerConsentChecked.js";let COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:b,builderProps:C,setting:j,builderAttrs:g,style:N,children:x})=>{let{isEditMode:B}=u(),P=h(),{checked:v,setChecked:_}=k(),{isHide:E}=p(),{description:F,policyLabel:I,policyLink:O,align:$}=j??{},D=P?.id?`buyer-consent-product-${C?.uid}-${P.id}`:void 0,H=a(O),M=o(s({styles:b})),R=t(d({align:$,uid:C?.uid})),T=o(i({styles:b})),V=t(n()),X=o(m({styles:b})),q=t(c()),w=o(l()),z=e=>{_(e.target.checked)},A=!B&&E;return A?null:e("div",{...g,style:{...N},children:[r("div",{"data-id":C?.uid,style:M,className:R,children:e("label",{htmlFor:D,dir:b?.direction??"ltr",style:T,className:V,children:[r(f,{id:D,name:D,type:"checkbox",checked:v,onChange:z}),e("bdo",{dir:b?.direction??"ltr",style:X,children:[F," ",r(H,{target:"_blank",rel:"noreferrer",href:O,className:q,style:w,children:I})]})]})}),y(x,!0)]})};export{BuyerConsent as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useProduct as i,useProductStore as e,usePageStore as r}from"@gem-sdk/core";import{useMemo as t}from"react";let useBuyerConsentVisibility=()=>{let n=i(),s=e(i=>i.uid),l=r(i=>i.subscriptionVisible),u=({productId:i,subscriptionVisibility:e})=>{if(!i)return!1;let r=e?.[i];return!r?.length},o=({productId:i,productOfferUid:e,subscriptionVisibility:r})=>{if(!i)return!1;let t=r?.[i];return!t?.includes(`${e??""}-${i}`)},b=t(()=>{let i=n?.id??"",e=!!n?.requiresSellingPlan,r=e?u({productId:i,subscriptionVisibility:l}):o({productId:i,productOfferUid:s,subscriptionVisibility:l});return r},[n?.id,n?.requiresSellingPlan,s,l]);return{isHide:b}};export{useBuyerConsentVisibility};
|
package/dist/esm/post-purchase/product/components/product-subscription/ProductSubscription.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as i,Fragment as s}from"react/jsx-runtime";import{useProduct as t,usePageStore as o,
|
|
1
|
+
import{jsxs as e,jsx as i,Fragment as s}from"react/jsx-runtime";import{useProduct as t,usePageStore as o,useProductStore as l,useRenderMode as n,filterToolbarPreview as r}from"@gem-sdk/core";import{createStyle as m,createClass as a}from"@gem-sdk/system";import{useRef as c,useId as d,useEffect as p}from"react";import{SubscriptionEnum as g}from"../../constants/index.js";import{getWrapperClasses as u,getContainerClasses as h}from"./common/classes.js";import{getSubscriptionStyles as S,getSubscriptionWrapperStyles as f}from"./common/styles.js";import{useSellingPlanChange as y}from"./hooks/useSellingPlanChange.js";import{useSellingSubscription as b}from"./hooks/useSellingSubscription.js";import{useSellingPlanOptions as I}from"./hooks/useSellingPlanOptions.js";import{useSubscriptionVisibility as N}from"./hooks/useSubscriptionVisibility.js";import{OneTimePurchaseTooltip as P}from"./components/OneTimePurchaseTooltip.js";import{SellingPlanDropdown as j}from"./components/SellingPlanDropdown.js";import{SellingPlanLabel as T}from"./components/SellingPlanLabel.js";import{SellingPlanRadio as O}from"./components/SellingPlanRadio.js";import{SubscriptionDetail as R}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:w,builderAttrs:$,style:B,children:D})=>{let U=t(),V=o(e=>e.setSubscriptionVisible),M=o(e=>e.getSubscriptionVisible),{defaultValue:_,selectedSellingPlan:x,setSelectedSellingPlan:L}=b(E),q=I(E),z=l(e=>e.uid),{selectedValue:A,handleSellingPlanChange:F}=y({defaultValue:_,selectedSellingPlan:x,setSelectedSellingPlan:L,sellingPlanOptions:q}),G=c(null),H=d(),{selectedType:J,shouldShowRadio:K,isOneTimeHidden:Q,hasNoSellingPlanOptions:W,setSubscriptionSellingType:X}=N({setting:E}),Y=m(S(C,K)),Z=m(f(C?.align)),ee=a(u()),ei=a(h()),es=m({...B}),{isEditMode:et}=n(),eo=`product-subscription-${U?.baseID}`,el=U?.baseID,en=`subscription-type-selection-${H}`,er=E?.sellingType===g.ONE_TIME,em=E?.sellingType===g.SUBSCRIPTION,{isDynamicProduct:ea}=v();if(p(()=>{if(!U?.id||!em)return;let e=U?.id,i=`${z}-${e}`,s=!(W||ea),t=M()??{};if(!s){V({...t,[e]:(t[e]??[]).filter(e=>e!==i)});return}V({...t,[e]:[...t[e]??[],i]})},[z,M,W,ea,em,U?.id,V]),Q||W||ea)return et?e("div",{...$,style:es,children:[i(P,{ref:G,setting:E}),r(D,!0)]}):null;let ec=s=>e("div",{...$,style:es,children:[i("div",{ref:G,"data-selling-type":E?.sellingType,id:eo,className:ee,style:Z,children:s}),r(D,!0)]}),ed=()=>i(s,{children:E?.sellingStyle==="radio"?i(O,{setting:E,styles:C,builderProps:w,productId:el??"",sellingPlanOptions:q,selectedValue:A,isShowRadio:K,onChange:F}):i(j,{setting:E,styles:C,sellingPlanOptions:q,selectedValue:A,isShowRadio:K,onChange:F})});return ec(er&&K?i("div",{className:ei,style:Y,children:i(k,{id:`${el}-one-time-radio`,name:en,value:g.ONE_TIME,checked:J===g.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&X(g.ONE_TIME)},children:i(T,{setting:E,styles:C,isShowRadio:K})})}):em&&K?e("div",{className:ei,style:Y,children:[i(k,{id:`${el}-subscription-radio`,name:en,value:g.SUBSCRIPTION,checked:J===g.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&X(g.SUBSCRIPTION)},children:i(T,{setting:E,styles:C,isShowRadio:K})}),J===g.SUBSCRIPTION&&e(s,{children:[i("div",{className:"gp-pl-7",children:ed()}),i("div",{className:"gp-pl-7",children:i(R,{setting:E,styles:C})})]})]}):e("div",{className:ei,style:Y,children:[i(T,{setting:E,styles:C,isShowRadio:K}),em&&ed(),em&&i(R,{setting:E,styles:C})]}))};export{ProductSubscription as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useProductStore as e,
|
|
1
|
+
import{useProductStore as e,useProduct as r,useVariants as n}from"@gem-sdk/core";import{useMemo as t}from"react";import{checkDefaultVariant as s}from"../../../product/helpers/product.js";import{useBuyerConsentVisibility as o}from"../../buyer-consent/hooks/useBuyerConsentVisibility.js";import{useBuyerConsentChecked as i}from"../../buyer-consent/hooks/useBuyerConsentChecked.js";import{useSubscriptionSellingType as l}from"./useSubscriptionSellingType.js";let useSubscriptionConsentCheck=()=>{let{checked:u}=i(),p=e(e=>e.selectedOptions),{isOneTime:c}=l(),m=r(),d=n(),{isHide:f}=o(),h=t(()=>{if(u||c||f)return!1;let e=!!m?.sellingPlanGroups?.length||!!m?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!e||!p)return!1;let r=s(m);if(!r){let e=d.find(e=>e?.selectedOptions.every(e=>p[e.name??""]===e.value)),r=!!e?.sellingPlanGroups?.length;return r}return!0},[p,c,u,f,m,d]);return{isDisableAccept:h}};export{useSubscriptionConsentCheck};
|