@gem-sdk/components 8.0.3 → 9.0.1

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"),Text=require("../../../text/components/Text.js"),system=require("@gem-sdk/system"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js"),helpers=require("./common/helpers.js"),useGpPrice=require("./hooks/useGpPrice.js"),core=require("@gem-sdk/core");const ProductPrice=e=>{let{style:s,children:r}=e,t=core.useEditorMode(),i="edit"===t,{elementRef:c,moneyFormatted:u,currentProductId:a,isNoComparePrice:m,isNoComparePriceILP:o,emitNoDataSignal:l}=useGpPrice.useGpPrice(e),n=system.createClass(classes.getWrapperClasses(e)),x=system.createAttr(attrs.getAttrs(e,a)),p=helpers.getTextProps(e,u),d={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},j=o?d:s;return jsxRuntime.jsxs("div",{ref:c,...x,className:n,style:j,"aria-hidden":"true",onClick:l,children:[m&&i?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:jsxRuntime.jsx("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:"No compare price"})})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Text.default,{...p}),r]}),core.filterToolbarPreview(r,!0)]})};exports.default=ProductPrice;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),Text=require("../../../text/components/Text.js"),system=require("@gem-sdk/system"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js"),helpers=require("./common/helpers.js"),useGpPrice=require("./hooks/useGpPrice.js"),core=require("@gem-sdk/core");const ProductPrice=e=>{let{style:s,children:r}=e,t=core.useEditorMode(),i="edit"===t,{elementRef:c,moneyFormatted:u,currentProductId:o,isNoComparePrice:a,isNoComparePriceILP:m,shouldHiddenComparePrice:l,emitNoDataSignal:n}=useGpPrice.useGpPrice(e),x=system.createClass(classes.getWrapperClasses(e)),d=system.createAttr(attrs.getAttrs(e,{isILP:!i,productId:o,shouldHiddenComparePrice:l})),p=helpers.getTextProps(e,u),j={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},g=m?j:s;return jsxRuntime.jsxs("div",{ref:c,...d,className:x,style:g,"aria-hidden":"true",onClick:n,children:[a&&i?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:jsxRuntime.jsx("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:"No compare price"})})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Text.default,{...p}),r]}),core.filterToolbarPreview(r,!0)]})};exports.default=ProductPrice;
@@ -1 +1 @@
1
- "use strict";var helpers=require("../../../../helpers.js");const getAttrs=(e,t)=>{let{builderAttrs:r,setting:a,builderProps:i}=e,p=a?.priceType==="compare";return helpers.filterTruthyObject({...r,id:`shopify-text-element-${i?.uid}`,"data-id":i?.uid,"data-product-id":t,"data-hidden":!!p&&"{% if variant.compare_at_price > variant.price and variant.compare_at_price >= 0 %}false{% else %}true{% endif %}"})};exports.getAttrs=getAttrs;
1
+ "use strict";var helpers=require("../../../../helpers.js");const getAttrs=(e,{isILP:t,productId:r,shouldHiddenComparePrice:a}={})=>{let{builderAttrs:i,setting:p,builderProps:s}=e,d=p?.priceType==="compare",c=()=>!!d&&(t?String(a):"{% if variant.compare_at_price > variant.price and variant.compare_at_price >= 0 %}false{% else %}true{% endif %}");return helpers.filterTruthyObject({...i,id:`shopify-text-element-${s?.uid}`,"data-id":s?.uid,"data-product-id":r,"data-hidden":c()})};exports.getAttrs=getAttrs;
@@ -1 +1 @@
1
- "use strict";const getWrapperClasses=s=>{let{builderProps:e,classNames:t,advanced:a}=s;return{"gp-product-price group-data-[state=loading]:gp-invisible data-[hidden=true]:gp-hidden":!0,...e?.uid&&{[e.uid]:!0},...a?.cssClass&&{[a.cssClass]:!0},...t&&{[t]:!0}}};exports.getWrapperClasses=getWrapperClasses;
1
+ "use strict";const getWrapperClasses=s=>{let{builderProps:e,classNames:t,advanced:a}=s;return{"gp-product-price group-data-[state=loading]:gp-invisible data-[hidden=true]:!gp-hidden":!0,...e?.uid&&{[e.uid]:!0},...a?.cssClass&&{[a.cssClass]:!0},...t&&{[t]:!0}}};exports.getWrapperClasses=getWrapperClasses;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),common=require("../../product-variants/common/common.js"),core=require("@gem-sdk/core");const useGpPrice=e=>{let{setting:r,builderProps:t}=e,c=React.useRef(null),o=core.useEditorMode(),{quantity:u,hasUpdatePrice:i}=core.useQuantity(),a=core.useCurrentVariant(),{useProductCompareAtPrice:n}=core.useProductBundleDiscount(),s=e["bundle-item"],d=a?.price??0,p=a?.salePrice??0,l=r?.priceType==="compare",{trigger:m}=core.useInteraction(),g=core.useProduct(),y=g?.baseID?.replace("gid://shopify/Product/",""),P=core.useShopStore(e=>e.showPriceCurrency),h=React.useMemo(()=>s?.quantity?s.quantity:i&&u||1,[u,i,s?.quantity]),b=React.useMemo(()=>{let e=Number(s?.discountValue);return s?.discountType==="percentage"?d*h*e/100:e},[s?.discountType,s?.discountValue,d,h]),v=React.useMemo(()=>s?.discountValue?n?(p||d)*h:d*h:p*h,[s?.discountValue,d,h,p,n]),M=React.useMemo(()=>{let e=d*h;return l?v:b?Math.max(0,e-b):e},[d,h,b,v,l]),R=(e,r)=>{m({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${t?.uid}"]`,element:c.current}),m({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${t?.uid}"]`,element:c.current})};common.useTransition(e=>{e!==d&&R(d,"price")},[d]),common.useTransition(e=>{e!==p&&R(p,"compare")},[p]);let q=()=>{if("edit"!==o)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:t?.uid,value:!M&&l,tag:"ProductPrice"}});window.dispatchEvent(e)},w=core.useFormatMoney(M??0,P||!1),T=l&&!M,V="edit"!==o&&T;return{elementRef:c,moneyFormatted:w,currentProductId:y,isNoComparePrice:T,isNoComparePriceILP:V,emitNoDataSignal:q}};exports.useGpPrice=useGpPrice;
1
+ "use strict";var React=require("react"),common=require("../../product-variants/common/common.js"),core=require("@gem-sdk/core");const useGpPrice=e=>{let{setting:r,builderProps:t}=e,c=React.useRef(null),o=core.useEditorMode(),{quantity:u,hasUpdatePrice:i}=core.useQuantity(),a=core.useCurrentVariant(),{useProductCompareAtPrice:n}=core.useProductBundleDiscount(),s=e["bundle-item"],d=a?.price??0,p=a?.salePrice??0,m=r?.priceType==="compare",{trigger:l}=core.useInteraction(),g=core.useProduct(),y=g?.baseID?.replace("gid://shopify/Product/",""),P=core.useShopStore(e=>e.showPriceCurrency),h=React.useMemo(()=>s?.quantity?s.quantity:i&&u||1,[u,i,s?.quantity]),b=React.useMemo(()=>{let e=Number(s?.discountValue);return s?.discountType==="percentage"?d*h*e/100:e},[s?.discountType,s?.discountValue,d,h]),M=React.useMemo(()=>s?.discountValue?n?(p||d)*h:d*h:p*h,[s?.discountValue,d,h,p,n]),R=React.useMemo(()=>{let e=d*h;return m?M:b?Math.max(0,e-b):e},[d,h,b,M,m]),v=React.useMemo(()=>!!m&&(!(p>d)||!(p>=0)),[m,p,d]),q=(e,r)=>{l({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${t?.uid}"]`,element:c.current}),l({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${t?.uid}"]`,element:c.current})};common.useTransition(e=>{e!==d&&q(d,"price")},[d]),common.useTransition(e=>{e!==p&&q(p,"compare")},[p]);let w=()=>{if("edit"!==o)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:t?.uid,value:!R&&m,tag:"ProductPrice"}});window.dispatchEvent(e)},T=core.useFormatMoney(R??0,P||!1),V=m&&!R,f="edit"!==o&&V;return{elementRef:c,moneyFormatted:T,currentProductId:y,isNoComparePrice:V,isNoComparePriceILP:f,emitNoDataSignal:w,shouldHiddenComparePrice:v}};exports.useGpPrice=useGpPrice;
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../../helpers.js");const getColorStyleWidth=e=>{let t=e?.height||"32px",o=e?.width||{desktop:t},r=Object.fromEntries(Object.entries(o).map(([e,o])=>{let r=o&&"undefined"!==o&&"auto"!==o?o:t;return[e,r]}));return core.makeStyleResponsive("minw",r)},getWrapperStyleActive=e=>{let{preset:t,optionTypography:o,optionTypo:r,typeOfOption:l}=e,a=t?.optionBgColor,p=t?.optionTextColor,i=t?.optionBorder,n=t?.optionHasShadow,c=t?.optionShadow,d=t?.optionRounded,h="color"===l,s="image"===l||"image_shopify"===l,y=core.composeTypographyStyle(r,o),S=e=>{let t=a?.active??a?.normal,o=i?.active??i?.normal;return core.makeStyle({bg:e&&core.getSingleColorVariable(t),bs:o?.border,bw:o?.width,bc:core.getSingleColorVariable(o?.color)})},g=c?.active??c?.normal,b=n?.active??n?.normal,u=p?.active??p?.normal;return helpers.filterTruthyObject({...S(!h),...core.getRadiusStyleActiveState(d),...core.getStyleShadow({value:g,state:"active",styleAppliedFor:"box-shadow",isEnableShadow:b},!0),...y,...!h&&!s&&core.makeStyle({c:core.getSingleColorVariable(u)}),...h&&getColorStyleWidth(t),...core.makeStyle({h:t?.height})})},getWrapperStyleNormalAndHover=e=>{let{preset:t,optionTransform:o,optionTypography:r,optionTypo:l,typeOfOption:a}=e,p=t?.optionBgColor,i=t?.optionTextColor,n=t?.optionBorder,c=t?.optionHasShadow,d=t?.optionShadow,h=t?.optionRounded,s="color"===a,y="image"===a||"image_shopify"===a,S=["normal","hover"].reduce((e,t)=>({...e,...core.getStyleShadow({value:d?.[t],state:t,styleAppliedFor:"box-shadow",isEnableShadow:c?.[t]})}),{});return helpers.filterTruthyObject({...core.composeRadius(h),...S,...!s&&core.getGlobalColorStateStyle("bg",p),...!s&&core.handleConvertBorderStyle(n),...!s&&core.handleConvertBorderWidth(n),...!s&&core.handleConvertBorderColor(n),...!s&&!y&&core.makeStyle({c:o}),...!s&&!y&&core.getGlobalColorStateStyle("c",i),...typoStyleNotIn(l,r,["--c"]),...s&&getColorStyleWidth(t),...core.makeStyle({h:t?.height})})};function typoStyleNotIn(e,t,o){let r=core.composeTypographyStyle(e,t);return o&&0!==o.length?Object.fromEntries(Object.entries(r).filter(([e])=>!o.includes(e))):r}const getWrapperTextStyle=e=>{let{preset:t,typeOfOption:o,checked:r}=e,l=t?.optionBorder,a=t?.optionRounded,p="color"===o,i=()=>{let e="16px",o={"--pl":"0px","--pr":"0px","--pl-tablet":"0px","--pr-tablet":"0px","--pl-mobile":"0px","--pr-mobile":"0px","--pt":"0px","--pb":"0px"};return t?.width?.desktop?.toLowerCase()!=="auto"&&t?.width?.desktop||(o["--pl"]=e,o["--pr"]=e),t?.width?.tablet?.toLowerCase()!=="auto"&&t?.width?.tablet||(o["--pl-tablet"]=e,o["--pr-tablet"]=e),t?.width?.mobile?.toLowerCase()!=="auto"&&t?.width?.mobile||(o["--pl-mobile"]=e,o["--pr-mobile"]=e),(t?.height?.toLowerCase()==="auto"||t?.height)&&(o["--pt"]="8px",o["--pb"]="8px"),o},n={...a,active:{...a?.active||{},radiusType:"custom"}},c=r?core.getRadiusStyleActiveState(n):core.composeRadius(a),d=!r&&p?{...core.handleConvertBorderStyle(l),...core.handleConvertBorderWidth(l),...core.handleConvertBorderColor(l)}:{};return helpers.filterTruthyObject({...!p&&i(),...p&&c,...d})},getColorStyle=({optionBorder:e,optionRounded:t,isActive:o,color:r})=>{let l=()=>r?r?.startsWith("linear-gradient")?{backgroundImage:r}:{backgroundColor:r}:{},a=t=>t?{"--bs":"none"}:core.handleConvertBorderStyle(e),p=o=>({"--d":"flex","--jc":"center"," --ai":"center","--w":"100%","--h":"100%","--of":"hidden",...a(o),...core.handleConvertBorderWidth(e),...core.handleConvertBorderColor(e),...core.composeRadius(t),...l()});return p(!!o)},getTextStyle=({optionTypo:e,optionTypography:t})=>{let o=core.composeTypographyStyle(e,t);return delete o["--c"],helpers.filterTruthyObject({...o})};exports.getColorStyle=getColorStyle,exports.getTextStyle=getTextStyle,exports.getWrapperStyleActive=getWrapperStyleActive,exports.getWrapperStyleNormalAndHover=getWrapperStyleNormalAndHover,exports.getWrapperTextStyle=getWrapperTextStyle;
1
+ "use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../../helpers.js");const getColorStyleWidth=e=>{let t=e?.height||"32px",o=e?.width||{desktop:t},r=Object.fromEntries(Object.entries(o).map(([e,o])=>{let r=o&&"undefined"!==o&&"auto"!==o?o:t;return[e,r]}));return core.makeStyleResponsive("minw",r)},getWrapperStyleActive=e=>{let{preset:t,optionTypography:o,optionTypo:r,typeOfOption:l}=e,a=t?.optionBgColor,p=t?.optionTextColor,i=t?.optionBorder,n=t?.optionHasShadow,c=t?.optionShadow,d=t?.optionRounded,h="color"===l,s="image"===l||"image_shopify"===l,y=core.composeTypographyStyle(r,o),S=e=>{let t=a?.active??a?.normal,o=i?.active??i?.normal;return core.makeStyle({bg:e&&core.getSingleColorVariable(t),bs:o?.border,bw:o?.width,bc:core.getSingleColorVariable(o?.color)})},g=c?.active??c?.normal,u=n?.active??n?.normal,b=p?.active??p?.normal;return helpers.filterTruthyObject({...S(!h),...core.getRadiusStyleActiveState(d),...core.getStyleShadow({value:g,state:"active",styleAppliedFor:"box-shadow",isEnableShadow:u},!0),...y,...!h&&!s&&core.makeStyle({c:core.getSingleColorVariable(b)}),...h&&getColorStyleWidth(t),...core.makeStyle({h:t?.height})})},getWrapperStyleNormalAndHover=e=>{let{preset:t,optionTransform:o,optionTypography:r,optionTypo:l,typeOfOption:a}=e,p=t?.optionBgColor,i=t?.optionTextColor,n=t?.optionBorder,c=t?.optionHasShadow,d=t?.optionShadow,h=t?.optionRounded,s="color"===a,y="image"===a||"image_shopify"===a,S=["normal","hover"].reduce((e,t)=>({...e,...core.getStyleShadow({value:d?.[t],state:t,styleAppliedFor:"box-shadow",isEnableShadow:c?.[t]})}),{});return helpers.filterTruthyObject({...core.composeRadius(h),...S,...!s&&core.getGlobalColorStateStyle("bg",p),...!s&&core.handleConvertBorderStyle(n),...!s&&core.handleConvertBorderWidth(n),...!s&&core.handleConvertBorderColor(n),...!s&&!y&&core.makeStyle({c:o}),...!s&&!y&&core.getGlobalColorStateStyle("c",i),...typoStyleNotIn(l,r,["--c"]),...s&&getColorStyleWidth(t),...core.makeStyle({h:t?.height})})};function typoStyleNotIn(e,t,o){let r=core.composeTypographyStyle(e,t);return o&&0!==o.length?Object.fromEntries(Object.entries(r).filter(([e])=>!o.includes(e))):r}const getWrapperTextStyle=e=>{let{preset:t,typeOfOption:o,checked:r}=e,l=t?.optionBorder,a=t?.optionRounded,p="color"===o,i=()=>{let e="16px",o={"--pl":"0px","--pr":"0px","--pl-tablet":"0px","--pr-tablet":"0px","--pl-mobile":"0px","--pr-mobile":"0px","--pt":"0px","--pb":"0px"};return t?.width?.desktop?.toLowerCase()!=="auto"&&t?.width?.desktop||(o["--pl"]=e,o["--pr"]=e),t?.width?.tablet?.toLowerCase()!=="auto"&&t?.width?.tablet||(o["--pl-tablet"]=e,o["--pr-tablet"]=e),t?.width?.mobile?.toLowerCase()!=="auto"&&t?.width?.mobile||(o["--pl-mobile"]=e,o["--pr-mobile"]=e),(t?.height?.toLowerCase()==="auto"||t?.height)&&(o["--pt"]="8px",o["--pb"]="8px"),o},n={...a,active:{...a?.active||{},radiusType:"custom"}},c=r?core.getRadiusStyleActiveState(n):core.composeRadius(a),d=!r&&p?{...core.handleConvertBorderStyle(l),...core.handleConvertBorderWidth(l),...core.handleConvertBorderColor(l)}:{};return helpers.filterTruthyObject({...!p&&i(),...p&&c,...d})},getColorStyle=({optionBorder:e,optionRounded:t,isActive:o,color:r})=>{let l=()=>r?r?.startsWith("linear-gradient")?{backgroundImage:r}:{backgroundColor:r}:{},a=t=>t?{"--bs":"none"}:core.handleConvertBorderStyle(e),p=o=>({"--d":"flex","--jc":"center"," --ai":"center","--w":"100%","--h":"100%","--of":"hidden","--hvr-c":"unset",...a(o),...core.handleConvertBorderWidth(e),...core.handleConvertBorderColor(e),...core.composeRadius(t),...l()});return p(!!o)},getTextStyle=({optionTypo:e,optionTypography:t})=>{let o=core.composeTypographyStyle(e,t);return delete o["--c"],helpers.filterTruthyObject({...o})};exports.getColorStyle=getColorStyle,exports.getTextStyle=getTextStyle,exports.getWrapperStyleActive=getWrapperStyleActive,exports.getWrapperStyleNormalAndHover=getWrapperStyleNormalAndHover,exports.getWrapperTextStyle=getWrapperTextStyle;
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsxs as e,jsx as r,Fragment as t}from"react/jsx-runtime";import o from"../../../text/components/Text.js";import{createClass as i,createAttr as m}from"@gem-sdk/system";import{getWrapperClasses as s}from"./common/classes.js";import{getAttrs as c}from"./common/attrs.js";import{getTextProps as p}from"./common/helpers.js";import{useGpPrice as l}from"./hooks/useGpPrice.js";import{useEditorMode as d,filterToolbarPreview as a}from"@gem-sdk/core";let ProductPrice=n=>{let{style:f,children:g}=n,h=d(),x="edit"===h,{elementRef:u,moneyFormatted:j,currentProductId:y,isNoComparePrice:P,isNoComparePriceILP:k,emitNoDataSignal:N}=l(n),v=i(s(n)),b=m(c(n,y)),w=p(n,j),C={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},G=k?C:f;return e("div",{ref:u,...b,className:v,style:G,"aria-hidden":"true",onClick:N,children:[P&&x?r(t,{children:r("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:r("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:"No compare price"})})}):e(t,{children:[r(o,{...w}),g]}),a(g,!0)]})};export{ProductPrice as default};
2
+ import{jsxs as e,jsx as r,Fragment as o}from"react/jsx-runtime";import t from"../../../text/components/Text.js";import{createClass as i,createAttr as m}from"@gem-sdk/system";import{getWrapperClasses as s}from"./common/classes.js";import{getAttrs as c}from"./common/attrs.js";import{getTextProps as p}from"./common/helpers.js";import{useGpPrice as d}from"./hooks/useGpPrice.js";import{useEditorMode as l,filterToolbarPreview as a}from"@gem-sdk/core";let ProductPrice=n=>{let{style:f,children:h}=n,g=l(),x="edit"===g,{elementRef:u,moneyFormatted:j,currentProductId:P,isNoComparePrice:y,isNoComparePriceILP:k,shouldHiddenComparePrice:N,emitNoDataSignal:v}=d(n),b=i(s(n)),C=m(c(n,{isILP:!x,productId:P,shouldHiddenComparePrice:N})),H=p(n,j),I={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},w=k?I:f;return e("div",{ref:u,...C,className:b,style:w,"aria-hidden":"true",onClick:v,children:[y&&x?r(o,{children:r("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:r("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:"No compare price"})})}):e(o,{children:[r(t,{...H}),h]}),a(h,!0)]})};export{ProductPrice as default};
@@ -1 +1 @@
1
- import{filterTruthyObject as e}from"../../../../helpers.js";let getAttrs=(t,r)=>{let{builderAttrs:a,setting:i,builderProps:d}=t,p=i?.priceType==="compare";return e({...a,id:`shopify-text-element-${d?.uid}`,"data-id":d?.uid,"data-product-id":r,"data-hidden":!!p&&"{% if variant.compare_at_price > variant.price and variant.compare_at_price >= 0 %}false{% else %}true{% endif %}"})};export{getAttrs};
1
+ import{filterTruthyObject as e}from"../../../../helpers.js";let getAttrs=(t,{isILP:r,productId:a,shouldHiddenComparePrice:i}={})=>{let{builderAttrs:d,setting:p,builderProps:n}=t,c=p?.priceType==="compare",o=()=>!!c&&(r?String(i):"{% if variant.compare_at_price > variant.price and variant.compare_at_price >= 0 %}false{% else %}true{% endif %}");return e({...d,id:`shopify-text-element-${n?.uid}`,"data-id":n?.uid,"data-product-id":a,"data-hidden":o()})};export{getAttrs};
@@ -1 +1 @@
1
- let getWrapperClasses=e=>{let{builderProps:s,classNames:a,advanced:t}=e;return{"gp-product-price group-data-[state=loading]:gp-invisible data-[hidden=true]:gp-hidden":!0,...s?.uid&&{[s.uid]:!0},...t?.cssClass&&{[t.cssClass]:!0},...a&&{[a]:!0}}};export{getWrapperClasses};
1
+ let getWrapperClasses=e=>{let{builderProps:s,classNames:a,advanced:t}=e;return{"gp-product-price group-data-[state=loading]:gp-invisible data-[hidden=true]:!gp-hidden":!0,...s?.uid&&{[s.uid]:!0},...t?.cssClass&&{[t.cssClass]:!0},...a&&{[a]:!0}}};export{getWrapperClasses};
@@ -1 +1 @@
1
- import{useRef as e,useMemo as r}from"react";import{useTransition as t}from"../../product-variants/common/common.js";import{useEditorMode as c,useQuantity as i,useCurrentVariant as a,useProductBundleDiscount as n,useInteraction as o,useProduct as u,useShopStore as p,useFormatMoney as d}from"@gem-sdk/core";let useGpPrice=l=>{let{setting:m,builderProps:s}=l,g=e(null),b=c(),{quantity:h,hasUpdatePrice:y}=i(),P=a(),{useProductCompareAtPrice:v}=n(),f=l["bundle-item"],w=P?.price??0,V=P?.salePrice??0,k=m?.priceType==="compare",{trigger:q}=o(),T=u(),x=T?.baseID?.replace("gid://shopify/Product/",""),C=p(e=>e.showPriceCurrency),E=r(()=>f?.quantity?f.quantity:y&&h||1,[h,y,f?.quantity]),G=r(()=>{let e=Number(f?.discountValue);return f?.discountType==="percentage"?w*E*e/100:e},[f?.discountType,f?.discountValue,w,E]),$=r(()=>f?.discountValue?v?(V||w)*E:w*E:V*E,[f?.discountValue,w,E,V,v]),j=r(()=>{let e=w*E;return k?$:G?Math.max(0,e-G):e},[w,E,G,$,k]),D=(e,r)=>{q({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${s?.uid}"]`,element:g.current}),q({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${s?.uid}"]`,element:g.current})};t(e=>{e!==w&&D(w,"price")},[w]),t(e=>{e!==V&&D(V,"compare")},[V]);let I=()=>{if("edit"!==b)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:s?.uid,value:!j&&k,tag:"ProductPrice"}});window.dispatchEvent(e)},M=d(j??0,C||!1),N=k&&!j,z="edit"!==b&&N;return{elementRef:g,moneyFormatted:M,currentProductId:x,isNoComparePrice:N,isNoComparePriceILP:z,emitNoDataSignal:I}};export{useGpPrice};
1
+ import{useRef as e,useMemo as r}from"react";import{useTransition as t}from"../../product-variants/common/common.js";import{useEditorMode as c,useQuantity as i,useCurrentVariant as a,useProductBundleDiscount as n,useInteraction as o,useProduct as u,useShopStore as p,useFormatMoney as d}from"@gem-sdk/core";let useGpPrice=l=>{let{setting:m,builderProps:s}=l,g=e(null),b=c(),{quantity:h,hasUpdatePrice:y}=i(),P=a(),{useProductCompareAtPrice:v}=n(),f=l["bundle-item"],w=P?.price??0,V=P?.salePrice??0,k=m?.priceType==="compare",{trigger:q}=o(),T=u(),x=T?.baseID?.replace("gid://shopify/Product/",""),C=p(e=>e.showPriceCurrency),E=r(()=>f?.quantity?f.quantity:y&&h||1,[h,y,f?.quantity]),G=r(()=>{let e=Number(f?.discountValue);return f?.discountType==="percentage"?w*E*e/100:e},[f?.discountType,f?.discountValue,w,E]),$=r(()=>f?.discountValue?v?(V||w)*E:w*E:V*E,[f?.discountValue,w,E,V,v]),j=r(()=>{let e=w*E;return k?$:G?Math.max(0,e-G):e},[w,E,G,$,k]),D=r(()=>!!k&&(!(V>w)||!(V>=0)),[k,V,w]),I=(e,r)=>{q({event:"price"===r?"gp:rollback:price-change":"gp:rollback:compare-price-change",selector:`[data-id="${s?.uid}"]`,element:g.current}),q({event:"price"===r?"gp:price-change":"gp:compare-price-change",data:e,selector:`[data-id="${s?.uid}"]`,element:g.current})};t(e=>{e!==w&&I(w,"price")},[w]),t(e=>{e!==V&&I(V,"compare")},[V]);let M=()=>{if("edit"!==b)return;let e=new CustomEvent("editor:product-source-no-data-warning",{bubbles:!0,detail:{uid:s?.uid,value:!j&&k,tag:"ProductPrice"}});window.dispatchEvent(e)},N=d(j??0,C||!1),z=k&&!j,A="edit"!==b&&z;return{elementRef:g,moneyFormatted:N,currentProductId:x,isNoComparePrice:z,isNoComparePriceILP:A,emitNoDataSignal:M,shouldHiddenComparePrice:D}};export{useGpPrice};
@@ -1 +1 @@
1
- import{composeTypographyStyle as e,getRadiusStyleActiveState as t,getStyleShadow as o,makeStyle as r,getSingleColorVariable as l,composeRadius as i,getGlobalColorStateStyle as p,handleConvertBorderStyle as a,handleConvertBorderWidth as n,handleConvertBorderColor as d,makeStyleResponsive as h}from"@gem-sdk/core";import{filterTruthyObject as c}from"../../../../../helpers.js";let getColorStyleWidth=e=>{let t=e?.height||"32px",o=e?.width||{desktop:t},r=Object.fromEntries(Object.entries(o).map(([e,o])=>{let r=o&&"undefined"!==o&&"auto"!==o?o:t;return[e,r]}));return h("minw",r)},getWrapperStyleActive=i=>{let{preset:p,optionTypography:a,optionTypo:n,typeOfOption:d}=i,h=p?.optionBgColor,g=p?.optionTextColor,s=p?.optionBorder,b=p?.optionHasShadow,m=p?.optionShadow,u=p?.optionRounded,w="color"===d,x="image"===d||"image_shopify"===d,y=e(n,a),S=e=>{let t=h?.active??h?.normal,o=s?.active??s?.normal;return r({bg:e&&l(t),bs:o?.border,bw:o?.width,bc:l(o?.color)})},v=m?.active??m?.normal,C=b?.active??b?.normal,f=g?.active??g?.normal;return c({...S(!w),...t(u),...o({value:v,state:"active",styleAppliedFor:"box-shadow",isEnableShadow:C},!0),...y,...!w&&!x&&r({c:l(f)}),...w&&getColorStyleWidth(p),...r({h:p?.height})})},getWrapperStyleNormalAndHover=e=>{let{preset:t,optionTransform:l,optionTypography:h,optionTypo:g,typeOfOption:s}=e,b=t?.optionBgColor,m=t?.optionTextColor,u=t?.optionBorder,w=t?.optionHasShadow,x=t?.optionShadow,y=t?.optionRounded,S="color"===s,v="image"===s||"image_shopify"===s,C=["normal","hover"].reduce((e,t)=>({...e,...o({value:x?.[t],state:t,styleAppliedFor:"box-shadow",isEnableShadow:w?.[t]})}),{});return c({...i(y),...C,...!S&&p("bg",b),...!S&&a(u),...!S&&n(u),...!S&&d(u),...!S&&!v&&r({c:l}),...!S&&!v&&p("c",m),...typoStyleNotIn(g,h,["--c"]),...S&&getColorStyleWidth(t),...r({h:t?.height})})};function typoStyleNotIn(t,o,r){let l=e(t,o);return r&&0!==r.length?Object.fromEntries(Object.entries(l).filter(([e])=>!r.includes(e))):l}let getWrapperTextStyle=e=>{let{preset:o,typeOfOption:r,checked:l}=e,p=o?.optionBorder,h=o?.optionRounded,g="color"===r,s=()=>{let e="16px",t={"--pl":"0px","--pr":"0px","--pl-tablet":"0px","--pr-tablet":"0px","--pl-mobile":"0px","--pr-mobile":"0px","--pt":"0px","--pb":"0px"};return o?.width?.desktop?.toLowerCase()!=="auto"&&o?.width?.desktop||(t["--pl"]=e,t["--pr"]=e),o?.width?.tablet?.toLowerCase()!=="auto"&&o?.width?.tablet||(t["--pl-tablet"]=e,t["--pr-tablet"]=e),o?.width?.mobile?.toLowerCase()!=="auto"&&o?.width?.mobile||(t["--pl-mobile"]=e,t["--pr-mobile"]=e),(o?.height?.toLowerCase()==="auto"||o?.height)&&(t["--pt"]="8px",t["--pb"]="8px"),t},b={...h,active:{...h?.active||{},radiusType:"custom"}},m=l?t(b):i(h),u=!l&&g?{...a(p),...n(p),...d(p)}:{};return c({...!g&&s(),...g&&m,...u})},getColorStyle=({optionBorder:e,optionRounded:t,isActive:o,color:r})=>{let l=()=>r?r?.startsWith("linear-gradient")?{backgroundImage:r}:{backgroundColor:r}:{},p=t=>t?{"--bs":"none"}:a(e),h=o=>({"--d":"flex","--jc":"center"," --ai":"center","--w":"100%","--h":"100%","--of":"hidden",...p(o),...n(e),...d(e),...i(t),...l()});return h(!!o)},getTextStyle=({optionTypo:t,optionTypography:o})=>{let r=e(t,o);return delete r["--c"],c({...r})};export{getColorStyle,getTextStyle,getWrapperStyleActive,getWrapperStyleNormalAndHover,getWrapperTextStyle};
1
+ import{composeTypographyStyle as e,getRadiusStyleActiveState as t,getStyleShadow as o,makeStyle as r,getSingleColorVariable as l,composeRadius as i,getGlobalColorStateStyle as p,handleConvertBorderStyle as a,handleConvertBorderWidth as n,handleConvertBorderColor as d,makeStyleResponsive as h}from"@gem-sdk/core";import{filterTruthyObject as c}from"../../../../../helpers.js";let getColorStyleWidth=e=>{let t=e?.height||"32px",o=e?.width||{desktop:t},r=Object.fromEntries(Object.entries(o).map(([e,o])=>{let r=o&&"undefined"!==o&&"auto"!==o?o:t;return[e,r]}));return h("minw",r)},getWrapperStyleActive=i=>{let{preset:p,optionTypography:a,optionTypo:n,typeOfOption:d}=i,h=p?.optionBgColor,s=p?.optionTextColor,g=p?.optionBorder,b=p?.optionHasShadow,m=p?.optionShadow,u=p?.optionRounded,w="color"===d,x="image"===d||"image_shopify"===d,y=e(n,a),S=e=>{let t=h?.active??h?.normal,o=g?.active??g?.normal;return r({bg:e&&l(t),bs:o?.border,bw:o?.width,bc:l(o?.color)})},v=m?.active??m?.normal,C=b?.active??b?.normal,f=s?.active??s?.normal;return c({...S(!w),...t(u),...o({value:v,state:"active",styleAppliedFor:"box-shadow",isEnableShadow:C},!0),...y,...!w&&!x&&r({c:l(f)}),...w&&getColorStyleWidth(p),...r({h:p?.height})})},getWrapperStyleNormalAndHover=e=>{let{preset:t,optionTransform:l,optionTypography:h,optionTypo:s,typeOfOption:g}=e,b=t?.optionBgColor,m=t?.optionTextColor,u=t?.optionBorder,w=t?.optionHasShadow,x=t?.optionShadow,y=t?.optionRounded,S="color"===g,v="image"===g||"image_shopify"===g,C=["normal","hover"].reduce((e,t)=>({...e,...o({value:x?.[t],state:t,styleAppliedFor:"box-shadow",isEnableShadow:w?.[t]})}),{});return c({...i(y),...C,...!S&&p("bg",b),...!S&&a(u),...!S&&n(u),...!S&&d(u),...!S&&!v&&r({c:l}),...!S&&!v&&p("c",m),...typoStyleNotIn(s,h,["--c"]),...S&&getColorStyleWidth(t),...r({h:t?.height})})};function typoStyleNotIn(t,o,r){let l=e(t,o);return r&&0!==r.length?Object.fromEntries(Object.entries(l).filter(([e])=>!r.includes(e))):l}let getWrapperTextStyle=e=>{let{preset:o,typeOfOption:r,checked:l}=e,p=o?.optionBorder,h=o?.optionRounded,s="color"===r,g=()=>{let e="16px",t={"--pl":"0px","--pr":"0px","--pl-tablet":"0px","--pr-tablet":"0px","--pl-mobile":"0px","--pr-mobile":"0px","--pt":"0px","--pb":"0px"};return o?.width?.desktop?.toLowerCase()!=="auto"&&o?.width?.desktop||(t["--pl"]=e,t["--pr"]=e),o?.width?.tablet?.toLowerCase()!=="auto"&&o?.width?.tablet||(t["--pl-tablet"]=e,t["--pr-tablet"]=e),o?.width?.mobile?.toLowerCase()!=="auto"&&o?.width?.mobile||(t["--pl-mobile"]=e,t["--pr-mobile"]=e),(o?.height?.toLowerCase()==="auto"||o?.height)&&(t["--pt"]="8px",t["--pb"]="8px"),t},b={...h,active:{...h?.active||{},radiusType:"custom"}},m=l?t(b):i(h),u=!l&&s?{...a(p),...n(p),...d(p)}:{};return c({...!s&&g(),...s&&m,...u})},getColorStyle=({optionBorder:e,optionRounded:t,isActive:o,color:r})=>{let l=()=>r?r?.startsWith("linear-gradient")?{backgroundImage:r}:{backgroundColor:r}:{},p=t=>t?{"--bs":"none"}:a(e),h=o=>({"--d":"flex","--jc":"center"," --ai":"center","--w":"100%","--h":"100%","--of":"hidden","--hvr-c":"unset",...p(o),...n(e),...d(e),...i(t),...l()});return h(!!o)},getTextStyle=({optionTypo:t,optionTypography:o})=>{let r=e(t,o);return delete r["--c"],c({...r})};export{getColorStyle,getTextStyle,getWrapperStyleActive,getWrapperStyleNormalAndHover,getWrapperTextStyle};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "8.0.3",
3
+ "version": "9.0.1",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",