@gem-sdk/core 1.14.0-dev.540 → 1.14.0-dev.541
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),
|
|
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 +1 @@
|
|
|
1
|
-
import{jsx as t,Fragment as e,jsxs as r}from"react/jsx-runtime";import{useRef as o}from"react";import"zustand";import{useBuilderPreviewStore as
|
|
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};
|