@bikdotai/bik-component-library 0.0.456-1 → 0.0.456-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 (75) hide show
  1. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/Legend/Legend.js +1 -1
  2. package/dist/cjs/components/product-picker-v2/ProductPickerShimmer.d.ts +3 -0
  3. package/dist/cjs/components/product-picker-v2/ProductPickerShimmer.js +1 -0
  4. package/dist/cjs/components/product-picker-v2/ProductPickerTag.d.ts +19 -0
  5. package/dist/cjs/components/product-picker-v2/ProductPickerTag.js +1 -0
  6. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +19 -0
  7. package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
  8. package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.d.ts +5 -0
  9. package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.js +1 -1
  10. package/dist/cjs/components/product-picker-v2/modal.d.ts +16 -3
  11. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  12. package/dist/cjs/components/product-picker-v2/product.d.ts +43 -0
  13. package/dist/cjs/components/product-picker-v2/product.js +1 -0
  14. package/dist/cjs/components/product-picker-v2/productInfoOverlay.d.ts +17 -0
  15. package/dist/cjs/components/product-picker-v2/productInfoOverlay.js +39 -0
  16. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +6 -37
  17. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  18. package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
  19. package/dist/cjs/components/product-picker-v2/rearrangeScreen.js +1 -1
  20. package/dist/cjs/components/product-picker-v2/reducers.d.ts +25 -1
  21. package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
  22. package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +10 -3
  23. package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
  24. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +5 -2
  25. package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
  26. package/dist/cjs/components/product-picker-v2/style.d.ts +1 -0
  27. package/dist/cjs/components/product-picker-v2/style.js +32 -12
  28. package/dist/cjs/components/product-picker-v2/utility.d.ts +37 -0
  29. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  30. package/dist/cjs/components/product-picker-v2/variant.js +1 -1
  31. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  32. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  33. package/dist/cjs/components/template-context-mapper/modalElements/ProductBox.d.ts +1 -0
  34. package/dist/cjs/components/template-context-mapper/modalElements/ProductBox.js +2 -2
  35. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
  36. package/dist/esm/components/analytics-chips-and-dropdowns/chart/Legend/Legend.js +1 -1
  37. package/dist/esm/components/product-picker-v2/ProductPickerShimmer.d.ts +3 -0
  38. package/dist/esm/components/product-picker-v2/ProductPickerShimmer.js +1 -0
  39. package/dist/esm/components/product-picker-v2/ProductPickerTag.d.ts +19 -0
  40. package/dist/esm/components/product-picker-v2/ProductPickerTag.js +1 -0
  41. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +19 -0
  42. package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
  43. package/dist/esm/components/product-picker-v2/helpers/ProductHelper.d.ts +5 -0
  44. package/dist/esm/components/product-picker-v2/helpers/ProductHelper.js +1 -1
  45. package/dist/esm/components/product-picker-v2/modal.d.ts +16 -3
  46. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  47. package/dist/esm/components/product-picker-v2/product.d.ts +43 -0
  48. package/dist/esm/components/product-picker-v2/product.js +1 -0
  49. package/dist/esm/components/product-picker-v2/productInfoOverlay.d.ts +17 -0
  50. package/dist/esm/components/product-picker-v2/productInfoOverlay.js +39 -0
  51. package/dist/esm/components/product-picker-v2/productScreen.d.ts +6 -37
  52. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  53. package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
  54. package/dist/esm/components/product-picker-v2/rearrangeScreen.js +1 -1
  55. package/dist/esm/components/product-picker-v2/reducers.d.ts +25 -1
  56. package/dist/esm/components/product-picker-v2/reducers.js +1 -1
  57. package/dist/esm/components/product-picker-v2/searchScreen.d.ts +10 -3
  58. package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
  59. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +5 -2
  60. package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
  61. package/dist/esm/components/product-picker-v2/style.d.ts +1 -0
  62. package/dist/esm/components/product-picker-v2/style.js +32 -12
  63. package/dist/esm/components/product-picker-v2/utility.d.ts +37 -0
  64. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  65. package/dist/esm/components/product-picker-v2/variant.js +1 -1
  66. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  67. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  68. package/dist/esm/components/template-context-mapper/modalElements/ProductBox.d.ts +1 -0
  69. package/dist/esm/components/template-context-mapper/modalElements/ProductBox.js +2 -2
  70. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +4 -4
  71. package/package.json +1 -1
  72. package/dist/cjs/components/product-picker-v2/helpers/AllProductHelper.d.ts +0 -4
  73. package/dist/cjs/components/product-picker-v2/helpers/AllProductHelper.js +0 -1
  74. package/dist/esm/components/product-picker-v2/helpers/AllProductHelper.d.ts +0 -4
  75. package/dist/esm/components/product-picker-v2/helpers/AllProductHelper.js +0 -1
