@bikdotai/bik-component-library 0.0.744-beta.13 → 0.0.744-beta.14
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("date-fns"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("date-fns"),s=require("react"),r=require("../../assets/icons/searchIcon.svg.js"),n=require("../../assets/icons/whatsNew.svg.js"),a=require("../../constants/Theme.js"),i=require("../button/Button.js"),o=require("../feature-announcements/VideoModal.js"),c=require("../searchBar/searchBar.js"),d=require("../side-modal/SideModal.js"),l=require("../TypographyStyle.js"),h=require("./WhatsNew.styles.js");exports.WhatsNewPanel=u=>{let{isOpen:j,onClose:m,content:x,isLoading:g=!1,title:w="What's new on BIK",searchPlaceholder:p="Search posts",emptyStateTitle:b="Nothing new!",emptyStateDescription:f="There are no new updates or features at the moment. Check back soon!",noResultsText:y="Sorry, no results found.",width:C="480px",onContentClick:O,renderCustomContent:N}=u;const[S,v]=s.useState(""),[M,L]=s.useState(!1),[q,k]=s.useState(""),B=e=>{if(!e.createdAt)return!1;const s=e.createdAt.toDate?e.createdAt.toDate():new Date(e.createdAt);return t.differenceInBusinessDays(new Date,s)<7},T=s.useMemo((()=>{if(!S.trim())return x;const e=S.toLowerCase();return x.filter((t=>t.title.toLowerCase().includes(e)||t.body.toLowerCase().includes(e)||t.content&&t.content.toLowerCase().includes(e)))}),[x,S]),R=e=>{if(e.productVideo)k(e.productVideo),L(!0);else{const t=e.primaryButtonRedirectionUrl||e.redirectUrl;t&&(e=>{const t=e.trim();try{const e=new URL(t,window.location.origin);e.origin===window.location.origin?window.location.href=e.href:window.open(e.href,"_blank","noopener,noreferrer")}catch(e){t.startsWith("/")||t.startsWith(".")?window.location.href=t:/^https?:\/\//i.test(t)&&window.open(t,"_blank","noopener,noreferrer")}})(t)}O&&O(e)},W=0===x.length,D=0===T.length;return j?e.jsxs(d.SideModal,Object.assign({width:C,onClose:m,header:"",headerCustomComponent:e.jsx(l.TitleMedium,Object.assign({color:a.COLORS.background.inverse},{children:w})),headerStyle:{background:a.COLORS.background.brandLight},hideFooter:!0},{children:[e.jsxs(h.MainContainer,{children:[e.jsx("div",Object.assign({className:"mt-8"},{children:e.jsx(c.SearchBar,{width:"100%",isEnabled:!W,onChange:e=>{v(e)},onEnter:e=>{v(e)},placeholder:p,variant:"default",searchValue:S,onClickCross:()=>{v("")}})})),e.jsx(h.WhatsNewWrapper,{children:W||D?e.jsxs("div",Object.assign({className:"no--data--found"},{children:[e.jsx("div",Object.assign({className:"icon--wrapper"},{children:W?e.jsx(n.default,{width:32,height:32}):e.jsx(r.default,{width:32,height:32})})),W?e.jsxs(e.Fragment,{children:[e.jsx(l.TitleRegular,{children:b}),e.jsx(l.BodyPrimary,Object.assign({color:a.COLORS.content.secondary,className:"text--align",style:{maxWidth:300}},{children:f}))]}):D?e.jsx(l.BodyPrimary,Object.assign({color:a.COLORS.content.secondary,className:"text--align",style:{maxWidth:300}},{children:y})):null]})):e.jsx("div",Object.assign({className:"scroller"},{children:T.map(((s,r)=>N?N(s):e.jsxs(h.MainCardContainer,Object.assign({className:"padding--16 mb-mt-8"},{children:[e.jsx(h.BackgroundImageContainer,{imageUrl:s.image,height:"209px",width:"100%",style:{borderRadius:"4px"}}),e.jsx("div",Object.assign({className:"mt-20 full--width"},{children:e.jsxs("div",Object.assign({className:"created--at flex flex--row"},{children:[B(s)?e.jsx("div",Object.assign({className:"new--content--tag"},{children:e.jsx(l.Caption,{children:"New"})})):e.jsx(e.Fragment,{}),e.jsx(l.Caption,Object.assign({style:{color:a.COLORS.content.placeholder}},{children:s.createdAt?t.format(s.createdAt.toDate?s.createdAt.toDate():new Date(s.createdAt),"dd MMMM yyyy"):""}))]}))})),e.jsx("div",Object.assign({className:"mt--8"},{children:e.jsx(l.TitleSmall,{children:s.title})})),e.jsx("div",{dangerouslySetInnerHTML:{__html:s.body},className:"card--desc mt--12"}),e.jsx("div",Object.assign({className:"flex flex--row mt-20 full--width"},{children:e.jsx(i.Button,{buttonText:s.buttonText||"Explore the feature",onClick:()=>R(s),matchParentWidth:!0,size:"medium"})}))]}),`whats-new-${r}`)))}))})]}),e.jsx(o.VideoModal,{isOpen:M,videoUrl:q,onClose:()=>{L(!1)}})]})):e.jsx(e.Fragment,{})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import{format as r,differenceInBusinessDays as o}from"date-fns";import{useState as s,useMemo as a}from"react";import i from"../../assets/icons/searchIcon.svg.js";import c from"../../assets/icons/whatsNew.svg.js";import{COLORS as d}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{VideoModal as h}from"../feature-announcements/VideoModal.js";import{SearchBar as m}from"../searchBar/searchBar.js";import{SideModal as p}from"../side-modal/SideModal.js";import{TitleMedium as w,TitleRegular as g,BodyPrimary as u,Caption as f,TitleSmall as b}from"../TypographyStyle.js";import{MainContainer as j,WhatsNewWrapper as y,MainCardContainer as C,BackgroundImageContainer as x}from"./WhatsNew.styles.js";const N=N=>{let{isOpen:O,onClose:v,content:k,isLoading:A=!1,title:D="What's new on BIK",searchPlaceholder:L="Search posts",emptyStateTitle:S="Nothing new!",emptyStateDescription:T="There are no new updates or features at the moment. Check back soon!",noResultsText:M="Sorry, no results found.",width:W="480px",onContentClick:B,renderCustomContent:U}=N;const[R,V]=s(""),[_,E]=s(!1),[I,P]=s(""),z=e=>{if(!e.createdAt)return!1;const t=e.createdAt.toDate?e.createdAt.toDate():new Date(e.createdAt);return o(new Date,t)<7},F=a((()=>{if(!R.trim())return k;const e=R.toLowerCase();return k.filter((t=>t.title.toLowerCase().includes(e)||t.body.toLowerCase().includes(e)||t.content&&t.content.toLowerCase().includes(e)))}),[k,R]),H=e=>{if(e.productVideo)P(e.productVideo),E(!0);else{const t=e.primaryButtonRedirectionUrl||e.redirectUrl;t&&(e=>{const t=e.trim();try{const e=new URL(t,window.location.origin);e.origin===window.location.origin?window.location.href=e.href:window.open(e.href,"_blank","noopener,noreferrer")}catch(e){t.startsWith("/")||t.startsWith(".")?window.location.href=t:/^https?:\/\//i.test(t)&&window.open(t,"_blank","noopener,noreferrer")}})(t)}B&&B(e)},K=0===k.length,$=0===F.length;return O?n(p,Object.assign({width:W,onClose:v,header:"",headerCustomComponent:e(w,Object.assign({color:d.background.inverse},{children:D})),headerStyle:{background:d.background.brandLight},hideFooter:!0},{children:[n(j,{children:[e("div",Object.assign({className:"mt-8"},{children:e(m,{width:"100%",isEnabled:!K,onChange:e=>{V(e)},onEnter:e=>{V(e)},placeholder:L,variant:"default",searchValue:R,onClickCross:()=>{V("")}})})),e(y,{children:K||$?n("div",Object.assign({className:"no--data--found"},{children:[e("div",Object.assign({className:"icon--wrapper"},{children:e(K?c:i,{width:32,height:32})})),K?n(t,{children:[e(g,{children:S}),e(u,Object.assign({color:d.content.secondary,className:"text--align",style:{maxWidth:300}},{children:T}))]}):$?e(u,Object.assign({color:d.content.secondary,className:"text--align",style:{maxWidth:300}},{children:M})):null]})):e("div",Object.assign({className:"scroller"},{children:F.map(((o,s)=>U?U(o):n(C,Object.assign({className:"padding--16 mb-mt-8"},{children:[e(x,{imageUrl:o.image,height:"209px",width:"100%",style:{borderRadius:"4px"}}),e("div",Object.assign({className:"mt-20 full--width"},{children:n("div",Object.assign({className:"created--at flex flex--row"},{children:[z(o)?e("div",Object.assign({className:"new--content--tag"},{children:e(f,{children:"New"})})):e(t,{}),e(f,Object.assign({style:{color:d.content.placeholder}},{children:o.createdAt?r(o.createdAt.toDate?o.createdAt.toDate():new Date(o.createdAt),"dd MMMM yyyy"):""}))]}))})),e("div",Object.assign({className:"mt--8"},{children:e(b,{children:o.title})})),e("div",{dangerouslySetInnerHTML:{__html:o.body},className:"card--desc mt--12"}),e("div",Object.assign({className:"flex flex--row mt-20 full--width"},{children:e(l,{buttonText:o.buttonText||"Explore the feature",onClick:()=>H(o),matchParentWidth:!0,size:"medium"})}))]}),`whats-new-${s}`)))}))})]}),e(h,{isOpen:_,videoUrl:I,onClose:()=>{E(!1)}})]})):e(t,{})};export{N as WhatsNewPanel};
|