@bikdotai/bik-component-library 0.0.153-beta0.7 → 0.0.153-beta0.9

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.
@@ -12,6 +12,7 @@ export interface Product {
12
12
  };
13
13
  }
14
14
  export interface Collection {
15
+ id: string;
15
16
  name: string;
16
17
  image: string;
17
18
  isSmartCollection: boolean;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../checkBox/CheckBox.js"),i=require("../icon-button/IconButton.js"),o=require("../shimmer/ShimmerComponent/BikShimmer.js"),n=require("../TypographyStyle.js"),l=require("./style.js");const d=(e,t,s)=>{if(e.length<=t)return e;const r=e.slice(0,t-1);return(s?r.slice(0,r.lastIndexOf(" ")):r)+"..."},a=s=>{const{data:o,selectedCollectionsDispatch:a,setCollectionId:u,isPartiallyChecked:h,setScreen:j,id:p,isChecked:x,isDisabled:C}=s;return e.jsxs(l.CollectionCardStyle,Object.assign({isDisabled:C},{children:[e.jsxs(l.CollectionCardInfoStyle,{children:[e.jsx(c.CheckBox,{isDisabled:C,isChecked:x,isPartiallyChecked:h,onValueChange:function(e,t){a(e?{type:"selected",data:{id:p,val:o}}:{type:"unselected",data:{id:p}}),u(e?p:"")}}),e.jsx(l.CollectionCardDetailStyle,{children:e.jsxs(l.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:d(o.name,40,!0)}),Object.keys(o.products||{}).length?e.jsxs(n.BodyCaption,Object.assign({color:r.COLORS.content.placeholder},{children:[Object.keys(o.products||{}).length," products"]})):e.jsx(e.Fragment,{})]})})]}),e.jsx(i.IconButton,{onClick:()=>{C||(u(p),j("products"))},Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{collections:r,selectedCollectionsDispatch:c,setCollectionId:i,selectedCollections:n,setScreen:l,collectionFetcher:d,collectionsDispatch:u,pagingControls:h,storeId:j,setSaveDisabled:p}=t,x=s.useRef(null),C=s.useRef(h.curPage),v=(null==n?void 0:n.isCustom)||!1,[b,g]=s.useState(!1);s.useEffect((()=>{C.current=h.curPage}),[h.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&C.current>0&&(p(!0),g(!0),d(C.current,j).then((e=>{u({type:"paged",data:(null==e?void 0:e.collections)||{}}),h.setCurPage(C.current+1),g(!1),p(!1)})).catch())}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x]);const y=e=>{var t,s;let c=0,i=0;if(n[e]){const o=null===(t=r[e])||void 0===t?void 0:t.products;o&&Object.keys(o).forEach((e=>{var t;const s=null===(t=o[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>c+=1))}));const l=null===(s=n[e])||void 0===s?void 0:s.products;return l&&Object.keys(l).forEach((e=>{var t;const s=null===(t=l[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))})),!(c<=0&&i>0)&&(i>0&&c!==i)}return!1};return e.jsxs("div",{children:[Object.keys(r).length?Object.keys(r).map((t=>e.jsx(a,{data:r[t],isDisabled:v&&!(null==n?void 0:n[t]),isChecked:!!(null==n?void 0:n[t]),isPartiallyChecked:y(t),selectedCollectionsDispatch:c,setCollectionId:i,setScreen:l,id:t},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(o.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))),e.jsx("div",{ref:x}),b&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(o.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../checkBox/CheckBox.js"),i=require("../icon-button/IconButton.js"),o=require("../shimmer/ShimmerComponent/BikShimmer.js"),n=require("../TypographyStyle.js"),l=require("./style.js");const d=(e,t,s)=>{if(e.length<=t)return e;const r=e.slice(0,t-1);return(s?r.slice(0,r.lastIndexOf(" ")):r)+"..."},a=s=>{const{data:o,selectedCollectionsDispatch:a,setCollectionId:u,isPartiallyChecked:h,setScreen:j,id:p,isChecked:x,isDisabled:C}=s;return e.jsxs(l.CollectionCardStyle,Object.assign({isDisabled:C},{children:[e.jsxs(l.CollectionCardInfoStyle,{children:[e.jsx(c.CheckBox,{isDisabled:C,isChecked:x,isPartiallyChecked:h,onValueChange:function(e,t){a(e?{type:"selected",data:{id:p,val:o}}:{type:"unselected",data:{id:p}}),u(e?p:"")}}),e.jsx(l.CollectionCardDetailStyle,{children:e.jsxs(l.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:d(o.name,40,!0)}),Object.keys(o.products||{}).length?e.jsxs(n.BodyCaption,Object.assign({color:r.COLORS.content.placeholder},{children:[Object.keys(o.products||{}).length," products"]})):e.jsx(e.Fragment,{})]})})]}),e.jsx(i.IconButton,{onClick:()=>{C||(u(p),j("products"))},Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{collections:r,selectedCollectionsDispatch:c,setCollectionId:i,selectedCollections:n,setScreen:l,collectionFetcher:d,collectionsDispatch:u,pagingControls:h,storeId:j,setSaveDisabled:p}=t,x=s.useRef(null),C=s.useRef(h.curPage),v=(null==n?void 0:n.isCustom)||!1,[b,g]=s.useState(!1);s.useEffect((()=>{C.current=h.curPage}),[h.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&C.current>0&&(p(!0),g(!0),d(C.current,j).then((e=>{u({type:"paged",data:(null==e?void 0:e.collections)||{}}),h.setCurPage(C.current+1),g(!1),p(!1)})).catch())}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x]);const y=e=>{var t,s;let c=0,i=0;if(n[e]){const o=null===(t=r[e])||void 0===t?void 0:t.products;o&&Object.keys(o).forEach((e=>{var t;const s=null===(t=o[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>c+=1))}));const l=null===(s=n[e])||void 0===s?void 0:s.products;return l&&Object.keys(l).forEach((e=>{var t;const s=null===(t=l[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))})),!(c<=0&&i>0)&&(i>0&&c!==i)}return!1};return e.jsxs("div",{children:[Object.keys(r).length?Object.keys(r).map((t=>e.jsx(a,{data:r[t],isDisabled:v&&!(null==n?void 0:n[t]),isChecked:!!(null==n?void 0:n[t]),isPartiallyChecked:y(t),selectedCollectionsDispatch:c,setCollectionId:i,setScreen:l,id:r[t].id},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(o.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))),e.jsx("div",{ref:x}),b&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(o.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=d;
@@ -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"),o=require("lodash"),c=require("react"),d=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),s=require("../shimmer/ShimmerComponent/BikShimmer.js"),r=require("../TypographyStyle.js"),n=require("./collectionScreen.js"),a=require("./reducers.js"),u=require("./style.js");const p=t=>{const{collectionId:o,productId:c,data:d,selectedData:i,selectedCollectionsDispatch:l,upliftAdditions:s,viewOnly:r,isProductPartiallyChecked:n}=t;return e.jsx("div",{children:e.jsx(v,{isVariant:!1,data:d,productId:c,collectionId:o,isSelected:!!(null===(u=null===(a=null==i?void 0:i[o])||void 0===a?void 0:a.products)||void 0===u?void 0:u[c]),isPartiallyChecked:n,selectedCollectionsDispatch:l,upliftAdditions:s,viewOnly:r},c)});var a,u},v=t=>{const{isVariant:o,data:c,productId:d,collectionId:l,variantId:s,isSelected:a,selectedCollectionsDispatch:p,upliftAdditions:v,viewOnly:h,isPartiallyChecked:j}=t;return e.jsxs(u.ProductCardStyle,Object.assign({isVariant:o},{children:[h?e.jsx(e.Fragment,{}):e.jsx(i.CheckBox,{isChecked:a,isPartiallyChecked:j||!1,onValueChange:function(e){o?e?v("variantSelected",{productId:d,variantId:s,collectionId:l,variant:c}):p({type:"variantUnselected",data:{productId:d,variantId:s,collectionId:l}}):e?v("productSelected",{productId:d,collectionId:l,product:c}):p({type:"productUnselected",data:{productId:d,collectionId:l}})}}),e.jsx(r.TitleRegular,{children:n.truncate(c.name,40,!0)})]}))};exports.ProductCard=v,exports.ProductGroup=p,exports.ProductsScreen=i=>{const n=c.useContext(a.CollectionIdContext),{data:v,collectionsDispatch:h,selectedData:j,selectedCollectionsDispatch:y,productFetcher:x,storeId:I,setScreen:C,setSaveDisabled:O}=i,[g]=c.useState(v),m=v.isSmartCollection||!1,b=e=>{var t,o,c,d,i,l,s,r;let a=0,u=0;return!!((null===(o=null===(t=null==j?void 0:j[n])||void 0===t?void 0:t.products)||void 0===o?void 0:o[e])&&(null===(i=Object.keys((null===(d=null===(c=null==v?void 0:v.products)||void 0===c?void 0:c[e])||void 0===d?void 0:d.variants)||[]))||void 0===i||i.forEach((()=>u++)),Object.keys((null===(r=null===(s=null===(l=null==j?void 0:j[n])||void 0===l?void 0:l.products)||void 0===s?void 0:s[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>a++)),a>0&&u!==a))};c.useEffect((()=>{(null==v?void 0:v.products)||(O(!0),x(n,I).then((e=>{Object.keys(e||[]).length&&h({type:"productsFetched",data:{collectionId:n,products:e}}),O(!1)})).catch())}),[]);const k=(e,t)=>{const c=o.cloneDeep(v);if(delete c.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:c})).productId&&v.products){const e=o.cloneDeep(v.products[t.productId]);(null==e?void 0:e.variants)&&delete e.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:c,productOnlyData:e})}y({type:e,data:t})};return e.jsxs("div",{children:[e.jsxs(u.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{C("collections")}}),e.jsx(r.BodyCaption,Object.assign({style:{color:d.COLORS.content.secondary}},{children:v.name}))]}),e.jsx("div",{children:Object.keys((null==g?void 0:g.products)||[]).length?Object.keys(g.products||[]).map((t=>e.jsx(p,{collectionId:n,isProductPartiallyChecked:b(t),productId:t,data:g.products[t],selectedData:j,selectedCollectionsDispatch:y,upliftAdditions:k,viewOnly:!!m},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(s.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))})]})};
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("lodash"),c=require("react"),d=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),s=require("../shimmer/ShimmerComponent/BikShimmer.js"),r=require("../TypographyStyle.js"),n=require("./collectionScreen.js"),a=require("./reducers.js"),u=require("./style.js");const p=t=>{const{collectionId:o,productId:c,data:d,selectedData:i,selectedCollectionsDispatch:l,upliftAdditions:s,viewOnly:r,isProductPartiallyChecked:n}=t;return e.jsx("div",{children:e.jsx(v,{isVariant:!1,data:d,productId:c,collectionId:o,isSelected:!!(null===(u=null===(a=null==i?void 0:i[o])||void 0===a?void 0:a.products)||void 0===u?void 0:u[c]),isPartiallyChecked:n,selectedCollectionsDispatch:l,upliftAdditions:s,viewOnly:r},c)});var a,u},v=t=>{const{isVariant:o,data:c,productId:d,collectionId:l,variantId:s,isSelected:a,selectedCollectionsDispatch:p,upliftAdditions:v,viewOnly:h,isPartiallyChecked:j}=t;return e.jsxs(u.ProductCardStyle,Object.assign({isVariant:o},{children:[h?e.jsx(e.Fragment,{}):e.jsx(i.CheckBox,{isChecked:a,isPartiallyChecked:j||!1,onValueChange:function(e){o?e?v("variantSelected",{productId:d,variantId:s,collectionId:l,variant:c}):p({type:"variantUnselected",data:{productId:d,variantId:s,collectionId:l}}):e?v("productSelected",{productId:d,collectionId:l,product:c}):p({type:"productUnselected",data:{productId:d,collectionId:l}})}}),e.jsx(r.TitleRegular,{children:n.truncate(null==c?void 0:c.name,40,!0)})]}))};exports.ProductCard=v,exports.ProductGroup=p,exports.ProductsScreen=i=>{const n=c.useContext(a.CollectionIdContext),{data:v,collectionsDispatch:h,selectedData:j,selectedCollectionsDispatch:y,productFetcher:x,storeId:I,setScreen:C,setSaveDisabled:O}=i,[g]=c.useState(v),m=(null==v?void 0:v.isSmartCollection)||!1,b=e=>{var t,o,c,d,i,l,s,r;let a=0,u=0;return!!((null===(o=null===(t=null==j?void 0:j[n])||void 0===t?void 0:t.products)||void 0===o?void 0:o[e])&&(null===(i=Object.keys((null===(d=null===(c=null==v?void 0:v.products)||void 0===c?void 0:c[e])||void 0===d?void 0:d.variants)||[]))||void 0===i||i.forEach((()=>u++)),Object.keys((null===(r=null===(s=null===(l=null==j?void 0:j[n])||void 0===l?void 0:l.products)||void 0===s?void 0:s[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>a++)),a>0&&u!==a))};c.useEffect((()=>{(null==v?void 0:v.products)||(O(!0),x(n,I).then((e=>{Object.keys(e||[]).length&&h({type:"productsFetched",data:{collectionId:n,products:e}}),O(!1)})).catch())}),[]);const k=(e,t)=>{const c=o.cloneDeep(v);if(delete c.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:c})).productId&&v.products){const e=o.cloneDeep(v.products[t.productId]);(null==e?void 0:e.variants)&&delete e.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:c,productOnlyData:e})}y({type:e,data:t})};return e.jsxs("div",{children:[e.jsxs(u.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{C("collections")}}),e.jsx(r.BodyCaption,Object.assign({style:{color:d.COLORS.content.secondary}},{children:null==v?void 0:v.name}))]}),e.jsx("div",{children:Object.keys((null==g?void 0:g.products)||[]).length?Object.keys(g.products||[]).map((t=>e.jsx(p,{collectionId:n,isProductPartiallyChecked:b(t),productId:t,data:g.products[t],selectedData:j,selectedCollectionsDispatch:y,upliftAdditions:k,viewOnly:!!m},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(s.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))})]})};
@@ -12,6 +12,7 @@ export interface Product {
12
12
  };
13
13
  }
