@gem-sdk/components 2.0.0-staging.1032 → 2.0.0-staging.1033

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.
@@ -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: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;
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;
@@ -1,11 +1,37 @@
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:v}=s??{},q="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: ',' %}`)}
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:d}=t??{},{label:u,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},_=()=>{let e={};return core.DEVICES.forEach(s=>{e[s]=r?.[s]==="fill"}),e},L=core.composeMemo(()=>{let e=mappingVariantStyles.mappingVariantStyles(i?.variantPresets,t);return{...i,variantPresets:e}},[i?.variantPresets,t]),S=e=>{let s={"'":"'",'"':"""},t=e;for(let i in s)e.indexOf(i)>=0&&(t=t.replaceAll(i,s[i]));return t},I=()=>i?.variantPresets?.map(e=>`${S(e.optionName)}($2)${e.optionType}`).join("($1)"),V=()=>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"),b=system.createClass(classes$1.getWrapVariantOptionClass(y,o)),w=()=>core.template`
2
+ ${system.Liquid(`{%- assign presets = "${I()}" | split: '($1)' -%}`)}
3
+ ${system.Liquid(`{% assign hiddenPresetOptions = "${V()}" | split: ',' %}`)}
4
+
5
+ ${system.Liquid(`{% assign all_option_names = options | map: 'name' %}
6
+ {% assign filtered_options_string = '' %}
7
+ {% assign delimiter = '||' %}
8
+
9
+ {% for item_name in all_option_names %}
10
+ {% assign is_excluded = false %}
11
+ {% for exclude_name in hiddenPresetOptions %}
12
+ {% if item_name == exclude_name %}
13
+ {% assign is_excluded = true %}
14
+ {% endif %}
15
+ {% endfor %}
16
+
17
+ {% unless is_excluded %}
18
+ {% if filtered_options_string == '' %}
19
+ {% assign filtered_options_string = item_name %}
20
+ {% else %}
21
+ {% assign filtered_options_string = filtered_options_string | append: delimiter | append: item_name %}
22
+ {% endif %}
23
+ {% endunless %}
24
+ {% endfor %}
25
+
26
+ {% assign filtered_options_array = filtered_options_string | split: delimiter %}`)}
27
+
28
+ ${system.Liquid("{% assign last_option_name = filtered_options_array | last %}")}
29
+
4
30
  ${system.LiquidFor("option in options",`
5
31
  <div
6
32
  option-name="{{option.name | escape}}"
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 %}")}"
33
+ class="${b} ${system.LiquidIf("hiddenPresetOptions contains option.name","gp-hidden")}"
34
+ style="${_function.getStyleOfObject(styles$1.getMarginBottomStyle(d))}${system.Liquid("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
9
35
  >
10
36
  ${system.Liquid("{%- assign showVariantClass = 'variant-display' -%}")}
11
37
  ${system.Liquid("{%- assign optionName = option.name -%}")}
@@ -13,7 +39,7 @@
13
39
  ${system.Liquid("{%- assign presetDetail = preset | split: '($2)' -%}")}
14
40
  ${system.LiquidIf("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${system.Liquid("{%- assign showVariantClass = '' -%}")} ${system.Liquid("{%- break -%}")}`)}
15
41
  `)}
16
- ${system.If(d,Text_liquid.default(A)," ")}
42
+ ${system.If(u,Text_liquid.default(A)," ")}
17
43
  <div
18
44
  variant-option-name="{{option.name | escape}}"
19
45
  class="${h}"
@@ -31,10 +57,10 @@
31
57
  {%- endif -%}
32
58
  `)}
33
59
  ${system.If(!g,system.Liquid("{%- assign selectedValue = null -%}"),"")}
34
- ${system.If(c,T(),P())}
60
+ ${system.If(c,P(),T())}
35
61
  </div>
36
62
  </div>`)}
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`
63
+ `,D=i?.variantPresets?.map(e=>({name:S(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),P=()=>core.template`
38
64
  ${system.Liquid("{%- assign optionRendered = false -%}")}
39
65
  ${system.Liquid("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
40
66
  ${system.Liquid("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
@@ -74,7 +100,7 @@
74
100
  ${system.Liquid("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
75
101
 
76
102
  ${system.LiquidIf("optionTitle == option.name",`
77
- ${system.Liquid(`{%- assign variantPresetString = "${b}" -%}`)}
103
+ ${system.Liquid(`{%- assign variantPresetString = "${D}" -%}`)}
78
104
  ${system.Liquid('{%- assign optionName = option.name | replace: "\'", "&apos;" | replace: \'"\', "&quot;" -%}')}
79
105
  ${system.Liquid("{%- assign items = variantPresetString | split:'($2)' -%}")}
80
106
  ${system.Liquid("{%- assign type = 'dropdown' -%}")}
@@ -84,23 +110,23 @@
84
110
  ${system.LiquidIf('itemPreset[0] == "base"',system.Liquid("{%- assign type = itemPreset[1] -%}"))}
85
111
  `)}
86
112
  ${system.Liquid("{%- assign optionRendered = true -%}")}
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:v,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}))}
113
+ ${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,...L,swatchAutoWidth:f(),optionTypo:l}))}
114
+ ${system.LiquidIf("type == 'dropdown'",Dropdown_liquid.default({...t,...L,swatchAutoWidth:_(),optionTypo:l}))}
89
115
  `)}
90
116
  `)}
91
117
 
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:v,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}">
95
- ${DropdownGroup_liquid.default(E)}
118
+ ${system.LiquidIf("optionRendered == false",T())}
119
+ `,T=()=>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,...L,swatchAutoWidth:f(),optionTypo:l,isRenderDefault:!0})),x=system.createClass(classes.getWrapDropdownClass(o)),O=getData.getDropdownGroupData(e),E=()=>`
120
+ <div className="${x}">
121
+ ${DropdownGroup_liquid.default(O)}
96
122
  </div>
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:v,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-v7-5.js' | asset_url }}":`${core.baseAssetURL}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return core.template`
123
+ `;system.createStateOrContext({setting:L,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-v7-5.js' | asset_url }}":`${core.baseAssetURL}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return core.template`
98
124
  ${system.Liquid("{%- assign total_combinations = 1 -%}")}
99
125
  ${system.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
100
126
  <gp-product-variants-v7-5
101
127
  ${C}
102
128
  gp-data='{
103
- "setting":${JSON.stringify(S)?.replaceAll("'","&#039;")},
129
+ "setting":${JSON.stringify(L)?.replaceAll("'","&#039;")},
104
130
  "styles":${JSON.stringify(t)},
105
131
  "variants":{{product.variants | json | escape}},
106
132
  "optionsWithValues": {{product.options_with_values | json | escape}},
@@ -122,7 +148,7 @@
122
148
  class="${F}"
123
149
  style="${N}"
124
150
  >
125
- ${system.If(q,x(),D())}
151
+ ${system.If(v,E(),w())}
126
152
  </div>`)}
127
153
  </gp-product-variants-v7-5>
128
154
 
@@ -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=()=>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};
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};
@@ -1,23 +1,49 @@
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={"'":"&apos;",'"':"&quot;"},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`
1
+ import{composeMemo as e,template as t,DEVICES as s,getResponsiveValueByScreen as i,isLocalEnv as a,baseAssetURL as o}from"@gem-sdk/core";import n from"../../../text/components/Text.liquid.js";import r from"./components/variants/index.liquid.js";import p 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 d}from"./utils/mappingVariantStyles.js";import{createClass as c,createStyle as u,createStateOrContext as g,createAttr as $,Liquid as v,LiquidFor as f,LiquidIf as y,If as _}from"@gem-sdk/system";import{getAttrs as S}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as h,getWrapperStyle as V}from"./common/main/styles.js";import{getVariantOptionGroupClass as j,getWrapDropdownClass as I}from"./common/main/classes.js";import{getTextVariantTitleData as A,getDropdownGroupData as b}from"./common/main/getData.js";import{getWrapVariantOptionClass as w}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:x,setting:E,advanced:O}=N,{align:U,swatchItemWidth:K,dropdownItemWidth:q,swatchSpacing:C,optionTypo:k,marginBottom:F}=x??{},{label:G,optionType:J,showAsSwatches:L,layout:R,hasPreSelected:W}=E??{},z=O?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:H}=D??{},M="groupOption"===J,Q=()=>{let e={};return s.forEach(t=>{let s=i(K,t);e[t]="auto"===s}),e},Y=()=>{let e={};return s.forEach(t=>{e[t]=q?.[t]==="fill"}),e},B=e(()=>{let e=d(E?.variantPresets,x);return{...E,variantPresets:e}},[E?.variantPresets,x]),X=e=>{let t={"'":"&apos;",'"':"&quot;"},s=e;for(let i in t)e.indexOf(i)>=0&&(s=s.replaceAll(i,t[i]));return s},Z=()=>E?.variantPresets?.map(e=>`${X(e.optionName)}($2)${e.optionType}`).join("($1)"),ee=()=>E?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),et=c(j(U)),es=u(h(C,C)),ei=A(N,"Liquid"),ea=c(w(R,U)),eo=()=>t`
2
2
  ${v(`{%- assign presets = "${Z()}" | split: '($1)' -%}`)}
3
- ${v(`{% assign hiddenPresetOptions = "${tt()}" | split: ',' %}`)}
4
- ${y("option in options",`
3
+ ${v(`{% assign hiddenPresetOptions = "${ee()}" | split: ',' %}`)}
4
+
5
+ ${v(`{% assign all_option_names = options | map: 'name' %}
6
+ {% assign filtered_options_string = '' %}
7
+ {% assign delimiter = '||' %}
8
+
9
+ {% for item_name in all_option_names %}
10
+ {% assign is_excluded = false %}
11
+ {% for exclude_name in hiddenPresetOptions %}
12
+ {% if item_name == exclude_name %}
13
+ {% assign is_excluded = true %}
14
+ {% endif %}
15
+ {% endfor %}
16
+
17
+ {% unless is_excluded %}
18
+ {% if filtered_options_string == '' %}
19
+ {% assign filtered_options_string = item_name %}
20
+ {% else %}
21
+ {% assign filtered_options_string = filtered_options_string | append: delimiter | append: item_name %}
22
+ {% endif %}
23
+ {% endunless %}
24
+ {% endfor %}
25
+
26
+ {% assign filtered_options_array = filtered_options_string | split: delimiter %}`)}
27
+
28
+ ${v("{% assign last_option_name = filtered_options_array | last %}")}
29
+
30
+ ${f("option in options",`
5
31
  <div
6
32
  option-name="{{option.name | escape}}"
7
- class="${ti} ${f("hiddenPresetOptions contains option.name","gp-hidden")}"
8
- style="${P(T(F))}${v("{% if forloop.last %}--mb:0;{% endif %}")}"
33
+ class="${ea} ${y("hiddenPresetOptions contains option.name","gp-hidden")}"
34
+ style="${P(T(F))}${v("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
9
35
  >
10
36
  ${v("{%- assign showVariantClass = 'variant-display' -%}")}
11
37
  ${v("{%- assign optionName = option.name -%}")}
12
- ${y("preset in presets",`
38
+ ${f("preset in presets",`
13
39
  ${v("{%- assign presetDetail = preset | split: '($2)' -%}")}
14
- ${f("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${v("{%- assign showVariantClass = '' -%}")} ${v("{%- break -%}")}`)}
40
+ ${y("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${v("{%- assign showVariantClass = '' -%}")} ${v("{%- break -%}")}`)}
15
41
  `)}
16
- ${S(G,n(ta)," ")}
42
+ ${_(G,n(ei)," ")}
17
43
  <div
18
44
  variant-option-name="{{option.name | escape}}"
19
- class="${te}"
20
- style="${P(ts)}"
45
+ class="${et}"
46
+ style="${P(es)}"
21
47
  >
22
48
  ${v("{%- assign values = option.values -%}")}
23
49
  ${v("{%- assign rootForloop = forloop.index0 -%}")}
@@ -30,22 +56,22 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
30
56
  {%- assign selectedValue = variant.option3 -%}
31
57
  {%- endif -%}
32
58
  `)}
33
- ${S(!W,v("{%- assign selectedValue = null -%}"),"")}
34
- ${S(L,tp(),tr())}
59
+ ${_(!W,v("{%- assign selectedValue = null -%}"),"")}
60
+ ${_(L,er(),ep())}
35
61
  </div>
36
62
  </div>`)}
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`
63
+ `,en=E?.variantPresets?.map(e=>({name:X(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),er=()=>t`
38
64
  ${v("{%- assign optionRendered = false -%}")}
39
65
  ${v("{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}")}
40
66
  ${v("{%- assign swatchesItems = swatches | split: '($1)' -%}")}
41
67
 
42
- ${y("swatchesItem in swatchesItems",`
68
+ ${f("swatchesItem in swatchesItems",`
43
69
  ${v('{%- assign colorArraysString = "" -%}')}
44
70
  ${v('{%- assign labelsString = "" -%}')}
45
71
  ${v('{%- assign imageUrlsString = "" -%}')}
46
72
  ${v("{%- assign attrItems = swatchesItem | split: '($3)' -%}")}
47
73
 
48
- ${y("attrItem in attrItems",`${v("{%- assign attrs = attrItem | split: '($2)' -%}")}
74
+ ${f("attrItem in attrItems",`${v("{%- assign attrs = attrItem | split: '($2)' -%}")}
49
75
  ${v("{%- assign optionKey = attrs[0] -%}")}
50
76
  ${v("{%- assign optionValue = attrs[1] -%}")}
51
77
  ${v(`
@@ -56,52 +82,52 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
56
82
  {% endif %}
57
83
  `)}
58
84
 
59
- ${f("optionKey == 'optionValues'",`${v("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
60
- ${y("opValueItem in opValueItems",`${v("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
61
- ${y("opValueItemAttr in opValueItemAttrs",`${v("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
85
+ ${y("optionKey == 'optionValues'",`${v("{%- assign opValueItems = optionValue | split: '($4)' -%}")}
86
+ ${f("opValueItem in opValueItems",`${v("{%- assign opValueItemAttrs = opValueItem | split: '($6)' -%}")}
87
+ ${f("opValueItemAttr in opValueItemAttrs",`${v("{%- assign attrs = opValueItemAttr | split: '($5)' -%}")}
62
88
  ${v("{%- assign opValueItemKey = attrs[0] -%}")}
63
89
  ${v("{%- assign opValueItemValue = attrs[1] -%}")}
64
90
 
65
- ${f("opValueItemKey == 'label'",`${v("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}${v('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
91
+ ${y("opValueItemKey == 'label'",`${v("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}${v('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
66
92
 
67
- ${f("opValueItemKey == 'colors'",`${v("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}${v('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
93
+ ${y("opValueItemKey == 'colors'",`${v("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}${v('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
68
94
 
69
- ${f("opValueItemKey == 'imageUrl'",`${v("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}${v('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}`)}`)}`)}
95
+ ${y("opValueItemKey == 'imageUrl'",`${v("{%- assign imageUrlsString = imageUrlsString | append: opValueItemValue -%}")}${v('{%- assign imageUrlsString = imageUrlsString | append: "($8)" -%}')}`)}`)}`)}`)}
70
96
  `)}
71
97
 
72
98
  ${v("{%- assign labels = labelsString | split: '($8)' -%}")}
73
99
  ${v("{%- assign colorStrings = colorArraysString | split: '($8)' -%}")}
74
100
  ${v("{%- assign imageUrls = imageUrlsString | split: '($8)' -%}")}
75
101
 
76
- ${f("optionTitle == option.name",`
77
- ${v(`{%- assign variantPresetString = "${tn}" -%}`)}
102
+ ${y("optionTitle == option.name",`
103
+ ${v(`{%- assign variantPresetString = "${en}" -%}`)}
78
104
  ${v('{%- assign optionName = option.name | replace: "\'", "&apos;" | replace: \'"\', "&quot;" -%}')}
79
105
  ${v("{%- assign items = variantPresetString | split:'($2)' -%}")}
80
106
  ${v("{%- assign type = 'dropdown' -%}")}
81
- ${y("item in items",`
107
+ ${f("item in items",`
82
108
  ${v("{%- assign itemPreset = item | split:'($1)' -%}")}
83
- ${f("itemPreset[0] == optionName",v("{%- assign type = itemPreset[1] -%}"))}
84
- ${f('itemPreset[0] == "base"',v("{%- assign type = itemPreset[1] -%}"))}
109
+ ${y("itemPreset[0] == optionName",v("{%- assign type = itemPreset[1] -%}"))}
110
+ ${y('itemPreset[0] == "base"',v("{%- assign type = itemPreset[1] -%}"))}
85
111
  `)}
86
112
  ${v("{%- assign optionRendered = true -%}")}
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}))}
113
+ ${f("value in values",r({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 -%}":"",...x,...B,swatchAutoWidth:Q(),optionTypo:k}))}
114
+ ${y("type == 'dropdown'",p({...x,...B,swatchAutoWidth:Y(),optionTypo:k}))}
89
115
  `)}
90
116
  `)}
91
117
 
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)}
118
+ ${y("optionRendered == false",ep())}
119
+ `,ep=()=>f("value in values",r({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 -%}":"",...x,...B,swatchAutoWidth:Q(),optionTypo:k,isRenderDefault:!0})),el=c(I(U)),em=b(N),ed=()=>`
120
+ <div className="${el}">
121
+ ${l(em)}
96
122
  </div>
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-v7-5.js' | asset_url }}":`${o}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${m('class="gps-link" delay',"src")}="${t}" defer="defer"></script>`};return e`
123
+ `;g({setting:B,styles:JSON.stringify(x),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 ec=$(S({uid:H,hasPreSelected:W})),eu=u(V(N)),eg=c({"gp-flex gp-flex-col !gp-ml-0":!0}),e$=()=>{let e=a?"{{ 'gp-product-variant-v7-5.js' | asset_url }}":`${o}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${m('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return t`
98
124
  ${v("{%- assign total_combinations = 1 -%}")}
99
- ${y("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
125
+ ${f("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
100
126
  <gp-product-variants-v7-5
101
- ${td}
127
+ ${ec}
102
128
  gp-data='{
103
129
  "setting":${JSON.stringify(B)?.replaceAll("'","&#039;")},
104
- "styles":${JSON.stringify(E)},
130
+ "styles":${JSON.stringify(x)},
105
131
  "variants":{{product.variants | json | escape}},
106
132
  "optionsWithValues": {{product.options_with_values | json | escape}},
107
133
  "variantSelected": {{ variant | json | escape }},
@@ -118,13 +144,13 @@ import{composeMemo as t,template as e,DEVICES as s,getResponsiveValueByScreen as
118
144
  '>
119
145
  ${v("{%- assign options = product.options_with_values -%}")}
120
146
  ${v("{%- assign variants = product.variants -%}")}
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
122
- class="${t$}"
123
- style="${tu}"
147
+ ${y("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>",t`<div
148
+ class="${eg}"
149
+ style="${eu}"
124
150
  >
125
- ${S(M,tc(),to())}
151
+ ${_(M,ed(),eo())}
126
152
  </div>`)}
127
153
  </gp-product-variants-v7-5>
128
154
 
129
- ${tg()}
155
+ ${e$()}
130
156
  `};export{ProductVariants as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-staging.1032",
3
+ "version": "2.0.0-staging.1033",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",