@bikdotai/bik-component-library 0.0.455 → 0.0.456-1

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("@emotion/styled/base"),t=require("react/jsx-runtime"),c=require("../../../TypographyStyle.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const i=l(e).default("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}"}:{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdH1cbmA7XHJcbmV4cG9ydCBjb25zdCBMZWdlbmQgPSAoeyBjb2xvciwgdGV4dCB9KSA9PiB7XHJcbiAgICBjb25zdCB0b1VwcGVyQ2FzZSA9IChuYW1lKSA9PiB7XHJcbiAgICAgICAgcmV0dXJuIG5hbWUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBuYW1lLnNsaWNlKDEpO1xyXG4gICAgfTtcclxuICAgIHJldHVybiAoX2pzeHMoTGVnZW5kU3R5bGVkLCB7IGNoaWxkcmVuOiBbX2pzeChcImRpdlwiLCB7IGNsYXNzTmFtZTogJ2NvbG9yJywgc3R5bGU6IHsgYmFja2dyb3VuZENvbG9yOiBjb2xvciB9IH0pLCBfanN4KEJvZHlQcmltYXJ5LCBPYmplY3QuYXNzaWduKHsgY2xhc3NOYW1lOiAndGl0bGUnIH0sIHsgY2hpbGRyZW46IHRvVXBwZXJDYXNlKHRleHQpIH0pKV0gfSkpO1xyXG59O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1MZWdlbmQuanMubWFwIl19 */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});exports.Legend=e=>{let{color:l,text:a}=e;return t.jsxs(i,{children:[t.jsx("div",{className:"color",style:{backgroundColor:l}}),t.jsx(c.BodyPrimary,Object.assign({className:"title"},{children:(s=a,s.charAt(0).toUpperCase()+s.slice(1))}))]});var s};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@emotion/styled/base"),t=require("react/jsx-runtime"),c=require("../../../TypographyStyle.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=l(e).default("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}"}:{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblx0ZmxleC1kaXJlY3Rpb246IHJvdztcblx0ZmxleDogMTtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdFx0ZmxleDogMTtcblx0fVxuYDtcclxuZXhwb3J0IGNvbnN0IExlZ2VuZCA9ICh7IGNvbG9yLCB0ZXh0IH0pID0+IHtcclxuICAgIGNvbnN0IHRvVXBwZXJDYXNlID0gKG5hbWUpID0+IHtcclxuICAgICAgICByZXR1cm4gbmFtZS5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIG5hbWUuc2xpY2UoMSk7XHJcbiAgICB9O1xyXG4gICAgcmV0dXJuIChfanN4cyhMZWdlbmRTdHlsZWQsIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2xhc3NOYW1lOiAnY29sb3InLCBzdHlsZTogeyBiYWNrZ3JvdW5kQ29sb3I6IGNvbG9yIH0gfSksIF9qc3goQm9keVByaW1hcnksIE9iamVjdC5hc3NpZ24oeyBjbGFzc05hbWU6ICd0aXRsZScgfSwgeyBjaGlsZHJlbjogdG9VcHBlckNhc2UodGV4dCkgfSkpXSB9KSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPUxlZ2VuZC5qcy5tYXAiXX0= */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});exports.Legend=e=>{let{color:l,text:i}=e;return t.jsxs(o,{children:[t.jsx("div",{className:"color",style:{backgroundColor:l}}),t.jsx(c.BodyPrimary,Object.assign({className:"title"},{children:(a=i,a.charAt(0).toUpperCase()+a.slice(1))}))]});var a};
@@ -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"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),l=require("../shimmer/ShimmerComponent/BikShimmer.js"),c=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)return"";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:l,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:v,isDisabled:y,hideCollectionCheckbox:g,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(!y){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:l}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!g&&e.jsx(s.CheckBox,{isDisabled:y,isChecked:v,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:l}}:{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:[a.name&&e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]}))};exports.CollectionsScreen=t=>{var s;const{customCollectionRestriction:o,dataLoading:c,collections:r,selectedCollectionsDispatch:n,setCollectionId:d,selectedCollections:u,setScreen:p,collectionFetcher:C,collectionsDispatch:j,pagingControls:x,storeId:v,setSaveDisabled:y,hideCollectionCheckbox:g,renderWithoutModal:m,pickerType:b}=t,k=i.useRef(null),f=i.useRef(x.curPage),O=!!o&&(null==u?void 0:u.isCustom),[S,E]=i.useState(!1);i.useEffect((()=>{f.current=x.curPage}),[x.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&(y(!0),E(!0),C(f.current,v).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(f.current+1),E(!1),y(!1)})).catch())}),{threshold:1});return k.current&&e.observe(k.current),()=>{k.current&&e.unobserve(k.current)}}),[k]);const T=e=>{var t,i;let s=0,o=0;if(u[e]){const l=null===(t=r[e])||void 0===t?void 0:t.products;l&&Object.keys(l).forEach((e=>{var t;const i=null===(t=l[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const c=null===(i=u[e])||void 0===i?void 0:i.products;return 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))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[(null===(s=Object.keys(null!=r?r:{}))||void 0===s?void 0:s.length)?Object.keys(r).map((t=>e.jsx(h,{customCollectionRestriction:o,data:r[t],isDisabled:O&&!(null==u?void 0:u[t]),isChecked:!!(null==u?void 0:u[t]),isPartiallyChecked:T(t),selectedCollectionsDispatch:n,setCollectionId:d,setScreen:p,id:t,hideCollectionCheckbox:g,selectedCollections:u,renderWithoutModal:m,pickerType:b},t))):c?[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(l.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:k}),S&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
@@ -0,0 +1,4 @@
1
+ import { SelectedItems } from '../modal';
2
+ export declare class AllProductHelper {
3
+ static removeDuplicatesForAllProducts(productItems: SelectedItems): SelectedItems;
4
+ }
@@ -0,0 +1 @@
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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),r=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"),x=require("./selectedScreen.js"),g=require("./style.js"),C=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:b,zIndex:v,exactLimit:P,limit:f,hideCollectionCheckbox:k,hideProductCheckbox:O,outOfStockAction:T=C.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:F,hideSelectionCount:I,title:q,width:E,renderWithoutModal:w,onClickSave:D,pickerType:N,hideProductVariants:A=!1,startupScreen:$=exports.ScreenName.Collections,rearrangeEnabled:B,selectSingleItem:L=!1}=e,[M,V]=r.useReducer(p.collectionsReducer,{}),[_,z]=r.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes($)?$:exports.ScreenName.Collections),[G,H]=r.useState("grid"),[W,K]=r.useState(""),[U,Y]=r.useState(0),[J,Q]=r.useState(!1),[X,Z]=r.useState(0),[ee,te]=r.useState(""),[oe,re]=r.useState(!1),[ce,se]=r.useState(!1),[ne,ie]=r.useState(),[le,ae]=r.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{}),de=r.useRef(null);r.useEffect((()=>{Q(!0),se(!0),e.collectionFetcher(U,j).then((e=>{V({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Q(!1),Y((e=>e+1)),se(!1)})).catch()}),[]),r.useEffect((()=>{let e=0;Object.keys(le||[]).forEach((t=>{var o;Object.keys((null===(o=le[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r,c;Object.keys((null===(c=null===(r=le[t].products)||void 0===r?void 0:r[o])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),Z(e)})),r.useEffect((()=>{var t;W&&!(null===(t=null==M?void 0:M[W])||void 0===t?void 0:t.products)&&(Q(!0),e.productFetcher(W,j).then((e=>{Object.keys(e).length&&V({type:"productsFetched",data:{collectionId:W,products:e}}),Q(!1)})).catch())}),[W]),r.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==_&&(ee.length?(re(!0),e.searchFetcher(j,ee).then((e=>{ie(Object.assign({},e)),z("searchProducts"),Q(!1),re(!1)}))):z("collections"))}),800);return()=>clearTimeout(t)}),[ee]),r.useEffect((()=>{D&&(e.onAdd(le,X),ue())}),[D]),r.useEffect((()=>{L&&Object.keys(le||{}).length&&X&&(e.onAdd(le,X),ue())}),[L,le,X]);const ue=()=>{ae({type:"reset",data:{}})},he=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"===_||"searchProducts"===_)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>oe?t.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:ee,onChangeText:e=>{e.length&&e.trim().length?te(e):te("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:de},{children:["collections"===_&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ce,collections:M,selectedCollectionsDispatch:ae,setCollectionId:K,setScreen:z,selectedCollections:le,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:V,setSaveDisabled:Q,pagingControls:{curPage:U,setCurPage:Y},hideCollectionCheckbox:k,renderWithoutModal:w,pickerType:N}),"products"===_&&W&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:W},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:z,storeId:j,data:M[W],collectionsDispatch:V,selectedCollectionsDispatch:ae,selectedData:le,setSaveDisabled:Q,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:T,hideVariantCheckbox:R,selectProductsFromCustomCollection:F,renderWithoutModal:w,pickerType:N,hideProductVariants:A})})),"view"===_&&t.jsx(x.SelectedScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,collections:M}),"rearrange"===_&&t.jsx(h.RearrangeScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,outOfStockAction:T,rearrangeViewType:"grid"===G?"list":"grid",scrollContainerRef:de}),"searchProducts"===_&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:le||{},searchedCollections:ne||{},selectedCollectionsDispatch:ae,setScreen:z,collections:M,onBackPress:()=>{te(""),ie({})},pickerType:N,hideProductCheckbox:O,hideProductVariants:A,hideVariantCheckbox:R})]}))]});return t.jsx(t.Fragment,{children:w?he:t.jsx(i.StyledModal,Object.assign({zIndex:v,open:b,onClose:()=>{null==y||y(),ue()},headingTitle:q||("collections"===_||"products"===_?"Select Products":"view"===_?"Selected Products":"searchProducts"===_?"Searched Products":"rearrange"===_?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"480px"},headerRightCustomElement:"rearrange"===_?(console.log("ignore:",H),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:c.COLORS.surface.standard}:void 0,primaryButton:{buttonText:J?"Loading...":_===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:J||X<1||P&&X<P||!P&&f&&X>f||!1,onClick:()=>{e.onAdd(le,X),ue()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:I?t.jsx(t.Fragment,{}):P&&X>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):f&&X>f?t.jsx(a.Tag,{tagText:`You can only select ${f} products`,type:"negative"}):X>0?t.jsx(s.Button,{onClick:()=>{z(B?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:["rearrange","view"].includes(_)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(_)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:"tertiaryGray"})},{children:he}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),r=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"),g=require("./selectedScreen.js"),x=require("./style.js"),C=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:y,onClose:m,visible:v,zIndex:b,exactLimit:P,limit:f,hideCollectionCheckbox:k,hideProductCheckbox:O,outOfStockAction:T=C.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:F,hideSelectionCount:I,title:E,width:q,renderWithoutModal:w,onClickSave:D,pickerType:N,hideProductVariants:A=!1,startupScreen:V=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:B=!1}=e,[L,M]=r.useReducer(p.collectionsReducer,{}),[_,z]=r.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(V)?V:exports.ScreenName.Collections),[G,H]=r.useState("grid"),[W,K]=r.useState(""),[U,Y]=r.useState(0),[J,Q]=r.useState(!1),[X,Z]=r.useState(0),[ee,te]=r.useState(""),[oe,re]=r.useState(!1),[ce,se]=r.useState(!1),[ne,ie]=r.useState(),[le,ae]=r.useReducer(p.selectedColectionsReducer,Object.keys(y).length>0?y:{}),de=r.useRef(null);r.useEffect((()=>{Q(!0),se(!0),e.collectionFetcher(U,j).then((e=>{M({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Q(!1),Y((e=>e+1)),se(!1)})).catch()}),[]),r.useEffect((()=>{console.log({selectedCollections:le});let e=0;A?Object.keys(le||[]).forEach((t=>{var o;Object.keys((null===(o=le[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r;"-1"!==t&&le[-1]&&(null===(r=le[-1].products)||void 0===r?void 0:r[o])||(e+=1)}))})):Object.keys(le||[]).forEach((t=>{var o;Object.keys((null===(o=le[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r,c;Object.keys((null===(c=null===(r=le[t].products)||void 0===r?void 0:r[o])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),Z(e)}),[le,A]),r.useEffect((()=>{var t;W&&!(null===(t=null==L?void 0:L[W])||void 0===t?void 0:t.products)&&(Q(!0),e.productFetcher(W,j).then((e=>{Object.keys(e).length&&M({type:"productsFetched",data:{collectionId:W,products:e}}),Q(!1)})).catch())}),[W]),r.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==_&&(ee.length?(re(!0),e.searchFetcher(j,ee).then((e=>{ie(Object.assign({},e)),z("searchProducts"),Q(!1),re(!1)}))):z("collections"))}),800);return()=>clearTimeout(t)}),[ee]),r.useEffect((()=>{D&&(e.onAdd(le,X),ue())}),[D]),r.useEffect((()=>{B&&Object.keys(le||{}).length&&X&&(e.onAdd(le,X),ue())}),[B,le,X]);const ue=()=>{ae({type:"reset",data:{}})},he=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"===_||"searchProducts"===_)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>oe?t.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:ee,onChangeText:e=>{e.length&&e.trim().length?te(e):te("")}})}))}),t.jsxs(x.ScrollContainerStyle,Object.assign({ref:de},{children:["collections"===_&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ce,collections:L,selectedCollectionsDispatch:ae,setCollectionId:K,setScreen:z,selectedCollections:le,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:M,setSaveDisabled:Q,pagingControls:{curPage:U,setCurPage:Y},hideCollectionCheckbox:k,renderWithoutModal:w,pickerType:N}),"products"===_&&W&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:W},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:z,storeId:j,data:L[W],collectionsDispatch:M,selectedCollectionsDispatch:ae,selectedData:le,setSaveDisabled:Q,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:T,hideVariantCheckbox:R,selectProductsFromCustomCollection:F,renderWithoutModal:w,pickerType:N,hideProductVariants:A})})),"view"===_&&t.jsx(g.SelectedScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,collections:L,hideProductVariants:A}),"rearrange"===_&&t.jsx(h.RearrangeScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,outOfStockAction:T,rearrangeViewType:"grid"===G?"list":"grid",scrollContainerRef:de}),"searchProducts"===_&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:le||{},searchedCollections:ne||{},selectedCollectionsDispatch:ae,setScreen:z,collections:L,onBackPress:()=>{te(""),ie({})},pickerType:N,hideProductCheckbox:O,hideProductVariants:A,hideVariantCheckbox:R})]}))]});return t.jsx(t.Fragment,{children:w?he:t.jsx(i.StyledModal,Object.assign({zIndex:b,open:v,onClose:()=>{null==m||m(),ue()},headingTitle:E||("collections"===_||"products"===_?"Select Products":"view"===_?"Selected Products":"searchProducts"===_?"Searched Products":"rearrange"===_?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:q||"480px"},headerRightCustomElement:"rearrange"===_?(console.log("ignore:",H),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:c.COLORS.surface.standard}:void 0,primaryButton:{buttonText:J?"Loading...":_===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:J||X<1||P&&X<P||!P&&f&&X>f||!1,onClick:()=>{e.onAdd(le,X),ue()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:I?t.jsx(t.Fragment,{}):P&&X>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):f&&X>f?t.jsx(a.Tag,{tagText:`You can only select ${f} products`,type:"negative"}):X>0?t.jsx(s.Button,{onClick:()=>{z($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:["rearrange","view"].includes(_)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(_)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:"tertiaryGray"})},{children:he}))})};
@@ -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"),r=require("react"),d=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"),m=require("./type.js"),b=require("./utility.js");const O=t=>{const{collectionId:i,productId:o,data:c,selectedData:r,selectedCollectionsDispatch:d,viewOnly:s,upliftAdditions:l,isProductPartiallyChecked:n,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v}=t,j=e=>{var t,c,d,s,l,n;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===(n=null===(l=null===(s=null===(d=null==r?void 0:r[i])||void 0===d?void 0:d.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==r?void 0:r[i])||void 0===x?void 0:x.products)||void 0===y?void 0:y[o]),isPartiallyChecked:n,selectedCollectionsDispatch:d,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:d,outOfStockAction:u},t)))]});var x,y},I=t=>{const{isVariant:i,data:o,productId:c,collectionId:r,variantId:s,isSelected:n,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:y,hideProductCheckbox:C,outOfStockAction:m,hideVariantCheckbox:b,hideProductVariants:O,pickerType:I}=t,S=g.ProductHelper.getProductLabels(o,m);return e.jsxs(k.ProductCardStyle,Object.assign({isVariant:i,onClick:e=>{"PRODUCT"===I&&O&&(e.stopPropagation(),a({type:"reset",data:{}}),p("variantSelected",{productId:c,variantId:s||Object.keys(o.variants)[0],collectionId:r,variant:o}))},isActive:n},{children:[i&&!u&&!b||!i&&!u&&!C?e.jsx(l.CheckBox,{isChecked:n,isPartiallyChecked:y||!1,onValueChange:function(e){i?e?p("variantSelected",{productId:c,variantId:s,collectionId:r,variant:o}):a({type:"variantUnselected",data:{productId:c,variantId:s,collectionId:r}}):e?p("productSelected",{productId:c,collectionId:r,product:o}):a({type:"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)}),S?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(d.Tag,{tagText:S,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=O,exports.ProductsScreen=d=>{const h=r.useContext(C.CollectionIdContext),{data:v,collectionsDispatch:x,selectedData:g,selectedCollectionsDispatch:I,productFetcher:S,storeId:f,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}=d,[F,U]=r.useState(""),[_,H]=r.useState(!1),[L,K]=r.useState(v);r.useEffect((()=>{const e=setTimeout((()=>{F.length?(H(!0),d.searchInCollectionFetcher(f,h,F).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)}),[F]);const N=!!V&&v.isSmartCollection,W=e=>{var t,i,o,c,r,d,s,l;let n=0,a=0;return!!((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===(l=null===(s=null===(d=null==g?void 0:g[h])||void 0===d?void 0:d.products)||void 0===s?void 0:s[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};r.useEffect((()=>{(null==v?void 0:v.products)||z()}),[]);const z=()=>{q(!0),H(!0),S(h,f).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(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:()=>_&&F.length?e.jsx(p.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:F,onChangeText:e=>{e.length&&e.trim().length?U(e):U("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==L?void 0:L.products)||[]).length>0&&!N&&!F.length&&!E&&e.jsxs(k.ProductScreenCollectionCardStyle,{children:[e.jsx(l.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:F.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"),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 +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,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}};
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}};
@@ -8,6 +8,7 @@ interface SelectedScreenInterface {
8
8
  collections: {
9
9
  [key: string]: Collection;
10
10
  };
11
+ hideProductVariants?: boolean;
11
12
  }
12
13
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
13
14
  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"),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
+ "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 +1 @@
1
- import t from"@emotion/styled/base";import{jsxs as c,jsx as l}from"react/jsx-runtime";import{BodyPrimary as e}from"../../../TypographyStyle.js";const i=t("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}"}:{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdH1cbmA7XHJcbmV4cG9ydCBjb25zdCBMZWdlbmQgPSAoeyBjb2xvciwgdGV4dCB9KSA9PiB7XHJcbiAgICBjb25zdCB0b1VwcGVyQ2FzZSA9IChuYW1lKSA9PiB7XHJcbiAgICAgICAgcmV0dXJuIG5hbWUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBuYW1lLnNsaWNlKDEpO1xyXG4gICAgfTtcclxuICAgIHJldHVybiAoX2pzeHMoTGVnZW5kU3R5bGVkLCB7IGNoaWxkcmVuOiBbX2pzeChcImRpdlwiLCB7IGNsYXNzTmFtZTogJ2NvbG9yJywgc3R5bGU6IHsgYmFja2dyb3VuZENvbG9yOiBjb2xvciB9IH0pLCBfanN4KEJvZHlQcmltYXJ5LCBPYmplY3QuYXNzaWduKHsgY2xhc3NOYW1lOiAndGl0bGUnIH0sIHsgY2hpbGRyZW46IHRvVXBwZXJDYXNlKHRleHQpIH0pKV0gfSkpO1xyXG59O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1MZWdlbmQuanMubWFwIl19 */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),o=t=>{let{color:o,text:a}=t;return c(i,{children:[l("div",{className:"color",style:{backgroundColor:o}}),l(e,Object.assign({className:"title"},{children:(n=a,n.charAt(0).toUpperCase()+n.slice(1))}))]});var n};export{o as Legend};
1
+ import c from"@emotion/styled/base";import{jsxs as t,jsx as e}from"react/jsx-runtime";import{BodyPrimary as l}from"../../../TypographyStyle.js";const o=c("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}"}:{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblx0ZmxleC1kaXJlY3Rpb246IHJvdztcblx0ZmxleDogMTtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdFx0ZmxleDogMTtcblx0fVxuYDtcclxuZXhwb3J0IGNvbnN0IExlZ2VuZCA9ICh7IGNvbG9yLCB0ZXh0IH0pID0+IHtcclxuICAgIGNvbnN0IHRvVXBwZXJDYXNlID0gKG5hbWUpID0+IHtcclxuICAgICAgICByZXR1cm4gbmFtZS5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIG5hbWUuc2xpY2UoMSk7XHJcbiAgICB9O1xyXG4gICAgcmV0dXJuIChfanN4cyhMZWdlbmRTdHlsZWQsIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2xhc3NOYW1lOiAnY29sb3InLCBzdHlsZTogeyBiYWNrZ3JvdW5kQ29sb3I6IGNvbG9yIH0gfSksIF9qc3goQm9keVByaW1hcnksIE9iamVjdC5hc3NpZ24oeyBjbGFzc05hbWU6ICd0aXRsZScgfSwgeyBjaGlsZHJlbjogdG9VcHBlckNhc2UodGV4dCkgfSkpXSB9KSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPUxlZ2VuZC5qcy5tYXAiXX0= */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}),i=c=>{let{color:i,text:a}=c;return t(o,{children:[e("div",{className:"color",style:{backgroundColor:i}}),e(l,Object.assign({className:"title"},{children:(r=a,r.charAt(0).toUpperCase()+r.slice(1))}))]});var r};export{i as Legend};
@@ -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 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 u}from"./emptyState.js";import{CollectionCardStyle as m,CollectionCardInfoStyle as C,CollectionCardDetailStyle as v,CollectionNameHolder as b}from"./style.js";const g=(e,t,o)=>{if(!e)return"";if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},y=o=>{var i;const{customCollectionRestriction:l,dataLoading:n,collections:a,selectedCollectionsDispatch:h,setCollectionId:p,selectedCollections:m,setScreen:C,collectionFetcher:v,collectionsDispatch:b,pagingControls:g,storeId:y,setSaveDisabled:k,hideCollectionCheckbox:j,renderWithoutModal:x,pickerType:O}=o,E=c(null),I=c(g.curPage),T=!!l&&(null==m?void 0:m.isCustom),[S,D]=s(!1);r((()=>{I.current=g.curPage}),[g.curPage]),r((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&I.current>0&&(k(!0),D(!0),v(I.current,y).then((e=>{b({type:"paged",data:(null==e?void 0:e.collections)||{}}),g.setCurPage(I.current+1),D(!1),k(!1)})).catch())}),{threshold:1});return E.current&&e.observe(E.current),()=>{E.current&&e.unobserve(E.current)}}),[E]);const P=e=>{var t,o;let i=0,c=0;if(m[e]){const s=null===(t=a[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=m[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:[(null===(i=Object.keys(null!=a?a:{}))||void 0===i?void 0:i.length)?Object.keys(a).map((e=>t(f,{customCollectionRestriction:l,data:a[e],isDisabled:T&&!(null==m?void 0:m[e]),isChecked:!!(null==m?void 0:m[e]),isPartiallyChecked:P(e),selectedCollectionsDispatch:h,setCollectionId:p,setScreen:C,id:e,hideCollectionCheckbox:j,selectedCollections:m,renderWithoutModal:x,pickerType:O},e))):n?[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(u,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:E}),S&&[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:u,isPartiallyChecked:y,setScreen:f,id:k,isChecked:j,isDisabled:x,hideCollectionCheckbox:O,pickerType:E,selectedCollections:I}=c;return e(m,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 u(k);u(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}}),u(e?k:"")}}),t(v,{children:t(h,Object.assign({body:r.name,placement:"bottom",delay:400},{children:e(b,{children:[r.name&&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};
@@ -0,0 +1,4 @@
1
+ import { SelectedItems } from '../modal';
2
+ export declare class AllProductHelper {
3
+ static removeDuplicatesForAllProducts(productItems: SelectedItems): SelectedItems;
4
+ }
@@ -0,0 +1 @@
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};
@@ -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,useRef as s,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as C}from"./rearrangeScreen.js";import{collectionsReducer as y,selectedColectionsReducer as b,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as f}from"./searchScreen.js";import{SelectedScreen as S}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as P}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 T=T=>{const{storeId:I,selectedItems:O,onClose:F,visible:R,zIndex:w,exactLimit:D,limit:E,hideCollectionCheckbox:$,hideProductCheckbox:A,outOfStockAction:V=j.BLUR,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,hideSelectionCount:z,title:M,width:G,renderWithoutModal:H,onClickSave:W,pickerType:Y,hideProductVariants:K=!1,startupScreen:U=k.Collections,rearrangeEnabled:q,selectSingleItem:J=!1}=T,[N,Q]=r(y,{}),[X,Z]=i([k.Collections,k.RearrangeProducts].includes(U)?U:k.Collections),[_,ee]=i("grid"),[te,oe]=i(""),[ce,re]=i(0),[ie,se]=i(!1),[ne,le]=i(0),[de,ae]=i(""),[ue,he]=i(!1),[pe,me]=i(!1),[ge,Ce]=i(),[ye,be]=r(b,Object.keys(O).length>0?O:{}),ve=s(null);n((()=>{se(!0),me(!0),T.collectionFetcher(ce,I).then((e=>{Q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),se(!1),re((e=>e+1)),me(!1)})).catch()}),[]),n((()=>{let e=0;Object.keys(ye||[]).forEach((t=>{var o;Object.keys((null===(o=ye[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ye[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),le(e)})),n((()=>{var e;te&&!(null===(e=null==N?void 0:N[te])||void 0===e?void 0:e.products)&&(se(!0),T.productFetcher(te,I).then((e=>{Object.keys(e).length&&Q({type:"productsFetched",data:{collectionId:te,products:e}}),se(!1)})).catch())}),[te]),n((()=>{const e=setTimeout((()=>{"rearrange"!==X&&(de.length?(he(!0),T.searchFetcher(I,de).then((e=>{Ce(Object.assign({},e)),Z("searchProducts"),se(!1),he(!1)}))):Z("collections"))}),800);return()=>clearTimeout(e)}),[de]),n((()=>{W&&(T.onAdd(ye,ne),fe())}),[W]),n((()=>{J&&Object.keys(ye||{}).length&&ne&&(T.onAdd(ye,ne),fe())}),[J,ye,ne]);const fe=()=>{be({type:"reset",data:{}})},Se=e(x,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===X||"searchProducts"===X)&&t("div",Object.assign({style:{padding:H?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ue?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:de,onChangeText:e=>{e.length&&e.trim().length?ae(e):ae("")}})}))}),e(P,Object.assign({ref:ve},{children:["collections"===X&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:pe,collections:N,selectedCollectionsDispatch:be,setCollectionId:oe,setScreen:Z,selectedCollections:ye,collectionFetcher:T.collectionFetcher,storeId:I,collectionsDispatch:Q,setSaveDisabled:se,pagingControls:{curPage:ce,setCurPage:re},hideCollectionCheckbox:$,renderWithoutModal:H,pickerType:Y}),"products"===X&&te&&t(v.Provider,Object.assign({value:te},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:Z,storeId:I,data:N[te],collectionsDispatch:Q,selectedCollectionsDispatch:be,selectedData:ye,setSaveDisabled:se,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:A,outOfStockAction:V,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,renderWithoutModal:H,pickerType:Y,hideProductVariants:K})})),"view"===X&&t(S,{selectedCollections:ye||{},selectedCollectionsDispatch:be,setScreen:Z,collections:N}),"rearrange"===X&&t(C,{selectedCollections:ye||{},selectedCollectionsDispatch:be,setScreen:Z,outOfStockAction:V,rearrangeViewType:"grid"===_?"list":"grid",scrollContainerRef:ve}),"searchProducts"===X&&t(f,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ye||{},searchedCollections:ge||{},selectedCollectionsDispatch:be,setScreen:Z,collections:N,onBackPress:()=>{ae(""),Ce({})},pickerType:Y,hideProductCheckbox:A,hideProductVariants:K,hideVariantCheckbox:B})]}))]});return t(o,{children:H?Se:t(u,Object.assign({zIndex:w,open:R,onClose:()=>{null==F||F(),fe()},headingTitle:M||("collections"===X||"products"===X?"Select Products":"view"===X?"Selected Products":"searchProducts"===X?"Searched Products":"rearrange"===X?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:G||"480px"},headerRightCustomElement:"rearrange"===X?(console.log("ignore:",ee),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:{buttonText:ie?"Loading...":X===k.RearrangeProducts?"Done":"Add",disabled:ie||ne<1||D&&ne<D||!D&&E&&ne>E||!1,onClick:()=>{T.onAdd(ye,ne),fe()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:z?t(o,{}):D&&ne>D?t(p,{tagText:`You can only select ${D} products`,type:"negative"}):E&&ne>E?t(p,{tagText:`You can only select ${E} products`,type:"negative"}):t(d,ne>0?{onClick:()=>{Z(q?k.RearrangeProducts:k.SelectedProducts)},buttonText:D?`${ne}/${D} products selected`:`${ne} products selected`,buttonType:["rearrange","view"].includes(X)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(X)}:{disabled:!0,buttonText:D?`${ne}/${D} products selected`:`${ne} products selected`,buttonType:"tertiaryGray"})},{children:Se}))})};export{T 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 i,useRef as s,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as C}from"./rearrangeScreen.js";import{collectionsReducer as v,selectedColectionsReducer as y,CollectionIdContext as b}from"./reducers.js";import{SearchScreen as f}from"./searchScreen.js";import{SelectedScreen as S}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as x}from"./type.js";var P;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(P||(P={}));const T=T=>{const{storeId:I,selectedItems:O,onClose:F,visible:R,zIndex:w,exactLimit:D,limit:E,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:A=x.BLUR,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,hideSelectionCount:z,title:M,width:G,renderWithoutModal:H,onClickSave:W,pickerType:Y,hideProductVariants:K=!1,startupScreen:U=P.Collections,rearrangeEnabled:q,selectSingleItem:J=!1}=T,[N,Q]=r(v,{}),[X,Z]=i([P.Collections,P.RearrangeProducts].includes(U)?U:P.Collections),[_,ee]=i("grid"),[te,oe]=i(""),[ce,re]=i(0),[ie,se]=i(!1),[ne,le]=i(0),[de,ae]=i(""),[ue,he]=i(!1),[pe,me]=i(!1),[ge,Ce]=i(),[ve,ye]=r(y,Object.keys(O).length>0?O:{}),be=s(null);n((()=>{se(!0),me(!0),T.collectionFetcher(ce,I).then((e=>{Q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),se(!1),re((e=>e+1)),me(!1)})).catch()}),[]),n((()=>{console.log({selectedCollections:ve});let e=0;K?Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&ve[-1]&&(null===(c=ve[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ve[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),le(e)}),[ve,K]),n((()=>{var e;te&&!(null===(e=null==N?void 0:N[te])||void 0===e?void 0:e.products)&&(se(!0),T.productFetcher(te,I).then((e=>{Object.keys(e).length&&Q({type:"productsFetched",data:{collectionId:te,products:e}}),se(!1)})).catch())}),[te]),n((()=>{const e=setTimeout((()=>{"rearrange"!==X&&(de.length?(he(!0),T.searchFetcher(I,de).then((e=>{Ce(Object.assign({},e)),Z("searchProducts"),se(!1),he(!1)}))):Z("collections"))}),800);return()=>clearTimeout(e)}),[de]),n((()=>{W&&(T.onAdd(ve,ne),fe())}),[W]),n((()=>{J&&Object.keys(ve||{}).length&&ne&&(T.onAdd(ve,ne),fe())}),[J,ve,ne]);const fe=()=>{ye({type:"reset",data:{}})},Se=e(j,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===X||"searchProducts"===X)&&t("div",Object.assign({style:{padding:H?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ue?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:de,onChangeText:e=>{e.length&&e.trim().length?ae(e):ae("")}})}))}),e(k,Object.assign({ref:be},{children:["collections"===X&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:pe,collections:N,selectedCollectionsDispatch:ye,setCollectionId:oe,setScreen:Z,selectedCollections:ve,collectionFetcher:T.collectionFetcher,storeId:I,collectionsDispatch:Q,setSaveDisabled:se,pagingControls:{curPage:ce,setCurPage:re},hideCollectionCheckbox:V,renderWithoutModal:H,pickerType:Y}),"products"===X&&te&&t(b.Provider,Object.assign({value:te},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:Z,storeId:I,data:N[te],collectionsDispatch:Q,selectedCollectionsDispatch:ye,selectedData:ve,setSaveDisabled:se,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:A,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,renderWithoutModal:H,pickerType:Y,hideProductVariants:K})})),"view"===X&&t(S,{selectedCollections:ve||{},selectedCollectionsDispatch:ye,setScreen:Z,collections:N,hideProductVariants:K}),"rearrange"===X&&t(C,{selectedCollections:ve||{},selectedCollectionsDispatch:ye,setScreen:Z,outOfStockAction:A,rearrangeViewType:"grid"===_?"list":"grid",scrollContainerRef:be}),"searchProducts"===X&&t(f,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ve||{},searchedCollections:ge||{},selectedCollectionsDispatch:ye,setScreen:Z,collections:N,onBackPress:()=>{ae(""),Ce({})},pickerType:Y,hideProductCheckbox:$,hideProductVariants:K,hideVariantCheckbox:B})]}))]});return t(o,{children:H?Se:t(u,Object.assign({zIndex:w,open:R,onClose:()=>{null==F||F(),fe()},headingTitle:M||("collections"===X||"products"===X?"Select Products":"view"===X?"Selected Products":"searchProducts"===X?"Searched Products":"rearrange"===X?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:G||"480px"},headerRightCustomElement:"rearrange"===X?(console.log("ignore:",ee),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:{buttonText:ie?"Loading...":X===P.RearrangeProducts?"Done":"Add",disabled:ie||ne<1||D&&ne<D||!D&&E&&ne>E||!1,onClick:()=>{T.onAdd(ve,ne),fe()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:z?t(o,{}):D&&ne>D?t(p,{tagText:`You can only select ${D} products`,type:"negative"}):E&&ne>E?t(p,{tagText:`You can only select ${E} products`,type:"negative"}):t(d,ne>0?{onClick:()=>{Z(q?P.RearrangeProducts:P.SelectedProducts)},buttonText:D?`${ne}/${D} products selected`:`${ne} products selected`,buttonType:["rearrange","view"].includes(X)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(X)}:{disabled:!0,buttonText:D?`${ne}/${D} products selected`:`${ne} products selected`,buttonType:"tertiaryGray"})},{children:Se}))})};export{T as ProductPickerModal,P 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 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:R,hideProductCheckbox:U,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=!!R&&y.isSmartCollection,Q=t=>{var e,o,i,c,d,r,n,l;let s=0,u=0;return!!((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:R})})};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&&!U&&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:U,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=>{"PRODUCT"===x&&O&&(t.stopPropagation(),u({type:"reset",data:{}}),v("variantSelected",{productId:r,variantId:l||Object.keys(d.variants)[0],collectionId:n,variant:d}))},isActive:s},{children:[c&&!h&&!C||!c&&!h&&!f?e(p,{isChecked:s,isPartiallyChecked:m||!1,onValueChange:function(t){c?t?v("variantSelected",{productId:r,variantId:l,collectionId:n,variant:d}):u({type:"variantUnselected",data:{productId:r,variantId:l,collectionId:n}}):t?v("productSelected",{productId:r,collectionId:n,product:d}):u({type:"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
+ 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 +1 @@
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};
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};
@@ -8,6 +8,7 @@ interface SelectedScreenInterface {
8
8
  collections: {
9
9
  [key: string]: Collection;
10
10
  };
11
+ hideProductVariants?: boolean;
11
12
  }
12
13
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
13
14
  export {};
@@ -1 +1 @@
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};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.455",
3
+ "version": "0.0.456-1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",