@bikdotai/bik-component-library 0.0.469-beta.pp-4 → 0.0.469-beta.pp-5

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 e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),c=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),r=require("lodash"),s=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),d=require("../input/Input.js"),u=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),v=require("./ProductPickerShimmer.js"),j=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=C=>{const{data:f,collectionsDispatch:k,selectedData:x,selectedCollectionsDispatch:O,productFetcher:b,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:E,customCollectionRestriction:q,hideProductCheckbox:A,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:F,onProductDetailClick:w,showProductDetailInfoIcon:B,scrollContainerRef:_}=C,H=s.useContext(j.CollectionIdContext),U=s.useRef(null),J=s.useRef(0),[K,M]=s.useState(!1),[N,W]=s.useState(""),[z,G]=s.useState(!1),[Q,X]=s.useState(f),Y=s.useRef(!1);s.useEffect((()=>{const e=setTimeout((()=>{N.length?(G(!0),C.searchInCollectionFetcher(S,H,N).then((e=>{const t=r.cloneDeep(f);t.products=e,X(t);const c=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});ee(c,null!=e?e:{},!0),I(!1),G(!1)}))):X(f)}),800);return()=>clearTimeout(e)}),[N]),s.useEffect((()=>{var e;return null===(e=null==_?void 0:_.current)||void 0===e||e.addEventListener("scroll",Z),()=>{var e;null===(e=null==_?void 0:_.current)||void 0===e||e.removeEventListener("scroll",Z)}}),[]);const Z=()=>{if(!_||!(null==_?void 0:_.current))return;console.log("handlescroll called");const{scrollTop:e,clientHeight:t,scrollHeight:c}=_.current;e+t>=c-10&&!Y.current&&(console.log("scrolling"),I(!0),M(!0),b(H,S,10,J.current).then((e=>{if(Object.keys(e).length||(Y.current=!0),Object.keys(e).length){const t=Q;t.products=Object.assign(Object.assign({},Q.products),e),X(t);const c=P.getVariantIdsToFetchAtProductLevel(e);ee(c,e),J.current+=1}M(!1),I(!1)})).catch())};s.useEffect((()=>{var e,t,c,o;Y.current=!1,J.current=Math.floor((null===(t=Object.keys(null!==(e=f.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const r=P.getVariantIdsToFetchAtProductLevel(null!==(c=f.products)&&void 0!==c?c:{});ee(r,null!==(o=f.products)&&void 0!==o?o:{})}),[H]);const $=!!q&&f.isSmartCollection;s.useEffect((()=>{(null==f?void 0:f.products)||te(10)}),[]);const ee=(e,t,c)=>{F||(c?P.markVariantsAsApprovedProductsLevel(t,k,H,Q,X):P.markVariantsAsApprovedProductsLevel(t,k,H)),e.length>0&&F&&F(S,e).then((e=>{const o=Object.assign({},t);Object.keys(t).forEach((c=>{var r,s;Object.keys(null!==(s=null===(r=null==t?void 0:t[c])||void 0===r?void 0:r.variants)&&void 0!==s?s:{}).forEach((r=>{var s,n;const i=null===(s=null==t?void 0:t[c].variants)||void 0===s?void 0:s[r];i&&"REJECTED"===e[r]?i.fbStatus="REJECTED":i&&"APPROVED"===e[r]&&(i.fbStatus="APPROVED");const l=null===(n=null==o?void 0:o[c])||void 0===n?void 0:n.variants;l&&l[r]&&(l[r]=i)}))})),c?(X((e=>{const t=Object.assign({},e);return t.products=o,t})),k({type:"productsPaged",data:{collectionId:H,products:o}})):k({type:"productsPaged",data:{collectionId:H,products:o}})})).catch((e=>{c?P.markVariantsAsApprovedProductsLevel(t,k,H,Q,X):P.markVariantsAsApprovedProductsLevel(t,k,H)}))},te=e=>{I(!0),G(!0),b(H,S,e,0).then((t=>{if(Object.keys(t).length||(Y.current=!0),Object.keys(t).length){X(Object.assign(Object.assign({},Q),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);ee(e,t),J.current=1}e||O({type:"selected",data:{id:H,val:Object.assign(Object.assign({},f),{products:t})}}),I(!1),G(!1)})).catch()},ce=(e,t)=>{const c=P.liftTheStateUp(t,f);O({type:e,data:Object.assign(Object.assign({},c),{isRestricted:q})})};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:f.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>z&&N.length?e.jsx(u.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:N,onChangeText:e=>{e.length&&e.trim().length?W(e):W("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==Q?void 0:Q.products)||[]).length>0&&!$&&!N.length&&!A&&"-1"!==H&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==x?void 0:x[H]),isPartiallyChecked:P.isCollectionPartiallyChecked(H,Q,x,L),onValueChange:function(e){e?te():O({type:"unselected",data:{id:H}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(c.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==Q?void 0:Q.products)||[]).length?Object.keys(Q.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:H,isProductPartiallyChecked:P.isProductPartiallyChecked(H,t,x,Q,L),productId:t,data:Q.products[t],selectedData:x,selectedCollectionsDispatch:O,viewOnly:!V&&!!$,upliftAdditions:ce,hideProductCheckbox:A,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:w,showProductDetailInfoIcon:B},t))):z?e.jsx(v.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:N.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})]}),K&&e.jsx(v.ProductPickerShimmer,{})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),c=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),r=require("lodash"),s=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),d=require("../input/Input.js"),u=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),v=require("./ProductPickerShimmer.js"),j=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=C=>{const{data:f,collectionsDispatch:k,selectedData:x,selectedCollectionsDispatch:O,productFetcher:b,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:E,customCollectionRestriction:q,hideProductCheckbox:A,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:F,onProductDetailClick:w,showProductDetailInfoIcon:B,scrollContainerRef:_}=C,H=s.useContext(j.CollectionIdContext),U=s.useRef(null),J=s.useRef(0),[K,M]=s.useState(!1),[N,W]=s.useState(""),[z,G]=s.useState(!1),[Q,X]=s.useState(f),Y=s.useRef(!1);s.useEffect((()=>{const e=setTimeout((()=>{N.length?(G(!0),C.searchInCollectionFetcher(S,H,N).then((e=>{const t=r.cloneDeep(f);t.products=e,X(t);const c=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});ee(c,null!=e?e:{},!0),I(!1),G(!1)}))):X(f)}),800);return()=>clearTimeout(e)}),[N]),s.useEffect((()=>{var e;return null===(e=null==_?void 0:_.current)||void 0===e||e.addEventListener("scroll",Z),()=>{var e;null===(e=null==_?void 0:_.current)||void 0===e||e.removeEventListener("scroll",Z)}}),[]);const Z=()=>{if(!_||!(null==_?void 0:_.current))return;console.log("handlescroll called");const{scrollTop:e,clientHeight:t,scrollHeight:c}=_.current;e+t>=c-10&&!Y.current&&!K&&(console.log("scrolling"),I(!0),M(!0),b(H,S,10,J.current).then((e=>{if(Object.keys(e).length||(Y.current=!0),Object.keys(e).length){const t=Q;t.products=Object.assign(Object.assign({},Q.products),e),X(t);const c=P.getVariantIdsToFetchAtProductLevel(e);ee(c,e),J.current+=1}M(!1),I(!1)})).catch())};s.useEffect((()=>{var e,t,c,o;Y.current=!1,J.current=Math.floor((null===(t=Object.keys(null!==(e=f.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const r=P.getVariantIdsToFetchAtProductLevel(null!==(c=f.products)&&void 0!==c?c:{});ee(r,null!==(o=f.products)&&void 0!==o?o:{})}),[H]);const $=!!q&&f.isSmartCollection;s.useEffect((()=>{(null==f?void 0:f.products)||te(10)}),[]);const ee=(e,t,c)=>{F||(c?P.markVariantsAsApprovedProductsLevel(t,k,H,Q,X):P.markVariantsAsApprovedProductsLevel(t,k,H)),e.length>0&&F&&F(S,e).then((e=>{const o=Object.assign({},t);Object.keys(t).forEach((c=>{var r,s;Object.keys(null!==(s=null===(r=null==t?void 0:t[c])||void 0===r?void 0:r.variants)&&void 0!==s?s:{}).forEach((r=>{var s,n;const i=null===(s=null==t?void 0:t[c].variants)||void 0===s?void 0:s[r];i&&"REJECTED"===e[r]?i.fbStatus="REJECTED":i&&"APPROVED"===e[r]&&(i.fbStatus="APPROVED");const l=null===(n=null==o?void 0:o[c])||void 0===n?void 0:n.variants;l&&l[r]&&(l[r]=i)}))})),c?(X((e=>{const t=Object.assign({},e);return t.products=o,t})),k({type:"productsPaged",data:{collectionId:H,products:o}})):k({type:"productsPaged",data:{collectionId:H,products:o}})})).catch((e=>{c?P.markVariantsAsApprovedProductsLevel(t,k,H,Q,X):P.markVariantsAsApprovedProductsLevel(t,k,H)}))},te=e=>{I(!0),G(!0),b(H,S,e,0).then((t=>{if(Object.keys(t).length||(Y.current=!0),Object.keys(t).length){X(Object.assign(Object.assign({},Q),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);ee(e,t),J.current=1}e||O({type:"selected",data:{id:H,val:Object.assign(Object.assign({},f),{products:t})}}),I(!1),G(!1)})).catch()},ce=(e,t)=>{const c=P.liftTheStateUp(t,f);O({type:e,data:Object.assign(Object.assign({},c),{isRestricted:q})})};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:f.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>z&&N.length?e.jsx(u.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:N,onChangeText:e=>{e.length&&e.trim().length?W(e):W("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==Q?void 0:Q.products)||[]).length>0&&!$&&!N.length&&!A&&"-1"!==H&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==x?void 0:x[H]),isPartiallyChecked:P.isCollectionPartiallyChecked(H,Q,x,L),onValueChange:function(e){e?te():O({type:"unselected",data:{id:H}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(c.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==Q?void 0:Q.products)||[]).length?Object.keys(Q.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:H,isProductPartiallyChecked:P.isProductPartiallyChecked(H,t,x,Q,L),productId:t,data:Q.products[t],selectedData:x,selectedCollectionsDispatch:O,viewOnly:!V&&!!$,upliftAdditions:ce,hideProductCheckbox:A,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:w,showProductDetailInfoIcon:B},t))):z?e.jsx(v.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:N.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})]}),K&&e.jsx(v.ProductPickerShimmer,{})]})};
@@ -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 n from"../../assets/icons/search.svg.js";import{cloneDeep as r}from"lodash";import{useContext as i,useRef as s,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 v}from"../TypographyStyle.js";import{EmptyState as f}from"./emptyState.js";import{ProductGroup as j}from"./product.js";import{ProductPickerShimmer as y}from"./ProductPickerShimmer.js";import{CollectionIdContext as b}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as O}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as E,isCollectionPartiallyChecked as I,isProductPartiallyChecked as D,liftTheStateUp as x}from"./utility.js";const S=S=>{const{data:T,collectionsDispatch:w,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:H,hideInCollectionSearch:L,customCollectionRestriction:J,hideProductCheckbox:W,outOfStockAction:z=C.BLUR,hideVariantCheckbox:K=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G,scrollContainerRef:Q}=S,X=i(b),Y=s(null),Z=s(0),[$,tt]=l(!1),[et,ot]=l(""),[ct,nt]=l(!1),[rt,it]=l(T),st=s(!1);d((()=>{const t=setTimeout((()=>{et.length?(nt(!0),S.searchInCollectionFetcher(B,X,et).then((t=>{const e=r(T);e.products=t,it(e);const o=P(null!=t?t:{});at(o,null!=t?t:{},!0),H(!1),nt(!1)}))):it(T)}),800);return()=>clearTimeout(t)}),[et]),d((()=>{var t;return null===(t=null==Q?void 0:Q.current)||void 0===t||t.addEventListener("scroll",lt),()=>{var t;null===(t=null==Q?void 0:Q.current)||void 0===t||t.removeEventListener("scroll",lt)}}),[]);const lt=()=>{if(!Q||!(null==Q?void 0:Q.current))return;console.log("handlescroll called");const{scrollTop:t,clientHeight:e,scrollHeight:o}=Q.current;t+e>=o-10&&!st.current&&(console.log("scrolling"),H(!0),tt(!0),A(X,B,10,Z.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),it(e);const o=P(t);at(o,t),Z.current+=1}tt(!1),H(!1)})).catch())};d((()=>{var t,e,o,c;st.current=!1,Z.current=Math.floor((null===(e=Object.keys(null!==(t=T.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const n=P(null!==(o=T.products)&&void 0!==o?o:{});at(n,null!==(c=T.products)&&void 0!==c?c:{})}),[X]);const dt=!!J&&T.isSmartCollection;d((()=>{(null==T?void 0:T.products)||ut(10)}),[]);const at=(t,e,o)=>{_||(o?E(e,w,X,rt,it):E(e,w,X)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var n,r;Object.keys(null!==(r=null===(n=null==e?void 0:e[o])||void 0===n?void 0:n.variants)&&void 0!==r?r:{}).forEach((n=>{var r,i;const s=null===(r=null==e?void 0:e[o].variants)||void 0===r?void 0:r[n];s&&"REJECTED"===t[n]?s.fbStatus="REJECTED":s&&"APPROVED"===t[n]&&(s.fbStatus="APPROVED");const l=null===(i=null==c?void 0:c[o])||void 0===i?void 0:i.variants;l&&l[n]&&(l[n]=s)}))})),o?(it((t=>{const e=Object.assign({},t);return e.products=c,e})),w({type:"productsPaged",data:{collectionId:X,products:c}})):w({type:"productsPaged",data:{collectionId:X,products:c}})})).catch((t=>{o?E(e,w,X,rt,it):E(e,w,X)}))},ut=t=>{H(!0),nt(!0),A(X,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){it(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);at(t,e),Z.current=1}t||V({type:"selected",data:{id:X,val:Object.assign(Object.assign({},T),{products:e})}}),H(!1),nt(!1)})).catch()},ht=(t,e)=>{const o=x(e,T);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:J})})};return t("div",{children:[t(k,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:T.name}))]}),!L&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ct&&et.length?e(m,{size:"small",color:a.content.primary}):e(n,{})},id:"listInput",height:"24px",type:"text",value:et,onChangeText:t=>{t.length&&t.trim().length?ot(t):ot("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!dt&&!et.length&&!W&&"-1"!==X&&t(O,{children:[e(u,{isChecked:!!(null==R?void 0:R[X]),isPartiallyChecked:I(X,rt,R,U),onValueChange:function(t){t?ut():V({type:"unselected",data:{id:X}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(v,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(j,{outOfStockAction:z,collectionId:X,isProductPartiallyChecked:D(X,t,R,rt,U),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!dt,upliftAdditions:ht,hideProductCheckbox:W,hideVariantCheckbox:K,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ct?e(y,{limit:10}):e(f,{title:"No products to show",subtitle:et.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:Y})]}),$&&e(y,{})]})};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 n from"../../assets/icons/search.svg.js";import{cloneDeep as r}from"lodash";import{useContext as i,useRef as s,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 v}from"../TypographyStyle.js";import{EmptyState as f}from"./emptyState.js";import{ProductGroup as j}from"./product.js";import{ProductPickerShimmer as y}from"./ProductPickerShimmer.js";import{CollectionIdContext as b}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as O}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as E,isCollectionPartiallyChecked as I,isProductPartiallyChecked as D,liftTheStateUp as x}from"./utility.js";const S=S=>{const{data:T,collectionsDispatch:w,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:H,hideInCollectionSearch:L,customCollectionRestriction:J,hideProductCheckbox:W,outOfStockAction:z=C.BLUR,hideVariantCheckbox:K=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G,scrollContainerRef:Q}=S,X=i(b),Y=s(null),Z=s(0),[$,tt]=l(!1),[et,ot]=l(""),[ct,nt]=l(!1),[rt,it]=l(T),st=s(!1);d((()=>{const t=setTimeout((()=>{et.length?(nt(!0),S.searchInCollectionFetcher(B,X,et).then((t=>{const e=r(T);e.products=t,it(e);const o=P(null!=t?t:{});at(o,null!=t?t:{},!0),H(!1),nt(!1)}))):it(T)}),800);return()=>clearTimeout(t)}),[et]),d((()=>{var t;return null===(t=null==Q?void 0:Q.current)||void 0===t||t.addEventListener("scroll",lt),()=>{var t;null===(t=null==Q?void 0:Q.current)||void 0===t||t.removeEventListener("scroll",lt)}}),[]);const lt=()=>{if(!Q||!(null==Q?void 0:Q.current))return;console.log("handlescroll called");const{scrollTop:t,clientHeight:e,scrollHeight:o}=Q.current;t+e>=o-10&&!st.current&&!$&&(console.log("scrolling"),H(!0),tt(!0),A(X,B,10,Z.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),it(e);const o=P(t);at(o,t),Z.current+=1}tt(!1),H(!1)})).catch())};d((()=>{var t,e,o,c;st.current=!1,Z.current=Math.floor((null===(e=Object.keys(null!==(t=T.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const n=P(null!==(o=T.products)&&void 0!==o?o:{});at(n,null!==(c=T.products)&&void 0!==c?c:{})}),[X]);const dt=!!J&&T.isSmartCollection;d((()=>{(null==T?void 0:T.products)||ut(10)}),[]);const at=(t,e,o)=>{_||(o?E(e,w,X,rt,it):E(e,w,X)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var n,r;Object.keys(null!==(r=null===(n=null==e?void 0:e[o])||void 0===n?void 0:n.variants)&&void 0!==r?r:{}).forEach((n=>{var r,i;const s=null===(r=null==e?void 0:e[o].variants)||void 0===r?void 0:r[n];s&&"REJECTED"===t[n]?s.fbStatus="REJECTED":s&&"APPROVED"===t[n]&&(s.fbStatus="APPROVED");const l=null===(i=null==c?void 0:c[o])||void 0===i?void 0:i.variants;l&&l[n]&&(l[n]=s)}))})),o?(it((t=>{const e=Object.assign({},t);return e.products=c,e})),w({type:"productsPaged",data:{collectionId:X,products:c}})):w({type:"productsPaged",data:{collectionId:X,products:c}})})).catch((t=>{o?E(e,w,X,rt,it):E(e,w,X)}))},ut=t=>{H(!0),nt(!0),A(X,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){it(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);at(t,e),Z.current=1}t||V({type:"selected",data:{id:X,val:Object.assign(Object.assign({},T),{products:e})}}),H(!1),nt(!1)})).catch()},ht=(t,e)=>{const o=x(e,T);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:J})})};return t("div",{children:[t(k,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:T.name}))]}),!L&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ct&&et.length?e(m,{size:"small",color:a.content.primary}):e(n,{})},id:"listInput",height:"24px",type:"text",value:et,onChangeText:t=>{t.length&&t.trim().length?ot(t):ot("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!dt&&!et.length&&!W&&"-1"!==X&&t(O,{children:[e(u,{isChecked:!!(null==R?void 0:R[X]),isPartiallyChecked:I(X,rt,R,U),onValueChange:function(t){t?ut():V({type:"unselected",data:{id:X}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(v,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(j,{outOfStockAction:z,collectionId:X,isProductPartiallyChecked:D(X,t,R,rt,U),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!dt,upliftAdditions:ht,hideProductCheckbox:W,hideVariantCheckbox:K,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ct?e(y,{limit:10}):e(f,{title:"No products to show",subtitle:et.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:Y})]}),$&&e(y,{})]})};export{S as ProductsScreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.469-beta.pp-4",
3
+ "version": "0.0.469-beta.pp-5",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",