@gem-sdk/components 8.0.0-dev.24 → 8.0.0-dev.25
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/product/components/product-button/ProductButton.liquid.js +6 -4
- package/dist/cjs/product/components/product-variants/ProductVariants.liquid.js +21 -19
- package/dist/cjs/product/components/product-wrap/Product.liquid.js +10 -12
- package/dist/esm/product/components/product-button/ProductButton.liquid.js +11 -9
- package/dist/esm/product/components/product-variants/ProductVariants.liquid.js +34 -32
- package/dist/esm/product/components/product-wrap/Product.liquid.js +31 -33
- package/package.json +2 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var styles=require("./common/styles.js"),helpers$1=require("./common/helpers.js"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),helpers=require("../../../helpers.js"),getButtonDynamicSourceLocales=require("./helpers/getButtonDynamicSourceLocales.js"),SoldOutButton_liquid=require("./SoldOutButton.liquid.js"),AddToCartButton_liquid=require("./AddToCartButton.liquid.js");const ProductButton=t=>{let{setting:e,builderProps:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var styles=require("./common/styles.js"),helpers$1=require("./common/helpers.js"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),helpers=require("../../../helpers.js"),getButtonDynamicSourceLocales=require("./helpers/getButtonDynamicSourceLocales.js"),SoldOutButton_liquid=require("./SoldOutButton.liquid.js"),AddToCartButton_liquid=require("./AddToCartButton.liquid.js");const ProductButton=t=>{let{setting:e,builderProps:s,style:r,styles:o,pageContext:a}=t,{wrapStyle:i,restStyle:l}=styles.getSplitStyle(r),{outOfStockButtonLabel:u,unavailableButtonLabel:n,variantSelectionRequiredMessage:c}=getButtonDynamicSourceLocales.getButtonDynamicSourceLocales({setting:e,pageContext:a,builderProps:s}),{urlData:d}=helpers.getInsertLinkData("",e?.actionEffect==="open-cart-drawer"?{link:"/cart",target:"_self"}:e?.customURL),p=system.createStateOrContext(helpers$1.getGPProductButtonState(o,e)),g=()=>AddToCartButton_liquid.AddToCartButton({...t,style:l}),y=()=>SoldOutButton_liquid.SoldOutButton({...t,style:l,label:u}),m=()=>system.If(core.isLocalEnv,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-product-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);return core.template`
|
|
2
|
+
${system.Liquid("{%- assign total_combinations = 1 -%}")}
|
|
3
|
+
${system.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
2
4
|
{%- liquid
|
|
3
5
|
assign inventory_quantity = variant.inventory_quantity | default: 0
|
|
4
6
|
assign is_in_stock = variant.available
|
|
5
7
|
-%}
|
|
6
8
|
<gp-product-button
|
|
7
|
-
style="${
|
|
9
|
+
style="${i}"
|
|
8
10
|
gp-data-wrapper="true"
|
|
9
11
|
gp-href="${d.href}"
|
|
10
12
|
class="gp-product-button"
|
|
11
|
-
gp-label-out-of-stock="${
|
|
13
|
+
gp-label-out-of-stock="${u}"
|
|
12
14
|
gp-label-unavailable="${n}"
|
|
13
15
|
gp-data='${JSON.stringify(p).replaceAll("'","'")}'
|
|
14
16
|
data-variant-selection-required-message="${c}"
|
|
@@ -16,5 +18,5 @@
|
|
|
16
18
|
${g()}
|
|
17
19
|
${y()}
|
|
18
20
|
</gp-product-button>
|
|
19
|
-
${
|
|
21
|
+
${m()}
|
|
20
22
|
`};exports.default=ProductButton;
|
|
@@ -1,8 +1,8 @@
|
|
|
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"),OptionVariantsNewFormat_liquid=require("./OptionVariantsNewFormat.liquid.js"),OptionVariantsOldFormat_liquid=require("./OptionVariantsOldFormat.liquid.js");const DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=e=>{let{builderProps:t,styles:s,setting:i,advanced:a}=e,{align:o,swatchItemWidth:n,dropdownItemWidth:r,swatchSpacing:l,optionTypo:p,marginBottom:d}=s??{},{label:u,optionType:m,showAsSwatches:c,layout:y,hasPreSelected:v}=i??{},
|
|
2
|
-
${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:
|
|
3
|
-
${system.LiquidIf(e?'type == "dropdown"':"false",Dropdown_liquid.default({...s,...
|
|
4
|
-
${system.Liquid(`{%- assign presets = "${
|
|
5
|
-
${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"),OptionVariantsNewFormat_liquid=require("./OptionVariantsNewFormat.liquid.js"),OptionVariantsOldFormat_liquid=require("./OptionVariantsOldFormat.liquid.js");const DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=e=>{let{builderProps:t,styles:s,setting:i,advanced:a}=e,{align:o,swatchItemWidth:n,dropdownItemWidth:r,swatchSpacing:l,optionTypo:p,marginBottom:d}=s??{},{label:u,optionType:m,showAsSwatches:c,layout:y,hasPreSelected:v}=i??{},g=a?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:_}=t??{},f="groupOption"===m,q=()=>{let e={};return core.DEVICES.forEach(t=>{let s=core.getResponsiveValueByScreen(n,t);e[t]="auto"===s}),e},$=()=>{let e={};return core.DEVICES.forEach(t=>{e[t]=r?.[t]==="fill"}),e},h=i?.variantPresets?mappingVariantStyles.mappingVariantStyles(i?.variantPresets,s):[],S=h?.map(e=>({...e,presets:{[e.optionType]:e.presets[e.optionType]}})),w={...i,variantPresetsOptionType:S},L=e=>{let t={"'":"'",'"':"""},s=e;for(let i in t)e.indexOf(i)>=0&&(s=s.replaceAll(i,t[i]));return s},j=()=>i?.variantPresets?.map(e=>`${L(e.optionName)}($2)${e.optionType}`).join("($1)"),O=()=>i?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),V=({showDropdown:e,isRenderDefault:t,typeOfOption:i})=>core.template`
|
|
2
|
+
${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:_,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:v?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:i,activeClass:v?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...s,...w,swatchAutoWidth:q(),optionTypo:p,isRenderDefault:t}))}
|
|
3
|
+
${system.LiquidIf(e?'type == "dropdown"':"false",Dropdown_liquid.default({...s,...w,swatchAutoWidth:$(),optionTypo:p}))}`,D=i?.variantPresets?.map(e=>({name:L(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),A={renderVariantItem:V,variantPresetsLiquid:D??""},b=system.createClass(classes.getVariantOptionGroupClass(o)),E=system.createStyle(styles.getVariantOptionGroupStyle(l,l)),P=getData.getTextVariantTitleData(e,"Liquid"),x=system.createClass(classes$1.getWrapVariantOptionClass(y,o)),N=()=>core.template`
|
|
4
|
+
${system.Liquid(`{%- assign presets = "${j()}" | split: '($1)' -%}`)}
|
|
5
|
+
${system.Liquid(`{% assign hiddenPresetOptions = "${O()}" | split: ',' %}`)}
|
|
6
6
|
|
|
7
7
|
${system.Liquid(`{% assign all_option_names = options | map: 'name' %}
|
|
8
8
|
{% assign filtered_options_string = '' %}
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
${system.Liquid("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
42
42
|
${system.LiquidIf("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${system.Liquid("{%- assign showVariantClass = '' -%}")} ${system.Liquid("{%- break -%}")}`)}
|
|
43
43
|
`)}
|
|
44
|
-
${system.If(u,Text_liquid.default(
|
|
44
|
+
${system.If(u,Text_liquid.default(P)," ")}
|
|
45
45
|
<div
|
|
46
46
|
variant-option-name="{{option.name | escape}}"
|
|
47
|
-
class="${
|
|
48
|
-
style="${_function.getStyleOfObject(
|
|
47
|
+
class="${b}"
|
|
48
|
+
style="${_function.getStyleOfObject(E)}"
|
|
49
49
|
>
|
|
50
50
|
${system.Liquid("{%- assign values = option.values -%}")}
|
|
51
51
|
${system.Liquid("{%- assign rootForloop = forloop.index0 -%}")}
|
|
@@ -59,20 +59,22 @@
|
|
|
59
59
|
{%- endif -%}
|
|
60
60
|
`)}
|
|
61
61
|
${system.If(!v,system.Liquid("{%- assign selectedValue = null -%}"),"")}
|
|
62
|
-
${system.If(c,
|
|
62
|
+
${system.If(c,T(),V({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
|
|
63
63
|
</div>
|
|
64
64
|
</div>`)}
|
|
65
|
-
`,
|
|
66
|
-
${system.LiquidIf("shop.metafields.GEMPAGES.
|
|
67
|
-
`,
|
|
68
|
-
<div className="${
|
|
69
|
-
${DropdownGroup_liquid.default(
|
|
65
|
+
`,T=()=>core.template`
|
|
66
|
+
${system.LiquidIf("shop.metafields.GEMPAGES.swatchesJSONFormat and shop.metafields.GEMPAGES.swatchesJSONFormat != blank",OptionVariantsNewFormat_liquid.renderOptionValuesNewFormatSwatches(A),OptionVariantsOldFormat_liquid.renderOptionValuesOld(A))}
|
|
67
|
+
`,I=system.createClass(classes.getWrapDropdownClass(o)),F=getData.getDropdownGroupData(e),C=()=>`
|
|
68
|
+
<div className="${I}">
|
|
69
|
+
${DropdownGroup_liquid.default(F)}
|
|
70
70
|
</div>
|
|
71
|
-
`,G=system.createAttr(getAttr.getAttrs({uid:
|
|
71
|
+
`,G=system.createAttr(getAttr.getAttrs({uid:_,hasPreSelected:v,cssClass:a?.cssClass})),k=system.createStyle(styles.getWrapperStyle(e)),W=system.createClass({"gp-flex gp-flex-col !gp-ml-0":!0}),J=()=>{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`
|
|
72
|
+
${system.Liquid("{%- assign total_combinations = 1 -%}")}
|
|
73
|
+
${system.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
72
74
|
<gp-product-variants
|
|
73
75
|
${G}
|
|
74
76
|
gp-data='{
|
|
75
|
-
"setting":${JSON.stringify(
|
|
77
|
+
"setting":${JSON.stringify(w)?.replaceAll("'","'")},
|
|
76
78
|
"styles":${JSON.stringify(s)},
|
|
77
79
|
"variants":{{product.variants | json | escape}},
|
|
78
80
|
"optionsWithValues": {{product.options_with_values | json | escape}},
|
|
@@ -83,7 +85,7 @@
|
|
|
83
85
|
"productId": {{product.id | json | escape}},
|
|
84
86
|
"productUrl": {{product.url | json | escape}},
|
|
85
87
|
"productHandle": {{product.handle | json | escape}},
|
|
86
|
-
"displayState": ${JSON.stringify(
|
|
88
|
+
"displayState": ${JSON.stringify(g)},
|
|
87
89
|
"totalVariantCombinations": {{total_combinations}},
|
|
88
90
|
"firstAvailableVariant": {{product.selected_or_first_available_variant | json | escape}}
|
|
89
91
|
}
|
|
@@ -95,9 +97,9 @@
|
|
|
95
97
|
class="${W}"
|
|
96
98
|
style="${k}"
|
|
97
99
|
>
|
|
98
|
-
${system.If(
|
|
100
|
+
${system.If(f,C(),N())}
|
|
99
101
|
</div>`)}
|
|
100
102
|
</gp-product-variants>
|
|
101
103
|
|
|
102
|
-
${
|
|
104
|
+
${J()}
|
|
103
105
|
`};exports.default=ProductVariants;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Row_liquid=require("../../../grid/components/row/Row.liquid.js"),system=require("@gem-sdk/system"),helpers$1=require("../../../helpers.js"),helpers=require("./common/helpers.js");const Product=e=>{let{children:t,setting:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Row_liquid=require("../../../grid/components/row/Row.liquid.js"),system=require("@gem-sdk/system"),helpers$1=require("../../../helpers.js"),helpers=require("./common/helpers.js");const Product=e=>{let{children:t,setting:r,style:i,builderProps:a,rawChildren:o,advanced:d}=e,{isSyncProduct:s}=r??{},{rowSetting:n,rowStyles:c,formatVariantId:l,formatProductId:p,productStatus:u,preSelectedOptionIds:f,productHandle:g,advancedStyle:m}=helpers.getData(e),_=()=>core.template`
|
|
2
2
|
{%- liquid
|
|
3
3
|
if request.page_type == 'product'
|
|
4
4
|
if '${u}' == '${helpers.STATIC_PRODUCT_STATUS}'
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
assign product = collections.all.products | sort: 'created_at' | reverse | first
|
|
8
8
|
endpaginate
|
|
9
9
|
else
|
|
10
|
-
assign product = all_products['${
|
|
10
|
+
assign product = all_products['${g}']
|
|
11
11
|
assign productId = '${p}' | times: 1
|
|
12
12
|
if product == empty or product == null
|
|
13
13
|
paginate collections.all.products by 100000
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
assign product = collections.all.products | sort: 'created_at'| reverse | first
|
|
27
27
|
endpaginate
|
|
28
28
|
else
|
|
29
|
-
assign product = all_products['${
|
|
29
|
+
assign product = all_products['${g}']
|
|
30
30
|
assign productId = '${p}' | times: 1
|
|
31
31
|
if product == empty or product == null
|
|
32
32
|
paginate collections.all.products by 100000
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
`,y=()=>core.template`
|
|
44
44
|
{%- liquid
|
|
45
45
|
if request.page_type != 'product'
|
|
46
|
-
assign product = all_products['${
|
|
46
|
+
assign product = all_products['${g}']
|
|
47
47
|
assign productId = '${p}' | times: 1
|
|
48
48
|
if product == empty or product == null
|
|
49
49
|
paginate collections.all.products by 100000
|
|
@@ -60,8 +60,6 @@
|
|
|
60
60
|
{%- assign gpBkProduct = product -%}
|
|
61
61
|
${system.If(u==helpers.DYNAMIC_PRODUCT_STATUS,y(),_())}
|
|
62
62
|
`,$=()=>core.template`
|
|
63
|
-
${system.Liquid("{%- assign total_combinations = 1 -%}")}
|
|
64
|
-
${system.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
65
63
|
{%- assign initVariantId = ${l} -%}
|
|
66
64
|
{%- assign product_form_id = 'product-form-' | append: "${a?.uid}" -%}
|
|
67
65
|
${l?"{%- assign variant = product.variants | where: 'id', initVariantId | first -%}":"{%- assign variant = product.selected_or_first_available_variant -%}"}
|
|
@@ -74,14 +72,14 @@
|
|
|
74
72
|
{%- endif -%}
|
|
75
73
|
`,S=()=>core.template`
|
|
76
74
|
<div class="gp-text-center">${helpers$1.getStaticLocale("Product","product_not_found")}</div>
|
|
77
|
-
`,
|
|
75
|
+
`,I=()=>core.template`
|
|
78
76
|
${$()}
|
|
79
77
|
<gp-product
|
|
80
78
|
data-uid="${a?.uid}"
|
|
81
79
|
data-id="${a?.uid}"
|
|
82
|
-
style="${
|
|
83
|
-
class="${
|
|
84
|
-
gp-context='{"productId": {{ product.id }}, "preSelectedOptionIds": [${f}], "isSyncProduct": "${
|
|
80
|
+
style="${m}"
|
|
81
|
+
class="${d?.cssClass}"
|
|
82
|
+
gp-context='{"productId": {{ product.id }}, "preSelectedOptionIds": [${f}], "isSyncProduct": "${s}", "variantSelected": {{ variant | json | escape }}, "inventory_management": {{ variant.inventory_management | json | escape }}, "inventory_policy": {{ variant.inventory_policy | json | escape }}, "inventoryQuantity": {{ variant.inventory_quantity }}, "quantity": 1, "formId": "{{ product_form_id }}" }'
|
|
85
83
|
gp-data='{"variantSelected": {{ variant | json | escape }}, "quantity": 1, "productUrl":{{ product.url | json | escape }}, "productHandle":{{ product.handle | json | escape }}, "collectionUrl": {{ collection.url | json | escape }}, "collectionHandle": {{ collection.handle | json | escape }}}'
|
|
86
84
|
>
|
|
87
85
|
<product-form class="product-form">
|
|
@@ -89,13 +87,13 @@
|
|
|
89
87
|
<input type="hidden" name="id" value="{{ variant.id }}" />
|
|
90
88
|
<input type="hidden" name="quantity" value="{{ quantity }}" />
|
|
91
89
|
<button type="submit" onclick="return false;" style="display:none;"></button>
|
|
92
|
-
${Row_liquid.default({builderProps:{...a,uid:a?.uid,uidInteraction:`${a?.uid}-row`},style:
|
|
90
|
+
${Row_liquid.default({builderProps:{...a,uid:a?.uid,uidInteraction:`${a?.uid}-row`},style:i,styles:c,setting:n,children:t,rawChildren:o})}
|
|
93
91
|
{%- endform -%}
|
|
94
92
|
</product-form>
|
|
95
93
|
</gp-product>
|
|
96
94
|
{%- assign product = gpBkProduct -%}
|
|
97
95
|
`;return core.template`
|
|
98
96
|
${v()}
|
|
99
|
-
${system.LiquidIf("product != empty and product != null",
|
|
97
|
+
${system.LiquidIf("product != empty and product != null",I(),S())}
|
|
100
98
|
${core.RenderIf(core.isLocalEnv,`<script ${helpers$1.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers$1.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-product-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
101
99
|
`};exports.default=Product;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import{getSplitStyle as t}from"./common/styles.js";import{getGPProductButtonState as
|
|
1
|
+
import{getSplitStyle as t}from"./common/styles.js";import{getGPProductButtonState as o}from"./common/helpers.js";import{template as s,isLocalEnv as e,baseAssetURL as r}from"@gem-sdk/core";import{createStateOrContext as a,Liquid as i,LiquidFor as l,If as n}from"@gem-sdk/system";import{getInsertLinkData as p,getSettingPreloadData as u}from"../../../helpers.js";import{getButtonDynamicSourceLocales as c}from"./helpers/getButtonDynamicSourceLocales.js";import{SoldOutButton as m}from"./SoldOutButton.liquid.js";import{AddToCartButton as d}from"./AddToCartButton.liquid.js";let ProductButton=f=>{let{setting:g,builderProps:$,style:b,styles:v,pageContext:y}=f,{wrapStyle:_,restStyle:j}=t(b),{outOfStockButtonLabel:S,unavailableButtonLabel:h,variantSelectionRequiredMessage:k}=c({setting:g,pageContext:y,builderProps:$}),{urlData:q}=p("",g?.actionEffect==="open-cart-drawer"?{link:"/cart",target:"_self"}:g?.customURL),B=a(o(v,g)),E=()=>d({...f,style:j}),A=()=>m({...f,style:j,label:S}),w=()=>n(e,`<script ${u('class="gps-link" delay',"src")}="{{ 'gp-product-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${u('class="gps-link" delay',"src")}="${r}/assets-v2/gp-product-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);return s`
|
|
2
|
+
${i("{%- assign total_combinations = 1 -%}")}
|
|
3
|
+
${l("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
2
4
|
{%- liquid
|
|
3
5
|
assign inventory_quantity = variant.inventory_quantity | default: 0
|
|
4
6
|
assign is_in_stock = variant.available
|
|
5
7
|
-%}
|
|
6
8
|
<gp-product-button
|
|
7
|
-
style="${
|
|
9
|
+
style="${_}"
|
|
8
10
|
gp-data-wrapper="true"
|
|
9
|
-
gp-href="${
|
|
11
|
+
gp-href="${q.href}"
|
|
10
12
|
class="gp-product-button"
|
|
11
|
-
gp-label-out-of-stock="${
|
|
12
|
-
gp-label-unavailable="${
|
|
13
|
-
gp-data='${JSON.stringify(
|
|
13
|
+
gp-label-out-of-stock="${S}"
|
|
14
|
+
gp-label-unavailable="${h}"
|
|
15
|
+
gp-data='${JSON.stringify(B).replaceAll("'","'")}'
|
|
14
16
|
data-variant-selection-required-message="${k}"
|
|
15
17
|
>
|
|
16
|
-
${
|
|
17
|
-
${
|
|
18
|
+
${E()}
|
|
19
|
+
${A()}
|
|
18
20
|
</gp-product-button>
|
|
19
|
-
${
|
|
21
|
+
${w()}
|
|
20
22
|
`};export{ProductButton as default};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{template as e,isLocalEnv as t,baseAssetURL as
|
|
2
|
-
${
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
1
|
+
import{template as e,isLocalEnv as t,baseAssetURL as i,DEVICES as o,getResponsiveValueByScreen as s}from"@gem-sdk/core";import a from"../../../text/components/Text.liquid.js";import n from"./components/variants/index.liquid.js";import r from"./components/dropdown-swatches/Dropdown.liquid.js";import p from"./components/dropdown-group/DropdownGroup.liquid.js";import{getSettingPreloadData as l}from"../../../helpers.js";import{mappingVariantStyles as d}from"./utils/mappingVariantStyles.js";import{createClass as m,createStyle as c,createAttr as u,Liquid as v,LiquidFor as f,LiquidIf as _,If as $}from"@gem-sdk/system";import{getAttrs as g}from"./common/main/getAttr.js";import{getVariantOptionGroupStyle as h,getWrapperStyle as y}from"./common/main/styles.js";import{getVariantOptionGroupClass as j,getWrapDropdownClass as w}from"./common/main/classes.js";import{getTextVariantTitleData as S,getDropdownGroupData as b}from"./common/main/getData.js";import{getWrapVariantOptionClass as A}from"./common/variants/classes.js";import{getStyleOfObject as P}from"../../helpers/function.js";import{getMarginBottomStyle as D}from"./common/variants/styles.js";import{renderOptionValuesNewFormatSwatches as N}from"./OptionVariantsNewFormat.liquid.js";import{renderOptionValuesOld as V}from"./OptionVariantsOldFormat.liquid.js";let DEFAULT_ADVANCED_DISPLAY_SETTING={desktop:!0,tablet:!0,mobile:!0},ProductVariants=E=>{let{builderProps:O,styles:T,setting:x,advanced:q}=E,{align:F,swatchItemWidth:G,dropdownItemWidth:C,swatchSpacing:I,optionTypo:k,marginBottom:L}=T??{},{label:J,optionType:z,showAsSwatches:M,layout:U,hasPreSelected:W}=x??{},R=q?.d??DEFAULT_ADVANCED_DISPLAY_SETTING,{uid:Y}=O??{},H="groupOption"===z,K=()=>{let e={};return o.forEach(t=>{let i=s(G,t);e[t]="auto"===i}),e},Q=()=>{let e={};return o.forEach(t=>{e[t]=C?.[t]==="fill"}),e},B=x?.variantPresets?d(x?.variantPresets,T):[],X=B?.map(e=>({...e,presets:{[e.optionType]:e.presets[e.optionType]}})),Z={...x,variantPresetsOptionType:X},ee=e=>{let t={"'":"'",'"':"""},i=e;for(let o in t)e.indexOf(o)>=0&&(i=i.replaceAll(o,t[o]));return i},et=()=>x?.variantPresets?.map(e=>`${ee(e.optionName)}($2)${e.optionType}`).join("($1)"),ei=()=>x?.variantPresets?.filter(e=>!!e?.hide)?.map(e=>e.optionName).join(","),eo=({showDropdown:t,isRenderDefault:i,typeOfOption:o})=>e`
|
|
2
|
+
${f("value in values",n({id:"{{option.name | escape}}-{{value | escape}}",variantKey:"{{option.name | escape}}-{{option.position}}-{{ forloop.index }}",showAsSwatches:M,uid:Y,name:"{{option.name | escape}}",value:{label:"{{value | escape}}"},checked:W?"{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}":"false",optionPosition:"rootForloop",typeOfOption:o,activeClass:W?"{%- if option.selected_value == value -%}option-item-active{%- endif -%}":"",...T,...Z,swatchAutoWidth:K(),optionTypo:k,isRenderDefault:i}))}
|
|
3
|
+
${_(t?'type == "dropdown"':"false",r({...T,...Z,swatchAutoWidth:Q(),optionTypo:k}))}`,es=x?.variantPresets?.map(e=>({name:ee(e.optionName),type:e.optionType})).map(e=>`${e.name}($1)${e.type}`).join("($2)").toString(),ea={renderVariantItem:eo,variantPresetsLiquid:es??""},en=m(j(F)),er=c(h(I,I)),ep=S(E,"Liquid"),el=m(A(U,F)),ed=()=>e`
|
|
4
|
+
${v(`{%- assign presets = "${et()}" | split: '($1)' -%}`)}
|
|
5
|
+
${v(`{% assign hiddenPresetOptions = "${ei()}" | split: ',' %}`)}
|
|
6
6
|
|
|
7
|
-
${
|
|
7
|
+
${v(`{% assign all_option_names = options | map: 'name' %}
|
|
8
8
|
{% assign filtered_options_string = '' %}
|
|
9
9
|
{% assign delimiter = '||' %}
|
|
10
10
|
|
|
@@ -27,29 +27,29 @@ import{template as e,isLocalEnv as t,baseAssetURL as s,DEVICES as i,getResponsiv
|
|
|
27
27
|
|
|
28
28
|
{% assign filtered_options_array = filtered_options_string | split: delimiter %}`)}
|
|
29
29
|
|
|
30
|
-
${
|
|
30
|
+
${v("{% assign last_option_name = filtered_options_array | last %}")}
|
|
31
31
|
|
|
32
|
-
${
|
|
32
|
+
${f("option in options",`
|
|
33
33
|
<div
|
|
34
34
|
option-name="{{option.name | escape}}"
|
|
35
|
-
class="${el} ${
|
|
36
|
-
style="${D(
|
|
35
|
+
class="${el} ${_("hiddenPresetOptions contains option.name","gp-hidden")}"
|
|
36
|
+
style="${P(D(L))}${v("{% if forloop.last or option.name == last_option_name %}--mb:0;--mb-mobile:0;--mb-tablet:0;{% endif %}")}"
|
|
37
37
|
>
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
38
|
+
${v("{%- assign showVariantClass = 'variant-display' -%}")}
|
|
39
|
+
${v("{%- assign optionName = option.name -%}")}
|
|
40
|
+
${f("preset in presets",`
|
|
41
|
+
${v("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
42
|
+
${_("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${v("{%- assign showVariantClass = '' -%}")} ${v("{%- break -%}")}`)}
|
|
43
43
|
`)}
|
|
44
44
|
${$(J,a(ep)," ")}
|
|
45
45
|
<div
|
|
46
46
|
variant-option-name="{{option.name | escape}}"
|
|
47
47
|
class="${en}"
|
|
48
|
-
style="${
|
|
48
|
+
style="${P(er)}"
|
|
49
49
|
>
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
50
|
+
${v("{%- assign values = option.values -%}")}
|
|
51
|
+
${v("{%- assign rootForloop = forloop.index0 -%}")}
|
|
52
|
+
${v(`
|
|
53
53
|
{%- if option.position == 1 -%}
|
|
54
54
|
{%- assign selectedValue = variant.option1 -%}
|
|
55
55
|
{%- elsif option.position == 2 -%}
|
|
@@ -58,22 +58,24 @@ import{template as e,isLocalEnv as t,baseAssetURL as s,DEVICES as i,getResponsiv
|
|
|
58
58
|
{%- assign selectedValue = variant.option3 -%}
|
|
59
59
|
{%- endif -%}
|
|
60
60
|
`)}
|
|
61
|
-
${$(!W,
|
|
62
|
-
${$(M,em(),
|
|
61
|
+
${$(!W,v("{%- assign selectedValue = null -%}"),"")}
|
|
62
|
+
${$(M,em(),eo({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
|
|
63
63
|
</div>
|
|
64
64
|
</div>`)}
|
|
65
65
|
`,em=()=>e`
|
|
66
|
-
${
|
|
67
|
-
`,ec=m(w(
|
|
66
|
+
${_("shop.metafields.GEMPAGES.swatchesJSONFormat and shop.metafields.GEMPAGES.swatchesJSONFormat != blank",N(ea),V(ea))}
|
|
67
|
+
`,ec=m(w(F)),eu=b(E),ev=()=>`
|
|
68
68
|
<div className="${ec}">
|
|
69
69
|
${p(eu)}
|
|
70
70
|
</div>
|
|
71
|
-
`,
|
|
71
|
+
`,ef=u(g({uid:Y,hasPreSelected:W,cssClass:q?.cssClass})),e_=c(y(E)),e$=m({"gp-flex gp-flex-col !gp-ml-0":!0}),eg=()=>{let e=t?"{{ 'gp-product-variant-v7-5.js' | asset_url }}":`${i}/assets-v2/gp-product-variant-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${l('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`};return e`
|
|
72
|
+
${v("{%- assign total_combinations = 1 -%}")}
|
|
73
|
+
${f("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
|
|
72
74
|
<gp-product-variants
|
|
73
|
-
${
|
|
75
|
+
${ef}
|
|
74
76
|
gp-data='{
|
|
75
77
|
"setting":${JSON.stringify(Z)?.replaceAll("'","'")},
|
|
76
|
-
"styles":${JSON.stringify(
|
|
78
|
+
"styles":${JSON.stringify(T)},
|
|
77
79
|
"variants":{{product.variants | json | escape}},
|
|
78
80
|
"optionsWithValues": {{product.options_with_values | json | escape}},
|
|
79
81
|
"variantSelected": {{ variant | json | escape }},
|
|
@@ -89,13 +91,13 @@ import{template as e,isLocalEnv as t,baseAssetURL as s,DEVICES as i,getResponsiv
|
|
|
89
91
|
}
|
|
90
92
|
'>
|
|
91
93
|
<div class="gp-hidden" style="--hvr-shadow: none; --hvr-shadow-tablet: none; --hvr-shadow-mobile: none"></div>
|
|
92
|
-
${
|
|
93
|
-
${
|
|
94
|
-
${
|
|
95
|
-
class="${
|
|
96
|
-
style="${
|
|
94
|
+
${v("{%- assign options = product.options_with_values -%}")}
|
|
95
|
+
${v("{%- assign variants = product.variants -%}")}
|
|
96
|
+
${_("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
|
|
97
|
+
class="${e$}"
|
|
98
|
+
style="${e_}"
|
|
97
99
|
>
|
|
98
|
-
${$(H,
|
|
100
|
+
${$(H,ev(),ed())}
|
|
99
101
|
</div>`)}
|
|
100
102
|
</gp-product-variants>
|
|
101
103
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{template as t,RenderIf as e,isLocalEnv as i,baseAssetURL as
|
|
1
|
+
import{template as t,RenderIf as e,isLocalEnv as i,baseAssetURL as r}from"@gem-sdk/core";import o from"../../../grid/components/row/Row.liquid.js";import{LiquidIf as a,If as d}from"@gem-sdk/system";import{getSettingPreloadData as n,getStaticLocale as s}from"../../../helpers.js";import{getData as c,DYNAMIC_PRODUCT_STATUS as p,STATIC_PRODUCT_STATUS as l,PRODUCT_ID_LATEST as u}from"./common/helpers.js";let Product=f=>{let{children:m,setting:g,style:y,builderProps:v,rawChildren:_,advanced:$}=f,{isSyncProduct:I}=g??{},{rowSetting:S,rowStyles:b,formatVariantId:j,formatProductId:h,productStatus:q,preSelectedOptionIds:V,productHandle:P,advancedStyle:k}=c(f),w=()=>t`
|
|
2
2
|
{%- liquid
|
|
3
3
|
if request.page_type == 'product'
|
|
4
|
-
if '${
|
|
5
|
-
if '${
|
|
4
|
+
if '${q}' == '${l}'
|
|
5
|
+
if '${h}' == '${u}'
|
|
6
6
|
paginate collections.all.products by 100000
|
|
7
7
|
assign product = collections.all.products | sort: 'created_at' | reverse | first
|
|
8
8
|
endpaginate
|
|
9
9
|
else
|
|
10
|
-
assign product = all_products['${
|
|
11
|
-
assign productId = '${
|
|
10
|
+
assign product = all_products['${P}']
|
|
11
|
+
assign productId = '${h}' | times: 1
|
|
12
12
|
if product == empty or product == null
|
|
13
13
|
paginate collections.all.products by 100000
|
|
14
14
|
for item in collections.all.products
|
|
@@ -21,13 +21,13 @@ import{template as t,RenderIf as e,isLocalEnv as i,baseAssetURL as o}from"@gem-s
|
|
|
21
21
|
endif
|
|
22
22
|
endif
|
|
23
23
|
else
|
|
24
|
-
if '${
|
|
24
|
+
if '${h}' == '${u}'
|
|
25
25
|
paginate collections.all.products by 100000
|
|
26
26
|
assign product = collections.all.products | sort: 'created_at'| reverse | first
|
|
27
27
|
endpaginate
|
|
28
28
|
else
|
|
29
|
-
assign product = all_products['${
|
|
30
|
-
assign productId = '${
|
|
29
|
+
assign product = all_products['${P}']
|
|
30
|
+
assign productId = '${h}' | times: 1
|
|
31
31
|
if product == empty or product == null
|
|
32
32
|
paginate collections.all.products by 100000
|
|
33
33
|
for item in collections.all.products
|
|
@@ -40,11 +40,11 @@ import{template as t,RenderIf as e,isLocalEnv as i,baseAssetURL as o}from"@gem-s
|
|
|
40
40
|
endif
|
|
41
41
|
endif
|
|
42
42
|
-%}
|
|
43
|
-
`,
|
|
43
|
+
`,E=()=>t`
|
|
44
44
|
{%- liquid
|
|
45
45
|
if request.page_type != 'product'
|
|
46
|
-
assign product = all_products['${
|
|
47
|
-
assign productId = '${
|
|
46
|
+
assign product = all_products['${P}']
|
|
47
|
+
assign productId = '${h}' | times: 1
|
|
48
48
|
if product == empty or product == null
|
|
49
49
|
paginate collections.all.products by 100000
|
|
50
50
|
for item in collections.all.products
|
|
@@ -56,32 +56,30 @@ import{template as t,RenderIf as e,isLocalEnv as i,baseAssetURL as o}from"@gem-s
|
|
|
56
56
|
endif
|
|
57
57
|
endif
|
|
58
58
|
-%}
|
|
59
|
-
`,
|
|
59
|
+
`,x=()=>t`
|
|
60
60
|
{%- assign gpBkProduct = product -%}
|
|
61
|
-
${
|
|
62
|
-
`,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{%- assign
|
|
66
|
-
{%- assign
|
|
67
|
-
${q?"{%- assign variant = product.variants | where: 'id', initVariantId | first -%}":"{%- assign variant = product.selected_or_first_available_variant -%}"}
|
|
68
|
-
${q?"{%- assign productSelectedVariant = product.variants | where: 'id', initVariantId | first -%}":"{%- assign productSelectedVariant = product.selected_or_first_available_variant -%}"}
|
|
61
|
+
${d(q==p,E(),w())}
|
|
62
|
+
`,A=()=>t`
|
|
63
|
+
{%- assign initVariantId = ${j} -%}
|
|
64
|
+
{%- assign product_form_id = 'product-form-' | append: "${v?.uid}" -%}
|
|
65
|
+
${j?"{%- assign variant = product.variants | where: 'id', initVariantId | first -%}":"{%- assign variant = product.selected_or_first_available_variant -%}"}
|
|
66
|
+
${j?"{%- assign productSelectedVariant = product.variants | where: 'id', initVariantId | first -%}":"{%- assign productSelectedVariant = product.selected_or_first_available_variant -%}"}
|
|
69
67
|
{%-if productSelectedVariant == empty or productSelectedVariant == null -%}
|
|
70
68
|
{%- assign productSelectedVariant = product.selected_or_first_available_variant -%}
|
|
71
69
|
{%- endif -%}
|
|
72
70
|
{%-if variant == empty or variant == null -%}
|
|
73
71
|
{%- assign variant = product.selected_or_first_available_variant -%}
|
|
74
72
|
{%- endif -%}
|
|
75
|
-
`,
|
|
76
|
-
<div class="gp-text-center">${
|
|
77
|
-
`,
|
|
78
|
-
${
|
|
73
|
+
`,B=()=>t`
|
|
74
|
+
<div class="gp-text-center">${s("Product","product_not_found")}</div>
|
|
75
|
+
`,G=()=>t`
|
|
76
|
+
${A()}
|
|
79
77
|
<gp-product
|
|
80
|
-
data-uid="${
|
|
81
|
-
data-id="${
|
|
82
|
-
style="${
|
|
83
|
-
class="${
|
|
84
|
-
gp-context='{"productId": {{ product.id }}, "preSelectedOptionIds": [${
|
|
78
|
+
data-uid="${v?.uid}"
|
|
79
|
+
data-id="${v?.uid}"
|
|
80
|
+
style="${k}"
|
|
81
|
+
class="${$?.cssClass}"
|
|
82
|
+
gp-context='{"productId": {{ product.id }}, "preSelectedOptionIds": [${V}], "isSyncProduct": "${I}", "variantSelected": {{ variant | json | escape }}, "inventory_management": {{ variant.inventory_management | json | escape }}, "inventory_policy": {{ variant.inventory_policy | json | escape }}, "inventoryQuantity": {{ variant.inventory_quantity }}, "quantity": 1, "formId": "{{ product_form_id }}" }'
|
|
85
83
|
gp-data='{"variantSelected": {{ variant | json | escape }}, "quantity": 1, "productUrl":{{ product.url | json | escape }}, "productHandle":{{ product.handle | json | escape }}, "collectionUrl": {{ collection.url | json | escape }}, "collectionHandle": {{ collection.handle | json | escape }}}'
|
|
86
84
|
>
|
|
87
85
|
<product-form class="product-form">
|
|
@@ -89,13 +87,13 @@ import{template as t,RenderIf as e,isLocalEnv as i,baseAssetURL as o}from"@gem-s
|
|
|
89
87
|
<input type="hidden" name="id" value="{{ variant.id }}" />
|
|
90
88
|
<input type="hidden" name="quantity" value="{{ quantity }}" />
|
|
91
89
|
<button type="submit" onclick="return false;" style="display:none;"></button>
|
|
92
|
-
${
|
|
90
|
+
${o({builderProps:{...v,uid:v?.uid,uidInteraction:`${v?.uid}-row`},style:y,styles:b,setting:S,children:m,rawChildren:_})}
|
|
93
91
|
{%- endform -%}
|
|
94
92
|
</product-form>
|
|
95
93
|
</gp-product>
|
|
96
94
|
{%- assign product = gpBkProduct -%}
|
|
97
95
|
`;return t`
|
|
98
|
-
${
|
|
99
|
-
${a("product != empty and product != null",
|
|
100
|
-
${e(i,`<script ${
|
|
96
|
+
${x()}
|
|
97
|
+
${a("product != empty and product != null",G(),B())}
|
|
98
|
+
${e(i,`<script ${n('class="gps-link" delay',"src")}="{{ 'gp-product-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${n('class="gps-link" delay',"src")}="${r}/assets-v2/gp-product-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
101
99
|
`};export{Product as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "8.0.0-dev.
|
|
3
|
+
"version": "8.0.0-dev.25",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scan-all-text": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/scan-all-text && node ./scripts/scan-all-text"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "8.0.0-dev.
|
|
29
|
+
"@gem-sdk/core": "8.0.0-dev.25",
|
|
30
30
|
"@gem-sdk/styles": "7.0.1-dev.6",
|
|
31
31
|
"@gem-sdk/system": "7.0.1-dev.6",
|
|
32
32
|
"@types/react-transition-group": "^4.4.12",
|