@gem-sdk/components 2.0.0-staging.1053 → 2.0.0-staging.1054
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/button/settings/configs/settings.js +1 -1
- package/dist/cjs/post-purchase/product/settings/accept-button/configs/settings.js +1 -1
- package/dist/cjs/product/components/product-variants/ProductVariants.js +1 -1
- package/dist/esm/post-purchase/button/settings/configs/settings.js +1 -1
- package/dist/esm/post-purchase/product/settings/accept-button/configs/settings.js +1 -1
- package/dist/esm/product/components/product-variants/ProductVariants.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const DeclineButtonSettings=[{id:"setting",controls:[{id:"text",label:"Content",type:"select",options:[{value:"No thanks",label:"No thanks"},{value:"Decline offer",label:"Decline offer"}],default:"No thanks"},{id:"buttonType",type:"layout-selector",label:"Style",popoverLabel:{en:"Style"},iconViewBox:"0 0 80 48",enableItemBackground:!0,enableItemOpacity:!0,itemPerRow:2,itemSpacing:"large",default:"secondary",options:[{label:"Outline",value:"secondary",type:"post-purchase-button",iconName:"gp-secondary-button"},{label:"Text link",value:"link",type:"post-purchase-button",iconName:"gp-link-button"}]}]},{id:"style",controls:[{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:"
|
|
1
|
+
"use strict";const DeclineButtonSettings=[{id:"setting",controls:[{id:"text",label:"Content",type:"select",options:[{value:"No thanks",label:"No thanks"},{value:"Decline offer",label:"Decline offer"}],default:"No thanks"},{id:"buttonType",type:"layout-selector",label:"Style",popoverLabel:{en:"Style"},iconViewBox:"0 0 80 48",enableItemBackground:!0,enableItemOpacity:!0,itemPerRow:2,itemSpacing:"large",default:"secondary",options:[{label:"Outline",value:"secondary",type:"post-purchase-button",iconName:"gp-secondary-button"},{label:"Text link",value:"link",type:"post-purchase-button",iconName:"gp-link-button"}]}]},{id:"style",controls:[{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:"Full",value:"100%",showValue:!0}]},{id:"typo",label:"Label",type:"typography-post-purchase",default:{fontSize:"medium",fontWeight:"bold",textTransform:"none"},hiddenSetting:["textColor","fontWeight"]},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"start",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:"end",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"start"},{id:"direction",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"}]}];exports.DeclineButtonSettings=DeclineButtonSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const AcceptButtonSettings=[{id:"setting",controls:[{id:"outOfStockLabel",type:"input",label:"Out Of Stock Message",default:"Out of stock",clearButton:!1},{id:"text",label:"Content",type:"select",options:[{value:"Take the deal",label:"Take the deal"},{value:"Buy",label:"Buy"}],default:"Take the deal"},{id:"buttonType",label:"Style",type:"layout-segment",iconViewBox:"0 0 120 72",enableItemBackground:!0,itemPerRow:2,itemSpacing:"large",options:[{label:"secondary",value:"secondary",type:"post-purchase-button"},{label:"link",value:"link",type:"post-purchase-button"}],default:"primary"}]},{id:"style",controls:[{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:"
|
|
1
|
+
"use strict";const AcceptButtonSettings=[{id:"setting",controls:[{id:"outOfStockLabel",type:"input",label:"Out Of Stock Message",default:"Out of stock",clearButton:!1},{id:"text",label:"Content",type:"select",options:[{value:"Take the deal",label:"Take the deal"},{value:"Buy",label:"Buy"}],default:"Take the deal"},{id:"buttonType",label:"Style",type:"layout-segment",iconViewBox:"0 0 120 72",enableItemBackground:!0,itemPerRow:2,itemSpacing:"large",options:[{label:"secondary",value:"secondary",type:"post-purchase-button"},{label:"link",value:"link",type:"post-purchase-button"}],default:"primary"}]},{id:"style",controls:[{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:"Full",value:"100%",showValue:!0}]},{id:"typo",label:"Label",type:"typography-post-purchase",default:{fontSize:"medium",fontWeight:"bold",textTransform:"none"},hiddenSetting:["textColor","fontWeight"]},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"start",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:"end",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"start"},{id:"direction",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"}]}];exports.AcceptButtonSettings=AcceptButtonSettings;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),Text=require("../../../text/components/Text.js"),index=require("./components/variants/index.js"),Dropdown=require("./components/dropdown-swatches/Dropdown.js"),DropdownGroup=require("./components/dropdown-group/DropdownGroup.js"),NoDataState=require("../../../common/components/NoDataState.js"),system=require("@gem-sdk/system"),styles=require("./common/main/styles.js"),getAttr=require("./common/main/getAttr.js"),classes=require("./common/main/classes.js"),getData=require("./common/main/getData.js"),useGpVariants=require("./hooks/useGpVariants.js"),classes$1=require("./common/variants/classes.js"),styles$1=require("./common/variants/styles.js");const ProductVariants=e=>{let{builderProps:t,styles:s,setting:a}=e,{align:r,optionTypo:o,swatchItemWidth:n,dropdownItemWidth:i,swatchSpacing:l,marginBottom:c}=s??{},{label:p,showAsSwatches:u,layout:m,hasPreSelected:d}=a??{},{uid:y}=t??{},x=core.useVariants(),{mode:j,options:g,variantId:f,elementRef:h,variantGroup:w,isChangeVariant:D,selectedOptions:S,isDefaultVariant:v,getVariantConfiguration:V,redirectProductShopifyLink:q}=useGpVariants.useGpVariants(e,x),R=()=>{let e={};return core.DEVICES.forEach(t=>{let s=core.getResponsiveValueByScreen(n,t);e[t]="auto"===s}),e},C=()=>{let e={};return core.DEVICES.forEach(t=>{e[t]=i?.[t]==="fill"}),e},N=()=>{let t=g?.filter(e=>{let t=V(e.name);return!t?.hide});return t?.map((n,i)=>{let j=V(n.name),h=j?j.optionType:n.optionType,w=j?j.presets[j.optionType||"rectangle_list"]?.spacing:l,v=(d||f)&&n.name?S?.[n.name]:void 0,q=system.createClass(classes.getVariantOptionGroupClass(r)),N=system.createStyle(styles.getVariantOptionGroupStyle(l,w)),T=getData.getTextVariantTitleData(e,"React",{optionName:n.name,hasPreSelected:d,selectedOptions:S,styleOptionSelected:h}),A=system.createClass(classes$1.getWrapVariantOptionClass(m,r)),G=i===t.length-1;return jsxRuntime.jsxs("div",{className:A,style:system.createStyle(styles$1.getMarginBottomStyle(c,G)),children:[system.If(p,jsxRuntime.jsx(Text.default,{...T})),jsxRuntime.jsxs("div",{className:q,style:N,children:[u&&core.OptionSpecialStyle.includes(`${h}`)&&n.values.map(e=>{let t=(!!d||!!D||!!f)&&!!n.name&&S?.[n.name]===e.label;return jsxRuntime.jsx(index.default,{variantKey:`${n.id}-${e.id}`,showAsSwatches:u,uid:y,optionName:n.name??"",optionValue:e.label??"",name:n.name,value:e,optionNumber:g.length,optionPosition:i,...s,...a,presetConfiguration:V(n.name),checked:t,typeOfOption:h||"dropdown",swatchAutoWidth:R(),optionTypo:o},e.id)}),system.If(("dropdown"===h||u&&!core.OptionSpecialStyle.includes(`${h}`))&&"radio_buttons"!==h,jsxRuntime.jsx(Dropdown.default,{...s,...a,variants:x,option:n,initValue:v,presetConfiguration:V(n.name),swatchAutoWidth:C(),optionTypo:o,optionPosition:i,optionNumber:g.length}))]})]},n.id)})},T=system.createClass(classes.getWrapDropdownClass(r)),A=getData.getDropdownGroupData(e),G=()=>jsxRuntime.jsx("div",{className:T,children:jsxRuntime.jsx(DropdownGroup.default,{...A})});if(v&&"edit"===j)return jsxRuntime.jsx(NoDataState.default,{elementType:"secondary",description:"Setup options like colors, sizes with product variant.",descriptionActions:[{text:"Add new variant",callback:q},{text:"sync data",callback:"syncProduct"}]});let b=system.createAttr(getAttr.getAttrs({uid:y,hasPreSelected:d})),O=system.createStyle(styles.getWrapperStyle(e)),$=system.createClass({"gp-flex gp-flex-col !gp-ml-0":!0});return jsxRuntime.jsx("div",{ref:h,...b,className:$,style:O,children:system.If(w,G(),N())})};exports.default=ProductVariants;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),Text=require("../../../text/components/Text.js"),index=require("./components/variants/index.js"),Dropdown=require("./components/dropdown-swatches/Dropdown.js"),DropdownGroup=require("./components/dropdown-group/DropdownGroup.js"),NoDataState=require("../../../common/components/NoDataState.js"),system=require("@gem-sdk/system"),styles=require("./common/main/styles.js"),getAttr=require("./common/main/getAttr.js"),classes=require("./common/main/classes.js"),getData=require("./common/main/getData.js"),useGpVariants=require("./hooks/useGpVariants.js"),classes$1=require("./common/variants/classes.js"),styles$1=require("./common/variants/styles.js");const ProductVariants=e=>{let{builderProps:t,styles:s,setting:a}=e,{align:r,optionTypo:o,swatchItemWidth:n,dropdownItemWidth:i,swatchSpacing:l,marginBottom:c}=s??{},{label:p,showAsSwatches:u,layout:m,hasPreSelected:d}=a??{},{uid:y}=t??{},x=core.useVariants(),{mode:j,options:g,variantId:f,elementRef:h,variantGroup:w,isChangeVariant:D,selectedOptions:S,isDefaultVariant:v,getVariantConfiguration:V,redirectProductShopifyLink:q}=useGpVariants.useGpVariants(e,x),R=()=>{let e={};return core.DEVICES.forEach(t=>{let s=core.getResponsiveValueByScreen(n,t);e[t]="auto"===s}),e},C=()=>{let e={};return core.DEVICES.forEach(t=>{e[t]=i?.[t]==="fill"}),e},N=()=>{let t=g?.filter(e=>{let t=V(e.name);return!t?.hide});return t?.map((n,i)=>{let j=V(n.name),h=j?j.optionType:n.optionType,w=j?j.presets[j.optionType||"rectangle_list"]?.spacing:l,v=(d||f)&&n.name?S?.[n.name]:void 0,q=system.createClass(classes.getVariantOptionGroupClass(r)),N=system.createStyle(styles.getVariantOptionGroupStyle(l,w)),T=getData.getTextVariantTitleData(e,"React",{optionName:n.name,hasPreSelected:d,selectedOptions:S,styleOptionSelected:h}),A=system.createClass(classes$1.getWrapVariantOptionClass(m,r)),G=i===t.length-1;return jsxRuntime.jsxs("div",{className:A,style:system.createStyle(styles$1.getMarginBottomStyle(c,G)),children:[system.If(p,jsxRuntime.jsx(Text.default,{...T})),jsxRuntime.jsxs("div",{className:q,style:N,children:[u&&core.OptionSpecialStyle.includes(`${h}`)&&n.values.map(e=>{let t=(!!d||!!D||!!f)&&!!n.name&&S?.[n.name]===e.label;return jsxRuntime.jsx(index.default,{variantKey:`${n.id}-${e.id}`,showAsSwatches:u,uid:y,optionName:n.name??"",optionValue:e.label??"",name:n.name,value:e,optionNumber:g.length,optionPosition:i,...s,...a,presetConfiguration:V(n.name),checked:t,typeOfOption:h||"dropdown",swatchAutoWidth:R(),optionTypo:o},e.id)}),system.If(("dropdown"===h||u&&!core.OptionSpecialStyle.includes(`${h}`))&&"radio_buttons"!==h,jsxRuntime.jsx(Dropdown.default,{...s,...a,variants:x,option:n,initValue:v,presetConfiguration:V(n.name),swatchAutoWidth:C(),optionTypo:o,optionPosition:i,optionNumber:g.length}))]})]},n.id)})},T=system.createClass(classes.getWrapDropdownClass(r)),A=getData.getDropdownGroupData(e),G=()=>jsxRuntime.jsx("div",{className:T,children:jsxRuntime.jsx(DropdownGroup.default,{...A})});if(v&&"edit"===j)return jsxRuntime.jsx(NoDataState.default,{elementType:"secondary",description:"Setup options like colors, sizes with product variant.",descriptionActions:[{text:"Add new variant",callback:q},{text:"sync data",callback:"syncProduct"}]});if(v)return;let b=system.createAttr(getAttr.getAttrs({uid:y,hasPreSelected:d})),O=system.createStyle(styles.getWrapperStyle(e)),$=system.createClass({"gp-flex gp-flex-col !gp-ml-0":!0});return jsxRuntime.jsx("div",{ref:h,...b,className:$,style:O,children:system.If(w,G(),N())})};exports.default=ProductVariants;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let DeclineButtonSettings=[{id:"setting",controls:[{id:"text",label:"Content",type:"select",options:[{value:"No thanks",label:"No thanks"},{value:"Decline offer",label:"Decline offer"}],default:"No thanks"},{id:"buttonType",type:"layout-selector",label:"Style",popoverLabel:{en:"Style"},iconViewBox:"0 0 80 48",enableItemBackground:!0,enableItemOpacity:!0,itemPerRow:2,itemSpacing:"large",default:"secondary",options:[{label:"Outline",value:"secondary",type:"post-purchase-button",iconName:"gp-secondary-button"},{label:"Text link",value:"link",type:"post-purchase-button",iconName:"gp-link-button"}]}]},{id:"style",controls:[{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:"
|
|
1
|
+
let DeclineButtonSettings=[{id:"setting",controls:[{id:"text",label:"Content",type:"select",options:[{value:"No thanks",label:"No thanks"},{value:"Decline offer",label:"Decline offer"}],default:"No thanks"},{id:"buttonType",type:"layout-selector",label:"Style",popoverLabel:{en:"Style"},iconViewBox:"0 0 80 48",enableItemBackground:!0,enableItemOpacity:!0,itemPerRow:2,itemSpacing:"large",default:"secondary",options:[{label:"Outline",value:"secondary",type:"post-purchase-button",iconName:"gp-secondary-button"},{label:"Text link",value:"link",type:"post-purchase-button",iconName:"gp-link-button"}]}]},{id:"style",controls:[{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:"Full",value:"100%",showValue:!0}]},{id:"typo",label:"Label",type:"typography-post-purchase",default:{fontSize:"medium",fontWeight:"bold",textTransform:"none"},hiddenSetting:["textColor","fontWeight"]},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"start",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:"end",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"start"},{id:"direction",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"}]}];export{DeclineButtonSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let AcceptButtonSettings=[{id:"setting",controls:[{id:"outOfStockLabel",type:"input",label:"Out Of Stock Message",default:"Out of stock",clearButton:!1},{id:"text",label:"Content",type:"select",options:[{value:"Take the deal",label:"Take the deal"},{value:"Buy",label:"Buy"}],default:"Take the deal"},{id:"buttonType",label:"Style",type:"layout-segment",iconViewBox:"0 0 120 72",enableItemBackground:!0,itemPerRow:2,itemSpacing:"large",options:[{label:"secondary",value:"secondary",type:"post-purchase-button"},{label:"link",value:"link",type:"post-purchase-button"}],default:"primary"}]},{id:"style",controls:[{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:"
|
|
1
|
+
let AcceptButtonSettings=[{id:"setting",controls:[{id:"outOfStockLabel",type:"input",label:"Out Of Stock Message",default:"Out of stock",clearButton:!1},{id:"text",label:"Content",type:"select",options:[{value:"Take the deal",label:"Take the deal"},{value:"Buy",label:"Buy"}],default:"Take the deal"},{id:"buttonType",label:"Style",type:"layout-segment",iconViewBox:"0 0 120 72",enableItemBackground:!0,itemPerRow:2,itemSpacing:"large",options:[{label:"secondary",value:"secondary",type:"post-purchase-button"},{label:"link",value:"link",type:"post-purchase-button"}],default:"primary"}]},{id:"style",controls:[{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:"Full",value:"100%",showValue:!0}]},{id:"typo",label:"Label",type:"typography-post-purchase",default:{fontSize:"medium",fontWeight:"bold",textTransform:"none"},hiddenSetting:["textColor","fontWeight"]},{id:"align",label:"Alignment",type:"option:value",options:[{label:"Left",value:"start",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:"end",type:"align",tooltip:"Align right",iconName:"gp-align-right"}],default:"start"},{id:"direction",label:"Direction",type:"option:value",options:[{label:"LTR",value:"ltr"},{label:"RTL",value:"rtl"}],default:"ltr"}]}];export{AcceptButtonSettings};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{jsx as o,jsxs as t}from"react/jsx-runtime";import{useVariants as e,OptionSpecialStyle as n,DEVICES as r,getResponsiveValueByScreen as i}from"@gem-sdk/core";import a from"../../../text/components/Text.js";import s from"./components/variants/index.js";import m from"./components/dropdown-swatches/Dropdown.js";import p from"./components/dropdown-group/DropdownGroup.js";import l from"../../../common/components/NoDataState.js";import{createClass as c,createAttr as d,createStyle as u,If as f}from"@gem-sdk/system";import{getWrapperStyle as h,getVariantOptionGroupStyle as y}from"./common/main/styles.js";import{getAttrs as g}from"./common/main/getAttr.js";import{getWrapDropdownClass as v,getVariantOptionGroupClass as j}from"./common/main/classes.js";import{getDropdownGroupData as w,getTextVariantTitleData as x}from"./common/main/getData.js";import{useGpVariants as N}from"./hooks/useGpVariants.js";import{getWrapVariantOptionClass as b}from"./common/variants/classes.js";import{getMarginBottomStyle as k}from"./common/variants/styles.js";let ProductVariants=T=>{let{builderProps:A,styles:P,setting:V}=T,{align:D,optionTypo:$,swatchItemWidth:S,dropdownItemWidth:C,swatchSpacing:E,marginBottom:G}=P??{},{label:O,showAsSwatches:W,layout:_,hasPreSelected:z}=V??{},{uid:K}=A??{},R=e(),{mode:q,options:B,variantId:F,elementRef:H,variantGroup:I,isChangeVariant:J,selectedOptions:L,isDefaultVariant:M,getVariantConfiguration:Q,redirectProductShopifyLink:U}=N(T,R),X=()=>{let o={};return r.forEach(t=>{let e=i(S,t);o[t]="auto"===e}),o},Y=()=>{let o={};return r.forEach(t=>{o[t]=C?.[t]==="fill"}),o},Z=()=>{let e=B?.filter(o=>{let t=Q(o.name);return!t?.hide});return e?.map((r,i)=>{let p=Q(r.name),l=p?p.optionType:r.optionType,d=p?p.presets[p.optionType||"rectangle_list"]?.spacing:E,h=(z||F)&&r.name?L?.[r.name]:void 0,g=c(j(D)),v=u(y(E,d)),w=x(T,"React",{optionName:r.name,hasPreSelected:z,selectedOptions:L,styleOptionSelected:l}),N=c(b(_,D)),A=i===e.length-1;return t("div",{className:N,style:u(k(G,A)),children:[f(O,o(a,{...w})),t("div",{className:g,style:v,children:[W&&n.includes(`${l}`)&&r.values.map(t=>{let e=(!!z||!!J||!!F)&&!!r.name&&L?.[r.name]===t.label;return o(s,{variantKey:`${r.id}-${t.id}`,showAsSwatches:W,uid:K,optionName:r.name??"",optionValue:t.label??"",name:r.name,value:t,optionNumber:B.length,optionPosition:i,...P,...V,presetConfiguration:Q(r.name),checked:e,typeOfOption:l||"dropdown",swatchAutoWidth:X(),optionTypo:$},t.id)}),f(("dropdown"===l||W&&!n.includes(`${l}`))&&"radio_buttons"!==l,o(m,{...P,...V,variants:R,option:r,initValue:h,presetConfiguration:Q(r.name),swatchAutoWidth:Y(),optionTypo:$,optionPosition:i,optionNumber:B.length}))]})]},r.id)})},oo=c(v(D)),ot=w(T),oe=()=>o("div",{className:oo,children:o(p,{...ot})});if(M&&"edit"===q)return o(l,{elementType:"secondary",description:"Setup options like colors, sizes with product variant.",descriptionActions:[{text:"Add new variant",callback:U},{text:"sync data",callback:"syncProduct"}]});let on=d(g({uid:K,hasPreSelected:z})),or=u(h(T)),oi=c({"gp-flex gp-flex-col !gp-ml-0":!0});return o("div",{ref:H,...on,className:oi,style:or,children:f(I,oe(),Z())})};export{ProductVariants as default};
|
|
2
|
+
import{jsx as o,jsxs as t}from"react/jsx-runtime";import{useVariants as e,OptionSpecialStyle as n,DEVICES as r,getResponsiveValueByScreen as i}from"@gem-sdk/core";import a from"../../../text/components/Text.js";import s from"./components/variants/index.js";import m from"./components/dropdown-swatches/Dropdown.js";import p from"./components/dropdown-group/DropdownGroup.js";import l from"../../../common/components/NoDataState.js";import{createClass as c,createAttr as d,createStyle as u,If as f}from"@gem-sdk/system";import{getWrapperStyle as h,getVariantOptionGroupStyle as y}from"./common/main/styles.js";import{getAttrs as g}from"./common/main/getAttr.js";import{getWrapDropdownClass as v,getVariantOptionGroupClass as j}from"./common/main/classes.js";import{getDropdownGroupData as w,getTextVariantTitleData as x}from"./common/main/getData.js";import{useGpVariants as N}from"./hooks/useGpVariants.js";import{getWrapVariantOptionClass as b}from"./common/variants/classes.js";import{getMarginBottomStyle as k}from"./common/variants/styles.js";let ProductVariants=T=>{let{builderProps:A,styles:P,setting:V}=T,{align:D,optionTypo:$,swatchItemWidth:S,dropdownItemWidth:C,swatchSpacing:E,marginBottom:G}=P??{},{label:O,showAsSwatches:W,layout:_,hasPreSelected:z}=V??{},{uid:K}=A??{},R=e(),{mode:q,options:B,variantId:F,elementRef:H,variantGroup:I,isChangeVariant:J,selectedOptions:L,isDefaultVariant:M,getVariantConfiguration:Q,redirectProductShopifyLink:U}=N(T,R),X=()=>{let o={};return r.forEach(t=>{let e=i(S,t);o[t]="auto"===e}),o},Y=()=>{let o={};return r.forEach(t=>{o[t]=C?.[t]==="fill"}),o},Z=()=>{let e=B?.filter(o=>{let t=Q(o.name);return!t?.hide});return e?.map((r,i)=>{let p=Q(r.name),l=p?p.optionType:r.optionType,d=p?p.presets[p.optionType||"rectangle_list"]?.spacing:E,h=(z||F)&&r.name?L?.[r.name]:void 0,g=c(j(D)),v=u(y(E,d)),w=x(T,"React",{optionName:r.name,hasPreSelected:z,selectedOptions:L,styleOptionSelected:l}),N=c(b(_,D)),A=i===e.length-1;return t("div",{className:N,style:u(k(G,A)),children:[f(O,o(a,{...w})),t("div",{className:g,style:v,children:[W&&n.includes(`${l}`)&&r.values.map(t=>{let e=(!!z||!!J||!!F)&&!!r.name&&L?.[r.name]===t.label;return o(s,{variantKey:`${r.id}-${t.id}`,showAsSwatches:W,uid:K,optionName:r.name??"",optionValue:t.label??"",name:r.name,value:t,optionNumber:B.length,optionPosition:i,...P,...V,presetConfiguration:Q(r.name),checked:e,typeOfOption:l||"dropdown",swatchAutoWidth:X(),optionTypo:$},t.id)}),f(("dropdown"===l||W&&!n.includes(`${l}`))&&"radio_buttons"!==l,o(m,{...P,...V,variants:R,option:r,initValue:h,presetConfiguration:Q(r.name),swatchAutoWidth:Y(),optionTypo:$,optionPosition:i,optionNumber:B.length}))]})]},r.id)})},oo=c(v(D)),ot=w(T),oe=()=>o("div",{className:oo,children:o(p,{...ot})});if(M&&"edit"===q)return o(l,{elementType:"secondary",description:"Setup options like colors, sizes with product variant.",descriptionActions:[{text:"Add new variant",callback:U},{text:"sync data",callback:"syncProduct"}]});if(M)return;let on=d(g({uid:K,hasPreSelected:z})),or=u(h(T)),oi=c({"gp-flex gp-flex-col !gp-ml-0":!0});return o("div",{ref:H,...on,className:oi,style:or,children:f(I,oe(),Z())})};export{ProductVariants as default};
|