@bikdotai/bik-component-library 0.0.665-beta.3 → 0.0.666

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 (19) hide show
  1. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
  2. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  3. package/dist/cjs/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
  4. package/dist/cjs/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  5. package/dist/cjs/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
  6. package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
  7. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  8. package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
  9. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  10. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
  11. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  12. package/dist/esm/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
  13. package/dist/esm/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  14. package/dist/esm/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
  15. package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
  16. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  17. package/dist/esm/components/product-picker-v2/reducers.js +1 -1
  18. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  19. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { QueryBuilderNodeProps } from "../../../Types/QueryBuilderNodeProps.type";
2
+ import { QueryBuilderNodeProps } from "../../../types/QueryBuilderNodeProps.type";
3
3
  declare const EventsTrigger: React.FC<QueryBuilderNodeProps>;
4
4
  export default EventsTrigger;
@@ -1,2 +1,2 @@
1
- import { QueryBuilderAPIData } from "../../../Types/QueryBuilderAPI.type";
1
+ import { QueryBuilderAPIData } from "../../../types/QueryBuilderAPI.type";
2
2
  export declare const useIGTriggerNameCacheSelector: () => QueryBuilderAPIData[];
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { QueryBuilderNodeProps } from "../../../Types/QueryBuilderNodeProps.type";
2
+ import { QueryBuilderNodeProps } from "../../../types/QueryBuilderNodeProps.type";
3
3
  declare const IGTrigger: React.FC<QueryBuilderNodeProps>;
4
4
  export default IGTrigger;
