@gem-sdk/components 4.0.0-staging.1163 → 4.0.0-staging.1166
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-badge/ProductBadge.liquid.js +4 -4
- package/dist/cjs/product/components/product-badge/utils/generateLiquidContent.js +3 -3
- package/dist/cjs/product/components/product-badge/utils/renderBadgeLiquid.js +2 -2
- package/dist/esm/product/components/product-badge/ProductBadge.liquid.js +17 -17
- package/dist/esm/product/components/product-badge/utils/generateLiquidContent.js +3 -3
- package/dist/esm/product/components/product-badge/utils/renderBadgeLiquid.js +2 -2
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),common=require("./utils/common.js"),generateLiquidContent=require("./utils/generateLiquidContent.js"),renderBadgeLiquid=require("./utils/renderBadgeLiquid.js"),system=require("@gem-sdk/system"),constants=require("./constants.js"),styles=require("./common/styles.js"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js");const ProductBadge=e=>{let{styles:t,setting:s,builderProps:r,pageContext:a}=e,i=s?.shape!=="image",c=common.checkDiscountContentProductBadge(s?.displayContent),n=system.createStyle({...styles.getContainerStyle(e,constants.IS_LIQUID)}),l=system.createClass({...classes.getWrapperClasses(e)}),o=system.createClass({...classes.getSubWrapperClass(e)}),d=system.createStyle({...styles.getSubWrapperStyle(e)}),p=system.createAttr({...attrs.getSubWrapperAttrs(e)}),u=styles.getContentStyleInternal(e),y=system.createClass({...classes.getTextContainerClasses()}),g=system.createAttr({...attrs.getContainerAttrs(e)}),m=system.createClass({...classes.getTextWrapperClasses()}),C=system.createStyle({...styles.getTextBadgeWrapperStyles({setting:s,styles:t})}),v=system.createClass({...classes.getTextContentClasses(t)})
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),common=require("./utils/common.js"),generateLiquidContent=require("./utils/generateLiquidContent.js"),renderBadgeLiquid=require("./utils/renderBadgeLiquid.js"),system=require("@gem-sdk/system"),constants=require("./constants.js"),styles=require("./common/styles.js"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js");const ProductBadge=e=>{let{styles:t,setting:s,builderProps:r,pageContext:a}=e,i=s?.shape!=="image",c=common.checkDiscountContentProductBadge(s?.displayContent),n=system.createStyle({...styles.getContainerStyle(e,constants.IS_LIQUID)}),l=system.createClass({...classes.getWrapperClasses(e)}),o=system.createClass({...classes.getSubWrapperClass(e)}),d=system.createStyle({...styles.getSubWrapperStyle(e)}),p=system.createAttr({...attrs.getSubWrapperAttrs(e)}),u=styles.getContentStyleInternal(e),y=system.createClass({...classes.getTextContainerClasses()}),g=system.createAttr({...attrs.getContainerAttrs(e)}),m=system.createClass({...classes.getTextWrapperClasses()}),C=system.createStyle({...styles.getTextBadgeWrapperStyles({setting:s,styles:t})}),v=system.createClass({...classes.getTextContentClasses(t)}),S=system.createStyle({...styles.getTextContentStyle({setting:s,styles:t})}),$=system.createAttr({...attrs.getTextContentAttrs()}),q=system.createClass({...classes.getImageContainerClasses()}),I=system.createStyle({...styles.getImageContainerStyles({setting:s,styles:t})}),j=system.createClass({...classes.getImageClasses()}),D=system.createAttr({...attrs.getImageAttr({setting:s})}),P=system.createStateOrContext({minPrice:"{{ minPriceValue | replace: '\"', '\\\"' | escape }}",variantIDs:'{{ product.variants | map: "id" | json | escape }}',variantInventoryQuantities:'{{ product.variants | map: "inventory_quantity" | json | escape }}',amountDiscount:"{{amountDiscountValue | replace: '\"', '\\\"' | escape }}",percentDiscount:"{{percentDiscountValue}}",price:"{{price}}",displayTrigger:JSON.parse(JSON.stringify(s?.displayTrigger).replaceAll("'","'")),uid:e.builderProps?.uid,productCreatedAt:'{{product.created_at | date: "%Y-%m-%d" }}',productTags:"{{ product.tags | join: \",\" | replace: '\"', '\\\"' | escape }}",isTextBadge:i}),{displayContent:f,translate:A}=s??{},L=helpers.getDynamicSourceLocales({val:f?.trim(),uid:r?.uid,settingId:"displayContent",isLiquid:!0,pageContext:a,translate:A});return core.template`
|
|
2
2
|
{% if product %}
|
|
3
|
-
${generateLiquidContent.generateBadgeContent(L)}
|
|
3
|
+
${generateLiquidContent.generateBadgeContent(L,a?.isPreviewing)}
|
|
4
4
|
${renderBadgeLiquid.renderBadgeInFirstTime(s?.displayTrigger,c,i)}
|
|
5
5
|
<gp-product-badge
|
|
6
6
|
${{...g}}
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
style="${C}"
|
|
24
24
|
>
|
|
25
25
|
<pre
|
|
26
|
-
${{
|
|
26
|
+
${{...$}}
|
|
27
27
|
class="${v}"
|
|
28
|
-
style="${
|
|
28
|
+
style="${S}"
|
|
29
29
|
>{{ content | replace: percentDiscountKey, percentDiscountValue | replace: amountDiscountKey, amountDiscountValue | replace: inventoryQuantityKey, inventoryQuantityValue | replace: minPriceKey, minPriceValue }}</pre>
|
|
30
30
|
</div>
|
|
31
31
|
</div>`,core.template`<div class="${q}" style="${I}">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const generateBadgeContent=
|
|
2
|
-
{% assign content = ${
|
|
1
|
+
"use strict";const generateBadgeContent=(n,i)=>`
|
|
2
|
+
{% assign content = ${i?JSON.stringify(n):n} %}
|
|
3
3
|
|
|
4
4
|
{%if content.size > 0 %}
|
|
5
5
|
{% if variant.compare_at_price and variant.compare_at_price > 0 %}
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
{% assign minPriceKey = "{min_price}" %}
|
|
22
22
|
{% assign inventoryQuantityKey = "{inventory_quantity}" %}
|
|
23
23
|
{% endif %}
|
|
24
|
-
|
|
24
|
+
`;exports.generateBadgeContent=generateBadgeContent;
|
|
@@ -127,8 +127,8 @@
|
|
|
127
127
|
{% assign conditionTriggers = conditionTriggers | append: "," | append: false %}
|
|
128
128
|
{% endif %}
|
|
129
129
|
|
|
130
|
-
`},checkProductTagCondition=e=>{let{searchTag:i}=e,n=i.join(", ");return`
|
|
131
|
-
{% assign productTags = product.tags %}
|
|
130
|
+
`},checkProductTagCondition=e=>{let{searchTag:i}=e,n=i.map(e=>e.replaceAll("'","'")).join(", ");return`
|
|
131
|
+
{% assign productTags = product.tags | escape %}
|
|
132
132
|
{% assign searchTag = '${n}' %}
|
|
133
133
|
{% for tag in productTags %}
|
|
134
134
|
{% if searchTag contains tag %}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import{template as e,dataStringify as
|
|
1
|
+
import{template as e,dataStringify as s,sanitizeLiquid as t,RenderIf as i,isLocalEnv as r,baseAssetURL as a}from"@gem-sdk/core";import{getDynamicSourceLocales as c,getSettingPreloadData as o}from"../../../helpers.js";import{checkDiscountContentProductBadge as n}from"./utils/common.js";import{generateBadgeContent as p}from"./utils/generateLiquidContent.js";import{renderBadgeInFirstTime as d}from"./utils/renderBadgeLiquid.js";import{createStyle as l,createClass as u,createAttr as m,createStateOrContext as g}from"@gem-sdk/system";import{IS_LIQUID as y}from"./constants.js";import{getContainerStyle as $,getSubWrapperStyle as v,getContentStyleInternal as f,getTextBadgeWrapperStyles as j,getTextContentStyle as P,getImageContainerStyles as D}from"./common/styles.js";import{getWrapperClasses as V,getSubWrapperClass as S,getTextContainerClasses as b,getTextWrapperClasses as C,getTextContentClasses as T,getImageContainerClasses as k,getImageClasses as q}from"./common/classes.js";import{getSubWrapperAttrs as A,getContainerAttrs as E,getTextContentAttrs as I,getImageAttr as K}from"./common/attrs.js";let ProductBadge=N=>{let{styles:_,setting:h,builderProps:B,pageContext:L}=N,O=h?.shape!=="image",Q=n(h?.displayContent),w=l({...$(N,y)}),G=u({...V(N)}),J=u({...S(N)}),x=l({...v(N)}),M=m({...A(N)}),R=f(N),Y=u({...b()}),z=m({...E(N)}),F=u({...C()}),H=l({...j({setting:h,styles:_})}),U=u({...T(_)}),W=l({...P({setting:h,styles:_})}),X=m({...I()}),Z=u({...k()}),ee=l({...D({setting:h,styles:_})}),es=u({...q()}),et=m({...K({setting:h})}),ei=g({minPrice:"{{ minPriceValue | replace: '\"', '\\\"' | escape }}",variantIDs:'{{ product.variants | map: "id" | json | escape }}',variantInventoryQuantities:'{{ product.variants | map: "inventory_quantity" | json | escape }}',amountDiscount:"{{amountDiscountValue | replace: '\"', '\\\"' | escape }}",percentDiscount:"{{percentDiscountValue}}",price:"{{price}}",displayTrigger:JSON.parse(JSON.stringify(h?.displayTrigger).replaceAll("'","'")),uid:N.builderProps?.uid,productCreatedAt:'{{product.created_at | date: "%Y-%m-%d" }}',productTags:"{{ product.tags | join: \",\" | replace: '\"', '\\\"' | escape }}",isTextBadge:O}),{displayContent:er,translate:ea}=h??{},ec=c({val:er?.trim(),uid:B?.uid,settingId:"displayContent",isLiquid:!0,pageContext:L,translate:ea});return e`
|
|
2
2
|
{% if product %}
|
|
3
|
-
${
|
|
4
|
-
${
|
|
3
|
+
${p(ec,L?.isPreviewing)}
|
|
4
|
+
${d(h?.displayTrigger,Q,O)}
|
|
5
5
|
<gp-product-badge
|
|
6
|
-
${{...
|
|
7
|
-
gp-data='${
|
|
6
|
+
${{...z}}
|
|
7
|
+
gp-data='${s(ei)}'
|
|
8
8
|
class="containerClass {{className}}"
|
|
9
9
|
style="${w}"
|
|
10
|
-
data-display-content="${
|
|
10
|
+
data-display-content="${L?.isPreviewing?ec:t(`{{${ec}}}`)}"
|
|
11
11
|
>
|
|
12
|
-
<div class="${
|
|
12
|
+
<div class="${G}">
|
|
13
13
|
<div
|
|
14
|
-
${{...
|
|
15
|
-
class="${
|
|
16
|
-
style="${
|
|
14
|
+
${{...M}}
|
|
15
|
+
class="${J}"
|
|
16
|
+
style="${x}"
|
|
17
17
|
>
|
|
18
|
-
<style>${
|
|
19
|
-
${i(
|
|
20
|
-
<div class="${
|
|
18
|
+
<style>${R}</style>
|
|
19
|
+
${i(O,e`
|
|
20
|
+
<div class="${Y}">
|
|
21
21
|
<div
|
|
22
|
-
class="${
|
|
23
|
-
style="${
|
|
22
|
+
class="${F}"
|
|
23
|
+
style="${H}"
|
|
24
24
|
>
|
|
25
25
|
<pre
|
|
26
26
|
${{...X}}
|
|
@@ -29,11 +29,11 @@ import{template as e,dataStringify as t,sanitizeLiquid as s,RenderIf as i,isLoca
|
|
|
29
29
|
>{{ content | replace: percentDiscountKey, percentDiscountValue | replace: amountDiscountKey, amountDiscountValue | replace: inventoryQuantityKey, inventoryQuantityValue | replace: minPriceKey, minPriceValue }}</pre>
|
|
30
30
|
</div>
|
|
31
31
|
</div>`,e`<div class="${Z}" style="${ee}">
|
|
32
|
-
<img ${{...
|
|
32
|
+
<img ${{...et}} class="${es}" alt="" />
|
|
33
33
|
</div>`)}
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
</gp-product-badge>
|
|
37
|
-
${i(r,`<script ${
|
|
37
|
+
${i(r,`<script ${o('class="gps-link" delay',"src")}="{{ 'gp-product-badge-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${o('class="gps-link" delay',"src")}="${a}/assets-v2/gp-product-badge-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
38
38
|
{% endif %}
|
|
39
39
|
`};export{ProductBadge as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
let generateBadgeContent=n
|
|
2
|
-
{% assign content = ${i} %}
|
|
1
|
+
let generateBadgeContent=(n,i)=>`
|
|
2
|
+
{% assign content = ${i?JSON.stringify(n):n} %}
|
|
3
3
|
|
|
4
4
|
{%if content.size > 0 %}
|
|
5
5
|
{% if variant.compare_at_price and variant.compare_at_price > 0 %}
|
|
@@ -21,4 +21,4 @@ let generateBadgeContent=n=>{let i;try{i=JSON.stringify(n)}catch(n){i=""}return`
|
|
|
21
21
|
{% assign minPriceKey = "{min_price}" %}
|
|
22
22
|
{% assign inventoryQuantityKey = "{inventory_quantity}" %}
|
|
23
23
|
{% endif %}
|
|
24
|
-
|
|
24
|
+
`;export{generateBadgeContent};
|
|
@@ -127,8 +127,8 @@ import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.A
|
|
|
127
127
|
{% assign conditionTriggers = conditionTriggers | append: "," | append: false %}
|
|
128
128
|
{% endif %}
|
|
129
129
|
|
|
130
|
-
`},checkProductTagCondition=e=>{let{searchTag:i}=e,n=i.join(", ");return`
|
|
131
|
-
{% assign productTags = product.tags %}
|
|
130
|
+
`},checkProductTagCondition=e=>{let{searchTag:i}=e,n=i.map(e=>e.replaceAll("'","'")).join(", ");return`
|
|
131
|
+
{% assign productTags = product.tags | escape %}
|
|
132
132
|
{% assign searchTag = '${n}' %}
|
|
133
133
|
{% for tag in productTags %}
|
|
134
134
|
{% if searchTag contains tag %}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "4.0.0-staging.
|
|
3
|
+
"version": "4.0.0-staging.1166",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"scan-all-text": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/scan-all-text && node ./scripts/scan-all-text"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@gem-sdk/core": "
|
|
28
|
+
"@gem-sdk/core": "4.0.0-staging.1164",
|
|
29
29
|
"@gem-sdk/styles": "3.1.0-staging.1137",
|
|
30
30
|
"@gem-sdk/system": "3.1.0-staging.1137",
|
|
31
31
|
"tsup": "^8.5.0",
|