@gem-sdk/components 8.0.0-dev.79 → 8.0.0-dev.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Text=require("../../text/components/Text.js"),useDynamicProduct=require("../hooks/useDynamicProduct.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:
|
|
2
|
+
"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"),useDynamicProduct=require("../hooks/useDynamicProduct.js");const PostPurchaseProductPrice=({styles:e,style:r,builderAttrs:t,builderProps:c,children:o,setting:s})=>{let i=core.useCurrentVariant(),u=core.useProduct(),a=core.convertDecimalToNumber(i?.price)??0,p=core.convertDecimalToNumber(i?.salePrice)??0,n=parseFloat(core.shopifyPriceRounding(core.useProductOfferDiscount(),2)),d=a-n>0?a-n:a,{isDynamicProduct:l}=useDynamicProduct.useDynamicProduct(),{t:m}=core.useI18nStore(),{priceType:g,source:x}=s??{},P="compare"===g,h="offer"===g,y="price"===x,j="compare-price"===x,f=React.useMemo(()=>P?y?a:p:h?d:a,[P,y,h,a,p,d]),R=core.useFormatMoney(parseFloat(core.shopifyPriceRounding(Number(f)||0,2)),!1),D=u?.baseID?.replace("gid://shopify/Product/",""),N=React.useMemo(()=>P&&(!n&&p<a||a<=0),[P,n,a,p]);return!f||N?jsxRuntime.jsx("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:jsxRuntime.jsx("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:m(P?"No compare price":"No price")})}):jsxRuntime.jsxs("div",{...t,className:core.cls(c?.uid),style:{...r},id:`shopify-text-element-${c?.uid}`,"data-product-id":D,children:[jsxRuntime.jsx(Text.default,{styles:e,setting:{text:l?"$???":R},className:core.cls({"gp-money":h,"gp-product-compare-price":P,"gp-line-through":P&&j&&e?.lineThrough})}),o]})};exports.default=PostPurchaseProductPrice;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useCurrentVariant as t,useProduct as p,convertDecimalToNumber as o,shopifyPriceRounding as s,useProductOfferDiscount as c,useI18nStore as a,useFormatMoney as i,cls as d}from"@gem-sdk/core";import{useMemo as m}from"react";import l from"../../text/components/Text.js";import{useDynamicProduct as g}from"../hooks/useDynamicProduct.js";let PostPurchaseProductPrice=({styles:u,style:n,builderAttrs:h,builderProps:f,children:x,setting:y})=>{let P=t(),N=p(),b=o(P?.price)??0,j=o(P?.salePrice)??0,k=parseFloat(s(c(),2)),D=b-k>0?b-k:b,{isDynamicProduct:v}=g(),{t:F}=a(),{priceType:T,source:$}=y??{},I="compare"===T,S="offer"===T,q="price"===$,w="compare-price"===$,z=m(()=>I?q?b:j:S?D:b,[I,q,S,b,j,D]),A=i(parseFloat(s(Number(z)||0,2)),!1),B=N?.baseID?.replace("gid://shopify/Product/",""),C=m(()=>I&&(!k&&j<b||b<=0),[I,k,b,j]);return!z||C?e("div",{className:"gp-h-[28px] gp-px-1.5 gp-py-1 gp-flex gp-border gp-border-light-200 gp-items-center gp-justify-center gp-rounded-lg",style:{borderStyle:"dashed",strokeDasharray:"2,2"},children:e("span",{className:"gp-text-dark-400 gp-text-[12px] gp-leading-5",children:F(I?"No compare price":"No price")})}):r("div",{...h,className:d(f?.uid),style:{...n},id:`shopify-text-element-${f?.uid}`,"data-product-id":B,children:[e(l,{styles:u,setting:{text:v?"$???":A},className:d({"gp-money":S,"gp-product-compare-price":I,"gp-line-through":I&&w&&u?.lineThrough})}),x]})};export{PostPurchaseProductPrice as default};
|