@bikdotai/bik-component-library 0.0.435-0 → 0.0.435-1
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/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),l=require("../shimmer/ShimmerComponent/BikShimmer.js"),c=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./emptyState.js"),d=require("./style.js");const u=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."},h=i=>{const{customCollectionRestriction:l,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:v,isDisabled:y,hideCollectionCheckbox:g,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(!y){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:l}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!g&&e.jsx(s.CheckBox,{isDisabled:y,isChecked:v,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:l}}:{type:"unselected",data:{id:x}}),p(e?x:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400},{children:e.jsxs(d.CollectionNameHolder,{children:[a.name&&e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]}))};exports.CollectionsScreen=t=>{var s;const{customCollectionRestriction:o,dataLoading:c,collections:r,selectedCollectionsDispatch:n,setCollectionId:d,selectedCollections:u,setScreen:p,collectionFetcher:C,collectionsDispatch:j,pagingControls:x,storeId:v,setSaveDisabled:y,hideCollectionCheckbox:g,renderWithoutModal:m,pickerType:b}=t,k=i.useRef(null),f=i.useRef(x.curPage),O=!!o&&(null==u?void 0:u.isCustom),[S,E]=i.useState(!1);i.useEffect((()=>{f.current=x.curPage}),[x.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&(y(!0),E(!0),C(f.current,v).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(f.current+1),E(!1),y(!1)})).catch())}),{threshold:1});return k.current&&e.observe(k.current),()=>{k.current&&e.unobserve(k.current)}}),[k]);const T=e=>{var t,i;let s=0,o=0;if(u[e]){const l=null===(t=r[e])||void 0===t?void 0:t.products;l&&Object.keys(l).forEach((e=>{var t;const i=null===(t=l[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const c=null===(i=u[e])||void 0===i?void 0:i.products;return c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[(null===(s=Object.keys(null!=r?r:{}))||void 0===s?void 0:s.length)?Object.keys(r).map((t=>e.jsx(h,{customCollectionRestriction:o,data:r[t],isDisabled:O&&!(null==u?void 0:u[t]),isChecked:!!(null==u?void 0:u[t]),isPartiallyChecked:T(t),selectedCollectionsDispatch:n,setCollectionId:d,setScreen:p,id:t,hideCollectionCheckbox:g,selectedCollections:u,renderWithoutModal:m,pickerType:b},t))):c?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(a.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:k}),S&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as l}from"react";import{CheckBox as r}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BikShimmer as d}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as a}from"../tag/Tag.js";import{Tooltip as h}from"../tooltips/Tooltip.js";import{TitleRegular as p}from"../TypographyStyle.js";import{EmptyState as u}from"./emptyState.js";import{CollectionCardStyle as m,CollectionCardInfoStyle as C,CollectionCardDetailStyle as v,CollectionNameHolder as b}from"./style.js";const g=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},y=o=>{var i;const{customCollectionRestriction:r,dataLoading:n,collections:a,selectedCollectionsDispatch:h,setCollectionId:p,selectedCollections:m,setScreen:C,collectionFetcher:v,collectionsDispatch:b,pagingControls:g,storeId:y,setSaveDisabled:k,hideCollectionCheckbox:j,renderWithoutModal:x,pickerType:O}=o,E=c(null),I=c(g.curPage),T=!!r&&(null==m?void 0:m.isCustom),[S,D]=s(!1);l((()=>{I.current=g.curPage}),[g.curPage]),l((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&I.current>0&&(k(!0),D(!0),v(I.current,y).then((e=>{b({type:"paged",data:(null==e?void 0:e.collections)||{}}),g.setCurPage(I.current+1),D(!1),k(!1)})).catch())}),{threshold:1});return E.current&&e.observe(E.current),()=>{E.current&&e.unobserve(E.current)}}),[E]);const P=e=>{var t,o;let i=0,c=0;if(m[e]){const s=null===(t=a[e])||void 0===t?void 0:t.products;s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const l=null===(o=m[e])||void 0===o?void 0:o.products;return l&&Object.keys(l).forEach((e=>{var t;const o=null===(t=l[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(i<=0&&c>0)&&(c>0&&i!==c)}return!1};return e("div",{children:[(null===(i=Object.keys(null!=a?a:{}))||void 0===i?void 0:i.length)?Object.keys(a).map((e=>t(f,{customCollectionRestriction:r,data:a[e],isDisabled:T&&!(null==m?void 0:m[e]),isChecked:!!(null==m?void 0:m[e]),isPartiallyChecked:P(e),selectedCollectionsDispatch:h,setCollectionId:p,setScreen:C,id:e,hideCollectionCheckbox:j,selectedCollections:m,renderWithoutModal:x,pickerType:O},e))):n?[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):t(u,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:E}),S&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},f=c=>{const{customCollectionRestriction:s,data:l,selectedCollectionsDispatch:d,setCollectionId:u,isPartiallyChecked:y,setScreen:f,id:k,isChecked:j,isDisabled:x,hideCollectionCheckbox:O,pickerType:E,selectedCollections:I}=c;return e(m,Object.assign({isDisabled:x,onClick:e=>{if(!x){if("COLLECTION"===E)return e.stopPropagation(),d({type:"reset",data:{}}),d({type:"selected",data:{id:k,val:l,isRestricted:s}}),void u(k);u(k),f("products")}},isActive:!!I[k]},{children:[e(C,{children:[!O&&t(r,{isDisabled:x,isChecked:j,isPartiallyChecked:y,onValueChange:function(e,t,o){null==o||o.stopPropagation(),d(e?{type:"selected",data:{id:k,val:l,isRestricted:s}}:{type:"unselected",data:{id:k}}),u(e?k:"")}}),t(v,{children:t(h,Object.assign({body:l.name,placement:"bottom",delay:400},{children:e(b,{children:[l.name&&t(p,{children:g(l.name,40,!0)}),l.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(a,{tagText:"Smart Collection",type:"warning"})})):t(o,{})]})}))})]}),"COLLECTION"!==E&&t(n,{height:12,width:12,disabled:x,Icon:i})]}))};export{y as CollectionsScreen,g as truncate};
|