@gem-sdk/components 8.0.0-dev.108 → 8.0.0-dev.110

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.
Files changed (18) hide show
  1. package/dist/cjs/post-purchase/product/components/product-subscription/common/extractSellingPlanSettings.js +1 -0
  2. package/dist/cjs/post-purchase/product/components/product-subscription/components/ProductSubscription.js +1 -1
  3. package/dist/cjs/post-purchase/product/components/product-subscription/components/SellingPlanDropdown.js +1 -1
  4. package/dist/cjs/post-purchase/product/components/product-subscription/components/SellingPlanRadio.js +1 -1
  5. package/dist/cjs/post-purchase/product/components/product-subscription/hooks/useSellingPlanOptions.js +1 -1
  6. package/dist/cjs/post-purchase/product/components/product-subscription/hooks/useSellingSubscription.js +1 -0
  7. package/dist/cjs/post-purchase/product/settings/product-subscription/configs/settings.js +1 -1
  8. package/dist/cjs/post-purchase/product/settings/product-subscription/configs/ui-v2.js +1 -1
  9. package/dist/esm/post-purchase/product/components/product-subscription/common/extractSellingPlanSettings.js +1 -0
  10. package/dist/esm/post-purchase/product/components/product-subscription/components/ProductSubscription.js +1 -1
  11. package/dist/esm/post-purchase/product/components/product-subscription/components/SellingPlanDropdown.js +1 -1
  12. package/dist/esm/post-purchase/product/components/product-subscription/components/SellingPlanRadio.js +1 -1
  13. package/dist/esm/post-purchase/product/components/product-subscription/hooks/useSellingPlanOptions.js +1 -1
  14. package/dist/esm/post-purchase/product/components/product-subscription/hooks/useSellingSubscription.js +1 -0
  15. package/dist/esm/post-purchase/product/settings/product-subscription/configs/settings.js +1 -1
  16. package/dist/esm/post-purchase/product/settings/product-subscription/configs/ui-v2.js +1 -1
  17. package/dist/types/index.d.ts +11 -1
  18. package/package.json +7 -7
