@bikdotai/bik-component-library 0.0.461-1 → 0.0.461-3

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,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),o=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),u=require("../input/Input.js"),d=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=b=>{const{data:C,collectionsDispatch:O,selectedData:k,selectedCollectionsDispatch:x,productFetcher:f,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:q,customCollectionRestriction:A,hideProductCheckbox:E,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:w,onProductDetailClick:F,showProductDetailInfoIcon:B}=b,_=o.useContext(v.CollectionIdContext),U=o.useRef(null),H=o.useRef(0),[J,K]=o.useState(!1),[M,N]=o.useState(""),[W,z]=o.useState(!1),[G,Q]=o.useState(C),X=o.useRef(!1);o.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),b.searchInCollectionFetcher(S,_,M).then((e=>{const t=s.cloneDeep(C);t.products=e,Q(t);const r=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});Z(r,null!=e?e:{},!0),I(!1),z(!1)}))):Q(C)}),800);return()=>clearTimeout(e)}),[M]),o.useEffect((()=>{var e,t,r,c;X.current=!1,H.current=Math.floor((null===(t=Object.keys(null!==(e=C.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const s=P.getVariantIdsToFetchAtProductLevel(null!==(r=C.products)&&void 0!==r?r:{});Z(s,null!==(c=C.products)&&void 0!==c?c:{})}),[_]);const Y=!!A&&C.isSmartCollection;o.useEffect((()=>{(null==C?void 0:C.products)||$(10)}),[]);const Z=(e,t,r)=>{w||(r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)),e.length>0&&w&&w(S,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((r=>{var s,o;Object.keys(null!==(o=null===(s=null==t?void 0:t[r])||void 0===s?void 0:s.variants)&&void 0!==o?o:{}).forEach((s=>{var o,n;const i=null===(o=null==t?void 0:t[r].variants)||void 0===o?void 0:o[s];i&&"REJECTED"===e[s]?i.fbStatus="REJECTED":i&&"APPROVED"===e[s]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.variants;l&&l[s]&&(l[s]=i)}))})),r?(Q((e=>{const t=Object.assign({},e);return t.products=c,t})),O({type:"productsPaged",data:{collectionId:_,products:c}})):O({type:"productsPaged",data:{collectionId:_,products:c}})})).catch((e=>{r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)}))};o.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&H.current>=0&&!X.current&&!M&&(I(!0),K(!0),f(_,S,10,H.current).then((e=>{if(Object.keys(e).length||(X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const r=P.getVariantIdsToFetchAtProductLevel(e);Z(r,e),H.current+=1}K(!1),I(!1)})).catch())}),{threshold:1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}}),[U,M]);const $=e=>{I(!0),z(!0),f(_,S,e,0).then((t=>{if(Object.keys(t).length||(X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);Z(e,t),H.current=1}e||x({type:"selected",data:{id:_,val:Object.assign(Object.assign({},C),{products:t})}}),I(!1),z(!1)})).catch()},ee=(e,t)=>{const r=P.liftTheStateUp(t,C);x({type:e,data:Object.assign(Object.assign({},r),{isRestricted:A})})};return e.jsxs("div",{children:[e.jsxs(g.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:C.name}))]}),!q&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(d.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!E&&"-1"!==_&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==k?void 0:k[_]),isPartiallyChecked:P.isCollectionPartiallyChecked(_,G,k,L),onValueChange:function(e){e?$():x({type:"unselected",data:{id:_}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:_,isProductPartiallyChecked:P.isProductPartiallyChecked(_,t,k,G),productId:t,data:G.products[t],selectedData:k,selectedCollectionsDispatch:x,viewOnly:!V&&!!Y,upliftAdditions:ee,hideProductCheckbox:E,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:F,showProductDetailInfoIcon:B},t))):W?e.jsx(j.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:U})]}),J&&e.jsx(j.ProductPickerShimmer,{})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),o=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),u=require("../input/Input.js"),d=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=b=>{const{data:C,collectionsDispatch:O,selectedData:k,selectedCollectionsDispatch:x,productFetcher:f,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:q,customCollectionRestriction:A,hideProductCheckbox:E,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:w,onProductDetailClick:F,showProductDetailInfoIcon:B}=b,_=o.useContext(v.CollectionIdContext),U=o.useRef(null),H=o.useRef(0),[J,K]=o.useState(!1),[M,N]=o.useState(""),[W,z]=o.useState(!1),[G,Q]=o.useState(C),X=o.useRef(!1);o.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),b.searchInCollectionFetcher(S,_,M).then((e=>{const t=s.cloneDeep(C);t.products=e,Q(t);const r=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});Z(r,null!=e?e:{},!0),I(!1),z(!1)}))):Q(C)}),800);return()=>clearTimeout(e)}),[M]),o.useEffect((()=>{var e,t,r,c;X.current=!1,H.current=Math.floor((null===(t=Object.keys(null!==(e=C.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const s=P.getVariantIdsToFetchAtProductLevel(null!==(r=C.products)&&void 0!==r?r:{});Z(s,null!==(c=C.products)&&void 0!==c?c:{})}),[_]);const Y=!!A&&C.isSmartCollection;o.useEffect((()=>{(null==C?void 0:C.products)||$(10)}),[]);const Z=(e,t,r)=>{w||(r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)),e.length>0&&w&&w(S,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((r=>{var s,o;Object.keys(null!==(o=null===(s=null==t?void 0:t[r])||void 0===s?void 0:s.variants)&&void 0!==o?o:{}).forEach((s=>{var o,n;const i=null===(o=null==t?void 0:t[r].variants)||void 0===o?void 0:o[s];i&&"REJECTED"===e[s]?i.fbStatus="REJECTED":i&&"APPROVED"===e[s]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.variants;l&&l[s]&&(l[s]=i)}))})),r?(Q((e=>{const t=Object.assign({},e);return t.products=c,t})),O({type:"productsPaged",data:{collectionId:_,products:c}})):O({type:"productsPaged",data:{collectionId:_,products:c}})})).catch((e=>{r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)}))};o.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&H.current>=0&&!X.current&&!M&&(I(!0),K(!0),f(_,S,10,H.current).then((e=>{if(Object.keys(e).length||(X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const r=P.getVariantIdsToFetchAtProductLevel(e);Z(r,e),H.current+=1}K(!1),I(!1)})).catch())}),{threshold:1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}}),[U,M]);const $=e=>{I(!0),z(!0),f(_,S,e,0).then((t=>{if(Object.keys(t).length||(X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);Z(e,t),H.current=1}e||x({type:"selected",data:{id:_,val:Object.assign(Object.assign({},C),{products:t})}}),I(!1),z(!1)})).catch()},ee=(e,t)=>{const r=P.liftTheStateUp(t,C);x({type:e,data:Object.assign(Object.assign({},r),{isRestricted:A})})};return e.jsxs("div",{children:[e.jsxs(g.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:C.name}))]}),!q&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(d.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!E&&"-1"!==_&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==k?void 0:k[_]),isPartiallyChecked:P.isCollectionPartiallyChecked(_,G,k,L),onValueChange:function(e){e?$():x({type:"unselected",data:{id:_}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:_,isProductPartiallyChecked:P.isProductPartiallyChecked(_,t,k,G,L),productId:t,data:G.products[t],selectedData:k,selectedCollectionsDispatch:x,viewOnly:!V&&!!Y,upliftAdditions:ee,hideProductCheckbox:E,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:F,showProductDetailInfoIcon:B},t))):W?e.jsx(j.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:U})]}),J&&e.jsx(j.ProductPickerShimmer,{})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),c=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:v,searchedCollections:p,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:y,collections:k,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:m,storeId:f,fbStatusFetcher:g,setCollectionId:I,setSelectedCollectionId:q,hideCollectionCheckbox:O,renderWithoutModal:D}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=p.products)&&void 0!==e?e:{},f,C,g,"setProducts")}),[null==p?void 0:p.products]);const F=!!h&&(null==v?void 0:v.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{y("collections"),b()}}),e.jsx(i.BodyCaption,{children:(null===(a=Object.keys(null==p?void 0:p.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==p?void 0:p.products).length||Object.keys(null==p?void 0:p.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.collections).map((t=>e.jsx(c.CollectionCard,{customCollectionRestriction:h,data:null==k?void 0:k[t],isDisabled:F&&!(null==v?void 0:v[t]),isChecked:!!(null==v?void 0:v[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==k?void 0:k[t],v,P),selectedCollectionsDispatch:j,setCollectionId:I,setSelectedCollectionId:q,setScreen:y,id:t,hideCollectionCheckbox:O||"-1"===t,selectedCollections:v,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==p?void 0:p.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,i,c;let s=!1;return(null===(l=null==p?void 0:p.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const i=n.liftTheStateUp(o,null===(l=null==p?void 0:p.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},i),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(i=null==p?void 0:p.products)||void 0===i?void 0:i[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,v,null===(c=p.products)||void 0===c?void 0:c[t]),selectedData:v,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:m,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),c=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:v,searchedCollections:p,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:y,collections:k,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:m,storeId:f,fbStatusFetcher:g,setCollectionId:I,setSelectedCollectionId:q,hideCollectionCheckbox:O,renderWithoutModal:D}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=p.products)&&void 0!==e?e:{},f,C,g,"setProducts")}),[null==p?void 0:p.products]);const F=!!h&&(null==v?void 0:v.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{y("collections"),b()}}),e.jsx(i.BodyCaption,{children:(null===(a=Object.keys(null==p?void 0:p.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==p?void 0:p.products).length||Object.keys(null==p?void 0:p.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.collections).map((t=>e.jsx(c.CollectionCard,{customCollectionRestriction:h,data:null==k?void 0:k[t],isDisabled:F&&!(null==v?void 0:v[t]),isChecked:!!(null==v?void 0:v[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==k?void 0:k[t],v,P),selectedCollectionsDispatch:j,setCollectionId:I,setSelectedCollectionId:q,setScreen:y,id:t,hideCollectionCheckbox:O||"-1"===t,selectedCollections:v,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==p?void 0:p.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,i,c;let s=!1;return(null===(l=null==p?void 0:p.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const i=n.liftTheStateUp(o,null===(l=null==p?void 0:p.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},i),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(i=null==p?void 0:p.products)||void 0===i?void 0:i[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,v,null===(c=p.products)||void 0===c?void 0:c[t],P),selectedData:v,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:m,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),c=require("../icon-button/IconButton.js"),s=require("../TypographyStyle.js"),l=require("./emptyState.js"),o=require("./helpers/AllProductHelper.js"),n=require("./product.js"),u=require("./reducers.js"),i=require("./style.js"),d=require("./utility.js");exports.SelectedScreen=a=>{const{selectedCollections:p,selectedCollectionsDispatch:j,setScreen:f,collections:h,hideProductVariants:S=!1,outOfStockAction:y,storeId:v,fbStatusFetcher:b}=a,P=r.useRef(0),g=r.useRef(null),[x,q]=r.useReducer(u.paginationReducer,{});r.useEffect((()=>{P.current=0;const e=d.paginateSelectedItems(p,10,0);q({type:"paginate",data:e}),d.fetchFbStatusCollection(e,v,q,b,"set"),P.current+=1}),[]),r.useEffect((()=>{q({type:"filter",data:p})}),[p]),r.useEffect((()=>{const e=new IntersectionObserver((e=>{if(e[0].isIntersecting&&P.current>0){const e=d.paginateSelectedItems(p,10,P.current);q({type:"paginate",data:e}),d.fetchFbStatusCollection(e,v,q,b,"update"),P.current+=1}}),{threshold:1});return g.current&&e.observe(g.current),()=>{g.current&&e.unobserve(g.current)}}),[g,p]);const C=S?o.AllProductHelper.removeDuplicatesForAllProducts(Object.assign({},p)):p;return console.log({curScreenData:x,selectedCollections:p}),e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,onClick:()=>{f("collections")}}),e.jsx(s.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(x).length>0?e.jsx(e.Fragment,{children:Object.keys(x).map((t=>{var r;return Object.keys((null===(r=null==x?void 0:x[t])||void 0===r?void 0:r.products)||[]).map((r=>{let c=!1;return(null==C?void 0:C.isCustom)&&(c=!0),e.jsx(n.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:x[t].products[r],isProductPartiallyChecked:d.isProductPartiallyChecked(t,r,C,null==h?void 0:h[t]),selectedData:C,selectedCollectionsDispatch:j,viewOnly:c,hideProductVariants:S,outOfStockAction:y},r)}))}))}):e.jsx(l.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:g})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),c=require("../icon-button/IconButton.js"),s=require("../TypographyStyle.js"),l=require("./emptyState.js"),o=require("./helpers/AllProductHelper.js"),n=require("./product.js"),u=require("./reducers.js"),i=require("./style.js"),d=require("./utility.js");exports.SelectedScreen=a=>{const{selectedCollections:p,selectedCollectionsDispatch:j,setScreen:f,collections:h,hideProductVariants:S=!1,outOfStockAction:y,storeId:v,fbStatusFetcher:b}=a,P=r.useRef(0),g=r.useRef(null),[x,q]=r.useReducer(u.paginationReducer,{});r.useEffect((()=>{P.current=0;const e=d.paginateSelectedItems(p,10,0);q({type:"paginate",data:e}),d.fetchFbStatusCollection(e,v,q,b,"set"),P.current+=1}),[]),r.useEffect((()=>{q({type:"filter",data:p})}),[p]),r.useEffect((()=>{const e=new IntersectionObserver((e=>{if(e[0].isIntersecting&&P.current>0){const e=d.paginateSelectedItems(p,10,P.current);q({type:"paginate",data:e}),d.fetchFbStatusCollection(e,v,q,b,"update"),P.current+=1}}),{threshold:1});return g.current&&e.observe(g.current),()=>{g.current&&e.unobserve(g.current)}}),[g,p]);const C=S?o.AllProductHelper.removeDuplicatesForAllProducts(Object.assign({},p)):p;return console.log({curScreenData:x,selectedCollections:p}),e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,onClick:()=>{f("collections")}}),e.jsx(s.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(x).length>0?e.jsx(e.Fragment,{children:Object.keys(x).map((t=>{var r;return Object.keys((null===(r=null==x?void 0:x[t])||void 0===r?void 0:r.products)||[]).map((r=>{let c=!1;return(null==C?void 0:C.isCustom)&&(c=!0),e.jsx(n.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:x[t].products[r],isProductPartiallyChecked:d.isProductPartiallyChecked(t,r,C,null==h?void 0:h[t],S),selectedData:C,selectedCollectionsDispatch:j,viewOnly:c,hideProductVariants:S,outOfStockAction:y},r)}))}))}):e.jsx(l.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:g})]})]})};
@@ -34,5 +34,5 @@ export declare const markVariantsAsApprovedProductsLevel: (products: {
34
34
  * Other cases returns true.
35
35
  */
36
36
  export declare const shouldShowVariant: (data: Product) => boolean;
37
- export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection) => boolean;
37
+ export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection, hideProductVariants?: boolean) => boolean;
38
38
  export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems, hideProductVariants?: boolean) => boolean;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function t(o,t,l){if(!o)return{};const i=Object.keys(o).slice(l,l+t),n={};return i.forEach((t=>{n[t]=o[t]})),n}const l=(o,t,l)=>{Object.keys(o).forEach((t=>{var l,i;const n=null!==(i=null===(l=o[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(n).forEach((l=>{var i,n,d,v;const s=null!==(v=null===(d=null===(n=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===n?void 0:n[l])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((i=>{var n,d,v,s;const e=null===(s=null===(v=null===(d=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===d?void 0:d[l])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[i];e&&!e.fbStatus&&(e.fbStatus="APPROVED")}))}))})),t({type:l,data:o})};exports.fetchFbStatusCollection=function(o,t,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||l(o,i,d);const v=(o=>{const t=[];return Object.keys(o).forEach((l=>{var i,n;const d=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const u=null===(e=null===(s=null===(v=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];(null==u?void 0:u.fbStatus)||t.push(n)}))}))})),t})(o);v.length>0&&n&&n(t,v).then((t=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var i,n;const d=null!==(n=null===(i=l[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const u=null===(e=null===(s=null===(v=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];u&&"REJECTED"===t[n]?u.fbStatus="REJECTED":u&&"APPROVED"===t[n]&&(u.fbStatus="APPROVED")}))}))})),i({type:d,data:l})})).catch((t=>{console.error("Error in fbStatusFetcher",t),l(o,i,d)}))},exports.getVariantIdsToFetchAtProductLevel=(o,t)=>{const l=[];return Object.keys(null!=o?o:{}).forEach((i=>{var n,d;const v=null!==(d=null===(n=null==o?void 0:o[i])||void 0===n?void 0:n.variants)&&void 0!==d?d:{};Object.keys(v).forEach((n=>{var d,v,s,e,u;let c;c=t?null===(s=null===(v=null===(d=null==t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n]:null===(u=null===(e=null==o?void 0:o[i])||void 0===e?void 0:e.variants)||void 0===u?void 0:u[n],(null==c?void 0:c.fbStatus)||l.push(n)}))})),l},exports.isCollectionPartiallyChecked=function(o,t,l){var i,n,d,v;let s=0,e=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(i=null==t?void 0:t.products)&&void 0!==i?i:{};s=Object.keys(v).length;const u=null!==(d=null===(n=l[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};e=Object.keys(u).length}else if(l[o]){const i=null==t?void 0:t.products;i&&Object.keys(i).forEach((o=>{var t;const l=null===(t=i[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>s+=1))}));const n=null===(v=l[o])||void 0===v?void 0:v.products;if(n&&Object.keys(n).forEach((o=>{var t;const l=null===(t=n[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>e+=1))})),s<=0&&e>0)return!1}return e>0&&s!==e},exports.isProductPartiallyChecked=(o,t,l,i)=>{var n,d,v,s,e,u,c,r,a,p,f,b,O,h,y,j,E,k,g;let P=0,S=0;if(null===(d=null===(n=null==l?void 0:l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[t]){const n=(null===(e=null===(s=null===(v=null==l?void 0:l[o])||void 0===v?void 0:v.products)||void 0===s?void 0:s[t])||void 0===e?void 0:e.variants)||[];if(1===Object.keys(n).length)for(const i in n){const n=null===(c=null===(u=null==l?void 0:l[o])||void 0===u?void 0:u.products)||void 0===c?void 0:c[t],d=null===(f=null===(p=null===(a=null===(r=null==l?void 0:l[o])||void 0===r?void 0:r.products)||void 0===a?void 0:a[t])||void 0===p?void 0:p.variants)||void 0===f?void 0:f[i];if(null===(b=null==d?void 0:d.name)||void 0===b?void 0:b.includes(null!==(O=null==n?void 0:n.name)&&void 0!==O?O:""))return!1}if(null===(j=Object.keys((null===(y=null===(h=null==i?void 0:i.products)||void 0===h?void 0:h[t])||void 0===y?void 0:y.variants)||[]))||void 0===j||j.forEach((()=>S++)),Object.keys((null===(g=null===(k=null===(E=null==l?void 0:l[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[t])||void 0===g?void 0:g.variants)||[]).forEach((()=>P++)),P>0&&S!==P)return!0}return!1},exports.liftTheStateUp=(t,l)=>{const i=o.cloneDeep(l);if(delete i.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:i})).productId&&l.products){const n=o.cloneDeep(l.products[t.productId]);(null==n?void 0:n.variants)&&delete n.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:i,productOnlyData:n})}return t},exports.markVariantsAsApprovedProductsLevel=(o,t,l,i,n)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((t=>{var l,i;Object.keys(null!==(i=null===(l=null==o?void 0:o[t])||void 0===l?void 0:l.variants)&&void 0!==i?i:{}).forEach((l=>{var i,n;const v=null===(i=null==o?void 0:o[t].variants)||void 0===i?void 0:i[l];v&&(v.fbStatus="APPROVED");const s=null===(n=null==d?void 0:d[t])||void 0===n?void 0:n.variants;s&&s[l]&&(s[l]=v)}))})),i&&n){const o=Object.assign({},i);o.products=d,n(o),t({type:"productsPaged",data:{collectionId:l,products:d}})}else t({type:"productsPaged",data:{collectionId:l,products:d}})},exports.paginateSelectedItems=function(o,l,i){var n;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const e=o[s],u=t(e.products,l,i-v);u&&Object.keys(u).length>0&&(d[s]=Object.assign(Object.assign({},e),{products:u})),v+=Object.keys(null!==(n=e.products)&&void 0!==n?n:{}).length}return d},exports.shouldShowVariant=o=>{const t=Object.keys(o.variants||[]);let l=!1;return!(t.length<=1)||(t.forEach((t=>{var i,n;l=null!==(n=null===(i=o.variants)||void 0===i?void 0:i[t].name.includes(o.name))&&void 0!==n&&n})),!l)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function t(o,t,l){if(!o)return{};const i=Object.keys(o).slice(l,l+t),n={};return i.forEach((t=>{n[t]=o[t]})),n}const l=(o,t,l)=>{Object.keys(o).forEach((t=>{var l,i;const n=null!==(i=null===(l=o[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(n).forEach((l=>{var i,n,d,v;const e=null!==(v=null===(d=null===(n=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===n?void 0:n[l])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(e).forEach((i=>{var n,d,v,e;const s=null===(e=null===(v=null===(d=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===d?void 0:d[l])||void 0===v?void 0:v.variants)||void 0===e?void 0:e[i];s&&!s.fbStatus&&(s.fbStatus="APPROVED")}))}))})),t({type:l,data:o})};exports.fetchFbStatusCollection=function(o,t,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||l(o,i,d);const v=(o=>{const t=[];return Object.keys(o).forEach((l=>{var i,n;const d=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,e;const s=null!==(e=null===(v=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==e?e:{};Object.keys(s).forEach((n=>{var d,v,e,s;const c=null===(s=null===(e=null===(v=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[n];(null==c?void 0:c.fbStatus)||t.push(n)}))}))})),t})(o);v.length>0&&n&&n(t,v).then((t=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var i,n;const d=null!==(n=null===(i=l[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,e;const s=null!==(e=null===(v=null===(d=null===(n=l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==e?e:{};Object.keys(s).forEach((n=>{var d,v,e,s;const c=null===(s=null===(e=null===(v=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[n];c&&"REJECTED"===t[n]?c.fbStatus="REJECTED":c&&"APPROVED"===t[n]&&(c.fbStatus="APPROVED")}))}))})),i({type:d,data:l})})).catch((t=>{console.error("Error in fbStatusFetcher",t),l(o,i,d)}))},exports.getVariantIdsToFetchAtProductLevel=(o,t)=>{const l=[];return Object.keys(null!=o?o:{}).forEach((i=>{var n,d;const v=null!==(d=null===(n=null==o?void 0:o[i])||void 0===n?void 0:n.variants)&&void 0!==d?d:{};Object.keys(v).forEach((n=>{var d,v,e,s,c;let r;r=t?null===(e=null===(v=null===(d=null==t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===e?void 0:e[n]:null===(c=null===(s=null==o?void 0:o[i])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[n],(null==r?void 0:r.fbStatus)||l.push(n)}))})),l},exports.isCollectionPartiallyChecked=function(o,t,l){var i,n,d,v;let e=0,s=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(i=null==t?void 0:t.products)&&void 0!==i?i:{};e=Object.keys(v).length;const c=null!==(d=null===(n=l[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};s=Object.keys(c).length}else if(l[o]){const i=null==t?void 0:t.products;i&&Object.keys(i).forEach((o=>{var t;const l=null===(t=i[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>e+=1))}));const n=null===(v=l[o])||void 0===v?void 0:v.products;if(n&&Object.keys(n).forEach((o=>{var t;const l=null===(t=n[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>s+=1))})),e<=0&&s>0)return!1}return s>0&&e!==s},exports.isProductPartiallyChecked=(o,t,l,i,n)=>{var d,v,e,s,c,r,u,a,p,f,b,h,O,y,j,E,k,g,P;let D=0,S=0;if(console.log({collectionId:o,productId:t,selectedData:l,currentCollection:i,hideProductVariants:n}),null===(v=null===(d=null==l?void 0:l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[t]){if(console.log({hideProductVariants:n}),n)return!0;const d=(null===(c=null===(s=null===(e=null==l?void 0:l[o])||void 0===e?void 0:e.products)||void 0===s?void 0:s[t])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(d).length)for(const i in d){const n=null===(u=null===(r=null==l?void 0:l[o])||void 0===r?void 0:r.products)||void 0===u?void 0:u[t],d=null===(b=null===(f=null===(p=null===(a=null==l?void 0:l[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[t])||void 0===f?void 0:f.variants)||void 0===b?void 0:b[i];if(null===(h=null==d?void 0:d.name)||void 0===h?void 0:h.includes(null!==(O=null==n?void 0:n.name)&&void 0!==O?O:""))return!1}if(null===(E=Object.keys((null===(j=null===(y=null==i?void 0:i.products)||void 0===y?void 0:y[t])||void 0===j?void 0:j.variants)||[]))||void 0===E||E.forEach((()=>S++)),Object.keys((null===(P=null===(g=null===(k=null==l?void 0:l[o])||void 0===k?void 0:k.products)||void 0===g?void 0:g[t])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},exports.liftTheStateUp=(t,l)=>{const i=o.cloneDeep(l);if(delete i.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:i})).productId&&l.products){const n=o.cloneDeep(l.products[t.productId]);(null==n?void 0:n.variants)&&delete n.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:i,productOnlyData:n})}return t},exports.markVariantsAsApprovedProductsLevel=(o,t,l,i,n)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((t=>{var l,i;Object.keys(null!==(i=null===(l=null==o?void 0:o[t])||void 0===l?void 0:l.variants)&&void 0!==i?i:{}).forEach((l=>{var i,n;const v=null===(i=null==o?void 0:o[t].variants)||void 0===i?void 0:i[l];v&&(v.fbStatus="APPROVED");const e=null===(n=null==d?void 0:d[t])||void 0===n?void 0:n.variants;e&&e[l]&&(e[l]=v)}))})),i&&n){const o=Object.assign({},i);o.products=d,n(o),t({type:"productsPaged",data:{collectionId:l,products:d}})}else t({type:"productsPaged",data:{collectionId:l,products:d}})},exports.paginateSelectedItems=function(o,l,i){var n;const d={};let v=0;for(const e in o)if(Object.prototype.hasOwnProperty.call(o,e)){const s=o[e],c=t(s.products,l,i-v);c&&Object.keys(c).length>0&&(d[e]=Object.assign(Object.assign({},s),{products:c})),v+=Object.keys(null!==(n=s.products)&&void 0!==n?n:{}).length}return d},exports.shouldShowVariant=o=>{const t=Object.keys(o.variants||[]);let l=!1;return!(t.length<=1)||(t.forEach((t=>{var i,n;l=null!==(n=null===(i=o.variants)||void 0===i?void 0:i[t].name.includes(o.name))&&void 0!==n&&n})),!l)};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as s,useRef as i,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as f}from"./ProductPickerShimmer.js";import{CollectionIdContext as y}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as I,isCollectionPartiallyChecked as D,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const S=S=>{const{data:w,collectionsDispatch:T,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:H,outOfStockAction:K=C.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G}=S,Q=s(y),X=i(null),Y=i(0),[Z,$]=l(!1),[tt,et]=l(""),[ot,ct]=l(!1),[rt,nt]=l(w),st=i(!1);d((()=>{const t=setTimeout((()=>{tt.length?(ct(!0),S.searchInCollectionFetcher(B,Q,tt).then((t=>{const e=n(w);e.products=t,nt(e);const o=P(null!=t?t:{});lt(o,null!=t?t:{},!0),J(!1),ct(!1)}))):nt(w)}),800);return()=>clearTimeout(t)}),[tt]),d((()=>{var t,e,o,c;st.current=!1,Y.current=Math.floor((null===(e=Object.keys(null!==(t=w.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=w.products)&&void 0!==o?o:{});lt(r,null!==(c=w.products)&&void 0!==c?c:{})}),[Q]);const it=!!z&&w.isSmartCollection;d((()=>{(null==w?void 0:w.products)||dt(10)}),[]);const lt=(t,e,o)=>{_||(o?I(e,T,Q,rt,nt):I(e,T,Q)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,s;const i=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];i&&"REJECTED"===t[r]?i.fbStatus="REJECTED":i&&"APPROVED"===t[r]&&(i.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[r]&&(l[r]=i)}))})),o?(nt((t=>{const e=Object.assign({},t);return e.products=c,e})),T({type:"productsPaged",data:{collectionId:Q,products:c}})):T({type:"productsPaged",data:{collectionId:Q,products:c}})})).catch((t=>{o?I(e,T,Q,rt,nt):I(e,T,Q)}))};d((()=>{const t=new IntersectionObserver((t=>{t[0].isIntersecting&&Y.current>=0&&!st.current&&!tt&&(J(!0),$(!0),A(Q,B,10,Y.current).then((t=>{if(Object.keys(t).length||(st.current=!0),Object.keys(t).length){const e=rt;e.products=Object.assign(Object.assign({},rt.products),t),nt(e);const o=P(t);lt(o,t),Y.current+=1}$(!1),J(!1)})).catch())}),{threshold:1});return X.current&&t.observe(X.current),()=>{X.current&&t.unobserve(X.current)}}),[X,tt]);const dt=t=>{J(!0),ct(!0),A(Q,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){nt(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);lt(t,e),Y.current=1}t||V({type:"selected",data:{id:Q,val:Object.assign(Object.assign({},w),{products:e})}}),J(!1),ct(!1)})).catch()},at=(t,e)=>{const o=E(e,w);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})};return t("div",{children:[t(O,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:w.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ot&&tt.length?e(m,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:tt,onChangeText:t=>{t.length&&t.trim().length?et(t):et("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!it&&!tt.length&&!H&&"-1"!==Q&&t(k,{children:[e(u,{isChecked:!!(null==R?void 0:R[Q]),isPartiallyChecked:D(Q,rt,R,U),onValueChange:function(t){t?dt():V({type:"unselected",data:{id:Q}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(b,{outOfStockAction:K,collectionId:Q,isProductPartiallyChecked:x(Q,t,R,rt),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!it,upliftAdditions:at,hideProductCheckbox:H,hideVariantCheckbox:L,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ot?e(f,{limit:10}):e(v,{title:"No products to show",subtitle:tt.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:X})]}),Z&&e(f,{})]})};export{S as ProductsScreen};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as s,useRef as i,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as f}from"./ProductPickerShimmer.js";import{CollectionIdContext as y}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as I,isCollectionPartiallyChecked as D,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const S=S=>{const{data:w,collectionsDispatch:T,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:H,outOfStockAction:K=C.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G}=S,Q=s(y),X=i(null),Y=i(0),[Z,$]=l(!1),[tt,et]=l(""),[ot,ct]=l(!1),[rt,nt]=l(w),st=i(!1);d((()=>{const t=setTimeout((()=>{tt.length?(ct(!0),S.searchInCollectionFetcher(B,Q,tt).then((t=>{const e=n(w);e.products=t,nt(e);const o=P(null!=t?t:{});lt(o,null!=t?t:{},!0),J(!1),ct(!1)}))):nt(w)}),800);return()=>clearTimeout(t)}),[tt]),d((()=>{var t,e,o,c;st.current=!1,Y.current=Math.floor((null===(e=Object.keys(null!==(t=w.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=w.products)&&void 0!==o?o:{});lt(r,null!==(c=w.products)&&void 0!==c?c:{})}),[Q]);const it=!!z&&w.isSmartCollection;d((()=>{(null==w?void 0:w.products)||dt(10)}),[]);const lt=(t,e,o)=>{_||(o?I(e,T,Q,rt,nt):I(e,T,Q)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,s;const i=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];i&&"REJECTED"===t[r]?i.fbStatus="REJECTED":i&&"APPROVED"===t[r]&&(i.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[r]&&(l[r]=i)}))})),o?(nt((t=>{const e=Object.assign({},t);return e.products=c,e})),T({type:"productsPaged",data:{collectionId:Q,products:c}})):T({type:"productsPaged",data:{collectionId:Q,products:c}})})).catch((t=>{o?I(e,T,Q,rt,nt):I(e,T,Q)}))};d((()=>{const t=new IntersectionObserver((t=>{t[0].isIntersecting&&Y.current>=0&&!st.current&&!tt&&(J(!0),$(!0),A(Q,B,10,Y.current).then((t=>{if(Object.keys(t).length||(st.current=!0),Object.keys(t).length){const e=rt;e.products=Object.assign(Object.assign({},rt.products),t),nt(e);const o=P(t);lt(o,t),Y.current+=1}$(!1),J(!1)})).catch())}),{threshold:1});return X.current&&t.observe(X.current),()=>{X.current&&t.unobserve(X.current)}}),[X,tt]);const dt=t=>{J(!0),ct(!0),A(Q,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){nt(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);lt(t,e),Y.current=1}t||V({type:"selected",data:{id:Q,val:Object.assign(Object.assign({},w),{products:e})}}),J(!1),ct(!1)})).catch()},at=(t,e)=>{const o=E(e,w);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})};return t("div",{children:[t(O,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:w.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ot&&tt.length?e(m,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:tt,onChangeText:t=>{t.length&&t.trim().length?et(t):et("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!it&&!tt.length&&!H&&"-1"!==Q&&t(k,{children:[e(u,{isChecked:!!(null==R?void 0:R[Q]),isPartiallyChecked:D(Q,rt,R,U),onValueChange:function(t){t?dt():V({type:"unselected",data:{id:Q}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(b,{outOfStockAction:K,collectionId:Q,isProductPartiallyChecked:x(Q,t,R,rt,U),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!it,upliftAdditions:at,hideProductCheckbox:H,hideVariantCheckbox:L,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ot?e(f,{limit:10}):e(v,{title:"No products to show",subtitle:tt.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:X})]}),Z&&e(f,{})]})};export{S as ProductsScreen};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:j,selectedCollectionsDispatch:f,setScreen:P,collections:S,onBackPress:I,hideVariantCheckbox:O,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:T,fbStatusFetcher:V,setCollectionId:w,setSelectedCollectionId:R,hideCollectionCheckbox:W,renderWithoutModal:B}=m;i((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},T,j,V,"setProducts")}),[null==b?void 0:b.products]);const M=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:l,onClick:()=>{P("collections"),I()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==S?void 0:S[o],isDisabled:M&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==S?void 0:S[o],y,x),selectedCollectionsDispatch:f,setCollectionId:w,setSelectedCollectionId:R,setScreen:P,id:o,hideCollectionCheckbox:W||"-1"===o,selectedCollections:y,renderWithoutModal:B,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var l;const i=v(t,null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o]);f({type:e,data:Object.assign(Object.assign({},i),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o]),selectedData:y,selectedCollectionsDispatch:f,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:O,hideProductVariants:x,pickerType:g},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
1
+ import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:j,selectedCollectionsDispatch:f,setScreen:P,collections:S,onBackPress:I,hideVariantCheckbox:O,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:T,fbStatusFetcher:V,setCollectionId:w,setSelectedCollectionId:R,hideCollectionCheckbox:W,renderWithoutModal:B}=m;i((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},T,j,V,"setProducts")}),[null==b?void 0:b.products]);const M=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:l,onClick:()=>{P("collections"),I()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==S?void 0:S[o],isDisabled:M&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==S?void 0:S[o],y,x),selectedCollectionsDispatch:f,setCollectionId:w,setSelectedCollectionId:R,setScreen:P,id:o,hideCollectionCheckbox:W||"-1"===o,selectedCollections:y,renderWithoutModal:B,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var l;const i=v(t,null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o]);f({type:e,data:Object.assign(Object.assign({},i),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o],x),selectedData:y,selectedCollectionsDispatch:f,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:O,hideProductVariants:x,pickerType:g},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as s,useEffect as l}from"react";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as n}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{AllProductHelper as u}from"./helpers/AllProductHelper.js";import{ProductGroup as a}from"./product.js";import{paginationReducer as p}from"./reducers.js";import{SelectedScreenHeader as m}from"./style.js";import{paginateSelectedItems as f,fetchFbStatusCollection as h,isProductPartiallyChecked as v}from"./utility.js";const j=j=>{const{selectedCollections:y,selectedCollectionsDispatch:b,setScreen:S,collections:g,hideProductVariants:O=!1,outOfStockAction:P,storeId:k,fbStatusFetcher:C}=j,I=c(0),A=c(null),[D,w]=s(p,{});l((()=>{I.current=0;const t=f(y,10,0);w({type:"paginate",data:t}),h(t,k,w,C,"set"),I.current+=1}),[]),l((()=>{w({type:"filter",data:y})}),[y]),l((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&I.current>0){const t=f(y,10,I.current);w({type:"paginate",data:t}),h(t,k,w,C,"update"),I.current+=1}}),{threshold:1});return A.current&&t.observe(A.current),()=>{A.current&&t.unobserve(A.current)}}),[A,y]);const x=O?u.removeDuplicatesForAllProducts(Object.assign({},y)):y;return console.log({curScreenData:D,selectedCollections:y}),t("div",{children:[t(m,{children:[e(i,{Icon:o,onClick:()=>{S("collections")}}),e(n,{children:"Selected Products"})]}),t("div",{children:[Object.keys(D).length>0?e(r,{children:Object.keys(D).map((t=>{var r;return Object.keys((null===(r=null==D?void 0:D[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==x?void 0:x.isCustom)&&(o=!0),e(a,{upliftAdditions:null,collectionId:t,productId:r,data:D[t].products[r],isProductPartiallyChecked:v(t,r,x,null==g?void 0:g[t]),selectedData:x,selectedCollectionsDispatch:b,viewOnly:o,hideProductVariants:O,outOfStockAction:P},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:A})]})]})};export{j as SelectedScreen};
1
+ import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as s,useEffect as l}from"react";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as n}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{AllProductHelper as u}from"./helpers/AllProductHelper.js";import{ProductGroup as a}from"./product.js";import{paginationReducer as p}from"./reducers.js";import{SelectedScreenHeader as m}from"./style.js";import{paginateSelectedItems as f,fetchFbStatusCollection as h,isProductPartiallyChecked as v}from"./utility.js";const j=j=>{const{selectedCollections:y,selectedCollectionsDispatch:b,setScreen:S,collections:g,hideProductVariants:O=!1,outOfStockAction:P,storeId:k,fbStatusFetcher:C}=j,I=c(0),A=c(null),[D,w]=s(p,{});l((()=>{I.current=0;const t=f(y,10,0);w({type:"paginate",data:t}),h(t,k,w,C,"set"),I.current+=1}),[]),l((()=>{w({type:"filter",data:y})}),[y]),l((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&I.current>0){const t=f(y,10,I.current);w({type:"paginate",data:t}),h(t,k,w,C,"update"),I.current+=1}}),{threshold:1});return A.current&&t.observe(A.current),()=>{A.current&&t.unobserve(A.current)}}),[A,y]);const x=O?u.removeDuplicatesForAllProducts(Object.assign({},y)):y;return console.log({curScreenData:D,selectedCollections:y}),t("div",{children:[t(m,{children:[e(i,{Icon:o,onClick:()=>{S("collections")}}),e(n,{children:"Selected Products"})]}),t("div",{children:[Object.keys(D).length>0?e(r,{children:Object.keys(D).map((t=>{var r;return Object.keys((null===(r=null==D?void 0:D[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==x?void 0:x.isCustom)&&(o=!0),e(a,{upliftAdditions:null,collectionId:t,productId:r,data:D[t].products[r],isProductPartiallyChecked:v(t,r,x,null==g?void 0:g[t],O),selectedData:x,selectedCollectionsDispatch:b,viewOnly:o,hideProductVariants:O,outOfStockAction:P},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:A})]})]})};export{j as SelectedScreen};
@@ -34,5 +34,5 @@ export declare const markVariantsAsApprovedProductsLevel: (products: {
34
34
  * Other cases returns true.
35
35
  */
36
36
  export declare const shouldShowVariant: (data: Product) => boolean;
37
- export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection) => boolean;
37
+ export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection, hideProductVariants?: boolean) => boolean;
38
38
  export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems, hideProductVariants?: boolean) => boolean;
@@ -1 +1 @@
1
- import{cloneDeep as o}from"lodash";const l=(l,n)=>{const i=o(n);if(delete i.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:i})).productId&&n.products){const t=o(n.products[l.productId]);(null==t?void 0:t.variants)&&delete t.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:i,productOnlyData:t})}return l};function n(o,l,n){var t;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const u=o[s],c=i(u.products,l,n-v);c&&Object.keys(c).length>0&&(d[s]=Object.assign(Object.assign({},u),{products:c})),v+=Object.keys(null!==(t=u.products)&&void 0!==t?t:{}).length}return d}function i(o,l,n){if(!o)return{};const i=Object.keys(o).slice(n,n+l),t={};return i.forEach((l=>{t[l]=o[l]})),t}const t=(o,l,n)=>{Object.keys(o).forEach((l=>{var n,i;const t=null!==(i=null===(n=o[l])||void 0===n?void 0:n.products)&&void 0!==i?i:{};Object.keys(t).forEach((n=>{var i,t,d,v;const s=null!==(v=null===(d=null===(t=null===(i=o[l])||void 0===i?void 0:i.products)||void 0===t?void 0:t[n])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((i=>{var t,d,v,s;const u=null===(s=null===(v=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[i];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),l({type:n,data:o})},d=function(o,l,n,i){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";i||t(o,n,d);const v=(o=>{const l=[];return Object.keys(o).forEach((n=>{var i,t;const d=null!==(t=null===(i=o[n])||void 0===i?void 0:i.products)&&void 0!==t?t:{};Object.keys(d).forEach((i=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=o[n])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=o[n])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];(null==c?void 0:c.fbStatus)||l.push(t)}))}))})),l})(o);v.length>0&&i&&i(l,v).then((l=>{const i=Object.assign({},o);Object.keys(i).forEach((o=>{var n,t;const d=null!==(t=null===(n=i[o])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=i[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=i[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];c&&"REJECTED"===l[t]?c.fbStatus="REJECTED":c&&"APPROVED"===l[t]&&(c.fbStatus="APPROVED")}))}))})),n({type:d,data:i})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,n,d)}))},v=(o,l)=>{const n=[];return Object.keys(null!=o?o:{}).forEach((i=>{var t,d;const v=null!==(d=null===(t=null==o?void 0:o[i])||void 0===t?void 0:t.variants)&&void 0!==d?d:{};Object.keys(v).forEach((t=>{var d,v,s,u,c;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[t]:null===(c=null===(u=null==o?void 0:o[i])||void 0===u?void 0:u.variants)||void 0===c?void 0:c[t],(null==r?void 0:r.fbStatus)||n.push(t)}))})),n},s=(o,l,n,i,t)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var n,i;Object.keys(null!==(i=null===(n=null==o?void 0:o[l])||void 0===n?void 0:n.variants)&&void 0!==i?i:{}).forEach((n=>{var i,t;const v=null===(i=null==o?void 0:o[l].variants)||void 0===i?void 0:i[n];v&&(v.fbStatus="APPROVED");const s=null===(t=null==d?void 0:d[l])||void 0===t?void 0:t.variants;s&&s[n]&&(s[n]=v)}))})),i&&t){const o=Object.assign({},i);o.products=d,t(o),l({type:"productsPaged",data:{collectionId:n,products:d}})}else l({type:"productsPaged",data:{collectionId:n,products:d}})},u=o=>{const l=Object.keys(o.variants||[]);let n=!1;return!(l.length<=1)||(l.forEach((l=>{var i,t;n=null!==(t=null===(i=o.variants)||void 0===i?void 0:i[l].name.includes(o.name))&&void 0!==t&&t})),!n)},c=(o,l,n,i)=>{var t,d,v,s,u,c,r,a,e,f,p,b,O,h,j,y,E,k,g;let P=0,D=0;if(null===(d=null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[l]){const t=(null===(u=null===(s=null===(v=null==n?void 0:n[o])||void 0===v?void 0:v.products)||void 0===s?void 0:s[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(t).length)for(const i in t){const t=null===(r=null===(c=null==n?void 0:n[o])||void 0===c?void 0:c.products)||void 0===r?void 0:r[l],d=null===(p=null===(f=null===(e=null===(a=null==n?void 0:n[o])||void 0===a?void 0:a.products)||void 0===e?void 0:e[l])||void 0===f?void 0:f.variants)||void 0===p?void 0:p[i];if(null===(b=null==d?void 0:d.name)||void 0===b?void 0:b.includes(null!==(O=null==t?void 0:t.name)&&void 0!==O?O:""))return!1}if(null===(y=Object.keys((null===(j=null===(h=null==i?void 0:i.products)||void 0===h?void 0:h[l])||void 0===j?void 0:j.variants)||[]))||void 0===y||y.forEach((()=>D++)),Object.keys((null===(g=null===(k=null===(E=null==n?void 0:n[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===g?void 0:g.variants)||[]).forEach((()=>P++)),P>0&&D!==P)return!0}return!1},r=function(o,l,n){var i,t,d,v;let s=0,u=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(i=null==l?void 0:l.products)&&void 0!==i?i:{};s=Object.keys(v).length;const c=null!==(d=null===(t=n[o])||void 0===t?void 0:t.products)&&void 0!==d?d:{};u=Object.keys(c).length}else if(n[o]){const i=null==l?void 0:l.products;i&&Object.keys(i).forEach((o=>{var l;const n=null===(l=i[o])||void 0===l?void 0:l.variants;n&&Object.keys(n).forEach((o=>s+=1))}));const t=null===(v=n[o])||void 0===v?void 0:v.products;if(t&&Object.keys(t).forEach((o=>{var l;const n=null===(l=t[o])||void 0===l?void 0:l.variants;n&&Object.keys(n).forEach((o=>u+=1))})),s<=0&&u>0)return!1}return u>0&&s!==u};export{d as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,n as paginateSelectedItems,u as shouldShowVariant};
1
+ import{cloneDeep as o}from"lodash";const l=(l,t)=>{const n=o(t);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&t.products){const i=o(t.products[l.productId]);(null==i?void 0:i.variants)&&delete i.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:i})}return l};function t(o,l,t){var i;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const u=o[s],c=n(u.products,l,t-v);c&&Object.keys(c).length>0&&(d[s]=Object.assign(Object.assign({},u),{products:c})),v+=Object.keys(null!==(i=u.products)&&void 0!==i?i:{}).length}return d}function n(o,l,t){if(!o)return{};const n=Object.keys(o).slice(t,t+l),i={};return n.forEach((l=>{i[l]=o[l]})),i}const i=(o,l,t)=>{Object.keys(o).forEach((l=>{var t,n;const i=null!==(n=null===(t=o[l])||void 0===t?void 0:t.products)&&void 0!==n?n:{};Object.keys(i).forEach((t=>{var n,i,d,v;const s=null!==(v=null===(d=null===(i=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((n=>{var i,d,v,s;const u=null===(s=null===(v=null===(d=null===(i=o[l])||void 0===i?void 0:i.products)||void 0===d?void 0:d[t])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),l({type:t,data:o})},d=function(o,l,t,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||i(o,t,d);const v=(o=>{const l=[];return Object.keys(o).forEach((t=>{var n,i;const d=null!==(i=null===(n=o[t])||void 0===n?void 0:n.products)&&void 0!==i?i:{};Object.keys(d).forEach((n=>{var i,d,v,s;const u=null!==(s=null===(v=null===(d=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((i=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=o[t])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[i];(null==c?void 0:c.fbStatus)||l.push(i)}))}))})),l})(o);v.length>0&&n&&n(l,v).then((l=>{const n=Object.assign({},o);Object.keys(n).forEach((o=>{var t,i;const d=null!==(i=null===(t=n[o])||void 0===t?void 0:t.products)&&void 0!==i?i:{};Object.keys(d).forEach((t=>{var i,d,v,s;const u=null!==(s=null===(v=null===(d=null===(i=n[o])||void 0===i?void 0:i.products)||void 0===d?void 0:d[t])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((i=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=n[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[t])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[i];c&&"REJECTED"===l[i]?c.fbStatus="REJECTED":c&&"APPROVED"===l[i]&&(c.fbStatus="APPROVED")}))}))})),t({type:d,data:n})})).catch((l=>{console.error("Error in fbStatusFetcher",l),i(o,t,d)}))},v=(o,l)=>{const t=[];return Object.keys(null!=o?o:{}).forEach((n=>{var i,d;const v=null!==(d=null===(i=null==o?void 0:o[n])||void 0===i?void 0:i.variants)&&void 0!==d?d:{};Object.keys(v).forEach((i=>{var d,v,s,u,c;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[i]:null===(c=null===(u=null==o?void 0:o[n])||void 0===u?void 0:u.variants)||void 0===c?void 0:c[i],(null==r?void 0:r.fbStatus)||t.push(i)}))})),t},s=(o,l,t,n,i)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var t,n;Object.keys(null!==(n=null===(t=null==o?void 0:o[l])||void 0===t?void 0:t.variants)&&void 0!==n?n:{}).forEach((t=>{var n,i;const v=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[t];v&&(v.fbStatus="APPROVED");const s=null===(i=null==d?void 0:d[l])||void 0===i?void 0:i.variants;s&&s[t]&&(s[t]=v)}))})),n&&i){const o=Object.assign({},n);o.products=d,i(o),l({type:"productsPaged",data:{collectionId:t,products:d}})}else l({type:"productsPaged",data:{collectionId:t,products:d}})},u=o=>{const l=Object.keys(o.variants||[]);let t=!1;return!(l.length<=1)||(l.forEach((l=>{var n,i;t=null!==(i=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==i&&i})),!t)},c=(o,l,t,n,i)=>{var d,v,s,u,c,r,a,e,f,p,b,O,h,j,y,E,k,g,P;let D=0,S=0;if(console.log({collectionId:o,productId:l,selectedData:t,currentCollection:n,hideProductVariants:i}),null===(v=null===(d=null==t?void 0:t[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[l]){if(console.log({hideProductVariants:i}),i)return!0;const d=(null===(c=null===(u=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[l])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(d).length)for(const n in d){const i=null===(a=null===(r=null==t?void 0:t[o])||void 0===r?void 0:r.products)||void 0===a?void 0:a[l],d=null===(b=null===(p=null===(f=null===(e=null==t?void 0:t[o])||void 0===e?void 0:e.products)||void 0===f?void 0:f[l])||void 0===p?void 0:p.variants)||void 0===b?void 0:b[n];if(null===(O=null==d?void 0:d.name)||void 0===O?void 0:O.includes(null!==(h=null==i?void 0:i.name)&&void 0!==h?h:""))return!1}if(null===(E=Object.keys((null===(y=null===(j=null==n?void 0:n.products)||void 0===j?void 0:j[l])||void 0===y?void 0:y.variants)||[]))||void 0===E||E.forEach((()=>S++)),Object.keys((null===(P=null===(g=null===(k=null==t?void 0:t[o])||void 0===k?void 0:k.products)||void 0===g?void 0:g[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},r=function(o,l,t){var n,i,d,v;let s=0,u=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(n=null==l?void 0:l.products)&&void 0!==n?n:{};s=Object.keys(v).length;const c=null!==(d=null===(i=t[o])||void 0===i?void 0:i.products)&&void 0!==d?d:{};u=Object.keys(c).length}else if(t[o]){const n=null==l?void 0:l.products;n&&Object.keys(n).forEach((o=>{var l;const t=null===(l=n[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>s+=1))}));const i=null===(v=t[o])||void 0===v?void 0:v.products;if(i&&Object.keys(i).forEach((o=>{var l;const t=null===(l=i[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>u+=1))})),s<=0&&u>0)return!1}return u>0&&s!==u};export{d as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,t as paginateSelectedItems,u as shouldShowVariant};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.461-1",
3
+ "version": "0.0.461-3",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",