@gem-sdk/components 2.0.0-dev.897 → 2.0.0-dev.898
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,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../helpers.js");const Button=({className:e,builderProps:t,builderAttrs:o,pageContext:a,setting:r={},styles:l={},style:s,wrapClassName:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../helpers.js");const Button=({className:e,builderProps:t,builderAttrs:o,pageContext:a,setting:r={},styles:l={},style:s,wrapClassName:i="",advanced:p})=>{let n=["#","mailto:","tel:"],g=["product.url"],{align:c,size:d,backgroundColor:h,textColor:u,roundedBtn:b,spacing:m,globalSize:y}=l,{label:v,iconSvg:$,btnLink:f,htmlType:S,disabled:w,loading:k,iconAlign:C,iconVisible:x,translate:B}=r,z=f?.link!==void 0&&""!==f.link,[G,j]=core.splitStyle(["pos","top","left","bottom","right","z"],s),R=f?.link||"",_=new RegExp(/^https?:\/\//i),q=new RegExp(/^\/?(?:collections|pages|products|blogs)\/?/i),A=z&&!_.test(R)&&q.test(R),E=z&&_.test(R);A&&(R="{{ request.origin }}{{ routes.root_url | split: '/' | join: '/' }}"+R);let I=()=>!!(n.find(e=>R.startsWith(e))||g.find(e=>R.includes(e))),M=E||A||I()||"/"===R?"a":"button",T=E||A||I()||"/"===R?{href:R,target:f?.target}:z?{href:R,target:f?.target,type:S}:{type:S},D="left"===C?core.makeStyle({mr:m}):core.makeStyle({ml:m});w&&(delete h?.hover,delete h?.focus);let F=core.makeGlobalSize(y),H=core.composeTypographyClassName(l?.typo,l?.typography),L=core.composeTypographyStyle(l?.typo,l?.typography),N=`
|
|
2
2
|
.${t?.uid}.gp-button-base::before {
|
|
3
3
|
content: "";
|
|
4
4
|
height: 100%;
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
<div
|
|
19
19
|
${{...o}}
|
|
20
20
|
style="${{...j,...core.makeStyleResponsive("ta",c)}}"
|
|
21
|
-
class="${core.cls(
|
|
21
|
+
class="${core.cls(i,e?.includes("gp-button-atc")?"":p?.cssClass)}"
|
|
22
22
|
>
|
|
23
23
|
<style>${N}</style>
|
|
24
24
|
<${M}
|
|
25
25
|
${{...T,"data-id":t?.uid,"aria-label":r?.label?.toString().replaceAll("'","'"),...w&&"boolean"==typeof w||w?{disabled:"disabled"}:{}}}
|
|
26
26
|
data-state="${k?"loading":"idle"}"
|
|
27
|
-
class="${core.cls(t?.uid,"gp-button-base gp-rounded-none gp-max-w-full gp-relative gp-group gp-inline-flex gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30 disabled:gp-pointer-events-none",core.getGlobalColorStateClass("bg",h),{"gp-animate-bounce":l?.animation?.normal==="bounce","hover:gp-animate-bounce":l?.animation?.hover==="bounce","gp-scale-[1.1]":l?.animation?.normal==="grow","hover:gp-scale-[1.1]":l?.animation?.hover==="grow","gp-flex-row-reverse":"right"===C},core.getGlobalColorStateClass("text",u),H,e,e?.includes("gp-button-atc")&&
|
|
27
|
+
class="${core.cls(t?.uid,"gp-button-base gp-rounded-none gp-max-w-full gp-relative gp-group gp-inline-flex gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30 disabled:gp-pointer-events-none",core.getGlobalColorStateClass("bg",h),{"gp-animate-bounce":l?.animation?.normal==="bounce","hover:gp-animate-bounce":l?.animation?.hover==="bounce","gp-scale-[1.1]":l?.animation?.normal==="grow","hover:gp-scale-[1.1]":l?.animation?.hover==="grow","gp-flex-row-reverse":"right"===C},core.getGlobalColorStateClass("text",u),H,e,e?.includes("gp-button-atc")&&p?p?.cssClass:"")}"
|
|
28
28
|
style="${{...core.getGlobalColorStateStyle("bg",h),...core.composeRadius(b),...core.getStyleShadowState(l?.boxShadowBtn,"box-shadow",l?.hasBoxShadowBtn),...core.getGlobalColorStateStyle("c",u),...l?.btnSpacing?.type?{}:core.composeSize(l?.btnSpacing?.custom),...F.width,...F.height,...F.padding,...core.makeStyle({tt:l.transform}),...L,...core.getGradientBgrStyleForButton(h)}}"
|
|
29
29
|
>
|
|
30
30
|
<svg
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),productBundle=require("./constants/product-bundle.js");const ProductTag=({setting:e,styles:t,builderProps:r,bundleItem:s})=>{let{customContent:u}=e??{},{textAlign:o,backgroundColor:i,roundedTag:n,borderTag:c,textColor:a}=t??{},l=core.useEditorMode(),d=core.useProduct(),p=core.useCurrentVariant(),{quantity:x}=core.useQuantity(),g=React.useMemo(()=>s?.quantity?s.quantity:x??1,[x,s?.quantity]),m=p?.price??0,y=p?.salePrice??0,f=y-m,j=core.useFormatMoney(f<0?0:f,e?.moneyWithCurrentFormat||!1),b=React.useMemo(()=>{if(!y||!m)return`${u?.unit==="percentage"?"0%":j}`;if(u?.unit==="percentage"){let e=Math.round(f/(y/100));return`${e<0?0:e}%`}return`${j}`},[u?.unit,j,m,f,y]),R=React.useMemo(()=>{let e=parseInt(s?.discountValue);return s?.discountType===productBundle.DiscountType.Percentage?m*g*e/100:s?.discountType===productBundle.DiscountType.FixedAmount?e:0},[s?.discountType,s?.discountValue,m,g]),T=React.useMemo(()=>{if(!s)return b;if(s?.discountType===productBundle.DiscountType.NoDiscount)return 0;if(u?.unit==="percentage"){let e=Math.round(R/(g*m)*100);return`${e<0?0:e}%`}return Math.round(100*R)/100},[s,u?.unit,R,b,g,m]),h=core.getGlobalColorClass("border",c?.color),M=core.getGlobalColorClass("text",a),C=core.getGlobalColorClass("bg",i);function S(e){return"none"===e?"gp-g-s-none":`gp-g-s-tag-${e}`}let q=d?.baseID?.replace("gid://shopify/Product/","");return jsxRuntime.jsx("div",{className:core.cls({"gp-opacity-0 ":"edit"!==l&&(y<=0||0>=Math.ceil(f/(y/100))),"gp-opacity-20 ":"edit"===l&&(y<=0||0>=Math.ceil(f/(y/100)))}),style:{...core.makeStyleResponsive("ta",o)},id:`shopify-text-element-${r?.uid}`,"data-product-id":q,children:d?jsxRuntime.jsx("div",{className:core.cls("gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3"),style:{},children:jsxRuntime.jsx("div",{className:core.cls("gp-inline-block",h,M,C,t?.tagSpacing?.type?S(t?.tagSpacing?.type):""),style:{...core.makeStyle({bs:c?.border,bw:c?.width,bc:""===h?c?.color:void 0,c:""===M?a:void 0,bg:""===C?i:void 0}),...n?.radiusType!=="custom"?core.getRadiusCSSFromGlobal("normal",n?.radiusType):{},...core.getCustomRadius("normal",n),...t?.tagSpacing?.type?{}:core.composeSize(t?.tagSpacing?.custom)},children:jsxRuntime.jsxs("div",{className:"gp-flex gp-break-all",children:[jsxRuntime.jsx(Text.default,{styles:t,setting:{...e,text:u?.prefix?.replaceAll(" "," "),options:{useState:!0,uniqueId:`${r?.uid}-prefix`},excludeFlex:!0}}),jsxRuntime.jsx(Text.default,{styles:t,setting:{...e,text:T,options:{isCannotEditing:!0},excludeFlex:!0}}),jsxRuntime.jsx(Text.default,{styles:t,setting:{...e,text:u?.suffix?.replaceAll(" "," "),excludeFlex:!0,options:{useState:!0,uniqueId:`${r?.uid}-suffix`}}})]})})}):null})};exports.default=ProductTag;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),productBundle=require("./constants/product-bundle.js");const ProductTag=({setting:e,styles:t,builderProps:r,bundleItem:s})=>{let{customContent:u}=e??{},{textAlign:o,backgroundColor:i,roundedTag:n,borderTag:c,textColor:a}=t??{},l=core.useEditorMode(),d=core.useProduct(),p=core.useCurrentVariant(),{quantity:x}=core.useQuantity(),g=React.useMemo(()=>s?.quantity?s.quantity:x??1,[x,s?.quantity]),m=p?.price??0,y=p?.salePrice??0,f=y-m,j=core.useFormatMoney(f<0?0:f,e?.moneyWithCurrentFormat||!1),b=React.useMemo(()=>{if(!y&&0!==y||!m&&0!==m)return`${u?.unit==="percentage"?"0%":j}`;if(u?.unit==="percentage"){let e=Math.round(f/(y/100));return`${e<0?0:e}%`}return`${j}`},[u?.unit,j,m,f,y]),R=React.useMemo(()=>{let e=parseInt(s?.discountValue);return s?.discountType===productBundle.DiscountType.Percentage?m*g*e/100:s?.discountType===productBundle.DiscountType.FixedAmount?e:0},[s?.discountType,s?.discountValue,m,g]),T=React.useMemo(()=>{if(!s)return b;if(s?.discountType===productBundle.DiscountType.NoDiscount)return 0;if(u?.unit==="percentage"){let e=Math.round(R/(g*m)*100);return`${e<0?0:e}%`}return Math.round(100*R)/100},[s,u?.unit,R,b,g,m]),h=core.getGlobalColorClass("border",c?.color),M=core.getGlobalColorClass("text",a),C=core.getGlobalColorClass("bg",i);function S(e){return"none"===e?"gp-g-s-none":`gp-g-s-tag-${e}`}let q=d?.baseID?.replace("gid://shopify/Product/","");return jsxRuntime.jsx("div",{className:core.cls({"gp-opacity-0 ":"edit"!==l&&(y<=0||0>=Math.ceil(f/(y/100))),"gp-opacity-20 ":"edit"===l&&(y<=0||0>=Math.ceil(f/(y/100)))}),style:{...core.makeStyleResponsive("ta",o)},id:`shopify-text-element-${r?.uid}`,"data-product-id":q,children:d?jsxRuntime.jsx("div",{className:core.cls("gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3"),style:{},children:jsxRuntime.jsx("div",{className:core.cls("gp-inline-block",h,M,C,t?.tagSpacing?.type?S(t?.tagSpacing?.type):""),style:{...core.makeStyle({bs:c?.border,bw:c?.width,bc:""===h?c?.color:void 0,c:""===M?a:void 0,bg:""===C?i:void 0}),...n?.radiusType!=="custom"?core.getRadiusCSSFromGlobal("normal",n?.radiusType):{},...core.getCustomRadius("normal",n),...t?.tagSpacing?.type?{}:core.composeSize(t?.tagSpacing?.custom)},children:jsxRuntime.jsxs("div",{className:"gp-flex gp-break-all",children:[jsxRuntime.jsx(Text.default,{styles:t,setting:{...e,text:u?.prefix?.replaceAll(" "," "),options:{useState:!0,uniqueId:`${r?.uid}-prefix`},excludeFlex:!0}}),jsxRuntime.jsx(Text.default,{styles:t,setting:{...e,text:T,options:{isCannotEditing:!0},excludeFlex:!0}}),jsxRuntime.jsx(Text.default,{styles:t,setting:{...e,text:u?.suffix?.replaceAll(" "," "),excludeFlex:!0,options:{useState:!0,uniqueId:`${r?.uid}-suffix`}}})]})})}):null})};exports.default=ProductTag;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{splitStyle as t,makeStyle as e,makeGlobalSize as o,composeTypographyClassName as a,composeTypographyStyle as i,composeBorderCss as p,composeCornerCss as
|
|
1
|
+
import{splitStyle as t,makeStyle as e,makeGlobalSize as o,composeTypographyClassName as a,composeTypographyStyle as i,composeBorderCss as p,composeCornerCss as s,template as l,makeStyleResponsive as n,cls as r,getGlobalColorStateClass as g,getGlobalColorStateStyle as d,composeRadius as h,getStyleShadowState as c,composeSize as b,getGradientBgrStyleForButton as u,RenderIf as m}from"@gem-sdk/core";import{getDynamicSourceLocales as v}from"../../helpers.js";let Button=({className:$,builderProps:f,builderAttrs:y,pageContext:w,setting:x={},styles:k={},style:B,wrapClassName:z="",advanced:C})=>{let S=["#","mailto:","tel:"],j=["product.url"],{align:_,size:A,backgroundColor:E,textColor:R,roundedBtn:q,spacing:H,globalSize:I}=k,{label:M,iconSvg:V,btnLink:W,htmlType:D,disabled:F,loading:G,iconAlign:J,iconVisible:K,translate:L}=x,N=W?.link!==void 0&&""!==W.link,[O,P]=t(["pos","top","left","bottom","right","z"],B),Q=W?.link||"",T=new RegExp(/^https?:\/\//i),U=new RegExp(/^\/?(?:collections|pages|products|blogs)\/?/i),X=N&&!T.test(Q)&&U.test(Q),Y=N&&T.test(Q);X&&(Q="{{ request.origin }}{{ routes.root_url | split: '/' | join: '/' }}"+Q);let Z=()=>!!(S.find(t=>Q.startsWith(t))||j.find(t=>Q.includes(t))),tt=Y||X||Z()||"/"===Q?"a":"button",te=Y||X||Z()||"/"===Q?{href:Q,target:W?.target}:N?{href:Q,target:W?.target,type:D}:{type:D},to="left"===J?e({mr:H}):e({ml:H});F&&(delete E?.hover,delete E?.focus);let ta=o(I),ti=a(k?.typo,k?.typography),tp=i(k?.typo,k?.typography),ts=`
|
|
2
2
|
.${f?.uid}.gp-button-base::before {
|
|
3
3
|
content: "";
|
|
4
4
|
height: 100%;
|
|
@@ -6,26 +6,26 @@ import{splitStyle as t,makeStyle as e,makeGlobalSize as o,composeTypographyClass
|
|
|
6
6
|
position: absolute;
|
|
7
7
|
pointer-events: none;
|
|
8
8
|
${p(k?.borderBtn?.normal)}
|
|
9
|
-
${
|
|
9
|
+
${s(k?.roundedBtn?.normal)}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.${f?.uid}:hover::before {
|
|
13
13
|
${p(k?.borderBtn?.hover)}
|
|
14
|
-
${
|
|
14
|
+
${s(k?.roundedBtn?.hover)}
|
|
15
15
|
}
|
|
16
|
-
`,
|
|
16
|
+
`,tl=v({val:M,uid:f?.uid,settingId:L??"label",pageContext:w,isCapitalize:k?.typo?.attrs?.transform==="capitalize"});return l`
|
|
17
17
|
<gp-button style="${{...O}}">
|
|
18
18
|
<div
|
|
19
19
|
${{...y}}
|
|
20
20
|
style="${{...P,...n("ta",_)}}"
|
|
21
21
|
class="${r(z,$?.includes("gp-button-atc")?"":C?.cssClass)}"
|
|
22
22
|
>
|
|
23
|
-
<style>${
|
|
23
|
+
<style>${ts}</style>
|
|
24
24
|
<${tt}
|
|
25
25
|
${{...te,"data-id":f?.uid,"aria-label":x?.label?.toString().replaceAll("'","'"),...F&&"boolean"==typeof F||F?{disabled:"disabled"}:{}}}
|
|
26
26
|
data-state="${G?"loading":"idle"}"
|
|
27
27
|
class="${r(f?.uid,"gp-button-base gp-rounded-none gp-max-w-full gp-relative gp-group gp-inline-flex gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30 disabled:gp-pointer-events-none",g("bg",E),{"gp-animate-bounce":k?.animation?.normal==="bounce","hover:gp-animate-bounce":k?.animation?.hover==="bounce","gp-scale-[1.1]":k?.animation?.normal==="grow","hover:gp-scale-[1.1]":k?.animation?.hover==="grow","gp-flex-row-reverse":"right"===J},g("text",R),ti,$,$?.includes("gp-button-atc")&&C?C?.cssClass:"")}"
|
|
28
|
-
style="${{...d("bg",E),...h(
|
|
28
|
+
style="${{...d("bg",E),...h(q),...c(k?.boxShadowBtn,"box-shadow",k?.hasBoxShadowBtn),...d("c",R),...k?.btnSpacing?.type?{}:b(k?.btnSpacing?.custom),...ta.width,...ta.height,...ta.padding,...e({tt:k.transform}),...tp,...u(E)}}"
|
|
29
29
|
>
|
|
30
30
|
<svg
|
|
31
31
|
class="gp-invisible gp-absolute gp-h-5 gp-w-5 group-data-[state=loading]:gp-animate-spin group-data-[state=loading]:gp-visible"
|
|
@@ -48,15 +48,15 @@ import{splitStyle as t,makeStyle as e,makeGlobalSize as o,composeTypographyClass
|
|
|
48
48
|
></path>
|
|
49
49
|
</svg>
|
|
50
50
|
|
|
51
|
-
${m(!!
|
|
51
|
+
${m(!!V&&K,l`<span
|
|
52
52
|
class="${"gp-inline-flex gp-shrink-0 gp-items-center gp-justify-center group-data-[state=loading]:gp-invisible gp-z-1 [&>*]:!gp-h-[var(--height-desktop)] [&>*]:!gp-w-auto tablet:[&>*]:!gp-h-[var(--height-tablet)] mobile:[&>*]:!gp-h-[var(--height-mobile)]"}"
|
|
53
|
-
style="${{...
|
|
54
|
-
>${
|
|
53
|
+
style="${{...M?to:{},"--height-desktop":`${A?.desktop}`,"--height-tablet":`${A?.desktop??A?.tablet}`,"--height-mobile":`${A?.mobile??A?.tablet??A?.desktop}`}}"
|
|
54
|
+
>${V}</span>`)}
|
|
55
55
|
<span
|
|
56
56
|
class="${`gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${k?.typo?.attrs?.italic?"[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]":""}`}"
|
|
57
57
|
style="${{...e({tt:k?.transform})}}"
|
|
58
58
|
>
|
|
59
|
-
${
|
|
59
|
+
${tl}
|
|
60
60
|
</span>
|
|
61
61
|
</${tt}>
|
|
62
62
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useEditorMode as i,useProduct as n,useCurrentVariant as r,useQuantity as o,useFormatMoney as a,getGlobalColorClass as u,cls as s,makeStyleResponsive as l,makeStyle as p,getRadiusCSSFromGlobal as c,getCustomRadius as d,composeSize as g}from"@gem-sdk/core";import{useMemo as m}from"react";import f from"../../text/components/Text.js";import{DiscountType as x}from"./constants/product-bundle.js";let ProductTag=({setting:y,styles:b,builderProps:h,bundleItem:T})=>{let{customContent:$}=y??{},{textAlign:v,backgroundColor:S,roundedTag:q,borderTag:F,textColor:M}=b??{},N=i(),P=n(),I=r(),{quantity:j}=o(),k=m(()=>T?.quantity?T.quantity:j??1,[j,T?.quantity]),w=I?.price??0,A=I?.salePrice??0,C=A-w,D=a(C<0?0:C,y?.moneyWithCurrentFormat||!1),V=m(()=>{if(!A||!w)return`${$?.unit==="percentage"?"0%":D}`;if($?.unit==="percentage"){let e=Math.round(C/(A/100));return`${e<0?0:e}%`}return`${D}`},[$?.unit,D,w,C,A]),E=m(()=>{let e=parseInt(T?.discountValue);return T?.discountType===x.Percentage?w*k*e/100:T?.discountType===x.FixedAmount?e:0},[T?.discountType,T?.discountValue,w,k]),W=m(()=>{if(!T)return V;if(T?.discountType===x.NoDiscount)return 0;if($?.unit==="percentage"){let e=Math.round(E/(k*w)*100);return`${e<0?0:e}%`}return Math.round(100*E)/100},[T,$?.unit,E,V,k,w]),z=u("border",F?.color),B=u("text",M),G=u("bg",S);function H(e){return"none"===e?"gp-g-s-none":`gp-g-s-tag-${e}`}let J=P?.baseID?.replace("gid://shopify/Product/","");return e("div",{className:s({"gp-opacity-0 ":"edit"!==N&&(A<=0||0>=Math.ceil(C/(A/100))),"gp-opacity-20 ":"edit"===N&&(A<=0||0>=Math.ceil(C/(A/100)))}),style:{...l("ta",v)},id:`shopify-text-element-${h?.uid}`,"data-product-id":J,children:P?e("div",{className:s("gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3"),style:{},children:e("div",{className:s("gp-inline-block",z,B,G,b?.tagSpacing?.type?H(b?.tagSpacing?.type):""),style:{...p({bs:F?.border,bw:F?.width,bc:""===z?F?.color:void 0,c:""===B?M:void 0,bg:""===G?S:void 0}),...q?.radiusType!=="custom"?c("normal",q?.radiusType):{},...d("normal",q),...b?.tagSpacing?.type?{}:g(b?.tagSpacing?.custom)},children:t("div",{className:"gp-flex gp-break-all",children:[e(f,{styles:b,setting:{...y,text:$?.prefix?.replaceAll(" "," "),options:{useState:!0,uniqueId:`${h?.uid}-prefix`},excludeFlex:!0}}),e(f,{styles:b,setting:{...y,text:W,options:{isCannotEditing:!0},excludeFlex:!0}}),e(f,{styles:b,setting:{...y,text:$?.suffix?.replaceAll(" "," "),excludeFlex:!0,options:{useState:!0,uniqueId:`${h?.uid}-suffix`}}})]})})}):null})};export{ProductTag as default};
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useEditorMode as i,useProduct as n,useCurrentVariant as r,useQuantity as o,useFormatMoney as a,getGlobalColorClass as u,cls as s,makeStyleResponsive as l,makeStyle as p,getRadiusCSSFromGlobal as c,getCustomRadius as d,composeSize as g}from"@gem-sdk/core";import{useMemo as m}from"react";import f from"../../text/components/Text.js";import{DiscountType as x}from"./constants/product-bundle.js";let ProductTag=({setting:y,styles:b,builderProps:h,bundleItem:T})=>{let{customContent:$}=y??{},{textAlign:v,backgroundColor:S,roundedTag:q,borderTag:F,textColor:M}=b??{},N=i(),P=n(),I=r(),{quantity:j}=o(),k=m(()=>T?.quantity?T.quantity:j??1,[j,T?.quantity]),w=I?.price??0,A=I?.salePrice??0,C=A-w,D=a(C<0?0:C,y?.moneyWithCurrentFormat||!1),V=m(()=>{if(!A&&0!==A||!w&&0!==w)return`${$?.unit==="percentage"?"0%":D}`;if($?.unit==="percentage"){let e=Math.round(C/(A/100));return`${e<0?0:e}%`}return`${D}`},[$?.unit,D,w,C,A]),E=m(()=>{let e=parseInt(T?.discountValue);return T?.discountType===x.Percentage?w*k*e/100:T?.discountType===x.FixedAmount?e:0},[T?.discountType,T?.discountValue,w,k]),W=m(()=>{if(!T)return V;if(T?.discountType===x.NoDiscount)return 0;if($?.unit==="percentage"){let e=Math.round(E/(k*w)*100);return`${e<0?0:e}%`}return Math.round(100*E)/100},[T,$?.unit,E,V,k,w]),z=u("border",F?.color),B=u("text",M),G=u("bg",S);function H(e){return"none"===e?"gp-g-s-none":`gp-g-s-tag-${e}`}let J=P?.baseID?.replace("gid://shopify/Product/","");return e("div",{className:s({"gp-opacity-0 ":"edit"!==N&&(A<=0||0>=Math.ceil(C/(A/100))),"gp-opacity-20 ":"edit"===N&&(A<=0||0>=Math.ceil(C/(A/100)))}),style:{...l("ta",v)},id:`shopify-text-element-${h?.uid}`,"data-product-id":J,children:P?e("div",{className:s("gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3"),style:{},children:e("div",{className:s("gp-inline-block",z,B,G,b?.tagSpacing?.type?H(b?.tagSpacing?.type):""),style:{...p({bs:F?.border,bw:F?.width,bc:""===z?F?.color:void 0,c:""===B?M:void 0,bg:""===G?S:void 0}),...q?.radiusType!=="custom"?c("normal",q?.radiusType):{},...d("normal",q),...b?.tagSpacing?.type?{}:g(b?.tagSpacing?.custom)},children:t("div",{className:"gp-flex gp-break-all",children:[e(f,{styles:b,setting:{...y,text:$?.prefix?.replaceAll(" "," "),options:{useState:!0,uniqueId:`${h?.uid}-prefix`},excludeFlex:!0}}),e(f,{styles:b,setting:{...y,text:W,options:{isCannotEditing:!0},excludeFlex:!0}}),e(f,{styles:b,setting:{...y,text:$?.suffix?.replaceAll(" "," "),excludeFlex:!0,options:{useState:!0,uniqueId:`${h?.uid}-suffix`}}})]})})}):null})};export{ProductTag as default};
|