@bikdotai/bik-component-library 0.0.159-beta.7 → 0.0.159-beta.9

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.
Files changed (25) hide show
  1. package/dist/cjs/assets/icons/box_round.svg.js +1 -0
  2. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +1 -0
  3. package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
  4. package/dist/cjs/components/product-picker-v2/emptyState.d.ts +7 -0
  5. package/dist/cjs/components/product-picker-v2/emptyState.js +7 -0
  6. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  7. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +2 -0
  8. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  9. package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
  10. package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
  11. package/dist/cjs/components/product-picker-v2/utility.d.ts +1 -1
  12. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  13. package/dist/esm/assets/icons/box_round.svg.js +1 -0
  14. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +1 -0
  15. package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
  16. package/dist/esm/components/product-picker-v2/emptyState.d.ts +7 -0
  17. package/dist/esm/components/product-picker-v2/emptyState.js +7 -0
  18. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  19. package/dist/esm/components/product-picker-v2/productScreen.d.ts +2 -0
  20. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  21. package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
  22. package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
  23. package/dist/esm/components/product-picker-v2/utility.d.ts +1 -1
  24. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  25. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,l.get?l:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t,r,l=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l])}return e},n.apply(this,arguments)}var a=e=>l.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 49 48"},e),t||(t=l.createElement("rect",{width:48,height:48,x:.5,fill:"#F0F0F0",rx:24})),r||(r=l.createElement("path",{fill:"#9E9E9E",fillRule:"evenodd",d:"M23.002 13.403a3 3 0 0 1 2.996 0H26l7 4a3 3 0 0 1 .937.85 1 1 0 0 1 .249.413 3 3 0 0 1 .314 1.333V28a3 3 0 0 1-1.5 2.595l-.004.002L26 34.596l-.002.001a3.001 3.001 0 0 1-1.023.363.996.996 0 0 1-.95 0 3 3 0 0 1-1.023-.363L23 34.596l-6.996-3.998-.004-.002A3 3 0 0 1 14.5 28v-8.002a3 3 0 0 1 .314-1.333 1.006 1.006 0 0 1 .249-.414 3 3 0 0 1 .937-.848l.004-.002 6.998-4ZM25.5 32.578l6.5-3.714.002-.001a1.001 1.001 0 0 0 .498-.864v-7.462l-7 4.05v7.991Zm-2-7.991v7.991L17 28.864l-.002-.001a1.001 1.001 0 0 1-.498-.864v-7.462l7 4.05Zm1.504-9.449 6.457 3.69-6.961 4.027-6.961-4.027 6.457-3.69.004-.002a1 1 0 0 1 1 0l.004.002Z",clipRule:"evenodd"})));exports.default=a;
@@ -3,6 +3,7 @@ import { Collection, CollectionFetcherReturn, SelectedItems } from '.';
3
3
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
4
4
  export declare const truncate: (str: string, n: number, useWordBoundary: boolean) => string;
