@bikdotai/bik-component-library 0.0.665-beta.0 → 0.0.665-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.
- package/dist/cjs/components/avatar/Avatar.d.ts +0 -1
- package/dist/cjs/components/avatar/Avatar.js +1 -1
- package/dist/cjs/components/avatar/Avatar.styled.js +4 -4
- package/dist/cjs/components/avatar/AvatarHelper.d.ts +1 -2
- package/dist/cjs/components/avatar/AvatarHelper.js +1 -1
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/utility.js +1 -1
- package/dist/esm/components/avatar/Avatar.d.ts +0 -1
- package/dist/esm/components/avatar/Avatar.js +1 -1
- package/dist/esm/components/avatar/Avatar.styled.js +2 -2
- package/dist/esm/components/avatar/AvatarHelper.d.ts +1 -2
- package/dist/esm/components/avatar/AvatarHelper.js +1 -1
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/utility.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("./Avatar.styled.js"),i=require("./AvatarHelper.js"),r=require("../TypographyStyle.js"),a=require("../../constants/Theme.js"),o=require("../../assets/icons/bik_livechat.svg.js"),n=require("../../assets/icons/CheckSquareOffset.svg.js"),A=require("../../assets/icons/email-channel.svg.js"),S=require("../../assets/icons/facebook_channel.svg.js"),c=require("../../assets/icons/gmail.svg.js"),l=require("../../assets/icons/instagram-channel.svg.js"),E=require("../../assets/icons/whatsapp_color.svg.js");const d={[i.SIZE.SMALL]:16,[i.SIZE.MEDIUM]:20,[i.SIZE.INBOX]:24,[i.SIZE.LARGE]:32},u={[i.AVATAR_BACKGROUND.LIGHT]:a.COLORS.content.secondary,[i.AVATAR_BACKGROUND.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("./Avatar.styled.js"),i=require("./AvatarHelper.js"),r=require("../TypographyStyle.js"),a=require("../../constants/Theme.js"),o=require("../../assets/icons/bik_livechat.svg.js"),n=require("../../assets/icons/CheckSquareOffset.svg.js"),A=require("../../assets/icons/email-channel.svg.js"),S=require("../../assets/icons/facebook_channel.svg.js"),c=require("../../assets/icons/gmail.svg.js"),l=require("../../assets/icons/instagram-channel.svg.js"),E=require("../../assets/icons/whatsapp_color.svg.js");const d={[i.SIZE.SMALL]:16,[i.SIZE.MEDIUM]:20,[i.SIZE.INBOX]:24,[i.SIZE.LARGE]:32},u={[i.AVATAR_BACKGROUND.LIGHT]:a.COLORS.content.secondary,[i.AVATAR_BACKGROUND.DARK]:a.COLORS.surface.standard};var h;exports.MESSAGE_CHANNELS=void 0,(h=exports.MESSAGE_CHANNELS||(exports.MESSAGE_CHANNELS={})).INSTAGRAM="instagram",h.MESSENGER="messenger",h.WHATSAPP="whatsapp",h.GMAIL="gmail",h.LIVECHAT="livechat",h.GOOGLE_BUSINESS_CHAT="gbm",h.SHOPIFY="shopify",h.FACEBOOK="facebook",h.EMAIL="email",h.SMTP="smtp",h.FACEBOOK_CATALOG="facebook-catalog",h.TASKS="tasks",h.BIK_LIVECHAT="livechat";exports.AVATAR_SIZE_VS_ICON_SIZE_MAP=d,exports.Avatar=h=>{const[p,g]=s.useState(!1),x=()=>{const s=(h.name||"").split(".").join(" ").split(" ").map((e=>e.charAt(0).toUpperCase())).slice(0,2).join("");return h.size===i.SIZE.SMALL?e.jsx(r.BodyTiny,Object.assign({style:{color:u[h.background]}},{children:s})):h.size===i.SIZE.MEDIUM||h.size===i.SIZE.INBOX?e.jsx(r.TitleSmall,Object.assign({style:{color:u[h.background]}},{children:s})):h.size===i.SIZE.LARGE?e.jsx(r.TitleMedium,Object.assign({style:{color:u[h.background]}},{children:s})):void 0};return e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[e.jsxs(t.AvatarStyle,Object.assign({type:h.type===i.AVATAR_TYPES.IMAGE&&p&&h.useNameFallback&&h.name?i.AVATAR_TYPES.INITIALS:h.type,size:h.size,background:h.background},{children:[h.type===i.AVATAR_TYPES.IMAGE&&(h.useNameFallback&&!p?e.jsx("img",{alt:"",width:i.AVATAR_SIZE_MAP[h.size],height:i.AVATAR_SIZE_MAP[h.size],style:{borderRadius:(null==h?void 0:h.borderRadius)||"50%",objectFit:"contain"},src:h.photoUrl,onError:()=>{g(!0)}}):h.useNameFallback&&p&&h.name?e.jsx("div",{children:x()}):e.jsx("img",{alt:"",width:i.AVATAR_SIZE_MAP[h.size],height:i.AVATAR_SIZE_MAP[h.size],style:{borderRadius:(null==h?void 0:h.borderRadius)||"50%",objectFit:"contain"},src:h.photoUrl})),h.type===i.AVATAR_TYPES.INITIALS&&e.jsx("div",{children:x()}),h.type===i.AVATAR_TYPES.ICON&&h.icon&&e.jsx(h.icon,{width:d[h.size],height:d[h.size],color:u[h.background]})]})),h.inboxSettings&&e.jsx("div",Object.assign({style:{position:"absolute",left:d[h.size]+"px",top:d[h.size]+"px",width:14,height:14,borderRadius:(null==h?void 0:h.borderRadius)||"50%",display:"flex",justifyContent:"center",backgroundColor:h.inboxSettings.isSelected?h.inboxSettings.isComments?a.COLORS.content.primary:a.COLORS.background.brandLight:h.inboxSettings.isComments?a.COLORS.content.primary:a.COLORS.surface.standard,alignItems:"center"}},{children:(()=>{switch(h.channelName){case exports.MESSAGE_CHANNELS.EMAIL:case exports.MESSAGE_CHANNELS.SMTP:return e.jsx(A.default,{width:11,height:11});case exports.MESSAGE_CHANNELS.FACEBOOK:case exports.MESSAGE_CHANNELS.FACEBOOK_CATALOG:case exports.MESSAGE_CHANNELS.MESSENGER:return e.jsx(S.default,{width:11,height:11});case exports.MESSAGE_CHANNELS.INSTAGRAM:return e.jsx(l.default,{width:11,height:11});case exports.MESSAGE_CHANNELS.WHATSAPP:return e.jsx(E.default,{width:11,height:11});case exports.MESSAGE_CHANNELS.GMAIL:return e.jsx(c.default,{width:11,height:11});case exports.MESSAGE_CHANNELS.TASKS:return e.jsx(n.default,{width:11,height:11});case exports.MESSAGE_CHANNELS.BIK_LIVECHAT:return e.jsx(o.default,{width:11,height:11})}})()})),h.status&&e.jsx("div",Object.assign({style:{position:"absolute",left:d[h.size]+"px",top:d[h.size]+"px",width:11,height:11,borderRadius:"50%",display:"flex",justifyContent:"center",backgroundColor:a.COLORS.surface.standard,alignItems:"center"}},{children:h.status?e.jsx("div",{style:{backgroundColor:"ONLINE"===h.status?a.COLORS.special.whatsapp.brand:a.COLORS.content.inactive,width:"8px",height:"8px",borderRadius:"50%"}}):null}))]}))},exports.BACKGROUND_VS_TEXT_COLOR_MAP=u;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("./AvatarHelper.js"),t=require("../../constants/Theme.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("./AvatarHelper.js"),t=require("../../constants/Theme.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const n=o(e).default.div`
|
|
2
2
|
width: ${e=>r.AVATAR_SIZE_MAP[e.size]+"px"};
|
|
3
3
|
height: ${e=>r.AVATAR_SIZE_MAP[e.size]+"px"};
|
|
4
4
|
display: flex;
|
|
5
5
|
justify-content: center;
|
|
6
6
|
align-items: center;
|
|
7
|
-
background-color: ${e=>e.type===r.AVATAR_TYPES.IMAGE?"null":e.background===r.AVATAR_BACKGROUND.LIGHT?t.COLORS.background.base:
|
|
8
|
-
border: ${e=>e.background===r.AVATAR_BACKGROUND.LIGHT
|
|
7
|
+
background-color: ${e=>e.type===r.AVATAR_TYPES.IMAGE?"null":e.background===r.AVATAR_BACKGROUND.LIGHT?t.COLORS.background.base:t.COLORS.background.inverse};
|
|
8
|
+
border: ${e=>e.background===r.AVATAR_BACKGROUND.LIGHT?"1px solid "+t.COLORS.stroke.primary:0};
|
|
9
9
|
border-radius: 50%;
|
|
10
|
-
`;exports.AvatarStyle=
|
|
10
|
+
`;exports.AvatarStyle=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var A,I,e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AVATAR_TYPES=void 0,(A=exports.AVATAR_TYPES||(exports.AVATAR_TYPES={})).IMAGE="IMAGE",A.INITIALS="INITIALS",A.ICON="ICON",exports.SIZE=void 0,(I=exports.SIZE||(exports.SIZE={})).SMALL="SMALL",I.MEDIUM="MEDIUM",I.LARGE="LARGE",I.INBOX="INBOX",exports.AVATAR_BACKGROUND=void 0,(e=exports.AVATAR_BACKGROUND||(exports.AVATAR_BACKGROUND={})).LIGHT="LIGHT",e.DARK="DARK"
|
|
1
|
+
"use strict";var A,I,e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AVATAR_TYPES=void 0,(A=exports.AVATAR_TYPES||(exports.AVATAR_TYPES={})).IMAGE="IMAGE",A.INITIALS="INITIALS",A.ICON="ICON",exports.SIZE=void 0,(I=exports.SIZE||(exports.SIZE={})).SMALL="SMALL",I.MEDIUM="MEDIUM",I.LARGE="LARGE",I.INBOX="INBOX",exports.AVATAR_BACKGROUND=void 0,(e=exports.AVATAR_BACKGROUND||(exports.AVATAR_BACKGROUND={})).LIGHT="LIGHT",e.DARK="DARK";const o={[exports.SIZE.SMALL]:24,[exports.SIZE.MEDIUM]:40,[exports.SIZE.LARGE]:64,[exports.SIZE.INBOX]:30};exports.AVATAR_SIZE_MAP=o;
|
|
@@ -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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),C=require("./reducers.js"),g=require("./searchScreen.js"),x=require("./selectedScreen.js"),j=require("./style.js"),y=require("./type.js"),m=require("./utility.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:b,selectedItems:f,onClose:v,visible:k,zIndex:I,exactLimit:P,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:R,outOfStockAction:D=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:T,selectProductsFromCustomCollection:N,hideSelectionCount:q,title:A,width:E,left:w,renderWithoutModal:B,onClickSave:L,pickerType:M,hideProductVariants:V=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:_=!1,showProductDetails:H,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:K={},primaryButton:U,secondaryButton:Y,subtitle:J}=e,[Q,X]=c.useReducer(C.collectionsReducer,{}),[Z,ee]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[te,oe]=c.useState("grid"),[ce,se]=c.useState(""),[re,ne]=c.useState(""),[ie,le]=c.useState(0),[ae,de]=c.useState(!1),[ue,he]=c.useState(0),[pe,Se]=c.useState(""),[Ce,ge]=c.useState(!1),[xe,je]=c.useState(!1),[ye,me]=c.useReducer(C.searchReducer,{collections:{},products:{}}),[be,fe]=c.useReducer(C.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=c.useRef(null),[ke,Ie]=c.useState(!1),[Pe,Oe]=c.useState();c.useEffect((()=>{de(!0),je(!0),e.collectionFetcher(ie,b).then((e=>{X({type:"fetched",data:(null==e?void 0:e.collections)||{}}),de(!1),le((e=>e+1)),je(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;V?Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&be[-1]&&(null===(c=be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=be[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Q,be,V]),c.useEffect((()=>{re&&(de(!0),e.productFetcher(re,b).then((e=>{Object.keys(e).length&&X({type:"productsFetched",data:{collectionId:re,products:e}}),de(!1)})).catch())}),[re]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==Z&&(pe.length||"collections"!==Z)&&(pe.length?(ge(!0),e.searchFetcher(b,pe).then((e=>{"collections"in e&&"products"in e?(me({type:"set",data:e}),X({type:"searched",data:e.collections})):(me({type:"set",data:{collections:{},products:e}}),X({type:"searched",data:e})),ee("searchProducts"),de(!1),ge(!1)}))):ee("collections"))}),800);return()=>clearTimeout(t)}),[pe]),c.useEffect((()=>{L&&(e.onAdd(be,ue),Fe())}),[L]),c.useEffect((()=>{_&&Object.keys(be||{}).length&&ue&&(e.onAdd(be,ue),Fe())}),[_,be,ue]);const Fe=()=>{fe({type:"reset",data:{}})},Re=()=>P&&ue>P?t.jsx(d.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):O&&ue>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):ue>0?t.jsx(n.Button,{onClick:()=>{ee($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:["rearrange","view"].includes(Z)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(Z)}):t.jsx(n.Button,{disabled:!0,buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:"tertiaryGray"}),De=e=>ae?"Loading...":Z===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Te=t.jsxs(j.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===Z||"searchProducts"===Z)&&t.jsx("div",Object.assign({style:{padding:B?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Ce?t.jsx(a.Spinner,{size:"small",color:s.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:pe,onChangeText:e=>{e.length&&e.trim().length?Se(e):Se("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:ve,screenName:Z},{children:["collections"===Z&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:xe,collections:Q,selectedCollectionsDispatch:fe,setCollectionId:se,setSelectedCollectionId:ne,setScreen:ee,selectedCollections:be,collectionFetcher:e.collectionFetcher,storeId:b,collectionsDispatch:X,setSaveDisabled:de,pagingControls:{curPage:ie,setCurPage:le},hideCollectionCheckbox:F,renderWithoutModal:B,pickerType:M,scrollContainerRef:ve}),"products"===Z&&ce&&t.jsx(C.CollectionIdContext.Provider,Object.assign({value:ce},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:ee,storeId:b,data:Q[ce],collectionsDispatch:X,selectedCollectionsDispatch:fe,selectedData:be,setSaveDisabled:de,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:R,outOfStockAction:D,hideVariantCheckbox:T,selectProductsFromCustomCollection:N,renderWithoutModal:B,pickerType:M,hideProductVariants:V,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Oe(e)},showProductDetailInfoIcon:H,scrollContainerRef:ve})})),"view"===Z&&t.jsx(x.SelectedScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,hideProductVariants:V,outOfStockAction:D,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===Z&&t.jsx(S.RearrangeScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,outOfStockAction:D,rearrangeViewType:"grid"===te?"list":"grid",scrollContainerRef:ve,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===Z&&t.jsx(g.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:be||{},searchedCollections:ye||{},searchedCollectionsDispatch:me,selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,onBackPress:()=>{Se(""),me({type:"set",data:{collections:{},products:{}}})},pickerType:M,hideProductCheckbox:R,hideProductVariants:V,hideVariantCheckbox:T,storeId:b,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:ne,renderWithoutModal:B,hideCollectionCheckbox:F,outOfStockAction:D})]}))]}));return t.jsx(t.Fragment,{children:B?t.jsxs(t.Fragment,{children:[Te,K.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Re(),t.jsx(n.Button,{buttonText:De(K.primaryButtonText),disabled:!K.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||K.primaryButtonDisabled,isLoading:K.isLoading,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):t.jsx(t.Fragment,{}),ke&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,outOfStockAction:D,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(l.StyledModal,Object.assign({zIndex:I,open:k,onClose:()=>{null==v||v(),Fe()},headingTitle:A||("collections"===Z||"products"===Z?"Select Products":"view"===Z?"Selected Products":"searchProducts"===Z?"Searched Results":"rearrange"===Z?"Rearrange Products":void 0),headingSubtitle:J,footerShadow:!0,centralContainerStyles:{width:E||"600px",left:w||"auto"},headerRightCustomElement:G?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:v},{children:t.jsx(r.default,{width:20,height:20,color:s.COLORS.content.secondary})})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:s.COLORS.surface.standard}:void 0,primaryButton:U?(t=>Object.assign(Object.assign({},t),{disabled:!t.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||t.disabled,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}))(U):{buttonText:De(),disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{e.onAdd(be,ue),Fe()}},secondaryButton:Y?(t=>Object.assign(Object.assign({},t),{disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{console.log("clicked ADD TO CART. Passing: ",{selectedCollections:be,collections:Q,searchedCollections:ye});const t=m.updateAllVariantsForSelectedProducts(be,Q,ye);console.log("response from Filtered collections: ",{filteredCollections:t}),e.onAdd(t,ue,!0)}}))(Y):void 0,wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):Re(),hideCrossButton:ke||G},{children:[Te,ke&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:D,onClose:()=>{Ie(!1)}}):t.jsx(t.Fragment,{})]}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function l(o,l,t){if(!o)return{};const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function l(o,l,t){if(!o)return{};const n=Object.keys(o).slice(t,t+l),d={};return n.forEach((l=>{d[l]=o[l]})),d}const t=(o,l,t)=>{Object.keys(o).forEach((l=>{var t,n;const d=null!==(n=null===(t=o[l])||void 0===t?void 0:t.products)&&void 0!==n?n:{};Object.keys(d).forEach((t=>{var n,d,i,e;const s=null!==(e=null===(i=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[t])||void 0===i?void 0:i.variants)&&void 0!==e?e:{};Object.keys(s).forEach((n=>{var d,i,e,s;const c=null===(s=null===(e=null===(i=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===i?void 0:i[t])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[n];c&&!c.fbStatus&&(c.fbStatus="APPROVED")}))}))})),l({type:t,data:o})};exports.fetchFbStatusCollection=function(o,l,n,d){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";d||t(o,n,i);const e=(o=>{const l=[];return Object.keys(o).forEach((t=>{var n,d;const i=null!==(d=null===(n=o[t])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,e,s;const c=null!==(s=null===(e=null===(i=null===(d=o[t])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===e?void 0:e.variants)&&void 0!==s?s:{};Object.keys(c).forEach((d=>{var i,e,s,c;const v=null===(c=null===(s=null===(e=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===e?void 0:e[n])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[d];(null==v?void 0:v.fbStatus)||l.push(d)}))}))})),l})(o);e.length>0&&d&&d(l,e).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var n,d;const i=null!==(d=null===(n=t[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,e,s;const c=null!==(s=null===(e=null===(i=null===(d=t[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===e?void 0:e.variants)&&void 0!==s?s:{};Object.keys(c).forEach((d=>{var i,e,s,c;const v=null===(c=null===(s=null===(e=null===(i=t[o])||void 0===i?void 0:i.products)||void 0===e?void 0:e[n])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[d];v&&"REJECTED"===l[d]?v.fbStatus="REJECTED":v&&"APPROVED"===l[d]&&(v.fbStatus="APPROVED")}))}))})),n({type:i,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,n,i)}))},exports.getSkuId=(o,l)=>{var t;if(l)return o.skuId;const n=Object.values(null!==(t=null==o?void 0:o.variants)&&void 0!==t?t:{});return 1===n.length&&n[0].name.includes(o.name)?n[0].skuId:""},exports.getVariantIdsToFetchAtProductLevel=(o,l)=>{const t=[];return Object.keys(null!=o?o:{}).forEach((n=>{var d,i;const e=null!==(i=null===(d=null==o?void 0:o[n])||void 0===d?void 0:d.variants)&&void 0!==i?i:{};Object.keys(e).forEach((d=>{var i,e,s,c,v;let r;r=l?null===(s=null===(e=null===(i=null==l?void 0:l.products)||void 0===i?void 0:i[n])||void 0===e?void 0:e.variants)||void 0===s?void 0:s[d]:null===(v=null===(c=null==o?void 0:o[n])||void 0===c?void 0:c.variants)||void 0===v?void 0:v[d],(null==r?void 0:r.fbStatus)||t.push(d)}))})),t},exports.isCollectionPartiallyChecked=function(o,l,t){var n,d,i,e;let s=0,c=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const e=null!==(n=null==l?void 0:l.products)&&void 0!==n?n:{};s=Object.keys(e).length;const v=null!==(i=null===(d=t[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};c=Object.keys(v).length}else if(t[o]){const n=null==l?void 0:l.products;n&&Object.keys(n).forEach((o=>{var l;const t=null===(l=n[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>s+=1))}));const d=null===(e=t[o])||void 0===e?void 0:e.products;if(d&&Object.keys(d).forEach((o=>{var l;const t=null===(l=d[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>c+=1))})),s<=0&&c>0)return!1}return c>0&&s!==c},exports.isProductPartiallyChecked=(o,l,t,n,d)=>{var i,e,s,c,v,r,u,a,p,b,O,f,g,h,j,y,k,E,P;let S=0,V=0;if(null===(e=null===(i=null==t?void 0:t[o])||void 0===i?void 0:i.products)||void 0===e?void 0:e[l]){if(d)return!1;const i=(null===(v=null===(c=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.products)||void 0===c?void 0:c[l])||void 0===v?void 0:v.variants)||[];if(1===Object.keys(i).length)for(const n in i){const d=null===(u=null===(r=null==t?void 0:t[o])||void 0===r?void 0:r.products)||void 0===u?void 0:u[l],i=null===(O=null===(b=null===(p=null===(a=null==t?void 0:t[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[n];if(null===(f=null==i?void 0:i.name)||void 0===f?void 0:f.includes(null!==(g=null==d?void 0:d.name)&&void 0!==g?g:""))return!1}if(null===(y=Object.keys((null===(j=null===(h=null==n?void 0:n.products)||void 0===h?void 0:h[l])||void 0===j?void 0:j.variants)||[]))||void 0===y||y.forEach((()=>V++)),Object.keys((null===(P=null===(E=null===(k=null==t?void 0:t[o])||void 0===k?void 0:k.products)||void 0===E?void 0:E[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>S++)),S>0&&V!==S)return!0}return!1},exports.liftTheStateUp=(l,t)=>{const n=o.cloneDeep(t);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&t.products){const d=o.cloneDeep(t.products[l.productId]);(null==d?void 0:d.variants)&&delete d.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:d})}return l},exports.markVariantsAsApprovedProductsLevel=(o,l,t,n,d)=>{const i=Object.assign({},o);if(Object.keys(o).forEach((l=>{var t,n;Object.keys(null!==(n=null===(t=null==o?void 0:o[l])||void 0===t?void 0:t.variants)&&void 0!==n?n:{}).forEach((t=>{var n,d;const e=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[t];e&&(e.fbStatus="APPROVED");const s=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.variants;s&&s[t]&&(s[t]=e)}))})),n&&d){const o=Object.assign({},n);o.products=i,d(o),l({type:"productsPaged",data:{collectionId:t,products:i}})}else l({type:"productsPaged",data:{collectionId:t,products:i}})},exports.paginateSelectedItems=function(o,t,n){var d;const i={};let e=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const c=o[s],v=l(c.products,t,n-e);v&&Object.keys(v).length>0&&(i[s]=Object.assign(Object.assign({},c),{products:v})),e+=Object.keys(null!==(d=c.products)&&void 0!==d?d:{}).length}return i},exports.shouldShowVariant=o=>{const l=Object.keys(o.variants||[]);let t=!1;return!(l.length<=1)||(l.forEach((l=>{var n,d;t=null!==(d=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==d&&d})),!t)},exports.updateAllVariantsForSelectedProducts=(l,t,n)=>{console.log("updateAllVariantsForSelectedProducts called"),console.log("selectedItems:",l),console.log("collections:",t),console.log("searchedProducts:",n);const d=Object.keys(l).reduce(((d,i)=>{var e;return console.log(`Processing collectionId: ${i}`),i in t?(d[i]=Object.assign(Object.assign({},l[i]),{products:Object.keys(null!==(e=l[i].products)&&void 0!==e?e:{}).reduce(((d,e)=>{var s,c,v,r,u,a,p,b,O,f;console.log(` Processing productId: ${e}`);const g=null===(s=t[i].products)||void 0===s?void 0:s[e],h=null===(r=null===(v=null===(c=null==n?void 0:n.products)||void 0===c?void 0:c[i])||void 0===v?void 0:v.products)||void 0===r?void 0:r[e];return g?(console.log(` Product ${e} found in collections[${i}]`),d[e]=Object.assign(Object.assign({},(null===(u=l[i].products)||void 0===u?void 0:u[e])||{}),{allVariants:o.cloneDeep(g.variants)})):h?(console.log(` Product ${e} found in searchedProducts.products[${i}]`),d[e]=Object.assign(Object.assign({},(null===(a=l[i].products)||void 0===a?void 0:a[e])||{}),{allVariants:o.cloneDeep(h.variants)})):(null===(b=null===(p=l[i].products)||void 0===p?void 0:p[e])||void 0===b?void 0:b.allVariants)?(console.log(` Product ${e} using preselected allVariants`),d[e]=Object.assign(Object.assign({},(null===(O=l[i].products)||void 0===O?void 0:O[e])||{}),{allVariants:o.cloneDeep(null===(f=l[i].products)||void 0===f?void 0:f[e].allVariants)})):console.log(` Product ${e} not found in collections or searchedProducts and has no preselected allVariants`),d}),{})}),d):(console.log(`Collection ${i} not found in collections`),d)}),{});return console.log("updatedSelectedItems:",d),d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as s}from"react";import{AvatarStyle as i}from"./Avatar.styled.js";import{SIZE as r,AVATAR_BACKGROUND as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as s}from"react";import{AvatarStyle as i}from"./Avatar.styled.js";import{SIZE as r,AVATAR_BACKGROUND as a,AVATAR_TYPES as o,AVATAR_SIZE_MAP as n}from"./AvatarHelper.js";import{BodyTiny as c,TitleSmall as l,TitleMedium as d}from"../TypographyStyle.js";import{COLORS as h}from"../../constants/Theme.js";import m from"../../assets/icons/bik_livechat.svg.js";import g from"../../assets/icons/CheckSquareOffset.svg.js";import p from"../../assets/icons/email-channel.svg.js";import u from"../../assets/icons/facebook_channel.svg.js";import b from"../../assets/icons/gmail.svg.js";import A from"../../assets/icons/instagram-channel.svg.js";import I from"../../assets/icons/whatsapp_color.svg.js";const f={[r.SMALL]:16,[r.MEDIUM]:20,[r.INBOX]:24,[r.LARGE]:32},S={[a.LIGHT]:h.content.secondary,[a.DARK]:h.surface.standard};var y;!function(e){e.INSTAGRAM="instagram",e.MESSENGER="messenger",e.WHATSAPP="whatsapp",e.GMAIL="gmail",e.LIVECHAT="livechat",e.GOOGLE_BUSINESS_CHAT="gbm",e.SHOPIFY="shopify",e.FACEBOOK="facebook",e.EMAIL="email",e.SMTP="smtp",e.FACEBOOK_CATALOG="facebook-catalog",e.TASKS="tasks",e.BIK_LIVECHAT="livechat"}(y||(y={}));const j=a=>{const[j,v]=s(!1),E=()=>{const e=(a.name||"").split(".").join(" ").split(" ").map((e=>e.charAt(0).toUpperCase())).slice(0,2).join("");return a.size===r.SMALL?t(c,Object.assign({style:{color:S[a.background]}},{children:e})):a.size===r.MEDIUM||a.size===r.INBOX?t(l,Object.assign({style:{color:S[a.background]}},{children:e})):a.size===r.LARGE?t(d,Object.assign({style:{color:S[a.background]}},{children:e})):void 0};return e("div",Object.assign({style:{position:"relative"}},{children:[e(i,Object.assign({type:a.type===o.IMAGE&&j&&a.useNameFallback&&a.name?o.INITIALS:a.type,size:a.size,background:a.background},{children:[a.type===o.IMAGE&&(a.useNameFallback&&!j?t("img",{alt:"",width:n[a.size],height:n[a.size],style:{borderRadius:(null==a?void 0:a.borderRadius)||"50%",objectFit:"contain"},src:a.photoUrl,onError:()=>{v(!0)}}):a.useNameFallback&&j&&a.name?t("div",{children:E()}):t("img",{alt:"",width:n[a.size],height:n[a.size],style:{borderRadius:(null==a?void 0:a.borderRadius)||"50%",objectFit:"contain"},src:a.photoUrl})),a.type===o.INITIALS&&t("div",{children:E()}),a.type===o.ICON&&a.icon&&t(a.icon,{width:f[a.size],height:f[a.size],color:S[a.background]})]})),a.inboxSettings&&t("div",Object.assign({style:{position:"absolute",left:f[a.size]+"px",top:f[a.size]+"px",width:14,height:14,borderRadius:(null==a?void 0:a.borderRadius)||"50%",display:"flex",justifyContent:"center",backgroundColor:a.inboxSettings.isSelected?a.inboxSettings.isComments?h.content.primary:h.background.brandLight:a.inboxSettings.isComments?h.content.primary:h.surface.standard,alignItems:"center"}},{children:(()=>{switch(a.channelName){case y.EMAIL:case y.SMTP:return t(p,{width:11,height:11});case y.FACEBOOK:case y.FACEBOOK_CATALOG:case y.MESSENGER:return t(u,{width:11,height:11});case y.INSTAGRAM:return t(A,{width:11,height:11});case y.WHATSAPP:return t(I,{width:11,height:11});case y.GMAIL:return t(b,{width:11,height:11});case y.TASKS:return t(g,{width:11,height:11});case y.BIK_LIVECHAT:return t(m,{width:11,height:11})}})()})),a.status&&t("div",Object.assign({style:{position:"absolute",left:f[a.size]+"px",top:f[a.size]+"px",width:11,height:11,borderRadius:"50%",display:"flex",justifyContent:"center",backgroundColor:h.surface.standard,alignItems:"center"}},{children:a.status?t("div",{style:{backgroundColor:"ONLINE"===a.status?h.special.whatsapp.brand:h.content.inactive,width:"8px",height:"8px",borderRadius:"50%"}}):null}))]}))};export{f as AVATAR_SIZE_VS_ICON_SIZE_MAP,j as Avatar,S as BACKGROUND_VS_TEXT_COLOR_MAP,y as MESSAGE_CHANNELS};
|
|
@@ -4,7 +4,7 @@ import r from"styled-components";import{AVATAR_SIZE_MAP as e,AVATAR_TYPES as o,A
|
|
|
4
4
|
display: flex;
|
|
5
5
|
justify-content: center;
|
|
6
6
|
align-items: center;
|
|
7
|
-
background-color: ${r=>r.type===o.IMAGE?"null":r.background===t.LIGHT?n.background.base:
|
|
8
|
-
border: ${r=>r.background===t.LIGHT
|
|
7
|
+
background-color: ${r=>r.type===o.IMAGE?"null":r.background===t.LIGHT?n.background.base:n.background.inverse};
|
|
8
|
+
border: ${r=>r.background===t.LIGHT?"1px solid "+n.stroke.primary:0};
|
|
9
9
|
border-radius: 50%;
|
|
10
10
|
`;export{s as AvatarStyle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var I,L,A;!function(I){I.IMAGE="IMAGE",I.INITIALS="INITIALS",I.ICON="ICON"}(I||(I={})),function(I){I.SMALL="SMALL",I.MEDIUM="MEDIUM",I.LARGE="LARGE",I.INBOX="INBOX"}(L||(L={})),function(I){I.LIGHT="LIGHT",I.DARK="DARK"
|
|
1
|
+
var I,L,A;!function(I){I.IMAGE="IMAGE",I.INITIALS="INITIALS",I.ICON="ICON"}(I||(I={})),function(I){I.SMALL="SMALL",I.MEDIUM="MEDIUM",I.LARGE="LARGE",I.INBOX="INBOX"}(L||(L={})),function(I){I.LIGHT="LIGHT",I.DARK="DARK"}(A||(A={}));const M={[L.SMALL]:24,[L.MEDIUM]:40,[L.LARGE]:64,[L.INBOX]:30};export{A as AVATAR_BACKGROUND,M as AVATAR_SIZE_MAP,I as AVATAR_TYPES,L as SIZE};
|
|
@@ -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
|
|
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 b}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as S,selectedColectionsReducer as v,CollectionIdContext as k}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as I}from"./selectedScreen.js";import{ContainerStyle as P,ScrollContainerStyle as x,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";var T;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(T||(T={}));const R=R=>{const{storeId:A,selectedItems:w,onClose:B,visible:E,zIndex:L,exactLimit:z,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:M,outOfStockAction:H=D.BLUR,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,hideSelectionCount:N,title:K,width:U,left:Y,renderWithoutModal:q,onClickSave:J,pickerType:Q,hideProductVariants:X=!1,startupScreen:Z=T.Collections,rearrangeEnabled:_,selectSingleItem:ee=!1,showProductDetails:te,containerStyle:oe,crossButtonInsideHeader:ce=!1,footerForNonModal:re={},primaryButton:se,secondaryButton:ie,subtitle:ne}=R,[le,de]=r(y,{}),[ae,ue]=s([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections),[he,pe]=s("grid"),[me,Ce]=s(""),[ge,fe]=s(""),[be,ye]=s(0),[Se,ve]=s(!1),[ke,je]=s(0),[Ie,Pe]=s(""),[xe,Oe]=s(!1),[De,Fe]=s(!1),[Te,Re]=r(S,{collections:{},products:{}}),[Ae,we]=r(v,Object.keys(w).length>0?w:{}),Be=i(null),[Ee,Le]=s(!1),[ze,Ve]=s();n((()=>{ve(!0),Fe(!0),R.collectionFetcher(be,A).then((e=>{de({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ve(!1),ye((e=>e+1)),Fe(!1)})).catch()}),[]),n((()=>{let e=0;X?Object.keys(Ae||[]).forEach((t=>{var o;Object.keys((null===(o=Ae[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Ae[-1]&&(null===(c=Ae[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Ae||[]).forEach((t=>{var o;Object.keys((null===(o=Ae[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Ae[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),je(e)}),[le,Ae,X]),n((()=>{ge&&(ve(!0),R.productFetcher(ge,A).then((e=>{Object.keys(e).length&&de({type:"productsFetched",data:{collectionId:ge,products:e}}),ve(!1)})).catch())}),[ge]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ae&&(Ie.length||"collections"!==ae)&&(Ie.length?(Oe(!0),R.searchFetcher(A,Ie).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),de({type:"searched",data:e.collections})):(Re({type:"set",data:{collections:{},products:e}}),de({type:"searched",data:e})),ue("searchProducts"),ve(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[Ie]),n((()=>{J&&(R.onAdd(Ae,ke),$e())}),[J]),n((()=>{ee&&Object.keys(Ae||{}).length&&ke&&(R.onAdd(Ae,ke),$e())}),[ee,Ae,ke]);const $e=()=>{we({type:"reset",data:{}})},Me=()=>z&&ke>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):V&&ke>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):t(a,ke>0?{onClick:()=>{ue(_?T.RearrangeProducts:T.SelectedProducts)},buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:["rearrange","view"].includes(ae)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ae)}:{disabled:!0,buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:"tertiaryGray"}),He=e=>Se?"Loading...":ae===T.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e(P,Object.assign({style:null!=oe?oe:{}},{children:[R.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&t(o,{children:("collections"===ae||"searchProducts"===ae)&&t("div",Object.assign({style:{padding:q?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>xe?t(p,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Ie,onChangeText:e=>{e.length&&e.trim().length?Pe(e):Pe("")}})}))}),e(x,Object.assign({ref:Be,screenName:ae},{children:["collections"===ae&&t(C,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:De,collections:le,selectedCollectionsDispatch:we,setCollectionId:Ce,setSelectedCollectionId:fe,setScreen:ue,selectedCollections:Ae,collectionFetcher:R.collectionFetcher,storeId:A,collectionsDispatch:de,setSaveDisabled:ve,pagingControls:{curPage:be,setCurPage:ye},hideCollectionCheckbox:$,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Be}),"products"===ae&&me&&t(k.Provider,Object.assign({value:me},{children:t(f,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:ue,storeId:A,data:le[me],collectionsDispatch:de,selectedCollectionsDispatch:we,selectedData:Ae,setSaveDisabled:ve,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:M,outOfStockAction:H,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:te,scrollContainerRef:Be})})),"view"===ae&&t(I,{selectedCollections:Ae||{},selectedCollectionsDispatch:we,setScreen:ue,collections:le,hideProductVariants:X,outOfStockAction:H,storeId:A,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===ae&&t(b,{selectedCollections:Ae||{},selectedCollectionsDispatch:we,setScreen:ue,outOfStockAction:H,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Be,storeId:A,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===ae&&t(j,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:Ae||{},searchedCollections:Te||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:we,setScreen:ue,collections:le,onBackPress:()=>{Pe(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:M,hideProductVariants:X,hideVariantCheckbox:W,storeId:A,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:Ce,setSelectedCollectionId:fe,renderWithoutModal:q,hideCollectionCheckbox:$,outOfStockAction:H})]}))]}));return t(o,{children:q?e(o,{children:[We,re.renderFooter?e(O,{children:[Me(),t(a,{buttonText:He(re.primaryButtonText),disabled:!re.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||re.primaryButtonDisabled,isLoading:re.isLoading,onClick:()=>{R.onAdd(Ae,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}})]}):t(o,{}),Ee&&ze?t(g,{productData:ze,outOfStockAction:H,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:L,open:E,onClose:()=>{null==B||B(),$e()},headingTitle:K||("collections"===ae||"products"===ae?"Select Products":"view"===ae?"Selected Products":"searchProducts"===ae?"Searched Results":"rearrange"===ae?"Rearrange Products":void 0),headingSubtitle:ne,footerShadow:!0,centralContainerStyles:{width:U||"600px",left:Y||"auto"},headerRightCustomElement:ce?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:B},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||e.disabled,onClick:()=>{R.onAdd(Ae,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}}))(se):{buttonText:He(),disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{R.onAdd(Ae,ke),$e()}},secondaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{console.log("clicked ADD TO CART. Passing: ",{selectedCollections:Ae,collections:le,searchedCollections:Te});const e=F(Ae,le,Te);console.log("response from Filtered collections: ",{filteredCollections:e}),R.onAdd(e,ke,!0)}}))(ie):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t(o,{}):Me(),hideCrossButton:Ee||ce},{children:[We,Ee&&ze?t(g,{productData:ze,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:H,onClose:()=>{Le(!1)}}):t(o,{})]}))})};export{R as ProductPickerModal,T as ScreenName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as o}from"lodash";const l=(l,
|
|
1
|
+
import{cloneDeep as o}from"lodash";const l=(l,n)=>{const t=o(n);if(delete t.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:t})).productId&&n.products){const d=o(n.products[l.productId]);(null==d?void 0:d.variants)&&delete d.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:t,productOnlyData:d})}return l};function n(o,l,n){var d;const i={};let s=0;for(const v in o)if(Object.prototype.hasOwnProperty.call(o,v)){const c=o[v],u=t(c.products,l,n-s);u&&Object.keys(u).length>0&&(i[v]=Object.assign(Object.assign({},c),{products:u})),s+=Object.keys(null!==(d=c.products)&&void 0!==d?d:{}).length}return i}function t(o,l,n){if(!o)return{};const t=Object.keys(o).slice(n,n+l),d={};return t.forEach((l=>{d[l]=o[l]})),d}const d=(o,l,n)=>{Object.keys(o).forEach((l=>{var n,t;const d=null!==(t=null===(n=o[l])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,i,s;const v=null!==(s=null===(i=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===i?void 0:i.variants)&&void 0!==s?s:{};Object.keys(v).forEach((t=>{var d,i,s,v;const c=null===(v=null===(s=null===(i=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===s?void 0:s.variants)||void 0===v?void 0:v[t];c&&!c.fbStatus&&(c.fbStatus="APPROVED")}))}))})),l({type:n,data:o})},i=function(o,l,n,t){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";t||d(o,n,i);const s=(o=>{const l=[];return Object.keys(o).forEach((n=>{var t,d;const i=null!==(d=null===(t=o[n])||void 0===t?void 0:t.products)&&void 0!==d?d:{};Object.keys(i).forEach((t=>{var d,i,s,v;const c=null!==(v=null===(s=null===(i=null===(d=o[n])||void 0===d?void 0:d.products)||void 0===i?void 0:i[t])||void 0===s?void 0:s.variants)&&void 0!==v?v:{};Object.keys(c).forEach((d=>{var i,s,v,c;const u=null===(c=null===(v=null===(s=null===(i=o[n])||void 0===i?void 0:i.products)||void 0===s?void 0:s[t])||void 0===v?void 0:v.variants)||void 0===c?void 0:c[d];(null==u?void 0:u.fbStatus)||l.push(d)}))}))})),l})(o);s.length>0&&t&&t(l,s).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var n,d;const i=null!==(d=null===(n=t[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,s,v;const c=null!==(v=null===(s=null===(i=null===(d=t[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===s?void 0:s.variants)&&void 0!==v?v:{};Object.keys(c).forEach((d=>{var i,s,v,c;const u=null===(c=null===(v=null===(s=null===(i=t[o])||void 0===i?void 0:i.products)||void 0===s?void 0:s[n])||void 0===v?void 0:v.variants)||void 0===c?void 0:c[d];u&&"REJECTED"===l[d]?u.fbStatus="REJECTED":u&&"APPROVED"===l[d]&&(u.fbStatus="APPROVED")}))}))})),n({type:i,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),d(o,n,i)}))},s=(o,l)=>{const n=[];return Object.keys(null!=o?o:{}).forEach((t=>{var d,i;const s=null!==(i=null===(d=null==o?void 0:o[t])||void 0===d?void 0:d.variants)&&void 0!==i?i:{};Object.keys(s).forEach((d=>{var i,s,v,c,u;let e;e=l?null===(v=null===(s=null===(i=null==l?void 0:l.products)||void 0===i?void 0:i[t])||void 0===s?void 0:s.variants)||void 0===v?void 0:v[d]:null===(u=null===(c=null==o?void 0:o[t])||void 0===c?void 0:c.variants)||void 0===u?void 0:u[d],(null==e?void 0:e.fbStatus)||n.push(d)}))})),n},v=(o,l,n,t,d)=>{const i=Object.assign({},o);if(Object.keys(o).forEach((l=>{var n,t;Object.keys(null!==(t=null===(n=null==o?void 0:o[l])||void 0===n?void 0:n.variants)&&void 0!==t?t:{}).forEach((n=>{var t,d;const s=null===(t=null==o?void 0:o[l].variants)||void 0===t?void 0:t[n];s&&(s.fbStatus="APPROVED");const v=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.variants;v&&v[n]&&(v[n]=s)}))})),t&&d){const o=Object.assign({},t);o.products=i,d(o),l({type:"productsPaged",data:{collectionId:n,products:i}})}else l({type:"productsPaged",data:{collectionId:n,products:i}})},c=o=>{const l=Object.keys(o.variants||[]);let n=!1;return!(l.length<=1)||(l.forEach((l=>{var t,d;n=null!==(d=null===(t=o.variants)||void 0===t?void 0:t[l].name.includes(o.name))&&void 0!==d&&d})),!n)},u=(o,l,n,t,d)=>{var i,s,v,c,u,e,r,a,p,b,O,f,g,j,h,y,E,k,P;let V=0,m=0;if(null===(s=null===(i=null==n?void 0:n[o])||void 0===i?void 0:i.products)||void 0===s?void 0:s[l]){if(d)return!1;const i=(null===(u=null===(c=null===(v=null==n?void 0:n[o])||void 0===v?void 0:v.products)||void 0===c?void 0:c[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(i).length)for(const t in i){const d=null===(r=null===(e=null==n?void 0:n[o])||void 0===e?void 0:e.products)||void 0===r?void 0:r[l],i=null===(O=null===(b=null===(p=null===(a=null==n?void 0:n[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[t];if(null===(f=null==i?void 0:i.name)||void 0===f?void 0:f.includes(null!==(g=null==d?void 0:d.name)&&void 0!==g?g:""))return!1}if(null===(y=Object.keys((null===(h=null===(j=null==t?void 0:t.products)||void 0===j?void 0:j[l])||void 0===h?void 0:h.variants)||[]))||void 0===y||y.forEach((()=>m++)),Object.keys((null===(P=null===(k=null===(E=null==n?void 0:n[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>V++)),V>0&&m!==V)return!0}return!1},e=function(o,l,n){var t,d,i,s;let v=0,c=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const s=null!==(t=null==l?void 0:l.products)&&void 0!==t?t:{};v=Object.keys(s).length;const u=null!==(i=null===(d=n[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};c=Object.keys(u).length}else if(n[o]){const t=null==l?void 0:l.products;t&&Object.keys(t).forEach((o=>{var l;const n=null===(l=t[o])||void 0===l?void 0:l.variants;n&&Object.keys(n).forEach((o=>v+=1))}));const d=null===(s=n[o])||void 0===s?void 0:s.products;if(d&&Object.keys(d).forEach((o=>{var l;const n=null===(l=d[o])||void 0===l?void 0:l.variants;n&&Object.keys(n).forEach((o=>c+=1))})),v<=0&&c>0)return!1}return c>0&&v!==c},r=(l,n,t)=>{console.log("updateAllVariantsForSelectedProducts called"),console.log("selectedItems:",l),console.log("collections:",n),console.log("searchedProducts:",t);const d=Object.keys(l).reduce(((d,i)=>{var s;return console.log(`Processing collectionId: ${i}`),i in n?(d[i]=Object.assign(Object.assign({},l[i]),{products:Object.keys(null!==(s=l[i].products)&&void 0!==s?s:{}).reduce(((d,s)=>{var v,c,u,e,r,a,p,b,O,f;console.log(` Processing productId: ${s}`);const g=null===(v=n[i].products)||void 0===v?void 0:v[s],j=null===(e=null===(u=null===(c=null==t?void 0:t.products)||void 0===c?void 0:c[i])||void 0===u?void 0:u.products)||void 0===e?void 0:e[s];return g?(console.log(` Product ${s} found in collections[${i}]`),d[s]=Object.assign(Object.assign({},(null===(r=l[i].products)||void 0===r?void 0:r[s])||{}),{allVariants:o(g.variants)})):j?(console.log(` Product ${s} found in searchedProducts.products[${i}]`),d[s]=Object.assign(Object.assign({},(null===(a=l[i].products)||void 0===a?void 0:a[s])||{}),{allVariants:o(j.variants)})):(null===(b=null===(p=l[i].products)||void 0===p?void 0:p[s])||void 0===b?void 0:b.allVariants)?(console.log(` Product ${s} using preselected allVariants`),d[s]=Object.assign(Object.assign({},(null===(O=l[i].products)||void 0===O?void 0:O[s])||{}),{allVariants:o(null===(f=l[i].products)||void 0===f?void 0:f[s].allVariants)})):console.log(` Product ${s} not found in collections or searchedProducts and has no preselected allVariants`),d}),{})}),d):(console.log(`Collection ${i} not found in collections`),d)}),{});return console.log("updatedSelectedItems:",d),d},a=(o,l)=>{var n;if(l)return o.skuId;const t=Object.values(null!==(n=null==o?void 0:o.variants)&&void 0!==n?n:{});return 1===t.length&&t[0].name.includes(o.name)?t[0].skuId:""};export{i as fetchFbStatusCollection,a as getSkuId,s as getVariantIdsToFetchAtProductLevel,e as isCollectionPartiallyChecked,u as isProductPartiallyChecked,l as liftTheStateUp,v as markVariantsAsApprovedProductsLevel,n as paginateSelectedItems,c as shouldShowVariant,r as updateAllVariantsForSelectedProducts};
|