@gem-sdk/components 2.0.0-dev.835 → 2.0.0-dev.837

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),dynamic=require("next/dynamic"),react=require("react"),Loading=require("../../common/components/Loading.js"),Carousel=require("../../carousel/components/Carousel.js"),CarouselItem=require("../../carousel/components/CarouselItem.js"),ChildrenDroppable=require("../../grid/components/ChildrenDroppable.js"),arrow=require("../../carousel/components/common/arrow.js"),dots=require("../../carousel/components/common/dots.js"),SalePageProductListWarning=require("./SalePageProductListWarning.js"),carousel=require("../../carousel/components/common/carousel.js"),product=require("../helpers/product.js");const ProductNotFound=dynamic(()=>Promise.resolve().then(function(){return require("./ProductNotFound.js")}),{loading:Loading.default}),ProductList=({children:e,className:t,setting:o,styles:r})=>{let d=core.useEditorMode(),i=core.usePageType(),l=o?.productSetting??{},a=core.usePageStore(e=>e.dynamicCollection),s="GP_COLLECTION"==i;s&&(l.productSrc="DynamicCollection",l.collectionId=a?.collectionId??"latest");let n=react.useMemo(()=>"GP_FUNNEL_PAGE"===i,[i]),c=react.useMemo(()=>arrow.getUpdatedArrowDisplay(o?.arrow,o?.controlOverContent),[o?.arrow,o?.controlOverContent]),[u,p]=react.useState(),[m,g]=react.useState(!1),h="RelatedProduct"===l.productSrc,P=react.useMemo(()=>dots.getUpdatedDotStyle(o?.dot),[o?.dot]),x=l?.productSrc??"Collection",j=react.useMemo(()=>({id:l?.collectionId??"latest",numberOfProducts:o?.numberOfProducts??4,orderBy:o?.orderBy==="none"?"CREATED_AT_DESC":o?.orderBy}),[l?.collectionId,o?.numberOfProducts,o?.orderBy]),{data:y}=core.useProductQuery(h&&o?.productSetting?.relatedProductId?o.productSetting.relatedProductId:void 0);react.useEffect(()=>{if(h&&y&&l.relatedTag&&"recommended-product"!==l.relatedType){let e;switch(g(!1),l.hasRelatedExclude&&(e=l?.relatedExclude&&l.relatedExclude.split(",").map(e=>e.trim())),l.relatedTag[0]){case"vendor":p({vendor:l.relatedTag&&"vendor"===l.relatedTag[0]?y?.vendor:"",limit:o?.numberOfProducts});break;case"collection":{let t;let r=y?.collections?.edges.map(e=>e.node?.id);if(!r||r?.length===0){g(!0);break}p(t=e&&e.length>0?{hasCollectionProductsWith:[{hasCollectionWith:[{idIn:r},{titleNotIn:e}]}],limit:o?.numberOfProducts}:{hasCollectionProductsWith:[{hasCollectionWith:[{idIn:r}]}],limit:o?.numberOfProducts});break}case"tag":{let t;if(!y.tags||0===y.tags.length){g(!0);break}p(t=e&&e.length>0?{hasProductTagsWith:[{hasTagsWith:[{nameIn:y?.tags||[]},{nameNotIn:e}]}],limit:o?.numberOfProducts}:{hasProductTagsWith:[{hasTagsWith:[{idIn:y?.tags||[]}]}],limit:o?.numberOfProducts})}}}},[y,l.relatedType,l.relatedTag,o?.numberOfProducts,l.relatedExclude,l.hasRelatedExclude,h]);let S=core.useCollectionQuery("PickProduct"!==x?j:void 0),C=core.useProductsQuery("PickProduct"===x?l?.productIds:void 0,{revalidateOnMount:"edit"===d},{defaultSelectedProductCount:l?.numOfSelectedProducts}),f=core.useProductsQueryAll(u,{revalidateOnMount:"edit"===d}),[v,b]=react.useState(!0),w="PickProduct"===x?C.isValidating:S.isValidating,T="PickProduct"===x?C.isLoading:S.isLoading,R="PickProduct"===x?C.error:S.error,k=S.data?.collections?.edges?.[0]?.node,I="PickProduct"===x?core.flattenConnection(C.data?.products):core.flattenConnection(k?.products),O=f?.data?.products?core.flattenConnection(f?.data?.products):void 0,W=h&&O?O:"PickProduct"===x&&l?.productIds?.length?l?.productIds?.map(e=>I?.find(t=>t?.baseID===e)).filter(Boolean)??I:"PickProduct"!==x?I:I.filter((e,t)=>t<(l?.numOfSelectedProducts||4));return m&&h&&"edit"==d?jsxRuntime.jsx(ProductNotFound,{collectionHandle:k?.handle,productSrc:x,onClose:()=>b(!1),children:e}):W.length||T||"edit"!=d?jsxRuntime.jsx(jsxRuntime.Fragment,{children:w||T?jsxRuntime.jsx(Loading.default,{}):R?jsxRuntime.jsxs("div",{children:["Error: ",R?.message]}):!W||m&&h?jsxRuntime.jsx("div",{children:"Products not found"}):jsxRuntime.jsx(core.ProductListProvider,{collection:k,products:W,settings:{loop:o?.loop??{desktop:!1},scrollMode:o?.scrollMode??{desktop:"snap"},slidesToShow:o?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:r?.layout,dot:o?.dot,dotStyle:o?.dotStyle,arrow:o?.arrow,controlOverContent:o?.controlOverContent},styles:{horizontalGutter:r?.horizontalGutter,verticalGutter:r?.verticalGutter,fullWidth:r?.fullWidth,spacing:r?.spacing,width:r?.width,height:r?.height},children:jsxRuntime.jsxs("div",{className:"gp-relative",children:[n&&jsxRuntime.jsx(SalePageProductListWarning.default,{}),r?.layout==="grid"?jsxRuntime.jsx("div",{style:{...core.makeStyleResponsive("w",core.makeWidth(r?.width,r?.fullWidth)),...core.makeStyleResponsive("rg",r?.horizontalGutter),...core.makeStyleResponsive("cg",r?.verticalGutter),...core.makeStyleResponsive("gtc",{desktop:`repeat(${core.getResponsiveValueByScreen(o?.slidesToShow,"desktop")}, minmax(0, 1fr))`,tablet:o?.slidesToShow?.tablet&&`repeat(${core.getResponsiveValueByScreen(o?.slidesToShow,"tablet")}, minmax(0, 1fr))`,mobile:o?.slidesToShow?.mobile&&`repeat(${core.getResponsiveValueByScreen(o?.slidesToShow,"mobile")}, minmax(0, 1fr))`})},className:core.cls(t,"gp-m-auto gp-grid gp-w-full"),children:W?.length?W?.map(t=>jsxRuntime.jsx(core.ProductProvider,{product:t,readOnly:!0,children:jsxRuntime.jsx("div",{..."edit"===d?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")}:{},children:core.isEmptyChildren(e)?jsxRuntime.jsx(ChildrenDroppable.default,{}):e})},t?.baseID)):null}):jsxRuntime.jsx(Carousel.default,{setting:{loop:o?.loop,slidesToShow:o?.slidesToShow,dot:o?.dot,dotStyle:P,dotSize:{desktop:12},dotGapToCarousel:{desktop:16},navigationStyle:c,arrowCustom:o?.arrowCustom,controlOverContent:o?.controlOverContent,enableDrag:{desktop:o?.dragToScroll,tablet:o?.dragToScroll,mobile:o?.dragToScroll},speed:o?.speed,dotActiveColor:o?.dotActiveColor,dotColor:o?.dotColor,autoplay:o?.autoplay,pauseOnHover:o?.pauseOnHover,autoplayTimeout:o?.autoplayTimeout,arrowCustomColor:o?.arrowCustomColor,arrowButtonSize:{desktop:{width:"24px",height:"24px"}}},rootClass:"gp-justify-center",styles:{sizeSetting:{...product.getSizeSetting({adaptiveHeight:r?.adaptiveHeight,fullWidth:r?.fullWidth,width:r?.width,height:r?.height})},spacing:r?.spacing},children:W?.map(t=>jsxRuntime.jsx(CarouselItem.default,{style:{...carousel.getInitialWidthForCarouselItem({spacing:r?.spacing,slidesToShow:o?.slidesToShow})},children:jsxRuntime.jsx(core.ProductProvider,{product:t,readOnly:!0,children:jsxRuntime.jsx("div",{..."edit"===d?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")}:{},children:core.isEmptyChildren(e)?jsxRuntime.jsx(ChildrenDroppable.default,{}):e})})},t?.baseID))})]})})}):v?jsxRuntime.jsx(ProductNotFound,{collectionHandle:k?.handle,productSrc:x,onClose:()=>b(!1),children:e}):null};exports.default=ProductList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),dynamic=require("next/dynamic"),react=require("react"),Loading=require("../../common/components/Loading.js"),Carousel=require("../../carousel/components/Carousel.js"),CarouselItem=require("../../carousel/components/CarouselItem.js"),ChildrenDroppable=require("../../grid/components/ChildrenDroppable.js"),arrow=require("../../carousel/components/common/arrow.js"),dots=require("../../carousel/components/common/dots.js"),SalePageProductListWarning=require("./SalePageProductListWarning.js"),carousel=require("../../carousel/components/common/carousel.js"),product=require("../helpers/product.js");const ProductNotFound=dynamic(()=>Promise.resolve().then(function(){return require("./ProductNotFound.js")}),{loading:Loading.default}),ProductList=({children:e,className:t,setting:o,styles:r})=>{let d=core.useEditorMode(),i=core.usePageType(),a=o?.productSetting??{},l=core.usePageStore(e=>e.dynamicCollection),s="GP_COLLECTION"==i;s&&(a.productSrc="DynamicCollection",a.collectionId=l?.collectionId??"latest");let n=react.useMemo(()=>"GP_FUNNEL_PAGE"===i,[i]),c=react.useMemo(()=>arrow.getUpdatedArrowDisplay(o?.arrow,o?.controlOverContent),[o?.arrow,o?.controlOverContent]),[u,p]=react.useState(),[m,g]=react.useState(!1),h="RelatedProduct"===a.productSrc,P=react.useMemo(()=>dots.getUpdatedDotStyle(o?.dot),[o?.dot]),x=a?.productSrc??"Collection",j=react.useMemo(()=>({id:a?.collectionId??"latest",numberOfProducts:o?.numberOfProducts??4,orderBy:o?.orderBy==="none"?"CREATED_AT_DESC":o?.orderBy}),[a?.collectionId,o?.numberOfProducts,o?.orderBy]),{data:y}=core.useProductQuery(h&&o?.productSetting?.relatedProductId?o.productSetting.relatedProductId:void 0);react.useEffect(()=>{if(h&&y&&a.relatedTag&&"recommended-product"!==a.relatedType){let e;switch(g(!1),a.hasRelatedExclude&&(e=a?.relatedExclude&&a.relatedExclude.split(",").map(e=>e.trim())),a.relatedTag[0]){case"vendor":p({vendor:a.relatedTag&&"vendor"===a.relatedTag[0]?y?.vendor:"",limit:o?.numberOfProducts,idNEQ:y.id});break;case"collection":{let t;let r=y?.collections?.edges.map(e=>e.node?.id);if(!r||r?.length===0){g(!0);break}p(t=e&&e.length>0?{idNEQ:y.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:r},{titleNotIn:e}]}],limit:o?.numberOfProducts}:{idNEQ:y.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:r}]}],limit:o?.numberOfProducts});break}case"tag":{let t;if(!y.tags||0===y.tags.length){g(!0);break}p(t=e&&e.length>0?{idNEQ:y.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:y.tags},{nameNotIn:e}]}],limit:o?.numberOfProducts}:{idNEQ:y.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:y.tags}]}],limit:o?.numberOfProducts})}}}},[y,a.relatedType,a.relatedTag,o?.numberOfProducts,a.relatedExclude,a.hasRelatedExclude,h]);let S=core.useCollectionQuery("PickProduct"!==x?j:void 0),C=core.useProductsQuery("PickProduct"===x?a?.productIds:void 0,{revalidateOnMount:"edit"===d},{defaultSelectedProductCount:a?.numOfSelectedProducts}),f=core.useProductsQueryAll(u,{revalidateOnMount:"edit"===d}),[v,b]=react.useState(!0),w="PickProduct"===x?C.isValidating:S.isValidating,T="PickProduct"===x?C.isLoading:S.isLoading,R="PickProduct"===x?C.error:S.error,k=S.data?.collections?.edges?.[0]?.node,I="PickProduct"===x?core.flattenConnection(C.data?.products):core.flattenConnection(k?.products),O=f?.data?.products?core.flattenConnection(f?.data?.products):void 0,E=h&&O?O:"PickProduct"===x&&a?.productIds?.length?a?.productIds?.map(e=>I?.find(t=>t?.baseID===e)).filter(Boolean)??I:"PickProduct"!==x?I:I.filter((e,t)=>t<(a?.numOfSelectedProducts||4));return m&&h&&"edit"==d?jsxRuntime.jsx(ProductNotFound,{collectionHandle:k?.handle,productSrc:x,onClose:()=>b(!1),children:e}):E.length||T||"edit"!=d?jsxRuntime.jsx(jsxRuntime.Fragment,{children:w||T?jsxRuntime.jsx(Loading.default,{}):R?jsxRuntime.jsxs("div",{children:["Error: ",R?.message]}):!E||m&&h?jsxRuntime.jsx("div",{children:"Products not found"}):jsxRuntime.jsx(core.ProductListProvider,{collection:k,products:E,settings:{loop:o?.loop??{desktop:!1},scrollMode:o?.scrollMode??{desktop:"snap"},slidesToShow:o?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:r?.layout,dot:o?.dot,dotStyle:o?.dotStyle,arrow:o?.arrow,controlOverContent:o?.controlOverContent},styles:{horizontalGutter:r?.horizontalGutter,verticalGutter:r?.verticalGutter,fullWidth:r?.fullWidth,spacing:r?.spacing,width:r?.width,height:r?.height},children:jsxRuntime.jsxs("div",{className:"gp-relative",children:[n&&jsxRuntime.jsx(SalePageProductListWarning.default,{}),r?.layout==="grid"?jsxRuntime.jsx("div",{style:{...core.makeStyleResponsive("w",core.makeWidth(r?.width,r?.fullWidth)),...core.makeStyleResponsive("rg",r?.horizontalGutter),...core.makeStyleResponsive("cg",r?.verticalGutter),...core.makeStyleResponsive("gtc",{desktop:`repeat(${core.getResponsiveValueByScreen(o?.slidesToShow,"desktop")}, minmax(0, 1fr))`,tablet:o?.slidesToShow?.tablet&&`repeat(${core.getResponsiveValueByScreen(o?.slidesToShow,"tablet")}, minmax(0, 1fr))`,mobile:o?.slidesToShow?.mobile&&`repeat(${core.getResponsiveValueByScreen(o?.slidesToShow,"mobile")}, minmax(0, 1fr))`})},className:core.cls(t,"gp-m-auto gp-grid gp-w-full"),children:E?.length?E?.map(t=>jsxRuntime.jsx(core.ProductProvider,{product:t,readOnly:!0,children:jsxRuntime.jsx("div",{..."edit"===d?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")}:{},children:core.isEmptyChildren(e)?jsxRuntime.jsx(ChildrenDroppable.default,{}):e})},t?.baseID)):null}):jsxRuntime.jsx(Carousel.default,{setting:{loop:o?.loop,slidesToShow:o?.slidesToShow,dot:o?.dot,dotStyle:P,dotSize:{desktop:12},dotGapToCarousel:{desktop:16},navigationStyle:c,arrowCustom:o?.arrowCustom,controlOverContent:o?.controlOverContent,enableDrag:{desktop:o?.dragToScroll,tablet:o?.dragToScroll,mobile:o?.dragToScroll},speed:o?.speed,dotActiveColor:o?.dotActiveColor,dotColor:o?.dotColor,autoplay:o?.autoplay,pauseOnHover:o?.pauseOnHover,autoplayTimeout:o?.autoplayTimeout,arrowCustomColor:o?.arrowCustomColor,arrowButtonSize:{desktop:{width:"24px",height:"24px"}}},rootClass:"gp-justify-center",styles:{sizeSetting:{...product.getSizeSetting({adaptiveHeight:r?.adaptiveHeight,fullWidth:r?.fullWidth,width:r?.width,height:r?.height})},spacing:r?.spacing},children:E?.map(t=>jsxRuntime.jsx(CarouselItem.default,{style:{...carousel.getInitialWidthForCarouselItem({spacing:r?.spacing,slidesToShow:o?.slidesToShow})},children:jsxRuntime.jsx(core.ProductProvider,{product:t,readOnly:!0,children:jsxRuntime.jsx("div",{..."edit"===d?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")}:{},children:core.isEmptyChildren(e)?jsxRuntime.jsx(ChildrenDroppable.default,{}):e})})},t?.baseID))})]})})}):v?jsxRuntime.jsx(ProductNotFound,{collectionHandle:k?.handle,productSrc:x,onClose:()=>b(!1),children:e}):null};exports.default=ProductList;
@@ -1 +1 @@
1
- import{jsx as t,Fragment as o,jsxs as e}from"react/jsx-runtime";import{useEditorMode as r,usePageType as d,usePageStore as l,useProductQuery as i,useCollectionQuery as a,useProductsQuery as c,useProductsQueryAll as n,flattenConnection as s,ProductListProvider as u,makeStyleResponsive as p,makeWidth as m,getResponsiveValueByScreen as h,cls as g,ProductProvider as P,isEmptyChildren as f}from"@gem-sdk/core";import C from"next/dynamic";import{useMemo as S,useState as v,useEffect as b}from"react";import y from"../../common/components/Loading.js";import T from"../../carousel/components/Carousel.js";import w from"../../carousel/components/CarouselItem.js";import O from"../../grid/components/ChildrenDroppable.js";import{getUpdatedArrowDisplay as k}from"../../carousel/components/common/arrow.js";import{getUpdatedDotStyle as I}from"../../carousel/components/common/dots.js";import W from"./SalePageProductListWarning.js";import{getInitialWidthForCarouselItem as x}from"../../carousel/components/common/carousel.js";import{getSizeSetting as j}from"../helpers/product.js";let ProductNotFound=C(()=>import("./ProductNotFound.js"),{loading:y}),ProductList=({children:C,className:E,setting:N,styles:D})=>{let G=r(),L=d(),z=N?.productSetting??{},B=l(t=>t.dynamicCollection),H="GP_COLLECTION"==L;H&&(z.productSrc="DynamicCollection",z.collectionId=B?.collectionId??"latest");let A=S(()=>"GP_FUNNEL_PAGE"===L,[L]),F=S(()=>k(N?.arrow,N?.controlOverContent),[N?.arrow,N?.controlOverContent]),[_,M]=v(),[R,$]=v(!1),V="RelatedProduct"===z.productSrc,U=S(()=>I(N?.dot),[N?.dot]),q=z?.productSrc??"Collection",J=S(()=>({id:z?.collectionId??"latest",numberOfProducts:N?.numberOfProducts??4,orderBy:N?.orderBy==="none"?"CREATED_AT_DESC":N?.orderBy}),[z?.collectionId,N?.numberOfProducts,N?.orderBy]),{data:K}=i(V&&N?.productSetting?.relatedProductId?N.productSetting.relatedProductId:void 0);b(()=>{if(V&&K&&z.relatedTag&&"recommended-product"!==z.relatedType){let t;switch($(!1),z.hasRelatedExclude&&(t=z?.relatedExclude&&z.relatedExclude.split(",").map(t=>t.trim())),z.relatedTag[0]){case"vendor":M({vendor:z.relatedTag&&"vendor"===z.relatedTag[0]?K?.vendor:"",limit:N?.numberOfProducts});break;case"collection":{let o;let e=K?.collections?.edges.map(t=>t.node?.id);if(!e||e?.length===0){$(!0);break}M(o=t&&t.length>0?{hasCollectionProductsWith:[{hasCollectionWith:[{idIn:e},{titleNotIn:t}]}],limit:N?.numberOfProducts}:{hasCollectionProductsWith:[{hasCollectionWith:[{idIn:e}]}],limit:N?.numberOfProducts});break}case"tag":{let o;if(!K.tags||0===K.tags.length){$(!0);break}M(o=t&&t.length>0?{hasProductTagsWith:[{hasTagsWith:[{nameIn:K?.tags||[]},{nameNotIn:t}]}],limit:N?.numberOfProducts}:{hasProductTagsWith:[{hasTagsWith:[{idIn:K?.tags||[]}]}],limit:N?.numberOfProducts})}}}},[K,z.relatedType,z.relatedTag,N?.numberOfProducts,z.relatedExclude,z.hasRelatedExclude,V]);let Q=a("PickProduct"!==q?J:void 0),X=c("PickProduct"===q?z?.productIds:void 0,{revalidateOnMount:"edit"===G},{defaultSelectedProductCount:z?.numOfSelectedProducts}),Y=n(_,{revalidateOnMount:"edit"===G}),[Z,tt]=v(!0),to="PickProduct"===q?X.isValidating:Q.isValidating,te="PickProduct"===q?X.isLoading:Q.isLoading,tr="PickProduct"===q?X.error:Q.error,td=Q.data?.collections?.edges?.[0]?.node,tl="PickProduct"===q?s(X.data?.products):s(td?.products),ti=Y?.data?.products?s(Y?.data?.products):void 0,ta=V&&ti?ti:"PickProduct"===q&&z?.productIds?.length?z?.productIds?.map(t=>tl?.find(o=>o?.baseID===t)).filter(Boolean)??tl:"PickProduct"!==q?tl:tl.filter((t,o)=>o<(z?.numOfSelectedProducts||4));return R&&V&&"edit"==G?t(ProductNotFound,{collectionHandle:td?.handle,productSrc:q,onClose:()=>tt(!1),children:C}):ta.length||te||"edit"!=G?t(o,{children:to||te?t(y,{}):tr?e("div",{children:["Error: ",tr?.message]}):!ta||R&&V?t("div",{children:"Products not found"}):t(u,{collection:td,products:ta,settings:{loop:N?.loop??{desktop:!1},scrollMode:N?.scrollMode??{desktop:"snap"},slidesToShow:N?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:D?.layout,dot:N?.dot,dotStyle:N?.dotStyle,arrow:N?.arrow,controlOverContent:N?.controlOverContent},styles:{horizontalGutter:D?.horizontalGutter,verticalGutter:D?.verticalGutter,fullWidth:D?.fullWidth,spacing:D?.spacing,width:D?.width,height:D?.height},children:e("div",{className:"gp-relative",children:[A&&t(W,{}),D?.layout==="grid"?t("div",{style:{...p("w",m(D?.width,D?.fullWidth)),...p("rg",D?.horizontalGutter),...p("cg",D?.verticalGutter),...p("gtc",{desktop:`repeat(${h(N?.slidesToShow,"desktop")}, minmax(0, 1fr))`,tablet:N?.slidesToShow?.tablet&&`repeat(${h(N?.slidesToShow,"tablet")}, minmax(0, 1fr))`,mobile:N?.slidesToShow?.mobile&&`repeat(${h(N?.slidesToShow,"mobile")}, minmax(0, 1fr))`})},className:g(E,"gp-m-auto gp-grid gp-w-full"),children:ta?.length?ta?.map(o=>t(P,{product:o,readOnly:!0,children:t("div",{..."edit"===G?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":o?.baseID?.replace("gid://shopify/Product/","")}:{},children:f(C)?t(O,{}):C})},o?.baseID)):null}):t(T,{setting:{loop:N?.loop,slidesToShow:N?.slidesToShow,dot:N?.dot,dotStyle:U,dotSize:{desktop:12},dotGapToCarousel:{desktop:16},navigationStyle:F,arrowCustom:N?.arrowCustom,controlOverContent:N?.controlOverContent,enableDrag:{desktop:N?.dragToScroll,tablet:N?.dragToScroll,mobile:N?.dragToScroll},speed:N?.speed,dotActiveColor:N?.dotActiveColor,dotColor:N?.dotColor,autoplay:N?.autoplay,pauseOnHover:N?.pauseOnHover,autoplayTimeout:N?.autoplayTimeout,arrowCustomColor:N?.arrowCustomColor,arrowButtonSize:{desktop:{width:"24px",height:"24px"}}},rootClass:"gp-justify-center",styles:{sizeSetting:{...j({adaptiveHeight:D?.adaptiveHeight,fullWidth:D?.fullWidth,width:D?.width,height:D?.height})},spacing:D?.spacing},children:ta?.map(o=>t(w,{style:{...x({spacing:D?.spacing,slidesToShow:N?.slidesToShow})},children:t(P,{product:o,readOnly:!0,children:t("div",{..."edit"===G?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":o?.baseID?.replace("gid://shopify/Product/","")}:{},children:f(C)?t(O,{}):C})})},o?.baseID))})]})})}):Z?t(ProductNotFound,{collectionHandle:td?.handle,productSrc:q,onClose:()=>tt(!1),children:C}):null};export{ProductList as default};
1
+ import{jsx as t,Fragment as o,jsxs as e}from"react/jsx-runtime";import{useEditorMode as r,usePageType as d,usePageStore as l,useProductQuery as i,useCollectionQuery as a,useProductsQuery as c,useProductsQueryAll as n,flattenConnection as s,ProductListProvider as u,makeStyleResponsive as p,makeWidth as m,getResponsiveValueByScreen as h,cls as g,ProductProvider as P,isEmptyChildren as f}from"@gem-sdk/core";import C from"next/dynamic";import{useMemo as S,useState as v,useEffect as b}from"react";import y from"../../common/components/Loading.js";import T from"../../carousel/components/Carousel.js";import w from"../../carousel/components/CarouselItem.js";import O from"../../grid/components/ChildrenDroppable.js";import{getUpdatedArrowDisplay as k}from"../../carousel/components/common/arrow.js";import{getUpdatedDotStyle as I}from"../../carousel/components/common/dots.js";import E from"./SalePageProductListWarning.js";import{getInitialWidthForCarouselItem as N}from"../../carousel/components/common/carousel.js";import{getSizeSetting as W}from"../helpers/product.js";let ProductNotFound=C(()=>import("./ProductNotFound.js"),{loading:y}),ProductList=({children:C,className:x,setting:j,styles:D})=>{let G=r(),L=d(),z=j?.productSetting??{},B=l(t=>t.dynamicCollection),H="GP_COLLECTION"==L;H&&(z.productSrc="DynamicCollection",z.collectionId=B?.collectionId??"latest");let A=S(()=>"GP_FUNNEL_PAGE"===L,[L]),F=S(()=>k(j?.arrow,j?.controlOverContent),[j?.arrow,j?.controlOverContent]),[Q,_]=v(),[M,R]=v(!1),$="RelatedProduct"===z.productSrc,V=S(()=>I(j?.dot),[j?.dot]),U=z?.productSrc??"Collection",q=S(()=>({id:z?.collectionId??"latest",numberOfProducts:j?.numberOfProducts??4,orderBy:j?.orderBy==="none"?"CREATED_AT_DESC":j?.orderBy}),[z?.collectionId,j?.numberOfProducts,j?.orderBy]),{data:J}=i($&&j?.productSetting?.relatedProductId?j.productSetting.relatedProductId:void 0);b(()=>{if($&&J&&z.relatedTag&&"recommended-product"!==z.relatedType){let t;switch(R(!1),z.hasRelatedExclude&&(t=z?.relatedExclude&&z.relatedExclude.split(",").map(t=>t.trim())),z.relatedTag[0]){case"vendor":_({vendor:z.relatedTag&&"vendor"===z.relatedTag[0]?J?.vendor:"",limit:j?.numberOfProducts,idNEQ:J.id});break;case"collection":{let o;let e=J?.collections?.edges.map(t=>t.node?.id);if(!e||e?.length===0){R(!0);break}_(o=t&&t.length>0?{idNEQ:J.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:e},{titleNotIn:t}]}],limit:j?.numberOfProducts}:{idNEQ:J.id,hasCollectionProductsWith:[{hasCollectionWith:[{idIn:e}]}],limit:j?.numberOfProducts});break}case"tag":{let o;if(!J.tags||0===J.tags.length){R(!0);break}_(o=t&&t.length>0?{idNEQ:J.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:J.tags},{nameNotIn:t}]}],limit:j?.numberOfProducts}:{idNEQ:J.id,hasProductTagsWith:[{hasTagsWith:[{nameIn:J.tags}]}],limit:j?.numberOfProducts})}}}},[J,z.relatedType,z.relatedTag,j?.numberOfProducts,z.relatedExclude,z.hasRelatedExclude,$]);let K=a("PickProduct"!==U?q:void 0),X=c("PickProduct"===U?z?.productIds:void 0,{revalidateOnMount:"edit"===G},{defaultSelectedProductCount:z?.numOfSelectedProducts}),Y=n(Q,{revalidateOnMount:"edit"===G}),[Z,tt]=v(!0),to="PickProduct"===U?X.isValidating:K.isValidating,te="PickProduct"===U?X.isLoading:K.isLoading,tr="PickProduct"===U?X.error:K.error,td=K.data?.collections?.edges?.[0]?.node,tl="PickProduct"===U?s(X.data?.products):s(td?.products),ti=Y?.data?.products?s(Y?.data?.products):void 0,ta=$&&ti?ti:"PickProduct"===U&&z?.productIds?.length?z?.productIds?.map(t=>tl?.find(o=>o?.baseID===t)).filter(Boolean)??tl:"PickProduct"!==U?tl:tl.filter((t,o)=>o<(z?.numOfSelectedProducts||4));return M&&$&&"edit"==G?t(ProductNotFound,{collectionHandle:td?.handle,productSrc:U,onClose:()=>tt(!1),children:C}):ta.length||te||"edit"!=G?t(o,{children:to||te?t(y,{}):tr?e("div",{children:["Error: ",tr?.message]}):!ta||M&&$?t("div",{children:"Products not found"}):t(u,{collection:td,products:ta,settings:{loop:j?.loop??{desktop:!1},scrollMode:j?.scrollMode??{desktop:"snap"},slidesToShow:j?.slidesToShow??{desktop:4,tablet:3,mobile:1},layout:D?.layout,dot:j?.dot,dotStyle:j?.dotStyle,arrow:j?.arrow,controlOverContent:j?.controlOverContent},styles:{horizontalGutter:D?.horizontalGutter,verticalGutter:D?.verticalGutter,fullWidth:D?.fullWidth,spacing:D?.spacing,width:D?.width,height:D?.height},children:e("div",{className:"gp-relative",children:[A&&t(E,{}),D?.layout==="grid"?t("div",{style:{...p("w",m(D?.width,D?.fullWidth)),...p("rg",D?.horizontalGutter),...p("cg",D?.verticalGutter),...p("gtc",{desktop:`repeat(${h(j?.slidesToShow,"desktop")}, minmax(0, 1fr))`,tablet:j?.slidesToShow?.tablet&&`repeat(${h(j?.slidesToShow,"tablet")}, minmax(0, 1fr))`,mobile:j?.slidesToShow?.mobile&&`repeat(${h(j?.slidesToShow,"mobile")}, minmax(0, 1fr))`})},className:g(x,"gp-m-auto gp-grid gp-w-full"),children:ta?.length?ta?.map(o=>t(P,{product:o,readOnly:!0,children:t("div",{..."edit"===G?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":o?.baseID?.replace("gid://shopify/Product/","")}:{},children:f(C)?t(O,{}):C})},o?.baseID)):null}):t(T,{setting:{loop:j?.loop,slidesToShow:j?.slidesToShow,dot:j?.dot,dotStyle:V,dotSize:{desktop:12},dotGapToCarousel:{desktop:16},navigationStyle:F,arrowCustom:j?.arrowCustom,controlOverContent:j?.controlOverContent,enableDrag:{desktop:j?.dragToScroll,tablet:j?.dragToScroll,mobile:j?.dragToScroll},speed:j?.speed,dotActiveColor:j?.dotActiveColor,dotColor:j?.dotColor,autoplay:j?.autoplay,pauseOnHover:j?.pauseOnHover,autoplayTimeout:j?.autoplayTimeout,arrowCustomColor:j?.arrowCustomColor,arrowButtonSize:{desktop:{width:"24px",height:"24px"}}},rootClass:"gp-justify-center",styles:{sizeSetting:{...W({adaptiveHeight:D?.adaptiveHeight,fullWidth:D?.fullWidth,width:D?.width,height:D?.height})},spacing:D?.spacing},children:ta?.map(o=>t(w,{style:{...N({spacing:D?.spacing,slidesToShow:j?.slidesToShow})},children:t(P,{product:o,readOnly:!0,children:t("div",{..."edit"===G?{"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":o?.baseID?.replace("gid://shopify/Product/","")}:{},children:f(C)?t(O,{}):C})})},o?.baseID))})]})})}):Z?t(ProductNotFound,{collectionHandle:td?.handle,productSrc:U,onClose:()=>tt(!1),children:C}):null};export{ProductList as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.835",
3
+ "version": "2.0.0-dev.837",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -21,7 +21,7 @@
21
21
  "format": "prettier --write \"./src/**/*.{ts,tsx}\""
22
22
  },
23
23
  "devDependencies": {
24
- "@gem-sdk/core": "2.0.0-dev.834",
24
+ "@gem-sdk/core": "2.0.0-dev.837",
25
25
  "@gem-sdk/styles": "1.14.0-dev.831",
26
26
  "@types/react-transition-group": "^4.4.5"
27
27
  },