@bikdotai/bik-component-library 0.0.657-13 → 0.0.657-15
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/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/product.js +1 -1
- package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +1 -0
- package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/product.js +1 -1
- package/dist/esm/components/product-picker-v2/searchScreen.d.ts +1 -0
- package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),x=require("./reducers.js"),g=require("./searchScreen.js"),C=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:P,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:R,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:E,width:A,left:w,renderWithoutModal:B,onClickSave:L,pickerType:M,hideProductVariants:V=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),x=require("./reducers.js"),g=require("./searchScreen.js"),C=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:P,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:R,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:E,width:A,left:w,renderWithoutModal:B,onClickSave:L,pickerType:M,hideProductVariants:V=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:W,selectSingleItem:$=!1,showProductDetails:_,containerStyle:H,crossButtonInsideHeader:G=!1,footerForNonModal:K={},primaryButton:U,secondaryButton:Y,subtitle:J}=e,[Q,X]=c.useReducer(x.collectionsReducer,{}),[Z,ee]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[te,oe]=c.useState("grid"),[ce,re]=c.useState(""),[se,ne]=c.useState(""),[ie,le]=c.useState(0),[ae,de]=c.useState(!1),[ue,he]=c.useState(0),[pe,Se]=c.useState(""),[xe,ge]=c.useState(!1),[Ce,je]=c.useState(!1),[ye,me]=c.useReducer(x.searchReducer,{collections:{},products:{}}),[be,fe]=c.useReducer(x.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=c.useRef(null),[ke,Pe]=c.useState(!1),[Ie,Oe]=c.useState();c.useEffect((()=>{de(!0),je(!0),e.collectionFetcher(ie,b).then((e=>{console.log("collectionsParsed?.collections",null==e?void 0:e.collections),X({type:"fetched",data:(null==e?void 0:e.collections)||{}}),de(!1),le((e=>e+1)),je(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;V?Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&be[-1]&&(null===(c=be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=be[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Q,be,V]),c.useEffect((()=>{se&&(de(!0),e.productFetcher(se,b).then((e=>{Object.keys(e).length&&X({type:"productsFetched",data:{collectionId:se,products:e}}),de(!1)})).catch())}),[se]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==Z&&(pe.length||"collections"!==Z)&&(pe.length?(ge(!0),e.searchFetcher(b,pe).then((e=>{"collections"in e&&"products"in e?(me({type:"set",data:e}),X({type:"searched",data:e.collections})):(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=()=>I&&ue>I?t.jsx(d.Tag,{tagText:`You can only select ${I} 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(W?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:I?`${ue}/${I} products selected`:`${ue} products selected`,buttonType:["rearrange","view"].includes(Z)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(Z)}):t.jsx(n.Button,{disabled:!0,buttonText:I?`${ue}/${I} products selected`:`${ue} products selected`,buttonType:"tertiaryGray"}),Te=e=>ae?"Loading...":Z===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",De=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"===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 products using name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>xe?t.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:pe,onChangeText:e=>{e.length&&e.trim().length?Se(e):Se("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:ve,screenName:Z},{children:["collections"===Z&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:Ce,collections:Q,selectedCollectionsDispatch:fe,setCollectionId:re,setSelectedCollectionId:ne,setScreen:ee,selectedCollections:be,collectionFetcher:e.collectionFetcher,storeId:b,collectionsDispatch:X,setSaveDisabled:de,pagingControls:{curPage:ie,setCurPage:le},hideCollectionCheckbox:F,renderWithoutModal:B,pickerType:M,scrollContainerRef:ve}),"products"===Z&&ce&&t.jsx(x.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:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:B,pickerType:M,hideProductVariants:V,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{Pe(!0),Oe(e)},showProductDetailInfoIcon:_,scrollContainerRef:ve,pickerWidth:A||"600px"})})),"view"===Z&&t.jsx(C.SelectedScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,hideProductVariants:V,outOfStockAction:T,storeId:b,fbStatusFetcher:e.fbStatusFetcher,pickerWidth:A||"600px"}),"rearrange"===Z&&t.jsx(S.RearrangeScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,outOfStockAction:T,rearrangeViewType:"grid"===te?"list":"grid",scrollContainerRef:ve,storeId:b,fbStatusFetcher:e.fbStatusFetcher,pickerWidth:A||"600px"}),"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:D,storeId:b,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:re,setSelectedCollectionId:ne,renderWithoutModal:B,hideCollectionCheckbox:F,outOfStockAction:T,pickerWidth:A||"600px"})]}))]}));return t.jsx(t.Fragment,{children:B?t.jsxs(t.Fragment,{children:[De,K.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Re(),t.jsx(n.Button,{buttonText:Te(K.primaryButtonText),disabled:!K.isLoading&&(ae||ue<1||I&&ue<I||!I&&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&&Ie?t.jsx(h.ProductInfoOverlay,{productData:Ie,outOfStockAction:T,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{Pe(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(l.StyledModal,Object.assign({zIndex:P,open:k,onClose:()=>{null==v||v(),Fe()},headingTitle:E||("collections"===Z||"products"===Z?"Select Products":"view"===Z?"Selected Products":"searchProducts"===Z?"Searched Results":"rearrange"===Z?"Rearrange Products":void 0),headingSubtitle:J,footerShadow:!0,centralContainerStyles:{width:A||"600px",left:w||"auto"},headerRightCustomElement:G?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:v},{children:t.jsx(s.default,{width:20,height:20,color:r.COLORS.content.secondary})})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:U?(t=>Object.assign(Object.assign({},t),{disabled:!t.isLoading&&(ae||ue<1||I&&ue<I||!I&&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:Te(),disabled:ae||ue<1||I&&ue<I||!I&&O&&ue>O||!1,onClick:()=>{e.onAdd(be,ue),Fe()}},secondaryButton:Y?(t=>Object.assign(Object.assign({},t),{disabled:ae||ue<1||I&&ue<I||!I&&O&&ue>O||!1,onClick:()=>{const t=m.updateAllVariantsForSelectedProducts(be,Q,ye);e.onAdd(t,ue,!0)}}))(Y):void 0,wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t.jsx(t.Fragment,{}):Re(),hideCrossButton:ke||G},{children:[De,ke&&Ie?t.jsx(h.ProductInfoOverlay,{productData:Ie,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Pe(!1)}}):t.jsx(t.Fragment,{})]}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../constants/Theme.js"),i=require("../../assets/icons/info.svg.js"),o=require("../checkBox/CheckBox.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../constants/Theme.js"),i=require("../../assets/icons/info.svg.js"),o=require("../checkBox/CheckBox.js"),c=require("../icon-button/IconButton.js"),d=require("../shimmer-image/ShimmerImage.js"),l=require("../tooltips/Tooltip.js"),r=require("../TypographyStyle.js"),n=require("./constants.js"),a=require("./helpers/ProductHelper.js"),s=require("./ProductPickerTag.js"),u=require("./style.js"),v=require("./utility.js");const p=n=>{var v,p,h,y,j;const{isVariant:I,data:P,productId:x,collectionId:k,variantId:g,isSelected:C,selectedCollectionsDispatch:b,viewOnly:O,upliftAdditions:S,isPartiallyChecked:m,hideProductCheckbox:f,outOfStockAction:T,hideVariantCheckbox:D,hideProductVariants:V,pickerType:w="PRODUCT",onProductDetailClick:q,showProductDetailInfoIcon:A,currencyAndPrice:U,pickerWidth:B}=n,{isVariantForProductPickerTag:$,dataForProductPickerTag:R,tagText:F,tagType:W}=a.ProductHelper.getDataForProductPickerTag(P,I,T);console.log({data:P});const L=I?P.skuId:1===(null===(p=Object.values(null!==(v=null==P?void 0:P.variants)&&void 0!==v?v:{}))||void 0===p?void 0:p.length)?null===(j=null===(y=Object.values(null!==(h=null==P?void 0:P.variants)&&void 0!==h?h:{}))||void 0===y?void 0:y[0])||void 0===j?void 0:j.skuId:void 0;return e.jsxs(u.ProductCardStyle,Object.assign({isVariant:I,onClick:e=>{if(e.stopPropagation(),"PRODUCT"===w&&(f||D)){const e=Object.keys(P.variants);V?C?b({type:"productUnselected",data:{productId:x,collectionId:k}}):S("productSelected",{productId:x,variantId:g,collectionId:k,product:P}):C?b({type:"variantUnselected",data:{productId:x,variantId:g,collectionId:k}}):S("variantSelected",{productId:x,variantId:g||e[0],collectionId:k,variant:P})}},isActive:C},{children:[I&&!O&&!D||!I&&!O&&!f?e.jsx(o.CheckBox,{isChecked:C,isPartiallyChecked:m||!1,onValueChange:function(e,t,i){null==i||i.stopPropagation(),I?e?S(V?"productSelected":"variantSelected",{productId:x,variantId:g,collectionId:k,variant:P}):b({type:V?"productUnselected":"variantUnselected",data:{productId:x,variantId:g,collectionId:k}}):e?S("productSelected",{productId:x,collectionId:k,product:P}):b({type:"productUnselected",data:{productId:x,collectionId:k}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(d.ShimmerImage,{width:40,height:40,imageUrl:P.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(l.Tooltip,Object.assign({variant:"light",body:P.name,placement:"bottom",delay:400},{children:e.jsx(u.StyledTitleSmall,Object.assign({style:{width:F?`calc(${B} - 310px)`:`calc(${B} - ${I?"30px":"0px"} - 160px)`},numberOfLines:1},{children:P.name}))})),e.jsxs(u.ProductInfo,{children:[e.jsx(s.ProductPickerTag,{isVariant:$,data:R,tagText:F,tagType:W}),A&&e.jsx(c.IconButton,{onClick:()=>{null==q||q(P)},Icon:()=>e.jsx(i.default,{width:20,height:20,color:t.COLORS.content.placeholder})})]})]})),e.jsxs(u.ProductSubTitle,{children:[!(null==R?void 0:R.fbStatus)&&$||F?null:e.jsx(r.BodyCaption,Object.assign({color:t.COLORS.content.secondary},{children:U})),L&&e.jsx(l.Tooltip,Object.assign({body:L,placement:"top"},{children:e.jsx(u.SKUIDBadge,{children:e.jsx(u.EllipsedBodyTiny,{children:`SKU ID: ${L}`})})}))]})]}))]}))};exports.ProductCard=p,exports.ProductGroup=t=>{var i,o,c,d,l,r,a,s,u;const{collectionId:h,productId:y,data:j,selectedData:I,selectedCollectionsDispatch:P,viewOnly:x,upliftAdditions:k,isProductPartiallyChecked:g,hideProductCheckbox:C,outOfStockAction:b,hideVariantCheckbox:O,hideProductVariants:S,pickerType:m,onProductDetailClick:f,showProductDetailInfoIcon:T,pickerWidth:D}=t,V=e=>{var t,i,o,c,d,l;if(!(null===(i=null===(t=null==I?void 0:I[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[y]))return!1;return!!(null===(l=null===(d=null===(c=null===(o=null==I?void 0:I[h])||void 0===o?void 0:o.products)||void 0===c?void 0:c[y])||void 0===d?void 0:d.variants)||void 0===l?void 0:l[e])},w=S||!v.shouldShowVariant(j)?`${j.currency&&null!==(i=n.CurrencySymbols[j.currency])&&void 0!==i?i:""}${null!==(u=null!==(l=null===(d=null===(c=Object.values(null!==(o=j.variants)&&void 0!==o?o:{}))||void 0===c?void 0:c[0])||void 0===d?void 0:d.price)&&void 0!==l?l:null===(s=null===(a=Object.values(null!==(r=j.variants)&&void 0!==r?r:{}))||void 0===a?void 0:a[0])||void 0===s?void 0:s.actualPrice)&&void 0!==u?u:""}`:"";return e.jsxs("div",{children:[e.jsx(p,{isVariant:!1,data:j,productId:y,collectionId:h,isSelected:(()=>{var e,t;return!!(null===(t=null===(e=null==I?void 0:I[h])||void 0===e?void 0:e.products)||void 0===t?void 0:t[y])})(),isPartiallyChecked:g,selectedCollectionsDispatch:P,upliftAdditions:k,viewOnly:x,hideProductCheckbox:C,hideVariantCheckbox:O,hideProductVariants:S,pickerType:m,outOfStockAction:b,onProductDetailClick:f,showProductDetailInfoIcon:T,currencyAndPrice:w,pickerWidth:D},y),S?null:v.shouldShowVariant(j)&&Object.keys(j.variants||[]).map((t=>{var i,o,c,d,l,r,a;const s=`${j.currency&&null!==(i=n.CurrencySymbols[j.currency])&&void 0!==i?i:""}${null!==(a=null!==(d=null===(c=null===(o=j.variants)||void 0===o?void 0:o[t])||void 0===c?void 0:c.price)&&void 0!==d?d:null===(r=null===(l=j.variants)||void 0===l?void 0:l[t])||void 0===r?void 0:r.actualPrice)&&void 0!==a?a:""}`;return e.jsx(p,{isVariant:!0,hideVariantCheckbox:O,data:Object.assign(Object.assign({},j.variants[t]),{currency:j.currency}),variantId:t,productId:y,viewOnly:x,upliftAdditions:k,collectionId:h,isSelected:V(t),selectedCollectionsDispatch:P,outOfStockAction:b,onProductDetailClick:f,showProductDetailInfoIcon:T,currencyAndPrice:s,pickerWidth:D},t)}))]})};
|
|
@@ -24,6 +24,7 @@ interface SearchScreenInterface {
|
|
|
24
24
|
hideCollectionCheckbox?: boolean;
|
|
25
25
|
renderWithoutModal?: boolean;
|
|
26
26
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
27
|
+
pickerWidth?: string;
|
|
27
28
|
}
|
|
28
29
|
export declare const SearchScreen: (props: SearchScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),c=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:p,searchedCollections:v,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:k,collections:y,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:f,storeId:m,fbStatusFetcher:O,setCollectionId:g,setSelectedCollectionId:I,hideCollectionCheckbox:q,renderWithoutModal:D,outOfStockAction:F,pickerWidth:T}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=v.products)&&void 0!==e?e:{},m,C,O,"setProducts")}),[null==v?void 0:v.products]);const W=!!h&&(null==p?void 0:p.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{k("collections"),b()}}),e.jsx(i.BodyCaption,{children:(null===(a=Object.keys(null==v?void 0:v.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==v?void 0:v.products).length||Object.keys(null==v?void 0:v.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==v?void 0:v.collections).map((t=>e.jsx(c.CollectionCard,{customCollectionRestriction:h,data:null==y?void 0:y[t],isDisabled:W&&!(null==p?void 0:p[t]),isChecked:!!(null==p?void 0:p[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==y?void 0:y[t],p,P),selectedCollectionsDispatch:j,setCollectionId:g,setSelectedCollectionId:I,setScreen:k,id:t,hideCollectionCheckbox:q||"-1"===t,selectedCollections:p,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==v?void 0:v.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,i,c;let s=!1;return(null===(l=null==v?void 0:v.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const i=n.liftTheStateUp(o,null===(l=null==v?void 0:v.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},i),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(i=null==v?void 0:v.products)||void 0===i?void 0:i[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,p,null===(c=v.products)||void 0===c?void 0:c[t],P),selectedData:p,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:f,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S,outOfStockAction:F,pickerWidth:T},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
|
|
@@ -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 g}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as b}from"./productScreen.js";import{RearrangeScreen as f}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as S,selectedColectionsReducer as k,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as x}from"./selectedScreen.js";import{ContainerStyle as I,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";var T;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(T||(T={}));const R=R=>{const{storeId:w,selectedItems:A,onClose:B,visible:E,zIndex:L,exactLimit:z,limit:V,hideCollectionCheckbox
|
|
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 g}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as b}from"./productScreen.js";import{RearrangeScreen as f}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as S,selectedColectionsReducer as k,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as x}from"./selectedScreen.js";import{ContainerStyle as I,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";var T;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(T||(T={}));const R=R=>{const{storeId:w,selectedItems:A,onClose:B,visible:E,zIndex:L,exactLimit:z,limit:V,hideCollectionCheckbox:W,hideProductCheckbox:$,outOfStockAction:M=D.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:G,hideSelectionCount:K,title:N,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,ge]=s(""),[Ce,be]=s(""),[fe,ye]=s(0),[Se,ke]=s(!1),[ve,je]=s(0),[xe,Ie]=s(""),[Pe,Oe]=s(!1),[De,Fe]=s(!1),[Te,Re]=r(S,{collections:{},products:{}}),[we,Ae]=r(k,Object.keys(A).length>0?A:{}),Be=i(null),[Ee,Le]=s(!1),[ze,Ve]=s();n((()=>{ke(!0),Fe(!0),R.collectionFetcher(fe,w).then((e=>{console.log("collectionsParsed?.collections",null==e?void 0:e.collections),de({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ke(!1),ye((e=>e+1)),Fe(!1)})).catch()}),[]),n((()=>{let e=0;X?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),je(e)}),[le,we,X]),n((()=>{Ce&&(ke(!0),R.productFetcher(Ce,w).then((e=>{Object.keys(e).length&&de({type:"productsFetched",data:{collectionId:Ce,products:e}}),ke(!1)})).catch())}),[Ce]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ae&&(xe.length||"collections"!==ae)&&(xe.length?(Oe(!0),R.searchFetcher(w,xe).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"),ke(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[xe]),n((()=>{J&&(R.onAdd(we,ve),We())}),[J]),n((()=>{ee&&Object.keys(we||{}).length&&ve&&(R.onAdd(we,ve),We())}),[ee,we,ve]);const We=()=>{Ae({type:"reset",data:{}})},$e=()=>z&&ve>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):V&&ve>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):t(a,ve>0?{onClick:()=>{ue(_?T.RearrangeProducts:T.SelectedProducts)},buttonText:z?`${ve}/${z} products selected`:`${ve} products selected`,buttonType:["rearrange","view"].includes(ae)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ae)}:{disabled:!0,buttonText:z?`${ve}/${z} products selected`:`${ve} products selected`,buttonType:"tertiaryGray"}),Me=e=>Se?"Loading...":ae===T.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",He=e(I,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 products using name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Pe?t(p,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:xe,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e(P,Object.assign({ref:Be,screenName:ae},{children:["collections"===ae&&t(g,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:De,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:be,setScreen:ue,selectedCollections:we,collectionFetcher:R.collectionFetcher,storeId:w,collectionsDispatch:de,setSaveDisabled:ke,pagingControls:{curPage:fe,setCurPage:ye},hideCollectionCheckbox:W,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Be}),"products"===ae&&me&&t(v.Provider,Object.assign({value:me},{children:t(b,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:ue,storeId:w,data:le[me],collectionsDispatch:de,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:ke,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:te,scrollContainerRef:Be,pickerWidth:U||"600px"})})),"view"===ae&&t(x,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:X,outOfStockAction:M,storeId:w,fbStatusFetcher:R.fbStatusFetcher,pickerWidth:U||"600px"}),"rearrange"===ae&&t(f,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Be,storeId:w,fbStatusFetcher:R.fbStatusFetcher,pickerWidth:U||"600px"}),"searchProducts"===ae&&t(j,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:we||{},searchedCollections:Te||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:$,hideProductVariants:X,hideVariantCheckbox:H,storeId:w,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:be,renderWithoutModal:q,hideCollectionCheckbox:W,outOfStockAction:M,pickerWidth:U||"600px"})]}))]}));return t(o,{children:q?e(o,{children:[He,re.renderFooter?e(O,{children:[$e(),t(a,{buttonText:Me(re.primaryButtonText),disabled:!re.isLoading&&(Se||ve<1||z&&ve<z||!z&&V&&ve>V)||re.primaryButtonDisabled,isLoading:re.isLoading,onClick:()=>{R.onAdd(we,ve),We(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}})]}):t(o,{}),Ee&&ze?t(C,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:L,open:E,onClose:()=>{null==B||B(),We()},headingTitle:N||("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||ve<1||z&&ve<z||!z&&V&&ve>V)||e.disabled,onClick:()=>{R.onAdd(we,ve),We(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}}))(se):{buttonText:Me(),disabled:Se||ve<1||z&&ve<z||!z&&V&&ve>V||!1,onClick:()=>{R.onAdd(we,ve),We()}},secondaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:Se||ve<1||z&&ve<z||!z&&V&&ve>V||!1,onClick:()=>{const e=F(we,le,Te);R.onAdd(e,ve,!0)}}))(ie):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:K?t(o,{}):$e(),hideCrossButton:Ee||ce},{children:[He,Ee&&ze?t(C,{productData:ze,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):t(o,{})]}))})};export{R as ProductPickerModal,T as ScreenName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as i,Fragment as o}from"react/jsx-runtime";import{COLORS as e}from"../../constants/Theme.js";import
|
|
1
|
+
import{jsxs as t,jsx as i,Fragment as o}from"react/jsx-runtime";import{COLORS as e}from"../../constants/Theme.js";import c from"../../assets/icons/info.svg.js";import{CheckBox as d}from"../checkBox/CheckBox.js";import{IconButton as l}from"../icon-button/IconButton.js";import{ShimmerImage as n}from"../shimmer-image/ShimmerImage.js";import{Tooltip as r}from"../tooltips/Tooltip.js";import{BodyCaption as a}from"../TypographyStyle.js";import{CurrencySymbols as s}from"./constants.js";import{ProductHelper as u}from"./helpers/ProductHelper.js";import{ProductPickerTag as v}from"./ProductPickerTag.js";import{ProductCardStyle as p,StyledTitleSmall as h,ProductInfo as I,ProductSubTitle as m,SKUIDBadge as y,EllipsedBodyTiny as k}from"./style.js";import{shouldShowVariant as P}from"./utility.js";const f=o=>{var e,c,d,l,n,r,a,u,v;const{collectionId:p,productId:h,data:I,selectedData:m,selectedCollectionsDispatch:y,viewOnly:k,upliftAdditions:f,isProductPartiallyChecked:b,hideProductCheckbox:j,outOfStockAction:C,hideVariantCheckbox:O,hideProductVariants:x,pickerType:D,onProductDetailClick:S,showProductDetailInfoIcon:T,pickerWidth:V}=o,w=t=>{var i,o,e,c,d,l;if(!(null===(o=null===(i=null==m?void 0:m[p])||void 0===i?void 0:i.products)||void 0===o?void 0:o[h]))return!1;return!!(null===(l=null===(d=null===(c=null===(e=null==m?void 0:m[p])||void 0===e?void 0:e.products)||void 0===c?void 0:c[h])||void 0===d?void 0:d.variants)||void 0===l?void 0:l[t])},A=x||!P(I)?`${I.currency&&null!==(e=s[I.currency])&&void 0!==e?e:""}${null!==(v=null!==(n=null===(l=null===(d=Object.values(null!==(c=I.variants)&&void 0!==c?c:{}))||void 0===d?void 0:d[0])||void 0===l?void 0:l.price)&&void 0!==n?n:null===(u=null===(a=Object.values(null!==(r=I.variants)&&void 0!==r?r:{}))||void 0===a?void 0:a[0])||void 0===u?void 0:u.actualPrice)&&void 0!==v?v:""}`:"";return t("div",{children:[i(g,{isVariant:!1,data:I,productId:h,collectionId:p,isSelected:(()=>{var t,i;return!!(null===(i=null===(t=null==m?void 0:m[p])||void 0===t?void 0:t.products)||void 0===i?void 0:i[h])})(),isPartiallyChecked:b,selectedCollectionsDispatch:y,upliftAdditions:f,viewOnly:k,hideProductCheckbox:j,hideVariantCheckbox:O,hideProductVariants:x,pickerType:D,outOfStockAction:C,onProductDetailClick:S,showProductDetailInfoIcon:T,currencyAndPrice:A,pickerWidth:V},h),x?null:P(I)&&Object.keys(I.variants||[]).map((t=>{var o,e,c,d,l,n,r;const a=`${I.currency&&null!==(o=s[I.currency])&&void 0!==o?o:""}${null!==(r=null!==(d=null===(c=null===(e=I.variants)||void 0===e?void 0:e[t])||void 0===c?void 0:c.price)&&void 0!==d?d:null===(n=null===(l=I.variants)||void 0===l?void 0:l[t])||void 0===n?void 0:n.actualPrice)&&void 0!==r?r:""}`;return i(g,{isVariant:!0,hideVariantCheckbox:O,data:Object.assign(Object.assign({},I.variants[t]),{currency:I.currency}),variantId:t,productId:h,viewOnly:k,upliftAdditions:f,collectionId:p,isSelected:w(t),selectedCollectionsDispatch:y,outOfStockAction:C,onProductDetailClick:S,showProductDetailInfoIcon:T,currencyAndPrice:a,pickerWidth:V},t)}))]})},g=s=>{var P,f,g,b,j;const{isVariant:C,data:O,productId:x,collectionId:D,variantId:S,isSelected:T,selectedCollectionsDispatch:V,viewOnly:w,upliftAdditions:A,isPartiallyChecked:U,hideProductCheckbox:$,outOfStockAction:W,hideVariantCheckbox:B,hideProductVariants:F,pickerType:R="PRODUCT",onProductDetailClick:H,showProductDetailInfoIcon:K,currencyAndPrice:L,pickerWidth:q}=s,{isVariantForProductPickerTag:z,dataForProductPickerTag:E,tagText:G,tagType:J}=u.getDataForProductPickerTag(O,C,W);console.log({data:O});const M=C?O.skuId:1===(null===(f=Object.values(null!==(P=null==O?void 0:O.variants)&&void 0!==P?P:{}))||void 0===f?void 0:f.length)?null===(j=null===(b=Object.values(null!==(g=null==O?void 0:O.variants)&&void 0!==g?g:{}))||void 0===b?void 0:b[0])||void 0===j?void 0:j.skuId:void 0;return t(p,Object.assign({isVariant:C,onClick:t=>{if(t.stopPropagation(),"PRODUCT"===R&&($||B)){const t=Object.keys(O.variants);F?T?V({type:"productUnselected",data:{productId:x,collectionId:D}}):A("productSelected",{productId:x,variantId:S,collectionId:D,product:O}):T?V({type:"variantUnselected",data:{productId:x,variantId:S,collectionId:D}}):A("variantSelected",{productId:x,variantId:S||t[0],collectionId:D,variant:O})}},isActive:T},{children:[C&&!w&&!B||!C&&!w&&!$?i(d,{isChecked:T,isPartiallyChecked:U||!1,onValueChange:function(t,i,o){null==o||o.stopPropagation(),C?t?A(F?"productSelected":"variantSelected",{productId:x,variantId:S,collectionId:D,variant:O}):V({type:F?"productUnselected":"variantUnselected",data:{productId:x,variantId:S,collectionId:D}}):t?A("productSelected",{productId:x,collectionId:D,product:O}):V({type:"productUnselected",data:{productId:x,collectionId:D}})}}):i(o,{}),i("div",{children:i(n,{width:40,height:40,imageUrl:O.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[i(r,Object.assign({variant:"light",body:O.name,placement:"bottom",delay:400},{children:i(h,Object.assign({style:{width:G?`calc(${q} - 310px)`:`calc(${q} - ${C?"30px":"0px"} - 160px)`},numberOfLines:1},{children:O.name}))})),t(I,{children:[i(v,{isVariant:z,data:E,tagText:G,tagType:J}),K&&i(l,{onClick:()=>{null==H||H(O)},Icon:()=>i(c,{width:20,height:20,color:e.content.placeholder})})]})]})),t(m,{children:[!(null==E?void 0:E.fbStatus)&&z||G?null:i(a,Object.assign({color:e.content.secondary},{children:L})),M&&i(r,Object.assign({body:M,placement:"top"},{children:i(y,{children:i(k,{children:`SKU ID: ${M}`})})}))]})]}))]}))};export{g as ProductCard,f as ProductGroup};
|
|
@@ -24,6 +24,7 @@ interface SearchScreenInterface {
|
|
|
24
24
|
hideCollectionCheckbox?: boolean;
|
|
25
25
|
renderWithoutModal?: boolean;
|
|
26
26
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
27
|
+
pickerWidth?: string;
|
|
27
28
|
}
|
|
28
29
|
export declare const SearchScreen: (props: SearchScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import
|
|
1
|
+
import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import{useEffect as l}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:f,selectedCollectionsDispatch:j,setScreen:S,collections:O,onBackPress:P,hideVariantCheckbox:I,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:W,fbStatusFetcher:T,setCollectionId:V,setSelectedCollectionId:w,hideCollectionCheckbox:A,renderWithoutModal:R,outOfStockAction:B,pickerWidth:M}=m;l((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},W,f,T,"setProducts")}),[null==b?void 0:b.products]);const F=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:i,onClick:()=>{S("collections"),P()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==O?void 0:O[o],isDisabled:F&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==O?void 0:O[o],y,x),selectedCollectionsDispatch:j,setCollectionId:V,setSelectedCollectionId:w,setScreen:S,id:o,hideCollectionCheckbox:A||"-1"===o,selectedCollections:y,renderWithoutModal:R,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,i;return Object.keys((null===(i=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===i?void 0:i.products)||[]).map((t=>{var i,l,c;let d=!1;return(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var i;const l=v(t,null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o]);j({type:e,data:Object.assign(Object.assign({},l),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o],x),selectedData:y,selectedCollectionsDispatch:j,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:I,hideProductVariants:x,pickerType:g,outOfStockAction:B,pickerWidth:M},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
|