14
14
  export interface Collection {
15
+ id: string;
15
16
  name: string;
16
17
  image: string;
17
18
  isSmartCollection: boolean;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import s from"../../assets/icons/chevronRight.svg.js";import{useRef as r,useState as c,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import{CheckBox as l}from"../checkBox/CheckBox.js";import{IconButton as d}from"../icon-button/IconButton.js";import{BikShimmer as a}from"../shimmer/ShimmerComponent/BikShimmer.js";import{TitleRegular as h,BodyCaption as u}from"../TypographyStyle.js";import{CollectionCardStyle as p,CollectionCardInfoStyle as m,CollectionCardDetailStyle as v,CollectionNameHolder as b}from"./style.js";const g=(e,t,o)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(o?s.slice(0,s.lastIndexOf(" ")):s)+"..."},j=o=>{const{collections:s,selectedCollectionsDispatch:n,setCollectionId:l,selectedCollections:d,setScreen:h,collectionFetcher:u,collectionsDispatch:p,pagingControls:m,storeId:v,setSaveDisabled:b}=o,g=r(null),j=r(m.curPage),C=(null==d?void 0:d.isCustom)||!1,[f,k]=c(!1);i((()=>{j.current=m.curPage}),[m.curPage]),i((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&j.current>0&&(b(!0),k(!0),u(j.current,v).then((e=>{p({type:"paged",data:(null==e?void 0:e.collections)||{}}),m.setCurPage(j.current+1),k(!1),b(!1)})).catch())}),{threshold:1});return g.current&&e.observe(g.current),()=>{g.current&&e.unobserve(g.current)}}),[g]);const O=e=>{var t,o;let r=0,c=0;if(d[e]){const i=null===(t=s[e])||void 0===t?void 0:t.products;i&&Object.keys(i).forEach((e=>{var t;const o=null===(t=i[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>r+=1))}));const n=null===(o=d[e])||void 0===o?void 0:o.products;return n&&Object.keys(n).forEach((e=>{var t;const o=null===(t=n[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(r<=0&&c>0)&&(c>0&&r!==c)}return!1};return e("div",{children:[Object.keys(s).length?Object.keys(s).map((e=>t(y,{data:s[e],isDisabled:C&&!(null==d?void 0:d[e]),isChecked:!!(null==d?void 0:d[e]),isPartiallyChecked:O(e),selectedCollectionsDispatch:n,setCollectionId:l,setScreen:h,id:e},e))):[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))),t("div",{ref:g}),f&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},y=r=>{const{data:c,selectedCollectionsDispatch:i,setCollectionId:a,isPartiallyChecked:j,setScreen:y,id:C,isChecked:f,isDisabled:k}=r;return e(p,Object.assign({isDisabled:k},{children:[e(m,{children:[t(l,{isDisabled:k,isChecked:f,isPartiallyChecked:j,onValueChange:function(e,t){i(e?{type:"selected",data:{id:C,val:c}}:{type:"unselected",data:{id:C}}),a(e?C:"")}}),t(v,{children:e(b,{children:[t(h,{children:g(c.name,40,!0)}),Object.keys(c.products||{}).length?e(u,Object.assign({color:n.content.placeholder},{children:[Object.keys(c.products||{}).length," products"]})):t(o,{})]})})]}),t(d,{onClick:()=>{k||(a(C),y("products"))},Icon:s})]}))};export{j as CollectionsScreen,g as truncate};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import s from"../../assets/icons/chevronRight.svg.js";import{useRef as r,useState as c,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import{CheckBox as l}from"../checkBox/CheckBox.js";import{IconButton as d}from"../icon-button/IconButton.js";import{BikShimmer as a}from"../shimmer/ShimmerComponent/BikShimmer.js";import{TitleRegular as h,BodyCaption as u}from"../TypographyStyle.js";import{CollectionCardStyle as p,CollectionCardInfoStyle as m,CollectionCardDetailStyle as v,CollectionNameHolder as b}from"./style.js";const g=(e,t,o)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(o?s.slice(0,s.lastIndexOf(" ")):s)+"..."},j=o=>{const{collections:s,selectedCollectionsDispatch:n,setCollectionId:l,selectedCollections:d,setScreen:h,collectionFetcher:u,collectionsDispatch:p,pagingControls:m,storeId:v,setSaveDisabled:b}=o,g=r(null),j=r(m.curPage),C=(null==d?void 0:d.isCustom)||!1,[f,k]=c(!1);i((()=>{j.current=m.curPage}),[m.curPage]),i((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&j.current>0&&(b(!0),k(!0),u(j.current,v).then((e=>{p({type:"paged",data:(null==e?void 0:e.collections)||{}}),m.setCurPage(j.current+1),k(!1),b(!1)})).catch())}),{threshold:1});return g.current&&e.observe(g.current),()=>{g.current&&e.unobserve(g.current)}}),[g]);const O=e=>{var t,o;let r=0,c=0;if(d[e]){const i=null===(t=s[e])||void 0===t?void 0:t.products;i&&Object.keys(i).forEach((e=>{var t;const o=null===(t=i[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>r+=1))}));const n=null===(o=d[e])||void 0===o?void 0:o.products;return n&&Object.keys(n).forEach((e=>{var t;const o=null===(t=n[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(r<=0&&c>0)&&(c>0&&r!==c)}return!1};return e("div",{children:[Object.keys(s).length?Object.keys(s).map((e=>t(y,{data:s[e],isDisabled:C&&!(null==d?void 0:d[e]),isChecked:!!(null==d?void 0:d[e]),isPartiallyChecked:O(e),selectedCollectionsDispatch:n,setCollectionId:l,setScreen:h,id:s[e].id},e))):[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))),t("div",{ref:g}),f&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(a,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},y=r=>{const{data:c,selectedCollectionsDispatch:i,setCollectionId:a,isPartiallyChecked:j,setScreen:y,id:C,isChecked:f,isDisabled:k}=r;return e(p,Object.assign({isDisabled:k},{children:[e(m,{children:[t(l,{isDisabled:k,isChecked:f,isPartiallyChecked:j,onValueChange:function(e,t){i(e?{type:"selected",data:{id:C,val:c}}:{type:"unselected",data:{id:C}}),a(e?C:"")}}),t(v,{children:e(b,{children:[t(h,{children:g(c.name,40,!0)}),Object.keys(c.products||{}).length?e(u,Object.assign({color:n.content.placeholder},{children:[Object.keys(c.products||{}).length," products"]})):t(o,{})]})})]}),t(d,{onClick:()=>{k||(a(C),y("products"))},Icon:s})]}))};export{j as CollectionsScreen,g as truncate};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import{cloneDeep as c}from"lodash";import{useContext as d,useState as l,useEffect as n}from"react";import{COLORS as r}from"../../constants/Theme.js";import{CheckBox as s}from"../checkBox/CheckBox.js";import{IconButton as a}from"../icon-button/IconButton.js";import{BikShimmer as p}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as u,TitleRegular as v}from"../TypographyStyle.js";import{truncate as h}from"./collectionScreen.js";import{CollectionIdContext as m}from"./reducers.js";import{ProductScreenHeader as y,ProductCardStyle as I}from"./style.js";const j=o=>{const s=d(m),{data:v,collectionsDispatch:h,selectedData:I,selectedCollectionsDispatch:j,productFetcher:O,storeId:g,setScreen:b,setSaveDisabled:C}=o,[k]=l(v),D=v.isSmartCollection||!1,S=t=>{var e,o,i,c,d,l,n,r;let a=0,p=0;return!!((null===(o=null===(e=null==I?void 0:I[s])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(d=Object.keys((null===(c=null===(i=null==v?void 0:v.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>p++)),Object.keys((null===(r=null===(n=null===(l=null==I?void 0:I[s])||void 0===l?void 0:l.products)||void 0===n?void 0:n[t])||void 0===r?void 0:r.variants)||[]).forEach((()=>a++)),a>0&&p!==a))};n((()=>{(null==v?void 0:v.products)||(C(!0),O(s,g).then((t=>{Object.keys(t||[]).length&&h({type:"productsFetched",data:{collectionId:s,products:t}}),C(!1)})).catch())}),[]);const x=(t,e)=>{const o=c(v);if(delete o.products,(e=Object.assign(Object.assign({},e),{catalogOnlyData:o})).productId&&v.products){const t=c(v.products[e.productId]);(null==t?void 0:t.variants)&&delete t.variants,e=Object.assign(Object.assign({},e),{catalogOnlyData:o,productOnlyData:t})}j({type:t,data:e})};return t("div",{children:[t(y,{children:[e(a,{Icon:i,height:16,onClick:()=>{b("collections")}}),e(u,Object.assign({style:{color:r.content.secondary}},{children:v.name}))]}),e("div",{children:Object.keys((null==k?void 0:k.products)||[]).length?Object.keys(k.products||[]).map((t=>e(f,{collectionId:s,isProductPartiallyChecked:S(t),productId:t,data:k.products[t],selectedData:I,selectedCollectionsDispatch:j,upliftAdditions:x,viewOnly:!!D},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e(p,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))})]})},f=t=>{const{collectionId:o,productId:i,data:c,selectedData:d,selectedCollectionsDispatch:l,upliftAdditions:n,viewOnly:r,isProductPartiallyChecked:s}=t;return e("div",{children:e(O,{isVariant:!1,data:c,productId:i,collectionId:o,isSelected:!!(null===(p=null===(a=null==d?void 0:d[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[i]),isPartiallyChecked:s,selectedCollectionsDispatch:l,upliftAdditions:n,viewOnly:r},i)});var a,p},O=i=>{const{isVariant:c,data:d,productId:l,collectionId:n,variantId:r,isSelected:a,selectedCollectionsDispatch:p,upliftAdditions:u,viewOnly:m,isPartiallyChecked:y}=i;return t(I,Object.assign({isVariant:c},{children:[m?e(o,{}):e(s,{isChecked:a,isPartiallyChecked:y||!1,onValueChange:function(t){c?t?u("variantSelected",{productId:l,variantId:r,collectionId:n,variant:d}):p({type:"variantUnselected",data:{productId:l,variantId:r,collectionId:n}}):t?u("productSelected",{productId:l,collectionId:n,product:d}):p({type:"productUnselected",data:{productId:l,collectionId:n}})}}),e(v,{children:h(d.name,40,!0)})]}))};export{O as ProductCard,f as ProductGroup,j as ProductsScreen};
1
+ import{jsxs as t,jsx as o,Fragment as e}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import{cloneDeep as d}from"lodash";import{useContext as c,useState as l,useEffect as n}from"react";import{COLORS as r}from"../../constants/Theme.js";import{CheckBox as s}from"../checkBox/CheckBox.js";import{IconButton as a}from"../icon-button/IconButton.js";import{BikShimmer as p}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as u,TitleRegular as v}from"../TypographyStyle.js";import{truncate as h}from"./collectionScreen.js";import{CollectionIdContext as m}from"./reducers.js";import{ProductScreenHeader as y,ProductCardStyle as I}from"./style.js";const j=e=>{const s=c(m),{data:v,collectionsDispatch:h,selectedData:I,selectedCollectionsDispatch:j,productFetcher:O,storeId:g,setScreen:b,setSaveDisabled:C}=e,[k]=l(v),D=(null==v?void 0:v.isSmartCollection)||!1,S=t=>{var o,e,i,d,c,l,n,r;let a=0,p=0;return!!((null===(e=null===(o=null==I?void 0:I[s])||void 0===o?void 0:o.products)||void 0===e?void 0:e[t])&&(null===(c=Object.keys((null===(d=null===(i=null==v?void 0:v.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===c||c.forEach((()=>p++)),Object.keys((null===(r=null===(n=null===(l=null==I?void 0:I[s])||void 0===l?void 0:l.products)||void 0===n?void 0:n[t])||void 0===r?void 0:r.variants)||[]).forEach((()=>a++)),a>0&&p!==a))};n((()=>{(null==v?void 0:v.products)||(C(!0),O(s,g).then((t=>{Object.keys(t||[]).length&&h({type:"productsFetched",data:{collectionId:s,products:t}}),C(!1)})).catch())}),[]);const x=(t,o)=>{const e=d(v);if(delete e.products,(o=Object.assign(Object.assign({},o),{catalogOnlyData:e})).productId&&v.products){const t=d(v.products[o.productId]);(null==t?void 0:t.variants)&&delete t.variants,o=Object.assign(Object.assign({},o),{catalogOnlyData:e,productOnlyData:t})}j({type:t,data:o})};return t("div",{children:[t(y,{children:[o(a,{Icon:i,height:16,onClick:()=>{b("collections")}}),o(u,Object.assign({style:{color:r.content.secondary}},{children:null==v?void 0:v.name}))]}),o("div",{children:Object.keys((null==k?void 0:k.products)||[]).length?Object.keys(k.products||[]).map((t=>o(f,{collectionId:s,isProductPartiallyChecked:S(t),productId:t,data:k.products[t],selectedData:I,selectedCollectionsDispatch:j,upliftAdditions:x,viewOnly:!!D},t))):[1,2,3,4,5,6,7,8,9,10].map(((t,e)=>o("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:o(p,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),e)))})]})},f=t=>{const{collectionId:e,productId:i,data:d,selectedData:c,selectedCollectionsDispatch:l,upliftAdditions:n,viewOnly:r,isProductPartiallyChecked:s}=t;return o("div",{children:o(O,{isVariant:!1,data:d,productId:i,collectionId:e,isSelected:!!(null===(p=null===(a=null==c?void 0:c[e])||void 0===a?void 0:a.products)||void 0===p?void 0:p[i]),isPartiallyChecked:s,selectedCollectionsDispatch:l,upliftAdditions:n,viewOnly:r},i)});var a,p},O=i=>{const{isVariant:d,data:c,productId:l,collectionId:n,variantId:r,isSelected:a,selectedCollectionsDispatch:p,upliftAdditions:u,viewOnly:m,isPartiallyChecked:y}=i;return t(I,Object.assign({isVariant:d},{children:[m?o(e,{}):o(s,{isChecked:a,isPartiallyChecked:y||!1,onValueChange:function(t){d?t?u("variantSelected",{productId:l,variantId:r,collectionId:n,variant:c}):p({type:"variantUnselected",data:{productId:l,variantId:r,collectionId:n}}):t?u("productSelected",{productId:l,collectionId:n,product:c}):p({type:"productUnselected",data:{productId:l,collectionId:n}})}}),o(v,{children:h(null==c?void 0:c.name,40,!0)})]}))};export{O as ProductCard,f as ProductGroup,j as ProductsScreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.153-beta0.7",
3
+ "version": "0.0.153-beta0.9",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",