@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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@emotion/styled/base"),t=require("react/jsx-runtime"),c=require("../../../TypographyStyle.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=l(e).default("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}"}:{name:"1o5bx8z",styles:"display:flex;align-items:center;flex-direction:row;flex:1;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;flex:1;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblx0ZmxleC1kaXJlY3Rpb246IHJvdztcblx0ZmxleDogMTtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdFx0ZmxleDogMTtcblx0fVxuYDtcclxuZXhwb3J0IGNvbnN0IExlZ2VuZCA9ICh7IGNvbG9yLCB0ZXh0IH0pID0+IHtcclxuICAgIGNvbnN0IHRvVXBwZXJDYXNlID0gKG5hbWUpID0+IHtcclxuICAgICAgICByZXR1cm4gbmFtZS5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIG5hbWUuc2xpY2UoMSk7XHJcbiAgICB9O1xyXG4gICAgcmV0dXJuIChfanN4cyhMZWdlbmRTdHlsZWQsIHsgY2hpbGRyZW46IFtfanN4KFwiZGl2XCIsIHsgY2xhc3NOYW1lOiAnY29sb3InLCBzdHlsZTogeyBiYWNrZ3JvdW5kQ29sb3I6IGNvbG9yIH0gfSksIF9qc3goQm9keVByaW1hcnksIE9iamVjdC5hc3NpZ24oeyBjbGFzc05hbWU6ICd0aXRsZScgfSwgeyBjaGlsZHJlbjogdG9VcHBlckNhc2UodGV4dCkgfSkpXSB9KSk7XHJcbn07XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPUxlZ2VuZC5qcy5tYXAiXX0= */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});exports.Legend=e=>{let{color:l,text:i}=e;return t.jsxs(o,{children:[t.jsx("div",{className:"color",style:{backgroundColor:l}}),t.jsx(c.BodyPrimary,Object.assign({className:"title"},{children:(a=i,a.charAt(0).toUpperCase()+a.slice(1))}))]});var a};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@emotion/styled/base"),t=require("react/jsx-runtime"),c=require("../../../TypographyStyle.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const i=l(e).default("div","production"===process.env.NODE_ENV?{target:"e1y33sa70"}:{target:"e1y33sa70",label:"LegendStyled"})("production"===process.env.NODE_ENV?{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}"}:{name:"tsn5c8",styles:"display:flex;align-items:center;.color{width:12px;height:12px;border-radius:20px;}.title{color:#474747;margin-left:12px;margin-right:12px;}",map:"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkxlZ2VuZC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR2dDIiwiZmlsZSI6IkxlZ2VuZC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBqc3ggYXMgX2pzeCwganN4cyBhcyBfanN4cyB9IGZyb20gXCJyZWFjdC9qc3gtcnVudGltZVwiO1xyXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XHJcbmltcG9ydCB7IEJvZHlQcmltYXJ5IH0gZnJvbSBcIi4uLy4uLy4uL1R5cG9ncmFwaHlTdHlsZVwiO1xyXG5jb25zdCBMZWdlbmRTdHlsZWQgPSBzdHlsZWQuZGl2IGBcblx0ZGlzcGxheTogZmxleDtcblx0YWxpZ24taXRlbXM6IGNlbnRlcjtcblxuXHQuY29sb3Ige1xuXHRcdHdpZHRoOiAxMnB4O1xuXHRcdGhlaWdodDogMTJweDtcblx0XHRib3JkZXItcmFkaXVzOiAyMHB4O1xuXHR9XG5cblx0LnRpdGxlIHtcblx0XHRjb2xvcjogIzQ3NDc0Nztcblx0XHRtYXJnaW4tbGVmdDogMTJweDtcblx0XHRtYXJnaW4tcmlnaHQ6IDEycHg7XG5cdH1cbmA7XHJcbmV4cG9ydCBjb25zdCBMZWdlbmQgPSAoeyBjb2xvciwgdGV4dCB9KSA9PiB7XHJcbiAgICBjb25zdCB0b1VwcGVyQ2FzZSA9IChuYW1lKSA9PiB7XHJcbiAgICAgICAgcmV0dXJuIG5hbWUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBuYW1lLnNsaWNlKDEpO1xyXG4gICAgfTtcclxuICAgIHJldHVybiAoX2pzeHMoTGVnZW5kU3R5bGVkLCB7IGNoaWxkcmVuOiBbX2pzeChcImRpdlwiLCB7IGNsYXNzTmFtZTogJ2NvbG9yJywgc3R5bGU6IHsgYmFja2dyb3VuZENvbG9yOiBjb2xvciB9IH0pLCBfanN4KEJvZHlQcmltYXJ5LCBPYmplY3QuYXNzaWduKHsgY2xhc3NOYW1lOiAndGl0bGUnIH0sIHsgY2hpbGRyZW46IHRvVXBwZXJDYXNlKHRleHQpIH0pKV0gfSkpO1xyXG59O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1MZWdlbmQuanMubWFwIl19 */",toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}});exports.Legend=e=>{let{color:l,text:a}=e;return t.jsxs(i,{children:[t.jsx("div",{className:"color",style:{backgroundColor:l}}),t.jsx(c.BodyPrimary,Object.assign({className:"title"},{children:(s=a,s.charAt(0).toUpperCase()+s.slice(1))}))]});var s};
@@ -0,0 +1,3 @@
1
+ export declare const ProductPickerShimmer: (props: {
2
+ limit?: number;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("../shimmer/ShimmerComponent/BikShimmer.js");exports.ProductPickerShimmer=i=>{const{limit:t}=i;return e.jsx(e.Fragment,{children:Array.from({length:null!=t?t:5}).map(((i,t)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),t)))})};
@@ -0,0 +1,19 @@
1
+ import { Product, ProductVariant } from './modal';
2
+ import { OUT_OF_STOCK_ACTION } from './type';
3
+ export type ProductPickerTagType = {
4
+ isVariant: boolean;
5
+ data: Product | ProductVariant;
6
+ outOfStockAction?: OUT_OF_STOCK_ACTION;
7
+ };
8
+ /**
9
+ * Used in Product Screen, Search Screen, Selected Screen and Rearrange Screen.
10
+ * Wherever product card is shown, we use this component.
11
+ *
12
+ * New logic: When product has only one variant and variant name is same as product name,
13
+ * we consider that a variant and do operations as variant.
14
+ *
15
+ * Note: If there is no Fb rejected tag in the variant, we show a shimmer,
16
+ * meanwhile hit the API to get FB status.
17
+ *
18
+ */
19
+ export declare const ProductPickerTag: (props: ProductPickerTagType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../shimmer/ShimmerComponent/BikShimmer.js"),r=require("../tag/Tag.js"),i=require("./helpers/ProductHelper.js");exports.ProductPickerTag=s=>{var l,a;const{isVariant:n,data:o,outOfStockAction:u}=s;let d=o,c=n;1===Object.keys(null!==(l=null==o?void 0:o.variants)&&void 0!==l?l:{}).length&&(d=Object.values(null!==(a=null==o?void 0:o.variants)&&void 0!==a?a:{})[0],c=!0);const p=i.ProductHelper.getProductLabels(d,u),g=i.ProductHelper.getTagType(null!=p?p:"");return e.jsx("div",Object.assign({style:{display:"flex"}},{children:!(null==d?void 0:d.fbStatus)&&c?e.jsx(t.BikShimmer,{boxes:[{height:"24px",width:"100px",marginTop:"0px"}]}):p?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(r.Tag,{tagText:p,type:g,theme:"light"})})):e.jsx(e.Fragment,{})}))};
@@ -13,6 +13,7 @@ interface CollectionsScreenInterface {
13
13
  storeId: string;
14
14
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
15
15
  setCollectionId: React.Dispatch<React.SetStateAction<string>>;
16
+ setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
16
17
  setScreen: React.Dispatch<React.SetStateAction<string>>;
17
18
  collectionsDispatch: React.Dispatch<CollectionsActions>;
18
19
  setSaveDisabled: React.Dispatch<boolean>;
@@ -25,4 +26,22 @@ interface CollectionsScreenInterface {
25
26
  pickerType?: 'COLLECTION' | 'PRODUCT';
26
27
  }
27
28
  export declare const CollectionsScreen: (props: CollectionsScreenInterface) => import("react/jsx-runtime").JSX.Element;
29
+ export interface CollectionCardInterface {
30
+ customCollectionRestriction?: boolean;
31
+ data: Collection;
32
+ selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
33
+ setCollectionId: React.Dispatch<React.SetStateAction<string>>;
34
+ setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
35
+ setScreen: React.Dispatch<React.SetStateAction<string>>;
36
+ id: string;
37
+ isChecked: boolean;
38
+ isDisabled: boolean;
39
+ isPartiallyChecked: boolean;
40
+ hideCollectionCheckbox?: boolean;
41
+ renderWithoutModal?: boolean;
42
+ pickerType?: 'COLLECTION' | 'PRODUCT';
43
+ selectedCollections: SelectedItems;
44
+ usedInSearch?: boolean;
45
+ }
46
+ export declare const CollectionCard: (props: CollectionCardInterface) => import("react/jsx-runtime").JSX.Element;
28
47
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),l=require("../shimmer/ShimmerComponent/BikShimmer.js"),c=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./emptyState.js"),d=require("./style.js");const u=(e,t,i)=>{if(!e)return"";if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."},h=i=>{const{customCollectionRestriction:l,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:v,isDisabled:y,hideCollectionCheckbox:g,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(!y){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:l}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!g&&e.jsx(s.CheckBox,{isDisabled:y,isChecked:v,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:l}}:{type:"unselected",data:{id:x}}),p(e?x:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400},{children:e.jsxs(d.CollectionNameHolder,{children:[a.name&&e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]}))};exports.CollectionsScreen=t=>{var s;const{customCollectionRestriction:o,dataLoading:c,collections:r,selectedCollectionsDispatch:n,setCollectionId:d,selectedCollections:u,setScreen:p,collectionFetcher:C,collectionsDispatch:j,pagingControls:x,storeId:v,setSaveDisabled:y,hideCollectionCheckbox:g,renderWithoutModal:m,pickerType:b}=t,k=i.useRef(null),f=i.useRef(x.curPage),O=!!o&&(null==u?void 0:u.isCustom),[S,E]=i.useState(!1);i.useEffect((()=>{f.current=x.curPage}),[x.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&(y(!0),E(!0),C(f.current,v).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(f.current+1),E(!1),y(!1)})).catch())}),{threshold:1});return k.current&&e.observe(k.current),()=>{k.current&&e.unobserve(k.current)}}),[k]);const T=e=>{var t,i;let s=0,o=0;if(u[e]){const l=null===(t=r[e])||void 0===t?void 0:t.products;l&&Object.keys(l).forEach((e=>{var t;const i=null===(t=l[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const c=null===(i=u[e])||void 0===i?void 0:i.products;return c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[(null===(s=Object.keys(null!=r?r:{}))||void 0===s?void 0:s.length)?Object.keys(r).map((t=>e.jsx(h,{customCollectionRestriction:o,data:r[t],isDisabled:O&&!(null==u?void 0:u[t]),isChecked:!!(null==u?void 0:u[t]),isPartiallyChecked:T(t),selectedCollectionsDispatch:n,setCollectionId:d,setScreen:p,id:t,hideCollectionCheckbox:g,selectedCollections:u,renderWithoutModal:m,pickerType:b},t))):c?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(a.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:k}),S&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),c=require("../tag/Tag.js"),o=require("../tooltips/Tooltip.js"),r=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./ProductPickerShimmer.js"),d=require("./style.js"),u=require("./utility.js");const h=i=>{const{customCollectionRestriction:n,data:a,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:j,setScreen:p,id:y,isChecked:g,isDisabled:x,hideCollectionCheckbox:b,pickerType:m,selectedCollections:k,usedInSearch:S}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:x,onClick:e=>{if(!x){if("COLLECTION"===m)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:y,val:a,isRestricted:n}}),void h(y);h(y),p("products")}},isActive:!!k[y],usedInSearch:null!=S&&S},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!b&&e.jsx(s.CheckBox,{isDisabled:x,isChecked:g,isPartiallyChecked:j,onValueChange:function(e,t,i){null==i||i.stopPropagation(),u(e?{type:"selected",data:{id:y,val:a,isRestricted:n}}:{type:"unselected",data:{id:y}}),C(e?y:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(o.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(d.CollectionNameHolder,{children:[S?e.jsx(r.BodyPrimary,Object.assign({numberOfLines:1},{children:a.name})):e.jsx(r.TitleRegular,Object.assign({numberOfLines:1},{children:a.name})),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(l.IconButton,{height:12,width:12,disabled:x,Icon:t.default})]}))};exports.CollectionCard=h,exports.CollectionsScreen=t=>{const{customCollectionRestriction:s,dataLoading:l,collections:c,selectedCollectionsDispatch:o,setCollectionId:r,setSelectedCollectionId:d,selectedCollections:C,setScreen:j,collectionFetcher:p,collectionsDispatch:y,pagingControls:g,storeId:x,setSaveDisabled:b,hideCollectionCheckbox:m,renderWithoutModal:k,pickerType:S}=t,v=i.useRef(null),f=i.useRef(g.curPage),I=!!s&&(null==C?void 0:C.isCustom),[P,O]=i.useState(!1),q=i.useRef(!1);return i.useEffect((()=>{f.current=g.curPage}),[g.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&!q.current&&(b(!0),O(!0),p(f.current,x).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),g.setCurPage(f.current+1),O(!1),b(!1),Object.keys(e).length||(q.current=!0)})).catch())}),{threshold:1});return v.current&&e.observe(v.current),()=>{v.current&&e.unobserve(v.current)}}),[v]),e.jsxs("div",{children:[Object.keys(c).length?Object.keys(c).map((t=>e.jsx(h,{customCollectionRestriction:s,data:c[t],isDisabled:I&&!(null==C?void 0:C[t]),isChecked:!!(null==C?void 0:C[t]),isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==c?void 0:c[t],C),selectedCollectionsDispatch:o,setCollectionId:r,setSelectedCollectionId:d,setScreen:j,id:t,hideCollectionCheckbox:m||"-1"===t,selectedCollections:C,renderWithoutModal:k,pickerType:S},t))):l?e.jsx(a.ProductPickerShimmer,{}):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:v}),P&&e.jsx(a.ProductPickerShimmer,{})]})},exports.truncate=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."};
@@ -1,3 +1,4 @@
1
+ import { TagType } from "../../tag/model";
1
2
  import { Product, ProductVariant, SelectedItems } from '../modal';
2
3
  import { OUT_OF_STOCK_ACTION } from '../type';
3
4
  import { ProductVariantForRearrange } from '../variant';
@@ -31,6 +32,10 @@ export declare class ProductHelper {
31
32
  * @param outOfStockAction
32
33
  */
33
34
  static getProductLabels(productVariant: Product | ProductVariant, outOfStockAction?: OUT_OF_STOCK_ACTION): string | null;
35
+ /**
36
+ * For FB Rejected returns 'negative', for rest returns 'warning'
37
+ */
38
+ static getTagType: (tagText: string) => TagType;
34
39
  }
35
40
  /**
36
41
  * Loops through each collection, each product, each variant.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../type.js");const n={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"};exports.ProductHelper=class{static getProductLabels(l){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.OUT_OF_STOCK_ACTION.NORMAL,u="NORMAL";if(l.variants)return n[u];const d=l;return i===t.OUT_OF_STOCK_ACTION.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")),i===t.OUT_OF_STOCK_ACTION.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")),i===t.OUT_OF_STOCK_ACTION.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")),n[u]}},exports.parseSelectedVariantsToArray=t=>{let n=[];Object.keys(t).forEach((l=>{var i;return Object.keys((null===(i=null==t?void 0:t[l])||void 0===i?void 0:i.products)||[]).forEach((i=>{var u,d;const a=null!==(u=t[l].products)&&void 0!==u?u:[],o=null!==(d=a[i].variants)&&void 0!==d?d:[];return Object.keys(o).map((t=>{const n=o[t];n.variantId=t,n.productId=i,n.collectionId=l,n.productName=a[i].name})),n=[...n,...Object.values(o)],n}))}));const l=n.sort(((t,n)=>null==t.displayOrder&&null==n.displayOrder?0:null==t.displayOrder?1:null==n.displayOrder?-1:t.displayOrder-n.displayOrder));return l.forEach(((t,n)=>{t.displayOrder=n})),l};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../type.js");const n={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]:t.OUT_OF_STOCK_ACTION.NORMAL,u="NORMAL";if(l.variants)return n[u];const e=l;return"REJECTED"===(null==e?void 0:e.fbStatus)?n.FB_REJECTED:(i===t.OUT_OF_STOCK_ACTION.HIDE&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.BLUR&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="OUT_OF_STOCK"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.NORMAL&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NORMAL"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),n[u])}}Object.defineProperty(l,"getTagType",{enumerable:!0,configurable:!0,writable:!0,value:t=>n.FB_REJECTED===t?"negative":"warning"});exports.ProductHelper=l,exports.parseSelectedVariantsToArray=t=>{let n=[];Object.keys(t).forEach((l=>{var i;return Object.keys((null===(i=null==t?void 0:t[l])||void 0===i?void 0:i.products)||[]).forEach((i=>{var u,e;const a=null!==(u=t[l].products)&&void 0!==u?u:[],d=null!==(e=a[i].variants)&&void 0!==e?e:[];return Object.keys(d).map((t=>{const n=d[t];n.variantId=t,n.productId=i,n.collectionId=l,n.productName=a[i].name})),n=[...n,...Object.values(d)],n}))}));const l=n.sort(((t,n)=>null==t.displayOrder&&null==n.displayOrder?0:null==t.displayOrder?1:null==n.displayOrder?-1:t.displayOrder-n.displayOrder));return l.forEach(((t,n)=>{t.displayOrder=n})),l};
@@ -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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),r=require("react"),c=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),g=require("./selectedScreen.js"),x=require("./style.js"),C=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:j,selectedItems:y,onClose:m,visible:v,zIndex:b,exactLimit:P,limit:f,hideCollectionCheckbox:k,hideProductCheckbox:O,outOfStockAction:T=C.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:F,hideSelectionCount:I,title:E,width:q,renderWithoutModal:w,onClickSave:D,pickerType:N,hideProductVariants:A=!1,startupScreen:V=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:B=!1}=e,[L,M]=r.useReducer(p.collectionsReducer,{}),[_,z]=r.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(V)?V:exports.ScreenName.Collections),[G,H]=r.useState("grid"),[W,K]=r.useState(""),[U,Y]=r.useState(0),[J,Q]=r.useState(!1),[X,Z]=r.useState(0),[ee,te]=r.useState(""),[oe,re]=r.useState(!1),[ce,se]=r.useState(!1),[ne,ie]=r.useState(),[le,ae]=r.useReducer(p.selectedColectionsReducer,Object.keys(y).length>0?y:{}),de=r.useRef(null);r.useEffect((()=>{Q(!0),se(!0),e.collectionFetcher(U,j).then((e=>{M({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Q(!1),Y((e=>e+1)),se(!1)})).catch()}),[]),r.useEffect((()=>{console.log({selectedCollections:le});let e=0;A?Object.keys(le||[]).forEach((t=>{var o;Object.keys((null===(o=le[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r;"-1"!==t&&le[-1]&&(null===(r=le[-1].products)||void 0===r?void 0:r[o])||(e+=1)}))})):Object.keys(le||[]).forEach((t=>{var o;Object.keys((null===(o=le[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r,c;Object.keys((null===(c=null===(r=le[t].products)||void 0===r?void 0:r[o])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),Z(e)}),[le,A]),r.useEffect((()=>{var t;W&&!(null===(t=null==L?void 0:L[W])||void 0===t?void 0:t.products)&&(Q(!0),e.productFetcher(W,j).then((e=>{Object.keys(e).length&&M({type:"productsFetched",data:{collectionId:W,products:e}}),Q(!1)})).catch())}),[W]),r.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==_&&(ee.length?(re(!0),e.searchFetcher(j,ee).then((e=>{ie(Object.assign({},e)),z("searchProducts"),Q(!1),re(!1)}))):z("collections"))}),800);return()=>clearTimeout(t)}),[ee]),r.useEffect((()=>{D&&(e.onAdd(le,X),ue())}),[D]),r.useEffect((()=>{B&&Object.keys(le||{}).length&&X&&(e.onAdd(le,X),ue())}),[B,le,X]);const ue=()=>{ae({type:"reset",data:{}})},he=t.jsxs(x.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===_||"searchProducts"===_)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>oe?t.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:ee,onChangeText:e=>{e.length&&e.trim().length?te(e):te("")}})}))}),t.jsxs(x.ScrollContainerStyle,Object.assign({ref:de},{children:["collections"===_&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ce,collections:L,selectedCollectionsDispatch:ae,setCollectionId:K,setScreen:z,selectedCollections:le,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:M,setSaveDisabled:Q,pagingControls:{curPage:U,setCurPage:Y},hideCollectionCheckbox:k,renderWithoutModal:w,pickerType:N}),"products"===_&&W&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:W},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:z,storeId:j,data:L[W],collectionsDispatch:M,selectedCollectionsDispatch:ae,selectedData:le,setSaveDisabled:Q,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:T,hideVariantCheckbox:R,selectProductsFromCustomCollection:F,renderWithoutModal:w,pickerType:N,hideProductVariants:A})})),"view"===_&&t.jsx(g.SelectedScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,collections:L,hideProductVariants:A}),"rearrange"===_&&t.jsx(h.RearrangeScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,outOfStockAction:T,rearrangeViewType:"grid"===G?"list":"grid",scrollContainerRef:de}),"searchProducts"===_&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:le||{},searchedCollections:ne||{},selectedCollectionsDispatch:ae,setScreen:z,collections:L,onBackPress:()=>{te(""),ie({})},pickerType:N,hideProductCheckbox:O,hideProductVariants:A,hideVariantCheckbox:R})]}))]});return t.jsx(t.Fragment,{children:w?he:t.jsx(i.StyledModal,Object.assign({zIndex:b,open:v,onClose:()=>{null==m||m(),ue()},headingTitle:E||("collections"===_||"products"===_?"Select Products":"view"===_?"Selected Products":"searchProducts"===_?"Searched Products":"rearrange"===_?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:q||"480px"},headerRightCustomElement:"rearrange"===_?(console.log("ignore:",H),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:c.COLORS.surface.standard}:void 0,primaryButton:{buttonText:J?"Loading...":_===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:J||X<1||P&&X<P||!P&&f&&X>f||!1,onClick:()=>{e.onAdd(le,X),ue()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:I?t.jsx(t.Fragment,{}):P&&X>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):f&&X>f?t.jsx(a.Tag,{tagText:`You can only select ${f} products`,type:"negative"}):X>0?t.jsx(s.Button,{onClick:()=>{z($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:["rearrange","view"].includes(_)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(_)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:"tertiaryGray"})},{children:he}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:y,selectedItems:b,onClose:m,visible:f,zIndex:P,exactLimit:v,limit:k,hideCollectionCheckbox:I,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:D,width:E,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:L=!1,showProductDetails:V}=e,[_,z]=c.useReducer(S.collectionsReducer,{}),[W,G]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[H,K]=c.useState("grid"),[U,Y]=c.useState(""),[J,Q]=c.useState(""),[X,Z]=c.useState(0),[ee,te]=c.useState(!1),[oe,ce]=c.useState(0),[re,se]=c.useState(""),[ne,le]=c.useState(!1),[ie,ae]=c.useState(!1),[de,ue]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[he,pe]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=c.useRef(null),[Ce,xe]=c.useState(!1),[ge,je]=c.useState();c.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,y).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=he[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ce(e)})),c.useEffect((()=>{J&&(te(!0),e.productFetcher(J,y).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==W&&(re.length?(le(!0),e.searchFetcher(y,re).then((e=>{"collections"in e&&"products"in e?(ue({type:"set",data:e}),z({type:"searched",data:e.collections})):(ue({type:"set",data:{collections:{},products:e}}),z({type:"searched",data:e})),G("searchProducts"),te(!1),le(!1)}))):G("collections"))}),800);return()=>clearTimeout(t)}),[re]),c.useEffect((()=>{N&&(e.onAdd(he,oe),ye())}),[N]),c.useEffect((()=>{L&&Object.keys(he||{}).length&&oe&&(e.onAdd(he,oe),ye())}),[L,he,oe]);const ye=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===W||"searchProducts"===W)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se},{children:["collections"===W&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ie,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:G,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:I,renderWithoutModal:w,pickerType:A}),"products"===W&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:G,storeId:y,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:V})})),"view"===W&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,collections:_,outOfStockAction:O,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===W&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,outOfStockAction:O,rearrangeViewType:"grid"===H?"list":"grid",scrollContainerRef:Se,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===W&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:G,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Y,setSelectedCollectionId:Q,renderWithoutModal:w,hideCollectionCheckbox:I})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(l.StyledModal,Object.assign({zIndex:P,open:f,onClose:()=>{null==m||m(),ye()},headingTitle:D||("collections"===W||"products"===W?"Select Products":"view"===W?"Selected Products":"searchProducts"===W?"Searched Products":"rearrange"===W?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"600px"},headerRightCustomElement:"rearrange"===W?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:{buttonText:ee?"Loading...":W===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||oe<1||v&&oe<v||!v&&k&&oe>k||!1,onClick:()=>{e.onAdd(he,oe),ye()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):v&&oe>v?t.jsx(a.Tag,{tagText:`You can only select ${v} products`,type:"negative"}):k&&oe>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):oe>0?t.jsx(s.Button,{onClick:()=>{G($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:["rearrange","view"].includes(W)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(W)}):t.jsx(s.Button,{disabled:!0,buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../constants/Theme.js"),i=require("../../assets/icons/info.svg.js"),o=require("../checkBox/CheckBox.js"),c=require("../icon-button/IconButton.js"),d=require("../shimmer-image/ShimmerImage.js"),r=require("../tooltips/Tooltip.js"),a=require("../TypographyStyle.js"),n=require("./ProductPickerTag.js"),l=require("./style.js"),s=require("./utility.js");const u=s=>{const{isVariant:u,data:h,productId:p,collectionId:v,variantId:I,isSelected:j,selectedCollectionsDispatch:k,viewOnly:x,upliftAdditions:y,isPartiallyChecked:C,hideProductCheckbox:P,outOfStockAction:f,hideVariantCheckbox:m,hideProductVariants:b,pickerType:g,onProductDetailClick:O,showProductDetailInfoIcon:S}=s;return e.jsxs(l.ProductCardStyle,Object.assign({isVariant:u,onClick:e=>{"PRODUCT"===g&&b&&(e.stopPropagation(),k({type:"reset",data:{}}),y("variantSelected",{productId:p,variantId:I||Object.keys(h.variants)[0],collectionId:v,variant:h}))},isActive:j},{children:[u&&!x&&!m||!u&&!x&&!P?e.jsx(o.CheckBox,{isChecked:j,isPartiallyChecked:C||!1,onValueChange:function(e){u?e?y("variantSelected",{productId:p,variantId:I,collectionId:v,variant:h}):k({type:"variantUnselected",data:{productId:p,variantId:I,collectionId:v}}):e?y("productSelected",{productId:p,collectionId:v,product:h}):k({type:"productUnselected",data:{productId:p,collectionId:v}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(d.ShimmerImage,{width:40,height:40,imageUrl:h.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(r.Tooltip,Object.assign({variant:"light",body:h.name,placement:"bottom",delay:400},{children:e.jsx(a.BodyPrimary,Object.assign({numberOfLines:1},{children:h.name}))})),S&&e.jsx(c.IconButton,{onClick:()=>{null==O||O(h)},Icon:()=>e.jsx(i.default,{width:20,height:20,color:t.COLORS.content.placeholder})})]})),e.jsx(n.ProductPickerTag,{isVariant:u,data:h,outOfStockAction:f})]}))]}))};exports.ProductCard=u,exports.ProductGroup=t=>{const{collectionId:i,productId:o,data:c,selectedData:d,selectedCollectionsDispatch:r,viewOnly:a,upliftAdditions:n,isProductPartiallyChecked:l,hideProductCheckbox:h,outOfStockAction:p,hideVariantCheckbox:v,hideProductVariants:I,pickerType:j,onProductDetailClick:k,showProductDetailInfoIcon:x}=t,y=e=>{var t,c,r,a,n,l;if(!(null===(c=null===(t=null==d?void 0:d[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(l=null===(n=null===(a=null===(r=null==d?void 0:d[i])||void 0===r?void 0:r.products)||void 0===a?void 0:a[o])||void 0===n?void 0:n.variants)||void 0===l?void 0:l[e])};return e.jsxs("div",{children:[e.jsx(u,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(P=null===(C=null==d?void 0:d[i])||void 0===C?void 0:C.products)||void 0===P?void 0:P[o]),isPartiallyChecked:l,selectedCollectionsDispatch:r,upliftAdditions:n,viewOnly:a,hideProductCheckbox:h,hideVariantCheckbox:v,hideProductVariants:I,pickerType:j,outOfStockAction:p,onProductDetailClick:k,showProductDetailInfoIcon:x},o),I?null:s.shouldShowVariant(c)&&Object.keys(c.variants||[]).map((t=>e.jsx(u,{isVariant:!0,hideVariantCheckbox:v,data:c.variants[t],variantId:t,productId:o,viewOnly:a,upliftAdditions:n,collectionId:i,isSelected:y(t),selectedCollectionsDispatch:r,outOfStockAction:p,onProductDetailClick:k,showProductDetailInfoIcon:x},t)))]});var C,P};
@@ -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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("styled-components"),o=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),i=require("../icon-button/IconButton.js"),a=require("../shimmer-image/ShimmerImage.js"),s=require("../TypographyStyle.js"),d=require("./ProductPickerTag.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);const c=t=>{var o;const r=void 0===t.productData.variants;return e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(a.ShimmerImage,{imageUrl:t.productData.image,width:"200px",height:200,borderRadius:4})}),e.jsxs(h,{children:[e.jsx(s.TitleSmall,Object.assign({style:{display:"flex"}},{children:t.productData.name})),e.jsx(s.BodyCaption,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(o=t.productData.description)&&void 0!==o?o:""}}),e.jsx(d.ProductPickerTag,{isVariant:r,data:t.productData,outOfStockAction:t.outOfStockAction})]})]})},u=l.default.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
+ `,p=l.default.div`
12
+ display: flex;
13
+ flex: 1;
14
+ background: rgba(0, 0, 0, 0.5);
15
+ `,x=l.default.div`
16
+ position: relative;
17
+
18
+ .close-button {
19
+ position: absolute;
20
+ top: -50px;
21
+ right: 0px;
22
+ margin: 10px;
23
+ background: ${o.COLORS.surface.standard};
24
+ border-radius: 50%;
25
+ }
26
+ `,f=l.default.div`
27
+ display: flex;
28
+ background: white;
29
+ padding: 24px;
30
+ gap: 24px;
31
+ border-radius: 8px 8px 0px 0px;
32
+ `,g=l.default.div`
33
+ display: flex;
34
+ `,h=l.default.div`
35
+ display: flex;
36
+ flex: 1;
37
+ flex-direction: column;
38
+ gap: 10px;
39
+ `;exports.ProductInfoCard=c,exports.ProductInfoOverlay=t=>e.jsxs(u,{children:[e.jsx(p,{}),e.jsx(x,{children:e.jsx(i.IconButton,{className:"close-button",onClick:t.onClose,Icon:r.default,width:20,height:20})}),e.jsx(c,{productData:t.productData,outOfStockAction:t.outOfStockAction})]});
@@ -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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),d=require("react"),r=require("../tag/Tag.js"),s=require("../../constants/Theme.js"),l=require("../checkBox/CheckBox.js"),n=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),p=require("../spinner/Spinner.js"),v=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),x=require("./collectionScreen.js"),y=require("./emptyState.js"),g=require("./helpers/ProductHelper.js"),C=require("./reducers.js"),k=require("./style.js"),b=require("./type.js"),m=require("./utility.js");const O=t=>{const{collectionId:i,productId:o,data:c,selectedData:d,selectedCollectionsDispatch:r,viewOnly:s,upliftAdditions:l,isProductPartiallyChecked:n,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v}=t,j=e=>{var t,c,r,s,l,n;if(!(null===(c=null===(t=null==d?void 0:d[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(n=null===(l=null===(s=null===(r=null==d?void 0:d[i])||void 0===r?void 0:r.products)||void 0===s?void 0:s[o])||void 0===l?void 0:l.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(y=null===(x=null==d?void 0:d[i])||void 0===x?void 0:x.products)||void 0===y?void 0:y[o]),isPartiallyChecked:n,selectedCollectionsDispatch:r,upliftAdditions:l,viewOnly:s,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v},o),p?null:Object.keys(c.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:o,viewOnly:s,upliftAdditions:l,collectionId:i,isSelected:j(t),selectedCollectionsDispatch:r,outOfStockAction:u},t)))]});var x,y},I=t=>{const{isVariant:i,data:o,productId:c,collectionId:d,variantId:s,isSelected:n,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:y,hideProductCheckbox:C,outOfStockAction:b,hideVariantCheckbox:m,hideProductVariants:O,pickerType:I}=t,f=g.ProductHelper.getProductLabels(o,b);return e.jsxs(k.ProductCardStyle,Object.assign({isVariant:i,onClick:e=>{if(e.stopPropagation(),"PRODUCT"===I)if(a({type:"reset",data:{}}),O)p("productSelected",{productId:c,variantId:s,collectionId:d});else{const e=Object.keys(o.variants);p("variantSelected",{productId:c,variantId:s||e[0],collectionId:d,variant:o})}},isActive:n},{children:[i&&!u&&!m||!i&&!u&&!C?e.jsx(l.CheckBox,{isChecked:n,isPartiallyChecked:y||!1,onValueChange:function(e){if(i)e?p(O?"productSelected":"variantSelected",{productId:c,variantId:s,collectionId:d,variant:o}):a({type:O?"productUnselected":"variantUnselected",data:{productId:c,variantId:s,collectionId:d}});else if(e){const e=Object.keys(o.variants);p(O?"productSelected":"variantSelected",{productId:c,collectionId:d,product:O?o.variants[e[0]]:o})}else a({type:O?"productUnselected":"variantUnselected",data:{productId:c,collectionId:d}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(v.Tooltip,Object.assign({body:o.name,placement:"bottom",delay:400},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx(j.TitleRegular,{children:x.truncate(o.name,40,!0)}),f?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(r.Tag,{tagText:f,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=O,exports.ProductsScreen=r=>{const h=d.useContext(C.CollectionIdContext),{data:v,collectionsDispatch:x,selectedData:g,selectedCollectionsDispatch:I,productFetcher:f,storeId:S,setScreen:P,setSaveDisabled:q,hideInCollectionSearch:T,customCollectionRestriction:V,hideProductCheckbox:E,outOfStockAction:D=b.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:w=!1,selectProductsFromCustomCollection:A=!1,pickerType:B,hideProductVariants:R}=r,[U,F]=d.useState(""),[_,H]=d.useState(!1),[L,K]=d.useState(v);d.useEffect((()=>{const e=setTimeout((()=>{U.length?(H(!0),r.searchInCollectionFetcher(S,h,U).then((e=>{var t;const i=c.cloneDeep(v);i.products={};for(const o of e)(null===(t=null==v?void 0:v.products)||void 0===t?void 0:t[o])&&(i.products[o]=v.products[o]);K(i),q(!1),H(!1)}))):K(v)}),800);return()=>clearTimeout(e)}),[U]);const N=!!V&&v.isSmartCollection,W=e=>{var t,i,o,c,d,r,s,l;let n=0,a=0;return!R&&!!((null===(i=null===(t=null==g?void 0:g[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(d=Object.keys((null===(c=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[e])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>a++)),Object.keys((null===(l=null===(s=null===(r=null==g?void 0:g[h])||void 0===r?void 0:r.products)||void 0===s?void 0:s[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};d.useEffect((()=>{(null==v?void 0:v.products)||z()}),[]);const z=()=>{q(!0),H(!0),f(h,S).then((e=>{Object.keys(e).length&&(x({type:"productsFetched",data:{collectionId:h,products:e}}),K(Object.assign(Object.assign({},L),{products:e}))),q(!1),H(!1)})).catch()},G=(e,t)=>{const i=m.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},i),{isRestricted:V})})};return e.jsxs("div",{children:[e.jsxs(k.ProductScreenHeader,{children:[e.jsx(n.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:v.name}))]}),!T&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>_&&U.length?e.jsx(p.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:U,onChangeText:e=>{e.length&&e.trim().length?F(e):F("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==L?void 0:L.products)||[]).length>0&&!N&&!U.length&&!E&&e.jsxs(k.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==g?void 0:g[h]),isPartiallyChecked:(e=>{var t,i,o,c;let d=0,r=0;if(R){const c=null!==(t=null==v?void 0:v.products)&&void 0!==t?t:{};d=Object.keys(c).length;const s=null!==(o=null===(i=g[e])||void 0===i?void 0:i.products)&&void 0!==o?o:{};r=Object.keys(s).length}else if(g[e]){const t=null==v?void 0:v.products;t&&Object.keys(t).forEach((e=>{var i;const o=null===(i=t[e])||void 0===i?void 0:i.variants;o&&Object.keys(o).forEach((e=>d+=1))}));const i=null===(c=g[e])||void 0===c?void 0:c.products;i&&Object.keys(i).forEach((e=>{var t;const o=null===(t=i[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((()=>r+=1))}))}return r>0&&d!==r})(h),onValueChange:function(e){I(e?{type:"selected",data:{id:h,val:v}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==L?void 0:L.products)||[]).length?Object.keys(L.products||[]).map((t=>e.jsx(O,{outOfStockAction:D,collectionId:h,isProductPartiallyChecked:W(t),productId:t,data:L.products[t],selectedData:g,selectedCollectionsDispatch:I,viewOnly:!A&&!!N,upliftAdditions:G,hideProductCheckbox:E,hideVariantCheckbox:w,hideProductVariants:R,pickerType:B},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(y.EmptyState,{title:"No products to show",subtitle:U.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),o=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),u=require("../input/Input.js"),d=require("../spinner/Spinner.js"),a=require("../TypographyStyle.js"),h=require("./emptyState.js"),p=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=b=>{const{data:C,collectionsDispatch:O,selectedData:k,selectedCollectionsDispatch:x,productFetcher:f,storeId:S,setScreen:m,setSaveDisabled:I,hideInCollectionSearch:q,customCollectionRestriction:A,hideProductCheckbox:E,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:V=!1,pickerType:R,hideProductVariants:L,fbStatusFetcher:w,onProductDetailClick:F,showProductDetailInfoIcon:B}=b,_=o.useContext(v.CollectionIdContext),U=o.useRef(null),H=o.useRef(0),[J,K]=o.useState(!1),[M,N]=o.useState(""),[W,z]=o.useState(!1),[G,Q]=o.useState(C),X=o.useRef(!1);o.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),b.searchInCollectionFetcher(S,_,M).then((e=>{const t=s.cloneDeep(C);t.products=e,Q(t);const r=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});Z(r,null!=e?e:{},!0),I(!1),z(!1)}))):Q(C)}),800);return()=>clearTimeout(e)}),[M]),o.useEffect((()=>{var e,t,r,c;X.current=!1,H.current=Math.floor((null===(t=Object.keys(null!==(e=C.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const s=P.getVariantIdsToFetchAtProductLevel(null!==(r=C.products)&&void 0!==r?r:{});Z(s,null!==(c=C.products)&&void 0!==c?c:{})}),[_]);const Y=!!A&&C.isSmartCollection;o.useEffect((()=>{(null==C?void 0:C.products)||$(10)}),[]);const Z=(e,t,r)=>{w||(r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)),e.length>0&&w&&w(S,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((r=>{var s,o;Object.keys(null!==(o=null===(s=null==t?void 0:t[r])||void 0===s?void 0:s.variants)&&void 0!==o?o:{}).forEach((s=>{var o,n;const i=null===(o=null==t?void 0:t[r].variants)||void 0===o?void 0:o[s];i&&"REJECTED"===e[s]?i.fbStatus="REJECTED":i&&"APPROVED"===e[s]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.variants;l&&l[s]&&(l[s]=i)}))})),r?(Q((e=>{const t=Object.assign({},e);return t.products=c,t})),O({type:"productsPaged",data:{collectionId:_,products:c}})):O({type:"productsPaged",data:{collectionId:_,products:c}})})).catch((e=>{r?P.markVariantsAsApprovedProductsLevel(t,O,_,G,Q):P.markVariantsAsApprovedProductsLevel(t,O,_)}))};o.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&H.current>=0&&!X.current&&!M&&(I(!0),K(!0),f(_,S,10,H.current).then((e=>{if(Object.keys(e).length||(X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const r=P.getVariantIdsToFetchAtProductLevel(e);Z(r,e),H.current+=1}K(!1),I(!1)})).catch())}),{threshold:1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}}),[U,M]);const $=e=>{I(!0),z(!0),f(_,S,e,0).then((t=>{if(Object.keys(t).length||(X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);Z(e,t),H.current=1}e||x({type:"selected",data:{id:_,val:Object.assign(Object.assign({},C),{products:t})}}),I(!1),z(!1)})).catch()},ee=(e,t)=>{const r=P.liftTheStateUp(t,C);x({type:e,data:Object.assign(Object.assign({},r),{isRestricted:A})})};return e.jsxs("div",{children:[e.jsxs(g.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:C.name}))]}),!q&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(d.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!E&&"-1"!==_&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:!!(null==k?void 0:k[_]),isPartiallyChecked:P.isCollectionPartiallyChecked(_,C,k),onValueChange:function(e){e?$():x({type:"unselected",data:{id:_}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(a.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:T,collectionId:_,isProductPartiallyChecked:P.isProductPartiallyChecked(_,t,k,G),productId:t,data:G.products[t],selectedData:k,selectedCollectionsDispatch:x,viewOnly:!V&&!!Y,upliftAdditions:ee,hideProductCheckbox:E,hideVariantCheckbox:D,hideProductVariants:L,pickerType:R,onProductDetailClick:F,showProductDetailInfoIcon:B},t))):W?e.jsx(j.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:U})]}),J&&e.jsx(j.ProductPickerShimmer,{})]})};
@@ -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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("react-beautiful-dnd"),n=require("../../constants/Theme.js"),c=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),i=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./variantComponents.js");exports.RearrangeScreen=u=>{const{selectedCollections:p,selectedCollectionsDispatch:j,setScreen:S,rearrangeViewType:h,outOfStockAction:y,scrollContainerRef:x}=u,[f,q]=r.useState(a.parseSelectedVariantsToArray(p));r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),q(a.parseSelectedVariantsToArray(p))}),[p]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=f,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),q(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,width:16,height:16,color:n.COLORS.content.secondary,onClick:()=>{S("collections")}}),e.jsx(o.BodyCaption,Object.assign({color:n.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(p).length>0?"list"===h?e.jsx(d.VariantsList,{selectedVariants:f,setSelectedVariants:q,selectedCollectionsDispatch:j,outOfStockAction:y}):e.jsx(d.VariantsGrid,{selectedVariants:f,setSelectedVariants:q,selectedCollectionsDispatch:j}):e.jsx(i.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("react-beautiful-dnd"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./utility.js"),u=require("./variantComponents.js");exports.RearrangeScreen=p=>{const{selectedCollections:j,selectedCollectionsDispatch:S,setScreen:h,rearrangeViewType:y,outOfStockAction:f,scrollContainerRef:x,storeId:q,fbStatusFetcher:C}=p,[O,g]=r.useState(a.parseSelectedVariantsToArray(j));r.useEffect((()=>{g(a.parseSelectedVariantsToArray(j))}),[j]),r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),d.fetchFbStatusCollection(j,q,S,C,"update")}),[]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=O,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),g(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,width:16,height:16,color:c.COLORS.content.secondary,onClick:()=>{h("collections")}}),e.jsx(i.BodyCaption,Object.assign({color:c.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===y?e.jsx(u.VariantsList,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S,outOfStockAction:f}):e.jsx(u.VariantsGrid,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
@@ -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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;default:return{}}},exports.selectedColectionsReducer=function(e,a){var d,o,c,l,s,r,i,n,u,p,v;let C={},O="",g="",m="";switch(a.type){case"selected":return C=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(C={}),C.isCustom=!0),C[a.data.id]=a.data.val,C;case"unselected":return C=t.cloneDeep(e),(null==C?void 0:C.isCustom)&&(C.isCustom=!1),delete C[a.data.id],C;case"productUnselected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,delete C[g].products[O],Object.keys(C[g].products).length||((null==C?void 0:C.isCustom)&&(C.isCustom=!1),delete C[g]),C;case"productSelected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,(null===(d=a.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(a.data.isRestricted&&(C={}),C.isCustom=!0),(null==C?void 0:C[g])||(C[g]=a.data.catalogOnlyData,C[g].products={}),C[g].products[O]=a.data.product,C;case"variantSelected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,m=a.data.variantId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(C={}),C.isCustom=!0),(null==C?void 0:C[g])||(C[g]=a.data.catalogOnlyData,C[g].products={},C[g].products[O]=a.data.productOnlyData,C[g].products[O].variants={}),(null===(l=null===(c=null==C?void 0:C[g])||void 0===c?void 0:c.products)||void 0===l?void 0:l[O])||((null===(s=null==C?void 0:C[g])||void 0===s?void 0:s.products)||(C[g].products={}),C[g].products[O]=a.data.productOnlyData,C[g].products[O].variants={}),C[g].products[O].variants[m]=a.data.variant,C;case"variantUnselected":return C=t.cloneDeep(e),O=a.data.productId,g=a.data.collectionId,m=a.data.variantId,(null===(i=null===(r=C[g].products[O])||void 0===r?void 0:r.variants)||void 0===i?void 0:i[m])&&delete C[g].products[O].variants[m],Object.keys(null!==(p=null===(u=null===(n=C[g].products)||void 0===n?void 0:n[O])||void 0===u?void 0:u.variants)&&void 0!==p?p:{}).length||(delete C[g].products[O],Object.keys(C[g].products).length||((null===(v=C[g])||void 0===v?void 0:v.isSmartCollection)&&(C.isCustom=!1),delete C[g])),C;case"reset":return{};default:return e}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return a=Object.assign({},t),a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;case"searched":a=Object.assign({},t);for(const t in e.data)t in a||(a[t]=e.data[t]);return a;default:return{}}},exports.paginationReducer=function(t,e){let a={};switch(e.type){case"paginate":a=Object.assign({},t);for(const t in e.data)if(Object.prototype.hasOwnProperty.call(e.data,t)){const s=e.data[t];if(Object.prototype.hasOwnProperty.call(a,t)){const e=a[t];a[t]=Object.assign(Object.assign({},e),{products:Object.assign(Object.assign({},e.products),s.products)})}else a[t]=s}return a;case"update":return a=Object.assign({},t),a;case"set":return a=Object.assign(Object.assign({},t),e.data),a;case"filter":a={};for(const s in t)if(s in e.data){const c=Object.assign({},t[s]),d=e.data[s],o={};for(const t in c.products)if(t in d.products){const e=Object.assign({},c.products[t]),a=d.products[t],s={};for(const t in e.variants)t in a.variants&&(s[t]=Object.assign({},e.variants[t]));Object.keys(s).length>0&&(e.variants=s,o[t]=e)}Object.keys(o).length>0&&(c.products=o,a[s]=c)}return a;default:return t}},exports.searchReducer=function(t,e){let a={collections:{},products:{}};switch(e.type){case"set":return e.data;case"setProducts":return a=Object.assign({},t),a.products=e.data,a;default:return t}},exports.selectedColectionsReducer=function(e,a){var s,c,d,o,r,n;let i={},u="",l="",p="";switch(a.type){case"selected":return i=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(i={}),i.isCustom=!0),i[a.data.id]=a.data.val,i;case"unselected":return i=t.cloneDeep(e),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[a.data.id],i;case"productUnselected":return i=t.cloneDeep(e),u=a.data.productId,l=a.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.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,(null===(s=a.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(a.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=a.data.catalogOnlyData,i[l].products={}),i[l].products[u]=a.data.product,i;case"variantSelected":return i=t.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,p=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=a.data.catalogOnlyData,i[l].products={},i[l].products[u]=a.data.productOnlyData,i[l].products[u].variants={}),(null===(o=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.products)||void 0===o?void 0:o[u])||((null===(r=null==i?void 0:i[l])||void 0===r?void 0:r.products)||(i[l].products={}),i[l].products[u]=a.data.productOnlyData,i[l].products[u].variants={}),i[l].products[u].variants[p]=a.data.variant,i;case"variantUnselected":return i=t.cloneDeep(e),u=a.data.productId,l=a.data.collectionId,p=a.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({},e),i;case"reset":return{};default:return e}};
@@ -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 {};