@gem-sdk/components 2.0.0-staging.1031 → 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.
- package/dist/cjs/product/components/product-variants/ProductVariants.js +1 -1
- package/dist/cjs/product/components/product-variants/ProductVariants.liquid.js +44 -18
- package/dist/cjs/text/common/styles.js +1 -1
- package/dist/esm/product/components/product-variants/ProductVariants.js +1 -1
- package/dist/esm/product/components/product-variants/ProductVariants.liquid.js +67 -41
- package/dist/esm/text/common/styles.js +1 -1
- package/package.json +1 -1
|
@@ -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:
|
|
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:
|
|
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: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="${
|
|
8
|
-
style="${_function.getStyleOfObject(styles$1.getMarginBottomStyle(
|
|
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(
|
|
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,
|
|
60
|
+
${system.If(c,P(),T())}
|
|
35
61
|
</div>
|
|
36
62
|
</div>`)}
|
|
37
|
-
`,
|
|
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 = "${
|
|
103
|
+
${system.Liquid(`{%- assign variantPresetString = "${D}" -%}`)}
|
|
78
104
|
${system.Liquid('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
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:
|
|
88
|
-
${system.LiquidIf("type == 'dropdown'",Dropdown_liquid.default({...t,...
|
|
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",
|
|
93
|
-
`,
|
|
94
|
-
<div className="${
|
|
95
|
-
${DropdownGroup_liquid.default(
|
|
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:
|
|
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(
|
|
129
|
+
"setting":${JSON.stringify(L)?.replaceAll("'","'")},
|
|
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(
|
|
151
|
+
${system.If(v,E(),w())}
|
|
126
152
|
</div>`)}
|
|
127
153
|
</gp-product-variants-v7-5>
|
|
128
154
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var core=require("@gem-sdk/core"),helpers=require("./helpers.js");function filterTruthyStyles(e){return Object.fromEntries(Object.entries(e||{}).filter(([,e])=>!!e))}const getStyle=(e,t)=>{let o={...core.makeStyle({mr:e?.spacing,mb:e?.spacing}),...core.makeStyleResponsive("ta",e?.align),...t,"--dynamic-source-color":"#F4F4F4"};return filterTruthyStyles(o)},getContainerStyle=(e,t)=>{let{tagWidth:o}=t??{},r={...core.makeStyleResponsive("jc",e?.align),...o};return filterTruthyStyles(r)},getTextStyle=(e,t)=>{let o=core.makeGlobalSize(t?.globalSize),r=[e?.lineThrough&&"line-through",e?.typo?.attrs?.underline&&"underline"].filter(Boolean),l={...o?.width?.["--w"]?o.width:{"--w":"100%"},...core.makeStyle({tdc:core.getSingleColorVariable(e?.lineColor?.normal),tdt:helpers.formatThickness(e?.thickness)}),...core.composeBorderResponsive(e?.shapeBorder),...core.composeRadiusResponsive(e?.shapeRounded),...core.getResponsiveStyleShadowWithoutState(e?.shapeBoxShadow,"box-shadow",e?.shapeBoxShadow),...core.getStyleShadow({value:e?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:e?.typo?.custom?.hasShadowText}),...core.makeStyleResponsive("ta",e?.textAlign),...core.makeStyleResponsive("line-clamp",core.makeLineClamp(e?.lineClamp,e?.hasLineClamp)),...e?.textColor?core.getGlobalColorStyle(e.textColor):core.getGlobalColorStateStyle("c",e?.color),...core.composeTypographyStyle(e?.typo),"word-break":"break-word",...core.getStyleBackgroundByDevice(t?.background),...o.padding,...core.getGradientBgrStyleByDevice(t?.background),overflow:"hidden",...e?.opacityPrice&&{opacity:`${e?.opacityPrice}%`},...core.makeStyle({tdl:r.join(" ")})};return e?.enableHoverEffect?filterTruthyStyles(l):core.filterHoverVariables(l)},getTextStyleInline=e=>{let t={...core.composeTypographyStyle(e?.typo),"word-break":"break-word",overflow:"hidden"};return filterTruthyStyles(t)};exports.getContainerStyle=getContainerStyle,exports.getStyle=getStyle,exports.getTextStyle=getTextStyle,exports.getTextStyleInline=getTextStyleInline;
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),helpers=require("./helpers.js");function filterTruthyStyles(e){return Object.fromEntries(Object.entries(e||{}).filter(([,e])=>!!e))}const getStyle=(e,t)=>{let o={...core.makeStyle({mr:e?.spacing,mb:e?.spacing}),...core.makeStyleResponsive("ta",e?.align),...t,"--dynamic-source-color":"#F4F4F4"};return filterTruthyStyles(o)},getContainerStyle=(e,t)=>{let{tagWidth:o}=t??{},r={...core.makeStyleResponsive("jc",e?.align),...o};return filterTruthyStyles(r)},getTextStyle=(e,t)=>{let o=core.makeGlobalSize(t?.globalSize),r=[e?.lineThrough&&"line-through",e?.typo?.attrs?.underline&&"underline"].filter(Boolean),l={...o?.width?.["--w"]?o.width:{"--w":"100%"},...core.makeStyle({tdc:core.getSingleColorVariable(e?.lineColor?.normal),tdt:helpers.formatThickness(e?.thickness)}),...core.composeBorderResponsive(e?.shapeBorder),...core.composeRadiusResponsive(e?.shapeRounded),...core.getResponsiveStyleShadowWithoutState(e?.shapeBoxShadow,"box-shadow",e?.shapeBoxShadow),...core.getStyleShadow({value:e?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:e?.typo?.custom?.hasShadowText}),...core.makeStyleResponsive("ta",e?.textAlign),...core.makeStyleResponsive("line-clamp",core.makeLineClamp(e?.lineClamp,e?.hasLineClamp)),...e?.textColor?core.getGlobalColorStyle(e.textColor):core.getGlobalColorStateStyle("c",e?.color),...core.composeTypographyStyle(e?.typo),"word-break":"break-word",...core.getStyleBackgroundByDevice(t?.background),...o.padding,...core.getGradientBgrStyleByDevice(t?.background,{desktop:!0,tablet:!0,mobile:!0}),overflow:"hidden",...e?.opacityPrice&&{opacity:`${e?.opacityPrice}%`},...core.makeStyle({tdl:r.join(" ")})};return e?.enableHoverEffect?filterTruthyStyles(l):core.filterHoverVariables(l)},getTextStyleInline=e=>{let t={...core.composeTypographyStyle(e?.typo),"word-break":"break-word",overflow:"hidden"};return filterTruthyStyles(t)};exports.getContainerStyle=getContainerStyle,exports.getStyle=getStyle,exports.getTextStyle=getTextStyle,exports.getTextStyleInline=getTextStyleInline;
|
|
@@ -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((
|
|
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
|
|
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={"'":"'",'"':"""},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 = "${
|
|
4
|
-
|
|
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="${
|
|
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
|
-
${
|
|
38
|
+
${f("preset in presets",`
|
|
13
39
|
${v("{%- assign presetDetail = preset | split: '($2)' -%}")}
|
|
14
|
-
${
|
|
40
|
+
${y("presetDetail[1] == 'dropdown' and presetDetail[0] == optionName",`${v("{%- assign showVariantClass = '' -%}")} ${v("{%- break -%}")}`)}
|
|
15
41
|
`)}
|
|
16
|
-
${
|
|
42
|
+
${_(G,n(ei)," ")}
|
|
17
43
|
<div
|
|
18
44
|
variant-option-name="{{option.name | escape}}"
|
|
19
|
-
class="${
|
|
20
|
-
style="${P(
|
|
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
|
-
${
|
|
34
|
-
${
|
|
59
|
+
${_(!W,v("{%- assign selectedValue = null -%}"),"")}
|
|
60
|
+
${_(L,er(),ep())}
|
|
35
61
|
</div>
|
|
36
62
|
</div>`)}
|
|
37
|
-
`,
|
|
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
|
-
${
|
|
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
|
-
${
|
|
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
|
-
${
|
|
60
|
-
${
|
|
61
|
-
${
|
|
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
|
-
${
|
|
91
|
+
${y("opValueItemKey == 'label'",`${v("{%- assign labelsString = labelsString | append: opValueItemValue -%}")}${v('{%- assign labelsString = labelsString | append: "($8)" -%}')}`)}
|
|
66
92
|
|
|
67
|
-
${
|
|
93
|
+
${y("opValueItemKey == 'colors'",`${v("{%- assign colorArraysString = colorArraysString | append: opValueItemValue -%}")}${v('{%- assign colorArraysString = colorArraysString | append: "($8)" -%}')}`)}
|
|
68
94
|
|
|
69
|
-
${
|
|
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
|
-
${
|
|
77
|
-
${v(`{%- assign variantPresetString = "${
|
|
102
|
+
${y("optionTitle == option.name",`
|
|
103
|
+
${v(`{%- assign variantPresetString = "${en}" -%}`)}
|
|
78
104
|
${v('{%- assign optionName = option.name | replace: "\'", "'" | replace: \'"\', """ -%}')}
|
|
79
105
|
${v("{%- assign items = variantPresetString | split:'($2)' -%}")}
|
|
80
106
|
${v("{%- assign type = 'dropdown' -%}")}
|
|
81
|
-
${
|
|
107
|
+
${f("item in items",`
|
|
82
108
|
${v("{%- assign itemPreset = item | split:'($1)' -%}")}
|
|
83
|
-
${
|
|
84
|
-
${
|
|
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
|
-
${
|
|
88
|
-
${
|
|
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
|
-
${
|
|
93
|
-
`,
|
|
94
|
-
<div className="${
|
|
95
|
-
${l(
|
|
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
|
-
|
|
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
|
-
${
|
|
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
|
-
${
|
|
127
|
+
${ec}
|
|
102
128
|
gp-data='{
|
|
103
129
|
"setting":${JSON.stringify(B)?.replaceAll("'","'")},
|
|
104
|
-
"styles":${JSON.stringify(
|
|
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
|
-
${
|
|
122
|
-
class="${
|
|
123
|
-
style="${
|
|
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
|
-
${
|
|
151
|
+
${_(M,ed(),eo())}
|
|
126
152
|
</div>`)}
|
|
127
153
|
</gp-product-variants-v7-5>
|
|
128
154
|
|
|
129
|
-
${
|
|
155
|
+
${e$()}
|
|
130
156
|
`};export{ProductVariants as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeStyle as e,makeStyleResponsive as t,makeGlobalSize as r,getSingleColorVariable as o,composeBorderResponsive as l,composeRadiusResponsive as i,getResponsiveStyleShadowWithoutState as n,getStyleShadow as a,makeLineClamp as d,getGlobalColorStyle as
|
|
1
|
+
import{makeStyle as e,makeStyleResponsive as t,makeGlobalSize as r,getSingleColorVariable as o,composeBorderResponsive as l,composeRadiusResponsive as i,getResponsiveStyleShadowWithoutState as n,getStyleShadow as a,makeLineClamp as d,getGlobalColorStyle as s,getGlobalColorStateStyle as h,composeTypographyStyle as y,getStyleBackgroundByDevice as c,getGradientBgrStyleByDevice as p,filterHoverVariables as u}from"@gem-sdk/core";import{formatThickness as g}from"./helpers.js";function filterTruthyStyles(e){return Object.fromEntries(Object.entries(e||{}).filter(([,e])=>!!e))}let getStyle=(r,o)=>{let l={...e({mr:r?.spacing,mb:r?.spacing}),...t("ta",r?.align),...o,"--dynamic-source-color":"#F4F4F4"};return filterTruthyStyles(l)},getContainerStyle=(e,r)=>{let{tagWidth:o}=r??{},l={...t("jc",e?.align),...o};return filterTruthyStyles(l)},getTextStyle=(S,w)=>{let m=r(w?.globalSize),b=[S?.lineThrough&&"line-through",S?.typo?.attrs?.underline&&"underline"].filter(Boolean),f={...m?.width?.["--w"]?m.width:{"--w":"100%"},...e({tdc:o(S?.lineColor?.normal),tdt:g(S?.thickness)}),...l(S?.shapeBorder),...i(S?.shapeRounded),...n(S?.shapeBoxShadow,"box-shadow",S?.shapeBoxShadow),...a({value:S?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:S?.typo?.custom?.hasShadowText}),...t("ta",S?.textAlign),...t("line-clamp",d(S?.lineClamp,S?.hasLineClamp)),...S?.textColor?s(S.textColor):h("c",S?.color),...y(S?.typo),"word-break":"break-word",...c(w?.background),...m.padding,...p(w?.background,{desktop:!0,tablet:!0,mobile:!0}),overflow:"hidden",...S?.opacityPrice&&{opacity:`${S?.opacityPrice}%`},...e({tdl:b.join(" ")})};return S?.enableHoverEffect?filterTruthyStyles(f):u(f)},getTextStyleInline=e=>{let t={...y(e?.typo),"word-break":"break-word",overflow:"hidden"};return filterTruthyStyles(t)};export{getContainerStyle,getStyle,getTextStyle,getTextStyleInline};
|