@gem-sdk/components 17.0.0-dev.30 → 17.0.0-dev.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/post-purchase/product/components/product-offer/components/ProductOfferItem.js +1 -1
- package/dist/cjs/post-purchase/product/components/product-offer/context/PrdOfferSubscriptionPresenceContext.js +2 -0
- package/dist/cjs/post-purchase/product/components/product-offer/helpers/scanSubscriptionBlocks.js +1 -0
- package/dist/cjs/post-purchase/product/components/product-offer/hooks/useProductOfferSubscriptionBlocksObserver.js +1 -0
- package/dist/cjs/post-purchase/product/components/product-subscription/hooks/useSubscriptionVisibility.js +1 -1
- package/dist/esm/post-purchase/product/components/product-offer/components/ProductOfferItem.js +1 -1
- package/dist/esm/post-purchase/product/components/product-offer/context/PrdOfferSubscriptionPresenceContext.js +2 -0
- package/dist/esm/post-purchase/product/components/product-offer/helpers/scanSubscriptionBlocks.js +1 -0
- package/dist/esm/post-purchase/product/components/product-offer/hooks/useProductOfferSubscriptionBlocksObserver.js +1 -0
- package/dist/esm/post-purchase/product/components/product-subscription/hooks/useSubscriptionVisibility.js +1 -1
- package/package.json +1 -1
package/dist/cjs/post-purchase/product/components/product-offer/components/ProductOfferItem.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("@gem-sdk/core")
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("@gem-sdk/core"),t=require("react"),s=require("../../../../../grid/components/row/Row.js"),i=require("../../../../../grid/components/ChildrenDroppable.js"),d=require("@gem-sdk/system"),c=require("../common/attrs.js"),n=require("../common/classes.js"),u=require("../context/PrdOfferSubscriptionPresenceContext.js");exports.ProductOfferItem=o=>{let{product:l,setting:a,builderProps:f,children:m,index:j,totalProduct:x,builderAttrs:P,styles:p}=o,{isEditMode:q}=r.useRenderMode(),{variantSelected:h,productOfferLayout:g,layout:O,...b}=a??{};Object.keys(O||{}).forEach(e=>{g?.[e]==="2col"&&O?.[e]&&(O[e].display="fill")});let v=h?.[l?.baseID??""]?.variantId,y=d.createAttr({...c.getProductOfferAttrs(l,f?.uid)}),C=d.createClass({...n.getProductOfferItemClasses(j,a,x)}),I=t.useRef(null),R=e.jsx("div",{ref:I,...q?{...y}:{},children:e.jsx(s.default,{builderAttrs:P,setting:{...b,layout:O},styles:p,children:r.isEmptyChildren(m)?e.jsx(i.default,{}):m})});return e.jsx("div",{className:C,children:e.jsx(r.ProductProvider,{product:l,readOnly:!0,initialVariantId:v??"Latest",uid:f?.uid,children:q?e.jsx(u.ProductOfferSubscriptionPresenceProvider,{containerRef:I,children:R}):R})},`uid-${l?.id}`)};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),s=require("../hooks/useProductOfferSubscriptionBlocksObserver.js");const t=r.createContext(void 0);exports.ProductOfferSubscriptionPresenceProvider=({children:r,containerRef:o})=>{let u=s.useProductOfferSubscriptionBlocksObserver(o);return e.jsx(t.Provider,{value:u,children:r})},exports.useProductOfferSubscriptionPresence=()=>r.useContext(t);
|
package/dist/cjs/post-purchase/product/components/product-offer/helpers/scanSubscriptionBlocks.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("../../../constants/index.js");exports.scanSubscriptionBlocks=e=>{let r=e.querySelectorAll('[id^="product-subscription-"][data-selling-type]'),s=!1,i=!1;return r.forEach(e=>{let r=e.getAttribute("data-selling-type");r===t.SubscriptionEnum.ONE_TIME&&(s=!0),r===t.SubscriptionEnum.SUBSCRIPTION&&(i=!0)}),{hasOneTimeBlock:s,hasSubscriptionBlock:i,hasBoth:s&&i}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react"),r=require("../helpers/scanSubscriptionBlocks.js");exports.useProductOfferSubscriptionBlocksObserver=t=>{let[s,c]=e.useState(()=>({hasOneTimeBlock:!1,hasSubscriptionBlock:!1,hasBoth:!1}));return e.useLayoutEffect(()=>{let e=t.current;if(!e)return;let s=()=>{c(r.scanSubscriptionBlocks(e))};s();let u=new MutationObserver(s);return u.observe(e,{childList:!0,subtree:!0}),()=>{u.disconnect()}},[t]),s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),i=require("@gem-sdk/core"),
|
|
1
|
+
"use strict";var e=require("react"),i=require("@gem-sdk/core"),s=require("../../../constants/index.js"),n=require("../../product-offer/context/PrdOfferSubscriptionPresenceContext.js"),u=require("./useSellingPlanOptions.js"),r=require("../../../hooks/useSubscriptionSellingType.js");exports.useSubscriptionVisibility=({setting:t})=>{let o=i.useProductStore(e=>e.setSubscriptionSellingType),{isOneTime:l,subscriptionSellingType:S}=r.useSubscriptionSellingType(),c=u.useSellingPlanOptions(t),p=i.useProduct(),E=n.useProductOfferSubscriptionPresence(),T=c&&c.length>0,b=void 0!==E,O=e.useMemo(()=>void 0===E||E.hasBoth,[E]),m=e.useMemo(()=>p?.requiresSellingPlan,[p?.requiresSellingPlan]),g=e.useMemo(()=>l?s.SubscriptionEnum.ONE_TIME:s.SubscriptionEnum.SUBSCRIPTION,[l]);e.useEffect(()=>{S||(t?.sellingType===s.SubscriptionEnum.ONE_TIME?o(s.SubscriptionEnum.ONE_TIME):o(t?.sellingType??s.SubscriptionEnum.SUBSCRIPTION))},[o,t?.sellingType,S]);let P=b&&!!E?.hasSubscriptionBlock&&!E?.hasOneTimeBlock&&S===s.SubscriptionEnum.ONE_TIME;e.useEffect(()=>{P&&o(s.SubscriptionEnum.SUBSCRIPTION)},[o,P]);let I=t?.sellingType===s.SubscriptionEnum.SUBSCRIPTION&&!T,a=t?.sellingType===s.SubscriptionEnum.ONE_TIME&&m;return{selectedType:g,shouldShowRadio:!m&&T&&O,isOneTimeHidden:a,requiresSellingPlan:m,isOnetimeOnly:!T&&!m,hasNoSellingPlanOptions:I,setSubscriptionSellingType:o}};
|
package/dist/esm/post-purchase/product/components/product-offer/components/ProductOfferItem.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{jsx as r}from"react/jsx-runtime";import{
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import{useRenderMode as e,isEmptyChildren as t,ProductProvider as o}from"@gem-sdk/core";import{useRef as i}from"react";import m from"../../../../../grid/components/row/Row.js";import s from"../../../../../grid/components/ChildrenDroppable.js";import{createAttr as n,createClass as d}from"@gem-sdk/system";import{getProductOfferAttrs as c}from"../common/attrs.js";import{getProductOfferItemClasses as l}from"../common/classes.js";import{ProductOfferSubscriptionPresenceProvider as a}from"../context/PrdOfferSubscriptionPresenceContext.js";let f=f=>{let{product:p,setting:u,builderProps:h,children:j,index:b,totalProduct:g,builderAttrs:y,styles:x}=f,{isEditMode:I}=e(),{variantSelected:O,productOfferLayout:k,layout:v,...P}=u??{};Object.keys(v||{}).forEach(r=>{k?.[r]==="2col"&&v?.[r]&&(v[r].display="fill")});let w=O?.[p?.baseID??""]?.variantId,C=n({...c(p,h?.uid)}),D=d({...l(b,u,g)}),R=i(null),A=r("div",{ref:R,...I?{...C}:{},children:r(m,{builderAttrs:y,setting:{...P,layout:v},styles:x,children:t(j)?r(s,{}):j})});return r("div",{className:D,children:r(o,{product:p,readOnly:!0,initialVariantId:w??"Latest",uid:h?.uid,children:I?r(a,{containerRef:R,children:A}):A})},`uid-${p?.id}`)};export{f as ProductOfferItem};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import{useContext as e,createContext as o}from"react";import{useProductOfferSubscriptionBlocksObserver as t}from"../hooks/useProductOfferSubscriptionBlocksObserver.js";let i=o(void 0),c=({children:e,containerRef:o})=>{let c=t(o);return r(i.Provider,{value:c,children:e})},s=()=>e(i);export{c as ProductOfferSubscriptionPresenceProvider,s as useProductOfferSubscriptionPresence};
|
package/dist/esm/post-purchase/product/components/product-offer/helpers/scanSubscriptionBlocks.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SubscriptionEnum as t}from"../../../constants/index.js";let e=e=>{let r=e.querySelectorAll('[id^="product-subscription-"][data-selling-type]'),l=!1,o=!1;return r.forEach(e=>{let r=e.getAttribute("data-selling-type");r===t.ONE_TIME&&(l=!0),r===t.SUBSCRIPTION&&(o=!0)}),{hasOneTimeBlock:l,hasSubscriptionBlock:o,hasBoth:l&&o}};export{e as scanSubscriptionBlocks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as e,useLayoutEffect as r}from"react";import{scanSubscriptionBlocks as t}from"../helpers/scanSubscriptionBlocks.js";let s=s=>{let[o,c]=e(()=>({hasOneTimeBlock:!1,hasSubscriptionBlock:!1,hasBoth:!1}));return r(()=>{let e=s.current;if(!e)return;let r=()=>{c(t(e))};r();let o=new MutationObserver(r);return o.observe(e,{childList:!0,subtree:!0}),()=>{o.disconnect()}},[s]),o};export{s as useProductOfferSubscriptionBlocksObserver};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as e,useEffect as
|
|
1
|
+
import{useMemo as e,useEffect as i}from"react";import{useProductStore as o,useProduct as l}from"@gem-sdk/core";import{SubscriptionEnum as s}from"../../../constants/index.js";import{useProductOfferSubscriptionPresence as r}from"../../product-offer/context/PrdOfferSubscriptionPresenceContext.js";import{useSellingPlanOptions as t}from"./useSellingPlanOptions.js";import{useSubscriptionSellingType as n}from"../../../hooks/useSubscriptionSellingType.js";let p=({setting:p})=>{let S=o(e=>e.setSubscriptionSellingType),{isOneTime:T,subscriptionSellingType:m}=n(),O=t(p),c=l(),u=r(),I=O&&O.length>0,g=void 0!==u,f=e(()=>void 0===u||u.hasBoth,[u]),E=e(()=>c?.requiresSellingPlan,[c?.requiresSellingPlan]),a=e(()=>T?s.ONE_TIME:s.SUBSCRIPTION,[T]);i(()=>{m||(p?.sellingType===s.ONE_TIME?S(s.ONE_TIME):S(p?.sellingType??s.SUBSCRIPTION))},[S,p?.sellingType,m]);let y=g&&!!u?.hasSubscriptionBlock&&!u?.hasOneTimeBlock&&m===s.ONE_TIME;i(()=>{y&&S(s.SUBSCRIPTION)},[S,y]);let N=p?.sellingType===s.SUBSCRIPTION&&!I,P=p?.sellingType===s.ONE_TIME&&E;return{selectedType:a,shouldShowRadio:!E&&I&&f,isOneTimeHidden:P,requiresSellingPlan:E,isOnetimeOnly:!I&&!E,hasNoSellingPlanOptions:N,setSubscriptionSellingType:S}};export{p as useSubscriptionVisibility};
|