@bikdotai/bik-component-library 0.0.547 → 0.0.548-beta.1

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.
@@ -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 +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"),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:f,visible:m,zIndex:v,exactLimit:P,limit:k,hideCollectionCheckbox:O,hideProductCheckbox:I,outOfStockAction:F=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:E,width:D,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:V,selectSingleItem:$=!1,showProductDetails:L,containerStyle:_}=e,[z,W]=c.useReducer(S.collectionsReducer,{}),[G,H]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[K,U]=c.useState("grid"),[Y,J]=c.useState(""),[Q,X]=c.useState(""),[Z,ee]=c.useState(0),[te,oe]=c.useState(!1),[ce,re]=c.useState(0),[se,ne]=c.useState(""),[le,ie]=c.useState(!1),[ae,de]=c.useState(!1),[ue,he]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[pe,Se]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Ce=c.useRef(null),[xe,ge]=c.useState(!1),[je,ye]=c.useState();c.useEffect((()=>{oe(!0),de(!0),e.collectionFetcher(Z,y).then((e=>{W({type:"fetched",data:(null==e?void 0:e.collections)||{}}),oe(!1),ee((e=>e+1)),de(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;B?Object.keys(pe||[]).forEach((t=>{var o;Object.keys((null===(o=pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&pe[-1]&&(null===(c=pe[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(pe||[]).forEach((t=>{var o;Object.keys((null===(o=pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=pe[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),re(e)}),[z,pe,B]),c.useEffect((()=>{Q&&(oe(!0),e.productFetcher(Q,y).then((e=>{Object.keys(e).length&&W({type:"productsFetched",data:{collectionId:Q,products:e}}),oe(!1)})).catch())}),[Q]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==G&&(se.length||"collections"!==G)&&(se.length?(ie(!0),e.searchFetcher(y,se).then((e=>{"collections"in e&&"products"in e?(he({type:"set",data:e}),W({type:"searched",data:e.collections})):(he({type:"set",data:{collections:{},products:e}}),W({type:"searched",data:e})),H("searchProducts"),oe(!1),ie(!1)}))):H("collections"))}),800);return()=>clearTimeout(t)}),[se]),c.useEffect((()=>{N&&(e.onAdd(pe,ce),be())}),[N]),c.useEffect((()=>{$&&Object.keys(pe||{}).length&&ce&&(e.onAdd(pe,ce),be())}),[$,pe,ce]);const be=()=>{Se({type:"reset",data:{}})},fe=t.jsxs(g.ContainerStyle,Object.assign({style:null!=_?_:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===G||"searchProducts"===G)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>le?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:se,onChangeText:e=>{e.length&&e.trim().length?ne(e):ne("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Ce,screenName:G},{children:["collections"===G&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ae,collections:z,selectedCollectionsDispatch:Se,setCollectionId:J,setSelectedCollectionId:X,setScreen:H,selectedCollections:pe,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:W,setSaveDisabled:oe,pagingControls:{curPage:Z,setCurPage:ee},hideCollectionCheckbox:O,renderWithoutModal:w,pickerType:A,scrollContainerRef:Ce}),"products"===G&&Y&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:Y},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:H,storeId:y,data:z[Y],collectionsDispatch:W,selectedCollectionsDispatch:Se,selectedData:pe,setSaveDisabled:oe,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:I,outOfStockAction:F,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{ge(!0),ye(e)},showProductDetailInfoIcon:L,scrollContainerRef:Ce})})),"view"===G&&t.jsx(x.SelectedScreen,{selectedCollections:pe||{},selectedCollectionsDispatch:Se,setScreen:H,collections:z,hideProductVariants:B,outOfStockAction:F,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===G&&t.jsx(p.RearrangeScreen,{selectedCollections:pe||{},selectedCollectionsDispatch:Se,setScreen:H,outOfStockAction:F,rearrangeViewType:"grid"===K?"list":"grid",scrollContainerRef:Ce,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===G&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:pe||{},searchedCollections:ue||{},searchedCollectionsDispatch:he,selectedCollectionsDispatch:Se,setScreen:H,collections:z,onBackPress:()=>{ne(""),he({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:I,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:J,setSelectedCollectionId:X,renderWithoutModal:w,hideCollectionCheckbox:O,outOfStockAction:F})]}))]}));return t.jsx(t.Fragment,{children:w?fe:t.jsxs(l.StyledModal,Object.assign({zIndex:v,open:m,onClose:()=>{null==f||f(),be()},headingTitle:E||("collections"===G||"products"===G?"Select Products":"view"===G?"Selected Products":"searchProducts"===G?"Searched Results":"rearrange"===G?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:D||"600px"},headerRightCustomElement: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:te?"Loading...":G===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:te||ce<1||P&&ce<P||!P&&k&&ce>k||!1,onClick:()=>{e.onAdd(pe,ce),be()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):P&&ce>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):k&&ce>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):ce>0?t.jsx(s.Button,{onClick:()=>{H(V?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${ce}/${P} products selected`:`${ce} products selected`,buttonType:["rearrange","view"].includes(G)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(G)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${ce}/${P} products selected`:`${ce} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:xe},{children:[fe,xe&&je?t.jsx(u.ProductInfoOverlay,{productData:je,outOfStockAction:F,onClose:()=>{ge(!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("../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:f,visible:m,zIndex:v,exactLimit:P,limit:k,hideCollectionCheckbox:I,hideProductCheckbox:O,outOfStockAction:F=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:E,title:q,width:D,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:V,selectSingleItem:$=!1,showProductDetails:L,containerStyle:_}=e,[z,W]=c.useReducer(S.collectionsReducer,{}),[G,H]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[K,U]=c.useState("grid"),[Y,J]=c.useState(""),[Q,X]=c.useState(""),[Z,ee]=c.useState(0),[te,oe]=c.useState(!1),[ce,re]=c.useState(0),[se,ne]=c.useState(""),[le,ie]=c.useState(!1),[ae,de]=c.useState(!1),[ue,he]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[pe,Se]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Ce=c.useRef(null),[xe,ge]=c.useState(!1),[je,ye]=c.useState();c.useEffect((()=>{oe(!0),de(!0),e.collectionFetcher(Z,y).then((e=>{W({type:"fetched",data:(null==e?void 0:e.collections)||{}}),oe(!1),ee((e=>e+1)),de(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;B?Object.keys(pe||[]).forEach((t=>{var o;Object.keys((null===(o=pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&pe[-1]&&(null===(c=pe[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(pe||[]).forEach((t=>{var o;Object.keys((null===(o=pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=pe[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),re(e)}),[z,pe,B]),c.useEffect((()=>{Q&&(oe(!0),console.log("useEffect selectedCollectionId modal.tsx:277",Q),e.productFetcher(Q,y).then((e=>{Object.keys(e).length&&W({type:"productsFetched",data:{collectionId:Q,products:e}}),oe(!1)})).catch())}),[Q]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==G&&(se.length||"collections"!==G)&&(se.length?(ie(!0),e.searchFetcher(y,se).then((e=>{"collections"in e&&"products"in e?(he({type:"set",data:e}),W({type:"searched",data:e.collections})):(he({type:"set",data:{collections:{},products:e}}),W({type:"searched",data:e})),H("searchProducts"),oe(!1),ie(!1)}))):H("collections"))}),800);return()=>clearTimeout(t)}),[se]),c.useEffect((()=>{N&&(e.onAdd(pe,ce),be())}),[N]),c.useEffect((()=>{$&&Object.keys(pe||{}).length&&ce&&(e.onAdd(pe,ce),be())}),[$,pe,ce]);const be=()=>{Se({type:"reset",data:{}})},fe=t.jsxs(g.ContainerStyle,Object.assign({style:null!=_?_:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===G||"searchProducts"===G)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>le?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:se,onChangeText:e=>{e.length&&e.trim().length?ne(e):ne("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Ce,screenName:G},{children:["collections"===G&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ae,collections:z,selectedCollectionsDispatch:Se,setCollectionId:J,setSelectedCollectionId:X,setScreen:H,selectedCollections:pe,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:W,setSaveDisabled:oe,pagingControls:{curPage:Z,setCurPage:ee},hideCollectionCheckbox:I,renderWithoutModal:w,pickerType:A,scrollContainerRef:Ce}),"products"===G&&Y&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:Y},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:H,storeId:y,data:z[Y],collectionsDispatch:W,selectedCollectionsDispatch:Se,selectedData:pe,setSaveDisabled:oe,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:F,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{ge(!0),ye(e)},showProductDetailInfoIcon:L,scrollContainerRef:Ce})})),"view"===G&&t.jsx(x.SelectedScreen,{selectedCollections:pe||{},selectedCollectionsDispatch:Se,setScreen:H,collections:z,hideProductVariants:B,outOfStockAction:F,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===G&&t.jsx(p.RearrangeScreen,{selectedCollections:pe||{},selectedCollectionsDispatch:Se,setScreen:H,outOfStockAction:F,rearrangeViewType:"grid"===K?"list":"grid",scrollContainerRef:Ce,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===G&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:pe||{},searchedCollections:ue||{},searchedCollectionsDispatch:he,selectedCollectionsDispatch:Se,setScreen:H,collections:z,onBackPress:()=>{ne(""),he({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:O,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:J,setSelectedCollectionId:X,renderWithoutModal:w,hideCollectionCheckbox:I,outOfStockAction:F})]}))]}));return t.jsx(t.Fragment,{children:w?fe:t.jsxs(l.StyledModal,Object.assign({zIndex:v,open:m,onClose:()=>{null==f||f(),be()},headingTitle:q||("collections"===G||"products"===G?"Select Products":"view"===G?"Selected Products":"searchProducts"===G?"Searched Results":"rearrange"===G?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:D||"600px"},headerRightCustomElement: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:te?"Loading...":G===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:te||ce<1||P&&ce<P||!P&&k&&ce>k||!1,onClick:()=>{e.onAdd(pe,ce),be()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:E?t.jsx(t.Fragment,{}):P&&ce>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):k&&ce>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):ce>0?t.jsx(s.Button,{onClick:()=>{H(V?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${ce}/${P} products selected`:`${ce} products selected`,buttonType:["rearrange","view"].includes(G)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(G)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${ce}/${P} products selected`:`${ce} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:xe},{children:[fe,xe&&je?t.jsx(u.ProductInfoOverlay,{productData:je,outOfStockAction:F,onClose:()=>{ge(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -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("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),o=require("lodash"),s=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"),v=require("./ProductPickerShimmer.js"),j=require("./reducers.js"),g=require("./style.js"),y=require("./type.js"),P=require("./utility.js");exports.ProductsScreen=C=>{var k,O;const{data:b,collectionsDispatch:f,selectedData:x,selectedCollectionsDispatch:S,productFetcher:m,storeId:I,setScreen:E,setSaveDisabled:q,hideInCollectionSearch:A,customCollectionRestriction:T,hideProductCheckbox:D,outOfStockAction:V=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R=!1,selectProductsFromCustomCollection:L=!1,pickerType:F,hideProductVariants:w,fbStatusFetcher:B,onProductDetailClick:_,showProductDetailInfoIcon:H,scrollContainerRef:U}=C,J=s.useContext(j.CollectionIdContext),K=s.useRef(0),M=s.useRef(!1),[N,W]=s.useState(!1),[z,G]=s.useState(""),[Q,X]=s.useState(!1),[Y,Z]=s.useState(b),$=s.useRef(!1);s.useEffect((()=>{const e=setTimeout((()=>{z.length?(X(!0),C.searchInCollectionFetcher(I,J,z).then((e=>{const t=o.cloneDeep(b);t.products=e,Z(t);const r=P.getVariantIdsToFetchAtProductLevel(null!=e?e:{});re(r,null!=e?e:{},!0),q(!1),X(!1)}))):Z(b)}),800);return()=>clearTimeout(e)}),[z]);const ee=()=>{if(!U||!(null==U?void 0:U.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:r}=U.current;e+t>=r-20&&!$.current&&!M.current&&(q(!0),W(!0),M.current=!0,m(J,I,10,K.current).then((e=>{if(Object.keys(e).length||($.current=!0),Object.keys(e).length){const t=Y;t.products=Object.assign(Object.assign({},Y.products),e),Z(t);const r=P.getVariantIdsToFetchAtProductLevel(e);re(r,e),K.current+=1}M.current=!1,W(!1),q(!1)})).catch())};s.useEffect((()=>{var e;return null===(e=null==U?void 0:U.current)||void 0===e||e.addEventListener("scroll",ee),()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.removeEventListener("scroll",ee)}}),[]),s.useEffect((()=>{var e,t,r,c;$.current=!1,K.current=Math.floor((null===(t=Object.keys(null!==(e=b.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const o=P.getVariantIdsToFetchAtProductLevel(null!==(r=b.products)&&void 0!==r?r:{});re(o,null!==(c=b.products)&&void 0!==c?c:{})}),[J]);const te=!!T&&b.isSmartCollection;s.useEffect((()=>{(null==b?void 0:b.products)||ce(10)}),[]);const re=(e,t,r)=>{B||(r?P.markVariantsAsApprovedProductsLevel(t,f,J,Y,Z):P.markVariantsAsApprovedProductsLevel(t,f,J)),e.length>0&&B&&B(I,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((r=>{var o,s;Object.keys(null!==(s=null===(o=null==t?void 0:t[r])||void 0===o?void 0:o.variants)&&void 0!==s?s:{}).forEach((o=>{var s,n;const i=null===(s=null==t?void 0:t[r].variants)||void 0===s?void 0:s[o];i&&"REJECTED"===e[o]?i.fbStatus="REJECTED":i&&"APPROVED"===e[o]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.variants;l&&l[o]&&(l[o]=i)}))})),r?(Z((e=>{const t=Object.assign({},e);return t.products=c,t})),f({type:"productsPaged",data:{collectionId:J,products:c}})):f({type:"productsPaged",data:{collectionId:J,products:c}})})).catch((e=>{r?P.markVariantsAsApprovedProductsLevel(t,f,J,Y,Z):P.markVariantsAsApprovedProductsLevel(t,f,J)}))},ce=e=>{q(!0),X(!0),m(J,I,e,0).then((t=>{if(Object.keys(t).length||($.current=!0),Object.keys(t).length){Z(Object.assign(Object.assign({},Y),{products:t}));const e=P.getVariantIdsToFetchAtProductLevel(t);re(e,t),K.current=1}e||S({type:"selected",data:{id:J,val:Object.assign(Object.assign({},b),{products:t})}}),q(!1),X(!1)})).catch()},oe=(e,t)=>{const r=P.liftTheStateUp(t,b);S({type:e,data:Object.assign(Object.assign({},r),{isRestricted:T})})},se=!!(null==x?void 0:x[J])&&!!Object.keys(null!==(O=null===(k=null==x?void 0:x[J])||void 0===k?void 0:k.products)&&void 0!==O?O:{}).length;return e.jsxs("div",{children:[e.jsxs(g.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{E("collections")}}),e.jsx(a.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:b.name}))]}),!A&&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:()=>Q&&z.length?e.jsx(d.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:z,onChangeText:e=>{e.length&&e.trim().length?G(e):G("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==Y?void 0:Y.products)||[]).length>0&&!te&&!z.length&&!D&&"-1"!==J&&e.jsxs(g.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:se,isPartiallyChecked:P.isCollectionPartiallyChecked(J,Y,x,w),onValueChange:function(e){e?ce():S({type:"unselected",data:{id:J}})}}),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==Y?void 0:Y.products)||[]).length?Object.keys(Y.products||[]).map((t=>e.jsx(p.ProductGroup,{outOfStockAction:V,collectionId:J,isProductPartiallyChecked:P.isProductPartiallyChecked(J,t,x,Y,w),productId:t,data:Y.products[t],selectedData:x,selectedCollectionsDispatch:S,viewOnly:!L&&!!te,upliftAdditions:oe,hideProductCheckbox:D,hideVariantCheckbox:R,hideProductVariants:w,pickerType:F,onProductDetailClick:_,showProductDetailInfoIcon:H},t))):Q?e.jsx(v.ProductPickerShimmer,{limit:10}):e.jsx(h.EmptyState,{title:"No products to show",subtitle:z.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]}),N&&e.jsx(v.ProductPickerShimmer,{})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),n=require("lodash"),s=require("react"),i=require("../../constants/Theme.js"),l=require("../checkBox/CheckBox.js"),u=require("../icon-button/IconButton.js"),d=require("../input/Input.js"),a=require("../spinner/Spinner.js"),h=require("../TypographyStyle.js"),p=require("./emptyState.js"),v=require("./product.js"),g=require("./ProductPickerShimmer.js"),j=require("./reducers.js"),f=require("./style.js"),y=require("./type.js"),C=require("./utility.js");const b=e=>{let{children:o,fetchMore:r,loadingComponent:c,containerRef:n}=e;const[i,l]=s.useState(!1),u=s.useRef(0);return s.useEffect((()=>{if(!n.current)return;const e=n.current,t=()=>{if(i)return;const t=e.querySelector("#sentinel");if(!t)return;const o=e.getBoundingClientRect(),c=t.getBoundingClientRect();c.top<=o.bottom&&c.bottom>=o.top&&(l(!0),u.current=e.scrollTop,r().then((()=>{e.scrollTo({top:u.current-10,behavior:"smooth"}),l(!1)})))};return e.addEventListener("scroll",t),()=>{e.removeEventListener("scroll",t)}}),[r,i,n]),t.jsxs("div",{children:[o,t.jsx("div",{id:"sentinel",style:{height:"10px"}}),i&&c]})};exports.ProductsScreen=P=>{var k,x;const{data:O,collectionsDispatch:m,selectedData:S,selectedCollectionsDispatch:I,productFetcher:T,storeId:E,setScreen:q,setSaveDisabled:R,hideInCollectionSearch:A,customCollectionRestriction:D,hideProductCheckbox:V,outOfStockAction:L=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:w=!1,selectProductsFromCustomCollection:B=!1,pickerType:F,hideProductVariants:_,fbStatusFetcher:H,onProductDetailClick:M,showProductDetailInfoIcon:U,scrollContainerRef:J}=P,K=s.useContext(j.CollectionIdContext),N=s.useRef(0),W=s.useRef(!1),[z,G]=s.useState(!1),[Q,X]=s.useState(""),[Y,Z]=s.useState(!1),[$,ee]=s.useState(O),te=s.useRef(!1);s.useEffect((()=>{const e=setTimeout((()=>{Q.length?(Z(!0),P.searchInCollectionFetcher(E,K,Q).then((e=>{const t=n.cloneDeep(O);t.products=e,ee(t);const o=C.getVariantIdsToFetchAtProductLevel(null!=e?e:{});re(o,null!=e?e:{},!0),R(!1),Z(!1)}))):ee(O)}),800);return()=>clearTimeout(e)}),[Q]),s.useCallback((()=>{if(!J||!(null==J?void 0:J.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:o}=J.current;console.log({scrollTop:e,clientHeight:t,scrollHeight:o}),e+t>=o-20&&!te.current&&!W.current&&(R(!0),G(!0),W.current=!0,console.log("handleScroll productFetcher",{collectionId:K,storeId:E,o:10,nc:N.current}),T(K,E,10,N.current).then((r=>{var c,n;if(Object.keys(r).length||(te.current=!0),Object.keys(r).length){const s=$;s.products=Object.assign(Object.assign({},$.products),r),ee(s);const i=C.getVariantIdsToFetchAtProductLevel(r);re(i,r),console.log("new scroll position",e+t-100),N.current+=1;const l=(null===(c=J.current)||void 0===c?void 0:c.scrollHeight)-o+e;null===(n=J.current)||void 0===n||n.scrollTo({top:l-100,behavior:"smooth"})}W.current=!1,G(!1),R(!1)})).catch())}),[K,$,J,E]),s.useEffect((()=>{var e,t,o,r;console.log("useEffect productScreen, collectionId",{collectionId:K}),te.current=!1,N.current=Math.floor((null===(t=Object.keys(null!==(e=O.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const c=C.getVariantIdsToFetchAtProductLevel(null!==(o=O.products)&&void 0!==o?o:{});re(c,null!==(r=O.products)&&void 0!==r?r:{})}),[K]);const oe=!!D&&O.isSmartCollection;s.useEffect((()=>{(null==O?void 0:O.products)||ce(10)}),[]);const re=(e,t,o)=>{H||(o?C.markVariantsAsApprovedProductsLevel(t,m,K,$,ee):C.markVariantsAsApprovedProductsLevel(t,m,K)),e.length>0&&H&&H(E,e).then((e=>{const r=Object.assign({},t);Object.keys(t).forEach((o=>{var c,n;Object.keys(null!==(n=null===(c=null==t?void 0:t[o])||void 0===c?void 0:c.variants)&&void 0!==n?n:{}).forEach((c=>{var n,s;const i=null===(n=null==t?void 0:t[o].variants)||void 0===n?void 0:n[c];i&&"REJECTED"===e[c]?i.fbStatus="REJECTED":i&&"APPROVED"===e[c]&&(i.fbStatus="APPROVED");const l=null===(s=null==r?void 0:r[o])||void 0===s?void 0:s.variants;l&&l[c]&&(l[c]=i)}))})),o?(ee((e=>{const t=Object.assign({},e);return t.products=r,t})),m({type:"productsPaged",data:{collectionId:K,products:r}})):m({type:"productsPaged",data:{collectionId:K,products:r}})})).catch((e=>{o?C.markVariantsAsApprovedProductsLevel(t,m,K,$,ee):C.markVariantsAsApprovedProductsLevel(t,m,K)}))},ce=e=>{R(!0),Z(!0),T(K,E,e,0).then((t=>{if(Object.keys(t).length||(te.current=!0),Object.keys(t).length){ee(Object.assign(Object.assign({},$),{products:t}));const e=C.getVariantIdsToFetchAtProductLevel(t);re(e,t),N.current=1}e||I({type:"selected",data:{id:K,val:Object.assign(Object.assign({},O),{products:t})}}),R(!1),Z(!1)})).catch()},ne=(e,t)=>{const o=C.liftTheStateUp(t,O);I({type:e,data:Object.assign(Object.assign({},o),{isRestricted:D})})},se=!!(null==S?void 0:S[K])&&!!Object.keys(null!==(x=null===(k=null==S?void 0:S[K])||void 0===k?void 0:k.products)&&void 0!==x?x:{}).length;return s.useRef(null),console.log({scrollContainerRef:J}),t.jsxs("div",{children:[t.jsxs(f.ProductScreenHeader,{children:[t.jsx(u.IconButton,{Icon:o.default,height:16,onClick:()=>{q("collections")}}),t.jsx(h.BodyCaption,Object.assign({style:{color:i.COLORS.content.secondary}},{children:O.name}))]}),!A&&t.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(d.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Y&&Q.length?t.jsx(a.Spinner,{size:"small",color:i.COLORS.content.primary}):t.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:Q,onChangeText:e=>{e.length&&e.trim().length?X(e):X("")},placeholder:"Search products in this collection..."})})),t.jsxs(b,Object.assign({containerRef:J,fetchMore:()=>e.__awaiter(void 0,void 0,void 0,(function*(){console.log("fetchMore called"),yield T(K,E,10,N.current),N.current+=1})),loadingComponent:t.jsx(g.ProductPickerShimmer,{limit:1})},{children:[Object.keys((null==$?void 0:$.products)||[]).length>0&&!oe&&!Q.length&&!V&&"-1"!==K&&t.jsxs(f.ProductScreenCollectionCardStyle,{children:[t.jsx(l.CheckBox,{isChecked:se,isPartiallyChecked:C.isCollectionPartiallyChecked(K,$,S,_),onValueChange:function(e){e?ce():I({type:"unselected",data:{id:K}})}}),t.jsx("div",Object.assign({style:{width:40,height:40}},{children:t.jsx(r.default,{})})),t.jsx(h.TitleRegular,{children:"All Products"})]}),Object.keys((null==$?void 0:$.products)||[]).length?Object.keys($.products||[]).map((e=>t.jsx(v.ProductGroup,{outOfStockAction:L,collectionId:K,isProductPartiallyChecked:C.isProductPartiallyChecked(K,e,S,$,_),productId:e,data:$.products[e],selectedData:S,selectedCollectionsDispatch:I,viewOnly:!B&&!!oe,upliftAdditions:ne,hideProductCheckbox:V,hideVariantCheckbox:w,hideProductVariants:_,pickerType:F,onProductDetailClick:M,showProductDetailInfoIcon:U},e))):Y?t.jsx(g.ProductPickerShimmer,{limit:10}):t.jsx(p.EmptyState,{title:"No products to show",subtitle:Q.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})),z&&t.jsx(g.ProductPickerShimmer,{limit: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 +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,useRef as i,useEffect as l}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as f}from"./rearrangeScreen.js";import{collectionsReducer as b,searchReducer as y,selectedColectionsReducer as S,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as x}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const O=O=>{const{storeId:T,selectedItems:D,onClose:R,visible:w,zIndex:E,exactLimit:A,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:N,hideProductVariants:U=!1,startupScreen:q=F.Collections,rearrangeEnabled:J,selectSingleItem:Q=!1,showProductDetails:X,containerStyle:Z}=O,[_,ee]=r(b,{}),[te,oe]=s([F.Collections,F.RearrangeProducts].includes(q)?q:F.Collections),[ce,re]=s("grid"),[se,ie]=s(""),[le,ne]=s(""),[de,ae]=s(0),[ue,he]=s(!1),[pe,me]=s(0),[Ce,ge]=s(""),[fe,be]=s(!1),[ye,Se]=s(!1),[ve,ke]=r(y,{collections:{},products:{}}),[Pe,je]=r(S,Object.keys(D).length>0?D:{}),xe=i(null),[Ie,Fe]=s(!1),[Oe,Te]=s();l((()=>{he(!0),Se(!0),O.collectionFetcher(de,T).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),he(!1),ae((e=>e+1)),Se(!1)})).catch()}),[]),l((()=>{let e=0;U?Object.keys(Pe||[]).forEach((t=>{var o;Object.keys((null===(o=Pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Pe[-1]&&(null===(c=Pe[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Pe||[]).forEach((t=>{var o;Object.keys((null===(o=Pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Pe[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),me(e)}),[_,Pe,U]),l((()=>{le&&(he(!0),O.productFetcher(le,T).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:le,products:e}}),he(!1)})).catch())}),[le]),l((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(Ce.length||"collections"!==te)&&(Ce.length?(be(!0),O.searchFetcher(T,Ce).then((e=>{"collections"in e&&"products"in e?(ke({type:"set",data:e}),ee({type:"searched",data:e.collections})):(ke({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),he(!1),be(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[Ce]),l((()=>{K&&(O.onAdd(Pe,pe),De())}),[K]),l((()=>{Q&&Object.keys(Pe||{}).length&&pe&&(O.onAdd(Pe,pe),De())}),[Q,Pe,pe]);const De=()=>{je({type:"reset",data:{}})},Re=e(j,Object.assign({style:null!=Z?Z:{}},{children:[O.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:O.postHeader})),!O.hideGlobalSearch&&t(o,{children:("collections"===te||"searchProducts"===te)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>fe?t(h,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Ce,onChangeText:e=>{e.length&&e.trim().length?ge(e):ge("")}})}))}),e(x,Object.assign({ref:xe,screenName:te},{children:["collections"===te&&t(m,{customCollectionRestriction:O.customCollectionRestriction,dataLoading:ye,collections:_,selectedCollectionsDispatch:je,setCollectionId:ie,setSelectedCollectionId:ne,setScreen:oe,selectedCollections:Pe,collectionFetcher:O.collectionFetcher,storeId:T,collectionsDispatch:ee,setSaveDisabled:he,pagingControls:{curPage:de,setCurPage:ae},hideCollectionCheckbox:$,renderWithoutModal:Y,pickerType:N,scrollContainerRef:xe}),"products"===te&&se&&t(v.Provider,Object.assign({value:se},{children:t(g,{hideInCollectionSearch:O.hideInCollectionSearch,customCollectionRestriction:O.customCollectionRestriction,productFetcher:O.productFetcher,setScreen:oe,storeId:T,data:_[se],collectionsDispatch:ee,selectedCollectionsDispatch:je,selectedData:Pe,setSaveDisabled:he,searchInCollectionFetcher:O.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:N,hideProductVariants:U,fbStatusFetcher:O.fbStatusFetcher,onProductDetailClick:e=>{Fe(!0),Te(e)},showProductDetailInfoIcon:X,scrollContainerRef:xe})})),"view"===te&&t(P,{selectedCollections:Pe||{},selectedCollectionsDispatch:je,setScreen:oe,collections:_,hideProductVariants:U,outOfStockAction:L,storeId:T,fbStatusFetcher:O.fbStatusFetcher}),"rearrange"===te&&t(f,{selectedCollections:Pe||{},selectedCollectionsDispatch:je,setScreen:oe,outOfStockAction:L,rearrangeViewType:"grid"===ce?"list":"grid",scrollContainerRef:xe,storeId:T,fbStatusFetcher:O.fbStatusFetcher}),"searchProducts"===te&&t(k,{customCollectionRestriction:O.customCollectionRestriction,selectedCollections:Pe||{},searchedCollections:ve||{},searchedCollectionsDispatch:ke,selectedCollectionsDispatch:je,setScreen:oe,collections:_,onBackPress:()=>{ge(""),ke({type:"set",data:{collections:{},products:{}}})},pickerType:N,hideProductCheckbox:B,hideProductVariants:U,hideVariantCheckbox:M,storeId:T,fbStatusFetcher:O.fbStatusFetcher,setCollectionId:ie,setSelectedCollectionId:ne,renderWithoutModal:Y,hideCollectionCheckbox:$,outOfStockAction:L})]}))]}));return t(o,{children:Y?Re:e(u,Object.assign({zIndex:E,open:w,onClose:()=>{null==R||R(),De()},headingTitle:G||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:t(o,{}),footerContainerStyle:O.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:{buttonText:ue?"Loading...":te===F.RearrangeProducts?"Done":"Add",disabled:ue||pe<1||A&&pe<A||!A&&V&&pe>V||!1,onClick:()=>{O.onAdd(Pe,pe),De()}},wrapperStyle:O.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&pe>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):V&&pe>V?t(p,{tagText:`You can only select ${V} products`,type:"negative"}):t(d,pe>0?{onClick:()=>{oe(J?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${pe}/${A} products selected`:`${pe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}:{disabled:!0,buttonText:A?`${pe}/${A} products selected`:`${pe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ie},{children:[Re,Ie&&Oe?t(C,{productData:Oe,outOfStockAction:L,onClose:()=>{Fe(!1)}}):t(o,{})]}))})};export{O as ProductPickerModal,F 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 l,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as f}from"./rearrangeScreen.js";import{collectionsReducer as b,searchReducer as y,selectedColectionsReducer as S,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const O=O=>{const{storeId:T,selectedItems:D,onClose:R,visible:w,zIndex:E,exactLimit:A,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:N,hideProductVariants:U=!1,startupScreen:q=F.Collections,rearrangeEnabled:J,selectSingleItem:Q=!1,showProductDetails:X,containerStyle:Z}=O,[_,ee]=r(b,{}),[te,oe]=s([F.Collections,F.RearrangeProducts].includes(q)?q:F.Collections),[ce,re]=s("grid"),[se,le]=s(""),[ie,ne]=s(""),[de,ae]=s(0),[ue,he]=s(!1),[pe,me]=s(0),[Ce,ge]=s(""),[fe,be]=s(!1),[ye,Se]=s(!1),[ve,ke]=r(y,{collections:{},products:{}}),[Pe,xe]=r(S,Object.keys(D).length>0?D:{}),je=l(null),[Ie,Fe]=s(!1),[Oe,Te]=s();i((()=>{he(!0),Se(!0),O.collectionFetcher(de,T).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),he(!1),ae((e=>e+1)),Se(!1)})).catch()}),[]),i((()=>{let e=0;U?Object.keys(Pe||[]).forEach((t=>{var o;Object.keys((null===(o=Pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Pe[-1]&&(null===(c=Pe[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Pe||[]).forEach((t=>{var o;Object.keys((null===(o=Pe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Pe[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),me(e)}),[_,Pe,U]),i((()=>{ie&&(he(!0),console.log("useEffect selectedCollectionId modal.tsx:277",ie),O.productFetcher(ie,T).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),he(!1)})).catch())}),[ie]),i((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(Ce.length||"collections"!==te)&&(Ce.length?(be(!0),O.searchFetcher(T,Ce).then((e=>{"collections"in e&&"products"in e?(ke({type:"set",data:e}),ee({type:"searched",data:e.collections})):(ke({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),he(!1),be(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[Ce]),i((()=>{K&&(O.onAdd(Pe,pe),De())}),[K]),i((()=>{Q&&Object.keys(Pe||{}).length&&pe&&(O.onAdd(Pe,pe),De())}),[Q,Pe,pe]);const De=()=>{xe({type:"reset",data:{}})},Re=e(x,Object.assign({style:null!=Z?Z:{}},{children:[O.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:O.postHeader})),!O.hideGlobalSearch&&t(o,{children:("collections"===te||"searchProducts"===te)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>fe?t(h,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Ce,onChangeText:e=>{e.length&&e.trim().length?ge(e):ge("")}})}))}),e(j,Object.assign({ref:je,screenName:te},{children:["collections"===te&&t(m,{customCollectionRestriction:O.customCollectionRestriction,dataLoading:ye,collections:_,selectedCollectionsDispatch:xe,setCollectionId:le,setSelectedCollectionId:ne,setScreen:oe,selectedCollections:Pe,collectionFetcher:O.collectionFetcher,storeId:T,collectionsDispatch:ee,setSaveDisabled:he,pagingControls:{curPage:de,setCurPage:ae},hideCollectionCheckbox:$,renderWithoutModal:Y,pickerType:N,scrollContainerRef:je}),"products"===te&&se&&t(v.Provider,Object.assign({value:se},{children:t(g,{hideInCollectionSearch:O.hideInCollectionSearch,customCollectionRestriction:O.customCollectionRestriction,productFetcher:O.productFetcher,setScreen:oe,storeId:T,data:_[se],collectionsDispatch:ee,selectedCollectionsDispatch:xe,selectedData:Pe,setSaveDisabled:he,searchInCollectionFetcher:O.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:N,hideProductVariants:U,fbStatusFetcher:O.fbStatusFetcher,onProductDetailClick:e=>{Fe(!0),Te(e)},showProductDetailInfoIcon:X,scrollContainerRef:je})})),"view"===te&&t(P,{selectedCollections:Pe||{},selectedCollectionsDispatch:xe,setScreen:oe,collections:_,hideProductVariants:U,outOfStockAction:L,storeId:T,fbStatusFetcher:O.fbStatusFetcher}),"rearrange"===te&&t(f,{selectedCollections:Pe||{},selectedCollectionsDispatch:xe,setScreen:oe,outOfStockAction:L,rearrangeViewType:"grid"===ce?"list":"grid",scrollContainerRef:je,storeId:T,fbStatusFetcher:O.fbStatusFetcher}),"searchProducts"===te&&t(k,{customCollectionRestriction:O.customCollectionRestriction,selectedCollections:Pe||{},searchedCollections:ve||{},searchedCollectionsDispatch:ke,selectedCollectionsDispatch:xe,setScreen:oe,collections:_,onBackPress:()=>{ge(""),ke({type:"set",data:{collections:{},products:{}}})},pickerType:N,hideProductCheckbox:B,hideProductVariants:U,hideVariantCheckbox:M,storeId:T,fbStatusFetcher:O.fbStatusFetcher,setCollectionId:le,setSelectedCollectionId:ne,renderWithoutModal:Y,hideCollectionCheckbox:$,outOfStockAction:L})]}))]}));return t(o,{children:Y?Re:e(u,Object.assign({zIndex:E,open:w,onClose:()=>{null==R||R(),De()},headingTitle:G||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:t(o,{}),footerContainerStyle:O.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:{buttonText:ue?"Loading...":te===F.RearrangeProducts?"Done":"Add",disabled:ue||pe<1||A&&pe<A||!A&&V&&pe>V||!1,onClick:()=>{O.onAdd(Pe,pe),De()}},wrapperStyle:O.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&pe>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):V&&pe>V?t(p,{tagText:`You can only select ${V} products`,type:"negative"}):t(d,pe>0?{onClick:()=>{oe(J?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${pe}/${A} products selected`:`${pe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}:{disabled:!0,buttonText:A?`${pe}/${A} products selected`:`${pe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ie},{children:[Re,Ie&&Oe?t(C,{productData:Oe,outOfStockAction:L,onClose:()=>{Fe(!1)}}):t(o,{})]}))})};export{O as ProductPickerModal,F as ScreenName};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as i,useRef as s,useState as l,useEffect as d}from"react";import{COLORS as u}from"../../constants/Theme.js";import{CheckBox as a}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as v,TitleRegular as g}from"../TypographyStyle.js";import{EmptyState as j}from"./emptyState.js";import{ProductGroup as f}from"./product.js";import{ProductPickerShimmer as y}from"./ProductPickerShimmer.js";import{CollectionIdContext as b}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as O}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as E,isCollectionPartiallyChecked as I,isProductPartiallyChecked as D,liftTheStateUp as x}from"./utility.js";const S=S=>{var T,w;const{data:R,collectionsDispatch:V,selectedData:A,selectedCollectionsDispatch:B,productFetcher:F,storeId:H,setScreen:L,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:K,outOfStockAction:M=C.BLUR,hideVariantCheckbox:N=!1,selectProductsFromCustomCollection:U=!1,pickerType:_,hideProductVariants:q,fbStatusFetcher:G,onProductDetailClick:Q,showProductDetailInfoIcon:X,scrollContainerRef:Y}=S,Z=i(b),$=s(0),tt=s(!1),[et,ot]=l(!1),[ct,rt]=l(""),[nt,it]=l(!1),[st,lt]=l(R),dt=s(!1);d((()=>{const t=setTimeout((()=>{ct.length?(it(!0),S.searchInCollectionFetcher(H,Z,ct).then((t=>{const e=n(R);e.products=t,lt(e);const o=P(null!=t?t:{});ht(o,null!=t?t:{},!0),J(!1),it(!1)}))):lt(R)}),800);return()=>clearTimeout(t)}),[ct]);const ut=()=>{if(!Y||!(null==Y?void 0:Y.current))return;const{scrollTop:t,clientHeight:e,scrollHeight:o}=Y.current;t+e>=o-20&&!dt.current&&!tt.current&&(J(!0),ot(!0),tt.current=!0,F(Z,H,10,$.current).then((t=>{if(Object.keys(t).length||(dt.current=!0),Object.keys(t).length){const e=st;e.products=Object.assign(Object.assign({},st.products),t),lt(e);const o=P(t);ht(o,t),$.current+=1}tt.current=!1,ot(!1),J(!1)})).catch())};d((()=>{var t;return null===(t=null==Y?void 0:Y.current)||void 0===t||t.addEventListener("scroll",ut),()=>{var t;null===(t=null==Y?void 0:Y.current)||void 0===t||t.removeEventListener("scroll",ut)}}),[]),d((()=>{var t,e,o,c;dt.current=!1,$.current=Math.floor((null===(e=Object.keys(null!==(t=R.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=R.products)&&void 0!==o?o:{});ht(r,null!==(c=R.products)&&void 0!==c?c:{})}),[Z]);const at=!!z&&R.isSmartCollection;d((()=>{(null==R?void 0:R.products)||pt(10)}),[]);const ht=(t,e,o)=>{G||(o?E(e,V,Z,st,lt):E(e,V,Z)),t.length>0&&G&&G(H,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,i;const s=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];s&&"REJECTED"===t[r]?s.fbStatus="REJECTED":s&&"APPROVED"===t[r]&&(s.fbStatus="APPROVED");const l=null===(i=null==c?void 0:c[o])||void 0===i?void 0:i.variants;l&&l[r]&&(l[r]=s)}))})),o?(lt((t=>{const e=Object.assign({},t);return e.products=c,e})),V({type:"productsPaged",data:{collectionId:Z,products:c}})):V({type:"productsPaged",data:{collectionId:Z,products:c}})})).catch((t=>{o?E(e,V,Z,st,lt):E(e,V,Z)}))},pt=t=>{J(!0),it(!0),F(Z,H,t,0).then((e=>{if(Object.keys(e).length||(dt.current=!0),Object.keys(e).length){lt(Object.assign(Object.assign({},st),{products:e}));const t=P(e);ht(t,e),$.current=1}t||B({type:"selected",data:{id:Z,val:Object.assign(Object.assign({},R),{products:e})}}),J(!1),it(!1)})).catch()},mt=(t,e)=>{const o=x(e,R);B({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})},vt=!!(null==A?void 0:A[Z])&&!!Object.keys(null!==(w=null===(T=null==A?void 0:A[Z])||void 0===T?void 0:T.products)&&void 0!==w?w:{}).length;return t("div",{children:[t(k,{children:[e(h,{Icon:o,height:16,onClick:()=>{L("collections")}}),e(v,Object.assign({style:{color:u.content.secondary}},{children:R.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>nt&&ct.length?e(m,{size:"small",color:u.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:ct,onChangeText:t=>{t.length&&t.trim().length?rt(t):rt("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==st?void 0:st.products)||[]).length>0&&!at&&!ct.length&&!K&&"-1"!==Z&&t(O,{children:[e(a,{isChecked:vt,isPartiallyChecked:I(Z,st,A,q),onValueChange:function(t){t?pt():B({type:"unselected",data:{id:Z}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(g,{children:"All Products"})]}),Object.keys((null==st?void 0:st.products)||[]).length?Object.keys(st.products||[]).map((t=>e(f,{outOfStockAction:M,collectionId:Z,isProductPartiallyChecked:D(Z,t,A,st,q),productId:t,data:st.products[t],selectedData:A,selectedCollectionsDispatch:B,viewOnly:!U&&!!at,upliftAdditions:mt,hideProductCheckbox:K,hideVariantCheckbox:N,hideProductVariants:q,pickerType:_,onProductDetailClick:Q,showProductDetailInfoIcon:X},t))):nt?e(y,{limit:10}):e(j,{title:"No products to show",subtitle:ct.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]}),et&&e(y,{})]})};export{S as ProductsScreen};
1
+ import{__awaiter as t}from"../../_virtual/_tslib.js";import{jsxs as o,jsx as e}from"react/jsx-runtime";import c from"../../assets/icons/arrow_left.svg.js";import n from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as i}from"lodash";import{useContext as l,useRef as s,useState as d,useEffect as u,useCallback as a}from"react";import{COLORS as h}from"../../constants/Theme.js";import{CheckBox as p}from"../checkBox/CheckBox.js";import{IconButton as m}from"../icon-button/IconButton.js";import{Input as g}from"../input/Input.js";import{Spinner as v}from"../spinner/Spinner.js";import{BodyCaption as f,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as b}from"./emptyState.js";import{ProductGroup as y}from"./product.js";import{ProductPickerShimmer as C}from"./ProductPickerShimmer.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as P}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";import{getVariantIdsToFetchAtProductLevel as E,markVariantsAsApprovedProductsLevel as S,isCollectionPartiallyChecked as x,isProductPartiallyChecked as D,liftTheStateUp as T}from"./utility.js";const R=R=>{var B,V;const{data:A,collectionsDispatch:H,selectedData:F,selectedCollectionsDispatch:M,productFetcher:L,storeId:_,setScreen:J,setSaveDisabled:W,hideInCollectionSearch:q,customCollectionRestriction:z,hideProductCheckbox:K,outOfStockAction:N=I.BLUR,hideVariantCheckbox:U=!1,selectProductsFromCustomCollection:G=!1,pickerType:Q,hideProductVariants:X,fbStatusFetcher:Y,onProductDetailClick:Z,showProductDetailInfoIcon:$,scrollContainerRef:tt}=R,ot=l(O),et=s(0),ct=s(!1),[nt,rt]=d(!1),[it,lt]=d(""),[st,dt]=d(!1),[ut,at]=d(A),ht=s(!1);u((()=>{const t=setTimeout((()=>{it.length?(dt(!0),R.searchInCollectionFetcher(_,ot,it).then((t=>{const o=i(A);o.products=t,at(o);const e=E(null!=t?t:{});mt(e,null!=t?t:{},!0),W(!1),dt(!1)}))):at(A)}),800);return()=>clearTimeout(t)}),[it]),a((()=>{if(!tt||!(null==tt?void 0:tt.current))return;const{scrollTop:t,clientHeight:o,scrollHeight:e}=tt.current;console.log({scrollTop:t,clientHeight:o,scrollHeight:e}),t+o>=e-20&&!ht.current&&!ct.current&&(W(!0),rt(!0),ct.current=!0,console.log("handleScroll productFetcher",{collectionId:ot,storeId:_,o:10,nc:et.current}),L(ot,_,10,et.current).then((c=>{var n,r;if(Object.keys(c).length||(ht.current=!0),Object.keys(c).length){const i=ut;i.products=Object.assign(Object.assign({},ut.products),c),at(i);const l=E(c);mt(l,c),console.log("new scroll position",t+o-100),et.current+=1;const s=(null===(n=tt.current)||void 0===n?void 0:n.scrollHeight)-e+t;null===(r=tt.current)||void 0===r||r.scrollTo({top:s-100,behavior:"smooth"})}ct.current=!1,rt(!1),W(!1)})).catch())}),[ot,ut,tt,_]),u((()=>{var t,o,e,c;console.log("useEffect productScreen, collectionId",{collectionId:ot}),ht.current=!1,et.current=Math.floor((null===(o=Object.keys(null!==(t=A.products)&&void 0!==t?t:{}))||void 0===o?void 0:o.length)/10);const n=E(null!==(e=A.products)&&void 0!==e?e:{});mt(n,null!==(c=A.products)&&void 0!==c?c:{})}),[ot]);const pt=!!z&&A.isSmartCollection;u((()=>{(null==A?void 0:A.products)||gt(10)}),[]);const mt=(t,o,e)=>{Y||(e?S(o,H,ot,ut,at):S(o,H,ot)),t.length>0&&Y&&Y(_,t).then((t=>{const c=Object.assign({},o);Object.keys(o).forEach((e=>{var n,r;Object.keys(null!==(r=null===(n=null==o?void 0:o[e])||void 0===n?void 0:n.variants)&&void 0!==r?r:{}).forEach((n=>{var r,i;const l=null===(r=null==o?void 0:o[e].variants)||void 0===r?void 0:r[n];l&&"REJECTED"===t[n]?l.fbStatus="REJECTED":l&&"APPROVED"===t[n]&&(l.fbStatus="APPROVED");const s=null===(i=null==c?void 0:c[e])||void 0===i?void 0:i.variants;s&&s[n]&&(s[n]=l)}))})),e?(at((t=>{const o=Object.assign({},t);return o.products=c,o})),H({type:"productsPaged",data:{collectionId:ot,products:c}})):H({type:"productsPaged",data:{collectionId:ot,products:c}})})).catch((t=>{e?S(o,H,ot,ut,at):S(o,H,ot)}))},gt=t=>{W(!0),dt(!0),L(ot,_,t,0).then((o=>{if(Object.keys(o).length||(ht.current=!0),Object.keys(o).length){at(Object.assign(Object.assign({},ut),{products:o}));const t=E(o);mt(t,o),et.current=1}t||M({type:"selected",data:{id:ot,val:Object.assign(Object.assign({},A),{products:o})}}),W(!1),dt(!1)})).catch()},vt=(t,o)=>{const e=T(o,A);M({type:t,data:Object.assign(Object.assign({},e),{isRestricted:z})})},ft=!!(null==F?void 0:F[ot])&&!!Object.keys(null!==(V=null===(B=null==F?void 0:F[ot])||void 0===B?void 0:B.products)&&void 0!==V?V:{}).length;return s(null),console.log({scrollContainerRef:tt}),o("div",{children:[o(k,{children:[e(m,{Icon:c,height:16,onClick:()=>{J("collections")}}),e(f,Object.assign({style:{color:h.content.secondary}},{children:A.name}))]}),!q&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(g,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>st&&it.length?e(v,{size:"small",color:h.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:it,onChangeText:t=>{t.length&&t.trim().length?lt(t):lt("")},placeholder:"Search products in this collection..."})})),o(w,Object.assign({containerRef:tt,fetchMore:()=>t(void 0,void 0,void 0,(function*(){console.log("fetchMore called"),yield L(ot,_,10,et.current),et.current+=1})),loadingComponent:e(C,{limit:1})},{children:[Object.keys((null==ut?void 0:ut.products)||[]).length>0&&!pt&&!it.length&&!K&&"-1"!==ot&&o(P,{children:[e(p,{isChecked:ft,isPartiallyChecked:x(ot,ut,F,X),onValueChange:function(t){t?gt():M({type:"unselected",data:{id:ot}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(n,{})})),e(j,{children:"All Products"})]}),Object.keys((null==ut?void 0:ut.products)||[]).length?Object.keys(ut.products||[]).map((t=>e(y,{outOfStockAction:N,collectionId:ot,isProductPartiallyChecked:D(ot,t,F,ut,X),productId:t,data:ut.products[t],selectedData:F,selectedCollectionsDispatch:M,viewOnly:!G&&!!pt,upliftAdditions:vt,hideProductCheckbox:K,hideVariantCheckbox:U,hideProductVariants:X,pickerType:Q,onProductDetailClick:Z,showProductDetailInfoIcon:$},t))):st?e(C,{limit:10}):e(b,{title:"No products to show",subtitle:it.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})),nt&&e(C,{limit:1})]})},w=t=>{let{children:c,fetchMore:n,loadingComponent:r,containerRef:i}=t;const[l,a]=d(!1),h=s(0);return u((()=>{if(!i.current)return;const t=i.current,o=()=>{if(l)return;const o=t.querySelector("#sentinel");if(!o)return;const e=t.getBoundingClientRect(),c=o.getBoundingClientRect();c.top<=e.bottom&&c.bottom>=e.top&&(a(!0),h.current=t.scrollTop,n().then((()=>{t.scrollTo({top:h.current-10,behavior:"smooth"}),a(!1)})))};return t.addEventListener("scroll",o),()=>{t.removeEventListener("scroll",o)}}),[n,l,i]),o("div",{children:[c,e("div",{id:"sentinel",style:{height:"10px"}}),l&&r]})};export{R as ProductsScreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.547",
3
+ "version": "0.0.548-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",