@gem-sdk/core 1.14.0-dev.688 → 1.14.0-dev.692
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ComponentToolbarPreview.js +1 -1
- package/dist/cjs/graphql/fragments/custom-font.generated.js +9 -0
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +3 -0
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +3 -2
- package/dist/cjs/helpers/queries/get-products.js +1 -1
- package/dist/cjs/hooks/shop/use-products-query.js +1 -1
- package/dist/esm/components/ComponentToolbarPreview.js +1 -1
- package/dist/esm/graphql/fragments/custom-font.generated.js +9 -0
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +3 -0
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +3 -2
- package/dist/esm/helpers/queries/get-products.js +1 -1
- package/dist/esm/hooks/shop/use-products-query.js +1 -1
- package/dist/types/index.d.ts +26 -1
- package/package.json +1 -1
|
@@ -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");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),[l,a]=react.useState(null),[s,d]=react.useState(!1),[u,C]=react.useState(!1),[c,h]=react.useState([]),{isUnableDelete:x,tooltipText:m,isDisableDuplicate:p}=useToolbarPostPurchase.usePostPurchase(e.uid,e.tag||""),j=(e,t)=>{let i=c.length,o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return o.top-n.top<36*i},b=(e,t)=>{let i=t||e;if(e&&!isSection(e))return notVisible(e)&&j(t,e)?e:e.parentElement?b(e.parentElement,i):void 0},v=react.useCallback(t=>{let i=t.detail;if(i?.componentUid==e.uid){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)},[h,o,e.uid,r]);if(react.useEffect(()=>(window.addEventListener("editor:active-component",v),()=>{window.removeEventListener("editor:active-component",v)}),[v]),"section"===e.type||e.editorConfigs?.toolbar?.hide)return null;let g=()=>n?.childrens?.length||0,R=()=>"Section"!==e.tag?-1:n?.childrens?.length?n.childrens.findIndex(t=>t==e.uid):-1,S=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=b(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)},w=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},f=i=>{if(i.preventDefault(),i.stopPropagation(),g()>=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},T=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},P=()=>{a(null),window.removeEventListener("editor:close-add-section-popup",P)},H=(t,i)=>{if(t.preventDefault(),t.stopPropagation(),g()>=25)return!1;let o=t.target;if(o){a(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",P)}return!1},V=()=>{let t=e.name&&e.name===`Section ${e.uid}`;return g()>=20?`${t?"Section":e?.name} ${R()+1}/25`:t?`Section ${R()+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":R()>=25,children:[jsxRuntime.jsxs("div",{"data-toolbar-show-parent":!0,onClick:e=>S(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:V()}):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>R()&&jsxRuntime.jsx(CreateThemeSection.CreateThemeSection,{...e}),"Sticky"==e.tag&&jsxRuntime.jsx("div",{"data-toolbar-zoom-out":!0,onClick:e=>T(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&&g()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==e.tag&&g()>=25,onClick:p()?void 0:e=>f(e),"aria-hidden":"true",className:p()?"text-[#757575] !bg-transparent":"",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=>x()?null:w(e),enable:x(),"data-toolbar-disable":x(),text:m(),position:"Section"==e.tag?"bottom":"top","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>R()&&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":R()>=25}),"Section"==e.tag&&!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tooltip.default,{enable:g()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":g()>=25,"data-toolbar-add-open":"above"==l,onClick:e=>H(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:g()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":g()>=25,"data-toolbar-add-open":"below"==l,onClick:e=>H(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"})})})]})]})};exports.ComponentToolbarPreview=ComponentToolbarPreview;
|
|
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");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),[l,a]=react.useState(null),[s,d]=react.useState(!1),[u,C]=react.useState(!1),[c,h]=react.useState([]),{isUnableDelete:x,tooltipText:m,isDisableDuplicate:p}=useToolbarPostPurchase.usePostPurchase(e.uid,e.tag||""),j=(e,t)=>{let i=c.length,o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return o.top-n.top<36*i},b=(e,t)=>{let i=t||e;if(e&&!isSection(e))return notVisible(e)&&j(t,e)?e:e.parentElement?b(e.parentElement,i):void 0},v=react.useCallback(t=>{let i=t.detail;if(i?.componentUid==e.uid){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)},[h,o,e.uid,r]);if(react.useEffect(()=>(window.addEventListener("editor:active-component",v),()=>{window.removeEventListener("editor:active-component",v)}),[v]),"section"===e.type||e.editorConfigs?.toolbar?.hide)return null;let g=()=>n?.childrens?.length||0,w=()=>"Section"!==e.tag?-1:n?.childrens?.length?n.childrens.findIndex(t=>t==e.uid):-1,R=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=b(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)},S=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},f=i=>{if(i.preventDefault(),i.stopPropagation(),g()>=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},T=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},P=()=>{a(null),window.removeEventListener("editor:close-add-section-popup",P)},H=(t,i)=>{if(t.preventDefault(),t.stopPropagation(),g()>=25)return!1;let o=t.target;if(o){a(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",P)}return!1},V=()=>{let t=e.name&&e.name===`Section ${e.uid}`;return g()>=20?`${t?"Section":e?.name} ${w()+1}/25`:t?`Section ${w()+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":w()>=25,children:[jsxRuntime.jsxs("div",{"data-toolbar-show-parent":!0,onClick:e=>R(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:V()}):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>w()&&jsxRuntime.jsx(CreateThemeSection.CreateThemeSection,{...e}),"Sticky"==e.tag&&jsxRuntime.jsx("div",{"data-toolbar-zoom-out":!0,onClick:e=>T(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&&g()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==e.tag&&g()>=25,onClick:p()?void 0:e=>f(e),"aria-hidden":"true",className:p()?"text-[#757575] !bg-transparent !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=>x()?null:S(e),enable:x(),"data-toolbar-disable":x(),text:m(),position:"Section"==e.tag?"bottom":"top","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>w()&&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":w()>=25}),"Section"==e.tag&&!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tooltip.default,{enable:g()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":g()>=25,"data-toolbar-add-open":"above"==l,onClick:e=>H(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:g()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":g()>=25,"data-toolbar-add-open":"below"==l,onClick:e=>H(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"})})})]})]})};exports.ComponentToolbarPreview=ComponentToolbarPreview;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var publishedThemePage_generated=require("../fragments/published-theme-page.generated.js"),publishedPageSection_generated=require("../fragments/published-page-section.generated.js"),publishedCustomSection_generated=require("../fragments/published-custom-section.generated.js"),dataSeo_generated=require("../fragments/data-seo.generated.js"),publishedThemeStyle_generated=require("../fragments/published-theme-style.generated.js"),analytic_generated=require("../fragments/analytic.generated.js"),customCode_generated=require("../fragments/custom-code.generated.js");const PublishedThemePagesDocument=`
|
|
1
|
+
"use strict";var publishedThemePage_generated=require("../fragments/published-theme-page.generated.js"),publishedPageSection_generated=require("../fragments/published-page-section.generated.js"),publishedCustomSection_generated=require("../fragments/published-custom-section.generated.js"),dataSeo_generated=require("../fragments/data-seo.generated.js"),publishedThemeStyle_generated=require("../fragments/published-theme-style.generated.js"),analytic_generated=require("../fragments/analytic.generated.js"),customCode_generated=require("../fragments/custom-code.generated.js"),customFont_generated=require("../fragments/custom-font.generated.js");const PublishedThemePagesDocument=`
|
|
2
2
|
query publishedThemePages($slug: String, $slugType: PublishedThemePageType!) {
|
|
3
3
|
publishedThemePages(slug: $slug, slugType: $slugType) {
|
|
4
4
|
...PublishedThemePageSelect
|
|
@@ -10,4 +10,5 @@ ${publishedCustomSection_generated.PublishedCustomSectionSelect}
|
|
|
10
10
|
${dataSeo_generated.DataSeoSelect}
|
|
11
11
|
${publishedThemeStyle_generated.PublishedThemeStyleSelect}
|
|
12
12
|
${analytic_generated.AnalyticSelect}
|
|
13
|
-
${customCode_generated.CustomCodeSelect}
|
|
13
|
+
${customCode_generated.CustomCodeSelect}
|
|
14
|
+
${customFont_generated.CustomFontSelect}`;exports.PublishedThemePagesDocument=PublishedThemePagesDocument;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var products_generated=require("../../graphql/queries/products.generated.js"),getCollection=require("./get-collection.js"),getProduct=require("./get-product.js");const getProducts=async(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s})=>{let
|
|
1
|
+
"use strict";var products_generated=require("../../graphql/queries/products.generated.js"),getCollection=require("./get-collection.js"),getProduct=require("./get-product.js");const getProducts=async(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s,allStatus:o})=>{let a=await loopFetchProducts(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s,allStatus:o});if(!a)throw Error("Product not found");let[c,n]=await Promise.all([mergeVariantsToProducts({fetcher:e,products:a,isSample:r,isStorefront:d}),mergeMediasToProducts({fetcher:e,products:a,isSample:r,isStorefront:d})]);return{...a,products:{...a.products,edges:a.products?.edges.map(e=>{let t=n.find(t=>t.productId===e.node?.baseID),r=c.find(t=>t.productId===e.node?.baseID);return e.node?{...e,node:{...e.node,variants:{...e.node?.variants,edges:r?.items??[]},medias:{...e.node?.medias,edges:t?.items??[]}}}:e})??[]}}},fetchProducts=async(e,t)=>e([products_generated.ProductsDocument,t]),loopFetchProducts=async(e,{ids:t,isSample:r,isStorefront:d,defaultSelectedProductCount:s,allStatus:o})=>{let a,c,n,u,i;let g=s||4,l=(t?.length==0?g:t?.length)??g,p=1,P=Math.ceil(l/8);for(;p<=P&&!1!==u;){let s=o?{}:{status:"ACTIVE"};a={first:getCollection.calculateFirstProduct(l,p,8),firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{...s,isSample:r,...d&&{isStorefront:d},...t?.length?{baseIDIn:t}:{}},after:c};let g=await fetchProducts(e,a);if(c=g?.products?.pageInfo?.endCursor,1===p?(n=g,i=g):i?.products&&g?.products?.edges.length&&(i.products={edges:i.products.edges.concat(g?.products?.edges),pageInfo:g?.products?.pageInfo}),p++,!i){u=!1;break}}return n},mergeVariantsToProducts=async({fetcher:e,products:t,isSample:r,isStorefront:d})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await getProduct.fetchVariants(e,{id:t?.node?.baseID,isSample:r,isStorefront:d});return{productId:t?.node?.baseID,items:s}})??[]);return s},mergeMediasToProducts=async({fetcher:e,products:t,isSample:r,isStorefront:d})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await getProduct.fetchMedias(e,{id:t?.node?.baseID,isSample:r,isStorefront:d});return{productId:t?.node?.baseID,items:s}})??[]);return s};exports.getProducts=getProducts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var useSWR=require("swr"),getProducts=require("../../helpers/queries/get-products.js"),query=require("../../helpers/query.js"),shop=require("../shop.js"),useFetchHandle=require("../useFetchHandle.js");const useProductsQuery=(e,r
|
|
1
|
+
"use strict";var useSWR=require("swr"),getProducts=require("../../helpers/queries/get-products.js"),query=require("../../helpers/query.js"),shop=require("../shop.js"),useFetchHandle=require("../useFetchHandle.js");const useProductsQuery=(e,u,r)=>{let s=useFetchHandle.useFetchHandle(),t=shop.useIsSampleProduct(),o=shop.useIsStorefrontProduct();return useSWR(e?query.generateProductsQueryKey({ids:e,isSample:t,isStorefront:o,defaultSelectedProductCount:r?.defaultSelectedProductCount,allStatus:r?.allStatus}):null,async([,e])=>getProducts.getProducts(s,e),u)};exports.useProductsQuery=useProductsQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,Fragment as e,jsx as o}from"react/jsx-runtime";import{useState as i,useCallback as n,useEffect as l}from"react";import"zustand";import{useBuilderPreviewStore as a}from"../contexts/BuilderPreviewContext.js";import{useShopStore as r}from"../contexts/ShopContext.js";import"@gem-sdk/adapter-shopify";import"swr";import"swr/mutation";import"vanilla-lazyload";import"../hooks/useCartUI.js";import{CreateThemeSection as d}from"./theme-section/CreateThemeSection.js";import C from"./toolbar/Tooltip.js";import{ThemeSectionStatusWrapper as c}from"./theme-section/ThemeSectionStatus.js";import{usePostPurchase as h}from"../hooks/useToolbarPostPurchase.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=({...s})=>{let p=s.isThemeSection,u=r(t=>t.pageType),m=a(t=>t.getParents),b=a(t=>t.getItem("ROOT")),g=a(t=>t.isThemeSectionEditor),[v,f]=i(null),[w,S]=i(!1),[H,V]=i(!1),[M,x]=i([]),{isUnableDelete:Z,tooltipText:T,isDisableDuplicate:E}=h(s.uid,s.tag||""),L=(t,e)=>{let o=M.length,i=t.getBoundingClientRect(),n=e.getBoundingClientRect();return i.top-n.top<36*o},P=(t,e)=>{let o=e||t;if(t&&!isSection(t))return notVisible(t)&&L(e,t)?t:t.parentElement?P(t.parentElement,o):void 0},R=n(t=>{let e=t.detail;if(e?.componentUid==s.uid){let t=m(s.uid).filter(t=>!("ROOT"===t.uid||"Section"===t.tag&&g||t.editorConfigs?.toolbar?.hide||t.editorConfigs?.component?.noSetting)).slice(0,3);x(t)}else x([]),S(!1)},[x,m,s.uid,g]);if(l(()=>(window.addEventListener("editor:active-component",R),()=>{window.removeEventListener("editor:active-component",R)}),[R]),"section"===s.type||s.editorConfigs?.toolbar?.hide)return null;let B=()=>b?.childrens?.length||0,k=()=>"Section"!==s.tag?-1:b?.childrens?.length?b.childrens.findIndex(t=>t==s.uid):-1,y=t=>{if(!M.length)return;let e=t?.target||null,o=e.closest("[data-toolbar-active]");if(!e||!o)return;if(w)V(!1),S(!1);else{let t=P(o,o);if(t)V(!0);else{let t=o.getBoundingClientRect();t.top<36*M.length?V(!0):V(!1)}S(!0)}let i=new CustomEvent("editor:toolbar:show-parents",{bubbles:!0,detail:{value:!w}});window.dispatchEvent(i)},j=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:delete-component",{bubbles:!0,detail:{componentUid:s.uid,isThemeSection:p}});return window.dispatchEvent(e),!1},I=t=>{if(t.preventDefault(),t.stopPropagation(),B()>=25&&"Section"==s.tag)return!1;let e=new CustomEvent("editor:toolbar:duplicate-component",{bubbles:!0,detail:{componentUid:s.uid,isThemeSection:p}});return window.dispatchEvent(e),!1},U=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:zoom-out-component",{bubbles:!0,detail:{componentUid:s.uid}});return window.dispatchEvent(e),!1},O=()=>{f(null),window.removeEventListener("editor:close-add-section-popup",O)},$=(t,e)=>{if(t.preventDefault(),t.stopPropagation(),B()>=25)return!1;let o=t.target;if(o){f(e);let t=o.getBoundingClientRect(),i=new CustomEvent("editor:toolbar:add-section",{bubbles:!0,detail:{componentUid:s.uid,position:e,top:t.top+t.height/2}});window.dispatchEvent(i),window.addEventListener("editor:close-add-section-popup",O)}return!1},A=()=>{let t=s.name&&s.name===`Section ${s.uid}`;return B()>=20?`${t?"Section":s?.name} ${k()+1}/25`:t?`Section ${k()+1}`:s?.name};return t(e,{children:[!("Section"==s.tag&&g)&&t("div",{"data-toolbar":!0,"data-toolbar-section":"Section"==s.tag,"data-toolbar-theme-section":"Section"==s.tag&&!!p||g,"data-toolbar-limit":k()>=25,children:[t("div",{"data-toolbar-show-parent":!0,onClick:t=>y(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"==s.tag?o("div",{"data-toolbar-name":!0,children:A()}):o("div",{"data-toolbar-name":!0,children:s.customLabel||s.label}),"Section"!==s.tag&&M.length>0&&o("div",{"data-toolbar-icon-parent":!0,"data-toolbar-icon-parent-open":w,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"})})})]}),w&&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":g,"data-toolbar-parent-revert":H,style:{top:H?`${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"===s.tag&&!s.isThemeSection&&"STATIC"!==u&&"POST_PURCHASE"!==u&&25>k()&&o(d,{...s}),"Sticky"==s.tag&&o("div",{"data-toolbar-zoom-out":!0,onClick:t=>U(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"==s.tag&&B()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==s.tag&&B()>=25,onClick:E()?void 0:t=>I(t),"aria-hidden":"true",className:E()?"text-[#757575] !bg-transparent":"",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=>Z()?null:j(t),enable:Z(),"data-toolbar-disable":Z(),text:T(),position:"Section"==s.tag?"bottom":"top","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"!==u&&"POST_PURCHASE"!==u&&25>k()&&o(c,{...s}),o("div",{"data-outline":!0,"data-outline-section":"Section"==s.tag,"data-outline-theme-section":"Section"==s.tag&&!!p||g,"data-outline-limit":k()>=25}),"Section"==s.tag&&!g&&t(e,{children:[o(C,{enable:B()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":B()>=25,"data-toolbar-add-open":"above"==v,onClick:t=>$(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:B()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":B()>=25,"data-toolbar-add-open":"below"==v,onClick:t=>$(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"})})})]})]})};export{ComponentToolbarPreview};
|
|
1
|
+
import{jsxs as t,Fragment as e,jsx as o}from"react/jsx-runtime";import{useState as i,useCallback as n,useEffect as l}from"react";import"zustand";import{useBuilderPreviewStore as a}from"../contexts/BuilderPreviewContext.js";import{useShopStore as r}from"../contexts/ShopContext.js";import"@gem-sdk/adapter-shopify";import"swr";import"swr/mutation";import"vanilla-lazyload";import"../hooks/useCartUI.js";import{CreateThemeSection as d}from"./theme-section/CreateThemeSection.js";import C from"./toolbar/Tooltip.js";import{ThemeSectionStatusWrapper as c}from"./theme-section/ThemeSectionStatus.js";import{usePostPurchase as h}from"../hooks/useToolbarPostPurchase.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=({...s})=>{let p=s.isThemeSection,u=r(t=>t.pageType),m=a(t=>t.getParents),b=a(t=>t.getItem("ROOT")),g=a(t=>t.isThemeSectionEditor),[v,f]=i(null),[w,S]=i(!1),[H,V]=i(!1),[M,x]=i([]),{isUnableDelete:Z,tooltipText:T,isDisableDuplicate:E}=h(s.uid,s.tag||""),L=(t,e)=>{let o=M.length,i=t.getBoundingClientRect(),n=e.getBoundingClientRect();return i.top-n.top<36*o},P=(t,e)=>{let o=e||t;if(t&&!isSection(t))return notVisible(t)&&L(e,t)?t:t.parentElement?P(t.parentElement,o):void 0},R=n(t=>{let e=t.detail;if(e?.componentUid==s.uid){let t=m(s.uid).filter(t=>!("ROOT"===t.uid||"Section"===t.tag&&g||t.editorConfigs?.toolbar?.hide||t.editorConfigs?.component?.noSetting)).slice(0,3);x(t)}else x([]),S(!1)},[x,m,s.uid,g]);if(l(()=>(window.addEventListener("editor:active-component",R),()=>{window.removeEventListener("editor:active-component",R)}),[R]),"section"===s.type||s.editorConfigs?.toolbar?.hide)return null;let B=()=>b?.childrens?.length||0,k=()=>"Section"!==s.tag?-1:b?.childrens?.length?b.childrens.findIndex(t=>t==s.uid):-1,y=t=>{if(!M.length)return;let e=t?.target||null,o=e.closest("[data-toolbar-active]");if(!e||!o)return;if(w)V(!1),S(!1);else{let t=P(o,o);if(t)V(!0);else{let t=o.getBoundingClientRect();t.top<36*M.length?V(!0):V(!1)}S(!0)}let i=new CustomEvent("editor:toolbar:show-parents",{bubbles:!0,detail:{value:!w}});window.dispatchEvent(i)},j=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:delete-component",{bubbles:!0,detail:{componentUid:s.uid,isThemeSection:p}});return window.dispatchEvent(e),!1},I=t=>{if(t.preventDefault(),t.stopPropagation(),B()>=25&&"Section"==s.tag)return!1;let e=new CustomEvent("editor:toolbar:duplicate-component",{bubbles:!0,detail:{componentUid:s.uid,isThemeSection:p}});return window.dispatchEvent(e),!1},U=t=>{t.preventDefault(),t.stopPropagation();let e=new CustomEvent("editor:toolbar:zoom-out-component",{bubbles:!0,detail:{componentUid:s.uid}});return window.dispatchEvent(e),!1},O=()=>{f(null),window.removeEventListener("editor:close-add-section-popup",O)},$=(t,e)=>{if(t.preventDefault(),t.stopPropagation(),B()>=25)return!1;let o=t.target;if(o){f(e);let t=o.getBoundingClientRect(),i=new CustomEvent("editor:toolbar:add-section",{bubbles:!0,detail:{componentUid:s.uid,position:e,top:t.top+t.height/2}});window.dispatchEvent(i),window.addEventListener("editor:close-add-section-popup",O)}return!1},A=()=>{let t=s.name&&s.name===`Section ${s.uid}`;return B()>=20?`${t?"Section":s?.name} ${k()+1}/25`:t?`Section ${k()+1}`:s?.name};return t(e,{children:[!("Section"==s.tag&&g)&&t("div",{"data-toolbar":!0,"data-toolbar-section":"Section"==s.tag,"data-toolbar-theme-section":"Section"==s.tag&&!!p||g,"data-toolbar-limit":k()>=25,children:[t("div",{"data-toolbar-show-parent":!0,onClick:t=>y(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"==s.tag?o("div",{"data-toolbar-name":!0,children:A()}):o("div",{"data-toolbar-name":!0,children:s.customLabel||s.label}),"Section"!==s.tag&&M.length>0&&o("div",{"data-toolbar-icon-parent":!0,"data-toolbar-icon-parent-open":w,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"})})})]}),w&&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":g,"data-toolbar-parent-revert":H,style:{top:H?`${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"===s.tag&&!s.isThemeSection&&"STATIC"!==u&&"POST_PURCHASE"!==u&&25>k()&&o(d,{...s}),"Sticky"==s.tag&&o("div",{"data-toolbar-zoom-out":!0,onClick:t=>U(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"==s.tag&&B()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"bottom","data-toolbar-duplicate":!0,"data-toolbar-disable":"Section"==s.tag&&B()>=25,onClick:E()?void 0:t=>I(t),"aria-hidden":"true",className:E()?"text-[#757575] !bg-transparent !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=>Z()?null:j(t),enable:Z(),"data-toolbar-disable":Z(),text:T(),position:"Section"==s.tag?"bottom":"top","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"!==u&&"POST_PURCHASE"!==u&&25>k()&&o(c,{...s}),o("div",{"data-outline":!0,"data-outline-section":"Section"==s.tag,"data-outline-theme-section":"Section"==s.tag&&!!p||g,"data-outline-limit":k()>=25}),"Section"==s.tag&&!g&&t(e,{children:[o(C,{enable:B()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-top":!0,"data-toolbar-disable":B()>=25,"data-toolbar-add-open":"above"==v,onClick:t=>$(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:B()>=25,text:"Page has reached Shopify’s 25 section-limit",position:"top","data-toolbar-add-bottom":!0,"data-toolbar-disable":B()>=25,"data-toolbar-add-open":"below"==v,onClick:t=>$(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"})})})]})]})};export{ComponentToolbarPreview};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{PublishedThemePageSelect as e}from"../fragments/published-theme-page.generated.js";import{PublishedPageSectionSelect as s}from"../fragments/published-page-section.generated.js";import{PublishedCustomSectionSelect as t}from"../fragments/published-custom-section.generated.js";import{DataSeoSelect as m}from"../fragments/data-seo.generated.js";import{PublishedThemeStyleSelect as r}from"../fragments/published-theme-style.generated.js";import{AnalyticSelect as g}from"../fragments/analytic.generated.js";import{CustomCodeSelect as a}from"../fragments/custom-code.generated.js";let PublishedThemePagesDocument=`
|
|
1
|
+
import{PublishedThemePageSelect as e}from"../fragments/published-theme-page.generated.js";import{PublishedPageSectionSelect as s}from"../fragments/published-page-section.generated.js";import{PublishedCustomSectionSelect as t}from"../fragments/published-custom-section.generated.js";import{DataSeoSelect as m}from"../fragments/data-seo.generated.js";import{PublishedThemeStyleSelect as r}from"../fragments/published-theme-style.generated.js";import{AnalyticSelect as g}from"../fragments/analytic.generated.js";import{CustomCodeSelect as a}from"../fragments/custom-code.generated.js";import{CustomFontSelect as o}from"../fragments/custom-font.generated.js";let PublishedThemePagesDocument=`
|
|
2
2
|
query publishedThemePages($slug: String, $slugType: PublishedThemePageType!) {
|
|
3
3
|
publishedThemePages(slug: $slug, slugType: $slugType) {
|
|
4
4
|
...PublishedThemePageSelect
|
|
@@ -10,4 +10,5 @@ ${t}
|
|
|
10
10
|
${m}
|
|
11
11
|
${r}
|
|
12
12
|
${g}
|
|
13
|
-
${a}
|
|
13
|
+
${a}
|
|
14
|
+
${o}`;export{PublishedThemePagesDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ProductsDocument as e}from"../../graphql/queries/products.generated.js";import{calculateFirstProduct as t}from"./get-collection.js";import{fetchVariants as r,fetchMedias as o}from"./get-product.js";let getProducts=async(e,{ids:t,isSample:r,isStorefront:o,defaultSelectedProductCount:d})=>{let
|
|
1
|
+
import{ProductsDocument as e}from"../../graphql/queries/products.generated.js";import{calculateFirstProduct as t}from"./get-collection.js";import{fetchVariants as r,fetchMedias as o}from"./get-product.js";let getProducts=async(e,{ids:t,isSample:r,isStorefront:o,defaultSelectedProductCount:d,allStatus:s})=>{let a=await loopFetchProducts(e,{ids:t,isSample:r,isStorefront:o,defaultSelectedProductCount:d,allStatus:s});if(!a)throw Error("Product not found");let[n,c]=await Promise.all([mergeVariantsToProducts({fetcher:e,products:a,isSample:r,isStorefront:o}),mergeMediasToProducts({fetcher:e,products:a,isSample:r,isStorefront:o})]);return{...a,products:{...a.products,edges:a.products?.edges.map(e=>{let t=c.find(t=>t.productId===e.node?.baseID),r=n.find(t=>t.productId===e.node?.baseID);return e.node?{...e,node:{...e.node,variants:{...e.node?.variants,edges:r?.items??[]},medias:{...e.node?.medias,edges:t?.items??[]}}}:e})??[]}}},fetchProducts=async(t,r)=>t([e,r]),loopFetchProducts=async(e,{ids:r,isSample:o,isStorefront:d,defaultSelectedProductCount:s,allStatus:a})=>{let n,c,i,u,p;let l=s||4,g=(r?.length==0?l:r?.length)??l,m=1,f=Math.ceil(g/8);for(;m<=f&&!1!==u;){let s=a?{}:{status:"ACTIVE"};n={first:t(g,m,8),firstMedia:1,firstVariant:1,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},where:{...s,isSample:o,...d&&{isStorefront:d},...r?.length?{baseIDIn:r}:{}},after:c};let l=await fetchProducts(e,n);if(c=l?.products?.pageInfo?.endCursor,1===m?(i=l,p=l):p?.products&&l?.products?.edges.length&&(p.products={edges:p.products.edges.concat(l?.products?.edges),pageInfo:l?.products?.pageInfo}),m++,!p){u=!1;break}}return i},mergeVariantsToProducts=async({fetcher:e,products:t,isSample:o,isStorefront:d})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await r(e,{id:t?.node?.baseID,isSample:o,isStorefront:d});return{productId:t?.node?.baseID,items:s}})??[]);return s},mergeMediasToProducts=async({fetcher:e,products:t,isSample:r,isStorefront:d})=>{let s=await Promise.all(t?.products?.edges?.map(async t=>{let s=await o(e,{id:t?.node?.baseID,isSample:r,isStorefront:d});return{productId:t?.node?.baseID,items:s}})??[]);return s};export{getProducts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"swr";import{getProducts as t}from"../../helpers/queries/get-products.js";import{generateProductsQueryKey as r}from"../../helpers/query.js";import{useIsSampleProduct as u,useIsStorefrontProduct as o}from"../shop.js";import{useFetchHandle as s}from"../useFetchHandle.js";let useProductsQuery=(l,d,m)=>{let p=s(),c=u(),a=o();return e(l?r({ids:l,isSample:c,isStorefront:a,defaultSelectedProductCount:m?.defaultSelectedProductCount,allStatus:m?.allStatus}):null,async([,e])=>t(p,e),d)};export{useProductsQuery};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1233,6 +1233,19 @@ type CustomCode = {
|
|
|
1233
1233
|
body?: Maybe<Scalars$1['String']>;
|
|
1234
1234
|
header?: Maybe<Scalars$1['String']>;
|
|
1235
1235
|
};
|
|
1236
|
+
type CustomFont = {
|
|
1237
|
+
backupFileKey?: Maybe<Scalars$1['String']>;
|
|
1238
|
+
backupFilePath?: Maybe<Scalars$1['String']>;
|
|
1239
|
+
fileKey: Scalars$1['String'];
|
|
1240
|
+
filePath: Scalars$1['String'];
|
|
1241
|
+
fontFamily: Scalars$1['String'];
|
|
1242
|
+
fontStyle?: Maybe<Scalars$1['String']>;
|
|
1243
|
+
fontWeight?: Maybe<Scalars$1['String']>;
|
|
1244
|
+
id: Scalars$1['ID'];
|
|
1245
|
+
mimeType: Scalars$1['String'];
|
|
1246
|
+
shopID: Scalars$1['String'];
|
|
1247
|
+
size: Scalars$1['String'];
|
|
1248
|
+
};
|
|
1236
1249
|
type Customer = {
|
|
1237
1250
|
acceptsMarketing?: Maybe<Scalars$1['Boolean']>;
|
|
1238
1251
|
acceptsMarketingUpdatedAt?: Maybe<Scalars$1['Time']>;
|
|
@@ -5743,6 +5756,7 @@ type shop_CollectionProductsArgs = CollectionProductsArgs;
|
|
|
5743
5756
|
type shop_CollectionTagWhereInput = CollectionTagWhereInput;
|
|
5744
5757
|
type shop_CollectionWhereInput = CollectionWhereInput;
|
|
5745
5758
|
type shop_CustomCode = CustomCode;
|
|
5759
|
+
type shop_CustomFont = CustomFont;
|
|
5746
5760
|
type shop_Customer = Customer;
|
|
5747
5761
|
type shop_CustomerAddress = CustomerAddress;
|
|
5748
5762
|
type shop_CustomerAddressPlatform = CustomerAddressPlatform;
|
|
@@ -5937,6 +5951,7 @@ declare namespace shop {
|
|
|
5937
5951
|
shop_CollectionTagWhereInput as CollectionTagWhereInput,
|
|
5938
5952
|
shop_CollectionWhereInput as CollectionWhereInput,
|
|
5939
5953
|
shop_CustomCode as CustomCode,
|
|
5954
|
+
shop_CustomFont as CustomFont,
|
|
5940
5955
|
shop_Customer as Customer,
|
|
5941
5956
|
shop_CustomerAddress as CustomerAddress,
|
|
5942
5957
|
shop_CustomerAddressPlatform as CustomerAddressPlatform,
|
|
@@ -6716,6 +6731,11 @@ type TextareaControlType<T> = SharedControlType<T> & {
|
|
|
6716
6731
|
minHeight?: number;
|
|
6717
6732
|
maxWidth?: number;
|
|
6718
6733
|
autoHeight?: boolean;
|
|
6734
|
+
suggestContents?: {
|
|
6735
|
+
message: string;
|
|
6736
|
+
eg?: string;
|
|
6737
|
+
isStrike?: boolean;
|
|
6738
|
+
}[];
|
|
6719
6739
|
};
|
|
6720
6740
|
|
|
6721
6741
|
type TextEditorControlType<T> = SharedControlType<T> & {
|
|
@@ -8185,6 +8205,7 @@ type PublishedThemePagesQueryResponse = {
|
|
|
8185
8205
|
pageStyle?: Maybe<Pick<PublishedThemeStyle, 'id' | 'data' | 'name'>>;
|
|
8186
8206
|
themePageAnalytic?: Maybe<Pick<Analytic, 'fbPixelID' | 'gaTrackingID' | 'tiktokPixelID'>>;
|
|
8187
8207
|
themePageCustomCode?: Maybe<Pick<CustomCode, 'body' | 'header'>>;
|
|
8208
|
+
themePageCustomFonts?: Maybe<Array<Maybe<CustomFont>>>;
|
|
8188
8209
|
}>>>;
|
|
8189
8210
|
};
|
|
8190
8211
|
declare const PublishedThemePagesDocument: string;
|
|
@@ -10071,6 +10092,7 @@ type FetchProductsParams = {
|
|
|
10071
10092
|
isSample?: boolean;
|
|
10072
10093
|
isStorefront?: boolean;
|
|
10073
10094
|
defaultSelectedProductCount?: number;
|
|
10095
|
+
allStatus?: boolean;
|
|
10074
10096
|
};
|
|
10075
10097
|
|
|
10076
10098
|
declare const generateProductQueryKey: (args: FetchProductParams) => ['query/product', FetchProductParams];
|
|
@@ -16157,7 +16179,10 @@ declare const useCollectionsQuery: (variable: CollectionsQueryVariables, options
|
|
|
16157
16179
|
|
|
16158
16180
|
declare const useProductQuery: (productId?: string, options?: SWRConfiguration<ProductSelectFragment>) => swr__internal.SWRResponse<ProductSelectFragment, any, Partial<swr__internal.PublicConfiguration<ProductSelectFragment, any, (arg: ["query/product", FetchProductParams]) => swr__internal.FetcherResponse<ProductSelectFragment>>> | undefined>;
|
|
16159
16181
|
|
|
16160
|
-
declare const useProductsQuery: (ids?: string[], options?: SWRConfiguration<ProductsQueryResponse>,
|
|
16182
|
+
declare const useProductsQuery: (ids?: string[], options?: SWRConfiguration<ProductsQueryResponse>, params?: {
|
|
16183
|
+
defaultSelectedProductCount?: number;
|
|
16184
|
+
allStatus?: boolean;
|
|
16185
|
+
}) => swr__internal.SWRResponse<ProductsQueryResponse, any, Partial<swr__internal.PublicConfiguration<ProductsQueryResponse, any, (arg: ["query/products", FetchProductsParams]) => swr__internal.FetcherResponse<ProductsQueryResponse>>> | undefined>;
|
|
16161
16186
|
|
|
16162
16187
|
declare const useCurrentDevice: () => NameDevices$1;
|
|
16163
16188
|
|