@@ -0,0 +1 @@
1
+ "use strict";const extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,isFromEvent:i=!1})=>{if(!t)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};if(i&&e?.id){let i;let r=Object.keys(t)[0];if(i="data"===r&&t[r]?Object.keys(t[r])[0]:r){let o=t["data"===r?"data":i],u="data"===r?o[i]:o;if(u){let t=extractVariantId(e.id?.toString()||""),i=extractVariantId(e.baseID||""),r=Object.keys(u).find(r=>r===e.id?.toString()||r===e.baseID||r===t||r===i||e.id?.toString()===r||e.baseID===r||e.id?.toString().includes(r)||e.baseID?.includes(r)||r.includes(t)||r.includes(i));if(r&&u[r]){let t=u[r];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}let o=Object.keys(u)[0];if(o&&u[o]){let t=u[o];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}}}}let r=Object.keys(t)[0];if(!r)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let o=t[r];if(!o)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let u=Object.keys(o)[0];if(!u)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let p=o[u];return{sourceApp:p?.sourceApp||p?.appSource,group:p?.group,defaultOptions:p?.defaultOption}};exports.extractSellingPlanSettings=extractSellingPlanSettings;
@@ -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"),SubscriptionDetail=require("./SubscriptionDetail.js"),SellingPlanDropdown=require("./SellingPlanDropdown.js"),SellingPlanRadio=require("./SellingPlanRadio.js"),SellingPlanLabel=require("./SellingPlanLabel.js"),core=require("@gem-sdk/core"),React=require("react"),index=require("../../../constants/index.js");const ProductSubscription=({styles:e,setting:s})=>{let l=core.useProductStore(e=>e.setSubscriptionSellingType),t=system.createStyle(styles.getSubscriptionStyles(e,s)),i=system.createStyle(styles.getSubscriptionWrapperStyles(e?.align)),n=system.createClass(classes.getWrapperClasses()),r=system.createClass(classes.getContainerClasses());return React.useEffect(()=>{l(s?.sellingType??index.PostPurchaseSubscriptionSellingType.SUBSCRIPTION)},[l,s?.sellingType]),jsxRuntime.jsx("div",{className:n,style:i,children:jsxRuntime.jsxs("div",{className:r,style:t,children:[jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e}),s?.sellingStyle==="radio"?jsxRuntime.jsx(SellingPlanRadio.SellingPlanRadio,{setting:s}):jsxRuntime.jsx(SellingPlanDropdown.SellingPlanDropdown,{setting:s}),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"),system=require("@gem-sdk/system"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),SubscriptionDetail=require("./SubscriptionDetail.js"),SellingPlanDropdown=require("./SellingPlanDropdown.js"),SellingPlanRadio=require("./SellingPlanRadio.js"),SellingPlanLabel=require("./SellingPlanLabel.js"),TooltipHover=require("../../../../../common/components/TooltipHover.js"),core=require("@gem-sdk/core"),React=require("react"),index=require("../../../constants/index.js"),useSellingSubscription=require("../hooks/useSellingSubscription.js");const ProductSubscription=({styles:e,setting:s})=>{let{sellingPlans:l,defaultValue:t}=useSellingSubscription.useSellingSubscription(s),i=core.useProductStore(e=>e.setSubscriptionSellingType),n=system.createStyle(styles.getSubscriptionStyles(e,s)),r=system.createStyle(styles.getSubscriptionWrapperStyles(e?.align)),a=system.createClass(classes.getWrapperClasses()),o=system.createClass(classes.getContainerClasses()),{t:u}=core.useI18nStore();return(React.useEffect(()=>{i(s?.sellingType??index.PostPurchaseSubscriptionSellingType.SUBSCRIPTION)},[i,s?.sellingType]),s?.sellingType!=="one-time"&&l&&0!==l.length)?jsxRuntime.jsx("div",{"data-selling-type":s?.sellingType,id:"product-subscription",className:a,style:r,children:jsxRuntime.jsxs("div",{className:o,style:n,children:[jsxRuntime.jsx(SellingPlanLabel.SellingPlanLabel,{setting:s,styles:e}),s?.sellingStyle==="radio"?jsxRuntime.jsx(SellingPlanRadio.SellingPlanRadio,{setting:s,defaultValue:t||""}):jsxRuntime.jsx(SellingPlanDropdown.SellingPlanDropdown,{setting:s,defaultValue:t||""}),jsxRuntime.jsx(SubscriptionDetail.SubscriptionDetail,{setting:s,styles:e})]})}):jsxRuntime.jsx(TooltipHover.default,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:jsxRuntime.jsx("div",{className:"gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:u("This product is only available as a one-time purchase")})})})};exports.default=ProductSubscription;
@@ -1 +1 @@
1
- "use strict";var jsxRuntime=require("react/jsx-runtime"),system=require("@gem-sdk/system"),useSellingPlanOptions=require("../hooks/useSellingPlanOptions.js"),classes=require("../common/classes.js");const SellingPlanDropdown=({setting:s})=>{let{sellingLabel:e}=s??{},l=useSellingPlanOptions.useSellingPlanOptions(),a=system.createClass(classes.getSellingPlanDropdownContainerClasses()),n=system.createClass(classes.getSellingPlanDropdownLabelClasses()),t=system.createClass(classes.getSellingPlanDropdownLabelSpanClasses()),i=system.createClass(classes.getSellingPlanDropdownLabelInnerSpanClasses()),r=system.createClass(classes.getSellingPlanDropdownSelectClasses()),o=system.createClass(classes.getSellingPlanDropdownOptionClasses()),c=system.createClass(classes.getSellingPlanDropdownIconContainerClasses()),m=system.createClass(classes.getSellingPlanDropdownIconClasses());return jsxRuntime.jsxs("div",{className:a,children:[jsxRuntime.jsx("label",{htmlFor:"selling-plan-select",className:n,children:jsxRuntime.jsx("span",{className:t,children:jsxRuntime.jsx("span",{className:i,children:e})})}),jsxRuntime.jsx("select",{autoComplete:"off",name:"Select Option",className:r,children:l.map(s=>jsxRuntime.jsx("option",{className:o,children:s.label},s.value))}),jsxRuntime.jsx("div",{className:c,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",focusable:"false","aria-hidden":"true",role:"presentation",className:m,children:jsxRuntime.jsx("path",{d:"M0 5h20L10 15"})})})]})};exports.SellingPlanDropdown=SellingPlanDropdown;
1
+ "use strict";var jsxRuntime=require("react/jsx-runtime"),React=require("react"),system=require("@gem-sdk/system"),useSellingPlanOptions=require("../hooks/useSellingPlanOptions.js"),classes=require("../common/classes.js");const SellingPlanDropdown=({setting:e,defaultValue:s})=>{let{sellingLabel:l}=e??{},a=useSellingPlanOptions.useSellingPlanOptions(e),[n,t]=React.useState(s||a[0]?.value||"");React.useEffect(()=>{if(s)t(s);else if(a.length>0){let e=a[0];e?.value&&t(s=>s||e.value)}},[s,a]);let i=system.createClass(classes.getSellingPlanDropdownContainerClasses()),r=system.createClass(classes.getSellingPlanDropdownLabelClasses()),c=system.createClass(classes.getSellingPlanDropdownLabelSpanClasses()),o=system.createClass(classes.getSellingPlanDropdownLabelInnerSpanClasses()),m=system.createClass(classes.getSellingPlanDropdownSelectClasses()),u=system.createClass(classes.getSellingPlanDropdownOptionClasses()),g=system.createClass(classes.getSellingPlanDropdownIconContainerClasses()),p=system.createClass(classes.getSellingPlanDropdownIconClasses());return jsxRuntime.jsxs("div",{className:i,children:[jsxRuntime.jsx("label",{htmlFor:"selling-plan-select",className:r,children:jsxRuntime.jsx("span",{className:c,children:jsxRuntime.jsx("span",{className:o,children:l})})}),jsxRuntime.jsx("select",{autoComplete:"off",name:"Select Option",className:m,value:n,onChange:e=>t(e.target.value),children:a.map(e=>jsxRuntime.jsx("option",{className:u,value:e.value,children:e.label},e.value))}),jsxRuntime.jsx("div",{className:g,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",focusable:"false","aria-hidden":"true",role:"presentation",className:p,children:jsxRuntime.jsx("path",{d:"M0 5h20L10 15"})})})]})};exports.SellingPlanDropdown=SellingPlanDropdown;
@@ -1 +1 @@
1
- "use strict";var jsxRuntime=require("react/jsx-runtime"),React=require("react"),system=require("@gem-sdk/system"),SubscriptionRadio=require("./SubscriptionRadio.js"),useSellingPlanOptions=require("../hooks/useSellingPlanOptions.js"),classes=require("../common/classes.js");const SellingPlanRadio=({setting:e})=>{let{sellingLabel:s}=e??{},[l,a]=React.useState("1 week"),i=useSellingPlanOptions.useSellingPlanOptions(),n=system.createClass(classes.getSellingPlanRadioContainerClasses()),t=system.createClass(classes.getSellingPlanRadioLabelClasses()),r=system.createClass(classes.getSellingPlanRadioOptionsClasses()),c=system.createClass(classes.getSellingPlanRadioOptionTextClasses());return jsxRuntime.jsxs("div",{className:n,children:[s&&jsxRuntime.jsx("label",{className:t,children:s}),jsxRuntime.jsx("div",{className:r,children:i.map(e=>jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{name:"selling-plan-options",value:e.value,checked:l===e.value,onChange:e=>a(e.target.value),children:jsxRuntime.jsx("span",{className:c,children:e.label})},e.value))})]})};exports.SellingPlanRadio=SellingPlanRadio;
1
+ "use strict";var jsxRuntime=require("react/jsx-runtime"),React=require("react"),system=require("@gem-sdk/system"),SubscriptionRadio=require("./SubscriptionRadio.js"),useSellingPlanOptions=require("../hooks/useSellingPlanOptions.js"),classes=require("../common/classes.js");const SellingPlanRadio=({setting:e,defaultValue:s})=>{let{sellingLabel:l}=e??{},a=useSellingPlanOptions.useSellingPlanOptions(e),[i,n]=React.useState(s||a[0]?.value||"");React.useEffect(()=>{s&&n(s)},[s]);let t=system.createClass(classes.getSellingPlanRadioContainerClasses()),r=system.createClass(classes.getSellingPlanRadioLabelClasses()),c=system.createClass(classes.getSellingPlanRadioOptionsClasses()),o=system.createClass(classes.getSellingPlanRadioOptionTextClasses());return jsxRuntime.jsxs("div",{className:t,children:[l&&jsxRuntime.jsx("label",{className:r,children:l}),jsxRuntime.jsx("div",{className:c,children:a.map(e=>jsxRuntime.jsx(SubscriptionRadio.SubscriptionRadio,{name:"selling-plan-options",value:e.value,checked:i===e.value,onChange:e=>n(e.target.value),children:jsxRuntime.jsx("span",{className:o,children:e.label})},e.value))})]})};exports.SellingPlanRadio=SellingPlanRadio;
@@ -1 +1 @@
1
- "use strict";const useSellingPlanOptions=()=>{let e=[{label:"Delivery each 1 week",value:"1 week"},{label:"Delivery each 2 weeks",value:"2 weeks"},{label:"Delivery each 3 weeks",value:"3 weeks"}];return e};exports.useSellingPlanOptions=useSellingPlanOptions;
1
+ "use strict";var useSellingSubscription=require("./useSellingSubscription.js");const useSellingPlanOptions=e=>{let{sellingPlans:i}=useSellingSubscription.useSellingSubscription(e);return i||[]};exports.useSellingPlanOptions=useSellingPlanOptions;
@@ -0,0 +1 @@
1
+ "use strict";var React=require("react"),core=require("@gem-sdk/core"),extractSellingPlanSettings=require("../common/extractSellingPlanSettings.js");const useSellingSubscription=e=>{let l=core.useProduct(),t=core.useVariants(),{selectedOptions:n}=core.useSelectedOption(),s=core.usePageStore(e=>e.sellingPlanMeta),i=core.useEditorMode(),u=React.useRef(!1);React.useEffect(()=>{if(!u.current&&i===core.RenderModeEnv.EDIT&&!s){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),u.current=!0}},[i,s]);let r=s??e?.sellingPlans,a=React.useMemo(()=>{if(!r)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=null;return s&&n&&(e=t.find(e=>!!e?.selectedOptions&&e.selectedOptions.every(e=>n[e.name??""]===e.value))??null),extractSellingPlanSettings.extractSellingPlanSettings({sellingPlansSetting:r,currentVariant:e,isFromEvent:!!s})},[r,s,t,n]),o=React.useMemo(()=>{if(!n||!t||0===t.length)return null;let e=t.find(e=>!!e?.selectedOptions&&e.selectedOptions.every(e=>n[e.name??""]===e.value))??null;return e},[n,t]),{sellingPlans:c,defaultValue:d}=React.useMemo(()=>{let e;let t=o?.sellingPlanGroups??l?.sellingPlanGroups??[];if(!t||0===t.length||!a.sourceApp||!a.group)return{sellingPlans:[],defaultValue:void 0};let n=t.find(e=>null!=e&&e.appID===a.sourceApp&&e.id===a.group),s=n?.sellingPlans?.filter(e=>null!=e).map(e=>({label:e.name,value:e.baseID}))??[];if(a.defaultOptions){let l=n?.sellingPlans?.find(e=>null!=e&&e.baseID===a.defaultOptions),t=n?.sellingPlans?.find(e=>null!=e&&e.id===a.defaultOptions);e=l?.baseID??t?.baseID??s[0]?.value}else e=s[0]?.value;return{sellingPlans:s,defaultValue:e}},[l,o,a]);return{sellingPlans:c,defaultValue:d}};exports.useSellingSubscription=useSellingSubscription;
@@ -1 +1 @@
1
- "use strict";var constants=require("../../../../common/constants.js");const ProductSubscriptionSettings=[{id:"setting",controls:[{id:"sellingType",label:"Type",type:"select",options:[{value:"one-time",label:"One-time"},{value:"subscription",label:"Subscription"}],default:"subscription"},{id:"sellingTitle",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Subscribe and save up to {total_max_discount}",suggestContents:[{message:"{total_max_discount}",eg:"E.g: 50% (offer’s + plan’s max discount)"},{message:"{offer_selling_plan_discount}",eg:"E.g: 20%"}]},{id:"sellingLabel",label:"Text",type:"input",default:"Purchase options",placeholder:"E.g. Purchase options",clearButton:!1},{id:"sellingStyle",label:"Style",type:"option:illustration",default:"dropdown",options:[{label:"Dropdown",value:"dropdown",svgName:"gp-selling-plan-dropdown"},{label:"Radio",value:"radio",svgName:"gp-selling-plan-radio"}]},{id:"subscriptionLabel",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",suggestContents:[{message:"{selling_plan_delivery_frequency}",eg:"E.g: every week"},{message:"{selling_plan_discount}",eg:"E.g: 10%"},{message:"{selling_plan_billing_cycle}",eg:"E.g: every 1 month"}]},{id:"enableSubscriptionDetail",label:"Enable subscription detail",type:"toggle",default:!1}]},{id:"style",controls:[{id:"sellingTitleDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"subscriptionDetailDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"sellingPlanItemGap",type:"select",label:"Item gap",options:constants.postPurchaseSpacing,default:"tight"},{id:"sellingTitleTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"sellingTitleAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"subscriptionDetailTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"subscriptionDetailAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"width",type:"dropdown:input",label:"Width",inputType:"number",units:["px","%"],hideUnit:!1,devices:{desktop:{default:"100%"},tablet:{default:"100%"},mobile:{default:"100%"}},displayOptions:[{label:"Fit content",value:"Auto",showValue:!0},{label:"Full",value:"100%",showValue:!0}]},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:"#DDDDDD"}},enableGradient:!0},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left",iconName:"gp-align-left"},{label:"Center",value:"center",type:"align",tooltip:"Align center",iconName:"gp-align-center"},{label:"Right",value:"right",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"left"}]}];exports.ProductSubscriptionSettings=ProductSubscriptionSettings;
1
+ "use strict";var constants=require("../../../../common/constants.js");const ProductSubscriptionSettings=[{id:"setting",controls:[{id:"sellingType",label:"Type",type:"pick-subscription",options:[{value:"one-time",label:"One-time"},{value:"subscription",label:"Subscription"}],default:"subscription"},{id:"sellingPlans",label:"Selling plans",type:"selling-plan"},{id:"sellingTitle",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Subscribe and save up to {total_max_discount}",suggestContents:[{message:"{total_max_discount}",eg:"E.g: 50% (offer’s + plan’s max discount)"},{message:"{offer_selling_plan_discount}",eg:"E.g: 20%"}]},{id:"sellingLabel",label:"Text",type:"input",default:"Purchase options",placeholder:"E.g. Purchase options",clearButton:!1},{id:"sellingStyle",label:"Style",type:"option:illustration",default:"dropdown",options:[{label:"Dropdown",value:"dropdown",svgName:"gp-selling-plan-dropdown"},{label:"Radio",value:"radio",svgName:"gp-selling-plan-radio"}]},{id:"subscriptionLabel",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",suggestContents:[{message:"{selling_plan_delivery_frequency}",eg:"E.g: every week"},{message:"{selling_plan_discount}",eg:"E.g: 10%"},{message:"{selling_plan_billing_cycle}",eg:"E.g: every 1 month"}]},{id:"enableSubscriptionDetail",label:"Enable subscription detail",type:"toggle",default:!1}]},{id:"style",controls:[{id:"sellingTitleDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"subscriptionDetailDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"sellingPlanItemGap",type:"select",label:"Item gap",options:constants.postPurchaseSpacing,default:"tight"},{id:"sellingTitleTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"sellingTitleAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"subscriptionDetailTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"subscriptionDetailAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"width",type:"dropdown:input",label:"Width",inputType:"number",units:["px","%"],hideUnit:!1,devices:{desktop:{default:"100%"},tablet:{default:"100%"},mobile:{default:"100%"}},displayOptions:[{label:"Fit content",value:"Auto",showValue:!0},{label:"Full",value:"100%",showValue:!0}]},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:"#DDDDDD"}},enableGradient:!0},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left",iconName:"gp-align-left"},{label:"Center",value:"center",type:"align",tooltip:"Align center",iconName:"gp-align-center"},{label:"Right",value:"right",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"left"}]}];exports.ProductSubscriptionSettings=ProductSubscriptionSettings;
@@ -1 +1 @@
1
- "use strict";const SettingUIV2=[{label:{en:"Selling options"},controls:[{type:"control",label:{en:"Type"},setting:{id:"sellingType"}},{type:"combo",label:{en:"Title"},iconName:"polaris-text-block",getValueFromSettingID:"sellingTitle",compoDefaultValue:"Subscribe and save up to {total_max_discount}",popoverLabel:{en:"Selling option title"},isHideClear:!0,controls:[{label:{en:"Content"},setting:{id:"sellingTitle"},layout:"vertical"},{type:"control",label:{en:"Direction"},setting:{id:"sellingTitleDirection"}},{type:"control",label:{en:""},setting:{id:"sellingTitleTypo"},layout:"vertical"},{type:"control",setting:{id:"sellingTitleAlign"},label:{en:"Align"}}]}]},{label:{en:"Selling plans"},controls:[{type:"control",label:{en:"Label"},setting:{id:"sellingLabel"},layout:"horizontal"},{type:"control",label:{en:"Style"},setting:{id:"sellingStyle"},layout:"horizontal"},{type:"control",label:{en:"Item gap"},setting:{id:"sellingPlanItemGap"},layout:"horizontal",conditionDisplay:"sellingStyle === 'radio'"}]},{controls:[{type:"control",label:{en:"Subscription detail"},setting:{id:"enableSubscriptionDetail"},options:{labelVariant:"primary",toggleStyle:"switch",fullWidth:!0}},{type:"combo",label:{en:"Label"},iconName:"polaris-text-block",getValueFromSettingID:"subscriptionLabel",compoDefaultValue:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",popoverLabel:{en:"Subscription detail"},isHideClear:!0,conditionDisplay:"enableSubscriptionDetail === true",controls:[{label:{en:"Content"},setting:{id:"subscriptionLabel"},layout:"vertical"}]},{type:"control",label:{en:"Direction"},setting:{id:"subscriptionDetailDirection"},conditionDisplay:"enableSubscriptionDetail === true",controlChangeTrigger:{settings:[{action:{controlId:"subscriptionDetailAlign",newValue:"right",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'rtl' && subscriptionDetailAlign === 'left'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]},{action:{controlId:"subscriptionDetailAlign",newValue:"left",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'ltr' && subscriptionDetailAlign === 'right'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]}],options:{noRecordHistory:!0}}},{type:"control",label:{en:""},setting:{id:"subscriptionDetailTypo"},layout:"vertical",conditionDisplay:"enableSubscriptionDetail === true"},{type:"control",setting:{id:"subscriptionDetailAlign"},label:{en:"Align"},conditionDisplay:"enableSubscriptionDetail === true"}]},{label:{en:"Size"},controls:[{type:"control",label:{en:"Width"},setting:{id:"width"},layout:"horizontal"}]},{label:{en:"Background"},controls:[{label:{en:"Color"},setting:{id:"backgroundColor"}}]},{controls:[{label:{en:"Align"},conditionEnable:"activeScreenId === 'desktop' ? !(parseInt(width) >= 100 && width?.includes(\"%\")) : (!(parseInt(width) >= 100 && width?.includes(\"%\")) && width !== 'default')",setting:{id:"align"},options:{labelVariant:"primary",fullWidth:!0,disableMessage:"Horizontal alignment is disabled when the width is set to 100% or greater"}}]}];exports.SettingUIV2=SettingUIV2;
1
+ "use strict";const SettingUIV2=[{label:{en:"Selling options"},controls:[{type:"control",label:{en:"Type"},setting:{id:"sellingType"}},{type:"combo",label:{en:"Title"},iconName:"polaris-text-block",getValueFromSettingID:"sellingTitle",compoDefaultValue:"Subscribe and save up to {total_max_discount}",popoverLabel:{en:"Selling option title"},isHideClear:!0,controls:[{label:{en:"Content"},setting:{id:"sellingTitle"},layout:"vertical"},{type:"control",label:{en:"Direction"},setting:{id:"sellingTitleDirection"}},{type:"control",label:{en:""},setting:{id:"sellingTitleTypo"},layout:"vertical"},{type:"control",setting:{id:"sellingTitleAlign"},label:{en:"Align"}}]}]},{label:{en:"Selling plans"},controls:[{type:"control",label:{en:"Selling plans"},setting:{id:"sellingPlans"}},{type:"control",label:{en:"Label"},setting:{id:"sellingLabel"},layout:"horizontal"},{type:"control",label:{en:"Style"},setting:{id:"sellingStyle"},layout:"horizontal"},{type:"control",label:{en:"Item gap"},setting:{id:"sellingPlanItemGap"},layout:"horizontal",conditionDisplay:"sellingStyle === 'radio'"}]},{controls:[{type:"control",label:{en:"Subscription detail"},setting:{id:"enableSubscriptionDetail"},options:{labelVariant:"primary",toggleStyle:"switch",fullWidth:!0}},{type:"combo",label:{en:"Label"},iconName:"polaris-text-block",getValueFromSettingID:"subscriptionLabel",compoDefaultValue:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",popoverLabel:{en:"Subscription detail"},isHideClear:!0,conditionDisplay:"enableSubscriptionDetail === true",controls:[{label:{en:"Content"},setting:{id:"subscriptionLabel"},layout:"vertical"}]},{type:"control",label:{en:"Direction"},setting:{id:"subscriptionDetailDirection"},conditionDisplay:"enableSubscriptionDetail === true",controlChangeTrigger:{settings:[{action:{controlId:"subscriptionDetailAlign",newValue:"right",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'rtl' && subscriptionDetailAlign === 'left'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]},{action:{controlId:"subscriptionDetailAlign",newValue:"left",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'ltr' && subscriptionDetailAlign === 'right'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]}],options:{noRecordHistory:!0}}},{type:"control",label:{en:""},setting:{id:"subscriptionDetailTypo"},layout:"vertical",conditionDisplay:"enableSubscriptionDetail === true"},{type:"control",setting:{id:"subscriptionDetailAlign"},label:{en:"Align"},conditionDisplay:"enableSubscriptionDetail === true"}]},{label:{en:"Size"},controls:[{type:"control",label:{en:"Width"},setting:{id:"width"},layout:"horizontal"}]},{label:{en:"Background"},controls:[{label:{en:"Color"},setting:{id:"backgroundColor"}}]},{controls:[{label:{en:"Align"},conditionEnable:"activeScreenId === 'desktop' ? !(parseInt(width) >= 100 && width?.includes(\"%\")) : (!(parseInt(width) >= 100 && width?.includes(\"%\")) && width !== 'default')",setting:{id:"align"},options:{labelVariant:"primary",fullWidth:!0,disableMessage:"Horizontal alignment is disabled when the width is set to 100% or greater"}}]}];exports.SettingUIV2=SettingUIV2;
@@ -0,0 +1 @@
1
+ let extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,isFromEvent:i=!1})=>{if(!t)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};if(i&&e?.id){let i;let r=Object.keys(t)[0];if(i="data"===r&&t[r]?Object.keys(t[r])[0]:r){let o=t["data"===r?"data":i],u="data"===r?o[i]:o;if(u){let t=extractVariantId(e.id?.toString()||""),i=extractVariantId(e.baseID||""),r=Object.keys(u).find(r=>r===e.id?.toString()||r===e.baseID||r===t||r===i||e.id?.toString()===r||e.baseID===r||e.id?.toString().includes(r)||e.baseID?.includes(r)||r.includes(t)||r.includes(i));if(r&&u[r]){let t=u[r];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}let o=Object.keys(u)[0];if(o&&u[o]){let t=u[o];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}}}}let r=Object.keys(t)[0];if(!r)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let o=t[r];if(!o)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let u=Object.keys(o)[0];if(!u)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let p=o[u];return{sourceApp:p?.sourceApp||p?.appSource,group:p?.group,defaultOptions:p?.defaultOption}};export{extractSellingPlanSettings};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as s}from"react/jsx-runtime";import{createStyle as e,createClass as i}from"@gem-sdk/system";import{getSubscriptionStyles as o,getSubscriptionWrapperStyles as r}from"../common/styles.js";import{getWrapperClasses as l,getContainerClasses as m}from"../common/classes.js";import{SubscriptionDetail as n}from"./SubscriptionDetail.js";import{SellingPlanDropdown as p}from"./SellingPlanDropdown.js";import{SellingPlanRadio as a}from"./SellingPlanRadio.js";import{SellingPlanLabel as c}from"./SellingPlanLabel.js";import{useProductStore as g}from"@gem-sdk/core";import{useEffect as d}from"react";import{PostPurchaseSubscriptionSellingType as f}from"../../../constants/index.js";let ProductSubscription=({styles:S,setting:y})=>{let u=g(t=>t.setSubscriptionSellingType),j=e(o(S,y)),P=e(r(S?.align)),b=i(l()),T=i(m());return d(()=>{u(y?.sellingType??f.SUBSCRIPTION)},[u,y?.sellingType]),t("div",{className:b,style:P,children:s("div",{className:T,style:j,children:[t(c,{setting:y,styles:S}),y?.sellingStyle==="radio"?t(a,{setting:y}):t(p,{setting:y}),t(n,{setting:y,styles:S})]})})};export{ProductSubscription as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{createStyle as s,createClass as o}from"@gem-sdk/system";import{getSubscriptionStyles as i,getSubscriptionWrapperStyles as l}from"../common/styles.js";import{getWrapperClasses as r,getContainerClasses as n}from"../common/classes.js";import{SubscriptionDetail as p}from"./SubscriptionDetail.js";import{SellingPlanDropdown as a}from"./SellingPlanDropdown.js";import{SellingPlanRadio as m}from"./SellingPlanRadio.js";import{SellingPlanLabel as d}from"./SellingPlanLabel.js";import g from"../../../../../common/components/TooltipHover.js";import{useProductStore as c,useI18nStore as u}from"@gem-sdk/core";import{useEffect as f}from"react";import{PostPurchaseSubscriptionSellingType as y}from"../../../constants/index.js";import{useSellingSubscription as b}from"../hooks/useSellingSubscription.js";let ProductSubscription=({styles:h,setting:S})=>{let{sellingPlans:j,defaultValue:x}=b(S),T=c(e=>e.setSubscriptionSellingType),N=s(i(h,S)),P=s(l(h?.align)),k=o(r()),v=o(n()),{t:w}=u();return(f(()=>{T(S?.sellingType??y.SUBSCRIPTION)},[T,S?.sellingType]),S?.sellingType!=="one-time"&&j&&0!==j.length)?e("div",{"data-selling-type":S?.sellingType,id:"product-subscription",className:k,style:P,children:t("div",{className:v,style:N,children:[e(d,{setting:S,styles:h}),S?.sellingStyle==="radio"?e(m,{setting:S,defaultValue:x||""}):e(a,{setting:S,defaultValue:x||""}),e(p,{setting:S,styles:h})]})}):e(g,{enable:!0,text:"Not be displayed when published",width:"205px",position:"bottom",className:"gp-arrow-left-offset-10",children:e("div",{className:"gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:e("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:w("This product is only available as a one-time purchase")})})})};export{ProductSubscription as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as l}from"react/jsx-runtime";import{createClass as s}from"@gem-sdk/system";import{useSellingPlanOptions as a}from"../hooks/useSellingPlanOptions.js";import{getSellingPlanDropdownContainerClasses as n,getSellingPlanDropdownLabelClasses as o,getSellingPlanDropdownLabelSpanClasses as r,getSellingPlanDropdownLabelInnerSpanClasses as i,getSellingPlanDropdownSelectClasses as m,getSellingPlanDropdownOptionClasses as t,getSellingPlanDropdownIconContainerClasses as c,getSellingPlanDropdownIconClasses as p}from"../common/classes.js";let SellingPlanDropdown=({setting:d})=>{let{sellingLabel:h}=d??{},f=a(),g=s(n()),N=s(o()),u=s(r()),w=s(i()),v=s(m()),x=s(t()),S=s(c()),b=s(p());return e("div",{className:g,children:[l("label",{htmlFor:"selling-plan-select",className:N,children:l("span",{className:u,children:l("span",{className:w,children:h})})}),l("select",{autoComplete:"off",name:"Select Option",className:v,children:f.map(e=>l("option",{className:x,children:e.label},e.value))}),l("div",{className:S,children:l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",focusable:"false","aria-hidden":"true",role:"presentation",className:b,children:l("path",{d:"M0 5h20L10 15"})})})]})};export{SellingPlanDropdown};
1
+ import{jsxs as e,jsx as l}from"react/jsx-runtime";import{useState as a,useEffect as s}from"react";import{createClass as n}from"@gem-sdk/system";import{useSellingPlanOptions as o}from"../hooks/useSellingPlanOptions.js";import{getSellingPlanDropdownContainerClasses as r,getSellingPlanDropdownLabelClasses as t,getSellingPlanDropdownLabelSpanClasses as i,getSellingPlanDropdownLabelInnerSpanClasses as m,getSellingPlanDropdownSelectClasses as c,getSellingPlanDropdownOptionClasses as p,getSellingPlanDropdownIconContainerClasses as d,getSellingPlanDropdownIconClasses as h}from"../common/classes.js";let SellingPlanDropdown=({setting:u,defaultValue:v})=>{let{sellingLabel:f}=u??{},g=o(u),[N,w]=a(v||g[0]?.value||"");s(()=>{if(v)w(v);else if(g.length>0){let e=g[0];e?.value&&w(l=>l||e.value)}},[v,g]);let x=n(r()),S=n(t()),b=n(i()),j=n(m()),P=n(c()),k=n(p()),C=n(d()),D=n(h());return e("div",{className:x,children:[l("label",{htmlFor:"selling-plan-select",className:S,children:l("span",{className:b,children:l("span",{className:j,children:f})})}),l("select",{autoComplete:"off",name:"Select Option",className:P,value:N,onChange:e=>w(e.target.value),children:g.map(e=>l("option",{className:k,value:e.value,children:e.label},e.value))}),l("div",{className:C,children:l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",focusable:"false","aria-hidden":"true",role:"presentation",className:D,children:l("path",{d:"M0 5h20L10 15"})})})]})};export{SellingPlanDropdown};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as l}from"react/jsx-runtime";import{useState as a}from"react";import{createClass as i}from"@gem-sdk/system";import{SubscriptionRadio as o}from"./SubscriptionRadio.js";import{useSellingPlanOptions as r}from"../hooks/useSellingPlanOptions.js";import{getSellingPlanRadioContainerClasses as s,getSellingPlanRadioLabelClasses as m,getSellingPlanRadioOptionsClasses as n,getSellingPlanRadioOptionTextClasses as t}from"../common/classes.js";let SellingPlanRadio=({setting:c})=>{let{sellingLabel:p}=c??{},[d,u]=a("1 week"),h=r(),g=i(s()),v=i(m()),f=i(n()),j=i(t());return e("div",{className:g,children:[p&&l("label",{className:v,children:p}),l("div",{className:f,children:h.map(e=>l(o,{name:"selling-plan-options",value:e.value,checked:d===e.value,onChange:e=>u(e.target.value),children:l("span",{className:j,children:e.label})},e.value))})]})};export{SellingPlanRadio};
1
+ import{jsxs as e,jsx as l}from"react/jsx-runtime";import{useState as a,useEffect as i}from"react";import{createClass as o}from"@gem-sdk/system";import{SubscriptionRadio as r}from"./SubscriptionRadio.js";import{useSellingPlanOptions as s}from"../hooks/useSellingPlanOptions.js";import{getSellingPlanRadioContainerClasses as m,getSellingPlanRadioLabelClasses as n,getSellingPlanRadioOptionsClasses as t,getSellingPlanRadioOptionTextClasses as c}from"../common/classes.js";let SellingPlanRadio=({setting:p,defaultValue:d})=>{let{sellingLabel:u}=p??{},h=s(p),[v,g]=a(d||h[0]?.value||"");i(()=>{d&&g(d)},[d]);let f=o(m()),j=o(n()),N=o(t()),S=o(c());return e("div",{className:f,children:[u&&l("label",{className:j,children:u}),l("div",{className:N,children:h.map(e=>l(r,{name:"selling-plan-options",value:e.value,checked:v===e.value,onChange:e=>g(e.target.value),children:l("span",{className:S,children:e.label})},e.value))})]})};export{SellingPlanRadio};
@@ -1 +1 @@
1
- let useSellingPlanOptions=()=>{let e=[{label:"Delivery each 1 week",value:"1 week"},{label:"Delivery each 2 weeks",value:"2 weeks"},{label:"Delivery each 3 weeks",value:"3 weeks"}];return e};export{useSellingPlanOptions};
1
+ import{useSellingSubscription as e}from"./useSellingSubscription.js";let useSellingPlanOptions=l=>{let{sellingPlans:n}=e(l);return n||[]};export{useSellingPlanOptions};
@@ -0,0 +1 @@
1
+ import{useRef as e,useEffect as l,useMemo as n}from"react";import{useProduct as t,useVariants as i,useSelectedOption as s,usePageStore as u,useEditorMode as r,RenderModeEnv as a}from"@gem-sdk/core";import{extractSellingPlanSettings as o}from"../common/extractSellingPlanSettings.js";let useSellingSubscription=p=>{let d=t(),f=i(),{selectedOptions:g}=s(),c=u(e=>e.sellingPlanMeta),m=r(),v=e(!1);l(()=>{if(!v.current&&m===a.EDIT&&!c){let e=new CustomEvent("element-subscription-mount");globalThis.dispatchEvent(e),v.current=!0}},[m,c]);let P=c??p?.sellingPlans,b=n(()=>{if(!P)return{sourceApp:void 0,group:void 0,defaultOptions:void 0};let e=null;return c&&g&&(e=f.find(e=>!!e?.selectedOptions&&e.selectedOptions.every(e=>g[e.name??""]===e.value))??null),o({sellingPlansSetting:P,currentVariant:e,isFromEvent:!!c})},[P,c,f,g]),O=n(()=>{if(!g||!f||0===f.length)return null;let e=f.find(e=>!!e?.selectedOptions&&e.selectedOptions.every(e=>g[e.name??""]===e.value))??null;return e},[g,f]),{sellingPlans:D,defaultValue:I}=n(()=>{let e;let l=O?.sellingPlanGroups??d?.sellingPlanGroups??[];if(!l||0===l.length||!b.sourceApp||!b.group)return{sellingPlans:[],defaultValue:void 0};let n=l.find(e=>null!=e&&e.appID===b.sourceApp&&e.id===b.group),t=n?.sellingPlans?.filter(e=>null!=e).map(e=>({label:e.name,value:e.baseID}))??[];if(b.defaultOptions){let l=n?.sellingPlans?.find(e=>null!=e&&e.baseID===b.defaultOptions),i=n?.sellingPlans?.find(e=>null!=e&&e.id===b.defaultOptions);e=l?.baseID??i?.baseID??t[0]?.value}else e=t[0]?.value;return{sellingPlans:t,defaultValue:e}},[d,O,b]);return{sellingPlans:D,defaultValue:I}};export{useSellingSubscription};
@@ -1 +1 @@
1
- import{postPurchaseSpacing as e}from"../../../../common/constants.js";let ProductSubscriptionSettings=[{id:"setting",controls:[{id:"sellingType",label:"Type",type:"select",options:[{value:"one-time",label:"One-time"},{value:"subscription",label:"Subscription"}],default:"subscription"},{id:"sellingTitle",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Subscribe and save up to {total_max_discount}",suggestContents:[{message:"{total_max_discount}",eg:"E.g: 50% (offer’s + plan’s max discount)"},{message:"{offer_selling_plan_discount}",eg:"E.g: 20%"}]},{id:"sellingLabel",label:"Text",type:"input",default:"Purchase options",placeholder:"E.g. Purchase options",clearButton:!1},{id:"sellingStyle",label:"Style",type:"option:illustration",default:"dropdown",options:[{label:"Dropdown",value:"dropdown",svgName:"gp-selling-plan-dropdown"},{label:"Radio",value:"radio",svgName:"gp-selling-plan-radio"}]},{id:"subscriptionLabel",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",suggestContents:[{message:"{selling_plan_delivery_frequency}",eg:"E.g: every week"},{message:"{selling_plan_discount}",eg:"E.g: 10%"},{message:"{selling_plan_billing_cycle}",eg:"E.g: every 1 month"}]},{id:"enableSubscriptionDetail",label:"Enable subscription detail",type:"toggle",default:!1}]},{id:"style",controls:[{id:"sellingTitleDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"subscriptionDetailDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"sellingPlanItemGap",type:"select",label:"Item gap",options:e,default:"tight"},{id:"sellingTitleTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"sellingTitleAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"subscriptionDetailTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"subscriptionDetailAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"width",type:"dropdown:input",label:"Width",inputType:"number",units:["px","%"],hideUnit:!1,devices:{desktop:{default:"100%"},tablet:{default:"100%"},mobile:{default:"100%"}},displayOptions:[{label:"Fit content",value:"Auto",showValue:!0},{label:"Full",value:"100%",showValue:!0}]},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:"#DDDDDD"}},enableGradient:!0},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left",iconName:"gp-align-left"},{label:"Center",value:"center",type:"align",tooltip:"Align center",iconName:"gp-align-center"},{label:"Right",value:"right",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"left"}]}];export{ProductSubscriptionSettings};
1
+ import{postPurchaseSpacing as e}from"../../../../common/constants.js";let ProductSubscriptionSettings=[{id:"setting",controls:[{id:"sellingType",label:"Type",type:"pick-subscription",options:[{value:"one-time",label:"One-time"},{value:"subscription",label:"Subscription"}],default:"subscription"},{id:"sellingPlans",label:"Selling plans",type:"selling-plan"},{id:"sellingTitle",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Subscribe and save up to {total_max_discount}",suggestContents:[{message:"{total_max_discount}",eg:"E.g: 50% (offer’s + plan’s max discount)"},{message:"{offer_selling_plan_discount}",eg:"E.g: 20%"}]},{id:"sellingLabel",label:"Text",type:"input",default:"Purchase options",placeholder:"E.g. Purchase options",clearButton:!1},{id:"sellingStyle",label:"Style",type:"option:illustration",default:"dropdown",options:[{label:"Dropdown",value:"dropdown",svgName:"gp-selling-plan-dropdown"},{label:"Radio",value:"radio",svgName:"gp-selling-plan-radio"}]},{id:"subscriptionLabel",label:"Text",type:"textarea",defaultRows:4,showPlusBtn:!0,autoHeight:!0,minHeight:72,default:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",suggestContents:[{message:"{selling_plan_delivery_frequency}",eg:"E.g: every week"},{message:"{selling_plan_discount}",eg:"E.g: 10%"},{message:"{selling_plan_billing_cycle}",eg:"E.g: every 1 month"}]},{id:"enableSubscriptionDetail",label:"Enable subscription detail",type:"toggle",default:!1}]},{id:"style",controls:[{id:"sellingTitleDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"subscriptionDetailDirection",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"},{id:"sellingPlanItemGap",type:"select",label:"Item gap",options:e,default:"tight"},{id:"sellingTitleTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"sellingTitleAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"subscriptionDetailTypo",label:"Label",type:"typography-post-purchase",default:{fontSize:"default",textColor:"default",fontWeight:"normal",textTransform:"none"}},{id:"subscriptionDetailAlign",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"text",tooltip:"Align left",iconName:"polaris-text-align-left"},{label:"Center",value:"center",type:"text",tooltip:"Align center",iconName:"polaris-text-align-center"},{label:"Right",value:"right",type:"text",tooltip:"Align right",iconName:"polaris-text-align-right"}],default:"left"},{id:"width",type:"dropdown:input",label:"Width",inputType:"number",units:["px","%"],hideUnit:!1,devices:{desktop:{default:"100%"},tablet:{default:"100%"},mobile:{default:"100%"}},displayOptions:[{label:"Fit content",value:"Auto",showValue:!0},{label:"Full",value:"100%",showValue:!0}]},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:"#DDDDDD"}},enableGradient:!0},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left",iconName:"gp-align-left"},{label:"Center",value:"center",type:"align",tooltip:"Align center",iconName:"gp-align-center"},{label:"Right",value:"right",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"left"}]}];export{ProductSubscriptionSettings};
@@ -1 +1 @@
1
- let SettingUIV2=[{label:{en:"Selling options"},controls:[{type:"control",label:{en:"Type"},setting:{id:"sellingType"}},{type:"combo",label:{en:"Title"},iconName:"polaris-text-block",getValueFromSettingID:"sellingTitle",compoDefaultValue:"Subscribe and save up to {total_max_discount}",popoverLabel:{en:"Selling option title"},isHideClear:!0,controls:[{label:{en:"Content"},setting:{id:"sellingTitle"},layout:"vertical"},{type:"control",label:{en:"Direction"},setting:{id:"sellingTitleDirection"}},{type:"control",label:{en:""},setting:{id:"sellingTitleTypo"},layout:"vertical"},{type:"control",setting:{id:"sellingTitleAlign"},label:{en:"Align"}}]}]},{label:{en:"Selling plans"},controls:[{type:"control",label:{en:"Label"},setting:{id:"sellingLabel"},layout:"horizontal"},{type:"control",label:{en:"Style"},setting:{id:"sellingStyle"},layout:"horizontal"},{type:"control",label:{en:"Item gap"},setting:{id:"sellingPlanItemGap"},layout:"horizontal",conditionDisplay:"sellingStyle === 'radio'"}]},{controls:[{type:"control",label:{en:"Subscription detail"},setting:{id:"enableSubscriptionDetail"},options:{labelVariant:"primary",toggleStyle:"switch",fullWidth:!0}},{type:"combo",label:{en:"Label"},iconName:"polaris-text-block",getValueFromSettingID:"subscriptionLabel",compoDefaultValue:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",popoverLabel:{en:"Subscription detail"},isHideClear:!0,conditionDisplay:"enableSubscriptionDetail === true",controls:[{label:{en:"Content"},setting:{id:"subscriptionLabel"},layout:"vertical"}]},{type:"control",label:{en:"Direction"},setting:{id:"subscriptionDetailDirection"},conditionDisplay:"enableSubscriptionDetail === true",controlChangeTrigger:{settings:[{action:{controlId:"subscriptionDetailAlign",newValue:"right",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'rtl' && subscriptionDetailAlign === 'left'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]},{action:{controlId:"subscriptionDetailAlign",newValue:"left",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'ltr' && subscriptionDetailAlign === 'right'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]}],options:{noRecordHistory:!0}}},{type:"control",label:{en:""},setting:{id:"subscriptionDetailTypo"},layout:"vertical",conditionDisplay:"enableSubscriptionDetail === true"},{type:"control",setting:{id:"subscriptionDetailAlign"},label:{en:"Align"},conditionDisplay:"enableSubscriptionDetail === true"}]},{label:{en:"Size"},controls:[{type:"control",label:{en:"Width"},setting:{id:"width"},layout:"horizontal"}]},{label:{en:"Background"},controls:[{label:{en:"Color"},setting:{id:"backgroundColor"}}]},{controls:[{label:{en:"Align"},conditionEnable:"activeScreenId === 'desktop' ? !(parseInt(width) >= 100 && width?.includes(\"%\")) : (!(parseInt(width) >= 100 && width?.includes(\"%\")) && width !== 'default')",setting:{id:"align"},options:{labelVariant:"primary",fullWidth:!0,disableMessage:"Horizontal alignment is disabled when the width is set to 100% or greater"}}]}];export{SettingUIV2};
1
+ let SettingUIV2=[{label:{en:"Selling options"},controls:[{type:"control",label:{en:"Type"},setting:{id:"sellingType"}},{type:"combo",label:{en:"Title"},iconName:"polaris-text-block",getValueFromSettingID:"sellingTitle",compoDefaultValue:"Subscribe and save up to {total_max_discount}",popoverLabel:{en:"Selling option title"},isHideClear:!0,controls:[{label:{en:"Content"},setting:{id:"sellingTitle"},layout:"vertical"},{type:"control",label:{en:"Direction"},setting:{id:"sellingTitleDirection"}},{type:"control",label:{en:""},setting:{id:"sellingTitleTypo"},layout:"vertical"},{type:"control",setting:{id:"sellingTitleAlign"},label:{en:"Align"}}]}]},{label:{en:"Selling plans"},controls:[{type:"control",label:{en:"Selling plans"},setting:{id:"sellingPlans"}},{type:"control",label:{en:"Label"},setting:{id:"sellingLabel"},layout:"horizontal"},{type:"control",label:{en:"Style"},setting:{id:"sellingStyle"},layout:"horizontal"},{type:"control",label:{en:"Item gap"},setting:{id:"sellingPlanItemGap"},layout:"horizontal",conditionDisplay:"sellingStyle === 'radio'"}]},{controls:[{type:"control",label:{en:"Subscription detail"},setting:{id:"enableSubscriptionDetail"},options:{labelVariant:"primary",toggleStyle:"switch",fullWidth:!0}},{type:"combo",label:{en:"Label"},iconName:"polaris-text-block",getValueFromSettingID:"subscriptionLabel",compoDefaultValue:"Delivery every {selling_plan_delivery_frequency}, save {selling_plan_discount}",popoverLabel:{en:"Subscription detail"},isHideClear:!0,conditionDisplay:"enableSubscriptionDetail === true",controls:[{label:{en:"Content"},setting:{id:"subscriptionLabel"},layout:"vertical"}]},{type:"control",label:{en:"Direction"},setting:{id:"subscriptionDetailDirection"},conditionDisplay:"enableSubscriptionDetail === true",controlChangeTrigger:{settings:[{action:{controlId:"subscriptionDetailAlign",newValue:"right",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'rtl' && subscriptionDetailAlign === 'left'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]},{action:{controlId:"subscriptionDetailAlign",newValue:"left",groupType:"style",controlType:"style"},condition:"subscriptionDetailDirection === 'ltr' && subscriptionDetailAlign === 'right'",source:["subscriptionDetailDirection","subscriptionDetailAlign"]}],options:{noRecordHistory:!0}}},{type:"control",label:{en:""},setting:{id:"subscriptionDetailTypo"},layout:"vertical",conditionDisplay:"enableSubscriptionDetail === true"},{type:"control",setting:{id:"subscriptionDetailAlign"},label:{en:"Align"},conditionDisplay:"enableSubscriptionDetail === true"}]},{label:{en:"Size"},controls:[{type:"control",label:{en:"Width"},setting:{id:"width"},layout:"horizontal"}]},{label:{en:"Background"},controls:[{label:{en:"Color"},setting:{id:"backgroundColor"}}]},{controls:[{label:{en:"Align"},conditionEnable:"activeScreenId === 'desktop' ? !(parseInt(width) >= 100 && width?.includes(\"%\")) : (!(parseInt(width) >= 100 && width?.includes(\"%\")) && width !== 'default')",setting:{id:"align"},options:{labelVariant:"primary",fullWidth:!0,disableMessage:"Horizontal alignment is disabled when the width is set to 100% or greater"}}]}];export{SettingUIV2};
@@ -3076,6 +3076,15 @@ type ProductSubscriptionSettingProps = {
3076
3076
  sellingTitle?: string;
3077
3077
  subscriptionLabel?: string;
3078
3078
  enableSubscriptionDetail?: boolean;
3079
+ sellingPlans?: {
3080
+ [key: string]: {
3081
+ [key: string]: {
3082
+ appSource?: string;
3083
+ group?: string;
3084
+ defaultOption?: string;
3085
+ };
3086
+ };
3087
+ };
3079
3088
  };
3080
3089
  type ProductSubscriptionStyleProps = {
3081
3090
  sellingTitleDirection?: 'ltr' | 'rtl';
@@ -3084,10 +3093,11 @@ type ProductSubscriptionStyleProps = {
3084
3093
  subscriptionDetailDirection?: 'ltr' | 'rtl';
3085
3094
  subscriptionDetailTypo?: PostPurchaseTypo;
3086
3095
  subscriptionDetailAlign?: AlignItemProp;
3087
- sellingPlanItemGap?: keyof typeof postPurchaseSpacing | undefined;
3096
+ sellingPlanItemGap?: keyof typeof postPurchaseSpacing;
3088
3097
  width?: ObjectDevices<string>;
3089
3098
  backgroundColor?: ObjectDevices<string | undefined>;
3090
3099
  align?: AlignItemProp;
3100
+ sellingPlanId?: string;
3091
3101
  };
3092
3102
  type PostPurchaseProductSubscriptionProps = BasePropsWrap<ProductSubscriptionSettingProps, ProductSubscriptionStyleProps> & {
3093
3103
  advanced?: any;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "8.0.0-dev.108",
3
+ "version": "8.0.0-dev.110",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
7
+ "types": "dist/types/index.d.ts",
7
8
  "files": [
8
9
  "dist"
9
10
  ],
@@ -26,11 +27,11 @@
26
27
  "i18n:generate": "node ./scripts/update-locales-to-setting.js"
27
28
  },
28
29
  "devDependencies": {
29
- "@gem-sdk/core": "8.0.0-dev.107",
30
- "@gem-sdk/styles": "8.0.0-dev.106",
31
- "@gem-sdk/system": "8.0.0-dev.106",
30
+ "@gem-sdk/core": "8.0.0-dev.110",
31
+ "@gem-sdk/styles": "8.0.0-dev.110",
32
+ "@gem-sdk/system": "8.0.0-dev.110",
32
33
  "@types/react-transition-group": "^4.4.12",
33
- "tsup": "^8.5.0",
34
+ "tsup": "8.5.1",
34
35
  "postcss-import": "^16.1.1",
35
36
  "react-transition-group": "^4.4.5",
36
37
  "@thedutchcoder/postcss-rem-to-px": "^0.0.2",
@@ -49,10 +50,9 @@
49
50
  "react-youtube": "^10.1.0"
50
51
  },
51
52
  "peerDependencies": {
52
- "next": ">=14"
53
+ "next": "14.2.35"
53
54
  },
54
55
  "module": "dist/esm/index.js",
55
- "types": "dist/types/index.d.ts",
56
56
  "exports": {
57
57
  "./package.json": "./package.json",
58
58
  ".": {