@bikdotai/bik-component-library 0.0.439-beta.ppi-1 → 0.0.439-beta.ppi-2

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"),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({}),S=r.useRef(0),b=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",b.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}),f(Object.assign(Object.assign({},g),e)),S.current+=1}}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b]);const h=(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:h(t,r),selectedData:g,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:b})]})]})};
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})]})]})};
@@ -8,3 +8,4 @@ export declare function paginateArray(array: Array<any>, limit: number, pageNo:
8
8
  export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
9
9
  [key: string]: Collection;
10
10
  };
11
+ export declare function mergeProducts(curData: any, paginatedData: any): any;
@@ -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.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
+ "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 +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 n,useRef as l,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}from"./utility.js";const p=p=>{const{selectedCollections:m,selectedCollectionsDispatch:g,setScreen:f,collections:j,outOfStockAction:h}=p,[b,y]=n({}),O=l(0),k=l(null);c((()=>{O.current=0;const e=v(m,10,O.current);console.log("paginated",{paginatedProducts:e,selectedCollections:m}),y(e),O.current+=1}),[]),c((()=>{console.log("paginated curscreen data change",b)}),[b]),c((()=>{console.log("vj: observertarget",k.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(m,10,O.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:m}),y(Object.assign(Object.assign({},b),e)),O.current+=1}}),{threshold:1});return k.current&&e.observe(k.current),()=>{k.current&&e.unobserve(k.current)}}),[k]);const S=(e,t)=>{var o,r,n,l,c,i,s,d,u;let a=0,v=0;return!!((null===(r=null===(o=null==m?void 0:m[e])||void 0===o?void 0:o.products)||void 0===r?void 0:r[t])&&(null===(i=Object.keys((null===(c=null===(l=null===(n=null==j?void 0:j[e])||void 0===n?void 0:n.products)||void 0===l?void 0:l[t])||void 0===c?void 0:c.variants)||[]))||void 0===i||i.forEach((()=>v++)),Object.keys((null===(u=null===(d=null===(s=null==m?void 0:m[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:()=>{f("collections")}}),t(s,{children:"Selected Products"})]}),e("div",{children:[Object.keys(b).length>0?t(o,{children:Object.keys(b).map((e=>{var o;return Object.keys((null===(o=null==b?void 0:b[e])||void 0===o?void 0:o.products)||[]).map((o=>{let r=!1;return(null==b?void 0:b.isCustom)&&(r=!0),t(u,{upliftAdditions:null,collectionId:e,productId:o,data:b[e].products[o],isProductPartiallyChecked:S(e,o),selectedData:b,selectedCollectionsDispatch:g,viewOnly:r,outOfStockAction:h},o)}))}))}):t(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),t("div",{ref:k})]})]})};export{p 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 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};
@@ -8,3 +8,4 @@ export declare function paginateArray(array: Array<any>, limit: number, pageNo:
8
8
  export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
9
9
  [key: string]: Collection;
10
10
  };
11
+ export declare function mergeProducts(curData: any, paginatedData: any): any;
@@ -1 +1 @@
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};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.439-beta.ppi-1",
3
+ "version": "0.0.439-beta.ppi-2",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",