@gem-sdk/core 1.14.0-dev.590 → 1.14.0-dev.601

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";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react"),composeAdvanceStyle=require("../helpers/compose-advance-style.js"),constant=require("./constant.js"),RenderCustomCode=require("./RenderCustomCode.js");const ComponentWrapper=({children:e,...s})=>{if("section"===s.type)return null;let t=composeAdvanceStyle.composeAdvanceStyle(s.advanced,s.tag),n=s.advanced;return constant.disableWrap.includes(s.tag)&&react.isValidElement(e)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:s.uid,advanced:n}),jsxRuntime.jsx(e.type,{className:n?.cssClass,...e.props,style:t,advanced:n})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:s.uid,advanced:n}),jsxRuntime.jsx("div",{style:t,className:`${s.uid} ${n?.cssClass}`,children:e})]})};exports.default=ComponentWrapper;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react"),composeAdvanceStyle=require("../helpers/compose-advance-style.js"),constant=require("./constant.js"),RenderCustomCode=require("./RenderCustomCode.js"),AnimationWrapper=require("./animation/AnimationWrapper.js");const ComponentWrapper=({children:e,...t})=>{if("section"===t.type)return null;let s=composeAdvanceStyle.composeAdvanceStyle(t.advanced,t.tag),n=t.advanced,{animation:a}=n??{},r=a?.desktop?.enabled||a?.tablet?.enabled||a?.mobile?.enabled,i=jsxRuntime.jsx("div",{style:s,className:`${t.uid} ${n?.cssClass}`,children:e});return constant.disableWrap.includes(t.tag)&&react.isValidElement(e)&&(i=jsxRuntime.jsx(e.type,{className:n?.cssClass,...e.props,style:s,advanced:n})),r&&(i=jsxRuntime.jsx(AnimationWrapper.default,{children:i,settings:a,tag:t.tag})),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:t.uid,advanced:n}),i]})};exports.default=ComponentWrapper;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),makeStyle=require("../../helpers/make-style.js"),react=require("react");require("zustand"),require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("vanilla-lazyload"),require("../../hooks/useCartUI.js"),require("react-transition-group"),require("@gem-sdk/core"),require("../../helpers/convert.js");var useLivePageAnimation=require("../../hooks/animation/useLivePageAnimation.js");const AnimationWrapper=({children:e,settings:r,tag:t})=>{let i=react.useRef(null),a=(e,r)=>e?.triggerConfig?.[r]?.animation??"none",s=e=>{if("desktop"===e);else if("tablet"===e)return r?.tablet??r?.desktop;else if("mobile"===e)return r?.mobile??r?.tablet??r?.desktop;return r?.desktop},n=e=>+!(s(e)?.enabled&&!["shake","none"].includes(a(s(e),"appear"))),o={desktop:n("desktop"),tablet:n("tablet"),mobile:n("mobile")};return useLivePageAnimation.useLivePageAnimation(i,r,t),jsxRuntime.jsx("div",{ref:i,style:{...makeStyle.makeStyleResponsive("op",o)},children:e})};exports.default=AnimationWrapper;
@@ -1 +1 @@
1
- "use strict";function checkInStock(n){return!!n&&(n?.inventoryQuantity&&n.inventoryQuantity>0||!n?.manageInventory||"CONTINUE"===n.inventoryPolicy)}exports.checkInStock=checkInStock;
1
+ "use strict";function checkInStock(t){return!!t&&(t?.inventoryQuantity&&t.inventoryQuantity>0&&!isDefaultVariant(t)||!t?.manageInventory||"CONTINUE"===t.inventoryPolicy)}function isDefaultVariant(t){return t?.title==="Default Title"}exports.checkInStock=checkInStock;
@@ -0,0 +1 @@
1
+ "use strict";const EASING={ease:"cubic-bezier(0.46,0.03,0.52,0.96)","ease-in":"cubic-bezier(0.55,0.08,0.68,0.53)","ease-out":"cubic-bezier(0.46,0.03,0.52,0.96)",linear:"linear"},animations=()=>{let t=t=>{let r=JSON.parse(JSON.stringify(t)),e=["delay","speed","scale","intensity"];return e.forEach(t=>{if(!r?.[t])return;if("scale"===t){if(!r?.zoomDirection)throw TypeError("zoomDirection not found on zoom preset");let[e,a]=r?.scale?.in??[1,1],[n,i]=r?.scale?.out??[1,1];r[t]={in:[Number(e)/100,Number(a)/100],out:[Number(n)/100,Number(i)/100]};return}let e=Number(r?.[t]);if("delay"===t?r[t]=1e3*e:r[t]=e,!isFinite(e))throw TypeError(`${t} must be a number`)}),r},r=(r,e)=>{let n=t(e),{direction:i,distance:o}=n,l=["left","right"].includes(i??"")?"X":"Y",c=["left","down"].includes(i??"")?"-":"",f=[{opacity:0,transform:`translate${l}(${c}${o??50}%)`},{opacity:1,transform:`translate${l}(0)`}];return s(r,f,{...a(n,500),fill:"forwards"})},e=(r,e)=>{let n=t(e),i=[{opacity:0},{opacity:1}];return s(r,i,{...a(n,500)})},a=(t,r)=>{let e=t=>t?1.5/t*1e3:r,{loop:a,delay:n,speed:i,easing:o}=t??{},s=e(i),l=n??0,c=a?s+l:s;return{iterations:a?1/0:1,duration:c,delay:l,easing:EASING[o??"linear"]}},n=(r,e)=>{let n=t(e),{scale:i,zoomDirection:o,isFade:l}=n,[c,f]=i.in,[p,m]=i.out,u=[{transform:`scale(${c}, ${c})`,opacity:l?0:1},{transform:`scale(${f??1.2}, ${f??1.2})`,opacity:1}],y=[{transform:`scale(${p}, ${p})`,opacity:l?0:1},{transform:`scale(${m??.8}, ${m??.8})`,opacity:1}],d="in"===o?u:y;return s(r,d,{...a(n,700),fill:"forwards"})},i=(t,r,e)=>{if(!r)return t;let a=r/e,n=[...t].pop();return[...t,{...n,offset:1-a}]},o=(r,e)=>{let n=t(e),{intensity:i}=n??{},o=[{transform:"translate3d(0, 0, 0)",opacity:1}],l=[{transform:"translate3d(4px, 0, 0)",opacity:1},{transform:"translate3d(-4px, 0, 0)",opacity:1},{transform:"translate3d(4px, 0, 0)",opacity:1}],c=[];Array.from(Array(i??1).keys()).forEach(()=>{c=[...c,...l]});let f=[{transform:"translate3d(-1px, 0, 0)",opacity:1},{transform:"translate3d(2px, 0, 0)",opacity:1},{transform:"translate3d(-4px, 0, 0)",opacity:1},...c,{transform:"translate3d(-4px, 0, 0)",opacity:1},{transform:"translate3d(2px, 0, 0)",opacity:1},{transform:"translate3d(-1px, 0, 0)",opacity:1}];return s(r,i?f:o,{...a(n??{},820)})},s=(t,r,e)=>{let a=new KeyframeEffect(t,e.iterations&&1===e.iterations?r:i(r,e?.delay??0,e?.duration??0),{...e});return new Animation(a,document.timeline)};return{zoom:n,shake:o,fade:e,slide:r}};exports.animations=animations;
@@ -0,0 +1 @@
1
+ "use strict";var react=require("react"),animations=require("./animations.js");const TAGS_SELECTOR={Button:".gp-button-base",Sticky:"gp-sticky",Dialog:"div[role=dialog]",Icon:"div div",ProductTag:"div div div"},useLivePageAnimation=(e,r,t)=>{let n=animations.animations(),[c,u]=react.useState(!1),a=react.useRef(void 0),i=react.useRef(void 0),o=react.useRef(null),l=react.useRef("none"),s=react.useRef("none"),b=react.useRef(null),d=react.useRef(null),p=react.useRef(null),m=react.useRef("animation-wrapper-"),f=react.useCallback(e=>{b.current&&(b.current.playbackRate=e??1,b.current.play())},[b]),v=react.useCallback(e=>{d.current&&(d.current.playbackRate=e??1,d.current.play())},[d]),g=react.useCallback(()=>{e.current&&(e.current.style.opacity="1"),o.current&&(o.current.style.opacity="1")},[e]),k=react.useCallback(()=>{e.current&&(e.current.style.opacity="1"),o.current&&(o.current.style.opacity="0")},[e]),C=react.useCallback(e=>{e&&e.stopPropagation(),Object.keys(TAGS_SELECTOR).includes(t)&&k(),b.current&&(d.current?.cancel(),f(),b.current.finished.then(()=>{o.current&&g()}),o.current&&a?.current?.unobserve(o.current))},[t,k,f,g]),y=react.useCallback(()=>{b.current&&b.current.cancel()},[b]),R=react.useCallback(e=>{e&&e.stopPropagation(),d.current&&(y(),v())},[d,y,v]),h=react.useCallback(()=>{if(d.current){if("zoom"===s.current){if(v(-1),!c)return;d.current.finished.then(()=>{clearTimeout(i.current),i.current=setTimeout(()=>{C()},100)});return}d.current.cancel(),c&&C()}},[v,c,C]),E=react.useCallback(()=>{if("desktop"===p.current);else if("tablet"===p.current)return r?.tablet??r?.desktop;else if("mobile"===p.current)return r?.mobile??r?.tablet??r?.desktop;return r?.desktop},[r?.desktop,r?.mobile,r?.tablet]),S=(e,r)=>e?.triggerConfig?.[r]?.animation??"none",L=react.useCallback(e=>{if("none"===l.current)return;let r=e?.triggerConfig?.appear?.setting?.[l.current];u(r.loop),b.current=n?.[l.current]?.(o.current,r)},[n]),T=react.useCallback(e=>{if("none"===s.current)return;let r=e?.triggerConfig?.hover?.setting?.[s.current];d.current=n?.[s.current]?.(o.current,r)},[n]),A=react.useCallback(()=>{b.current&&(b.current=null,o.current&&a.current?.unobserve(o.current)),d&&(d.current=null,o.current&&(o.current.removeEventListener("mouseenter",R),o.current.removeEventListener("mouseleave",h)))},[h,R]),O=react.useCallback(e=>{if(A(),o.current){if(!e?.enabled){g();return}l.current=S(e,"appear"),s.current=S(e,"hover"),"none"===l.current&&g(),"none"!==s.current&&"desktop"===p.current&&(T(e),o.current.addEventListener("mouseenter",R),o.current.addEventListener("mouseleave",h)),"none"!==l.current?(L(e),a.current=new IntersectionObserver(e=>{e.forEach(e=>{e.intersectionRatio>.1&&C()})},{root:null,rootMargin:"0px",threshold:[.1]}),a.current.observe(o.current)):g()}},[h,L,T,C,R,g,A]),P=react.useCallback(()=>{let e=document.querySelector("html");if(!o.current||!e)return;let r=new ResizeObserver(([e])=>{let r;let t=e?.target.getBoundingClientRect().width??0;r=t>=1024?"desktop":t>=768?"tablet":"mobile",p.current!==r&&(p.current=r,O(E()))});return r.observe(e),()=>r.disconnect()},[E,O]);return react.useEffect(()=>{setTimeout(()=>{if(r&&e.current)return m.current=`animation-wrapper-${Math.random().toString(36).substr(2,5)}`,e.current.setAttribute("data-animationid",m.current),o.current=document.querySelector(`[data-animationid='${m.current}'] ${TAGS_SELECTOR?.[t]??""}`),P()},100)},[P,r,t,e]),{initAnimation:O}};exports.useLivePageAnimation=useLivePageAnimation;
@@ -1 +1 @@
1
- import{jsxs as e,Fragment as r,jsx as s}from"react/jsx-runtime";import{isValidElement as t}from"react";import{composeAdvanceStyle as a}from"../helpers/compose-advance-style.js";import{disableWrap as d}from"./constant.js";import o from"./RenderCustomCode.js";let ComponentWrapper=({children:n,...c})=>{if("section"===c.type)return null;let i=a(c.advanced,c.tag),p=c.advanced;return d.includes(c.tag)&&t(n)?e(r,{children:[s(o,{uid:c.uid,advanced:p}),s(n.type,{className:p?.cssClass,...n.props,style:i,advanced:p})]}):e(r,{children:[s(o,{uid:c.uid,advanced:p}),s("div",{style:i,className:`${c.uid} ${p?.cssClass}`,children:n})]})};export{ComponentWrapper as default};
1
+ import{jsxs as e,Fragment as t,jsx as a}from"react/jsx-runtime";import{isValidElement as r}from"react";import{composeAdvanceStyle as s}from"../helpers/compose-advance-style.js";import{disableWrap as n}from"./constant.js";import o from"./RenderCustomCode.js";import i from"./animation/AnimationWrapper.js";let ComponentWrapper=({children:d,...m})=>{if("section"===m.type)return null;let p=s(m.advanced,m.tag),l=m.advanced,{animation:c}=l??{},u=c?.desktop?.enabled||c?.tablet?.enabled||c?.mobile?.enabled,f=a("div",{style:p,className:`${m.uid} ${l?.cssClass}`,children:d});return n.includes(m.tag)&&r(d)&&(f=a(d.type,{className:l?.cssClass,...d.props,style:p,advanced:l})),u&&(f=a(i,{children:f,settings:c,tag:m.tag})),e(t,{children:[a(o,{uid:m.uid,advanced:l}),f]})};export{ComponentWrapper as default};
@@ -0,0 +1 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{makeStyleResponsive as t}from"../../helpers/make-style.js";import{useRef as r}from"react";import"zustand";import"swr";import"@gem-sdk/adapter-shopify";import"swr/mutation";import"vanilla-lazyload";import"../../hooks/useCartUI.js";import"react-transition-group";import"@gem-sdk/core";import"../../helpers/convert.js";import{useLivePageAnimation as o}from"../../hooks/animation/useLivePageAnimation.js";let AnimationWrapper=({children:i,settings:a,tag:p})=>{let m=r(null),s=(e,t)=>e?.triggerConfig?.[t]?.animation??"none",n=e=>{if("desktop"===e);else if("tablet"===e)return a?.tablet??a?.desktop;else if("mobile"===e)return a?.mobile??a?.tablet??a?.desktop;return a?.desktop},l=e=>+!(n(e)?.enabled&&!["shake","none"].includes(s(n(e),"appear"))),d={desktop:l("desktop"),tablet:l("tablet"),mobile:l("mobile")};return o(m,a,p),e("div",{ref:m,style:{...t("op",d)},children:i})};export{AnimationWrapper as default};
@@ -1 +1 @@
1
- function checkInStock(n){return!!n&&(n?.inventoryQuantity&&n.inventoryQuantity>0||!n?.manageInventory||"CONTINUE"===n.inventoryPolicy)}export{checkInStock};
1
+ function checkInStock(t){return!!t&&(t?.inventoryQuantity&&t.inventoryQuantity>0&&!isDefaultVariant(t)||!t?.manageInventory||"CONTINUE"===t.inventoryPolicy)}function isDefaultVariant(t){return t?.title==="Default Title"}export{checkInStock};
@@ -0,0 +1 @@
1
+ let EASING={ease:"cubic-bezier(0.46,0.03,0.52,0.96)","ease-in":"cubic-bezier(0.55,0.08,0.68,0.53)","ease-out":"cubic-bezier(0.46,0.03,0.52,0.96)",linear:"linear"},animations=()=>{let t=t=>{let r=JSON.parse(JSON.stringify(t)),e=["delay","speed","scale","intensity"];return e.forEach(t=>{if(!r?.[t])return;if("scale"===t){if(!r?.zoomDirection)throw TypeError("zoomDirection not found on zoom preset");let[e,a]=r?.scale?.in??[1,1],[n,o]=r?.scale?.out??[1,1];r[t]={in:[Number(e)/100,Number(a)/100],out:[Number(n)/100,Number(o)/100]};return}let e=Number(r?.[t]);if("delay"===t?r[t]=1e3*e:r[t]=e,!isFinite(e))throw TypeError(`${t} must be a number`)}),r},r=(r,e)=>{let n=t(e),{direction:o,distance:i}=n,l=["left","right"].includes(o??"")?"X":"Y",c=["left","down"].includes(o??"")?"-":"",f=[{opacity:0,transform:`translate${l}(${c}${i??50}%)`},{opacity:1,transform:`translate${l}(0)`}];return s(r,f,{...a(n,500),fill:"forwards"})},e=(r,e)=>{let n=t(e),o=[{opacity:0},{opacity:1}];return s(r,o,{...a(n,500)})},a=(t,r)=>{let e=t=>t?1.5/t*1e3:r,{loop:a,delay:n,speed:o,easing:i}=t??{},s=e(o),l=n??0,c=a?s+l:s;return{iterations:a?1/0:1,duration:c,delay:l,easing:EASING[i??"linear"]}},n=(r,e)=>{let n=t(e),{scale:o,zoomDirection:i,isFade:l}=n,[c,f]=o.in,[p,m]=o.out,u=[{transform:`scale(${c}, ${c})`,opacity:l?0:1},{transform:`scale(${f??1.2}, ${f??1.2})`,opacity:1}],y=[{transform:`scale(${p}, ${p})`,opacity:l?0:1},{transform:`scale(${m??.8}, ${m??.8})`,opacity:1}],d="in"===i?u:y;return s(r,d,{...a(n,700),fill:"forwards"})},o=(t,r,e)=>{if(!r)return t;let a=r/e,n=[...t].pop();return[...t,{...n,offset:1-a}]},i=(r,e)=>{let n=t(e),{intensity:o}=n??{},i=[{transform:"translate3d(0, 0, 0)",opacity:1}],l=[{transform:"translate3d(4px, 0, 0)",opacity:1},{transform:"translate3d(-4px, 0, 0)",opacity:1},{transform:"translate3d(4px, 0, 0)",opacity:1}],c=[];Array.from(Array(o??1).keys()).forEach(()=>{c=[...c,...l]});let f=[{transform:"translate3d(-1px, 0, 0)",opacity:1},{transform:"translate3d(2px, 0, 0)",opacity:1},{transform:"translate3d(-4px, 0, 0)",opacity:1},...c,{transform:"translate3d(-4px, 0, 0)",opacity:1},{transform:"translate3d(2px, 0, 0)",opacity:1},{transform:"translate3d(-1px, 0, 0)",opacity:1}];return s(r,o?f:i,{...a(n??{},820)})},s=(t,r,e)=>{let a=new KeyframeEffect(t,e.iterations&&1===e.iterations?r:o(r,e?.delay??0,e?.duration??0),{...e});return new Animation(a,document.timeline)};return{zoom:n,shake:i,fade:e,slide:r}};export{animations};
@@ -0,0 +1 @@
1
+ import{useState as e,useRef as r,useCallback as t,useEffect as n}from"react";import{animations as u}from"./animations.js";let TAGS_SELECTOR={Button:".gp-button-base",Sticky:"gp-sticky",Dialog:"div[role=dialog]",Icon:"div div",ProductTag:"div div div"},useLivePageAnimation=(c,o,i)=>{let a=u(),[l,s]=e(!1),d=r(void 0),p=r(void 0),m=r(null),v=r("none"),g=r("none"),b=r(null),f=r(null),y=r(null),h=r("animation-wrapper-"),k=t(e=>{b.current&&(b.current.playbackRate=e??1,b.current.play())},[b]),E=t(e=>{f.current&&(f.current.playbackRate=e??1,f.current.play())},[f]),S=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="1")},[c]),T=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="0")},[c]),L=t(e=>{e&&e.stopPropagation(),Object.keys(TAGS_SELECTOR).includes(i)&&T(),b.current&&(f.current?.cancel(),k(),b.current.finished.then(()=>{m.current&&S()}),m.current&&d?.current?.unobserve(m.current))},[i,T,k,S]),R=t(()=>{b.current&&b.current.cancel()},[b]),C=t(e=>{e&&e.stopPropagation(),f.current&&(R(),E())},[f,R,E]),A=t(()=>{if(f.current){if("zoom"===g.current){if(E(-1),!l)return;f.current.finished.then(()=>{clearTimeout(p.current),p.current=setTimeout(()=>{L()},100)});return}f.current.cancel(),l&&L()}},[E,l,L]),O=t(()=>{if("desktop"===y.current);else if("tablet"===y.current)return o?.tablet??o?.desktop;else if("mobile"===y.current)return o?.mobile??o?.tablet??o?.desktop;return o?.desktop},[o?.desktop,o?.mobile,o?.tablet]),w=(e,r)=>e?.triggerConfig?.[r]?.animation??"none",P=t(e=>{if("none"===v.current)return;let r=e?.triggerConfig?.appear?.setting?.[v.current];s(r.loop),b.current=a?.[v.current]?.(m.current,r)},[a]),G=t(e=>{if("none"===g.current)return;let r=e?.triggerConfig?.hover?.setting?.[g.current];f.current=a?.[g.current]?.(m.current,r)},[a]),$=t(()=>{b.current&&(b.current=null,m.current&&d.current?.unobserve(m.current)),f&&(f.current=null,m.current&&(m.current.removeEventListener("mouseenter",C),m.current.removeEventListener("mouseleave",A)))},[A,C]),_=t(e=>{if($(),m.current){if(!e?.enabled){S();return}v.current=w(e,"appear"),g.current=w(e,"hover"),"none"===v.current&&S(),"none"!==g.current&&"desktop"===y.current&&(G(e),m.current.addEventListener("mouseenter",C),m.current.addEventListener("mouseleave",A)),"none"!==v.current?(P(e),d.current=new IntersectionObserver(e=>{e.forEach(e=>{e.intersectionRatio>.1&&L()})},{root:null,rootMargin:"0px",threshold:[.1]}),d.current.observe(m.current)):S()}},[A,P,G,L,C,S,$]),j=t(()=>{let e=document.querySelector("html");if(!m.current||!e)return;let r=new ResizeObserver(([e])=>{let r;let t=e?.target.getBoundingClientRect().width??0;r=t>=1024?"desktop":t>=768?"tablet":"mobile",y.current!==r&&(y.current=r,_(O()))});return r.observe(e),()=>r.disconnect()},[O,_]);return n(()=>{setTimeout(()=>{if(o&&c.current)return h.current=`animation-wrapper-${Math.random().toString(36).substr(2,5)}`,c.current.setAttribute("data-animationid",h.current),m.current=document.querySelector(`[data-animationid='${h.current}'] ${TAGS_SELECTOR?.[i]??""}`),j()},100)},[j,o,i,c]),{initAnimation:_}};export{useLivePageAnimation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.14.0-dev.590",
3
+ "version": "1.14.0-dev.601",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",