@bikdotai/bik-component-library 0.0.552-beta.9 → 0.0.553-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.
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ALERT_TYPES, CONTENT_POSITION } from "./AlertHelper";
3
3
  export type AlertProps = {
4
4
  type: ALERT_TYPES;
5
- text: string;
5
+ text: string | React.ReactNode;
6
6
  icon?: React.FC<{
7
7
  width: number;
8
8
  height: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("./Alert.styled.js"),r=require("./AlertHelper.js"),s=require("../TypographyStyle.js");exports.Alert=i=>e.jsxs(t.AlertStyle,Object.assign({type:i.type,contentPosition:i.contentPosition,style:i.containerStyle},{children:[i.icon&&e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(i.icon,{color:r.COLOR_CONFIG_MAP[i.type].textColor,height:20,width:20})})),e.jsx(s.BodyCaption,Object.assign({style:{color:i.textColor||r.COLOR_CONFIG_MAP[i.type].textColor,marginLeft:12}},{children:i.text}))]}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("./Alert.styled.js"),r=require("./AlertHelper.js"),s=require("../TypographyStyle.js");exports.Alert=i=>e.jsxs(t.AlertStyle,Object.assign({type:i.type,contentPosition:i.contentPosition,style:i.containerStyle},{children:[i.icon&&e.jsx("div",Object.assign({style:{display:"flex",alignSelf:"flex-start"}},{children:e.jsx(i.icon,{color:r.COLOR_CONFIG_MAP[i.type].textColor,height:20,width:20})})),e.jsx(s.BodyCaption,Object.assign({style:{color:i.textColor||r.COLOR_CONFIG_MAP[i.type].textColor,marginLeft:12}},{children:i.text}))]}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../utils/StringUtils.js"),l=require("../../constants/Theme.js"),r=require("../../assets/icons/chevronDown.svg.js"),n=require("../../assets/icons/cross.svg.js"),i=require("../tag/Tag.js"),o=require("../TypographyStyle.js"),c=require("./Common.styled.js");exports.default=a=>{let{chips:d,onDeleteChip:h,containerStyle:g={},sizeToUse:u="default",isDropdownOpened:j,placeholder:p="Select.."}=a;const[x,O]=t.useState(),[b,y]=t.useState(0);return t.useEffect((()=>{if(!d||!(null==d?void 0:d.length))return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(d);let s=d.filter((s=>(e+=s.label.length,e<=t)));console.log("options",s),console.log("chips",d),O(s),y(d.length-s.length)}),[d]),e.jsxs(c.ChipInputWrapper,Object.assign({style:Object.assign({},g)},{children:[e.jsxs("div",Object.assign({className:"chips-container"},{children:[null==x?void 0:x.map(((t,l)=>e.jsx("div",Object.assign({style:{zIndex:2}},{children:e.jsx(i.Tag,Object.assign({tagText:s.default.truncateText(t.selectedLabel||t.label,40),TrailingIcon:()=>e.jsx(n.default,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{h(t)}})},{children:t.selectedLabel||t.label}))}),l))),!!b&&e.jsx(o.BodyCaption,Object.assign({color:l.COLORS.content.placeholder},{children:`+${b} more`})),0===d.length&&e.jsx("div",Object.assign({style:{color:l.COLORS.content.placeholder}},{children:p}))]})),e.jsx("div",{children:e.jsx(r.default,{style:{transform:j?"rotate(180deg)":"rotate(0deg)"},width:"small"===u?20:24,height:"small"===u?20:24,color:l.COLORS.content.primary})})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../utils/StringUtils.js"),l=require("../../constants/Theme.js"),r=require("../../assets/icons/chevronDown.svg.js"),n=require("../../assets/icons/cross.svg.js"),i=require("../tag/Tag.js"),o=require("../TypographyStyle.js"),c=require("./Common.styled.js");exports.default=a=>{let{chips:d,onDeleteChip:h,containerStyle:g={},sizeToUse:u="default",isDropdownOpened:j,placeholder:p="Select.."}=a;const[x,O]=t.useState(),[b,y]=t.useState(0);return t.useEffect((()=>{if(!d)return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(d);let s=d.filter((s=>(e+=s.label.length,e<=t)));console.log("test options",s),console.log("test chips",d),0===s.length&&d.length>0&&(s=[d[0]]),O(s),y(d.length-s.length)}),[d]),e.jsxs(c.ChipInputWrapper,Object.assign({style:Object.assign({},g)},{children:[e.jsxs("div",Object.assign({className:"chips-container"},{children:[null==x?void 0:x.map(((t,l)=>e.jsx("div",Object.assign({style:{zIndex:2}},{children:e.jsx(i.Tag,Object.assign({tagText:s.default.truncateText(t.selectedLabel||t.label,40),TrailingIcon:()=>e.jsx(n.default,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{h(t)}})},{children:t.selectedLabel||t.label}))}),l))),!!b&&e.jsx(o.BodyCaption,Object.assign({color:l.COLORS.content.placeholder},{children:`+${b} more`})),0===d.length&&e.jsx("div",Object.assign({style:{color:l.COLORS.content.placeholder}},{children:p}))]})),e.jsx("div",{children:e.jsx(r.default,{style:{transform:j?"rotate(180deg)":"rotate(0deg)"},width:"small"===u?20:24,height:"small"===u?20:24,color:l.COLORS.content.primary})})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),i=require("./IconButton.styled.js"),o=require("./theme.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(r);const n=r.forwardRef(((r,s)=>{var{id:n,iconButtonType:l="default",Icon:c,height:u=20,width:a=20,bordered:y,disabled:b,isSelected:h,style:f,svgStyle:j}=r,p=e.__rest(r,["id","iconButtonType","Icon","height","width","bordered","disabled","isSelected","style","svgStyle"]);const g=o.getIconColor(l,b,h);return t.jsx(i.IconButton,Object.assign({id:n,ref:s,style:f,iconButtonType:l,bordered:y,disabled:b,isSelected:h},p,{children:d.default.createElement(c,{height:u,width:a,color:g,style:Object.assign({display:"block"},null!=j?j:{})})}))}));n.displayName="IconButton",exports.IconButton=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),o=require("./IconButton.styled.js"),i=require("./theme.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(r);const d=r.forwardRef(((r,n)=>{var{id:d,iconButtonType:l="default",Icon:c,height:u=20,width:a=20,bordered:y,disabled:b,isSelected:h,style:f,svgStyle:j,iconColor:p}=r,g=e.__rest(r,["id","iconButtonType","Icon","height","width","bordered","disabled","isSelected","style","svgStyle","iconColor"]);const v=i.getIconColor(l,b,h);return t.jsx(o.IconButton,Object.assign({id:d,ref:n,style:f,iconButtonType:l,bordered:y,disabled:b,isSelected:h},g,{children:s.default.createElement(c,{height:u,width:a,color:p||v,style:Object.assign({display:"block"},null!=j?j:{})})}))}));d.displayName="IconButton",exports.IconButton=d;
@@ -39,4 +39,5 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
39
39
  * Flag to check if icon button is selected/clicked
40
40
  */
41
41
  isSelected?: boolean;
42
+ iconColor?: string;
42
43
  }
@@ -82,6 +82,7 @@ export type ProductPickerInterface = {
82
82
  title?: string;
83
83
  postHeader?: React.ReactNode;
84
84
  width?: string;
85
+ left?: string;
85
86
  renderWithoutModal?: boolean;
86
87
  onClickSave?: number;
87
88
  pickerType?: 'COLLECTION' | 'PRODUCT';
@@ -91,6 +92,7 @@ export type ProductPickerInterface = {
91
92
  stickyFooter?: boolean;
92
93
  showProductDetails?: boolean;
93
94
  containerStyle?: React.CSSProperties;
95
+ crossButtonInsideHeader?: boolean;
94
96
  } & ({
95
97
  startupScreen: ScreenName.RearrangeProducts;
96
98
  rearrangeEnabled: true;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),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("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),l=require("../input/Input.js"),i=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),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:f,selectedItems:b,onClose:m,visible:v,zIndex:P,exactLimit:k,limit:O,hideCollectionCheckbox:I,hideProductCheckbox:F,outOfStockAction:R=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:q,hideSelectionCount:E,title:D,width:w,left:N,renderWithoutModal:A,onClickSave:B,pickerType:L,hideProductVariants:M=!1,startupScreen:V=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:_=!1,showProductDetails:z,containerStyle:H,crossButtonInsideHeader:W=!1}=e,[G,K]=c.useReducer(C.collectionsReducer,{}),[U,Y]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(V)?V:exports.ScreenName.Collections),[J,Q]=c.useState("grid"),[X,Z]=c.useState(""),[ee,te]=c.useState(""),[oe,ce]=c.useState(0),[re,se]=c.useState(!1),[ne,le]=c.useState(0),[ie,ae]=c.useState(""),[de,ue]=c.useState(!1),[he,pe]=c.useState(!1),[Se,Ce]=c.useReducer(C.searchReducer,{collections:{},products:{}}),[xe,ge]=c.useReducer(C.selectedColectionsReducer,Object.keys(b).length>0?b:{}),je=c.useRef(null),[ye,fe]=c.useState(!1),[be,me]=c.useState();c.useEffect((()=>{se(!0),pe(!0),e.collectionFetcher(oe,f).then((e=>{K({type:"fetched",data:(null==e?void 0:e.collections)||{}}),se(!1),ce((e=>e+1)),pe(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;M?Object.keys(xe||[]).forEach((t=>{var o;Object.keys((null===(o=xe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&xe[-1]&&(null===(c=xe[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(xe||[]).forEach((t=>{var o;Object.keys((null===(o=xe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=xe[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),le(e)}),[G,xe,M]),c.useEffect((()=>{ee&&(se(!0),e.productFetcher(ee,f).then((e=>{Object.keys(e).length&&K({type:"productsFetched",data:{collectionId:ee,products:e}}),se(!1)})).catch())}),[ee]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==U&&(ie.length||"collections"!==U)&&(ie.length?(ue(!0),e.searchFetcher(f,ie).then((e=>{"collections"in e&&"products"in e?(Ce({type:"set",data:e}),K({type:"searched",data:e.collections})):(Ce({type:"set",data:{collections:{},products:e}}),K({type:"searched",data:e})),Y("searchProducts"),se(!1),ue(!1)}))):Y("collections"))}),800);return()=>clearTimeout(t)}),[ie]),c.useEffect((()=>{B&&(e.onAdd(xe,ne),ve())}),[B]),c.useEffect((()=>{_&&Object.keys(xe||{}).length&&ne&&(e.onAdd(xe,ne),ve())}),[_,xe,ne]);const ve=()=>{ge({type:"reset",data:{}})},Pe=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"===U||"searchProducts"===U)&&t.jsx("div",Object.assign({style:{padding:A?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(l.Input,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>de?t.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:ie,onChangeText:e=>{e.length&&e.trim().length?ae(e):ae("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:je,screenName:U},{children:["collections"===U&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:he,collections:G,selectedCollectionsDispatch:ge,setCollectionId:Z,setSelectedCollectionId:te,setScreen:Y,selectedCollections:xe,collectionFetcher:e.collectionFetcher,storeId:f,collectionsDispatch:K,setSaveDisabled:se,pagingControls:{curPage:oe,setCurPage:ce},hideCollectionCheckbox:I,renderWithoutModal:A,pickerType:L,scrollContainerRef:je}),"products"===U&&X&&t.jsx(C.CollectionIdContext.Provider,Object.assign({value:X},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:Y,storeId:f,data:G[X],collectionsDispatch:K,selectedCollectionsDispatch:ge,selectedData:xe,setSaveDisabled:se,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:R,hideVariantCheckbox:T,selectProductsFromCustomCollection:q,renderWithoutModal:A,pickerType:L,hideProductVariants:M,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{fe(!0),me(e)},showProductDetailInfoIcon:z,scrollContainerRef:je})})),"view"===U&&t.jsx(g.SelectedScreen,{selectedCollections:xe||{},selectedCollectionsDispatch:ge,setScreen:Y,collections:G,hideProductVariants:M,outOfStockAction:R,storeId:f,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===U&&t.jsx(S.RearrangeScreen,{selectedCollections:xe||{},selectedCollectionsDispatch:ge,setScreen:Y,outOfStockAction:R,rearrangeViewType:"grid"===J?"list":"grid",scrollContainerRef:je,storeId:f,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===U&&t.jsx(x.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:xe||{},searchedCollections:Se||{},searchedCollectionsDispatch:Ce,selectedCollectionsDispatch:ge,setScreen:Y,collections:G,onBackPress:()=>{ae(""),Ce({type:"set",data:{collections:{},products:{}}})},pickerType:L,hideProductCheckbox:F,hideProductVariants:M,hideVariantCheckbox:T,storeId:f,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Z,setSelectedCollectionId:te,renderWithoutModal:A,hideCollectionCheckbox:I,outOfStockAction:R})]}))]}));return t.jsx(t.Fragment,{children:A?Pe:t.jsxs(i.StyledModal,Object.assign({zIndex:P,open:v,onClose:()=>{null==m||m(),ve()},headingTitle:D||("collections"===U||"products"===U?"Select Products":"view"===U?"Selected Products":"searchProducts"===U?"Searched Results":"rearrange"===U?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:w||"600px",left:N||"auto"},headerRightCustomElement:W?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:m},{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:{buttonText:re?"Loading...":U===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:re||ne<1||k&&ne<k||!k&&O&&ne>O||!1,onClick:()=>{e.onAdd(xe,ne),ve()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:E?t.jsx(t.Fragment,{}):k&&ne>k?t.jsx(d.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):O&&ne>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):ne>0?t.jsx(n.Button,{onClick:()=>{Y($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:k?`${ne}/${k} products selected`:`${ne} products selected`,buttonType:["rearrange","view"].includes(U)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(U)}):t.jsx(n.Button,{disabled:!0,buttonText:k?`${ne}/${k} products selected`:`${ne} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:ye||W},{children:[Pe,ye&&be?t.jsx(h.ProductInfoOverlay,{productData:be,outOfStockAction:R,onClose:()=>{fe(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -213,7 +213,7 @@ export interface IMimeTypeResponse {
213
213
  export type WhatsAppPickerMeta = {
214
214
  uploadMediaFiles: (params: WhatsAppMediaUploadRequest, index?: number) => Promise<WhatsAppMediaUploadResponse>;
215
215
  uploadMediaLink?: (link: string) => Promise<MediaLinkUploadResponse>;
216
- validateMimeType: (file: File | Blob) => Promise<IMimeTypeResponse>;
216
+ validateMimeType?: (file: File | Blob) => Promise<IMimeTypeResponse>;
217
217
  CTAoptions?: ButtonPlaceHolderOptions[];
218
218
  QRBoptions?: ButtonPlaceHolderOptions[];
219
219
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ALERT_TYPES, CONTENT_POSITION } from "./AlertHelper";
3
3
  export type AlertProps = {
4
4
  type: ALERT_TYPES;
5
- text: string;
5
+ text: string | React.ReactNode;
6
6
  icon?: React.FC<{
7
7
  width: number;
8
8
  height: number;
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import{AlertStyle as o}from"./Alert.styled.js";import{COLOR_CONFIG_MAP as r}from"./AlertHelper.js";import{BodyCaption as i}from"../TypographyStyle.js";const l=l=>t(o,Object.assign({type:l.type,contentPosition:l.contentPosition,style:l.containerStyle},{children:[l.icon&&e("div",Object.assign({style:{display:"flex"}},{children:e(l.icon,{color:r[l.type].textColor,height:20,width:20})})),e(i,Object.assign({style:{color:l.textColor||r[l.type].textColor,marginLeft:12}},{children:l.text}))]}));export{l as Alert};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import{AlertStyle as o}from"./Alert.styled.js";import{COLOR_CONFIG_MAP as r}from"./AlertHelper.js";import{BodyCaption as i}from"../TypographyStyle.js";const l=l=>t(o,Object.assign({type:l.type,contentPosition:l.contentPosition,style:l.containerStyle},{children:[l.icon&&e("div",Object.assign({style:{display:"flex",alignSelf:"flex-start"}},{children:e(l.icon,{color:r[l.type].textColor,height:20,width:20})})),e(i,Object.assign({style:{color:l.textColor||r[l.type].textColor,marginLeft:12}},{children:l.text}))]}));export{l as Alert};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useEffect as l}from"react";import s from"../../utils/StringUtils.js";import{COLORS as n}from"../../constants/Theme.js";import r from"../../assets/icons/chevronDown.svg.js";import i from"../../assets/icons/cross.svg.js";import{Tag as c}from"../tag/Tag.js";import{BodyCaption as a}from"../TypographyStyle.js";import{ChipInputWrapper as h}from"./Common.styled.js";const m=m=>{let{chips:d,onDeleteChip:g,containerStyle:p={},sizeToUse:j="default",isDropdownOpened:f,placeholder:b="Select.."}=m;const[y,u]=o(),[v,O]=o(0);return l((()=>{if(!d||!(null==d?void 0:d.length))return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(d);let o=d.filter((o=>(e+=o.label.length,e<=t)));console.log("options",o),console.log("chips",d),u(o),O(d.length-o.length)}),[d]),e(h,Object.assign({style:Object.assign({},p)},{children:[e("div",Object.assign({className:"chips-container"},{children:[null==y?void 0:y.map(((e,o)=>t("div",Object.assign({style:{zIndex:2}},{children:t(c,Object.assign({tagText:s.truncateText(e.selectedLabel||e.label,40),TrailingIcon:()=>t(i,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{g(e)}})},{children:e.selectedLabel||e.label}))}),o))),!!v&&t(a,Object.assign({color:n.content.placeholder},{children:`+${v} more`})),0===d.length&&t("div",Object.assign({style:{color:n.content.placeholder}},{children:b}))]})),t("div",{children:t(r,{style:{transform:f?"rotate(180deg)":"rotate(0deg)"},width:"small"===j?20:24,height:"small"===j?20:24,color:n.content.primary})})]}))};export{m as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as s,useEffect as o}from"react";import l from"../../utils/StringUtils.js";import{COLORS as n}from"../../constants/Theme.js";import r from"../../assets/icons/chevronDown.svg.js";import i from"../../assets/icons/cross.svg.js";import{Tag as c}from"../tag/Tag.js";import{BodyCaption as a}from"../TypographyStyle.js";import{ChipInputWrapper as h}from"./Common.styled.js";const g=g=>{let{chips:m,onDeleteChip:d,containerStyle:p={},sizeToUse:j="default",isDropdownOpened:f,placeholder:b="Select.."}=g;const[y,u]=s(),[v,O]=s(0);return o((()=>{if(!m)return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(m);let s=m.filter((s=>(e+=s.label.length,e<=t)));console.log("test options",s),console.log("test chips",m),0===s.length&&m.length>0&&(s=[m[0]]),u(s),O(m.length-s.length)}),[m]),e(h,Object.assign({style:Object.assign({},p)},{children:[e("div",Object.assign({className:"chips-container"},{children:[null==y?void 0:y.map(((e,s)=>t("div",Object.assign({style:{zIndex:2}},{children:t(c,Object.assign({tagText:l.truncateText(e.selectedLabel||e.label,40),TrailingIcon:()=>t(i,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{d(e)}})},{children:e.selectedLabel||e.label}))}),s))),!!v&&t(a,Object.assign({color:n.content.placeholder},{children:`+${v} more`})),0===m.length&&t("div",Object.assign({style:{color:n.content.placeholder}},{children:b}))]})),t("div",{children:t(r,{style:{transform:f?"rotate(180deg)":"rotate(0deg)"},width:"small"===j?20:24,height:"small"===j?20:24,color:n.content.primary})})]}))};export{g as default};
@@ -1 +1 @@
1
- import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import o,{forwardRef as i}from"react";import{IconButton as r}from"./IconButton.styled.js";import{getIconColor as s}from"./theme.js";const d=i(((i,d)=>{var{id:l,iconButtonType:n="default",Icon:c,height:a=20,width:m=20,bordered:y,disabled:h,isSelected:p,style:u,svgStyle:b}=i,f=e(i,["id","iconButtonType","Icon","height","width","bordered","disabled","isSelected","style","svgStyle"]);const g=s(n,h,p);return t(r,Object.assign({id:l,ref:d,style:u,iconButtonType:n,bordered:y,disabled:h,isSelected:p},f,{children:o.createElement(c,{height:a,width:m,color:g,style:Object.assign({display:"block"},null!=b?b:{})})}))}));d.displayName="IconButton";export{d as IconButton};
1
+ import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import o,{forwardRef as i}from"react";import{IconButton as r}from"./IconButton.styled.js";import{getIconColor as s}from"./theme.js";const d=i(((i,d)=>{var{id:l,iconButtonType:n="default",Icon:c,height:a=20,width:m=20,bordered:y,disabled:h,isSelected:p,style:u,svgStyle:b,iconColor:f}=i,g=e(i,["id","iconButtonType","Icon","height","width","bordered","disabled","isSelected","style","svgStyle","iconColor"]);const j=s(n,h,p);return t(r,Object.assign({id:l,ref:d,style:u,iconButtonType:n,bordered:y,disabled:h,isSelected:p},g,{children:o.createElement(c,{height:a,width:m,color:f||j,style:Object.assign({display:"block"},null!=b?b:{})})}))}));d.displayName="IconButton";export{d as IconButton};
@@ -39,4 +39,5 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
39
39
  * Flag to check if icon button is selected/clicked
40
40
  */
41
41
  isSelected?: boolean;
42
+ iconColor?: string;
42
43
  }
@@ -82,6 +82,7 @@ export type ProductPickerInterface = {
82
82
  title?: string;
83
83
  postHeader?: React.ReactNode;
84
84
  width?: string;
85
+ left?: string;
85
86
  renderWithoutModal?: boolean;
86
87
  onClickSave?: number;
87
88
  pickerType?: 'COLLECTION' | 'PRODUCT';
@@ -91,6 +92,7 @@ export type ProductPickerInterface = {
91
92
  stickyFooter?: boolean;
92
93
  showProductDetails?: boolean;
93
94
  containerStyle?: React.CSSProperties;
95
+ crossButtonInsideHeader?: boolean;
94
96
  } & ({
95
97
  startupScreen: ScreenName.RearrangeProducts;
96
98
  rearrangeEnabled: true;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as 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 i,useEffect as l}from"react";import{COLORS as n}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 P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as I}from"./style.js";import{OUT_OF_STOCK_ACTION as F}from"./type.js";var O;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(O||(O={}));const T=T=>{const{storeId:D,selectedItems:R,onClose:w,visible:E,zIndex:A,exactLimit:V,limit:$,hideCollectionCheckbox:B,hideProductCheckbox:L,outOfStockAction:M=F.BLUR,hideVariantCheckbox:z,selectProductsFromCustomCollection:H,hideSelectionCount:W,title:G,width:Y,left:K,renderWithoutModal:N,onClickSave:U,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=O.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:_,containerStyle:ee,crossButtonInsideHeader:te=!1}=T,[oe,ce]=r(b,{}),[re,se]=s([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections),[ie,le]=s("grid"),[ne,de]=s(""),[ae,ue]=s(""),[he,pe]=s(0),[me,Ce]=s(!1),[ge,fe]=s(0),[ye,be]=s(""),[Se,ve]=s(!1),[ke,je]=s(!1),[Pe,xe]=r(S,{collections:{},products:{}}),[Ie,Fe]=r(v,Object.keys(R).length>0?R:{}),Oe=i(null),[Te,De]=s(!1),[Re,we]=s();l((()=>{Ce(!0),je(!0),T.collectionFetcher(he,D).then((e=>{ce({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Ce(!1),pe((e=>e+1)),je(!1)})).catch()}),[]),l((()=>{let e=0;J?Object.keys(Ie||[]).forEach((t=>{var o;Object.keys((null===(o=Ie[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Ie[-1]&&(null===(c=Ie[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Ie||[]).forEach((t=>{var o;Object.keys((null===(o=Ie[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Ie[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),fe(e)}),[oe,Ie,J]),l((()=>{ae&&(Ce(!0),T.productFetcher(ae,D).then((e=>{Object.keys(e).length&&ce({type:"productsFetched",data:{collectionId:ae,products:e}}),Ce(!1)})).catch())}),[ae]),l((()=>{const e=setTimeout((()=>{"rearrange"!==re&&(ye.length||"collections"!==re)&&(ye.length?(ve(!0),T.searchFetcher(D,ye).then((e=>{"collections"in e&&"products"in e?(xe({type:"set",data:e}),ce({type:"searched",data:e.collections})):(xe({type:"set",data:{collections:{},products:e}}),ce({type:"searched",data:e})),se("searchProducts"),Ce(!1),ve(!1)}))):se("collections"))}),800);return()=>clearTimeout(e)}),[ye]),l((()=>{U&&(T.onAdd(Ie,ge),Ee())}),[U]),l((()=>{Z&&Object.keys(Ie||{}).length&&ge&&(T.onAdd(Ie,ge),Ee())}),[Z,Ie,ge]);const Ee=()=>{Fe({type:"reset",data:{}})},Ae=e(x,Object.assign({style:null!=ee?ee:{}},{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===re||"searchProducts"===re)&&t("div",Object.assign({style:{padding:N?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search Collections or Products",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?t(p,{size:"small",color:n.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:ye,onChangeText:e=>{e.length&&e.trim().length?be(e):be("")}})}))}),e(I,Object.assign({ref:Oe,screenName:re},{children:["collections"===re&&t(C,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:ke,collections:oe,selectedCollectionsDispatch:Fe,setCollectionId:de,setSelectedCollectionId:ue,setScreen:se,selectedCollections:Ie,collectionFetcher:T.collectionFetcher,storeId:D,collectionsDispatch:ce,setSaveDisabled:Ce,pagingControls:{curPage:he,setCurPage:pe},hideCollectionCheckbox:B,renderWithoutModal:N,pickerType:q,scrollContainerRef:Oe}),"products"===re&&ne&&t(k.Provider,Object.assign({value:ne},{children:t(f,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:se,storeId:D,data:oe[ne],collectionsDispatch:ce,selectedCollectionsDispatch:Fe,selectedData:Ie,setSaveDisabled:Ce,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:L,outOfStockAction:M,hideVariantCheckbox:z,selectProductsFromCustomCollection:H,renderWithoutModal:N,pickerType:q,hideProductVariants:J,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{De(!0),we(e)},showProductDetailInfoIcon:_,scrollContainerRef:Oe})})),"view"===re&&t(P,{selectedCollections:Ie||{},selectedCollectionsDispatch:Fe,setScreen:se,collections:oe,hideProductVariants:J,outOfStockAction:M,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===re&&t(y,{selectedCollections:Ie||{},selectedCollectionsDispatch:Fe,setScreen:se,outOfStockAction:M,rearrangeViewType:"grid"===ie?"list":"grid",scrollContainerRef:Oe,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===re&&t(j,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:Ie||{},searchedCollections:Pe||{},searchedCollectionsDispatch:xe,selectedCollectionsDispatch:Fe,setScreen:se,collections:oe,onBackPress:()=>{be(""),xe({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:L,hideProductVariants:J,hideVariantCheckbox:z,storeId:D,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:de,setSelectedCollectionId:ue,renderWithoutModal:N,hideCollectionCheckbox:B,outOfStockAction:M})]}))]}));return t(o,{children:N?Ae:e(h,Object.assign({zIndex:A,open:E,onClose:()=>{null==w||w(),Ee()},headingTitle:G||("collections"===re||"products"===re?"Select Products":"view"===re?"Selected Products":"searchProducts"===re?"Searched Results":"rearrange"===re?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:Y||"600px",left:K||"auto"},headerRightCustomElement:te?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:w},{children:t(d,{width:20,height:20,color:n.content.secondary})})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:{buttonText:me?"Loading...":re===O.RearrangeProducts?"Done":"Add",disabled:me||ge<1||V&&ge<V||!V&&$&&ge>$||!1,onClick:()=>{T.onAdd(Ie,ge),Ee()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):V&&ge>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):$&&ge>$?t(m,{tagText:`You can only select ${$} products`,type:"negative"}):t(a,ge>0?{onClick:()=>{se(X?O.RearrangeProducts:O.SelectedProducts)},buttonText:V?`${ge}/${V} products selected`:`${ge} products selected`,buttonType:["rearrange","view"].includes(re)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(re)}:{disabled:!0,buttonText:V?`${ge}/${V} products selected`:`${ge} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Te||te},{children:[Ae,Te&&Re?t(g,{productData:Re,outOfStockAction:M,onClose:()=>{De(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,O as ScreenName};
@@ -213,7 +213,7 @@ export interface IMimeTypeResponse {
213
213
  export type WhatsAppPickerMeta = {
214
214
  uploadMediaFiles: (params: WhatsAppMediaUploadRequest, index?: number) => Promise<WhatsAppMediaUploadResponse>;
215
215
  uploadMediaLink?: (link: string) => Promise<MediaLinkUploadResponse>;
216
- validateMimeType: (file: File | Blob) => Promise<IMimeTypeResponse>;
216
+ validateMimeType?: (file: File | Blob) => Promise<IMimeTypeResponse>;
217
217
  CTAoptions?: ButtonPlaceHolderOptions[];
218
218
  QRBoptions?: ButtonPlaceHolderOptions[];
219
219
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.552-beta.9",
3
+ "version": "0.0.553-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",