@bikdotai/bik-component-library 0.0.727-beta.24 → 0.0.727-beta.26

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"),r=require("../../assets/icons/info.svg.js"),i=require("react"),u=require("react-dom"),l=require("react-toastify"),a=require("../button/Button.js"),d=require("./Toaster.styled.js"),c=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(i),h=p(u);const g=e=>t.jsxRuntimeExports.jsxs(c.BodySecondary,{children:["Skip in ",e.duration," sec "]}),y=e=>{console.log(e);const o="default"===e.type?"#fff":"success"===e.type?x.COLORS.background.positive.light:"error"===e.type?x.COLORS.background.negative.light:"warning"===e.type?x.COLORS.background.warning.light:x.COLORS.background.brandLight,n="default"===e.type?x.COLORS.stroke.primary:"success"===e.type?x.COLORS.stroke.positive.lightAlt:"error"===e.type?x.COLORS.stroke.negative.lightAlt:"warning"===e.type?x.COLORS.stroke.warning.lightAlt:x.COLORS.stroke.brandLightAlt,r="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:u}=i.useContext(R);return console.log(u),t.jsxRuntimeExports.jsx("div",Object.assign({tabIndex:0,role:"button",style:{backgroundColor:o,border:`1px solid ${n}`,borderRadius:8,position:"absolute",top:-12,right:-12,width:u>0?130:40,display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",zIndex:10,paddingRight:u>0?8:0},onClick:e.closeToast,onKeyDown:t=>{"Enter"===t.key&&e.closeToast&&e.closeToast()}},{children:u>0?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(g,{duration:u}),t.jsxRuntimeExports.jsx(s.default,{height:20,width:20,color:r})]}):t.jsxRuntimeExports.jsx(s.default,{height:20,width:20,color:r})}))},f=e=>{var o,s;const n=x.COLORS.content.placeholder,{toasterText:r}=i.useContext(R);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(c.TitleSmall,Object.assign({color:"inherit"},{children:null!==(o=e.toastText)&&void 0!==o?o:r})):t.jsxRuntimeExports.jsx(c.BodySecondary,Object.assign({color:"inherit"},{children:null!==(s=e.toastText)&&void 0!==s?s:r})),e.subText&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:2}},{children:t.jsxRuntimeExports.jsx(c.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(a.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(a.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]}))})},R=j.default.createContext({toasterText:"",timerValue:0});exports.Toaster=s=>{const u=i.useRef(s.toastId||"default-toast"),[a,c]=i.useState(s.text),[p,j]=i.useState(s.duration||0),g=i.useRef(!1),m=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(r.default,{width:20,height:20,color:x.COLORS.content.brand});i.useEffect((()=>{u.current&&u.current===s.toastId?(c(s.text),l.toast.update(u.current,{autoClose:s.autoClose})):u.current&&u.current!==s.toastId&&v(s.text)}),[s.toastId,s.text]),i.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]),i.useEffect((()=>{s.duration&&0===p&&!g.current||g.current||(g.current=!0,v())}),[p,s.duration]);const v=e=>{var o,n,r,i,a,d,c,x,j,h,g,R;void 0!==s.hideLeftIcon||s.leftIcon?l.toast(t.jsxRuntimeExports.jsx(f,{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===(r=s.buttonProps)||void 0===r?void 0:r.showButton,showSecondButton:null===(i=s.secondButtonProps)||void 0===i?void 0:i.showButton,onButtonClick:null===(a=s.buttonProps)||void 0===a?void 0:a.onButtonClick,onSecondButtonClick:null===(d=s.secondButtonProps)||void 0===d?void 0:d.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(y,{type:s.type||"default",timer:p}),toastId:s.toastId||"default-toast",transition:m}):u.current=l.toast(t.jsxRuntimeExports.jsx(f,{toastText:e,type:s.type||"info",buttonText:null===(c=s.buttonProps)||void 0===c?void 0:c.buttonText,secondButtonText:null===(x=s.secondButtonProps)||void 0===x?void 0:x.buttonText,showButton:null===(j=s.buttonProps)||void 0===j?void 0:j.showButton,showSecondButton:null===(h=s.secondButtonProps)||void 0===h?void 0:h.showButton,onButtonClick:null===(g=s.buttonProps)||void 0===g?void 0:g.onButtonClick,onSecondButtonClick:null===(R=s.secondButtonProps)||void 0===R?void 0:R.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(y,{type:s.type||"default",timer:p}),toastId:s.toastId||"default-toast",transition:m})};return h.default.createPortal(t.jsxRuntimeExports.jsx(d.ToasterStyled,Object.assign({width:s.width,height:s.height,zIndex:s.zIndex,isSubTextIncluded:!!s.subText,type:s.type},{children:t.jsxRuntimeExports.jsx(R.Provider,Object.assign({value:{toasterText:a,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"),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"),a=require("../button/Button.js"),d=require("./Toaster.styled.js"),c=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 g=e=>t.jsxRuntimeExports.jsxs(c.BodySecondary,{children:["Skip in ",e.duration," sec "]}),y=e=>{console.log(e);const o="default"===e.type?"#fff":"success"===e.type?x.COLORS.background.positive.light:"error"===e.type?x.COLORS.background.negative.light:"warning"===e.type?x.COLORS.background.warning.light:x.COLORS.background.brandLight,n="default"===e.type?x.COLORS.stroke.primary:"success"===e.type?x.COLORS.stroke.positive.lightAlt:"error"===e.type?x.COLORS.stroke.negative.lightAlt:"warning"===e.type?x.COLORS.stroke.warning.lightAlt:x.COLORS.stroke.brandLightAlt,i="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:u}=r.useContext(R);return console.log(u),t.jsxRuntimeExports.jsx("div",Object.assign({tabIndex:0,role:"button",style:{backgroundColor:o,border:`1px solid ${n}`,borderRadius:8,position:"absolute",top:-12,right:-12,width:u>0?130:40,display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",zIndex:10,paddingRight:u>0?8:0},onClick:e.closeToast,onKeyDown:t=>{"Enter"===t.key&&e.closeToast&&e.closeToast()}},{children:u>0?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(g,{duration:u}),t.jsxRuntimeExports.jsx(s.default,{height:20,width:20,color:i})]}):t.jsxRuntimeExports.jsx(s.default,{height:20,width:20,color:i})}))},f=e=>{var o,s;const n=x.COLORS.content.placeholder,{toasterText:i}=r.useContext(R);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(c.TitleSmall,Object.assign({color:"inherit"},{children:null!==(o=e.toastText)&&void 0!==o?o:i})):t.jsxRuntimeExports.jsx(c.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(c.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(a.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(a.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]}))})},R=j.default.createContext({toasterText:"",timerValue:0});exports.Toaster=s=>{const u=r.useRef(s.toastId||"default-toast"),[a,c]=r.useState(s.text),[p,j]=r.useState(s.duration||0),g=l.cssTransition({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),m="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?(c(s.text),l.toast.update(u.current,{autoClose:s.autoClose})):u.current&&u.current!==s.toastId&&b(s.text)}),[s.toastId,s.text]),r.useEffect((()=>{if(console.log("Inside useffect",s.duration),!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 b=e=>{var o,n,i,r,a,d,c,x,j,h,R,b;void 0!==s.hideLeftIcon||s.leftIcon?l.toast(t.jsxRuntimeExports.jsx(f,{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===(a=s.buttonProps)||void 0===a?void 0:a.onButtonClick,onSecondButtonClick:null===(d=s.secondButtonProps)||void 0===d?void 0:d.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:m}))),type:s.type,closeButton:t.jsxRuntimeExports.jsx(y,{type:s.type||"default",timer:p}),toastId:s.toastId||"default-toast",transition:g}):u.current=l.toast(t.jsxRuntimeExports.jsx(f,{toastText:e,type:s.type||"info",buttonText:null===(c=s.buttonProps)||void 0===c?void 0:c.buttonText,secondButtonText:null===(x=s.secondButtonProps)||void 0===x?void 0:x.buttonText,showButton:null===(j=s.buttonProps)||void 0===j?void 0:j.showButton,showSecondButton:null===(h=s.secondButtonProps)||void 0===h?void 0:h.showButton,onButtonClick:null===(R=s.buttonProps)||void 0===R?void 0:R.onButtonClick,onSecondButtonClick:null===(b=s.secondButtonProps)||void 0===b?void 0:b.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:m})),closeButton:t.jsxRuntimeExports.jsx(y,{type:s.type||"default",timer:p}),toastId:s.toastId||"default-toast",transition:g})};return r.useEffect((()=>{b()}),[]),h.default.createPortal(t.jsxRuntimeExports.jsx(d.ToasterStyled,Object.assign({width:s.width,height:s.height,zIndex:s.zIndex,isSubTextIncluded:!!s.subText,type:s.type},{children:t.jsxRuntimeExports.jsx(R.Provider,Object.assign({value:{toasterText:a,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 +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 p,toast as x,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 b,BodySecondary as f,BodyCaption as j}from"../TypographyStyle.js";import{COLORS as v}from"../../constants/Theme.js";const m=o=>t.jsxs(f,{children:["Skip in ",o.duration," sec "]}),T=o=>{console.log(o);const e="default"===o.type?"#fff":"success"===o.type?v.background.positive.light:"error"===o.type?v.background.negative.light:"warning"===o.type?v.background.warning.light:v.background.brandLight,s="default"===o.type?v.stroke.primary:"success"===o.type?v.stroke.positive.lightAlt:"error"===o.type?v.stroke.negative.lightAlt:"warning"===o.type?v.stroke.warning.lightAlt:v.stroke.brandLightAlt,i="default"===o.type?v.content.primary:"success"===o.type?v.content.positive:"error"===o.type?v.content.negative:"warning"===o.type?v.content.warning:v.content.brand,{timerValue:r}=a(k);return console.log(r),t.jsx("div",Object.assign({tabIndex:0,role:"button",style:{backgroundColor:e,border:`1px solid ${s}`,borderRadius:8,position:"absolute",top:-12,right:-12,width:r>0?130:40,display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",zIndex:10,paddingRight:r>0?8:0},onClick:o.closeToast,onKeyDown:t=>{"Enter"===t.key&&o.closeToast&&o.closeToast()}},{children:r>0?t.jsxs(t.Fragment,{children:[t.jsx(m,{duration:r}),t.jsx(n,{height:20,width:20,color:i})]}):t.jsx(n,{height:20,width:20,color:i})}))},B=o=>{var e,n;const s=v.content.placeholder,{toasterText:i}=a(k);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(b,Object.assign({color:"inherit"},{children:null!==(e=o.toastText)&&void 0!==e?e:i})):t.jsx(f,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(j,Object.assign({color:v.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:v.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:v.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),[b,f]=c(n.duration||0),j=l(!1),m=p({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),w="default"===n.type?null:"success"===n.type?t.jsx(e,{width:20,height:20,color:v.content.positive}):"error"===n.type?t.jsx(s,{width:20,height:20,color:v.content.negative}):"warning"===n.type?t.jsx(o,{width:20,height:20,color:v.content.warning}):t.jsx(i,{width:20,height:20,color:v.content.brand});d((()=>{r.current&&r.current===n.toastId?(g(n.text),x.update(r.current,{autoClose:n.autoClose})):r.current&&r.current!==n.toastId&&C(n.text)}),[n.toastId,n.text]),d((()=>{if(!n.duration)return;f(n.duration);const t=setInterval((()=>{f((o=>{const e=o-1;return e<=0?(clearInterval(t),0):e}))}),1e3);return()=>clearInterval(t)}),[n.duration]),d((()=>{n.duration&&0===b&&!j.current||j.current||(j.current=!0,C())}),[b,n.duration]);const C=o=>{var e,s,i,l,c,d,a,u,p,h,g,y;void 0!==n.hideLeftIcon||n.leftIcon?x(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:w}))),type:n.type,closeButton:t.jsx(T,{type:n.type||"default",timer:b}),toastId:n.toastId||"default-toast",transition:m}):r.current=x(t.jsx(B,{toastText:o,type:n.type||"info",buttonText:null===(a=n.buttonProps)||void 0===a?void 0:a.buttonText,secondButtonText:null===(u=n.secondButtonProps)||void 0===u?void 0:u.buttonText,showButton:null===(p=n.buttonProps)||void 0===p?void 0:p.showButton,showSecondButton:null===(h=n.secondButtonProps)||void 0===h?void 0:h.showButton,onButtonClick:null===(g=n.buttonProps)||void 0===g?void 0:g.onButtonClick,onSecondButtonClick:null===(y=n.secondButtonProps)||void 0===y?void 0:y.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:w})),closeButton:t.jsx(T,{type:n.type||"default",timer:b}),toastId:n.toastId||"default-toast",transition:m})};return 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(k.Provider,Object.assign({value:{toasterText:a,timerValue:b}},{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)},k=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 p,toast as x,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 f,BodySecondary as b,BodyCaption as j}from"../TypographyStyle.js";import{COLORS as v}from"../../constants/Theme.js";const m=o=>t.jsxs(b,{children:["Skip in ",o.duration," sec "]}),T=o=>{console.log(o);const e="default"===o.type?"#fff":"success"===o.type?v.background.positive.light:"error"===o.type?v.background.negative.light:"warning"===o.type?v.background.warning.light:v.background.brandLight,s="default"===o.type?v.stroke.primary:"success"===o.type?v.stroke.positive.lightAlt:"error"===o.type?v.stroke.negative.lightAlt:"warning"===o.type?v.stroke.warning.lightAlt:v.stroke.brandLightAlt,i="default"===o.type?v.content.primary:"success"===o.type?v.content.positive:"error"===o.type?v.content.negative:"warning"===o.type?v.content.warning:v.content.brand,{timerValue:r}=a(k);return console.log(r),t.jsx("div",Object.assign({tabIndex:0,role:"button",style:{backgroundColor:e,border:`1px solid ${s}`,borderRadius:8,position:"absolute",top:-12,right:-12,width:r>0?130:40,display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",zIndex:10,paddingRight:r>0?8:0},onClick:o.closeToast,onKeyDown:t=>{"Enter"===t.key&&o.closeToast&&o.closeToast()}},{children:r>0?t.jsxs(t.Fragment,{children:[t.jsx(m,{duration:r}),t.jsx(n,{height:20,width:20,color:i})]}):t.jsx(n,{height:20,width:20,color:i})}))},B=o=>{var e,n;const s=v.content.placeholder,{toasterText:i}=a(k);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(f,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(j,Object.assign({color:v.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:v.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:v.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),[f,b]=c(n.duration||0),j=p({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit"}),m="default"===n.type?null:"success"===n.type?t.jsx(e,{width:20,height:20,color:v.content.positive}):"error"===n.type?t.jsx(s,{width:20,height:20,color:v.content.negative}):"warning"===n.type?t.jsx(o,{width:20,height:20,color:v.content.warning}):t.jsx(i,{width:20,height:20,color:v.content.brand});d((()=>{r.current&&r.current===n.toastId?(g(n.text),x.update(r.current,{autoClose:n.autoClose})):r.current&&r.current!==n.toastId&&w(n.text)}),[n.toastId,n.text]),d((()=>{if(console.log("Inside useffect",n.duration),!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,p,h,g,y;void 0!==n.hideLeftIcon||n.leftIcon?x(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:m}))),type:n.type,closeButton:t.jsx(T,{type:n.type||"default",timer:f}),toastId:n.toastId||"default-toast",transition:j}):r.current=x(t.jsx(B,{toastText:o,type:n.type||"info",buttonText:null===(a=n.buttonProps)||void 0===a?void 0:a.buttonText,secondButtonText:null===(u=n.secondButtonProps)||void 0===u?void 0:u.buttonText,showButton:null===(p=n.buttonProps)||void 0===p?void 0:p.showButton,showSecondButton:null===(h=n.secondButtonProps)||void 0===h?void 0:h.showButton,onButtonClick:null===(g=n.buttonProps)||void 0===g?void 0:g.onButtonClick,onSecondButtonClick:null===(y=n.secondButtonProps)||void 0===y?void 0:y.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:m})),closeButton:t.jsx(T,{type:n.type||"default",timer:f}),toastId:n.toastId||"default-toast",transition:j})};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(k.Provider,Object.assign({value:{toasterText:a,timerValue:f}},{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)},k=r.createContext({toasterText:"",timerValue:0});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.24",
3
+ "version": "0.0.727-beta.26",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",