@gem-sdk/components 2.0.0-staging.772 → 2.0.0-staging.774
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/marquee/settings/configs/settings-v2.js +1 -1
- package/dist/cjs/product/components/product-variants/ProductVariants.js +1 -1
- package/dist/esm/marquee/settings/configs/settings-v2.js +1 -1
- package/dist/esm/product/components/product-variants/ProductVariants.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var childTemplate=require("./child-template.js");const MarqueeSettingsV2=[{id:"setting",controls:[{id:"itemWidthType",type:"select",options:[{label:"Fit to content",value:"FIT_CONTENT",subTitle:"Match the width of the element inside",disableHoverIcon:!0},{label:"Based on the item count",value:"BASE_ON_NUMBER_OF_ITEMS",subTitle:"Max item width is screen width divided by the number of items",disableHoverIcon:!0},{label:"Custom",value:"CUSTOM",subTitle:"Set the max width as you want",disableHoverIcon:!0}],devices:{desktop:{default:"FIT_CONTENT"},tablet:{default:"FIT_CONTENT"},mobile:{default:"CUSTOM"}}},{id:"activeItem",type:"input",default:"0"},{id:"hoverItem",type:"input",default:"0"},{id:"childItem",label:"Item management",type:"child-item",childTemplate:childTemplate.ChildTemplate,default:["Item 1","Item 2","Item 3","Item 4"]},{id:"isShowIconSeparator",label:"isShowIconSeparator",type:"toggle",default:!1},{id:"iconSeparatorSvg",label:"iconSeparatorSvg",type:"icon",default:`<svg height="20px" width="20px" data-name="dot-filled" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor" data-id="508817731477504360">
|
|
2
|
-
<path fill="currentColor" strokelinecap="round" strokelinejoin="round" d="M128,80a48,48,0,1,0,48,48A48,48,0,0,0,128,80Zm0,60a12,12,0,1,1,12-12A12,12,0,0,1,128,140Z"></path></svg>`},{id:"stopOnHover",label:"stopOnHover",type:"toggle",default:!0},{id:"speed",label:"speed",type:"input:slider",hideInput:!0,useOnlyUnitInit:!0,hideUnit:!0,min:0,max:4,step:.1,default:1},{id:"direction",label:"direction",type:"segment",options:[{label:"Left",value:"left",type:"direction",tooltip:"Left"},{label:"Right",value:"right",type:"direction",tooltip:"Right"}],default:"left"},{id:"isPreview",type:"play-pause",hideLabel:!0,default:!1},{id:"hasItemShadow",label:"hasItemShadow",type:"toggle",default:!1}]},{id:"style",controls:[{id:"iconSeparatorSize",label:"iconSeparatorSize",type:"input:stepper",devices:{desktop:{default:16}}},{id:"iconSeparatorColor",label:"iconSeparatorColor",type:"color-picker-v2",default:"text-2"},{id:"itemSpacing",label:"Spacing",type:"input:slider",units:["px"],min:0,max:100,step:1,ignoreMax:!0,placeholder:"Auto",devices:{desktop:{default:"60px"}}},{id:"itemMaxWidth",label:"itemMaxWidth",type:"input:unit",units:["px"],placeholder:"Auto",min:40,devices:{desktop:{default:"300px"},tablet:{default:"300px"},mobile:{default:"150px"}}},{id:"sizeSetting",type:"size-setting",label:"",devices:{desktop:{default:{shapeLinked:!1,width:"100%",height:"auto"}}},settingConfig:{width:{name:"Width"},height:{displayOptions:["auto","small","medium","large"],name:"Height",sizeConfig:{small:"32px",medium:"64px",large:"96px"}}},hiddenSettings:["gap","shape","padding"]},{id:"itemBorderStyle",type:"border",label:"Border",default:{borderType:"none",border:"none",borderWidth:"1px",width:"1px 1px 1px 1px",isCustom:!1,color:"#000000"}},{id:"itemCorner",type:"radius-preset",label:"Border Radius",default:{radiusType:"none"}},{id:"itemBackgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"align",label:"Alignment",type:"segment",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left"},{label:"Center",value:"center",type:"align",tooltip:"Align center"},{label:"Right",value:"right",type:"align",tooltip:"Align right"}],devices:{desktop:{default:"center"}}},{id:"itemShadow",type:"shadow-v2",label:"Button Shadow",default:{type:"none",distance:"4px",blur:"12px",spread:"0px",color:"#121212",angle:90}}]}];exports.MarqueeSettingsV2=MarqueeSettingsV2;
|
|
2
|
+
<path fill="currentColor" strokelinecap="round" strokelinejoin="round" d="M128,80a48,48,0,1,0,48,48A48,48,0,0,0,128,80Zm0,60a12,12,0,1,1,12-12A12,12,0,0,1,128,140Z"></path></svg>`},{id:"stopOnHover",label:"stopOnHover",type:"toggle",default:!0},{id:"speed",label:"speed",type:"input:slider",hideInput:!0,useOnlyUnitInit:!0,hideUnit:!0,min:0,max:4,step:.1,default:1},{id:"direction",label:"direction",type:"segment",options:[{label:"Left",value:"left",type:"direction",tooltip:"Left"},{label:"Right",value:"right",type:"direction",tooltip:"Right"}],default:"left"},{id:"isPreview",type:"play-pause",hideLabel:!0,default:!1},{id:"hasItemShadow",label:"hasItemShadow",type:"toggle",default:!1}]},{id:"style",controls:[{id:"iconSeparatorSize",label:"iconSeparatorSize",type:"input:stepper",devices:{desktop:{default:16}}},{id:"iconSeparatorColor",label:"iconSeparatorColor",type:"color-picker-v2",default:"text-2"},{id:"itemSpacing",label:"Spacing",type:"input:slider",units:["px"],min:0,max:100,step:1,ignoreMax:!0,placeholder:"Auto",devices:{desktop:{default:"60px"}}},{id:"itemMaxWidth",label:"itemMaxWidth",type:"input:unit",units:["px"],placeholder:"Auto",min:40,devices:{desktop:{default:"300px"},tablet:{default:"300px"},mobile:{default:"150px"}}},{id:"sizeSetting",type:"size-setting",label:"",devices:{desktop:{default:{shapeLinked:!1,width:"100%",height:"auto"}}},settingConfig:{width:{name:"Width"},height:{displayOptions:["auto","small","medium","large"],name:"Height",sizeConfig:{small:"32px",medium:"64px",large:"96px"}}},hiddenSettings:["gap","shape","padding"]},{id:"itemBorderStyle",type:"border",label:"Border",default:{borderType:"none",border:"none",borderWidth:"1px",width:"1px 1px 1px 1px",isCustom:!1,color:"#000000"}},{id:"itemCorner",type:"radius-preset",label:"Border Radius",default:{radiusType:"none"}},{id:"itemBackgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"align",label:"Alignment",type:"segment",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left"},{label:"Center",value:"center",type:"align",tooltip:"Align center"},{label:"Right",value:"right",type:"align",tooltip:"Align right"}],devices:{desktop:{default:"center"}}},{id:"itemShadow",type:"shadow-v2",label:"Button Shadow",default:{type:"none",distance:"4px",blur:"12px",spread:"0px",color:"#121212",angle:90,enable:!1}}]}];exports.MarqueeSettingsV2=MarqueeSettingsV2;
|
|
@@ -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");const ProductVariants=e=>{let{builderProps:t,styles:s,setting:a}=e,{align:r,optionTypo:o,swatchItemWidth:n,dropdownItemWidth:i,swatchSpacing:l}=s??{},{label:p,showAsSwatches:c,layout:u,hasPreSelected:m}=a??{},{uid:d}=t??{},y=core.useVariants(),{mode:j,options:x,variantId:g,elementRef:f,variantGroup:h,isChangeVariant:w,selectedOptions:D,isDefaultVariant:v,getVariantConfiguration:S,redirectProductShopifyLink:V}=useGpVariants.useGpVariants(e,y),q=()=>{let e={};return core.DEVICES.forEach(t=>{let s=core.getResponsiveValueByScreen(n,t);e[t]="auto"===s}),e},R=()=>{let e={};return core.DEVICES.forEach(t=>{e[t]=i?.[t]==="fill"}),e},C=()=>x?.map((t,n)=>{let i=S(t.name),j=i?i.optionType:t.optionType,f=i?i.presets[i.optionType||"rectangle_list"]?.spacing:l,h=(m||g)&&t.name?D?.[t.name]:void 0,v=i?.hide;if(v)return null;let V=system.createClass(classes.getVariantOptionGroupClass(r)),C=system.createStyle(styles.getVariantOptionGroupStyle(l,f)),N=getData.getTextVariantTitleData(e,"React",{optionName:t.name,hasPreSelected:m,selectedOptions:D,styleOptionSelected:j}),T=system.createClass(classes$1.getWrapVariantOptionClass(u,r));return jsxRuntime.jsxs("div",{className:T,children:[system.If(p,jsxRuntime.jsx(Text.default,{...N})),jsxRuntime.jsxs("div",{className:V,style:C,children:[c&&core.OptionSpecialStyle.includes(`${j}`)&&t.values.map(e=>{let r=(!!m||!!w
|
|
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");const ProductVariants=e=>{let{builderProps:t,styles:s,setting:a}=e,{align:r,optionTypo:o,swatchItemWidth:n,dropdownItemWidth:i,swatchSpacing:l}=s??{},{label:p,showAsSwatches:c,layout:u,hasPreSelected:m}=a??{},{uid:d}=t??{},y=core.useVariants(),{mode:j,options:x,variantId:g,elementRef:f,variantGroup:h,isChangeVariant:w,selectedOptions:D,isDefaultVariant:v,getVariantConfiguration:S,redirectProductShopifyLink:V}=useGpVariants.useGpVariants(e,y),q=()=>{let e={};return core.DEVICES.forEach(t=>{let s=core.getResponsiveValueByScreen(n,t);e[t]="auto"===s}),e},R=()=>{let e={};return core.DEVICES.forEach(t=>{e[t]=i?.[t]==="fill"}),e},C=()=>x?.map((t,n)=>{let i=S(t.name),j=i?i.optionType:t.optionType,f=i?i.presets[i.optionType||"rectangle_list"]?.spacing:l,h=(m||g)&&t.name?D?.[t.name]:void 0,v=i?.hide;if(v)return null;let V=system.createClass(classes.getVariantOptionGroupClass(r)),C=system.createStyle(styles.getVariantOptionGroupStyle(l,f)),N=getData.getTextVariantTitleData(e,"React",{optionName:t.name,hasPreSelected:m,selectedOptions:D,styleOptionSelected:j}),T=system.createClass(classes$1.getWrapVariantOptionClass(u,r));return jsxRuntime.jsxs("div",{className:T,children:[system.If(p,jsxRuntime.jsx(Text.default,{...N})),jsxRuntime.jsxs("div",{className:V,style:C,children:[c&&core.OptionSpecialStyle.includes(`${j}`)&&t.values.map(e=>{let r=(!!m||!!w&&!!g)&&!!t.name&&D?.[t.name]===e.label;return jsxRuntime.jsx(index.default,{variantKey:`${t.id}-${e.id}`,showAsSwatches:c,uid:d,optionName:t.name??"",optionValue:e.label??"",name:t.name,value:e,optionNumber:x.length,optionPosition:n,...s,...a,presetConfiguration:S(t.name),checked:r,typeOfOption:j||"dropdown",swatchAutoWidth:q(),optionTypo:o},e.id)}),system.If(("dropdown"===j||c&&!core.OptionSpecialStyle.includes(`${j}`))&&"radio_buttons"!==j,jsxRuntime.jsx(Dropdown.default,{...s,...a,variants:y,option:t,initValue:h,presetConfiguration:S(t.name),swatchAutoWidth:R(),optionTypo:o,optionPosition:n,optionNumber:x.length}))]})]},t.id)}),N=system.createClass(classes.getWrapDropdownClass(r)),T=getData.getDropdownGroupData(e),A=()=>jsxRuntime.jsx("div",{className:N,children:jsxRuntime.jsx(DropdownGroup.default,{...T})});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:V},{text:"sync data",callback:"syncProduct"}]});let G=system.createAttr(getAttr.getAttrs({uid:d,hasPreSelected:m})),b=system.createStyle(styles.getWrapperStyle(e)),O=system.createClass({"gp-grid !gp-ml-0":!0});return jsxRuntime.jsx("div",{ref:f,...G,className:O,style:b,children:system.If(h,A(),C())})};exports.default=ProductVariants;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{ChildTemplate as e}from"./child-template.js";let MarqueeSettingsV2=[{id:"setting",controls:[{id:"itemWidthType",type:"select",options:[{label:"Fit to content",value:"FIT_CONTENT",subTitle:"Match the width of the element inside",disableHoverIcon:!0},{label:"Based on the item count",value:"BASE_ON_NUMBER_OF_ITEMS",subTitle:"Max item width is screen width divided by the number of items",disableHoverIcon:!0},{label:"Custom",value:"CUSTOM",subTitle:"Set the max width as you want",disableHoverIcon:!0}],devices:{desktop:{default:"FIT_CONTENT"},tablet:{default:"FIT_CONTENT"},mobile:{default:"CUSTOM"}}},{id:"activeItem",type:"input",default:"0"},{id:"hoverItem",type:"input",default:"0"},{id:"childItem",label:"Item management",type:"child-item",childTemplate:e,default:["Item 1","Item 2","Item 3","Item 4"]},{id:"isShowIconSeparator",label:"isShowIconSeparator",type:"toggle",default:!1},{id:"iconSeparatorSvg",label:"iconSeparatorSvg",type:"icon",default:`<svg height="20px" width="20px" data-name="dot-filled" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor" data-id="508817731477504360">
|
|
2
|
-
<path fill="currentColor" strokelinecap="round" strokelinejoin="round" d="M128,80a48,48,0,1,0,48,48A48,48,0,0,0,128,80Zm0,60a12,12,0,1,1,12-12A12,12,0,0,1,128,140Z"></path></svg>`},{id:"stopOnHover",label:"stopOnHover",type:"toggle",default:!0},{id:"speed",label:"speed",type:"input:slider",hideInput:!0,useOnlyUnitInit:!0,hideUnit:!0,min:0,max:4,step:.1,default:1},{id:"direction",label:"direction",type:"segment",options:[{label:"Left",value:"left",type:"direction",tooltip:"Left"},{label:"Right",value:"right",type:"direction",tooltip:"Right"}],default:"left"},{id:"isPreview",type:"play-pause",hideLabel:!0,default:!1},{id:"hasItemShadow",label:"hasItemShadow",type:"toggle",default:!1}]},{id:"style",controls:[{id:"iconSeparatorSize",label:"iconSeparatorSize",type:"input:stepper",devices:{desktop:{default:16}}},{id:"iconSeparatorColor",label:"iconSeparatorColor",type:"color-picker-v2",default:"text-2"},{id:"itemSpacing",label:"Spacing",type:"input:slider",units:["px"],min:0,max:100,step:1,ignoreMax:!0,placeholder:"Auto",devices:{desktop:{default:"60px"}}},{id:"itemMaxWidth",label:"itemMaxWidth",type:"input:unit",units:["px"],placeholder:"Auto",min:40,devices:{desktop:{default:"300px"},tablet:{default:"300px"},mobile:{default:"150px"}}},{id:"sizeSetting",type:"size-setting",label:"",devices:{desktop:{default:{shapeLinked:!1,width:"100%",height:"auto"}}},settingConfig:{width:{name:"Width"},height:{displayOptions:["auto","small","medium","large"],name:"Height",sizeConfig:{small:"32px",medium:"64px",large:"96px"}}},hiddenSettings:["gap","shape","padding"]},{id:"itemBorderStyle",type:"border",label:"Border",default:{borderType:"none",border:"none",borderWidth:"1px",width:"1px 1px 1px 1px",isCustom:!1,color:"#000000"}},{id:"itemCorner",type:"radius-preset",label:"Border Radius",default:{radiusType:"none"}},{id:"itemBackgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"align",label:"Alignment",type:"segment",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left"},{label:"Center",value:"center",type:"align",tooltip:"Align center"},{label:"Right",value:"right",type:"align",tooltip:"Align right"}],devices:{desktop:{default:"center"}}},{id:"itemShadow",type:"shadow-v2",label:"Button Shadow",default:{type:"none",distance:"4px",blur:"12px",spread:"0px",color:"#121212",angle:90}}]}];export{MarqueeSettingsV2};
|
|
2
|
+
<path fill="currentColor" strokelinecap="round" strokelinejoin="round" d="M128,80a48,48,0,1,0,48,48A48,48,0,0,0,128,80Zm0,60a12,12,0,1,1,12-12A12,12,0,0,1,128,140Z"></path></svg>`},{id:"stopOnHover",label:"stopOnHover",type:"toggle",default:!0},{id:"speed",label:"speed",type:"input:slider",hideInput:!0,useOnlyUnitInit:!0,hideUnit:!0,min:0,max:4,step:.1,default:1},{id:"direction",label:"direction",type:"segment",options:[{label:"Left",value:"left",type:"direction",tooltip:"Left"},{label:"Right",value:"right",type:"direction",tooltip:"Right"}],default:"left"},{id:"isPreview",type:"play-pause",hideLabel:!0,default:!1},{id:"hasItemShadow",label:"hasItemShadow",type:"toggle",default:!1}]},{id:"style",controls:[{id:"iconSeparatorSize",label:"iconSeparatorSize",type:"input:stepper",devices:{desktop:{default:16}}},{id:"iconSeparatorColor",label:"iconSeparatorColor",type:"color-picker-v2",default:"text-2"},{id:"itemSpacing",label:"Spacing",type:"input:slider",units:["px"],min:0,max:100,step:1,ignoreMax:!0,placeholder:"Auto",devices:{desktop:{default:"60px"}}},{id:"itemMaxWidth",label:"itemMaxWidth",type:"input:unit",units:["px"],placeholder:"Auto",min:40,devices:{desktop:{default:"300px"},tablet:{default:"300px"},mobile:{default:"150px"}}},{id:"sizeSetting",type:"size-setting",label:"",devices:{desktop:{default:{shapeLinked:!1,width:"100%",height:"auto"}}},settingConfig:{width:{name:"Width"},height:{displayOptions:["auto","small","medium","large"],name:"Height",sizeConfig:{small:"32px",medium:"64px",large:"96px"}}},hiddenSettings:["gap","shape","padding"]},{id:"itemBorderStyle",type:"border",label:"Border",default:{borderType:"none",border:"none",borderWidth:"1px",width:"1px 1px 1px 1px",isCustom:!1,color:"#000000"}},{id:"itemCorner",type:"radius-preset",label:"Border Radius",default:{radiusType:"none"}},{id:"itemBackgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"backgroundColor",type:"color-picker-v2",devices:{desktop:{default:"transparent"}}},{id:"align",label:"Alignment",type:"segment",options:[{label:"Left",value:"left",type:"align",tooltip:"Align left"},{label:"Center",value:"center",type:"align",tooltip:"Align center"},{label:"Right",value:"right",type:"align",tooltip:"Align right"}],devices:{desktop:{default:"center"}}},{id:"itemShadow",type:"shadow-v2",label:"Button Shadow",default:{type:"none",distance:"4px",blur:"12px",spread:"0px",color:"#121212",angle:90,enable:!1}}]}];export{MarqueeSettingsV2};
|
|
@@ -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 i,getResponsiveValueByScreen as r}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 c from"../../../common/components/NoDataState.js";import{createClass as l,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 w}from"./common/main/classes.js";import{getDropdownGroupData as j,getTextVariantTitleData as N}from"./common/main/getData.js";import{useGpVariants as b}from"./hooks/useGpVariants.js";import{getWrapVariantOptionClass as k}from"./common/variants/classes.js";let ProductVariants=x=>{let{builderProps:T,styles:A,setting:P}=x,{align:V,optionTypo:D,swatchItemWidth:$,dropdownItemWidth:S,swatchSpacing:C}=A??{},{label:E,showAsSwatches:G,layout:O,hasPreSelected:W}=P??{},{uid:_}=T??{},z=e(),{mode:K,options:R,variantId:q,elementRef:B,variantGroup:F,isChangeVariant:H,selectedOptions:I,isDefaultVariant:J,getVariantConfiguration:L,redirectProductShopifyLink:M}=b(x,z),Q=()=>{let o={};return i.forEach(t=>{let e=r($,t);o[t]="auto"===e}),o},U=()=>{let o={};return i.forEach(t=>{o[t]=S?.[t]==="fill"}),o},X=()=>R?.map((e,i)=>{let r=L(e.name),p=r?r.optionType:e.optionType,c=r?r.presets[r.optionType||"rectangle_list"]?.spacing:C,d=(W||q)&&e.name?I?.[e.name]:void 0,h=r?.hide;if(h)return null;let g=l(w(V)),v=u(y(C,c)),j=N(x,"React",{optionName:e.name,hasPreSelected:W,selectedOptions:I,styleOptionSelected:p}),b=l(k(O,V));return t("div",{className:b,children:[f(E,o(a,{...j})),t("div",{className:g,style:v,children:[G&&n.includes(`${p}`)&&e.values.map(t=>{let n=(!!W||!!H
|
|
2
|
+
import{jsx as o,jsxs as t}from"react/jsx-runtime";import{useVariants as e,OptionSpecialStyle as n,DEVICES as i,getResponsiveValueByScreen as r}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 c from"../../../common/components/NoDataState.js";import{createClass as l,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 w}from"./common/main/classes.js";import{getDropdownGroupData as j,getTextVariantTitleData as N}from"./common/main/getData.js";import{useGpVariants as b}from"./hooks/useGpVariants.js";import{getWrapVariantOptionClass as k}from"./common/variants/classes.js";let ProductVariants=x=>{let{builderProps:T,styles:A,setting:P}=x,{align:V,optionTypo:D,swatchItemWidth:$,dropdownItemWidth:S,swatchSpacing:C}=A??{},{label:E,showAsSwatches:G,layout:O,hasPreSelected:W}=P??{},{uid:_}=T??{},z=e(),{mode:K,options:R,variantId:q,elementRef:B,variantGroup:F,isChangeVariant:H,selectedOptions:I,isDefaultVariant:J,getVariantConfiguration:L,redirectProductShopifyLink:M}=b(x,z),Q=()=>{let o={};return i.forEach(t=>{let e=r($,t);o[t]="auto"===e}),o},U=()=>{let o={};return i.forEach(t=>{o[t]=S?.[t]==="fill"}),o},X=()=>R?.map((e,i)=>{let r=L(e.name),p=r?r.optionType:e.optionType,c=r?r.presets[r.optionType||"rectangle_list"]?.spacing:C,d=(W||q)&&e.name?I?.[e.name]:void 0,h=r?.hide;if(h)return null;let g=l(w(V)),v=u(y(C,c)),j=N(x,"React",{optionName:e.name,hasPreSelected:W,selectedOptions:I,styleOptionSelected:p}),b=l(k(O,V));return t("div",{className:b,children:[f(E,o(a,{...j})),t("div",{className:g,style:v,children:[G&&n.includes(`${p}`)&&e.values.map(t=>{let n=(!!W||!!H&&!!q)&&!!e.name&&I?.[e.name]===t.label;return o(s,{variantKey:`${e.id}-${t.id}`,showAsSwatches:G,uid:_,optionName:e.name??"",optionValue:t.label??"",name:e.name,value:t,optionNumber:R.length,optionPosition:i,...A,...P,presetConfiguration:L(e.name),checked:n,typeOfOption:p||"dropdown",swatchAutoWidth:Q(),optionTypo:D},t.id)}),f(("dropdown"===p||G&&!n.includes(`${p}`))&&"radio_buttons"!==p,o(m,{...A,...P,variants:z,option:e,initValue:d,presetConfiguration:L(e.name),swatchAutoWidth:U(),optionTypo:D,optionPosition:i,optionNumber:R.length}))]})]},e.id)}),Y=l(v(V)),Z=j(x),oo=()=>o("div",{className:Y,children:o(p,{...Z})});if(J&&"edit"===K)return o(c,{elementType:"secondary",description:"Setup options like colors, sizes with product variant.",descriptionActions:[{text:"Add new variant",callback:M},{text:"sync data",callback:"syncProduct"}]});let ot=d(g({uid:_,hasPreSelected:W})),oe=u(h(x)),on=l({"gp-grid !gp-ml-0":!0});return o("div",{ref:B,...ot,className:on,style:oe,children:f(F,oo(),X())})};export{ProductVariants as default};
|