@gem-sdk/components 23.0.0-staging.21 → 23.0.0-staging.23

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.
Files changed (35) hide show
  1. package/dist/cjs/article/components/ArticleList.js +1 -1
  2. package/dist/cjs/common/components/Loading.js +1 -1
  3. package/dist/cjs/common/const.js +1 -1
  4. package/dist/cjs/common/helpers.js +1 -0
  5. package/dist/cjs/common/hooks/useElementWidth.js +1 -0
  6. package/dist/cjs/common/hooks/useLoadingProgress.js +1 -0
  7. package/dist/cjs/grid/components/section/Section.js +1 -1
  8. package/dist/cjs/post-purchase/product/components/product-offer/components/ProductOffer.js +1 -1
  9. package/dist/cjs/post-purchase/product/components/product-offer/helpers/getOfferErrorText.js +1 -0
  10. package/dist/cjs/post-purchase/product/components/product-offer/hooks/useProductOfferData.js +1 -1
  11. package/dist/cjs/product/components/product-badge/ProductBadge.js +1 -1
  12. package/dist/cjs/product/components/product-discount-tag/ProductDiscountTag.js +1 -1
  13. package/dist/cjs/product/components/product-list/ProductList.js +1 -1
  14. package/dist/cjs/product/components/product-list/common/helpers.js +1 -1
  15. package/dist/cjs/product/components/product-list-v3/ProductList.js +1 -1
  16. package/dist/cjs/product/components/product-wrap/Product.js +1 -1
  17. package/dist/cjs/product/components/product-wrap/hook/useProductSetting.js +1 -1
  18. package/dist/esm/article/components/ArticleList.js +1 -1
  19. package/dist/esm/common/components/Loading.js +1 -1
  20. package/dist/esm/common/const.js +1 -1
  21. package/dist/esm/common/helpers.js +1 -0
  22. package/dist/esm/common/hooks/useElementWidth.js +1 -0
  23. package/dist/esm/common/hooks/useLoadingProgress.js +1 -0
  24. package/dist/esm/grid/components/section/Section.js +1 -1
  25. package/dist/esm/post-purchase/product/components/product-offer/components/ProductOffer.js +1 -1
  26. package/dist/esm/post-purchase/product/components/product-offer/helpers/getOfferErrorText.js +1 -0
  27. package/dist/esm/post-purchase/product/components/product-offer/hooks/useProductOfferData.js +1 -1
  28. package/dist/esm/product/components/product-badge/ProductBadge.js +1 -1
  29. package/dist/esm/product/components/product-discount-tag/ProductDiscountTag.js +1 -1
  30. package/dist/esm/product/components/product-list/ProductList.js +1 -1
  31. package/dist/esm/product/components/product-list/common/helpers.js +1 -1
  32. package/dist/esm/product/components/product-list-v3/ProductList.js +1 -1
  33. package/dist/esm/product/components/product-wrap/Product.js +1 -1
  34. package/dist/esm/product/components/product-wrap/hook/useProductSetting.js +1 -1
  35. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),l=require("../../grid/components/ChildrenDroppable.js"),i=require("./ArticleNotFound.js");require("../../common/const.js");var r=require("react"),a=require("../../common/components/Loading.js");exports.default=s=>{let o=t.useEditorMode(),{styles:n,setting:d,className:c,children:g,builderProps:u,advanced:m,builderAttrs:p,style:h}=s??{},{articleSetting:y,numberOfArticle:b}=d??{},{articleIds:v,articlePickType:f}=y??{},{border:S,rounded:w,hasBoxShadow:A,boxShadow:D}=m??{},[T]=t.splitStyle(["pos","top","left","bottom","right","z","d"],h),j=t.composeAdvanceStyle({border:S,rounded:w,hasBoxShadow:A,boxShadow:D,"spacing-setting":m?.["spacing-setting"]}),x={first:v?.length||50,where:{baseIDIn:[...y?.articleIds??[]]},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},k={first:1,where:{baseID:y?.blogId},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"},articlesOrderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},[B,P]=r.useState(!0),O=t.useBlogsQuery("latest"===f?k:null,{revalidateOnMount:!0}),E=t.useArticlesQuery("manually"===f?x:null,{revalidateOnMount:!0}),R=O.data?.blogs?.edges?.[0]?.node,C="manually"===f?E.isLoading:O.isLoading,I="manually"===f?E.isValidating:O.isValidating,_="manually"===f?E.error:O.error,q=O?.data?.blogs?.edges?.[0]?.node,G="latest"===f?t.flattenConnection(q?.articles):t.flattenConnection(E?.data?.articles),L=(e,t)=>({...e??{},blog:{title:t?.title??"",handle:t?.handle??""}}),M="latest"===f?G?.filter((e,t)=>t<+(b||4)).map(e=>L(e,q)):"manually"===f&&y?.articleIds?.length?v?.map(e=>{let t=G?.find(t=>t?.baseID===e);return L(t,t?.blogs?.edges?.[0]?.node)}).filter(Boolean):G.filter((e,t)=>t<(y?.numOfSelectedArticles||4)).map(e=>L(e,e?.blogs?.edges?.[0]?.node));return M?.length||C||"edit"!=o?e.jsxs("div",{...p,className:u?.builderData?.uid,style:T,children:[I||C?e.jsx(a.default,{}):_?e.jsxs("div",{children:["Error: ",_?.message]}):M?.length?e.jsx(t.ArticleListProvider,{styles:{horizontalGutter:n?.horizontalGutter,verticalGutter:n?.verticalGutter,spacing:n?.spacing,width:n?.width,height:n?.height},settings:{slidesToShow:d?.slideToShow??{desktop:4,tablet:3,mobile:1}},articles:M,children:e.jsx("div",{"data-id":u?.uid,className:"gp-relative",children:e.jsx("div",{style:{...j,...t.makeStyleWithDefault("w",t.makeWidth(n?.width),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),...t.makeStyleResponsive("rg",n?.horizontalGutter),...t.makeStyleResponsive("cg",n?.verticalGutter),...t.getStyleBackgroundByDevice(d?.background),...t.getGradientBgrStyleByDevice(d?.background),...t.makeStyleResponsive("gtc",{desktop:`repeat(${t.getResponsiveValueByScreen(d?.slideToShow,"desktop")}, minmax(0, 1fr))`,tablet:d?.slideToShow?.tablet&&`repeat(${t.getResponsiveValueByScreen(d?.slideToShow,"tablet")}, minmax(0, 1fr))`,mobile:d?.slideToShow?.mobile&&`repeat(${t.getResponsiveValueByScreen(d?.slideToShow,"mobile")}, minmax(0, 1fr))`})},className:t.cls(c,"gp-m-auto gp-grid gp-w-full"),children:M.map(i=>e.jsx(t.ArticleProvider,{article:i,readOnly:!0,children:e.jsx("div",{"data-component-type":"component","data-component-tag":"Article","data-component-label":"Article","data-component-no-setting":!0,"data-article-id":i?.baseID?.replace("gid://shopify/OnlineStoreArticle/",""),children:t.isEmptyChildren(g)?e.jsx(l.default,{}):g})},i?.id))})})}):e.jsx("div",{children:"Articles not found"}),t.filterToolbarPreview(g,!0)]}):B?e.jsxs("div",{...p,className:u?.builderData?.uid,children:[e.jsx(i.default,{blogHandle:R?.handle,onClose:()=>P(!1),articlePickType:f??"manually",children:g}),t.filterToolbarPreview(g,!0)]}):null};
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),i=require("../../grid/components/ChildrenDroppable.js"),l=require("../../common/helpers.js");require("../../common/const.js");var r=require("react"),a=require("../../common/components/Loading.js"),o=require("./ArticleNotFound.js");exports.default=s=>{let n=t.useEditorMode(),{styles:d,setting:c,className:u,children:g,builderProps:m,advanced:p,builderAttrs:h,style:b}=s??{},{articleSetting:y,numberOfArticle:v}=c??{},{articleIds:f,articlePickType:S}=y??{},{border:D,rounded:j,hasBoxShadow:w,boxShadow:A}=p??{},[T]=t.splitStyle(["pos","top","left","bottom","right","z","d"],b),x=t.composeAdvanceStyle({border:D,rounded:j,hasBoxShadow:w,boxShadow:A,"spacing-setting":p?.["spacing-setting"]}),k={first:f?.length||50,where:{baseIDIn:[...y?.articleIds??[]]},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},B={first:1,where:{baseID:y?.blogId},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"},articlesOrderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},[P,E]=r.useState(!0),O="manually"===S,L="latest"===S,R=t.useBlogsQuery(L?B:null,{revalidateOnMount:!0}),q=t.useArticlesQuery(O?k:null,{revalidateOnMount:!0}),C=R.data?.blogs?.edges?.[0]?.node,I=O?q:R,_=I.error,G=I.isValidating,M=l.isQueryLoading({hasQuery:O||L,data:I.data,error:I.error,isLoading:I.isLoading}),N=R?.data?.blogs?.edges?.[0]?.node,z="latest"===S?t.flattenConnection(N?.articles):t.flattenConnection(q?.data?.articles),F=(e,t)=>({...e??{},blog:{title:t?.title??"",handle:t?.handle??""}}),Q="latest"===S?z?.filter((e,t)=>t<+(v||4)).map(e=>F(e,N)):"manually"===S&&y?.articleIds?.length?f?.map(e=>{let t=z?.find(t=>t?.baseID===e);return F(t,t?.blogs?.edges?.[0]?.node)}).filter(Boolean):z.filter((e,t)=>t<(y?.numOfSelectedArticles||4)).map(e=>F(e,e?.blogs?.edges?.[0]?.node));return Q?.length||M||"edit"!=n?e.jsxs("div",{...h,className:m?.builderData?.uid,style:T,children:[G||M?e.jsx(a.default,{label:l.getElementLabel({builderData:m?.builderData})}):_?e.jsxs("div",{children:["Error: ",_?.message]}):Q?.length?e.jsx(t.ArticleListProvider,{styles:{horizontalGutter:d?.horizontalGutter,verticalGutter:d?.verticalGutter,spacing:d?.spacing,width:d?.width,height:d?.height},settings:{slidesToShow:c?.slideToShow??{desktop:4,tablet:3,mobile:1}},articles:Q,children:e.jsx("div",{"data-id":m?.uid,className:"gp-relative",children:e.jsx("div",{style:{...x,...t.makeStyleWithDefault("w",t.makeWidth(d?.width),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),...t.makeStyleResponsive("rg",d?.horizontalGutter),...t.makeStyleResponsive("cg",d?.verticalGutter),...t.getStyleBackgroundByDevice(c?.background),...t.getGradientBgrStyleByDevice(c?.background),...t.makeStyleResponsive("gtc",{desktop:`repeat(${t.getResponsiveValueByScreen(c?.slideToShow,"desktop")}, minmax(0, 1fr))`,tablet:c?.slideToShow?.tablet&&`repeat(${t.getResponsiveValueByScreen(c?.slideToShow,"tablet")}, minmax(0, 1fr))`,mobile:c?.slideToShow?.mobile&&`repeat(${t.getResponsiveValueByScreen(c?.slideToShow,"mobile")}, minmax(0, 1fr))`})},className:t.cls(u,"gp-m-auto gp-grid gp-w-full"),children:Q.map(l=>e.jsx(t.ArticleProvider,{article:l,readOnly:!0,children:e.jsx("div",{"data-component-type":"component","data-component-tag":"Article","data-component-label":"Article","data-component-no-setting":!0,"data-article-id":l?.baseID?.replace("gid://shopify/OnlineStoreArticle/",""),children:t.isEmptyChildren(g)?e.jsx(i.default,{}):g})},l?.id))})})}):e.jsx("div",{children:"Articles not found"}),t.filterToolbarPreview(g,!0)]}):P?e.jsxs("div",{...h,className:m?.builderData?.uid,children:[e.jsx(o.default,{blogHandle:C?.handle,onClose:()=>E(!1),articlePickType:S??"manually",children:g}),t.filterToolbarPreview(g,!0)]}):null};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");exports.default=()=>e.jsxs("div",{className:"gp-loading-placeholder gp-relative gp-my-0.5 gp-h-3 gp-w-full gp-overflow-hidden",children:[e.jsx("div",{className:"gp-absolute gp-h-full gp-w-full gp-bg-gray-200"}),e.jsx("div",{className:"gp-absolute gp-h-full gp-bg-green-500 gp-animate-progress-bar"})]});
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("../hooks/useLoadingProgress.js"),i=require("../hooks/useElementWidth.js"),s=require("../const.js"),g=require("../helpers.js");const l="gp-loading-placeholder gp-border-loading-frame gp-flex gp-w-full gp-flex-col gp-gap-4 gp-overflow-hidden gp-border-[0.5px] gp-border-solid gp-bg-white",t="gp-text-loading-label !gp-font-g-ui !gp-text-xs !gp-font-medium !gp-leading-5 gp-px-4 gp-text-center";exports.default=({label:d,error:p,retry:o})=>{let a=r.useLoadingProgress(),{ref:n,width:u}=i.useElementWidth(),c=(({minWidth:e})=>void 0===u||u>e)({minWidth:s.LOADING_MIN_WIDTH.SHOW_TEXT}),h=(({minWidth:e})=>void 0===u||u>e)({minWidth:s.LOADING_MIN_WIDTH.SHOW_LABEL});return p?e.jsx("div",{ref:n,className:l,children:e.jsxs("div",{className:`${t} gp-py-4`,children:[g.getLoadingErrorText({label:d,hasRoomForLabel:h}),!!o&&e.jsx("button",{type:"button",onClick:o,className:"gp-ml-1 gp-underline",children:"Retry"})]})}):e.jsxs("div",{ref:n,className:l,children:[e.jsx("div",{className:"gp-h-0.5 gp-w-full gp-bg-loading-track",children:e.jsx("div",{className:"gp-bg-loading-bar gp-h-full gp-transition-[width] gp-duration-100 gp-ease-linear",style:{width:`${a}%`}})}),c&&e.jsx("div",{className:`${t} gp-pb-4`,children:g.getLoadingText({label:d,percent:a,hasRoomForLabel:h})})]})};
@@ -1 +1 @@
1
- "use strict";exports.PRODUCT_LIST_PRODUCT_SOURCE=void 0,function(o){o.Collection="Collection",o.PickProduct="PickProduct",o.DynamicCollection="DynamicCollection",o.RelatedProduct="RelatedProduct"}(exports.PRODUCT_LIST_PRODUCT_SOURCE||(exports.PRODUCT_LIST_PRODUCT_SOURCE={})),exports.ELEMENT_Z_INDEX={STICKY:999,DIALOG:100001,CART_DRAWER:100002,CART_DRAWER_CONFIRM_MODAL:100003};
1
+ "use strict";exports.PRODUCT_LIST_PRODUCT_SOURCE=void 0,function(e){e.Collection="Collection",e.PickProduct="PickProduct",e.DynamicCollection="DynamicCollection",e.RelatedProduct="RelatedProduct"}(exports.PRODUCT_LIST_PRODUCT_SOURCE||(exports.PRODUCT_LIST_PRODUCT_SOURCE={})),exports.ELEMENT_Z_INDEX={STICKY:999,DIALOG:100001,CART_DRAWER:100002,CART_DRAWER_CONFIRM_MODAL:100003},exports.LOADING_MIN_WIDTH={SHOW_LABEL:154,SHOW_TEXT:55},exports.LOADING_PROGRESS={TICK_MS:100,MILESTONES:[{atMs:0,percent:0},{atMs:500,percent:30},{atMs:1e3,percent:50},{atMs:3e3,percent:75},{atMs:5e3,percent:83},{atMs:1e4,percent:90},{atMs:2e4,percent:96}],MAX_PERCENT:99,TAIL_MS:6e4};
@@ -0,0 +1 @@
1
+ "use strict";exports.getElementLabel=({builderData:e})=>e?.customLabel??e?.label,exports.getLoadingErrorText=({label:e,hasRoomForLabel:o})=>e&&o?`${e} failed to load.`:"Failed to load.",exports.getLoadingText=({label:e,percent:o,hasRoomForLabel:t})=>t?e?`Loading ${e}...${o}%`:`Loading ${o}%`:`${o}%`,exports.isQueryLoading=({hasQuery:e,data:o,error:t,isLoading:a})=>a||e&&void 0===o&&void 0===t;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@gem-sdk/core"),t=require("react");exports.useElementWidth=()=>{let r=t.useRef(null),[n,s]=t.useState();return e.useIsomorphicLayoutEffect(()=>{let e=r.current;if(!e||(s(e.getBoundingClientRect().width),"undefined"==typeof ResizeObserver))return;let t=new ResizeObserver(e=>{let t=e[0];t&&s(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),{ref:r,width:n}};
@@ -0,0 +1 @@
1
+ "use strict";let e;var t=require("react"),r=require("../const.js");const{MILESTONES:a,MAX_PERCENT:s,TAIL_MS:l,TICK_MS:o}=r.LOADING_PROGRESS,n=a[a.length-1],u=({value:e,fromValue:t,toValue:r,fromResult:a,toResult:s})=>r===t?s:a+(s-a)*((e-t)/(r-t)),c=({elapsedMs:e})=>{if(e>=n.atMs){let t=u({value:e,fromValue:n.atMs,toValue:n.atMs+l,fromResult:n.percent,toResult:s});return Math.floor(Math.min(t,s))}let t=a.findIndex(t=>e<t.atMs),r=a[t-1]??a[0],o=a[t];return Math.floor(u({value:e,fromValue:r.atMs,toValue:o.atMs,fromResult:r.percent,toResult:o.percent}))},f=new Map,i=()=>{let e=Date.now();f.forEach((t,r)=>r(e-t))},M=t=>(f.set(t,Date.now()),e=e??setInterval(i,o),()=>{f.delete(t),!f.size&&e&&(clearInterval(e),e=void 0)});exports.getLoadingPercent=c,exports.useLoadingProgress=()=>{let[e,r]=t.useState(0);return t.useEffect(()=>{let e=()=>{};return e=M(t=>{let a=c({elapsedMs:t});r(a),a>=s&&e()}),()=>e()},[]),e};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../../common/const.js"),require("@gem-sdk/core");var r=require("react"),t=require("../../../common/components/Loading.js"),o=require("../row/Row.js");exports.default=s=>{let i=r.useMemo(()=>{let{builderProps:e}=s;return e?.builderData?.name==="SectionLoading"},[s]);return i?e.jsx(t.default,{}):e.jsx(o.default,{...s,setting:{...s.setting,as:"section",isSection:!0}})};
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("../../../common/helpers.js");require("../../../common/const.js"),require("@gem-sdk/core");var t=require("react"),o=require("../../../common/components/Loading.js"),s=require("../row/Row.js");exports.default=i=>{let{builderProps:a}=i,u=t.useMemo(()=>a?.builderData?.name==="SectionLoading",[a]);return u?e.jsx(o.default,{label:r.getElementLabel({builderData:a?.builderData})}):e.jsx(s.default,{...i,setting:{...i.setting,as:"section",isSection:!0}})};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../common/classes.js"),s=require("../common/styles.js"),a=require("../hooks/useProductOfferData.js"),o=require("@gem-sdk/system"),c=require("./ProductOfferItem.js");require("../../../../../common/const.js"),require("@gem-sdk/core");var u=require("../../../../../common/components/Loading.js");exports.default=l=>{let{styles:d,builderAttrs:i,builderProps:n,setting:m}=l,{isLoading:f,productSortedById:j,totalProduct:p}=a.useProductOfferData(),y=o.createClass({...t.getProductOfferContainerClasses(n?.uid)}),g=o.createClass({...t.getProductOfferWrapperClasses()}),q=o.createStyle({...s.getWrapperStyles(d)}),x=o.createStyle({...s.getContainerStyles(m)});return e.jsx(e.Fragment,{children:f?e.jsx(u.default,{}):j?.length?e.jsx("div",{...i,className:y,style:x,children:e.jsx("div",{className:g,style:q,children:j?.map((e,t)=>r.createElement(c.ProductOfferItem,{...l,product:e,index:t,key:t,totalProduct:p}))})}):e.jsx("div",{children:"You haven't set up a product yet. Please go back to the sales funnel details to add a product."})})};
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../common/classes.js"),s=require("../common/styles.js"),a=require("../hooks/useProductOfferData.js"),o=require("../../../../../common/helpers.js");require("../../../../../common/const.js");var l=require("@gem-sdk/core"),u=require("../../../../../common/components/Loading.js"),d=require("@gem-sdk/system"),c=require("../helpers/getOfferErrorText.js"),i=require("./ProductOfferItem.js");exports.default=n=>{let{styles:m,builderAttrs:f,builderProps:g,setting:j}=n,{isLoading:p,errorMsg:h,productSortedById:q,totalProduct:x}=a.useProductOfferData(),y=l.useEditorMode(),O=d.createClass({...t.getProductOfferContainerClasses(g?.uid)}),P=d.createClass({...t.getProductOfferWrapperClasses()}),v=d.createStyle({...s.getWrapperStyles(m)}),b=d.createStyle({...s.getContainerStyles(j)}),C=!!h&&!q?.length,E=c.getOfferErrorText({message:h?.message,isEditor:"edit"===y});return e.jsx(e.Fragment,{children:p?e.jsx(u.default,{label:o.getElementLabel({builderData:g?.builderData})}):C?e.jsx("div",{children:E}):q?.length?e.jsx("div",{...f,className:O,style:b,children:e.jsx("div",{className:P,style:v,children:q?.map((e,t)=>r.createElement(i.ProductOfferItem,{...n,product:e,index:t,key:t,totalProduct:x}))})}):e.jsx("div",{children:"You haven't set up a product yet. Please go back to the sales funnel details to add a product."})})};
@@ -0,0 +1 @@
1
+ "use strict";const e="Could not load the offer products",r=`${e}. Please reload the page.`;exports.getOfferErrorText=({message:o,isEditor:t})=>t?`${e}: ${o??"unknown error"}`:r;
@@ -1 +1 @@
1
- "use strict";var e=require("@gem-sdk/core"),o=require("../../../constants/ProductOfferPlaceholder.js"),t=require("../../../helpers/index.js"),r=require("../../../hooks/useDynamicProduct.js"),u=require("react");exports.useProductOfferData=()=>{let n=e.usePageStore(e=>e.productOffers),s=e.usePageStore(e=>e.publicStoreFrontData),{isDynamicProduct:a}=r.useDynamicProduct(),i=e.usePageStore(e=>e.dynamicDiscountOffer),{isEditMode:d}=e.useRenderMode(),c=u.useMemo(()=>a?i?.appliedProductCount:n?.length,[i?.appliedProductCount,a,n?.length]),l=u.useMemo(()=>n?.sort((e,o)=>e?.node?.position&&o?.node?.position?e.node.position-o.node.position:0).map(e=>e?.node?.objectBaseID).filter(Boolean),[n]),{isLoading:p,isValidating:f,data:P}=e.useProductOffersQuery(l||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:t.hasPublicStoreFrontData(s)?t.createStoreFrontFetcher(s):void 0}),m=u.useMemo(()=>p||f,[p,f]),h=u.useMemo(()=>e.flattenConnection(P?.products),[P?.products]),b=u.useMemo(()=>a&&i?.appliedProductCount?Array(i.appliedProductCount).fill(o.productOfferPlaceholder):l?.map(e=>h?.find(o=>o?.baseID===e)).filter(Boolean),[a,i?.appliedProductCount,l,h]);return u.useEffect(()=>{if(m||!d)return;let e=new CustomEvent("editor:toolbar:force-active-component",{bubbles:!0,detail:{}});window.dispatchEvent(e)},[m,d]),{isLoading:m,productSortedById:b,totalProduct:c}};
1
+ "use strict";var e=require("@gem-sdk/core"),o=require("../../../constants/ProductOfferPlaceholder.js"),r=require("../../../helpers/index.js"),t=require("../../../hooks/useDynamicProduct.js"),u=require("../../../../../common/helpers.js");require("../../../../../common/const.js"),require("react/jsx-runtime");var s=require("react");exports.useProductOfferData=()=>{let n=e.usePageStore(e=>e.productOffers),i=e.usePageStore(e=>e.publicStoreFrontData),{isDynamicProduct:a}=t.useDynamicProduct(),c=e.usePageStore(e=>e.dynamicDiscountOffer),{isEditMode:d}=e.useRenderMode(),l=s.useMemo(()=>a?c?.appliedProductCount:n?.length,[c?.appliedProductCount,a,n?.length]),p=s.useMemo(()=>n?.sort((e,o)=>e?.node?.position&&o?.node?.position?e.node.position-o.node.position:0).map(e=>e?.node?.objectBaseID).filter(Boolean),[n]),{isLoading:f,isValidating:m,data:P,error:h}=e.useProductOffersQuery(p||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:r.hasPublicStoreFrontData(i)?r.createStoreFrontFetcher(i):void 0}),g=s.useMemo(()=>m||u.isQueryLoading({hasQuery:!0,data:P,error:h,isLoading:f}),[P,h,f,m]),b=s.useMemo(()=>e.flattenConnection(P?.products),[P?.products]),q=s.useMemo(()=>a&&c?.appliedProductCount?Array(c.appliedProductCount).fill(o.productOfferPlaceholder):p?.map(e=>b?.find(o=>o?.baseID===e)).filter(Boolean),[a,c?.appliedProductCount,p,b]);return s.useEffect(()=>{if(g||!d)return;let e=new CustomEvent("editor:toolbar:force-active-component",{bubbles:!0,detail:{}});window.dispatchEvent(e)},[g,d]),{isLoading:g,errorMsg:h,productSortedById:q,totalProduct:l}};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),s=require("./common/classes.js"),r=require("./common/styles.js"),a=require("./common/attrs.js"),l=require("@gem-sdk/system");require("../../../common/const.js");var n=require("../../../common/components/TooltipHover.js"),o=require("../../../common/components/NoDataState.js"),c=require("./utils/common.js");require("./constants.js"),exports.default=i=>{let{t:u}=t.useI18nStore(),{setting:d,styles:m,children:g,builderAttrs:C,...y}=i,p=t.useProduct(),j=t.useCurrentVariant(),{moneyFormat:x}=t.useMoneyFormat(),S=t.useCurrentDevice(),{useProductCompareAtPrice:T}=t.useProductBundleDiscount(),v=y?.["bundle-item"],h=t.useEditorMode(),{isEditMode:q}=t.useRenderMode(),A="STATIC"===t.usePageType(),{settings:N}=t.useSafeGetProductListSettings(),I=N?.sameHeight,f=c.getBadgeContent({detail:p,currentVariant:j,bundleItem:v,useProductCompareAtPrice:T},d?.displayContent,x),b=c.getIsNoDiscountState({props:i,product:p,currentVariant:j,moneyFormat:x,useProductCompareAtPrice:T}),P=l.createClass({...s.getContainerClasses({mode:h,isInstant:A,product:p,currentVariant:j,props:i,isSameHeightInProductList:I})}),W=l.createStyle({...r.getContainerStyle(i)}),M=l.createAttr({...a.getEditTooltipAttrs(i,q)}),D=l.createClass({...s.getWrapperClasses(i)}),B=l.createClass({...s.getSubWrapperClass(i,S)}),k=l.createStyle({...r.getSubWrapperStyle({props:i,product:p,currentVariant:j,isEditMode:q})}),w=l.createAttr({...a.getSubWrapperAttrs(i,p)}),E=r.getContentStyleInternal(i),H=l.createClass({...s.getTextContainerClasses()}),_=l.createAttr({...a.getContainerAttrs(i)}),F=l.createClass({...s.getTextWrapperClasses()}),G=l.createStyle({...r.getTextBadgeWrapperStyles({setting:d,styles:m})}),L=l.createClass({...s.getTextContentClasses(m)}),O=l.createStyle({...r.getTextContentStyle({setting:d,styles:m})}),R=l.createAttr({...a.getTextContentAttrs()}),V=l.createClass({...s.getImageContainerClasses()}),z=l.createStyle({...r.getImageContainerStyles({setting:d,styles:m})}),J=l.createClass({...s.getImageClasses()}),K=l.createAttr({...a.getImageAttr({setting:d})});return p?e.jsxs("div",{..._,style:W,className:P,children:[l.If(q&&b,e.jsx(n.default,{...M,children:e.jsx(o.default,{...C,elementType:"secondary",description:u("No discount"),rawMode:!0})}),e.jsx("div",{className:D,children:e.jsxs("div",{...w,className:B,style:k,children:[e.jsx("style",{children:E}),l.If(d?.shape!=="image",e.jsx("div",{className:H,children:e.jsx("div",{className:F,style:G,children:e.jsx("pre",{...R,className:L,style:O,children:f})})}),e.jsx("div",{className:V,style:z,children:e.jsx("img",{...K,className:J,alt:""})}))]})})),t.filterToolbarPreview(g,!0)]}):null};
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),s=require("./common/classes.js"),r=require("./common/styles.js"),a=require("./common/attrs.js"),l=require("@gem-sdk/system");require("../../../common/const.js");var n=require("../../../common/components/TooltipHover.js"),o=require("../../../common/components/NoDataState.js");require("react");var c=require("./utils/common.js");require("./constants.js"),exports.default=i=>{let{t:u}=t.useI18nStore(),{setting:d,styles:m,children:g,builderAttrs:C,...y}=i,p=t.useProduct(),j=t.useCurrentVariant(),{moneyFormat:x}=t.useMoneyFormat(),S=t.useCurrentDevice(),{useProductCompareAtPrice:v}=t.useProductBundleDiscount(),T=y?.["bundle-item"],q=t.useEditorMode(),{isEditMode:h}=t.useRenderMode(),A="STATIC"===t.usePageType(),{settings:N}=t.useSafeGetProductListSettings(),I=N?.sameHeight,f=c.getBadgeContent({detail:p,currentVariant:j,bundleItem:T,useProductCompareAtPrice:v},d?.displayContent,x),b=c.getIsNoDiscountState({props:i,product:p,currentVariant:j,moneyFormat:x,useProductCompareAtPrice:v}),P=l.createClass({...s.getContainerClasses({mode:q,isInstant:A,product:p,currentVariant:j,props:i,isSameHeightInProductList:I})}),W=l.createStyle({...r.getContainerStyle(i)}),M=l.createAttr({...a.getEditTooltipAttrs(i,h)}),D=l.createClass({...s.getWrapperClasses(i)}),B=l.createClass({...s.getSubWrapperClass(i,S)}),k=l.createStyle({...r.getSubWrapperStyle({props:i,product:p,currentVariant:j,isEditMode:h})}),w=l.createAttr({...a.getSubWrapperAttrs(i,p)}),E=r.getContentStyleInternal(i),H=l.createClass({...s.getTextContainerClasses()}),_=l.createAttr({...a.getContainerAttrs(i)}),F=l.createClass({...s.getTextWrapperClasses()}),G=l.createStyle({...r.getTextBadgeWrapperStyles({setting:d,styles:m})}),L=l.createClass({...s.getTextContentClasses(m)}),O=l.createStyle({...r.getTextContentStyle({setting:d,styles:m})}),R=l.createAttr({...a.getTextContentAttrs()}),V=l.createClass({...s.getImageContainerClasses()}),z=l.createStyle({...r.getImageContainerStyles({setting:d,styles:m})}),J=l.createClass({...s.getImageClasses()}),K=l.createAttr({...a.getImageAttr({setting:d})});return p?e.jsxs("div",{..._,style:W,className:P,children:[l.If(h&&b,e.jsx(n.default,{...M,children:e.jsx(o.default,{...C,elementType:"secondary",description:u("No discount"),rawMode:!0})}),e.jsx("div",{className:D,children:e.jsxs("div",{...w,className:B,style:k,children:[e.jsx("style",{children:E}),l.If(d?.shape!=="image",e.jsx("div",{className:H,children:e.jsx("div",{className:F,style:G,children:e.jsx("pre",{...R,className:L,style:O,children:f})})}),e.jsx("div",{className:V,style:z,children:e.jsx("img",{...K,className:J,alt:""})}))]})})),t.filterToolbarPreview(g,!0)]}):null};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("./common/classes.js"),s=require("./common/styles.js"),l=require("@gem-sdk/core"),i=require("@gem-sdk/system"),r=require("./hooks/useGpDiscountTag.js");require("../../../common/const.js");var a=require("../../../common/components/TooltipHover.js"),o=require("../../../common/components/NoDataState.js"),n=require("../../../text/components/Text.js");exports.default=({setting:d,styles:u,builderProps:c,...p})=>{let{customContent:x}=d??{},m=p["bundle-item"],{textAlign:y}=u??{},{t:f}=l.useI18nStore(),{mode:g,product:j,salePrice:q,priceSave:b,currentProductId:h,unitCustomDisplay:C,shouldPlaceholderNoDiscount:v}=r.useGpDiscountTag({setting:d,styles:u,builderProps:c,...p});if(v)return e.jsx(a.default,{enable:!0,text:f("Not be displayed when published"),position:"bottom",width:"205px",children:e.jsx(o.default,{builderAttrs:c?.builderData,elementType:"secondary",description:f("No discount"),rawMode:!0,customClass:"!gp-p-[5px]"})});let S=i.createStyle(s.getWrapperTextStyle(u)),N=i.createStyle(s.getContainerStyle(u)),T=i.createClass(t.getWrapperTextClass(u)),k=i.createClass(t.getContainerClass()),D=i.createClass(t.getRootClass({mode:g,salePrice:q,priceSave:b,bundleItem:m}));return e.jsx("div",{className:D,style:{...l.makeStyleResponsive("ta",y)},id:`shopify-text-element-${c?.uid}`,"data-id":c?.uid,"data-product-id":h,"gp-data-hidden":"false",children:i.If(!j," ",e.jsx("div",{className:k,style:N,children:e.jsx("div",{className:T,style:S,children:e.jsxs("div",{className:"gp-flex gp-break-all gp-items-center",children:[e.jsx(n.default,{styles:u,setting:{...d,text:x?.prefix?.replaceAll(" ","&nbsp;"),options:{useState:!0,uniqueId:`${c?.uid}-prefix`},excludeFlex:!0}}),e.jsx(n.default,{styles:u,setting:{...d,text:C,options:{isCannotEditing:!0},excludeFlex:!0}}),e.jsx(n.default,{styles:u,setting:{...d,text:x?.suffix?.replaceAll(" ","&nbsp;"),excludeFlex:!0,options:{useState:!0,uniqueId:`${c?.uid}-suffix`}}})]})})}))})};
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("./common/classes.js"),s=require("./common/styles.js"),r=require("@gem-sdk/core"),i=require("@gem-sdk/system"),l=require("./hooks/useGpDiscountTag.js");require("../../../common/const.js");var a=require("../../../common/components/TooltipHover.js"),o=require("../../../common/components/NoDataState.js");require("react");var n=require("../../../text/components/Text.js");exports.default=({setting:u,styles:d,builderProps:c,...p})=>{let{customContent:x}=u??{},m=p["bundle-item"],{textAlign:y}=d??{},{t:f}=r.useI18nStore(),{mode:g,product:j,salePrice:q,priceSave:b,currentProductId:h,unitCustomDisplay:v,shouldPlaceholderNoDiscount:C}=l.useGpDiscountTag({setting:u,styles:d,builderProps:c,...p});if(C)return e.jsx(a.default,{enable:!0,text:f("Not be displayed when published"),position:"bottom",width:"205px",children:e.jsx(o.default,{builderAttrs:c?.builderData,elementType:"secondary",description:f("No discount"),rawMode:!0,customClass:"!gp-p-[5px]"})});let S=i.createStyle(s.getWrapperTextStyle(d)),N=i.createStyle(s.getContainerStyle(d)),T=i.createClass(t.getWrapperTextClass(d)),k=i.createClass(t.getContainerClass()),D=i.createClass(t.getRootClass({mode:g,salePrice:q,priceSave:b,bundleItem:m}));return e.jsx("div",{className:D,style:{...r.makeStyleResponsive("ta",y)},id:`shopify-text-element-${c?.uid}`,"data-id":c?.uid,"data-product-id":h,"gp-data-hidden":"false",children:i.If(!j," ",e.jsx("div",{className:k,style:N,children:e.jsx("div",{className:T,style:S,children:e.jsxs("div",{className:"gp-flex gp-break-all gp-items-center",children:[e.jsx(n.default,{styles:d,setting:{...u,text:x?.prefix?.replaceAll(" ","&nbsp;"),options:{useState:!0,uniqueId:`${c?.uid}-prefix`},excludeFlex:!0}}),e.jsx(n.default,{styles:d,setting:{...u,text:v,options:{isCannotEditing:!0},excludeFlex:!0}}),e.jsx(n.default,{styles:d,setting:{...u,text:x?.suffix?.replaceAll(" ","&nbsp;"),excludeFlex:!0,options:{useState:!0,uniqueId:`${c?.uid}-suffix`}}})]})})}))})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../common/const.js"),r=require("@gem-sdk/core"),o=require("react"),d=require("../../../common/components/Loading.js"),a=require("next/dynamic"),s=require("../SalePageProductListWarning.js"),l=require("../../../dialog/common/helpers.js"),i=require("./ProductListCarouselLayout.js"),c=require("./ProductListGridLayout.js"),n=require("./common/classes.js"),u=require("./common/helpers.js"),g=require("./common/styles.js"),P=require("@gem-sdk/system"),m=require("next/head");const h=a(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:d.default});exports.default=a=>{let{children:T,styles:C,builderProps:O,setting:S,builderAttrs:f}=a,{isRelatedProduct:p,productSetting:_}=u.getData(a),I=_.relatedTag&&_.relatedTag[0],{isEditMode:R,isPreviewSharePageMode:U}=r.useRenderMode(),y=r.useCurrentDevice(),D=r.usePageType(),v=r.usePageStore(e=>e.dynamicProduct),b=r.usePageStore(e=>e.dynamicCollection),[E,j]=o.useState(1),[x,k]=o.useState(!0),[L,q]=o.useState(),[M,N]=o.useState(!1),w="GP_FUNNEL_PAGE"===D;"GP_COLLECTION"!=D||[t.PRODUCT_LIST_PRODUCT_SOURCE.Collection,t.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection].includes(_?.productSrc)||(_.productSrc=t.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection);let W=_?.productSrc??t.PRODUCT_LIST_PRODUCT_SOURCE.Collection;W===t.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection&&(_.collectionId=b?.collectionId||"latest");let F=v?.productId&&v?.productId!==_.relatedProductId?v?.productId:_.relatedProductId,G=r.useFetchHandle(),Q=r.usePageStore(e=>e.publicStoreFrontData),A=o.useMemo(()=>r.hasPublicStoreFrontData(Q)?r.createStoreFrontFetcher(Q):G,[Q]),{data:B}=r.useProductQuery(p&&F?F:void 0,{revalidateOnMount:R||U},A),H=_.relatedTag&&"tags"===_.relatedTag[0]&&(!B?.tags||B?.tags.length===0),z=_.relatedTag&&"collection"===_.relatedTag[0]&&(!B?.collections?.edges||B?.collections.edges.length===0),$=_.relatedTag&&"vendor"===_.relatedTag[0]&&!B?.vendor,V=r.useProductsQueryAll(L,{revalidateOnMount:R||U},A),K=R||U,J=r.useProductsQuery(W===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?_?.productIds:void 0,{revalidateOnMount:K},{defaultSelectedProductCount:_?.numOfSelectedProducts,selectedStatus:K&&_?.productIds?.length?r.PICKED_PRODUCT_STATUSES:void 0}),X=o.useMemo(()=>({id:_?.collectionId??"latest",numberOfProducts:S?.numberOfProducts??4,orderBy:S?.orderBy}),[_?.collectionId,Number(S?.numberOfProducts),S?.orderBy]),Y=r.useCollectionQuery(W!==t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?X:void 0,{revalidateOnMount:K});o.useEffect(()=>{if(p&&B&&_.relatedTag&&"recommended-product"!==_.relatedType){let e;switch(N(!1),_.hasRelatedExclude&&(e=_?.relatedExclude&&_.relatedExclude.split(",").map(e=>e.trim())),_.relatedTag[0]){case"vendor":q({first:S?.numberOfProducts,vendor:_.relatedTag&&"vendor"===_.relatedTag[0]?B?.vendor:"",idNEQ:B.id});break;case"collection":{let t=B?.collections?.edges.map(e=>e.node?.id);if(!t||t?.length===0){N(!0);break}q(e&&e.length>0?{first:S?.numberOfProducts,idNEQ:B.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t},{titleNotIn:e}]}]}:{first:S?.numberOfProducts,idNEQ:B.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t}]}]});break}case"tags":if(!B.tags||0===B.tags.length){N(!0);break}q(e&&e.length>0?{first:S?.numberOfProducts,idNEQ:B.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:B.tags},{nameNotIn:e}]}]}:{first:S?.numberOfProducts,idNEQ:B.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:B.tags}]}]})}}},[B,_.relatedType,_.relatedTag,S?.numberOfProducts,_.relatedExclude,_.hasRelatedExclude,p]);let Z=W===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?J.isValidating:Y.isValidating,ee=W===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?J.isLoading:Y.isLoading,et=W===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?J.error:Y.error,er=Y.data?.collections?.edges?.[0]?.node,eo=W===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?r.flattenConnection(J.data?.products):r.flattenConnection(er?.products),ed=V?.data?.products?r.flattenConnection(V?.data?.products):void 0,ea=p&&ed?ed:W===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct&&_?.productIds?.length?_?.productIds?.map(e=>eo?.find(t=>t?.baseID===e)).filter(Boolean)??eo:W!==t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?eo:eo.filter((e,t)=>t<(_?.numOfSelectedProducts??4)),es=o.useMemo(()=>M&&p&&R||!ea.length&&!ee&&x&&R,[x,ee,M,p,R,ea.length]),el=o.useMemo(()=>!ea||M&&p,[M,p,ea]),ei=o.useMemo(()=>{if(!S?.sameHeight)return[];let e=0,t=Math.ceil((ea?.length??0)/+(S?.slidesToShow?.[y]??1));return Array.from(Array(ea?.length??0)).map((r,o)=>(o>=+(S?.slidesToShow?.[y]??1)*(e+1)&&++e,{gridRow:`${1+E*e}/${E+1+E*e}`,marginBottom:e+1<t?l.getPropertyByDevice(C?.horizontalGutter,y):void 0}))},[S?.sameHeight,S?.slidesToShow,E,ea?.length,y,C?.horizontalGutter]),ec=o.useMemo(()=>Z||ee||et||!ea||M&&p,[et,ee,M,p,Z,ea]);o.useEffect(()=>{ec||setTimeout(()=>{let{builderData:e}=O??{},t=e?.childrens?.[0];if(!t)return;let r=document.querySelector(`[data-id=${t}] div`);r&&j(r.childElementCount||1)},R?0:500)},[O,ec,R]);let en=o.useMemo(()=>({collection:er,products:ea,settings:{loop:S?.loop??{desktop:!1},scrollMode:S?.scrollMode??{desktop:"snap"},slidesToShow:S?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:C?.layout,dot:S?.dot,dotStyle:S?.dotStyle,arrow:S?.arrow,controlOverContent:S?.controlOverContent,sameHeight:S?.sameHeight},styles:{horizontalGutter:C?.horizontalGutter,verticalGutter:C?.verticalGutter,fullWidth:C?.fullWidth,spacing:C?.spacing,width:C?.width,height:C?.height}}),[er,ea,S,C]);if(O?.isPreview&&w)return e.jsx(e.Fragment,{});if(es)return e.jsx(e.Fragment,{children:P.If(x,e.jsx(h,{builderAttrs:f,collectionHandle:er?.handle,productSrc:W,onClose:()=>k(!1),children:T,relatedTagString:I,assignProductNoTags:H||z||$,noAssignedProduct:!F}))});let{productListWrapStyle:eu,productListContentStyle:eg,productListWrapAlignStyle:eP}=g.getStyle(a),{productListWrapClass:em}=n.getClass(a);return e.jsxs("div",{...f,className:em,style:eu,children:[!!C?.preloadBgImage&&e.jsxs(m,{children:[!!C.backgroundImage?.desktop?.image?.src&&e.jsx("link",{rel:"preload",href:C.backgroundImage.desktop.image.src,as:"image"}),!!C.backgroundImage?.tablet?.image?.src&&e.jsx("link",{rel:"preload",href:C.backgroundImage?.tablet?.image?.src,as:"image"}),!!C.backgroundImage?.mobile?.image?.src&&e.jsx("link",{rel:"preload",href:C.backgroundImage?.mobile?.image?.src,as:"image"})]}),Z||ee?e.jsx(d.default,{}):et?e.jsxs("div",{children:["Error: ",et?.message]}):el?e.jsx("div",{children:"Products not found"}):e.jsx(r.ProductListProvider,{...en,children:e.jsx("div",{className:"gp-flex gp-w-full",style:eP,children:e.jsxs("div",{style:eg,children:[w&&e.jsx(s.default,{}),e.jsx(e.Fragment,{children:P.If(C?.layout==="grid",e.jsx(c.default,{...a,productSortedById:ea,generateGridRowArray:ei}),e.jsx(i.default,{...a,productSortedById:ea}))})]})})}),r.filterToolbarPreview(T,!0)]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../common/helpers.js"),r=require("../../../common/const.js"),o=require("@gem-sdk/core"),d=require("react"),a=require("../../../common/components/Loading.js"),l=require("next/dynamic"),s=require("../SalePageProductListWarning.js"),i=require("../../../dialog/common/helpers.js"),n=require("./common/helpers.js"),c=require("./ProductListCarouselLayout.js"),u=require("./ProductListGridLayout.js"),g=require("./common/classes.js"),m=require("./common/styles.js"),P=require("@gem-sdk/system"),h=require("next/head");const T=l(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:a.default});exports.default=l=>{let{children:C,styles:O,builderProps:S,setting:f,builderAttrs:p}=l,{isRelatedProduct:I,productSetting:y}=n.getData(l),R=y.relatedTag&&y.relatedTag[0],{isEditMode:_,isPreviewSharePageMode:b}=o.useRenderMode(),U=o.useCurrentDevice(),v=o.usePageType(),D=o.usePageStore(e=>e.dynamicProduct),j=o.usePageStore(e=>e.dynamicCollection),[E,L]=d.useState(1),[x,k]=d.useState(!0),[q,M]=d.useState(),[N,w]=d.useState(!1),[Q,W]=d.useState(),F="GP_FUNNEL_PAGE"===v;"GP_COLLECTION"!=v||[r.PRODUCT_LIST_PRODUCT_SOURCE.Collection,r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection].includes(y?.productSrc)||(y.productSrc=r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection);let G=y?.productSrc??r.PRODUCT_LIST_PRODUCT_SOURCE.Collection;G===r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection&&(y.collectionId=j?.collectionId||"latest");let A=D?.productId&&D?.productId!==y.relatedProductId?D?.productId:y.relatedProductId,B=o.useFetchHandle(),H=o.usePageStore(e=>e.publicStoreFrontData),z=d.useMemo(()=>o.hasPublicStoreFrontData(H)?o.createStoreFrontFetcher(H):B,[H]),{data:$,error:K,isLoading:V}=o.useProductQuery(I&&A?A:void 0,{revalidateOnMount:_||b},z),J=y.relatedTag&&"tags"===y.relatedTag[0]&&(!$?.tags||$?.tags.length===0),X=y.relatedTag&&"collection"===y.relatedTag[0]&&(!$?.collections?.edges||$?.collections.edges.length===0),Y=y.relatedTag&&"vendor"===y.relatedTag[0]&&!$?.vendor,Z=o.useProductsQueryAll(q,{revalidateOnMount:_||b},z),ee=_||b,et=o.useProductsQuery(G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?y?.productIds:void 0,{revalidateOnMount:ee},{defaultSelectedProductCount:y?.numOfSelectedProducts,selectedStatus:ee&&y?.productIds?.length?o.PICKED_PRODUCT_STATUSES:void 0}),er=d.useMemo(()=>({id:y?.collectionId??"latest",numberOfProducts:f?.numberOfProducts??4,orderBy:f?.orderBy}),[y?.collectionId,Number(f?.numberOfProducts),f?.orderBy]),eo=o.useCollectionQuery(G!==r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?er:void 0,{revalidateOnMount:ee});d.useEffect(()=>{if(I&&$&&y.relatedTag&&"recommended-product"!==y.relatedType){let e;switch(w(!1),y.hasRelatedExclude&&(e=y?.relatedExclude&&y.relatedExclude.split(",").map(e=>e.trim())),y.relatedTag[0]){case"vendor":M({first:f?.numberOfProducts,vendor:y.relatedTag&&"vendor"===y.relatedTag[0]?$?.vendor:"",idNEQ:$.id}),W($.id);break;case"collection":{let t=$?.collections?.edges.map(e=>e.node?.id);if(!t||t?.length===0){w(!0);break}M(e&&e.length>0?{first:f?.numberOfProducts,idNEQ:$.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t},{titleNotIn:e}]}]}:{first:f?.numberOfProducts,idNEQ:$.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t}]}]}),W($.id);break}case"tags":if(!$.tags||0===$.tags.length){w(!0);break}M(e&&e.length>0?{first:f?.numberOfProducts,idNEQ:$.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:$.tags},{nameNotIn:e}]}]}:{first:f?.numberOfProducts,idNEQ:$.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:$.tags}]}]}),W($.id)}}},[$,y.relatedType,y.relatedTag,f?.numberOfProducts,y.relatedExclude,y.hasRelatedExclude,I]);let ed=G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct,ea=ed?et:eo,el=ea.isValidating,es=ea.error,ei=t.isQueryLoading({hasQuery:ee&&(!ed||!!y?.productIds),data:ea.data,error:ea.error,isLoading:ea.isLoading}),en=n.isRelatedProductsLoading({isRelatedProduct:I,relatedType:y.relatedType,hasRelatedTag:n.hasQueryableRelatedTag({relatedTag:y.relatedTag}),relatedProductIdAssigned:A,canRevalidateOnMount:ee,mainProduct:{data:$,error:K,isLoading:V},relatedQuery:q,relatedQuerySource:Q,mainProductId:$?.id,isNotFoundRelatedProduct:N,relatedProducts:{data:Z.data,error:Z.error,isLoading:Z.isLoading}}),ec=ei||en,eu=eo.data?.collections?.edges?.[0]?.node,eg=G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?o.flattenConnection(et.data?.products):o.flattenConnection(eu?.products),em=Z?.data?.products?o.flattenConnection(Z?.data?.products):void 0,eP=I&&em?em:G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct&&y?.productIds?.length?y?.productIds?.map(e=>eg?.find(t=>t?.baseID===e)).filter(Boolean)??eg:G!==r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?eg:eg.filter((e,t)=>t<(y?.numOfSelectedProducts??4)),eh=d.useMemo(()=>N&&I&&_||!eP.length&&!ec&&x&&_,[x,ec,N,I,_,eP.length]),eT=d.useMemo(()=>!eP||N&&I,[N,I,eP]),eC=d.useMemo(()=>{if(!f?.sameHeight)return[];let e=0,t=Math.ceil((eP?.length??0)/+(f?.slidesToShow?.[U]??1));return Array.from(Array(eP?.length??0)).map((r,o)=>(o>=+(f?.slidesToShow?.[U]??1)*(e+1)&&++e,{gridRow:`${1+E*e}/${E+1+E*e}`,marginBottom:e+1<t?i.getPropertyByDevice(O?.horizontalGutter,U):void 0}))},[f?.sameHeight,f?.slidesToShow,E,eP?.length,U,O?.horizontalGutter]),eO=d.useMemo(()=>el||ec||es||!eP||N&&I,[es,ec,N,I,el,eP]);d.useEffect(()=>{eO||setTimeout(()=>{let{builderData:e}=S??{},t=e?.childrens?.[0];if(!t)return;let r=document.querySelector(`[data-id=${t}] div`);r&&L(r.childElementCount||1)},_?0:500)},[S,eO,_]);let eS=d.useMemo(()=>({collection:eu,products:eP,settings:{loop:f?.loop??{desktop:!1},scrollMode:f?.scrollMode??{desktop:"snap"},slidesToShow:f?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:O?.layout,dot:f?.dot,dotStyle:f?.dotStyle,arrow:f?.arrow,controlOverContent:f?.controlOverContent,sameHeight:f?.sameHeight},styles:{horizontalGutter:O?.horizontalGutter,verticalGutter:O?.verticalGutter,fullWidth:O?.fullWidth,spacing:O?.spacing,width:O?.width,height:O?.height}}),[eu,eP,f,O]);if(S?.isPreview&&F)return e.jsx(e.Fragment,{});if(eh)return e.jsx(e.Fragment,{children:P.If(x,e.jsx(T,{builderAttrs:p,collectionHandle:eu?.handle,productSrc:G,onClose:()=>k(!1),children:C,relatedTagString:R,assignProductNoTags:J||X||Y,noAssignedProduct:!A}))});let{productListWrapStyle:ef,productListContentStyle:ep,productListWrapAlignStyle:eI}=m.getStyle(l),{productListWrapClass:ey}=g.getClass(l);return e.jsxs("div",{...p,className:ey,style:ef,children:[!!O?.preloadBgImage&&e.jsxs(h,{children:[!!O.backgroundImage?.desktop?.image?.src&&e.jsx("link",{rel:"preload",href:O.backgroundImage.desktop.image.src,as:"image"}),!!O.backgroundImage?.tablet?.image?.src&&e.jsx("link",{rel:"preload",href:O.backgroundImage?.tablet?.image?.src,as:"image"}),!!O.backgroundImage?.mobile?.image?.src&&e.jsx("link",{rel:"preload",href:O.backgroundImage?.mobile?.image?.src,as:"image"})]}),el||ec?e.jsx(a.default,{label:t.getElementLabel({builderData:S?.builderData})}):es?e.jsxs("div",{children:["Error: ",es?.message]}):eT?e.jsx("div",{children:"Products not found"}):e.jsx(o.ProductListProvider,{...eS,children:e.jsx("div",{className:"gp-flex gp-w-full",style:eI,children:e.jsxs("div",{style:ep,children:[F&&e.jsx(s.default,{}),e.jsx(e.Fragment,{children:P.If(O?.layout==="grid",e.jsx(u.default,{...l,productSortedById:eP,generateGridRowArray:eC}),e.jsx(c.default,{...l,productSortedById:eP}))})]})})}),o.filterToolbarPreview(C,!0)]})};
@@ -1 +1 @@
1
- "use strict";var e=require("../../../../carousel/components/dot/common/helpers.js"),t=require("../../product-images/common/productFeaturedImage.js"),o=require("../../../helpers/product.js");const r="gid://shopify/Collection/",d="gid://shopify/Product/";exports.PREFIX_COLLECTION_ID=r,exports.PREFIX_PRODUCT_ID=d,exports.getData=t=>{let{setting:r,styles:d}=t,c=r?.productSetting??{},l="RelatedProduct"===c.productSrc,i=e.getUpdatedDotStyle(r?.dot,r?.dotStyle),u={dotSize:{desktop:12},dotGapToCarousel:{desktop:16},arrowIconSize:{desktop:24},showWhenHover:!1,rtl:!1,...r};delete u.childItem;let n={...d,sizeSetting:{...o.getSizeSetting({adaptiveHeight:d?.adaptiveHeight,height:d?.height,fullWidth:{desktop:!0}})},spacing:d?.spacing};return delete n.backgroundColor,delete n.backgroundImage,{isRelatedProduct:l,productSetting:c,dotStyle:i,carouselConfigSetting:u,carouselConfigStyle:n}},exports.getDataLiquid=e=>{let{setting:o,styles:c}=e,l=o?.productSetting,i=l?.relatedTag,u=l?.hasRelatedExclude,n=(i&&"collection"===i[0]?l?.relatedCollectionExclude:l?.relatedTagsExclude)??"",a=n?.split(",").map(e=>e.trim()).toString(),p=l?.productSrc??"Collection",s=l?.collectionId?.replace(r,"")??"latest",g=l?.productSrc==="PickProduct"&&l?.productIds?.length===0,h=c?.layout==="grid",m=t.convertUnitToNumber(o?.numberOfProducts,4),S="PickProduct"===p&&l?.productIds?.length?l?.productIds.map(e=>e.replace(d,"")):[],P="PickProduct"===p&&l?.productHandles?.length?l?.productHandles:[],I=o?.orderBy&&o?.orderBy!=="none",C=(l?.productSrc==="Collection"||l?.productSrc==="DynamicCollection")&&I?o?.orderBy?.split("_"):"none",k=I&&C?.[0]==="TITLE"?"| sort: 'title'":"| sort: 'updated_at'",y=C?.[C.length-1]==="DESC";return{hasRelatedExclude:u,relatedExcludeTrim:a,collectionID:s,isLatestProducts:g,isGrid:h,numberOfProducts:m,productListId:S,productListHandles:P,sortedBy:k,isReverse:y,productSrc:p,productSetting:l,isSorted:I,relatedTag:i,productNumber:"PickProduct"===p?g?4:l?.numOfSelectedProducts??4:m,collectionHandle:l?.collectionHandle}};
1
+ "use strict";var e=require("../../../../carousel/components/dot/common/helpers.js"),t=require("../../product-images/common/productFeaturedImage.js"),r=require("../../../helpers/product.js"),o=require("../../../../common/helpers.js");require("../../../../common/const.js"),require("react/jsx-runtime"),require("@gem-sdk/core"),require("react");const d="gid://shopify/Collection/",c="gid://shopify/Product/",i=["vendor","collection","tags"];exports.PREFIX_COLLECTION_ID=d,exports.PREFIX_PRODUCT_ID=c,exports.getData=t=>{let{setting:o,styles:d}=t,c=o?.productSetting??{},i="RelatedProduct"===c.productSrc,l=e.getUpdatedDotStyle(o?.dot,o?.dotStyle),u={dotSize:{desktop:12},dotGapToCarousel:{desktop:16},arrowIconSize:{desktop:24},showWhenHover:!1,rtl:!1,...o};delete u.childItem;let a={...d,sizeSetting:{...r.getSizeSetting({adaptiveHeight:d?.adaptiveHeight,height:d?.height,fullWidth:{desktop:!0}})},spacing:d?.spacing};return delete a.backgroundColor,delete a.backgroundImage,{isRelatedProduct:i,productSetting:c,dotStyle:l,carouselConfigSetting:u,carouselConfigStyle:a}},exports.getDataLiquid=e=>{let{setting:r,styles:o}=e,i=r?.productSetting,l=i?.relatedTag,u=i?.hasRelatedExclude,a=(l&&"collection"===l[0]?i?.relatedCollectionExclude:i?.relatedTagsExclude)??"",n=a?.split(",").map(e=>e.trim()).toString(),s=i?.productSrc??"Collection",p=i?.collectionId?.replace(d,"")??"latest",g=i?.productSrc==="PickProduct"&&i?.productIds?.length===0,m=o?.layout==="grid",h=t.convertUnitToNumber(r?.numberOfProducts,4),S="PickProduct"===s&&i?.productIds?.length?i?.productIds.map(e=>e.replace(c,"")):[],P="PickProduct"===s&&i?.productHandles?.length?i?.productHandles:[],y=r?.orderBy&&r?.orderBy!=="none",I=(i?.productSrc==="Collection"||i?.productSrc==="DynamicCollection")&&y?r?.orderBy?.split("_"):"none",k=y&&I?.[0]==="TITLE"?"| sort: 'title'":"| sort: 'updated_at'",C=I?.[I.length-1]==="DESC";return{hasRelatedExclude:u,relatedExcludeTrim:n,collectionID:p,isLatestProducts:g,isGrid:m,numberOfProducts:h,productListId:S,productListHandles:P,sortedBy:k,isReverse:C,productSrc:s,productSetting:i,isSorted:y,relatedTag:l,productNumber:"PickProduct"===s?g?4:i?.numOfSelectedProducts??4:h,collectionHandle:i?.collectionHandle}},exports.hasQueryableRelatedTag=({relatedTag:e})=>!!e?.[0]&&i.includes(e[0]),exports.isRelatedProductsLoading=({isRelatedProduct:e,relatedType:t,hasRelatedTag:r,relatedProductIdAssigned:d,canRevalidateOnMount:c,mainProduct:i,mainProductId:l,relatedQuery:u,relatedQuerySource:a,isNotFoundRelatedProduct:n,relatedProducts:s})=>{if(!e)return!1;let p="recommended-product"!==t&&r&&!!d,g=p&&!!i.data&&a!==l&&!n;return c?o.isQueryLoading({hasQuery:p,...i})||g||o.isQueryLoading({hasQuery:!!u,...s}):i.isLoading||s.isLoading};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../common/const.js"),r=require("@gem-sdk/core"),o=require("react"),s=require("../../../common/components/Loading.js"),i=require("next/dynamic"),l=require("./hooks/useRelatedProductIDAssigned.js"),d=require("../SalePageProductListWarning.js"),u=require("../../../dialog/common/helpers.js"),c=require("./hooks/useProductRelatedQuery.js"),n=require("./ProductListCarouselLayout.js"),a=require("./constants/index.js"),g=require("./hooks/useCollectionQuery.js"),m=require("./hooks/useProductsQuery.js"),P=require("./ProductListGridLayout.js"),C=require("./common/classes.js"),h=require("./common/helpers.js"),T=require("./common/styles.js"),S=require("@gem-sdk/system"),O=require("next/head");const _=i(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:s.default});exports.default=i=>{let{children:p,styles:f,builderProps:R,setting:U,builderAttrs:j}=i,{isRelatedProduct:y,productSetting:D}=h.getData(i),{isEditMode:I,isPreviewSharePageMode:L}=r.useRenderMode(),k=r.useCurrentDevice(),x=r.usePageType(),q=r.usePageStore(e=>e.dynamicCollection),[E,b]=o.useState(1),[v,N]=o.useState(!0),w=o.useRef(),M="GP_FUNNEL_PAGE"===x;"GP_COLLECTION"!=x||[t.PRODUCT_LIST_PRODUCT_SOURCE.Collection,t.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection].includes(D?.productSrc)||(D.productSrc=t.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection);let A=D?.productSrc??t.PRODUCT_LIST_PRODUCT_SOURCE.Collection;A===t.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection&&(D.collectionId=q?.collectionId||"latest");let G=Number.isNaN(Number(U?.numberOfProducts))?a.DEFAULT_COLLECTION_NUMBER_OF_PRODUCTS:Number(U?.numberOfProducts),{relatedProductIdAssigned:B}=l.default({productSetting:D}),{isNotFoundRelatedProduct:F,relatedProducts:H,isNoRelatedProductData:Q,relatedTagString:z,isLoading:W}=c.default({productSetting:D,isRelatedProduct:y,relatedProductIdAssigned:B,numberOfProducts:G}),$=I||L,V=m.useProductsQuery({productIds:D?.productIds,defaultSelectedProductCount:D?.numOfSelectedProducts,productSrc:A,selectedStatus:$&&D?.productIds?.length?r.PICKED_PRODUCT_STATUSES:void 0}),K=g.useCollectionQuery({productSrc:A,collectionID:D?.collectionId??"latest",numberOfProducts:G,orderBy:U?.orderBy}),J=W||(A===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?V.isLoading:K.isLoading),X=A===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?V.error:K.error,Y=A===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?V.isValidating:K.isValidating,Z=K.data?.collections?.edges?.[0]?.node,ee=A===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?r.flattenConnection(V.data?.products):r.flattenConnection(Z?.products),et=r.usePageStore(e=>e.assignedProductIds),er=r.usePageStore(e=>e.isApplyAllProducts),eo=o.useMemo(()=>(et??[]).length>0&&!er||er,[et,er]),es=H?.data?.products&&eo?r.flattenConnection(H?.data?.products):[],ei=y?es:A===t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct&&D?.productIds?.length?D?.productIds?.map(e=>ee?.find(t=>t?.baseID===e)).filter(Boolean)??ee:A!==t.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?ee:ee.filter((e,t)=>t<(D?.numOfSelectedProducts??4)),el=o.useMemo(()=>F&&y&&I||!ei.length&&!J&&v&&I,[v,J,F,y,I,ei.length]),ed=o.useMemo(()=>!ei||F&&y,[F,y,ei]),eu=o.useMemo(()=>{if(!U?.sameHeight)return[];let e=0,t=Math.ceil((ei?.length??0)/+(U?.slidesToShow?.[k]??1));return Array.from(Array(ei?.length??0)).map((r,o)=>(o>=+(U?.slidesToShow?.[k]??1)*(e+1)&&++e,{gridRow:`${1+E*e}/${E+1+E*e}`,marginBottom:e+1<t?u.getPropertyByDevice(f?.horizontalGutter,k):void 0}))},[U?.sameHeight,U?.slidesToShow,E,ei?.length,k,f?.horizontalGutter]),ec=o.useMemo(()=>Y||J||X||!ei||F&&y,[X,J,F,y,Y,ei]);o.useEffect(()=>{if(!ec)return w.current=setTimeout(()=>{let{builderData:e}=R??{},t=e?.childrens?.[0];if(!t)return;let r=document.querySelector(`[data-id=${t}] div`);r&&b(r.childElementCount||1)},I?0:500),()=>{clearTimeout(w.current)}},[R,ec,I,ei]);let en=o.useMemo(()=>({collection:Z,products:ei,settings:{loop:U?.loop??{desktop:!1},scrollMode:U?.scrollMode??{desktop:"snap"},slidesToShow:U?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:f?.layout,dot:U?.dot,dotStyle:U?.dotStyle,arrow:U?.arrow,controlOverContent:U?.controlOverContent,sameHeight:U?.sameHeight},styles:{horizontalGutter:f?.horizontalGutter,verticalGutter:f?.verticalGutter,fullWidth:f?.fullWidth,spacing:f?.spacing,width:f?.width,height:f?.height}}),[Z,ei,U,f]);if(R?.isPreview&&M)return e.jsx(e.Fragment,{});if(el)return e.jsx(e.Fragment,{children:S.If(v,e.jsx(_,{builderAttrs:j,collectionHandle:Z?.handle,productSrc:A,onClose:()=>N(!1),children:p,relatedTagString:z,assignProductNoTags:Q,noAssignedProduct:!B}))});let{productListWrapStyle:ea,productListContentStyle:eg,productListWrapAlignStyle:em}=T.getStyle(i),{productListWrapClass:eP}=C.getClass(i);return e.jsxs("div",{...j,className:eP,style:ea,children:[!!f?.preloadBgImage&&e.jsxs(O,{children:[!!f.backgroundImage?.desktop?.image?.src&&e.jsx("link",{rel:"preload",href:f.backgroundImage.desktop.image.src,as:"image"}),!!f.backgroundImage?.tablet?.image?.src&&e.jsx("link",{rel:"preload",href:f.backgroundImage?.tablet?.image?.src,as:"image"}),!!f.backgroundImage?.mobile?.image?.src&&e.jsx("link",{rel:"preload",href:f.backgroundImage?.mobile?.image?.src,as:"image"})]}),J||Y?e.jsx(s.default,{}):X?e.jsxs("div",{children:["Error: ",X?.message]}):ed?e.jsx("div",{children:"Products not found"}):e.jsx(r.ProductListProvider,{...en,children:e.jsx("div",{className:"gp-flex gp-w-full",style:em,children:e.jsxs("div",{style:eg,children:[M&&e.jsx(d.default,{}),e.jsx(e.Fragment,{children:S.If(f?.layout==="grid",e.jsx(P.default,{...i,productSortedById:ei,generateGridRowArray:eu}),e.jsx(n.default,{...i,productSortedById:ei}))})]})})}),r.filterToolbarPreview(p,!0)]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../common/helpers.js"),r=require("../../../common/const.js"),o=require("@gem-sdk/core"),s=require("react"),l=require("../../../common/components/Loading.js"),i=require("next/dynamic"),d=require("./hooks/useRelatedProductIDAssigned.js"),u=require("../SalePageProductListWarning.js"),a=require("../../../dialog/common/helpers.js"),n=require("./hooks/useProductRelatedQuery.js"),c=require("./ProductListCarouselLayout.js"),g=require("./constants/index.js"),m=require("./hooks/useCollectionQuery.js"),P=require("./hooks/useProductsQuery.js"),C=require("./ProductListGridLayout.js"),h=require("./common/classes.js"),T=require("./common/helpers.js"),S=require("./common/styles.js"),O=require("@gem-sdk/system"),p=require("next/head");const _=i(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:l.default});exports.default=i=>{let{children:f,styles:R,builderProps:U,setting:y,builderAttrs:D}=i,{isRelatedProduct:j,productSetting:I}=T.getData(i),{isEditMode:L,isPreviewSharePageMode:b}=o.useRenderMode(),x=o.useCurrentDevice(),k=o.usePageType(),q=o.usePageStore(e=>e.dynamicCollection),[E,v]=s.useState(1),[N,w]=s.useState(!0),M=s.useRef(),A="GP_FUNNEL_PAGE"===k;"GP_COLLECTION"!=k||[r.PRODUCT_LIST_PRODUCT_SOURCE.Collection,r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection].includes(I?.productSrc)||(I.productSrc=r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection);let G=I?.productSrc??r.PRODUCT_LIST_PRODUCT_SOURCE.Collection;G===r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection&&(I.collectionId=q?.collectionId||"latest");let B=Number.isNaN(Number(y?.numberOfProducts))?g.DEFAULT_COLLECTION_NUMBER_OF_PRODUCTS:Number(y?.numberOfProducts),{relatedProductIdAssigned:F}=d.default({productSetting:I}),{isNotFoundRelatedProduct:Q,relatedProducts:H,isNoRelatedProductData:z,relatedTagString:W,isLoading:$}=n.default({productSetting:I,isRelatedProduct:j,relatedProductIdAssigned:F,numberOfProducts:B}),K=L||b,V=P.useProductsQuery({productIds:I?.productIds,defaultSelectedProductCount:I?.numOfSelectedProducts,productSrc:G,selectedStatus:K&&I?.productIds?.length?o.PICKED_PRODUCT_STATUSES:void 0}),J=m.useCollectionQuery({productSrc:G,collectionID:I?.collectionId??"latest",numberOfProducts:B,orderBy:y?.orderBy}),X=G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct,Y=X?V:J,Z=X?!!I?.productIds:G===r.PRODUCT_LIST_PRODUCT_SOURCE.Collection||G===r.PRODUCT_LIST_PRODUCT_SOURCE.DynamicCollection,ee=$||t.isQueryLoading({hasQuery:Z,data:Y.data,error:Y.error,isLoading:Y.isLoading}),et=Y.error,er=Y.isValidating,eo=J.data?.collections?.edges?.[0]?.node,es=G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?o.flattenConnection(V.data?.products):o.flattenConnection(eo?.products),el=o.usePageStore(e=>e.assignedProductIds),ei=o.usePageStore(e=>e.isApplyAllProducts),ed=s.useMemo(()=>(el??[]).length>0&&!ei||ei,[el,ei]),eu=H?.data?.products&&ed?o.flattenConnection(H?.data?.products):[],ea=j?eu:G===r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct&&I?.productIds?.length?I?.productIds?.map(e=>es?.find(t=>t?.baseID===e)).filter(Boolean)??es:G!==r.PRODUCT_LIST_PRODUCT_SOURCE.PickProduct?es:es.filter((e,t)=>t<(I?.numOfSelectedProducts??4)),en=s.useMemo(()=>Q&&j&&L||!ea.length&&!ee&&N&&L,[N,ee,Q,j,L,ea.length]),ec=s.useMemo(()=>!ea||Q&&j,[Q,j,ea]),eg=s.useMemo(()=>{if(!y?.sameHeight)return[];let e=0,t=Math.ceil((ea?.length??0)/+(y?.slidesToShow?.[x]??1));return Array.from(Array(ea?.length??0)).map((r,o)=>(o>=+(y?.slidesToShow?.[x]??1)*(e+1)&&++e,{gridRow:`${1+E*e}/${E+1+E*e}`,marginBottom:e+1<t?a.getPropertyByDevice(R?.horizontalGutter,x):void 0}))},[y?.sameHeight,y?.slidesToShow,E,ea?.length,x,R?.horizontalGutter]),em=s.useMemo(()=>er||ee||et||!ea||Q&&j,[et,ee,Q,j,er,ea]);s.useEffect(()=>{if(!em)return M.current=setTimeout(()=>{let{builderData:e}=U??{},t=e?.childrens?.[0];if(!t)return;let r=document.querySelector(`[data-id=${t}] div`);r&&v(r.childElementCount||1)},L?0:500),()=>{clearTimeout(M.current)}},[U,em,L,ea]);let eP=s.useMemo(()=>({collection:eo,products:ea,settings:{loop:y?.loop??{desktop:!1},scrollMode:y?.scrollMode??{desktop:"snap"},slidesToShow:y?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:R?.layout,dot:y?.dot,dotStyle:y?.dotStyle,arrow:y?.arrow,controlOverContent:y?.controlOverContent,sameHeight:y?.sameHeight},styles:{horizontalGutter:R?.horizontalGutter,verticalGutter:R?.verticalGutter,fullWidth:R?.fullWidth,spacing:R?.spacing,width:R?.width,height:R?.height}}),[eo,ea,y,R]);if(U?.isPreview&&A)return e.jsx(e.Fragment,{});if(en)return e.jsx(e.Fragment,{children:O.If(N,e.jsx(_,{builderAttrs:D,collectionHandle:eo?.handle,productSrc:G,onClose:()=>w(!1),children:f,relatedTagString:W,assignProductNoTags:z,noAssignedProduct:!F}))});let{productListWrapStyle:eC,productListContentStyle:eh,productListWrapAlignStyle:eT}=S.getStyle(i),{productListWrapClass:eS}=h.getClass(i);return e.jsxs("div",{...D,className:eS,style:eC,children:[!!R?.preloadBgImage&&e.jsxs(p,{children:[!!R.backgroundImage?.desktop?.image?.src&&e.jsx("link",{rel:"preload",href:R.backgroundImage.desktop.image.src,as:"image"}),!!R.backgroundImage?.tablet?.image?.src&&e.jsx("link",{rel:"preload",href:R.backgroundImage?.tablet?.image?.src,as:"image"}),!!R.backgroundImage?.mobile?.image?.src&&e.jsx("link",{rel:"preload",href:R.backgroundImage?.mobile?.image?.src,as:"image"})]}),ee||er?e.jsx(l.default,{label:t.getElementLabel({builderData:U?.builderData})}):et?e.jsxs("div",{children:["Error: ",et?.message]}):ec?e.jsx("div",{children:"Products not found"}):e.jsx(o.ProductListProvider,{...eP,children:e.jsx("div",{className:"gp-flex gp-w-full",style:eT,children:e.jsxs("div",{style:eh,children:[A&&e.jsx(u.default,{}),e.jsx(e.Fragment,{children:O.If(R?.layout==="grid",e.jsx(C.default,{...i,productSortedById:ea,generateGridRowArray:eg}),e.jsx(c.default,{...i,productSortedById:ea}))})]})})}),o.filterToolbarPreview(f,!0)]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@gem-sdk/core"),t=require("../../../grid/components/ChildrenDroppable.js"),s=require("./hook/useProductSetting.js"),i=require("./common/helpers.js");require("../../../common/const.js"),require("react");var o=require("../../../common/components/Loading.js"),d=require("@gem-sdk/system"),n=require("../../../grid/components/row/Row.js"),u=require("next/dynamic");const c=u(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:o.default});exports.default=u=>{let{builderProps:l,children:a,setting:m,style:j,builderAttrs:g}=u,{isAuto:h}=m??{},{isLoading:p,isProductPage:x,isProductNotFound:q,showProductNotFound:f,errorLoadProduct:P,product:y,isEditor:v,productProviderData:b,setShowProductNotFound:F}=s.useProductSetting(u),{rowSetting:k,rowStyles:C}=i.getData(u);return x&&h?e.jsx(e.Fragment,{children:r.isEmptyChildren(a)?e.jsx(t.default,{}):a}):e.jsx(e.Fragment,{children:d.If(!q,e.jsx(e.Fragment,{children:p?e.jsx(o.default,{}):e.jsx(e.Fragment,{children:P?e.jsxs("div",{children:["Error: ",P?.message]}):y?e.jsx(r.ProductProvider,{...b,children:e.jsx(n.default,{builderProps:l,builderAttrs:g,style:j,styles:C,setting:k,customAttrs:v?{"data-product-id":y?.baseID?.replace("gid://shopify/Product/","")??""}:void 0,children:r.isEmptyChildren(a)?e.jsx(t.default,{}):a})}):null})}),e.jsx(e.Fragment,{children:d.If(f,e.jsx(c,{builderAttrs:g,productSrc:"PickProduct",onClose:()=>F(!1),children:a}))}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@gem-sdk/core"),t=require("../../../grid/components/ChildrenDroppable.js"),s=require("./hook/useProductSetting.js"),i=require("../../../common/helpers.js");require("../../../common/const.js"),require("react");var o=require("../../../common/components/Loading.js"),d=require("./common/helpers.js"),n=require("@gem-sdk/system"),u=require("../../../grid/components/row/Row.js"),l=require("next/dynamic");const c=l(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:o.default});exports.default=l=>{let{builderProps:a,children:m,setting:j,style:g,builderAttrs:h}=l,{isAuto:p}=j??{},{isLoadingProduct:x,isProductPage:q,isProductNotFound:f,showProductNotFound:P,errorLoadProduct:b,product:y,isEditor:v,productProviderData:F,setShowProductNotFound:D}=s.useProductSetting(l),{rowSetting:k,rowStyles:C}=d.getData(l);return q&&p?e.jsx(e.Fragment,{children:r.isEmptyChildren(m)?e.jsx(t.default,{}):m}):e.jsx(e.Fragment,{children:n.If(!f,e.jsx(e.Fragment,{children:x?e.jsx(o.default,{label:i.getElementLabel({builderData:a?.builderData})}):e.jsx(e.Fragment,{children:b?e.jsxs("div",{children:["Error: ",b?.message]}):y?e.jsx(r.ProductProvider,{...F,children:e.jsx(u.default,{builderProps:a,builderAttrs:h,style:g,styles:C,setting:k,customAttrs:v?{"data-product-id":y?.baseID?.replace("gid://shopify/Product/","")??""}:void 0,children:r.isEmptyChildren(m)?e.jsx(t.default,{}):m})}):null})}),e.jsx(e.Fragment,{children:n.If(P,e.jsx(c,{builderAttrs:h,productSrc:"PickProduct",onClose:()=>D(!1),children:m}))}))})};
@@ -1 +1 @@
1
- "use strict";var e=require("@gem-sdk/core"),t=require("./useProductQuery.js"),r=require("react");exports.useProductSetting=a=>{let{setting:d}=a,{productSetting:u,quantity:i,readOnly:s,isSyncProduct:c}=d??{},o=e.usePageType(),P=e.usePageStore(e=>e.dynamicProduct),{isEditMode:n}=e.useRenderMode(),l=u?.productId??"latest",S=u?.productStatus=="dynamic"?{...u,...P}:u,g=S?.initialVariantId,p=S?.initialVariantBaseId,{productData:{data:y,isLoading:m,error:h}}=t.default({id:l}),[q,I]=r.useState(!0),k=(h||!y&&!m)&&n,D=r.useMemo(()=>({product:y,initialVariantId:g,initialVariantBaseId:p,quantity:i,readOnly:s,isSyncProduct:c,key:`uid-${y?.id}-${g??""}`,hasPreSelected:u?.hasPreSelected}),[p,g,c,y,u?.hasPreSelected,i,s]);return{forceProductSetting:S,isProductPage:"PRODUCT"===o,isProductNotFound:k,showProductNotFound:q,isLoading:m,product:y,errorLoadProduct:h,isEditor:n,productProviderData:D,setShowProductNotFound:I}};
1
+ "use strict";var e=require("@gem-sdk/core"),r=require("../../../../common/helpers.js");require("../../../../common/const.js"),require("react/jsx-runtime");var t=require("react"),a=require("./useProductQuery.js");exports.useProductSetting=u=>{let{setting:d}=u,{productSetting:i,quantity:s,readOnly:o,isSyncProduct:c}=d??{},n=e.usePageType(),P=e.usePageStore(e=>e.dynamicProduct),{isEditMode:l}=e.useRenderMode(),m=i?.productId??"latest",y=i?.productStatus=="dynamic"?{...i,...P}:i,S=y?.initialVariantId,g=y?.initialVariantBaseId,{productData:{data:p,isLoading:q,error:h}}=a.default({id:m}),[j,I]=t.useState(!0),Q=r.isQueryLoading({hasQuery:!!m,data:p,error:h,isLoading:q}),k=(h||!p&&!Q)&&l,v=t.useMemo(()=>({product:p,initialVariantId:S,initialVariantBaseId:g,quantity:s,readOnly:o,isSyncProduct:c,key:`uid-${p?.id}-${S??""}`,hasPreSelected:i?.hasPreSelected}),[g,S,c,p,i?.hasPreSelected,s,o]);return{forceProductSetting:y,isProductPage:"PRODUCT"===n,isProductNotFound:k,showProductNotFound:j,isLoadingProduct:Q,product:p,errorLoadProduct:h,isEditor:l,productProviderData:v,setShowProductNotFound:I}};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useEditorMode as i,splitStyle as l,composeAdvanceStyle as a,useBlogsQuery as r,useArticlesQuery as o,flattenConnection as d,filterToolbarPreview as n,ArticleListProvider as s,ArticleProvider as c,isEmptyChildren as m,cls as g,makeStyleResponsive as p,getResponsiveValueByScreen as h,getGradientBgrStyleByDevice as u,getStyleBackgroundByDevice as b,makeStyleWithDefault as f,makeWidth as w}from"@gem-sdk/core";import T from"../../grid/components/ChildrenDroppable.js";import y from"./ArticleNotFound.js";import"../../common/const.js";import{useState as A}from"react";import D from"../../common/components/Loading.js";let v=v=>{let S=i(),{styles:O,setting:k,className:I,children:E,builderProps:L,advanced:P,builderAttrs:G,style:_}=v??{},{articleSetting:j,numberOfArticle:x}=k??{},{articleIds:C,articlePickType:M}=j??{},{border:N,rounded:z,hasBoxShadow:B,boxShadow:F}=P??{},[R]=l(["pos","top","left","bottom","right","z","d"],_),U=a({border:N,rounded:z,hasBoxShadow:B,boxShadow:F,"spacing-setting":P?.["spacing-setting"]}),$={first:C?.length||50,where:{baseIDIn:[...j?.articleIds??[]]},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},V={first:1,where:{baseID:j?.blogId},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"},articlesOrderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},[H,q]=A(!0),J=r("latest"===M?V:null,{revalidateOnMount:!0}),K=o("manually"===M?$:null,{revalidateOnMount:!0}),Q=J.data?.blogs?.edges?.[0]?.node,W="manually"===M?K.isLoading:J.isLoading,X="manually"===M?K.isValidating:J.isValidating,Y="manually"===M?K.error:J.error,Z=J?.data?.blogs?.edges?.[0]?.node,ee="latest"===M?d(Z?.articles):d(K?.data?.articles),et=(e,t)=>({...e??{},blog:{title:t?.title??"",handle:t?.handle??""}}),ei="latest"===M?ee?.filter((e,t)=>t<+(x||4)).map(e=>et(e,Z)):"manually"===M&&j?.articleIds?.length?C?.map(e=>{let t=ee?.find(t=>t?.baseID===e);return et(t,t?.blogs?.edges?.[0]?.node)}).filter(Boolean):ee.filter((e,t)=>t<(j?.numOfSelectedArticles||4)).map(e=>et(e,e?.blogs?.edges?.[0]?.node));return ei?.length||W||"edit"!=S?e("div",{...G,className:L?.builderData?.uid,style:R,children:[X||W?t(D,{}):Y?e("div",{children:["Error: ",Y?.message]}):ei?.length?t(s,{styles:{horizontalGutter:O?.horizontalGutter,verticalGutter:O?.verticalGutter,spacing:O?.spacing,width:O?.width,height:O?.height},settings:{slidesToShow:k?.slideToShow??{desktop:4,tablet:3,mobile:1}},articles:ei,children:t("div",{"data-id":L?.uid,className:"gp-relative",children:t("div",{style:{...U,...f("w",w(O?.width),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),...p("rg",O?.horizontalGutter),...p("cg",O?.verticalGutter),...b(k?.background),...u(k?.background),...p("gtc",{desktop:`repeat(${h(k?.slideToShow,"desktop")}, minmax(0, 1fr))`,tablet:k?.slideToShow?.tablet&&`repeat(${h(k?.slideToShow,"tablet")}, minmax(0, 1fr))`,mobile:k?.slideToShow?.mobile&&`repeat(${h(k?.slideToShow,"mobile")}, minmax(0, 1fr))`})},className:g(I,"gp-m-auto gp-grid gp-w-full"),children:ei.map(e=>t(c,{article:e,readOnly:!0,children:t("div",{"data-component-type":"component","data-component-tag":"Article","data-component-label":"Article","data-component-no-setting":!0,"data-article-id":e?.baseID?.replace("gid://shopify/OnlineStoreArticle/",""),children:m(E)?t(T,{}):E})},e?.id))})})}):t("div",{children:"Articles not found"}),n(E,!0)]}):H?e("div",{...G,className:L?.builderData?.uid,children:[t(y,{blogHandle:Q?.handle,onClose:()=>q(!1),articlePickType:M??"manually",children:E}),n(E,!0)]}):null};export{v as default};
2
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useEditorMode as i,splitStyle as l,composeAdvanceStyle as r,useBlogsQuery as a,useArticlesQuery as o,flattenConnection as d,filterToolbarPreview as n,ArticleListProvider as s,ArticleProvider as c,isEmptyChildren as m,cls as g,makeStyleResponsive as p,getResponsiveValueByScreen as h,getGradientBgrStyleByDevice as u,getStyleBackgroundByDevice as b,makeStyleWithDefault as f,makeWidth as D}from"@gem-sdk/core";import w from"../../grid/components/ChildrenDroppable.js";import{getElementLabel as T,isQueryLoading as A}from"../../common/helpers.js";import"../../common/const.js";import{useState as y}from"react";import v from"../../common/components/Loading.js";import S from"./ArticleNotFound.js";let O=O=>{let k=i(),{styles:I,setting:E,className:L,children:P,builderProps:j,advanced:G,builderAttrs:_,style:x}=O??{},{articleSetting:C,numberOfArticle:M}=E??{},{articleIds:N,articlePickType:z}=C??{},{border:B,rounded:F,hasBoxShadow:R,boxShadow:U}=G??{},[$]=l(["pos","top","left","bottom","right","z","d"],x),H=r({border:B,rounded:F,hasBoxShadow:R,boxShadow:U,"spacing-setting":G?.["spacing-setting"]}),Q={first:N?.length||50,where:{baseIDIn:[...C?.articleIds??[]]},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},V={first:1,where:{baseID:C?.blogId},orderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"},articlesOrderBy:{direction:"DESC",field:"PLATFORM_UPDATED_AT"}},[q,J]=y(!0),K="manually"===z,W="latest"===z,X=a(W?V:null,{revalidateOnMount:!0}),Y=o(K?Q:null,{revalidateOnMount:!0}),Z=X.data?.blogs?.edges?.[0]?.node,ee=K?Y:X,et=ee.error,ei=ee.isValidating,el=A({hasQuery:K||W,data:ee.data,error:ee.error,isLoading:ee.isLoading}),er=X?.data?.blogs?.edges?.[0]?.node,ea="latest"===z?d(er?.articles):d(Y?.data?.articles),eo=(e,t)=>({...e??{},blog:{title:t?.title??"",handle:t?.handle??""}}),ed="latest"===z?ea?.filter((e,t)=>t<+(M||4)).map(e=>eo(e,er)):"manually"===z&&C?.articleIds?.length?N?.map(e=>{let t=ea?.find(t=>t?.baseID===e);return eo(t,t?.blogs?.edges?.[0]?.node)}).filter(Boolean):ea.filter((e,t)=>t<(C?.numOfSelectedArticles||4)).map(e=>eo(e,e?.blogs?.edges?.[0]?.node));return ed?.length||el||"edit"!=k?e("div",{..._,className:j?.builderData?.uid,style:$,children:[ei||el?t(v,{label:T({builderData:j?.builderData})}):et?e("div",{children:["Error: ",et?.message]}):ed?.length?t(s,{styles:{horizontalGutter:I?.horizontalGutter,verticalGutter:I?.verticalGutter,spacing:I?.spacing,width:I?.width,height:I?.height},settings:{slidesToShow:E?.slideToShow??{desktop:4,tablet:3,mobile:1}},articles:ed,children:t("div",{"data-id":j?.uid,className:"gp-relative",children:t("div",{style:{...H,...f("w",D(I?.width),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),...p("rg",I?.horizontalGutter),...p("cg",I?.verticalGutter),...b(E?.background),...u(E?.background),...p("gtc",{desktop:`repeat(${h(E?.slideToShow,"desktop")}, minmax(0, 1fr))`,tablet:E?.slideToShow?.tablet&&`repeat(${h(E?.slideToShow,"tablet")}, minmax(0, 1fr))`,mobile:E?.slideToShow?.mobile&&`repeat(${h(E?.slideToShow,"mobile")}, minmax(0, 1fr))`})},className:g(L,"gp-m-auto gp-grid gp-w-full"),children:ed.map(e=>t(c,{article:e,readOnly:!0,children:t("div",{"data-component-type":"component","data-component-tag":"Article","data-component-label":"Article","data-component-no-setting":!0,"data-article-id":e?.baseID?.replace("gid://shopify/OnlineStoreArticle/",""),children:m(P)?t(w,{}):P})},e?.id))})})}):t("div",{children:"Articles not found"}),n(P,!0)]}):q?e("div",{..._,className:j?.builderData?.uid,children:[t(S,{blogHandle:Z?.handle,onClose:()=>J(!1),articlePickType:z??"manually",children:P}),n(P,!0)]}):null};export{O as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsxs as e,jsx as g}from"react/jsx-runtime";let l=()=>e("div",{className:"gp-loading-placeholder gp-relative gp-my-0.5 gp-h-3 gp-w-full gp-overflow-hidden",children:[g("div",{className:"gp-absolute gp-h-full gp-w-full gp-bg-gray-200"}),g("div",{className:"gp-absolute gp-h-full gp-bg-green-500 gp-animate-progress-bar"})]});export{l as default};
2
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{useLoadingProgress as l}from"../hooks/useLoadingProgress.js";import{useElementWidth as g}from"../hooks/useElementWidth.js";import{LOADING_MIN_WIDTH as p}from"../const.js";import{getLoadingErrorText as r,getLoadingText as o}from"../helpers.js";let t="gp-loading-placeholder gp-border-loading-frame gp-flex gp-w-full gp-flex-col gp-gap-4 gp-overflow-hidden gp-border-[0.5px] gp-border-solid gp-bg-white",d="gp-text-loading-label !gp-font-g-ui !gp-text-xs !gp-font-medium !gp-leading-5 gp-px-4 gp-text-center",a=({label:a,error:n,retry:s})=>{let m=l(),{ref:c,width:h}=g(),f=(({minWidth:e})=>void 0===h||h>e)({minWidth:p.SHOW_TEXT}),u=(({minWidth:e})=>void 0===h||h>e)({minWidth:p.SHOW_LABEL});return n?e("div",{ref:c,className:t,children:i("div",{className:`${d} gp-py-4`,children:[r({label:a,hasRoomForLabel:u}),!!s&&e("button",{type:"button",onClick:s,className:"gp-ml-1 gp-underline",children:"Retry"})]})}):i("div",{ref:c,className:t,children:[e("div",{className:"gp-h-0.5 gp-w-full gp-bg-loading-track",children:e("div",{className:"gp-bg-loading-bar gp-h-full gp-transition-[width] gp-duration-100 gp-ease-linear",style:{width:`${m}%`}})}),f&&e("div",{className:`${d} gp-pb-4`,children:o({label:a,percent:m,hasRoomForLabel:u})})]})};export{a as default};
@@ -1 +1 @@
1
- var o;let c={STICKY:999,DIALOG:100001,CART_DRAWER:100002,CART_DRAWER_CONFIRM_MODAL:100003};!function(o){o.Collection="Collection",o.PickProduct="PickProduct",o.DynamicCollection="DynamicCollection",o.RelatedProduct="RelatedProduct"}(o||(o={}));export{c as ELEMENT_Z_INDEX,o as PRODUCT_LIST_PRODUCT_SOURCE};
1
+ var e;let t={STICKY:999,DIALOG:100001,CART_DRAWER:100002,CART_DRAWER_CONFIRM_MODAL:100003};!function(e){e.Collection="Collection",e.PickProduct="PickProduct",e.DynamicCollection="DynamicCollection",e.RelatedProduct="RelatedProduct"}(e||(e={}));let c={TICK_MS:100,MILESTONES:[{atMs:0,percent:0},{atMs:500,percent:30},{atMs:1e3,percent:50},{atMs:3e3,percent:75},{atMs:5e3,percent:83},{atMs:1e4,percent:90},{atMs:2e4,percent:96}],MAX_PERCENT:99,TAIL_MS:6e4},_={SHOW_LABEL:154,SHOW_TEXT:55};export{t as ELEMENT_Z_INDEX,_ as LOADING_MIN_WIDTH,c as LOADING_PROGRESS,e as PRODUCT_LIST_PRODUCT_SOURCE};
@@ -0,0 +1 @@
1
+ let e=({builderData:e})=>e?.customLabel??e?.label,o=({label:e,percent:o,hasRoomForLabel:a})=>a?e?`Loading ${e}...${o}%`:`Loading ${o}%`:`${o}%`,a=({label:e,hasRoomForLabel:o})=>e&&o?`${e} failed to load.`:"Failed to load.",d=({hasQuery:e,data:o,error:a,isLoading:d})=>d||e&&void 0===o&&void 0===a;export{e as getElementLabel,a as getLoadingErrorText,o as getLoadingText,d as isQueryLoading};
@@ -0,0 +1 @@
1
+ import{useIsomorphicLayoutEffect as e}from"@gem-sdk/core";import{useRef as t,useState as r}from"react";let n=()=>{let n=t(null),[i,o]=r();return e(()=>{let e=n.current;if(!e||(o(e.getBoundingClientRect().width),"undefined"==typeof ResizeObserver))return;let t=new ResizeObserver(e=>{let t=e[0];t&&o(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),{ref:n,width:i}};export{n as useElementWidth};
@@ -0,0 +1 @@
1
+ let e;import{useState as t,useEffect as r}from"react";import{LOADING_PROGRESS as a}from"../const.js";let{MILESTONES:l,MAX_PERCENT:o,TAIL_MS:n,TICK_MS:s}=a,u=l[l.length-1],f=({value:e,fromValue:t,toValue:r,fromResult:a,toResult:l})=>r===t?l:a+(l-a)*((e-t)/(r-t)),M=({elapsedMs:e})=>{if(e>=u.atMs){let t=f({value:e,fromValue:u.atMs,toValue:u.atMs+n,fromResult:u.percent,toResult:o});return Math.floor(Math.min(t,o))}let t=l.findIndex(t=>e<t.atMs),r=l[t-1]??l[0],a=l[t];return Math.floor(f({value:e,fromValue:r.atMs,toValue:a.atMs,fromResult:r.percent,toResult:a.percent}))},i=new Map,m=()=>{let e=Date.now();i.forEach((t,r)=>r(e-t))},c=t=>(i.set(t,Date.now()),e=e??setInterval(m,s),()=>{i.delete(t),!i.size&&e&&(clearInterval(e),e=void 0)}),p=()=>{let[e,a]=t(0);return r(()=>{let e=()=>{};return e=c(t=>{let r=M({elapsedMs:t});a(r),r>=o&&e()}),()=>e()},[]),e};export{M as getLoadingPercent,p as useLoadingProgress};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as o}from"react/jsx-runtime";import"../../../common/const.js";import"@gem-sdk/core";import{useMemo as t}from"react";import e from"../../../common/components/Loading.js";import r from"../row/Row.js";let m=m=>{let i=t(()=>{let{builderProps:o}=m;return o?.builderData?.name==="SectionLoading"},[m]);return i?o(e,{}):o(r,{...m,setting:{...m.setting,as:"section",isSection:!0}})};export{m as default};
2
+ import{jsx as o}from"react/jsx-runtime";import{getElementLabel as t}from"../../../common/helpers.js";import"../../../common/const.js";import"@gem-sdk/core";import{useMemo as e}from"react";import r from"../../../common/components/Loading.js";import m from"../row/Row.js";let i=i=>{let{builderProps:n}=i,a=e(()=>n?.builderData?.name==="SectionLoading",[n]);return a?o(r,{label:t({builderData:n?.builderData})}):o(m,{...i,setting:{...i.setting,as:"section",isSection:!0}})};export{i as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as o,Fragment as t}from"react/jsx-runtime";import{createElement as e}from"react";import{getProductOfferContainerClasses as r,getProductOfferWrapperClasses as m}from"../common/classes.js";import{getWrapperStyles as s,getContainerStyles as c}from"../common/styles.js";import{useProductOfferData as a}from"../hooks/useProductOfferData.js";import{createClass as d,createStyle as i}from"@gem-sdk/system";import{ProductOfferItem as l}from"./ProductOfferItem.js";import"../../../../../common/const.js";import"@gem-sdk/core";import n from"../../../../../common/components/Loading.js";let p=p=>{let{styles:f,builderAttrs:u,builderProps:h,setting:j}=p,{isLoading:P,productSortedById:y,totalProduct:g}=a(),k=d({...r(h?.uid)}),v=d({...m()}),x=i({...s(f)}),O=i({...c(j)});return o(t,{children:P?o(n,{}):y?.length?o("div",{...u,className:k,style:O,children:o("div",{className:v,style:x,children:y?.map((o,t)=>e(l,{...p,product:o,index:t,key:t,totalProduct:g}))})}):o("div",{children:"You haven't set up a product yet. Please go back to the sales funnel details to add a product."})})};export{p as default};
2
+ import{jsx as e,Fragment as o}from"react/jsx-runtime";import{createElement as r}from"react";import{getProductOfferContainerClasses as t,getProductOfferWrapperClasses as m}from"../common/classes.js";import{getWrapperStyles as s,getContainerStyles as i}from"../common/styles.js";import{useProductOfferData as a}from"../hooks/useProductOfferData.js";import{getElementLabel as d}from"../../../../../common/helpers.js";import"../../../../../common/const.js";import{useEditorMode as c}from"@gem-sdk/core";import l from"../../../../../common/components/Loading.js";import{createClass as n,createStyle as f}from"@gem-sdk/system";import{getOfferErrorText as p}from"../helpers/getOfferErrorText.js";import{ProductOfferItem as u}from"./ProductOfferItem.js";let h=h=>{let{styles:g,builderAttrs:j,builderProps:P,setting:y}=h,{isLoading:k,errorMsg:v,productSortedById:b,totalProduct:x}=a(),O=c(),D=n({...t(P?.uid)}),E=n({...m()}),N=f({...s(g)}),I=f({...i(y)}),L=!!v&&!b?.length,T=p({message:v?.message,isEditor:"edit"===O});return e(o,{children:k?e(l,{label:d({builderData:P?.builderData})}):L?e("div",{children:T}):b?.length?e("div",{...j,className:D,style:I,children:e("div",{className:E,style:N,children:b?.map((e,o)=>r(u,{...h,product:e,index:o,key:o,totalProduct:x}))})}):e("div",{children:"You haven't set up a product yet. Please go back to the sales funnel details to add a product."})})};export{h as default};
@@ -0,0 +1 @@
1
+ let e="Could not load the offer products",r=`${e}. Please reload the page.`,o=({message:o,isEditor:t})=>t?`${e}: ${o??"unknown error"}`:r;export{o as getOfferErrorText};
@@ -1 +1 @@
1
- import{usePageStore as o,useRenderMode as t,useProductOffersQuery as e,flattenConnection as r}from"@gem-sdk/core";import{productOfferPlaceholder as i}from"../../../constants/ProductOfferPlaceholder.js";import{hasPublicStoreFrontData as n,createStoreFrontFetcher as d}from"../../../helpers/index.js";import{useDynamicProduct as a}from"../../../hooks/useDynamicProduct.js";import{useMemo as p,useEffect as l}from"react";let s=()=>{let s=o(o=>o.productOffers),u=o(o=>o.publicStoreFrontData),{isDynamicProduct:c}=a(),f=o(o=>o.dynamicDiscountOffer),{isEditMode:m}=t(),P=p(()=>c?f?.appliedProductCount:s?.length,[f?.appliedProductCount,c,s?.length]),b=p(()=>s?.sort((o,t)=>o?.node?.position&&t?.node?.position?o.node.position-t.node.position:0).map(o=>o?.node?.objectBaseID).filter(Boolean),[s]),{isLoading:h,isValidating:C,data:D}=e(b||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:n(u)?d(u):void 0}),v=p(()=>h||C,[h,C]),O=p(()=>r(D?.products),[D?.products]),g=p(()=>c&&f?.appliedProductCount?Array(f.appliedProductCount).fill(i):b?.map(o=>O?.find(t=>t?.baseID===o)).filter(Boolean),[c,f?.appliedProductCount,b,O]);return l(()=>{if(v||!m)return;let o=new CustomEvent("editor:toolbar:force-active-component",{bubbles:!0,detail:{}});window.dispatchEvent(o)},[v,m]),{isLoading:v,productSortedById:g,totalProduct:P}};export{s as useProductOfferData};
1
+ import{usePageStore as o,useRenderMode as t,useProductOffersQuery as e,flattenConnection as r}from"@gem-sdk/core";import{productOfferPlaceholder as i}from"../../../constants/ProductOfferPlaceholder.js";import{hasPublicStoreFrontData as n,createStoreFrontFetcher as d}from"../../../helpers/index.js";import{useDynamicProduct as p}from"../../../hooks/useDynamicProduct.js";import{isQueryLoading as s}from"../../../../../common/helpers.js";import"../../../../../common/const.js";import"react/jsx-runtime";import{useMemo as a,useEffect as c}from"react";let u=()=>{let u=o(o=>o.productOffers),l=o(o=>o.publicStoreFrontData),{isDynamicProduct:m}=p(),f=o(o=>o.dynamicDiscountOffer),{isEditMode:h}=t(),P=a(()=>m?f?.appliedProductCount:u?.length,[f?.appliedProductCount,m,u?.length]),b=a(()=>u?.sort((o,t)=>o?.node?.position&&t?.node?.position?o.node.position-t.node.position:0).map(o=>o?.node?.objectBaseID).filter(Boolean),[u]),{isLoading:j,isValidating:C,data:D,error:g}=e(b||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:n(l)?d(l):void 0}),v=a(()=>C||s({hasQuery:!0,data:D,error:g,isLoading:j}),[D,g,j,C]),O=a(()=>r(D?.products),[D?.products]),y=a(()=>m&&f?.appliedProductCount?Array(f.appliedProductCount).fill(i):b?.map(o=>O?.find(t=>t?.baseID===o)).filter(Boolean),[m,f?.appliedProductCount,b,O]);return c(()=>{if(v||!h)return;let o=new CustomEvent("editor:toolbar:force-active-component",{bubbles:!0,detail:{}});window.dispatchEvent(o)},[v,h]),{isLoading:v,errorMsg:g,productSortedById:y,totalProduct:P}};export{u as useProductOfferData};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useI18nStore as m,useProduct as o,useCurrentVariant as t,useMoneyFormat as r,useCurrentDevice as i,useProductBundleDiscount as l,useEditorMode as c,useRenderMode as a,usePageType as n,useSafeGetProductListSettings as d,filterToolbarPreview as p}from"@gem-sdk/core";import{getContainerClasses as h,getWrapperClasses as y,getSubWrapperClass as f,getTextContainerClasses as N,getTextWrapperClasses as j,getTextContentClasses as u,getImageContainerClasses as g,getImageClasses as v}from"./common/classes.js";import{getContainerStyle as T,getSubWrapperStyle as k,getContentStyleInternal as x,getTextBadgeWrapperStyles as C,getTextContentStyle as H,getImageContainerStyles as S}from"./common/styles.js";import{getEditTooltipAttrs as b,getSubWrapperAttrs as w,getContainerAttrs as A,getTextContentAttrs as B,getImageAttr as D}from"./common/attrs.js";import{createClass as I,createStyle as M,createAttr as P,If as q}from"@gem-sdk/system";import"../../../common/const.js";import z from"../../../common/components/TooltipHover.js";import E from"../../../common/components/NoDataState.js";import{getBadgeContent as F,getIsNoDiscountState as G}from"./utils/common.js";import"./constants.js";let J=J=>{let{t:K}=m(),{setting:L,styles:O,children:Q,builderAttrs:R,...U}=J,V=o(),W=t(),{moneyFormat:X}=r(),Y=i(),{useProductCompareAtPrice:Z}=l(),$=U?.["bundle-item"],_=c(),{isEditMode:ee}=a(),es="STATIC"===n(),{settings:em}=d(),eo=em?.sameHeight,et=F({detail:V,currentVariant:W,bundleItem:$,useProductCompareAtPrice:Z},L?.displayContent,X),er=G({props:J,product:V,currentVariant:W,moneyFormat:X,useProductCompareAtPrice:Z}),ei=I({...h({mode:_,isInstant:es,product:V,currentVariant:W,props:J,isSameHeightInProductList:eo})}),el=M({...T(J)}),ec=P({...b(J,ee)}),ea=I({...y(J)}),en=I({...f(J,Y)}),ed=M({...k({props:J,product:V,currentVariant:W,isEditMode:ee})}),ep=P({...w(J,V)}),eh=x(J),ey=I({...N()}),ef=P({...A(J)}),eN=I({...j()}),ej=M({...C({setting:L,styles:O})}),eu=I({...u(O)}),eg=M({...H({setting:L,styles:O})}),ev=P({...B()}),eT=I({...g()}),ek=M({...S({setting:L,styles:O})}),ex=I({...v()}),eC=P({...D({setting:L})});return V?e("div",{...ef,style:el,className:ei,children:[q(ee&&er,s(z,{...ec,children:s(E,{...R,elementType:"secondary",description:K("No discount"),rawMode:!0})}),s("div",{className:ea,children:e("div",{...ep,className:en,style:ed,children:[s("style",{children:eh}),q(L?.shape!=="image",s("div",{className:ey,children:s("div",{className:eN,style:ej,children:s("pre",{...ev,className:eu,style:eg,children:et})})}),s("div",{className:eT,style:ek,children:s("img",{...eC,className:ex,alt:""})}))]})})),p(Q,!0)]}):null};export{J as default};
2
+ import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useI18nStore as m,useProduct as o,useCurrentVariant as t,useMoneyFormat as r,useCurrentDevice as i,useProductBundleDiscount as l,useEditorMode as c,useRenderMode as a,usePageType as n,useSafeGetProductListSettings as d,filterToolbarPreview as p}from"@gem-sdk/core";import{getContainerClasses as h,getWrapperClasses as y,getSubWrapperClass as f,getTextContainerClasses as N,getTextWrapperClasses as j,getTextContentClasses as u,getImageContainerClasses as g,getImageClasses as v}from"./common/classes.js";import{getContainerStyle as T,getSubWrapperStyle as k,getContentStyleInternal as x,getTextBadgeWrapperStyles as C,getTextContentStyle as H,getImageContainerStyles as S}from"./common/styles.js";import{getEditTooltipAttrs as b,getSubWrapperAttrs as w,getContainerAttrs as A,getTextContentAttrs as B,getImageAttr as D}from"./common/attrs.js";import{createClass as I,createStyle as M,createAttr as P,If as q}from"@gem-sdk/system";import"../../../common/const.js";import z from"../../../common/components/TooltipHover.js";import E from"../../../common/components/NoDataState.js";import"react";import{getBadgeContent as F,getIsNoDiscountState as G}from"./utils/common.js";import"./constants.js";let J=J=>{let{t:K}=m(),{setting:L,styles:O,children:Q,builderAttrs:R,...U}=J,V=o(),W=t(),{moneyFormat:X}=r(),Y=i(),{useProductCompareAtPrice:Z}=l(),$=U?.["bundle-item"],_=c(),{isEditMode:ee}=a(),es="STATIC"===n(),{settings:em}=d(),eo=em?.sameHeight,et=F({detail:V,currentVariant:W,bundleItem:$,useProductCompareAtPrice:Z},L?.displayContent,X),er=G({props:J,product:V,currentVariant:W,moneyFormat:X,useProductCompareAtPrice:Z}),ei=I({...h({mode:_,isInstant:es,product:V,currentVariant:W,props:J,isSameHeightInProductList:eo})}),el=M({...T(J)}),ec=P({...b(J,ee)}),ea=I({...y(J)}),en=I({...f(J,Y)}),ed=M({...k({props:J,product:V,currentVariant:W,isEditMode:ee})}),ep=P({...w(J,V)}),eh=x(J),ey=I({...N()}),ef=P({...A(J)}),eN=I({...j()}),ej=M({...C({setting:L,styles:O})}),eu=I({...u(O)}),eg=M({...H({setting:L,styles:O})}),ev=P({...B()}),eT=I({...g()}),ek=M({...S({setting:L,styles:O})}),ex=I({...v()}),eC=P({...D({setting:L})});return V?e("div",{...ef,style:el,className:ei,children:[q(ee&&er,s(z,{...ec,children:s(E,{...R,elementType:"secondary",description:K("No discount"),rawMode:!0})}),s("div",{className:ea,children:e("div",{...ep,className:en,style:ed,children:[s("style",{children:eh}),q(L?.shape!=="image",s("div",{className:ey,children:s("div",{className:eN,style:ej,children:s("pre",{...ev,className:eu,style:eg,children:et})})}),s("div",{className:eT,style:ek,children:s("img",{...eC,className:ex,alt:""})}))]})})),p(Q,!0)]}):null};export{J as default};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{getWrapperTextClass as s,getContainerClass as o,getRootClass as i}from"./common/classes.js";import{getWrapperTextStyle as l,getContainerStyle as r}from"./common/styles.js";import{useI18nStore as m,makeStyleResponsive as n}from"@gem-sdk/core";import{createStyle as d,createClass as p,If as a}from"@gem-sdk/system";import{useGpDiscountTag as c}from"./hooks/useGpDiscountTag.js";import"../../../common/const.js";import u from"../../../common/components/TooltipHover.js";import x from"../../../common/components/NoDataState.js";import f from"../../../text/components/Text.js";let g=({setting:g,styles:y,builderProps:h,...b})=>{let{customContent:j}=g??{},N=b["bundle-item"],{textAlign:v}=y??{},{t:T}=m(),{mode:k,product:w,salePrice:A,priceSave:D,currentProductId:F,unitCustomDisplay:S,shouldPlaceholderNoDiscount:$}=c({setting:g,styles:y,builderProps:h,...b});if($)return e(u,{enable:!0,text:T("Not be displayed when published"),position:"bottom",width:"205px",children:e(x,{builderAttrs:h?.builderData,elementType:"secondary",description:T("No discount"),rawMode:!0,customClass:"!gp-p-[5px]"})});let q=d(l(y)),C=d(r(y)),I=p(s(y)),E=p(o()),G=p(i({mode:k,salePrice:A,priceSave:D,bundleItem:N}));return e("div",{className:G,style:{...n("ta",v)},id:`shopify-text-element-${h?.uid}`,"data-id":h?.uid,"data-product-id":F,"gp-data-hidden":"false",children:a(!w," ",e("div",{className:E,style:C,children:e("div",{className:I,style:q,children:t("div",{className:"gp-flex gp-break-all gp-items-center",children:[e(f,{styles:y,setting:{...g,text:j?.prefix?.replaceAll(" ","&nbsp;"),options:{useState:!0,uniqueId:`${h?.uid}-prefix`},excludeFlex:!0}}),e(f,{styles:y,setting:{...g,text:S,options:{isCannotEditing:!0},excludeFlex:!0}}),e(f,{styles:y,setting:{...g,text:j?.suffix?.replaceAll(" ","&nbsp;"),excludeFlex:!0,options:{useState:!0,uniqueId:`${h?.uid}-suffix`}}})]})})}))})};export{g as default};
2
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{getWrapperTextClass as s,getContainerClass as o,getRootClass as i}from"./common/classes.js";import{getWrapperTextStyle as r,getContainerStyle as l}from"./common/styles.js";import{useI18nStore as m,makeStyleResponsive as n}from"@gem-sdk/core";import{createStyle as d,createClass as p,If as a}from"@gem-sdk/system";import{useGpDiscountTag as c}from"./hooks/useGpDiscountTag.js";import"../../../common/const.js";import u from"../../../common/components/TooltipHover.js";import x from"../../../common/components/NoDataState.js";import"react";import f from"../../../text/components/Text.js";let g=({setting:g,styles:y,builderProps:h,...b})=>{let{customContent:j}=g??{},N=b["bundle-item"],{textAlign:v}=y??{},{t:T}=m(),{mode:k,product:w,salePrice:A,priceSave:D,currentProductId:F,unitCustomDisplay:S,shouldPlaceholderNoDiscount:$}=c({setting:g,styles:y,builderProps:h,...b});if($)return e(u,{enable:!0,text:T("Not be displayed when published"),position:"bottom",width:"205px",children:e(x,{builderAttrs:h?.builderData,elementType:"secondary",description:T("No discount"),rawMode:!0,customClass:"!gp-p-[5px]"})});let q=d(r(y)),C=d(l(y)),I=p(s(y)),E=p(o()),G=p(i({mode:k,salePrice:A,priceSave:D,bundleItem:N}));return e("div",{className:G,style:{...n("ta",v)},id:`shopify-text-element-${h?.uid}`,"data-id":h?.uid,"data-product-id":F,"gp-data-hidden":"false",children:a(!w," ",e("div",{className:E,style:C,children:e("div",{className:I,style:q,children:t("div",{className:"gp-flex gp-break-all gp-items-center",children:[e(f,{styles:y,setting:{...g,text:j?.prefix?.replaceAll(" ","&nbsp;"),options:{useState:!0,uniqueId:`${h?.uid}-prefix`},excludeFlex:!0}}),e(f,{styles:y,setting:{...g,text:S,options:{isCannotEditing:!0},excludeFlex:!0}}),e(f,{styles:y,setting:{...g,text:j?.suffix?.replaceAll(" ","&nbsp;"),excludeFlex:!0,options:{useState:!0,uniqueId:`${h?.uid}-suffix`}}})]})})}))})};export{g as default};
@@ -1 +1 @@
1
- import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import{PRODUCT_LIST_PRODUCT_SOURCE as r}from"../../../common/const.js";import{useRenderMode as d,useCurrentDevice as l,usePageType as i,usePageStore as a,useFetchHandle as c,hasPublicStoreFrontData as s,createStoreFrontFetcher as n,useProductQuery as u,useProductsQueryAll as m,useProductsQuery as g,PICKED_PRODUCT_STATUSES as h,useCollectionQuery as p,flattenConnection as f,ProductListProvider as P,filterToolbarPreview as b}from"@gem-sdk/core";import{useState as k,useMemo as I,useEffect as T}from"react";import v from"../../../common/components/Loading.js";import y from"next/dynamic";import O from"../SalePageProductListWarning.js";import{getPropertyByDevice as S}from"../../../dialog/common/helpers.js";import C from"./ProductListCarouselLayout.js";import E from"./ProductListGridLayout.js";import{getClass as N}from"./common/classes.js";import{getData as w}from"./common/helpers.js";import{getStyle as L}from"./common/styles.js";import{If as j}from"@gem-sdk/system";import W from"next/head";let x=y(()=>import("../ProductNotFound.js"),{loading:v}),G=y=>{let{children:G,styles:M,builderProps:B,setting:A,builderAttrs:D}=y,{isRelatedProduct:H,productSetting:Q}=w(y),z=Q.relatedTag&&Q.relatedTag[0],{isEditMode:F,isPreviewSharePageMode:R}=d(),$=l(),_=i(),V=a(e=>e.dynamicProduct),q=a(e=>e.dynamicCollection),[U,J]=k(1),[K,X]=k(!0),[Y,Z]=k(),[ee,et]=k(!1),eo="GP_FUNNEL_PAGE"===_;"GP_COLLECTION"!=_||[r.Collection,r.DynamicCollection].includes(Q?.productSrc)||(Q.productSrc=r.DynamicCollection);let er=Q?.productSrc??r.Collection;er===r.DynamicCollection&&(Q.collectionId=q?.collectionId||"latest");let ed=V?.productId&&V?.productId!==Q.relatedProductId?V?.productId:Q.relatedProductId,el=c(),ei=a(e=>e.publicStoreFrontData),ea=I(()=>s(ei)?n(ei):el,[ei]),{data:ec}=u(H&&ed?ed:void 0,{revalidateOnMount:F||R},ea),es=Q.relatedTag&&"tags"===Q.relatedTag[0]&&(!ec?.tags||ec?.tags.length===0),en=Q.relatedTag&&"collection"===Q.relatedTag[0]&&(!ec?.collections?.edges||ec?.collections.edges.length===0),eu=Q.relatedTag&&"vendor"===Q.relatedTag[0]&&!ec?.vendor,em=m(Y,{revalidateOnMount:F||R},ea),eg=F||R,eh=g(er===r.PickProduct?Q?.productIds:void 0,{revalidateOnMount:eg},{defaultSelectedProductCount:Q?.numOfSelectedProducts,selectedStatus:eg&&Q?.productIds?.length?h:void 0}),ep=I(()=>({id:Q?.collectionId??"latest",numberOfProducts:A?.numberOfProducts??4,orderBy:A?.orderBy}),[Q?.collectionId,Number(A?.numberOfProducts),A?.orderBy]),ef=p(er!==r.PickProduct?ep:void 0,{revalidateOnMount:eg});T(()=>{if(H&&ec&&Q.relatedTag&&"recommended-product"!==Q.relatedType){let e;switch(et(!1),Q.hasRelatedExclude&&(e=Q?.relatedExclude&&Q.relatedExclude.split(",").map(e=>e.trim())),Q.relatedTag[0]){case"vendor":Z({first:A?.numberOfProducts,vendor:Q.relatedTag&&"vendor"===Q.relatedTag[0]?ec?.vendor:"",idNEQ:ec.id});break;case"collection":{let t=ec?.collections?.edges.map(e=>e.node?.id);if(!t||t?.length===0){et(!0);break}Z(e&&e.length>0?{first:A?.numberOfProducts,idNEQ:ec.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t},{titleNotIn:e}]}]}:{first:A?.numberOfProducts,idNEQ:ec.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t}]}]});break}case"tags":if(!ec.tags||0===ec.tags.length){et(!0);break}Z(e&&e.length>0?{first:A?.numberOfProducts,idNEQ:ec.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:ec.tags},{nameNotIn:e}]}]}:{first:A?.numberOfProducts,idNEQ:ec.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:ec.tags}]}]})}}},[ec,Q.relatedType,Q.relatedTag,A?.numberOfProducts,Q.relatedExclude,Q.hasRelatedExclude,H]);let eP=er===r.PickProduct?eh.isValidating:ef.isValidating,eb=er===r.PickProduct?eh.isLoading:ef.isLoading,ek=er===r.PickProduct?eh.error:ef.error,eI=ef.data?.collections?.edges?.[0]?.node,eT=er===r.PickProduct?f(eh.data?.products):f(eI?.products),ev=em?.data?.products?f(em?.data?.products):void 0,ey=H&&ev?ev:er===r.PickProduct&&Q?.productIds?.length?Q?.productIds?.map(e=>eT?.find(t=>t?.baseID===e)).filter(Boolean)??eT:er!==r.PickProduct?eT:eT.filter((e,t)=>t<(Q?.numOfSelectedProducts??4)),eO=I(()=>ee&&H&&F||!ey.length&&!eb&&K&&F,[K,eb,ee,H,F,ey.length]),eS=I(()=>!ey||ee&&H,[ee,H,ey]),eC=I(()=>{if(!A?.sameHeight)return[];let e=0,t=Math.ceil((ey?.length??0)/+(A?.slidesToShow?.[$]??1));return Array.from(Array(ey?.length??0)).map((o,r)=>(r>=+(A?.slidesToShow?.[$]??1)*(e+1)&&++e,{gridRow:`${1+U*e}/${U+1+U*e}`,marginBottom:e+1<t?S(M?.horizontalGutter,$):void 0}))},[A?.sameHeight,A?.slidesToShow,U,ey?.length,$,M?.horizontalGutter]),eE=I(()=>eP||eb||ek||!ey||ee&&H,[ek,eb,ee,H,eP,ey]);T(()=>{eE||setTimeout(()=>{let{builderData:e}=B??{},t=e?.childrens?.[0];if(!t)return;let o=document.querySelector(`[data-id=${t}] div`);o&&J(o.childElementCount||1)},F?0:500)},[B,eE,F]);let eN=I(()=>({collection:eI,products:ey,settings:{loop:A?.loop??{desktop:!1},scrollMode:A?.scrollMode??{desktop:"snap"},slidesToShow:A?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:M?.layout,dot:A?.dot,dotStyle:A?.dotStyle,arrow:A?.arrow,controlOverContent:A?.controlOverContent,sameHeight:A?.sameHeight},styles:{horizontalGutter:M?.horizontalGutter,verticalGutter:M?.verticalGutter,fullWidth:M?.fullWidth,spacing:M?.spacing,width:M?.width,height:M?.height}}),[eI,ey,A,M]);if(B?.isPreview&&eo)return e(t,{});if(eO)return e(t,{children:j(K,e(x,{builderAttrs:D,collectionHandle:eI?.handle,productSrc:er,onClose:()=>X(!1),children:G,relatedTagString:z,assignProductNoTags:es||en||eu,noAssignedProduct:!ed}))});let{productListWrapStyle:ew,productListContentStyle:eL,productListWrapAlignStyle:ej}=L(y),{productListWrapClass:eW}=N(y);return o("div",{...D,className:eW,style:ew,children:[!!M?.preloadBgImage&&o(W,{children:[!!M.backgroundImage?.desktop?.image?.src&&e("link",{rel:"preload",href:M.backgroundImage.desktop.image.src,as:"image"}),!!M.backgroundImage?.tablet?.image?.src&&e("link",{rel:"preload",href:M.backgroundImage?.tablet?.image?.src,as:"image"}),!!M.backgroundImage?.mobile?.image?.src&&e("link",{rel:"preload",href:M.backgroundImage?.mobile?.image?.src,as:"image"})]}),eP||eb?e(v,{}):ek?o("div",{children:["Error: ",ek?.message]}):eS?e("div",{children:"Products not found"}):e(P,{...eN,children:e("div",{className:"gp-flex gp-w-full",style:ej,children:o("div",{style:eL,children:[eo&&e(O,{}),e(t,{children:j(M?.layout==="grid",e(E,{...y,productSortedById:ey,generateGridRowArray:eC}),e(C,{...y,productSortedById:ey}))})]})})}),b(G,!0)]})};export{G as default};
1
+ import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{getElementLabel as o,isQueryLoading as d}from"../../../common/helpers.js";import{PRODUCT_LIST_PRODUCT_SOURCE as a}from"../../../common/const.js";import{useRenderMode as l,useCurrentDevice as i,usePageType as c,usePageStore as s,useFetchHandle as n,hasPublicStoreFrontData as u,createStoreFrontFetcher as m,useProductQuery as g,useProductsQueryAll as h,useProductsQuery as p,PICKED_PRODUCT_STATUSES as f,useCollectionQuery as P,flattenConnection as T,ProductListProvider as b,filterToolbarPreview as y}from"@gem-sdk/core";import{useState as I,useMemo as v,useEffect as k}from"react";import O from"../../../common/components/Loading.js";import S from"next/dynamic";import C from"../SalePageProductListWarning.js";import{getPropertyByDevice as L}from"../../../dialog/common/helpers.js";import{getData as E,isRelatedProductsLoading as N,hasQueryableRelatedTag as w}from"./common/helpers.js";import j from"./ProductListCarouselLayout.js";import W from"./ProductListGridLayout.js";import{getClass as x}from"./common/classes.js";import{getStyle as G}from"./common/styles.js";import{If as M}from"@gem-sdk/system";import D from"next/head";let Q=S(()=>import("../ProductNotFound.js"),{loading:O}),B=S=>{let{children:B,styles:A,builderProps:H,setting:R,builderAttrs:z}=S,{isRelatedProduct:F,productSetting:$}=E(S),_=$.relatedTag&&$.relatedTag[0],{isEditMode:q,isPreviewSharePageMode:U}=l(),V=i(),J=c(),K=s(e=>e.dynamicProduct),X=s(e=>e.dynamicCollection),[Y,Z]=I(1),[ee,et]=I(!0),[er,eo]=I(),[ed,ea]=I(!1),[el,ei]=I(),ec="GP_FUNNEL_PAGE"===J;"GP_COLLECTION"!=J||[a.Collection,a.DynamicCollection].includes($?.productSrc)||($.productSrc=a.DynamicCollection);let es=$?.productSrc??a.Collection;es===a.DynamicCollection&&($.collectionId=X?.collectionId||"latest");let en=K?.productId&&K?.productId!==$.relatedProductId?K?.productId:$.relatedProductId,eu=n(),em=s(e=>e.publicStoreFrontData),eg=v(()=>u(em)?m(em):eu,[em]),{data:eh,error:ep,isLoading:ef}=g(F&&en?en:void 0,{revalidateOnMount:q||U},eg),eP=$.relatedTag&&"tags"===$.relatedTag[0]&&(!eh?.tags||eh?.tags.length===0),eT=$.relatedTag&&"collection"===$.relatedTag[0]&&(!eh?.collections?.edges||eh?.collections.edges.length===0),eb=$.relatedTag&&"vendor"===$.relatedTag[0]&&!eh?.vendor,ey=h(er,{revalidateOnMount:q||U},eg),eI=q||U,ev=p(es===a.PickProduct?$?.productIds:void 0,{revalidateOnMount:eI},{defaultSelectedProductCount:$?.numOfSelectedProducts,selectedStatus:eI&&$?.productIds?.length?f:void 0}),ek=v(()=>({id:$?.collectionId??"latest",numberOfProducts:R?.numberOfProducts??4,orderBy:R?.orderBy}),[$?.collectionId,Number(R?.numberOfProducts),R?.orderBy]),eO=P(es!==a.PickProduct?ek:void 0,{revalidateOnMount:eI});k(()=>{if(F&&eh&&$.relatedTag&&"recommended-product"!==$.relatedType){let e;switch(ea(!1),$.hasRelatedExclude&&(e=$?.relatedExclude&&$.relatedExclude.split(",").map(e=>e.trim())),$.relatedTag[0]){case"vendor":eo({first:R?.numberOfProducts,vendor:$.relatedTag&&"vendor"===$.relatedTag[0]?eh?.vendor:"",idNEQ:eh.id}),ei(eh.id);break;case"collection":{let t=eh?.collections?.edges.map(e=>e.node?.id);if(!t||t?.length===0){ea(!0);break}eo(e&&e.length>0?{first:R?.numberOfProducts,idNEQ:eh.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t},{titleNotIn:e}]}]}:{first:R?.numberOfProducts,idNEQ:eh.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:t}]}]}),ei(eh.id);break}case"tags":if(!eh.tags||0===eh.tags.length){ea(!0);break}eo(e&&e.length>0?{first:R?.numberOfProducts,idNEQ:eh.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:eh.tags},{nameNotIn:e}]}]}:{first:R?.numberOfProducts,idNEQ:eh.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:eh.tags}]}]}),ei(eh.id)}}},[eh,$.relatedType,$.relatedTag,R?.numberOfProducts,$.relatedExclude,$.hasRelatedExclude,F]);let eS=es===a.PickProduct,eC=eS?ev:eO,eL=eC.isValidating,eE=eC.error,eN=d({hasQuery:eI&&(!eS||!!$?.productIds),data:eC.data,error:eC.error,isLoading:eC.isLoading}),ew=N({isRelatedProduct:F,relatedType:$.relatedType,hasRelatedTag:w({relatedTag:$.relatedTag}),relatedProductIdAssigned:en,canRevalidateOnMount:eI,mainProduct:{data:eh,error:ep,isLoading:ef},relatedQuery:er,relatedQuerySource:el,mainProductId:eh?.id,isNotFoundRelatedProduct:ed,relatedProducts:{data:ey.data,error:ey.error,isLoading:ey.isLoading}}),ej=eN||ew,eW=eO.data?.collections?.edges?.[0]?.node,ex=es===a.PickProduct?T(ev.data?.products):T(eW?.products),eG=ey?.data?.products?T(ey?.data?.products):void 0,eM=F&&eG?eG:es===a.PickProduct&&$?.productIds?.length?$?.productIds?.map(e=>ex?.find(t=>t?.baseID===e)).filter(Boolean)??ex:es!==a.PickProduct?ex:ex.filter((e,t)=>t<($?.numOfSelectedProducts??4)),eD=v(()=>ed&&F&&q||!eM.length&&!ej&&ee&&q,[ee,ej,ed,F,q,eM.length]),eQ=v(()=>!eM||ed&&F,[ed,F,eM]),eB=v(()=>{if(!R?.sameHeight)return[];let e=0,t=Math.ceil((eM?.length??0)/+(R?.slidesToShow?.[V]??1));return Array.from(Array(eM?.length??0)).map((r,o)=>(o>=+(R?.slidesToShow?.[V]??1)*(e+1)&&++e,{gridRow:`${1+Y*e}/${Y+1+Y*e}`,marginBottom:e+1<t?L(A?.horizontalGutter,V):void 0}))},[R?.sameHeight,R?.slidesToShow,Y,eM?.length,V,A?.horizontalGutter]),eA=v(()=>eL||ej||eE||!eM||ed&&F,[eE,ej,ed,F,eL,eM]);k(()=>{eA||setTimeout(()=>{let{builderData:e}=H??{},t=e?.childrens?.[0];if(!t)return;let r=document.querySelector(`[data-id=${t}] div`);r&&Z(r.childElementCount||1)},q?0:500)},[H,eA,q]);let eH=v(()=>({collection:eW,products:eM,settings:{loop:R?.loop??{desktop:!1},scrollMode:R?.scrollMode??{desktop:"snap"},slidesToShow:R?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:A?.layout,dot:R?.dot,dotStyle:R?.dotStyle,arrow:R?.arrow,controlOverContent:R?.controlOverContent,sameHeight:R?.sameHeight},styles:{horizontalGutter:A?.horizontalGutter,verticalGutter:A?.verticalGutter,fullWidth:A?.fullWidth,spacing:A?.spacing,width:A?.width,height:A?.height}}),[eW,eM,R,A]);if(H?.isPreview&&ec)return e(t,{});if(eD)return e(t,{children:M(ee,e(Q,{builderAttrs:z,collectionHandle:eW?.handle,productSrc:es,onClose:()=>et(!1),children:B,relatedTagString:_,assignProductNoTags:eP||eT||eb,noAssignedProduct:!en}))});let{productListWrapStyle:eR,productListContentStyle:ez,productListWrapAlignStyle:eF}=G(S),{productListWrapClass:e$}=x(S);return r("div",{...z,className:e$,style:eR,children:[!!A?.preloadBgImage&&r(D,{children:[!!A.backgroundImage?.desktop?.image?.src&&e("link",{rel:"preload",href:A.backgroundImage.desktop.image.src,as:"image"}),!!A.backgroundImage?.tablet?.image?.src&&e("link",{rel:"preload",href:A.backgroundImage?.tablet?.image?.src,as:"image"}),!!A.backgroundImage?.mobile?.image?.src&&e("link",{rel:"preload",href:A.backgroundImage?.mobile?.image?.src,as:"image"})]}),eL||ej?e(O,{label:o({builderData:H?.builderData})}):eE?r("div",{children:["Error: ",eE?.message]}):eQ?e("div",{children:"Products not found"}):e(b,{...eH,children:e("div",{className:"gp-flex gp-w-full",style:eF,children:r("div",{style:ez,children:[ec&&e(C,{}),e(t,{children:M(A?.layout==="grid",e(W,{...S,productSortedById:eM,generateGridRowArray:eB}),e(j,{...S,productSortedById:eM}))})]})})}),y(B,!0)]})};export{B as default};
@@ -1 +1 @@
1
- import{getUpdatedDotStyle as t}from"../../../../carousel/components/dot/common/helpers.js";import{convertUnitToNumber as e}from"../../product-images/common/productFeaturedImage.js";import{getSizeSetting as o}from"../../../helpers/product.js";let r=e=>{let{setting:r,styles:d}=e,c=r?.productSetting??{},l="RelatedProduct"===c.productSrc,i=t(r?.dot,r?.dotStyle),a={dotSize:{desktop:12},dotGapToCarousel:{desktop:16},arrowIconSize:{desktop:24},showWhenHover:!1,rtl:!1,...r};delete a.childItem;let p={...d,sizeSetting:{...o({adaptiveHeight:d?.adaptiveHeight,height:d?.height,fullWidth:{desktop:!0}})},spacing:d?.spacing};return delete p.backgroundColor,delete p.backgroundImage,{isRelatedProduct:l,productSetting:c,dotStyle:i,carouselConfigSetting:a,carouselConfigStyle:p}},d=t=>{let{setting:o,styles:r}=t,d=o?.productSetting,i=d?.relatedTag,a=d?.hasRelatedExclude,p=(i&&"collection"===i[0]?d?.relatedCollectionExclude:d?.relatedTagsExclude)??"",u=p?.split(",").map(t=>t.trim()).toString(),n=d?.productSrc??"Collection",s=d?.collectionId?.replace(c,"")??"latest",g=d?.productSrc==="PickProduct"&&d?.productIds?.length===0,m=r?.layout==="grid",h=e(o?.numberOfProducts,4),P="PickProduct"===n&&d?.productIds?.length?d?.productIds.map(t=>t.replace(l,"")):[],I="PickProduct"===n&&d?.productHandles?.length?d?.productHandles:[],S=o?.orderBy&&o?.orderBy!=="none",C=(d?.productSrc==="Collection"||d?.productSrc==="DynamicCollection")&&S?o?.orderBy?.split("_"):"none",k=S&&C?.[0]==="TITLE"?"| sort: 'title'":"| sort: 'updated_at'",f=C?.[C.length-1]==="DESC";return{hasRelatedExclude:a,relatedExcludeTrim:u,collectionID:s,isLatestProducts:g,isGrid:m,numberOfProducts:h,productListId:P,productListHandles:I,sortedBy:k,isReverse:f,productSrc:n,productSetting:d,isSorted:S,relatedTag:i,productNumber:"PickProduct"===n?g?4:d?.numOfSelectedProducts??4:h,collectionHandle:d?.collectionHandle}},c="gid://shopify/Collection/",l="gid://shopify/Product/";export{c as PREFIX_COLLECTION_ID,l as PREFIX_PRODUCT_ID,r as getData,d as getDataLiquid};
1
+ import{getUpdatedDotStyle as e}from"../../../../carousel/components/dot/common/helpers.js";import{convertUnitToNumber as t}from"../../product-images/common/productFeaturedImage.js";import{getSizeSetting as o}from"../../../helpers/product.js";import{isQueryLoading as r}from"../../../../common/helpers.js";import"../../../../common/const.js";import"react/jsx-runtime";import"@gem-sdk/core";import"react";let d=t=>{let{setting:r,styles:d}=t,c=r?.productSetting??{},l="RelatedProduct"===c.productSrc,i=e(r?.dot,r?.dotStyle),a={dotSize:{desktop:12},dotGapToCarousel:{desktop:16},arrowIconSize:{desktop:24},showWhenHover:!1,rtl:!1,...r};delete a.childItem;let n={...d,sizeSetting:{...o({adaptiveHeight:d?.adaptiveHeight,height:d?.height,fullWidth:{desktop:!0}})},spacing:d?.spacing};return delete n.backgroundColor,delete n.backgroundImage,{isRelatedProduct:l,productSetting:c,dotStyle:i,carouselConfigSetting:a,carouselConfigStyle:n}},c=e=>{let{setting:o,styles:r}=e,d=o?.productSetting,c=d?.relatedTag,a=d?.hasRelatedExclude,n=(c&&"collection"===c[0]?d?.relatedCollectionExclude:d?.relatedTagsExclude)??"",u=n?.split(",").map(e=>e.trim()).toString(),p=d?.productSrc??"Collection",s=d?.collectionId?.replace(l,"")??"latest",m=d?.productSrc==="PickProduct"&&d?.productIds?.length===0,g=r?.layout==="grid",h=t(o?.numberOfProducts,4),P="PickProduct"===p&&d?.productIds?.length?d?.productIds.map(e=>e.replace(i,"")):[],I="PickProduct"===p&&d?.productHandles?.length?d?.productHandles:[],S=o?.orderBy&&o?.orderBy!=="none",k=(d?.productSrc==="Collection"||d?.productSrc==="DynamicCollection")&&S?o?.orderBy?.split("_"):"none",y=S&&k?.[0]==="TITLE"?"| sort: 'title'":"| sort: 'updated_at'",C=k?.[k.length-1]==="DESC";return{hasRelatedExclude:a,relatedExcludeTrim:u,collectionID:s,isLatestProducts:m,isGrid:g,numberOfProducts:h,productListId:P,productListHandles:I,sortedBy:y,isReverse:C,productSrc:p,productSetting:d,isSorted:S,relatedTag:c,productNumber:"PickProduct"===p?m?4:d?.numOfSelectedProducts??4:h,collectionHandle:d?.collectionHandle}},l="gid://shopify/Collection/",i="gid://shopify/Product/",a=["vendor","collection","tags"],n=({relatedTag:e})=>!!e?.[0]&&a.includes(e[0]),u=({isRelatedProduct:e,relatedType:t,hasRelatedTag:o,relatedProductIdAssigned:d,canRevalidateOnMount:c,mainProduct:l,mainProductId:i,relatedQuery:a,relatedQuerySource:n,isNotFoundRelatedProduct:u,relatedProducts:p})=>{if(!e)return!1;let s="recommended-product"!==t&&o&&!!d,m=s&&!!l.data&&n!==i&&!u;return c?r({hasQuery:s,...l})||m||r({hasQuery:!!a,...p}):l.isLoading||p.isLoading};export{l as PREFIX_COLLECTION_ID,i as PREFIX_PRODUCT_ID,d as getData,c as getDataLiquid,n as hasQueryableRelatedTag,u as isRelatedProductsLoading};
@@ -1 +1 @@
1
- import{jsx as o,Fragment as e,jsxs as t}from"react/jsx-runtime";import{PRODUCT_LIST_PRODUCT_SOURCE as r}from"../../../common/const.js";import{useRenderMode as i,useCurrentDevice as d,usePageType as l,usePageStore as s,flattenConnection as c,ProductListProvider as n,filterToolbarPreview as a,PICKED_PRODUCT_STATUSES as m}from"@gem-sdk/core";import{useState as u,useRef as g,useMemo as p,useEffect as h}from"react";import f from"../../../common/components/Loading.js";import P from"next/dynamic";import y from"./hooks/useRelatedProductIDAssigned.js";import k from"../SalePageProductListWarning.js";import{getPropertyByDevice as I}from"../../../dialog/common/helpers.js";import b from"./hooks/useProductRelatedQuery.js";import S from"./ProductListCarouselLayout.js";import{DEFAULT_COLLECTION_NUMBER_OF_PRODUCTS as j}from"./constants/index.js";import{useCollectionQuery as C}from"./hooks/useCollectionQuery.js";import{useProductsQuery as v}from"./hooks/useProductsQuery.js";import L from"./ProductListGridLayout.js";import{getClass as w}from"./common/classes.js";import{getData as N}from"./common/helpers.js";import{getStyle as G}from"./common/styles.js";import{If as T}from"@gem-sdk/system";import A from"next/head";let O=P(()=>import("../ProductNotFound.js"),{loading:f}),x=P=>{let{children:x,styles:D,builderProps:B,setting:E,builderAttrs:H}=P,{isRelatedProduct:z,productSetting:M}=N(P),{isEditMode:Q,isPreviewSharePageMode:R}=i(),W=d(),$=l(),_=s(o=>o.dynamicCollection),[F,V]=u(1),[q,U]=u(!0),J=g(),K="GP_FUNNEL_PAGE"===$;"GP_COLLECTION"!=$||[r.Collection,r.DynamicCollection].includes(M?.productSrc)||(M.productSrc=r.DynamicCollection);let X=M?.productSrc??r.Collection;X===r.DynamicCollection&&(M.collectionId=_?.collectionId||"latest");let Y=Number.isNaN(Number(E?.numberOfProducts))?j:Number(E?.numberOfProducts),{relatedProductIdAssigned:Z}=y({productSetting:M}),{isNotFoundRelatedProduct:oo,relatedProducts:oe,isNoRelatedProductData:ot,relatedTagString:or,isLoading:oi}=b({productSetting:M,isRelatedProduct:z,relatedProductIdAssigned:Z,numberOfProducts:Y}),od=Q||R,ol=v({productIds:M?.productIds,defaultSelectedProductCount:M?.numOfSelectedProducts,productSrc:X,selectedStatus:od&&M?.productIds?.length?m:void 0}),os=C({productSrc:X,collectionID:M?.collectionId??"latest",numberOfProducts:Y,orderBy:E?.orderBy}),oc=oi||(X===r.PickProduct?ol.isLoading:os.isLoading),on=X===r.PickProduct?ol.error:os.error,oa=X===r.PickProduct?ol.isValidating:os.isValidating,om=os.data?.collections?.edges?.[0]?.node,ou=X===r.PickProduct?c(ol.data?.products):c(om?.products),og=s(o=>o.assignedProductIds),op=s(o=>o.isApplyAllProducts),oh=p(()=>(og??[]).length>0&&!op||op,[og,op]),of=oe?.data?.products&&oh?c(oe?.data?.products):[],oP=z?of:X===r.PickProduct&&M?.productIds?.length?M?.productIds?.map(o=>ou?.find(e=>e?.baseID===o)).filter(Boolean)??ou:X!==r.PickProduct?ou:ou.filter((o,e)=>e<(M?.numOfSelectedProducts??4)),oy=p(()=>oo&&z&&Q||!oP.length&&!oc&&q&&Q,[q,oc,oo,z,Q,oP.length]),ok=p(()=>!oP||oo&&z,[oo,z,oP]),oI=p(()=>{if(!E?.sameHeight)return[];let o=0,e=Math.ceil((oP?.length??0)/+(E?.slidesToShow?.[W]??1));return Array.from(Array(oP?.length??0)).map((t,r)=>(r>=+(E?.slidesToShow?.[W]??1)*(o+1)&&++o,{gridRow:`${1+F*o}/${F+1+F*o}`,marginBottom:o+1<e?I(D?.horizontalGutter,W):void 0}))},[E?.sameHeight,E?.slidesToShow,F,oP?.length,W,D?.horizontalGutter]),ob=p(()=>oa||oc||on||!oP||oo&&z,[on,oc,oo,z,oa,oP]);h(()=>{if(!ob)return J.current=setTimeout(()=>{let{builderData:o}=B??{},e=o?.childrens?.[0];if(!e)return;let t=document.querySelector(`[data-id=${e}] div`);t&&V(t.childElementCount||1)},Q?0:500),()=>{clearTimeout(J.current)}},[B,ob,Q,oP]);let oS=p(()=>({collection:om,products:oP,settings:{loop:E?.loop??{desktop:!1},scrollMode:E?.scrollMode??{desktop:"snap"},slidesToShow:E?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:D?.layout,dot:E?.dot,dotStyle:E?.dotStyle,arrow:E?.arrow,controlOverContent:E?.controlOverContent,sameHeight:E?.sameHeight},styles:{horizontalGutter:D?.horizontalGutter,verticalGutter:D?.verticalGutter,fullWidth:D?.fullWidth,spacing:D?.spacing,width:D?.width,height:D?.height}}),[om,oP,E,D]);if(B?.isPreview&&K)return o(e,{});if(oy)return o(e,{children:T(q,o(O,{builderAttrs:H,collectionHandle:om?.handle,productSrc:X,onClose:()=>U(!1),children:x,relatedTagString:or,assignProductNoTags:ot,noAssignedProduct:!Z}))});let{productListWrapStyle:oj,productListContentStyle:oC,productListWrapAlignStyle:ov}=G(P),{productListWrapClass:oL}=w(P);return t("div",{...H,className:oL,style:oj,children:[!!D?.preloadBgImage&&t(A,{children:[!!D.backgroundImage?.desktop?.image?.src&&o("link",{rel:"preload",href:D.backgroundImage.desktop.image.src,as:"image"}),!!D.backgroundImage?.tablet?.image?.src&&o("link",{rel:"preload",href:D.backgroundImage?.tablet?.image?.src,as:"image"}),!!D.backgroundImage?.mobile?.image?.src&&o("link",{rel:"preload",href:D.backgroundImage?.mobile?.image?.src,as:"image"})]}),oc||oa?o(f,{}):on?t("div",{children:["Error: ",on?.message]}):ok?o("div",{children:"Products not found"}):o(n,{...oS,children:o("div",{className:"gp-flex gp-w-full",style:ov,children:t("div",{style:oC,children:[K&&o(k,{}),o(e,{children:T(D?.layout==="grid",o(L,{...P,productSortedById:oP,generateGridRowArray:oI}),o(S,{...P,productSortedById:oP}))})]})})}),a(x,!0)]})};export{x as default};
1
+ import{jsx as o,Fragment as e,jsxs as t}from"react/jsx-runtime";import{getElementLabel as r,isQueryLoading as i}from"../../../common/helpers.js";import{PRODUCT_LIST_PRODUCT_SOURCE as l}from"../../../common/const.js";import{useRenderMode as d,useCurrentDevice as s,usePageType as c,usePageStore as a,flattenConnection as n,ProductListProvider as m,filterToolbarPreview as u,PICKED_PRODUCT_STATUSES as g}from"@gem-sdk/core";import{useState as p,useRef as h,useMemo as f,useEffect as P}from"react";import y from"../../../common/components/Loading.js";import k from"next/dynamic";import b from"./hooks/useRelatedProductIDAssigned.js";import I from"../SalePageProductListWarning.js";import{getPropertyByDevice as S}from"../../../dialog/common/helpers.js";import j from"./hooks/useProductRelatedQuery.js";import C from"./ProductListCarouselLayout.js";import{DEFAULT_COLLECTION_NUMBER_OF_PRODUCTS as v}from"./constants/index.js";import{useCollectionQuery as L}from"./hooks/useCollectionQuery.js";import{useProductsQuery as w}from"./hooks/useProductsQuery.js";import N from"./ProductListGridLayout.js";import{getClass as G}from"./common/classes.js";import{getData as T}from"./common/helpers.js";import{getStyle as D}from"./common/styles.js";import{If as A}from"@gem-sdk/system";import O from"next/head";let x=k(()=>import("../ProductNotFound.js"),{loading:y}),B=k=>{let{children:B,styles:E,builderProps:H,setting:z,builderAttrs:Q}=k,{isRelatedProduct:M,productSetting:R}=T(k),{isEditMode:W,isPreviewSharePageMode:$}=d(),_=s(),F=c(),q=a(o=>o.dynamicCollection),[U,V]=p(1),[J,K]=p(!0),X=h(),Y="GP_FUNNEL_PAGE"===F;"GP_COLLECTION"!=F||[l.Collection,l.DynamicCollection].includes(R?.productSrc)||(R.productSrc=l.DynamicCollection);let Z=R?.productSrc??l.Collection;Z===l.DynamicCollection&&(R.collectionId=q?.collectionId||"latest");let oo=Number.isNaN(Number(z?.numberOfProducts))?v:Number(z?.numberOfProducts),{relatedProductIdAssigned:oe}=b({productSetting:R}),{isNotFoundRelatedProduct:ot,relatedProducts:or,isNoRelatedProductData:oi,relatedTagString:ol,isLoading:od}=j({productSetting:R,isRelatedProduct:M,relatedProductIdAssigned:oe,numberOfProducts:oo}),os=W||$,oc=w({productIds:R?.productIds,defaultSelectedProductCount:R?.numOfSelectedProducts,productSrc:Z,selectedStatus:os&&R?.productIds?.length?g:void 0}),oa=L({productSrc:Z,collectionID:R?.collectionId??"latest",numberOfProducts:oo,orderBy:z?.orderBy}),on=Z===l.PickProduct,om=on?oc:oa,ou=on?!!R?.productIds:Z===l.Collection||Z===l.DynamicCollection,og=od||i({hasQuery:ou,data:om.data,error:om.error,isLoading:om.isLoading}),op=om.error,oh=om.isValidating,of=oa.data?.collections?.edges?.[0]?.node,oP=Z===l.PickProduct?n(oc.data?.products):n(of?.products),oy=a(o=>o.assignedProductIds),ok=a(o=>o.isApplyAllProducts),ob=f(()=>(oy??[]).length>0&&!ok||ok,[oy,ok]),oI=or?.data?.products&&ob?n(or?.data?.products):[],oS=M?oI:Z===l.PickProduct&&R?.productIds?.length?R?.productIds?.map(o=>oP?.find(e=>e?.baseID===o)).filter(Boolean)??oP:Z!==l.PickProduct?oP:oP.filter((o,e)=>e<(R?.numOfSelectedProducts??4)),oj=f(()=>ot&&M&&W||!oS.length&&!og&&J&&W,[J,og,ot,M,W,oS.length]),oC=f(()=>!oS||ot&&M,[ot,M,oS]),ov=f(()=>{if(!z?.sameHeight)return[];let o=0,e=Math.ceil((oS?.length??0)/+(z?.slidesToShow?.[_]??1));return Array.from(Array(oS?.length??0)).map((t,r)=>(r>=+(z?.slidesToShow?.[_]??1)*(o+1)&&++o,{gridRow:`${1+U*o}/${U+1+U*o}`,marginBottom:o+1<e?S(E?.horizontalGutter,_):void 0}))},[z?.sameHeight,z?.slidesToShow,U,oS?.length,_,E?.horizontalGutter]),oL=f(()=>oh||og||op||!oS||ot&&M,[op,og,ot,M,oh,oS]);P(()=>{if(!oL)return X.current=setTimeout(()=>{let{builderData:o}=H??{},e=o?.childrens?.[0];if(!e)return;let t=document.querySelector(`[data-id=${e}] div`);t&&V(t.childElementCount||1)},W?0:500),()=>{clearTimeout(X.current)}},[H,oL,W,oS]);let ow=f(()=>({collection:of,products:oS,settings:{loop:z?.loop??{desktop:!1},scrollMode:z?.scrollMode??{desktop:"snap"},slidesToShow:z?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:E?.layout,dot:z?.dot,dotStyle:z?.dotStyle,arrow:z?.arrow,controlOverContent:z?.controlOverContent,sameHeight:z?.sameHeight},styles:{horizontalGutter:E?.horizontalGutter,verticalGutter:E?.verticalGutter,fullWidth:E?.fullWidth,spacing:E?.spacing,width:E?.width,height:E?.height}}),[of,oS,z,E]);if(H?.isPreview&&Y)return o(e,{});if(oj)return o(e,{children:A(J,o(x,{builderAttrs:Q,collectionHandle:of?.handle,productSrc:Z,onClose:()=>K(!1),children:B,relatedTagString:ol,assignProductNoTags:oi,noAssignedProduct:!oe}))});let{productListWrapStyle:oN,productListContentStyle:oG,productListWrapAlignStyle:oT}=D(k),{productListWrapClass:oD}=G(k);return t("div",{...Q,className:oD,style:oN,children:[!!E?.preloadBgImage&&t(O,{children:[!!E.backgroundImage?.desktop?.image?.src&&o("link",{rel:"preload",href:E.backgroundImage.desktop.image.src,as:"image"}),!!E.backgroundImage?.tablet?.image?.src&&o("link",{rel:"preload",href:E.backgroundImage?.tablet?.image?.src,as:"image"}),!!E.backgroundImage?.mobile?.image?.src&&o("link",{rel:"preload",href:E.backgroundImage?.mobile?.image?.src,as:"image"})]}),og||oh?o(y,{label:r({builderData:H?.builderData})}):op?t("div",{children:["Error: ",op?.message]}):oC?o("div",{children:"Products not found"}):o(m,{...ow,children:o("div",{className:"gp-flex gp-w-full",style:oT,children:t("div",{style:oG,children:[Y&&o(I,{}),o(e,{children:A(E?.layout==="grid",o(N,{...k,productSortedById:oS,generateGridRowArray:ov}),o(C,{...k,productSortedById:oS}))})]})})}),u(B,!0)]})};export{B as default};
@@ -1 +1 @@
1
- import{jsx as r,Fragment as o,jsxs as t}from"react/jsx-runtime";import{isEmptyChildren as e,ProductProvider as i}from"@gem-sdk/core";import m from"../../../grid/components/ChildrenDroppable.js";import{useProductSetting as d}from"./hook/useProductSetting.js";import{getData as s}from"./common/helpers.js";import"../../../common/const.js";import"react";import c from"../../../common/components/Loading.js";import{If as n}from"@gem-sdk/system";import l from"../../../grid/components/row/Row.js";import p from"next/dynamic";let u=p(()=>import("../ProductNotFound.js"),{loading:c}),a=p=>{let{builderProps:a,children:h,setting:f,style:g,builderAttrs:j}=p,{isAuto:P}=f??{},{isLoading:b,isProductPage:y,isProductNotFound:k,showProductNotFound:x,errorLoadProduct:A,product:v,isEditor:w,productProviderData:C,setShowProductNotFound:D}=d(p),{rowSetting:S,rowStyles:E}=s(p);return y&&P?r(o,{children:e(h)?r(m,{}):h}):r(o,{children:n(!k,r(o,{children:b?r(c,{}):r(o,{children:A?t("div",{children:["Error: ",A?.message]}):v?r(i,{...C,children:r(l,{builderProps:a,builderAttrs:j,style:g,styles:E,setting:S,customAttrs:w?{"data-product-id":v?.baseID?.replace("gid://shopify/Product/","")??""}:void 0,children:e(h)?r(m,{}):h})}):null})}),r(o,{children:n(x,r(u,{builderAttrs:j,productSrc:"PickProduct",onClose:()=>D(!1),children:h}))}))})};export{a as default};
1
+ import{jsx as r,Fragment as o,jsxs as t}from"react/jsx-runtime";import{isEmptyChildren as e,ProductProvider as i}from"@gem-sdk/core";import m from"../../../grid/components/ChildrenDroppable.js";import{useProductSetting as d}from"./hook/useProductSetting.js";import{getElementLabel as s}from"../../../common/helpers.js";import"../../../common/const.js";import"react";import c from"../../../common/components/Loading.js";import{getData as n}from"./common/helpers.js";import{If as l}from"@gem-sdk/system";import p from"../../../grid/components/row/Row.js";import u from"next/dynamic";let a=u(()=>import("../ProductNotFound.js"),{loading:c}),h=u=>{let{builderProps:h,children:f,setting:g,style:j,builderAttrs:b}=u,{isAuto:P}=g??{},{isLoadingProduct:y,isProductPage:k,isProductNotFound:D,showProductNotFound:x,errorLoadProduct:A,product:v,isEditor:w,productProviderData:C,setShowProductNotFound:S}=d(u),{rowSetting:E,rowStyles:F}=n(u);return k&&P?r(o,{children:e(f)?r(m,{}):f}):r(o,{children:l(!D,r(o,{children:y?r(c,{label:s({builderData:h?.builderData})}):r(o,{children:A?t("div",{children:["Error: ",A?.message]}):v?r(i,{...C,children:r(p,{builderProps:h,builderAttrs:b,style:j,styles:F,setting:E,customAttrs:w?{"data-product-id":v?.baseID?.replace("gid://shopify/Product/","")??""}:void 0,children:e(f)?r(m,{}):f})}):null})}),r(o,{children:l(x,r(a,{builderAttrs:b,productSrc:"PickProduct",onClose:()=>S(!1),children:f}))}))})};export{h as default};
@@ -1 +1 @@
1
- import{usePageType as t,usePageStore as r,useRenderMode as e}from"@gem-sdk/core";import d from"./useProductQuery.js";import{useState as a,useMemo as i}from"react";let o=o=>{let{setting:c}=o,{productSetting:u,quantity:s,readOnly:P,isSyncProduct:m}=c??{},l=t(),n=r(t=>t.dynamicProduct),{isEditMode:p}=e(),S=u?.productId??"latest",y=u?.productStatus=="dynamic"?{...u,...n}:u,f=y?.initialVariantId,g=y?.initialVariantBaseId,{productData:{data:h,isLoading:I,error:k}}=d({id:S}),[D,V]=a(!0),$=(k||!h&&!I)&&p,j=i(()=>({product:h,initialVariantId:f,initialVariantBaseId:g,quantity:s,readOnly:P,isSyncProduct:m,key:`uid-${h?.id}-${f??""}`,hasPreSelected:u?.hasPreSelected}),[g,f,m,h,u?.hasPreSelected,s,P]);return{forceProductSetting:y,isProductPage:"PRODUCT"===l,isProductNotFound:$,showProductNotFound:D,isLoading:I,product:h,errorLoadProduct:k,isEditor:p,productProviderData:j,setShowProductNotFound:V}};export{o as useProductSetting};
1
+ import{usePageType as t,usePageStore as r,useRenderMode as e}from"@gem-sdk/core";import{isQueryLoading as o}from"../../../../common/helpers.js";import"../../../../common/const.js";import"react/jsx-runtime";import{useState as a,useMemo as d}from"react";import i from"./useProductQuery.js";let c=c=>{let{setting:m}=c,{productSetting:s,quantity:u,readOnly:n,isSyncProduct:p}=m??{},P=t(),l=r(t=>t.dynamicProduct),{isEditMode:h}=e(),y=s?.productId??"latest",S=s?.productStatus=="dynamic"?{...s,...l}:s,f=S?.initialVariantId,j=S?.initialVariantBaseId,{productData:{data:g,isLoading:I,error:k}}=i({id:y}),[x,D]=a(!0),Q=o({hasQuery:!!y,data:g,error:k,isLoading:I}),V=(k||!g&&!Q)&&h,$=d(()=>({product:g,initialVariantId:f,initialVariantBaseId:j,quantity:u,readOnly:n,isSyncProduct:p,key:`uid-${g?.id}-${f??""}`,hasPreSelected:s?.hasPreSelected}),[j,f,p,g,s?.hasPreSelected,u,n]);return{forceProductSetting:S,isProductPage:"PRODUCT"===P,isProductNotFound:V,showProductNotFound:x,isLoadingProduct:Q,product:g,errorLoadProduct:k,isEditor:h,productProviderData:$,setShowProductNotFound:D}};export{c as useProductSetting};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "23.0.0-staging.21",
3
+ "version": "23.0.0-staging.23",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -34,8 +34,8 @@
34
34
  "react-youtube": "10.1.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@gem-sdk/core": "23.0.0-staging.12",
38
- "@gem-sdk/styles": "23.0.0-staging.9",
37
+ "@gem-sdk/core": "23.0.0-staging.22",
38
+ "@gem-sdk/styles": "23.0.0-staging.23",
39
39
  "@gem-sdk/system": "23.0.0-staging.1",
40
40
  "@shopify/prettier-plugin-liquid": "^1.10.3",
41
41
  "@thedutchcoder/postcss-rem-to-px": "0.0.2",