@bikdotai/bik-component-library 0.0.439-beta.ppi-9 → 0.0.439-beta.ppi-11
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"),
|
|
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"),s=require("../icon-button/IconButton.js"),r=require("../TypographyStyle.js"),n=require("./emptyState.js"),c=require("./productScreen.js"),i=require("./style.js"),l=require("./utility.js");exports.SelectedScreen=d=>{const{selectedCollections:u,selectedCollectionsDispatch:a,setScreen:v,collections:p,outOfStockAction:j}=d,[g,b]=o.useState({}),f=o.useRef(0),O=o.useRef(null);o.useEffect((()=>{f.current=0;const e=l.paginateSelectedItems(u,10,f.current);console.log("paginated",{paginatedProducts:e,selectedCollections:u}),b(e),f.current+=1}),[]),o.useEffect((()=>{b((e=>{var t,o,s,r;const n=Object.assign({},e);for(const e in n)if(e in n){const c=n[e],i={};for(const n in c.products)if(n in c.products){const l=c.products[n],d={};for(const c in l.variants)if(c in l.variants){void 0!==(null===(r=null===(s=null===(o=null===(t=u[e])||void 0===t?void 0:t.products)||void 0===o?void 0:o[n])||void 0===s?void 0:s.variants)||void 0===r?void 0:r[c])&&(d[c]=l.variants[c])}Object.keys(d).length>0&&(i[n]=Object.assign(Object.assign({},l),{variants:d}))}Object.keys(i).length>0?n[e]=Object.assign(Object.assign({},c),{products:i}):delete n[e]}return n}))}),[u]),o.useEffect((()=>{console.log("vj: observertarget",O.current);const e=new IntersectionObserver((e=>{if(console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",f.current),f.current>0)){const e=l.paginateSelectedItems(u,10,f.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:u,curScreenData:g}),b((t=>{const o=Object.assign({},t);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const s=e[t];if(Object.prototype.hasOwnProperty.call(o,t)){const e=o[t];o[t]=Object.assign(Object.assign({},e),{products:Object.assign(Object.assign({},e.products),s.products)})}else o[t]=s}return o})),f.current+=1}}),{threshold:1});return O.current&&e.observe(O.current),()=>{O.current&&e.unobserve(O.current)}}),[O]);const y=(e,t)=>{var o,s,r,n,c,i,l,d,a;let v=0,j=0;return!!((null===(s=null===(o=null==u?void 0:u[e])||void 0===o?void 0:o.products)||void 0===s?void 0:s[t])&&(null===(i=Object.keys((null===(c=null===(n=null===(r=null==p?void 0:p[e])||void 0===r?void 0:r.products)||void 0===n?void 0:n[t])||void 0===c?void 0:c.variants)||[]))||void 0===i||i.forEach((()=>j++)),Object.keys((null===(a=null===(d=null===(l=null==u?void 0:u[e])||void 0===l?void 0:l.products)||void 0===d?void 0:d[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>v++)),v>0&&j!==v))};return e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(s.IconButton,{Icon:t.default,onClick:()=>{v("collections")}}),e.jsx(r.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(g).length>0?e.jsx(e.Fragment,{children:Object.keys(g).map((t=>{var o;return Object.keys((null===(o=null==g?void 0:g[t])||void 0===o?void 0:o.products)||[]).map((o=>{let s=!1;return(null==g?void 0:g.isCustom)&&(s=!0),e.jsx(c.ProductGroup,{upliftAdditions:null,collectionId:t,productId:o,data:g[t].products[o],isProductPartiallyChecked:y(t,o),selectedData:u,selectedCollectionsDispatch:a,viewOnly:s,outOfStockAction:j},o)}))}))}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:O})]})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");function e(t,e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");function e(t,e,s){if(!t)return{};const c=Object.keys(t).slice(s,s+e),o={};return c.forEach((e=>{o[e]=t[e]})),o}exports.liftTheStateUp=(e,s)=>{const c=t.cloneDeep(s);if(delete c.products,(e=Object.assign(Object.assign({},e),{catalogOnlyData:c})).productId&&s.products){const o=t.cloneDeep(s.products[e.productId]);(null==o?void 0:o.variants)&&delete o.variants,e=Object.assign(Object.assign({},e),{catalogOnlyData:c,productOnlyData:o})}return e},exports.paginateSelectedItems=function(t,s,c){var o;const n={};let r=0;console.log("paginated offset",c);for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const l=t[a],i=e(l.products,s,c-r);i&&Object.keys(i).length>0&&(n[a]=Object.assign(Object.assign({},l),{products:i})),r+=Object.keys(null!==(o=l.products)&&void 0!==o?o:{}).length}return n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import r from"../../assets/icons/arrow_left.svg.js";import{useState as
|
|
1
|
+
import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import r from"../../assets/icons/arrow_left.svg.js";import{useState as n,useRef as s,useEffect as c}from"react";import{IconButton as i}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{SelectedScreenHeader as a}from"./style.js";import{paginateSelectedItems as v}from"./utility.js";const p=p=>{const{selectedCollections:j,selectedCollectionsDispatch:g,setScreen:b,collections:f,outOfStockAction:O}=p,[m,h]=n({}),y=s(0),k=s(null);c((()=>{y.current=0;const t=v(j,10,y.current);console.log("paginated",{paginatedProducts:t,selectedCollections:j}),h(t),y.current+=1}),[]),c((()=>{h((t=>{var e,o,r,n;const s=Object.assign({},t);for(const t in s)if(t in s){const c=s[t],i={};for(const s in c.products)if(s in c.products){const l=c.products[s],d={};for(const c in l.variants)if(c in l.variants){void 0!==(null===(n=null===(r=null===(o=null===(e=j[t])||void 0===e?void 0:e.products)||void 0===o?void 0:o[s])||void 0===r?void 0:r.variants)||void 0===n?void 0:n[c])&&(d[c]=l.variants[c])}Object.keys(d).length>0&&(i[s]=Object.assign(Object.assign({},l),{variants:d}))}Object.keys(i).length>0?s[t]=Object.assign(Object.assign({},c),{products:i}):delete s[t]}return s}))}),[j]),c((()=>{console.log("vj: observertarget",k.current);const t=new IntersectionObserver((t=>{if(console.log("vj: observertargetinside",t),t[0].isIntersecting&&(console.log("vj: nextPageRef",y.current),y.current>0)){const t=v(j,10,y.current);console.log("paginated inside observer target",{paginatedProducts:t,selectedCollections:j,curScreenData:m}),h((e=>{const o=Object.assign({},e);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e];if(Object.prototype.hasOwnProperty.call(o,e)){const t=o[e];o[e]=Object.assign(Object.assign({},t),{products:Object.assign(Object.assign({},t.products),r.products)})}else o[e]=r}return o})),y.current+=1}}),{threshold:1});return k.current&&t.observe(k.current),()=>{k.current&&t.unobserve(k.current)}}),[k]);const S=(t,e)=>{var o,r,n,s,c,i,l,d,u;let a=0,v=0;return!!((null===(r=null===(o=null==j?void 0:j[t])||void 0===o?void 0:o.products)||void 0===r?void 0:r[e])&&(null===(i=Object.keys((null===(c=null===(s=null===(n=null==f?void 0:f[t])||void 0===n?void 0:n.products)||void 0===s?void 0:s[e])||void 0===c?void 0:c.variants)||[]))||void 0===i||i.forEach((()=>v++)),Object.keys((null===(u=null===(d=null===(l=null==j?void 0:j[t])||void 0===l?void 0:l.products)||void 0===d?void 0:d[e])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&v!==a))};return t("div",{children:[t(a,{children:[e(i,{Icon:r,onClick:()=>{b("collections")}}),e(l,{children:"Selected Products"})]}),t("div",{children:[Object.keys(m).length>0?e(o,{children:Object.keys(m).map((t=>{var o;return Object.keys((null===(o=null==m?void 0:m[t])||void 0===o?void 0:o.products)||[]).map((o=>{let r=!1;return(null==m?void 0:m.isCustom)&&(r=!0),e(u,{upliftAdditions:null,collectionId:t,productId:o,data:m[t].products[o],isProductPartiallyChecked:S(t,o),selectedData:j,selectedCollectionsDispatch:g,viewOnly:r,outOfStockAction:O},o)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:k})]})]})};export{p as SelectedScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as t}from"lodash";const o=(o,
|
|
1
|
+
import{cloneDeep as t}from"lodash";const o=(o,s)=>{const c=t(s);if(delete c.products,(o=Object.assign(Object.assign({},o),{catalogOnlyData:c})).productId&&s.products){const n=t(s.products[o.productId]);(null==n?void 0:n.variants)&&delete n.variants,o=Object.assign(Object.assign({},o),{catalogOnlyData:c,productOnlyData:n})}return o};function s(t,o,s){var n;const e={};let r=0;console.log("paginated offset",s);for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const l=t[a],i=c(l.products,o,s-r);i&&Object.keys(i).length>0&&(e[a]=Object.assign(Object.assign({},l),{products:i})),r+=Object.keys(null!==(n=l.products)&&void 0!==n?n:{}).length}return e}function c(t,o,s){if(!t)return{};const c=Object.keys(t).slice(s,s+o),n={};return c.forEach((o=>{n[o]=t[o]})),n}export{o as liftTheStateUp,s as paginateSelectedItems};
|