@bikdotai/bik-component-library 0.0.435-0 → 0.0.435-beta.0

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/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),l=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./emptyState.js"),d=require("./style.js");const u=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."},h=i=>{const{customCollectionRestriction:c,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:y,isDisabled:g,hideCollectionCheckbox:v,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:g,onClick:e=>{if(!g){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:c}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!v&&e.jsx(s.CheckBox,{isDisabled:g,isChecked:y,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:c}}:{type:"unselected",data:{id:x}}),p(e?x:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400},{children:e.jsxs(d.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(l.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:g,Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:s,dataLoading:o,collections:l,selectedCollectionsDispatch:r,setCollectionId:n,selectedCollections:d,setScreen:u,collectionFetcher:p,collectionsDispatch:C,pagingControls:j,storeId:x,setSaveDisabled:y,hideCollectionCheckbox:g,renderWithoutModal:v,pickerType:m}=t,b=i.useRef(null),k=i.useRef(j.curPage),f=!!s&&(null==d?void 0:d.isCustom),[O,S]=i.useState(!1);i.useEffect((()=>{k.current=j.curPage}),[j.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&k.current>0&&(y(!0),S(!0),p(k.current,x).then((e=>{C({type:"paged",data:(null==e?void 0:e.collections)||{}}),j.setCurPage(k.current+1),S(!1),y(!1)})).catch())}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b]);const E=e=>{var t,i;let s=0,o=0;if(d[e]){const c=null===(t=l[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const r=null===(i=d[e])||void 0===i?void 0:i.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[Object.keys(l).length?Object.keys(l).map((t=>e.jsx(h,{customCollectionRestriction:s,data:l[t],isDisabled:f&&!(null==d?void 0:d[t]),isChecked:!!(null==d?void 0:d[t]),isPartiallyChecked:E(t),selectedCollectionsDispatch:r,setCollectionId:n,setScreen:u,id:t,hideCollectionCheckbox:g,selectedCollections:d,renderWithoutModal:v,pickerType:m},t))):o?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(a.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:b}),O&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),o=require("../checkBox/CheckBox.js"),s=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),l=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./emptyState.js"),d=require("./style.js");const u=(e,t,i)=>{if(e.length<=t)return e;const o=e.slice(0,t-1);return(i?o.slice(0,o.lastIndexOf(" ")):o)+"..."},h=i=>{const{customCollectionRestriction:c,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:g,isDisabled:y,hideCollectionCheckbox:v,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(console.log("onClickChevron"),!y){if("COLLECTION"===m)return console.log("pickerType == COLLECTION"),e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:c}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!v&&e.jsx(o.CheckBox,{isDisabled:y,isChecked:g,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:c}}:{type:"unselected",data:{id:x}}),p(e?x:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400},{children:e.jsxs(d.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(l.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(s.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:o,dataLoading:s,collections:l,selectedCollectionsDispatch:r,setCollectionId:n,selectedCollections:d,setScreen:u,collectionFetcher:p,collectionsDispatch:C,pagingControls:j,storeId:x,setSaveDisabled:g,hideCollectionCheckbox:y,renderWithoutModal:v,pickerType:m}=t,b=i.useRef(null),k=i.useRef(j.curPage),f=!!o&&(null==d?void 0:d.isCustom),[O,S]=i.useState(!1);i.useEffect((()=>{k.current=j.curPage}),[j.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&k.current>0&&(g(!0),S(!0),p(k.current,x).then((e=>{C({type:"paged",data:(null==e?void 0:e.collections)||{}}),j.setCurPage(k.current+1),S(!1),g(!1)})).catch())}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b]);const E=e=>{var t,i;let o=0,s=0;if(d[e]){const c=null===(t=l[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))}));const r=null===(i=d[e])||void 0===i?void 0:i.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))})),!(o<=0&&s>0)&&(s>0&&o!==s)}return!1};return e.jsxs("div",{children:[Object.keys(l).length?Object.keys(l).map((t=>e.jsx(h,{customCollectionRestriction:o,data:l[t],isDisabled:f&&!(null==d?void 0:d[t]),isChecked:!!(null==d?void 0:d[t]),isPartiallyChecked:E(t),selectedCollectionsDispatch:r,setCollectionId:n,setScreen:u,id:t,hideCollectionCheckbox:y,selectedCollections:d,renderWithoutModal:v,pickerType:m},t))):s?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(a.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:b}),O&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),r=require("../../assets/icons/search.svg.js"),o=require("react"),c=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),C=require("./selectedScreen.js"),x=require("./style.js"),g=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:j,selectedItems:m,onClose:v,visible:y,zIndex:b,limit:P,hideCollectionCheckbox:k,hideProductCheckbox:f,outOfStockAction:O=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:R,hideSelectionCount:F,title:I,width:q,renderWithoutModal:E,onClickSave:D,pickerType:N,hideProductVariants:w=!1,startupScreen:V=exports.ScreenName.Collections,rearrangeEnabled:A}=e,[B,M]=o.useReducer(p.collectionsReducer,{}),[L,_]=o.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(V)?V:exports.ScreenName.Collections),[z,G]=o.useState("grid"),[H,W]=o.useState(""),[$,K]=o.useState(0),[U,Y]=o.useState(!1),[J,Q]=o.useState(0),[X,Z]=o.useState(""),[ee,te]=o.useState(!1),[re,oe]=o.useState(!1),[ce,se]=o.useState(),[ne,ie]=o.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{});o.useEffect((()=>{Y(!0),oe(!0),e.collectionFetcher($,j).then((e=>{M({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Y(!1),K((e=>e+1)),oe(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;w?Object.keys(ne||[]).forEach((t=>{var r;Object.keys((null===(r=ne[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var o;"-1"!==t&&ne[-1]&&(null===(o=ne[-1].products)||void 0===o?void 0:o[r])||(e+=1)}))})):Object.keys(ne||[]).forEach((t=>{var r;Object.keys((null===(r=ne[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var o,c;Object.keys((null===(c=null===(o=ne[t].products)||void 0===o?void 0:o[r])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),Q(e)})),o.useEffect((()=>{var t;H&&!(null===(t=null==B?void 0:B[H])||void 0===t?void 0:t.products)&&(Y(!0),e.productFetcher(H,j).then((e=>{Object.keys(e).length&&M({type:"productsFetched",data:{collectionId:H,products:e}}),Y(!1)})).catch())}),[H]),o.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==L&&(X.length?(te(!0),e.searchFetcher(j,X).then((e=>{se(Object.assign({},e)),_("searchProducts"),Y(!1),te(!1)}))):_("collections"))}),800);return()=>clearTimeout(t)}),[X]),o.useEffect((()=>{D&&(e.onAdd(ne,J),le())}),[D]);const le=()=>{ie({type:"reset",data:{}})},ae=t.jsxs(x.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===L||"searchProducts"===L)&&t.jsx("div",Object.assign({style:{padding:E?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ee?t.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):t.jsx(r.default,{})},id:"listInput",height:"24px",type:"text",value:X,onChangeText:e=>{e.length&&e.trim().length?Z(e):Z("")}})}))}),t.jsxs(x.ScrollContainerStyle,{children:["collections"===L&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:re,collections:B,selectedCollectionsDispatch:ie,setCollectionId:W,setScreen:_,selectedCollections:ne,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:M,setSaveDisabled:Y,pagingControls:{curPage:$,setCurPage:K},hideCollectionCheckbox:k,renderWithoutModal:E,pickerType:N}),"products"===L&&H&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:H},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:_,storeId:j,data:B[H],collectionsDispatch:M,selectedCollectionsDispatch:ie,selectedData:ne,setSaveDisabled:Y,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:f,outOfStockAction:O,hideVariantCheckbox:T,selectProductsFromCustomCollection:R,renderWithoutModal:E,pickerType:N,hideProductVariants:w})})),"view"===L&&t.jsx(C.SelectedScreen,{selectedCollections:ne||{},selectedCollectionsDispatch:ie,setScreen:_,collections:B,hideProductVariants:w}),"rearrange"===L&&t.jsx(h.RearrangeScreen,{selectedCollections:ne||{},selectedCollectionsDispatch:ie,setScreen:_,outOfStockAction:O,rearrangeViewType:"grid"===z?"list":"grid"}),"searchProducts"===L&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:ne||{},searchedCollections:ce||{},selectedCollectionsDispatch:ie,setScreen:_,collections:B,onBackPress:()=>{Z(""),se({})},pickerType:N,hideProductCheckbox:f,hideProductVariants:w,hideVariantCheckbox:T})]})]});return t.jsx(t.Fragment,{children:E?ae:t.jsx(i.StyledModal,Object.assign({zIndex:b,open:y,onClose:()=>{null==v||v(),le()},headingTitle:I||("collections"===L||"products"===L?"Select Products":"view"===L?"Selected Products":"searchProducts"===L?"Searched Products":"rearrange"===L?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:q||"480px"},headerRightCustomElement:"rearrange"===L?(console.log("ignore:",G),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:U?"Loading...":L===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:U||J<1||P&&J>P||!1,onClick:()=>{e.onAdd(ne,J),le()}},footerLeftCustomElement:F?t.jsx(t.Fragment,{}):P&&J>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):J>0?t.jsx(s.Button,{onClick:()=>{_(A?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:`${J} products selected`,buttonType:["rearrange","view"].includes(L)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(L)}):t.jsx(s.Button,{disabled:!0,buttonText:`${J} products selected`,buttonType:"tertiaryGray"})},{children:ae}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),C=require("./selectedScreen.js"),g=require("./style.js"),x=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:j,selectedItems:m,onClose:y,visible:v,zIndex:P,limit:b,hideCollectionCheckbox:k,hideProductCheckbox:f,outOfStockAction:T=x.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:O,selectProductsFromCustomCollection:R,hideSelectionCount:F,title:I,width:q,renderWithoutModal:E,onClickSave:D,pickerType:N,hideProductVariants:w=!1,startupScreen:A=exports.ScreenName.Collections,rearrangeEnabled:B}=e,[M,V]=c.useReducer(p.collectionsReducer,{}),[L,_]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(A)?A:exports.ScreenName.Collections),[z,G]=c.useState("grid"),[H,W]=c.useState(""),[$,K]=c.useState(0),[U,Y]=c.useState(!1),[J,Q]=c.useState(0),[X,Z]=c.useState(""),[ee,te]=c.useState(!1),[oe,ce]=c.useState(!1),[re,se]=c.useState(),[ne,le]=c.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{});c.useEffect((()=>{console.log({selectedCollections:ne})}),[ne]),c.useEffect((()=>{Y(!0),ce(!0),e.collectionFetcher($,j).then((e=>{console.log({collectionsParsed:e}),V({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Y(!1),K((e=>e+1)),ce(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(ne||[]).forEach((t=>{var o;Object.keys((null===(o=ne[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ne[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),Q(e)})),c.useEffect((()=>{var t;H&&!(null===(t=null==M?void 0:M[H])||void 0===t?void 0:t.products)&&(Y(!0),e.productFetcher(H,j).then((e=>{Object.keys(e).length&&V({type:"productsFetched",data:{collectionId:H,products:e}}),Y(!1)})).catch())}),[H]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==L&&(X.length?(te(!0),e.searchFetcher(j,X).then((e=>{se(Object.assign({},e)),_("searchProducts"),Y(!1),te(!1)}))):_("collections"))}),800);return()=>clearTimeout(t)}),[X]),c.useEffect((()=>{console.log("onClickSave",D),D&&(e.onAdd(ne,J),ie())}),[D]);const ie=()=>{console.log("resetPicker"),le({type:"reset",data:{}})},ae=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===L||"searchProducts"===L)&&t.jsx("div",Object.assign({style:{padding:E?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ee?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:X,onChangeText:e=>{e.length&&e.trim().length?Z(e):Z("")}})}))}),t.jsxs(g.ScrollContainerStyle,{children:["collections"===L&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:oe,collections:M,selectedCollectionsDispatch:le,setCollectionId:W,setScreen:_,selectedCollections:ne,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:V,setSaveDisabled:Y,pagingControls:{curPage:$,setCurPage:K},hideCollectionCheckbox:k,renderWithoutModal:E,pickerType:N}),"products"===L&&H&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:H},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:_,storeId:j,data:M[H],collectionsDispatch:V,selectedCollectionsDispatch:le,selectedData:ne,setSaveDisabled:Y,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:f,outOfStockAction:T,hideVariantCheckbox:O,selectProductsFromCustomCollection:R,renderWithoutModal:E,pickerType:N,hideProductVariants:w})})),"view"===L&&t.jsx(C.SelectedScreen,{selectedCollections:ne||{},selectedCollectionsDispatch:le,setScreen:_,collections:M}),"rearrange"===L&&t.jsx(h.RearrangeScreen,{selectedCollections:ne||{},selectedCollectionsDispatch:le,setScreen:_,outOfStockAction:T,rearrangeViewType:"grid"===z?"list":"grid"}),"searchProducts"===L&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:ne||{},searchedCollections:re||{},selectedCollectionsDispatch:le,setScreen:_,collections:M,onBackPress:()=>{Z(""),se({})},pickerType:N,hideProductCheckbox:f,hideProductVariants:w,hideVariantCheckbox:O})]})]});return t.jsx(t.Fragment,{children:E?ae:t.jsx(l.StyledModal,Object.assign({zIndex:P,open:v,onClose:()=>{null==y||y(),ie()},headingTitle:I||("collections"===L||"products"===L?"Select Products":"view"===L?"Selected Products":"searchProducts"===L?"Searched Products":"rearrange"===L?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:q||"480px"},headerRightCustomElement:"rearrange"===L?(console.log("ignore:",G),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:U?"Loading...":L===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:U||J<1||b&&J>b||!1,onClick:()=>{e.onAdd(ne,J),ie()}},footerLeftCustomElement:F?t.jsx(t.Fragment,{}):b&&J>b?t.jsx(a.Tag,{tagText:`You can only select ${b} products`,type:"negative"}):J>0?t.jsx(s.Button,{onClick:()=>{_(B?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:`${J} products selected`,buttonType:["rearrange","view"].includes(L)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(L)}):t.jsx(s.Button,{disabled:!0,buttonText:`${J} products selected`,buttonType:"tertiaryGray"})},{children:ae}))})};
@@ -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"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),d=require("react"),r=require("../tag/Tag.js"),s=require("../../constants/Theme.js"),l=require("../checkBox/CheckBox.js"),n=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),p=require("../spinner/Spinner.js"),v=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),x=require("./collectionScreen.js"),y=require("./emptyState.js"),g=require("./helpers/ProductHelper.js"),C=require("./reducers.js"),k=require("./style.js"),b=require("./type.js"),m=require("./utility.js");const O=t=>{const{collectionId:i,productId:o,data:c,selectedData:d,selectedCollectionsDispatch:r,viewOnly:s,upliftAdditions:l,isProductPartiallyChecked:n,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v}=t,j=e=>{var t,c,r,s,l,n;if(!(null===(c=null===(t=null==d?void 0:d[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(n=null===(l=null===(s=null===(r=null==d?void 0:d[i])||void 0===r?void 0:r.products)||void 0===s?void 0:s[o])||void 0===l?void 0:l.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(y=null===(x=null==d?void 0:d[i])||void 0===x?void 0:x.products)||void 0===y?void 0:y[o]),isPartiallyChecked:n,selectedCollectionsDispatch:r,upliftAdditions:l,viewOnly:s,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v},o),p?null:Object.keys(c.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:o,viewOnly:s,upliftAdditions:l,collectionId:i,isSelected:j(t),selectedCollectionsDispatch:r,outOfStockAction:u},t)))]});var x,y},I=t=>{const{isVariant:i,data:o,productId:c,collectionId:d,variantId:s,isSelected:n,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:y,hideProductCheckbox:C,outOfStockAction:b,hideVariantCheckbox:m,hideProductVariants:O,pickerType:I}=t,f=g.ProductHelper.getProductLabels(o,b);return e.jsxs(k.ProductCardStyle,Object.assign({isVariant:i,onClick:e=>{if(e.stopPropagation(),"PRODUCT"===I)if(a({type:"reset",data:{}}),O)p("productSelected",{productId:c,variantId:s,collectionId:d});else{const e=Object.keys(o.variants);p("variantSelected",{productId:c,variantId:s||e[0],collectionId:d,variant:o})}},isActive:n},{children:[i&&!u&&!m||!i&&!u&&!C?e.jsx(l.CheckBox,{isChecked:n,isPartiallyChecked:y||!1,onValueChange:function(e){if(i)e?p(O?"productSelected":"variantSelected",{productId:c,variantId:s,collectionId:d,variant:o}):a({type:O?"productUnselected":"variantUnselected",data:{productId:c,variantId:s,collectionId:d}});else if(e){const e=Object.keys(o.variants);p(O?"productSelected":"variantSelected",{productId:c,collectionId:d,product:O?o.variants[e[0]]:o})}else a({type:O?"productUnselected":"variantUnselected",data:{productId:c,collectionId:d}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(v.Tooltip,Object.assign({body:o.name,placement:"bottom",delay:400},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx(j.TitleRegular,{children:x.truncate(o.name,40,!0)}),f?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(r.Tag,{tagText:f,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=O,exports.ProductsScreen=r=>{const h=d.useContext(C.CollectionIdContext),{data:v,collectionsDispatch:x,selectedData:g,selectedCollectionsDispatch:I,productFetcher:f,storeId:S,setScreen:P,setSaveDisabled:q,hideInCollectionSearch:T,customCollectionRestriction:V,hideProductCheckbox:E,outOfStockAction:D=b.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:w=!1,selectProductsFromCustomCollection:A=!1,pickerType:B,hideProductVariants:R}=r,[U,F]=d.useState(""),[_,H]=d.useState(!1),[L,K]=d.useState(v);d.useEffect((()=>{const e=setTimeout((()=>{U.length?(H(!0),r.searchInCollectionFetcher(S,h,U).then((e=>{var t;const i=c.cloneDeep(v);i.products={};for(const o of e)(null===(t=null==v?void 0:v.products)||void 0===t?void 0:t[o])&&(i.products[o]=v.products[o]);K(i),q(!1),H(!1)}))):K(v)}),800);return()=>clearTimeout(e)}),[U]);const N=!!V&&v.isSmartCollection,W=e=>{var t,i,o,c,d,r,s,l;let n=0,a=0;return!R&&!!((null===(i=null===(t=null==g?void 0:g[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(d=Object.keys((null===(c=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[e])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>a++)),Object.keys((null===(l=null===(s=null===(r=null==g?void 0:g[h])||void 0===r?void 0:r.products)||void 0===s?void 0:s[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};d.useEffect((()=>{(null==v?void 0:v.products)||z()}),[]);const z=()=>{q(!0),H(!0),f(h,S).then((e=>{Object.keys(e).length&&(x({type:"productsFetched",data:{collectionId:h,products:e}}),K(Object.assign(Object.assign({},L),{products:e}))),q(!1),H(!1)})).catch()},G=(e,t)=>{const i=m.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},i),{isRestricted:V})})};return e.jsxs("div",{children:[e.jsxs(k.ProductScreenHeader,{children:[e.jsx(n.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:v.name}))]}),!T&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&U.length?e.jsx(p.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:U,onChangeText:e=>{e.length&&e.trim().length?F(e):F("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==L?void 0:L.products)||[]).length>0&&!N&&!U.length&&!E&&e.jsxs(k.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==g?void 0:g[h]),isPartiallyChecked:(e=>{var t,i,o,c;let d=0,r=0;if(R){const c=null!==(t=null==v?void 0:v.products)&&void 0!==t?t:{};d=Object.keys(c).length;const s=null!==(o=null===(i=g[e])||void 0===i?void 0:i.products)&&void 0!==o?o:{};r=Object.keys(s).length}else if(g[e]){const t=null==v?void 0:v.products;t&&Object.keys(t).forEach((e=>{var i;const o=null===(i=t[e])||void 0===i?void 0:i.variants;o&&Object.keys(o).forEach((e=>d+=1))}));const i=null===(c=g[e])||void 0===c?void 0:c.products;i&&Object.keys(i).forEach((e=>{var t;const o=null===(t=i[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((()=>r+=1))}))}return r>0&&d!==r})(h),onValueChange:function(e){I(e?{type:"selected",data:{id:h,val:v}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==L?void 0:L.products)||[]).length?Object.keys(L.products||[]).map((t=>e.jsx(O,{outOfStockAction:D,collectionId:h,isProductPartiallyChecked:W(t),productId:t,data:L.products[t],selectedData:g,selectedCollectionsDispatch:I,viewOnly:!A&&!!N,upliftAdditions:G,hideProductCheckbox:E,hideVariantCheckbox:w,hideProductVariants:R,pickerType:B},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(y.EmptyState,{title:"No products to show",subtitle:U.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),r=require("react"),s=require("../tag/Tag.js"),d=require("../../constants/Theme.js"),n=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),p=require("../spinner/Spinner.js"),v=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),x=require("./collectionScreen.js"),y=require("./emptyState.js"),g=require("./helpers/ProductHelper.js"),C=require("./reducers.js"),k=require("./style.js"),m=require("./type.js"),b=require("./utility.js");const O=t=>{const{collectionId:i,productId:o,data:c,selectedData:r,selectedCollectionsDispatch:s,viewOnly:d,upliftAdditions:n,isProductPartiallyChecked:l,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v}=t,j=e=>{var t,c,s,d,n,l;if(!(null===(c=null===(t=null==r?void 0:r[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(l=null===(n=null===(d=null===(s=null==r?void 0:r[i])||void 0===s?void 0:s.products)||void 0===d?void 0:d[o])||void 0===n?void 0:n.variants)||void 0===l?void 0:l[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(y=null===(x=null==r?void 0:r[i])||void 0===x?void 0:x.products)||void 0===y?void 0:y[o]),isPartiallyChecked:l,selectedCollectionsDispatch:s,upliftAdditions:n,viewOnly:d,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v},o),p?null:Object.keys(c.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:o,viewOnly:d,upliftAdditions:n,collectionId:i,isSelected:j(t),selectedCollectionsDispatch:s,outOfStockAction:u},t)))]});var x,y},I=t=>{const{isVariant:i,data:o,productId:c,collectionId:r,variantId:d,isSelected:l,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:y,hideProductCheckbox:C,outOfStockAction:m,hideVariantCheckbox:b,hideProductVariants:O,pickerType:I}=t,f=g.ProductHelper.getProductLabels(o,m);return e.jsxs(k.ProductCardStyle,Object.assign({isVariant:i,onClick:e=>{const t=Object.keys(o.variants);"PRODUCT"===I&&O&&(e.stopPropagation(),a({type:"reset",data:{}}),p("variantSelected",{productId:c,variantId:d||t[0],collectionId:r,variant:o.variants[t[0]]}))},isActive:l},{children:[i&&!u&&!b||!i&&!u&&!C?e.jsx(n.CheckBox,{isChecked:l,isPartiallyChecked:y||!1,onValueChange:function(e){if(i)e?p("variantSelected",{productId:c,variantId:d,collectionId:r,variant:o}):a({type:"variantUnselected",data:{productId:c,variantId:d,collectionId:r}});else if(e){const e=Object.keys(o.variants);p(O?"variantSelected":"productSelected",{productId:c,collectionId:r,product:O?o.variants[e[0]]:o})}else a({type:O?"variantUnselected":"productUnselected",data:{productId:c,collectionId:r}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(v.Tooltip,Object.assign({body:o.name,placement:"bottom",delay:400},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx(j.TitleRegular,{children:x.truncate(o.name,40,!0)}),f?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(s.Tag,{tagText:f,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=O,exports.ProductsScreen=s=>{const h=r.useContext(C.CollectionIdContext),{data:v,collectionsDispatch:x,selectedData:g,selectedCollectionsDispatch:I,productFetcher:f,storeId:S,setScreen:P,setSaveDisabled:q,hideInCollectionSearch:T,customCollectionRestriction:V,hideProductCheckbox:E,outOfStockAction:D=m.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:w=!1,selectProductsFromCustomCollection:A=!1,pickerType:B,hideProductVariants:R}=s,[U,F]=r.useState(""),[_,H]=r.useState(!1),[L,K]=r.useState(v);r.useEffect((()=>{const e=setTimeout((()=>{U.length?(H(!0),s.searchInCollectionFetcher(S,h,U).then((e=>{var t;const i=c.cloneDeep(v);i.products={};for(const o of e)(null===(t=null==v?void 0:v.products)||void 0===t?void 0:t[o])&&(i.products[o]=v.products[o]);K(i),q(!1),H(!1)}))):K(v)}),800);return()=>clearTimeout(e)}),[U]);const N=!!V&&v.isSmartCollection,W=e=>{var t,i,o,c,r,s,d,n;let l=0,a=0;return!R&&!!((null===(i=null===(t=null==g?void 0:g[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(r=Object.keys((null===(c=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[e])||void 0===c?void 0:c.variants)||[]))||void 0===r||r.forEach((()=>a++)),Object.keys((null===(n=null===(d=null===(s=null==g?void 0:g[h])||void 0===s?void 0:s.products)||void 0===d?void 0:d[e])||void 0===n?void 0:n.variants)||[]).forEach((()=>l++)),l>0&&a!==l))};r.useEffect((()=>{(null==v?void 0:v.products)||z()}),[]);const z=()=>{q(!0),H(!0),f(h,S).then((e=>{Object.keys(e).length&&(x({type:"productsFetched",data:{collectionId:h,products:e}}),K(Object.assign(Object.assign({},L),{products:e}))),q(!1),H(!1)})).catch()},G=(e,t)=>{const i=b.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},i),{isRestricted:V})})};return e.jsxs("div",{children:[e.jsxs(k.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:d.COLORS.content.secondary}},{children:v.name}))]}),!T&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&U.length?e.jsx(p.Spinner,{size:"small",color:d.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:U,onChangeText:e=>{e.length&&e.trim().length?F(e):F("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==L?void 0:L.products)||[]).length>0&&!N&&!U.length&&!E&&e.jsxs(k.ProductScreenCollectionCardStyle,{children:[e.jsx(n.CheckBox,{isChecked:!!(null==g?void 0:g[h]),isPartiallyChecked:(e=>{var t;let i=0,o=0;if(g[e]){const c=null==v?void 0:v.products;c&&Object.keys(c).forEach((e=>{var t;const o=null===(t=c[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const r=null===(t=g[e])||void 0===t?void 0:t.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((()=>o+=1))})),o>0&&i!==o}return!1})(h),onValueChange:function(e){I(e?{type:"selected",data:{id:h,val:v}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==L?void 0:L.products)||[]).length?Object.keys(L.products||[]).map((t=>e.jsx(O,{outOfStockAction:D,collectionId:h,isProductPartiallyChecked:W(t),productId:t,data:L.products[t],selectedData:g,selectedCollectionsDispatch:I,viewOnly:!A&&!!N,upliftAdditions:G,hideProductCheckbox:E,hideVariantCheckbox:w,hideProductVariants:R,pickerType:B},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(y.EmptyState,{title:"No products to show",subtitle:U.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;default:return{}}},exports.selectedColectionsReducer=function(e,a){var d,o,c,l,s,r,i,n,u,p,v;let C={},O="",g="",m="";switch(a.type){case"selected":return C=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(C={}),C.isCustom=!0),C[a.data.id]=a.data.val,C;case"unselected":return C=t.cloneDeep(e),(null==C?void 0:C.isCustom)&&(C.isCustom=!1),delete C[a.data.id],C;case"productUnselected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,delete C[g].products[O],Object.keys(C[g].products).length||((null==C?void 0:C.isCustom)&&(C.isCustom=!1),delete C[g]),C;case"productSelected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,(null===(d=a.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(a.data.isRestricted&&(C={}),C.isCustom=!0),(null==C?void 0:C[g])||(C[g]=a.data.catalogOnlyData,C[g].products={}),C[g].products[O]=a.data.product,C;case"variantSelected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,m=a.data.variantId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(C={}),C.isCustom=!0),(null==C?void 0:C[g])||(C[g]=a.data.catalogOnlyData,C[g].products={},C[g].products[O]=a.data.productOnlyData,C[g].products[O].variants={}),(null===(l=null===(c=null==C?void 0:C[g])||void 0===c?void 0:c.products)||void 0===l?void 0:l[O])||((null===(s=null==C?void 0:C[g])||void 0===s?void 0:s.products)||(C[g].products={}),C[g].products[O]=a.data.productOnlyData,C[g].products[O].variants={}),C[g].products[O].variants[m]=a.data.variant,C;case"variantUnselected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,m=a.data.variantId,(null===(i=null===(r=C[g].products[O])||void 0===r?void 0:r.variants)||void 0===i?void 0:i[m])&&delete C[g].products[O].variants[m],Object.keys(null!==(p=null===(u=null===(n=C[g].products)||void 0===n?void 0:n[O])||void 0===u?void 0:u.variants)&&void 0!==p?p:{}).length||(delete C[g].products[O],Object.keys(C[g].products).length||((null===(v=C[g])||void 0===v?void 0:v.isSmartCollection)&&(C.isCustom=!1),delete C[g])),C;case"reset":return{};default:return e}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;default:return{}}},exports.selectedColectionsReducer=function(e,a){var d,o,c,s,l,r;let n={},u="",i="",p="";switch(a.type){case"selected":return n=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(n={}),n.isCustom=!0),n[a.data.id]=a.data.val,n;case"unselected":return n=t.cloneDeep(e),(null==n?void 0:n.isCustom)&&(n.isCustom=!1),delete n[a.data.id],n;case"productUnselected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,delete n[i].products[u],Object.keys(n[i].products).length||((null==n?void 0:n.isCustom)&&(n.isCustom=!1),delete n[i]),n;case"productSelected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,(null===(d=a.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(a.data.isRestricted&&(n={}),n.isCustom=!0),(null==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,n[i].products={}),n[i].products[u]=a.data.product,n;case"variantSelected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,p=a.data.variantId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(n={}),n.isCustom=!0),(null==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,n[i].products={},n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),(null===(s=null===(c=null==n?void 0:n[i])||void 0===c?void 0:c.products)||void 0===s?void 0:s[u])||((null===(l=null==n?void 0:n[i])||void 0===l?void 0:l.products)||(n[i].products={}),n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),n[i].products[u].variants[p]=a.data.variant,n;case"variantUnselected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,p=a.data.variantId,delete n[i].products[u].variants[p],Object.keys(n[i].products[u].variants).length||(delete n[i].products[u],Object.keys(n[i].products).length||((null===(r=n[i])||void 0===r?void 0:r.isSmartCollection)&&(n.isCustom=!1),delete n[i])),n;case"reset":return{};default:return e}};
@@ -8,7 +8,6 @@ interface SelectedScreenInterface {
8
8
  collections: {
9
9
  [key: string]: Collection;
10
10
  };
11
- hideProductVariants?: boolean;
12
11
  }
13
12
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
14
13
  export {};
@@ -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"),l=require("../icon-button/IconButton.js"),r=require("../TypographyStyle.js"),o=require("./emptyState.js"),i=require("./helpers/AllProductHelper.js"),d=require("./productScreen.js"),s=require("./style.js");exports.SelectedScreen=c=>{const{selectedCollections:u,selectedCollectionsDispatch:n,setScreen:a,collections:v,hideProductVariants:p=!1}=c,j=(e,t)=>{var l,r,o,i,d,s,c,n,a;let p=0,j=0;return!!((null===(r=null===(l=null==u?void 0:u[e])||void 0===l?void 0:l.products)||void 0===r?void 0:r[t])&&(null===(s=Object.keys((null===(d=null===(i=null===(o=null==v?void 0:v[e])||void 0===o?void 0:o.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===s||s.forEach((()=>j++)),Object.keys((null===(a=null===(n=null===(c=null==u?void 0:u[e])||void 0===c?void 0:c.products)||void 0===n?void 0:n[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))},h=p?i.AllProductHelper.removeDuplicatesForAllProducts(Object.assign({},u)):u;return e.jsxs("div",{children:[e.jsxs(s.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{a("collections")}}),e.jsx(r.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(h).length>0?e.jsx(e.Fragment,{children:Object.keys(h).map((t=>{var l;return Object.keys((null===(l=null==h?void 0:h[t])||void 0===l?void 0:l.products)||[]).map((l=>{let r=!1;return(null==h?void 0:h.isCustom)&&(r=!0),e.jsx(d.ProductGroup,{upliftAdditions:null,collectionId:t,productId:l,data:h[t].products[l],isProductPartiallyChecked:j(t,l),selectedData:h,selectedCollectionsDispatch:n,viewOnly:r,hideProductVariants:p},l)}))}))}):e.jsx(o.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),l=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),r=require("./emptyState.js"),i=require("./productScreen.js"),d=require("./style.js");exports.SelectedScreen=s=>{const{selectedCollections:c,selectedCollectionsDispatch:n,setScreen:u,collections:v}=s,a=(e,t)=>{var l,o,r,i,d,s,n,u,a;let p=0,j=0;return!!((null===(o=null===(l=null==c?void 0:c[e])||void 0===l?void 0:l.products)||void 0===o?void 0:o[t])&&(null===(s=Object.keys((null===(d=null===(i=null===(r=null==v?void 0:v[e])||void 0===r?void 0:r.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===s||s.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(n=null==c?void 0:c[e])||void 0===n?void 0:n.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))};return e.jsxs("div",{children:[e.jsxs(d.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{u("collections")}}),e.jsx(o.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(c).length>0?e.jsx(e.Fragment,{children:Object.keys(c).map((t=>{var l;return Object.keys((null===(l=null==c?void 0:c[t])||void 0===l?void 0:l.products)||[]).map((l=>{let o=!1;return(null==c?void 0:c.isCustom)&&(o=!0),e.jsx(i.ProductGroup,{upliftAdditions:null,collectionId:t,productId:l,data:c[t].products[l],isProductPartiallyChecked:a(t,l),selectedData:c,selectedCollectionsDispatch:n,viewOnly:o},l)}))}))}):e.jsx(r.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as r}from"react";import{CheckBox as l}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BikShimmer as d}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as a}from"../tag/Tag.js";import{Tooltip as h}from"../tooltips/Tooltip.js";import{TitleRegular as p}from"../TypographyStyle.js";import{EmptyState as m}from"./emptyState.js";import{CollectionCardStyle as u,CollectionCardInfoStyle as C,CollectionCardDetailStyle as v,CollectionNameHolder as b}from"./style.js";const g=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},y=o=>{const{customCollectionRestriction:i,dataLoading:l,collections:n,selectedCollectionsDispatch:a,setCollectionId:h,selectedCollections:p,setScreen:u,collectionFetcher:C,collectionsDispatch:v,pagingControls:b,storeId:g,setSaveDisabled:y,hideCollectionCheckbox:k,renderWithoutModal:j,pickerType:x}=o,O=c(null),E=c(b.curPage),I=!!i&&(null==p?void 0:p.isCustom),[T,S]=s(!1);r((()=>{E.current=b.curPage}),[b.curPage]),r((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&E.current>0&&(y(!0),S(!0),C(E.current,g).then((e=>{v({type:"paged",data:(null==e?void 0:e.collections)||{}}),b.setCurPage(E.current+1),S(!1),y(!1)})).catch())}),{threshold:1});return O.current&&e.observe(O.current),()=>{O.current&&e.unobserve(O.current)}}),[O]);const D=e=>{var t,o;let i=0,c=0;if(p[e]){const s=null===(t=n[e])||void 0===t?void 0:t.products;s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const r=null===(o=p[e])||void 0===o?void 0:o.products;return r&&Object.keys(r).forEach((e=>{var t;const o=null===(t=r[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(i<=0&&c>0)&&(c>0&&i!==c)}return!1};return e("div",{children:[Object.keys(n).length?Object.keys(n).map((e=>t(f,{customCollectionRestriction:i,data:n[e],isDisabled:I&&!(null==p?void 0:p[e]),isChecked:!!(null==p?void 0:p[e]),isPartiallyChecked:D(e),selectedCollectionsDispatch:a,setCollectionId:h,setScreen:u,id:e,hideCollectionCheckbox:k,selectedCollections:p,renderWithoutModal:j,pickerType:x},e))):l?[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):t(m,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:O}),T&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},f=c=>{const{customCollectionRestriction:s,data:r,selectedCollectionsDispatch:d,setCollectionId:m,isPartiallyChecked:y,setScreen:f,id:k,isChecked:j,isDisabled:x,hideCollectionCheckbox:O,pickerType:E,selectedCollections:I}=c;return e(u,Object.assign({isDisabled:x,onClick:e=>{if(!x){if("COLLECTION"===E)return e.stopPropagation(),d({type:"reset",data:{}}),d({type:"selected",data:{id:k,val:r,isRestricted:s}}),void m(k);m(k),f("products")}},isActive:!!I[k]},{children:[e(C,{children:[!O&&t(l,{isDisabled:x,isChecked:j,isPartiallyChecked:y,onValueChange:function(e,t,o){null==o||o.stopPropagation(),d(e?{type:"selected",data:{id:k,val:r,isRestricted:s}}:{type:"unselected",data:{id:k}}),m(e?k:"")}}),t(v,{children:t(h,Object.assign({body:r.name,placement:"bottom",delay:400},{children:e(b,{children:[t(p,{children:g(r.name,40,!0)}),r.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(a,{tagText:"Smart Collection",type:"warning"})})):t(o,{})]})}))})]}),"COLLECTION"!==E&&t(n,{height:12,width:12,disabled:x,Icon:i})]}))};export{y as CollectionsScreen,g as truncate};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as l}from"react";import{CheckBox as r}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BikShimmer as d}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as a}from"../tag/Tag.js";import{Tooltip as h}from"../tooltips/Tooltip.js";import{TitleRegular as p}from"../TypographyStyle.js";import{EmptyState as m}from"./emptyState.js";import{CollectionCardStyle as u,CollectionCardInfoStyle as C,CollectionCardDetailStyle as g,CollectionNameHolder as v}from"./style.js";const b=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},y=o=>{const{customCollectionRestriction:i,dataLoading:r,collections:n,selectedCollectionsDispatch:a,setCollectionId:h,selectedCollections:p,setScreen:u,collectionFetcher:C,collectionsDispatch:g,pagingControls:v,storeId:b,setSaveDisabled:y,hideCollectionCheckbox:k,renderWithoutModal:j,pickerType:O}=o,x=c(null),E=c(v.curPage),T=!!i&&(null==p?void 0:p.isCustom),[I,S]=s(!1);l((()=>{E.current=v.curPage}),[v.curPage]),l((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&E.current>0&&(y(!0),S(!0),C(E.current,b).then((e=>{g({type:"paged",data:(null==e?void 0:e.collections)||{}}),v.setCurPage(E.current+1),S(!1),y(!1)})).catch())}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x]);const D=e=>{var t,o;let i=0,c=0;if(p[e]){const s=null===(t=n[e])||void 0===t?void 0:t.products;s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const l=null===(o=p[e])||void 0===o?void 0:o.products;return l&&Object.keys(l).forEach((e=>{var t;const o=null===(t=l[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(i<=0&&c>0)&&(c>0&&i!==c)}return!1};return e("div",{children:[Object.keys(n).length?Object.keys(n).map((e=>t(f,{customCollectionRestriction:i,data:n[e],isDisabled:T&&!(null==p?void 0:p[e]),isChecked:!!(null==p?void 0:p[e]),isPartiallyChecked:D(e),selectedCollectionsDispatch:a,setCollectionId:h,setScreen:u,id:e,hideCollectionCheckbox:k,selectedCollections:p,renderWithoutModal:j,pickerType:O},e))):r?[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):t(m,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:x}),I&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},f=c=>{const{customCollectionRestriction:s,data:l,selectedCollectionsDispatch:d,setCollectionId:m,isPartiallyChecked:y,setScreen:f,id:k,isChecked:j,isDisabled:O,hideCollectionCheckbox:x,pickerType:E,selectedCollections:T}=c;return e(u,Object.assign({isDisabled:O,onClick:e=>{if(console.log("onClickChevron"),!O){if("COLLECTION"===E)return console.log("pickerType == COLLECTION"),e.stopPropagation(),d({type:"reset",data:{}}),d({type:"selected",data:{id:k,val:l,isRestricted:s}}),void m(k);m(k),f("products")}},isActive:!!T[k]},{children:[e(C,{children:[!x&&t(r,{isDisabled:O,isChecked:j,isPartiallyChecked:y,onValueChange:function(e,t,o){null==o||o.stopPropagation(),d(e?{type:"selected",data:{id:k,val:l,isRestricted:s}}:{type:"unselected",data:{id:k}}),m(e?k:"")}}),t(g,{children:t(h,Object.assign({body:l.name,placement:"bottom",delay:400},{children:e(v,{children:[t(p,{children:b(l.name,40,!0)}),l.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(a,{tagText:"Smart Collection",type:"warning"})})):t(o,{})]})}))})]}),"COLLECTION"!==E&&t(n,{height:12,width:12,disabled:O,Icon:i})]}))};export{y as CollectionsScreen,b as truncate};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as i,useEffect as s}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as a}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as u}from"../tag/Tag.js";import{CollectionsScreen as p}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{RearrangeScreen as C}from"./rearrangeScreen.js";import{collectionsReducer as g,selectedColectionsReducer as v,CollectionIdContext as b}from"./reducers.js";import{SearchScreen as y}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as P,ScrollContainerStyle as S}from"./style.js";import{OUT_OF_STOCK_ACTION as j}from"./type.js";var k;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(k||(k={}));const x=x=>{const{storeId:T,selectedItems:I,onClose:O,visible:R,zIndex:D,limit:E,hideCollectionCheckbox:F,hideProductCheckbox:w,outOfStockAction:V=j.BLUR,hideVariantCheckbox:A,selectProductsFromCustomCollection:B,hideSelectionCount:L,title:M,width:z,renderWithoutModal:G,onClickSave:H,pickerType:W,hideProductVariants:$=!1,startupScreen:K=k.Collections,rearrangeEnabled:U}=x,[Y,q]=r(g,{}),[J,N]=i([k.Collections,k.RearrangeProducts].includes(K)?K:k.Collections),[Q,X]=i("grid"),[Z,_]=i(""),[ee,te]=i(0),[oe,ce]=i(!1),[re,ie]=i(0),[se,ne]=i(""),[le,de]=i(!1),[ae,he]=i(!1),[ue,pe]=i(),[me,Ce]=r(v,Object.keys(I).length>0?I:{});s((()=>{ce(!0),he(!0),x.collectionFetcher(ee,T).then((e=>{q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ce(!1),te((e=>e+1)),he(!1)})).catch()}),[]),s((()=>{let e=0;$?Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&me[-1]&&(null===(c=me[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=me[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ie(e)})),s((()=>{var e;Z&&!(null===(e=null==Y?void 0:Y[Z])||void 0===e?void 0:e.products)&&(ce(!0),x.productFetcher(Z,T).then((e=>{Object.keys(e).length&&q({type:"productsFetched",data:{collectionId:Z,products:e}}),ce(!1)})).catch())}),[Z]),s((()=>{const e=setTimeout((()=>{"rearrange"!==J&&(se.length?(de(!0),x.searchFetcher(T,se).then((e=>{pe(Object.assign({},e)),N("searchProducts"),ce(!1),de(!1)}))):N("collections"))}),800);return()=>clearTimeout(e)}),[se]),s((()=>{H&&(x.onAdd(me,re),ge())}),[H]);const ge=()=>{Ce({type:"reset",data:{}})},ve=e(P,{children:[x.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:x.postHeader})),!x.hideGlobalSearch&&t(o,{children:("collections"===J||"searchProducts"===J)&&t("div",Object.assign({style:{padding:G?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(d,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>le?t(h,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:se,onChangeText:e=>{e.length&&e.trim().length?ne(e):ne("")}})}))}),e(S,{children:["collections"===J&&t(p,{customCollectionRestriction:x.customCollectionRestriction,dataLoading:ae,collections:Y,selectedCollectionsDispatch:Ce,setCollectionId:_,setScreen:N,selectedCollections:me,collectionFetcher:x.collectionFetcher,storeId:T,collectionsDispatch:q,setSaveDisabled:ce,pagingControls:{curPage:ee,setCurPage:te},hideCollectionCheckbox:F,renderWithoutModal:G,pickerType:W}),"products"===J&&Z&&t(b.Provider,Object.assign({value:Z},{children:t(m,{hideInCollectionSearch:x.hideInCollectionSearch,customCollectionRestriction:x.customCollectionRestriction,productFetcher:x.productFetcher,setScreen:N,storeId:T,data:Y[Z],collectionsDispatch:q,selectedCollectionsDispatch:Ce,selectedData:me,setSaveDisabled:ce,searchInCollectionFetcher:x.searchInCollectionFetcher,hideProductCheckbox:w,outOfStockAction:V,hideVariantCheckbox:A,selectProductsFromCustomCollection:B,renderWithoutModal:G,pickerType:W,hideProductVariants:$})})),"view"===J&&t(f,{selectedCollections:me||{},selectedCollectionsDispatch:Ce,setScreen:N,collections:Y,hideProductVariants:$}),"rearrange"===J&&t(C,{selectedCollections:me||{},selectedCollectionsDispatch:Ce,setScreen:N,outOfStockAction:V,rearrangeViewType:"grid"===Q?"list":"grid"}),"searchProducts"===J&&t(y,{customCollectionRestriction:x.customCollectionRestriction,selectedCollections:me||{},searchedCollections:ue||{},selectedCollectionsDispatch:Ce,setScreen:N,collections:Y,onBackPress:()=>{ne(""),pe({})},pickerType:W,hideProductCheckbox:w,hideProductVariants:$,hideVariantCheckbox:A})]})]});return t(o,{children:G?ve:t(a,Object.assign({zIndex:D,open:R,onClose:()=>{null==O||O(),ge()},headingTitle:M||("collections"===J||"products"===J?"Select Products":"view"===J?"Selected Products":"searchProducts"===J?"Searched Products":"rearrange"===J?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:z||"480px"},headerRightCustomElement:"rearrange"===J?(console.log("ignore:",X),t(o,{})):t(o,{}),primaryButton:{buttonText:oe?"Loading...":J===k.RearrangeProducts?"Done":"Add",disabled:oe||re<1||E&&re>E||!1,onClick:()=>{x.onAdd(me,re),ge()}},footerLeftCustomElement:L?t(o,{}):E&&re>E?t(u,{tagText:`You can only select ${E} products`,type:"negative"}):t(l,re>0?{onClick:()=>{N(U?k.RearrangeProducts:k.SelectedProducts)},buttonText:`${re} products selected`,buttonType:["rearrange","view"].includes(J)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(J)}:{disabled:!0,buttonText:`${re} products selected`,buttonType:"tertiaryGray"})},{children:ve}))})};export{x as ProductPickerModal,k as ScreenName};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as a}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as u}from"../tag/Tag.js";import{CollectionsScreen as p}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{RearrangeScreen as C}from"./rearrangeScreen.js";import{collectionsReducer as g,selectedColectionsReducer as b,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as y}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as S,ScrollContainerStyle as f}from"./style.js";import{OUT_OF_STOCK_ACTION as j}from"./type.js";var k;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(k||(k={}));const x=x=>{const{storeId:T,selectedItems:I,onClose:O,visible:R,zIndex:D,limit:F,hideCollectionCheckbox:w,hideProductCheckbox:E,outOfStockAction:V=j.BLUR,hideVariantCheckbox:A,selectProductsFromCustomCollection:B,hideSelectionCount:L,title:M,width:z,renderWithoutModal:G,onClickSave:H,pickerType:W,hideProductVariants:$=!1,startupScreen:K=k.Collections,rearrangeEnabled:U}=x,[Y,q]=r(g,{}),[J,N]=s([k.Collections,k.RearrangeProducts].includes(K)?K:k.Collections),[Q,X]=s("grid"),[Z,_]=s(""),[ee,te]=s(0),[oe,ce]=s(!1),[re,se]=s(0),[ie,ne]=s(""),[le,de]=s(!1),[ae,he]=s(!1),[ue,pe]=s(),[me,Ce]=r(b,Object.keys(I).length>0?I:{});i((()=>{console.log({selectedCollections:me})}),[me]),i((()=>{ce(!0),he(!0),x.collectionFetcher(ee,T).then((e=>{console.log({collectionsParsed:e}),q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ce(!1),te((e=>e+1)),he(!1)})).catch()}),[]),i((()=>{let e=0;Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=me[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),se(e)})),i((()=>{var e;Z&&!(null===(e=null==Y?void 0:Y[Z])||void 0===e?void 0:e.products)&&(ce(!0),x.productFetcher(Z,T).then((e=>{Object.keys(e).length&&q({type:"productsFetched",data:{collectionId:Z,products:e}}),ce(!1)})).catch())}),[Z]),i((()=>{const e=setTimeout((()=>{"rearrange"!==J&&(ie.length?(de(!0),x.searchFetcher(T,ie).then((e=>{pe(Object.assign({},e)),N("searchProducts"),ce(!1),de(!1)}))):N("collections"))}),800);return()=>clearTimeout(e)}),[ie]),i((()=>{console.log("onClickSave",H),H&&(x.onAdd(me,re),ge())}),[H]);const ge=()=>{console.log("resetPicker"),Ce({type:"reset",data:{}})},be=e(S,{children:[x.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:x.postHeader})),!x.hideGlobalSearch&&t(o,{children:("collections"===J||"searchProducts"===J)&&t("div",Object.assign({style:{padding:G?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(d,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>le?t(h,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:ie,onChangeText:e=>{e.length&&e.trim().length?ne(e):ne("")}})}))}),e(f,{children:["collections"===J&&t(p,{customCollectionRestriction:x.customCollectionRestriction,dataLoading:ae,collections:Y,selectedCollectionsDispatch:Ce,setCollectionId:_,setScreen:N,selectedCollections:me,collectionFetcher:x.collectionFetcher,storeId:T,collectionsDispatch:q,setSaveDisabled:ce,pagingControls:{curPage:ee,setCurPage:te},hideCollectionCheckbox:w,renderWithoutModal:G,pickerType:W}),"products"===J&&Z&&t(v.Provider,Object.assign({value:Z},{children:t(m,{hideInCollectionSearch:x.hideInCollectionSearch,customCollectionRestriction:x.customCollectionRestriction,productFetcher:x.productFetcher,setScreen:N,storeId:T,data:Y[Z],collectionsDispatch:q,selectedCollectionsDispatch:Ce,selectedData:me,setSaveDisabled:ce,searchInCollectionFetcher:x.searchInCollectionFetcher,hideProductCheckbox:E,outOfStockAction:V,hideVariantCheckbox:A,selectProductsFromCustomCollection:B,renderWithoutModal:G,pickerType:W,hideProductVariants:$})})),"view"===J&&t(P,{selectedCollections:me||{},selectedCollectionsDispatch:Ce,setScreen:N,collections:Y}),"rearrange"===J&&t(C,{selectedCollections:me||{},selectedCollectionsDispatch:Ce,setScreen:N,outOfStockAction:V,rearrangeViewType:"grid"===Q?"list":"grid"}),"searchProducts"===J&&t(y,{customCollectionRestriction:x.customCollectionRestriction,selectedCollections:me||{},searchedCollections:ue||{},selectedCollectionsDispatch:Ce,setScreen:N,collections:Y,onBackPress:()=>{ne(""),pe({})},pickerType:W,hideProductCheckbox:E,hideProductVariants:$,hideVariantCheckbox:A})]})]});return t(o,{children:G?be:t(a,Object.assign({zIndex:D,open:R,onClose:()=>{null==O||O(),ge()},headingTitle:M||("collections"===J||"products"===J?"Select Products":"view"===J?"Selected Products":"searchProducts"===J?"Searched Products":"rearrange"===J?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:z||"480px"},headerRightCustomElement:"rearrange"===J?(console.log("ignore:",X),t(o,{})):t(o,{}),primaryButton:{buttonText:oe?"Loading...":J===k.RearrangeProducts?"Done":"Add",disabled:oe||re<1||F&&re>F||!1,onClick:()=>{x.onAdd(me,re),ge()}},footerLeftCustomElement:L?t(o,{}):F&&re>F?t(u,{tagText:`You can only select ${F} products`,type:"negative"}):t(l,re>0?{onClick:()=>{N(U?k.RearrangeProducts:k.SelectedProducts)},buttonText:`${re} products selected`,buttonType:["rearrange","view"].includes(J)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(J)}:{disabled:!0,buttonText:`${re} products selected`,buttonType:"tertiaryGray"})},{children:be}))})};export{x as ProductPickerModal,k as ScreenName};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import d from"../../assets/icons/search.svg.js";import{cloneDeep as l}from"lodash";import{useContext as n,useState as r,useEffect as s}from"react";import{Tag as a}from"../tag/Tag.js";import{COLORS as u}from"../../constants/Theme.js";import{CheckBox as p}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as v}from"../input/Input.js";import{BikShimmer as m}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as y}from"../shimmer-image/ShimmerImage.js";import{Spinner as f}from"../spinner/Spinner.js";import{Tooltip as g}from"../tooltips/Tooltip.js";import{BodyCaption as k,TitleRegular as b}from"../TypographyStyle.js";import{truncate as j}from"./collectionScreen.js";import{EmptyState as C}from"./emptyState.js";import{ProductHelper as I}from"./helpers/ProductHelper.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as x,ProductScreenCollectionCardStyle as S,ProductCardStyle as P}from"./style.js";import{OUT_OF_STOCK_ACTION as V}from"./type.js";import{liftTheStateUp as T}from"./utility.js";const w=o=>{const a=n(O),{data:y,collectionsDispatch:g,selectedData:j,selectedCollectionsDispatch:I,productFetcher:P,storeId:w,setScreen:E,setSaveDisabled:A,hideInCollectionSearch:B,customCollectionRestriction:U,hideProductCheckbox:R,outOfStockAction:F=V.BLUR,hideVariantCheckbox:H=!1,selectProductsFromCustomCollection:L=!1,pickerType:W,hideProductVariants:z}=o,[K,N]=r(""),[_,q]=r(!1),[G,J]=r(y);s((()=>{const t=setTimeout((()=>{K.length?(q(!0),o.searchInCollectionFetcher(w,a,K).then((t=>{var e;const o=l(y);o.products={};for(const i of t)(null===(e=null==y?void 0:y.products)||void 0===e?void 0:e[i])&&(o.products[i]=y.products[i]);J(o),A(!1),q(!1)}))):J(y)}),800);return()=>clearTimeout(t)}),[K]);const M=!!U&&y.isSmartCollection,Q=t=>{var e,o,i,c,d,l,n,r;let s=0,u=0;return!z&&!!((null===(o=null===(e=null==j?void 0:j[a])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(d=Object.keys((null===(c=null===(i=null==y?void 0:y.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>u++)),Object.keys((null===(r=null===(n=null===(l=null==j?void 0:j[a])||void 0===l?void 0:l.products)||void 0===n?void 0:n[t])||void 0===r?void 0:r.variants)||[]).forEach((()=>s++)),s>0&&u!==s))};s((()=>{(null==y?void 0:y.products)||X()}),[]);const X=()=>{A(!0),q(!0),P(a,w).then((t=>{Object.keys(t).length&&(g({type:"productsFetched",data:{collectionId:a,products:t}}),J(Object.assign(Object.assign({},G),{products:t}))),A(!1),q(!1)})).catch()},Y=(t,e)=>{const o=T(e,y);I({type:t,data:Object.assign(Object.assign({},o),{isRestricted:U})})};return t("div",{children:[t(x,{children:[e(h,{Icon:i,height:16,onClick:()=>{E("collections")}}),e(k,Object.assign({style:{color:u.content.secondary}},{children:y.name}))]}),!B&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(v,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&K.length?e(f,{size:"small",color:u.content.primary}):e(d,{})},id:"listInput",height:"24px",type:"text",value:K,onChangeText:t=>{t.length&&t.trim().length?N(t):N("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!M&&!K.length&&!R&&t(S,{children:[e(p,{isChecked:!!(null==j?void 0:j[a]),isPartiallyChecked:(t=>{var e,o,i,c;let d=0,l=0;if(z){const c=null!==(e=null==y?void 0:y.products)&&void 0!==e?e:{};d=Object.keys(c).length;const n=null!==(i=null===(o=j[t])||void 0===o?void 0:o.products)&&void 0!==i?i:{};l=Object.keys(n).length}else if(j[t]){const e=null==y?void 0:y.products;e&&Object.keys(e).forEach((t=>{var o;const i=null===(o=e[t])||void 0===o?void 0:o.variants;i&&Object.keys(i).forEach((t=>d+=1))}));const o=null===(c=j[t])||void 0===c?void 0:c.products;o&&Object.keys(o).forEach((t=>{var e;const i=null===(e=o[t])||void 0===e?void 0:e.variants;i&&Object.keys(i).forEach((()=>l+=1))}))}return l>0&&d!==l})(a),onValueChange:function(t){I(t?{type:"selected",data:{id:a,val:y}}:{type:"unselected",data:{id:a}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(b,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e(D,{outOfStockAction:F,collectionId:a,isProductPartiallyChecked:Q(t),productId:t,data:G.products[t],selectedData:j,selectedCollectionsDispatch:I,viewOnly:!L&&!!M,upliftAdditions:Y,hideProductCheckbox:R,hideVariantCheckbox:H,hideProductVariants:z,pickerType:W},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e(m,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e(C,{title:"No products to show",subtitle:K.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})},D=o=>{const{collectionId:i,productId:c,data:d,selectedData:l,selectedCollectionsDispatch:n,viewOnly:r,upliftAdditions:s,isProductPartiallyChecked:a,hideProductCheckbox:u,outOfStockAction:p,hideVariantCheckbox:h,hideProductVariants:v,pickerType:m}=o,y=t=>{var e,o,d,n,r,s;if(!(null===(o=null===(e=null==l?void 0:l[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(s=null===(r=null===(n=null===(d=null==l?void 0:l[i])||void 0===d?void 0:d.products)||void 0===n?void 0:n[c])||void 0===r?void 0:r.variants)||void 0===s?void 0:s[t])};return t("div",{children:[e(E,{isVariant:!1,data:d,productId:c,collectionId:i,isSelected:!!(null===(g=null===(f=null==l?void 0:l[i])||void 0===f?void 0:f.products)||void 0===g?void 0:g[c]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:s,viewOnly:r,hideProductCheckbox:u,hideVariantCheckbox:h,hideProductVariants:v,pickerType:m},c),v?null:Object.keys(d.variants||[]).map((t=>e(E,{isVariant:!0,hideVariantCheckbox:h,data:d.variants[t],variantId:t,productId:c,viewOnly:r,upliftAdditions:s,collectionId:i,isSelected:y(t),selectedCollectionsDispatch:n,outOfStockAction:p},t)))]});var f,g},E=i=>{const{isVariant:c,data:d,productId:l,collectionId:n,variantId:r,isSelected:s,selectedCollectionsDispatch:u,viewOnly:h,upliftAdditions:v,isPartiallyChecked:m,hideProductCheckbox:f,outOfStockAction:k,hideVariantCheckbox:C,hideProductVariants:O,pickerType:x}=i,S=I.getProductLabels(d,k);return t(P,Object.assign({isVariant:c,onClick:t=>{if(t.stopPropagation(),"PRODUCT"===x)if(u({type:"reset",data:{}}),O)v("productSelected",{productId:l,variantId:r,collectionId:n});else{const t=Object.keys(d.variants);v("variantSelected",{productId:l,variantId:r||t[0],collectionId:n,variant:d})}},isActive:s},{children:[c&&!h&&!C||!c&&!h&&!f?e(p,{isChecked:s,isPartiallyChecked:m||!1,onValueChange:function(t){if(c)t?v(O?"productSelected":"variantSelected",{productId:l,variantId:r,collectionId:n,variant:d}):u({type:O?"productUnselected":"variantUnselected",data:{productId:l,variantId:r,collectionId:n}});else if(t){const t=Object.keys(d.variants);v(O?"productSelected":"variantSelected",{productId:l,collectionId:n,product:O?d.variants[t[0]]:d})}else u({type:O?"productUnselected":"variantUnselected",data:{productId:l,collectionId:n}})}}):e(o,{}),e("div",{children:e(y,{width:40,height:40,imageUrl:d.image,alt:"Item",borderRadius:4})}),e(g,Object.assign({body:d.name,placement:"bottom",delay:400},{children:t("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e(b,{children:j(d.name,40,!0)}),S?e("div",Object.assign({style:{width:90,display:"flex"}},{children:e(a,{tagText:S,type:"warning",theme:"light"})})):e(o,{})]}))}))]}))};export{E as ProductCard,D as ProductGroup,w as ProductsScreen};
1
+ import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import d from"../../assets/icons/search.svg.js";import{cloneDeep as r}from"lodash";import{useContext as n,useState as l,useEffect as s}from"react";import{Tag as a}from"../tag/Tag.js";import{COLORS as u}from"../../constants/Theme.js";import{CheckBox as p}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as v}from"../input/Input.js";import{BikShimmer as m}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as y}from"../shimmer-image/ShimmerImage.js";import{Spinner as f}from"../spinner/Spinner.js";import{Tooltip as g}from"../tooltips/Tooltip.js";import{BodyCaption as k,TitleRegular as b}from"../TypographyStyle.js";import{truncate as j}from"./collectionScreen.js";import{EmptyState as C}from"./emptyState.js";import{ProductHelper as I}from"./helpers/ProductHelper.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as x,ProductScreenCollectionCardStyle as P,ProductCardStyle as S}from"./style.js";import{OUT_OF_STOCK_ACTION as V}from"./type.js";import{liftTheStateUp as T}from"./utility.js";const w=o=>{const a=n(O),{data:y,collectionsDispatch:g,selectedData:j,selectedCollectionsDispatch:I,productFetcher:S,storeId:w,setScreen:E,setSaveDisabled:A,hideInCollectionSearch:B,customCollectionRestriction:U,hideProductCheckbox:R,outOfStockAction:F=V.BLUR,hideVariantCheckbox:H=!1,selectProductsFromCustomCollection:L=!1,pickerType:W,hideProductVariants:z}=o,[K,N]=l(""),[_,q]=l(!1),[G,J]=l(y);s((()=>{const t=setTimeout((()=>{K.length?(q(!0),o.searchInCollectionFetcher(w,a,K).then((t=>{var e;const o=r(y);o.products={};for(const i of t)(null===(e=null==y?void 0:y.products)||void 0===e?void 0:e[i])&&(o.products[i]=y.products[i]);J(o),A(!1),q(!1)}))):J(y)}),800);return()=>clearTimeout(t)}),[K]);const M=!!U&&y.isSmartCollection,Q=t=>{var e,o,i,c,d,r,n,l;let s=0,u=0;return!z&&!!((null===(o=null===(e=null==j?void 0:j[a])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(d=Object.keys((null===(c=null===(i=null==y?void 0:y.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>u++)),Object.keys((null===(l=null===(n=null===(r=null==j?void 0:j[a])||void 0===r?void 0:r.products)||void 0===n?void 0:n[t])||void 0===l?void 0:l.variants)||[]).forEach((()=>s++)),s>0&&u!==s))};s((()=>{(null==y?void 0:y.products)||X()}),[]);const X=()=>{A(!0),q(!0),S(a,w).then((t=>{Object.keys(t).length&&(g({type:"productsFetched",data:{collectionId:a,products:t}}),J(Object.assign(Object.assign({},G),{products:t}))),A(!1),q(!1)})).catch()},Y=(t,e)=>{const o=T(e,y);I({type:t,data:Object.assign(Object.assign({},o),{isRestricted:U})})};return t("div",{children:[t(x,{children:[e(h,{Icon:i,height:16,onClick:()=>{E("collections")}}),e(k,Object.assign({style:{color:u.content.secondary}},{children:y.name}))]}),!B&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(v,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&K.length?e(f,{size:"small",color:u.content.primary}):e(d,{})},id:"listInput",height:"24px",type:"text",value:K,onChangeText:t=>{t.length&&t.trim().length?N(t):N("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!M&&!K.length&&!R&&t(P,{children:[e(p,{isChecked:!!(null==j?void 0:j[a]),isPartiallyChecked:(t=>{var e;let o=0,i=0;if(j[t]){const c=null==y?void 0:y.products;c&&Object.keys(c).forEach((t=>{var e;const i=null===(e=c[t])||void 0===e?void 0:e.variants;i&&Object.keys(i).forEach((t=>o+=1))}));const d=null===(e=j[t])||void 0===e?void 0:e.products;return d&&Object.keys(d).forEach((t=>{var e;const o=null===(e=d[t])||void 0===e?void 0:e.variants;o&&Object.keys(o).forEach((()=>i+=1))})),i>0&&o!==i}return!1})(a),onValueChange:function(t){I(t?{type:"selected",data:{id:a,val:y}}:{type:"unselected",data:{id:a}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(b,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e(D,{outOfStockAction:F,collectionId:a,isProductPartiallyChecked:Q(t),productId:t,data:G.products[t],selectedData:j,selectedCollectionsDispatch:I,viewOnly:!L&&!!M,upliftAdditions:Y,hideProductCheckbox:R,hideVariantCheckbox:H,hideProductVariants:z,pickerType:W},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e(m,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e(C,{title:"No products to show",subtitle:K.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})},D=o=>{const{collectionId:i,productId:c,data:d,selectedData:r,selectedCollectionsDispatch:n,viewOnly:l,upliftAdditions:s,isProductPartiallyChecked:a,hideProductCheckbox:u,outOfStockAction:p,hideVariantCheckbox:h,hideProductVariants:v,pickerType:m}=o,y=t=>{var e,o,d,n,l,s;if(!(null===(o=null===(e=null==r?void 0:r[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(s=null===(l=null===(n=null===(d=null==r?void 0:r[i])||void 0===d?void 0:d.products)||void 0===n?void 0:n[c])||void 0===l?void 0:l.variants)||void 0===s?void 0:s[t])};return t("div",{children:[e(E,{isVariant:!1,data:d,productId:c,collectionId:i,isSelected:!!(null===(g=null===(f=null==r?void 0:r[i])||void 0===f?void 0:f.products)||void 0===g?void 0:g[c]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:s,viewOnly:l,hideProductCheckbox:u,hideVariantCheckbox:h,hideProductVariants:v,pickerType:m},c),v?null:Object.keys(d.variants||[]).map((t=>e(E,{isVariant:!0,hideVariantCheckbox:h,data:d.variants[t],variantId:t,productId:c,viewOnly:l,upliftAdditions:s,collectionId:i,isSelected:y(t),selectedCollectionsDispatch:n,outOfStockAction:p},t)))]});var f,g},E=i=>{const{isVariant:c,data:d,productId:r,collectionId:n,variantId:l,isSelected:s,selectedCollectionsDispatch:u,viewOnly:h,upliftAdditions:v,isPartiallyChecked:m,hideProductCheckbox:f,outOfStockAction:k,hideVariantCheckbox:C,hideProductVariants:O,pickerType:x}=i,P=I.getProductLabels(d,k);return t(S,Object.assign({isVariant:c,onClick:t=>{const e=Object.keys(d.variants);"PRODUCT"===x&&O&&(t.stopPropagation(),u({type:"reset",data:{}}),v("variantSelected",{productId:r,variantId:l||e[0],collectionId:n,variant:d.variants[e[0]]}))},isActive:s},{children:[c&&!h&&!C||!c&&!h&&!f?e(p,{isChecked:s,isPartiallyChecked:m||!1,onValueChange:function(t){if(c)t?v("variantSelected",{productId:r,variantId:l,collectionId:n,variant:d}):u({type:"variantUnselected",data:{productId:r,variantId:l,collectionId:n}});else if(t){const t=Object.keys(d.variants);v(O?"variantSelected":"productSelected",{productId:r,collectionId:n,product:O?d.variants[t[0]]:d})}else u({type:O?"variantUnselected":"productUnselected",data:{productId:r,collectionId:n}})}}):e(o,{}),e("div",{children:e(y,{width:40,height:40,imageUrl:d.image,alt:"Item",borderRadius:4})}),e(g,Object.assign({body:d.name,placement:"bottom",delay:400},{children:t("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e(b,{children:j(d.name,40,!0)}),P?e("div",Object.assign({style:{width:90,display:"flex"}},{children:e(a,{tagText:P,type:"warning",theme:"light"})})):e(o,{})]}))}))]}))};export{E as ProductCard,D as ProductGroup,w as ProductsScreen};
@@ -1 +1 @@
1
- import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function d(a,d){var e,o,l,s,c,r,i,u,n,v,p;let m={},O="",g="",C="";switch(d.type){case"selected":return m=t(a),d.data.val.isSmartCollection&&(d.data.isRestricted&&(m={}),m.isCustom=!0),m[d.data.id]=d.data.val,m;case"unselected":return m=t(a),(null==m?void 0:m.isCustom)&&(m.isCustom=!1),delete m[d.data.id],m;case"productUnselected":return m=t(a),O=d.data.productId,g=d.data.collectionId,delete m[g].products[O],Object.keys(m[g].products).length||((null==m?void 0:m.isCustom)&&(m.isCustom=!1),delete m[g]),m;case"productSelected":return m=t(a),O=d.data.productId,g=d.data.collectionId,(null===(e=d.data.catalogOnlyData)||void 0===e?void 0:e.isSmartCollection)&&(d.data.isRestricted&&(m={}),m.isCustom=!0),(null==m?void 0:m[g])||(m[g]=d.data.catalogOnlyData,m[g].products={}),m[g].products[O]=d.data.product,m;case"variantSelected":return m=t(a),O=d.data.productId,g=d.data.collectionId,C=d.data.variantId,(null===(o=d.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(d.data.isRestricted&&(m={}),m.isCustom=!0),(null==m?void 0:m[g])||(m[g]=d.data.catalogOnlyData,m[g].products={},m[g].products[O]=d.data.productOnlyData,m[g].products[O].variants={}),(null===(s=null===(l=null==m?void 0:m[g])||void 0===l?void 0:l.products)||void 0===s?void 0:s[O])||((null===(c=null==m?void 0:m[g])||void 0===c?void 0:c.products)||(m[g].products={}),m[g].products[O]=d.data.productOnlyData,m[g].products[O].variants={}),m[g].products[O].variants[C]=d.data.variant,m;case"variantUnselected":return m=t(a),O=d.data.productId,g=d.data.collectionId,C=d.data.variantId,(null===(i=null===(r=m[g].products[O])||void 0===r?void 0:r.variants)||void 0===i?void 0:i[C])&&delete m[g].products[O].variants[C],Object.keys(null!==(v=null===(n=null===(u=m[g].products)||void 0===u?void 0:u[O])||void 0===n?void 0:n.variants)&&void 0!==v?v:{}).length||(delete m[g].products[O],Object.keys(m[g].products).length||((null===(p=m[g])||void 0===p?void 0:p.isSmartCollection)&&(m.isCustom=!1),delete m[g])),m;case"reset":return{};default:return a}}function e(t,a){let d={};switch(a.type){case"fetched":return d=Object.assign({},a.data),d;case"productsFetched":return d=Object.assign({},t),d[a.data.collectionId].products=a.data.products,d;case"paged":return d=Object.assign(Object.assign({},t),a.data),d;default:return{}}}const o=a("");export{o as CollectionIdContext,e as collectionsReducer,d as selectedColectionsReducer};
1
+ import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function d(a,d){var e,o,c,s,r,l;let i={},u="",n="",p="";switch(d.type){case"selected":return i=t(a),d.data.val.isSmartCollection&&(d.data.isRestricted&&(i={}),i.isCustom=!0),i[d.data.id]=d.data.val,i;case"unselected":return i=t(a),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[d.data.id],i;case"productUnselected":return i=t(a),u=d.data.productId,n=d.data.collectionId,delete i[n].products[u],Object.keys(i[n].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[n]),i;case"productSelected":return i=t(a),u=d.data.productId,n=d.data.collectionId,(null===(e=d.data.catalogOnlyData)||void 0===e?void 0:e.isSmartCollection)&&(d.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[n])||(i[n]=d.data.catalogOnlyData,i[n].products={}),i[n].products[u]=d.data.product,i;case"variantSelected":return i=t(a),u=d.data.productId,n=d.data.collectionId,p=d.data.variantId,(null===(o=d.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(d.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[n])||(i[n]=d.data.catalogOnlyData,i[n].products={},i[n].products[u]=d.data.productOnlyData,i[n].products[u].variants={}),(null===(s=null===(c=null==i?void 0:i[n])||void 0===c?void 0:c.products)||void 0===s?void 0:s[u])||((null===(r=null==i?void 0:i[n])||void 0===r?void 0:r.products)||(i[n].products={}),i[n].products[u]=d.data.productOnlyData,i[n].products[u].variants={}),i[n].products[u].variants[p]=d.data.variant,i;case"variantUnselected":return i=t(a),u=d.data.productId,n=d.data.collectionId,p=d.data.variantId,delete i[n].products[u].variants[p],Object.keys(i[n].products[u].variants).length||(delete i[n].products[u],Object.keys(i[n].products).length||((null===(l=i[n])||void 0===l?void 0:l.isSmartCollection)&&(i.isCustom=!1),delete i[n])),i;case"reset":return{};default:return a}}function e(t,a){let d={};switch(a.type){case"fetched":return d=Object.assign({},a.data),d;case"productsFetched":return d=Object.assign({},t),d[a.data.collectionId].products=a.data.products,d;case"paged":return d=Object.assign(Object.assign({},t),a.data),d;default:return{}}}const o=a("");export{o as CollectionIdContext,e as collectionsReducer,d as selectedColectionsReducer};
@@ -8,7 +8,6 @@ interface SelectedScreenInterface {
8
8
  collections: {
9
9
  [key: string]: Collection;
10
10
  };
11
- hideProductVariants?: boolean;
12
11
  }
13
12
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
14
13
  export {};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as t,Fragment as e}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as r}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{AllProductHelper as c}from"./helpers/AllProductHelper.js";import{ProductGroup as s}from"./productScreen.js";import{SelectedScreenHeader as n}from"./style.js";const u=u=>{const{selectedCollections:v,selectedCollectionsDispatch:a,setScreen:p,collections:m,hideProductVariants:h=!1}=u,j=(o,t)=>{var e,l,i,r,d,c,s,n,u;let a=0,p=0;return!!((null===(l=null===(e=null==v?void 0:v[o])||void 0===e?void 0:e.products)||void 0===l?void 0:l[t])&&(null===(c=Object.keys((null===(d=null===(r=null===(i=null==m?void 0:m[o])||void 0===i?void 0:i.products)||void 0===r?void 0:r[t])||void 0===d?void 0:d.variants)||[]))||void 0===c||c.forEach((()=>p++)),Object.keys((null===(u=null===(n=null===(s=null==v?void 0:v[o])||void 0===s?void 0:s.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&p!==a))},f=h?c.removeDuplicatesForAllProducts(Object.assign({},v)):v;return o("div",{children:[o(n,{children:[t(i,{Icon:l,onClick:()=>{p("collections")}}),t(r,{children:"Selected Products"})]}),t("div",{children:Object.keys(f).length>0?t(e,{children:Object.keys(f).map((o=>{var e;return Object.keys((null===(e=null==f?void 0:f[o])||void 0===e?void 0:e.products)||[]).map((e=>{let l=!1;return(null==f?void 0:f.isCustom)&&(l=!0),t(s,{upliftAdditions:null,collectionId:o,productId:e,data:f[o].products[e],isProductPartiallyChecked:j(o,e),selectedData:f,selectedCollectionsDispatch:a,viewOnly:l,hideProductVariants:h},e)}))}))}):t(d,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};export{u as SelectedScreen};
1
+ import{jsxs as o,jsx as t,Fragment as l}from"react/jsx-runtime";import e from"../../assets/icons/arrow_left.svg.js";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as r}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as c}from"./productScreen.js";import{SelectedScreenHeader as n}from"./style.js";const s=s=>{const{selectedCollections:u,selectedCollectionsDispatch:v,setScreen:p,collections:a}=s,m=(o,t)=>{var l,e,i,r,d,c,n,s,v;let p=0,m=0;return!!((null===(e=null===(l=null==u?void 0:u[o])||void 0===l?void 0:l.products)||void 0===e?void 0:e[t])&&(null===(c=Object.keys((null===(d=null===(r=null===(i=null==a?void 0:a[o])||void 0===i?void 0:i.products)||void 0===r?void 0:r[t])||void 0===d?void 0:d.variants)||[]))||void 0===c||c.forEach((()=>m++)),Object.keys((null===(v=null===(s=null===(n=null==u?void 0:u[o])||void 0===n?void 0:n.products)||void 0===s?void 0:s[t])||void 0===v?void 0:v.variants)||[]).forEach((()=>p++)),p>0&&m!==p))};return o("div",{children:[o(n,{children:[t(i,{Icon:e,onClick:()=>{p("collections")}}),t(r,{children:"Selected Products"})]}),t("div",{children:Object.keys(u).length>0?t(l,{children:Object.keys(u).map((o=>{var l;return Object.keys((null===(l=null==u?void 0:u[o])||void 0===l?void 0:l.products)||[]).map((l=>{let e=!1;return(null==u?void 0:u.isCustom)&&(e=!0),t(c,{upliftAdditions:null,collectionId:o,productId:l,data:u[o].products[l],isProductPartiallyChecked:m(o,l),selectedData:u,selectedCollectionsDispatch:v,viewOnly:e},l)}))}))}):t(d,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};export{s as SelectedScreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.435-0",
3
+ "version": "0.0.435-beta.0",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +0,0 @@
1
- import { SelectedItems } from '../modal';
2
- export declare class AllProductHelper {
3
- static removeDuplicatesForAllProducts(productItems: SelectedItems): SelectedItems;
4
- }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.AllProductHelper=class{static removeDuplicatesForAllProducts(s){var e,t;const c=Object.assign({},s);if(!(null==c?void 0:c[-1])||!(null==c?void 0:c[-1].products))return c;let o=[];const r=Object.keys(null!==(t=null===(e=c[-1])||void 0===e?void 0:e.products)&&void 0!==t?t:{});for(const s in c)if("-1"!==s){const e=c[s].products;Object.keys(null!=e?e:{}).forEach((s=>{r.includes(s)&&o.push(s)}))}o=Array.from(new Set(o));const n=Object.assign({},c[-1]),l=Object.assign({},n.products);return o.forEach((s=>delete l[s])),Object.assign(Object.assign({},c),{"-1":Object.assign(Object.assign({},n),{products:Object.assign({},l)})})}};
@@ -1,4 +0,0 @@
1
- import { SelectedItems } from '../modal';
2
- export declare class AllProductHelper {
3
- static removeDuplicatesForAllProducts(productItems: SelectedItems): SelectedItems;
4
- }
@@ -1 +0,0 @@
1
- class s{static removeDuplicatesForAllProducts(s){var t,c;const e=Object.assign({},s);if(!(null==e?void 0:e[-1])||!(null==e?void 0:e[-1].products))return e;let n=[];const o=Object.keys(null!==(c=null===(t=e[-1])||void 0===t?void 0:t.products)&&void 0!==c?c:{});for(const s in e)if("-1"!==s){const t=e[s].products;Object.keys(null!=t?t:{}).forEach((s=>{o.includes(s)&&n.push(s)}))}n=Array.from(new Set(n));const r=Object.assign({},e[-1]),i=Object.assign({},r.products);return n.forEach((s=>delete i[s])),Object.assign(Object.assign({},e),{"-1":Object.assign(Object.assign({},r),{products:Object.assign({},i)})})}}export{s as AllProductHelper};