@gem-sdk/components 12.0.0-staging.75 → 12.0.0-staging.77
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-subscription/common/extractSellingPlanSettings.js +1 -1
- package/dist/cjs/post-purchase/product/components/product-subscription/hooks/useSellingSubscription.js +1 -1
- package/dist/esm/post-purchase/product/components/product-subscription/common/extractSellingPlanSettings.js +1 -1
- package/dist/esm/post-purchase/product/components/product-subscription/hooks/useSellingSubscription.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractProductId=t=>t?t.includes("/Product/")?t.split("/Product/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,product:i,isFromEvent:
|
|
1
|
+
"use strict";const extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractProductId=t=>t?t.includes("/Product/")?t.split("/Product/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,product:i,isFromEvent:a=!1})=>{let r={sourceApp:void 0,group:void 0,defaultOptions:void 0};if(!t)return r;if(a&&e?.id){let a,r;if(i&&"baseID"in i&&i.baseID?(a=extractProductId(i.baseID),r=Object.keys(t)[0]):a="data"===(r=Object.keys(t)[0])&&t[r]?Object.keys(t[r])[0]:r,a){let i="data"===r?t.data:t[a],d="data"===r?i[a]:i;if(d){let t=extractVariantId(e.id?.toString()||""),i=extractVariantId(e.baseID||""),a=Object.keys(d).find(a=>a===e.id?.toString()||a===e.baseID||a===t||a===i||e.id?.toString()===a||e.baseID===a||e.id?.toString().includes(a)||e.baseID?.includes(a)||a.includes(t)||a.includes(i));if(a&&d[a]){let t=d[a];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}}}}return r};exports.extractSellingPlanSettings=extractSellingPlanSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),core=require("@gem-sdk/core"),extractSellingPlanSettings=require("../common/extractSellingPlanSettings.js"),findMatchedGroup=require("../helpers/findMatchedGroup.js"),findDefaultValue=require("../helpers/findDefaultValue.js"),findVariantByOptions=require("../helpers/findVariantByOptions.js");const useSellingSubscription=e=>{let t=core.useProduct(),n=core.useVariants(),{selectedOptions:l}=core.useSelectedOption(),r=core.useProductStore(e=>e.selectedSellingPlan),i=core.useProductStore(e=>e.setSelectedSellingPlan),a=core.usePageStore(e=>e.sellingPlanMeta),u=core.useEditorMode(),s=React.useRef(!1),o=React.useRef(void 0);React.useEffect(()=>{if(!s.current&&u===core.RenderModeEnv.EDIT&&!a){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),s.current=!0}},[u,a]);let c=a??e?.sellingPlans,d=React.useMemo(()=>{if(!c)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=
|
|
1
|
+
"use strict";var React=require("react"),core=require("@gem-sdk/core"),extractSellingPlanSettings=require("../common/extractSellingPlanSettings.js"),findMatchedGroup=require("../helpers/findMatchedGroup.js"),findDefaultValue=require("../helpers/findDefaultValue.js"),findVariantByOptions=require("../helpers/findVariantByOptions.js");const useSellingSubscription=e=>{let t=core.useProduct(),n=core.useVariants(),{selectedOptions:l}=core.useSelectedOption(),r=core.useProductStore(e=>e.selectedSellingPlan),i=core.useProductStore(e=>e.setSelectedSellingPlan),a=core.usePageStore(e=>e.sellingPlanMeta),u=core.useEditorMode(),s=React.useRef(!1),o=React.useRef(void 0);React.useEffect(()=>{if(!s.current&&u===core.RenderModeEnv.EDIT&&!a){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),s.current=!0}},[u,a]);let c=a??e?.sellingPlans,d=React.useMemo(()=>{if(!c)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=a&&l?findVariantByOptions.findVariantByOptions({variants:n,selectedOptions:l}):null,r=extractSellingPlanSettings.extractSellingPlanSettings({sellingPlansSetting:c,currentVariant:e,product:t,isFromEvent:!!a});return r},[c,a,n,l,t]),f=React.useMemo(()=>l?findVariantByOptions.findVariantByOptions({variants:n,selectedOptions:l}):null,[l,n]);React.useEffect(()=>{o.current=void 0},[f?.baseID]);let{sellingPlans:p,defaultValue:g}=React.useMemo(()=>{let e=f?.sellingPlanGroups??t?.sellingPlanGroups??[];if(!e||0===e.length)return{sellingPlans:[],defaultValue:void 0};let n=findMatchedGroup.findMatchedGroup({sellingPlanGroups:e,extractedSettings:d,currentVariant:f}),l=n?.sellingPlans?.filter(e=>null!=e)??[],r=l.map(e=>({label:e.name||"",value:e.baseID})),i=findDefaultValue.findDefaultValue({validPlans:l,extractedSettings:d,currentVariant:f,plans:r});return{sellingPlans:r,defaultValue:i}},[t,f,d]);return React.useEffect(()=>{!r&&g&&o.current!==g&&(o.current=g,i(g))},[g,r,i]),{sellingPlans:p,defaultValue:g,selectedSellingPlan:r,setSelectedSellingPlan:i}};exports.useSellingSubscription=useSellingSubscription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractProductId=t=>t?t.includes("/Product/")?t.split("/Product/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,product:i,isFromEvent:
|
|
1
|
+
let extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractProductId=t=>t?t.includes("/Product/")?t.split("/Product/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,product:i,isFromEvent:a=!1})=>{let r={sourceApp:void 0,group:void 0,defaultOptions:void 0};if(!t)return r;if(a&&e?.id){let a,r;if(i&&"baseID"in i&&i.baseID?(a=extractProductId(i.baseID),r=Object.keys(t)[0]):a="data"===(r=Object.keys(t)[0])&&t[r]?Object.keys(t[r])[0]:r,a){let i="data"===r?t.data:t[a],d="data"===r?i[a]:i;if(d){let t=extractVariantId(e.id?.toString()||""),i=extractVariantId(e.baseID||""),a=Object.keys(d).find(a=>a===e.id?.toString()||a===e.baseID||a===t||a===i||e.id?.toString()===a||e.baseID===a||e.id?.toString().includes(a)||e.baseID?.includes(a)||a.includes(t)||a.includes(i));if(a&&d[a]){let t=d[a];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}}}}return r};export{extractSellingPlanSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as e,useEffect as l,useMemo as n}from"react";import{useProduct as t,useVariants as r,useSelectedOption as i,useProductStore as s,usePageStore as o,useEditorMode as u,RenderModeEnv as a}from"@gem-sdk/core";import{extractSellingPlanSettings as p}from"../common/extractSellingPlanSettings.js";import{findMatchedGroup as m}from"../helpers/findMatchedGroup.js";import{findDefaultValue as c}from"../helpers/findDefaultValue.js";import{findVariantByOptions as d}from"../helpers/findVariantByOptions.js";let useSellingSubscription=f=>{let g=t(),v=r(),{selectedOptions:P}=i(),S=s(e=>e.selectedSellingPlan),b=s(e=>e.setSelectedSellingPlan),h=o(e=>e.sellingPlanMeta),V=u(),j=e(!1),D=e(void 0);l(()=>{if(!j.current&&V===a.EDIT&&!h){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),j.current=!0}},[V,h]);let E=h??f?.sellingPlans,G=n(()=>{if(!E)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=
|
|
1
|
+
import{useRef as e,useEffect as l,useMemo as n}from"react";import{useProduct as t,useVariants as r,useSelectedOption as i,useProductStore as s,usePageStore as o,useEditorMode as u,RenderModeEnv as a}from"@gem-sdk/core";import{extractSellingPlanSettings as p}from"../common/extractSellingPlanSettings.js";import{findMatchedGroup as m}from"../helpers/findMatchedGroup.js";import{findDefaultValue as c}from"../helpers/findDefaultValue.js";import{findVariantByOptions as d}from"../helpers/findVariantByOptions.js";let useSellingSubscription=f=>{let g=t(),v=r(),{selectedOptions:P}=i(),S=s(e=>e.selectedSellingPlan),b=s(e=>e.setSelectedSellingPlan),h=o(e=>e.sellingPlanMeta),V=u(),j=e(!1),D=e(void 0);l(()=>{if(!j.current&&V===a.EDIT&&!h){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),j.current=!0}},[V,h]);let E=h??f?.sellingPlans,G=n(()=>{if(!E)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=h&&P?d({variants:v,selectedOptions:P}):null,l=p({sellingPlansSetting:E,currentVariant:e,product:g,isFromEvent:!!h});return l},[E,h,v,P,g]),I=n(()=>P?d({variants:v,selectedOptions:P}):null,[P,v]);l(()=>{D.current=void 0},[I?.baseID]);let{sellingPlans:x,defaultValue:M}=n(()=>{let e=I?.sellingPlanGroups??g?.sellingPlanGroups??[];if(!e||0===e.length)return{sellingPlans:[],defaultValue:void 0};let l=m({sellingPlanGroups:e,extractedSettings:G,currentVariant:I}),n=l?.sellingPlans?.filter(e=>null!=e)??[],t=n.map(e=>({label:e.name||"",value:e.baseID})),r=c({validPlans:n,extractedSettings:G,currentVariant:I,plans:t});return{sellingPlans:t,defaultValue:r}},[g,I,G]);return l(()=>{!S&&M&&D.current!==M&&(D.current=M,b(M))},[M,S,b]),{sellingPlans:x,defaultValue:M,selectedSellingPlan:S,setSelectedSellingPlan:b}};export{useSellingSubscription};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "12.0.0-staging.
|
|
3
|
+
"version": "12.0.0-staging.77",
|
|
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-staging.
|
|
29
|
+
"@gem-sdk/core": "12.0.0-staging.77",
|
|
30
30
|
"@gem-sdk/styles": "12.0.0-staging.66",
|
|
31
31
|
"@gem-sdk/system": "12.0.0-staging.66",
|
|
32
32
|
"@types/react-transition-group": "^4.4.12",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@gem-sdk/keen-slider": "^6.8.8",
|
|
44
|
-
"@gem-sdk/swiper": "0.0.
|
|
44
|
+
"@gem-sdk/swiper": "0.0.14-staging.2",
|
|
45
45
|
"node-html-parser": "^6.1.13",
|
|
46
46
|
"react-transition-group": "^4.4.5",
|
|
47
47
|
"react-youtube": "10.1.0"
|