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