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