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