@gem-sdk/components 19.0.0-staging.17 → 19.0.0-staging.18
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 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@gem-sdk/core"),
|
|
1
|
+
"use strict";var e=require("@gem-sdk/core"),t=require("react"),r=require("../../../helpers/tracking.js"),s=require("./useDispatchAfterSubmitEvent.js"),u=require("./useCartMessage.js"),a=require("./useCartOperations.js");exports.useBtnAddToCart=({styles:i,setting:n,builderProps:c})=>{let o=t.useRef(null),{isEditMode:d,isPreviewSharePageMode:l}=e.useRenderMode(),v=e.useProduct(),{currency:b}=e.useCurrency(),{quantity:p}=e.useQuantity(),k=e.useProductProperties(),m=e.useCurrentVariant(),{hasPreSelected:C}=e.useHasPreSelected(),f=e.useStickyStore(e=>e.setElement),g=e.useStickyStore(e=>e.removeElement),D=e.useProductStore(e=>e.updateIsSubmit),S=s.useDispatchInteractionEvent(c?.uid),E=s.useDispatchCustomEvent({product:v,currentVariant:m,quantity:p}),{showMessage:I,notiComponent:y}=u.useCartMessage(i,n),{handleSuccess:q,handleError:M,cartId:P}=a.useCartOperations({setting:n,showMessage:I,dispatchInteractionEvent:S,dispatchCustomEvent:E}),{isMutating:T,trigger:h}=e.useCreateCart({onSuccess:q,onError:M}),{isMutating:j,trigger:A}=e.useAddToCart({onSuccess:q,onError:M});t.useEffect(()=>{let e=o.current;if(!(!e||e.closest(".sticky-wrapper"))&&c?.uid&&c.builderData?.advanced)return f({id:c.uid,element:e,deviceVisibility:c.builderData.advanced.d}),()=>{c?.uid&&g(c.uid)}},[]);let O=t.useCallback(()=>{if(!m?.baseID||!p||!v?.baseID||void 0!==C&&!C||d||l)return;let t=k?.some(e=>e.required&&!e.value);if(D(!0),t)return;let s=k?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));r.addToCartTracking({quantity:p,currency:b,id:v?.baseID,name:v?.title,brand:v?.vendor,sku:m.sku,price:e.convertDecimalToNumber(m?.price),variant:m.title});let u={quantity:p,attributes:s,variantId:m.baseID};n?.actionEffect!=="buy-now"&&P?A({cartId:P,lines:[u]}):h({items:[u]})},[d,l,P,b,p,k,C,v?.title,v?.vendor,v?.baseID,m?.sku,m?.price,m?.title,m?.baseID,n?.actionEffect,h,A,D]),V=e.useCurrentVariantInStock(),w=m?n?.outOfStockLabel:"Unavailable";return{addToCartRef:o,isLoading:T||j,isInStock:V,notiComponent:y,outOfStockLabel:w,addToCart:O}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),t=require("react");exports.default=o=>{let{width:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),t=require("react");exports.default=o=>{let{width:s,position:l}=o??{},{desktop:r,tablet:i,mobile:b}=o?.display||{},p=e.makeStyleResponsive("w",s),a=e.usePageStore(e=>"interaction"===e.sidebarMode),u=e.useCurrentDevice(),[d,n]=t.useState(!1),m=e.useStickyStore(e=>e.getFirstVisibleElement(u)),k=(e,t)=>({[`--left${t}`]:"top"==e?"0":"50%",[`--t${t}`]:"top"==e?"unset":"translateX(-50%)"}),c=t.useMemo(()=>({...k(l?.desktop,""),...k(l?.tablet??l?.desktop,"-tablet"),...k(l?.mobile??l?.tablet??l?.desktop,"-mobile")}),[l?.desktop,l?.mobile,l?.tablet]),f=t.useMemo(()=>{if(a&&l?.[u]==="top")return"40px"},[u,a,l]),x=t.useMemo(()=>{let e=e=>"after-first-cart-button"!==e||d?"block":"none";return{"--d":e(r),"--d-tablet":e(i??r),"--d-mobile":e(b??i??r)}},[r,i,b,d]),M=t.useMemo(()=>({"--top":f??"auto","--top-tablet":f??"auto","--top-mobile":f??"auto",[`--${l?.desktop}`]:f??"0px",[`--${l?.tablet??l?.desktop}-tablet`]:f??"0px",[`--${l?.mobile??l?.tablet??l?.desktop}-mobile`]:f??"0px"}),[f,l?.desktop,l?.mobile,l?.tablet]),v=e=>"top"==e?"sticky":"fixed",g=t.useMemo(()=>({"--pos":v(l?.desktop),"--pos-tablet":v(l?.tablet??l?.desktop),"--pos-mobile":v(l?.mobile??l?.tablet??l?.desktop)}),[l?.desktop,l?.mobile,l?.tablet]);return t.useEffect(()=>{if(!m)return;let e=new IntersectionObserver(([e])=>{e&&n(e.isIntersecting||e.boundingClientRect.top<=0)});return e.observe(m),()=>e.disconnect()},[m]),t.useEffect(()=>{n(!1)},[u]),{w:p,displayStyle:M,positionStyle:g,getCSSAlign:c,makeDisplaySettingStyles:x}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRenderMode as e,useProduct as t,useCurrency as r,useQuantity as i,useProductProperties as
|
|
1
|
+
import{useRenderMode as e,useProduct as t,useCurrency as r,useQuantity as i,useProductProperties as a,useCurrentVariant as s,useHasPreSelected as o,useStickyStore as u,useProductStore as n,useCreateCart as l,useAddToCart as d,convertDecimalToNumber as m,useCurrentVariantInStock as c}from"@gem-sdk/core";import{useRef as p,useEffect as f,useCallback as b}from"react";import{addToCartTracking as v}from"../../../helpers/tracking.js";import{useDispatchInteractionEvent as g,useDispatchCustomEvent as k}from"./useDispatchAfterSubmitEvent.js";import{useCartMessage as D}from"./useCartMessage.js";import{useCartOperations as I}from"./useCartOperations.js";let E=({styles:E,setting:y,builderProps:S})=>{let j=p(null),{isEditMode:C,isPreviewSharePageMode:M}=e(),h=t(),{currency:w}=r(),{quantity:A}=i(),L=a(),O=s(),{hasPreSelected:q}=o(),x=u(e=>e.setElement),B=u(e=>e.removeElement),T=n(e=>e.updateIsSubmit),U=g(S?.uid),V=k({product:h,currentVariant:O,quantity:A}),{showMessage:z,notiComponent:F}=D(E,y),{handleSuccess:G,handleError:H,cartId:J}=I({setting:y,showMessage:z,dispatchInteractionEvent:U,dispatchCustomEvent:V}),{isMutating:K,trigger:N}=l({onSuccess:G,onError:H}),{isMutating:P,trigger:Q}=d({onSuccess:G,onError:H});f(()=>{let e=j.current;if(!(!e||e.closest(".sticky-wrapper"))&&S?.uid&&S.builderData?.advanced)return x({id:S.uid,element:e,deviceVisibility:S.builderData.advanced.d}),()=>{S?.uid&&B(S.uid)}},[]);let R=b(()=>{if(!O?.baseID||!A||!h?.baseID||void 0!==q&&!q||C||M)return;let e=L?.some(e=>e.required&&!e.value);if(T(!0),e)return;let t=L?.filter(e=>!!e.value)?.map(e=>({key:e.key,value:e.value}));v({quantity:A,currency:w,id:h?.baseID,name:h?.title,brand:h?.vendor,sku:O.sku,price:m(O?.price),variant:O.title});let r={quantity:A,attributes:t,variantId:O.baseID};y?.actionEffect!=="buy-now"&&J?Q({cartId:J,lines:[r]}):N({items:[r]})},[C,M,J,w,A,L,q,h?.title,h?.vendor,h?.baseID,O?.sku,O?.price,O?.title,O?.baseID,y?.actionEffect,N,Q,T]),W=c(),X=O?y?.outOfStockLabel:"Unavailable";return{addToCartRef:j,isLoading:K||P,isInStock:W,notiComponent:F,outOfStockLabel:X,addToCart:R}};export{E as useBtnAddToCart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeStyleResponsive as t,usePageStore as e,useCurrentDevice as o}from"@gem-sdk/core";import{useMemo as
|
|
1
|
+
import{makeStyleResponsive as t,usePageStore as e,useCurrentDevice as o,useStickyStore as l}from"@gem-sdk/core";import{useState as b,useMemo as i,useEffect as s}from"react";let p=p=>{let{width:r,position:a}=p??{},{desktop:d,tablet:n,mobile:m}=p?.display||{},k=t("w",r),u=e(t=>"interaction"===t.sidebarMode),c=o(),[f,x]=b(!1),$=l(t=>t.getFirstVisibleElement(c)),g=(t,e)=>({[`--left${e}`]:"top"==t?"0":"50%",[`--t${e}`]:"top"==t?"unset":"translateX(-50%)"}),y=i(()=>({...g(a?.desktop,""),...g(a?.tablet??a?.desktop,"-tablet"),...g(a?.mobile??a?.tablet??a?.desktop,"-mobile")}),[a?.desktop,a?.mobile,a?.tablet]),v=i(()=>{if(u&&a?.[c]==="top")return"40px"},[c,u,a]),w=i(()=>{let t=t=>"after-first-cart-button"!==t||f?"block":"none";return{"--d":t(d),"--d-tablet":t(n??d),"--d-mobile":t(m??n??d)}},[d,n,m,f]),I=i(()=>({"--top":v??"auto","--top-tablet":v??"auto","--top-mobile":v??"auto",[`--${a?.desktop}`]:v??"0px",[`--${a?.tablet??a?.desktop}-tablet`]:v??"0px",[`--${a?.mobile??a?.tablet??a?.desktop}-mobile`]:v??"0px"}),[v,a?.desktop,a?.mobile,a?.tablet]),C=t=>"top"==t?"sticky":"fixed",E=i(()=>({"--pos":C(a?.desktop),"--pos-tablet":C(a?.tablet??a?.desktop),"--pos-mobile":C(a?.mobile??a?.tablet??a?.desktop)}),[a?.desktop,a?.mobile,a?.tablet]);return s(()=>{if(!$)return;let t=new IntersectionObserver(([t])=>{t&&x(t.isIntersecting||t.boundingClientRect.top<=0)});return t.observe($),()=>t.disconnect()},[$]),s(()=>{x(!1)},[c]),{w:k,displayStyle:I,positionStyle:E,getCSSAlign:y,makeDisplaySettingStyles:w}};export{p as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "19.0.0-staging.
|
|
3
|
+
"version": "19.0.0-staging.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"i18n:extract": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/translate/extract-texts-to-locales.js && node ./scripts/translate/en-keys-usage.js"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "19.0.0-staging.
|
|
29
|
+
"@gem-sdk/core": "19.0.0-staging.18",
|
|
30
30
|
"@gem-sdk/styles": "19.0.0-staging.14",
|
|
31
31
|
"@gem-sdk/system": "19.0.0-staging.8",
|
|
32
32
|
"@types/react-transition-group": "^4.4.12",
|