@bikdotai/bik-component-library 0.0.159-beta.12 → 0.0.159-beta.2

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 (37) hide show
  1. package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
  2. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +0 -2
  3. package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
  4. package/dist/cjs/components/product-picker-v2/modal.d.ts +0 -6
  5. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  6. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +2 -5
  7. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  8. package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
  9. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +1 -0
  10. package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
  11. package/dist/cjs/components/stepper/WorkingStepper.d.ts +0 -1
  12. package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
  13. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +0 -2
  14. package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
  15. package/dist/esm/components/product-picker-v2/modal.d.ts +0 -6
  16. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  17. package/dist/esm/components/product-picker-v2/productScreen.d.ts +2 -5
  18. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  19. package/dist/esm/components/product-picker-v2/reducers.js +1 -1
  20. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +1 -0
  21. package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
  22. package/dist/esm/components/stepper/WorkingStepper.d.ts +0 -1
  23. package/package.json +1 -1
  24. package/dist/cjs/assets/icons/box_round.svg.js +0 -1
  25. package/dist/cjs/components/product-picker-v2/emptyState.d.ts +0 -7
  26. package/dist/cjs/components/product-picker-v2/emptyState.js +0 -7
  27. package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +0 -16
  28. package/dist/cjs/components/product-picker-v2/searchScreen.js +0 -1
  29. package/dist/cjs/components/product-picker-v2/utility.d.ts +0 -1
  30. package/dist/cjs/components/product-picker-v2/utility.js +0 -1
  31. package/dist/esm/assets/icons/box_round.svg.js +0 -1
  32. package/dist/esm/components/product-picker-v2/emptyState.d.ts +0 -7
  33. package/dist/esm/components/product-picker-v2/emptyState.js +0 -7
  34. package/dist/esm/components/product-picker-v2/searchScreen.d.ts +0 -16
  35. package/dist/esm/components/product-picker-v2/searchScreen.js +0 -1
  36. package/dist/esm/components/product-picker-v2/utility.d.ts +0 -1
  37. package/dist/esm/components/product-picker-v2/utility.js +0 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -3,8 +3,6 @@ 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
- customCollectionRestriction?: boolean;
7
- dataLoading: boolean;
8
6
  collections: {
9
7
  [key: string]: Collection;
10
8
  };
