@gem-sdk/components 2.0.0-staging.813 → 2.0.0-staging.814
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/estimate-delivery/settings/configs/settings.js +1 -1
- package/dist/cjs/product/components/product-variants/ProductVariants.js +1 -1
- package/dist/cjs/product/components/product-variants/ProductVariants.liquid.js +22 -21
- package/dist/cjs/product/components/product-variants/common/main/styles.js +1 -1
- package/dist/cjs/product/components/product-variants/common/variants/styles.js +1 -1
- package/dist/esm/estimate-delivery/settings/configs/settings.js +1 -1
- package/dist/esm/product/components/product-variants/ProductVariants.js +1 -1
- package/dist/esm/product/components/product-variants/ProductVariants.liquid.js +27 -26
- package/dist/esm/product/components/product-variants/common/main/styles.js +1 -1
- package/dist/esm/product/components/product-variants/common/variants/styles.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var helpers=require("../../common/helpers.js");const EstimateDateSettings=[{id:"setting",controls:[{id:"enableCustomText",label:"",type:"toggle",default:!0},{id:"customTextContainer",type:"group",controls:[{id:"customText",type:"input",default:"Estimate delivery between"}]},{id:"estimateDays",type:"group",controls:[{id:"typeEstimate",type:"group",controls:[{id:"typeEstimate",label:"Type",type:"option:value",default:helpers.ESTIMATE_DAYS.RANGE,options:[{label:"Specific",value:helpers.ESTIMATE_DAYS.SPECIFIC},{label:"Range",value:helpers.ESTIMATE_DAYS.RANGE}]},{id:"minEstimate",label:"Min estimate",type:"input:number",default:2,emptyOnClear:!1,min:1,max:99969999},{id:"maxEstimate",label:"Max estimate",type:"input:number",default:5,emptyOnClear:!1,min:1,max:99969999},{id:"estimateTime",label:"Estimate",type:"input:number",default:5,emptyOnClear:!1,min:0,max:99969999}]}]},{id:"dateFormat",type:"group",controls:[{id:"typeFormat",label:"Type",type:"select",default:helpers.listFormatDate().FORMAT_1.value,options:[{label:helpers.listFormatDate().FORMAT_1.Label,value:helpers.listFormatDate().FORMAT_1.value},{label:helpers.listFormatDate().FORMAT_2.Label,value:helpers.listFormatDate().FORMAT_2.value},{label:helpers.listFormatDate().FORMAT_3.Label,value:helpers.listFormatDate().FORMAT_3.value},{label:helpers.listFormatDate().FORMAT_4.Label,value:helpers.listFormatDate().FORMAT_4.value},{label:helpers.listFormatDate().FORMAT_5.Label,value:helpers.listFormatDate().FORMAT_5.value},{label:helpers.listFormatDate().FORMAT_6.Label,value:helpers.listFormatDate().FORMAT_6.Label}]},{id:"customFormat",label:"Custom format",type:"input",default:"",placeholder:"Eg: %d, %b, %y"},{id:"moreFormat",type:"group"}]},{id:"visibilityContainer",type:"group",controls:[{id:"visibility",type:"childrens"},{id:"ifOutOfStock",label:"If out of stock",type:"option:value",default:helpers.OUT_OF_STOCK.HIDE,options:[{label:"Show",value:helpers.OUT_OF_STOCK.SHOW},{label:"Hide",value:helpers.OUT_OF_STOCK.HIDE}]}]},{id:"translate",type:"input",default:"customText"},{id:"globalSize",type:"size-setting",devices:{desktop:{default:{width:"100%"}}},settingConfig:{width:{displayOptions:["full","auto"],sizeConfig:{small:"100px",medium:"116px",large:"132px"}}},hiddenSettings:["shape","gap","height"]},{id:"background",type:"background-media",ignoreReRender:!0,devices:{desktop:{default:{type:"color",color:"transparent",image:{src:"",width:0,height:0},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll"}}},compoDefaultValue:{desktop:{default:{type:"color",color:"#FFFFFF",image:{src:"https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/",width:1200,height:480},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll",preload:!1}}}}]},{id:"style",controls:[{id:"typoCustom",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1"}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!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"}],devices:{desktop:{default:"left"}}},{id:"typoDate",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1",bold:!0}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!0}},{id:"shapeBorder",type:"border-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{border:"solid",color:"#121212",width:"1px",borderWidth:"1px"}}}},{id:"shapeRounded",type:"corner-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{btrr:"8px",bblr:"8px",bbrr:"8px",btlr:"8px",radiusType:"rounded"}}}},{id:"padding",type:"padding-v2",devices:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}},compoDefaultValue:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}}},{id:"shapeBoxShadow",type:"shadow-v2",devices:{desktop:{default:{enable:!1}}},compoDefaultValue:{desktop:{default:{type:"shadow-1",distance:"4px",blur:"4px",spread:"0px",color:"rgba(18, 18, 18, 0.2)",angle:45,enable:!0}}}}]}];exports.EstimateDateSettings=EstimateDateSettings;
|
|
1
|
+
"use strict";var helpers=require("../../common/helpers.js");const EstimateDateSettings=[{id:"setting",controls:[{id:"enableCustomText",label:"",type:"toggle",default:!0},{id:"customTextContainer",type:"group",controls:[{id:"customText",type:"input",default:"Estimate delivery between"}]},{id:"estimateDays",type:"group",controls:[{id:"typeEstimate",type:"group",controls:[{id:"typeEstimate",label:"Type",type:"option:value",default:helpers.ESTIMATE_DAYS.RANGE,options:[{label:"Specific",value:helpers.ESTIMATE_DAYS.SPECIFIC},{label:"Range",value:helpers.ESTIMATE_DAYS.RANGE}]},{id:"minEstimate",label:"Min estimate",type:"input:number",default:2,emptyOnClear:!1,min:1,max:99969999,fallbackValue:2},{id:"maxEstimate",label:"Max estimate",type:"input:number",default:5,emptyOnClear:!1,min:1,max:99969999,fallbackValue:5},{id:"estimateTime",label:"Estimate",type:"input:number",default:5,emptyOnClear:!1,min:0,max:99969999,fallbackValue:5}]}]},{id:"dateFormat",type:"group",controls:[{id:"typeFormat",label:"Type",type:"select",default:helpers.listFormatDate().FORMAT_1.value,options:[{label:helpers.listFormatDate().FORMAT_1.Label,value:helpers.listFormatDate().FORMAT_1.value},{label:helpers.listFormatDate().FORMAT_2.Label,value:helpers.listFormatDate().FORMAT_2.value},{label:helpers.listFormatDate().FORMAT_3.Label,value:helpers.listFormatDate().FORMAT_3.value},{label:helpers.listFormatDate().FORMAT_4.Label,value:helpers.listFormatDate().FORMAT_4.value},{label:helpers.listFormatDate().FORMAT_5.Label,value:helpers.listFormatDate().FORMAT_5.value},{label:helpers.listFormatDate().FORMAT_6.Label,value:helpers.listFormatDate().FORMAT_6.Label}]},{id:"customFormat",label:"Custom format",type:"input",default:"",placeholder:"Eg: %d, %b, %y"},{id:"moreFormat",type:"group"}]},{id:"visibilityContainer",type:"group",controls:[{id:"visibility",type:"childrens"},{id:"ifOutOfStock",label:"If out of stock",type:"option:value",default:helpers.OUT_OF_STOCK.HIDE,options:[{label:"Show",value:helpers.OUT_OF_STOCK.SHOW},{label:"Hide",value:helpers.OUT_OF_STOCK.HIDE}]}]},{id:"translate",type:"input",default:"customText"},{id:"globalSize",type:"size-setting",devices:{desktop:{default:{width:"100%"}}},settingConfig:{width:{displayOptions:["full","auto"],sizeConfig:{small:"100px",medium:"116px",large:"132px"}}},hiddenSettings:["shape","gap","height"]},{id:"background",type:"background-media",ignoreReRender:!0,devices:{desktop:{default:{type:"color",color:"transparent",image:{src:"",width:0,height:0},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll"}}},compoDefaultValue:{desktop:{default:{type:"color",color:"#FFFFFF",image:{src:"https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/",width:1200,height:480},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll",preload:!1}}}}]},{id:"style",controls:[{id:"typoCustom",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1"}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!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"}],devices:{desktop:{default:"left"}}},{id:"typoDate",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1",bold:!0}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!0}},{id:"shapeBorder",type:"border-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{border:"solid",color:"#121212",width:"1px",borderWidth:"1px"}}}},{id:"shapeRounded",type:"corner-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{btrr:"8px",bblr:"8px",bbrr:"8px",btlr:"8px",radiusType:"rounded"}}}},{id:"padding",type:"padding-v2",devices:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}},compoDefaultValue:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}}},{id:"shapeBoxShadow",type:"shadow-v2",devices:{desktop:{default:{enable:!1}}},compoDefaultValue:{desktop:{default:{type:"shadow-1",distance:"4px",blur:"4px",spread:"0px",color:"rgba(18, 18, 18, 0.2)",angle:45,enable:!0}}}}]}];exports.EstimateDateSettings=EstimateDateSettings;
|
|
@@ -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:
|
|
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:o,optionTypo:r,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=()=>g?.map((t,n)=>{let i=V(t.name),j=i?i.optionType:t.optionType,h=i?i.presets[i.optionType||"rectangle_list"]?.spacing:l,w=(d||f)&&t.name?S?.[t.name]:void 0,v=i?.hide;if(v)return null;let q=system.createClass(classes.getVariantOptionGroupClass(o)),N=system.createStyle(styles.getVariantOptionGroupStyle(l,h)),T=getData.getTextVariantTitleData(e,"React",{optionName:t.name,hasPreSelected:d,selectedOptions:S,styleOptionSelected:j}),A=system.createClass(classes$1.getWrapVariantOptionClass(m,o)),G=n===g.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(`${j}`)&&t.values.map(e=>{let o=(!!d||!!D&&!!f)&&!!t.name&&S?.[t.name]===e.label;return jsxRuntime.jsx(index.default,{variantKey:`${t.id}-${e.id}`,showAsSwatches:u,uid:y,optionName:t.name??"",optionValue:e.label??"",name:t.name,value:e,optionNumber:g.length,optionPosition:n,...s,...a,presetConfiguration:V(t.name),checked:o,typeOfOption:j||"dropdown",swatchAutoWidth:R(),optionTypo:r},e.id)}),system.If(("dropdown"===j||u&&!core.OptionSpecialStyle.includes(`${j}`))&&"radio_buttons"!==j,jsxRuntime.jsx(Dropdown.default,{...s,...a,variants:x,option:t,initValue:w,presetConfiguration:V(t.name),swatchAutoWidth:C(),optionTypo:r,optionPosition:n,optionNumber:g.length}))]})]},t.id)}),T=system.createClass(classes.getWrapDropdownClass(o)),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;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Text_liquid=require("../../../text/components/Text.liquid.js"),index_liquid=require("./components/variants/index.liquid.js"),Dropdown_liquid=require("./components/dropdown-swatches/Dropdown.liquid.js"),DropdownGroup_liquid=require("./components/dropdown-group/DropdownGroup.liquid.js"),helpers=require("../../../helpers.js"),mappingVariantStyles=require("./utils/mappingVariantStyles.js"),system=require("@gem-sdk/system"),getAttr=require("./common/main/getAttr.js"),styles=require("./common/main/styles.js"),classes=require("./common/main/classes.js"),getData=require("./common/main/getData.js"),classes$1=require("./common/variants/classes.js"),_function=require("../../helpers/function.js");const DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=e=>{let{builderProps:s,styles:t,setting:i,advanced:a}=e,{align:o,swatchItemWidth:n,dropdownItemWidth:r,swatchSpacing:p,optionTypo:l}=t??{},{label:
|
|
2
|
-
${system.Liquid(`{%- assign presets = "${
|
|
3
|
-
${system.Liquid(`{% assign hiddenPresetOptions = "${
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Text_liquid=require("../../../text/components/Text.liquid.js"),index_liquid=require("./components/variants/index.liquid.js"),Dropdown_liquid=require("./components/dropdown-swatches/Dropdown.liquid.js"),DropdownGroup_liquid=require("./components/dropdown-group/DropdownGroup.liquid.js"),helpers=require("../../../helpers.js"),mappingVariantStyles=require("./utils/mappingVariantStyles.js"),system=require("@gem-sdk/system"),getAttr=require("./common/main/getAttr.js"),styles=require("./common/main/styles.js"),classes=require("./common/main/classes.js"),getData=require("./common/main/getData.js"),classes$1=require("./common/variants/classes.js"),_function=require("../../helpers/function.js"),styles$1=require("./common/variants/styles.js");const DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=e=>{let{builderProps:s,styles:t,setting:i,advanced:a}=e,{align:o,swatchItemWidth:n,dropdownItemWidth:r,swatchSpacing:p,optionTypo:l,marginBottom:u}=t??{},{label:d,optionType:m,showAsSwatches:c,layout:y,hasPreSelected:g}=i??{},$=a?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:q}=s??{},v="groupOption"===m,f=()=>{let e={};return core.DEVICES.forEach(s=>{let t=core.getResponsiveValueByScreen(n,s);e[s]="auto"===t}),e},L=()=>{let e={};return core.DEVICES.forEach(s=>{e[s]=r?.[s]==="fill"}),e},S=core.composeMemo(()=>{let e=mappingVariantStyles.mappingVariantStyles(i?.variantPresets,t);return{...i,variantPresets:e}},[i?.variantPresets,t]),I=e=>{let s={"'":"'",'"':"""},t=e;for(let i in s)e.indexOf(i)>=0&&(t=t.replaceAll(i,s[i]));return t},V=()=>i?.variantPresets?.map(e=>`${I(e.optionName)}($2)${e.optionType}`).join("($1)"),_=()=>i?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),h=system.createClass(classes.getVariantOptionGroupClass(o)),j=system.createStyle(styles.getVariantOptionGroupStyle(p,p)),A=getData.getTextVariantTitleData(e,"Liquid"),w=system.createClass(classes$1.getWrapVariantOptionClass(y,o)),D=()=>core.template`
|
|
2
|
+
${system.Liquid(`{%- assign presets = "${V()}" | split: '($1)' -%}`)}
|
|
3
|
+
${system.Liquid(`{% assign hiddenPresetOptions = "${_()}" | split: ',' %}`)}
|
|
4
4
|
${system.LiquidFor("option in options",`
|
|
5
5
|
<div
|
|
6
6
|
option-name="{{option.name | escape}}"
|
|
7
|
-
class="${
|
|
7
|
+
class="${w} ${system.LiquidIf("hiddenPresetOptions contains option.name","gp-hidden")}"
|
|
8
|
+
style="${_function.getStyleOfObject(styles$1.getMarginBottomStyle(u))}${system.Liquid("{% if forloop.last %}--mb:0;{% endif %}")}"
|
|
8
9
|
>
|
|
9
10
|
${system.Liquid("{%- assign showVariantClass = 'variant-display' -%}")}
|
|
10
11
|
${system.Liquid("{%- assign optionName = option.name -%}")}
|
|
@@ -12,11 +13,11 @@
|
|
|
12
13
|
${system.Liquid("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
13
14
|
${system.LiquidIf("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${system.Liquid("{%- assign showVariantClass = '' -%}")} ${system.Liquid("{%- break -%}")}`)}
|
|
14
15
|
`)}
|
|
15
|
-
${system.If(
|
|
16
|
+
${system.If(d,Text_liquid.default(A)," ")}
|
|
16
17
|
<div
|
|
17
18
|
variant-option-name="{{option.name | escape}}"
|
|
18
|
-
class="${
|
|
19
|
-
style="${_function.getStyleOfObject(
|
|
19
|
+
class="${h}"
|
|
20
|
+
style="${_function.getStyleOfObject(j)}"
|
|
20
21
|
>
|
|
21
22
|
${system.Liquid("{%- assign values = option.values -%}")}
|
|
22
23
|
${system.Liquid("{%- assign rootForloop = forloop.index0 -%}")}
|
|
@@ -29,11 +30,11 @@
|
|
|
29
30
|
{%- assign selectedValue = variant.option3 -%}
|
|
30
31
|
{%- endif -%}
|
|
31
32
|
`)}
|
|
32
|
-
${system.If(!
|
|
33
|
-
${system.If(
|
|
33
|
+
${system.If(!g,system.Liquid("{%- assign selectedValue = null -%}"),"")}
|
|
34
|
+
${system.If(c,T(),P())}
|
|
34
35
|
</div>
|
|
35
36
|
</div>`)}
|
|
36
|
-
`,
|
|
37
|
+
`,b=i?.variantPresets?.map(e=>({name:I(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),T=()=>core.template`
|
|
37
38
|
${system.Liquid("{%- assign optionRendered = false -%}")}
|
|
38
39
|
${system.Liquid("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
|
|
39
40
|
${system.Liquid("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
${system.Liquid("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
|
|
74
75
|
|
|
75
76
|
${system.LiquidIf("optionTitle == option.name",`
|
|
76
|
-
${system.Liquid(`{%- assign variantPresetString = "${
|
|
77
|
+
${system.Liquid(`{%- assign variantPresetString = "${b}" -%}`)}
|
|
77
78
|
${system.Liquid('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
78
79
|
${system.Liquid("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
79
80
|
${system.Liquid("{%- assign type = 'dropdown' -%}")}
|
|
@@ -83,23 +84,23 @@
|
|
|
83
84
|
${system.LiquidIf('itemPreset[0] == "base"',system.Liquid("{%- assign type = itemPreset[1] -%}"))}
|
|
84
85
|
`)}
|
|
85
86
|
${system.Liquid("{%- assign optionRendered = true -%}")}
|
|
86
|
-
${system.LiquidFor("value in values",index_liquid.default({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:
|
|
87
|
-
${system.LiquidIf("type == 'dropdown'",Dropdown_liquid.default({...t,...
|
|
87
|
+
${system.LiquidFor("value in values",index_liquid.default({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:c,uid:q,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:g?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",optionType:"optionType",activeClass:g?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...t,...S,swatchAutoWidth:f(),optionTypo:l}))}
|
|
88
|
+
${system.LiquidIf("type == 'dropdown'",Dropdown_liquid.default({...t,...S,swatchAutoWidth:L(),optionTypo:l}))}
|
|
88
89
|
`)}
|
|
89
90
|
`)}
|
|
90
91
|
|
|
91
|
-
${system.LiquidIf("optionRendered == false",
|
|
92
|
-
`,
|
|
93
|
-
<div className="${
|
|
92
|
+
${system.LiquidIf("optionRendered == false",P())}
|
|
93
|
+
`,P=()=>system.LiquidFor("value in values",index_liquid.default({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:c,uid:q,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:g?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:g?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...t,...S,swatchAutoWidth:f(),optionTypo:l,isRenderDefault:!0})),O=system.createClass(classes.getWrapDropdownClass(o)),E=getData.getDropdownGroupData(e),x=()=>`
|
|
94
|
+
<div className="${O}">
|
|
94
95
|
${DropdownGroup_liquid.default(E)}
|
|
95
96
|
</div>
|
|
96
|
-
`;system.createStateOrContext({setting:
|
|
97
|
+
`;system.createStateOrContext({setting:S,styles:JSON.stringify(t),variants:"{{ product.variants | json | escape }}",optionsWithValues:"{{ product.options_with_values | json | escape }}",variantSelected:"{{ variant | json | escape }}",variantInventoryQuantity:"{{ product.variants | map: 'inventory_quantity' | json | escape }}",variantInventoryPolicy:"{{ product.variants | map: 'inventory_policy' | json | escape }}",moneyFormat:"{{ shop.money_format | json | escape }}",productId:"{{ product.id | json | escape }}",productUrl:"{{ product.url | json | escape }}",productHandle:"{{ product.handle | json | escape }}",displayState:`${JSON.stringify($)}`,totalVariantCombinations:"{{ total_combinations }}",firstAvailableVariant:"{{ product.selected_or_first_available_variant | json | escape }}"});let C=system.createAttr(getAttr.getAttrs({uid:q,hasPreSelected:g})),N=system.createStyle(styles.getWrapperStyle(e)),F=system.createClass({"gp-flex gp-flex-col !gp-ml-0":!0}),U=()=>{let e=core.isLocalEnv?"{{ 'gp-product-variant-v3.js' | asset_url }}":`${core.baseAssetURL}/assets-v2/gp-product-variant-v3.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return core.template`
|
|
97
98
|
${system.Liquid("{%- assign total_combinations = 1 -%}")}
|
|
98
99
|
${system.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
99
100
|
<gp-product-variants
|
|
100
101
|
${C}
|
|
101
102
|
gp-data='{
|
|
102
|
-
"setting":${JSON.stringify(
|
|
103
|
+
"setting":${JSON.stringify(S)?.replaceAll("'","'")},
|
|
103
104
|
"styles":${JSON.stringify(t)},
|
|
104
105
|
"variants":{{product.variants | json | escape}},
|
|
105
106
|
"optionsWithValues": {{product.options_with_values | json | escape}},
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"productId": {{product.id | json | escape}},
|
|
111
112
|
"productUrl": {{product.url | json | escape}},
|
|
112
113
|
"productHandle": {{product.handle | json | escape}},
|
|
113
|
-
"displayState": ${JSON.stringify(
|
|
114
|
+
"displayState": ${JSON.stringify($)},
|
|
114
115
|
"totalVariantCombinations": {{total_combinations}},
|
|
115
116
|
"firstAvailableVariant": {{product.selected_or_first_available_variant | json | escape}}
|
|
116
117
|
}
|
|
@@ -121,9 +122,9 @@
|
|
|
121
122
|
class="${F}"
|
|
122
123
|
style="${N}"
|
|
123
124
|
>
|
|
124
|
-
${system.If(v,
|
|
125
|
+
${system.If(v,x(),D())}
|
|
125
126
|
</div>`)}
|
|
126
127
|
</gp-product-variants>
|
|
127
128
|
|
|
128
|
-
${
|
|
129
|
+
${U()}
|
|
129
130
|
`};exports.default=ProductVariants;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../../helpers.js");const getWrapperStyle=e=>{let{style:
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../../helpers.js");const getWrapperStyle=e=>{let{style:t,styles:r,setting:o}=e,{width:p,align:l}=r??{},{column:a}=o??{},i=core.makeStyleResponsive("w",core.makeWidth(p));return helpers.filterTruthyObject({...core.optionLayoutStyle(a),...core.makeStyleResponsive("ta",l),...i,...t})},getVariantOptionGroupStyle=(e,t)=>helpers.filterTruthyObject({...core.makeStyle({rg:e,cg:t})});exports.getVariantOptionGroupStyle=getVariantOptionGroupStyle,exports.getWrapperStyle=getWrapperStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../../helpers.js");const getLabelVariantStyle=e=>e?helpers.filterTruthyObject(core.makeStyleResponsive("w",core.makeWidth(e))):{};exports.getLabelVariantStyle=getLabelVariantStyle;
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../../helpers.js");const getLabelVariantStyle=e=>e?helpers.filterTruthyObject(core.makeStyleResponsive("w",core.makeWidth(e))):{},getMarginBottomStyle=(e,t)=>!e||t?{}:helpers.filterTruthyObject(core.makeStyleResponsive("mb",e));exports.getLabelVariantStyle=getLabelVariantStyle,exports.getMarginBottomStyle=getMarginBottomStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ESTIMATE_DAYS as e,listFormatDate as t,OUT_OF_STOCK as a}from"../../common/helpers.js";let EstimateDateSettings=[{id:"setting",controls:[{id:"enableCustomText",label:"",type:"toggle",default:!0},{id:"customTextContainer",type:"group",controls:[{id:"customText",type:"input",default:"Estimate delivery between"}]},{id:"estimateDays",type:"group",controls:[{id:"typeEstimate",type:"group",controls:[{id:"typeEstimate",label:"Type",type:"option:value",default:e.RANGE,options:[{label:"Specific",value:e.SPECIFIC},{label:"Range",value:e.RANGE}]},{id:"minEstimate",label:"Min estimate",type:"input:number",default:2,emptyOnClear:!1,min:1,max:99969999},{id:"maxEstimate",label:"Max estimate",type:"input:number",default:5,emptyOnClear:!1,min:1,max:99969999},{id:"estimateTime",label:"Estimate",type:"input:number",default:5,emptyOnClear:!1,min:0,max:99969999}]}]},{id:"dateFormat",type:"group",controls:[{id:"typeFormat",label:"Type",type:"select",default:t().FORMAT_1.value,options:[{label:t().FORMAT_1.Label,value:t().FORMAT_1.value},{label:t().FORMAT_2.Label,value:t().FORMAT_2.value},{label:t().FORMAT_3.Label,value:t().FORMAT_3.value},{label:t().FORMAT_4.Label,value:t().FORMAT_4.value},{label:t().FORMAT_5.Label,value:t().FORMAT_5.value},{label:t().FORMAT_6.Label,value:t().FORMAT_6.Label}]},{id:"customFormat",label:"Custom format",type:"input",default:"",placeholder:"Eg: %d, %b, %y"},{id:"moreFormat",type:"group"}]},{id:"visibilityContainer",type:"group",controls:[{id:"visibility",type:"childrens"},{id:"ifOutOfStock",label:"If out of stock",type:"option:value",default:a.HIDE,options:[{label:"Show",value:a.SHOW},{label:"Hide",value:a.HIDE}]}]},{id:"translate",type:"input",default:"customText"},{id:"globalSize",type:"size-setting",devices:{desktop:{default:{width:"100%"}}},settingConfig:{width:{displayOptions:["full","auto"],sizeConfig:{small:"100px",medium:"116px",large:"132px"}}},hiddenSettings:["shape","gap","height"]},{id:"background",type:"background-media",ignoreReRender:!0,devices:{desktop:{default:{type:"color",color:"transparent",image:{src:"",width:0,height:0},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll"}}},compoDefaultValue:{desktop:{default:{type:"color",color:"#FFFFFF",image:{src:"https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/",width:1200,height:480},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll",preload:!1}}}}]},{id:"style",controls:[{id:"typoCustom",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1"}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!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"}],devices:{desktop:{default:"left"}}},{id:"typoDate",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1",bold:!0}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!0}},{id:"shapeBorder",type:"border-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{border:"solid",color:"#121212",width:"1px",borderWidth:"1px"}}}},{id:"shapeRounded",type:"corner-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{btrr:"8px",bblr:"8px",bbrr:"8px",btlr:"8px",radiusType:"rounded"}}}},{id:"padding",type:"padding-v2",devices:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}},compoDefaultValue:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}}},{id:"shapeBoxShadow",type:"shadow-v2",devices:{desktop:{default:{enable:!1}}},compoDefaultValue:{desktop:{default:{type:"shadow-1",distance:"4px",blur:"4px",spread:"0px",color:"rgba(18, 18, 18, 0.2)",angle:45,enable:!0}}}}]}];export{EstimateDateSettings};
|
|
1
|
+
import{ESTIMATE_DAYS as e,listFormatDate as t,OUT_OF_STOCK as a}from"../../common/helpers.js";let EstimateDateSettings=[{id:"setting",controls:[{id:"enableCustomText",label:"",type:"toggle",default:!0},{id:"customTextContainer",type:"group",controls:[{id:"customText",type:"input",default:"Estimate delivery between"}]},{id:"estimateDays",type:"group",controls:[{id:"typeEstimate",type:"group",controls:[{id:"typeEstimate",label:"Type",type:"option:value",default:e.RANGE,options:[{label:"Specific",value:e.SPECIFIC},{label:"Range",value:e.RANGE}]},{id:"minEstimate",label:"Min estimate",type:"input:number",default:2,emptyOnClear:!1,min:1,max:99969999,fallbackValue:2},{id:"maxEstimate",label:"Max estimate",type:"input:number",default:5,emptyOnClear:!1,min:1,max:99969999,fallbackValue:5},{id:"estimateTime",label:"Estimate",type:"input:number",default:5,emptyOnClear:!1,min:0,max:99969999,fallbackValue:5}]}]},{id:"dateFormat",type:"group",controls:[{id:"typeFormat",label:"Type",type:"select",default:t().FORMAT_1.value,options:[{label:t().FORMAT_1.Label,value:t().FORMAT_1.value},{label:t().FORMAT_2.Label,value:t().FORMAT_2.value},{label:t().FORMAT_3.Label,value:t().FORMAT_3.value},{label:t().FORMAT_4.Label,value:t().FORMAT_4.value},{label:t().FORMAT_5.Label,value:t().FORMAT_5.value},{label:t().FORMAT_6.Label,value:t().FORMAT_6.Label}]},{id:"customFormat",label:"Custom format",type:"input",default:"",placeholder:"Eg: %d, %b, %y"},{id:"moreFormat",type:"group"}]},{id:"visibilityContainer",type:"group",controls:[{id:"visibility",type:"childrens"},{id:"ifOutOfStock",label:"If out of stock",type:"option:value",default:a.HIDE,options:[{label:"Show",value:a.SHOW},{label:"Hide",value:a.HIDE}]}]},{id:"translate",type:"input",default:"customText"},{id:"globalSize",type:"size-setting",devices:{desktop:{default:{width:"100%"}}},settingConfig:{width:{displayOptions:["full","auto"],sizeConfig:{small:"100px",medium:"116px",large:"132px"}}},hiddenSettings:["shape","gap","height"]},{id:"background",type:"background-media",ignoreReRender:!0,devices:{desktop:{default:{type:"color",color:"transparent",image:{src:"",width:0,height:0},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll"}}},compoDefaultValue:{desktop:{default:{type:"color",color:"#FFFFFF",image:{src:"https://ucarecdn.com/06075225-af9e-460c-8e3c-6be63c0b773a/-/format/auto/",width:1200,height:480},size:"cover",position:{x:50,y:50},repeat:"no-repeat",attachment:"scroll",preload:!1}}}}]},{id:"style",controls:[{id:"typoCustom",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1"}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!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"}],devices:{desktop:{default:"left"}}},{id:"typoDate",type:"typography-v2",default:{type:"paragraph-2",attrs:{color:"text-1",bold:!0}},ignoreReRender:!0,hiddenSetting:{textAlign:!0,textShadow:!0}},{id:"shapeBorder",type:"border-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{border:"solid",color:"#121212",width:"1px",borderWidth:"1px"}}}},{id:"shapeRounded",type:"corner-v2",devices:{desktop:{default:void 0}},compoDefaultValue:{desktop:{default:{btrr:"8px",bblr:"8px",bbrr:"8px",btlr:"8px",radiusType:"rounded"}}}},{id:"padding",type:"padding-v2",devices:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}},compoDefaultValue:{desktop:{default:{padding:{type:"small",top:"4px",left:"4px",bottom:"4px",right:"4px"}}}}},{id:"shapeBoxShadow",type:"shadow-v2",devices:{desktop:{default:{enable:!1}}},compoDefaultValue:{desktop:{default:{type:"shadow-1",distance:"4px",blur:"4px",spread:"0px",color:"rgba(18, 18, 18, 0.2)",angle:45,enable:!0}}}}]}];export{EstimateDateSettings};
|
|
@@ -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
|
|
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=()=>B?.map((e,r)=>{let i=Q(e.name),p=i?i.optionType:e.optionType,l=i?i.presets[i.optionType||"rectangle_list"]?.spacing:E,d=(z||F)&&e.name?L?.[e.name]:void 0,h=i?.hide;if(h)return null;let g=c(j(D)),v=u(y(E,l)),w=x(T,"React",{optionName:e.name,hasPreSelected:z,selectedOptions:L,styleOptionSelected:p}),N=c(b(_,D)),A=r===B.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(`${p}`)&&e.values.map(t=>{let n=(!!z||!!J&&!!F)&&!!e.name&&L?.[e.name]===t.label;return o(s,{variantKey:`${e.id}-${t.id}`,showAsSwatches:W,uid:K,optionName:e.name??"",optionValue:t.label??"",name:e.name,value:t,optionNumber:B.length,optionPosition:r,...P,...V,presetConfiguration:Q(e.name),checked:n,typeOfOption:p||"dropdown",swatchAutoWidth:X(),optionTypo:$},t.id)}),f(("dropdown"===p||W&&!n.includes(`${p}`))&&"radio_buttons"!==p,o(m,{...P,...V,variants:R,option:e,initValue:d,presetConfiguration:Q(e.name),swatchAutoWidth:Y(),optionTypo:$,optionPosition:r,optionNumber:B.length}))]})]},e.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};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as a,isLocalEnv as i,baseAssetURL as o}from"@gem-sdk/core";import n from"../../../text/components/Text.liquid.js";import p from"./components/variants/index.liquid.js";import r from"./components/dropdown-swatches/Dropdown.liquid.js";import l from"./components/dropdown-group/DropdownGroup.liquid.js";import{getSettingPreloadData as m}from"../../../helpers.js";import{mappingVariantStyles as c}from"./utils/mappingVariantStyles.js";import{createClass as d,createStyle as u,createStateOrContext as $,createAttr as g,Liquid as v,LiquidFor as y,LiquidIf as f,If as S}from"@gem-sdk/system";import{getAttrs as V}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as h,getWrapperStyle as _}from"./common/main/styles.js";import{getVariantOptionGroupClass as j,getWrapDropdownClass as I}from"./common/main/classes.js";import{getTextVariantTitleData as A,getDropdownGroupData as w}from"./common/main/getData.js";import{getWrapVariantOptionClass as b}from"./common/variants/classes.js";import{getStyleOfObject as P}from"../../helpers/function.js";let DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=
|
|
2
|
-
${v(`{%- assign presets = "${
|
|
3
|
-
${v(`{% assign hiddenPresetOptions = "${
|
|
1
|
+
import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as a,isLocalEnv as i,baseAssetURL as o}from"@gem-sdk/core";import n from"../../../text/components/Text.liquid.js";import p from"./components/variants/index.liquid.js";import r from"./components/dropdown-swatches/Dropdown.liquid.js";import l from"./components/dropdown-group/DropdownGroup.liquid.js";import{getSettingPreloadData as m}from"../../../helpers.js";import{mappingVariantStyles as c}from"./utils/mappingVariantStyles.js";import{createClass as d,createStyle as u,createStateOrContext as $,createAttr as g,Liquid as v,LiquidFor as y,LiquidIf as f,If as S}from"@gem-sdk/system";import{getAttrs as V}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as h,getWrapperStyle as _}from"./common/main/styles.js";import{getVariantOptionGroupClass as j,getWrapDropdownClass as I}from"./common/main/classes.js";import{getTextVariantTitleData as A,getDropdownGroupData as w}from"./common/main/getData.js";import{getWrapVariantOptionClass as b}from"./common/variants/classes.js";import{getStyleOfObject as P}from"../../helpers/function.js";import{getMarginBottomStyle as T}from"./common/variants/styles.js";let DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=N=>{let{builderProps:D,styles:E,setting:O,advanced:U}=N,{align:x,swatchItemWidth:K,dropdownItemWidth:q,swatchSpacing:C,optionTypo:k,marginBottom:F}=E??{},{label:G,optionType:J,showAsSwatches:L,layout:R,hasPreSelected:W}=O??{},z=U?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:H}=D??{},M="groupOption"===J,Q=()=>{let t={};return s.forEach(e=>{let s=a(K,e);t[e]="auto"===s}),t},Y=()=>{let t={};return s.forEach(e=>{t[e]=q?.[e]==="fill"}),t},B=t(()=>{let t=c(O?.variantPresets,E);return{...O,variantPresets:t}},[O?.variantPresets,E]),X=t=>{let e={"'":"'",'"':"""},s=t;for(let a in e)t.indexOf(a)>=0&&(s=s.replaceAll(a,e[a]));return s},Z=()=>O?.variantPresets?.map(t=>`${X(t.optionName)}($2)${t.optionType}`).join("($1)"),tt=()=>O?.variantPresets?.filter(t=>!!t?.hide)?.map(t=>t.optionName).join(","),te=d(j(x)),ts=u(h(C,C)),ta=A(N,"Liquid"),ti=d(b(R,x)),to=()=>e`
|
|
2
|
+
${v(`{%- assign presets = "${Z()}" | split: '($1)' -%}`)}
|
|
3
|
+
${v(`{% assign hiddenPresetOptions = "${tt()}" | split: ',' %}`)}
|
|
4
4
|
${y("option in options",`
|
|
5
5
|
<div
|
|
6
6
|
option-name="{{option.name | escape}}"
|
|
7
|
-
class="${
|
|
7
|
+
class="${ti} ${f("hiddenPresetOptions contains option.name","gp-hidden")}"
|
|
8
|
+
style="${P(T(F))}${v("{% if forloop.last %}--mb:0;{% endif %}")}"
|
|
8
9
|
>
|
|
9
10
|
${v("{%- assign showVariantClass = 'variant-display' -%}")}
|
|
10
11
|
${v("{%- assign optionName = option.name -%}")}
|
|
@@ -12,11 +13,11 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
|
|
|
12
13
|
${v("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
13
14
|
${f("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${v("{%- assign showVariantClass = '' -%}")} ${v("{%- break -%}")}`)}
|
|
14
15
|
`)}
|
|
15
|
-
${S(
|
|
16
|
+
${S(G,n(ta)," ")}
|
|
16
17
|
<div
|
|
17
18
|
variant-option-name="{{option.name | escape}}"
|
|
18
|
-
class="${
|
|
19
|
-
style="${P(
|
|
19
|
+
class="${te}"
|
|
20
|
+
style="${P(ts)}"
|
|
20
21
|
>
|
|
21
22
|
${v("{%- assign values = option.values -%}")}
|
|
22
23
|
${v("{%- assign rootForloop = forloop.index0 -%}")}
|
|
@@ -29,11 +30,11 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
|
|
|
29
30
|
{%- assign selectedValue = variant.option3 -%}
|
|
30
31
|
{%- endif -%}
|
|
31
32
|
`)}
|
|
32
|
-
${S(!
|
|
33
|
-
${S(
|
|
33
|
+
${S(!W,v("{%- assign selectedValue = null -%}"),"")}
|
|
34
|
+
${S(L,tp(),tr())}
|
|
34
35
|
</div>
|
|
35
36
|
</div>`)}
|
|
36
|
-
`,
|
|
37
|
+
`,tn=O?.variantPresets?.map(t=>({name:X(t.optionName),type:t.optionType})).map(t=>`${t.name}($1)${t.type}`).join("($2)").toString(),tp=()=>e`
|
|
37
38
|
${v("{%- assign optionRendered = false -%}")}
|
|
38
39
|
${v("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
|
|
39
40
|
${v("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
|
|
@@ -73,7 +74,7 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
|
|
|
73
74
|
${v("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
|
|
74
75
|
|
|
75
76
|
${f("optionTitle == option.name",`
|
|
76
|
-
${v(`{%- assign variantPresetString = "${
|
|
77
|
+
${v(`{%- assign variantPresetString = "${tn}" -%}`)}
|
|
77
78
|
${v('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
78
79
|
${v("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
79
80
|
${v("{%- assign type = 'dropdown' -%}")}
|
|
@@ -83,24 +84,24 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
|
|
|
83
84
|
${f('itemPreset[0] == "base"',v("{%- assign type = itemPreset[1] -%}"))}
|
|
84
85
|
`)}
|
|
85
86
|
${v("{%- assign optionRendered = true -%}")}
|
|
86
|
-
${y("value in values",p({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:
|
|
87
|
-
${f("type == 'dropdown'",r({...
|
|
87
|
+
${y("value in values",p({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:L,uid:H,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",optionType:"optionType",activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...E,...B,swatchAutoWidth:Q(),optionTypo:k}))}
|
|
88
|
+
${f("type == 'dropdown'",r({...E,...B,swatchAutoWidth:Y(),optionTypo:k}))}
|
|
88
89
|
`)}
|
|
89
90
|
`)}
|
|
90
91
|
|
|
91
|
-
${f("optionRendered == false",
|
|
92
|
-
`,
|
|
93
|
-
<div className="${
|
|
94
|
-
${l(
|
|
92
|
+
${f("optionRendered == false",tr())}
|
|
93
|
+
`,tr=()=>y("value in values",p({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:L,uid:H,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:"optionType",activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...E,...B,swatchAutoWidth:Q(),optionTypo:k,isRenderDefault:!0})),tl=d(I(x)),tm=w(N),tc=()=>`
|
|
94
|
+
<div className="${tl}">
|
|
95
|
+
${l(tm)}
|
|
95
96
|
</div>
|
|
96
|
-
`;$({setting:
|
|
97
|
+
`;$({setting:B,styles:JSON.stringify(E),variants:"{{ product.variants | json | escape }}",optionsWithValues:"{{ product.options_with_values | json | escape }}",variantSelected:"{{ variant | json | escape }}",variantInventoryQuantity:"{{ product.variants | map: 'inventory_quantity' | json | escape }}",variantInventoryPolicy:"{{ product.variants | map: 'inventory_policy' | json | escape }}",moneyFormat:"{{ shop.money_format | json | escape }}",productId:"{{ product.id | json | escape }}",productUrl:"{{ product.url | json | escape }}",productHandle:"{{ product.handle | json | escape }}",displayState:`${JSON.stringify(z)}`,totalVariantCombinations:"{{ total_combinations }}",firstAvailableVariant:"{{ product.selected_or_first_available_variant | json | escape }}"});let td=g(V({uid:H,hasPreSelected:W})),tu=u(_(N)),t$=d({"gp-flex gp-flex-col !gp-ml-0":!0}),tg=()=>{let t=i?"{{ 'gp-product-variant-v3.js' | asset_url }}":`${o}/assets-v2/gp-product-variant-v3.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${m('class="gps-link" delay',"src")}="${t}" defer="defer"></script>`};return e`
|
|
97
98
|
${v("{%- assign total_combinations = 1 -%}")}
|
|
98
99
|
${y("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
99
100
|
<gp-product-variants
|
|
100
|
-
${
|
|
101
|
+
${td}
|
|
101
102
|
gp-data='{
|
|
102
|
-
"setting":${JSON.stringify(
|
|
103
|
-
"styles":${JSON.stringify(
|
|
103
|
+
"setting":${JSON.stringify(B)?.replaceAll("'","'")},
|
|
104
|
+
"styles":${JSON.stringify(E)},
|
|
104
105
|
"variants":{{product.variants | json | escape}},
|
|
105
106
|
"optionsWithValues": {{product.options_with_values | json | escape}},
|
|
106
107
|
"variantSelected": {{ variant | json | escape }},
|
|
@@ -110,7 +111,7 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
|
|
|
110
111
|
"productId": {{product.id | json | escape}},
|
|
111
112
|
"productUrl": {{product.url | json | escape}},
|
|
112
113
|
"productHandle": {{product.handle | json | escape}},
|
|
113
|
-
"displayState": ${JSON.stringify(
|
|
114
|
+
"displayState": ${JSON.stringify(z)},
|
|
114
115
|
"totalVariantCombinations": {{total_combinations}},
|
|
115
116
|
"firstAvailableVariant": {{product.selected_or_first_available_variant | json | escape}}
|
|
116
117
|
}
|
|
@@ -118,12 +119,12 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
|
|
|
118
119
|
${v("{%- assign options = product.options_with_values -%}")}
|
|
119
120
|
${v("{%- assign variants = product.variants -%}")}
|
|
120
121
|
${f("options.size == 0 or options.size == 1 and variants.size == 1 and variants[0].title == 'Default Title' and variants[0].option1 == 'Default Title'","<div></div>",e`<div
|
|
121
|
-
class="${
|
|
122
|
-
style="${
|
|
122
|
+
class="${t$}"
|
|
123
|
+
style="${tu}"
|
|
123
124
|
>
|
|
124
|
-
${S(
|
|
125
|
+
${S(M,tc(),to())}
|
|
125
126
|
</div>`)}
|
|
126
127
|
</gp-product-variants>
|
|
127
128
|
|
|
128
|
-
${
|
|
129
|
+
${tg()}
|
|
129
130
|
`};export{ProductVariants as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeStyleResponsive as
|
|
1
|
+
import{makeStyleResponsive as t,makeWidth as e,optionLayoutStyle as r,makeStyle as p}from"@gem-sdk/core";import{filterTruthyObject as o}from"../../../../../helpers.js";let getWrapperStyle=p=>{let{style:a,styles:g,setting:l}=p,{width:i,align:m}=g??{},{column:n}=l??{},y=t("w",e(i));return o({...r(n),...t("ta",m),...y,...a})},getVariantOptionGroupStyle=(t,e)=>o({...p({rg:t,cg:e})});export{getVariantOptionGroupStyle,getWrapperStyle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeStyleResponsive as
|
|
1
|
+
import{makeStyleResponsive as t,makeWidth as e}from"@gem-sdk/core";import{filterTruthyObject as r}from"../../../../../helpers.js";let getLabelVariantStyle=o=>o?r(t("w",e(o))):{},getMarginBottomStyle=(e,o)=>!e||o?{}:r(t("mb",e));export{getLabelVariantStyle,getMarginBottomStyle};
|