@gem-sdk/core 1.14.0-dev.734 → 1.14.0-dev.740

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";var jsxRuntime=require("react/jsx-runtime"),react=require("react");require("zustand");var BuilderPreviewContext=require("../contexts/BuilderPreviewContext.js"),ShopContext=require("../contexts/ShopContext.js");require("@gem-sdk/adapter-shopify"),require("swr"),require("swr/mutation"),require("vanilla-lazyload"),require("../hooks/useCartUI.js");var CreateThemeSection=require("./theme-section/CreateThemeSection.js"),Tooltip=require("./toolbar/Tooltip.js"),ThemeSectionStatus=require("./theme-section/ThemeSectionStatus.js"),useToolbarPostPurchase=require("../hooks/useToolbarPostPurchase.js"),Resize=require("./resize/Resize.js");require("../helpers/convert.js");const SECTION_LIMIT=25,notVisible=e=>{let t=getComputedStyle(e).overflow;return"visible"!==t},isSection=e=>{let t=e.getAttribute("data-component-tag");return"Section"===t},ComponentToolbarPreview=({...e})=>{let t=e.isThemeSection,i=ShopContext.useShopStore(e=>e.pageType),o=BuilderPreviewContext.useBuilderPreviewStore(e=>e.getParents),n=BuilderPreviewContext.useBuilderPreviewStore(e=>e.getItem("ROOT")),r=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),[a,l]=react.useState(null),[s,d]=react.useState(!1),[u,c]=react.useState(!1),[C,h]=react.useState([]),[m,x]=react.useState("top"),[p,j]=react.useState(!0),[v,b]=react.useState({width:"",text:""}),[g,S]=react.useState(!0),w=react.useMemo(()=>"POST_PURCHASE"===i||"GP_FUNNEL_PAGE"===i,[i]),{checkDisableDelete:R,getTooltipText:f,checkDisableDuplicate:T}=useToolbarPostPurchase.usePostPurchase(e.uid,e.tag||""),P=(e,t)=>{let i=C.length,o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return o.top-n.top<36*i},H=(e,t)=>{let i=t||e;if(e&&!isSection(e))return notVisible(e)&&P(t,e)?e:e.parentElement?H(e.parentElement,i):void 0},V=react.useCallback(t=>{let i=t.detail;if(i?.componentUid==e.uid){w&&(j(R()),b(f()),S(T()));let t=o(e.uid).filter(e=>!("ROOT"===e.uid||"Section"===e.tag&&r||e.editorConfigs?.toolbar?.hide||e.editorConfigs?.component?.noSetting)).slice(0,3);h(t)}else h([]),d(!1)},[e.uid,w,o,R,f,T,r]),E=react.useCallback(()=>{if("Section"==e.tag)return"bottom";let t=document.querySelector('[data-toolbar-active="true"]');if(t){let e=t.getBoundingClientRect();e.top<60?x("bottom"):x("top")}},[e.tag]);if(react.useEffect(()=>{let e=document.querySelector('[data-toolbar-delete="true"]');return e&&window.addEventListener("mouseover",E),window.addEventListener("editor:active-component",V),()=>{window.removeEventListener("editor:active-component",V),window.removeEventListener("mousemove",V)}},[E,V]),"section"===e.type||e.editorConfigs?.toolbar?.hide)return null;let M=()=>n?.childrens?.length||0,Z=()=>"Section"!==e.tag?-1:n?.childrens?.length?n.childrens.findIndex(t=>t==e.uid):-1,B=e=>{if(!C.length)return;let t=e?.target||null,i=t.closest("[data-toolbar-active]");if(!t||!i)return;if(s)c(!1),d(!1);else{let e=H(i,i);if(e)c(!0);else{let e=i.getBoundingClientRect();e.top<36*C.length?c(!0):c(!1)}d(!0)}let o=new CustomEvent("editor:toolbar:show-parents",{bubbles:!0,detail:{value:!s}});window.dispatchEvent(o)},L=i=>{i.preventDefault(),i.stopPropagation();let o=new CustomEvent("editor:toolbar:delete-component",{bubbles:!0,detail:{componentUid:e.uid,isThemeSection:t}});return window.dispatchEvent(o),!1},q=i=>{if(i.preventDefault(),i.stopPropagation(),M()>=25&&"Section"==e.tag)return!1;let o=new CustomEvent("editor:toolbar:duplicate-component",{bubbles:!0,detail:{componentUid:e.uid,isThemeSection:t}});return window.dispatchEvent(o),!1},k=t=>{t.preventDefault(),t.stopPropagation();let i=new CustomEvent("editor:toolbar:zoom-out-component",{bubbles:!0,detail:{componentUid:e.uid}});return window.dispatchEvent(i),!1},y=()=>{l(null),window.removeEventListener("editor:close-add-section-popup",y)},U=(t,i)=>{if(t.preventDefault(),t.stopPropagation(),M()>=25)return!1;let o=t.target;if(o){l(i);let t=o.getBoundingClientRect(),n=new CustomEvent("editor:toolbar:add-section",{bubbles:!0,detail:{componentUid:e.uid,position:i,top:t.top+t.height/2}});window.dispatchEvent(n),window.addEventListener("editor:close-add-section-popup",y)}return!1},z=()=>{let t=e.name&&e.name===`Section ${e.uid}`;return M()>=20?`${t?"Section":e?.name} ${Z()+1}/25`:t?`Section ${Z()+1}`:e?.name};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!("Section"==e.tag&&r)&&jsxRuntime.jsxs("div",{"data-toolbar":!0,"data-toolbar-section":"Section"==e.tag,"data-toolbar-theme-section":"Section"==e.tag&&!!t||r,"data-toolbar-limit":Z()>=25,children:[jsxRuntime.jsxs("div",{"data-toolbar-show-parent":!0,onClick:e=>B(e),"aria-hidden":"true",children:[jsxRuntime.jsx("div",{"data-toolbar-icon-drag":!0,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),"Section"==e.tag?jsxRuntime.jsx("div",{"data-toolbar-name":!0,children:z()}):jsxRuntime.jsx("div",{"data-toolbar-name":!0,children:e.customLabel||e.label}),"Section"!==e.tag&&C.length>0&&jsxRuntime.jsx("div",{"data-toolbar-icon-parent":!0,"data-toolbar-icon-parent-open":s,children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M5.65522 10C5.07265 10 4.7809 9.22865 5.19284 8.77753L7.53762 6.20974C7.79298 5.93009 8.20702 5.93009 8.46238 6.20974L10.8072 8.77754C11.2191 9.22866 10.9274 10 10.3448 10H5.65522Z",fill:"currentColor"})})})]}),s&&C.map((e,t)=>{let i=e?.childrens?.length??0,o=e.label;return"Row"===e.label&&(o=i<=1?e.label+" "+i+" col":e.label+" "+i+" cols"),jsxRuntime.jsxs("div",{"data-toolbar-parent":!0,"data-parent-uid":e.uid,"data-toolbar-theme-section":r,"data-toolbar-parent-revert":u,style:{top:u?`${36*(t+1)}px`:`${-36*(t+1)}px`},children:[jsxRuntime.jsx("div",{"data-toolbar-icon-drag":!0,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),jsxRuntime.jsx("div",{"data-toolbar-name":!0,children:o})]},e.uid)}),"Section"===e.tag&&!e.isThemeSection&&"STATIC"!==i&&"POST_PURCHASE"!==i&&25>Z()&&jsxRuntime.jsx(CreateThemeSection.CreateThemeSection,{...e}),"Sticky"==e.tag&&jsxRuntime.jsx("div",{"data-toolbar-zoom-out":!0,onClick:e=>k(e),"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5 7C14.7761 7 15 6.77614 15 6.5C15 6.22386 14.7761 6 14.5 6L10.7072 6L14.8536 1.85355C15.0489 1.65829 15.0489 1.34171 14.8536 1.14645C14.6584 0.951186 14.3418 0.951185 14.1465 1.14645L10 5.29297L10 1.5C10 1.22386 9.77614 1 9.5 1C9.22386 1 9 1.22386 9 1.5L9 6.5C9 6.77614 9.22386 7 9.5 7L14.5 7ZM6 10.7073L6 14.5C6 14.7761 6.22386 15 6.5 15C6.77614 15 7 14.7761 7 14.5L7 9.5C7 9.22386 6.77614 9 6.5 9H1.5C1.22386 9 1 9.22386 1 9.5C1 9.77614 1.22386 10 1.5 10H5.29306L1.14662 14.1464C0.951353 14.3417 0.951353 14.6583 1.14662 14.8536C1.34188 15.0488 1.65846 15.0488 1.85372 14.8536L6 10.7073Z",fill:"currentColor"})})}),jsxRuntime.jsx(Tooltip.default,{enable:"Section"==e.tag&&M()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==e.tag&&M()>=25||g,onClick:g?void 0:e=>q(e),"aria-hidden":"true",className:g?"!gp-cursor-not-allowed":"",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.08423 1.21289C5.53194 1.21289 5.08423 1.66061 5.08423 2.21289V3.78711H4.26172C3.43329 3.78711 2.76172 4.45868 2.76172 5.28711V13.2871C2.76172 14.1155 3.43329 14.7871 4.26172 14.7871H10.2617C11.0901 14.7871 11.7617 14.1155 11.7617 13.2871V12.4629H13.0842C13.6365 12.4629 14.0842 12.0152 14.0842 11.4629V2.21289C14.0842 1.66061 13.6365 1.21289 13.0842 1.21289H6.08423ZM10.7617 12.4629H6.08423C5.53194 12.4629 5.08423 12.0152 5.08423 11.4629V4.78711H4.26172C3.98558 4.78711 3.76172 5.01097 3.76172 5.28711V13.2871C3.76172 13.5633 3.98558 13.7871 4.26172 13.7871H10.2617C10.5379 13.7871 10.7617 13.5633 10.7617 13.2871V12.4629Z",fill:"currentColor"})})}),jsxRuntime.jsx(Tooltip.default,{"data-toolbar-delete":!0,onClick:e=>p?null:L(e),enable:p,"data-toolbar-disable":p,width:v.width,text:v.text,position:m,"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2.88965V2.38965C11 1.56122 10.3284 0.889648 9.5 0.889648H6.5C5.67157 0.889648 5 1.56122 5 2.38965V2.88965H2C1.72386 2.88965 1.5 3.11351 1.5 3.38965C1.5 3.66579 1.72386 3.88965 2 3.88965H3.21997V13.1099C3.21997 14.2144 4.1154 15.1099 5.21997 15.1099H11.22C12.3245 15.1099 13.22 14.2144 13.22 13.1099V3.88965H14C14.2761 3.88965 14.5 3.66579 14.5 3.38965C14.5 3.11351 14.2761 2.88965 14 2.88965H11ZM6 2.88965H10V2.38965C10 2.11351 9.77614 1.88965 9.5 1.88965H6.5C6.22386 1.88965 6 2.11351 6 2.38965V2.88965ZM6.24976 6.13965C6.66397 6.13965 6.99976 6.47543 6.99976 6.88965V11.3896C6.99976 11.8039 6.66397 12.1396 6.24976 12.1396C5.83554 12.1396 5.49976 11.8039 5.49976 11.3896V6.88965C5.49976 6.47543 5.83554 6.13965 6.24976 6.13965ZM10.4998 6.88965C10.4998 6.47543 10.164 6.13965 9.74976 6.13965C9.33554 6.13965 8.99976 6.47543 8.99976 6.88965V11.3896C8.99976 11.8039 9.33554 12.1396 9.74976 12.1396C10.164 12.1396 10.4998 11.8039 10.4998 11.3896V6.88965Z",fill:"currentColor"})})})]}),"STATIC"!==i&&"POST_PURCHASE"!==i&&25>Z()&&jsxRuntime.jsx(ThemeSectionStatus.ThemeSectionStatusWrapper,{...e}),jsxRuntime.jsx("div",{"data-outline":!0,"data-outline-section":"Section"==e.tag,"data-outline-theme-section":"Section"==e.tag&&!!t||r,"data-outline-limit":Z()>=25}),"Section"==e.tag&&!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tooltip.default,{enable:M()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":M()>=25,"data-toolbar-add-open":"above"==a,onClick:e=>U(e,"above"),"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})}),jsxRuntime.jsx(Tooltip.default,{enable:M()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":M()>=25,"data-toolbar-add-open":"below"==a,onClick:e=>U(e,"below"),"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})})]}),jsxRuntime.jsx(Resize.default,{...e})]})};exports.ComponentToolbarPreview=ComponentToolbarPreview;
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"),ShopContext=require("../contexts/ShopContext.js");require("@gem-sdk/adapter-shopify"),require("swr"),require("swr/mutation"),require("vanilla-lazyload"),require("../hooks/useCartUI.js");var CreateThemeSection=require("./theme-section/CreateThemeSection.js"),Tooltip=require("./toolbar/Tooltip.js"),ThemeSectionStatus=require("./theme-section/ThemeSectionStatus.js"),useToolbarPostPurchase=require("../hooks/useToolbarPostPurchase.js"),Resize=require("./resize/Resize.js");require("../helpers/convert.js");const SECTION_LIMIT=25,notVisible=e=>{let t=getComputedStyle(e).overflow;return"visible"!==t},isSection=e=>{let t=e.getAttribute("data-component-tag");return"Section"===t},ComponentToolbarPreview=e=>{let t=e.isThemeSection,i=ShopContext.useShopStore(e=>e.pageType),o=BuilderPreviewContext.useBuilderPreviewStore(e=>e.getParents),n=BuilderPreviewContext.useBuilderPreviewStore(e=>e.getItem("ROOT")),r=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),[a,l]=react.useState(null),[s,d]=react.useState(!1),[u,c]=react.useState(!1),[C,h]=react.useState([]),[m,x]=react.useState("top"),[p,j]=react.useState(!1),[v,b]=react.useState({width:"",text:""}),[g,w]=react.useState(!1),S=react.useMemo(()=>"POST_PURCHASE"===i||"GP_FUNNEL_PAGE"===i,[i]),{checkDisableDelete:R,getTooltipText:f,checkDisableDuplicate:T}=useToolbarPostPurchase.usePostPurchase(e.uid,e.tag||""),P=(e,t)=>{let i=C.length,o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return o.top-n.top<36*i},H=(e,t)=>{let i=t||e;if(e&&!isSection(e))return notVisible(e)&&P(t,e)?e:e.parentElement?H(e.parentElement,i):void 0},V=react.useCallback(t=>{let i=t.detail;if(i?.componentUid==e.uid){S&&(j(R()),b(f()),w(T()));let t=o(e.uid).filter(e=>!("ROOT"===e.uid||"Section"===e.tag&&r||e.editorConfigs?.toolbar?.hide||e.editorConfigs?.component?.noSetting)).slice(0,3);h(t)}},[e.uid,S,o,R,f,T,r]),E=react.useCallback(()=>{if("Section"==e.tag)return"bottom";let t=document.querySelector('[data-toolbar-active="true"]');if(t){let e=t.getBoundingClientRect();e.top<60?x("bottom"):x("top")}},[e.tag]);if(react.useEffect(()=>{let e=document.querySelector('[data-toolbar-delete="true"]');return e&&window.addEventListener("mouseover",E),window.addEventListener("editor:active-component",V),()=>{window.removeEventListener("editor:active-component",V),window.removeEventListener("mousemove",V)}},[E,V]),"section"===e.type||e.editorConfigs?.toolbar?.hide)return null;let M=()=>n?.childrens?.length||0,Z=()=>"Section"!==e.tag?-1:n?.childrens?.length?n.childrens.findIndex(t=>t==e.uid):-1,B=e=>{if(!C.length)return;let t=e?.target||null,i=t.closest("[data-toolbar-active]");if(!t||!i)return;if(s)c(!1),d(!1);else{let e=H(i,i);if(e)c(!0);else{let e=i.getBoundingClientRect();e.top<36*C.length?c(!0):c(!1)}d(!0)}let o=new CustomEvent("editor:toolbar:show-parents",{bubbles:!0,detail:{value:!s}});window.dispatchEvent(o)},L=i=>{i.preventDefault(),i.stopPropagation();let o=new CustomEvent("editor:toolbar:delete-component",{bubbles:!0,detail:{componentUid:e.uid,isThemeSection:t}});return window.dispatchEvent(o),!1},q=i=>{if(i.preventDefault(),i.stopPropagation(),M()>=25&&"Section"==e.tag)return!1;let o=new CustomEvent("editor:toolbar:duplicate-component",{bubbles:!0,detail:{componentUid:e.uid,isThemeSection:t}});return window.dispatchEvent(o),!1},y=t=>{t.preventDefault(),t.stopPropagation();let i=new CustomEvent("editor:toolbar:zoom-out-component",{bubbles:!0,detail:{componentUid:e.uid}});return window.dispatchEvent(i),!1},k=()=>{l(null),window.removeEventListener("editor:close-add-section-popup",k)},U=(t,i)=>{if(t.preventDefault(),t.stopPropagation(),M()>=25)return!1;let o=t.target;if(o){l(i);let t=o.getBoundingClientRect(),n=new CustomEvent("editor:toolbar:add-section",{bubbles:!0,detail:{componentUid:e.uid,position:i,top:t.top+t.height/2}});window.dispatchEvent(n),window.addEventListener("editor:close-add-section-popup",k)}return!1},O=()=>{let t=e.name&&e.name===`Section ${e.uid}`;return M()>=20?`${t?"Section":e?.name} ${Z()+1}/25`:t?`Section ${Z()+1}`:e?.name};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!("Section"==e.tag&&r)&&jsxRuntime.jsxs("div",{"data-toolbar":!0,"data-toolbar-section":"Section"==e.tag,"data-toolbar-theme-section":"Section"==e.tag&&!!t||r,"data-toolbar-limit":Z()>=25,children:[jsxRuntime.jsxs("div",{"data-toolbar-show-parent":!0,onClick:e=>B(e),"aria-hidden":"true",children:[jsxRuntime.jsx("div",{"data-toolbar-icon-drag":!0,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),"Section"==e.tag?jsxRuntime.jsx("div",{"data-toolbar-name":!0,children:O()}):jsxRuntime.jsx("div",{"data-toolbar-name":!0,children:e.customLabel||e.label}),"Section"!==e.tag&&C.length>0&&jsxRuntime.jsx("div",{"data-toolbar-icon-parent":!0,"data-toolbar-icon-parent-open":s,children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M5.65522 10C5.07265 10 4.7809 9.22865 5.19284 8.77753L7.53762 6.20974C7.79298 5.93009 8.20702 5.93009 8.46238 6.20974L10.8072 8.77754C11.2191 9.22866 10.9274 10 10.3448 10H5.65522Z",fill:"currentColor"})})})]}),s&&C.map((e,t)=>{let i=e?.childrens?.length??0,o=e.label;return"Row"===e.label&&(o=i<=1?e.label+" "+i+" col":e.label+" "+i+" cols"),jsxRuntime.jsxs("div",{"data-toolbar-parent":!0,"data-parent-uid":e.uid,"data-toolbar-theme-section":r,"data-toolbar-parent-revert":u,style:{top:u?`${36*(t+1)}px`:`${-36*(t+1)}px`},children:[jsxRuntime.jsx("div",{"data-toolbar-icon-drag":!0,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),jsxRuntime.jsx("div",{"data-toolbar-name":!0,children:o})]},e.uid)}),"Section"===e.tag&&!e.isThemeSection&&"STATIC"!==i&&"POST_PURCHASE"!==i&&25>Z()&&jsxRuntime.jsx(CreateThemeSection.CreateThemeSection,{...e}),"Sticky"==e.tag&&jsxRuntime.jsx("div",{"data-toolbar-zoom-out":!0,onClick:e=>y(e),"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5 7C14.7761 7 15 6.77614 15 6.5C15 6.22386 14.7761 6 14.5 6L10.7072 6L14.8536 1.85355C15.0489 1.65829 15.0489 1.34171 14.8536 1.14645C14.6584 0.951186 14.3418 0.951185 14.1465 1.14645L10 5.29297L10 1.5C10 1.22386 9.77614 1 9.5 1C9.22386 1 9 1.22386 9 1.5L9 6.5C9 6.77614 9.22386 7 9.5 7L14.5 7ZM6 10.7073L6 14.5C6 14.7761 6.22386 15 6.5 15C6.77614 15 7 14.7761 7 14.5L7 9.5C7 9.22386 6.77614 9 6.5 9H1.5C1.22386 9 1 9.22386 1 9.5C1 9.77614 1.22386 10 1.5 10H5.29306L1.14662 14.1464C0.951353 14.3417 0.951353 14.6583 1.14662 14.8536C1.34188 15.0488 1.65846 15.0488 1.85372 14.8536L6 10.7073Z",fill:"currentColor"})})}),jsxRuntime.jsx(Tooltip.default,{enable:"Section"==e.tag&&M()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==e.tag&&M()>=25||g,onClick:g?void 0:e=>q(e),"aria-hidden":"true",className:g?"!gp-cursor-not-allowed":"",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.08423 1.21289C5.53194 1.21289 5.08423 1.66061 5.08423 2.21289V3.78711H4.26172C3.43329 3.78711 2.76172 4.45868 2.76172 5.28711V13.2871C2.76172 14.1155 3.43329 14.7871 4.26172 14.7871H10.2617C11.0901 14.7871 11.7617 14.1155 11.7617 13.2871V12.4629H13.0842C13.6365 12.4629 14.0842 12.0152 14.0842 11.4629V2.21289C14.0842 1.66061 13.6365 1.21289 13.0842 1.21289H6.08423ZM10.7617 12.4629H6.08423C5.53194 12.4629 5.08423 12.0152 5.08423 11.4629V4.78711H4.26172C3.98558 4.78711 3.76172 5.01097 3.76172 5.28711V13.2871C3.76172 13.5633 3.98558 13.7871 4.26172 13.7871H10.2617C10.5379 13.7871 10.7617 13.5633 10.7617 13.2871V12.4629Z",fill:"currentColor"})})}),jsxRuntime.jsx(Tooltip.default,{"data-toolbar-delete":!0,onClick:e=>p?null:L(e),enable:p,"data-toolbar-disable":p,width:v.width,text:v.text,position:m,"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2.88965V2.38965C11 1.56122 10.3284 0.889648 9.5 0.889648H6.5C5.67157 0.889648 5 1.56122 5 2.38965V2.88965H2C1.72386 2.88965 1.5 3.11351 1.5 3.38965C1.5 3.66579 1.72386 3.88965 2 3.88965H3.21997V13.1099C3.21997 14.2144 4.1154 15.1099 5.21997 15.1099H11.22C12.3245 15.1099 13.22 14.2144 13.22 13.1099V3.88965H14C14.2761 3.88965 14.5 3.66579 14.5 3.38965C14.5 3.11351 14.2761 2.88965 14 2.88965H11ZM6 2.88965H10V2.38965C10 2.11351 9.77614 1.88965 9.5 1.88965H6.5C6.22386 1.88965 6 2.11351 6 2.38965V2.88965ZM6.24976 6.13965C6.66397 6.13965 6.99976 6.47543 6.99976 6.88965V11.3896C6.99976 11.8039 6.66397 12.1396 6.24976 12.1396C5.83554 12.1396 5.49976 11.8039 5.49976 11.3896V6.88965C5.49976 6.47543 5.83554 6.13965 6.24976 6.13965ZM10.4998 6.88965C10.4998 6.47543 10.164 6.13965 9.74976 6.13965C9.33554 6.13965 8.99976 6.47543 8.99976 6.88965V11.3896C8.99976 11.8039 9.33554 12.1396 9.74976 12.1396C10.164 12.1396 10.4998 11.8039 10.4998 11.3896V6.88965Z",fill:"currentColor"})})})]},e.uid),"STATIC"!==i&&"POST_PURCHASE"!==i&&25>Z()&&jsxRuntime.jsx(ThemeSectionStatus.ThemeSectionStatusWrapper,{...e}),jsxRuntime.jsx("div",{"data-outline":!0,"data-outline-section":"Section"==e.tag,"data-outline-theme-section":"Section"==e.tag&&!!t||r,"data-outline-limit":Z()>=25}),"Section"==e.tag&&!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tooltip.default,{enable:M()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":M()>=25,"data-toolbar-add-open":"above"==a,onClick:e=>U(e,"above"),"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})}),jsxRuntime.jsx(Tooltip.default,{enable:M()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":M()>=25,"data-toolbar-add-open":"below"==a,onClick:e=>U(e,"below"),"aria-hidden":"true",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})})]}),jsxRuntime.jsx(Resize.default,{...e})]})};var ComponentToolbarPreview$1=react.memo(ComponentToolbarPreview);exports.default=ComponentToolbarPreview$1;
@@ -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"),ComponentToolbarPreview=require("./ComponentToolbarPreview.js"),useApplyAnimation=require("../hooks/animation/useApplyAnimation.js");require("zustand"),require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation");var shop=require("../hooks/shop.js");require("vanilla-lazyload"),require("../hooks/useCartUI.js"),require("../helpers/convert.js");const ComponentWrapperPreview=({children:e,...t})=>{react.useEffect(()=>{let e=new CustomEvent("editor:component:render",{bubbles:!0,detail:{componentUid:t.uid}});window.dispatchEvent(e)},[t.uid]),useApplyAnimation.default({props:t});let o=shop.usePageType();if("section"===t.type)return null;let n={};if("Section"===t.tag&&t.isThemeSection&&(n["data-theme-section"]=!0),t.editorConfigs){let e=t.editorConfigs;e.placeholder?.notAppendBeforeAfter&&(n["data-placeholder-not-append-before-after"]=!0),e.placeholder?.notAppendLeftRight&&(n["data-placeholder-not-append-left-right"]=!0),e.toolbar?.parent&&(n["data-toolbar-parent"]=!0),e.component?.noDelete&&(n["data-component-no-delete"]=!0),e.component?.noDuplicate&&(n["data-component-no-duplicate"]=!0),e.component?.noDragDrop&&(n["data-component-no-drag-drop"]=!0),e.component?.noSetting&&(n["data-component-no-setting"]=!0),e.component?.isThirdParty&&(n["data-component-is-third-party"]=!0),e.toolbar?.hide&&(n["data-toolbar-hide"]=!0),e.slots?.children&&(n["data-slots-children"]=!0),e.toolbar?.hide||(n["data-toolbar-wrap"]=!0)}t?.editorConfigs?.toolbar?.hide||(n["data-toolbar-wrap"]=!0);let a=e=>"GP_FUNNEL_PAGE"===o&&["ProductList","Header"].includes(e),r=composeAdvanceStyle.composeAdvanceStyle(t.advanced,t.tag,o),s=t.advanced,i={...n,"data-uid":t.uid,"data-component-type":"component","data-component-tag":t.tag,"data-component-label":t.label,"data-not-droppable":a(t.tag)};return constant.disableWrap.includes(t.tag)&&react.isValidElement(e)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:t.uid,advanced:s}),jsxRuntime.jsxs(e.type,{className:s?.cssClass,...e.props,style:r,builderAttrs:i,advanced:s,children:[e.props.children,jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview,{...t})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:t.uid,advanced:s}),jsxRuntime.jsxs("div",{style:constant.excludeApplyStyle.includes(t.tag)?{"--mb":r?.["--mb"],"--mb-tablet":r?.["--mb-tablet"],"--mb-mobile":r?.["--mb-mobile"]}:r,className:`${t.uid} ${t.advanced?.cssClass?t.advanced?.cssClass:""}`,...i,children:[!constant.excludeApplyStyle.includes(t.tag)&&e,react.isValidElement(e)&&constant.excludeApplyStyle.includes(t.tag)&&jsxRuntime.jsx(e.type,{...e.props,style:r,advanced:s}),jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview,{...t})]})]})};exports.default=ComponentWrapperPreview;
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"),ComponentToolbarPreview=require("./ComponentToolbarPreview.js"),useApplyAnimation=require("../hooks/animation/useApplyAnimation.js");require("zustand"),require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation");var shop=require("../hooks/shop.js");require("vanilla-lazyload"),require("../hooks/useCartUI.js"),require("../helpers/convert.js");const ComponentWrapperPreview=({children:e,...t})=>{react.useEffect(()=>{let e=new CustomEvent("editor:component:render",{bubbles:!0,detail:{componentUid:t.uid}});window.dispatchEvent(e)},[t.uid]),useApplyAnimation.default({props:t});let o=shop.usePageType();if("section"===t.type)return null;let a={};if("Section"===t.tag&&t.isThemeSection&&(a["data-theme-section"]=!0),t.editorConfigs){let e=t.editorConfigs;e.placeholder?.notAppendBeforeAfter&&(a["data-placeholder-not-append-before-after"]=!0),e.placeholder?.notAppendLeftRight&&(a["data-placeholder-not-append-left-right"]=!0),e.toolbar?.parent&&(a["data-toolbar-parent"]=!0),e.component?.noDelete&&(a["data-component-no-delete"]=!0),e.component?.noDuplicate&&(a["data-component-no-duplicate"]=!0),e.component?.noDragDrop&&(a["data-component-no-drag-drop"]=!0),e.component?.noSetting&&(a["data-component-no-setting"]=!0),e.component?.isThirdParty&&(a["data-component-is-third-party"]=!0),e.toolbar?.hide&&(a["data-toolbar-hide"]=!0),e.slots?.children&&(a["data-slots-children"]=!0),e.toolbar?.hide||(a["data-toolbar-wrap"]=!0)}t?.editorConfigs?.toolbar?.hide||(a["data-toolbar-wrap"]=!0);let n=e=>"GP_FUNNEL_PAGE"===o&&["ProductList","Header"].includes(e),r=composeAdvanceStyle.composeAdvanceStyle(t.advanced,t.tag,o),s=t.advanced,d={...a,"data-uid":t.uid,"data-component-type":"component","data-component-tag":t.tag,"data-component-label":t.label,"data-not-droppable":n(t.tag)};return constant.disableWrap.includes(t.tag)&&react.isValidElement(e)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:t.uid,advanced:s}),jsxRuntime.jsxs(e.type,{className:s?.cssClass,...e.props,style:r,builderAttrs:d,advanced:s,children:[e.props.children,jsxRuntime.jsx(ComponentToolbarPreview.default,{...t})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{uid:t.uid,advanced:s}),jsxRuntime.jsxs("div",{style:constant.excludeApplyStyle.includes(t.tag)?{"--mb":r?.["--mb"],"--mb-tablet":r?.["--mb-tablet"],"--mb-mobile":r?.["--mb-mobile"]}:r,className:`${t.uid} ${t.advanced?.cssClass?t.advanced?.cssClass:""}`,...d,children:[!constant.excludeApplyStyle.includes(t.tag)&&e,react.isValidElement(e)&&constant.excludeApplyStyle.includes(t.tag)&&jsxRuntime.jsx(e.type,{...e.props,style:r,advanced:s}),jsxRuntime.jsx(ComponentToolbarPreview.default,{...t})]})]})};var ComponentWrapperPreview$1=react.memo(ComponentWrapperPreview);exports.default=ComponentWrapperPreview$1;
@@ -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),a=react.useRef(null),i=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,a=n+r>=0?`${n+r}px`:"0px";return{newValue:a}},l=e=>{if(r.current&&n.current){let{newValue:t}=s(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",l),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",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=e=>{let t=e.getAttribute("data-component-tag");return"Row"===t||"Product"===t},b=react.useCallback(()=>{let e=r.current?.closest("[data-toolbar-wrap]");if(!e)return;let t=p(e,"data-toolbar");if(!t)return;let a=t.getAttribute("data-toolbar-active");if(!a)return;let i=getComputedStyle(e),o=p(e,"data-spacing"),u=o?.querySelector("[data-spacing-margin-bottom]")||null;if(u&&n.current&&r.current){let t=i.marginBottom;if(0>parseFloat(t)&&(t="0"),n.current.style.height=t,r.current.style.top=t,u.setAttribute("data-spacing-margin-bottom-active","true"),g(e))n.current.style.left="0";else{let e=i.paddingLeft,t=`-${e}`,a=`translate(${t}, -100%)`;n.current.style.left=t,r.current.style.transform=a}}},[]);return react.useEffect(()=>{b()}),react.useEffect(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",b),window.addEventListener("editor:toolbar:update-padding-left",b),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",b),window.removeEventListener("editor:toolbar:update-padding-left",b)}),[b]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Section"!==e.tag&&jsxRuntime.jsx("div",{"data-spacing":!0,"data-spacing-theme-section":t,className:"gp-absolute gp-w-full gp-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");require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation");var shop=require("../../hooks/shop.js");function Spacing(e){let t=BuilderPreviewContext.useBuilderPreviewStore(e=>e.isThemeSectionEditor),r=shop.usePageType(),n=react.useRef(null),a=react.useRef(null),o=react.useRef(null),i=react.useRef(!1),u=react.useRef(0),s=react.useRef(0),l=e=>{let t=e.clientY,r=Math.ceil(t-u.current),n=s.current||0,a=n+r>=0?`${n+r}px`:"0px";return{newValue:a}},c=e=>{if(n.current&&a.current){let{newValue:t}=l(e);a.current.style.height=t,n.current.style.top=t;let r=n.current.closest("[data-toolbar-wrap]");r&&(r.style.marginBottom=t)}},d=()=>{p()},m=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.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",d)},100)},p=()=>{o.current&&clearTimeout(o.current),i.current=!1;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!1}});if(window.dispatchEvent(t),n.current){let t=getComputedStyle(n.current),r=t.top,a=new CustomEvent("editor:toolbar:change-margin-bottom",{bubbles:!0,detail:{componentUid:e.uid,marginBottom:r}});window.dispatchEvent(a)}let r=n.current?.closest("[data-toolbar-wrap]");r&&(r.style.marginBottom=""),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d)},g=(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}}},v=e=>{let t=e.getAttribute("data-component-tag");return"Row"===t||"Product"===t},b=react.useCallback(()=>{let e=n.current?.closest("[data-toolbar-wrap]");if(!e)return;let t=g(e,"data-toolbar");if(!t)return;let r=t.getAttribute("data-toolbar-active");if(!r)return;let o=getComputedStyle(e),i=g(e,"data-spacing"),u=i?.querySelector("[data-spacing-margin-bottom]")||null;if(u&&a.current&&n.current){let t=o.marginBottom;if(0>parseFloat(t)&&(t="0"),a.current.style.height=t,n.current.style.top=t,u.setAttribute("data-spacing-margin-bottom-active","true"),v(e))a.current.style.left="0";else{let e=o.paddingLeft,t=`-${e}`,r=`translate(${t}, -100%)`;a.current.style.left=t,n.current.style.transform=r}}},[]);return react.useEffect(()=>{b()}),react.useEffect(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",b),window.addEventListener("editor:toolbar:update-padding-left",b),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",b),window.removeEventListener("editor:toolbar:update-padding-left",b)}),[b]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Section"!==e.tag&&"POST_PURCHASE"!==r&&jsxRuntime.jsx("div",{"data-spacing":!0,"data-spacing-theme-section":t,className:"gp-absolute gp-w-full gp-bottom-0",children:jsxRuntime.jsxs("div",{"data-spacing-margin-bottom":!0,children:[jsxRuntime.jsx("div",{"data-spacing-margin-bottom-bg":!0,ref:a,children:jsxRuntime.jsx("div",{"data-spacing-margin-bottom-value":!0})}),jsxRuntime.jsx("div",{ref:n,"data-spacing-margin-bottom-drag":!0,onMouseDown:e=>{if(n.current){let t=getComputedStyle(n.current);u.current=e.clientY,s.current=parseFloat(t.top),m()}},onMouseUp:()=>{p()},role:"presentation"})]})})})}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";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),ComponentToolbarPreview=require("../components/ComponentToolbarPreview.js");const filterToolbarPreview=(e,r=!1)=>{let o=react.Children.toArray(e);return o.filter(e=>r?e?.type==ComponentToolbarPreview.ComponentToolbarPreview:e?.type!=ComponentToolbarPreview.ComponentToolbarPreview)};exports.default=filterToolbarPreview,exports.filterToolbarPreview=filterToolbarPreview;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),ComponentToolbarPreview=require("../components/ComponentToolbarPreview.js");const filterToolbarPreview=(e,r=!1)=>{let o=react.Children.toArray(e);return o.filter(e=>r?e?.type==ComponentToolbarPreview.default:e?.type!=ComponentToolbarPreview.default)};exports.default=filterToolbarPreview,exports.filterToolbarPreview=filterToolbarPreview;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),ComponentToolbarPreview=require("../components/ComponentToolbarPreview.js");const isEmptyChildren=e=>{let r=react.Children.toArray(e);return r=r.filter(e=>e?.type!=ComponentToolbarPreview.ComponentToolbarPreview),1>react.Children.count(r)||!e};exports.default=isEmptyChildren,exports.isEmptyChildren=isEmptyChildren;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),ComponentToolbarPreview=require("../components/ComponentToolbarPreview.js");const isEmptyChildren=e=>{let r=react.Children.toArray(e);return r=r.filter(e=>e?.type!=ComponentToolbarPreview.default),1>react.Children.count(r)||!e};exports.default=isEmptyChildren,exports.isEmptyChildren=isEmptyChildren;
@@ -1 +1 @@
1
- "use strict";var react=require("react"),animations=require("./animations.js");const TAGS_SELECTOR={Button:".gp-button-base",ProductButton:".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(),"shake"!==l.current&&k(),b.current&&(d.current?.cancel(),f(),b.current.finished.then(()=>{o.current&&g()}),o.current&&a?.current?.unobserve(o.current))},[k,f,g]),y=react.useCallback(()=>{g(),b.current&&b.current.cancel()},[g,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]),L=(e,r)=>e?.triggerConfig?.[r]?.animation??"none",S=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]),P=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]),A=react.useCallback(e=>{if(P(),o.current){if(!e?.enabled){g();return}l.current=L(e,"appear"),s.current=L(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?(S(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,S,T,C,R,g,P]),w=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,A(E()))});return r.observe(e),()=>r.disconnect()},[E,A]);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]??""}`),w()},100)},[w,r,t,e]),{initAnimation:A}};exports.useLivePageAnimation=useLivePageAnimation;
1
+ "use strict";var react=require("react"),animations=require("./animations.js");const TAGS_SELECTOR={Button:".gp-button-base",ProductButton:".gp-button-base",Sticky:"gp-sticky",Dialog:"div[role=dialog]",Icon:"div div",ProductTag:"div div div",Product:"product-form form 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"),d=react.useRef(null),b=react.useRef(null),p=react.useRef(null),m=react.useRef("animation-wrapper-"),f=react.useCallback(e=>{d.current&&(d.current.playbackRate=e??1,d.current.play())},[d]),v=react.useCallback(e=>{b.current&&(b.current.playbackRate=e??1,b.current.play())},[b]),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(),"shake"!==l.current&&k(),d.current&&(b.current?.cancel(),f(),d.current.finished.then(()=>{o.current&&g()}),o.current&&a?.current?.unobserve(o.current))},[k,f,g]),y=react.useCallback(()=>{g(),d.current&&d.current.cancel()},[g,d]),R=react.useCallback(e=>{e&&e.stopPropagation(),b.current&&(y(),v())},[b,y,v]),h=react.useCallback(()=>{if(b.current){if("zoom"===s.current){if(v(-1),!c)return;b.current.finished.then(()=>{clearTimeout(i.current),i.current=setTimeout(()=>{C()},100)});return}b.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]),L=(e,r)=>e?.triggerConfig?.[r]?.animation??"none",S=react.useCallback(e=>{if("none"===l.current)return;let r=e?.triggerConfig?.appear?.setting?.[l.current];u(r.loop),d.current=n?.[l.current]?.(o.current,r)},[n]),P=react.useCallback(e=>{if("none"===s.current)return;let r=e?.triggerConfig?.hover?.setting?.[s.current];b.current=n?.[s.current]?.(o.current,r)},[n]),T=react.useCallback(()=>{d.current&&(d.current=null,o.current&&a.current?.unobserve(o.current)),b&&(b.current=null,o.current&&(o.current.removeEventListener("mouseenter",R),o.current.removeEventListener("mouseleave",h)))},[h,R]),A=react.useCallback(e=>{if(T(),o.current){if(!e?.enabled){g();return}l.current=L(e,"appear"),s.current=L(e,"hover"),"none"===l.current&&g(),"none"!==s.current&&"desktop"===p.current&&(P(e),o.current.addEventListener("mouseenter",R),o.current.addEventListener("mouseleave",h)),"none"!==l.current?(S(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,S,P,C,R,g,T]),w=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,A(E()))});return r.observe(e),()=>r.disconnect()},[E,A]);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]??""}`),w()},100)},[w,r,t,e]),{initAnimation:A}};exports.useLivePageAnimation=useLivePageAnimation;
@@ -1 +1 @@
1
- "use strict";var constant=require("../components/constant.js"),ShopContext=require("../contexts/ShopContext.js");const usePostPurchase=(e,t)=>{let r=ShopContext.useShopStore(e=>e.pageType),n=(e,r)=>{let n=e||t,o=0,s=(r||document).querySelectorAll(`[data-component-tag="${n}"]`);if("PostPurchaseProductOffer"===n)return s.length;let u="";return r?s.length:(s.forEach(e=>{let t=e.closest('[data-component-tag="PostPurchaseProductOffer"]'),r=t?.getAttribute("data-uid")||"",s=e.closest('[data-component-tag="Product"]'),c=s?.querySelectorAll(`[data-component-tag="${n}"]`).length||0,a=t?r!==u?c:0:1;t&&(u=r),o+=a}),o)},o=()=>{let e=n();return e<=1},s=()=>{let t=document.querySelector(`[data-uid="${e}"]`);if(!t)return!1;for(let e of constant.postPurchaseRequiredElements){let r=n(e),o=n(e,t);if(o>0&&r-o<1)return!0}return!1},u=()=>constant.postPurchaseRequiredElements.reduce((t,r)=>{let n=document.querySelector(`[data-uid="${e}"]`);if(!n)return 0;let o=n.querySelectorAll(`[data-component-tag="${r}"]`).length;return t+o},0),c=()=>{if("POST_PURCHASE"!==r)return!1;let e=!1;return constant.postPurchaseRequiredElements.includes(t)&&(e=o())?e:!!(constant.postPurchaseWrapElements.includes(t)&&u()>0)&&s()},a=()=>{if(constant.postPurchaseRequiredElements.includes(t))return{text:"This element is required <br> and can’t be deleted",width:"175px"};{let e="Section"===t?"section":"element";return{text:`This ${e} contains required <br> elements and cannot be deleted`,width:"206px"}}};return{checkDisableDelete:c,getTooltipText:a,checkDisableDuplicate:()=>"GP_FUNNEL_PAGE"===r&&"ProductList"===t}};exports.usePostPurchase=usePostPurchase;
1
+ "use strict";var constant=require("../components/constant.js"),ShopContext=require("../contexts/ShopContext.js");const usePostPurchase=(e,t)=>{let r=ShopContext.useShopStore(e=>e.pageType),n=(e,r)=>{let n=e||t,o=0,s=(r||document).querySelectorAll(`[data-component-tag="${n}"]`);if("PostPurchaseProductOffer"===n)return s.length;let u="";return s.forEach(e=>{let t=e.closest('[data-component-tag="PostPurchaseProductOffer"]'),r=t?.getAttribute("data-uid")||"",s=e.closest('[data-component-tag="Product"]'),c=s?.querySelectorAll(`[data-component-tag="${n}"]`).length||0,a=t?r!==u?c:0:1;t&&(u=r),o+=a}),o},o=()=>{let e=n();return e<=1},s=()=>{let t=document.querySelector(`[data-uid="${e}"]`);if(!t)return!1;for(let e of constant.postPurchaseRequiredElements){let r=n(e),o=n(e,t);if(o>0&&r-o<1)return!0}return!1},u=()=>constant.postPurchaseRequiredElements.reduce((t,r)=>{let n=document.querySelector(`[data-uid="${e}"]`);if(!n)return 0;let o=n.querySelectorAll(`[data-component-tag="${r}"]`).length;return t+o},0),c=()=>{if("POST_PURCHASE"!==r)return!1;let e=!1;return constant.postPurchaseRequiredElements.includes(t)&&(e=o())?e:!!(constant.postPurchaseWrapElements.includes(t)&&u()>0)&&s()},a=()=>{if(constant.postPurchaseRequiredElements.includes(t))return{text:"This element is required <br> and can’t be deleted",width:"175px"};{let e="Section"===t?"section":"element";return{text:`This ${e} contains required <br> elements and cannot be deleted`,width:"206px"}}};return{checkDisableDelete:c,getTooltipText:a,checkDisableDuplicate:()=>"GP_FUNNEL_PAGE"===r&&"ProductList"===t}};exports.usePostPurchase=usePostPurchase;
@@ -1 +1 @@
1
- import{jsxs as t,Fragment as e,jsx as o}from"react/jsx-runtime";import{useState as i,useMemo as n,useCallback as l,useEffect as r}from"react";import"zustand";import{useBuilderPreviewStore as a}from"../contexts/BuilderPreviewContext.js";import{useShopStore as d}from"../contexts/ShopContext.js";import"@gem-sdk/adapter-shopify";import"swr";import"swr/mutation";import"vanilla-lazyload";import"../hooks/useCartUI.js";import{CreateThemeSection as C}from"./theme-section/CreateThemeSection.js";import c from"./toolbar/Tooltip.js";import{ThemeSectionStatusWrapper as s}from"./theme-section/ThemeSectionStatus.js";import{usePostPurchase as h}from"../hooks/useToolbarPostPurchase.js";import p from"./resize/Resize.js";import"../helpers/convert.js";let SECTION_LIMIT=25,notVisible=t=>{let e=getComputedStyle(t).overflow;return"visible"!==e},isSection=t=>{let e=t.getAttribute("data-component-tag");return"Section"===e},ComponentToolbarPreview=({...u})=>{let m=u.isThemeSection,b=d(t=>t.pageType),g=a(t=>t.getParents),v=a(t=>t.getItem("ROOT")),f=a(t=>t.isThemeSectionEditor),[w,S]=i(null),[H,V]=i(!1),[E,x]=i(!1),[M,T]=i([]),[Z,L]=i("top"),[P,R]=i(!0),[B,y]=i({width:"",text:""}),[j,k]=i(!0),U=n(()=>"POST_PURCHASE"===b||"GP_FUNNEL_PAGE"===b,[b]),{checkDisableDelete:I,getTooltipText:O,checkDisableDuplicate:A}=h(u.uid,u.tag||""),z=(t,e)=>{let o=M.length,i=t.getBoundingClientRect(),n=e.getBoundingClientRect();return i.top-n.top<36*o},$=(t,e)=>{let o=e||t;if(t&&!isSection(t))return notVisible(t)&&z(e,t)?t:t.parentElement?$(t.parentElement,o):void 0},_=l(t=>{let e=t.detail;if(e?.componentUid==u.uid){U&&(R(I()),y(O()),k(A()));let t=g(u.uid).filter(t=>!("ROOT"===t.uid||"Section"===t.tag&&f||t.editorConfigs?.toolbar?.hide||t.editorConfigs?.component?.noSetting)).slice(0,3);T(t)}else T([]),V(!1)},[u.uid,U,g,I,O,A,f]),D=l(()=>{if("Section"==u.tag)return"bottom";let t=document.querySelector('[data-toolbar-active="true"]');if(t){let e=t.getBoundingClientRect();e.top<60?L("bottom"):L("top")}},[u.tag]);if(r(()=>{let t=document.querySelector('[data-toolbar-delete="true"]');return t&&window.addEventListener("mouseover",D),window.addEventListener("editor:active-component",_),()=>{window.removeEventListener("editor:active-component",_),window.removeEventListener("mousemove",_)}},[D,_]),"section"===u.type||u.editorConfigs?.toolbar?.hide)return null;let N=()=>v?.childrens?.length||0,q=()=>"Section"!==u.tag?-1:v?.childrens?.length?v.childrens.findIndex(t=>t==u.uid):-1,G=t=>{if(!M.length)return;let e=t?.target||null,o=e.closest("[data-toolbar-active]");if(!e||!o)return;if(H)x(!1),V(!1);else{let t=$(o,o);if(t)x(!0);else{let t=o.getBoundingClientRect();t.top<36*M.length?x(!0):x(!1)}V(!0)}let i=new CustomEvent("editor:toolbar:show-parents",{bubbles:!0,detail:{value:!H}});window.dispatchEvent(i)},F=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:delete-component",{bubbles:!0,detail:{componentUid:u.uid,isThemeSection:m}});return window.dispatchEvent(e),!1},J=t=>{if(t.preventDefault(),t.stopPropagation(),N()>=25&&"Section"==u.tag)return!1;let e=new CustomEvent("editor:toolbar:duplicate-component",{bubbles:!0,detail:{componentUid:u.uid,isThemeSection:m}});return window.dispatchEvent(e),!1},K=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:zoom-out-component",{bubbles:!0,detail:{componentUid:u.uid}});return window.dispatchEvent(e),!1},Q=()=>{S(null),window.removeEventListener("editor:close-add-section-popup",Q)},W=(t,e)=>{if(t.preventDefault(),t.stopPropagation(),N()>=25)return!1;let o=t.target;if(o){S(e);let t=o.getBoundingClientRect(),i=new CustomEvent("editor:toolbar:add-section",{bubbles:!0,detail:{componentUid:u.uid,position:e,top:t.top+t.height/2}});window.dispatchEvent(i),window.addEventListener("editor:close-add-section-popup",Q)}return!1},X=()=>{let t=u.name&&u.name===`Section ${u.uid}`;return N()>=20?`${t?"Section":u?.name} ${q()+1}/25`:t?`Section ${q()+1}`:u?.name};return t(e,{children:[!("Section"==u.tag&&f)&&t("div",{"data-toolbar":!0,"data-toolbar-section":"Section"==u.tag,"data-toolbar-theme-section":"Section"==u.tag&&!!m||f,"data-toolbar-limit":q()>=25,children:[t("div",{"data-toolbar-show-parent":!0,onClick:t=>G(t),"aria-hidden":"true",children:[o("div",{"data-toolbar-icon-drag":!0,children:t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),o("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),o("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),o("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),o("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),o("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),"Section"==u.tag?o("div",{"data-toolbar-name":!0,children:X()}):o("div",{"data-toolbar-name":!0,children:u.customLabel||u.label}),"Section"!==u.tag&&M.length>0&&o("div",{"data-toolbar-icon-parent":!0,"data-toolbar-icon-parent-open":H,children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M5.65522 10C5.07265 10 4.7809 9.22865 5.19284 8.77753L7.53762 6.20974C7.79298 5.93009 8.20702 5.93009 8.46238 6.20974L10.8072 8.77754C11.2191 9.22866 10.9274 10 10.3448 10H5.65522Z",fill:"currentColor"})})})]}),H&&M.map((e,i)=>{let n=e?.childrens?.length??0,l=e.label;return"Row"===e.label&&(l=n<=1?e.label+" "+n+" col":e.label+" "+n+" cols"),t("div",{"data-toolbar-parent":!0,"data-parent-uid":e.uid,"data-toolbar-theme-section":f,"data-toolbar-parent-revert":E,style:{top:E?`${36*(i+1)}px`:`${-36*(i+1)}px`},children:[o("div",{"data-toolbar-icon-drag":!0,children:t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),o("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),o("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),o("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),o("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),o("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),o("div",{"data-toolbar-name":!0,children:l})]},e.uid)}),"Section"===u.tag&&!u.isThemeSection&&"STATIC"!==b&&"POST_PURCHASE"!==b&&25>q()&&o(C,{...u}),"Sticky"==u.tag&&o("div",{"data-toolbar-zoom-out":!0,onClick:t=>K(t),"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5 7C14.7761 7 15 6.77614 15 6.5C15 6.22386 14.7761 6 14.5 6L10.7072 6L14.8536 1.85355C15.0489 1.65829 15.0489 1.34171 14.8536 1.14645C14.6584 0.951186 14.3418 0.951185 14.1465 1.14645L10 5.29297L10 1.5C10 1.22386 9.77614 1 9.5 1C9.22386 1 9 1.22386 9 1.5L9 6.5C9 6.77614 9.22386 7 9.5 7L14.5 7ZM6 10.7073L6 14.5C6 14.7761 6.22386 15 6.5 15C6.77614 15 7 14.7761 7 14.5L7 9.5C7 9.22386 6.77614 9 6.5 9H1.5C1.22386 9 1 9.22386 1 9.5C1 9.77614 1.22386 10 1.5 10H5.29306L1.14662 14.1464C0.951353 14.3417 0.951353 14.6583 1.14662 14.8536C1.34188 15.0488 1.65846 15.0488 1.85372 14.8536L6 10.7073Z",fill:"currentColor"})})}),o(c,{enable:"Section"==u.tag&&N()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==u.tag&&N()>=25||j,onClick:j?void 0:t=>J(t),"aria-hidden":"true",className:j?"!gp-cursor-not-allowed":"",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.08423 1.21289C5.53194 1.21289 5.08423 1.66061 5.08423 2.21289V3.78711H4.26172C3.43329 3.78711 2.76172 4.45868 2.76172 5.28711V13.2871C2.76172 14.1155 3.43329 14.7871 4.26172 14.7871H10.2617C11.0901 14.7871 11.7617 14.1155 11.7617 13.2871V12.4629H13.0842C13.6365 12.4629 14.0842 12.0152 14.0842 11.4629V2.21289C14.0842 1.66061 13.6365 1.21289 13.0842 1.21289H6.08423ZM10.7617 12.4629H6.08423C5.53194 12.4629 5.08423 12.0152 5.08423 11.4629V4.78711H4.26172C3.98558 4.78711 3.76172 5.01097 3.76172 5.28711V13.2871C3.76172 13.5633 3.98558 13.7871 4.26172 13.7871H10.2617C10.5379 13.7871 10.7617 13.5633 10.7617 13.2871V12.4629Z",fill:"currentColor"})})}),o(c,{"data-toolbar-delete":!0,onClick:t=>P?null:F(t),enable:P,"data-toolbar-disable":P,width:B.width,text:B.text,position:Z,"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2.88965V2.38965C11 1.56122 10.3284 0.889648 9.5 0.889648H6.5C5.67157 0.889648 5 1.56122 5 2.38965V2.88965H2C1.72386 2.88965 1.5 3.11351 1.5 3.38965C1.5 3.66579 1.72386 3.88965 2 3.88965H3.21997V13.1099C3.21997 14.2144 4.1154 15.1099 5.21997 15.1099H11.22C12.3245 15.1099 13.22 14.2144 13.22 13.1099V3.88965H14C14.2761 3.88965 14.5 3.66579 14.5 3.38965C14.5 3.11351 14.2761 2.88965 14 2.88965H11ZM6 2.88965H10V2.38965C10 2.11351 9.77614 1.88965 9.5 1.88965H6.5C6.22386 1.88965 6 2.11351 6 2.38965V2.88965ZM6.24976 6.13965C6.66397 6.13965 6.99976 6.47543 6.99976 6.88965V11.3896C6.99976 11.8039 6.66397 12.1396 6.24976 12.1396C5.83554 12.1396 5.49976 11.8039 5.49976 11.3896V6.88965C5.49976 6.47543 5.83554 6.13965 6.24976 6.13965ZM10.4998 6.88965C10.4998 6.47543 10.164 6.13965 9.74976 6.13965C9.33554 6.13965 8.99976 6.47543 8.99976 6.88965V11.3896C8.99976 11.8039 9.33554 12.1396 9.74976 12.1396C10.164 12.1396 10.4998 11.8039 10.4998 11.3896V6.88965Z",fill:"currentColor"})})})]}),"STATIC"!==b&&"POST_PURCHASE"!==b&&25>q()&&o(s,{...u}),o("div",{"data-outline":!0,"data-outline-section":"Section"==u.tag,"data-outline-theme-section":"Section"==u.tag&&!!m||f,"data-outline-limit":q()>=25}),"Section"==u.tag&&!f&&t(e,{children:[o(c,{enable:N()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":N()>=25,"data-toolbar-add-open":"above"==w,onClick:t=>W(t,"above"),"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})}),o(c,{enable:N()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":N()>=25,"data-toolbar-add-open":"below"==w,onClick:t=>W(t,"below"),"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})})]}),o(p,{...u})]})};export{ComponentToolbarPreview};
1
+ import{jsxs as t,Fragment as e,jsx as o}from"react/jsx-runtime";import{memo as i,useState as n,useMemo as l,useCallback as r,useEffect as a}from"react";import"zustand";import{useBuilderPreviewStore as d}from"../contexts/BuilderPreviewContext.js";import{useShopStore as C}from"../contexts/ShopContext.js";import"@gem-sdk/adapter-shopify";import"swr";import"swr/mutation";import"vanilla-lazyload";import"../hooks/useCartUI.js";import{CreateThemeSection as c}from"./theme-section/CreateThemeSection.js";import s from"./toolbar/Tooltip.js";import{ThemeSectionStatusWrapper as h}from"./theme-section/ThemeSectionStatus.js";import{usePostPurchase as p}from"../hooks/useToolbarPostPurchase.js";import u from"./resize/Resize.js";import"../helpers/convert.js";let SECTION_LIMIT=25,notVisible=t=>{let e=getComputedStyle(t).overflow;return"visible"!==e},isSection=t=>{let e=t.getAttribute("data-component-tag");return"Section"===e},ComponentToolbarPreview=i=>{let m=i.isThemeSection,b=C(t=>t.pageType),v=d(t=>t.getParents),g=d(t=>t.getItem("ROOT")),f=d(t=>t.isThemeSectionEditor),[w,S]=n(null),[H,V]=n(!1),[E,T]=n(!1),[x,M]=n([]),[P,Z]=n("top"),[L,R]=n(!1),[B,y]=n({width:"",text:""}),[j,k]=n(!1),U=l(()=>"POST_PURCHASE"===b||"GP_FUNNEL_PAGE"===b,[b]),{checkDisableDelete:I,getTooltipText:O,checkDisableDuplicate:$}=p(i.uid,i.tag||""),A=(t,e)=>{let o=x.length,i=t.getBoundingClientRect(),n=e.getBoundingClientRect();return i.top-n.top<36*o},z=(t,e)=>{let o=e||t;if(t&&!isSection(t))return notVisible(t)&&A(e,t)?t:t.parentElement?z(t.parentElement,o):void 0},_=r(t=>{let e=t.detail;if(e?.componentUid==i.uid){U&&(R(I()),y(O()),k($()));let t=v(i.uid).filter(t=>!("ROOT"===t.uid||"Section"===t.tag&&f||t.editorConfigs?.toolbar?.hide||t.editorConfigs?.component?.noSetting)).slice(0,3);M(t)}},[i.uid,U,v,I,O,$,f]),D=r(()=>{if("Section"==i.tag)return"bottom";let t=document.querySelector('[data-toolbar-active="true"]');if(t){let e=t.getBoundingClientRect();e.top<60?Z("bottom"):Z("top")}},[i.tag]);if(a(()=>{let t=document.querySelector('[data-toolbar-delete="true"]');return t&&window.addEventListener("mouseover",D),window.addEventListener("editor:active-component",_),()=>{window.removeEventListener("editor:active-component",_),window.removeEventListener("mousemove",_)}},[D,_]),"section"===i.type||i.editorConfigs?.toolbar?.hide)return null;let N=()=>g?.childrens?.length||0,q=()=>"Section"!==i.tag?-1:g?.childrens?.length?g.childrens.findIndex(t=>t==i.uid):-1,G=t=>{if(!x.length)return;let e=t?.target||null,o=e.closest("[data-toolbar-active]");if(!e||!o)return;if(H)T(!1),V(!1);else{let t=z(o,o);if(t)T(!0);else{let t=o.getBoundingClientRect();t.top<36*x.length?T(!0):T(!1)}V(!0)}let i=new CustomEvent("editor:toolbar:show-parents",{bubbles:!0,detail:{value:!H}});window.dispatchEvent(i)},F=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:delete-component",{bubbles:!0,detail:{componentUid:i.uid,isThemeSection:m}});return window.dispatchEvent(e),!1},J=t=>{if(t.preventDefault(),t.stopPropagation(),N()>=25&&"Section"==i.tag)return!1;let e=new CustomEvent("editor:toolbar:duplicate-component",{bubbles:!0,detail:{componentUid:i.uid,isThemeSection:m}});return window.dispatchEvent(e),!1},K=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:zoom-out-component",{bubbles:!0,detail:{componentUid:i.uid}});return window.dispatchEvent(e),!1},Q=()=>{S(null),window.removeEventListener("editor:close-add-section-popup",Q)},W=(t,e)=>{if(t.preventDefault(),t.stopPropagation(),N()>=25)return!1;let o=t.target;if(o){S(e);let t=o.getBoundingClientRect(),n=new CustomEvent("editor:toolbar:add-section",{bubbles:!0,detail:{componentUid:i.uid,position:e,top:t.top+t.height/2}});window.dispatchEvent(n),window.addEventListener("editor:close-add-section-popup",Q)}return!1},X=()=>{let t=i.name&&i.name===`Section ${i.uid}`;return N()>=20?`${t?"Section":i?.name} ${q()+1}/25`:t?`Section ${q()+1}`:i?.name};return t(e,{children:[!("Section"==i.tag&&f)&&t("div",{"data-toolbar":!0,"data-toolbar-section":"Section"==i.tag,"data-toolbar-theme-section":"Section"==i.tag&&!!m||f,"data-toolbar-limit":q()>=25,children:[t("div",{"data-toolbar-show-parent":!0,onClick:t=>G(t),"aria-hidden":"true",children:[o("div",{"data-toolbar-icon-drag":!0,children:t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),o("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),o("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),o("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),o("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),o("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),"Section"==i.tag?o("div",{"data-toolbar-name":!0,children:X()}):o("div",{"data-toolbar-name":!0,children:i.customLabel||i.label}),"Section"!==i.tag&&x.length>0&&o("div",{"data-toolbar-icon-parent":!0,"data-toolbar-icon-parent-open":H,children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M5.65522 10C5.07265 10 4.7809 9.22865 5.19284 8.77753L7.53762 6.20974C7.79298 5.93009 8.20702 5.93009 8.46238 6.20974L10.8072 8.77754C11.2191 9.22866 10.9274 10 10.3448 10H5.65522Z",fill:"currentColor"})})})]}),H&&x.map((e,i)=>{let n=e?.childrens?.length??0,l=e.label;return"Row"===e.label&&(l=n<=1?e.label+" "+n+" col":e.label+" "+n+" cols"),t("div",{"data-toolbar-parent":!0,"data-parent-uid":e.uid,"data-toolbar-theme-section":f,"data-toolbar-parent-revert":E,style:{top:E?`${36*(i+1)}px`:`${-36*(i+1)}px`},children:[o("div",{"data-toolbar-icon-drag":!0,children:t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",fill:"currentColor"}),o("path",{d:"M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",fill:"currentColor"}),o("path",{d:"M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",fill:"currentColor"}),o("path",{d:"M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",fill:"currentColor"}),o("path",{d:"M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",fill:"currentColor"}),o("path",{d:"M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",fill:"currentColor"})]})}),o("div",{"data-toolbar-name":!0,children:l})]},e.uid)}),"Section"===i.tag&&!i.isThemeSection&&"STATIC"!==b&&"POST_PURCHASE"!==b&&25>q()&&o(c,{...i}),"Sticky"==i.tag&&o("div",{"data-toolbar-zoom-out":!0,onClick:t=>K(t),"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5 7C14.7761 7 15 6.77614 15 6.5C15 6.22386 14.7761 6 14.5 6L10.7072 6L14.8536 1.85355C15.0489 1.65829 15.0489 1.34171 14.8536 1.14645C14.6584 0.951186 14.3418 0.951185 14.1465 1.14645L10 5.29297L10 1.5C10 1.22386 9.77614 1 9.5 1C9.22386 1 9 1.22386 9 1.5L9 6.5C9 6.77614 9.22386 7 9.5 7L14.5 7ZM6 10.7073L6 14.5C6 14.7761 6.22386 15 6.5 15C6.77614 15 7 14.7761 7 14.5L7 9.5C7 9.22386 6.77614 9 6.5 9H1.5C1.22386 9 1 9.22386 1 9.5C1 9.77614 1.22386 10 1.5 10H5.29306L1.14662 14.1464C0.951353 14.3417 0.951353 14.6583 1.14662 14.8536C1.34188 15.0488 1.65846 15.0488 1.85372 14.8536L6 10.7073Z",fill:"currentColor"})})}),o(s,{enable:"Section"==i.tag&&N()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==i.tag&&N()>=25||j,onClick:j?void 0:t=>J(t),"aria-hidden":"true",className:j?"!gp-cursor-not-allowed":"",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.08423 1.21289C5.53194 1.21289 5.08423 1.66061 5.08423 2.21289V3.78711H4.26172C3.43329 3.78711 2.76172 4.45868 2.76172 5.28711V13.2871C2.76172 14.1155 3.43329 14.7871 4.26172 14.7871H10.2617C11.0901 14.7871 11.7617 14.1155 11.7617 13.2871V12.4629H13.0842C13.6365 12.4629 14.0842 12.0152 14.0842 11.4629V2.21289C14.0842 1.66061 13.6365 1.21289 13.0842 1.21289H6.08423ZM10.7617 12.4629H6.08423C5.53194 12.4629 5.08423 12.0152 5.08423 11.4629V4.78711H4.26172C3.98558 4.78711 3.76172 5.01097 3.76172 5.28711V13.2871C3.76172 13.5633 3.98558 13.7871 4.26172 13.7871H10.2617C10.5379 13.7871 10.7617 13.5633 10.7617 13.2871V12.4629Z",fill:"currentColor"})})}),o(s,{"data-toolbar-delete":!0,onClick:t=>L?null:F(t),enable:L,"data-toolbar-disable":L,width:B.width,text:B.text,position:P,"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2.88965V2.38965C11 1.56122 10.3284 0.889648 9.5 0.889648H6.5C5.67157 0.889648 5 1.56122 5 2.38965V2.88965H2C1.72386 2.88965 1.5 3.11351 1.5 3.38965C1.5 3.66579 1.72386 3.88965 2 3.88965H3.21997V13.1099C3.21997 14.2144 4.1154 15.1099 5.21997 15.1099H11.22C12.3245 15.1099 13.22 14.2144 13.22 13.1099V3.88965H14C14.2761 3.88965 14.5 3.66579 14.5 3.38965C14.5 3.11351 14.2761 2.88965 14 2.88965H11ZM6 2.88965H10V2.38965C10 2.11351 9.77614 1.88965 9.5 1.88965H6.5C6.22386 1.88965 6 2.11351 6 2.38965V2.88965ZM6.24976 6.13965C6.66397 6.13965 6.99976 6.47543 6.99976 6.88965V11.3896C6.99976 11.8039 6.66397 12.1396 6.24976 12.1396C5.83554 12.1396 5.49976 11.8039 5.49976 11.3896V6.88965C5.49976 6.47543 5.83554 6.13965 6.24976 6.13965ZM10.4998 6.88965C10.4998 6.47543 10.164 6.13965 9.74976 6.13965C9.33554 6.13965 8.99976 6.47543 8.99976 6.88965V11.3896C8.99976 11.8039 9.33554 12.1396 9.74976 12.1396C10.164 12.1396 10.4998 11.8039 10.4998 11.3896V6.88965Z",fill:"currentColor"})})})]},i.uid),"STATIC"!==b&&"POST_PURCHASE"!==b&&25>q()&&o(h,{...i}),o("div",{"data-outline":!0,"data-outline-section":"Section"==i.tag,"data-outline-theme-section":"Section"==i.tag&&!!m||f,"data-outline-limit":q()>=25}),"Section"==i.tag&&!f&&t(e,{children:[o(s,{enable:N()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":N()>=25,"data-toolbar-add-open":"above"==w,onClick:t=>W(t,"above"),"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})}),o(s,{enable:N()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":N()>=25,"data-toolbar-add-open":"below"==w,onClick:t=>W(t,"below"),"aria-hidden":"true",children:o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",fill:"#212121"})})})]}),o(u,{...i})]})};var ComponentToolbarPreview$1=i(ComponentToolbarPreview);export{ComponentToolbarPreview$1 as default};
@@ -1 +1 @@
1
- import{jsxs as t,Fragment as e,jsx as o}from"react/jsx-runtime";import{useEffect as a,isValidElement as n}from"react";import{composeAdvanceStyle as r}from"../helpers/compose-advance-style.js";import{disableWrap as d,excludeApplyStyle as i}from"./constant.js";import p from"./RenderCustomCode.js";import{ComponentToolbarPreview as l}from"./ComponentToolbarPreview.js";import s from"../hooks/animation/useApplyAnimation.js";import"zustand";import"swr";import"@gem-sdk/adapter-shopify";import"swr/mutation";import{usePageType as m}from"../hooks/shop.js";import"vanilla-lazyload";import"../hooks/useCartUI.js";import"../helpers/convert.js";let ComponentWrapperPreview=({children:c,...h})=>{a(()=>{let t=new CustomEvent("editor:component:render",{bubbles:!0,detail:{componentUid:h.uid}});window.dispatchEvent(t)},[h.uid]),s({props:h});let u=m();if("section"===h.type)return null;let b={};if("Section"===h.tag&&h.isThemeSection&&(b["data-theme-section"]=!0),h.editorConfigs){let t=h.editorConfigs;t.placeholder?.notAppendBeforeAfter&&(b["data-placeholder-not-append-before-after"]=!0),t.placeholder?.notAppendLeftRight&&(b["data-placeholder-not-append-left-right"]=!0),t.toolbar?.parent&&(b["data-toolbar-parent"]=!0),t.component?.noDelete&&(b["data-component-no-delete"]=!0),t.component?.noDuplicate&&(b["data-component-no-duplicate"]=!0),t.component?.noDragDrop&&(b["data-component-no-drag-drop"]=!0),t.component?.noSetting&&(b["data-component-no-setting"]=!0),t.component?.isThirdParty&&(b["data-component-is-third-party"]=!0),t.toolbar?.hide&&(b["data-toolbar-hide"]=!0),t.slots?.children&&(b["data-slots-children"]=!0),t.toolbar?.hide||(b["data-toolbar-wrap"]=!0)}h?.editorConfigs?.toolbar?.hide||(b["data-toolbar-wrap"]=!0);let f=t=>"GP_FUNNEL_PAGE"===u&&["ProductList","Header"].includes(t),g=r(h.advanced,h.tag,u),v=h.advanced,C={...b,"data-uid":h.uid,"data-component-type":"component","data-component-tag":h.tag,"data-component-label":h.label,"data-not-droppable":f(h.tag)};return d.includes(h.tag)&&n(c)?t(e,{children:[o(p,{uid:h.uid,advanced:v}),t(c.type,{className:v?.cssClass,...c.props,style:g,builderAttrs:C,advanced:v,children:[c.props.children,o(l,{...h})]})]}):t(e,{children:[o(p,{uid:h.uid,advanced:v}),t("div",{style:i.includes(h.tag)?{"--mb":g?.["--mb"],"--mb-tablet":g?.["--mb-tablet"],"--mb-mobile":g?.["--mb-mobile"]}:g,className:`${h.uid} ${h.advanced?.cssClass?h.advanced?.cssClass:""}`,...C,children:[!i.includes(h.tag)&&c,n(c)&&i.includes(h.tag)&&o(c.type,{...c.props,style:g,advanced:v}),o(l,{...h})]})]})};export{ComponentWrapperPreview as default};
1
+ import{jsxs as e,Fragment as t,jsx as o}from"react/jsx-runtime";import{memo as a,useEffect as n,isValidElement as r}from"react";import{composeAdvanceStyle as d}from"../helpers/compose-advance-style.js";import{disableWrap as p,excludeApplyStyle as i}from"./constant.js";import l from"./RenderCustomCode.js";import s from"./ComponentToolbarPreview.js";import m from"../hooks/animation/useApplyAnimation.js";import"zustand";import"swr";import"@gem-sdk/adapter-shopify";import"swr/mutation";import{usePageType as c}from"../hooks/shop.js";import"vanilla-lazyload";import"../hooks/useCartUI.js";import"../helpers/convert.js";let ComponentWrapperPreview=({children:a,...h})=>{n(()=>{let e=new CustomEvent("editor:component:render",{bubbles:!0,detail:{componentUid:h.uid}});window.dispatchEvent(e)},[h.uid]),m({props:h});let u=c();if("section"===h.type)return null;let b={};if("Section"===h.tag&&h.isThemeSection&&(b["data-theme-section"]=!0),h.editorConfigs){let e=h.editorConfigs;e.placeholder?.notAppendBeforeAfter&&(b["data-placeholder-not-append-before-after"]=!0),e.placeholder?.notAppendLeftRight&&(b["data-placeholder-not-append-left-right"]=!0),e.toolbar?.parent&&(b["data-toolbar-parent"]=!0),e.component?.noDelete&&(b["data-component-no-delete"]=!0),e.component?.noDuplicate&&(b["data-component-no-duplicate"]=!0),e.component?.noDragDrop&&(b["data-component-no-drag-drop"]=!0),e.component?.noSetting&&(b["data-component-no-setting"]=!0),e.component?.isThirdParty&&(b["data-component-is-third-party"]=!0),e.toolbar?.hide&&(b["data-toolbar-hide"]=!0),e.slots?.children&&(b["data-slots-children"]=!0),e.toolbar?.hide||(b["data-toolbar-wrap"]=!0)}h?.editorConfigs?.toolbar?.hide||(b["data-toolbar-wrap"]=!0);let f=e=>"GP_FUNNEL_PAGE"===u&&["ProductList","Header"].includes(e),g=d(h.advanced,h.tag,u),v=h.advanced,C={...b,"data-uid":h.uid,"data-component-type":"component","data-component-tag":h.tag,"data-component-label":h.label,"data-not-droppable":f(h.tag)};return p.includes(h.tag)&&r(a)?e(t,{children:[o(l,{uid:h.uid,advanced:v}),e(a.type,{className:v?.cssClass,...a.props,style:g,builderAttrs:C,advanced:v,children:[a.props.children,o(s,{...h})]})]}):e(t,{children:[o(l,{uid:h.uid,advanced:v}),e("div",{style:i.includes(h.tag)?{"--mb":g?.["--mb"],"--mb-tablet":g?.["--mb-tablet"],"--mb-mobile":g?.["--mb-mobile"]}:g,className:`${h.uid} ${h.advanced?.cssClass?h.advanced?.cssClass:""}`,...C,children:[!i.includes(h.tag)&&a,r(a)&&i.includes(h.tag)&&o(a.type,{...a.props,style:g,advanced:v}),o(s,{...h})]})]})};var ComponentWrapperPreview$1=a(ComponentWrapperPreview);export{ComponentWrapperPreview$1 as default};
@@ -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 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=t=>{let e=t.getAttribute("data-component-tag");return"Row"===e||"Product"===e},L=n(()=>{let t=d.current?.closest("[data-toolbar-wrap]");if(!t)return;let e=y(t,"data-toolbar");if(!e)return;let r=e.getAttribute("data-toolbar-active");if(!r)return;let o=getComputedStyle(t),n=y(t,"data-spacing"),a=n?.querySelector("[data-spacing-margin-bottom]")||null;if(a&&c.current&&d.current){let e=o.marginBottom;if(0>parseFloat(e)&&(e="0"),c.current.style.height=e,d.current.style.top=e,a.setAttribute("data-spacing-margin-bottom-active","true"),E(t))c.current.style.left="0";else{let t=o.paddingLeft,e=`-${t}`,r=`translate(${e}, -100%)`;c.current.style.left=e,d.current.style.transform=r}}},[]);return a(()=>{L()}),a(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",L),window.addEventListener("editor:toolbar:update-padding-left",L),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",L),window.removeEventListener("editor:toolbar:update-padding-left",L)}),[L]),t(e,{children:"Section"!==l.tag&&t("div",{"data-spacing":!0,"data-spacing-theme-section":u,className:"gp-absolute gp-w-full gp-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};
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{usePageType as l}from"../../hooks/shop.js";import"vanilla-lazyload";import"../../hooks/useCartUI.js";import"react-transition-group";import"@gem-sdk/core";import"../../helpers/convert.js";function Spacing(u){let d=i(t=>t.isThemeSectionEditor),s=l(),c=o(null),m=o(null),p=o(null),g=o(!1),b=o(0),v=o(0),f=t=>{let e=t.clientY,r=Math.ceil(e-b.current),o=v.current||0,n=o+r>=0?`${o+r}px`:"0px";return{newValue:n}},w=t=>{if(c.current&&m.current){let{newValue:e}=f(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=()=>{y()},E=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{g.current=!0;let t=new CustomEvent("editor:toolbar:resize-spacing",{bubbles:!0,detail:{value:!0}});window.dispatchEvent(t),document.addEventListener("mousemove",w),document.addEventListener("mouseup",h)},100)},y=()=>{p.current&&clearTimeout(p.current),g.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:u.uid,marginBottom:e}});window.dispatchEvent(r)}let e=c.current?.closest("[data-toolbar-wrap]");e&&(e.style.marginBottom=""),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",h)},S=(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}}},C=t=>{let e=t.getAttribute("data-component-tag");return"Row"===e||"Product"===e},L=n(()=>{let t=c.current?.closest("[data-toolbar-wrap]");if(!t)return;let e=S(t,"data-toolbar");if(!e)return;let r=e.getAttribute("data-toolbar-active");if(!r)return;let o=getComputedStyle(t),n=S(t,"data-spacing"),a=n?.querySelector("[data-spacing-margin-bottom]")||null;if(a&&m.current&&c.current){let e=o.marginBottom;if(0>parseFloat(e)&&(e="0"),m.current.style.height=e,c.current.style.top=e,a.setAttribute("data-spacing-margin-bottom-active","true"),C(t))m.current.style.left="0";else{let t=o.paddingLeft,e=`-${t}`,r=`translate(${e}, -100%)`;m.current.style.left=e,c.current.style.transform=r}}},[]);return a(()=>{L()}),a(()=>(window.addEventListener("editor:toolbar:update-margin-bottom",L),window.addEventListener("editor:toolbar:update-padding-left",L),()=>{window.removeEventListener("editor:toolbar:update-margin-bottom",L),window.removeEventListener("editor:toolbar:update-padding-left",L)}),[L]),t(e,{children:"Section"!==u.tag&&"POST_PURCHASE"!==s&&t("div",{"data-spacing":!0,"data-spacing-theme-section":d,className:"gp-absolute gp-w-full gp-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);b.current=t.clientY,v.current=parseFloat(e.top),E()}},onMouseUp:()=>{y()},role:"presentation"})]})})})}export{Spacing as default};
@@ -1 +1 @@
1
- import{Children as e}from"react";import{ComponentToolbarPreview as r}from"../components/ComponentToolbarPreview.js";let filterToolbarPreview=(o,t=!1)=>{let l=e.toArray(o);return l.filter(e=>t?e?.type==r:e?.type!=r)};export{filterToolbarPreview as default,filterToolbarPreview};
1
+ import{Children as e}from"react";import r from"../components/ComponentToolbarPreview.js";let filterToolbarPreview=(o,t=!1)=>{let l=e.toArray(o);return l.filter(e=>t?e?.type==r:e?.type!=r)};export{filterToolbarPreview as default,filterToolbarPreview};
@@ -1 +1 @@
1
- import{Children as t}from"react";import{ComponentToolbarPreview as r}from"../components/ComponentToolbarPreview.js";let isEmptyChildren=e=>{let o=t.toArray(e);return o=o.filter(t=>t?.type!=r),1>t.count(o)||!e};export{isEmptyChildren as default,isEmptyChildren};
1
+ import{Children as t}from"react";import r from"../components/ComponentToolbarPreview.js";let isEmptyChildren=e=>{let o=t.toArray(e);return o=o.filter(t=>t?.type!=r),1>t.count(o)||!e};export{isEmptyChildren as default,isEmptyChildren};
@@ -1 +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",ProductButton:".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),g=r("none"),v=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]),L=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="1")},[c]),S=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="0")},[c]),T=t(e=>{e&&e.stopPropagation(),"shake"!==g.current&&S(),b.current&&(f.current?.cancel(),k(),b.current.finished.then(()=>{m.current&&L()}),m.current&&d?.current?.unobserve(m.current))},[S,k,L]),R=t(()=>{L(),b.current&&b.current.cancel()},[L,b]),C=t(e=>{e&&e.stopPropagation(),f.current&&(R(),E())},[f,R,E]),P=t(()=>{if(f.current){if("zoom"===v.current){if(E(-1),!l)return;f.current.finished.then(()=>{clearTimeout(p.current),p.current=setTimeout(()=>{T()},100)});return}f.current.cancel(),l&&T()}},[E,l,T]),w=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]),A=(e,r)=>e?.triggerConfig?.[r]?.animation??"none",O=t(e=>{if("none"===g.current)return;let r=e?.triggerConfig?.appear?.setting?.[g.current];s(r.loop),b.current=a?.[g.current]?.(m.current,r)},[a]),B=t(e=>{if("none"===v.current)return;let r=e?.triggerConfig?.hover?.setting?.[v.current];f.current=a?.[v.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",P)))},[P,C]),q=t(e=>{if($(),m.current){if(!e?.enabled){L();return}g.current=A(e,"appear"),v.current=A(e,"hover"),"none"===g.current&&L(),"none"!==v.current&&"desktop"===y.current&&(B(e),m.current.addEventListener("mouseenter",C),m.current.addEventListener("mouseleave",P)),"none"!==g.current?(O(e),d.current=new IntersectionObserver(e=>{e.forEach(e=>{e.intersectionRatio>.1&&T()})},{root:null,rootMargin:"0px",threshold:[.1]}),d.current.observe(m.current)):L()}},[P,O,B,T,C,L,$]),x=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,q(w()))});return r.observe(e),()=>r.disconnect()},[w,q]);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]??""}`),x()},100)},[x,o,i,c]),{initAnimation:q}};export{useLivePageAnimation};
1
+ import{useState as r,useRef as e,useCallback as t,useEffect as n}from"react";import{animations as u}from"./animations.js";let TAGS_SELECTOR={Button:".gp-button-base",ProductButton:".gp-button-base",Sticky:"gp-sticky",Dialog:"div[role=dialog]",Icon:"div div",ProductTag:"div div div",Product:"product-form form div"},useLivePageAnimation=(c,o,i)=>{let a=u(),[l,s]=r(!1),d=e(void 0),p=e(void 0),m=e(null),v=e("none"),g=e("none"),b=e(null),f=e(null),y=e(null),h=e("animation-wrapper-"),k=t(r=>{b.current&&(b.current.playbackRate=r??1,b.current.play())},[b]),E=t(r=>{f.current&&(f.current.playbackRate=r??1,f.current.play())},[f]),L=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="1")},[c]),S=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="0")},[c]),T=t(r=>{r&&r.stopPropagation(),"shake"!==v.current&&S(),b.current&&(f.current?.cancel(),k(),b.current.finished.then(()=>{m.current&&L()}),m.current&&d?.current?.unobserve(m.current))},[S,k,L]),P=t(()=>{L(),b.current&&b.current.cancel()},[L,b]),R=t(r=>{r&&r.stopPropagation(),f.current&&(P(),E())},[f,P,E]),C=t(()=>{if(f.current){if("zoom"===g.current){if(E(-1),!l)return;f.current.finished.then(()=>{clearTimeout(p.current),p.current=setTimeout(()=>{T()},100)});return}f.current.cancel(),l&&T()}},[E,l,T]),w=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]),A=(r,e)=>r?.triggerConfig?.[e]?.animation??"none",O=t(r=>{if("none"===v.current)return;let e=r?.triggerConfig?.appear?.setting?.[v.current];s(e.loop),b.current=a?.[v.current]?.(m.current,e)},[a]),B=t(r=>{if("none"===g.current)return;let e=r?.triggerConfig?.hover?.setting?.[g.current];f.current=a?.[g.current]?.(m.current,e)},[a]),$=t(()=>{b.current&&(b.current=null,m.current&&d.current?.unobserve(m.current)),f&&(f.current=null,m.current&&(m.current.removeEventListener("mouseenter",R),m.current.removeEventListener("mouseleave",C)))},[C,R]),q=t(r=>{if($(),m.current){if(!r?.enabled){L();return}v.current=A(r,"appear"),g.current=A(r,"hover"),"none"===v.current&&L(),"none"!==g.current&&"desktop"===y.current&&(B(r),m.current.addEventListener("mouseenter",R),m.current.addEventListener("mouseleave",C)),"none"!==v.current?(O(r),d.current=new IntersectionObserver(r=>{r.forEach(r=>{r.intersectionRatio>.1&&T()})},{root:null,rootMargin:"0px",threshold:[.1]}),d.current.observe(m.current)):L()}},[C,O,B,T,R,L,$]),x=t(()=>{let r=document.querySelector("html");if(!m.current||!r)return;let e=new ResizeObserver(([r])=>{let e;let t=r?.target.getBoundingClientRect().width??0;e=t>=1024?"desktop":t>=768?"tablet":"mobile",y.current!==e&&(y.current=e,q(w()))});return e.observe(r),()=>e.disconnect()},[w,q]);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]??""}`),x()},100)},[x,o,i,c]),{initAnimation:q}};export{useLivePageAnimation};
@@ -1 +1 @@
1
- import{postPurchaseRequiredElements as e,postPurchaseWrapElements as t}from"../components/constant.js";import{useShopStore as r}from"../contexts/ShopContext.js";let usePostPurchase=(n,o)=>{let u=r(e=>e.pageType),l=(e,t)=>{let r=e||o,n=0,u=(t||document).querySelectorAll(`[data-component-tag="${r}"]`);if("PostPurchaseProductOffer"===r)return u.length;let l="";return t?u.length:(u.forEach(e=>{let t=e.closest('[data-component-tag="PostPurchaseProductOffer"]'),o=t?.getAttribute("data-uid")||"",u=e.closest('[data-component-tag="Product"]'),c=u?.querySelectorAll(`[data-component-tag="${r}"]`).length||0,a=t?o!==l?c:0:1;t&&(l=o),n+=a}),n)},c=()=>{let e=l();return e<=1},a=()=>{let t=document.querySelector(`[data-uid="${n}"]`);if(!t)return!1;for(let r of e){let e=l(r),n=l(r,t);if(n>0&&e-n<1)return!0}return!1},d=()=>e.reduce((e,t)=>{let r=document.querySelector(`[data-uid="${n}"]`);if(!r)return 0;let o=r.querySelectorAll(`[data-component-tag="${t}"]`).length;return e+o},0),s=()=>{if("POST_PURCHASE"!==u)return!1;let r=!1;return e.includes(o)&&(r=c())?r:!!(t.includes(o)&&d()>0)&&a()},i=()=>{if(e.includes(o))return{text:"This element is required <br> and can’t be deleted",width:"175px"};{let e="Section"===o?"section":"element";return{text:`This ${e} contains required <br> elements and cannot be deleted`,width:"206px"}}};return{checkDisableDelete:s,getTooltipText:i,checkDisableDuplicate:()=>"GP_FUNNEL_PAGE"===u&&"ProductList"===o}};export{usePostPurchase};
1
+ import{postPurchaseRequiredElements as e,postPurchaseWrapElements as t}from"../components/constant.js";import{useShopStore as r}from"../contexts/ShopContext.js";let usePostPurchase=(n,o)=>{let u=r(e=>e.pageType),c=(e,t)=>{let r=e||o,n=0,u=(t||document).querySelectorAll(`[data-component-tag="${r}"]`);if("PostPurchaseProductOffer"===r)return u.length;let c="";return u.forEach(e=>{let t=e.closest('[data-component-tag="PostPurchaseProductOffer"]'),o=t?.getAttribute("data-uid")||"",u=e.closest('[data-component-tag="Product"]'),l=u?.querySelectorAll(`[data-component-tag="${r}"]`).length||0,a=t?o!==c?l:0:1;t&&(c=o),n+=a}),n},l=()=>{let e=c();return e<=1},a=()=>{let t=document.querySelector(`[data-uid="${n}"]`);if(!t)return!1;for(let r of e){let e=c(r),n=c(r,t);if(n>0&&e-n<1)return!0}return!1},d=()=>e.reduce((e,t)=>{let r=document.querySelector(`[data-uid="${n}"]`);if(!r)return 0;let o=r.querySelectorAll(`[data-component-tag="${t}"]`).length;return e+o},0),s=()=>{if("POST_PURCHASE"!==u)return!1;let r=!1;return e.includes(o)&&(r=l())?r:!!(t.includes(o)&&d()>0)&&a()},i=()=>{if(e.includes(o))return{text:"This element is required <br> and can’t be deleted",width:"175px"};{let e="Section"===o?"section":"element";return{text:`This ${e} contains required <br> elements and cannot be deleted`,width:"206px"}}};return{checkDisableDelete:s,getTooltipText:i,checkDisableDuplicate:()=>"GP_FUNNEL_PAGE"===u&&"ProductList"===o}};export{usePostPurchase};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.14.0-dev.734",
3
+ "version": "1.14.0-dev.740",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",