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

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.
@@ -0,0 +1 @@
1
+ "use strict";const DEFAULT_BUYER_CONSENT_CHECKED_VALUE=!0;exports.DEFAULT_BUYER_CONSENT_CHECKED_VALUE=!0;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),React=require("react"),system=require("@gem-sdk/system"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),helpers$1=require("../common/helpers.js"),core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),PostPurchaseCheckbox=require("./PostPurchaseCheckbox.js");const DEFAULT_PRE_CHECK_VALUE=!0,COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:e,builderProps:s,setting:t,builderAttrs:r,style:l,children:c})=>{console.log("children",c);let{isEditMode:o}=core.useRenderMode(),a=core.useProduct(),n=core.usePageStore(e=>e.buyerConsentChecked),i=core.usePageStore(e=>e.setBuyerConsentChecked),u=core.usePageStore(e=>e.subscriptionVisible),{description:d,policyLabel:y,policyLink:m,align:h}=t??{},C=a?.id?`buyer-consent-product-${s?.uid}-${a.id}`:void 0,x=helpers$1.getComponentTag(m),j=system.createStyle(styles.getWrapperStyles({styles:e})),p=system.createClass(classes.getWrapperClassName({align:h,uid:s?.uid})),g=system.createStyle(styles.getContainerStyles({styles:e})),b=system.createClass(classes.getCheckboxContainerClassName()),P=system.createStyle(styles.getTextStyle({styles:e})),k=system.createClass(classes.getLinkComponentClassName()),R=system.createStyle(classes.getLinkComponentStyles()),S=React.useMemo(()=>helpers.extractProductID(a?.baseID??""),[a?.baseID]),q=React.useMemo(()=>{let e=`${S}`;return n?.[e]??!0},[n,S]),N=e=>{let s=`${S}`,t={...n,[s]:e.target.checked};i(t)},_=!o&&!u?.[a?.id??""];return _?null:jsxRuntime.jsxs("div",{...r,style:{...l},children:[jsxRuntime.jsx("div",{"data-id":s?.uid,style:j,className:p,children:jsxRuntime.jsxs("label",{htmlFor:C,dir:e?.direction??"ltr",style:g,className:b,children:[jsxRuntime.jsx(PostPurchaseCheckbox.default,{id:C,name:C,type:"checkbox",checked:q,onChange:N}),jsxRuntime.jsxs("bdo",{dir:e?.direction??"ltr",style:P,children:[d," ",jsxRuntime.jsx(x,{target:"_blank",rel:"noreferrer",href:m,className:k,style:R,children:y})]})]})}),core.filterToolbarPreview(c,!0)]})};exports.default=BuyerConsent;
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:l,children:c})=>{let{isEditMode:n}=core.useRenderMode(),o=core.useProduct(),{checked:a,setChecked:i}=useBuyerConsentChecked.useBuyerConsentChecked(),u=core.usePageStore(e=>e.subscriptionVisible),{description:y,policyLabel:d,policyLink:m,align:h}=t??{},C=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:h,uid:s?.uid})),p=system.createStyle(styles.getContainerStyles({styles:e})),g=system.createClass(classes.getCheckboxContainerClassName()),b=system.createStyle(styles.getTextStyle({styles:e})),P=system.createClass(classes.getLinkComponentClassName()),R=system.createStyle(classes.getLinkComponentStyles()),S=e=>{i(e.target.checked)},q=!n&&!u?.[o?.id??""]?.length;return q?null:jsxRuntime.jsxs("div",{...r,style:{...l},children:[jsxRuntime.jsx("div",{"data-id":s?.uid,style:j,className:k,children:jsxRuntime.jsxs("label",{htmlFor:C,dir:e?.direction??"ltr",style:p,className:g,children:[jsxRuntime.jsx(PostPurchaseCheckbox.default,{id:C,name:C,type:"checkbox",checked:a,onChange:S}),jsxRuntime.jsxs("bdo",{dir:e?.direction??"ltr",style:b,children:[y," ",jsxRuntime.jsx(x,{target:"_blank",rel:"noreferrer",href:m,className:P,style:R,children:d})]})]})}),core.filterToolbarPreview(c,!0)]})};exports.default=BuyerConsent;
@@ -0,0 +1 @@
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),constants=require("../common/constants.js");const useBuyerConsentChecked=()=>{let e=core.useProduct(),t=core.useProductStore(e=>e.uid),r=!!e?.requiresSellingPlan,s=core.usePageStore(e=>e.buyerConsentChecked),c=core.usePageStore(e=>e.setBuyerConsentChecked),o=core.usePageStore(e=>e.getBuyerConsentChecked),u=helpers.extractProductID(e?.baseID??""),n=s?.[u],C=React.useMemo(()=>{let e=r?u:`${u}_${t}`;return e},[r,u,t]),a=s?.[C]??constants.DEFAULT_BUYER_CONSENT_CHECKED_VALUE,E=e=>{let t=o();c({...t,[C]:e})};return React.useEffect(()=>{void 0!==n&&E(n)},[n]),React.useEffect(()=>{0===Object.keys(s??{}).length&&E(constants.DEFAULT_BUYER_CONSENT_CHECKED_VALUE)},[s]),{checked:a,setChecked:E}};exports.useBuyerConsentChecked=useBuyerConsentChecked;
@@ -1 +1 @@
1
- "use strict";require("react/jsx-runtime"),require("react"),require("@gem-sdk/system"),require("@gem-sdk/core"),require("next/link");var BuyerConsent$1=require("./settings/BuyerConsent.js");const postPurchaseBuyerConsentSetting={PostPurchaseBuyerConsent:BuyerConsent$1.default};exports.postPurchaseBuyerConsentSetting=postPurchaseBuyerConsentSetting;
1
+ "use strict";require("react/jsx-runtime"),require("@gem-sdk/system"),require("@gem-sdk/core"),require("react"),require("next/link");var BuyerConsent$1=require("./settings/BuyerConsent.js");const postPurchaseBuyerConsentSetting={PostPurchaseBuyerConsent:BuyerConsent$1.default};exports.postPurchaseBuyerConsentSetting=postPurchaseBuyerConsentSetting;
@@ -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),{defaultValue:o,selectedSellingPlan:a,setSelectedSellingPlan:c}=useSellingSubscription.useSellingSubscription(s),d=useSellingPlanOptions.useSellingPlanOptions(s),{selectedValue:S,handleSellingPlanChange:p}=useSellingPlanChange.useSellingPlanChange({defaultValue:o,selectedSellingPlan:a,setSelectedSellingPlan:c,sellingPlanOptions:d}),m=React.useRef(null),g=React.useId(),{selectedType:j,shouldShowRadio:x,isOneTimeHidden:b,hasNoSellingPlanOptions:P,setSubscriptionSellingType:y}=useSubscriptionVisibility.useSubscriptionVisibility({setting:s}),R=system.createStyle(styles.getSubscriptionStyles(e)),h=system.createStyle(styles.getSubscriptionWrapperStyles(e?.align)),T=system.createClass(classes.getWrapperClasses()),O=system.createClass(classes.getContainerClasses()),I=system.createStyle({...t}),{isEditMode:q}=core.useRenderMode(),C=`product-subscription-${r?.baseID}`,E=r?.baseID,D=`subscription-type-selection-${g}`,N=s?.sellingType===index.SubscriptionEnum.ONE_TIME,v=s?.sellingType===index.SubscriptionEnum.SUBSCRIPTION,{isDynamicProduct:k}=useDynamicProduct.useDynamicProduct();if(React.useEffect(()=>{r?.id&&v&&!q&&u({productID:r.id,isShow:!(P||k)})},[P,k,q,v,r?.id,u]),b||P||k)return q?jsxRuntime.jsxs("div",{...n,style:I,children:[jsxRuntime.jsx(OneTimePurchaseTooltip.OneTimePurchaseTooltip,{ref:m,setting:s}),core.filterToolbarPreview(l,!0)]}):null;let f=e=>jsxRuntime.jsxs("div",{...n,style:I,children:[jsxRuntime.jsx("div",{ref:m,"data-selling-type":s?.sellingType,id:C,className:T,style:h,children:e}),core.filterToolbarPreview(l,!0)]}),L=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:s?.sellingStyle==="radio"?jsxRuntime.jsx(SellingPlanRadio.SellingPlanRadio,{setting:s,styles:e,builderProps:i,productId:E??"",sellingPlanOptions:d,selectedValue:S,onChange:p}):jsxRuntime.jsx(SellingPlanDropdown.SellingPlanDropdown,{setting:s,sellingPlanOptions:d,selectedValue:S,onChange:p})});return f(N&&x?jsxRuntime.jsx("div",{className:O,style:R,children:jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${E}-one-time-radio`,name:D,value:index.SubscriptionEnum.ONE_TIME,checked:j===index.SubscriptionEnum.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&y(index.SubscriptionEnum.ONE_TIME)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e})})}):v&&x?jsxRuntime.jsxs("div",{className:O,style:R,children:[jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{id:`${E}-subscription-radio`,name:D,value:index.SubscriptionEnum.SUBSCRIPTION,checked:j===index.SubscriptionEnum.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&y(index.SubscriptionEnum.SUBSCRIPTION)},children:jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e})}),j===index.SubscriptionEnum.SUBSCRIPTION&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"gp-pl-7",children:L()}),jsxRuntime.jsx("div",{className:"gp-pl-7",children:jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:s,styles:e})})]})]}):jsxRuntime.jsxs("div",{className:O,style:R,children:[jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e}),v&&L(),v&&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||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 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),React=require("react"),index=require("../constants/index.js"),product=require("../../../product/helpers/product.js"),helpers=require("../../../helpers.js");const useSubscriptionConsentCheck=()=>{let e=core.usePageStore(e=>e.buyerConsentChecked),r=core.useProductStore(e=>e.selectedOptions),t=core.useProductStore(e=>e.subscriptionSellingType),s=core.useProduct(),n=core.useVariants(),u=React.useMemo(()=>{let r=helpers.extractProductID(s?.baseID??""),t=`${r}`;return e?.[t]},[e,s?.baseID]),o=React.useMemo(()=>{let e=t===index.SubscriptionEnum.ONE_TIME;if(u||e)return!1;let o=!!s?.sellingPlanGroups?.length||!!s?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!o||!r)return!1;let c=product.checkDefaultVariant(s);if(!c){let e=n.find(e=>e?.selectedOptions.every(e=>r[e.name??""]===e.value)),t=!!e?.sellingPlanGroups?.length;return t}return!0},[r,t,u,s,n]);return{isDisableAccept:o}};exports.useSubscriptionConsentCheck=useSubscriptionConsentCheck;
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;
@@ -0,0 +1 @@
1
+ let DEFAULT_BUYER_CONSENT_CHECKED_VALUE=!0;export{DEFAULT_BUYER_CONSENT_CHECKED_VALUE};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useMemo as t}from"react";import{createStyle as o,createClass as s}from"@gem-sdk/system";import{getWrapperStyles as i,getContainerStyles as l,getTextStyle as c}from"../common/styles.js";import{getWrapperClassName as n,getCheckboxContainerClassName as d,getLinkComponentClassName as m,getLinkComponentStyles as a}from"../common/classes.js";import{getComponentTag as u}from"../common/helpers.js";import{useRenderMode as h,useProduct as p,usePageStore as y,filterToolbarPreview as b}from"@gem-sdk/core";import{extractProductID as f}from"../../../helpers.js";import C from"./PostPurchaseCheckbox.js";let DEFAULT_PRE_CHECK_VALUE=!0,COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:k,builderProps:g,setting:j,builderAttrs:E,style:_,children:N})=>{console.log("children",N);let{isEditMode:P}=h(),x=p(),D=y(e=>e.buyerConsentChecked),I=y(e=>e.setBuyerConsentChecked),$=y(e=>e.subscriptionVisible),{description:v,policyLabel:B,policyLink:F,align:A}=j??{},L=x?.id?`buyer-consent-product-${g?.uid}-${x.id}`:void 0,O=u(F),R=o(i({styles:k})),T=s(n({align:A,uid:g?.uid})),U=o(l({styles:k})),V=s(d()),H=o(c({styles:k})),K=s(m()),M=o(a()),X=t(()=>f(x?.baseID??""),[x?.baseID]),q=t(()=>{let e=`${X}`;return D?.[e]??!0},[D,X]),w=e=>{let r=`${X}`,t={...D,[r]:e.target.checked};I(t)},z=!P&&!$?.[x?.id??""];return z?null:e("div",{...E,style:{..._},children:[r("div",{"data-id":g?.uid,style:R,className:T,children:e("label",{htmlFor:L,dir:k?.direction??"ltr",style:U,className:V,children:[r(C,{id:L,name:L,type:"checkbox",checked:q,onChange:w}),e("bdo",{dir:k?.direction??"ltr",style:H,children:[v," ",r(O,{target:"_blank",rel:"noreferrer",href:F,className:K,style:M,children:B})]})]})}),b(N,!0)]})};export{BuyerConsent as default};
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 d}from"../common/styles.js";import{getWrapperClassName as m,getCheckboxContainerClassName as c,getLinkComponentClassName as l,getLinkComponentStyles as n}from"../common/classes.js";import{getComponentTag as a}from"../common/helpers.js";import{useRenderMode as u,useProduct as h,usePageStore as p,filterToolbarPreview as y}from"@gem-sdk/core";import f from"./PostPurchaseCheckbox.js";import{useBuyerConsentChecked as b}from"../hooks/useBuyerConsentChecked.js";let COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:k,builderProps:C,setting:g,builderAttrs:j,style:N,children:x})=>{let{isEditMode:P}=u(),v=h(),{checked:B,setChecked:_}=b(),E=p(e=>e.subscriptionVisible),{description:F,policyLabel:I,policyLink:O,align:$}=g??{},D=v?.id?`buyer-consent-product-${C?.uid}-${v.id}`:void 0,M=a(O),R=o(s({styles:k})),T=t(m({align:$,uid:C?.uid})),V=o(i({styles:k})),X=t(c()),q=o(d({styles:k})),w=t(l()),z=o(n()),A=e=>{_(e.target.checked)},G=!P&&!E?.[v?.id??""]?.length;return G?null:e("div",{...j,style:{...N},children:[r("div",{"data-id":C?.uid,style:R,className:T,children:e("label",{htmlFor:D,dir:k?.direction??"ltr",style:V,className:X,children:[r(f,{id:D,name:D,type:"checkbox",checked:B,onChange:A}),e("bdo",{dir:k?.direction??"ltr",style:q,children:[F," ",r(M,{target:"_blank",rel:"noreferrer",href:O,className:w,style:z,children:I})]})]})}),y(x,!0)]})};export{BuyerConsent as default};
@@ -0,0 +1 @@
1
+ import{useMemo as e,useEffect as r}from"react";import{useProduct as t,useProductStore as o,usePageStore as n}from"@gem-sdk/core";import{extractProductID as s}from"../../../helpers.js";import{DEFAULT_BUYER_CONSENT_CHECKED_VALUE as m}from"../common/constants.js";let useBuyerConsentChecked=()=>{let u=t(),c=o(e=>e.uid),C=!!u?.requiresSellingPlan,l=n(e=>e.buyerConsentChecked),d=n(e=>e.setBuyerConsentChecked),i=n(e=>e.getBuyerConsentChecked),h=s(u?.baseID??""),k=l?.[h],p=e(()=>{let e=C?h:`${h}_${c}`;return e},[C,h,c]),y=l?.[p]??m,a=e=>{let r=i();d({...r,[p]:e})};return r(()=>{void 0!==k&&a(k)},[k]),r(()=>{0===Object.keys(l??{}).length&&a(m)},[l]),{checked:y,setChecked:a}};export{useBuyerConsentChecked};
@@ -1 +1 @@
1
- import"react/jsx-runtime";import"react";import"@gem-sdk/system";import"@gem-sdk/core";import"next/link";import t from"./settings/BuyerConsent.js";let postPurchaseBuyerConsentSetting={PostPurchaseBuyerConsent:t};export{postPurchaseBuyerConsentSetting};
1
+ import"react/jsx-runtime";import"@gem-sdk/system";import"@gem-sdk/core";import"react";import"next/link";import t from"./settings/BuyerConsent.js";let postPurchaseBuyerConsentSetting={PostPurchaseBuyerConsent:t};export{postPurchaseBuyerConsentSetting};
@@ -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 g,getContainerClasses as u}from"./common/classes.js";import{getSubscriptionStyles as h,getSubscriptionWrapperStyles as S}from"./common/styles.js";import{useSellingPlanChange as f}from"./hooks/useSellingPlanChange.js";import{useSellingSubscription as y}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 b}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:D,style:B,children:U})=>{let M=t(),V=o(e=>e.setSubscriptionVisible),{defaultValue:$,selectedSellingPlan:_,setSelectedSellingPlan:x}=y(E),w=I(E),{selectedValue:L,handleSellingPlanChange:q}=f({defaultValue:$,selectedSellingPlan:_,setSelectedSellingPlan:x,sellingPlanOptions:w}),z=c(null),A=a(),{selectedType:F,shouldShowRadio:G,isOneTimeHidden:H,hasNoSellingPlanOptions:J,setSubscriptionSellingType:K}=N({setting:E}),Q=r(h(C)),W=r(S(C?.align)),X=m(g()),Y=m(u()),Z=r({...B}),{isEditMode:ee}=l(),es=`product-subscription-${M?.baseID}`,ei=M?.baseID,et=`subscription-type-selection-${A}`,eo=E?.sellingType===d.ONE_TIME,el=E?.sellingType===d.SUBSCRIPTION,{isDynamicProduct:en}=v();if(p(()=>{M?.id&&el&&!ee&&V({productID:M.id,isShow:!(J||en)})},[J,en,ee,el,M?.id,V]),H||J||en)return ee?e("div",{...D,style:Z,children:[s(P,{ref:z,setting:E}),n(U,!0)]}):null;let er=i=>e("div",{...D,style:Z,children:[s("div",{ref:z,"data-selling-type":E?.sellingType,id:es,className:X,style:W,children:i}),n(U,!0)]}),em=()=>s(i,{children:E?.sellingStyle==="radio"?s(T,{setting:E,styles:C,builderProps:R,productId:ei??"",sellingPlanOptions:w,selectedValue:L,onChange:q}):s(b,{setting:E,sellingPlanOptions:w,selectedValue:L,onChange:q})});return er(eo&&G?s("div",{className:Y,style:Q,children:s(k,{id:`${ei}-one-time-radio`,name:et,value:d.ONE_TIME,checked:F===d.ONE_TIME,className:"!gp-items-start",onChange:e=>{e.target.checked&&K(d.ONE_TIME)},children:s(j,{setting:E,styles:C})})}):el&&G?e("div",{className:Y,style:Q,children:[s(k,{id:`${ei}-subscription-radio`,name:et,value:d.SUBSCRIPTION,checked:F===d.SUBSCRIPTION,className:"!gp-items-start",onChange:e=>{e.target.checked&&K(d.SUBSCRIPTION)},children:s(j,{setting:E,styles:C})}),F===d.SUBSCRIPTION&&e(i,{children:[s("div",{className:"gp-pl-7",children:em()}),s("div",{className:"gp-pl-7",children:s(O,{setting:E,styles:C})})]})]}):e("div",{className:Y,style:Q,children:[s(j,{setting:E,styles:C}),el&&em(),el&&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||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 +1 @@
1
- import{usePageStore as e,useProductStore as r,useProduct as t,useVariants as n}from"@gem-sdk/core";import{useMemo as s}from"react";import{SubscriptionEnum as o}from"../constants/index.js";import{checkDefaultVariant as l}from"../../../product/helpers/product.js";import{extractProductID as i}from"../../../helpers.js";let useSubscriptionConsentCheck=()=>{let p=e(e=>e.buyerConsentChecked),u=r(e=>e.selectedOptions),c=r(e=>e.subscriptionSellingType),m=t(),a=n(),d=s(()=>{let e=i(m?.baseID??""),r=`${e}`;return p?.[r]},[p,m?.baseID]),f=s(()=>{let e=c===o.ONE_TIME;if(d||e)return!1;let r=!!m?.sellingPlanGroups?.length||!!m?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!r||!u)return!1;let t=l(m);if(!t){let e=a.find(e=>e?.selectedOptions.every(e=>u[e.name??""]===e.value)),r=!!e?.sellingPlanGroups?.length;return r}return!0},[u,c,d,m,a]);return{isDisableAccept:f}};export{useSubscriptionConsentCheck};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "12.0.0-dev.97",
3
+ "version": "12.0.0-dev.98",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -26,7 +26,7 @@
26
26
  "i18n:extract": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/translate/extract-texts-to-locales.js && node ./scripts/translate/en-keys-usage.js"
27
27
  },
28
28
  "devDependencies": {
29
- "@gem-sdk/core": "12.0.0-dev.87",
29
+ "@gem-sdk/core": "12.0.0-dev.98",
30
30
  "@gem-sdk/styles": "12.0.0-dev.86",
31
31
  "@gem-sdk/system": "12.0.0-dev.53",
32
32
  "@types/react-transition-group": "^4.4.12",