5
5
  interface CollectionsScreenInterface {
6
+ dataLoading: boolean;
6
7
  collections: {
7
8
  [key: string]: Collection;
8
9
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),s=require("react"),r=require("../checkBox/CheckBox.js"),i=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),o=require("../tag/Tag.js"),n=require("../TypographyStyle.js"),l=require("./style.js");const a=(e,t,s)=>{if(e.length<=t)return e;const r=e.slice(0,t-1);return(s?r.slice(0,r.lastIndexOf(" ")):r)+"..."},d=s=>{const{data:c,selectedCollectionsDispatch:d,setCollectionId:u,isPartiallyChecked:h,setScreen:j,id:x,isChecked:p,isDisabled:C}=s;return e.jsxs(l.CollectionCardStyle,Object.assign({isDisabled:C},{children:[e.jsxs(l.CollectionCardInfoStyle,{children:[e.jsx(r.CheckBox,{isDisabled:C,isChecked:p,isPartiallyChecked:h,onValueChange:function(e,t){d(e?{type:"selected",data:{id:x,val:c}}:{type:"unselected",data:{id:x}}),u(e?x:"")}}),e.jsx(l.CollectionCardDetailStyle,{children:e.jsxs(l.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:a(c.name,40,!0)}),c.isSmartCollection?e.jsx(o.Tag,{tagText:"Smart Collection",type:"warning"}):e.jsx(e.Fragment,{})]})})]}),e.jsx(i.IconButton,{onClick:()=>{C||(u(x),j("products"))},Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{collections:r,selectedCollectionsDispatch:i,setCollectionId:o,selectedCollections:n,setScreen:l,collectionFetcher:a,collectionsDispatch:u,pagingControls:h,storeId:j,setSaveDisabled:x}=t,p=s.useRef(null),C=s.useRef(h.curPage),v=(null==n?void 0:n.isCustom)||!1,[g,m]=s.useState(!1);s.useEffect((()=>{C.current=h.curPage}),[h.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&C.current>0&&(x(!0),m(!0),a(C.current,j).then((e=>{u({type:"paged",data:(null==e?void 0:e.collections)||{}}),h.setCurPage(C.current+1),m(!1),x(!1)})).catch())}),{threshold:1});return p.current&&e.observe(p.current),()=>{p.current&&e.unobserve(p.current)}}),[p]);const b=e=>{var t,s;let i=0,c=0;if(n[e]){const o=null===(t=r[e])||void 0===t?void 0:t.products;o&&Object.keys(o).forEach((e=>{var t;const s=null===(t=o[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))}));const l=null===(s=n[e])||void 0===s?void 0:s.products;return l&&Object.keys(l).forEach((e=>{var t;const s=null===(t=l[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>c+=1))})),!(i<=0&&c>0)&&(c>0&&i!==c)}return!1};return e.jsxs("div",{children:[Object.keys(r).length?Object.keys(r).map((t=>e.jsx(d,{data:r[t],isDisabled:v&&!(null==n?void 0:n[t]),isChecked:!!(null==n?void 0:n[t]),isPartiallyChecked:b(t),selectedCollectionsDispatch:i,setCollectionId:o,setScreen:l,id:t},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))),e.jsx("div",{ref:p}),g&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),s=require("react"),i=require("../checkBox/CheckBox.js"),r=require("../icon-button/IconButton.js"),o=require("../shimmer/ShimmerComponent/BikShimmer.js"),c=require("../tag/Tag.js"),n=require("../TypographyStyle.js"),l=require("./emptyState.js"),a=require("./style.js");const d=(e,t,s)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(s?i.slice(0,i.lastIndexOf(" ")):i)+"..."},u=s=>{const{data:o,selectedCollectionsDispatch:l,setCollectionId:u,isPartiallyChecked:h,setScreen:j,id:x,isChecked:p,isDisabled:C}=s;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:C},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[e.jsx(i.CheckBox,{isDisabled:C,isChecked:p,isPartiallyChecked:h,onValueChange:function(e,t){l(e?{type:"selected",data:{id:x,val:o}}:{type:"unselected",data:{id:x}}),u(e?x:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsxs(a.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:d(o.name,40,!0)}),o.isSmartCollection?e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"}):e.jsx(e.Fragment,{})]})})]}),e.jsx(r.IconButton,{onClick:()=>{C||(u(x),j("products"))},Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{dataLoading:i,collections:r,selectedCollectionsDispatch:c,setCollectionId:n,selectedCollections:a,setScreen:d,collectionFetcher:h,collectionsDispatch:j,pagingControls:x,storeId:p,setSaveDisabled:C}=t,v=s.useRef(null),g=s.useRef(x.curPage),m=(null==a?void 0:a.isCustom)||!1,[y,b]=s.useState(!1);s.useEffect((()=>{g.current=x.curPage}),[x.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&g.current>0&&(C(!0),b(!0),h(g.current,p).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(g.current+1),b(!1),C(!1)})).catch())}),{threshold:1});return v.current&&e.observe(v.current),()=>{v.current&&e.unobserve(v.current)}}),[v]);const f=e=>{var t,s;let i=0,o=0;if(a[e]){const c=null===(t=r[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const s=null===(t=c[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))}));const n=null===(s=a[e])||void 0===s?void 0:s.products;return n&&Object.keys(n).forEach((e=>{var t;const s=null===(t=n[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>o+=1))})),!(i<=0&&o>0)&&(o>0&&i!==o)}return!1};return e.jsxs("div",{children:[Object.keys(r).length?Object.keys(r).map((t=>e.jsx(u,{data:r[t],isDisabled:m&&!(null==a?void 0:a[t]),isChecked:!!(null==a?void 0:a[t]),isPartiallyChecked:f(t),selectedCollectionsDispatch:c,setCollectionId:n,setScreen:d,id:t},t))):i?[1,2,3,4,5,6,7,8,9,10].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(o.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))):e.jsx(l.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:v}),y&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(o.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=d;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface EmptyStateProps {
3
+ title: string;
4
+ subtitle: string;
5
+ }
6
+ export declare const EmptyState: ({ title, subtitle }: EmptyStateProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/box_round.svg.js"),r=require("styled-components"),s=require("../../constants/Theme.js"),n=require("../TypographyStyle.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=i(r).default.div`
2
+ height: 400px;
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: center;
6
+ justify-content: center;
7
+ `;exports.EmptyState=r=>{let{title:i,subtitle:l}=r;return e.jsxs(o,{children:[e.jsx(t.default,{width:48,height:48}),e.jsx(n.TitleRegular,Object.assign({style:{marginTop:8}},{children:i})),e.jsx(n.BodySecondary,Object.assign({style:{color:s.COLORS.content.secondary,marginTop:4}},{children:l}))]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/search.svg.js"),c=require("react"),s=require("../../constants/Theme.js"),o=require("../button/Button.js"),r=require("../input/Input.js"),l=require("../modals/styledModal.js"),n=require("../spinner/Spinner.js"),i=require("../tag/Tag.js"),d=require("./collectionScreen.js"),a=require("./productScreen.js"),u=require("./reducers.js"),h=require("./searchScreen.js"),p=require("./selectedScreen.js"),j=require("./style.js");exports.ProductPickerModal=S=>{const{storeId:x,selectedItems:v,onClose:y,visible:C,zIndex:g,limit:b}=S,[f,q]=c.useReducer(u.collectionsReducer,{}),[I,P]=c.useState("collections"),[T,m]=c.useState(""),[E,O]=c.useState(0),[F,k]=c.useState(!1),[D,B]=c.useState(0),[w,R]=c.useState(""),[M,z]=c.useState(!1),[L,$]=c.useState(),[A,G]=c.useReducer(u.selectedColectionsReducer,Object.keys(v).length>0?v:{});c.useEffect((()=>{k(!0),S.collectionFetcher(E,x).then((e=>{q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),k(!1),O((e=>e+1))})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(A||[]).forEach((t=>{var c;Object.keys((null===(c=A[t])||void 0===c?void 0:c.products)||[]).forEach((c=>{var s,o;Object.keys((null===(o=null===(s=A[t].products)||void 0===s?void 0:s[c])||void 0===o?void 0:o.variants)||[]).forEach((()=>{e+=1}))}))})),B(e)})),c.useEffect((()=>{var e;T&&!(null===(e=null==f?void 0:f[T])||void 0===e?void 0:e.products)&&(k(!0),S.productFetcher(T,x).then((e=>{Object.keys(e).length&&q({type:"productsFetched",data:{collectionId:T,products:e}}),k(!1)})).catch())}),[T]),c.useEffect((()=>{const e=setTimeout((()=>{w.length&&(z(!0),S.searchFetcher(x,w).then((e=>{$(e),P("searchProducts"),k(!1),z(!1)})))}),800);return()=>clearTimeout(e)}),[w]);const _=()=>{G({type:"reset",data:{}})};return e.jsx(l.StyledModal,Object.assign({zIndex:g,open:C,onClose:()=>{y(),_()},headingTitle:"collections"===I||"products"===I?"Select Products":"view"===I?"Selected Products":"searchProducts"===I?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:F?"Loading...":"Add",disabled:F||b&&D>b||!1,onClick:()=>{S.onAdd(A,D),_()}},footerLeftCustomElement:b&&D>b?e.jsx(i.Tag,{tagText:`You can only select ${b} products`,type:"negative"}):D>0?e.jsx(o.Button,{onClick:()=>{P("view")},buttonText:`${D} products selected`,buttonType:"tertiaryGray"}):e.jsx(o.Button,{disabled:!0,buttonText:`${D} products selected`,buttonType:"tertiaryGray"})},{children:e.jsxs(j.ContainerStyle,{children:[("collections"===I||"searchProducts"===I)&&e.jsx("div",Object.assign({style:{padding:16,paddingTop:0,height:"60px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.Input,{rightIcon:{icon:()=>M?e.jsx(n.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:w,onChangeText:e=>{R(e)},placeholder:"Search products..."})})),e.jsxs(j.ScrollContainerStyle,{children:["collections"===I&&e.jsx(d.CollectionsScreen,{collections:f,selectedCollectionsDispatch:G,setCollectionId:m,setScreen:P,selectedCollections:A,collectionFetcher:S.collectionFetcher,storeId:x,collectionsDispatch:q,setSaveDisabled:k,pagingControls:{curPage:E,setCurPage:O}}),"products"===I&&T&&e.jsx(u.CollectionIdContext.Provider,Object.assign({value:T},{children:e.jsx(a.ProductsScreen,{productFetcher:S.productFetcher,setScreen:P,storeId:x,data:f[T],collectionsDispatch:q,selectedCollectionsDispatch:G,selectedData:A,setSaveDisabled:k,searchInCollectionFetcher:S.searchInCollectionFetcher})})),"view"===I&&e.jsx(p.SelectedScreen,{selectedCollections:A||{},selectedCollectionsDispatch:G,setScreen:P,collections:f}),"searchProducts"===I&&e.jsx(h.SearchScreen,{selectedCollections:A||{},searchedCollections:L||{},selectedCollectionsDispatch:G,setScreen:P,collections:f,onBackPress:()=>R("")})]})]})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/search.svg.js"),c=require("react"),s=require("../../constants/Theme.js"),o=require("../button/Button.js"),r=require("../input/Input.js"),l=require("../modals/styledModal.js"),n=require("../spinner/Spinner.js"),i=require("../tag/Tag.js"),d=require("./collectionScreen.js"),a=require("./productScreen.js"),u=require("./reducers.js"),h=require("./searchScreen.js"),p=require("./selectedScreen.js"),j=require("./style.js");exports.ProductPickerModal=S=>{const{storeId:x,selectedItems:v,onClose:y,visible:C,zIndex:g,limit:b}=S,[f,q]=c.useReducer(u.collectionsReducer,{}),[I,P]=c.useState("collections"),[T,m]=c.useState(""),[E,O]=c.useState(0),[F,k]=c.useState(!1),[D,B]=c.useState(0),[w,R]=c.useState(""),[L,M]=c.useState(!1),[z,$]=c.useState(!1),[A,G]=c.useState(),[_,Y]=c.useReducer(u.selectedColectionsReducer,Object.keys(v).length>0?v:{});c.useEffect((()=>{k(!0),$(!0),S.collectionFetcher(E,x).then((e=>{q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),k(!1),O((e=>e+1)),$(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(_||[]).forEach((t=>{var c;Object.keys((null===(c=_[t])||void 0===c?void 0:c.products)||[]).forEach((c=>{var s,o;Object.keys((null===(o=null===(s=_[t].products)||void 0===s?void 0:s[c])||void 0===o?void 0:o.variants)||[]).forEach((()=>{e+=1}))}))})),B(e)})),c.useEffect((()=>{var e;T&&!(null===(e=null==f?void 0:f[T])||void 0===e?void 0:e.products)&&(k(!0),S.productFetcher(T,x).then((e=>{Object.keys(e).length&&q({type:"productsFetched",data:{collectionId:T,products:e}}),k(!1)})).catch())}),[T]),c.useEffect((()=>{const e=setTimeout((()=>{w.length&&(M(!0),S.searchFetcher(x,w).then((e=>{G(e),P("searchProducts"),k(!1),M(!1)})))}),800);return()=>clearTimeout(e)}),[w]);const H=()=>{Y({type:"reset",data:{}})};return e.jsx(l.StyledModal,Object.assign({zIndex:g,open:C,onClose:()=>{y(),H()},headingTitle:"collections"===I||"products"===I?"Select Products":"view"===I?"Selected Products":"searchProducts"===I?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:F?"Loading...":"Add",disabled:F||b&&D>b||!1,onClick:()=>{S.onAdd(_,D),H()}},footerLeftCustomElement:b&&D>b?e.jsx(i.Tag,{tagText:`You can only select ${b} products`,type:"negative"}):D>0?e.jsx(o.Button,{onClick:()=>{P("view")},buttonText:`${D} products selected`,buttonType:"tertiaryGray"}):e.jsx(o.Button,{disabled:!0,buttonText:`${D} products selected`,buttonType:"tertiaryGray"})},{children:e.jsxs(j.ContainerStyle,{children:[("collections"===I||"searchProducts"===I)&&e.jsx("div",Object.assign({style:{padding:16,paddingTop:0,height:"60px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.Input,{rightIcon:{icon:()=>L?e.jsx(n.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:w,onChangeText:e=>{R(e)},placeholder:"Search products..."})})),e.jsxs(j.ScrollContainerStyle,{children:["collections"===I&&e.jsx(d.CollectionsScreen,{dataLoading:z,collections:f,selectedCollectionsDispatch:Y,setCollectionId:m,setScreen:P,selectedCollections:_,collectionFetcher:S.collectionFetcher,storeId:x,collectionsDispatch:q,setSaveDisabled:k,pagingControls:{curPage:E,setCurPage:O}}),"products"===I&&T&&e.jsx(u.CollectionIdContext.Provider,Object.assign({value:T},{children:e.jsx(a.ProductsScreen,{productFetcher:S.productFetcher,setScreen:P,storeId:x,data:f[T],collectionsDispatch:q,selectedCollectionsDispatch:Y,selectedData:_,setSaveDisabled:k,searchInCollectionFetcher:S.searchInCollectionFetcher})})),"view"===I&&e.jsx(p.SelectedScreen,{selectedCollections:_||{},selectedCollectionsDispatch:Y,setScreen:P,collections:f}),"searchProducts"===I&&e.jsx(h.SearchScreen,{selectedCollections:_||{},searchedCollections:A||{},selectedCollectionsDispatch:Y,setScreen:P,collections:f,onBackPress:()=>{R(""),G({})}})]})]})}))};
@@ -21,6 +21,7 @@ interface ProductGroupInterface {
21
21
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
22
22
  viewOnly: boolean;
23
23
  isProductPartiallyChecked?: boolean;
24
+ upliftAdditions: any;
24
25
  }
