@bikdotai/bik-component-library 0.0.453-beta.ppi-2 → 0.0.453-beta.ppi-4
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"),r=require("react"),s=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),c=require("./emptyState.js"),i=require("./productScreen.js"),n=require("./reducers.js"),u=require("./style.js"),l=require("./useFetchFbStatus.js"),d=require("./useFetchFbStatus copy.js"),a=require("./utility.js");exports.SearchScreen=v=>{const{customCollectionRestriction:h,selectedCollections:p,searchedCollections:j,selectedCollectionsDispatch:b,setScreen:y,collections:f,onBackPress:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),c=require("./emptyState.js"),i=require("./productScreen.js"),n=require("./reducers.js"),u=require("./style.js"),l=require("./useFetchFbStatus.js"),d=require("./useFetchFbStatus copy.js"),a=require("./utility.js");exports.SearchScreen=v=>{const{customCollectionRestriction:h,selectedCollections:p,searchedCollections:j,selectedCollectionsDispatch:b,setScreen:y,collections:f,onBackPress:x,hideVariantCheckbox:g,pickerType:S,hideProductVariants:k,hideProductCheckbox:C,storeId:q,fbStatusFetcher:F}=v;l.useFetchFbStatusForCollections(j,q,b,F,!0);const P=r.useRef(1),O=r.useRef(null),[m,I]=r.useReducer(n.paginationReducer,{});r.useEffect((()=>{I({type:"paginate",data:j}),d.fetchFbStatus(j,q,I,F,!0),P.current+=1}),[]),r.useEffect((()=>{console.log("vj: observertarget",O.current);const e=new IntersectionObserver((e=>{console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",P.current),P.current>0&&v.searchFetcher(q,v.searchText,10,P.current).then((e=>{I({type:"paginate",data:e}),d.fetchFbStatus(e,q,I,F),P.current+=1})))}),{threshold:1});return O.current&&e.observe(O.current),()=>{O.current&&e.unobserve(O.current)}}),[O]);const R=(e,t)=>{var r,s,o,c,i,n,u,l,d;let a=0,v=0;return!!((null===(s=null===(r=null==p?void 0:p[e])||void 0===r?void 0:r.products)||void 0===s?void 0:s[t])&&(null===(n=Object.keys((null===(i=null===(c=null===(o=null==f?void 0:f[e])||void 0===o?void 0:o.products)||void 0===c?void 0:c[t])||void 0===i?void 0:i.variants)||[]))||void 0===n||n.forEach((()=>v++)),Object.keys((null===(d=null===(l=null===(u=null==p?void 0:p[e])||void 0===u?void 0:u.products)||void 0===l?void 0:l[t])||void 0===d?void 0:d.variants)||[]).forEach((()=>a++)),a>0&&v!==a))};return e.jsxs("div",{children:[e.jsxs(u.SelectedScreenHeader,{children:[e.jsx(s.IconButton,{Icon:t.default,onClick:()=>{y("collections"),x()}}),e.jsx(o.BodyCaption,{children:"Searched Products"})]}),e.jsxs("div",{children:[Object.keys(m).length?e.jsx(e.Fragment,{children:Object.keys(m).map((t=>{var r;return Object.keys((null===(r=null==m?void 0:m[t])||void 0===r?void 0:r.products)||[]).map((r=>{let s=!1;return(null==m?void 0:m.isCustom)&&(s=!0),e.jsx(i.ProductGroup,{collectionId:t,upliftAdditions:(e,r)=>((e,t,r)=>{const s=a.liftTheStateUp(r,j[e]);b({type:t,data:Object.assign(Object.assign({},s),{isRestricted:h})})})(t,e,r),productId:r,data:m[t].products[r],isProductPartiallyChecked:R(t,r),selectedData:p,selectedCollectionsDispatch:b,viewOnly:s,hideProductCheckbox:C,hideVariantCheckbox:g,hideProductVariants:k,pickerType:S},r)}))}))}):e.jsx(c.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."}),e.jsx("div",{ref:O})]})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as i,useEffect as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as i,useEffect as s}from"react";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./productScreen.js";import{paginationReducer as a}from"./reducers.js";import{SelectedScreenHeader as v}from"./style.js";import{useFetchFbStatusForCollections as p}from"./useFetchFbStatus.js";import{fetchFbStatus as h}from"./useFetchFbStatus copy.js";import{liftTheStateUp as m}from"./utility.js";const f=f=>{const{customCollectionRestriction:b,selectedCollections:j,searchedCollections:y,selectedCollectionsDispatch:g,setScreen:k,collections:C,onBackPress:O,hideVariantCheckbox:P,pickerType:x,hideProductVariants:S,hideProductCheckbox:I,storeId:F,fbStatusFetcher:w}=f;p(y,F,g,w,!0);const T=c(1),V=c(null),[D,R]=i(a,{});s((()=>{R({type:"paginate",data:y}),h(y,F,R,w,!0),T.current+=1}),[]),s((()=>{console.log("vj: observertarget",V.current);const e=new IntersectionObserver((e=>{console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",T.current),T.current>0&&f.searchFetcher(F,f.searchText,10,T.current).then((e=>{R({type:"paginate",data:e}),h(e,F,R,w),T.current+=1})))}),{threshold:1});return V.current&&e.observe(V.current),()=>{V.current&&e.unobserve(V.current)}}),[V]);const B=(e,t)=>{var o,r,c,i,s,n,l,d,u;let a=0,v=0;return!!((null===(r=null===(o=null==j?void 0:j[e])||void 0===o?void 0:o.products)||void 0===r?void 0:r[t])&&(null===(n=Object.keys((null===(s=null===(i=null===(c=null==C?void 0:C[e])||void 0===c?void 0:c.products)||void 0===i?void 0:i[t])||void 0===s?void 0:s.variants)||[]))||void 0===n||n.forEach((()=>v++)),Object.keys((null===(u=null===(d=null===(l=null==j?void 0:j[e])||void 0===l?void 0:l.products)||void 0===d?void 0:d[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&v!==a))};return e("div",{children:[e(v,{children:[t(n,{Icon:r,onClick:()=>{k("collections"),O()}}),t(l,{children:"Searched Products"})]}),e("div",{children:[Object.keys(D).length?t(o,{children:Object.keys(D).map((e=>{var o;return Object.keys((null===(o=null==D?void 0:D[e])||void 0===o?void 0:o.products)||[]).map((o=>{let r=!1;return(null==D?void 0:D.isCustom)&&(r=!0),t(u,{collectionId:e,upliftAdditions:(t,o)=>((e,t,o)=>{const r=m(o,y[e]);g({type:t,data:Object.assign(Object.assign({},r),{isRestricted:b})})})(e,t,o),productId:o,data:D[e].products[o],isProductPartiallyChecked:B(e,o),selectedData:j,selectedCollectionsDispatch:g,viewOnly:r,hideProductCheckbox:I,hideVariantCheckbox:P,hideProductVariants:S,pickerType:x},o)}))}))}):t(d,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."}),t("div",{ref:V})]})]})};export{f as SearchScreen};
|