@bikdotai/bik-component-library 0.0.558-beta.1136 → 0.0.558-beta.1137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +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("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),r=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),d=require("../InfiniteScroll/InfiniteScroll.js"),a=require("../input/Input.js"),u=require("../spinner/Spinner.js"),h=require("../TypographyStyle.js"),p=require("./emptyState.js"),g=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),y=require("./style.js"),f=require("./type.js"),O=require("./utility.js");exports.ProductsScreen=b=>{var C,P;const{data:k,collectionsDispatch:x,selectedData:S,selectedCollectionsDispatch:I,productFetcher:m,storeId:q,setScreen:T,setSaveDisabled:A,hideInCollectionSearch:E,customCollectionRestriction:D,hideProductCheckbox:R,outOfStockAction:V=f.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:F=!1,pickerType:w,hideProductVariants:B,fbStatusFetcher:_,onProductDetailClick:M,showProductDetailInfoIcon:U,scrollContainerRef:H}=b,J=r.useContext(v.CollectionIdContext),K=r.useRef(0),N=r.useRef(!1),[W,z]=r.useState(""),[G,Q]=r.useState(!1),[X,Y]=r.useState(k),Z=r.useRef(!1);r.useEffect((()=>{console.log("changed screen data",X)}),[X]),r.useEffect((()=>{const e=setTimeout((()=>{
|
|
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("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),s=require("lodash"),r=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),d=require("../InfiniteScroll/InfiniteScroll.js"),a=require("../input/Input.js"),u=require("../spinner/Spinner.js"),h=require("../TypographyStyle.js"),p=require("./emptyState.js"),g=require("./product.js"),j=require("./ProductPickerShimmer.js"),v=require("./reducers.js"),y=require("./style.js"),f=require("./type.js"),O=require("./utility.js");exports.ProductsScreen=b=>{var C,P;const{data:k,collectionsDispatch:x,selectedData:S,selectedCollectionsDispatch:I,productFetcher:m,storeId:q,setScreen:T,setSaveDisabled:A,hideInCollectionSearch:E,customCollectionRestriction:D,hideProductCheckbox:R,outOfStockAction:V=f.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:F=!1,pickerType:w,hideProductVariants:B,fbStatusFetcher:_,onProductDetailClick:M,showProductDetailInfoIcon:U,scrollContainerRef:H}=b,J=r.useContext(v.CollectionIdContext),K=r.useRef(0),N=r.useRef(!1),[W,z]=r.useState(""),[G,Q]=r.useState(!1),[X,Y]=r.useState(k),Z=r.useRef(!1);r.useEffect((()=>{console.log("changed screen data",X)}),[X]),r.useEffect((()=>{const e=setTimeout((()=>{W.length?(Q(!0),b.searchInCollectionFetcher(q,J,W).then((e=>{const t=s.cloneDeep(k);t.products=e,Y(t),console.log("i changed at searchText.length");const o=O.getVariantIdsToFetchAtProductLevel(null!=e?e:{});ee(o,null!=e?e:{},!0),A(!1),Q(!1)}))):console.log("i changed at earchText.length")}),800);return()=>clearTimeout(e)}),[W]);r.useEffect((()=>{var e,t,o,c;Z.current=!1,K.current=Math.floor((null===(t=Object.keys(null!==(e=k.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const s=O.getVariantIdsToFetchAtProductLevel(null!==(o=k.products)&&void 0!==o?o:{});ee(s,null!==(c=k.products)&&void 0!==c?c:{})}),[J]);const $=!!D&&k.isSmartCollection;r.useEffect((()=>{(null==k?void 0:k.products)||te(10)}),[]);const ee=(e,t,o)=>{console.log("func called",_),_||(o?O.markVariantsAsApprovedProductsLevel(t,x,J,X,Y):O.markVariantsAsApprovedProductsLevel(t,x,J)),e.length>0&&_&&_(q,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((o=>{var s,r;Object.keys(null!==(r=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.variants)&&void 0!==r?r:{}).forEach((s=>{var r,n;const i=null===(r=null==t?void 0:t[o].variants)||void 0===r?void 0:r[s];i&&"REJECTED"===e[s]?i.fbStatus="REJECTED":i&&"APPROVED"===e[s]&&(i.fbStatus="APPROVED");const l=null===(n=null==c?void 0:c[o])||void 0===n?void 0:n.variants;l&&l[s]&&(l[s]=i)}))})),o?(Y((e=>{const t=Object.assign({},e);return t.products=c,t})),x({type:"productsPaged",data:{collectionId:J,products:c}})):x({type:"productsPaged",data:{collectionId:J,products:c}})})).catch((e=>{o?O.markVariantsAsApprovedProductsLevel(t,x,J,X,Y):O.markVariantsAsApprovedProductsLevel(t,x,J)}))},te=e=>{A(!0),Q(!0),m(J,q,e,0).then((t=>{if(Object.keys(t).length||(Z.current=!0),Object.keys(t).length){Y(Object.assign(Object.assign({},X),{products:t})),console.log("i changed at getProductsForCollection");const e=O.getVariantIdsToFetchAtProductLevel(t);ee(e,t),K.current=1}e||I({type:"selected",data:{id:J,val:Object.assign(Object.assign({},k),{products:t})}}),A(!1),Q(!1)})).catch()},oe=(e,t)=>{const o=O.liftTheStateUp(t,k);I({type:e,data:Object.assign(Object.assign({},o),{isRestricted:D})})},ce=!!(null==S?void 0:S[J])&&!!Object.keys(null!==(P=null===(C=null==S?void 0:S[J])||void 0===C?void 0:C.products)&&void 0!==P?P:{}).length;return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{T("collections")}}),e.jsx(h.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:k.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>G&&W.length?e.jsx(u.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:W,onChangeText:e=>{e.length&&e.trim().length?z(e):z("")},placeholder:"Search products in this collection..."})})),Object.keys((null==X?void 0:X.products)||[]).length>0&&!$&&!W.length&&!R&&"-1"!==J&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:ce,isPartiallyChecked:O.isCollectionPartiallyChecked(J,X,S,B),onValueChange:function(e){e?te():I({type:"unselected",data:{id:J}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(o.default,{})})),e.jsx(h.TitleRegular,{children:"All Products"})]}),e.jsx(d.InfiniteScroll,Object.assign({hasData:!(Object.keys((null==X?void 0:X.products)||[]).length<10)&&!!Object.keys((null==X?void 0:X.products)||[]).length,fetchMore:()=>(N.current=!0,m(J,q,10,K.current).then((e=>{let t=!1;if(Object.keys(e).length||(t=!0),Object.keys(e).length){const t=X;t.products=Object.assign(Object.assign({},X.products),e),Y(Object.assign({},t)),console.log("i changed at fetch more");const o=O.getVariantIdsToFetchAtProductLevel(e);ee(o,e)}return A(!1),N.current=!1,K.current+=1,t}))),containerRef:H},{children:Object.keys((null==X?void 0:X.products)||[]).length?Object.keys(X.products||[]).map((t=>e.jsx(g.ProductGroup,{outOfStockAction:V,collectionId:J,isProductPartiallyChecked:O.isProductPartiallyChecked(J,t,S,X,B),productId:t,data:X.products[t],selectedData:S,selectedCollectionsDispatch:I,viewOnly:!F&&!!$,upliftAdditions:oe,hideProductCheckbox:R,hideVariantCheckbox:L,hideProductVariants:B,pickerType:w,onProductDetailClick:M,showProductDetailInfoIcon:U},t))):G?e.jsx(j.ProductPickerShimmer,{limit:10}):e.jsx(p.EmptyState,{title:"No products to show",subtitle:W.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})}))]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import n from"../../assets/icons/search.svg.js";import{cloneDeep as s}from"lodash";import{useContext as i,useRef as r,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{InfiniteScroll as p}from"../InfiniteScroll/InfiniteScroll.js";import{Input as g}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import n from"../../assets/icons/search.svg.js";import{cloneDeep as s}from"lodash";import{useContext as i,useRef as r,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{InfiniteScroll as p}from"../InfiniteScroll/InfiniteScroll.js";import{Input as g}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as j,TitleRegular as f}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as y}from"./ProductPickerShimmer.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as C}from"./style.js";import{OUT_OF_STOCK_ACTION as P}from"./type.js";import{getVariantIdsToFetchAtProductLevel as I,markVariantsAsApprovedProductsLevel as x,isCollectionPartiallyChecked as D,isProductPartiallyChecked as S,liftTheStateUp as E}from"./utility.js";const T=T=>{var R,w;const{data:V,collectionsDispatch:A,selectedData:B,selectedCollectionsDispatch:F,productFetcher:J,storeId:M,setScreen:W,setSaveDisabled:z,hideInCollectionSearch:H,customCollectionRestriction:K,hideProductCheckbox:L,outOfStockAction:N=P.BLUR,hideVariantCheckbox:U=!1,selectProductsFromCustomCollection:_=!1,pickerType:q,hideProductVariants:G,fbStatusFetcher:Q,onProductDetailClick:X,showProductDetailInfoIcon:Y,scrollContainerRef:Z}=T,$=i(O),tt=r(0),et=r(!1),[ot,ct]=l(""),[nt,st]=l(!1),[it,rt]=l(V),lt=r(!1);d((()=>{console.log("changed screen data",it)}),[it]),d((()=>{const t=setTimeout((()=>{ot.length?(st(!0),T.searchInCollectionFetcher(M,$,ot).then((t=>{const e=s(V);e.products=t,rt(e),console.log("i changed at searchText.length");const o=I(null!=t?t:{});at(o,null!=t?t:{},!0),z(!1),st(!1)}))):console.log("i changed at earchText.length")}),800);return()=>clearTimeout(t)}),[ot]);d((()=>{var t,e,o,c;lt.current=!1,tt.current=Math.floor((null===(e=Object.keys(null!==(t=V.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const n=I(null!==(o=V.products)&&void 0!==o?o:{});at(n,null!==(c=V.products)&&void 0!==c?c:{})}),[$]);const dt=!!K&&V.isSmartCollection;d((()=>{(null==V?void 0:V.products)||ut(10)}),[]);const at=(t,e,o)=>{console.log("func called",Q),Q||(o?x(e,A,$,it,rt):x(e,A,$)),t.length>0&&Q&&Q(M,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var n,s;Object.keys(null!==(s=null===(n=null==e?void 0:e[o])||void 0===n?void 0:n.variants)&&void 0!==s?s:{}).forEach((n=>{var s,i;const r=null===(s=null==e?void 0:e[o].variants)||void 0===s?void 0:s[n];r&&"REJECTED"===t[n]?r.fbStatus="REJECTED":r&&"APPROVED"===t[n]&&(r.fbStatus="APPROVED");const l=null===(i=null==c?void 0:c[o])||void 0===i?void 0:i.variants;l&&l[n]&&(l[n]=r)}))})),o?(rt((t=>{const e=Object.assign({},t);return e.products=c,e})),A({type:"productsPaged",data:{collectionId:$,products:c}})):A({type:"productsPaged",data:{collectionId:$,products:c}})})).catch((t=>{o?x(e,A,$,it,rt):x(e,A,$)}))},ut=t=>{z(!0),st(!0),J($,M,t,0).then((e=>{if(Object.keys(e).length||(lt.current=!0),Object.keys(e).length){rt(Object.assign(Object.assign({},it),{products:e})),console.log("i changed at getProductsForCollection");const t=I(e);at(t,e),tt.current=1}t||F({type:"selected",data:{id:$,val:Object.assign(Object.assign({},V),{products:e})}}),z(!1),st(!1)})).catch()},ht=(t,e)=>{const o=E(e,V);F({type:t,data:Object.assign(Object.assign({},o),{isRestricted:K})})},pt=!!(null==B?void 0:B[$])&&!!Object.keys(null!==(w=null===(R=null==B?void 0:B[$])||void 0===R?void 0:R.products)&&void 0!==w?w:{}).length;return t("div",{children:[t(k,{children:[e(h,{Icon:o,height:16,onClick:()=>{W("collections")}}),e(j,Object.assign({style:{color:a.content.secondary}},{children:V.name}))]}),!H&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(g,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>nt&&ot.length?e(m,{size:"small",color:a.content.primary}):e(n,{})},id:"listInput",height:"24px",type:"text",value:ot,onChangeText:t=>{t.length&&t.trim().length?ct(t):ct("")},placeholder:"Search products in this collection..."})})),Object.keys((null==it?void 0:it.products)||[]).length>0&&!dt&&!ot.length&&!L&&"-1"!==$&&t(C,{children:[e(u,{isChecked:pt,isPartiallyChecked:D($,it,B,G),onValueChange:function(t){t?ut():F({type:"unselected",data:{id:$}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(f,{children:"All Products"})]}),e(p,Object.assign({hasData:!(Object.keys((null==it?void 0:it.products)||[]).length<10)&&!!Object.keys((null==it?void 0:it.products)||[]).length,fetchMore:()=>(et.current=!0,J($,M,10,tt.current).then((t=>{let e=!1;if(Object.keys(t).length||(e=!0),Object.keys(t).length){const e=it;e.products=Object.assign(Object.assign({},it.products),t),rt(Object.assign({},e)),console.log("i changed at fetch more");const o=I(t);at(o,t)}return z(!1),et.current=!1,tt.current+=1,e}))),containerRef:Z},{children:Object.keys((null==it?void 0:it.products)||[]).length?Object.keys(it.products||[]).map((t=>e(b,{outOfStockAction:N,collectionId:$,isProductPartiallyChecked:S($,t,B,it,G),productId:t,data:it.products[t],selectedData:B,selectedCollectionsDispatch:F,viewOnly:!_&&!!dt,upliftAdditions:ht,hideProductCheckbox:L,hideVariantCheckbox:U,hideProductVariants:G,pickerType:q,onProductDetailClick:X,showProductDetailInfoIcon:Y},t))):nt?e(y,{limit:10}):e(v,{title:"No products to show",subtitle:ot.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})}))]})};export{T as ProductsScreen};
|