@bikdotai/bik-component-library 0.0.727-beta.30 → 0.0.727-beta.34

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 t=require("../../node_modules/react/jsx-runtime.js"),e=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/check.svg.js"),s=require("../../assets/icons/cross.svg.js"),n=require("../../assets/icons/errorInfo.svg.js"),i=require("../../assets/icons/info.svg.js"),r=require("react"),u=require("react-dom"),l=require("react-toastify"),d=require("../button/Button.js"),c=require("./Toaster.styled.js"),a=require("../TypographyStyle.js"),x=require("../../constants/Theme.js");function p(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var j=p(r),h=p(u);const y=e=>t.jsxRuntimeExports.jsxs(a.BodySecondary,Object.assign({color:"#9E9E9E",customStyles:{fontWeight:600,fontSize:14,width:18}},{children:[e.duration,"s"]})),g=e=>{const o="default"===e.type?x.COLORS.content.primary:"success"===e.type?x.COLORS.content.positive:"error"===e.type?x.COLORS.content.negative:"warning"===e.type?x.COLORS.content.warning:x.COLORS.content.brand,{timerValue:n}=r.useContext(f);let i=e.blocking&&n>0;return t.jsxRuntimeExports.jsx("div",Object.assign({tabIndex:i?-1:0,role:"button",style:{width:20,display:"flex",cursor:i?"not-allowed":"pointer",alignSelf:""+(e.alignTop?"flex-start":"center"),opacity:i?.5:1},onClick:()=>{!i&&e.closeToast&&e.closeToast()},onKeyDown:t=>{"Enter"===t.key&&!i&&e.closeToast&&e.closeToast()}},{children:n>0?t.jsxRuntimeExports.jsx(y,{duration:n}):t.jsxRuntimeExports.jsx(s.default,{height:20,width:20,color:o})}))},v=e=>{var o,s;const n=x.COLORS.content.placeholder,{toasterText:i}=r.useContext(f);return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexGrow:1}},{children:[t.jsxRuntimeExports.jsx("div",Object.assign({style:{flexGrow:1,marginRight:32,display:"flex",alignItems:"center"}},{children:t.jsxRuntimeExports.jsxs("div",{children:[e.subText?t.jsxRuntimeExports.jsx(a.TitleSmall,Object.assign({color:"inherit"},{children:null!==(o=e.toastText)&&void 0!==o?o:i})):t.jsxRuntimeExports.jsx(a.BodySecondary,Object.assign({color:"inherit"},{children:null!==(s=e.toastText)&&void 0!==s?s:i})),e.subText&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:2}},{children:t.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:x.COLORS.content.secondary},{children:e.subText}))}))]})})),e.showButton&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px",marginRight:{showSecondButton:4,showButton:0}[e.showSecondButton?"showSecondButton":"showButton"]}},{children:t.jsxRuntimeExports.jsx(d.Button,{buttonText:e.buttonText,buttonType:"tertiaryGray",color:x.COLORS.content.secondary,onClick:e.onButtonClick})})),e.showSecondButton&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px"}},{children:t.jsxRuntimeExports.jsx(d.Button,{buttonText:e.secondButtonText,buttonType:"tertiaryGray",color:x.COLORS.content.secondary,onClick:e.onSecondButtonClick})})),e.showButton||e.showSecondButton?t.jsxRuntimeExports.jsx("div",{style:{height:28,alignSelf:"center",marginLeft:8,marginRight:8,borderRight:`1px solid ${n}`,borderRadius:1}}):null]}))})},f=j.default.createContext({toasterText:"",timerValue:0});exports.Toaster=s=>{const u=r.useRef(s.toastId||"default-toast"),[d,a]=r.useState(s.text),[p,j]=r.useState(s.duration||0),y=l.cssTransition({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),b="default"===s.type?null:"success"===s.type?t.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:x.COLORS.content.positive}):"error"===s.type?t.jsxRuntimeExports.jsx(n.default,{width:20,height:20,color:x.COLORS.content.negative}):"warning"===s.type?t.jsxRuntimeExports.jsx(e.default,{width:20,height:20,color:x.COLORS.content.warning}):t.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:x.COLORS.content.brand});r.useEffect((()=>{u.current&&u.current===s.toastId?(a(s.text),l.toast.update(u.current,{autoClose:s.autoClose})):u.current&&u.current!==s.toastId&&m(s.text)}),[s.toastId,s.text]),r.useEffect((()=>{if(!s.duration)return;j(s.duration);const t=setInterval((()=>{j((e=>{const o=e-1;return o<=0?(clearInterval(t),0):o}))}),1e3);return()=>clearInterval(t)}),[s.duration]);const m=e=>{var o,n,i,r,d,c,a,x,p,j,h,f,m,T,B,R;void 0!==s.hideLeftIcon||s.leftIcon?l.toast(t.jsxRuntimeExports.jsx(v,{toastText:e,type:s.type||"info",buttonText:null===(o=s.buttonProps)||void 0===o?void 0:o.buttonText,secondButtonText:null===(n=s.secondButtonProps)||void 0===n?void 0:n.buttonText,showButton:null===(i=s.buttonProps)||void 0===i?void 0:i.showButton,showSecondButton:null===(r=s.secondButtonProps)||void 0===r?void 0:r.showButton,onButtonClick:null===(d=s.buttonProps)||void 0===d?void 0:d.onButtonClick,onSecondButtonClick:null===(c=s.secondButtonProps)||void 0===c?void 0:c.onButtonClick,subText:s.subText}),{onClose:s.onCloseToast?s.onCloseToast:()=>({}),icon:!0!==s.hideLeftIcon&&(s.leftIcon?s.leftIcon:"default"!==s.type&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:b}))),type:s.type,closeButton:t.jsxRuntimeExports.jsx(g,{type:s.type||"default",alignTop:!(!s.subText||(null===(a=s.buttonProps)||void 0===a?void 0:a.showButton)||(null===(x=s.secondButtonProps)||void 0===x?void 0:x.showButton)),blocking:s.blocking}),toastId:s.toastId||"default-toast",transition:y}):u.current=l.toast(t.jsxRuntimeExports.jsx(v,{toastText:e,type:s.type||"info",buttonText:null===(p=s.buttonProps)||void 0===p?void 0:p.buttonText,secondButtonText:null===(j=s.secondButtonProps)||void 0===j?void 0:j.buttonText,showButton:null===(h=s.buttonProps)||void 0===h?void 0:h.showButton,showSecondButton:null===(f=s.secondButtonProps)||void 0===f?void 0:f.showButton,onButtonClick:null===(m=s.buttonProps)||void 0===m?void 0:m.onButtonClick,onSecondButtonClick:null===(T=s.secondButtonProps)||void 0===T?void 0:T.onButtonClick,subText:s.subText}),{onClose:s.onCloseToast?s.onCloseToast:()=>({}),type:s.type,icon:"default"!==s.type&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:b})),closeButton:t.jsxRuntimeExports.jsx(g,{type:s.type||"default",alignTop:!(!s.subText||(null===(B=s.buttonProps)||void 0===B?void 0:B.showButton)||(null===(R=s.secondButtonProps)||void 0===R?void 0:R.showButton)),blocking:s.blocking}),toastId:s.toastId||"default-toast",transition:y})};return r.useEffect((()=>{m()}),[]),h.default.createPortal(t.jsxRuntimeExports.jsx(c.ToasterStyled,Object.assign({width:s.width,height:s.height,zIndex:s.zIndex,isSubTextIncluded:!!s.subText,type:s.type},{children:t.jsxRuntimeExports.jsx(f.Provider,Object.assign({value:{toasterText:d,timerValue:p}},{children:t.jsxRuntimeExports.jsx(l.ToastContainer,{position:s.position||"top-right",closeOnClick:s.closeOnClick||!1,hideProgressBar:s.hideProgressBar||!1,draggable:!1,autoClose:s.autoClose||!1,theme:"colored"})}))})),document.body)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../node_modules/react/jsx-runtime.js"),e=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/check.svg.js"),n=require("../../assets/icons/cross.svg.js"),s=require("../../assets/icons/errorInfo.svg.js"),i=require("../../assets/icons/info.svg.js"),r=require("react"),u=require("react-dom"),l=require("react-toastify"),c=require("../button/Button.js"),d=require("./Toaster.styled.js"),a=require("../TypographyStyle.js"),x=require("../../constants/Theme.js");function p(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var j=p(r),h=p(u);const y=e=>t.jsxRuntimeExports.jsxs(a.BodySecondary,Object.assign({color:"#9E9E9E",customStyles:{fontWeight:600,fontSize:14,width:18}},{children:[e.duration,"s"]})),g=e=>{const o="default"===e.type?x.COLORS.content.primary:"success"===e.type?x.COLORS.content.positive:"error"===e.type?x.COLORS.content.negative:"warning"===e.type?x.COLORS.content.warning:x.COLORS.content.brand,{timerValue:s}=r.useContext(f),i=(!e.blocking||-1!==s)&&(e.blocking&&s>0);return t.jsxRuntimeExports.jsx("div",Object.assign({tabIndex:i?-1:0,role:"button",style:{width:20,display:"flex",cursor:i?"not-allowed":"pointer",alignSelf:""+(e.alignTop?"flex-start":"center"),opacity:i?.5:1},onClick:()=>{!i&&e.closeToast&&e.closeToast()},onKeyDown:t=>{"Enter"===t.key&&!i&&e.closeToast&&e.closeToast()}},{children:s>0?t.jsxRuntimeExports.jsx(y,{duration:s}):t.jsxRuntimeExports.jsx(n.default,{height:20,width:20,color:o})}))},v=e=>{var o,n;const s=x.COLORS.content.placeholder,{toasterText:i}=r.useContext(f);return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexGrow:1}},{children:[t.jsxRuntimeExports.jsx("div",Object.assign({style:{flexGrow:1,marginRight:32,display:"flex",alignItems:"center"}},{children:t.jsxRuntimeExports.jsxs("div",{children:[e.subText?t.jsxRuntimeExports.jsx(a.TitleSmall,Object.assign({color:"inherit"},{children:null!==(o=e.toastText)&&void 0!==o?o:i})):t.jsxRuntimeExports.jsx(a.BodySecondary,Object.assign({color:"inherit"},{children:null!==(n=e.toastText)&&void 0!==n?n:i})),e.subText&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:2}},{children:t.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:x.COLORS.content.secondary},{children:e.subText}))}))]})})),e.showButton&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px",marginRight:{showSecondButton:4,showButton:0}[e.showSecondButton?"showSecondButton":"showButton"]}},{children:t.jsxRuntimeExports.jsx(c.Button,{buttonText:e.buttonText,buttonType:"tertiaryGray",color:x.COLORS.content.secondary,onClick:e.onButtonClick})})),e.showSecondButton&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px"}},{children:t.jsxRuntimeExports.jsx(c.Button,{buttonText:e.secondButtonText,buttonType:"tertiaryGray",color:x.COLORS.content.secondary,onClick:e.onSecondButtonClick})})),e.showButton||e.showSecondButton?t.jsxRuntimeExports.jsx("div",{style:{height:28,alignSelf:"center",marginLeft:8,marginRight:8,borderRight:`1px solid ${s}`,borderRadius:1}}):null]}))})},f=j.default.createContext({toasterText:"",timerValue:-1});exports.Toaster=n=>{const u=r.useRef(n.toastId||"default-toast"),[c,a]=r.useState(n.text),[p,j]=r.useState(n.duration||-1),y=l.cssTransition({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),b="default"===n.type?null:"success"===n.type?t.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:x.COLORS.content.positive}):"error"===n.type?t.jsxRuntimeExports.jsx(s.default,{width:20,height:20,color:x.COLORS.content.negative}):"warning"===n.type?t.jsxRuntimeExports.jsx(e.default,{width:20,height:20,color:x.COLORS.content.warning}):t.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:x.COLORS.content.brand});r.useEffect((()=>{u.current&&u.current===n.toastId?(a(n.text),l.toast.update(u.current,{autoClose:n.autoClose})):u.current&&u.current!==n.toastId&&m(n.text)}),[n.toastId,n.text]),r.useEffect((()=>{if(!n.duration)return;j(n.duration);const t=setInterval((()=>{j((e=>{const o=e-1;return o<=0?(clearInterval(t),0):o}))}),1e3);return()=>clearInterval(t)}),[n.duration]);const m=e=>{var o,s,i,r,c,d,a,x,p,j,h,f,m,T,B,R;void 0!==n.hideLeftIcon||n.leftIcon?l.toast(t.jsxRuntimeExports.jsx(v,{toastText:e,type:n.type||"info",buttonText:null===(o=n.buttonProps)||void 0===o?void 0:o.buttonText,secondButtonText:null===(s=n.secondButtonProps)||void 0===s?void 0:s.buttonText,showButton:null===(i=n.buttonProps)||void 0===i?void 0:i.showButton,showSecondButton:null===(r=n.secondButtonProps)||void 0===r?void 0:r.showButton,onButtonClick:null===(c=n.buttonProps)||void 0===c?void 0:c.onButtonClick,onSecondButtonClick:null===(d=n.secondButtonProps)||void 0===d?void 0:d.onButtonClick,subText:n.subText}),{onClose:n.onCloseToast?n.onCloseToast:()=>({}),icon:!0!==n.hideLeftIcon&&(n.leftIcon?n.leftIcon:"default"!==n.type&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:b}))),type:n.type,closeButton:t.jsxRuntimeExports.jsx(g,{type:n.type||"default",alignTop:!(!n.subText||(null===(a=n.buttonProps)||void 0===a?void 0:a.showButton)||(null===(x=n.secondButtonProps)||void 0===x?void 0:x.showButton)),blocking:n.blocking}),toastId:n.toastId||"default-toast",transition:y}):u.current=l.toast(t.jsxRuntimeExports.jsx(v,{toastText:e,type:n.type||"info",buttonText:null===(p=n.buttonProps)||void 0===p?void 0:p.buttonText,secondButtonText:null===(j=n.secondButtonProps)||void 0===j?void 0:j.buttonText,showButton:null===(h=n.buttonProps)||void 0===h?void 0:h.showButton,showSecondButton:null===(f=n.secondButtonProps)||void 0===f?void 0:f.showButton,onButtonClick:null===(m=n.buttonProps)||void 0===m?void 0:m.onButtonClick,onSecondButtonClick:null===(T=n.secondButtonProps)||void 0===T?void 0:T.onButtonClick,subText:n.subText}),{onClose:n.onCloseToast?n.onCloseToast:()=>({}),type:n.type,icon:"default"!==n.type&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:b})),closeButton:t.jsxRuntimeExports.jsx(g,{type:n.type||"default",alignTop:!(!n.subText||(null===(B=n.buttonProps)||void 0===B?void 0:B.showButton)||(null===(R=n.secondButtonProps)||void 0===R?void 0:R.showButton)),blocking:n.blocking}),toastId:n.toastId||"default-toast",transition:y})};return r.useEffect((()=>{m()}),[]),h.default.createPortal(t.jsxRuntimeExports.jsx(d.ToasterStyled,Object.assign({width:n.width,height:n.height,zIndex:n.zIndex,isSubTextIncluded:!!n.subText,type:n.type},{children:t.jsxRuntimeExports.jsx(f.Provider,Object.assign({value:{toasterText:c,timerValue:p}},{children:t.jsxRuntimeExports.jsx(l.ToastContainer,{position:n.position||"top-right",closeOnClick:n.closeOnClick||!1,hideProgressBar:n.hideProgressBar||!1,draggable:!1,autoClose:n.autoClose||!1,theme:"colored"})}))})),document.body)};
@@ -1 +1 @@
1
- import{j as t}from"../../node_modules/react/jsx-runtime.js";import o from"../../assets/icons/alert_triangle.svg.js";import e from"../../assets/icons/check.svg.js";import n from"../../assets/icons/cross.svg.js";import s from"../../assets/icons/errorInfo.svg.js";import i from"../../assets/icons/info.svg.js";import r,{useRef as l,useState as c,useEffect as d,useContext as a}from"react";import u from"react-dom";import{cssTransition as x,toast as p,ToastContainer as h}from"react-toastify";import{Button as g}from"../button/Button.js";import{ToasterStyled as y}from"./Toaster.styled.js";import{TitleSmall as v,BodySecondary as b,BodyCaption as f}from"../TypographyStyle.js";import{COLORS as j}from"../../constants/Theme.js";const T=o=>t.jsxs(b,Object.assign({color:"#9E9E9E",customStyles:{fontWeight:600,fontSize:14,width:18}},{children:[o.duration,"s"]})),m=o=>{const e="default"===o.type?j.content.primary:"success"===o.type?j.content.positive:"error"===o.type?j.content.negative:"warning"===o.type?j.content.warning:j.content.brand,{timerValue:s}=a(C);let i=o.blocking&&s>0;return t.jsx("div",Object.assign({tabIndex:i?-1:0,role:"button",style:{width:20,display:"flex",cursor:i?"not-allowed":"pointer",alignSelf:""+(o.alignTop?"flex-start":"center"),opacity:i?.5:1},onClick:()=>{!i&&o.closeToast&&o.closeToast()},onKeyDown:t=>{"Enter"===t.key&&!i&&o.closeToast&&o.closeToast()}},{children:s>0?t.jsx(T,{duration:s}):t.jsx(n,{height:20,width:20,color:e})}))},B=o=>{var e,n;const s=j.content.placeholder,{toasterText:i}=a(C);return t.jsx(t.Fragment,{children:t.jsxs("div",Object.assign({style:{display:"flex",flexGrow:1}},{children:[t.jsx("div",Object.assign({style:{flexGrow:1,marginRight:32,display:"flex",alignItems:"center"}},{children:t.jsxs("div",{children:[o.subText?t.jsx(v,Object.assign({color:"inherit"},{children:null!==(e=o.toastText)&&void 0!==e?e:i})):t.jsx(b,Object.assign({color:"inherit"},{children:null!==(n=o.toastText)&&void 0!==n?n:i})),o.subText&&t.jsx("div",Object.assign({style:{marginTop:2}},{children:t.jsx(f,Object.assign({color:j.content.secondary},{children:o.subText}))}))]})})),o.showButton&&t.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px",marginRight:{showSecondButton:4,showButton:0}[o.showSecondButton?"showSecondButton":"showButton"]}},{children:t.jsx(g,{buttonText:o.buttonText,buttonType:"tertiaryGray",color:j.content.secondary,onClick:o.onButtonClick})})),o.showSecondButton&&t.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px"}},{children:t.jsx(g,{buttonText:o.secondButtonText,buttonType:"tertiaryGray",color:j.content.secondary,onClick:o.onSecondButtonClick})})),o.showButton||o.showSecondButton?t.jsx("div",{style:{height:28,alignSelf:"center",marginLeft:8,marginRight:8,borderRight:`1px solid ${s}`,borderRadius:1}}):null]}))})},w=n=>{const r=l(n.toastId||"default-toast"),[a,g]=c(n.text),[v,b]=c(n.duration||0),f=x({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),T="default"===n.type?null:"success"===n.type?t.jsx(e,{width:20,height:20,color:j.content.positive}):"error"===n.type?t.jsx(s,{width:20,height:20,color:j.content.negative}):"warning"===n.type?t.jsx(o,{width:20,height:20,color:j.content.warning}):t.jsx(i,{width:20,height:20,color:j.content.brand});d((()=>{r.current&&r.current===n.toastId?(g(n.text),p.update(r.current,{autoClose:n.autoClose})):r.current&&r.current!==n.toastId&&w(n.text)}),[n.toastId,n.text]),d((()=>{if(!n.duration)return;b(n.duration);const t=setInterval((()=>{b((o=>{const e=o-1;return e<=0?(clearInterval(t),0):e}))}),1e3);return()=>clearInterval(t)}),[n.duration]);const w=o=>{var e,s,i,l,c,d,a,u,x,h,g,y,v,b,j,w;void 0!==n.hideLeftIcon||n.leftIcon?p(t.jsx(B,{toastText:o,type:n.type||"info",buttonText:null===(e=n.buttonProps)||void 0===e?void 0:e.buttonText,secondButtonText:null===(s=n.secondButtonProps)||void 0===s?void 0:s.buttonText,showButton:null===(i=n.buttonProps)||void 0===i?void 0:i.showButton,showSecondButton:null===(l=n.secondButtonProps)||void 0===l?void 0:l.showButton,onButtonClick:null===(c=n.buttonProps)||void 0===c?void 0:c.onButtonClick,onSecondButtonClick:null===(d=n.secondButtonProps)||void 0===d?void 0:d.onButtonClick,subText:n.subText}),{onClose:n.onCloseToast?n.onCloseToast:()=>({}),icon:!0!==n.hideLeftIcon&&(n.leftIcon?n.leftIcon:"default"!==n.type&&t.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:T}))),type:n.type,closeButton:t.jsx(m,{type:n.type||"default",alignTop:!(!n.subText||(null===(a=n.buttonProps)||void 0===a?void 0:a.showButton)||(null===(u=n.secondButtonProps)||void 0===u?void 0:u.showButton)),blocking:n.blocking}),toastId:n.toastId||"default-toast",transition:f}):r.current=p(t.jsx(B,{toastText:o,type:n.type||"info",buttonText:null===(x=n.buttonProps)||void 0===x?void 0:x.buttonText,secondButtonText:null===(h=n.secondButtonProps)||void 0===h?void 0:h.buttonText,showButton:null===(g=n.buttonProps)||void 0===g?void 0:g.showButton,showSecondButton:null===(y=n.secondButtonProps)||void 0===y?void 0:y.showButton,onButtonClick:null===(v=n.buttonProps)||void 0===v?void 0:v.onButtonClick,onSecondButtonClick:null===(b=n.secondButtonProps)||void 0===b?void 0:b.onButtonClick,subText:n.subText}),{onClose:n.onCloseToast?n.onCloseToast:()=>({}),type:n.type,icon:"default"!==n.type&&t.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:T})),closeButton:t.jsx(m,{type:n.type||"default",alignTop:!(!n.subText||(null===(j=n.buttonProps)||void 0===j?void 0:j.showButton)||(null===(w=n.secondButtonProps)||void 0===w?void 0:w.showButton)),blocking:n.blocking}),toastId:n.toastId||"default-toast",transition:f})};return d((()=>{w()}),[]),u.createPortal(t.jsx(y,Object.assign({width:n.width,height:n.height,zIndex:n.zIndex,isSubTextIncluded:!!n.subText,type:n.type},{children:t.jsx(C.Provider,Object.assign({value:{toasterText:a,timerValue:v}},{children:t.jsx(h,{position:n.position||"top-right",closeOnClick:n.closeOnClick||!1,hideProgressBar:n.hideProgressBar||!1,draggable:!1,autoClose:n.autoClose||!1,theme:"colored"})}))})),document.body)},C=r.createContext({toasterText:"",timerValue:0});export{w as Toaster};
1
+ import{j as t}from"../../node_modules/react/jsx-runtime.js";import o from"../../assets/icons/alert_triangle.svg.js";import e from"../../assets/icons/check.svg.js";import n from"../../assets/icons/cross.svg.js";import s from"../../assets/icons/errorInfo.svg.js";import i from"../../assets/icons/info.svg.js";import r,{useRef as l,useState as c,useEffect as d,useContext as a}from"react";import u from"react-dom";import{cssTransition as x,toast as p,ToastContainer as h}from"react-toastify";import{Button as g}from"../button/Button.js";import{ToasterStyled as y}from"./Toaster.styled.js";import{TitleSmall as v,BodySecondary as b,BodyCaption as f}from"../TypographyStyle.js";import{COLORS as j}from"../../constants/Theme.js";const T=o=>t.jsxs(b,Object.assign({color:"#9E9E9E",customStyles:{fontWeight:600,fontSize:14,width:18}},{children:[o.duration,"s"]})),m=o=>{const e="default"===o.type?j.content.primary:"success"===o.type?j.content.positive:"error"===o.type?j.content.negative:"warning"===o.type?j.content.warning:j.content.brand,{timerValue:s}=a(C),i=(!o.blocking||-1!==s)&&(o.blocking&&s>0);return t.jsx("div",Object.assign({tabIndex:i?-1:0,role:"button",style:{width:20,display:"flex",cursor:i?"not-allowed":"pointer",alignSelf:""+(o.alignTop?"flex-start":"center"),opacity:i?.5:1},onClick:()=>{!i&&o.closeToast&&o.closeToast()},onKeyDown:t=>{"Enter"===t.key&&!i&&o.closeToast&&o.closeToast()}},{children:s>0?t.jsx(T,{duration:s}):t.jsx(n,{height:20,width:20,color:e})}))},B=o=>{var e,n;const s=j.content.placeholder,{toasterText:i}=a(C);return t.jsx(t.Fragment,{children:t.jsxs("div",Object.assign({style:{display:"flex",flexGrow:1}},{children:[t.jsx("div",Object.assign({style:{flexGrow:1,marginRight:32,display:"flex",alignItems:"center"}},{children:t.jsxs("div",{children:[o.subText?t.jsx(v,Object.assign({color:"inherit"},{children:null!==(e=o.toastText)&&void 0!==e?e:i})):t.jsx(b,Object.assign({color:"inherit"},{children:null!==(n=o.toastText)&&void 0!==n?n:i})),o.subText&&t.jsx("div",Object.assign({style:{marginTop:2}},{children:t.jsx(f,Object.assign({color:j.content.secondary},{children:o.subText}))}))]})})),o.showButton&&t.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px",marginRight:{showSecondButton:4,showButton:0}[o.showSecondButton?"showSecondButton":"showButton"]}},{children:t.jsx(g,{buttonText:o.buttonText,buttonType:"tertiaryGray",color:j.content.secondary,onClick:o.onButtonClick})})),o.showSecondButton&&t.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",alignSelf:"center",padding:"6px 4px"}},{children:t.jsx(g,{buttonText:o.secondButtonText,buttonType:"tertiaryGray",color:j.content.secondary,onClick:o.onSecondButtonClick})})),o.showButton||o.showSecondButton?t.jsx("div",{style:{height:28,alignSelf:"center",marginLeft:8,marginRight:8,borderRight:`1px solid ${s}`,borderRadius:1}}):null]}))})},w=n=>{const r=l(n.toastId||"default-toast"),[a,g]=c(n.text),[v,b]=c(n.duration||-1),f=x({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),T="default"===n.type?null:"success"===n.type?t.jsx(e,{width:20,height:20,color:j.content.positive}):"error"===n.type?t.jsx(s,{width:20,height:20,color:j.content.negative}):"warning"===n.type?t.jsx(o,{width:20,height:20,color:j.content.warning}):t.jsx(i,{width:20,height:20,color:j.content.brand});d((()=>{r.current&&r.current===n.toastId?(g(n.text),p.update(r.current,{autoClose:n.autoClose})):r.current&&r.current!==n.toastId&&w(n.text)}),[n.toastId,n.text]),d((()=>{if(!n.duration)return;b(n.duration);const t=setInterval((()=>{b((o=>{const e=o-1;return e<=0?(clearInterval(t),0):e}))}),1e3);return()=>clearInterval(t)}),[n.duration]);const w=o=>{var e,s,i,l,c,d,a,u,x,h,g,y,v,b,j,w;void 0!==n.hideLeftIcon||n.leftIcon?p(t.jsx(B,{toastText:o,type:n.type||"info",buttonText:null===(e=n.buttonProps)||void 0===e?void 0:e.buttonText,secondButtonText:null===(s=n.secondButtonProps)||void 0===s?void 0:s.buttonText,showButton:null===(i=n.buttonProps)||void 0===i?void 0:i.showButton,showSecondButton:null===(l=n.secondButtonProps)||void 0===l?void 0:l.showButton,onButtonClick:null===(c=n.buttonProps)||void 0===c?void 0:c.onButtonClick,onSecondButtonClick:null===(d=n.secondButtonProps)||void 0===d?void 0:d.onButtonClick,subText:n.subText}),{onClose:n.onCloseToast?n.onCloseToast:()=>({}),icon:!0!==n.hideLeftIcon&&(n.leftIcon?n.leftIcon:"default"!==n.type&&t.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:T}))),type:n.type,closeButton:t.jsx(m,{type:n.type||"default",alignTop:!(!n.subText||(null===(a=n.buttonProps)||void 0===a?void 0:a.showButton)||(null===(u=n.secondButtonProps)||void 0===u?void 0:u.showButton)),blocking:n.blocking}),toastId:n.toastId||"default-toast",transition:f}):r.current=p(t.jsx(B,{toastText:o,type:n.type||"info",buttonText:null===(x=n.buttonProps)||void 0===x?void 0:x.buttonText,secondButtonText:null===(h=n.secondButtonProps)||void 0===h?void 0:h.buttonText,showButton:null===(g=n.buttonProps)||void 0===g?void 0:g.showButton,showSecondButton:null===(y=n.secondButtonProps)||void 0===y?void 0:y.showButton,onButtonClick:null===(v=n.buttonProps)||void 0===v?void 0:v.onButtonClick,onSecondButtonClick:null===(b=n.secondButtonProps)||void 0===b?void 0:b.onButtonClick,subText:n.subText}),{onClose:n.onCloseToast?n.onCloseToast:()=>({}),type:n.type,icon:"default"!==n.type&&t.jsx("div",Object.assign({style:{display:"flex",alignItems:"flex-start"}},{children:T})),closeButton:t.jsx(m,{type:n.type||"default",alignTop:!(!n.subText||(null===(j=n.buttonProps)||void 0===j?void 0:j.showButton)||(null===(w=n.secondButtonProps)||void 0===w?void 0:w.showButton)),blocking:n.blocking}),toastId:n.toastId||"default-toast",transition:f})};return d((()=>{w()}),[]),u.createPortal(t.jsx(y,Object.assign({width:n.width,height:n.height,zIndex:n.zIndex,isSubTextIncluded:!!n.subText,type:n.type},{children:t.jsx(C.Provider,Object.assign({value:{toasterText:a,timerValue:v}},{children:t.jsx(h,{position:n.position||"top-right",closeOnClick:n.closeOnClick||!1,hideProgressBar:n.hideProgressBar||!1,draggable:!1,autoClose:n.autoClose||!1,theme:"colored"})}))})),document.body)},C=r.createContext({toasterText:"",timerValue:-1});export{w as Toaster};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.727-beta.30",
3
+ "version": "0.0.727-beta.34",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",