@bikdotai/bik-component-library 0.0.640-2 → 0.0.640-3

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.
@@ -74,7 +74,7 @@ export type ProductPickerInterface = {
74
74
  fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
75
75
  storeId: string;
76
76
  selectedItems: SelectedItems;
77
- onAdd: (items: SelectedItems, total: number) => void;
77
+ onAdd: (items: SelectedItems, total: number, secondaryClick?: boolean) => void;
78
78
  onClose?: () => void;
79
79
  visible: boolean;
80
80
  zIndex?: 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"),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"),x=require("./searchScreen.js"),g=require("./selectedScreen.js"),j=require("./style.js"),y=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:m,selectedItems:b,onClose:f,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:P,hideProductCheckbox:F,outOfStockAction:R=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:D,hideSelectionCount:N,title:q,width:E,left:w,renderWithoutModal:A,onClickSave:B,pickerType:L,hideProductVariants:M=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:V,selectSingleItem:$=!1,showProductDetails:_,containerStyle:H,crossButtonInsideHeader:W=!1,footerForNonModal:G={},primaryButton:K,secondaryButton:U,subtitle:Y}=e,[J,Q]=c.useReducer(C.collectionsReducer,{}),[X,Z]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[ee,te]=c.useState("grid"),[oe,ce]=c.useState(""),[re,se]=c.useState(""),[ne,ie]=c.useState(0),[le,ae]=c.useState(!1),[de,ue]=c.useState(0),[he,pe]=c.useState(""),[Se,Ce]=c.useState(!1),[xe,ge]=c.useState(!1),[je,ye]=c.useReducer(C.searchReducer,{collections:{},products:{}}),[me,be]=c.useReducer(C.selectedColectionsReducer,Object.keys(b).length>0?b:{}),fe=c.useRef(null),[ve,ke]=c.useState(!1),[Ie,Oe]=c.useState();c.useEffect((()=>{ae(!0),ge(!0),e.collectionFetcher(ne,m).then((e=>{Q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ae(!1),ie((e=>e+1)),ge(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;M?Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&me[-1]&&(null===(c=me[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=me[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ue(e)}),[J,me,M]),c.useEffect((()=>{re&&(ae(!0),e.productFetcher(re,m).then((e=>{Object.keys(e).length&&Q({type:"productsFetched",data:{collectionId:re,products:e}}),ae(!1)})).catch())}),[re]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==X&&(he.length||"collections"!==X)&&(he.length?(Ce(!0),e.searchFetcher(m,he).then((e=>{"collections"in e&&"products"in e?(ye({type:"set",data:e}),Q({type:"searched",data:e.collections})):(ye({type:"set",data:{collections:{},products:e}}),Q({type:"searched",data:e})),Z("searchProducts"),ae(!1),Ce(!1)}))):Z("collections"))}),800);return()=>clearTimeout(t)}),[he]),c.useEffect((()=>{B&&(e.onAdd(me,de),Pe())}),[B]),c.useEffect((()=>{$&&Object.keys(me||{}).length&&de&&(e.onAdd(me,de),Pe())}),[$,me,de]);const Pe=()=>{be({type:"reset",data:{}})},Fe=()=>I&&de>I?t.jsx(d.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):O&&de>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):de>0?t.jsx(n.Button,{onClick:()=>{Z(V?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:I?`${de}/${I} products selected`:`${de} products selected`,buttonType:["rearrange","view"].includes(X)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(X)}):t.jsx(n.Button,{disabled:!0,buttonText:I?`${de}/${I} products selected`:`${de} products selected`,buttonType:"tertiaryGray"}),Re=e=>le?"Loading...":X===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Te=t.jsxs(j.ContainerStyle,Object.assign({style:null!=H?H:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===X||"searchProducts"===X)&&t.jsx("div",Object.assign({style:{padding:A?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(i.Input,{placeholder:"Search for collections and products, or type a product ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?t.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:he,onChangeText:e=>{e.length&&e.trim().length?pe(e):pe("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:fe,screenName:X},{children:["collections"===X&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:xe,collections:J,selectedCollectionsDispatch:be,setCollectionId:ce,setSelectedCollectionId:se,setScreen:Z,selectedCollections:me,collectionFetcher:e.collectionFetcher,storeId:m,collectionsDispatch:Q,setSaveDisabled:ae,pagingControls:{curPage:ne,setCurPage:ie},hideCollectionCheckbox:P,renderWithoutModal:A,pickerType:L,scrollContainerRef:fe}),"products"===X&&oe&&t.jsx(C.CollectionIdContext.Provider,Object.assign({value:oe},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:Z,storeId:m,data:J[oe],collectionsDispatch:Q,selectedCollectionsDispatch:be,selectedData:me,setSaveDisabled:ae,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:R,hideVariantCheckbox:T,selectProductsFromCustomCollection:D,renderWithoutModal:A,pickerType:L,hideProductVariants:M,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{ke(!0),Oe(e)},showProductDetailInfoIcon:_,scrollContainerRef:fe})})),"view"===X&&t.jsx(g.SelectedScreen,{selectedCollections:me||{},selectedCollectionsDispatch:be,setScreen:Z,collections:J,hideProductVariants:M,outOfStockAction:R,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===X&&t.jsx(S.RearrangeScreen,{selectedCollections:me||{},selectedCollectionsDispatch:be,setScreen:Z,outOfStockAction:R,rearrangeViewType:"grid"===ee?"list":"grid",scrollContainerRef:fe,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===X&&t.jsx(x.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:me||{},searchedCollections:je||{},searchedCollectionsDispatch:ye,selectedCollectionsDispatch:be,setScreen:Z,collections:J,onBackPress:()=>{pe(""),ye({type:"set",data:{collections:{},products:{}}})},pickerType:L,hideProductCheckbox:F,hideProductVariants:M,hideVariantCheckbox:T,storeId:m,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:ce,setSelectedCollectionId:se,renderWithoutModal:A,hideCollectionCheckbox:P,outOfStockAction:R})]}))]}));return t.jsx(t.Fragment,{children:A?t.jsxs(t.Fragment,{children:[Te,G.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Fe(),t.jsx(n.Button,{buttonText:Re(G.primaryButtonText),disabled:!G.isLoading&&(le||de<1||I&&de<I||!I&&O&&de>O)||G.primaryButtonDisabled,isLoading:G.isLoading,onClick:()=>{e.onAdd(me,de),Pe(),Z([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):t.jsx(t.Fragment,{}),ve&&Ie?t.jsx(h.ProductInfoOverlay,{productData:Ie,outOfStockAction:R,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{ke(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(l.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==f||f(),Pe()},headingTitle:q||("collections"===X||"products"===X?"Select Products":"view"===X?"Selected Products":"searchProducts"===X?"Searched Results":"rearrange"===X?"Rearrange Products":void 0),headingSubtitle:Y,footerShadow:!0,centralContainerStyles:{width:E||"600px",left:w||"auto"},headerRightCustomElement:W?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:f},{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:K?Object.assign(Object.assign({},K),{disabled:!K.isLoading&&(le||de<1||I&&de<I||!I&&O&&de>O)||K.disabled,onClick:()=>{e.onAdd(me,de),Pe(),Z([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}):{buttonText:Re(),disabled:le||de<1||I&&de<I||!I&&O&&de>O||!1,onClick:()=>{e.onAdd(me,de),Pe()}},secondaryButton:U?Object.assign(Object.assign({},U),{onClick:()=>{e.onAdd(me,de),Pe()}}):{},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t.jsx(t.Fragment,{}):Fe(),hideCrossButton:ve||W},{children:[Te,ve&&Ie?t.jsx(h.ProductInfoOverlay,{productData:Ie,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:R,onClose:()=>{ke(!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"),x=require("./searchScreen.js"),g=require("./selectedScreen.js"),j=require("./style.js"),y=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:m,selectedItems:b,onClose:f,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:P,hideProductCheckbox:F,outOfStockAction:R=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:D,hideSelectionCount:N,title:q,width:E,left:w,renderWithoutModal:A,onClickSave:B,pickerType:L,hideProductVariants:M=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:V,selectSingleItem:$=!1,showProductDetails:_,containerStyle:H,crossButtonInsideHeader:W=!1,footerForNonModal:G={},primaryButton:K,secondaryButton:U,subtitle:Y}=e,[J,Q]=c.useReducer(C.collectionsReducer,{}),[X,Z]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[ee,te]=c.useState("grid"),[oe,ce]=c.useState(""),[re,se]=c.useState(""),[ne,ie]=c.useState(0),[le,ae]=c.useState(!1),[de,ue]=c.useState(0),[he,pe]=c.useState(""),[Se,Ce]=c.useState(!1),[xe,ge]=c.useState(!1),[je,ye]=c.useReducer(C.searchReducer,{collections:{},products:{}}),[me,be]=c.useReducer(C.selectedColectionsReducer,Object.keys(b).length>0?b:{}),fe=c.useRef(null),[ve,ke]=c.useState(!1),[Ie,Oe]=c.useState();c.useEffect((()=>{ae(!0),ge(!0),e.collectionFetcher(ne,m).then((e=>{Q({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ae(!1),ie((e=>e+1)),ge(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;M?Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&me[-1]&&(null===(c=me[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(me||[]).forEach((t=>{var o;Object.keys((null===(o=me[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=me[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ue(e)}),[J,me,M]),c.useEffect((()=>{re&&(ae(!0),e.productFetcher(re,m).then((e=>{Object.keys(e).length&&Q({type:"productsFetched",data:{collectionId:re,products:e}}),ae(!1)})).catch())}),[re]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==X&&(he.length||"collections"!==X)&&(he.length?(Ce(!0),e.searchFetcher(m,he).then((e=>{"collections"in e&&"products"in e?(ye({type:"set",data:e}),Q({type:"searched",data:e.collections})):(ye({type:"set",data:{collections:{},products:e}}),Q({type:"searched",data:e})),Z("searchProducts"),ae(!1),Ce(!1)}))):Z("collections"))}),800);return()=>clearTimeout(t)}),[he]),c.useEffect((()=>{B&&(e.onAdd(me,de),Pe())}),[B]),c.useEffect((()=>{$&&Object.keys(me||{}).length&&de&&(e.onAdd(me,de),Pe())}),[$,me,de]);const Pe=()=>{be({type:"reset",data:{}})},Fe=()=>I&&de>I?t.jsx(d.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):O&&de>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):de>0?t.jsx(n.Button,{onClick:()=>{Z(V?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:I?`${de}/${I} products selected`:`${de} products selected`,buttonType:["rearrange","view"].includes(X)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(X)}):t.jsx(n.Button,{disabled:!0,buttonText:I?`${de}/${I} products selected`:`${de} products selected`,buttonType:"tertiaryGray"}),Re=e=>le?"Loading...":X===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Te=t.jsxs(j.ContainerStyle,Object.assign({style:null!=H?H:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===X||"searchProducts"===X)&&t.jsx("div",Object.assign({style:{padding:A?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(i.Input,{placeholder:"Search for collections and products, or type a product ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?t.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:he,onChangeText:e=>{e.length&&e.trim().length?pe(e):pe("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:fe,screenName:X},{children:["collections"===X&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:xe,collections:J,selectedCollectionsDispatch:be,setCollectionId:ce,setSelectedCollectionId:se,setScreen:Z,selectedCollections:me,collectionFetcher:e.collectionFetcher,storeId:m,collectionsDispatch:Q,setSaveDisabled:ae,pagingControls:{curPage:ne,setCurPage:ie},hideCollectionCheckbox:P,renderWithoutModal:A,pickerType:L,scrollContainerRef:fe}),"products"===X&&oe&&t.jsx(C.CollectionIdContext.Provider,Object.assign({value:oe},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:Z,storeId:m,data:J[oe],collectionsDispatch:Q,selectedCollectionsDispatch:be,selectedData:me,setSaveDisabled:ae,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:R,hideVariantCheckbox:T,selectProductsFromCustomCollection:D,renderWithoutModal:A,pickerType:L,hideProductVariants:M,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{ke(!0),Oe(e)},showProductDetailInfoIcon:_,scrollContainerRef:fe})})),"view"===X&&t.jsx(g.SelectedScreen,{selectedCollections:me||{},selectedCollectionsDispatch:be,setScreen:Z,collections:J,hideProductVariants:M,outOfStockAction:R,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===X&&t.jsx(S.RearrangeScreen,{selectedCollections:me||{},selectedCollectionsDispatch:be,setScreen:Z,outOfStockAction:R,rearrangeViewType:"grid"===ee?"list":"grid",scrollContainerRef:fe,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===X&&t.jsx(x.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:me||{},searchedCollections:je||{},searchedCollectionsDispatch:ye,selectedCollectionsDispatch:be,setScreen:Z,collections:J,onBackPress:()=>{pe(""),ye({type:"set",data:{collections:{},products:{}}})},pickerType:L,hideProductCheckbox:F,hideProductVariants:M,hideVariantCheckbox:T,storeId:m,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:ce,setSelectedCollectionId:se,renderWithoutModal:A,hideCollectionCheckbox:P,outOfStockAction:R})]}))]}));return t.jsx(t.Fragment,{children:A?t.jsxs(t.Fragment,{children:[Te,G.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Fe(),t.jsx(n.Button,{buttonText:Re(G.primaryButtonText),disabled:!G.isLoading&&(le||de<1||I&&de<I||!I&&O&&de>O)||G.primaryButtonDisabled,isLoading:G.isLoading,onClick:()=>{e.onAdd(me,de),Pe(),Z([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):t.jsx(t.Fragment,{}),ve&&Ie?t.jsx(h.ProductInfoOverlay,{productData:Ie,outOfStockAction:R,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{ke(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(l.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==f||f(),Pe()},headingTitle:q||("collections"===X||"products"===X?"Select Products":"view"===X?"Selected Products":"searchProducts"===X?"Searched Results":"rearrange"===X?"Rearrange Products":void 0),headingSubtitle:Y,footerShadow:!0,centralContainerStyles:{width:E||"600px",left:w||"auto"},headerRightCustomElement:W?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:f},{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:K?Object.assign(Object.assign({},K),{disabled:!K.isLoading&&(le||de<1||I&&de<I||!I&&O&&de>O)||K.disabled,onClick:()=>{e.onAdd(me,de),Pe(),Z([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}):{buttonText:Re(),disabled:le||de<1||I&&de<I||!I&&O&&de>O||!1,onClick:()=>{e.onAdd(me,de),Pe()}},secondaryButton:U?Object.assign(Object.assign({},U),{onClick:()=>{e.onAdd(me,de,!0),Pe()}}):{},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t.jsx(t.Fragment,{}):Fe(),hideCrossButton:ve||W},{children:[Te,ve&&Ie?t.jsx(h.ProductInfoOverlay,{productData:Ie,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:R,onClose:()=>{ke(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -74,7 +74,7 @@ export type ProductPickerInterface = {
74
74
  fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
75
75
  storeId: string;
76
76
  selectedItems: SelectedItems;
77
- onAdd: (items: SelectedItems, total: number) => void;
77
+ onAdd: (items: SelectedItems, total: number, secondaryClick?: boolean) => void;
78
78
  onClose?: () => void;
79
79
  visible: boolean;
80
80
  zIndex?: 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,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 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 x,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=D.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:N,width:Y,left:K,renderWithoutModal:U,onClickSave:q,pickerType:J,hideProductVariants:Q=!1,startupScreen:X=F.Collections,rearrangeEnabled:Z,selectSingleItem:_=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:re,secondaryButton:se,subtitle:ie}=T,[ne,le]=r(b,{}),[de,ae]=s([F.Collections,F.RearrangeProducts].includes(X)?X:F.Collections),[ue,he]=s("grid"),[pe,me]=s(""),[Ce,ge]=s(""),[fe,ye]=s(0),[be,Se]=s(!1),[ve,ke]=s(0),[je,Ie]=s(""),[xe,Pe]=s(!1),[Oe,De]=s(!1),[Fe,Te]=r(S,{collections:{},products:{}}),[Re,we]=r(v,Object.keys(w).length>0?w:{}),Ae=i(null),[Be,Ee]=s(!1),[Le,ze]=s();n((()=>{Se(!0),De(!0),T.collectionFetcher(fe,R).then((e=>{le({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Se(!1),ye((e=>e+1)),De(!1)})).catch()}),[]),n((()=>{let e=0;Q?Object.keys(Re||[]).forEach((t=>{var o;Object.keys((null===(o=Re[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Re[-1]&&(null===(c=Re[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Re||[]).forEach((t=>{var o;Object.keys((null===(o=Re[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Re[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[ne,Re,Q]),n((()=>{Ce&&(Se(!0),T.productFetcher(Ce,R).then((e=>{Object.keys(e).length&&le({type:"productsFetched",data:{collectionId:Ce,products:e}}),Se(!1)})).catch())}),[Ce]),n((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(je.length||"collections"!==de)&&(je.length?(Pe(!0),T.searchFetcher(R,je).then((e=>{"collections"in e&&"products"in e?(Te({type:"set",data:e}),le({type:"searched",data:e.collections})):(Te({type:"set",data:{collections:{},products:e}}),le({type:"searched",data:e})),ae("searchProducts"),Se(!1),Pe(!1)}))):ae("collections"))}),800);return()=>clearTimeout(e)}),[je]),n((()=>{q&&(T.onAdd(Re,ve),Ve())}),[q]),n((()=>{_&&Object.keys(Re||{}).length&&ve&&(T.onAdd(Re,ve),Ve())}),[_,Re,ve]);const Ve=()=>{we({type:"reset",data:{}})},$e=()=>L&&ve>L?t(m,{tagText:`You can only select ${L} products`,type:"negative"}):z&&ve>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):t(a,ve>0?{onClick:()=>{ae(Z?F.RearrangeProducts:F.SelectedProducts)},buttonText:L?`${ve}/${L} products selected`:`${ve} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}:{disabled:!0,buttonText:L?`${ve}/${L} products selected`:`${ve} products selected`,buttonType:"tertiaryGray"}),Me=e=>be?"Loading...":de===F.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",He=e(x,Object.assign({style:null!=te?te:{}},{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===de||"searchProducts"===de)&&t("div",Object.assign({style:{padding:U?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search for collections and products, or type a product 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:je,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e(P,Object.assign({ref:Ae,screenName:de},{children:["collections"===de&&t(C,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:Oe,collections:ne,selectedCollectionsDispatch:we,setCollectionId:me,setSelectedCollectionId:ge,setScreen:ae,selectedCollections:Re,collectionFetcher:T.collectionFetcher,storeId:R,collectionsDispatch:le,setSaveDisabled:Se,pagingControls:{curPage:fe,setCurPage:ye},hideCollectionCheckbox:V,renderWithoutModal:U,pickerType:J,scrollContainerRef:Ae}),"products"===de&&pe&&t(k.Provider,Object.assign({value:pe},{children:t(f,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:ae,storeId:R,data:ne[pe],collectionsDispatch:le,selectedCollectionsDispatch:we,selectedData:Re,setSaveDisabled:Se,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:U,pickerType:J,hideProductVariants:Q,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{Ee(!0),ze(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Ae})})),"view"===de&&t(I,{selectedCollections:Re||{},selectedCollectionsDispatch:we,setScreen:ae,collections:ne,hideProductVariants:Q,outOfStockAction:M,storeId:R,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===de&&t(y,{selectedCollections:Re||{},selectedCollectionsDispatch:we,setScreen:ae,outOfStockAction:M,rearrangeViewType:"grid"===ue?"list":"grid",scrollContainerRef:Ae,storeId:R,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===de&&t(j,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:Re||{},searchedCollections:Fe||{},searchedCollectionsDispatch:Te,selectedCollectionsDispatch:we,setScreen:ae,collections:ne,onBackPress:()=>{Ie(""),Te({type:"set",data:{collections:{},products:{}}})},pickerType:J,hideProductCheckbox:$,hideProductVariants:Q,hideVariantCheckbox:H,storeId:R,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:me,setSelectedCollectionId:ge,renderWithoutModal:U,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return t(o,{children:U?e(o,{children:[He,ce.renderFooter?e(O,{children:[$e(),t(a,{buttonText:Me(ce.primaryButtonText),disabled:!ce.isLoading&&(be||ve<1||L&&ve<L||!L&&z&&ve>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{T.onAdd(Re,ve),Ve(),ae([F.Collections,F.RearrangeProducts].includes(X)?X:F.Collections)}})]}):t(o,{}),Be&&Le?t(g,{productData:Le,outOfStockAction:M,useDynamicInfoImageSize:T.useDynamicInfoImageSize,onClose:()=>{Ee(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),Ve()},headingTitle:N||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:Y||"600px",left:K||"auto"},headerRightCustomElement:oe?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:re?Object.assign(Object.assign({},re),{disabled:!re.isLoading&&(be||ve<1||L&&ve<L||!L&&z&&ve>z)||re.disabled,onClick:()=>{T.onAdd(Re,ve),Ve(),ae([F.Collections,F.RearrangeProducts].includes(X)?X:F.Collections)}}):{buttonText:Me(),disabled:be||ve<1||L&&ve<L||!L&&z&&ve>z||!1,onClick:()=>{T.onAdd(Re,ve),Ve()}},secondaryButton:se?Object.assign(Object.assign({},se),{onClick:()=>{T.onAdd(Re,ve),Ve()}}):{},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?t(o,{}):$e(),hideCrossButton:Be||oe},{children:[He,Be&&Le?t(g,{productData:Le,useDynamicInfoImageSize:T.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Ee(!1)}}):t(o,{})]}))})};export{T 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 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 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 x,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=D.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:N,width:Y,left:K,renderWithoutModal:U,onClickSave:q,pickerType:J,hideProductVariants:Q=!1,startupScreen:X=F.Collections,rearrangeEnabled:Z,selectSingleItem:_=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:re,secondaryButton:se,subtitle:ie}=T,[ne,le]=r(b,{}),[de,ae]=s([F.Collections,F.RearrangeProducts].includes(X)?X:F.Collections),[ue,he]=s("grid"),[pe,me]=s(""),[Ce,ge]=s(""),[fe,ye]=s(0),[be,Se]=s(!1),[ve,ke]=s(0),[je,Ie]=s(""),[xe,Pe]=s(!1),[Oe,De]=s(!1),[Fe,Te]=r(S,{collections:{},products:{}}),[Re,we]=r(v,Object.keys(w).length>0?w:{}),Ae=i(null),[Be,Ee]=s(!1),[Le,ze]=s();n((()=>{Se(!0),De(!0),T.collectionFetcher(fe,R).then((e=>{le({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Se(!1),ye((e=>e+1)),De(!1)})).catch()}),[]),n((()=>{let e=0;Q?Object.keys(Re||[]).forEach((t=>{var o;Object.keys((null===(o=Re[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Re[-1]&&(null===(c=Re[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Re||[]).forEach((t=>{var o;Object.keys((null===(o=Re[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Re[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[ne,Re,Q]),n((()=>{Ce&&(Se(!0),T.productFetcher(Ce,R).then((e=>{Object.keys(e).length&&le({type:"productsFetched",data:{collectionId:Ce,products:e}}),Se(!1)})).catch())}),[Ce]),n((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(je.length||"collections"!==de)&&(je.length?(Pe(!0),T.searchFetcher(R,je).then((e=>{"collections"in e&&"products"in e?(Te({type:"set",data:e}),le({type:"searched",data:e.collections})):(Te({type:"set",data:{collections:{},products:e}}),le({type:"searched",data:e})),ae("searchProducts"),Se(!1),Pe(!1)}))):ae("collections"))}),800);return()=>clearTimeout(e)}),[je]),n((()=>{q&&(T.onAdd(Re,ve),Ve())}),[q]),n((()=>{_&&Object.keys(Re||{}).length&&ve&&(T.onAdd(Re,ve),Ve())}),[_,Re,ve]);const Ve=()=>{we({type:"reset",data:{}})},$e=()=>L&&ve>L?t(m,{tagText:`You can only select ${L} products`,type:"negative"}):z&&ve>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):t(a,ve>0?{onClick:()=>{ae(Z?F.RearrangeProducts:F.SelectedProducts)},buttonText:L?`${ve}/${L} products selected`:`${ve} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}:{disabled:!0,buttonText:L?`${ve}/${L} products selected`:`${ve} products selected`,buttonType:"tertiaryGray"}),Me=e=>be?"Loading...":de===F.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",He=e(x,Object.assign({style:null!=te?te:{}},{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===de||"searchProducts"===de)&&t("div",Object.assign({style:{padding:U?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search for collections and products, or type a product 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:je,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e(P,Object.assign({ref:Ae,screenName:de},{children:["collections"===de&&t(C,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:Oe,collections:ne,selectedCollectionsDispatch:we,setCollectionId:me,setSelectedCollectionId:ge,setScreen:ae,selectedCollections:Re,collectionFetcher:T.collectionFetcher,storeId:R,collectionsDispatch:le,setSaveDisabled:Se,pagingControls:{curPage:fe,setCurPage:ye},hideCollectionCheckbox:V,renderWithoutModal:U,pickerType:J,scrollContainerRef:Ae}),"products"===de&&pe&&t(k.Provider,Object.assign({value:pe},{children:t(f,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:ae,storeId:R,data:ne[pe],collectionsDispatch:le,selectedCollectionsDispatch:we,selectedData:Re,setSaveDisabled:Se,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:U,pickerType:J,hideProductVariants:Q,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{Ee(!0),ze(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Ae})})),"view"===de&&t(I,{selectedCollections:Re||{},selectedCollectionsDispatch:we,setScreen:ae,collections:ne,hideProductVariants:Q,outOfStockAction:M,storeId:R,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===de&&t(y,{selectedCollections:Re||{},selectedCollectionsDispatch:we,setScreen:ae,outOfStockAction:M,rearrangeViewType:"grid"===ue?"list":"grid",scrollContainerRef:Ae,storeId:R,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===de&&t(j,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:Re||{},searchedCollections:Fe||{},searchedCollectionsDispatch:Te,selectedCollectionsDispatch:we,setScreen:ae,collections:ne,onBackPress:()=>{Ie(""),Te({type:"set",data:{collections:{},products:{}}})},pickerType:J,hideProductCheckbox:$,hideProductVariants:Q,hideVariantCheckbox:H,storeId:R,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:me,setSelectedCollectionId:ge,renderWithoutModal:U,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return t(o,{children:U?e(o,{children:[He,ce.renderFooter?e(O,{children:[$e(),t(a,{buttonText:Me(ce.primaryButtonText),disabled:!ce.isLoading&&(be||ve<1||L&&ve<L||!L&&z&&ve>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{T.onAdd(Re,ve),Ve(),ae([F.Collections,F.RearrangeProducts].includes(X)?X:F.Collections)}})]}):t(o,{}),Be&&Le?t(g,{productData:Le,outOfStockAction:M,useDynamicInfoImageSize:T.useDynamicInfoImageSize,onClose:()=>{Ee(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),Ve()},headingTitle:N||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:Y||"600px",left:K||"auto"},headerRightCustomElement:oe?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:re?Object.assign(Object.assign({},re),{disabled:!re.isLoading&&(be||ve<1||L&&ve<L||!L&&z&&ve>z)||re.disabled,onClick:()=>{T.onAdd(Re,ve),Ve(),ae([F.Collections,F.RearrangeProducts].includes(X)?X:F.Collections)}}):{buttonText:Me(),disabled:be||ve<1||L&&ve<L||!L&&z&&ve>z||!1,onClick:()=>{T.onAdd(Re,ve),Ve()}},secondaryButton:se?Object.assign(Object.assign({},se),{onClick:()=>{T.onAdd(Re,ve,!0),Ve()}}):{},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?t(o,{}):$e(),hideCrossButton:Be||oe},{children:[He,Be&&Le?t(g,{productData:Le,useDynamicInfoImageSize:T.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Ee(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,F as ScreenName};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.640-2",
3
+ "version": "0.0.640-3",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",