@@ -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"),i=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),r=require("../shimmer/ShimmerComponent/BikShimmer.js"),c=require("../tag/Tag.js"),l=require("../TypographyStyle.js"),n=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{customCollectionRestriction:r,data:n,selectedCollectionsDispatch:u,setCollectionId:h,isPartiallyChecked:j,setScreen:x,id:C,isChecked:p,isDisabled:m}=s;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:m},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[e.jsx(i.CheckBox,{isDisabled:m,isChecked:p,isPartiallyChecked:j,onValueChange:function(e){u(e?{type:"selected",data:{id:C,val:n,isRestricted:r}}:{type:"unselected",data:{id:C}}),h(e?C:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsxs(a.CollectionNameHolder,{children:[e.jsx(l.TitleRegular,{children:d(n.name,40,!0)}),n.isSmartCollection?e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"}):e.jsx(e.Fragment,{})]})})]}),e.jsx(o.IconButton,{disabled:m,onClick:()=>{m||(h(C),x("products"))},Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:i,dataLoading:o,collections:c,selectedCollectionsDispatch:l,setCollectionId:a,selectedCollections:d,setScreen:h,collectionFetcher:j,collectionsDispatch:x,pagingControls:C,storeId:p,setSaveDisabled:m}=t,v=s.useRef(null),g=s.useRef(C.curPage),y=!!i&&(null==d?void 0:d.isCustom),[b,f]=s.useState(!1);s.useEffect((()=>{g.current=C.curPage}),[C.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&g.current>0&&(m(!0),f(!0),j(g.current,p).then((e=>{x({type:"paged",data:(null==e?void 0:e.collections)||{}}),C.setCurPage(g.current+1),f(!1),m(!1)})).catch())}),{threshold:1});return v.current&&e.observe(v.current),()=>{v.current&&e.unobserve(v.current)}}),[v]);const k=e=>{var t,s;let i=0,o=0;if(d[e]){const r=null===(t=c[e])||void 0===t?void 0:t.products;r&&Object.keys(r).forEach((e=>{var t;const s=null===(t=r[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))}));const l=null===(s=d[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=>o+=1))})),!(i<=0&&o>0)&&(o>0&&i!==o)}return!1};return e.jsxs("div",{children:[Object.keys(c).length?Object.keys(c).map((t=>e.jsx(u,{customCollectionRestriction:i,data:c[t],isDisabled:y&&!(null==d?void 0:d[t]),isChecked:!!(null==d?void 0:d[t]),isPartiallyChecked:k(t),selectedCollectionsDispatch:l,setCollectionId:a,setScreen:h,id:t},t))):o?[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(r.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:v}),b&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=d;
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;
@@ -35,11 +35,6 @@ export type ProductFetcherReturn = Promise<{
35
35
  [key: string]: Product;
36
36
  }>;
37
37
  export interface ProductPickerInterface {
38
- hideGlobalSearch?: boolean;
39
- hideInCollectionSearch?: boolean;
40
- customCollectionRestriction?: boolean;
41
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
42
- searchFetcher: (storeId: string, query: string) => Promise<SelectedItems>;
43
38
  collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
44
39
  productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
45
40
  storeId: string;
@@ -48,6 +43,5 @@ export interface ProductPickerInterface {
48
43
  onClose: () => void;
49
44
  visible: boolean;
50
45
  zIndex?: number;
51
- limit?: number;
52
46
  }
53
47
  export declare const ProductPickerModal: (props: ProductPickerInterface) => JSX.Element;
@@ -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"),o=require("../../constants/Theme.js"),s=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"),S=require("./style.js");exports.ProductPickerModal=j=>{const{storeId:C,selectedItems:x,onClose:v,visible:g,zIndex:y,limit:b}=j,[m,f]=c.useReducer(u.collectionsReducer,{}),[I,q]=c.useState("collections"),[P,T]=c.useState(""),[E,F]=c.useState(0),[O,R]=c.useState(!1),[k,D]=c.useState(0),[B,w]=c.useState(""),[L,M]=c.useState(!1),[z,G]=c.useState(!1),[$,A]=c.useState(),[_,H]=c.useReducer(u.selectedColectionsReducer,Object.keys(x).length>0?x:{});c.useEffect((()=>{R(!0),G(!0),j.collectionFetcher(E,C).then((e=>{f({type:"fetched",data:(null==e?void 0:e.collections)||{}}),R(!1),F((e=>e+1)),G(!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 o,s;Object.keys((null===(s=null===(o=_[t].products)||void 0===o?void 0:o[c])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),D(e)})),c.useEffect((()=>{var e;P&&!(null===(e=null==m?void 0:m[P])||void 0===e?void 0:e.products)&&(R(!0),j.productFetcher(P,C).then((e=>{Object.keys(e).length&&f({type:"productsFetched",data:{collectionId:P,products:e}}),R(!1)})).catch())}),[P]),c.useEffect((()=>{const e=setTimeout((()=>{B.length&&(M(!0),j.searchFetcher(C,B).then((e=>{A(e),q("searchProducts"),R(!1),M(!1)})))}),800);return()=>clearTimeout(e)}),[B]);const Y=()=>{H({type:"reset",data:{}})};return e.jsx(l.StyledModal,Object.assign({zIndex:y,open:g,onClose:()=>{v(),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:O?"Loading...":"Add",disabled:O||b&&k>b||!1,onClick:()=>{j.onAdd(_,k),Y()}},footerLeftCustomElement:b&&k>b?e.jsx(i.Tag,{tagText:`You can only select ${b} products`,type:"negative"}):k>0?e.jsx(s.Button,{onClick:()=>{q("view")},buttonText:`${k} products selected`,buttonType:"tertiaryGray"}):e.jsx(s.Button,{disabled:!0,buttonText:`${k} products selected`,buttonType:"tertiaryGray"})},{children:e.jsxs(S.ContainerStyle,{children:[!j.hideGlobalSearch&&e.jsx(e.Fragment,{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,{noErrorHint:!0,rightIcon:{icon:()=>L?e.jsx(n.Spinner,{size:"small",color:o.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:B,onChangeText:e=>{e.length&&e.trim().length&&w(e)},placeholder:"Search products..."})}))}),e.jsxs(S.ScrollContainerStyle,{children:["collections"===I&&e.jsx(d.CollectionsScreen,{customCollectionRestriction:j.customCollectionRestriction,dataLoading:z,collections:m,selectedCollectionsDispatch:H,setCollectionId:T,setScreen:q,selectedCollections:_,collectionFetcher:j.collectionFetcher,storeId:C,collectionsDispatch:f,setSaveDisabled:R,pagingControls:{curPage:E,setCurPage:F}}),"products"===I&&P&&e.jsx(u.CollectionIdContext.Provider,Object.assign({value:P},{children:e.jsx(a.ProductsScreen,{hideInCollectionSearch:j.hideInCollectionSearch,customCollectionRestriction:j.customCollectionRestriction,productFetcher:j.productFetcher,setScreen:q,storeId:C,data:m[P],collectionsDispatch:f,selectedCollectionsDispatch:H,selectedData:_,setSaveDisabled:R,searchInCollectionFetcher:j.searchInCollectionFetcher})})),"view"===I&&e.jsx(p.SelectedScreen,{selectedCollections:_||{},selectedCollectionsDispatch:H,setScreen:q,collections:m}),"searchProducts"===I&&e.jsx(h.SearchScreen,{customCollectionRestriction:j.customCollectionRestriction,selectedCollections:_||{},searchedCollections:$||{},selectedCollectionsDispatch:H,setScreen:q,collections:m,onBackPress:()=>{w(""),A({})}})]})]})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),c=require("../button/Button.js"),o=require("../modals/styledModal.js"),s=require("./collectionScreen.js"),l=require("./productScreen.js"),r=require("./reducers.js"),n=require("./selectedScreen.js"),d=require("./style.js");exports.ProductPickerModal=i=>{const{storeId:u,selectedItems:a,onClose:p,visible:h,zIndex:j}=i;console.log("selectedItems",a);const[v,S]=t.useReducer(r.collectionsReducer,{}),[y,C]=t.useState("collections"),[x,b]=t.useState(""),[f,g]=t.useState(0),[I,m]=t.useReducer(r.selectedColectionsReducer,Object.keys(a).length>0?a:{});console.log("selectedCollections",I),t.useEffect((()=>{P(!0),i.collectionFetcher(f,u).then((e=>{S({type:"fetched",data:(null==e?void 0:e.collections)||{}}),P(!1),g((e=>e+1))})).catch()}),[]);const[q,P]=t.useState(!1),[k,D]=t.useState(0);t.useEffect((()=>{let e=0;Object.keys(I||[]).forEach((t=>{var c;Object.keys((null===(c=I[t])||void 0===c?void 0:c.products)||[]).forEach((c=>{var o,s;Object.keys((null===(s=null===(o=I[t].products)||void 0===o?void 0:o[c])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),D(e)})),t.useEffect((()=>{var e;x&&!(null===(e=null==v?void 0:v[x])||void 0===e?void 0:e.products)&&(P(!0),i.productFetcher(x,u).then((e=>{Object.keys(e).length&&(S({type:"productsFetched",data:{collectionId:x,products:e}}),P(!1))})).catch())}),[x]);const F=()=>{m({type:"reset",data:{}})};return e.jsx(o.StyledModal,Object.assign({zIndex:j,open:h,onClose:()=>{p(),F()},headingTitle:"collections"===y?"Select Products":"products"===y?v[x].name:"view"===y?"Selected Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:q?"Loading...":"Add",disabled:q,onClick:()=>{i.onAdd(I,k),F()}},footerLeftCustomElement:e.jsx(e.Fragment,{children:k>0?e.jsx(c.Button,{onClick:()=>{C("view")},buttonText:`${k} products selected`,buttonType:"tertiaryGray"}):e.jsx(c.Button,{disabled:!0,buttonText:`${k} products selected`,buttonType:"tertiaryGray"})})},{children:e.jsx(d.ContainerStyle,{children:e.jsxs(d.ScrollContainerStyle,{children:["collections"===y&&e.jsx(s.CollectionsScreen,{collections:v,selectedCollectionsDispatch:m,setCollectionId:b,setScreen:C,selectedCollections:I,collectionFetcher:i.collectionFetcher,storeId:u,collectionsDispatch:S,setSaveDisabled:P,pagingControls:{curPage:f,setCurPage:g}}),"products"===y&&x&&e.jsx(r.CollectionIdContext.Provider,Object.assign({value:x},{children:e.jsx(l.ProductsScreen,{productFetcher:i.productFetcher,setScreen:C,storeId:u,data:v[x],collectionsDispatch:S,selectedCollectionsDispatch:m,selectedData:I,setSaveDisabled:P})})),"view"===y&&e.jsx(n.SelectedScreen,{selectedCollections:I||{},selectedCollectionsDispatch:m,upliftAdditions:null,setScreen:C,collections:v})]})})}))};
@@ -2,13 +2,10 @@
2
2
  import { Collection, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
3
3
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
4
4
  interface ProductsScreenInterface {
5
- hideInCollectionSearch?: boolean;
6
- customCollectionRestriction?: boolean;
7
5
  data: Collection;
8
6
  collectionsDispatch: React.Dispatch<CollectionsActions>;
9
7
  selectedData: SelectedItems;
10
8
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
11
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
12
9
  productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
13
10
  storeId: string;
14
11
  setScreen: React.Dispatch<React.SetStateAction<string>>;
@@ -21,9 +18,9 @@ interface ProductGroupInterface {
21
18
  data: Product;
22
19
  selectedData: SelectedItems;
23
20
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
21
+ upliftAdditions: any;
24
22
  viewOnly: boolean;
25
23
  isProductPartiallyChecked?: boolean;
26
- upliftAdditions: any;
27
24
  }
28
25
  export declare const ProductGroup: (props: ProductGroupInterface) => JSX.Element;
29
26
  interface ProductCardInterface {
@@ -34,9 +31,9 @@ interface ProductCardInterface {
34
31
  variantId?: string;
35
32
  isSelected: boolean;
36
33
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
34
+ upliftAdditions: any;
37
35
  viewOnly: boolean;
38
36
  isPartiallyChecked?: boolean;
39
- upliftAdditions: any;
40
37
  }
41
38
  export declare const ProductCard: (props: ProductCardInterface) => JSX.Element;
42
39
  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"),l=require("react"),c=require("../../constants/Theme.js"),d=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"),h=require("../spinner/Spinner.js"),v=require("../TypographyStyle.js"),p=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:l,selectedCollectionsDispatch:c,viewOnly:d,upliftAdditions:r,isProductPartiallyChecked:n}=t,a=e=>{var t,s,c,d,r,n;if(!(null===(s=null===(t=null==l?void 0:l[i])||void 0===t?void 0:t.products)||void 0===s?void 0:s[o]))return!1;return!!(null===(n=null===(r=null===(d=null===(c=null==l?void 0:l[i])||void 0===c?void 0:c.products)||void 0===d?void 0:d[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===(h=null===(u=null==l?void 0:l[i])||void 0===u?void 0:u.products)||void 0===h?void 0:h[o]),isPartiallyChecked:n,selectedCollectionsDispatch:c,upliftAdditions: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,upliftAdditions:r,collectionId:i,isSelected:a(t),selectedCollectionsDispatch:c},t)))]});var u,h},I=t=>{const{isVariant:i,data:o,productId:s,collectionId:l,variantId:c,isSelected:r,selectedCollectionsDispatch:n,viewOnly:a,upliftAdditions:h,isPartiallyChecked:j}=t;return e.jsxs(y.ProductCardStyle,Object.assign({isVariant:i},{children:[a?e.jsx(e.Fragment,{}):e.jsx(d.CheckBox,{isChecked:r,isPartiallyChecked:j||!1,onValueChange:function(e){i?e?h("variantSelected",{productId:s,variantId:c,collectionId:l,variant:o}):n({type:"variantUnselected",data:{productId:s,variantId:c,collectionId:l}}):e?h("productSelected",{productId:s,collectionId:l,product:o}):n({type:"productUnselected",data:{productId:s,collectionId:l}})}}),e.jsx("div",{children:e.jsx(u.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(v.TitleRegular,{children:p.truncate(o.name,40,!0)})]}))};exports.ProductCard=I,exports.ProductGroup=m,exports.ProductsScreen=u=>{const p=l.useContext(x.CollectionIdContext),{data:I,collectionsDispatch:C,selectedData:S,selectedCollectionsDispatch:f,productFetcher:O,storeId:b,setScreen:k,setSaveDisabled:q,hideInCollectionSearch:E,customCollectionRestriction:P}=u,[D,w]=l.useState(""),[B,T]=l.useState(!1),[R,A]=l.useState(I);l.useEffect((()=>{const e=setTimeout((()=>{D.length?(T(!0),u.searchInCollectionFetcher(b,p,D).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]);A(i),q(!1),T(!1)}))):A(I)}),800);return()=>clearTimeout(e)}),[D]);const V=!!P&&I.isSmartCollection,F=e=>{var t,i,o,s,l,c,d,r;let n=0,a=0;return!!((null===(i=null===(t=null==S?void 0:S[p])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(l=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===l||l.forEach((()=>a++)),Object.keys((null===(r=null===(d=null===(c=null==S?void 0:S[p])||void 0===c?void 0:c.products)||void 0===d?void 0:d[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};l.useEffect((()=>{(null==I?void 0:I.products)||U()}),[]);const U=()=>{q(!0),T(!0),O(p,b).then((e=>{Object.keys(e).length&&(C({type:"productsFetched",data:{collectionId:p,products:e}}),A(Object.assign(Object.assign({},R),{products:e}))),q(!1),T(!1)})).catch()},_=(e,t)=>{const i=g.liftTheStateUp(t,I);f({type:e,data:Object.assign(Object.assign({},i),{isRestricted:P})})};return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(r.IconButton,{Icon:t.default,height:16,onClick:()=>{k("collections")}}),e.jsx(v.BodyCaption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:I.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(n.Input,{noErrorHint:!0,rightIcon:{icon:()=>B&&D.length?e.jsx(h.Spinner,{size:"small",color:c.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:D,onChangeText:e=>{e.length&&e.trim().length&&w(e)},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==R?void 0:R.products)||[]).length>0&&!V&&!D.length&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(d.CheckBox,{isChecked:!!(null==S?void 0:S[p]),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 l=null===(t=S[e])||void 0===t?void 0:t.products;return 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=>o+=1))})),o>0&&i!==o}return!1})(p),onValueChange:function(e){f(e?{type:"selected",data:{id:p,val:I}}:{type:"unselected",data:{id:p}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(v.TitleRegular,{children:"All Products"})]}),Object.keys((null==R?void 0:R.products)||[]).length?Object.keys(R.products||[]).map((t=>e.jsx(m,{collectionId:p,isProductPartiallyChecked:F(t),productId:t,data:R.products[t],selectedData:S,selectedCollectionsDispatch:f,viewOnly:!!V,upliftAdditions:_},t))):B?[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:D.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"),d=require("lodash"),o=require("react"),l=require("../../constants/Theme.js"),c=require("../checkBox/CheckBox.js"),s=require("../icon-button/IconButton.js"),r=require("../shimmer/ShimmerComponent/BikShimmer.js"),n=require("../shimmer-image/ShimmerImage.js"),a=require("../TypographyStyle.js"),u=require("./collectionScreen.js"),v=require("./reducers.js"),p=require("./style.js");const h=t=>{const{collectionId:i,productId:d,data:o,selectedData:l,selectedCollectionsDispatch:c,upliftAdditions:s,viewOnly:r,isProductPartiallyChecked:n}=t,a=e=>{var t,o,c,s,r,n;if(!(null===(o=null===(t=null==l?void 0:l[i])||void 0===t?void 0:t.products)||void 0===o?void 0:o[d]))return!1;return!!(null===(n=null===(r=null===(s=null===(c=null==l?void 0:l[i])||void 0===c?void 0:c.products)||void 0===s?void 0:s[d])||void 0===r?void 0:r.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(j,{isVariant:!1,data:o,productId:d,collectionId:i,isSelected:!!(null===(v=null===(u=null==l?void 0:l[i])||void 0===u?void 0:u.products)||void 0===v?void 0:v[d]),isPartiallyChecked:n,selectedCollectionsDispatch:c,upliftAdditions:s,viewOnly:r},d),Object.keys(o.variants||[]).map((t=>e.jsx(j,{isVariant:!0,data:o.variants[t],variantId:t,productId:d,viewOnly:r,collectionId:i,isSelected:a(t),selectedCollectionsDispatch:c,upliftAdditions:s},t)))]});var u,v},j=t=>{const{isVariant:i,data:d,productId:o,collectionId:l,variantId:s,isSelected:r,selectedCollectionsDispatch:v,upliftAdditions:h,viewOnly:j,isPartiallyChecked:y}=t;return e.jsxs(p.ProductCardStyle,Object.assign({isVariant:i},{children:[j?e.jsx(e.Fragment,{}):e.jsx(c.CheckBox,{isChecked:r,isPartiallyChecked:y||!1,onValueChange:function(e){i?e?h("variantSelected",{productId:o,variantId:s,collectionId:l,variant:d}):v({type:"variantUnselected",data:{productId:o,variantId:s,collectionId:l}}):e?h("productSelected",{productId:o,collectionId:l,product:d}):v({type:"productUnselected",data:{productId:o,collectionId:l}})}}),e.jsx("div",{children:e.jsx(n.ShimmerImage,{width:40,height:40,imageUrl:d.image,alt:"Item",borderRadius:4})}),e.jsx(a.TitleRegular,{children:u.truncate(d.name,40,!0)})]}))};exports.ProductCard=j,exports.ProductGroup=h,exports.ProductsScreen=n=>{const u=o.useContext(v.CollectionIdContext),{data:j,collectionsDispatch:y,selectedData:x,selectedCollectionsDispatch:m,productFetcher:I,storeId:g,setScreen:C,setSaveDisabled:O}=n,[b]=o.useState(j),k=j.isSmartCollection||!1,f=e=>{var t,i,d,o,l,c,s,r;let n=0,a=0;return!!((null===(i=null===(t=null==x?void 0:x[u])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(l=Object.keys((null===(o=null===(d=null==j?void 0:j.products)||void 0===d?void 0:d[e])||void 0===o?void 0:o.variants)||[]))||void 0===l||l.forEach((()=>a++)),Object.keys((null===(r=null===(s=null===(c=null==x?void 0:x[u])||void 0===c?void 0:c.products)||void 0===s?void 0:s[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};o.useEffect((()=>{(null==j?void 0:j.products)||(O(!0),I(u,g).then((e=>{Object.keys(e).length&&y({type:"productsFetched",data:{collectionId:u,products:e}}),O(!1)})).catch())}),[]);const S=(e,t)=>{const i=d.cloneDeep(j);if(delete i.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:i})).productId&&j.products){const e=d.cloneDeep(j.products[t.productId]);(null==e?void 0:e.variants)&&delete e.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:i,productOnlyData:e})}m({type:e,data:t})};return e.jsxs("div",{children:[e.jsxs(p.ProductScreenHeader,{children:[e.jsx(s.IconButton,{Icon:t.default,height:16,onClick:()=>{C("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:l.COLORS.content.secondary}},{children:j.name}))]}),e.jsxs("div",{children:[e.jsxs(p.ProductScreenCollectionCardStyle,{children:[k?e.jsx(e.Fragment,{}):e.jsx(c.CheckBox,{isChecked:!!(null==x?void 0:x[u]),isPartiallyChecked:(e=>{var t;let i=0,d=0;if(x[e]){const o=null==j?void 0:j.products;o&&Object.keys(o).forEach((e=>{var t;const d=null===(t=o[e])||void 0===t?void 0:t.variants;d&&Object.keys(d).forEach((e=>i+=1))}));const l=null===(t=x[e])||void 0===t?void 0:t.products;return 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=>d+=1))})),d>0&&i!==d}return!1})(u),onValueChange:function(e){m(e?{type:"selected",data:{id:u,val:j}}:{type:"unselected",data:{id:u}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==b?void 0:b.products)||[]).length?Object.keys(b.products||[]).map((t=>e.jsx(h,{collectionId:u,isProductPartiallyChecked:f(t),productId:t,data:b.products[t],selectedData:x,selectedCollectionsDispatch:m,upliftAdditions:S,viewOnly:!!k},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(r.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})]})};
@@ -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,r,s;let n={},u="",i="",p="";switch(a.type){case"selected":return n=t.cloneDeep(e),a.data.val.isSmartCollection&&(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==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,(null===(d=a.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(n={},n.isCustom=!0),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==n?void 0:n[i])||((null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(n={},n.isCustom=!0),n[i]=a.data.catalogOnlyData,n[i].products={},n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),(null===(l=null===(c=null==n?void 0:n[i])||void 0===c?void 0:c.products)||void 0===l?void 0:l[u])||((null===(r=null==n?void 0:n[i])||void 0===r?void 0:r.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===(s=n[i])||void 0===s?void 0:s.isSmartCollection)&&(n.isCustom=!1),delete n[i])),n;case"reset":return{};default:return e}};
@@ -4,6 +4,7 @@ import { SelectedCollectionsActions } from './reducers';
4
4
  interface SelectedScreenInterface {
5
5
  selectedCollections: SelectedItems;
6
6
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
7
+ upliftAdditions: any;
7
8
  setScreen: React.Dispatch<React.SetStateAction<string>>;
8
9
  collections: {
9
10
  [key: string]: Collection;
@@ -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"),o=require("../../assets/icons/arrow_left.svg.js"),l=require("../icon-button/IconButton.js"),t=require("../TypographyStyle.js"),i=require("./productScreen.js"),d=require("./style.js");exports.SelectedScreen=r=>{const{selectedCollections:s,selectedCollectionsDispatch:c,upliftAdditions:n,setScreen:u,collections:v}=r,a=(e,o)=>{var l,t,i,d,r,c,n,u,a;let p=0,j=0;return!!((null===(t=null===(l=null==s?void 0:s[e])||void 0===l?void 0:l.products)||void 0===t?void 0:t[o])&&(null===(c=Object.keys((null===(r=null===(d=null===(i=null==v?void 0:v[e])||void 0===i?void 0:i.products)||void 0===d?void 0:d[o])||void 0===r?void 0:r.variants)||[]))||void 0===c||c.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(n=null==s?void 0:s[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(d.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:o.default,onClick:()=>{u("collections")}}),e.jsx(t.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(s).map((o=>{var l;return Object.keys((null===(l=null==s?void 0:s[o])||void 0===l?void 0:l.products)||[]).map((l=>{let t=!1;return(null==s?void 0:s.isCustom)&&(t=!0),e.jsx(i.ProductGroup,{collectionId:o,productId:l,data:s[o].products[l],isProductPartiallyChecked:a(o,l),selectedData:s,selectedCollectionsDispatch:c,upliftAdditions:n,viewOnly:t},l)}))}))})]})};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const WorkingStepper: () => JSX.Element;
3
2
  export declare enum STEPENUM {
4
3
  STEP1 = "STEP1",
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -3,8 +3,6 @@ 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
- customCollectionRestriction?: boolean;
7
- dataLoading: boolean;
8
6
  collections: {
9
7
  [key: string]: Collection;
10
8
  };
@@ -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 s,useState as c,useEffect as r}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 C=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},b=o=>{const{customCollectionRestriction:i,dataLoading:n,collections:l,selectedCollectionsDispatch:d,setCollectionId:h,selectedCollections:m,setScreen:p,collectionFetcher:v,collectionsDispatch:g,pagingControls:C,storeId:b,setSaveDisabled:f}=o,j=s(null),k=s(C.curPage),x=!!i&&(null==m?void 0:m.isCustom),[O,E]=c(!1);r((()=>{k.current=C.curPage}),[C.curPage]),r((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&k.current>0&&(f(!0),E(!0),v(k.current,b).then((e=>{g({type:"paged",data:(null==e?void 0:e.collections)||{}}),C.setCurPage(k.current+1),E(!1),f(!1)})).catch())}),{threshold:1});return j.current&&e.observe(j.current),()=>{j.current&&e.unobserve(j.current)}}),[j]);const S=e=>{var t,o;let i=0,s=0;if(m[e]){const c=null===(t=l[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 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=>s+=1))})),!(i<=0&&s>0)&&(s>0&&i!==s)}return!1};return e("div",{children:[Object.keys(l).length?Object.keys(l).map((e=>t(y,{customCollectionRestriction:i,data:l[e],isDisabled:x&&!(null==m?void 0:m[e]),isChecked:!!(null==m?void 0:m[e]),isPartiallyChecked:S(e),selectedCollectionsDispatch:d,setCollectionId:h,setScreen:p,id:e},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(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:j}),O&&[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=s=>{const{customCollectionRestriction:c,data:r,selectedCollectionsDispatch:a,setCollectionId:u,isPartiallyChecked:b,setScreen:y,id:f,isChecked:j,isDisabled:k}=s;return e(m,Object.assign({isDisabled:k},{children:[e(p,{children:[t(n,{isDisabled:k,isChecked:j,isPartiallyChecked:b,onValueChange:function(e){a(e?{type:"selected",data:{id:f,val:r,isRestricted:c}}:{type:"unselected",data:{id:f}}),u(e?f:"")}}),t(v,{children:e(g,{children:[t(h,{children:C(r.name,40,!0)}),r.isSmartCollection?t(d,{tagText:"Smart Collection",type:"warning"}):t(o,{})]})})]}),t(l,{disabled:k,onClick:()=>{k||(u(f),y("products"))},Icon:i})]}))};export{b as CollectionsScreen,C as truncate};
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};
@@ -35,11 +35,6 @@ export type ProductFetcherReturn = Promise<{
35
35
  [key: string]: Product;
36
36
  }>;
37
37
  export interface ProductPickerInterface {
38
- hideGlobalSearch?: boolean;
39
- hideInCollectionSearch?: boolean;
40
- customCollectionRestriction?: boolean;
41
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
42
- searchFetcher: (storeId: string, query: string) => Promise<SelectedItems>;
43
38
  collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
44
39
  productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
45
40
  storeId: string;
@@ -48,6 +43,5 @@ export interface ProductPickerInterface {
48
43
  onClose: () => void;
49
44
  visible: boolean;
50
45
  zIndex?: number;
51
- limit?: number;
52
46
  }
53
47
  export declare const ProductPickerModal: (props: ProductPickerInterface) => JSX.Element;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as s,useState as r,useEffect as l}from"react";import{COLORS as i}from"../../constants/Theme.js";import{Button as n}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as a}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as u}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{collectionsReducer as C,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 S=S=>{const{storeId:I,selectedItems:x,onClose:T,visible:P,zIndex:F,limit:D}=S,[k,E]=s(C,{}),[O,R]=r("collections"),[w,B]=r(""),[z,G]=r(0),[L,$]=r(!1),[A,H]=r(0),[M,Y]=r(""),[q,J]=r(!1),[K,N]=r(!1),[Q,U]=r(),[V,W]=s(v,Object.keys(x).length>0?x:{});l((()=>{$(!0),N(!0),S.collectionFetcher(z,I).then((e=>{E({type:"fetched",data:(null==e?void 0:e.collections)||{}}),$(!1),G((e=>e+1)),N(!1)})).catch()}),[]),l((()=>{let e=0;Object.keys(V||[]).forEach((t=>{var o;Object.keys((null===(o=V[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=V[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),H(e)})),l((()=>{var e;w&&!(null===(e=null==k?void 0:k[w])||void 0===e?void 0:e.products)&&($(!0),S.productFetcher(w,I).then((e=>{Object.keys(e).length&&E({type:"productsFetched",data:{collectionId:w,products:e}}),$(!1)})).catch())}),[w]),l((()=>{const e=setTimeout((()=>{M.length&&(J(!0),S.searchFetcher(I,M).then((e=>{U(e),R("searchProducts"),$(!1),J(!1)})))}),800);return()=>clearTimeout(e)}),[M]);const X=()=>{W({type:"reset",data:{}})};return e(a,Object.assign({zIndex:F,open:P,onClose:()=>{T(),X()},headingTitle:"collections"===O||"products"===O?"Select Products":"view"===O?"Selected Products":"searchProducts"===O?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:L?"Loading...":"Add",disabled:L||D&&A>D||!1,onClick:()=>{S.onAdd(V,A),X()}},footerLeftCustomElement:D&&A>D?e(p,{tagText:`You can only select ${D} products`,type:"negative"}):e(n,A>0?{onClick:()=>{R("view")},buttonText:`${A} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${A} products selected`,buttonType:"tertiaryGray"})},{children:t(j,{children:[!S.hideGlobalSearch&&e(o,{children:("collections"===O||"searchProducts"===O)&&e("div",Object.assign({style:{padding:16,paddingTop:0,height:"60px",borderBottom:"1px solid #E0E0E0"}},{children:e(d,{noErrorHint:!0,rightIcon:{icon:()=>q?e(h,{size:"small",color:i.content.primary}):e(c,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length&&Y(e)},placeholder:"Search products..."})}))}),t(b,{children:["collections"===O&&e(u,{customCollectionRestriction:S.customCollectionRestriction,dataLoading:K,collections:k,selectedCollectionsDispatch:W,setCollectionId:B,setScreen:R,selectedCollections:V,collectionFetcher:S.collectionFetcher,storeId:I,collectionsDispatch:E,setSaveDisabled:$,pagingControls:{curPage:z,setCurPage:G}}),"products"===O&&w&&e(g.Provider,Object.assign({value:w},{children:e(m,{hideInCollectionSearch:S.hideInCollectionSearch,customCollectionRestriction:S.customCollectionRestriction,productFetcher:S.productFetcher,setScreen:R,storeId:I,data:k[w],collectionsDispatch:E,selectedCollectionsDispatch:W,selectedData:V,setSaveDisabled:$,searchInCollectionFetcher:S.searchInCollectionFetcher})})),"view"===O&&e(f,{selectedCollections:V||{},selectedCollectionsDispatch:W,setScreen:R,collections:k}),"searchProducts"===O&&e(y,{customCollectionRestriction:S.customCollectionRestriction,selectedCollections:V||{},searchedCollections:Q||{},selectedCollectionsDispatch:W,setScreen:R,collections:k,onBackPress:()=>{Y(""),U({})}})]})]})}))};export{S as ProductPickerModal};
1
+ import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import{useReducer as c,useState as l,useEffect as s}from"react";import{Button as r}from"../button/Button.js";import{StyledModal as n}from"../modals/styledModal.js";import{CollectionsScreen as d}from"./collectionScreen.js";import{ProductsScreen as i}from"./productScreen.js";import{collectionsReducer as a,selectedColectionsReducer as p,CollectionIdContext as u}from"./reducers.js";import{SelectedScreen as h}from"./selectedScreen.js";import{ContainerStyle as m,ScrollContainerStyle as v}from"./style.js";const b=b=>{const{storeId:y,selectedItems:f,onClose:j,visible:C,zIndex:g}=b;console.log("selectedItems",f);const[S,I]=c(a,{}),[x,D]=l("collections"),[k,F]=l(""),[O,T]=l(0),[w,P]=c(p,Object.keys(f).length>0?f:{});console.log("selectedCollections",w),s((()=>{A(!0),b.collectionFetcher(O,y).then((e=>{I({type:"fetched",data:(null==e?void 0:e.collections)||{}}),A(!1),T((e=>e+1))})).catch()}),[]);const[E,A]=l(!1),[z,B]=l(0);s((()=>{let e=0;Object.keys(w||[]).forEach((t=>{var o;Object.keys((null===(o=w[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,l;Object.keys((null===(l=null===(c=w[t].products)||void 0===c?void 0:c[o])||void 0===l?void 0:l.variants)||[]).forEach((()=>{e+=1}))}))})),B(e)})),s((()=>{var e;k&&!(null===(e=null==S?void 0:S[k])||void 0===e?void 0:e.products)&&(A(!0),b.productFetcher(k,y).then((e=>{Object.keys(e).length&&(I({type:"productsFetched",data:{collectionId:k,products:e}}),A(!1))})).catch())}),[k]);const G=()=>{P({type:"reset",data:{}})};return e(n,Object.assign({zIndex:g,open:C,onClose:()=>{j(),G()},headingTitle:"collections"===x?"Select Products":"products"===x?S[k].name:"view"===x?"Selected Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:E?"Loading...":"Add",disabled:E,onClick:()=>{b.onAdd(w,z),G()}},footerLeftCustomElement:e(t,{children:e(r,z>0?{onClick:()=>{D("view")},buttonText:`${z} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${z} products selected`,buttonType:"tertiaryGray"})})},{children:e(m,{children:o(v,{children:["collections"===x&&e(d,{collections:S,selectedCollectionsDispatch:P,setCollectionId:F,setScreen:D,selectedCollections:w,collectionFetcher:b.collectionFetcher,storeId:y,collectionsDispatch:I,setSaveDisabled:A,pagingControls:{curPage:O,setCurPage:T}}),"products"===x&&k&&e(u.Provider,Object.assign({value:k},{children:e(i,{productFetcher:b.productFetcher,setScreen:D,storeId:y,data:S[k],collectionsDispatch:I,selectedCollectionsDispatch:P,selectedData:w,setSaveDisabled:A})})),"view"===x&&e(h,{selectedCollections:w||{},selectedCollectionsDispatch:P,upliftAdditions:null,setScreen:D,collections:S})]})})}))};export{b as ProductPickerModal};
@@ -2,13 +2,10 @@
2
2
  import { Collection, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
3
3
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
4
4
  interface ProductsScreenInterface {
5
- hideInCollectionSearch?: boolean;
6
- customCollectionRestriction?: boolean;
7
5
  data: Collection;
8
6
  collectionsDispatch: React.Dispatch<CollectionsActions>;
9
7
  selectedData: SelectedItems;
10
8
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
11
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
12
9
  productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
13
10
  storeId: string;
14
11
  setScreen: React.Dispatch<React.SetStateAction<string>>;
@@ -21,9 +18,9 @@ interface ProductGroupInterface {
21
18
  data: Product;
22
19
  selectedData: SelectedItems;
23
20
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
21
+ upliftAdditions: any;
24
22
  viewOnly: boolean;
25
23
  isProductPartiallyChecked?: boolean;
26
- upliftAdditions: any;
27
24
  }
28
25
  export declare const ProductGroup: (props: ProductGroupInterface) => JSX.Element;
29
26
  interface ProductCardInterface {
@@ -34,9 +31,9 @@ interface ProductCardInterface {
34
31
  variantId?: string;
35
32
  isSelected: boolean;
36
33
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
34
+ upliftAdditions: any;
37
35
  viewOnly: boolean;
38
36
  isPartiallyChecked?: boolean;
39
- upliftAdditions: any;
40
37
  }
41
38
  export declare const ProductCard: (props: ProductCardInterface) => JSX.Element;
42
39
  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 l from"../../assets/icons/box.svg.js";import d 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 O,ProductScreenCollectionCardStyle as k,ProductCardStyle as C}from"./style.js";import{liftTheStateUp as S}from"./utility.js";const x=o=>{const m=n(b),{data:j,collectionsDispatch:C,selectedData:x,selectedCollectionsDispatch:w,productFetcher:D,storeId:P,setScreen:A,setSaveDisabled:B,hideInCollectionSearch:T,customCollectionRestriction:V}=o,[F,R]=r(""),[U,W]=r(!1),[z,H]=r(j);s((()=>{const t=setTimeout((()=>{F.length?(W(!0),o.searchInCollectionFetcher(P,m,F).then((t=>{var e;const o=c(j);o.products={};for(const i of t)(null===(e=null==j?void 0:j.products)||void 0===e?void 0:e[i])&&(o.products[i]=j.products[i]);H(o),B(!1),W(!1)}))):H(j)}),800);return()=>clearTimeout(t)}),[F]);const N=!!V&&j.isSmartCollection,_=t=>{var e,o,i,l,d,c,n,r;let s=0,a=0;return!!((null===(o=null===(e=null==x?void 0:x[m])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(d=Object.keys((null===(l=null===(i=null==j?void 0:j.products)||void 0===i?void 0:i[t])||void 0===l?void 0:l.variants)||[]))||void 0===d||d.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)||q()}),[]);const q=()=>{B(!0),W(!0),D(m,P).then((t=>{Object.keys(t).length&&(C({type:"productsFetched",data:{collectionId:m,products:t}}),H(Object.assign(Object.assign({},z),{products:t}))),B(!1),W(!1)})).catch()},G=(t,e)=>{const o=S(e,j);w({type:t,data:Object.assign(Object.assign({},o),{isRestricted:V})})};return t("div",{children:[t(O,{children:[e(p,{Icon:i,height:16,onClick:()=>{A("collections")}}),e(f,Object.assign({style:{color:a.content.secondary}},{children:j.name}))]}),!T&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(v,{noErrorHint:!0,rightIcon:{icon:()=>U&&F.length?e(y,{size:"small",color:a.content.primary}):e(d,{})},id:"listInput",height:"24px",type:"text",value:F,onChangeText:t=>{t.length&&t.trim().length&&R(t)},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==z?void 0:z.products)||[]).length>0&&!N&&!F.length&&t(k,{children:[e(u,{isChecked:!!(null==x?void 0:x[m]),isPartiallyChecked:(t=>{var e;let o=0,i=0;if(x[t]){const l=null==j?void 0:j.products;l&&Object.keys(l).forEach((t=>{var e;const i=null===(e=l[t])||void 0===e?void 0:e.variants;i&&Object.keys(i).forEach((t=>o+=1))}));const d=null===(e=x[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((t=>i+=1))})),i>0&&o!==i}return!1})(m),onValueChange:function(t){w(t?{type:"selected",data:{id:m,val:j}}:{type:"unselected",data:{id:m}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(l,{})})),e(g,{children:"All Products"})]}),Object.keys((null==z?void 0:z.products)||[]).length?Object.keys(z.products||[]).map((t=>e(E,{collectionId:m,isProductPartiallyChecked:_(t),productId:t,data:z.products[t],selectedData:x,selectedCollectionsDispatch:w,viewOnly:!!N,upliftAdditions:G},t))):U?[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))):e(I,{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."})]})]})},E=o=>{const{collectionId:i,productId:l,data:d,selectedData:c,selectedCollectionsDispatch:n,viewOnly:r,upliftAdditions:s,isProductPartiallyChecked:a}=o,u=t=>{var e,o,d,n,r,s;if(!(null===(o=null===(e=null==c?void 0:c[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[l]))return!1;return!!(null===(s=null===(r=null===(n=null===(d=null==c?void 0:c[i])||void 0===d?void 0:d.products)||void 0===n?void 0:n[l])||void 0===r?void 0:r.variants)||void 0===s?void 0:s[t])};return t("div",{children:[e(w,{isVariant:!1,data:d,productId:l,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[l]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:s,viewOnly:r},l),Object.keys(d.variants||[]).map((t=>e(w,{isVariant:!0,data:d.variants[t],variantId:t,productId:l,viewOnly:r,upliftAdditions:s,collectionId:i,isSelected:u(t),selectedCollectionsDispatch:n},t)))]});var p,v},w=i=>{const{isVariant:l,data:d,productId:c,collectionId:n,variantId:r,isSelected:s,selectedCollectionsDispatch:a,viewOnly:p,upliftAdditions:v,isPartiallyChecked:h}=i;return t(C,Object.assign({isVariant:l},{children:[p?e(o,{}):e(u,{isChecked:s,isPartiallyChecked:h||!1,onValueChange:function(t){l?t?v("variantSelected",{productId:c,variantId:r,collectionId:n,variant:d}):a({type:"variantUnselected",data:{productId:c,variantId:r,collectionId:n}}):t?v("productSelected",{productId:c,collectionId:n,product:d}):a({type:"productUnselected",data:{productId:c,collectionId:n}})}}),e("div",{children:e(m,{width:40,height:40,imageUrl:d.image,alt:"Item",borderRadius:4})}),e(g,{children:j(d.name,40,!0)})]}))};export{w as ProductCard,E as ProductGroup,x 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 d from"../../assets/icons/box.svg.js";import{cloneDeep as l}from"lodash";import{useContext as c,useState as n,useEffect as r}from"react";import{COLORS as s}from"../../constants/Theme.js";import{CheckBox as a}from"../checkBox/CheckBox.js";import{IconButton as u}from"../icon-button/IconButton.js";import{BikShimmer as v}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as p}from"../shimmer-image/ShimmerImage.js";import{BodyCaption as h,TitleRegular as m}from"../TypographyStyle.js";import{truncate as y}from"./collectionScreen.js";import{CollectionIdContext as f}from"./reducers.js";import{ProductScreenHeader as j,ProductScreenCollectionCardStyle as I,ProductCardStyle as g}from"./style.js";const O=p=>{const y=c(f),{data:g,collectionsDispatch:O,selectedData:k,selectedCollectionsDispatch:C,productFetcher:D,storeId:S,setScreen:w,setSaveDisabled:x}=p,[E]=n(g),P=g.isSmartCollection||!1,A=t=>{var e,o,i,d,l,c,n,r;let s=0,a=0;return!!((null===(o=null===(e=null==k?void 0:k[y])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(l=Object.keys((null===(d=null===(i=null==g?void 0:g.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==k?void 0:k[y])||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))};r((()=>{(null==g?void 0:g.products)||(x(!0),D(y,S).then((t=>{Object.keys(t).length&&O({type:"productsFetched",data:{collectionId:y,products:t}}),x(!1)})).catch())}),[]);const V=(t,e)=>{const o=l(g);if(delete o.products,(e=Object.assign(Object.assign({},e),{catalogOnlyData:o})).productId&&g.products){const t=l(g.products[e.productId]);(null==t?void 0:t.variants)&&delete t.variants,e=Object.assign(Object.assign({},e),{catalogOnlyData:o,productOnlyData:t})}C({type:t,data:e})};return t("div",{children:[t(j,{children:[e(u,{Icon:i,height:16,onClick:()=>{w("collections")}}),e(h,Object.assign({style:{color:s.content.secondary}},{children:g.name}))]}),t("div",{children:[t(I,{children:[P?e(o,{}):e(a,{isChecked:!!(null==k?void 0:k[y]),isPartiallyChecked:(t=>{var e;let o=0,i=0;if(k[t]){const d=null==g?void 0:g.products;d&&Object.keys(d).forEach((t=>{var e;const i=null===(e=d[t])||void 0===e?void 0:e.variants;i&&Object.keys(i).forEach((t=>o+=1))}));const l=null===(e=k[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})(y),onValueChange:function(t){C(t?{type:"selected",data:{id:y,val:g}}:{type:"unselected",data:{id:y}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(d,{})})),e(m,{children:"All Products"})]}),Object.keys((null==E?void 0:E.products)||[]).length?Object.keys(E.products||[]).map((t=>e(b,{collectionId:y,isProductPartiallyChecked:A(t),productId:t,data:E.products[t],selectedData:k,selectedCollectionsDispatch:C,upliftAdditions:V,viewOnly:!!P},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(v,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})]})},b=o=>{const{collectionId:i,productId:d,data:l,selectedData:c,selectedCollectionsDispatch:n,upliftAdditions:r,viewOnly:s,isProductPartiallyChecked:a}=o,u=t=>{var e,o,l,n,r,s;if(!(null===(o=null===(e=null==c?void 0:c[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[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:[e(k,{isVariant:!1,data:l,productId:d,collectionId:i,isSelected:!!(null===(p=null===(v=null==c?void 0:c[i])||void 0===v?void 0:v.products)||void 0===p?void 0:p[d]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:r,viewOnly:s},d),Object.keys(l.variants||[]).map((t=>e(k,{isVariant:!0,data:l.variants[t],variantId:t,productId:d,viewOnly:s,collectionId:i,isSelected:u(t),selectedCollectionsDispatch:n,upliftAdditions:r},t)))]});var v,p},k=i=>{const{isVariant:d,data:l,productId:c,collectionId:n,variantId:r,isSelected:s,selectedCollectionsDispatch:u,upliftAdditions:v,viewOnly:h,isPartiallyChecked:f}=i;return t(g,Object.assign({isVariant:d},{children:[h?e(o,{}):e(a,{isChecked:s,isPartiallyChecked:f||!1,onValueChange:function(t){d?t?v("variantSelected",{productId:c,variantId:r,collectionId:n,variant:l}):u({type:"variantUnselected",data:{productId:c,variantId:r,collectionId:n}}):t?v("productSelected",{productId:c,collectionId:n,product:l}):u({type:"productUnselected",data:{productId:c,collectionId:n}})}}),e("div",{children:e(p,{width:40,height:40,imageUrl:l.image,alt:"Item",borderRadius:4})}),e(m,{children:y(l.name,40,!0)})]}))};export{k as ProductCard,b as ProductGroup,O 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,c,r,s,l;let u={},n="",i="",p="";switch(d.type){case"selected":return u=t(a),d.data.val.isSmartCollection&&(u={},u.isCustom=!0),u[d.data.id]=d.data.val,u;case"unselected":return u=t(a),(null==u?void 0:u.isCustom)&&(u.isCustom=!1),delete u[d.data.id],u;case"productUnselected":return u=t(a),n=d.data.productId,i=d.data.collectionId,delete u[i].products[n],Object.keys(u[i].products).length||((null==u?void 0:u.isCustom)&&(u.isCustom=!1),delete u[i]),u;case"productSelected":return u=t(a),n=d.data.productId,i=d.data.collectionId,(null==u?void 0:u[i])||(u[i]=d.data.catalogOnlyData,(null===(e=d.data.catalogOnlyData)||void 0===e?void 0:e.isSmartCollection)&&(u={},u.isCustom=!0),u[i].products={}),u[i].products[n]=d.data.product,u;case"variantSelected":return u=t(a),n=d.data.productId,i=d.data.collectionId,p=d.data.variantId,(null==u?void 0:u[i])||((null===(o=d.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(u={},u.isCustom=!0),u[i]=d.data.catalogOnlyData,u[i].products={},u[i].products[n]=d.data.productOnlyData,u[i].products[n].variants={}),(null===(r=null===(c=null==u?void 0:u[i])||void 0===c?void 0:c.products)||void 0===r?void 0:r[n])||((null===(s=null==u?void 0:u[i])||void 0===s?void 0:s.products)||(u[i].products={}),u[i].products[n]=d.data.productOnlyData,u[i].products[n].variants={}),u[i].products[n].variants[p]=d.data.variant,u;case"variantUnselected":return u=t(a),n=d.data.productId,i=d.data.collectionId,p=d.data.variantId,delete u[i].products[n].variants[p],Object.keys(u[i].products[n].variants).length||(delete u[i].products[n],Object.keys(u[i].products).length||((null===(l=u[i])||void 0===l?void 0:l.isSmartCollection)&&(u.isCustom=!1),delete u[i])),u;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};
@@ -4,6 +4,7 @@ import { SelectedCollectionsActions } from './reducers';
4
4
  interface SelectedScreenInterface {
5
5
  selectedCollections: SelectedItems;
6
6
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
7
+ upliftAdditions: any;
7
8
  setScreen: React.Dispatch<React.SetStateAction<string>>;
8
9
  collections: {
9
10
  [key: string]: Collection;
@@ -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 l}from"react/jsx-runtime";import t from"../../assets/icons/arrow_left.svg.js";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as e}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,upliftAdditions:u,setScreen:v,collections:a}=c,p=(o,l)=>{var t,i,e,d,r,c,s,u,v;let p=0,m=0;return!!((null===(i=null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||void 0===i?void 0:i[l])&&(null===(c=Object.keys((null===(r=null===(d=null===(e=null==a?void 0:a[o])||void 0===e?void 0:e.products)||void 0===d?void 0:d[l])||void 0===r?void 0:r.variants)||[]))||void 0===c||c.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(r,{children:[l(i,{Icon:t,onClick:()=>{v("collections")}}),l(e,{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 i=!1;return(null==n?void 0:n.isCustom)&&(i=!0),l(d,{collectionId:o,productId:t,data:n[o].products[t],isProductPartiallyChecked:p(o,t),selectedData:n,selectedCollectionsDispatch:s,upliftAdditions:u,viewOnly:i},t)}))}))})]})};export{c as SelectedScreen};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const WorkingStepper: () => JSX.Element;
3
2
  export declare enum STEPENUM {
4
3
  STEP1 = "STEP1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.159-beta.12",
3
+ "version": "0.0.159-beta.2",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
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;
@@ -1,7 +0,0 @@
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 {};
@@ -1,7 +0,0 @@
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,16 +0,0 @@
1
- /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
3
- import { SelectedCollectionsActions } from './reducers';
4
- interface SearchScreenInterface {
5
- customCollectionRestriction?: boolean;
6
- selectedCollections: SelectedItems;
7
- searchedCollections: SelectedItems;
8
- selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
9
- setScreen: React.Dispatch<React.SetStateAction<string>>;
10
- collections: {
11
- [key: string]: Collection;
12
- };
13
- onBackPress: () => void;
14
- }
15
- export declare const SearchScreen: (props: SearchScreenInterface) => JSX.Element;
16
- export {};
@@ -1 +0,0 @@
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"),i=require("../TypographyStyle.js"),l=require("./emptyState.js"),s=require("./productScreen.js"),r=require("./style.js"),c=require("./utility.js");exports.SearchScreen=d=>{const{customCollectionRestriction:n,selectedCollections:u,searchedCollections:a,selectedCollectionsDispatch:v,setScreen:j,collections:p,onBackPress:h}=d,y=(e,t)=>{var o,i,l,s,r,c,d,n,a;let v=0,j=0;return!!((null===(i=null===(o=null==u?void 0:u[e])||void 0===o?void 0:o.products)||void 0===i?void 0:i[t])&&(null===(c=Object.keys((null===(r=null===(s=null===(l=null==p?void 0:p[e])||void 0===l?void 0:l.products)||void 0===s?void 0:s[t])||void 0===r?void 0:r.variants)||[]))||void 0===c||c.forEach((()=>j++)),Object.keys((null===(a=null===(n=null===(d=null==u?void 0:u[e])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>v++)),v>0&&j!==v))};return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{j("collections"),h()}}),e.jsx(i.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(a).length?e.jsx(e.Fragment,{children:Object.keys(a).map((t=>{var o;return Object.keys((null===(o=null==a?void 0:a[t])||void 0===o?void 0:o.products)||[]).map((o=>{let i=!1;return(null==a?void 0:a.isCustom)&&(i=!0),e.jsx(s.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{const i=c.liftTheStateUp(o,a[e]);v({type:t,data:Object.assign(Object.assign({},i),{isRestricted:n})})})(t,e,o),productId:o,data:a[t].products[o],isProductPartiallyChecked:y(t,o),selectedData:u,selectedCollectionsDispatch:v,viewOnly:i},o)}))}))}):e.jsx(l.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
@@ -1 +0,0 @@
1
- export declare const liftTheStateUp: (payload: any, data: any) => any;
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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};
@@ -1,7 +0,0 @@
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 {};
@@ -1,7 +0,0 @@
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,16 +0,0 @@
1
- /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
3
- import { SelectedCollectionsActions } from './reducers';
4
- interface SearchScreenInterface {
5
- customCollectionRestriction?: boolean;
6
- selectedCollections: SelectedItems;
7
- searchedCollections: SelectedItems;
8
- selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
9
- setScreen: React.Dispatch<React.SetStateAction<string>>;
10
- collections: {
11
- [key: string]: Collection;
12
- };
13
- onBackPress: () => void;
14
- }
15
- export declare const SearchScreen: (props: SearchScreenInterface) => JSX.Element;
16
- export {};
@@ -1 +0,0 @@
1
- import{jsxs as o,jsx as t,Fragment as e}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import{IconButton as l}from"../icon-button/IconButton.js";import{BodyCaption as r}from"../TypographyStyle.js";import{EmptyState as s}from"./emptyState.js";import{ProductGroup as c}from"./productScreen.js";import{SelectedScreenHeader as d}from"./style.js";import{liftTheStateUp as n}from"./utility.js";const u=u=>{const{customCollectionRestriction:v,selectedCollections:a,searchedCollections:p,selectedCollectionsDispatch:m,setScreen:h,collections:f,onBackPress:j}=u,y=(o,t)=>{var e,i,l,r,s,c,d,n,u;let v=0,p=0;return!!((null===(i=null===(e=null==a?void 0:a[o])||void 0===e?void 0:e.products)||void 0===i?void 0:i[t])&&(null===(c=Object.keys((null===(s=null===(r=null===(l=null==f?void 0:f[o])||void 0===l?void 0:l.products)||void 0===r?void 0:r[t])||void 0===s?void 0:s.variants)||[]))||void 0===c||c.forEach((()=>p++)),Object.keys((null===(u=null===(n=null===(d=null==a?void 0:a[o])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>v++)),v>0&&p!==v))};return o("div",{children:[o(d,{children:[t(l,{Icon:i,onClick:()=>{h("collections"),j()}}),t(r,{children:"Searched Products"})]}),t("div",{children:Object.keys(p).length?t(e,{children:Object.keys(p).map((o=>{var e;return Object.keys((null===(e=null==p?void 0:p[o])||void 0===e?void 0:e.products)||[]).map((e=>{let i=!1;return(null==p?void 0:p.isCustom)&&(i=!0),t(c,{collectionId:o,upliftAdditions:(t,e)=>((o,t,e)=>{const i=n(e,p[o]);m({type:t,data:Object.assign(Object.assign({},i),{isRestricted:v})})})(o,t,e),productId:e,data:p[o].products[e],isProductPartiallyChecked:y(o,e),selectedData:a,selectedCollectionsDispatch:m,viewOnly:i},e)}))}))}):t(s,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{u as SearchScreen};
@@ -1 +0,0 @@
1
- export declare const liftTheStateUp: (payload: any, data: any) => any;
@@ -1 +0,0 @@
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};