@gem-sdk/core 1.14.0-dev.559 → 1.14.0-dev.563
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),
|
|
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),a=react.useRef(null),i=react.useRef(!1),o=react.useRef(0),u=react.useRef(0),l=e=>{let t=e.clientY,r=Math.ceil(t-o.current),n=u.current||0,a=n+r>=0?`${n+r}px`:"0px";return{newValue:a}},s=e=>{if(r.current&&n.current){let{newValue:t}=l(e);n.current.style.height=t,r.current.style.top=t;let a=r.current.closest("[data-toolbar-wrap]");a&&(a.style.marginBottom=t)}},c=()=>{m()},d=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=!0;let e=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(e),document.addEventListener("mousemove",s),document.addEventListener("mouseup",c)},100)},m=()=>{a.current&&clearTimeout(a.current),i.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,a=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:e.uid,marginBottom:n}});window.dispatchEvent(a)}let n=r.current?.closest("[data-toolbar-wrap]");n&&(n.style.marginBottom=""),document.removeEventListener("mousemove",s),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(i.current)return;let t=e.detail,a=r.current?.closest("[data-toolbar-wrap]"),o=a&&p(a,"data-toolbar"),u=o&&o.getAttribute("data-toolbar-active");if(u&&t?.marginBottom){let e=parseInt(t?.marginBottom),a=`${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=a,r.current.style.top=a))}},[]),b=e=>{let t=e.getAttribute("data-component-tag");return"Dialog"===t},v=e=>{let t=e.getAttribute("data-component-tag");return"Sticky"===t},f=react.useCallback(e=>{let t=r.current?.closest("[data-toolbar-wrap]");if(t){if(b(t)||v(t))return;let a=t&&p(t,"data-toolbar"),i=a&&a.getAttribute("data-toolbar-active");if(i&&e){let t=isNaN(parseInt(e))?0:Math.max(parseInt(e),0),a=`-${t}px`,i=`translate(-${t}px, -100%)`;r.current&&n.current&&(n.current.style.left=a,r.current.style.transform=i)}}},[]),w=react.useCallback(e=>{if(i.current)return;let t=e.detail;t?.paddingLeft&&f(t.paddingLeft)},[f]);return react.useEffect(()=>{let e=r.current?.closest("[data-toolbar-wrap]");if(e){let t=getComputedStyle(e),r=t.paddingLeft;f(r)}}),react.useEffect(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",g),window.addEventListener("editor:toolbar:update-padding-left",w),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",g),window.removeEventListener("editor:toolbar:update-padding-left",w)}),[g,w]),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,useCallback as n,useEffect 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 a}from"react";import"zustand";import{useBuilderPreviewStore as i}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=i(t=>t.isThemeSectionEditor),d=o(null),c=o(null),s=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(d.current&&c.current){let{newValue:e}=b(t);c.current.style.height=e,d.current.style.top=e;let r=d.current.closest("[data-toolbar-wrap]");r&&(r.style.marginBottom=e)}},f=()=>{h()},w=()=>{s.current&&clearTimeout(s.current),s.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",f)},100)},h=()=>{s.current&&clearTimeout(s.current),m.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),d.current){let t=getComputedStyle(d.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=d.current?.closest("[data-toolbar-wrap]");e&&(e.style.marginBottom=""),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",f)},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=d.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`;d.current&&c.current&&(t<0?(c.current.style.display="none",d.current.style.display="none"):(c.current.style.display="block",d.current.style.display="block",c.current.style.height=r,d.current.style.top=r))}},[]),L=t=>{let e=t.getAttribute("data-component-tag");return"Dialog"===e},x=t=>{let e=t.getAttribute("data-component-tag");return"Sticky"===e},C=n(t=>{let e=d.current?.closest("[data-toolbar-wrap]");if(e){if(L(e)||x(e))return;let r=e&&y(e,"data-toolbar"),o=r&&r.getAttribute("data-toolbar-active");if(o&&t){let e=isNaN(parseInt(t))?0:Math.max(parseInt(t),0),r=`-${e}px`,o=`translate(-${e}px, -100%)`;d.current&&c.current&&(c.current.style.left=r,d.current.style.transform=o)}}},[]),S=n(t=>{if(m.current)return;let e=t.detail;e?.paddingLeft&&C(e.paddingLeft)},[C]);return a(()=>{let t=d.current?.closest("[data-toolbar-wrap]");if(t){let e=getComputedStyle(t),r=e.paddingLeft;C(r)}}),a(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",E),window.addEventListener("editor:toolbar:update-padding-left",S),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",E),window.removeEventListener("editor:toolbar:update-padding-left",S)}),[E,S]),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:c,children:t("div",{"data-spacing-margin-bottom-value":!0})}),t("div",{ref:d,"data-spacing-margin-bottom-drag":!0,onMouseDown:t=>{if(d.current){let e=getComputedStyle(d.current);p.current=t.clientY,g.current=parseFloat(e.top),w()}},onMouseUp:()=>{h()},role:"presentation"})]})})})}export{Spacing as default};
|