@gem-sdk/core 1.14.0-dev.550 → 1.14.0-dev.553

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");require("zustand");var BuilderPreviewContext=require("../../contexts/BuilderPreviewContext.js");function Spacing(e){let t=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),r=react.useRef(null),n=react.useRef(null),i=react.useRef(null),a=react.useRef(!1),o=react.useRef(0),u=react.useRef(0),s=e=>{let t=e.clientY,r=Math.ceil(t-o.current),n=u.current||0,i=n+r>=0?`${n+r}px`:"0px";return{newValue:i}},c=e=>{if(r.current&&n.current){let{newValue:t}=s(e);n.current.style.height=t,r.current.style.top=t;let i=r.current.closest("[data-toolbar-wrap]");i&&(i.style.marginBottom=t)}},l=()=>{m()},d=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a.current=!0;let e=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(e),document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)},100)},m=()=>{i.current&&clearTimeout(i.current),a.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),r.current){let t=getComputedStyle(r.current),n=t.top,i=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:e.uid,marginBottom:n}});window.dispatchEvent(i)}let n=r.current?.closest("[data-toolbar-wrap]");n&&(n.style.marginBottom=""),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l)},p=(e,t)=>{let r=e.children.length;if(r)for(let n=0;n<r;n++){let r=e.children[n];if(r){let e=r.getAttribute(t);if(e)return r}}},g=react.useCallback(e=>{if(a.current)return;let t=e.detail,i=r.current?.closest("[data-toolbar-wrap]"),o=i&&p(i,"data-toolbar"),u=o&&o.getAttribute("data-toolbar-active");if(u&&t?.marginBottom){let e=isNaN(parseInt(t?.marginBottom))?0:Math.max(parseInt(t?.marginBottom),0),i=`${e}px`;r.current&&n.current&&(n.current.style.height=i,r.current.style.top=i)}},[]);return react.useEffect(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",g),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",g)}),[g]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Section"!==e.tag&&jsxRuntime.jsx("div",{"data-spacing":!0,"data-spacing-theme-section":t,className:"absolute w-full bottom-0",children:jsxRuntime.jsxs("div",{"data-spacing-margin-bottom":!0,children:[jsxRuntime.jsx("div",{"data-spacing-margin-bottom-bg":!0,ref:n,children:jsxRuntime.jsx("div",{"data-spacing-margin-bottom-value":!0})}),jsxRuntime.jsx("div",{ref:r,"data-spacing-margin-bottom-drag":!0,onMouseDown:e=>{if(r.current){let t=getComputedStyle(r.current);o.current=e.clientY,u.current=parseFloat(t.top),d()}},onMouseUp:()=>{m()},role:"presentation"})]})})})}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"),exports.default=Spacing;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react");require("zustand");var BuilderPreviewContext=require("../../contexts/BuilderPreviewContext.js");function Spacing(e){let t=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),r=react.useRef(null),n=react.useRef(null),i=react.useRef(null),o=react.useRef(!1),a=react.useRef(0),u=react.useRef(0),s=e=>{let t=e.clientY,r=Math.ceil(t-a.current),n=u.current||0,i=n+r>=0?`${n+r}px`:"0px";return{newValue:i}},l=e=>{if(r.current&&n.current){let{newValue:t}=s(e);n.current.style.height=t,r.current.style.top=t;let i=r.current.closest("[data-toolbar-wrap]");i&&(i.style.marginBottom=t)}},c=()=>{m()},d=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{o.current=!0;let e=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(e),document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)},100)},m=()=>{i.current&&clearTimeout(i.current),o.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),r.current){let t=getComputedStyle(r.current),n=t.top,i=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:e.uid,marginBottom:n}});window.dispatchEvent(i)}let n=r.current?.closest("[data-toolbar-wrap]");n&&(n.style.marginBottom=""),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)},p=(e,t)=>{let r=e.children.length;if(r)for(let n=0;n<r;n++){let r=e.children[n];if(r){let e=r.getAttribute(t);if(e)return r}}},g=react.useCallback(e=>{if(o.current)return;let t=e.detail,i=r.current?.closest("[data-toolbar-wrap]"),a=i&&p(i,"data-toolbar"),u=a&&a.getAttribute("data-toolbar-active");if(u&&t?.marginBottom){let e=parseInt(t?.marginBottom),i=`${e}px`;r.current&&n.current&&(e<0?(n.current.style.display="none",r.current.style.display="none"):(n.current.style.display="block",r.current.style.display="block",n.current.style.height=i,r.current.style.top=i))}},[]);return react.useEffect(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",g),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",g)}),[g]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Section"!==e.tag&&jsxRuntime.jsx("div",{"data-spacing":!0,"data-spacing-theme-section":t,className:"absolute w-full bottom-0",children:jsxRuntime.jsxs("div",{"data-spacing-margin-bottom":!0,children:[jsxRuntime.jsx("div",{"data-spacing-margin-bottom-bg":!0,ref:n,children:jsxRuntime.jsx("div",{"data-spacing-margin-bottom-value":!0})}),jsxRuntime.jsx("div",{ref:r,"data-spacing-margin-bottom-drag":!0,onMouseDown:e=>{if(r.current){let t=getComputedStyle(r.current);a.current=e.clientY,u.current=parseFloat(t.top),d()}},onMouseUp:()=>{m()},role:"presentation"})]})})})}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"),exports.default=Spacing;
@@ -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}`]:"inherit",[`--h${o}`]:"inherit",[`--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
+ "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
- import{jsx as t,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as o,useCallback as n,useEffect as i}from"react";import"zustand";import{useBuilderPreviewStore as a}from"../../contexts/BuilderPreviewContext.js";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";function Spacing(l){let u=a(t=>t.isThemeSectionEditor),c=o(null),m=o(null),s=o(null),d=o(!1),p=o(0),g=o(0),b=t=>{let e=t.clientY,r=Math.ceil(e-p.current),o=g.current||0,n=o+r>=0?`${o+r}px`:"0px";return{newValue:n}},v=t=>{if(c.current&&m.current){let{newValue:e}=b(t);m.current.style.height=e,c.current.style.top=e;let r=c.current.closest("[data-toolbar-wrap]");r&&(r.style.marginBottom=e)}},h=()=>{f()},w=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{d.current=!0;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(t),document.addEventListener("mousemove",v),document.addEventListener("mouseup",h)},100)},f=()=>{s.current&&clearTimeout(s.current),d.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),c.current){let t=getComputedStyle(c.current),e=t.top,r=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:l.uid,marginBottom:e}});window.dispatchEvent(r)}let e=c.current?.closest("[data-toolbar-wrap]");e&&(e.style.marginBottom=""),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",h)},E=(t,e)=>{let r=t.children.length;if(r)for(let o=0;o<r;o++){let r=t.children[o];if(r){let t=r.getAttribute(e);if(t)return r}}},y=n(t=>{if(d.current)return;let e=t.detail,r=c.current?.closest("[data-toolbar-wrap]"),o=r&&E(r,"data-toolbar"),n=o&&o.getAttribute("data-toolbar-active");if(n&&e?.marginBottom){let t=isNaN(parseInt(e?.marginBottom))?0:Math.max(parseInt(e?.marginBottom),0),r=`${t}px`;c.current&&m.current&&(m.current.style.height=r,c.current.style.top=r)}},[]);return i(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",y),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",y)}),[y]),t(e,{children:"Section"!==l.tag&&t("div",{"data-spacing":!0,"data-spacing-theme-section":u,className:"absolute w-full bottom-0",children:r("div",{"data-spacing-margin-bottom":!0,children:[t("div",{"data-spacing-margin-bottom-bg":!0,ref:m,children:t("div",{"data-spacing-margin-bottom-value":!0})}),t("div",{ref:c,"data-spacing-margin-bottom-drag":!0,onMouseDown:t=>{if(c.current){let e=getComputedStyle(c.current);p.current=t.clientY,g.current=parseFloat(e.top),w()}},onMouseUp:()=>{f()},role:"presentation"})]})})})}export{Spacing as default};
1
+ import{jsx as t,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as o,useCallback as n,useEffect as i}from"react";import"zustand";import{useBuilderPreviewStore as a}from"../../contexts/BuilderPreviewContext.js";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";function Spacing(l){let u=a(t=>t.isThemeSectionEditor),c=o(null),s=o(null),d=o(null),m=o(!1),p=o(0),g=o(0),b=t=>{let e=t.clientY,r=Math.ceil(e-p.current),o=g.current||0,n=o+r>=0?`${o+r}px`:"0px";return{newValue:n}},v=t=>{if(c.current&&s.current){let{newValue:e}=b(t);s.current.style.height=e,c.current.style.top=e;let r=c.current.closest("[data-toolbar-wrap]");r&&(r.style.marginBottom=e)}},h=()=>{f()},w=()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{m.current=!0;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(t),document.addEventListener("mousemove",v),document.addEventListener("mouseup",h)},100)},f=()=>{d.current&&clearTimeout(d.current),m.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),c.current){let t=getComputedStyle(c.current),e=t.top,r=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:l.uid,marginBottom:e}});window.dispatchEvent(r)}let e=c.current?.closest("[data-toolbar-wrap]");e&&(e.style.marginBottom=""),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",h)},y=(t,e)=>{let r=t.children.length;if(r)for(let o=0;o<r;o++){let r=t.children[o];if(r){let t=r.getAttribute(e);if(t)return r}}},E=n(t=>{if(m.current)return;let e=t.detail,r=c.current?.closest("[data-toolbar-wrap]"),o=r&&y(r,"data-toolbar"),n=o&&o.getAttribute("data-toolbar-active");if(n&&e?.marginBottom){let t=parseInt(e?.marginBottom),r=`${t}px`;c.current&&s.current&&(t<0?(s.current.style.display="none",c.current.style.display="none"):(s.current.style.display="block",c.current.style.display="block",s.current.style.height=r,c.current.style.top=r))}},[]);return i(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",E),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",E)}),[E]),t(e,{children:"Section"!==l.tag&&t("div",{"data-spacing":!0,"data-spacing-theme-section":u,className:"absolute w-full bottom-0",children:r("div",{"data-spacing-margin-bottom":!0,children:[t("div",{"data-spacing-margin-bottom-bg":!0,ref:s,children:t("div",{"data-spacing-margin-bottom-value":!0})}),t("div",{ref:c,"data-spacing-margin-bottom-drag":!0,onMouseDown:t=>{if(c.current){let e=getComputedStyle(c.current);p.current=t.clientY,g.current=parseFloat(e.top),w()}},onMouseUp:()=>{f()},role:"presentation"})]})})})}export{Spacing as default};
@@ -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}`]:"inherit",[`--h${o}`]:"inherit",[`--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
+ 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.14.0-dev.550",
3
+ "version": "1.14.0-dev.553",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",