react-toastify
Advanced tools
Comparing version 8.0.1 to 8.0.2-with-side-effects
@@ -851,2 +851,4 @@ 'use strict'; | ||
viewBox: "0 0 24 24", | ||
width: "100%", | ||
height: "100%", | ||
fill: theme === 'colored' ? 'currentColor' : "var(--toastify-icon-color-" + type + ")" | ||
@@ -853,0 +855,0 @@ }, rest)); |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function s(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)t.indexOf(n=a[o])>=0||(r[n]=e[n]);return r}function i(e){return"number"==typeof e&&!isNaN(e)}function c(e){return"boolean"==typeof e}function l(e){return"string"==typeof e}function u(e){return"function"==typeof e}function d(e){return l(e)||u(e)?e:null}function f(e){return 0===e||e}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function m(e){return t.isValidElement(e)||l(e)||u(e)||i(e)}var g={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},v={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"};function y(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function h(e){var o=e.enter,r=e.exit,a=e.appendPosition,s=void 0!==a&&a,i=e.collapse,c=void 0===i||i,l=e.collapseDuration,u=void 0===l?300:l;return function(e){var a=e.children,i=e.position,l=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=s?o+"--"+i:o,g=s?r+"--"+i:r,v=t.useRef(),h=t.useRef(0);function T(e){if(e.target===f.current){var t=f.current;t.removeEventListener("animationend",T),0===h.current&&(t.className=v.current)}}function E(){var e=f.current;e.removeEventListener("animationend",E),c?y(e,d,u):d()}return t.useLayoutEffect((function(){var e;v.current=(e=f.current).className,e.className+=" "+m,e.addEventListener("animationend",T)}),[]),t.useEffect((function(){p||(l?E():function(){h.current=1;var e=f.current;e.className+=" "+g,e.addEventListener("animationend",E)}())}),[p]),n.createElement(n.Fragment,null,a)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}};function E(e,n){void 0===n&&(n=!1);var o=t.useRef(e);return t.useEffect((function(){n&&(o.current=e)})),o.current}function b(e,t){switch(t.type){case 0:return[].concat(e,[t.toastId]).filter((function(e){return e!==t.staleId}));case 1:return f(t.toastId)?e.filter((function(e){return e!==t.toastId})):[]}}var O=["delay","staleId"];function C(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useReducer(b,[]),r=o[0],a=o[1],p=t.useRef(null),g=E(0),v=E([]),y=E({}),h=E({toastKey:1,displayedToast:0,props:e,containerId:null,isToastActive:C,getToast:function(e){return y[e]||null}});function C(e){return-1!==r.indexOf(e)}function _(e){var t=e.containerId;!h.props.limit||t&&h.containerId!==t||(g-=v.length,v=[])}function I(e){a({type:1,toastId:e})}function L(){var e=v.shift();N(e.toastContent,e.toastProps,e.staleId)}function x(e,o){var r=o.delay,a=o.staleId,T=s(o,O);if(m(e)&&(E=T,!(!p.current||h.props.enableMultiContainer&&E.containerId!==h.props.containerId||y[E.toastId]&&null==E.updateId))){var E,b=T.toastId,C=T.data,_=h.props,x=function(){return I(b)},R=null==T.updateId;R&&g++;var P,k,B={toastId:b,updateId:T.updateId,isLoading:T.isLoading,theme:T.theme||_.theme,icon:T.icon||_.icon,isIn:!1,key:T.key||h.toastKey++,type:T.type,closeToast:x,closeButton:T.closeButton,rtl:_.rtl,position:T.position||_.position,transition:T.transition||_.transition,className:d(T.className||_.toastClassName),bodyClassName:d(T.bodyClassName||_.bodyClassName),style:T.style||_.toastStyle,bodyStyle:T.bodyStyle||_.bodyStyle,onClick:T.onClick||_.onClick,pauseOnHover:c(T.pauseOnHover)?T.pauseOnHover:_.pauseOnHover,pauseOnFocusLoss:c(T.pauseOnFocusLoss)?T.pauseOnFocusLoss:_.pauseOnFocusLoss,draggable:c(T.draggable)?T.draggable:_.draggable,draggablePercent:i(T.draggablePercent)?T.draggablePercent:_.draggablePercent,draggableDirection:T.draggableDirection||_.draggableDirection,closeOnClick:c(T.closeOnClick)?T.closeOnClick:_.closeOnClick,progressClassName:d(T.progressClassName||_.progressClassName),progressStyle:T.progressStyle||_.progressStyle,autoClose:!T.isLoading&&(P=T.autoClose,k=_.autoClose,!1===P||i(P)&&P>0?P:k),hideProgressBar:c(T.hideProgressBar)?T.hideProgressBar:_.hideProgressBar,progress:T.progress,role:l(T.role)?T.role:_.role,deleteToast:function(){!function(e){delete y[e];var t=v.length;if((g=f(e)?g-1:g-h.displayedToast)<0&&(g=0),t>0){var o=f(e)?1:h.props.limit;if(1===t||1===o)h.displayedToast++,L();else{var r=o>t?t:o;h.displayedToast=r;for(var a=0;a<r;a++)L()}}else n()}(b)}};u(T.onOpen)&&(B.onOpen=T.onOpen),u(T.onClose)&&(B.onClose=T.onClose),"y"===B.draggableDirection&&80===B.draggablePercent&&(B.draggablePercent*=1.5);var w=_.closeButton;!1===T.closeButton||m(T.closeButton)?w=T.closeButton:!0===T.closeButton&&(w=!m(_.closeButton)||_.closeButton),B.closeButton=w;var D=e;t.isValidElement(e)&&!l(e.type)?D=t.cloneElement(e,{closeToast:x,toastProps:B,data:C}):u(e)&&(D=e({closeToast:x,toastProps:B,data:C})),_.limit&&_.limit>0&&g>_.limit&&R?v.push({toastContent:D,toastProps:B,staleId:a}):i(r)&&r>0?setTimeout((function(){N(D,B,a)}),r):N(D,B,a)}}function N(e,t,n){var o=t.toastId;n&&delete y[n],y[o]={content:e,props:t},a({type:0,toastId:o,staleId:n})}return t.useEffect((function(){return h.containerId=e.containerId,T.cancelEmit(3).on(0,x).on(1,(function(e){return p.current&&I(e)})).on(5,_).emit(2,h),function(){return T.emit(3,h)}}),[]),t.useEffect((function(){h.isToastActive=C,h.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){h.props=e})),{getToastToRender:function(t){for(var n={},o=e.newestOnTop?Object.keys(y).reverse():Object.keys(y),r=0;r<o.length;r++){var a=y[o[r]],s=a.props.position;n[s]||(n[s]=[]),n[s].push(a)}return Object.keys(n).map((function(e){return t(e,n[e])}))},collection:y,containerRef:p,isToastActive:C}}function _(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function I(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function L(e){var n=t.useState(!0),o=n[0],r=n[1],a=t.useState(!1),s=a[0],i=a[1],c=t.useRef(null),l=E({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=E(e,!0),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){var n=c.current;l.canCloseOnClick=!0,l.canDrag=!0,l.boundingRect=n.getBoundingClientRect(),n.style.transition="",l.x=_(t.nativeEvent),l.y=I(t.nativeEvent),"x"===e.draggableDirection?(l.start=l.x,l.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(l.start=l.y,l.removalDistance=n.offsetHeight*(e.draggablePercent/100))}}function h(){if(l.boundingRect){var t=l.boundingRect;e.pauseOnHover&&l.x>=t.left&&l.x<=t.right&&l.y>=t.top&&l.y<=t.bottom?b():T()}}function T(){r(!0)}function b(){r(!1)}function O(t){if(l.canDrag){t.preventDefault();var n=c.current;o&&b(),l.x=_(t),l.y=I(t),l.delta="x"===e.draggableDirection?l.x-l.start:l.y-l.start,l.start!==l.x&&(l.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+l.delta+"px)",n.style.opacity=""+(1-Math.abs(l.delta/l.removalDistance))}}function C(){var t=c.current;if(l.canDrag){if(l.canDrag=!1,Math.abs(l.delta)>l.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){return u(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){u(d.onClose)&&d.onClose(t.isValidElement(d.children)&&d.children.props)}}),[]),t.useEffect((function(){return e.draggable&&(document.addEventListener("mousemove",O),document.addEventListener("mouseup",C),document.addEventListener("touchmove",O),document.addEventListener("touchend",C)),function(){e.draggable&&(document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",C))}}),[e.draggable]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||b(),window.addEventListener("focus",T),window.addEventListener("blur",b)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",T),window.removeEventListener("blur",b))}}),[e.pauseOnFocusLoss]);var L={onMouseDown:y,onTouchStart:y,onMouseUp:h,onTouchEnd:h};return f&&p&&(L.onMouseEnter=b,L.onMouseLeave=T),v&&(L.onClick=function(e){g&&g(e),l.canCloseOnClick&&m()}),{playToast:T,pauseToast:b,isRunning:o,preventExitTransition:s,toastRef:c,eventHandlers:L}}function x(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.theme,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function N(e){var n,r,s=e.closeToast,i=e.type,c=e.hide,l=e.className,d=e.controlledProgress,f=e.progress,p=e.rtl,m=e.isIn,g=e.theme,v=a({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:c?0:1});d&&(v.transform="scaleX("+f+")");var y=o("Toastify__progress-bar",d?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar-theme--"+g,"Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=p,n)),h=u(l)?l({rtl:p,type:i,defaultClassName:y}):o(y,l),T=((r={})[d&&f>=1?"onTransitionEnd":"onAnimationEnd"]=d&&f<1?null:function(){m&&s()},r);return t.createElement("div",Object.assign({role:"progressbar","aria-hidden":c?"true":"false","aria-label":"notification timer",className:h,style:v},T))}N.defaultProps={type:v.DEFAULT,hide:!1};var R=["theme","type"],P=function(e){var t=e.theme,o=e.type,r=s(e,R);return n.createElement("svg",Object.assign({viewBox:"0 0 24 24",fill:"colored"===t?"currentColor":"var(--toastify-icon-color-"+o+")"},r))},k={info:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return n.createElement("div",{className:"Toastify__spinner"})}},B=function(e){var n,r,a=L(e),s=a.isRunning,i=a.preventExitTransition,c=a.toastRef,d=a.eventHandlers,f=e.closeButton,p=e.children,m=e.autoClose,g=e.onClick,v=e.type,y=e.hideProgressBar,h=e.closeToast,T=e.transition,E=e.position,b=e.className,O=e.style,C=e.bodyClassName,_=e.bodyStyle,I=e.progressClassName,x=e.progressStyle,R=e.updateId,P=e.role,B=e.progress,w=e.rtl,D=e.toastId,A=e.deleteToast,F=e.isIn,M=e.isLoading,S=e.icon,j=e.theme,z=o("Toastify__toast","Toastify__toast-theme--"+j,"Toastify__toast--"+v,((n={})["Toastify__toast--rtl"]=w,n)),H=u(b)?b({rtl:w,position:E,type:v,defaultClassName:z}):o(z,b),U=!!B,Q=k[v],V={theme:j,type:v},q=Q&&Q(V);return!1===S?q=void 0:u(S)?q=S(V):t.isValidElement(S)?q=t.cloneElement(S,V):l(S)?q=S:M&&(q=k.spinner()),t.createElement(T,{isIn:F,done:A,position:E,preventExitTransition:i,nodeRef:c},t.createElement("div",Object.assign({id:D,onClick:g,className:H},d,{style:O,ref:c}),t.createElement("div",Object.assign({},F&&{role:P},{className:u(C)?C({type:v}):o("Toastify__toast-body",C),style:_}),q&&t.createElement("div",{className:o("Toastify__toast-icon",(r={},r["Toastify--animate-icon Toastify__zoom-enter"]=!M,r))},q),t.createElement("div",null,p)),function(e){if(e){var n={closeToast:h,type:v,theme:j};return u(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(f),(m||U)&&t.createElement(N,Object.assign({},R&&!U?{key:"pb-"+R}:{},{rtl:w,theme:j,delay:m,isRunning:s,isIn:F,closeToast:h,hide:y,type:v,style:x,className:I,controlledProgress:U,progress:B}))))},w=h({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),D=h({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),A=h({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),F=h({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),M=function(e){var n=C(e),r=n.isToastActive,s=e.className,i=e.style,c=e.rtl;function l(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return u(s)?s({position:e,rtl:c,defaultClassName:n}):o(n,d(s))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=0===n.length?a({},i,{pointerEvents:"none"}):a({},i);return t.createElement("div",{className:l(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(B,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?x:o.closeButton}),n)})))})))};M.defaultProps={position:g.TOP_RIGHT,transition:w,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:x,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};var S,j,z,H=new Map,U=[],Q=!1;function V(){return Math.random().toString(36).substr(2,9)}function q(e){return e&&(l(e.toastId)||i(e.toastId))?e.toastId:V()}function G(e,n){return H.size>0?T.emit(0,e,n):(U.push({content:e,options:n}),Q&&p&&(Q=!1,j=document.createElement("div"),document.body.appendChild(j),r.render(t.createElement(M,Object.assign({},z)),j))),n.toastId}function W(e,t){return a({},t,{type:t&&t.type||e,toastId:q(t)})}var X=function(e){return function(t,n){return G(t,W(e,n))}},Y=function(e,t){return G(e,W(v.DEFAULT,t))};Y.loading=function(e,t){return G(e,W(v.DEFAULT,a({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},t)))},Y.promise=function(e,t,n){var o=t.pending,r=t.error,s=t.success,i=l(o)?Y.loading(o,n):Y.loading(o.render,a({},n,o)),c={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},d=function(e,t,o){var r=l(t)?{render:t}:t;return Y.update(i,a({type:e},c,n,r,{data:o})),o},f=u(e)?e():e;return f.then((function(e){return d("success",s,e)})).catch((function(e){return d("error",r,e)})),f},Y.success=X(v.SUCCESS),Y.info=X(v.INFO),Y.error=X(v.ERROR),Y.warn=Y.warning=X(v.WARNING),Y.dark=function(e,t){return G(e,W(v.DEFAULT,a({theme:"dark"},t)))},Y.dismiss=function(e){return T.emit(1,e)},Y.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},Y.isActive=function(e){var t=!1;return H.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},Y.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=H.get(t.containerId||S);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=a({},n.props,t,{toastId:t.toastId||e,updateId:V()});r.toastId!==e&&(r.staleId=e);var s=r.render||o;delete r.render,G(s,r)}}),0)},Y.done=function(e){Y.update(e,{progress:1})},Y.onChange=function(e){return u(e)&&T.on(4,e),function(){u(e)&&T.off(4,e)}},Y.configure=function(e){void 0===e&&(e={}),Q=!0,z=e},Y.POSITION=g,Y.TYPE=v,T.on(2,(function(e){H.set(S=e.containerId||e,e),U.forEach((function(e){T.emit(0,e.content,e.options)})),U=[]})).on(3,(function(e){H.delete(e.containerId||e),0===H.size&&T.off(0).off(1).off(5),p&&j&&document.body.removeChild(j)})),exports.Bounce=w,exports.Flip=F,exports.Icons=k,exports.Slide=D,exports.ToastContainer=M,exports.Zoom=A,exports.collapseToast=y,exports.cssTransition=h,exports.toast=Y,exports.useToast=L,exports.useToastContainer=C; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function s(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)t.indexOf(n=a[o])>=0||(r[n]=e[n]);return r}function i(e){return"number"==typeof e&&!isNaN(e)}function c(e){return"boolean"==typeof e}function l(e){return"string"==typeof e}function u(e){return"function"==typeof e}function d(e){return l(e)||u(e)?e:null}function f(e){return 0===e||e}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function m(e){return t.isValidElement(e)||l(e)||u(e)||i(e)}var g={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},v={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"};function y(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function h(e){var o=e.enter,r=e.exit,a=e.appendPosition,s=void 0!==a&&a,i=e.collapse,c=void 0===i||i,l=e.collapseDuration,u=void 0===l?300:l;return function(e){var a=e.children,i=e.position,l=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=s?o+"--"+i:o,g=s?r+"--"+i:r,v=t.useRef(),h=t.useRef(0);function T(e){if(e.target===f.current){var t=f.current;t.removeEventListener("animationend",T),0===h.current&&(t.className=v.current)}}function E(){var e=f.current;e.removeEventListener("animationend",E),c?y(e,d,u):d()}return t.useLayoutEffect((function(){var e;v.current=(e=f.current).className,e.className+=" "+m,e.addEventListener("animationend",T)}),[]),t.useEffect((function(){p||(l?E():function(){h.current=1;var e=f.current;e.className+=" "+g,e.addEventListener("animationend",E)}())}),[p]),n.createElement(n.Fragment,null,a)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}};function E(e,n){void 0===n&&(n=!1);var o=t.useRef(e);return t.useEffect((function(){n&&(o.current=e)})),o.current}function b(e,t){switch(t.type){case 0:return[].concat(e,[t.toastId]).filter((function(e){return e!==t.staleId}));case 1:return f(t.toastId)?e.filter((function(e){return e!==t.toastId})):[]}}var O=["delay","staleId"];function C(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useReducer(b,[]),r=o[0],a=o[1],p=t.useRef(null),g=E(0),v=E([]),y=E({}),h=E({toastKey:1,displayedToast:0,props:e,containerId:null,isToastActive:C,getToast:function(e){return y[e]||null}});function C(e){return-1!==r.indexOf(e)}function _(e){var t=e.containerId;!h.props.limit||t&&h.containerId!==t||(g-=v.length,v=[])}function I(e){a({type:1,toastId:e})}function L(){var e=v.shift();N(e.toastContent,e.toastProps,e.staleId)}function x(e,o){var r=o.delay,a=o.staleId,T=s(o,O);if(m(e)&&(E=T,!(!p.current||h.props.enableMultiContainer&&E.containerId!==h.props.containerId||y[E.toastId]&&null==E.updateId))){var E,b=T.toastId,C=T.data,_=h.props,x=function(){return I(b)},R=null==T.updateId;R&&g++;var P,k,w={toastId:b,updateId:T.updateId,isLoading:T.isLoading,theme:T.theme||_.theme,icon:T.icon||_.icon,isIn:!1,key:T.key||h.toastKey++,type:T.type,closeToast:x,closeButton:T.closeButton,rtl:_.rtl,position:T.position||_.position,transition:T.transition||_.transition,className:d(T.className||_.toastClassName),bodyClassName:d(T.bodyClassName||_.bodyClassName),style:T.style||_.toastStyle,bodyStyle:T.bodyStyle||_.bodyStyle,onClick:T.onClick||_.onClick,pauseOnHover:c(T.pauseOnHover)?T.pauseOnHover:_.pauseOnHover,pauseOnFocusLoss:c(T.pauseOnFocusLoss)?T.pauseOnFocusLoss:_.pauseOnFocusLoss,draggable:c(T.draggable)?T.draggable:_.draggable,draggablePercent:i(T.draggablePercent)?T.draggablePercent:_.draggablePercent,draggableDirection:T.draggableDirection||_.draggableDirection,closeOnClick:c(T.closeOnClick)?T.closeOnClick:_.closeOnClick,progressClassName:d(T.progressClassName||_.progressClassName),progressStyle:T.progressStyle||_.progressStyle,autoClose:!T.isLoading&&(P=T.autoClose,k=_.autoClose,!1===P||i(P)&&P>0?P:k),hideProgressBar:c(T.hideProgressBar)?T.hideProgressBar:_.hideProgressBar,progress:T.progress,role:l(T.role)?T.role:_.role,deleteToast:function(){!function(e){delete y[e];var t=v.length;if((g=f(e)?g-1:g-h.displayedToast)<0&&(g=0),t>0){var o=f(e)?1:h.props.limit;if(1===t||1===o)h.displayedToast++,L();else{var r=o>t?t:o;h.displayedToast=r;for(var a=0;a<r;a++)L()}}else n()}(b)}};u(T.onOpen)&&(w.onOpen=T.onOpen),u(T.onClose)&&(w.onClose=T.onClose),"y"===w.draggableDirection&&80===w.draggablePercent&&(w.draggablePercent*=1.5);var B=_.closeButton;!1===T.closeButton||m(T.closeButton)?B=T.closeButton:!0===T.closeButton&&(B=!m(_.closeButton)||_.closeButton),w.closeButton=B;var D=e;t.isValidElement(e)&&!l(e.type)?D=t.cloneElement(e,{closeToast:x,toastProps:w,data:C}):u(e)&&(D=e({closeToast:x,toastProps:w,data:C})),_.limit&&_.limit>0&&g>_.limit&&R?v.push({toastContent:D,toastProps:w,staleId:a}):i(r)&&r>0?setTimeout((function(){N(D,w,a)}),r):N(D,w,a)}}function N(e,t,n){var o=t.toastId;n&&delete y[n],y[o]={content:e,props:t},a({type:0,toastId:o,staleId:n})}return t.useEffect((function(){return h.containerId=e.containerId,T.cancelEmit(3).on(0,x).on(1,(function(e){return p.current&&I(e)})).on(5,_).emit(2,h),function(){return T.emit(3,h)}}),[]),t.useEffect((function(){h.isToastActive=C,h.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){h.props=e})),{getToastToRender:function(t){for(var n={},o=e.newestOnTop?Object.keys(y).reverse():Object.keys(y),r=0;r<o.length;r++){var a=y[o[r]],s=a.props.position;n[s]||(n[s]=[]),n[s].push(a)}return Object.keys(n).map((function(e){return t(e,n[e])}))},collection:y,containerRef:p,isToastActive:C}}function _(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function I(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function L(e){var n=t.useState(!0),o=n[0],r=n[1],a=t.useState(!1),s=a[0],i=a[1],c=t.useRef(null),l=E({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=E(e,!0),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){var n=c.current;l.canCloseOnClick=!0,l.canDrag=!0,l.boundingRect=n.getBoundingClientRect(),n.style.transition="",l.x=_(t.nativeEvent),l.y=I(t.nativeEvent),"x"===e.draggableDirection?(l.start=l.x,l.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(l.start=l.y,l.removalDistance=n.offsetHeight*(e.draggablePercent/100))}}function h(){if(l.boundingRect){var t=l.boundingRect;e.pauseOnHover&&l.x>=t.left&&l.x<=t.right&&l.y>=t.top&&l.y<=t.bottom?b():T()}}function T(){r(!0)}function b(){r(!1)}function O(t){if(l.canDrag){t.preventDefault();var n=c.current;o&&b(),l.x=_(t),l.y=I(t),l.delta="x"===e.draggableDirection?l.x-l.start:l.y-l.start,l.start!==l.x&&(l.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+l.delta+"px)",n.style.opacity=""+(1-Math.abs(l.delta/l.removalDistance))}}function C(){var t=c.current;if(l.canDrag){if(l.canDrag=!1,Math.abs(l.delta)>l.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){return u(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){u(d.onClose)&&d.onClose(t.isValidElement(d.children)&&d.children.props)}}),[]),t.useEffect((function(){return e.draggable&&(document.addEventListener("mousemove",O),document.addEventListener("mouseup",C),document.addEventListener("touchmove",O),document.addEventListener("touchend",C)),function(){e.draggable&&(document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",C))}}),[e.draggable]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||b(),window.addEventListener("focus",T),window.addEventListener("blur",b)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",T),window.removeEventListener("blur",b))}}),[e.pauseOnFocusLoss]);var L={onMouseDown:y,onTouchStart:y,onMouseUp:h,onTouchEnd:h};return f&&p&&(L.onMouseEnter=b,L.onMouseLeave=T),v&&(L.onClick=function(e){g&&g(e),l.canCloseOnClick&&m()}),{playToast:T,pauseToast:b,isRunning:o,preventExitTransition:s,toastRef:c,eventHandlers:L}}function x(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.theme,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function N(e){var n,r,s=e.closeToast,i=e.type,c=e.hide,l=e.className,d=e.controlledProgress,f=e.progress,p=e.rtl,m=e.isIn,g=e.theme,v=a({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:c?0:1});d&&(v.transform="scaleX("+f+")");var y=o("Toastify__progress-bar",d?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar-theme--"+g,"Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=p,n)),h=u(l)?l({rtl:p,type:i,defaultClassName:y}):o(y,l),T=((r={})[d&&f>=1?"onTransitionEnd":"onAnimationEnd"]=d&&f<1?null:function(){m&&s()},r);return t.createElement("div",Object.assign({role:"progressbar","aria-hidden":c?"true":"false","aria-label":"notification timer",className:h,style:v},T))}N.defaultProps={type:v.DEFAULT,hide:!1};var R=["theme","type"],P=function(e){var t=e.theme,o=e.type,r=s(e,R);return n.createElement("svg",Object.assign({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:"colored"===t?"currentColor":"var(--toastify-icon-color-"+o+")"},r))},k={info:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(e){return n.createElement(P,Object.assign({},e),n.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return n.createElement("div",{className:"Toastify__spinner"})}},w=function(e){var n,r,a=L(e),s=a.isRunning,i=a.preventExitTransition,c=a.toastRef,d=a.eventHandlers,f=e.closeButton,p=e.children,m=e.autoClose,g=e.onClick,v=e.type,y=e.hideProgressBar,h=e.closeToast,T=e.transition,E=e.position,b=e.className,O=e.style,C=e.bodyClassName,_=e.bodyStyle,I=e.progressClassName,x=e.progressStyle,R=e.updateId,P=e.role,w=e.progress,B=e.rtl,D=e.toastId,A=e.deleteToast,F=e.isIn,M=e.isLoading,S=e.icon,j=e.theme,z=o("Toastify__toast","Toastify__toast-theme--"+j,"Toastify__toast--"+v,((n={})["Toastify__toast--rtl"]=B,n)),H=u(b)?b({rtl:B,position:E,type:v,defaultClassName:z}):o(z,b),U=!!w,Q=k[v],V={theme:j,type:v},q=Q&&Q(V);return!1===S?q=void 0:u(S)?q=S(V):t.isValidElement(S)?q=t.cloneElement(S,V):l(S)?q=S:M&&(q=k.spinner()),t.createElement(T,{isIn:F,done:A,position:E,preventExitTransition:i,nodeRef:c},t.createElement("div",Object.assign({id:D,onClick:g,className:H},d,{style:O,ref:c}),t.createElement("div",Object.assign({},F&&{role:P},{className:u(C)?C({type:v}):o("Toastify__toast-body",C),style:_}),q&&t.createElement("div",{className:o("Toastify__toast-icon",(r={},r["Toastify--animate-icon Toastify__zoom-enter"]=!M,r))},q),t.createElement("div",null,p)),function(e){if(e){var n={closeToast:h,type:v,theme:j};return u(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(f),(m||U)&&t.createElement(N,Object.assign({},R&&!U?{key:"pb-"+R}:{},{rtl:B,theme:j,delay:m,isRunning:s,isIn:F,closeToast:h,hide:y,type:v,style:x,className:I,controlledProgress:U,progress:w}))))},B=h({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),D=h({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),A=h({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),F=h({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),M=function(e){var n=C(e),r=n.isToastActive,s=e.className,i=e.style,c=e.rtl;function l(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return u(s)?s({position:e,rtl:c,defaultClassName:n}):o(n,d(s))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=0===n.length?a({},i,{pointerEvents:"none"}):a({},i);return t.createElement("div",{className:l(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(w,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?x:o.closeButton}),n)})))})))};M.defaultProps={position:g.TOP_RIGHT,transition:B,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:x,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};var S,j,z,H=new Map,U=[],Q=!1;function V(){return Math.random().toString(36).substr(2,9)}function q(e){return e&&(l(e.toastId)||i(e.toastId))?e.toastId:V()}function G(e,n){return H.size>0?T.emit(0,e,n):(U.push({content:e,options:n}),Q&&p&&(Q=!1,j=document.createElement("div"),document.body.appendChild(j),r.render(t.createElement(M,Object.assign({},z)),j))),n.toastId}function W(e,t){return a({},t,{type:t&&t.type||e,toastId:q(t)})}var X=function(e){return function(t,n){return G(t,W(e,n))}},Y=function(e,t){return G(e,W(v.DEFAULT,t))};Y.loading=function(e,t){return G(e,W(v.DEFAULT,a({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},t)))},Y.promise=function(e,t,n){var o=t.pending,r=t.error,s=t.success,i=l(o)?Y.loading(o,n):Y.loading(o.render,a({},n,o)),c={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},d=function(e,t,o){var r=l(t)?{render:t}:t;return Y.update(i,a({type:e},c,n,r,{data:o})),o},f=u(e)?e():e;return f.then((function(e){return d("success",s,e)})).catch((function(e){return d("error",r,e)})),f},Y.success=X(v.SUCCESS),Y.info=X(v.INFO),Y.error=X(v.ERROR),Y.warn=Y.warning=X(v.WARNING),Y.dark=function(e,t){return G(e,W(v.DEFAULT,a({theme:"dark"},t)))},Y.dismiss=function(e){return T.emit(1,e)},Y.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},Y.isActive=function(e){var t=!1;return H.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},Y.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=H.get(t.containerId||S);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=a({},n.props,t,{toastId:t.toastId||e,updateId:V()});r.toastId!==e&&(r.staleId=e);var s=r.render||o;delete r.render,G(s,r)}}),0)},Y.done=function(e){Y.update(e,{progress:1})},Y.onChange=function(e){return u(e)&&T.on(4,e),function(){u(e)&&T.off(4,e)}},Y.configure=function(e){void 0===e&&(e={}),Q=!0,z=e},Y.POSITION=g,Y.TYPE=v,T.on(2,(function(e){H.set(S=e.containerId||e,e),U.forEach((function(e){T.emit(0,e.content,e.options)})),U=[]})).on(3,(function(e){H.delete(e.containerId||e),0===H.size&&T.off(0).off(1).off(5),p&&j&&document.body.removeChild(j)})),exports.Bounce=B,exports.Flip=F,exports.Icons=k,exports.Slide=D,exports.ToastContainer=M,exports.Zoom=A,exports.collapseToast=y,exports.cssTransition=h,exports.toast=Y,exports.useToast=L,exports.useToastContainer=C; | ||
//# sourceMappingURL=react-toastify.cjs.production.min.js.map |
@@ -844,2 +844,4 @@ import React__default, { isValidElement, useRef, useLayoutEffect, useEffect, useReducer, cloneElement, useState, createElement } from 'react'; | ||
viewBox: "0 0 24 24", | ||
width: "100%", | ||
height: "100%", | ||
fill: theme === 'colored' ? 'currentColor' : "var(--toastify-icon-color-" + type + ")" | ||
@@ -846,0 +848,0 @@ }, rest)); |
{ | ||
"version": "8.0.1", | ||
"version": "8.0.2-with-side-effects", | ||
"license": "MIT", | ||
@@ -20,5 +20,3 @@ "main": "dist/index.js", | ||
], | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"sideEffects": true, | ||
"scripts": { | ||
@@ -25,0 +23,0 @@ "start": "cd example && npm run start", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
442121
3937
2