@@ -1 +1 @@
1
- import{OUT_OF_STOCK_ACTION as n}from"../type.js";const t={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"};class i{static getProductLabels(i){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.NORMAL,u="NORMAL";if(i.variants)return t[u];const d=i;return l===n.HIDE&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),l===n.BLUR&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="OUT_OF_STOCK"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),l===n.NORMAL&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NORMAL"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),t[u]}}const l=n=>{let t=[];Object.keys(n).forEach((i=>{var l;return Object.keys((null===(l=null==n?void 0:n[i])||void 0===l?void 0:l.products)||[]).forEach((l=>{var u,d;const o=null!==(u=n[i].products)&&void 0!==u?u:[],a=null!==(d=o[l].variants)&&void 0!==d?d:[];return Object.keys(a).map((n=>{const t=a[n];t.variantId=n,t.productId=l,t.collectionId=i,t.productName=o[l].name})),t=[...t,...Object.values(a)],t}))}));const i=t.sort(((n,t)=>null==n.displayOrder&&null==t.displayOrder?0:null==n.displayOrder?1:null==t.displayOrder?-1:n.displayOrder-t.displayOrder));return i.forEach(((n,t)=>{n.displayOrder=t})),i};export{i as ProductHelper,l as parseSelectedVariantsToArray};
1
+ import{OUT_OF_STOCK_ACTION as n}from"../type.js";const t={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock",FB_REJECTED:"Rejected on FB catalog"};class l{static getProductLabels(l){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.NORMAL,u="NORMAL";if(l.variants)return t[u];const a=l;return"REJECTED"===(null==a?void 0:a.fbStatus)?t.FB_REJECTED:(i===n.HIDE&&(!a.skipSync||0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)||(u="NOT_SYNCED"),a.skipSync&&0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)&&(u="NOT_SYNCED"),a.skipSync||0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)||(u="NOT_SYNCED"),a.skipSync||0===(null==a?void 0:a.quantity)||-2===(null==a?void 0:a.quantity)||(u="NORMAL")),i===n.BLUR&&(!a.skipSync||0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)||(u="NOT_SYNCED"),a.skipSync&&0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)&&(u="NOT_SYNCED"),a.skipSync||0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)||(u="OUT_OF_STOCK"),a.skipSync||0===(null==a?void 0:a.quantity)||-2===(null==a?void 0:a.quantity)||(u="NORMAL")),i===n.NORMAL&&(!a.skipSync||0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)||(u="NOT_SYNCED"),a.skipSync&&0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)&&(u="NOT_SYNCED"),a.skipSync||0!==(null==a?void 0:a.quantity)&&-2!==(null==a?void 0:a.quantity)||(u="NORMAL"),a.skipSync||0===(null==a?void 0:a.quantity)||-2===(null==a?void 0:a.quantity)||(u="NORMAL")),t[u])}}Object.defineProperty(l,"getTagType",{enumerable:!0,configurable:!0,writable:!0,value:n=>t.FB_REJECTED===n?"negative":"warning"});const i=n=>{let t=[];Object.keys(n).forEach((l=>{var i;return Object.keys((null===(i=null==n?void 0:n[l])||void 0===i?void 0:i.products)||[]).forEach((i=>{var u,a;const d=null!==(u=n[l].products)&&void 0!==u?u:[],o=null!==(a=d[i].variants)&&void 0!==a?a:[];return Object.keys(o).map((n=>{const t=o[n];t.variantId=n,t.productId=i,t.collectionId=l,t.productName=d[i].name})),t=[...t,...Object.values(o)],t}))}));const l=t.sort(((n,t)=>null==n.displayOrder&&null==t.displayOrder?0:null==n.displayOrder?1:null==t.displayOrder?-1:n.displayOrder-t.displayOrder));return l.forEach(((n,t)=>{n.displayOrder=t})),l};export{l as ProductHelper,i as parseSelectedVariantsToArray};
@@ -7,10 +7,13 @@ export interface ProductVariant {
7
7
  quantity: number;
8
8
  skipSync?: boolean;
9
9
  displayOrder?: number | null;
10
+ fbStatus?: FbProductStatus;
11
+ description?: string;
10
12
  }
11
13
  export interface Product {
12
14
  name: string;
13
15
  image: string;
16
+ description?: string;
14
17
  variants?: {
15
18
  [key: string]: ProductVariant;
16
19
  };
@@ -26,6 +29,10 @@ export interface Collection {
26
29
  export type SelectedItems = {
27
30
  [key: string]: Collection;
28
31
  };
32
+ export type SearchedItems = {
33
+ collections: SelectedItems;
34
+ products: SelectedItems;
35
+ };
29
36
  export type CollectionFetcherReturn = Promise<{
30
37
  collections: {
31
38
  [key: string]: {
@@ -38,6 +45,10 @@ export type CollectionFetcherReturn = Promise<{
38
45
  export type ProductFetcherReturn = Promise<{
39
46
  [key: string]: Product;
40
47
  }>;
48
+ export type FbStatusFetcherReturn = Promise<{
49
+ [key: string]: FbProductStatus;
50
+ }>;
51
+ export type FbProductStatus = 'APPROVED' | 'REJECTED';
41
52
  export declare enum ScreenName {
42
53
  Collections = "collections",
43
54
  RearrangeProducts = "rearrange",
@@ -49,10 +60,11 @@ export type ProductPickerInterface = {
49
60
  hideGlobalSearch?: boolean;
50
61
  hideInCollectionSearch?: boolean;
51
62
  customCollectionRestriction?: boolean;
52
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
53
- searchFetcher: (storeId: string, query: string) => Promise<SelectedItems>;
63
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
64
+ searchFetcher: (storeId: string, query: string) => Promise<SearchedItems | SelectedItems>;
54
65
  collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
55
- productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
66
+ productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
67
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
56
68
  storeId: string;
57
69
  selectedItems: SelectedItems;
58
70
  onAdd: (items: SelectedItems, total: number) => void;
@@ -77,6 +89,7 @@ export type ProductPickerInterface = {
77
89
  rearrangeEnabled?: boolean;
78
90
  selectSingleItem?: boolean;
79
91
  stickyFooter?: boolean;
92
+ showProductDetails?: boolean;
80
93
  } & ({
81
94
  startupScreen: ScreenName.RearrangeProducts;
82
95
  rearrangeEnabled: true;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as i,useRef as s,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as C}from"./rearrangeScreen.js";import{collectionsReducer as v,selectedColectionsReducer as y,CollectionIdContext as b}from"./reducers.js";import{SearchScreen as f}from"./searchScreen.js";import{SelectedScreen as S}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as x}from"./type.js";var P;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(P||(P={}));const T=T=>{const{storeId:I,selectedItems:O,onClose:F,visible:R,zIndex:w,exactLimit:D,limit:E,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:A=x.BLUR,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,hideSelectionCount:z,title:M,width:G,renderWithoutModal:H,onClickSave:W,pickerType:Y,hideProductVariants:K=!1,startupScreen:U=P.Collections,rearrangeEnabled:q,selectSingleItem:J=!1}=T,[N,Q]=r(v,{}),[X,Z]=i([P.Collections,P.RearrangeProducts].includes(U)?U:P.Collections),[_,ee]=i("grid"),[te,oe]=i(""),[ce,re]=i(0),[ie,se]=i(!1),[ne,le]=i(0),[de,ae]=i(""),[ue,he]=i(!1),[pe,me]=i(!1),[ge,Ce]=i(),[ve,ye]=r(y,Object.keys(O).length>0?O:{}),be=s(null);n((()=>{se(!0),me(!0),T.collectionFetcher(ce,I).then((e=>{Q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),se(!1),re((e=>e+1)),me(!1)})).catch()}),[]),n((()=>{console.log({selectedCollections:ve});let e=0;K?Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&ve[-1]&&(null===(c=ve[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ve[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),le(e)}),[ve,K]),n((()=>{var e;te&&!(null===(e=null==N?void 0:N[te])||void 0===e?void 0:e.products)&&(se(!0),T.productFetcher(te,I).then((e=>{Object.keys(e).length&&Q({type:"productsFetched",data:{collectionId:te,products:e}}),se(!1)})).catch())}),[te]),n((()=>{const e=setTimeout((()=>{"rearrange"!==X&&(de.length?(he(!0),T.searchFetcher(I,de).then((e=>{Ce(Object.assign({},e)),Z("searchProducts"),se(!1),he(!1)}))):Z("collections"))}),800);return()=>clearTimeout(e)}),[de]),n((()=>{W&&(T.onAdd(ve,ne),fe())}),[W]),n((()=>{J&&Object.keys(ve||{}).length&&ne&&(T.onAdd(ve,ne),fe())}),[J,ve,ne]);const fe=()=>{ye({type:"reset",data:{}})},Se=e(j,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===X||"searchProducts"===X)&&t("div",Object.assign({style:{padding:H?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ue?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:de,onChangeText:e=>{e.length&&e.trim().length?ae(e):ae("")}})}))}),e(k,Object.assign({ref:be},{children:["collections"===X&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:pe,collections:N,selectedCollectionsDispatch:ye,setCollectionId:oe,setScreen:Z,selectedCollections:ve,collectionFetcher:T.collectionFetcher,storeId:I,collectionsDispatch:Q,setSaveDisabled:se,pagingControls:{curPage:ce,setCurPage:re},hideCollectionCheckbox:V,renderWithoutModal:H,pickerType:Y}),"products"===X&&te&&t(b.Provider,Object.assign({value:te},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:Z,storeId:I,data:N[te],collectionsDispatch:Q,selectedCollectionsDispatch:ye,selectedData:ve,setSaveDisabled:se,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:A,hideVariantCheckbox:B,selectProductsFromCustomCollection:L,renderWithoutModal:H,pickerType:Y,hideProductVariants:K})})),"view"===X&&t(S,{selectedCollections:ve||{},selectedCollectionsDispatch:ye,setScreen:Z,collections:N,hideProductVariants:K}),"rearrange"===X&&t(C,{selectedCollections:ve||{},selectedCollectionsDispatch:ye,setScreen:Z,outOfStockAction:A,rearrangeViewType:"grid"===_?"list":"grid",scrollContainerRef:be}),"searchProducts"===X&&t(f,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ve||{},searchedCollections:ge||{},selectedCollectionsDispatch:ye,setScreen:Z,collections:N,onBackPress:()=>{ae(""),Ce({})},pickerType:Y,hideProductCheckbox:$,hideProductVariants:K,hideVariantCheckbox:B})]}))]});return t(o,{children:H?Se:t(u,Object.assign({zIndex:w,open:R,onClose:()=>{null==F||F(),fe()},headingTitle:M||("collections"===X||"products"===X?"Select Products":"view"===X?"Selected Products":"searchProducts"===X?"Searched Products":"rearrange"===X?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:G||"480px"},headerRightCustomElement:"rearrange"===X?(console.log("ignore:",ee),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:{buttonText:ie?"Loading...":X===P.RearrangeProducts?"Done":"Add",disabled:ie||ne<1||D&&ne<D||!D&&E&&ne>E||!1,onClick:()=>{T.onAdd(ve,ne),fe()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:z?t(o,{}):D&&ne>D?t(p,{tagText:`You can only select ${D} products`,type:"negative"}):E&&ne>E?t(p,{tagText:`You can only select ${E} products`,type:"negative"}):t(d,ne>0?{onClick:()=>{Z(q?P.RearrangeProducts:P.SelectedProducts)},buttonText:D?`${ne}/${D} products selected`:`${ne} products selected`,buttonType:["rearrange","view"].includes(X)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(X)}:{disabled:!0,buttonText:D?`${ne}/${D} products selected`:`${ne} products selected`,buttonType:"tertiaryGray"})},{children:Se}))})};export{T as ProductPickerModal,P as ScreenName};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as y,selectedColectionsReducer as S,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:D,selectedItems:O,onClose:w,visible:R,zIndex:E,exactLimit:A,limit:$,hideCollectionCheckbox:V,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:U,hideProductVariants:q=!1,startupScreen:J=F.Collections,rearrangeEnabled:N,selectSingleItem:Q=!1,showProductDetails:X}=T,[Z,_]=r(f,{}),[ee,te]=s([F.Collections,F.RearrangeProducts].includes(J)?J:F.Collections),[oe,ce]=s("grid"),[re,se]=s(""),[ie,ne]=s(""),[le,de]=s(0),[ae,ue]=s(!1),[he,pe]=s(0),[me,Ce]=s(""),[ge,be]=s(!1),[fe,ye]=s(!1),[Se,ve]=r(y,{collections:{},products:{}}),[ke,Pe]=r(S,Object.keys(O).length>0?O:{}),xe=i(null),[je,Ie]=s(!1),[Fe,Te]=s();n((()=>{ue(!0),ye(!0),T.collectionFetcher(le,D).then((e=>{_({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ue(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),n((()=>{let e=0;Object.keys(ke||[]).forEach((t=>{var o;Object.keys((null===(o=ke[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ke[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),pe(e)})),n((()=>{ie&&(ue(!0),T.productFetcher(ie,D).then((e=>{Object.keys(e).length&&_({type:"productsFetched",data:{collectionId:ie,products:e}}),ue(!1)})).catch())}),[ie]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ee&&(me.length?(be(!0),T.searchFetcher(D,me).then((e=>{"collections"in e&&"products"in e?(ve({type:"set",data:e}),_({type:"searched",data:e.collections})):(ve({type:"set",data:{collections:{},products:e}}),_({type:"searched",data:e})),te("searchProducts"),ue(!1),be(!1)}))):te("collections"))}),800);return()=>clearTimeout(e)}),[me]),n((()=>{K&&(T.onAdd(ke,he),De())}),[K]),n((()=>{Q&&Object.keys(ke||{}).length&&he&&(T.onAdd(ke,he),De())}),[Q,ke,he]);const De=()=>{Pe({type:"reset",data:{}})},Oe=e(x,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===ee||"searchProducts"===ee)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:me,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e(j,Object.assign({ref:xe},{children:["collections"===ee&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:fe,collections:Z,selectedCollectionsDispatch:Pe,setCollectionId:se,setSelectedCollectionId:ne,setScreen:te,selectedCollections:ke,collectionFetcher:T.collectionFetcher,storeId:D,collectionsDispatch:_,setSaveDisabled:ue,pagingControls:{curPage:le,setCurPage:de},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:U}),"products"===ee&&re&&t(v.Provider,Object.assign({value:re},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:te,storeId:D,data:Z[re],collectionsDispatch:_,selectedCollectionsDispatch:Pe,selectedData:ke,setSaveDisabled:ue,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:U,hideProductVariants:q,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Te(e)},showProductDetailInfoIcon:X})})),"view"===ee&&t(P,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,outOfStockAction:L,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===ee&&t(b,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,outOfStockAction:L,rearrangeViewType:"grid"===oe?"list":"grid",scrollContainerRef:xe,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===ee&&t(k,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ke||{},searchedCollections:Se||{},searchedCollectionsDispatch:ve,selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,onBackPress:()=>{Ce(""),ve({type:"set",data:{collections:{},products:{}}})},pickerType:U,hideProductCheckbox:B,hideProductVariants:q,hideVariantCheckbox:M,storeId:D,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:ne,renderWithoutModal:Y,hideCollectionCheckbox:V})]}))]});return t(o,{children:Y?Oe:e(u,Object.assign({zIndex:E,open:R,onClose:()=>{null==w||w(),De()},headingTitle:G||("collections"===ee||"products"===ee?"Select Products":"view"===ee?"Selected Products":"searchProducts"===ee?"Searched Products":"rearrange"===ee?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:"rearrange"===ee?(console.log("ignore:",ce),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:{buttonText:ae?"Loading...":ee===F.RearrangeProducts?"Done":"Add",disabled:ae||he<1||A&&he<A||!A&&$&&he>$||!1,onClick:()=>{T.onAdd(ke,he),De()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&he>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):$&&he>$?t(p,{tagText:`You can only select ${$} products`,type:"negative"}):t(d,he>0?{onClick:()=>{te(N?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:["rearrange","view"].includes(ee)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ee)}:{disabled:!0,buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:je},{children:[Oe,je&&Fe?t(C,{productData:Fe,outOfStockAction:L,onClose:()=>{Ie(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,F as ScreenName};
@@ -0,0 +1,43 @@
1
+ /// <reference types="react" />
2
+ import { Product, ProductVariant, SelectedItems } from './modal';
3
+ import { SelectedCollectionsActions } from './reducers';
4
+ import { OUT_OF_STOCK_ACTION } from './type';
5
+ interface ProductGroupInterface {
6
+ collectionId: string;
7
+ productId: string;
8
+ data: Product;
9
+ selectedData: SelectedItems;
10
+ selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
11
+ viewOnly: boolean;
12
+ isProductPartiallyChecked?: boolean;
13
+ upliftAdditions: any;
14
+ hideProductCheckbox?: boolean;
15
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
16
+ hideVariantCheckbox?: boolean;
17
+ hideProductVariants?: boolean;
18
+ showProductDetailInfoIcon?: boolean;
19
+ pickerType?: 'COLLECTION' | 'PRODUCT';
20
+ onProductDetailClick?: (productData: Product | ProductVariant) => void;
21
+ }
22
+ export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
23
+ interface ProductCardInterface {
24
+ isVariant: boolean;
25
+ data: Product | ProductVariant;
26
+ productId: string;
27
+ collectionId: string;
28
+ variantId?: string;
29
+ isSelected: boolean;
30
+ selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
31
+ viewOnly: boolean;
32
+ isPartiallyChecked?: boolean;
33
+ upliftAdditions: any;
34
+ hideProductCheckbox?: boolean;
35
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
36
+ hideVariantCheckbox?: boolean;
37
+ hideProductVariants?: boolean;
38
+ showProductDetailInfoIcon?: boolean;
39
+ pickerType?: 'COLLECTION' | 'PRODUCT';
40
+ onProductDetailClick?: (productData: Product | ProductVariant) => void;
41
+ }
42
+ export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
43
+ export {};
@@ -0,0 +1 @@
1
+ import{jsxs as t,jsx as i,Fragment as o}from"react/jsx-runtime";import{COLORS as e}from"../../constants/Theme.js";import c from"../../assets/icons/info.svg.js";import{CheckBox as d}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{ShimmerImage as l}from"../shimmer-image/ShimmerImage.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{BodyPrimary as r}from"../TypographyStyle.js";import{ProductPickerTag as s}from"./ProductPickerTag.js";import{ProductCardStyle as u}from"./style.js";import{shouldShowVariant as p}from"./utility.js";const h=o=>{const{collectionId:e,productId:c,data:d,selectedData:n,selectedCollectionsDispatch:l,viewOnly:a,upliftAdditions:r,isProductPartiallyChecked:s,hideProductCheckbox:u,outOfStockAction:h,hideVariantCheckbox:m,hideProductVariants:I,pickerType:f,onProductDetailClick:k,showProductDetailInfoIcon:y}=o,C=t=>{var i,o,d,l,a,r;if(!(null===(o=null===(i=null==n?void 0:n[e])||void 0===i?void 0:i.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(r=null===(a=null===(l=null===(d=null==n?void 0:n[e])||void 0===d?void 0:d.products)||void 0===l?void 0:l[c])||void 0===a?void 0:a.variants)||void 0===r?void 0:r[t])};return t("div",{children:[i(v,{isVariant:!1,data:d,productId:c,collectionId:e,isSelected:!!(null===(b=null===(P=null==n?void 0:n[e])||void 0===P?void 0:P.products)||void 0===b?void 0:b[c]),isPartiallyChecked:s,selectedCollectionsDispatch:l,upliftAdditions:r,viewOnly:a,hideProductCheckbox:u,hideVariantCheckbox:m,hideProductVariants:I,pickerType:f,outOfStockAction:h,onProductDetailClick:k,showProductDetailInfoIcon:y},c),I?null:p(d)&&Object.keys(d.variants||[]).map((t=>i(v,{isVariant:!0,hideVariantCheckbox:m,data:d.variants[t],variantId:t,productId:c,viewOnly:a,upliftAdditions:r,collectionId:e,isSelected:C(t),selectedCollectionsDispatch:l,outOfStockAction:h,onProductDetailClick:k,showProductDetailInfoIcon:y},t)))]});var P,b},v=p=>{const{isVariant:h,data:v,productId:m,collectionId:I,variantId:f,isSelected:k,selectedCollectionsDispatch:y,viewOnly:C,upliftAdditions:P,isPartiallyChecked:b,hideProductCheckbox:j,outOfStockAction:g,hideVariantCheckbox:O,hideProductVariants:x,pickerType:D,onProductDetailClick:S,showProductDetailInfoIcon:V}=p;return t(u,Object.assign({isVariant:h,onClick:t=>{"PRODUCT"===D&&x&&(t.stopPropagation(),y({type:"reset",data:{}}),P("variantSelected",{productId:m,variantId:f||Object.keys(v.variants)[0],collectionId:I,variant:v}))},isActive:k},{children:[h&&!C&&!O||!h&&!C&&!j?i(d,{isChecked:k,isPartiallyChecked:b||!1,onValueChange:function(t){h?t?P("variantSelected",{productId:m,variantId:f,collectionId:I,variant:v}):y({type:"variantUnselected",data:{productId:m,variantId:f,collectionId:I}}):t?P("productSelected",{productId:m,collectionId:I,product:v}):y({type:"productUnselected",data:{productId:m,collectionId:I}})}}):i(o,{}),i("div",{children:i(l,{width:40,height:40,imageUrl:v.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[i(a,Object.assign({variant:"light",body:v.name,placement:"bottom",delay:400},{children:i(r,Object.assign({numberOfLines:1},{children:v.name}))})),V&&i(n,{onClick:()=>{null==S||S(v)},Icon:()=>i(c,{width:20,height:20,color:e.content.placeholder})})]})),i(s,{isVariant:h,data:v,outOfStockAction:g})]}))]}))};export{v as ProductCard,h as ProductGroup};
@@ -0,0 +1,17 @@
1
+ import { Product, ProductVariant } from './modal';
2
+ import { OUT_OF_STOCK_ACTION } from './type';
3
+ /**
4
+ * When user presses i icon on a product, we show the overlay.
5
+ * In case of a product, contains products image, product name & description
6
+ * In case of a variant, contains variant image, variant name,
7
+ * description as product name, variant tag
8
+ */
9
+ export declare const ProductInfoOverlay: (props: {
10
+ productData: Product | ProductVariant;
11
+ onClose: () => void;
12
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
13
+ }) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const ProductInfoCard: (props: {
15
+ productData: Product | ProductVariant;
16
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
17
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import{jsxs as o,jsx as t}from"react/jsx-runtime";import i from"styled-components";import{COLORS as r}from"../../constants/Theme.js";import e from"../../assets/icons/cross.svg.js";import{IconButton as a}from"../icon-button/IconButton.js";import{ShimmerImage as n}from"../shimmer-image/ShimmerImage.js";import{TitleSmall as d,BodyCaption as s}from"../TypographyStyle.js";import{ProductPickerTag as c}from"./ProductPickerTag.js";const l=i=>o(m,{children:[t(u,{}),t(x,{children:t(a,{className:"close-button",onClick:i.onClose,Icon:e,width:20,height:20})}),t(p,{productData:i.productData,outOfStockAction:i.outOfStockAction})]}),p=i=>{var r;const e=void 0===i.productData.variants;return o(f,{children:[t(g,{children:t(n,{imageUrl:i.productData.image,width:"200px",height:200,borderRadius:4})}),o(h,{children:[t(d,Object.assign({style:{display:"flex"}},{children:i.productData.name})),t(s,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(r=i.productData.description)&&void 0!==r?r:""}}),t(c,{isVariant:e,data:i.productData,outOfStockAction:i.outOfStockAction})]})]})},m=i.div`
2
+ display: flex;
3
+ flex: 1;
4
+ background: rgba(0, 0, 0, 0.5);
5
+ flex-direction: column;
6
+ width: 100%;
7
+ height: 100%;
8
+ position: absolute;
9
+ bottom: 0;
10
+ z-index: 10;
11
+ `,u=i.div`
12
+ display: flex;
13
+ flex: 1;
14
+ background: rgba(0, 0, 0, 0.5);
15
+ `,x=i.div`
16
+ position: relative;
17
+
18
+ .close-button {
19
+ position: absolute;
20
+ top: -50px;
21
+ right: 0px;
22
+ margin: 10px;
23
+ background: ${r.surface.standard};
24
+ border-radius: 50%;
25
+ }
26
+ `,f=i.div`
27
+ display: flex;
28
+ background: white;
29
+ padding: 24px;
30
+ gap: 24px;
31
+ border-radius: 8px 8px 0px 0px;
32
+ `,g=i.div`
33
+ display: flex;
34
+ `,h=i.div`
35
+ display: flex;
36
+ flex: 1;
37
+ flex-direction: column;
38
+ gap: 10px;
39
+ `;export{p as ProductInfoCard,l as ProductInfoOverlay};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Collection, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
2
+ import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
3
3
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
4
4
  import { OUT_OF_STOCK_ACTION } from './type';
5
5
  interface ProductsScreenInterface {
@@ -9,8 +9,8 @@ interface ProductsScreenInterface {
9
9
  collectionsDispatch: React.Dispatch<CollectionsActions>;
10
10
  selectedData: SelectedItems;
11
11
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
12
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
13
- productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
12
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
13
+ productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
14
14
  storeId: string;
15
15
  setScreen: React.Dispatch<React.SetStateAction<string>>;
16
16
  setSaveDisabled: React.Dispatch<React.SetStateAction<boolean>>;
@@ -21,40 +21,9 @@ interface ProductsScreenInterface {
21
21
  renderWithoutModal?: boolean;
22
22
  pickerType?: 'COLLECTION' | 'PRODUCT';
23
23
  hideProductVariants?: boolean;
24
+ showProductDetailInfoIcon?: boolean;
25
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
26
+ onProductDetailClick: (productData: Product | ProductVariant) => void;
24
27
  }
25
28
  export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
26
- interface ProductGroupInterface {
27
- collectionId: string;
28
- productId: string;
29
- data: Product;
30
- selectedData: SelectedItems;
31
- selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
32
- viewOnly: boolean;
33
- isProductPartiallyChecked?: boolean;
34
- upliftAdditions: any;
35
- hideProductCheckbox?: boolean;
36
- outOfStockAction?: OUT_OF_STOCK_ACTION;
37
- hideVariantCheckbox?: boolean;
38
- hideProductVariants?: boolean;
39
- pickerType?: 'COLLECTION' | 'PRODUCT';
40
- }
41
- export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
42
- interface ProductCardInterface {
43
- isVariant: boolean;
44
- data: Product | ProductVariant;
45
- productId: string;
46
- collectionId: string;
47
- variantId?: string;
48
- isSelected: boolean;
49
- selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
50
- viewOnly: boolean;
51
- isPartiallyChecked?: boolean;
52
- upliftAdditions: any;
53
- hideProductCheckbox?: boolean;
54
- outOfStockAction?: OUT_OF_STOCK_ACTION;
55
- hideVariantCheckbox?: boolean;
56
- hideProductVariants?: boolean;
57
- pickerType?: 'COLLECTION' | 'PRODUCT';
58
- }
59
- export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
60
29
  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 d from"../../assets/icons/search.svg.js";import{cloneDeep as l}from"lodash";import{useContext as n,useState as r,useEffect as s}from"react";import{Tag as a}from"../tag/Tag.js";import{COLORS as u}from"../../constants/Theme.js";import{CheckBox as p}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as v}from"../input/Input.js";import{BikShimmer as m}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as y}from"../shimmer-image/ShimmerImage.js";import{Spinner as f}from"../spinner/Spinner.js";import{Tooltip as g}from"../tooltips/Tooltip.js";import{BodyCaption as k,TitleRegular as b}from"../TypographyStyle.js";import{truncate as j}from"./collectionScreen.js";import{EmptyState as C}from"./emptyState.js";import{ProductHelper as I}from"./helpers/ProductHelper.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as x,ProductScreenCollectionCardStyle as S,ProductCardStyle as P}from"./style.js";import{OUT_OF_STOCK_ACTION as V}from"./type.js";import{liftTheStateUp as T}from"./utility.js";const w=o=>{const a=n(O),{data:y,collectionsDispatch:g,selectedData:j,selectedCollectionsDispatch:I,productFetcher:P,storeId:w,setScreen:E,setSaveDisabled:A,hideInCollectionSearch:B,customCollectionRestriction:U,hideProductCheckbox:R,outOfStockAction:F=V.BLUR,hideVariantCheckbox:H=!1,selectProductsFromCustomCollection:L=!1,pickerType:W,hideProductVariants:z}=o,[K,N]=r(""),[_,q]=r(!1),[G,J]=r(y);s((()=>{const t=setTimeout((()=>{K.length?(q(!0),o.searchInCollectionFetcher(w,a,K).then((t=>{var e;const o=l(y);o.products={};for(const i of t)(null===(e=null==y?void 0:y.products)||void 0===e?void 0:e[i])&&(o.products[i]=y.products[i]);J(o),A(!1),q(!1)}))):J(y)}),800);return()=>clearTimeout(t)}),[K]);const M=!!U&&y.isSmartCollection,Q=t=>{var e,o,i,c,d,l,n,r;let s=0,u=0;return!z&&!!((null===(o=null===(e=null==j?void 0:j[a])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(d=Object.keys((null===(c=null===(i=null==y?void 0:y.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>u++)),Object.keys((null===(r=null===(n=null===(l=null==j?void 0:j[a])||void 0===l?void 0:l.products)||void 0===n?void 0:n[t])||void 0===r?void 0:r.variants)||[]).forEach((()=>s++)),s>0&&u!==s))};s((()=>{(null==y?void 0:y.products)||X()}),[]);const X=()=>{A(!0),q(!0),P(a,w).then((t=>{Object.keys(t).length&&(g({type:"productsFetched",data:{collectionId:a,products:t}}),J(Object.assign(Object.assign({},G),{products:t}))),A(!1),q(!1)})).catch()},Y=(t,e)=>{const o=T(e,y);I({type:t,data:Object.assign(Object.assign({},o),{isRestricted:U})})};return t("div",{children:[t(x,{children:[e(h,{Icon:i,height:16,onClick:()=>{E("collections")}}),e(k,Object.assign({style:{color:u.content.secondary}},{children:y.name}))]}),!B&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(v,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&K.length?e(f,{size:"small",color:u.content.primary}):e(d,{})},id:"listInput",height:"24px",type:"text",value:K,onChangeText:t=>{t.length&&t.trim().length?N(t):N("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!M&&!K.length&&!R&&t(S,{children:[e(p,{isChecked:!!(null==j?void 0:j[a]),isPartiallyChecked:(t=>{var e,o,i,c;let d=0,l=0;if(z){const c=null!==(e=null==y?void 0:y.products)&&void 0!==e?e:{};d=Object.keys(c).length;const n=null!==(i=null===(o=j[t])||void 0===o?void 0:o.products)&&void 0!==i?i:{};l=Object.keys(n).length}else if(j[t]){const e=null==y?void 0:y.products;e&&Object.keys(e).forEach((t=>{var o;const i=null===(o=e[t])||void 0===o?void 0:o.variants;i&&Object.keys(i).forEach((t=>d+=1))}));const o=null===(c=j[t])||void 0===c?void 0:c.products;o&&Object.keys(o).forEach((t=>{var e;const i=null===(e=o[t])||void 0===e?void 0:e.variants;i&&Object.keys(i).forEach((()=>l+=1))}))}return l>0&&d!==l})(a),onValueChange:function(t){I(t?{type:"selected",data:{id:a,val:y}}:{type:"unselected",data:{id:a}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(b,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e(D,{outOfStockAction:F,collectionId:a,isProductPartiallyChecked:Q(t),productId:t,data:G.products[t],selectedData:j,selectedCollectionsDispatch:I,viewOnly:!L&&!!M,upliftAdditions:Y,hideProductCheckbox:R,hideVariantCheckbox:H,hideProductVariants:z,pickerType:W},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e(m,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e(C,{title:"No products to show",subtitle:K.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})},D=o=>{const{collectionId:i,productId:c,data:d,selectedData:l,selectedCollectionsDispatch:n,viewOnly:r,upliftAdditions:s,isProductPartiallyChecked:a,hideProductCheckbox:u,outOfStockAction:p,hideVariantCheckbox:h,hideProductVariants:v,pickerType:m}=o,y=t=>{var e,o,d,n,r,s;if(!(null===(o=null===(e=null==l?void 0:l[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(s=null===(r=null===(n=null===(d=null==l?void 0:l[i])||void 0===d?void 0:d.products)||void 0===n?void 0:n[c])||void 0===r?void 0:r.variants)||void 0===s?void 0:s[t])};return t("div",{children:[e(E,{isVariant:!1,data:d,productId:c,collectionId:i,isSelected:!!(null===(g=null===(f=null==l?void 0:l[i])||void 0===f?void 0:f.products)||void 0===g?void 0:g[c]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:s,viewOnly:r,hideProductCheckbox:u,hideVariantCheckbox:h,hideProductVariants:v,pickerType:m},c),v?null:Object.keys(d.variants||[]).map((t=>e(E,{isVariant:!0,hideVariantCheckbox:h,data:d.variants[t],variantId:t,productId:c,viewOnly:r,upliftAdditions:s,collectionId:i,isSelected:y(t),selectedCollectionsDispatch:n,outOfStockAction:p},t)))]});var f,g},E=i=>{const{isVariant:c,data:d,productId:l,collectionId:n,variantId:r,isSelected:s,selectedCollectionsDispatch:u,viewOnly:h,upliftAdditions:v,isPartiallyChecked:m,hideProductCheckbox:f,outOfStockAction:k,hideVariantCheckbox:C,hideProductVariants:O,pickerType:x}=i,S=I.getProductLabels(d,k);return t(P,Object.assign({isVariant:c,onClick:t=>{if(t.stopPropagation(),"PRODUCT"===x)if(u({type:"reset",data:{}}),O)v("productSelected",{productId:l,variantId:r,collectionId:n});else{const t=Object.keys(d.variants);v("variantSelected",{productId:l,variantId:r||t[0],collectionId:n,variant:d})}},isActive:s},{children:[c&&!h&&!C||!c&&!h&&!f?e(p,{isChecked:s,isPartiallyChecked:m||!1,onValueChange:function(t){if(c)t?v(O?"productSelected":"variantSelected",{productId:l,variantId:r,collectionId:n,variant:d}):u({type:O?"productUnselected":"variantUnselected",data:{productId:l,variantId:r,collectionId:n}});else if(t){const t=Object.keys(d.variants);v(O?"productSelected":"variantSelected",{productId:l,collectionId:n,product:O?d.variants[t[0]]:d})}else u({type:O?"productUnselected":"variantUnselected",data:{productId:l,collectionId:n}})}}):e(o,{}),e("div",{children:e(y,{width:40,height:40,imageUrl:d.image,alt:"Item",borderRadius:4})}),e(g,Object.assign({body:d.name,placement:"bottom",delay:400},{children:t("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e(b,{children:j(d.name,40,!0)}),S?e("div",Object.assign({style:{width:90,display:"flex"}},{children:e(a,{tagText:S,type:"warning",theme:"light"})})):e(o,{})]}))}))]}))};export{E as ProductCard,D as ProductGroup,w as ProductsScreen};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as s,useRef as i,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as f}from"./ProductPickerShimmer.js";import{CollectionIdContext as y}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as I,isCollectionPartiallyChecked as D,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const S=S=>{const{data:w,collectionsDispatch:T,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:H,outOfStockAction:K=C.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G}=S,Q=s(y),X=i(null),Y=i(0),[Z,$]=l(!1),[tt,et]=l(""),[ot,ct]=l(!1),[rt,nt]=l(w),st=i(!1);d((()=>{const t=setTimeout((()=>{tt.length?(ct(!0),S.searchInCollectionFetcher(B,Q,tt).then((t=>{const e=n(w);e.products=t,nt(e);const o=P(null!=t?t:{});lt(o,null!=t?t:{},!0),J(!1),ct(!1)}))):nt(w)}),800);return()=>clearTimeout(t)}),[tt]),d((()=>{var t,e,o,c;st.current=!1,Y.current=Math.floor((null===(e=Object.keys(null!==(t=w.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=w.products)&&void 0!==o?o:{});lt(r,null!==(c=w.products)&&void 0!==c?c:{})}),[Q]);const it=!!z&&w.isSmartCollection;d((()=>{(null==w?void 0:w.products)||dt(10)}),[]);const lt=(t,e,o)=>{_||(o?I(e,T,Q,rt,nt):I(e,T,Q)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,s;const i=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];i&&"REJECTED"===t[r]?i.fbStatus="REJECTED":i&&"APPROVED"===t[r]&&(i.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[r]&&(l[r]=i)}))})),o?(nt((t=>{const e=Object.assign({},t);return e.products=c,e})),T({type:"productsPaged",data:{collectionId:Q,products:c}})):T({type:"productsPaged",data:{collectionId:Q,products:c}})})).catch((t=>{o?I(e,T,Q,rt,nt):I(e,T,Q)}))};d((()=>{const t=new IntersectionObserver((t=>{t[0].isIntersecting&&Y.current>=0&&!st.current&&!tt&&(J(!0),$(!0),A(Q,B,10,Y.current).then((t=>{if(Object.keys(t).length||(st.current=!0),Object.keys(t).length){const e=rt;e.products=Object.assign(Object.assign({},rt.products),t),nt(e);const o=P(t);lt(o,t),Y.current+=1}$(!1),J(!1)})).catch())}),{threshold:1});return X.current&&t.observe(X.current),()=>{X.current&&t.unobserve(X.current)}}),[X,tt]);const dt=t=>{J(!0),ct(!0),A(Q,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){nt(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);lt(t,e),Y.current=1}t||V({type:"selected",data:{id:Q,val:Object.assign(Object.assign({},w),{products:e})}}),J(!1),ct(!1)})).catch()},at=(t,e)=>{const o=E(e,w);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})};return t("div",{children:[t(O,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:w.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ot&&tt.length?e(m,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:tt,onChangeText:t=>{t.length&&t.trim().length?et(t):et("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!it&&!tt.length&&!H&&"-1"!==Q&&t(k,{children:[e(u,{isChecked:!!(null==R?void 0:R[Q]),isPartiallyChecked:D(Q,w,R),onValueChange:function(t){t?dt():V({type:"unselected",data:{id:Q}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(b,{outOfStockAction:K,collectionId:Q,isProductPartiallyChecked:x(Q,t,R,rt),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!it,upliftAdditions:at,hideProductCheckbox:H,hideVariantCheckbox:L,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ot?e(f,{limit:10}):e(v,{title:"No products to show",subtitle:tt.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:X})]}),Z&&e(f,{})]})};export{S as ProductsScreen};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { SelectedItems } from '.';
2
+ import { FbStatusFetcherReturn, SelectedItems } from '.';
3
3
  import { SelectedCollectionsActions } from './reducers';
4
4
  import { OUT_OF_STOCK_ACTION } from './type';
5
5
  interface RearrangeScreenInterface {
@@ -9,6 +9,8 @@ interface RearrangeScreenInterface {
9
9
  rearrangeViewType: 'grid' | 'list';
10
10
  outOfStockAction?: OUT_OF_STOCK_ACTION;
11
11
  scrollContainerRef: React.RefObject<HTMLDivElement>;
12
+ storeId: string;
13
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
12
14
  }
13
15
  /**
14
16
  * Screen will be opened on two conditions -
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as n}from"../../constants/Theme.js";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as d}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as p}from"./style.js";import{VariantsList as m,VariantsGrid as f}from"./variantComponents.js";const u=u=>{const{selectedCollections:h,selectedCollectionsDispatch:j,setScreen:y,rearrangeViewType:S,outOfStockAction:g,scrollContainerRef:C}=u,[b,O]=r(d(h));s((()=>{var e;null===(e=null==C?void 0:C.current)||void 0===e||e.scrollTo({top:0}),O(d(h))}),[h]);return e(c,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=b,[o]=t.splice(e.source.index,1);t.splice(e.destination.index,0,o),t.forEach(((e,t)=>{e.displayOrder=t})),O(t)}},{children:[e(p,{children:[t(i,{Icon:o,width:16,height:16,color:n.content.secondary,onClick:()=>{y("collections")}}),t(l,Object.assign({color:n.content.secondary},{children:"All Products"}))]}),Object.keys(h).length>0?"list"===S?t(m,{selectedVariants:b,setSelectedVariants:O,selectedCollectionsDispatch:j,outOfStockAction:g}):t(f,{selectedVariants:b,setSelectedVariants:O,selectedCollectionsDispatch:j}):t(a,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};export{u as RearrangeScreen};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as i}from"../../constants/Theme.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as d}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as p}from"./style.js";import{fetchFbStatusCollection as m}from"./utility.js";import{VariantsList as u,VariantsGrid as f}from"./variantComponents.js";const h=h=>{const{selectedCollections:j,selectedCollectionsDispatch:y,setScreen:S,rearrangeViewType:g,outOfStockAction:b,scrollContainerRef:C,storeId:O,fbStatusFetcher:v}=h,[V,k]=r(d(j));s((()=>{k(d(j))}),[j]),s((()=>{var t;null===(t=null==C?void 0:C.current)||void 0===t||t.scrollTo({top:0}),m(j,O,y,v,"update")}),[]);return t(c,Object.assign({onDragEnd:t=>{if(!t.destination)return;const e=V,[o]=e.splice(t.source.index,1);e.splice(t.destination.index,0,o),e.forEach(((t,e)=>{t.displayOrder=e})),k(e)}},{children:[t(p,{children:[e(n,{Icon:o,width:16,height:16,color:i.content.secondary,onClick:()=>{S("collections")}}),e(l,Object.assign({color:i.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===g?e(u,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y,outOfStockAction:b}):e(f,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y}):e(a,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};export{h as RearrangeScreen};
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
2
+ import { Collection, SearchedItems, SelectedItems } from '.';
3
3
  export interface SelectedCollectionsActions {
4
4
  type: string;
5
5
  data: {
@@ -14,4 +14,28 @@ export interface CollectionsActions {
14
14
  };
15
15
  }
16
16
  export declare function collectionsReducer(collections: Collection, action: CollectionsActions): any;
17
+ /**
18
+ * Pagination reducer used in selected screen.
19
+ * Used for local pagination.
20
+ *
21
+ * Actions used:
22
+ * paginate -> Checks if the products of the collection is already displayed, if yes addes the products, if no adds the entire collection
23
+ * update -> triggers a re-render.
24
+ * set -> adds the data to existing collections.
25
+ * filter -> When user unselects a product in selected screen, we filter out the selected data and show only unselected data.
26
+ */
27
+ export declare function paginationReducer(collections: SelectedItems, action: SelectedCollectionsActions): SelectedItems;
28
+ export interface SearchReducerActions {
29
+ type: string;
30
+ data: SearchedItems;
31
+ }
32
+ /**
33
+ * Data used in search screen.
34
+ * To display both collections and products.
35
+ *
36
+ * Actions:
37
+ * set -> no change and sets the data.
38
+ * setProducts -> keeps the collection from search as-is and sets only products
39
+ */
40
+ export declare function searchReducer(searchedItems: SearchedItems, action: SearchReducerActions): SearchedItems;
17
41
  export declare const CollectionIdContext: import("react").Context<string>;
@@ -1 +1 @@
1
- import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function d(a,d){var e,o,l,s,c,r,i,u,n,v,p;let m={},O="",g="",C="";switch(d.type){case"selected":return m=t(a),d.data.val.isSmartCollection&&(d.data.isRestricted&&(m={}),m.isCustom=!0),m[d.data.id]=d.data.val,m;case"unselected":return m=t(a),(null==m?void 0:m.isCustom)&&(m.isCustom=!1),delete m[d.data.id],m;case"productUnselected":return m=t(a),O=d.data.productId,g=d.data.collectionId,delete m[g].products[O],Object.keys(m[g].products).length||((null==m?void 0:m.isCustom)&&(m.isCustom=!1),delete m[g]),m;case"productSelected":return m=t(a),O=d.data.productId,g=d.data.collectionId,(null===(e=d.data.catalogOnlyData)||void 0===e?void 0:e.isSmartCollection)&&(d.data.isRestricted&&(m={}),m.isCustom=!0),(null==m?void 0:m[g])||(m[g]=d.data.catalogOnlyData,m[g].products={}),m[g].products[O]=d.data.product,m;case"variantSelected":return m=t(a),O=d.data.productId,g=d.data.collectionId,C=d.data.variantId,(null===(o=d.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(d.data.isRestricted&&(m={}),m.isCustom=!0),(null==m?void 0:m[g])||(m[g]=d.data.catalogOnlyData,m[g].products={},m[g].products[O]=d.data.productOnlyData,m[g].products[O].variants={}),(null===(s=null===(l=null==m?void 0:m[g])||void 0===l?void 0:l.products)||void 0===s?void 0:s[O])||((null===(c=null==m?void 0:m[g])||void 0===c?void 0:c.products)||(m[g].products={}),m[g].products[O]=d.data.productOnlyData,m[g].products[O].variants={}),m[g].products[O].variants[C]=d.data.variant,m;case"variantUnselected":return m=t(a),O=d.data.productId,g=d.data.collectionId,C=d.data.variantId,(null===(i=null===(r=m[g].products[O])||void 0===r?void 0:r.variants)||void 0===i?void 0:i[C])&&delete m[g].products[O].variants[C],Object.keys(null!==(v=null===(n=null===(u=m[g].products)||void 0===u?void 0:u[O])||void 0===n?void 0:n.variants)&&void 0!==v?v:{}).length||(delete m[g].products[O],Object.keys(m[g].products).length||((null===(p=m[g])||void 0===p?void 0:p.isSmartCollection)&&(m.isCustom=!1),delete m[g])),m;case"reset":return{};default:return a}}function e(t,a){let d={};switch(a.type){case"fetched":return d=Object.assign({},a.data),d;case"productsFetched":return d=Object.assign({},t),d[a.data.collectionId].products=a.data.products,d;case"paged":return d=Object.assign(Object.assign({},t),a.data),d;default:return{}}}const o=a("");export{o as CollectionIdContext,e as collectionsReducer,d as selectedColectionsReducer};
1
+ import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,c,d,r,o,n;let i={},u="",l="",p="";switch(e.type){case"selected":return i=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(i={}),i.isCustom=!0),i[e.data.id]=e.data.val,i;case"unselected":return i=t(a),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[e.data.id],i;case"productUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,delete i[l].products[u],Object.keys(i[l].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[l]),i;case"productSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={}),i[l].products[u]=e.data.product,i;case"variantSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,(null===(c=e.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={},i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),(null===(r=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.products)||void 0===r?void 0:r[u])||((null===(o=null==i?void 0:i[l])||void 0===o?void 0:o.products)||(i[l].products={}),i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),i[l].products[u].variants[p]=e.data.variant,i;case"variantUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,delete i[l].products[u].variants[p],Object.keys(i[l].products[u].variants).length||(delete i[l].products[u],Object.keys(i[l].products).length||((null===(n=i[l])||void 0===n?void 0:n.isSmartCollection)&&(i.isCustom=!1),delete i[l])),i;case"update":return i=Object.assign({},a),i;case"reset":return{};default:return a}}function s(t,a){let e={};switch(a.type){case"fetched":return e=Object.assign({},a.data),e;case"productsFetched":return e=Object.assign({},t),e[a.data.collectionId].products=a.data.products,e;case"paged":return e=Object.assign(Object.assign({},t),a.data),e;case"productsPaged":return e=Object.assign({},t),e[a.data.collectionId].products=Object.assign(Object.assign({},e[a.data.collectionId].products),a.data.products),e;case"searched":e=Object.assign({},t);for(const t in a.data)t in e||(e[t]=a.data[t]);return e;default:return{}}}function c(t,a){let e={};switch(a.type){case"paginate":e=Object.assign({},t);for(const t in a.data)if(Object.prototype.hasOwnProperty.call(a.data,t)){const s=a.data[t];if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t];e[t]=Object.assign(Object.assign({},a),{products:Object.assign(Object.assign({},a.products),s.products)})}else e[t]=s}return e;case"update":return e=Object.assign({},t),e;case"set":return e=Object.assign(Object.assign({},t),a.data),e;case"filter":e={};for(const s in t)if(s in a.data){const c=Object.assign({},t[s]),d=a.data[s],r={};for(const t in c.products)if(t in d.products){const a=Object.assign({},c.products[t]),e=d.products[t],s={};for(const t in a.variants)t in e.variants&&(s[t]=Object.assign({},a.variants[t]));Object.keys(s).length>0&&(a.variants=s,r[t]=a)}Object.keys(r).length>0&&(c.products=r,e[s]=c)}return e;default:return t}}function d(t,a){let e={collections:{},products:{}};switch(a.type){case"set":return a.data;case"setProducts":return e=Object.assign({},t),e.products=a.data,e;default:return t}}const r=a("");export{r as CollectionIdContext,s as collectionsReducer,c as paginationReducer,d as searchReducer,e as selectedColectionsReducer};
@@ -1,12 +1,15 @@
1
1
  /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
3
- import { SelectedCollectionsActions } from './reducers';
2
+ import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
3
+ import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
4
4
  interface SearchScreenInterface {
5
5
  customCollectionRestriction?: boolean;
6
6
  selectedCollections: SelectedItems;
7
- searchedCollections: SelectedItems;
7
+ searchedCollections: SearchedItems;
8
+ searchedCollectionsDispatch: React.Dispatch<SearchReducerActions>;
8
9
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
9
10
  setScreen: React.Dispatch<React.SetStateAction<string>>;
11
+ setCollectionId: React.Dispatch<React.SetStateAction<string>>;
12
+ setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
10
13
  collections: {
11
14
  [key: string]: Collection;
12
15
  };
@@ -15,6 +18,10 @@ interface SearchScreenInterface {
15
18
  pickerType?: 'COLLECTION' | 'PRODUCT';
16
19
  hideProductVariants?: boolean;
17
20
  hideProductCheckbox?: boolean;
21
+ storeId: string;
22
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
23
+ hideCollectionCheckbox?: boolean;
24
+ renderWithoutModal?: boolean;
18
25
  }
19
26
  export declare const SearchScreen: (props: SearchScreenInterface) => import("react/jsx-runtime").JSX.Element;
20
27
  export {};
@@ -1 +1 @@
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 r}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as c}from"./emptyState.js";import{ProductGroup as d}from"./productScreen.js";import{SelectedScreenHeader as s}from"./style.js";import{liftTheStateUp as n}from"./utility.js";const u=u=>{const{customCollectionRestriction:a,selectedCollections:v,searchedCollections:p,selectedCollectionsDispatch:h,setScreen:m,collections:y,onBackPress:f,hideVariantCheckbox:j,pickerType:k,hideProductVariants:b,hideProductCheckbox:C}=u,O=(o,t)=>{var e,i,r,l,c,d,s,n,u;let a=0,p=0;return!!((null===(i=null===(e=null==v?void 0:v[o])||void 0===e?void 0:e.products)||void 0===i?void 0:i[t])&&(null===(d=Object.keys((null===(c=null===(l=null===(r=null==y?void 0:y[o])||void 0===r?void 0:r.products)||void 0===l?void 0:l[t])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>p++)),Object.keys((null===(u=null===(n=null===(s=null==v?void 0:v[o])||void 0===s?void 0:s.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&p!==a))};return o("div",{children:[o(s,{children:[t(r,{Icon:i,onClick:()=>{m("collections"),f()}}),t(l,{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(d,{collectionId:o,upliftAdditions:(t,e)=>((o,t,e)=>{const i=n(e,p[o]);h({type:t,data:Object.assign(Object.assign({},i),{isRestricted:a})})})(o,t,e),productId:e,data:p[o].products[e],isProductPartiallyChecked:O(o,e),selectedData:v,selectedCollectionsDispatch:h,viewOnly:i,hideProductCheckbox:C,hideVariantCheckbox:j,hideProductVariants:b,pickerType:k},e)}))}))}):t(c,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{u as SearchScreen};
1
+ import{jsxs as e,jsx as o,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{const{customCollectionRestriction:C,selectedCollections:k,searchedCollections:y,searchedCollectionsDispatch:b,selectedCollectionsDispatch:f,setScreen:j,collections:I,onBackPress:P,hideVariantCheckbox:S,pickerType:x,hideProductVariants:O,hideProductCheckbox:g,storeId:D,fbStatusFetcher:T,setCollectionId:V,setSelectedCollectionId:w,hideCollectionCheckbox:R,renderWithoutModal:W}=m;i((()=>{var e;a(null!==(e=y.products)&&void 0!==e?e:{},D,b,T,"setProducts")}),[null==y?void 0:y.products]);const B=!!C&&(null==k?void 0:k.isCustom);return e("div",{children:[e(u,{children:[o(c,{Icon:l,onClick:()=>{j("collections"),P()}}),o(d,{children:"Searched Products"})]}),o("div",{children:Object.keys(null==y?void 0:y.products).length||Object.keys(null==y?void 0:y.collections).length?e(t,{children:[o(t,{children:Object.keys(null==y?void 0:y.collections).map((e=>o(s,{customCollectionRestriction:C,data:null==I?void 0:I[e],isDisabled:B&&!(null==k?void 0:k[e]),isChecked:!!(null==k?void 0:k[e]),isPartiallyChecked:p(e,null==I?void 0:I[e],k),selectedCollectionsDispatch:f,setCollectionId:V,setSelectedCollectionId:w,setScreen:j,id:e,hideCollectionCheckbox:R||"-1"===e,selectedCollections:k,renderWithoutModal:W,pickerType:x,usedInSearch:!0},e)))}),o(t,{children:Object.keys(null==y?void 0:y.products).map((e=>{var t,l;return Object.keys((null===(l=null===(t=null==y?void 0:y.products)||void 0===t?void 0:t[e])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==y?void 0:y.products)||void 0===l?void 0:l.isCustom)&&(d=!0),o(n,{collectionId:e,upliftAdditions:(o,t)=>((e,o,t)=>{var l;const i=v(t,null===(l=null==y?void 0:y.products)||void 0===l?void 0:l[e]);f({type:o,data:Object.assign(Object.assign({},i),{isRestricted:C})})})(e,o,t),productId:t,data:(null===(i=null==y?void 0:y.products)||void 0===i?void 0:i[e].products)[t],isProductPartiallyChecked:h(e,t,k,null===(c=y.products)||void 0===c?void 0:c[e]),selectedData:k,selectedCollectionsDispatch:f,viewOnly:d,hideProductCheckbox:g,hideVariantCheckbox:S,hideProductVariants:O,pickerType:x},t)}))}))})]}):o(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { Collection, SelectedItems } from '.';
2
+ import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
3
3
  import { SelectedCollectionsActions } from './reducers';
4
+ import { OUT_OF_STOCK_ACTION } from './type';
4
5
  interface SelectedScreenInterface {
5
6
  selectedCollections: SelectedItems;
6
7
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
@@ -8,7 +9,9 @@ interface SelectedScreenInterface {
8
9
  collections: {
9
10
  [key: string]: Collection;
10
11
  };
11
- hideProductVariants?: boolean;
12
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
13
+ storeId: string;
14
+ fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
12
15
  }
13
16
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
14
17
  export {};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as t,Fragment as e}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as r}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{AllProductHelper as c}from"./helpers/AllProductHelper.js";import{ProductGroup as s}from"./productScreen.js";import{SelectedScreenHeader as n}from"./style.js";const u=u=>{const{selectedCollections:v,selectedCollectionsDispatch:a,setScreen:p,collections:m,hideProductVariants:h=!1}=u,j=(o,t)=>{var e,l,i,r,d,c,s,n,u;let a=0,p=0;return!!((null===(l=null===(e=null==v?void 0:v[o])||void 0===e?void 0:e.products)||void 0===l?void 0:l[t])&&(null===(c=Object.keys((null===(d=null===(r=null===(i=null==m?void 0:m[o])||void 0===i?void 0:i.products)||void 0===r?void 0:r[t])||void 0===d?void 0:d.variants)||[]))||void 0===c||c.forEach((()=>p++)),Object.keys((null===(u=null===(n=null===(s=null==v?void 0:v[o])||void 0===s?void 0:s.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&p!==a))},f=h?c.removeDuplicatesForAllProducts(Object.assign({},v)):v;return o("div",{children:[o(n,{children:[t(i,{Icon:l,onClick:()=>{p("collections")}}),t(r,{children:"Selected Products"})]}),t("div",{children:Object.keys(f).length>0?t(e,{children:Object.keys(f).map((o=>{var e;return Object.keys((null===(e=null==f?void 0:f[o])||void 0===e?void 0:e.products)||[]).map((e=>{let l=!1;return(null==f?void 0:f.isCustom)&&(l=!0),t(s,{upliftAdditions:null,collectionId:o,productId:e,data:f[o].products[e],isProductPartiallyChecked:j(o,e),selectedData:f,selectedCollectionsDispatch:a,viewOnly:l,hideProductVariants:h},e)}))}))}):t(d,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};export{u as SelectedScreen};
1
+ import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as n,useEffect as i}from"react";import{IconButton as s}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./product.js";import{paginationReducer as p}from"./reducers.js";import{SelectedScreenHeader as a}from"./style.js";import{paginateSelectedItems as m,fetchFbStatusCollection as f,isProductPartiallyChecked as h}from"./utility.js";const v=v=>{const{selectedCollections:y,selectedCollectionsDispatch:j,setScreen:b,collections:S,outOfStockAction:k,storeId:I,fbStatusFetcher:O}=v,g=c(0),C=c(null),[w,P]=n(p,{});return i((()=>{g.current=0;const t=m(y,10,0);P({type:"paginate",data:t}),f(t,I,P,O,"set"),g.current+=1}),[]),i((()=>{P({type:"filter",data:y})}),[y]),i((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&g.current>0){const t=m(y,10,g.current);P({type:"paginate",data:t}),f(t,I,P,O,"update"),g.current+=1}}),{threshold:1});return C.current&&t.observe(C.current),()=>{C.current&&t.unobserve(C.current)}}),[C,y]),t("div",{children:[t(a,{children:[e(s,{Icon:o,onClick:()=>{b("collections")}}),e(l,{children:"Selected Products"})]}),t("div",{children:[Object.keys(w).length>0?e(r,{children:Object.keys(w).map((t=>{var r;return Object.keys((null===(r=null==w?void 0:w[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==y?void 0:y.isCustom)&&(o=!0),e(u,{upliftAdditions:null,collectionId:t,productId:r,data:w[t].products[r],isProductPartiallyChecked:h(t,r,y,null==S?void 0:S[t]),selectedData:y,selectedCollectionsDispatch:j,viewOnly:o,outOfStockAction:k},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:C})]})]})};export{v as SelectedScreen};
@@ -3,6 +3,7 @@ export declare const ScrollContainerStyle: import("styled-components").StyledCom
3
3
  export declare const CollectionCardStyle: import("styled-components").StyledComponent<"div", any, {
4
4
  isDisabled: boolean;
5
5
  isActive: boolean;
6
+ usedInSearch: boolean;
6
7
  }, never>;
7
8
  export declare const CollectionCardInfoStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
8
9
  export declare const CollectionCardDetailStyle: import("styled-components").StyledComponent<"div", any, {}, never>;