@bikdotai/bik-component-library 0.0.439-beta.ppi-9 → 0.0.439-beta.ppi-10

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