@bikdotai/bik-component-library 0.0.547-beta.pp-3 → 0.0.547-beta.pp-4
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"),e=require("../../assets/icons/cross.svg.js"),o=require("react"),n=require("react-dom"),s=require("react-toastify"),r=require("./Toaster.styled.js"),i=require("../TypographyStyle.js"),l=require("../../constants/Theme.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../../assets/icons/cross.svg.js"),o=require("react"),n=require("react-dom"),s=require("react-toastify"),r=require("./Toaster.styled.js"),i=require("../TypographyStyle.js"),l=require("../../constants/Theme.js");function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var u=a(o),d=a(n);const c=o=>{const n="default"===o.type?l.COLORS.content.secondary:l.COLORS.content.secondaryInverse;return t.jsx("div",Object.assign({tabIndex:0,role:"button",style:{width:20,display:"flex",margin:"auto",cursor:"pointer"},onClick:o.closeToast,onKeyDown:t=>{"Enter"===t.key&&o.closeToast()}},{children:t.jsx(e.default,{height:20,width:20,color:n})}))},h=e=>{var n;const s="default"===e.type?l.COLORS.stroke.primary:"success"===e.type?l.COLORS.background.positive.vibrant:"error"===e.type?l.COLORS.background.negative.vibrant:"warning"===e.type?l.COLORS.background.warning.vibrant:l.COLORS.background.inverseLight;console.log("render content rendered",e.toastText);const{toasterText:r}=o.useContext(x);return t.jsx(t.Fragment,{children:t.jsxs("div",Object.assign({style:{display:"flex",flexGrow:1,borderRight:e.hideCloseButton?"unset":`1px solid ${s}`}},{children:[t.jsx("div",Object.assign({style:{flexGrow:1,marginRight:e.showButton?16:e.hideCloseButton?0:12}},{children:t.jsx(i.BodyPrimary,Object.assign({color:"inherit"},{children:null!==(n=e.toastText)&&void 0!==n?n:r}))})),e.showButton&&t.jsx(i.ButtonRegular,Object.assign({style:{marginRight:e.hideCloseButton?0:12,marginTop:"auto",marginBottom:"auto",display:"flex",cursor:"pointer"},onClick:e.onButtonClick,color:"default"===e.type?l.COLORS.content.brand:"inherit"},{children:e.buttonText}))]}))})},x=u.default.createContext({toasterText:""});exports.Toaster=e=>{const n=o.useRef(null),[i,l]=o.useState(e.text);console.log("toastId",n),o.useEffect((()=>{console.log("id changes",n.current,e.toastId),n.current&&n.current===e.toastId?l(e.text):n.current&&n.current!==e.toastId&&a(e.text)}),[e.toastId,e.text]);const a=o=>{var r,l,a,u,d,x;void 0!==e.hideLeftIcon||e.leftIcon?s.toast(t.jsx(h,{toastText:e.text,type:e.type||"info",buttonText:null===(r=e.buttonProps)||void 0===r?void 0:r.buttonText,showButton:null===(l=e.buttonProps)||void 0===l?void 0:l.showButton,onButtonClick:null===(a=e.buttonProps)||void 0===a?void 0:a.onButtonClick,hideCloseButton:e.hideCloseButton},`${e.text}-${e.toastId}`),{onClose:e.onCloseToast?e.onCloseToast:()=>({}),icon:t=>!1!==e.hideLeftIcon&&(e.leftIcon?e.leftIcon:null),type:e.type,closeButton:!e.hideCloseButton&&t.jsx(c,{type:e.type||"default"})}):(console.log("notify called",e.toastId,e.text,i),n.current=s.toast(t.jsx(h,{toastText:o,type:e.type||"info",buttonText:null===(u=e.buttonProps)||void 0===u?void 0:u.buttonText,showButton:null===(d=e.buttonProps)||void 0===d?void 0:d.showButton,onButtonClick:null===(x=e.buttonProps)||void 0===x?void 0:x.onButtonClick,hideCloseButton:e.hideCloseButton},e.toastId),{onClose:e.onCloseToast?e.onCloseToast:()=>({}),type:e.type,closeButton:!e.hideCloseButton&&t.jsx(c,{type:e.type||"info"}),toastId:e.toastId}))};return o.useEffect((()=>{a()}),[]),d.default.createPortal(t.jsx(r.ToasterStyled,Object.assign({width:e.width,height:e.height,zIndex:e.zIndex},{children:t.jsx(x.Provider,Object.assign({value:{toasterText:i}},{children:t.jsx(s.ToastContainer,{position:e.position||"top-right",closeOnClick:e.closeOnClick||!1,hideProgressBar:e.hideProgressBar||!1,draggable:!1,autoClose:e.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/cross.svg.js";import{useRef as
|
|
1
|
+
import{jsx as t,Fragment as o,jsxs as e}from"react/jsx-runtime";import n from"../../assets/icons/cross.svg.js";import s,{useRef as r,useState as i,useEffect as l,useContext as a}from"react";import d from"react-dom";import{toast as c,ToastContainer as u}from"react-toastify";import{ToasterStyled as h}from"./Toaster.styled.js";import{BodyPrimary as p,ButtonRegular as g}from"../TypographyStyle.js";import{COLORS as y}from"../../constants/Theme.js";const b=o=>{const e="default"===o.type?y.content.secondary:y.content.secondaryInverse;return t("div",Object.assign({tabIndex:0,role:"button",style:{width:20,display:"flex",margin:"auto",cursor:"pointer"},onClick:o.closeToast,onKeyDown:t=>{"Enter"===t.key&&o.closeToast()}},{children:t(n,{height:20,width:20,color:e})}))},x=n=>{var s;const r="default"===n.type?y.stroke.primary:"success"===n.type?y.background.positive.vibrant:"error"===n.type?y.background.negative.vibrant:"warning"===n.type?y.background.warning.vibrant:y.background.inverseLight;console.log("render content rendered",n.toastText);const{toasterText:i}=a(m);return t(o,{children:e("div",Object.assign({style:{display:"flex",flexGrow:1,borderRight:n.hideCloseButton?"unset":`1px solid ${r}`}},{children:[t("div",Object.assign({style:{flexGrow:1,marginRight:n.showButton?16:n.hideCloseButton?0:12}},{children:t(p,Object.assign({color:"inherit"},{children:null!==(s=n.toastText)&&void 0!==s?s:i}))})),n.showButton&&t(g,Object.assign({style:{marginRight:n.hideCloseButton?0:12,marginTop:"auto",marginBottom:"auto",display:"flex",cursor:"pointer"},onClick:n.onButtonClick,color:"default"===n.type?y.content.brand:"inherit"},{children:n.buttonText}))]}))})},v=o=>{const e=r(null),[n,s]=i(o.text);console.log("toastId",e),l((()=>{console.log("id changes",e.current,o.toastId),e.current&&e.current===o.toastId?s(o.text):e.current&&e.current!==o.toastId&&a(o.text)}),[o.toastId,o.text]);const a=s=>{var r,i,l,a,d,u;void 0!==o.hideLeftIcon||o.leftIcon?c(t(x,{toastText:o.text,type:o.type||"info",buttonText:null===(r=o.buttonProps)||void 0===r?void 0:r.buttonText,showButton:null===(i=o.buttonProps)||void 0===i?void 0:i.showButton,onButtonClick:null===(l=o.buttonProps)||void 0===l?void 0:l.onButtonClick,hideCloseButton:o.hideCloseButton},`${o.text}-${o.toastId}`),{onClose:o.onCloseToast?o.onCloseToast:()=>({}),icon:t=>!1!==o.hideLeftIcon&&(o.leftIcon?o.leftIcon:null),type:o.type,closeButton:!o.hideCloseButton&&t(b,{type:o.type||"default"})}):(console.log("notify called",o.toastId,o.text,n),e.current=c(t(x,{toastText:s,type:o.type||"info",buttonText:null===(a=o.buttonProps)||void 0===a?void 0:a.buttonText,showButton:null===(d=o.buttonProps)||void 0===d?void 0:d.showButton,onButtonClick:null===(u=o.buttonProps)||void 0===u?void 0:u.onButtonClick,hideCloseButton:o.hideCloseButton},o.toastId),{onClose:o.onCloseToast?o.onCloseToast:()=>({}),type:o.type,closeButton:!o.hideCloseButton&&t(b,{type:o.type||"info"}),toastId:o.toastId}))};return l((()=>{a()}),[]),d.createPortal(t(h,Object.assign({width:o.width,height:o.height,zIndex:o.zIndex},{children:t(m.Provider,Object.assign({value:{toasterText:n}},{children:t(u,{position:o.position||"top-right",closeOnClick:o.closeOnClick||!1,hideProgressBar:o.hideProgressBar||!1,draggable:!1,autoClose:o.autoClose||!1,theme:"colored"})}))})),document.body)},m=s.createContext({toasterText:""});export{v as Toaster};
|