@@ -1,2 +1,2 @@
1
- import { QueryBuilderAPIData } from "../../../Types/QueryBuilderAPI.type";
1
+ import { QueryBuilderAPIData } from "../../../types/QueryBuilderAPI.type";
2
2
  export declare const useIGTriggerNameCacheSelector: () => QueryBuilderAPIData[];
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { DropdownOption } from "../../../dropdown/type";
3
- import { QueryBuilderProperty } from "../../Types/QueryBuilder.type";
4
- import { QueryBuilderNodeProps } from "../../Types/QueryBuilderNodeProps.type";
3
+ import { QueryBuilderProperty } from "../../types/QueryBuilder.type";
4
+ import { QueryBuilderNodeProps } from "../../types/QueryBuilderNodeProps.type";
5
5
  declare const BaseTriggerQueryBuilderNode: React.FC<QueryBuilderNodeProps & {
6
6
  cacheKey: string;
7
7
  propertyAddBtnText: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -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"),c=require("react"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),l=require("../input/Input.js"),i=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),g=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),j=require("./style.js"),y=require("./type.js"),m=require("./utility.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:b,selectedItems:f,onClose:v,visible:k,zIndex:I,exactLimit:P,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:R,outOfStockAction:D=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:N,hideSelectionCount:q,title:E,width:A,left:w,renderWithoutModal:B,onClickSave:L,pickerType:M,hideProductVariants:V=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:_=!1,showProductDetails:H,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:K={},primaryButton:U,secondaryButton:Y,subtitle:J}=e,[Q,X]=c.useReducer(g.collectionsReducer,{}),[Z,ee]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[te,oe]=c.useState("grid"),[ce,se]=c.useState(""),[re,ne]=c.useState(""),[le,ie]=c.useState(0),[ae,de]=c.useState(!1),[ue,he]=c.useState(0),[pe,Se]=c.useState(""),[ge,Ce]=c.useState(!1),[xe,je]=c.useState(!1),[ye,me]=c.useReducer(g.searchReducer,{collections:{},products:{}});c.useEffect((()=>{console.log("collections changed: ",Q)}),[Q]);const[be,fe]=c.useReducer(g.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=c.useRef(null),[ke,Ie]=c.useState(!1),[Pe,Oe]=c.useState();c.useEffect((()=>{de(!0),je(!0),e.collectionFetcher(le,b).then((e=>{X({type:"fetched",data:(null==e?void 0:e.collections)||{}}),de(!1),ie((e=>e+1)),je(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;V?Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&be[-1]&&(null===(c=be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=be[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Q,be,V]),c.useEffect((()=>{re&&(de(!0),e.productFetcher(re,b).then((e=>{Object.keys(e).length&&X({type:"productsFetched",data:{collectionId:re,products:e}}),de(!1)})).catch())}),[re]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==Z&&(pe.length||"collections"!==Z)&&(pe.length?(Ce(!0),e.searchFetcher(b,pe).then((e=>{console.log("search data: ",e),"collections"in e&&"products"in e?(me({type:"set",data:e}),X({type:"searched",data:e.collections}),X({type:"searched",data:e.products})):(me({type:"set",data:{collections:{},products:e}}),X({type:"searched",data:e})),ee("searchProducts"),de(!1),Ce(!1)}))):ee("collections"))}),800);return()=>clearTimeout(t)}),[pe]),c.useEffect((()=>{L&&(e.onAdd(be,ue),Fe())}),[L]),c.useEffect((()=>{_&&Object.keys(be||{}).length&&ue&&(e.onAdd(be,ue),Fe())}),[_,be,ue]);const Fe=()=>{fe({type:"reset",data:{}})},Re=()=>P&&ue>P?t.jsx(d.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):O&&ue>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):ue>0?t.jsx(n.Button,{onClick:()=>{ee($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:["rearrange","view"].includes(Z)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(Z)}):t.jsx(n.Button,{disabled:!0,buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:"tertiaryGray"}),De=e=>ae?"Loading...":Z===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Te=t.jsxs(j.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===Z||"searchProducts"===Z)&&t.jsx("div",Object.assign({style:{padding:B?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(l.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t.jsx(a.Spinner,{size:"small",color:s.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:pe,onChangeText:e=>{e.length&&e.trim().length?Se(e):Se("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:ve,screenName:Z},{children:["collections"===Z&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:xe,collections:Q,selectedCollectionsDispatch:fe,setCollectionId:se,setSelectedCollectionId:ne,setScreen:ee,selectedCollections:be,collectionFetcher:e.collectionFetcher,storeId:b,collectionsDispatch:X,setSaveDisabled:de,pagingControls:{curPage:le,setCurPage:ie},hideCollectionCheckbox:F,renderWithoutModal:B,pickerType:M,scrollContainerRef:ve}),"products"===Z&&ce&&t.jsx(g.CollectionIdContext.Provider,Object.assign({value:ce},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:ee,storeId:b,data:Q[ce],collectionsDispatch:X,selectedCollectionsDispatch:fe,selectedData:be,setSaveDisabled:de,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:R,outOfStockAction:D,hideVariantCheckbox:T,selectProductsFromCustomCollection:N,renderWithoutModal:B,pickerType:M,hideProductVariants:V,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Oe(e)},showProductDetailInfoIcon:H,scrollContainerRef:ve})})),"view"===Z&&t.jsx(x.SelectedScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,hideProductVariants:V,outOfStockAction:D,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===Z&&t.jsx(S.RearrangeScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,outOfStockAction:D,rearrangeViewType:"grid"===te?"list":"grid",scrollContainerRef:ve,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===Z&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:be||{},searchedCollections:ye||{},searchedCollectionsDispatch:me,selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,onBackPress:()=>{Se(""),me({type:"set",data:{collections:{},products:{}}})},pickerType:M,hideProductCheckbox:R,hideProductVariants:V,hideVariantCheckbox:T,storeId:b,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:ne,renderWithoutModal:B,hideCollectionCheckbox:F,outOfStockAction:D})]}))]}));return t.jsx(t.Fragment,{children:B?t.jsxs(t.Fragment,{children:[Te,K.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Re(),t.jsx(n.Button,{buttonText:De(K.primaryButtonText),disabled:!K.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||K.primaryButtonDisabled,isLoading:K.isLoading,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):t.jsx(t.Fragment,{}),ke&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,outOfStockAction:D,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(i.StyledModal,Object.assign({zIndex:I,open:k,onClose:()=>{null==v||v(),Fe()},headingTitle:E||("collections"===Z||"products"===Z?"Select Products":"view"===Z?"Selected Products":"searchProducts"===Z?"Searched Results":"rearrange"===Z?"Rearrange Products":void 0),headingSubtitle:J,footerShadow:!0,centralContainerStyles:{width:A||"600px",left:w||"auto"},headerRightCustomElement:G?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:v},{children:t.jsx(r.default,{width:20,height:20,color:s.COLORS.content.secondary})})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:s.COLORS.surface.standard}:void 0,primaryButton:U?(t=>Object.assign(Object.assign({},t),{disabled:!t.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||t.disabled,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}))(U):{buttonText:De(),disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{e.onAdd(be,ue),Fe()}},secondaryButton:Y?(t=>Object.assign(Object.assign({},t),{disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{console.log("clicked ADD TO CART. Passing: ",{selectedCollections:be,collections:Q,searchedCollections:ye});const t=m.updateAllVariantsForSelectedProducts(be,Q,ye);console.log("response from Filtered collections: ",{filteredCollections:t}),e.onAdd(t,ue,!0)}}))(Y):void 0,wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):Re(),hideCrossButton:ke||G},{children:[Te,ke&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:D,onClose:()=>{Ie(!1)}}):t.jsx(t.Fragment,{})]}))})};
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("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),C=require("./reducers.js"),g=require("./searchScreen.js"),x=require("./selectedScreen.js"),j=require("./style.js"),y=require("./type.js"),m=require("./utility.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:b,selectedItems:f,onClose:v,visible:I,zIndex:k,exactLimit:P,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:R,outOfStockAction:D=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:N,hideSelectionCount:q,title:E,width:A,left:w,renderWithoutModal:B,onClickSave:L,pickerType:M,hideProductVariants:V=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:_=!1,showProductDetails:H,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:K={},primaryButton:U,secondaryButton:Y,subtitle:J}=e,[Q,X]=c.useReducer(C.collectionsReducer,{}),[Z,ee]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[te,oe]=c.useState("grid"),[ce,re]=c.useState(""),[se,ne]=c.useState(""),[ie,le]=c.useState(0),[ae,de]=c.useState(!1),[ue,he]=c.useState(0),[pe,Se]=c.useState(""),[Ce,ge]=c.useState(!1),[xe,je]=c.useState(!1),[ye,me]=c.useReducer(C.searchReducer,{collections:{},products:{}}),[be,fe]=c.useReducer(C.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=c.useRef(null),[Ie,ke]=c.useState(!1),[Pe,Oe]=c.useState();c.useEffect((()=>{de(!0),je(!0),e.collectionFetcher(ie,b).then((e=>{X({type:"fetched",data:(null==e?void 0:e.collections)||{}}),de(!1),le((e=>e+1)),je(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;V?Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&be[-1]&&(null===(c=be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=be[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Q,be,V]),c.useEffect((()=>{se&&(de(!0),e.productFetcher(se,b).then((e=>{Object.keys(e).length&&X({type:"productsFetched",data:{collectionId:se,products:e}}),de(!1)})).catch())}),[se]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==Z&&(pe.length||"collections"!==Z)&&(pe.length?(ge(!0),e.searchFetcher(b,pe).then((e=>{"collections"in e&&"products"in e?(me({type:"set",data:e}),X({type:"searched",data:e.collections}),X({type:"searched",data:e.products})):(me({type:"set",data:{collections:{},products:e}}),X({type:"searched",data:e})),ee("searchProducts"),de(!1),ge(!1)}))):ee("collections"))}),800);return()=>clearTimeout(t)}),[pe]),c.useEffect((()=>{L&&(e.onAdd(be,ue),Fe())}),[L]),c.useEffect((()=>{_&&Object.keys(be||{}).length&&ue&&(e.onAdd(be,ue),Fe())}),[_,be,ue]);const Fe=()=>{fe({type:"reset",data:{}})},Re=()=>P&&ue>P?t.jsx(d.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):O&&ue>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):ue>0?t.jsx(n.Button,{onClick:()=>{ee($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:["rearrange","view"].includes(Z)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(Z)}):t.jsx(n.Button,{disabled:!0,buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:"tertiaryGray"}),De=e=>ae?"Loading...":Z===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Te=t.jsxs(j.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===Z||"searchProducts"===Z)&&t.jsx("div",Object.assign({style:{padding:B?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Ce?t.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:pe,onChangeText:e=>{e.length&&e.trim().length?Se(e):Se("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:ve,screenName:Z},{children:["collections"===Z&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:xe,collections:Q,selectedCollectionsDispatch:fe,setCollectionId:re,setSelectedCollectionId:ne,setScreen:ee,selectedCollections:be,collectionFetcher:e.collectionFetcher,storeId:b,collectionsDispatch:X,setSaveDisabled:de,pagingControls:{curPage:ie,setCurPage:le},hideCollectionCheckbox:F,renderWithoutModal:B,pickerType:M,scrollContainerRef:ve}),"products"===Z&&ce&&t.jsx(C.CollectionIdContext.Provider,Object.assign({value:ce},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:ee,storeId:b,data:Q[ce],collectionsDispatch:X,selectedCollectionsDispatch:fe,selectedData:be,setSaveDisabled:de,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:R,outOfStockAction:D,hideVariantCheckbox:T,selectProductsFromCustomCollection:N,renderWithoutModal:B,pickerType:M,hideProductVariants:V,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{ke(!0),Oe(e)},showProductDetailInfoIcon:H,scrollContainerRef:ve})})),"view"===Z&&t.jsx(x.SelectedScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,hideProductVariants:V,outOfStockAction:D,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===Z&&t.jsx(S.RearrangeScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,outOfStockAction:D,rearrangeViewType:"grid"===te?"list":"grid",scrollContainerRef:ve,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===Z&&t.jsx(g.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:be||{},searchedCollections:ye||{},searchedCollectionsDispatch:me,selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,onBackPress:()=>{Se(""),me({type:"set",data:{collections:{},products:{}}})},pickerType:M,hideProductCheckbox:R,hideProductVariants:V,hideVariantCheckbox:T,storeId:b,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:re,setSelectedCollectionId:ne,renderWithoutModal:B,hideCollectionCheckbox:F,outOfStockAction:D})]}))]}));return t.jsx(t.Fragment,{children:B?t.jsxs(t.Fragment,{children:[Te,K.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Re(),t.jsx(n.Button,{buttonText:De(K.primaryButtonText),disabled:!K.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||K.primaryButtonDisabled,isLoading:K.isLoading,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):t.jsx(t.Fragment,{}),Ie&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,outOfStockAction:D,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{ke(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(l.StyledModal,Object.assign({zIndex:k,open:I,onClose:()=>{null==v||v(),Fe()},headingTitle:E||("collections"===Z||"products"===Z?"Select Products":"view"===Z?"Selected Products":"searchProducts"===Z?"Searched Results":"rearrange"===Z?"Rearrange Products":void 0),headingSubtitle:J,footerShadow:!0,centralContainerStyles:{width:A||"600px",left:w||"auto"},headerRightCustomElement:G?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:v},{children:t.jsx(s.default,{width:20,height:20,color:r.COLORS.content.secondary})})):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:U?(t=>Object.assign(Object.assign({},t),{disabled:!t.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||t.disabled,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}))(U):{buttonText:De(),disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{e.onAdd(be,ue),Fe()}},secondaryButton:Y?(t=>Object.assign(Object.assign({},t),{disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{const t=m.updateAllVariantsForSelectedProducts(be,Q,ye);e.onAdd(t,ue,!0)}}))(Y):void 0,wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):Re(),hideCrossButton:Ie||G},{children:[Te,Ie&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:D,onClose:()=>{ke(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -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;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":console.log("Searched collections reducer called",{data:e.data,collections:t}),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,i,l,u,p,v;let O={},g="",b="",j="";switch(a.type){case"selected":return O=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(O={}),O.isCustom=!0),O[a.data.id]=a.data.val,O;case"unselected":return O=t.cloneDeep(e),(null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[a.data.id],O;case"productUnselected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,delete O[b].products[g],Object.keys(O[b].products).length||((null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[b]),O;case"productSelected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,(null===(s=a.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(a.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=a.data.catalogOnlyData,O[b].products={}),O[b].products[g]=a.data.product,O;case"variantSelected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,j=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=a.data.catalogOnlyData,O[b].products={},O[b].products[g]=a.data.productOnlyData,O[b].products[g].variants={}),(null===(d=null==O?void 0:O[b])||void 0===d?void 0:d.products)||(O[b].products={}),(null===(r=null===(o=null==O?void 0:O[b])||void 0===o?void 0:o.products)||void 0===r?void 0:r[g])||(O[b].products[g]=a.data.productOnlyData,O[b].products[g].variants={}),O[b].products[g].variants||(O[b].products[g].variants={}),O[b].products[g].variants[j]=a.data.variant,O;case"variantUnselected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,j=a.data.variantId,(null===(i=null===(n=O[b].products[g])||void 0===n?void 0:n.variants)||void 0===i?void 0:i[j])&&delete O[b].products[g].variants[j],Object.keys(null!==(p=null===(u=null===(l=O[b].products)||void 0===l?void 0:l[g])||void 0===u?void 0:u.variants)&&void 0!==p?p:{}).length||(delete O[b].products[g],Object.keys(O[b].products).length||((null===(v=O[b])||void 0===v?void 0:v.isSmartCollection)&&(O.isCustom=!1),delete O[b])),O;case"update":return O=Object.assign({},e),O;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,i,l,u,p,v;let O={},g="",b="",j="";switch(a.type){case"selected":return O=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(O={}),O.isCustom=!0),O[a.data.id]=a.data.val,O;case"unselected":return O=t.cloneDeep(e),(null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[a.data.id],O;case"productUnselected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,delete O[b].products[g],Object.keys(O[b].products).length||((null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[b]),O;case"productSelected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,(null===(s=a.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(a.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=a.data.catalogOnlyData,O[b].products={}),O[b].products[g]=a.data.product,O;case"variantSelected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,j=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=a.data.catalogOnlyData,O[b].products={},O[b].products[g]=a.data.productOnlyData,O[b].products[g].variants={}),(null===(d=null==O?void 0:O[b])||void 0===d?void 0:d.products)||(O[b].products={}),(null===(r=null===(o=null==O?void 0:O[b])||void 0===o?void 0:o.products)||void 0===r?void 0:r[g])||(O[b].products[g]=a.data.productOnlyData,O[b].products[g].variants={}),O[b].products[g].variants||(O[b].products[g].variants={}),O[b].products[g].variants[j]=a.data.variant,O;case"variantUnselected":return O=t.cloneDeep(e),g=a.data.productId,b=a.data.collectionId,j=a.data.variantId,(null===(i=null===(n=O[b].products[g])||void 0===n?void 0:n.variants)||void 0===i?void 0:i[j])&&delete O[b].products[g].variants[j],Object.keys(null!==(p=null===(u=null===(l=O[b].products)||void 0===l?void 0:l[g])||void 0===u?void 0:u.variants)&&void 0!==p?p:{}).length||(delete O[b].products[g],Object.keys(O[b].products).length||((null===(v=O[b])||void 0===v?void 0:v.isSmartCollection)&&(O.isCustom=!1),delete O[b])),O;case"update":return O=Object.assign({},e),O;case"reset":return{};default:return e}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function l(o,l,t){if(!o)return{};const n=Object.keys(o).slice(t,t+l),d={};return n.forEach((l=>{d[l]=o[l]})),d}const t=(o,l,t)=>{Object.keys(o).forEach((l=>{var t,n;const d=null!==(n=null===(t=o[l])||void 0===t?void 0:t.products)&&void 0!==n?n:{};Object.keys(d).forEach((t=>{var n,d,i,e;const s=null!==(e=null===(i=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[t])||void 0===i?void 0:i.variants)&&void 0!==e?e:{};Object.keys(s).forEach((n=>{var d,i,e,s;const c=null===(s=null===(e=null===(i=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===i?void 0:i[t])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[n];c&&!c.fbStatus&&(c.fbStatus="APPROVED")}))}))})),l({type:t,data:o})};exports.fetchFbStatusCollection=function(o,l,n,d){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";d||t(o,n,i);const e=(o=>{const l=[];return Object.keys(o).forEach((t=>{var n,d;const i=null!==(d=null===(n=o[t])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,e,s;const c=null!==(s=null===(e=null===(i=null===(d=o[t])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===e?void 0:e.variants)&&void 0!==s?s:{};Object.keys(c).forEach((d=>{var i,e,s,c;const v=null===(c=null===(s=null===(e=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===e?void 0:e[n])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[d];(null==v?void 0:v.fbStatus)||l.push(d)}))}))})),l})(o);e.length>0&&d&&d(l,e).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var n,d;const i=null!==(d=null===(n=t[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,e,s;const c=null!==(s=null===(e=null===(i=null===(d=t[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===e?void 0:e.variants)&&void 0!==s?s:{};Object.keys(c).forEach((d=>{var i,e,s,c;const v=null===(c=null===(s=null===(e=null===(i=t[o])||void 0===i?void 0:i.products)||void 0===e?void 0:e[n])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[d];v&&"REJECTED"===l[d]?v.fbStatus="REJECTED":v&&"APPROVED"===l[d]&&(v.fbStatus="APPROVED")}))}))})),n({type:i,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,n,i)}))},exports.getSkuId=(o,l)=>{var t;if(l)return o.skuId;const n=Object.values(null!==(t=null==o?void 0:o.variants)&&void 0!==t?t:{});return 1===n.length&&n[0].name.includes(o.name)?n[0].skuId:""},exports.getVariantIdsToFetchAtProductLevel=(o,l)=>{const t=[];return Object.keys(null!=o?o:{}).forEach((n=>{var d,i;const e=null!==(i=null===(d=null==o?void 0:o[n])||void 0===d?void 0:d.variants)&&void 0!==i?i:{};Object.keys(e).forEach((d=>{var i,e,s,c,v;let r;r=l?null===(s=null===(e=null===(i=null==l?void 0:l.products)||void 0===i?void 0:i[n])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[d]:null===(v=null===(c=null==o?void 0:o[n])||void 0===c?void 0:c.variants)||void 0===v?void 0:v[d],(null==r?void 0:r.fbStatus)||t.push(d)}))})),t},exports.isCollectionPartiallyChecked=function(o,l,t){var n,d,i,e;let s=0,c=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const e=null!==(n=null==l?void 0:l.products)&&void 0!==n?n:{};s=Object.keys(e).length;const v=null!==(i=null===(d=t[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};c=Object.keys(v).length}else if(t[o]){const n=null==l?void 0:l.products;n&&Object.keys(n).forEach((o=>{var l;const t=null===(l=n[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>s+=1))}));const d=null===(e=t[o])||void 0===e?void 0:e.products;if(d&&Object.keys(d).forEach((o=>{var l;const t=null===(l=d[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>c+=1))})),s<=0&&c>0)return!1}return c>0&&s!==c},exports.isProductPartiallyChecked=(o,l,t,n,d)=>{var i,e,s,c,v,r,u,a,p,b,O,f,g,h,j,y,k,E,P;let S=0,V=0;if(null===(e=null===(i=null==t?void 0:t[o])||void 0===i?void 0:i.products)||void 0===e?void 0:e[l]){if(d)return!1;const i=(null===(v=null===(c=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.products)||void 0===c?void 0:c[l])||void 0===v?void 0:v.variants)||[];if(1===Object.keys(i).length)for(const n in i){const d=null===(u=null===(r=null==t?void 0:t[o])||void 0===r?void 0:r.products)||void 0===u?void 0:u[l],i=null===(O=null===(b=null===(p=null===(a=null==t?void 0:t[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[n];if(null===(f=null==i?void 0:i.name)||void 0===f?void 0:f.includes(null!==(g=null==d?void 0:d.name)&&void 0!==g?g:""))return!1}if(null===(y=Object.keys((null===(j=null===(h=null==n?void 0:n.products)||void 0===h?void 0:h[l])||void 0===j?void 0:j.variants)||[]))||void 0===y||y.forEach((()=>V++)),Object.keys((null===(P=null===(E=null===(k=null==t?void 0:t[o])||void 0===k?void 0:k.products)||void 0===E?void 0:E[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>S++)),S>0&&V!==S)return!0}return!1},exports.liftTheStateUp=(l,t)=>{const n=o.cloneDeep(t);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&t.products){const d=o.cloneDeep(t.products[l.productId]);(null==d?void 0:d.variants)&&delete d.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:d})}return l},exports.markVariantsAsApprovedProductsLevel=(o,l,t,n,d)=>{const i=Object.assign({},o);if(Object.keys(o).forEach((l=>{var t,n;Object.keys(null!==(n=null===(t=null==o?void 0:o[l])||void 0===t?void 0:t.variants)&&void 0!==n?n:{}).forEach((t=>{var n,d;const e=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[t];e&&(e.fbStatus="APPROVED");const s=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.variants;s&&s[t]&&(s[t]=e)}))})),n&&d){const o=Object.assign({},n);o.products=i,d(o),l({type:"productsPaged",data:{collectionId:t,products:i}})}else l({type:"productsPaged",data:{collectionId:t,products:i}})},exports.paginateSelectedItems=function(o,t,n){var d;const i={};let e=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const c=o[s],v=l(c.products,t,n-e);v&&Object.keys(v).length>0&&(i[s]=Object.assign(Object.assign({},c),{products:v})),e+=Object.keys(null!==(d=c.products)&&void 0!==d?d:{}).length}return i},exports.shouldShowVariant=o=>{const l=Object.keys(o.variants||[]);let t=!1;return!(l.length<=1)||(l.forEach((l=>{var n,d;t=null!==(d=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==d&&d})),!t)},exports.updateAllVariantsForSelectedProducts=(l,t,n)=>{console.log("updateAllVariantsForSelectedProducts called"),console.log("selectedItems:",l),console.log("collections:",t),console.log("searchedProducts:",n);const d=Object.keys(l).reduce(((d,i)=>{var e;return console.log(`Processing collectionId: ${i}`),i in t?(d[i]=Object.assign(Object.assign({},l[i]),{products:Object.keys(null!==(e=l[i].products)&&void 0!==e?e:{}).reduce(((d,e)=>{var s,c,v,r,u,a,p,b,O,f;console.log(` Processing productId: ${e}`);const g=null===(s=t[i].products)||void 0===s?void 0:s[e],h=null===(r=null===(v=null===(c=null==n?void 0:n.products)||void 0===c?void 0:c[i])||void 0===v?void 0:v.products)||void 0===r?void 0:r[e];return g?(console.log(` Product ${e} found in collections[${i}]`),d[e]=Object.assign(Object.assign({},(null===(u=l[i].products)||void 0===u?void 0:u[e])||{}),{allVariants:o.cloneDeep(g.variants)})):h?(console.log(` Product ${e} found in searchedProducts.products[${i}]`),d[e]=Object.assign(Object.assign({},(null===(a=l[i].products)||void 0===a?void 0:a[e])||{}),{allVariants:o.cloneDeep(h.variants)})):(null===(b=null===(p=l[i].products)||void 0===p?void 0:p[e])||void 0===b?void 0:b.allVariants)?(console.log(` Product ${e} using preselected allVariants`),d[e]=Object.assign(Object.assign({},(null===(O=l[i].products)||void 0===O?void 0:O[e])||{}),{allVariants:o.cloneDeep(null===(f=l[i].products)||void 0===f?void 0:f[e].allVariants)})):console.log(` Product ${e} not found in collections or searchedProducts and has no preselected allVariants`),d}),{})}),d):(console.log(`Collection ${i} not found in collections`),d)}),{});return console.log("updatedSelectedItems:",d),d};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function l(o,l,t){if(!o)return{};const i=Object.keys(o).slice(t,t+l),n={};return i.forEach((l=>{n[l]=o[l]})),n}const t=(o,l,t)=>{Object.keys(o).forEach((l=>{var t,i;const n=null!==(i=null===(t=o[l])||void 0===t?void 0:t.products)&&void 0!==i?i:{};Object.keys(n).forEach((t=>{var i,n,d,v;const s=null!==(v=null===(d=null===(n=null===(i=o[l])||void 0===i?void 0:i.products)||void 0===n?void 0:n[t])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((i=>{var n,d,v,s;const e=null===(s=null===(v=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[t])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[i];e&&!e.fbStatus&&(e.fbStatus="APPROVED")}))}))})),l({type:t,data:o})};exports.fetchFbStatusCollection=function(o,l,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||t(o,i,d);const v=(o=>{const l=[];return Object.keys(o).forEach((t=>{var i,n;const d=null!==(n=null===(i=o[t])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const u=null===(e=null===(s=null===(v=null===(d=o[t])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];(null==u?void 0:u.fbStatus)||l.push(n)}))}))})),l})(o);v.length>0&&n&&n(l,v).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var i,n;const d=null!==(n=null===(i=t[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=t[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const u=null===(e=null===(s=null===(v=null===(d=t[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];u&&"REJECTED"===l[n]?u.fbStatus="REJECTED":u&&"APPROVED"===l[n]&&(u.fbStatus="APPROVED")}))}))})),i({type:d,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,i,d)}))},exports.getSkuId=(o,l)=>{var t;if(l)return o.skuId;const i=Object.values(null!==(t=null==o?void 0:o.variants)&&void 0!==t?t:{});return 1===i.length&&i[0].name.includes(o.name)?i[0].skuId:""},exports.getVariantIdsToFetchAtProductLevel=(o,l)=>{const t=[];return Object.keys(null!=o?o:{}).forEach((i=>{var n,d;const v=null!==(d=null===(n=null==o?void 0:o[i])||void 0===n?void 0:n.variants)&&void 0!==d?d:{};Object.keys(v).forEach((n=>{var d,v,s,e,u;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n]:null===(u=null===(e=null==o?void 0:o[i])||void 0===e?void 0:e.variants)||void 0===u?void 0:u[n],(null==r?void 0:r.fbStatus)||t.push(n)}))})),t},exports.isCollectionPartiallyChecked=function(o,l,t){var i,n,d,v;let s=0,e=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(i=null==l?void 0:l.products)&&void 0!==i?i:{};s=Object.keys(v).length;const u=null!==(d=null===(n=t[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};e=Object.keys(u).length}else if(t[o]){const i=null==l?void 0:l.products;i&&Object.keys(i).forEach((o=>{var l;const t=null===(l=i[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>s+=1))}));const n=null===(v=t[o])||void 0===v?void 0:v.products;if(n&&Object.keys(n).forEach((o=>{var l;const t=null===(l=n[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>e+=1))})),s<=0&&e>0)return!1}return e>0&&s!==e},exports.isProductPartiallyChecked=(o,l,t,i,n)=>{var d,v,s,e,u,r,c,a,p,b,O,f,j,h,y,g,k,E,P;let D=0,S=0;if(null===(v=null===(d=null==t?void 0:t[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[l]){if(n)return!1;const d=(null===(u=null===(e=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.products)||void 0===e?void 0:e[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(d).length)for(const i in d){const n=null===(c=null===(r=null==t?void 0:t[o])||void 0===r?void 0:r.products)||void 0===c?void 0:c[l],d=null===(O=null===(b=null===(p=null===(a=null==t?void 0:t[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[i];if(null===(f=null==d?void 0:d.name)||void 0===f?void 0:f.includes(null!==(j=null==n?void 0:n.name)&&void 0!==j?j:""))return!1}if(null===(g=Object.keys((null===(y=null===(h=null==i?void 0:i.products)||void 0===h?void 0:h[l])||void 0===y?void 0:y.variants)||[]))||void 0===g||g.forEach((()=>S++)),Object.keys((null===(P=null===(E=null===(k=null==t?void 0:t[o])||void 0===k?void 0:k.products)||void 0===E?void 0:E[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},exports.liftTheStateUp=(l,t)=>{const i=o.cloneDeep(t);if(delete i.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:i})).productId&&t.products){const n=o.cloneDeep(t.products[l.productId]);(null==n?void 0:n.variants)&&delete n.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:i,productOnlyData:n})}return l},exports.markVariantsAsApprovedProductsLevel=(o,l,t,i,n)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var t,i;Object.keys(null!==(i=null===(t=null==o?void 0:o[l])||void 0===t?void 0:t.variants)&&void 0!==i?i:{}).forEach((t=>{var i,n;const v=null===(i=null==o?void 0:o[l].variants)||void 0===i?void 0:i[t];v&&(v.fbStatus="APPROVED");const s=null===(n=null==d?void 0:d[l])||void 0===n?void 0:n.variants;s&&s[t]&&(s[t]=v)}))})),i&&n){const o=Object.assign({},i);o.products=d,n(o),l({type:"productsPaged",data:{collectionId:t,products:d}})}else l({type:"productsPaged",data:{collectionId:t,products:d}})},exports.paginateSelectedItems=function(o,t,i){var n;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const e=o[s],u=l(e.products,t,i-v);u&&Object.keys(u).length>0&&(d[s]=Object.assign(Object.assign({},e),{products:u})),v+=Object.keys(null!==(n=e.products)&&void 0!==n?n:{}).length}return d},exports.shouldShowVariant=o=>{const l=Object.keys(o.variants||[]);let t=!1;return!(l.length<=1)||(l.forEach((l=>{var i,n;t=null!==(n=null===(i=o.variants)||void 0===i?void 0:i[l].name.includes(o.name))&&void 0!==n&&n})),!t)},exports.updateAllVariantsForSelectedProducts=(l,t,i)=>Object.keys(l).reduce(((n,d)=>{var v;return d in t?(n[d]=Object.assign(Object.assign({},l[d]),{products:Object.keys(null!==(v=l[d].products)&&void 0!==v?v:{}).reduce(((n,v)=>{var s,e,u,r,c,a,p,b,O,f;const j=null===(s=t[d].products)||void 0===s?void 0:s[v],h=null===(r=null===(u=null===(e=null==i?void 0:i.products)||void 0===e?void 0:e[d])||void 0===u?void 0:u.products)||void 0===r?void 0:r[v];return j?n[v]=Object.assign(Object.assign({},(null===(c=l[d].products)||void 0===c?void 0:c[v])||{}),{allVariants:o.cloneDeep(j.variants)}):h?n[v]=Object.assign(Object.assign({},(null===(a=l[d].products)||void 0===a?void 0:a[v])||{}),{allVariants:o.cloneDeep(h.variants)}):(null===(b=null===(p=l[d].products)||void 0===p?void 0:p[v])||void 0===b?void 0:b.allVariants)&&(n[v]=Object.assign(Object.assign({},(null===(O=l[d].products)||void 0===O?void 0:O[v])||{}),{allVariants:o.cloneDeep(null===(f=l[d].products)||void 0===f?void 0:f[v].allVariants)})),n}),{})}),n):n}),{});
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { QueryBuilderNodeProps } from "../../../Types/QueryBuilderNodeProps.type";
2
+ import { QueryBuilderNodeProps } from "../../../types/QueryBuilderNodeProps.type";
3
3
  declare const EventsTrigger: React.FC<QueryBuilderNodeProps>;
4
4
  export default EventsTrigger;
@@ -1,2 +1,2 @@
1
- import { QueryBuilderAPIData } from "../../../Types/QueryBuilderAPI.type";
1
+ import { QueryBuilderAPIData } from "../../../types/QueryBuilderAPI.type";
2
2
  export declare const useIGTriggerNameCacheSelector: () => QueryBuilderAPIData[];
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { QueryBuilderNodeProps } from "../../../Types/QueryBuilderNodeProps.type";
2
+ import { QueryBuilderNodeProps } from "../../../types/QueryBuilderNodeProps.type";
3
3
  declare const IGTrigger: React.FC<QueryBuilderNodeProps>;
4
4
  export default IGTrigger;
@@ -1,2 +1,2 @@
1
- import { QueryBuilderAPIData } from "../../../Types/QueryBuilderAPI.type";
1
+ import { QueryBuilderAPIData } from "../../../types/QueryBuilderAPI.type";
2
2
  export declare const useIGTriggerNameCacheSelector: () => QueryBuilderAPIData[];
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { DropdownOption } from "../../../dropdown/type";
3
- import { QueryBuilderProperty } from "../../Types/QueryBuilder.type";
4
- import { QueryBuilderNodeProps } from "../../Types/QueryBuilderNodeProps.type";
3
+ import { QueryBuilderProperty } from "../../types/QueryBuilder.type";
4
+ import { QueryBuilderNodeProps } from "../../types/QueryBuilderNodeProps.type";
5
5
  declare const BaseTriggerQueryBuilderNode: React.FC<QueryBuilderNodeProps & {
6
6
  cacheKey: string;
7
7
  propertyAddBtnText: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -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 s,useEffect as i,useRef as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import d from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as u}from"../input/Input.js";import{StyledModal as h}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as m}from"../tag/Tag.js";import{CollectionsScreen as g}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as f}from"./productScreen.js";import{RearrangeScreen as y}from"./rearrangeScreen.js";import{collectionsReducer as b,searchReducer as S,selectedColectionsReducer as v,CollectionIdContext as k}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as I}from"./selectedScreen.js";import{ContainerStyle as P,ScrollContainerStyle as x,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";var T;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(T||(T={}));const R=R=>{const{storeId:A,selectedItems:w,onClose:B,visible:E,zIndex:L,exactLimit:z,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:M,outOfStockAction:H=D.BLUR,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,hideSelectionCount:N,title:K,width:U,left:Y,renderWithoutModal:q,onClickSave:J,pickerType:Q,hideProductVariants:X=!1,startupScreen:Z=T.Collections,rearrangeEnabled:_,selectSingleItem:ee=!1,showProductDetails:te,containerStyle:oe,crossButtonInsideHeader:ce=!1,footerForNonModal:re={},primaryButton:se,secondaryButton:ie,subtitle:ne}=R,[le,de]=r(b,{}),[ae,ue]=s([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections),[he,pe]=s("grid"),[me,ge]=s(""),[Ce,fe]=s(""),[ye,be]=s(0),[Se,ve]=s(!1),[ke,je]=s(0),[Ie,Pe]=s(""),[xe,Oe]=s(!1),[De,Fe]=s(!1),[Te,Re]=r(S,{collections:{},products:{}});i((()=>{console.log("collections changed: ",le)}),[le]);const[Ae,we]=r(v,Object.keys(w).length>0?w:{}),Be=n(null),[Ee,Le]=s(!1),[ze,Ve]=s();i((()=>{ve(!0),Fe(!0),R.collectionFetcher(ye,A).then((e=>{de({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ve(!1),be((e=>e+1)),Fe(!1)})).catch()}),[]),i((()=>{let e=0;X?Object.keys(Ae||[]).forEach((t=>{var o;Object.keys((null===(o=Ae[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Ae[-1]&&(null===(c=Ae[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Ae||[]).forEach((t=>{var o;Object.keys((null===(o=Ae[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Ae[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),je(e)}),[le,Ae,X]),i((()=>{Ce&&(ve(!0),R.productFetcher(Ce,A).then((e=>{Object.keys(e).length&&de({type:"productsFetched",data:{collectionId:Ce,products:e}}),ve(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==ae&&(Ie.length||"collections"!==ae)&&(Ie.length?(Oe(!0),R.searchFetcher(A,Ie).then((e=>{console.log("search data: ",e),"collections"in e&&"products"in e?(Re({type:"set",data:e}),de({type:"searched",data:e.collections}),de({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),de({type:"searched",data:e})),ue("searchProducts"),ve(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[Ie]),i((()=>{J&&(R.onAdd(Ae,ke),$e())}),[J]),i((()=>{ee&&Object.keys(Ae||{}).length&&ke&&(R.onAdd(Ae,ke),$e())}),[ee,Ae,ke]);const $e=()=>{we({type:"reset",data:{}})},Me=()=>z&&ke>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):V&&ke>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):t(a,ke>0?{onClick:()=>{ue(_?T.RearrangeProducts:T.SelectedProducts)},buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:["rearrange","view"].includes(ae)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ae)}:{disabled:!0,buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:"tertiaryGray"}),He=e=>Se?"Loading...":ae===T.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e(P,Object.assign({style:null!=oe?oe:{}},{children:[R.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&t(o,{children:("collections"===ae||"searchProducts"===ae)&&t("div",Object.assign({style:{padding:q?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>xe?t(p,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Ie,onChangeText:e=>{e.length&&e.trim().length?Pe(e):Pe("")}})}))}),e(x,Object.assign({ref:Be,screenName:ae},{children:["collections"===ae&&t(g,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:De,collections:le,selectedCollectionsDispatch:we,setCollectionId:ge,setSelectedCollectionId:fe,setScreen:ue,selectedCollections:Ae,collectionFetcher:R.collectionFetcher,storeId:A,collectionsDispatch:de,setSaveDisabled:ve,pagingControls:{curPage:ye,setCurPage:be},hideCollectionCheckbox:$,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Be}),"products"===ae&&me&&t(k.Provider,Object.assign({value:me},{children:t(f,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:ue,storeId:A,data:le[me],collectionsDispatch:de,selectedCollectionsDispatch:we,selectedData:Ae,setSaveDisabled:ve,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:M,outOfStockAction:H,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:te,scrollContainerRef:Be})})),"view"===ae&&t(I,{selectedCollections:Ae||{},selectedCollectionsDispatch:we,setScreen:ue,collections:le,hideProductVariants:X,outOfStockAction:H,storeId:A,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===ae&&t(y,{selectedCollections:Ae||{},selectedCollectionsDispatch:we,setScreen:ue,outOfStockAction:H,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Be,storeId:A,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===ae&&t(j,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:Ae||{},searchedCollections:Te||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:we,setScreen:ue,collections:le,onBackPress:()=>{Pe(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:M,hideProductVariants:X,hideVariantCheckbox:W,storeId:A,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:fe,renderWithoutModal:q,hideCollectionCheckbox:$,outOfStockAction:H})]}))]}));return t(o,{children:q?e(o,{children:[We,re.renderFooter?e(O,{children:[Me(),t(a,{buttonText:He(re.primaryButtonText),disabled:!re.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||re.primaryButtonDisabled,isLoading:re.isLoading,onClick:()=>{R.onAdd(Ae,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}})]}):t(o,{}),Ee&&ze?t(C,{productData:ze,outOfStockAction:H,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:L,open:E,onClose:()=>{null==B||B(),$e()},headingTitle:K||("collections"===ae||"products"===ae?"Select Products":"view"===ae?"Selected Products":"searchProducts"===ae?"Searched Results":"rearrange"===ae?"Rearrange Products":void 0),headingSubtitle:ne,footerShadow:!0,centralContainerStyles:{width:U||"600px",left:Y||"auto"},headerRightCustomElement:ce?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:B},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||e.disabled,onClick:()=>{R.onAdd(Ae,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}}))(se):{buttonText:He(),disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{R.onAdd(Ae,ke),$e()}},secondaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{console.log("clicked ADD TO CART. Passing: ",{selectedCollections:Ae,collections:le,searchedCollections:Te});const e=F(Ae,le,Te);console.log("response from Filtered collections: ",{filteredCollections:e}),R.onAdd(e,ke,!0)}}))(ie):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t(o,{}):Me(),hideCrossButton:Ee||ce},{children:[We,Ee&&ze?t(C,{productData:ze,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:H,onClose:()=>{Le(!1)}}):t(o,{})]}))})};export{R as ProductPickerModal,T 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 d from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as u}from"../input/Input.js";import{StyledModal as h}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as m}from"../tag/Tag.js";import{CollectionsScreen as C}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as y}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as S,selectedColectionsReducer as v,CollectionIdContext as k}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as I}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";var T;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(T||(T={}));const R=R=>{const{storeId:w,selectedItems:A,onClose:B,visible:E,zIndex:L,exactLimit:z,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:M,outOfStockAction:H=D.BLUR,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,hideSelectionCount:N,title:K,width:U,left:Y,renderWithoutModal:q,onClickSave:J,pickerType:Q,hideProductVariants:X=!1,startupScreen:Z=T.Collections,rearrangeEnabled:_,selectSingleItem:ee=!1,showProductDetails:te,containerStyle:oe,crossButtonInsideHeader:ce=!1,footerForNonModal:re={},primaryButton:se,secondaryButton:ie,subtitle:ne}=R,[le,de]=r(f,{}),[ae,ue]=s([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections),[he,pe]=s("grid"),[me,Ce]=s(""),[ge,ye]=s(""),[be,fe]=s(0),[Se,ve]=s(!1),[ke,je]=s(0),[Ie,xe]=s(""),[Pe,Oe]=s(!1),[De,Fe]=s(!1),[Te,Re]=r(S,{collections:{},products:{}}),[we,Ae]=r(v,Object.keys(A).length>0?A:{}),Be=i(null),[Ee,Le]=s(!1),[ze,Ve]=s();n((()=>{ve(!0),Fe(!0),R.collectionFetcher(be,w).then((e=>{de({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ve(!1),fe((e=>e+1)),Fe(!1)})).catch()}),[]),n((()=>{let e=0;X?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),je(e)}),[le,we,X]),n((()=>{ge&&(ve(!0),R.productFetcher(ge,w).then((e=>{Object.keys(e).length&&de({type:"productsFetched",data:{collectionId:ge,products:e}}),ve(!1)})).catch())}),[ge]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ae&&(Ie.length||"collections"!==ae)&&(Ie.length?(Oe(!0),R.searchFetcher(w,Ie).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),de({type:"searched",data:e.collections}),de({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),de({type:"searched",data:e})),ue("searchProducts"),ve(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[Ie]),n((()=>{J&&(R.onAdd(we,ke),$e())}),[J]),n((()=>{ee&&Object.keys(we||{}).length&&ke&&(R.onAdd(we,ke),$e())}),[ee,we,ke]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>z&&ke>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):V&&ke>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):t(a,ke>0?{onClick:()=>{ue(_?T.RearrangeProducts:T.SelectedProducts)},buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:["rearrange","view"].includes(ae)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ae)}:{disabled:!0,buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:"tertiaryGray"}),He=e=>Se?"Loading...":ae===T.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e(x,Object.assign({style:null!=oe?oe:{}},{children:[R.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&t(o,{children:("collections"===ae||"searchProducts"===ae)&&t("div",Object.assign({style:{padding:q?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Pe?t(p,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Ie,onChangeText:e=>{e.length&&e.trim().length?xe(e):xe("")}})}))}),e(P,Object.assign({ref:Be,screenName:ae},{children:["collections"===ae&&t(C,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:De,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:Ce,setSelectedCollectionId:ye,setScreen:ue,selectedCollections:we,collectionFetcher:R.collectionFetcher,storeId:w,collectionsDispatch:de,setSaveDisabled:ve,pagingControls:{curPage:be,setCurPage:fe},hideCollectionCheckbox:$,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Be}),"products"===ae&&me&&t(k.Provider,Object.assign({value:me},{children:t(y,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:ue,storeId:w,data:le[me],collectionsDispatch:de,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:ve,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:M,outOfStockAction:H,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:te,scrollContainerRef:Be})})),"view"===ae&&t(I,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:X,outOfStockAction:H,storeId:w,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===ae&&t(b,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:H,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Be,storeId:w,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===ae&&t(j,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:we||{},searchedCollections:Te||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{xe(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:M,hideProductVariants:X,hideVariantCheckbox:W,storeId:w,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:Ce,setSelectedCollectionId:ye,renderWithoutModal:q,hideCollectionCheckbox:$,outOfStockAction:H})]}))]}));return t(o,{children:q?e(o,{children:[We,re.renderFooter?e(O,{children:[Me(),t(a,{buttonText:He(re.primaryButtonText),disabled:!re.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||re.primaryButtonDisabled,isLoading:re.isLoading,onClick:()=>{R.onAdd(we,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}})]}):t(o,{}),Ee&&ze?t(g,{productData:ze,outOfStockAction:H,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:L,open:E,onClose:()=>{null==B||B(),$e()},headingTitle:K||("collections"===ae||"products"===ae?"Select Products":"view"===ae?"Selected Products":"searchProducts"===ae?"Searched Results":"rearrange"===ae?"Rearrange Products":void 0),headingSubtitle:ne,footerShadow:!0,centralContainerStyles:{width:U||"600px",left:Y||"auto"},headerRightCustomElement:ce?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:B},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||e.disabled,onClick:()=>{R.onAdd(we,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}}))(se):{buttonText:He(),disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{R.onAdd(we,ke),$e()}},secondaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{const e=F(we,le,Te);R.onAdd(e,ke,!0)}}))(ie):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t(o,{}):Me(),hideCrossButton:Ee||ce},{children:[We,Ee&&ze?t(g,{productData:ze,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:H,onClose:()=>{Le(!1)}}):t(o,{})]}))})};export{R as ProductPickerModal,T as ScreenName};
@@ -1 +1 @@
1
- import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,d,c,o,r,n,i,l,u,p,v;let O={},g="",b="",j="";switch(e.type){case"selected":return O=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(O={}),O.isCustom=!0),O[e.data.id]=e.data.val,O;case"unselected":return O=t(a),(null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[e.data.id],O;case"productUnselected":return O=t(a),g=e.data.productId,b=e.data.collectionId,delete O[b].products[g],Object.keys(O[b].products).length||((null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[b]),O;case"productSelected":return O=t(a),g=e.data.productId,b=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=e.data.catalogOnlyData,O[b].products={}),O[b].products[g]=e.data.product,O;case"variantSelected":return O=t(a),g=e.data.productId,b=e.data.collectionId,j=e.data.variantId,(null===(d=e.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(e.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=e.data.catalogOnlyData,O[b].products={},O[b].products[g]=e.data.productOnlyData,O[b].products[g].variants={}),(null===(c=null==O?void 0:O[b])||void 0===c?void 0:c.products)||(O[b].products={}),(null===(r=null===(o=null==O?void 0:O[b])||void 0===o?void 0:o.products)||void 0===r?void 0:r[g])||(O[b].products[g]=e.data.productOnlyData,O[b].products[g].variants={}),O[b].products[g].variants||(O[b].products[g].variants={}),O[b].products[g].variants[j]=e.data.variant,O;case"variantUnselected":return O=t(a),g=e.data.productId,b=e.data.collectionId,j=e.data.variantId,(null===(i=null===(n=O[b].products[g])||void 0===n?void 0:n.variants)||void 0===i?void 0:i[j])&&delete O[b].products[g].variants[j],Object.keys(null!==(p=null===(u=null===(l=O[b].products)||void 0===l?void 0:l[g])||void 0===u?void 0:u.variants)&&void 0!==p?p:{}).length||(delete O[b].products[g],Object.keys(O[b].products).length||((null===(v=O[b])||void 0===v?void 0:v.isSmartCollection)&&(O.isCustom=!1),delete O[b])),O;case"update":return O=Object.assign({},a),O;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":console.log("Searched collections reducer called",{data:a.data,collections:t}),e=Object.assign({},t);for(const t in a.data)t in e||(e[t]=a.data[t]);return e;default:return{}}}function d(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 d=Object.assign({},t[s]),c=a.data[s],o={};for(const t in d.products)if(t in c.products){const a=Object.assign({},d.products[t]),e=c.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,o[t]=a)}Object.keys(o).length>0&&(d.products=o,e[s]=d)}return e;default:return t}}function c(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 o=a("");export{o as CollectionIdContext,s as collectionsReducer,d as paginationReducer,c as searchReducer,e as selectedColectionsReducer};
1
+ import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,d,c,o,r,n,i,u,l,p,v;let O={},g="",b="",j="";switch(e.type){case"selected":return O=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(O={}),O.isCustom=!0),O[e.data.id]=e.data.val,O;case"unselected":return O=t(a),(null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[e.data.id],O;case"productUnselected":return O=t(a),g=e.data.productId,b=e.data.collectionId,delete O[b].products[g],Object.keys(O[b].products).length||((null==O?void 0:O.isCustom)&&(O.isCustom=!1),delete O[b]),O;case"productSelected":return O=t(a),g=e.data.productId,b=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=e.data.catalogOnlyData,O[b].products={}),O[b].products[g]=e.data.product,O;case"variantSelected":return O=t(a),g=e.data.productId,b=e.data.collectionId,j=e.data.variantId,(null===(d=e.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(e.data.isRestricted&&(O={}),O.isCustom=!0),(null==O?void 0:O[b])||(O[b]=e.data.catalogOnlyData,O[b].products={},O[b].products[g]=e.data.productOnlyData,O[b].products[g].variants={}),(null===(c=null==O?void 0:O[b])||void 0===c?void 0:c.products)||(O[b].products={}),(null===(r=null===(o=null==O?void 0:O[b])||void 0===o?void 0:o.products)||void 0===r?void 0:r[g])||(O[b].products[g]=e.data.productOnlyData,O[b].products[g].variants={}),O[b].products[g].variants||(O[b].products[g].variants={}),O[b].products[g].variants[j]=e.data.variant,O;case"variantUnselected":return O=t(a),g=e.data.productId,b=e.data.collectionId,j=e.data.variantId,(null===(i=null===(n=O[b].products[g])||void 0===n?void 0:n.variants)||void 0===i?void 0:i[j])&&delete O[b].products[g].variants[j],Object.keys(null!==(p=null===(l=null===(u=O[b].products)||void 0===u?void 0:u[g])||void 0===l?void 0:l.variants)&&void 0!==p?p:{}).length||(delete O[b].products[g],Object.keys(O[b].products).length||((null===(v=O[b])||void 0===v?void 0:v.isSmartCollection)&&(O.isCustom=!1),delete O[b])),O;case"update":return O=Object.assign({},a),O;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 d(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 d=Object.assign({},t[s]),c=a.data[s],o={};for(const t in d.products)if(t in c.products){const a=Object.assign({},d.products[t]),e=c.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,o[t]=a)}Object.keys(o).length>0&&(d.products=o,e[s]=d)}return e;default:return t}}function c(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 o=a("");export{o as CollectionIdContext,s as collectionsReducer,d as paginationReducer,c as searchReducer,e as selectedColectionsReducer};
@@ -1 +1 @@
1
- import{cloneDeep as o}from"lodash";const l=(l,n)=>{const t=o(n);if(delete t.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:t})).productId&&n.products){const d=o(n.products[l.productId]);(null==d?void 0:d.variants)&&delete d.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:t,productOnlyData:d})}return l};function n(o,l,n){var d;const i={};let s=0;for(const v in o)if(Object.prototype.hasOwnProperty.call(o,v)){const c=o[v],u=t(c.products,l,n-s);u&&Object.keys(u).length>0&&(i[v]=Object.assign(Object.assign({},c),{products:u})),s+=Object.keys(null!==(d=c.products)&&void 0!==d?d:{}).length}return i}function t(o,l,n){if(!o)return{};const t=Object.keys(o).slice(n,n+l),d={};return t.forEach((l=>{d[l]=o[l]})),d}const d=(o,l,n)=>{Object.keys(o).forEach((l=>{var n,t;const d=null!==(t=null===(n=o[l])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,i,s;const v=null!==(s=null===(i=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===i?void 0:i.variants)&&void 0!==s?s:{};Object.keys(v).forEach((t=>{var d,i,s,v;const c=null===(v=null===(s=null===(i=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===s?void 0:s.variants)||void 0===v?void 0:v[t];c&&!c.fbStatus&&(c.fbStatus="APPROVED")}))}))})),l({type:n,data:o})},i=function(o,l,n,t){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";t||d(o,n,i);const s=(o=>{const l=[];return Object.keys(o).forEach((n=>{var t,d;const i=null!==(d=null===(t=o[n])||void 0===t?void 0:t.products)&&void 0!==d?d:{};Object.keys(i).forEach((t=>{var d,i,s,v;const c=null!==(v=null===(s=null===(i=null===(d=o[n])||void 0===d?void 0:d.products)||void 0===i?void 0:i[t])||void 0===s?void 0:s.variants)&&void 0!==v?v:{};Object.keys(c).forEach((d=>{var i,s,v,c;const u=null===(c=null===(v=null===(s=null===(i=o[n])||void 0===i?void 0:i.products)||void 0===s?void 0:s[t])||void 0===v?void 0:v.variants)||void 0===c?void 0:c[d];(null==u?void 0:u.fbStatus)||l.push(d)}))}))})),l})(o);s.length>0&&t&&t(l,s).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var n,d;const i=null!==(d=null===(n=t[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,s,v;const c=null!==(v=null===(s=null===(i=null===(d=t[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===s?void 0:s.variants)&&void 0!==v?v:{};Object.keys(c).forEach((d=>{var i,s,v,c;const u=null===(c=null===(v=null===(s=null===(i=t[o])||void 0===i?void 0:i.products)||void 0===s?void 0:s[n])||void 0===v?void 0:v.variants)||void 0===c?void 0:c[d];u&&"REJECTED"===l[d]?u.fbStatus="REJECTED":u&&"APPROVED"===l[d]&&(u.fbStatus="APPROVED")}))}))})),n({type:i,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),d(o,n,i)}))},s=(o,l)=>{const n=[];return Object.keys(null!=o?o:{}).forEach((t=>{var d,i;const s=null!==(i=null===(d=null==o?void 0:o[t])||void 0===d?void 0:d.variants)&&void 0!==i?i:{};Object.keys(s).forEach((d=>{var i,s,v,c,u;let e;e=l?null===(v=null===(s=null===(i=null==l?void 0:l.products)||void 0===i?void 0:i[t])||void 0===s?void 0:s.variants)||void 0===v?void 0:v[d]:null===(u=null===(c=null==o?void 0:o[t])||void 0===c?void 0:c.variants)||void 0===u?void 0:u[d],(null==e?void 0:e.fbStatus)||n.push(d)}))})),n},v=(o,l,n,t,d)=>{const i=Object.assign({},o);if(Object.keys(o).forEach((l=>{var n,t;Object.keys(null!==(t=null===(n=null==o?void 0:o[l])||void 0===n?void 0:n.variants)&&void 0!==t?t:{}).forEach((n=>{var t,d;const s=null===(t=null==o?void 0:o[l].variants)||void 0===t?void 0:t[n];s&&(s.fbStatus="APPROVED");const v=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.variants;v&&v[n]&&(v[n]=s)}))})),t&&d){const o=Object.assign({},t);o.products=i,d(o),l({type:"productsPaged",data:{collectionId:n,products:i}})}else l({type:"productsPaged",data:{collectionId:n,products:i}})},c=o=>{const l=Object.keys(o.variants||[]);let n=!1;return!(l.length<=1)||(l.forEach((l=>{var t,d;n=null!==(d=null===(t=o.variants)||void 0===t?void 0:t[l].name.includes(o.name))&&void 0!==d&&d})),!n)},u=(o,l,n,t,d)=>{var i,s,v,c,u,e,r,a,p,b,O,f,g,j,h,y,E,k,P;let V=0,m=0;if(null===(s=null===(i=null==n?void 0:n[o])||void 0===i?void 0:i.products)||void 0===s?void 0:s[l]){if(d)return!1;const i=(null===(u=null===(c=null===(v=null==n?void 0:n[o])||void 0===v?void 0:v.products)||void 0===c?void 0:c[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(i).length)for(const t in i){const d=null===(r=null===(e=null==n?void 0:n[o])||void 0===e?void 0:e.products)||void 0===r?void 0:r[l],i=null===(O=null===(b=null===(p=null===(a=null==n?void 0:n[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[t];if(null===(f=null==i?void 0:i.name)||void 0===f?void 0:f.includes(null!==(g=null==d?void 0:d.name)&&void 0!==g?g:""))return!1}if(null===(y=Object.keys((null===(h=null===(j=null==t?void 0:t.products)||void 0===j?void 0:j[l])||void 0===h?void 0:h.variants)||[]))||void 0===y||y.forEach((()=>m++)),Object.keys((null===(P=null===(k=null===(E=null==n?void 0:n[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>V++)),V>0&&m!==V)return!0}return!1},e=function(o,l,n){var t,d,i,s;let v=0,c=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const s=null!==(t=null==l?void 0:l.products)&&void 0!==t?t:{};v=Object.keys(s).length;const u=null!==(i=null===(d=n[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};c=Object.keys(u).length}else if(n[o]){const t=null==l?void 0:l.products;t&&Object.keys(t).forEach((o=>{var l;const n=null===(l=t[o])||void 0===l?void 0:l.variants;n&&Object.keys(n).forEach((o=>v+=1))}));const d=null===(s=n[o])||void 0===s?void 0:s.products;if(d&&Object.keys(d).forEach((o=>{var l;const n=null===(l=d[o])||void 0===l?void 0:l.variants;n&&Object.keys(n).forEach((o=>c+=1))})),v<=0&&c>0)return!1}return c>0&&v!==c},r=(l,n,t)=>{console.log("updateAllVariantsForSelectedProducts called"),console.log("selectedItems:",l),console.log("collections:",n),console.log("searchedProducts:",t);const d=Object.keys(l).reduce(((d,i)=>{var s;return console.log(`Processing collectionId: ${i}`),i in n?(d[i]=Object.assign(Object.assign({},l[i]),{products:Object.keys(null!==(s=l[i].products)&&void 0!==s?s:{}).reduce(((d,s)=>{var v,c,u,e,r,a,p,b,O,f;console.log(` Processing productId: ${s}`);const g=null===(v=n[i].products)||void 0===v?void 0:v[s],j=null===(e=null===(u=null===(c=null==t?void 0:t.products)||void 0===c?void 0:c[i])||void 0===u?void 0:u.products)||void 0===e?void 0:e[s];return g?(console.log(` Product ${s} found in collections[${i}]`),d[s]=Object.assign(Object.assign({},(null===(r=l[i].products)||void 0===r?void 0:r[s])||{}),{allVariants:o(g.variants)})):j?(console.log(` Product ${s} found in searchedProducts.products[${i}]`),d[s]=Object.assign(Object.assign({},(null===(a=l[i].products)||void 0===a?void 0:a[s])||{}),{allVariants:o(j.variants)})):(null===(b=null===(p=l[i].products)||void 0===p?void 0:p[s])||void 0===b?void 0:b.allVariants)?(console.log(` Product ${s} using preselected allVariants`),d[s]=Object.assign(Object.assign({},(null===(O=l[i].products)||void 0===O?void 0:O[s])||{}),{allVariants:o(null===(f=l[i].products)||void 0===f?void 0:f[s].allVariants)})):console.log(` Product ${s} not found in collections or searchedProducts and has no preselected allVariants`),d}),{})}),d):(console.log(`Collection ${i} not found in collections`),d)}),{});return console.log("updatedSelectedItems:",d),d},a=(o,l)=>{var n;if(l)return o.skuId;const t=Object.values(null!==(n=null==o?void 0:o.variants)&&void 0!==n?n:{});return 1===t.length&&t[0].name.includes(o.name)?t[0].skuId:""};export{i as fetchFbStatusCollection,a as getSkuId,s as getVariantIdsToFetchAtProductLevel,e as isCollectionPartiallyChecked,u as isProductPartiallyChecked,l as liftTheStateUp,v as markVariantsAsApprovedProductsLevel,n as paginateSelectedItems,c as shouldShowVariant,r as updateAllVariantsForSelectedProducts};
1
+ import{cloneDeep as o}from"lodash";const l=(l,i)=>{const n=o(i);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&i.products){const t=o(i.products[l.productId]);(null==t?void 0:t.variants)&&delete t.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:t})}return l};function i(o,l,i){var t;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const u=o[s],c=n(u.products,l,i-v);c&&Object.keys(c).length>0&&(d[s]=Object.assign(Object.assign({},u),{products:c})),v+=Object.keys(null!==(t=u.products)&&void 0!==t?t:{}).length}return d}function n(o,l,i){if(!o)return{};const n=Object.keys(o).slice(i,i+l),t={};return n.forEach((l=>{t[l]=o[l]})),t}const t=(o,l,i)=>{Object.keys(o).forEach((l=>{var i,n;const t=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(t).forEach((i=>{var n,t,d,v;const s=null!==(v=null===(d=null===(t=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===t?void 0:t[i])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((n=>{var t,d,v,s;const u=null===(s=null===(v=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),l({type:i,data:o})},d=function(o,l,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||t(o,i,d);const v=(o=>{const l=[];return Object.keys(o).forEach((i=>{var n,t;const d=null!==(t=null===(n=o[i])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=o[i])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=o[i])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];(null==c?void 0:c.fbStatus)||l.push(t)}))}))})),l})(o);v.length>0&&n&&n(l,v).then((l=>{const n=Object.assign({},o);Object.keys(n).forEach((o=>{var i,t;const d=null!==(t=null===(i=n[o])||void 0===i?void 0:i.products)&&void 0!==t?t:{};Object.keys(d).forEach((i=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=n[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=n[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];c&&"REJECTED"===l[t]?c.fbStatus="REJECTED":c&&"APPROVED"===l[t]&&(c.fbStatus="APPROVED")}))}))})),i({type:d,data:n})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,i,d)}))},v=(o,l)=>{const i=[];return Object.keys(null!=o?o:{}).forEach((n=>{var t,d;const v=null!==(d=null===(t=null==o?void 0:o[n])||void 0===t?void 0:t.variants)&&void 0!==d?d:{};Object.keys(v).forEach((t=>{var d,v,s,u,c;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[t]:null===(c=null===(u=null==o?void 0:o[n])||void 0===u?void 0:u.variants)||void 0===c?void 0:c[t],(null==r?void 0:r.fbStatus)||i.push(t)}))})),i},s=(o,l,i,n,t)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var i,n;Object.keys(null!==(n=null===(i=null==o?void 0:o[l])||void 0===i?void 0:i.variants)&&void 0!==n?n:{}).forEach((i=>{var n,t;const v=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[i];v&&(v.fbStatus="APPROVED");const s=null===(t=null==d?void 0:d[l])||void 0===t?void 0:t.variants;s&&s[i]&&(s[i]=v)}))})),n&&t){const o=Object.assign({},n);o.products=d,t(o),l({type:"productsPaged",data:{collectionId:i,products:d}})}else l({type:"productsPaged",data:{collectionId:i,products:d}})},u=o=>{const l=Object.keys(o.variants||[]);let i=!1;return!(l.length<=1)||(l.forEach((l=>{var n,t;i=null!==(t=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==t&&t})),!i)},c=(o,l,i,n,t)=>{var d,v,s,u,c,r,a,e,p,b,O,f,j,h,y,g,E,k,P;let D=0,V=0;if(null===(v=null===(d=null==i?void 0:i[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[l]){if(t)return!1;const d=(null===(c=null===(u=null===(s=null==i?void 0:i[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[l])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(d).length)for(const n in d){const t=null===(a=null===(r=null==i?void 0:i[o])||void 0===r?void 0:r.products)||void 0===a?void 0:a[l],d=null===(O=null===(b=null===(p=null===(e=null==i?void 0:i[o])||void 0===e?void 0:e.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[n];if(null===(f=null==d?void 0:d.name)||void 0===f?void 0:f.includes(null!==(j=null==t?void 0:t.name)&&void 0!==j?j:""))return!1}if(null===(g=Object.keys((null===(y=null===(h=null==n?void 0:n.products)||void 0===h?void 0:h[l])||void 0===y?void 0:y.variants)||[]))||void 0===g||g.forEach((()=>V++)),Object.keys((null===(P=null===(k=null===(E=null==i?void 0:i[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&V!==D)return!0}return!1},r=function(o,l,i){var n,t,d,v;let s=0,u=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(n=null==l?void 0:l.products)&&void 0!==n?n:{};s=Object.keys(v).length;const c=null!==(d=null===(t=i[o])||void 0===t?void 0:t.products)&&void 0!==d?d:{};u=Object.keys(c).length}else if(i[o]){const n=null==l?void 0:l.products;n&&Object.keys(n).forEach((o=>{var l;const i=null===(l=n[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>s+=1))}));const t=null===(v=i[o])||void 0===v?void 0:v.products;if(t&&Object.keys(t).forEach((o=>{var l;const i=null===(l=t[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>u+=1))})),s<=0&&u>0)return!1}return u>0&&s!==u},a=(l,i,n)=>Object.keys(l).reduce(((t,d)=>{var v;return d in i?(t[d]=Object.assign(Object.assign({},l[d]),{products:Object.keys(null!==(v=l[d].products)&&void 0!==v?v:{}).reduce(((t,v)=>{var s,u,c,r,a,e,p,b,O,f;const j=null===(s=i[d].products)||void 0===s?void 0:s[v],h=null===(r=null===(c=null===(u=null==n?void 0:n.products)||void 0===u?void 0:u[d])||void 0===c?void 0:c.products)||void 0===r?void 0:r[v];return j?t[v]=Object.assign(Object.assign({},(null===(a=l[d].products)||void 0===a?void 0:a[v])||{}),{allVariants:o(j.variants)}):h?t[v]=Object.assign(Object.assign({},(null===(e=l[d].products)||void 0===e?void 0:e[v])||{}),{allVariants:o(h.variants)}):(null===(b=null===(p=l[d].products)||void 0===p?void 0:p[v])||void 0===b?void 0:b.allVariants)&&(t[v]=Object.assign(Object.assign({},(null===(O=l[d].products)||void 0===O?void 0:O[v])||{}),{allVariants:o(null===(f=l[d].products)||void 0===f?void 0:f[v].allVariants)})),t}),{})}),t):t}),{}),e=(o,l)=>{var i;if(l)return o.skuId;const n=Object.values(null!==(i=null==o?void 0:o.variants)&&void 0!==i?i:{});return 1===n.length&&n[0].name.includes(o.name)?n[0].skuId:""};export{d as fetchFbStatusCollection,e as getSkuId,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,i as paginateSelectedItems,u as shouldShowVariant,a as updateAllVariantsForSelectedProducts};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.665-beta.3",
3
+ "version": "0.0.666",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",