25
26
  export declare const ProductGroup: (props: ProductGroupInterface) => JSX.Element;
26
27
  interface ProductCardInterface {
@@ -33,6 +34,7 @@ interface ProductCardInterface {
33
34
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
34
35
  viewOnly: boolean;
35
36
  isPartiallyChecked?: boolean;
37
+ upliftAdditions: any;
36
38
  }
37
39
  export declare const ProductCard: (props: ProductCardInterface) => JSX.Element;
38
40
  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"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),s=require("lodash"),c=require("react"),r=require("../../constants/Theme.js"),d=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),n=require("../input/Input.js"),a=require("../shimmer/ShimmerComponent/BikShimmer.js"),u=require("../shimmer-image/ShimmerImage.js"),v=require("../spinner/Spinner.js"),h=require("../TypographyStyle.js"),p=require("./collectionScreen.js"),j=require("./reducers.js"),x=require("./style.js"),y=require("./utility.js");const m=t=>{const{collectionId:i,productId:o,data:s,selectedData:c,selectedCollectionsDispatch:r,viewOnly:d,isProductPartiallyChecked:l}=t,n=e=>{var t,s,r,d,l,n;if(!(null===(s=null===(t=null==c?void 0:c[i])||void 0===t?void 0:t.products)||void 0===s?void 0:s[o]))return!1;return!!(null===(n=null===(l=null===(d=null===(r=null==c?void 0:c[i])||void 0===r?void 0:r.products)||void 0===d?void 0:d[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:s,productId:o,collectionId:i,isSelected:!!(null===(u=null===(a=null==c?void 0:c[i])||void 0===a?void 0:a.products)||void 0===u?void 0:u[o]),isPartiallyChecked:l,selectedCollectionsDispatch:r,viewOnly:d},o),Object.keys(s.variants||[]).map((t=>e.jsx(I,{isVariant:!0,data:s.variants[t],variantId:t,productId:o,viewOnly:d,collectionId:i,isSelected:n(t),selectedCollectionsDispatch:r},t)))]});var a,u},I=t=>{const{isVariant:i,data:o,productId:s,collectionId:c,variantId:r,isSelected:l,selectedCollectionsDispatch:n,viewOnly:a,isPartiallyChecked:v}=t;return e.jsxs(x.ProductCardStyle,Object.assign({isVariant:i},{children:[a?e.jsx(e.Fragment,{}):e.jsx(d.CheckBox,{isChecked:l,isPartiallyChecked:v||!1,onValueChange:function(e){if(i)if(e){const e=y.upliftAdditions({productId:s,variantId:r,collectionId:c,variant:o},o);n({type:"variantSelected",data:e})}else n({type:"variantUnselected",data:{productId:s,variantId:r,collectionId:c}});else if(e){const e=y.upliftAdditions({productId:s,collectionId:c,product:o},o);n({type:"productSelected",data:e})}else n({type:"productUnselected",data:{productId:s,collectionId:c}})}}),e.jsx("div",{children:e.jsx(u.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(h.TitleRegular,{children:p.truncate(o.name,40,!0)})]}))};exports.ProductCard=I,exports.ProductGroup=m,exports.ProductsScreen=u=>{const p=c.useContext(j.CollectionIdContext),{data:y,collectionsDispatch:I,selectedData:g,selectedCollectionsDispatch:C,productFetcher:S,storeId:O,setScreen:f,setSaveDisabled:b}=u,[k,q]=c.useState(""),[P,E]=c.useState(!1),[D,B]=c.useState(y);c.useEffect((()=>{const e=setTimeout((()=>{k.length?(E(!0),u.searchInCollectionFetcher(O,p,k).then((e=>{var t;const i=s.cloneDeep(y);i.products={};for(const o of e)(null===(t=null==y?void 0:y.products)||void 0===t?void 0:t[o])&&(i.products[o]=y.products[o]);B(i),b(!1),E(!1)}))):B(y)}),800);return()=>clearTimeout(e)}),[k]);const w=y.isSmartCollection||!1,T=e=>{var t,i,o,s,c,r,d,l;let n=0,a=0;return!!((null===(i=null===(t=null==g?void 0:g[p])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(c=Object.keys((null===(s=null===(o=null==y?void 0:y.products)||void 0===o?void 0:o[e])||void 0===s?void 0:s.variants)||[]))||void 0===c||c.forEach((()=>a++)),Object.keys((null===(l=null===(d=null===(r=null==g?void 0:g[p])||void 0===r?void 0:r.products)||void 0===d?void 0:d[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};c.useEffect((()=>{(null==y?void 0:y.products)||V()}),[]);const V=()=>{b(!0),S(p,O).then((e=>{Object.keys(e).length&&(I({type:"productsFetched",data:{collectionId:p,products:e}}),B(Object.assign(Object.assign({},D),{products:e}))),b(!1),E(!1)})).catch()};return e.jsxs("div",{children:[e.jsxs(x.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{f("collections")}}),e.jsx(h.BodyCaption,Object.assign({style:{color:r.COLORS.content.secondary}},{children:y.name}))]}),e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(n.Input,{rightIcon:{icon:()=>P?e.jsx(v.Spinner,{size:"small",color:r.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:k,onChangeText:e=>{q(e)},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[e.jsxs(x.ProductScreenCollectionCardStyle,{children:[w?e.jsx(e.Fragment,{}):e.jsx(d.CheckBox,{isChecked:!!(null==g?void 0:g[p]),isPartiallyChecked:(e=>{var t;let i=0,o=0;if(g[e]){const s=null==y?void 0:y.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 c=null===(t=g[e])||void 0===t?void 0:t.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))})),o>0&&i!==o}return!1})(p),onValueChange:function(e){C(e?{type:"selected",data:{id:p,val:y}}:{type:"unselected",data:{id:p}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(h.TitleRegular,{children:"All Products"})]}),Object.keys((null==D?void 0:D.products)||[]).length&&!P?Object.keys(D.products||[]).map((t=>e.jsx(m,{collectionId:p,isProductPartiallyChecked:T(t),productId:t,data:D.products[t],selectedData:g,selectedCollectionsDispatch:C,viewOnly:!!w},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(a.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})]})};
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"),s=require("lodash"),d=require("react"),l=require("../../constants/Theme.js"),c=require("../checkBox/CheckBox.js"),r=require("../icon-button/IconButton.js"),n=require("../input/Input.js"),a=require("../shimmer/ShimmerComponent/BikShimmer.js"),u=require("../shimmer-image/ShimmerImage.js"),v=require("../spinner/Spinner.js"),p=require("../TypographyStyle.js"),h=require("./collectionScreen.js"),j=require("./emptyState.js"),x=require("./reducers.js"),y=require("./style.js"),g=require("./utility.js");const m=t=>{const{collectionId:i,productId:o,data:s,selectedData:d,selectedCollectionsDispatch:l,viewOnly:c,upliftAdditions:r,isProductPartiallyChecked:n}=t,a=e=>{var t,s,l,c,r,n;if(!(null===(s=null===(t=null==d?void 0:d[i])||void 0===t?void 0:t.products)||void 0===s?void 0:s[o]))return!1;return!!(null===(n=null===(r=null===(c=null===(l=null==d?void 0:d[i])||void 0===l?void 0:l.products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:s,productId:o,collectionId:i,isSelected:!!(null===(v=null===(u=null==d?void 0:d[i])||void 0===u?void 0:u.products)||void 0===v?void 0:v[o]),isPartiallyChecked:n,selectedCollectionsDispatch:l,upliftAdditions:r,viewOnly:c},o),Object.keys(s.variants||[]).map((t=>e.jsx(I,{isVariant:!0,data:s.variants[t],variantId:t,productId:o,viewOnly:c,upliftAdditions:r,collectionId:i,isSelected:a(t),selectedCollectionsDispatch:l},t)))]});var u,v},I=t=>{const{isVariant:i,data:o,productId:s,collectionId:d,variantId:l,isSelected:r,selectedCollectionsDispatch:n,viewOnly:a,upliftAdditions:v,isPartiallyChecked:j}=t;return e.jsxs(y.ProductCardStyle,Object.assign({isVariant:i},{children:[a?e.jsx(e.Fragment,{}):e.jsx(c.CheckBox,{isChecked:r,isPartiallyChecked:j||!1,onValueChange:function(e){i?e?v("variantSelected",{productId:s,variantId:l,collectionId:d,variant:o}):n({type:"variantUnselected",data:{productId:s,variantId:l,collectionId:d}}):e?v("productSelected",{productId:s,collectionId:d,product:o}):n({type:"productUnselected",data:{productId:s,collectionId:d}})}}),e.jsx("div",{children:e.jsx(u.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(p.TitleRegular,{children:h.truncate(o.name,40,!0)})]}))};exports.ProductCard=I,exports.ProductGroup=m,exports.ProductsScreen=u=>{const h=d.useContext(x.CollectionIdContext),{data:I,collectionsDispatch:C,selectedData:S,selectedCollectionsDispatch:f,productFetcher:O,storeId:b,setScreen:k,setSaveDisabled:q}=u,[P,E]=d.useState(""),[D,w]=d.useState(!1),[B,T]=d.useState(I);d.useEffect((()=>{const e=setTimeout((()=>{P.length?(w(!0),u.searchInCollectionFetcher(b,h,P).then((e=>{var t;const i=s.cloneDeep(I);i.products={};for(const o of e)(null===(t=null==I?void 0:I.products)||void 0===t?void 0:t[o])&&(i.products[o]=I.products[o]);T(i),q(!1),w(!1)}))):T(I)}),800);return()=>clearTimeout(e)}),[P]);const A=I.isSmartCollection||!1,V=e=>{var t,i,o,s,d,l,c,r;let n=0,a=0;return!!((null===(i=null===(t=null==S?void 0:S[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(d=Object.keys((null===(s=null===(o=null==I?void 0:I.products)||void 0===o?void 0:o[e])||void 0===s?void 0:s.variants)||[]))||void 0===d||d.forEach((()=>a++)),Object.keys((null===(r=null===(c=null===(l=null==S?void 0:S[h])||void 0===l?void 0:l.products)||void 0===c?void 0:c[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};d.useEffect((()=>{(null==I?void 0:I.products)||R()}),[]);const R=()=>{q(!0),w(!0),O(h,b).then((e=>{Object.keys(e).length&&(C({type:"productsFetched",data:{collectionId:h,products:e}}),T(Object.assign(Object.assign({},B),{products:e}))),q(!1),w(!1)})).catch()},F=(e,t)=>{const i=g.liftTheStateUp(t,I);f({type:e,data:i})};return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(r.IconButton,{Icon:t.default,height:16,onClick:()=>{k("collections")}}),e.jsx(p.BodyCaption,Object.assign({style:{color:l.COLORS.content.secondary}},{children:I.name}))]}),e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(n.Input,{rightIcon:{icon:()=>D&&P.length?e.jsx(v.Spinner,{size:"small",color:l.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:P,onChangeText:e=>{E(e)},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==B?void 0:B.products)||[]).length>0&&!A&&!P.length&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(c.CheckBox,{isChecked:!!(null==S?void 0:S[h]),isPartiallyChecked:(e=>{var t;let i=0,o=0;if(S[e]){const s=null==I?void 0:I.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 d=null===(t=S[e])||void 0===t?void 0:t.products;return d&&Object.keys(d).forEach((e=>{var t;const i=null===(t=d[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),o>0&&i!==o}return!1})(h),onValueChange:function(e){f(e?{type:"selected",data:{id:h,val:I}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(p.TitleRegular,{children:"All Products"})]}),Object.keys((null==B?void 0:B.products)||[]).length?Object.keys(B.products||[]).map((t=>e.jsx(m,{collectionId:h,isProductPartiallyChecked:V(t),productId:t,data:B.products[t],selectedData:S,selectedCollectionsDispatch:f,viewOnly:!!A,upliftAdditions:F},t))):D?[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(a.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(j.EmptyState,{title:"No products to show",subtitle:P.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 e=require("react/jsx-runtime"),o=require("../../assets/icons/arrow_left.svg.js"),l=require("../icon-button/IconButton.js"),r=require("../TypographyStyle.js"),t=require("./productScreen.js"),i=require("./style.js");exports.SearchScreen=s=>{const{selectedCollections:c,searchedCollections:d,selectedCollectionsDispatch:n,setScreen:u,collections:v,onBackPress:a}=s,p=(e,o)=>{var l,r,t,i,s,d,n,u,a;let p=0,j=0;return!!((null===(r=null===(l=null==c?void 0:c[e])||void 0===l?void 0:l.products)||void 0===r?void 0:r[o])&&(null===(d=Object.keys((null===(s=null===(i=null===(t=null==v?void 0:v[e])||void 0===t?void 0:t.products)||void 0===i?void 0:i[o])||void 0===s?void 0:s.variants)||[]))||void 0===d||d.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[o])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))};return e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:o.default,onClick:()=>{u("collections"),a()}}),e.jsx(r.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(d).map((o=>{var l;return Object.keys((null===(l=null==d?void 0:d[o])||void 0===l?void 0:l.products)||[]).map((l=>{let r=!1;return(null==d?void 0:d.isCustom)&&(r=!0),e.jsx(t.ProductGroup,{collectionId:o,productId:l,data:d[o].products[l],isProductPartiallyChecked:p(o,l),selectedData:c,selectedCollectionsDispatch:n,viewOnly:r},l)}))}))})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("../icon-button/IconButton.js"),l=require("../TypographyStyle.js"),r=require("./emptyState.js"),i=require("./productScreen.js"),s=require("./style.js"),d=require("./utility.js");exports.SearchScreen=c=>{const{selectedCollections:n,searchedCollections:u,selectedCollectionsDispatch:a,setScreen:v,collections:p,onBackPress:j}=c,h=(e,t)=>{var o,l,r,i,s,d,c,u,a;let v=0,j=0;return!!((null===(l=null===(o=null==n?void 0:n[e])||void 0===o?void 0:o.products)||void 0===l?void 0:l[t])&&(null===(d=Object.keys((null===(s=null===(i=null===(r=null==p?void 0:p[e])||void 0===r?void 0:r.products)||void 0===i?void 0:i[t])||void 0===s?void 0:s.variants)||[]))||void 0===d||d.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(c=null==n?void 0:n[e])||void 0===c?void 0:c.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>v++)),v>0&&j!==v))};return e.jsxs("div",{children:[e.jsxs(s.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{v("collections"),j()}}),e.jsx(l.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(u).length?e.jsx(e.Fragment,{children:Object.keys(u).map((t=>{var o;return Object.keys((null===(o=null==u?void 0:u[t])||void 0===o?void 0:o.products)||[]).map((o=>{let l=!1;return(null==u?void 0:u.isCustom)&&(l=!0),e.jsx(i.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{const l=d.liftTheStateUp(o,u[e]);a({type:t,data:l})})(t,e,o),productId:o,data:u[t].products[o],isProductPartiallyChecked:h(t,o),selectedData:n,selectedCollectionsDispatch:a,viewOnly:l},o)}))}))}):e.jsx(r.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("../../assets/icons/arrow_left.svg.js"),l=require("../icon-button/IconButton.js"),t=require("../TypographyStyle.js"),r=require("./productScreen.js"),i=require("./style.js");exports.SelectedScreen=d=>{const{selectedCollections:c,selectedCollectionsDispatch:s,setScreen:n,collections:u}=d,v=(e,o)=>{var l,t,r,i,d,s,n,v,a;let p=0,j=0;return!!((null===(t=null===(l=null==c?void 0:c[e])||void 0===l?void 0:l.products)||void 0===t?void 0:t[o])&&(null===(s=Object.keys((null===(d=null===(i=null===(r=null==u?void 0:u[e])||void 0===r?void 0:r.products)||void 0===i?void 0:i[o])||void 0===d?void 0:d.variants)||[]))||void 0===s||s.forEach((()=>j++)),Object.keys((null===(a=null===(v=null===(n=null==c?void 0:c[e])||void 0===n?void 0:n.products)||void 0===v?void 0:v[o])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))};return e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:o.default,onClick:()=>{n("collections")}}),e.jsx(t.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(c).map((o=>{var l;return Object.keys((null===(l=null==c?void 0:c[o])||void 0===l?void 0:l.products)||[]).map((l=>{let t=!1;return(null==c?void 0:c.isCustom)&&(t=!0),e.jsx(r.ProductGroup,{collectionId:o,productId:l,data:c[o].products[l],isProductPartiallyChecked:v(o,l),selectedData:c,selectedCollectionsDispatch:s,viewOnly:t},l)}))}))})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),l=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),r=require("./emptyState.js"),i=require("./productScreen.js"),d=require("./style.js");exports.SelectedScreen=s=>{const{selectedCollections:c,selectedCollectionsDispatch:n,setScreen:u,collections:v}=s,a=(e,t)=>{var l,o,r,i,d,s,n,u,a;let p=0,j=0;return!!((null===(o=null===(l=null==c?void 0:c[e])||void 0===l?void 0:l.products)||void 0===o?void 0:o[t])&&(null===(s=Object.keys((null===(d=null===(i=null===(r=null==v?void 0:v[e])||void 0===r?void 0:r.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===s||s.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(n=null==c?void 0:c[e])||void 0===n?void 0:n.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))};return e.jsxs("div",{children:[e.jsxs(d.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{u("collections")}}),e.jsx(o.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(c).length>0?e.jsx(e.Fragment,{children:Object.keys(c).map((t=>{var l;return Object.keys((null===(l=null==c?void 0:c[t])||void 0===l?void 0:l.products)||[]).map((l=>{let o=!1;return(null==c?void 0:c.isCustom)&&(o=!0),e.jsx(i.ProductGroup,{upliftAdditions:null,collectionId:t,productId:l,data:c[t].products[l],isProductPartiallyChecked:a(t,l),selectedData:c,selectedCollectionsDispatch:n,viewOnly:o},l)}))}))}):e.jsx(r.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};
@@ -1 +1 @@
1
- export declare const upliftAdditions: (payload: any, data: any) => any;
1
+ export declare const liftTheStateUp: (payload: any, data: any) => any;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");exports.upliftAdditions=(e,s)=>{const a=t.cloneDeep(s);if(delete a.products,(e=Object.assign(Object.assign({},e),{catalogOnlyData:a})).productId&&s.products){const o=t.cloneDeep(s.products[e.productId]);(null==o?void 0:o.variants)&&delete o.variants,e=Object.assign(Object.assign({},e),{catalogOnlyData:a,productOnlyData:o})}return e};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash");exports.liftTheStateUp=(t,a)=>{const s=e.cloneDeep(a);if(delete s.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:s})).productId&&a.products){const c=e.cloneDeep(a.products[t.productId]);(null==c?void 0:c.variants)&&delete c.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:s,productOnlyData:c})}return t};
@@ -0,0 +1 @@
1
+ import*as e from"react";var l,t;function a(){return a=Object.assign?Object.assign.bind():function(e){for(var l=1;l<arguments.length;l++){var t=arguments[l];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},a.apply(this,arguments)}var r=r=>e.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 49 48"},r),l||(l=e.createElement("rect",{width:48,height:48,x:.5,fill:"#F0F0F0",rx:24})),t||(t=e.createElement("path",{fill:"#9E9E9E",fillRule:"evenodd",d:"M23.002 13.403a3 3 0 0 1 2.996 0H26l7 4a3 3 0 0 1 .937.85 1 1 0 0 1 .249.413 3 3 0 0 1 .314 1.333V28a3 3 0 0 1-1.5 2.595l-.004.002L26 34.596l-.002.001a3.001 3.001 0 0 1-1.023.363.996.996 0 0 1-.95 0 3 3 0 0 1-1.023-.363L23 34.596l-6.996-3.998-.004-.002A3 3 0 0 1 14.5 28v-8.002a3 3 0 0 1 .314-1.333 1.006 1.006 0 0 1 .249-.414 3 3 0 0 1 .937-.848l.004-.002 6.998-4ZM25.5 32.578l6.5-3.714.002-.001a1.001 1.001 0 0 0 .498-.864v-7.462l-7 4.05v7.991Zm-2-7.991v7.991L17 28.864l-.002-.001a1.001 1.001 0 0 1-.498-.864v-7.462l7 4.05Zm1.504-9.449 6.457 3.69-6.961 4.027-6.961-4.027 6.457-3.69.004-.002a1 1 0 0 1 1 0l.004.002Z",clipRule:"evenodd"})));export{r as default};
@@ -3,6 +3,7 @@ import { Collection, CollectionFetcherReturn, SelectedItems } from '.';
3
3
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
4
4
  export declare const truncate: (str: string, n: number, useWordBoundary: boolean) => string;
5
5
  interface CollectionsScreenInterface {
6
+ dataLoading: boolean;
6
7
  collections: {
7
8
  [key: string]: Collection;
8
9
  };
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../assets/icons/chevronRight.svg.js";import{useRef as i,useState as s,useEffect as c}from"react";import{CheckBox as n}from"../checkBox/CheckBox.js";import{IconButton as l}from"../icon-button/IconButton.js";import{BikShimmer as a}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as d}from"../tag/Tag.js";import{TitleRegular as h}from"../TypographyStyle.js";import{CollectionCardStyle as u,CollectionCardInfoStyle as m,CollectionCardDetailStyle as p,CollectionNameHolder as v}from"./style.js";const g=(e,t,o)=>{if(e.length<=t)return e;const r=e.slice(0,t-1);return(o?r.slice(0,r.lastIndexOf(" ")):r)+"..."},b=o=>{const{collections:r,selectedCollectionsDispatch:n,setCollectionId:l,selectedCollections:d,setScreen:h,collectionFetcher:u,collectionsDispatch:m,pagingControls:p,storeId:v,setSaveDisabled:g}=o,b=i(null),y=i(p.curPage),f=(null==d?void 0:d.isCustom)||!1,[j,k]=s(!1);c((()=>{y.current=p.curPage}),[p.curPage]),c((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&y.current>0&&(g(!0),k(!0),u(y.current,v).then((e=>{m({type:"paged",data:(null==e?void 0:e.collections)||{}}),p.setCurPage(y.current+1),k(!1),g(!1)})).catch())}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b]);const x=e=>{var t,o;let i=0,s=0;if(d[e]){const c=null===(t=r[e])||void 0===t?void 0:t.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 n=null===(o=d[e])||void 0===o?void 0:o.products;return n&&Object.keys(n).forEach((e=>{var t;const o=null===(t=n[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>s+=1))})),!(i<=0&&s>0)&&(s>0&&i!==s)}return!1};return e("div",{children:[Object.keys(r).length?Object.keys(r).map((e=>t(C,{data:r[e],isDisabled:f&&!(null==d?void 0:d[e]),isChecked:!!(null==d?void 0:d[e]),isPartiallyChecked:x(e),selectedCollectionsDispatch:n,setCollectionId:l,setScreen:h,id:e},e))):[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))),t("div",{ref:b}),j&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},C=i=>{const{data:s,selectedCollectionsDispatch:c,setCollectionId:a,isPartiallyChecked:b,setScreen:C,id:y,isChecked:f,isDisabled:j}=i;return e(u,Object.assign({isDisabled:j},{children:[e(m,{children:[t(n,{isDisabled:j,isChecked:f,isPartiallyChecked:b,onValueChange:function(e,t){c(e?{type:"selected",data:{id:y,val:s}}:{type:"unselected",data:{id:y}}),a(e?y:"")}}),t(p,{children:e(v,{children:[t(h,{children:g(s.name,40,!0)}),s.isSmartCollection?t(d,{tagText:"Smart Collection",type:"warning"}):t(o,{})]})})]}),t(l,{onClick:()=>{j||(a(y),C("products"))},Icon:r})]}))};export{b 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 r,useState as s,useEffect as c}from"react";import{CheckBox as n}from"../checkBox/CheckBox.js";import{IconButton as l}from"../icon-button/IconButton.js";import{BikShimmer as a}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as d}from"../tag/Tag.js";import{TitleRegular as h}from"../TypographyStyle.js";import{EmptyState as u}from"./emptyState.js";import{CollectionCardStyle as m,CollectionCardInfoStyle as p,CollectionCardDetailStyle as v,CollectionNameHolder as g}from"./style.js";const b=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},C=o=>{const{dataLoading:i,collections:n,selectedCollectionsDispatch:l,setCollectionId:d,selectedCollections:h,setScreen:m,collectionFetcher:p,collectionsDispatch:v,pagingControls:g,storeId:b,setSaveDisabled:C}=o,f=r(null),j=r(g.curPage),k=(null==h?void 0:h.isCustom)||!1,[x,O]=s(!1);c((()=>{j.current=g.curPage}),[g.curPage]),c((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&j.current>0&&(C(!0),O(!0),p(j.current,b).then((e=>{v({type:"paged",data:(null==e?void 0:e.collections)||{}}),g.setCurPage(j.current+1),O(!1),C(!1)})).catch())}),{threshold:1});return f.current&&e.observe(f.current),()=>{f.current&&e.unobserve(f.current)}}),[f]);const E=e=>{var t,o;let i=0,r=0;if(h[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 c=null===(o=h[e])||void 0===o?void 0:o.products;return 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=>r+=1))})),!(i<=0&&r>0)&&(r>0&&i!==r)}return!1};return e("div",{children:[Object.keys(n).length?Object.keys(n).map((e=>t(y,{data:n[e],isDisabled:k&&!(null==h?void 0:h[e]),isChecked:!!(null==h?void 0:h[e]),isPartiallyChecked:E(e),selectedCollectionsDispatch:l,setCollectionId:d,setScreen:m,id:e},e))):i?[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{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:f}),x&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},y=r=>{const{data:s,selectedCollectionsDispatch:c,setCollectionId:a,isPartiallyChecked:u,setScreen:C,id:y,isChecked:f,isDisabled:j}=r;return e(m,Object.assign({isDisabled:j},{children:[e(p,{children:[t(n,{isDisabled:j,isChecked:f,isPartiallyChecked:u,onValueChange:function(e,t){c(e?{type:"selected",data:{id:y,val:s}}:{type:"unselected",data:{id:y}}),a(e?y:"")}}),t(v,{children:e(g,{children:[t(h,{children:b(s.name,40,!0)}),s.isSmartCollection?t(d,{tagText:"Smart Collection",type:"warning"}):t(o,{})]})})]}),t(l,{onClick:()=>{j||(a(y),C("products"))},Icon:i})]}))};export{C as CollectionsScreen,b as truncate};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface EmptyStateProps {
3
+ title: string;
4
+ subtitle: string;
5
+ }
6
+ export declare const EmptyState: ({ title, subtitle }: EmptyStateProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/box_round.svg.js";import r from"styled-components";import{COLORS as i}from"../../constants/Theme.js";import{TitleRegular as n,BodySecondary as s}from"../TypographyStyle.js";const c=r=>{let{title:c,subtitle:l}=r;return t(m,{children:[e(o,{width:48,height:48}),e(n,Object.assign({style:{marginTop:8}},{children:c})),e(s,Object.assign({style:{color:i.content.secondary,marginTop:4}},{children:l}))]})},m=r.div`
2
+ height: 400px;
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: center;
6
+ justify-content: center;
7
+ `;export{c as EmptyState};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useEffect as r}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as i}from"../button/Button.js";import{Input as n}from"../input/Input.js";import{StyledModal as d}from"../modals/styledModal.js";import{Spinner as a}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as h}from"./collectionScreen.js";import{ProductsScreen as u}from"./productScreen.js";import{collectionsReducer as m,selectedColectionsReducer as v,CollectionIdContext as g}from"./reducers.js";import{SearchScreen as y}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as b}from"./style.js";const C=C=>{const{storeId:S,selectedItems:x,onClose:I,visible:T,zIndex:P,limit:F}=C,[D,k]=c(m,{}),[O,E]=s("collections"),[w,B]=s(""),[z,$]=s(0),[A,G]=s(!1),[L,M]=s(0),[Y,q]=s(""),[H,J]=s(!1),[K,N]=s(),[Q,R]=c(v,Object.keys(x).length>0?x:{});r((()=>{G(!0),C.collectionFetcher(z,S).then((e=>{k({type:"fetched",data:(null==e?void 0:e.collections)||{}}),G(!1),$((e=>e+1))})).catch()}),[]),r((()=>{let e=0;Object.keys(Q||[]).forEach((t=>{var o;Object.keys((null===(o=Q[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=Q[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),M(e)})),r((()=>{var e;w&&!(null===(e=null==D?void 0:D[w])||void 0===e?void 0:e.products)&&(G(!0),C.productFetcher(w,S).then((e=>{Object.keys(e).length&&k({type:"productsFetched",data:{collectionId:w,products:e}}),G(!1)})).catch())}),[w]),r((()=>{const e=setTimeout((()=>{Y.length&&(J(!0),C.searchFetcher(S,Y).then((e=>{N(e),E("searchProducts"),G(!1),J(!1)})))}),800);return()=>clearTimeout(e)}),[Y]);const U=()=>{R({type:"reset",data:{}})};return e(d,Object.assign({zIndex:P,open:T,onClose:()=>{I(),U()},headingTitle:"collections"===O||"products"===O?"Select Products":"view"===O?"Selected Products":"searchProducts"===O?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:A?"Loading...":"Add",disabled:A||F&&L>F||!1,onClick:()=>{C.onAdd(Q,L),U()}},footerLeftCustomElement:F&&L>F?e(p,{tagText:`You can only select ${F} products`,type:"negative"}):e(i,L>0?{onClick:()=>{E("view")},buttonText:`${L} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${L} products selected`,buttonType:"tertiaryGray"})},{children:t(j,{children:[("collections"===O||"searchProducts"===O)&&e("div",Object.assign({style:{padding:16,paddingTop:0,height:"60px",borderBottom:"1px solid #E0E0E0"}},{children:e(n,{rightIcon:{icon:()=>H?e(a,{size:"small",color:l.content.primary}):e(o,{})},id:"listInput",height:"24px",type:"text",value:Y,onChangeText:e=>{q(e)},placeholder:"Search products..."})})),t(b,{children:["collections"===O&&e(h,{collections:D,selectedCollectionsDispatch:R,setCollectionId:B,setScreen:E,selectedCollections:Q,collectionFetcher:C.collectionFetcher,storeId:S,collectionsDispatch:k,setSaveDisabled:G,pagingControls:{curPage:z,setCurPage:$}}),"products"===O&&w&&e(g.Provider,Object.assign({value:w},{children:e(u,{productFetcher:C.productFetcher,setScreen:E,storeId:S,data:D[w],collectionsDispatch:k,selectedCollectionsDispatch:R,selectedData:Q,setSaveDisabled:G,searchInCollectionFetcher:C.searchInCollectionFetcher})})),"view"===O&&e(f,{selectedCollections:Q||{},selectedCollectionsDispatch:R,setScreen:E,collections:D}),"searchProducts"===O&&e(y,{selectedCollections:Q||{},searchedCollections:K||{},selectedCollectionsDispatch:R,setScreen:E,collections:D,onBackPress:()=>q("")})]})]})}))};export{C as ProductPickerModal};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useEffect as r}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as i}from"../button/Button.js";import{Input as n}from"../input/Input.js";import{StyledModal as d}from"../modals/styledModal.js";import{Spinner as a}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as h}from"./collectionScreen.js";import{ProductsScreen as u}from"./productScreen.js";import{collectionsReducer as m,selectedColectionsReducer as v,CollectionIdContext as g}from"./reducers.js";import{SearchScreen as y}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as b}from"./style.js";const C=C=>{const{storeId:S,selectedItems:x,onClose:I,visible:T,zIndex:P,limit:F}=C,[D,k]=c(m,{}),[O,E]=s("collections"),[w,B]=s(""),[z,L]=s(0),[$,A]=s(!1),[G,M]=s(0),[Y,q]=s(""),[H,J]=s(!1),[K,N]=s(!1),[Q,R]=s(),[U,V]=c(v,Object.keys(x).length>0?x:{});r((()=>{A(!0),N(!0),C.collectionFetcher(z,S).then((e=>{k({type:"fetched",data:(null==e?void 0:e.collections)||{}}),A(!1),L((e=>e+1)),N(!1)})).catch()}),[]),r((()=>{let e=0;Object.keys(U||[]).forEach((t=>{var o;Object.keys((null===(o=U[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=U[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),M(e)})),r((()=>{var e;w&&!(null===(e=null==D?void 0:D[w])||void 0===e?void 0:e.products)&&(A(!0),C.productFetcher(w,S).then((e=>{Object.keys(e).length&&k({type:"productsFetched",data:{collectionId:w,products:e}}),A(!1)})).catch())}),[w]),r((()=>{const e=setTimeout((()=>{Y.length&&(J(!0),C.searchFetcher(S,Y).then((e=>{R(e),E("searchProducts"),A(!1),J(!1)})))}),800);return()=>clearTimeout(e)}),[Y]);const W=()=>{V({type:"reset",data:{}})};return e(d,Object.assign({zIndex:P,open:T,onClose:()=>{I(),W()},headingTitle:"collections"===O||"products"===O?"Select Products":"view"===O?"Selected Products":"searchProducts"===O?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:$?"Loading...":"Add",disabled:$||F&&G>F||!1,onClick:()=>{C.onAdd(U,G),W()}},footerLeftCustomElement:F&&G>F?e(p,{tagText:`You can only select ${F} products`,type:"negative"}):e(i,G>0?{onClick:()=>{E("view")},buttonText:`${G} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${G} products selected`,buttonType:"tertiaryGray"})},{children:t(j,{children:[("collections"===O||"searchProducts"===O)&&e("div",Object.assign({style:{padding:16,paddingTop:0,height:"60px",borderBottom:"1px solid #E0E0E0"}},{children:e(n,{rightIcon:{icon:()=>H?e(a,{size:"small",color:l.content.primary}):e(o,{})},id:"listInput",height:"24px",type:"text",value:Y,onChangeText:e=>{q(e)},placeholder:"Search products..."})})),t(b,{children:["collections"===O&&e(h,{dataLoading:K,collections:D,selectedCollectionsDispatch:V,setCollectionId:B,setScreen:E,selectedCollections:U,collectionFetcher:C.collectionFetcher,storeId:S,collectionsDispatch:k,setSaveDisabled:A,pagingControls:{curPage:z,setCurPage:L}}),"products"===O&&w&&e(g.Provider,Object.assign({value:w},{children:e(u,{productFetcher:C.productFetcher,setScreen:E,storeId:S,data:D[w],collectionsDispatch:k,selectedCollectionsDispatch:V,selectedData:U,setSaveDisabled:A,searchInCollectionFetcher:C.searchInCollectionFetcher})})),"view"===O&&e(f,{selectedCollections:U||{},selectedCollectionsDispatch:V,setScreen:E,collections:D}),"searchProducts"===O&&e(y,{selectedCollections:U||{},searchedCollections:Q||{},selectedCollectionsDispatch:V,setScreen:E,collections:D,onBackPress:()=>{q(""),R({})}})]})]})}))};export{C as ProductPickerModal};
@@ -21,6 +21,7 @@ interface ProductGroupInterface {
21
21
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
22
22
  viewOnly: boolean;
23
23
  isProductPartiallyChecked?: boolean;
24
+ upliftAdditions: any;
24
25
  }
25
26
  export declare const ProductGroup: (props: ProductGroupInterface) => JSX.Element;
26
27
  interface ProductCardInterface {
@@ -33,6 +34,7 @@ interface ProductCardInterface {
33
34
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
34
35
  viewOnly: boolean;
35
36
  isPartiallyChecked?: boolean;
37
+ upliftAdditions: any;
36
38
  }
37
39
  export declare const ProductCard: (props: ProductCardInterface) => JSX.Element;
38
40
  export {};
@@ -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 l from"../../assets/icons/search.svg.js";import{cloneDeep as d}from"lodash";import{useContext as r,useState as n,useEffect as s}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as v}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{BikShimmer as h}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as m}from"../shimmer-image/ShimmerImage.js";import{Spinner as y}from"../spinner/Spinner.js";import{BodyCaption as f,TitleRegular as j}from"../TypographyStyle.js";import{truncate as I}from"./collectionScreen.js";import{CollectionIdContext as g}from"./reducers.js";import{ProductScreenHeader as b,ProductScreenCollectionCardStyle as k,ProductCardStyle as C}from"./style.js";import{upliftAdditions as O}from"./utility.js";const S=m=>{const I=r(g),{data:C,collectionsDispatch:O,selectedData:S,selectedCollectionsDispatch:E,productFetcher:D,storeId:w,setScreen:P,setSaveDisabled:B}=m,[T,V]=n(""),[F,U]=n(!1),[z,A]=n(C);s((()=>{const t=setTimeout((()=>{T.length?(U(!0),m.searchInCollectionFetcher(w,I,T).then((t=>{var e;const o=d(C);o.products={};for(const i of t)(null===(e=null==C?void 0:C.products)||void 0===e?void 0:e[i])&&(o.products[i]=C.products[i]);A(o),B(!1),U(!1)}))):A(C)}),800);return()=>clearTimeout(t)}),[T]);const R=C.isSmartCollection||!1,_=t=>{var e,o,i,c,l,d,r,n;let s=0,a=0;return!!((null===(o=null===(e=null==S?void 0:S[I])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(l=Object.keys((null===(c=null===(i=null==C?void 0:C.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===l||l.forEach((()=>a++)),Object.keys((null===(n=null===(r=null===(d=null==S?void 0:S[I])||void 0===d?void 0:d.products)||void 0===r?void 0:r[t])||void 0===n?void 0:n.variants)||[]).forEach((()=>s++)),s>0&&a!==s))};s((()=>{(null==C?void 0:C.products)||q()}),[]);const q=()=>{B(!0),D(I,w).then((t=>{Object.keys(t).length&&(O({type:"productsFetched",data:{collectionId:I,products:t}}),A(Object.assign(Object.assign({},z),{products:t}))),B(!1),U(!1)})).catch()};return t("div",{children:[t(b,{children:[e(v,{Icon:i,height:16,onClick:()=>{P("collections")}}),e(f,Object.assign({style:{color:a.content.secondary}},{children:C.name}))]}),e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{rightIcon:{icon:()=>F?e(y,{size:"small",color:a.content.primary}):e(l,{})},id:"listInput",height:"24px",type:"text",value:T,onChangeText:t=>{V(t)},placeholder:"Search products in this collection..."})})),t("div",{children:[t(k,{children:[R?e(o,{}):e(u,{isChecked:!!(null==S?void 0:S[I]),isPartiallyChecked:(t=>{var e;let o=0,i=0;if(S[t]){const c=null==C?void 0:C.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 l=null===(e=S[t])||void 0===e?void 0:e.products;return l&&Object.keys(l).forEach((t=>{var e;const o=null===(e=l[t])||void 0===e?void 0:e.variants;o&&Object.keys(o).forEach((t=>i+=1))})),i>0&&o!==i}return!1})(I),onValueChange:function(t){E(t?{type:"selected",data:{id:I,val:C}}:{type:"unselected",data:{id:I}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==z?void 0:z.products)||[]).length&&!F?Object.keys(z.products||[]).map((t=>e(x,{collectionId:I,isProductPartiallyChecked:_(t),productId:t,data:z.products[t],selectedData:S,selectedCollectionsDispatch:E,viewOnly:!!R},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(h,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})]})},x=o=>{const{collectionId:i,productId:c,data:l,selectedData:d,selectedCollectionsDispatch:r,viewOnly:n,isProductPartiallyChecked:s}=o,a=t=>{var e,o,l,r,n,s;if(!(null===(o=null===(e=null==d?void 0:d[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(s=null===(n=null===(r=null===(l=null==d?void 0:d[i])||void 0===l?void 0:l.products)||void 0===r?void 0:r[c])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[t])};return t("div",{children:[e(E,{isVariant:!1,data:l,productId:c,collectionId:i,isSelected:!!(null===(v=null===(u=null==d?void 0:d[i])||void 0===u?void 0:u.products)||void 0===v?void 0:v[c]),isPartiallyChecked:s,selectedCollectionsDispatch:r,viewOnly:n},c),Object.keys(l.variants||[]).map((t=>e(E,{isVariant:!0,data:l.variants[t],variantId:t,productId:c,viewOnly:n,collectionId:i,isSelected:a(t),selectedCollectionsDispatch:r},t)))]});var u,v},E=i=>{const{isVariant:c,data:l,productId:d,collectionId:r,variantId:n,isSelected:s,selectedCollectionsDispatch:a,viewOnly:v,isPartiallyChecked:p}=i;return t(C,Object.assign({isVariant:c},{children:[v?e(o,{}):e(u,{isChecked:s,isPartiallyChecked:p||!1,onValueChange:function(t){if(c)if(t){const t=O({productId:d,variantId:n,collectionId:r,variant:l},l);a({type:"variantSelected",data:t})}else a({type:"variantUnselected",data:{productId:d,variantId:n,collectionId:r}});else if(t){const t=O({productId:d,collectionId:r,product:l},l);a({type:"productSelected",data:t})}else a({type:"productUnselected",data:{productId:d,collectionId:r}})}}),e("div",{children:e(m,{width:40,height:40,imageUrl:l.image,alt:"Item",borderRadius:4})}),e(j,{children:I(l.name,40,!0)})]}))};export{E as ProductCard,x as ProductGroup,S as ProductsScreen};
1
+ import{jsxs as t,jsx as o,Fragment as e}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import d from"../../assets/icons/box.svg.js";import l from"../../assets/icons/search.svg.js";import{cloneDeep as c}from"lodash";import{useContext as n,useState as r,useEffect as s}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as p}from"../icon-button/IconButton.js";import{Input as v}from"../input/Input.js";import{BikShimmer as h}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as m}from"../shimmer-image/ShimmerImage.js";import{Spinner as y}from"../spinner/Spinner.js";import{BodyCaption as f,TitleRegular as g}from"../TypographyStyle.js";import{truncate as j}from"./collectionScreen.js";import{EmptyState as I}from"./emptyState.js";import{CollectionIdContext as b}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as O,ProductCardStyle as C}from"./style.js";import{liftTheStateUp as S}from"./utility.js";const x=e=>{const m=n(b),{data:j,collectionsDispatch:C,selectedData:x,selectedCollectionsDispatch:w,productFetcher:D,storeId:P,setScreen:A,setSaveDisabled:B}=e,[T,V]=r(""),[F,U]=r(!1),[W,z]=r(j);s((()=>{const t=setTimeout((()=>{T.length?(U(!0),e.searchInCollectionFetcher(P,m,T).then((t=>{var o;const e=c(j);e.products={};for(const i of t)(null===(o=null==j?void 0:j.products)||void 0===o?void 0:o[i])&&(e.products[i]=j.products[i]);z(e),B(!1),U(!1)}))):z(j)}),800);return()=>clearTimeout(t)}),[T]);const N=j.isSmartCollection||!1,R=t=>{var o,e,i,d,l,c,n,r;let s=0,a=0;return!!((null===(e=null===(o=null==x?void 0:x[m])||void 0===o?void 0:o.products)||void 0===e?void 0:e[t])&&(null===(l=Object.keys((null===(d=null===(i=null==j?void 0:j.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===l||l.forEach((()=>a++)),Object.keys((null===(r=null===(n=null===(c=null==x?void 0:x[m])||void 0===c?void 0:c.products)||void 0===n?void 0:n[t])||void 0===r?void 0:r.variants)||[]).forEach((()=>s++)),s>0&&a!==s))};s((()=>{(null==j?void 0:j.products)||_()}),[]);const _=()=>{B(!0),U(!0),D(m,P).then((t=>{Object.keys(t).length&&(C({type:"productsFetched",data:{collectionId:m,products:t}}),z(Object.assign(Object.assign({},W),{products:t}))),B(!1),U(!1)})).catch()},q=(t,o)=>{const e=S(o,j);w({type:t,data:e})};return t("div",{children:[t(k,{children:[o(p,{Icon:i,height:16,onClick:()=>{A("collections")}}),o(f,Object.assign({style:{color:a.content.secondary}},{children:j.name}))]}),o("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:o(v,{rightIcon:{icon:()=>F&&T.length?o(y,{size:"small",color:a.content.primary}):o(l,{})},id:"listInput",height:"24px",type:"text",value:T,onChangeText:t=>{V(t)},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==W?void 0:W.products)||[]).length>0&&!N&&!T.length&&t(O,{children:[o(u,{isChecked:!!(null==x?void 0:x[m]),isPartiallyChecked:(t=>{var o;let e=0,i=0;if(x[t]){const d=null==j?void 0:j.products;d&&Object.keys(d).forEach((t=>{var o;const i=null===(o=d[t])||void 0===o?void 0:o.variants;i&&Object.keys(i).forEach((t=>e+=1))}));const l=null===(o=x[t])||void 0===o?void 0:o.products;return l&&Object.keys(l).forEach((t=>{var o;const e=null===(o=l[t])||void 0===o?void 0:o.variants;e&&Object.keys(e).forEach((t=>i+=1))})),i>0&&e!==i}return!1})(m),onValueChange:function(t){w(t?{type:"selected",data:{id:m,val:j}}:{type:"unselected",data:{id:m}})}}),o("div",Object.assign({style:{width:40,height:40}},{children:o(d,{})})),o(g,{children:"All Products"})]}),Object.keys((null==W?void 0:W.products)||[]).length?Object.keys(W.products||[]).map((t=>o(E,{collectionId:m,isProductPartiallyChecked:R(t),productId:t,data:W.products[t],selectedData:x,selectedCollectionsDispatch:w,viewOnly:!!N,upliftAdditions:q},t))):F?[1,2,3,4,5,6,7,8,9,10].map(((t,e)=>o("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:o(h,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),e))):o(I,{title:"No products to show",subtitle:T.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})},E=e=>{const{collectionId:i,productId:d,data:l,selectedData:c,selectedCollectionsDispatch:n,viewOnly:r,upliftAdditions:s,isProductPartiallyChecked:a}=e,u=t=>{var o,e,l,n,r,s;if(!(null===(e=null===(o=null==c?void 0:c[i])||void 0===o?void 0:o.products)||void 0===e?void 0:e[d]))return!1;return!!(null===(s=null===(r=null===(n=null===(l=null==c?void 0:c[i])||void 0===l?void 0:l.products)||void 0===n?void 0:n[d])||void 0===r?void 0:r.variants)||void 0===s?void 0:s[t])};return t("div",{children:[o(w,{isVariant:!1,data:l,productId:d,collectionId:i,isSelected:!!(null===(v=null===(p=null==c?void 0:c[i])||void 0===p?void 0:p.products)||void 0===v?void 0:v[d]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:s,viewOnly:r},d),Object.keys(l.variants||[]).map((t=>o(w,{isVariant:!0,data:l.variants[t],variantId:t,productId:d,viewOnly:r,upliftAdditions:s,collectionId:i,isSelected:u(t),selectedCollectionsDispatch:n},t)))]});var p,v},w=i=>{const{isVariant:d,data:l,productId:c,collectionId:n,variantId:r,isSelected:s,selectedCollectionsDispatch:a,viewOnly:p,upliftAdditions:v,isPartiallyChecked:h}=i;return t(C,Object.assign({isVariant:d},{children:[p?o(e,{}):o(u,{isChecked:s,isPartiallyChecked:h||!1,onValueChange:function(t){d?t?v("variantSelected",{productId:c,variantId:r,collectionId:n,variant:l}):a({type:"variantUnselected",data:{productId:c,variantId:r,collectionId:n}}):t?v("productSelected",{productId:c,collectionId:n,product:l}):a({type:"productUnselected",data:{productId:c,collectionId:n}})}}),o("div",{children:o(m,{width:40,height:40,imageUrl:l.image,alt:"Item",borderRadius:4})}),o(g,{children:j(l.name,40,!0)})]}))};export{w as ProductCard,E as ProductGroup,x as ProductsScreen};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as l}from"react/jsx-runtime";import t from"../../assets/icons/arrow_left.svg.js";import{IconButton as e}from"../icon-button/IconButton.js";import{BodyCaption as i}from"../TypographyStyle.js";import{ProductGroup as r}from"./productScreen.js";import{SelectedScreenHeader as c}from"./style.js";const d=d=>{const{selectedCollections:n,searchedCollections:s,selectedCollectionsDispatch:u,setScreen:v,collections:a,onBackPress:p}=d,m=(o,l)=>{var t,e,i,r,c,d,s,u,v;let p=0,m=0;return!!((null===(e=null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||void 0===e?void 0:e[l])&&(null===(d=Object.keys((null===(c=null===(r=null===(i=null==a?void 0:a[o])||void 0===i?void 0:i.products)||void 0===r?void 0:r[l])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>m++)),Object.keys((null===(v=null===(u=null===(s=null==n?void 0:n[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[l])||void 0===v?void 0:v.variants)||[]).forEach((()=>p++)),p>0&&m!==p))};return o("div",{children:[o(c,{children:[l(e,{Icon:t,onClick:()=>{v("collections"),p()}}),l(i,{children:"Searched Products"})]}),l("div",{children:Object.keys(s).map((o=>{var t;return Object.keys((null===(t=null==s?void 0:s[o])||void 0===t?void 0:t.products)||[]).map((t=>{let e=!1;return(null==s?void 0:s.isCustom)&&(e=!0),l(r,{collectionId:o,productId:t,data:s[o].products[t],isProductPartiallyChecked:m(o,t),selectedData:n,selectedCollectionsDispatch:u,viewOnly:e},t)}))}))})]})};export{d as SearchScreen};
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{ProductGroup as c}from"./productScreen.js";import{SelectedScreenHeader as n}from"./style.js";import{liftTheStateUp as s}from"./utility.js";const u=u=>{const{selectedCollections:v,searchedCollections:a,selectedCollectionsDispatch:p,setScreen:m,collections:h,onBackPress:f}=u,y=(o,t)=>{var e,l,i,r,d,c,n,s,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==h?void 0:h[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===(s=null===(n=null==v?void 0:v[o])||void 0===n?void 0:n.products)||void 0===s?void 0:s[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&p!==a))};return o("div",{children:[o(n,{children:[t(i,{Icon:l,onClick:()=>{m("collections"),f()}}),t(r,{children:"Searched Products"})]}),t("div",{children:Object.keys(a).length?t(e,{children:Object.keys(a).map((o=>{var e;return Object.keys((null===(e=null==a?void 0:a[o])||void 0===e?void 0:e.products)||[]).map((e=>{let l=!1;return(null==a?void 0:a.isCustom)&&(l=!0),t(c,{collectionId:o,upliftAdditions:(t,e)=>((o,t,e)=>{const l=s(e,a[o]);p({type:t,data:l})})(o,t,e),productId:e,data:a[o].products[e],isProductPartiallyChecked:y(o,e),selectedData:v,selectedCollectionsDispatch:p,viewOnly:l},e)}))}))}):t(d,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{u as SearchScreen};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as l}from"react/jsx-runtime";import t from"../../assets/icons/arrow_left.svg.js";import{IconButton as e}from"../icon-button/IconButton.js";import{BodyCaption as i}from"../TypographyStyle.js";import{ProductGroup as d}from"./productScreen.js";import{SelectedScreenHeader as r}from"./style.js";const c=c=>{const{selectedCollections:n,selectedCollectionsDispatch:s,setScreen:u,collections:v}=c,a=(o,l)=>{var t,e,i,d,r,c,s,u,a;let p=0,m=0;return!!((null===(e=null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||void 0===e?void 0:e[l])&&(null===(c=Object.keys((null===(r=null===(d=null===(i=null==v?void 0:v[o])||void 0===i?void 0:i.products)||void 0===d?void 0:d[l])||void 0===r?void 0:r.variants)||[]))||void 0===c||c.forEach((()=>m++)),Object.keys((null===(a=null===(u=null===(s=null==n?void 0:n[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[l])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&m!==p))};return o("div",{children:[o(r,{children:[l(e,{Icon:t,onClick:()=>{u("collections")}}),l(i,{children:"Selected Products"})]}),l("div",{children:Object.keys(n).map((o=>{var t;return Object.keys((null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||[]).map((t=>{let e=!1;return(null==n?void 0:n.isCustom)&&(e=!0),l(d,{collectionId:o,productId:t,data:n[o].products[t],isProductPartiallyChecked:a(o,t),selectedData:n,selectedCollectionsDispatch:s,viewOnly:e},t)}))}))})]})};export{c as SelectedScreen};
1
+ import{jsxs as o,jsx as t,Fragment as l}from"react/jsx-runtime";import e from"../../assets/icons/arrow_left.svg.js";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as r}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as c}from"./productScreen.js";import{SelectedScreenHeader as n}from"./style.js";const s=s=>{const{selectedCollections:u,selectedCollectionsDispatch:v,setScreen:p,collections:a}=s,m=(o,t)=>{var l,e,i,r,d,c,n,s,v;let p=0,m=0;return!!((null===(e=null===(l=null==u?void 0:u[o])||void 0===l?void 0:l.products)||void 0===e?void 0:e[t])&&(null===(c=Object.keys((null===(d=null===(r=null===(i=null==a?void 0:a[o])||void 0===i?void 0:i.products)||void 0===r?void 0:r[t])||void 0===d?void 0:d.variants)||[]))||void 0===c||c.forEach((()=>m++)),Object.keys((null===(v=null===(s=null===(n=null==u?void 0:u[o])||void 0===n?void 0:n.products)||void 0===s?void 0:s[t])||void 0===v?void 0:v.variants)||[]).forEach((()=>p++)),p>0&&m!==p))};return o("div",{children:[o(n,{children:[t(i,{Icon:e,onClick:()=>{p("collections")}}),t(r,{children:"Selected Products"})]}),t("div",{children:Object.keys(u).length>0?t(l,{children:Object.keys(u).map((o=>{var l;return Object.keys((null===(l=null==u?void 0:u[o])||void 0===l?void 0:l.products)||[]).map((l=>{let e=!1;return(null==u?void 0:u.isCustom)&&(e=!0),t(c,{upliftAdditions:null,collectionId:o,productId:l,data:u[o].products[l],isProductPartiallyChecked:m(o,l),selectedData:u,selectedCollectionsDispatch:v,viewOnly:e},l)}))}))}):t(d,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};export{s as SelectedScreen};
@@ -1 +1 @@
1
- export declare const upliftAdditions: (payload: any, data: any) => any;
1
+ export declare const liftTheStateUp: (payload: any, data: any) => any;
@@ -1 +1 @@
1
- import{cloneDeep as t}from"lodash";const a=(a,s)=>{const o=t(s);if(delete o.products,(a=Object.assign(Object.assign({},a),{catalogOnlyData:o})).productId&&s.products){const c=t(s.products[a.productId]);(null==c?void 0:c.variants)&&delete c.variants,a=Object.assign(Object.assign({},a),{catalogOnlyData:o,productOnlyData:c})}return a};export{a as upliftAdditions};
1
+ import{cloneDeep as t}from"lodash";const a=(a,s)=>{const o=t(s);if(delete o.products,(a=Object.assign(Object.assign({},a),{catalogOnlyData:o})).productId&&s.products){const c=t(s.products[a.productId]);(null==c?void 0:c.variants)&&delete c.variants,a=Object.assign(Object.assign({},a),{catalogOnlyData:o,productOnlyData:c})}return a};export{a as liftTheStateUp};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.159-beta.7",
3
+ "version": "0.0.159-beta.9",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",