@gem-sdk/core 1.14.0-dev.552 → 1.14.0-dev.556
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/helpers/background.js +1 -1
- package/dist/cjs/hooks/animation/useAnimationActions.js +1 -1
- package/dist/cjs/hooks/animation/useAnimationPreview.js +1 -1
- package/dist/cjs/hooks/animation/useAnimationTarget.js +1 -1
- package/dist/cjs/hooks/animation/useApplyAnimation.js +1 -1
- package/dist/esm/helpers/background.js +1 -1
- package/dist/esm/hooks/animation/useAnimationActions.js +1 -1
- package/dist/esm/hooks/animation/useAnimationPreview.js +1 -1
- package/dist/esm/hooks/animation/useAnimationTarget.js +1 -1
- package/dist/esm/hooks/animation/useApplyAnimation.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var constant=require("./constant.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js");const getStyleBackgroundByDevice=(e,t)=>e?{...getStyleBgColor(e),...getStyleBgImage(e,t),...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e),...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?colors.isColor(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return makeStyle.makeStyleResponsive("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;let i=e?.[t]?.image?.backupFileKey,a=o?.liquid&&i&&`{{ "${i}" | asset_url }}`||e?.[t]?.image?.src;if("string"==typeof a)return`url(${a})`},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop"),tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop"),tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop"),tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${colors.getSingleColorVariable(e)} !important;`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(e,t)=>{let o=constant.devicesMapping[e]??"";return"fixed"===t?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"
|
|
1
|
+
"use strict";var constant=require("./constant.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js");const getStyleBackgroundByDevice=(e,t)=>e?{...getStyleBgColor(e),...getStyleBgImage(e,t),...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e),...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?colors.isColor(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return makeStyle.makeStyleResponsive("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;let i=e?.[t]?.image?.backupFileKey,a=o?.liquid&&i&&`{{ "${i}" | asset_url }}`||e?.[t]?.image?.src;if("string"==typeof a)return`url(${a})`},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop"),tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop"),tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop"),tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${colors.getSingleColorVariable(e)} !important;`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(e,t)=>{let o=constant.devicesMapping[e]??"";return"fixed"===t?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"100%",[`--h${o}`]:"100%",[`--pos${o}`]:"absolute",[`--bga${o}`]:t}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};return Object.keys(e).forEach(o=>{e[o]?.startsWith(GRADIENT_BGR_KEY)&&("normal"===o?Object.assign(t,{"--bg":e[o]}):Object.assign(t,{"--hvr-bg":e[o]}))}),t},getGradientBgrStyleByDevice=e=>{if(!e)return;let t={};return["desktop","tablet","mobile"].forEach(o=>{e[o]?.type==="color"&&e[o]?.color?.includes(GRADIENT_BGR_KEY)&&Object.assign(t,{[`--bgc${"desktop"!==o?"-"+o:""}`]:"transparent",[`--bgi${"desktop"!==o?"-"+o:""}`]:e[o]?.color})}),t};exports.GRADIENT_BGR_KEY=GRADIENT_BGR_KEY,exports.composeBackgroundCss=composeBackgroundCss,exports.getBgImageByDevice=getBgImageByDevice,exports.getGradientBgrStyleByDevice=getGradientBgrStyleByDevice,exports.getGradientBgrStyleForButton=getGradientBgrStyleForButton,exports.getStyleBackgroundByDevice=getStyleBackgroundByDevice,exports.makeFixedBgAttachment=makeFixedBgAttachment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var react=require("react");const useAnimationActions=()=>{let e=react.useRef(
|
|
1
|
+
"use strict";var react=require("react");const useAnimationActions=()=>{let e=react.useRef(),r=react.useCallback(r=>{e.current=r},[e]),t=react.useCallback(()=>{if(e.current)for(let r of e.current)r.play()},[]),c=react.useCallback(()=>{if(e.current)for(let r of e.current)r.cancel()},[]),n=react.useCallback(r=>{if(e.current)for(let t of e.current)t.onfinish=r},[]);return{currentAnimation:e.current,setAnimation:r,playAnimation:t,cancelAnimation:c,setAnimationOnFinish:n}};exports.useAnimationActions=useAnimationActions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var react=require("react"),useAnimationTarget=require("./useAnimationTarget.js");const useAnimationPreview=({
|
|
1
|
+
"use strict";var react=require("react"),useAnimationTarget=require("./useAnimationTarget.js");const useAnimationPreview=({props:e,playAnimation:i,cancelAnimation:t,setAnimationOnFinish:r})=>{let{setToolbarActive:a}=useAnimationTarget.useAnimationTarget(e),n=react.useCallback(n=>{let{uid:u,isCancel:s}=n.detail;if(e.uid===u){if(t(),s){a(!0);return}i(),a(!1),r(()=>{a(!0)})}},[e.uid,t,i,r,a]);return{previewAnimation:n}};exports.useAnimationPreview=useAnimationPreview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var react=require("react");const SPACING_ACTIVE_ATTRIBUTE="data-spacing",TOOLBAR_ACTIVE_ATTRIBUTE="data-toolbar-active",OUTLINE_ACTIVE_ATTRIBUTE="data-outline-active",TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE="data-toolbar-add-active",useAnimationTarget=
|
|
1
|
+
"use strict";var react=require("react"),useAnimationConfig=require("./useAnimationConfig.js");const SPACING_ACTIVE_ATTRIBUTE="data-spacing",TOOLBAR_ACTIVE_ATTRIBUTE="data-toolbar-active",OUTLINE_ACTIVE_ATTRIBUTE="data-outline-active",TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE="data-toolbar-add-active",useAnimationTarget=t=>{let{isEnabledAnimation:e}=useAnimationConfig.useAnimationConfig(t),r=t.tag,a=t.uid,T=react.useRef([]),o=react.useCallback(t=>{if(T.current)for(let e of T.current)t?(e.toolbar?.setAttribute(TOOLBAR_ACTIVE_ATTRIBUTE,"true"),e.outline?.setAttribute(OUTLINE_ACTIVE_ATTRIBUTE,"true"),e.spacing?.setAttribute(SPACING_ACTIVE_ATTRIBUTE,"true"),e.addSectionTop?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE,"true"),e.addSectionBottom?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE,"true")):(e.toolbar?.removeAttribute(TOOLBAR_ACTIVE_ATTRIBUTE),e.outline?.removeAttribute(OUTLINE_ACTIVE_ATTRIBUTE),e.spacing?.removeAttribute(SPACING_ACTIVE_ATTRIBUTE),e.addSectionTop?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE),e.addSectionBottom?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE))},[]),u=t=>{let e=t.querySelector("[data-toolbar-add-top]"),r=t.querySelector("[data-toolbar-add-bottom]"),a=Array.from(t.children),T=a.find(t=>null!==t.getAttribute("data-toolbar")),o=a.find(t=>null!==t.getAttribute("data-outline"));return{sectionToolbar:T,sectionOutline:o,sectionAddTop:e,sectionAddBottom:r}},A=react.useCallback(t=>t.reduce((t,e)=>{let a=null,T=null,o=e,A=e.querySelector("[data-toolbar]"),i=e.querySelector("[data-outline]"),n=e.querySelector("[data-spacing]");switch(r){case"Button":case"SubmitButton":case"ProductButton":case"DynamicCheckout":o=e.querySelector("button");break;case"ProductProperties":o=e.querySelector("input");break;case"Section":{o=e;let{sectionOutline:t,sectionToolbar:r,sectionAddTop:n,sectionAddBottom:c}=u(o);i=t,A=r,a=n,T=c;break}default:o=e}let c={target:o,toolbar:A,outline:i,spacing:n,addSectionTop:a,addSectionBottom:T};return t.push(c),t},[]),[r]),i=react.useCallback(()=>{let t=document.querySelectorAll(`[data-uid="${a}"]`),e=Array.from(t);if(!e.length)return;let r=A(e);T.current=r},[a,A]);return react.useEffect(()=>{e&&i()},[e,i]),{targetObjects:T,setToolbarActive:o,initListOfTargets:i}};exports.useAnimationTarget=useAnimationTarget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),useAnimations=require("../useAnimations.js"),useAnimationTarget=require("./useAnimationTarget.js"),useAnimationConfig=require("./useAnimationConfig.js"),useAnimationActions=require("./useAnimationActions.js"),useAnimationPreview=require("./useAnimationPreview.js"),animations=require("../../types/animations.js");const useApplyAnimation=({props:e})=>{let{uid:i
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),useAnimations=require("../useAnimations.js"),useAnimationTarget=require("./useAnimationTarget.js"),useAnimationConfig=require("./useAnimationConfig.js"),useAnimationActions=require("./useAnimationActions.js"),useAnimationPreview=require("./useAnimationPreview.js"),animations=require("../../types/animations.js");const useApplyAnimation=({props:e})=>{let{uid:i}=e,n=useAnimations.useAnimations(),{initListOfTargets:t,targetObjects:a}=useAnimationTarget.useAnimationTarget(e),{isEnabledAnimation:s,getAnimationConfig:r}=useAnimationConfig.useAnimationConfig(e),{setAnimation:o,cancelAnimation:u,playAnimation:m,setAnimationOnFinish:A}=useAnimationActions.useAnimationActions(),{previewAnimation:c}=useAnimationPreview.useAnimationPreview({props:e,playAnimation:m,cancelAnimation:u,setAnimationOnFinish:A}),p=react.useCallback(({target:e,setting:i,type:t})=>n[t](e,i),[n]),l=react.useCallback(()=>{let{type:e,setting:i}=r();if(!e||e===animations.AnimationType.None||!a.current.length){u();return}let n=a.current.map(n=>p({type:e,setting:i,target:n.target}));u(),o(n)},[r,a,u,o,p]);react.useEffect(()=>(s?(t(),l()):u(),()=>{u()}),[i,l,u,s,t]),react.useEffect(()=>(window.addEventListener("preview-animation",c),()=>{window.removeEventListener("preview-animation",c)}),[c])};exports.default=useApplyAnimation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devicesMapping as e}from"./constant.js";import{isColor as t,getSingleColorVariable as g}from"./colors.js";import{makeStyleResponsive as o}from"./make-style.js";let getStyleBackgroundByDevice=(e,t)=>e?{...getStyleBgColor(e),...getStyleBgImage(e,t),...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e),...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return o("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?t(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let g={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return o("bgi",g)},getBgImageByDevice=(e,t,g)=>{let o=e?.[t]?.type==="video";if(o)return;let i=e?.[t]?.image?.backupFileKey,l=g?.liquid&&i&&`{{ "${i}" | asset_url }}`||e?.[t]?.image?.src;if("string"==typeof l)return`url(${l})`},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop"),tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return o("bgp",t)},getBgPositionByDevice=(e,t)=>{let g=e?.[t]?.position;return g&&`${g.x}% ${g.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop"),tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return o("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop"),tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return o("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return o("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${g(e)} !important;`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},g={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...g.desktop?.wrapper,...g.tablet?.wrapper,...g.mobile?.wrapper},content:{...g.desktop?.content,...g.tablet?.content,...g.mobile?.content}}},makeFixedBgAttachmentByDevice=(t,g)=>{let o=e[t]??"";return"fixed"===g?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"
|
|
1
|
+
import{devicesMapping as e}from"./constant.js";import{isColor as t,getSingleColorVariable as g}from"./colors.js";import{makeStyleResponsive as o}from"./make-style.js";let getStyleBackgroundByDevice=(e,t)=>e?{...getStyleBgColor(e),...getStyleBgImage(e,t),...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e),...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return o("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?t(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let g={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return o("bgi",g)},getBgImageByDevice=(e,t,g)=>{let o=e?.[t]?.type==="video";if(o)return;let i=e?.[t]?.image?.backupFileKey,l=g?.liquid&&i&&`{{ "${i}" | asset_url }}`||e?.[t]?.image?.src;if("string"==typeof l)return`url(${l})`},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop"),tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return o("bgp",t)},getBgPositionByDevice=(e,t)=>{let g=e?.[t]?.position;return g&&`${g.x}% ${g.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop"),tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return o("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop"),tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return o("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return o("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${g(e)} !important;`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},g={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...g.desktop?.wrapper,...g.tablet?.wrapper,...g.mobile?.wrapper},content:{...g.desktop?.content,...g.tablet?.content,...g.mobile?.content}}},makeFixedBgAttachmentByDevice=(t,g)=>{let o=e[t]??"";return"fixed"===g?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"100%",[`--h${o}`]:"100%",[`--pos${o}`]:"absolute",[`--bga${o}`]:g}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};return Object.keys(e).forEach(g=>{e[g]?.startsWith(GRADIENT_BGR_KEY)&&("normal"===g?Object.assign(t,{"--bg":e[g]}):Object.assign(t,{"--hvr-bg":e[g]}))}),t},getGradientBgrStyleByDevice=e=>{if(!e)return;let t={};return["desktop","tablet","mobile"].forEach(g=>{e[g]?.type==="color"&&e[g]?.color?.includes(GRADIENT_BGR_KEY)&&Object.assign(t,{[`--bgc${"desktop"!==g?"-"+g:""}`]:"transparent",[`--bgi${"desktop"!==g?"-"+g:""}`]:e[g]?.color})}),t};export{GRADIENT_BGR_KEY,composeBackgroundCss,getBgImageByDevice,getGradientBgrStyleByDevice,getGradientBgrStyleForButton,getStyleBackgroundByDevice,makeFixedBgAttachment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as
|
|
1
|
+
import{useRef as r,useCallback as t}from"react";let useAnimationActions=()=>{let n=r(),e=t(r=>{n.current=r},[n]),o=t(()=>{if(n.current)for(let r of n.current)r.play()},[]),c=t(()=>{if(n.current)for(let r of n.current)r.cancel()},[]),i=t(r=>{if(n.current)for(let t of n.current)t.onfinish=r},[]);return{currentAnimation:n.current,setAnimation:e,playAnimation:o,cancelAnimation:c,setAnimationOnFinish:i}};export{useAnimationActions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as e}from"react";import{useAnimationTarget as
|
|
1
|
+
import{useCallback as e}from"react";import{useAnimationTarget as i}from"./useAnimationTarget.js";let useAnimationPreview=({props:t,playAnimation:r,cancelAnimation:n,setAnimationOnFinish:o})=>{let{setToolbarActive:m}=i(t),u=e(e=>{let{uid:i,isCancel:u}=e.detail;if(t.uid===i){if(n(),u){m(!0);return}r(),m(!1),o(()=>{m(!0)})}},[t.uid,n,r,o,m]);return{previewAnimation:u}};export{useAnimationPreview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as t,useCallback as
|
|
1
|
+
import{useRef as t,useCallback as e,useEffect as r}from"react";import{useAnimationConfig as T}from"./useAnimationConfig.js";let SPACING_ACTIVE_ATTRIBUTE="data-spacing",TOOLBAR_ACTIVE_ATTRIBUTE="data-toolbar-active",OUTLINE_ACTIVE_ATTRIBUTE="data-outline-active",TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE="data-toolbar-add-active",useAnimationTarget=o=>{let{isEnabledAnimation:a}=T(o),A=o.tag,u=o.uid,i=t([]),l=e(t=>{if(i.current)for(let e of i.current)t?(e.toolbar?.setAttribute(TOOLBAR_ACTIVE_ATTRIBUTE,"true"),e.outline?.setAttribute(OUTLINE_ACTIVE_ATTRIBUTE,"true"),e.spacing?.setAttribute(SPACING_ACTIVE_ATTRIBUTE,"true"),e.addSectionTop?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE,"true"),e.addSectionBottom?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE,"true")):(e.toolbar?.removeAttribute(TOOLBAR_ACTIVE_ATTRIBUTE),e.outline?.removeAttribute(OUTLINE_ACTIVE_ATTRIBUTE),e.spacing?.removeAttribute(SPACING_ACTIVE_ATTRIBUTE),e.addSectionTop?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE),e.addSectionBottom?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE))},[]),n=t=>{let e=t.querySelector("[data-toolbar-add-top]"),r=t.querySelector("[data-toolbar-add-bottom]"),T=Array.from(t.children),o=T.find(t=>null!==t.getAttribute("data-toolbar")),a=T.find(t=>null!==t.getAttribute("data-outline"));return{sectionToolbar:o,sectionOutline:a,sectionAddTop:e,sectionAddBottom:r}},I=e(t=>t.reduce((t,e)=>{let r=null,T=null,o=e,a=e.querySelector("[data-toolbar]"),u=e.querySelector("[data-outline]"),i=e.querySelector("[data-spacing]");switch(A){case"Button":case"SubmitButton":case"ProductButton":case"DynamicCheckout":o=e.querySelector("button");break;case"ProductProperties":o=e.querySelector("input");break;case"Section":{o=e;let{sectionOutline:t,sectionToolbar:A,sectionAddTop:i,sectionAddBottom:l}=n(o);u=t,a=A,r=i,T=l;break}default:o=e}let l={target:o,toolbar:a,outline:u,spacing:i,addSectionTop:r,addSectionBottom:T};return t.push(l),t},[]),[A]),c=e(()=>{let t=document.querySelectorAll(`[data-uid="${u}"]`),e=Array.from(t);if(!e.length)return;let r=I(e);i.current=r},[u,I]);return r(()=>{a&&c()},[a,c]),{targetObjects:i,setToolbarActive:l,initListOfTargets:c}};export{useAnimationTarget};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{useCallback as t,useEffect as i}from"react";import{useAnimations as e}from"../useAnimations.js";import{useAnimationTarget as n}from"./useAnimationTarget.js";import{useAnimationConfig as o}from"./useAnimationConfig.js";import{useAnimationActions as r}from"./useAnimationActions.js";import{useAnimationPreview as m}from"./useAnimationPreview.js";import{AnimationType as a}from"../../types/animations.js";let useApplyAnimation=({props:s})=>{let{uid:p}=s,u=e(),{initListOfTargets:f,targetObjects:A}=n(s),{isEnabledAnimation:l,getAnimationConfig:w}=o(s),{setAnimation:d,cancelAnimation:j,playAnimation:v,setAnimationOnFinish:g}=r(),{previewAnimation:c}=m({props:s,playAnimation:v,cancelAnimation:j,setAnimationOnFinish:g}),y=t(({target:t,setting:i,type:e})=>u[e](t,i),[u]),E=t(()=>{let{type:t,setting:i}=w();if(!t||t===a.None||!A.current.length){j();return}let e=A.current.map(e=>y({type:t,setting:i,target:e.target}));j(),d(e)},[w,A,j,d,y]);i(()=>(l?(f(),E()):j(),()=>{j()}),[p,E,j,l,f]),i(()=>(window.addEventListener("preview-animation",c),()=>{window.removeEventListener("preview-animation",c)}),[c])};export{useApplyAnimation as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "1.14.0-dev.
|
|
3
|
+
"version": "1.14.0-dev.556",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@gem-sdk/adapter-shopify": "1.14.0-dev.284",
|
|
28
|
-
"@gem-sdk/styles": "1.14.0-dev.
|
|
28
|
+
"@gem-sdk/styles": "1.14.0-dev.554"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"react-error-boundary": "4.0.10",
|