@bikdotai/bik-component-library 0.0.509-beta.pp-2 → 0.0.509-beta.pp-3

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"),l=require("react"),c=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),i=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),s=require("../TypographyStyle.js"),n=require("./emptyState.js"),d=require("./ProductPickerShimmer.js"),a=require("./style.js"),u=require("./utility.js");const h=l=>{const{customCollectionRestriction:n,data:d,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:g,setScreen:p,id:j,isChecked:v,isDisabled:y,hideCollectionCheckbox:x,pickerType:b,usedInSearch:f}=l;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(!y){if("COLLECTION"===b)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:j,val:d,isRestricted:n}}),h(j),void C(j);h(j),C(j),p("products")}},isActive:v,usedInSearch:null!=f&&f},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!x&&e.jsx(c.CheckBox,{isDisabled:y,isChecked:v,isPartiallyChecked:g,onValueChange:function(e,t,l){null==l||l.stopPropagation(),u(e?{type:"selected",data:{id:j,val:d,isRestricted:n}}:{type:"unselected",data:{id:j}}),C(e?j:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(a.CollectionNameHolder,{children:[f?e.jsx(s.BodyPrimary,Object.assign({numberOfLines:1},{children:d.name})):e.jsx(s.TitleRegular,Object.assign({numberOfLines:1},{children:d.name})),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(i.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==b&&e.jsx(o.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]}))};exports.CollectionCard=h,exports.CollectionsScreen=t=>{var c;const{customCollectionRestriction:o,dataLoading:i,collections:r,selectedCollectionsDispatch:s,setCollectionId:a,setSelectedCollectionId:C,selectedCollections:g,setScreen:p,collectionFetcher:j,collectionsDispatch:v,pagingControls:y,storeId:x,setSaveDisabled:b,hideCollectionCheckbox:f,renderWithoutModal:m,pickerType:k,scrollContainerRef:S}=t,P=l.useRef(null),O=l.useRef(y.curPage),I=!!o&&(null==g?void 0:g.isCustom),[R,T]=l.useState(!1),q=l.useRef(!1),D=l.useRef(!1),L=()=>{if(console.log("handleScroll called"),!S||!(null==S?void 0:S.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:l}=S.current;console.log("handleScroll check",{hasAllCollectionsLoaded:q,isFetchingRef:D}),e+t>=l-20&&!q.current&&!D.current&&(b(!0),T(!0),D.current=!0,b(!0),T(!0),j(O.current,x).then((e=>{v({type:"paged",data:(null==e?void 0:e.collections)||{}}),y.setCurPage(O.current+1),T(!1),b(!1),D.current=!1,console.log("handleScroll collectionsParsed",{collectionsParsed:e}),Object.keys(e).length||(console.log("handleScroll setting hasCollections",{hasAllCollectionsLoaded:q,isFetchingRef:D}),q.current=!0)})).catch())};return l.useEffect((()=>{var e;return null===(e=null==S?void 0:S.current)||void 0===e||e.addEventListener("scroll",L),()=>{var e;null===(e=null==S?void 0:S.current)||void 0===e||e.removeEventListener("scroll",L)}}),[]),l.useEffect((()=>{O.current=y.curPage}),[y.curPage]),l.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&O.current>0&&!q.current&&(b(!0),T(!0),j(O.current,x).then((e=>{v({type:"paged",data:(null==e?void 0:e.collections)||{}}),y.setCurPage(O.current+1),T(!1),b(!1),Object.keys(e).length||(q.current=!0)})).catch())}),{threshold:1});return P.current&&e.observe(P.current),()=>{P.current&&e.unobserve(P.current)}}),[P]),e.jsxs("div",{children:[(null===(c=Object.keys(null!=r?r:{}))||void 0===c?void 0:c.length)?Object.keys(r).map((t=>{var l,c;const i=!!(null==g?void 0:g[t])&&("PRODUCT"!==k||!!Object.keys(null!==(c=null===(l=null==g?void 0:g[t])||void 0===l?void 0:l.products)&&void 0!==c?c:{}).length);return e.jsx(h,{customCollectionRestriction:o,data:r[t],isDisabled:I&&!(null==g?void 0:g[t]),isChecked:i,isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==r?void 0:r[t],g),selectedCollectionsDispatch:s,setCollectionId:a,setSelectedCollectionId:C,setScreen:p,id:t,hideCollectionCheckbox:f||"-1"===t,selectedCollections:g,renderWithoutModal:m,pickerType:k},t)})):i?e.jsx(d.ProductPickerShimmer,{}):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:P}),R&&e.jsx(d.ProductPickerShimmer,{})]})},exports.truncate=(e,t,l)=>{if(!e)return"";if(e.length<=t)return e;const c=e.slice(0,t-1);return(l?c.slice(0,c.lastIndexOf(" ")):c)+"..."};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),l=require("react"),o=require("../checkBox/CheckBox.js"),c=require("../icon-button/IconButton.js"),i=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),s=require("./emptyState.js"),d=require("./ProductPickerShimmer.js"),a=require("./style.js"),u=require("./utility.js");const h=l=>{const{customCollectionRestriction:s,data:d,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:g,setScreen:p,id:v,isChecked:j,isDisabled:y,hideCollectionCheckbox:x,pickerType:b,usedInSearch:f}=l;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(!y){if("COLLECTION"===b)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:v,val:d,isRestricted:s}}),h(v),void C(v);h(v),C(v),p("products")}},isActive:j,usedInSearch:null!=f&&f},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!x&&e.jsx(o.CheckBox,{isDisabled:y,isChecked:j,isPartiallyChecked:g,onValueChange:function(e,t,l){null==l||l.stopPropagation(),u(e?{type:"selected",data:{id:v,val:d,isRestricted:s}}:{type:"unselected",data:{id:v}}),C(e?v:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(a.CollectionNameHolder,{children:[f?e.jsx(n.BodyPrimary,Object.assign({numberOfLines:1},{children:d.name})):e.jsx(n.TitleRegular,Object.assign({numberOfLines:1},{children:d.name})),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(i.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==b&&e.jsx(c.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]}))};exports.CollectionCard=h,exports.CollectionsScreen=t=>{var o;const{customCollectionRestriction:c,dataLoading:i,collections:r,selectedCollectionsDispatch:n,setCollectionId:a,setSelectedCollectionId:C,selectedCollections:g,setScreen:p,collectionFetcher:v,collectionsDispatch:j,pagingControls:y,storeId:x,setSaveDisabled:b,hideCollectionCheckbox:f,renderWithoutModal:m,pickerType:k,scrollContainerRef:S}=t,P=l.useRef(null),O=l.useRef(y.curPage),I=!!c&&(null==g?void 0:g.isCustom),[R,T]=l.useState(!1),q=l.useRef(!1),D=l.useRef(!1),L=()=>{if(console.log("handleScroll called"),!S||!(null==S?void 0:S.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:l}=S.current;console.log("handleScroll check",{hasAllCollectionsLoaded:q,isFetchingRef:D}),e+t>=l-20&&!q.current&&!D.current&&(b(!0),T(!0),D.current=!0,b(!0),T(!0),v(O.current,x).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),y.setCurPage(O.current+1),T(!1),b(!1),D.current=!1,console.log("handleScroll collectionsParsed",{collectionsParsed:e}),Object.keys(null==e?void 0:e.collections).length||(console.log("handleScroll setting hasCollections",{hasAllCollectionsLoaded:q,isFetchingRef:D}),q.current=!0)})).catch())};return l.useEffect((()=>{var e;return null===(e=null==S?void 0:S.current)||void 0===e||e.addEventListener("scroll",L),()=>{var e;null===(e=null==S?void 0:S.current)||void 0===e||e.removeEventListener("scroll",L)}}),[]),l.useEffect((()=>{O.current=y.curPage}),[y.curPage]),l.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&O.current>0&&!q.current&&(b(!0),T(!0),v(O.current,x).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),y.setCurPage(O.current+1),T(!1),b(!1),Object.keys(e).length||(q.current=!0)})).catch())}),{threshold:1});return P.current&&e.observe(P.current),()=>{P.current&&e.unobserve(P.current)}}),[P]),e.jsxs("div",{children:[(null===(o=Object.keys(null!=r?r:{}))||void 0===o?void 0:o.length)?Object.keys(r).map((t=>{var l,o;const i=!!(null==g?void 0:g[t])&&("PRODUCT"!==k||!!Object.keys(null!==(o=null===(l=null==g?void 0:g[t])||void 0===l?void 0:l.products)&&void 0!==o?o:{}).length);return e.jsx(h,{customCollectionRestriction:c,data:r[t],isDisabled:I&&!(null==g?void 0:g[t]),isChecked:i,isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==r?void 0:r[t],g),selectedCollectionsDispatch:n,setCollectionId:a,setSelectedCollectionId:C,setScreen:p,id:t,hideCollectionCheckbox:f||"-1"===t,selectedCollections:g,renderWithoutModal:m,pickerType:k},t)})):i?e.jsx(d.ProductPickerShimmer,{}):e.jsx(s.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:P}),R&&e.jsx(d.ProductPickerShimmer,{})]})},exports.truncate=(e,t,l)=>{if(!e)return"";if(e.length<=t)return e;const o=e.slice(0,t-1);return(l?o.slice(0,o.lastIndexOf(" ")):o)+"..."};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import o from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as i,useEffect as n}from"react";import{CheckBox as r}from"../checkBox/CheckBox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{TitleRegular as u,BodyPrimary as h}from"../TypographyStyle.js";import{EmptyState as p}from"./emptyState.js";import{ProductPickerShimmer as C}from"./ProductPickerShimmer.js";import{CollectionCardStyle as g,CollectionCardInfoStyle as m,CollectionCardDetailStyle as v,CollectionNameHolder as y}from"./style.js";import{isCollectionPartiallyChecked as b}from"./utility.js";const f=(e,t,l)=>{if(!e)return"";if(e.length<=t)return e;const o=e.slice(0,t-1);return(l?o.slice(0,o.lastIndexOf(" ")):o)+"..."},k=l=>{var o;const{customCollectionRestriction:r,dataLoading:s,collections:d,selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,selectedCollections:g,setScreen:m,collectionFetcher:v,collectionsDispatch:y,pagingControls:f,storeId:k,setSaveDisabled:S,hideCollectionCheckbox:O,renderWithoutModal:I,pickerType:P,scrollContainerRef:T}=l,x=c(null),D=c(f.curPage),L=!!r&&(null==g?void 0:g.isCustom),[R,w]=i(!1),E=c(!1),A=c(!1),B=()=>{if(console.log("handleScroll called"),!T||!(null==T?void 0:T.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:l}=T.current;console.log("handleScroll check",{hasAllCollectionsLoaded:E,isFetchingRef:A}),e+t>=l-20&&!E.current&&!A.current&&(S(!0),w(!0),A.current=!0,S(!0),w(!0),v(D.current,k).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),f.setCurPage(D.current+1),w(!1),S(!1),A.current=!1,console.log("handleScroll collectionsParsed",{collectionsParsed:e}),Object.keys(e).length||(console.log("handleScroll setting hasCollections",{hasAllCollectionsLoaded:E,isFetchingRef:A}),E.current=!0)})).catch())};return n((()=>{var e;return null===(e=null==T?void 0:T.current)||void 0===e||e.addEventListener("scroll",B),()=>{var e;null===(e=null==T?void 0:T.current)||void 0===e||e.removeEventListener("scroll",B)}}),[]),n((()=>{D.current=f.curPage}),[f.curPage]),n((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&D.current>0&&!E.current&&(S(!0),w(!0),v(D.current,k).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),f.setCurPage(D.current+1),w(!1),S(!1),Object.keys(e).length||(E.current=!0)})).catch())}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x]),e("div",{children:[(null===(o=Object.keys(null!=d?d:{}))||void 0===o?void 0:o.length)?Object.keys(d).map((e=>{var l,o;const c=!!(null==g?void 0:g[e])&&("PRODUCT"!==P||!!Object.keys(null!==(o=null===(l=null==g?void 0:g[e])||void 0===l?void 0:l.products)&&void 0!==o?o:{}).length);return t(j,{customCollectionRestriction:r,data:d[e],isDisabled:L&&!(null==g?void 0:g[e]),isChecked:c,isPartiallyChecked:b(e,null==d?void 0:d[e],g),selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,setScreen:m,id:e,hideCollectionCheckbox:O||"-1"===e,selectedCollections:g,renderWithoutModal:I,pickerType:P},e)})):s?t(C,{}):t(p,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:x}),R&&t(C,{})]})},j=c=>{const{customCollectionRestriction:i,data:n,selectedCollectionsDispatch:p,setCollectionId:C,setSelectedCollectionId:b,isPartiallyChecked:f,setScreen:k,id:j,isChecked:S,isDisabled:O,hideCollectionCheckbox:I,pickerType:P,usedInSearch:T}=c;return e(g,Object.assign({isDisabled:O,onClick:e=>{if(!O){if("COLLECTION"===P)return e.stopPropagation(),p({type:"reset",data:{}}),p({type:"selected",data:{id:j,val:n,isRestricted:i}}),C(j),void b(j);C(j),b(j),k("products")}},isActive:S,usedInSearch:null!=T&&T},{children:[e(m,{children:[!I&&t(r,{isDisabled:O,isChecked:S,isPartiallyChecked:f,onValueChange:function(e,t,l){null==l||l.stopPropagation(),p(e?{type:"selected",data:{id:j,val:n,isRestricted:i}}:{type:"unselected",data:{id:j}}),b(e?j:"")}}),t(v,{children:t(a,Object.assign({body:n.name,placement:"bottom",delay:400,variant:"light"},{children:e(y,{children:[t(T?h:u,Object.assign({numberOfLines:1},{children:n.name})),n.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(d,{tagText:"Smart Collection",type:"warning"})})):t(l,{})]})}))})]}),"COLLECTION"!==P&&t(s,{height:12,width:12,disabled:O,Icon:o})]}))};export{j as CollectionCard,k as CollectionsScreen,f as truncate};
1
+ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import o from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as i,useEffect as n}from"react";import{CheckBox as r}from"../checkBox/CheckBox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{TitleRegular as u,BodyPrimary as h}from"../TypographyStyle.js";import{EmptyState as p}from"./emptyState.js";import{ProductPickerShimmer as C}from"./ProductPickerShimmer.js";import{CollectionCardStyle as g,CollectionCardInfoStyle as m,CollectionCardDetailStyle as v,CollectionNameHolder as y}from"./style.js";import{isCollectionPartiallyChecked as b}from"./utility.js";const f=(e,t,l)=>{if(!e)return"";if(e.length<=t)return e;const o=e.slice(0,t-1);return(l?o.slice(0,o.lastIndexOf(" ")):o)+"..."},k=l=>{var o;const{customCollectionRestriction:r,dataLoading:s,collections:d,selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,selectedCollections:g,setScreen:m,collectionFetcher:v,collectionsDispatch:y,pagingControls:f,storeId:k,setSaveDisabled:S,hideCollectionCheckbox:O,renderWithoutModal:I,pickerType:P,scrollContainerRef:T}=l,x=c(null),D=c(f.curPage),L=!!r&&(null==g?void 0:g.isCustom),[R,w]=i(!1),E=c(!1),A=c(!1),B=()=>{if(console.log("handleScroll called"),!T||!(null==T?void 0:T.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:l}=T.current;console.log("handleScroll check",{hasAllCollectionsLoaded:E,isFetchingRef:A}),e+t>=l-20&&!E.current&&!A.current&&(S(!0),w(!0),A.current=!0,S(!0),w(!0),v(D.current,k).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),f.setCurPage(D.current+1),w(!1),S(!1),A.current=!1,console.log("handleScroll collectionsParsed",{collectionsParsed:e}),Object.keys(null==e?void 0:e.collections).length||(console.log("handleScroll setting hasCollections",{hasAllCollectionsLoaded:E,isFetchingRef:A}),E.current=!0)})).catch())};return n((()=>{var e;return null===(e=null==T?void 0:T.current)||void 0===e||e.addEventListener("scroll",B),()=>{var e;null===(e=null==T?void 0:T.current)||void 0===e||e.removeEventListener("scroll",B)}}),[]),n((()=>{D.current=f.curPage}),[f.curPage]),n((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&D.current>0&&!E.current&&(S(!0),w(!0),v(D.current,k).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),f.setCurPage(D.current+1),w(!1),S(!1),Object.keys(e).length||(E.current=!0)})).catch())}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x]),e("div",{children:[(null===(o=Object.keys(null!=d?d:{}))||void 0===o?void 0:o.length)?Object.keys(d).map((e=>{var l,o;const c=!!(null==g?void 0:g[e])&&("PRODUCT"!==P||!!Object.keys(null!==(o=null===(l=null==g?void 0:g[e])||void 0===l?void 0:l.products)&&void 0!==o?o:{}).length);return t(j,{customCollectionRestriction:r,data:d[e],isDisabled:L&&!(null==g?void 0:g[e]),isChecked:c,isPartiallyChecked:b(e,null==d?void 0:d[e],g),selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,setScreen:m,id:e,hideCollectionCheckbox:O||"-1"===e,selectedCollections:g,renderWithoutModal:I,pickerType:P},e)})):s?t(C,{}):t(p,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:x}),R&&t(C,{})]})},j=c=>{const{customCollectionRestriction:i,data:n,selectedCollectionsDispatch:p,setCollectionId:C,setSelectedCollectionId:b,isPartiallyChecked:f,setScreen:k,id:j,isChecked:S,isDisabled:O,hideCollectionCheckbox:I,pickerType:P,usedInSearch:T}=c;return e(g,Object.assign({isDisabled:O,onClick:e=>{if(!O){if("COLLECTION"===P)return e.stopPropagation(),p({type:"reset",data:{}}),p({type:"selected",data:{id:j,val:n,isRestricted:i}}),C(j),void b(j);C(j),b(j),k("products")}},isActive:S,usedInSearch:null!=T&&T},{children:[e(m,{children:[!I&&t(r,{isDisabled:O,isChecked:S,isPartiallyChecked:f,onValueChange:function(e,t,l){null==l||l.stopPropagation(),p(e?{type:"selected",data:{id:j,val:n,isRestricted:i}}:{type:"unselected",data:{id:j}}),b(e?j:"")}}),t(v,{children:t(a,Object.assign({body:n.name,placement:"bottom",delay:400,variant:"light"},{children:e(y,{children:[t(T?h:u,Object.assign({numberOfLines:1},{children:n.name})),n.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(d,{tagText:"Smart Collection",type:"warning"})})):t(l,{})]})}))})]}),"COLLECTION"!==P&&t(s,{height:12,width:12,disabled:O,Icon:o})]}))};export{j as CollectionCard,k as CollectionsScreen,f as truncate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.509-beta.pp-2",
3
+ "version": "0.0.509-beta.pp-3",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",