Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-toastify

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-toastify - npm Package Compare versions

Comparing version 6.1.0 to 6.2.0

10

dist/react-toastify.cjs.development.js

@@ -166,3 +166,4 @@ 'use strict';

node.classList.remove(enterClassName);
node.style.cssText = '';
node.style.removeProperty('animationFillMode');
node.style.removeProperty('animationDuration');
}

@@ -488,7 +489,9 @@ };

toastContent = React.cloneElement(content, {
closeToast: closeToast
closeToast: closeToast,
toastProps: toastProps
});
} else if (isFn(content)) {
toastContent = content({
closeToast: closeToast
closeToast: closeToast,
toastProps: toastProps
});

@@ -667,2 +670,3 @@ } // not handling limit + delay by design. Waiting for user feedback first

function onDragMove(e) {
e.preventDefault();
var toast = toastRef.current;

@@ -669,0 +673,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=require("react-transition-group"),o=(t=require("clsx"))&&"object"==typeof t&&"default"in t?t.default:t;require("prop-types");var r=require("react-dom");function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function i(t,e){if(null==t)return{};var n,o,r={},s=Object.keys(t);for(o=0;o<s.length;o++)e.indexOf(n=s[o])>=0||(r[n]=t[n]);return r}function a(t){return"number"==typeof t&&!isNaN(t)}function c(t){return"boolean"==typeof t}function u(t){return"string"==typeof t}function l(t){return"function"==typeof t}function d(t){return u(t)||l(t)?t:null}function f(t){return 0===t||t}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function m(t){return e.isValidElement(t)||u(t)||l(t)||a(t)}var v={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},y={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default",DARK:"dark"};function g(t,e,n){void 0===n&&(n=300);var o=t.scrollHeight,r=t.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((function(){return e()}),n)}))}))}function T(t){var o,r,s=t.enter,a=t.exit,c=t.duration,u=void 0===c?750:c,l=t.appendPosition,d=void 0!==l&&l,f=t.collapse,p=void 0===f||f,m=t.collapseDuration,v=void 0===m?300:m;return Array.isArray(u)&&2===u.length?(o=u[0],r=u[1]):o=r=u,function(t){var c=t.children,u=t.position,l=t.preventExitTransition,f=t.done,m=i(t,["children","position","preventExitTransition","done"]),y=d?s+"--"+u:s,T=d?a+"--"+u:a,h=function t(){var e=m.nodeRef.current;e&&(e.removeEventListener("animationend",t),p?g(e,f,v):f())};return e.createElement(n.Transition,Object.assign({},m,{timeout:l?p?v:50:{enter:o,exit:p?r+v:r+50},onEnter:function(){var t=m.nodeRef.current;t&&(t.classList.add(y),t.style.animationFillMode="forwards",t.style.animationDuration=o+"ms")},onEntered:function(){var t=m.nodeRef.current;t&&(t.classList.remove(y),t.style.cssText="")},onExit:l?h:function(){var t=m.nodeRef.current;t&&(t.classList.add(T),t.style.animationFillMode="forwards",t.style.animationDuration=r+"ms",t.addEventListener("animationend",h))},unmountOnExit:!0}),c)}}var h={list:new Map,emitQueue:new Map,on:function(t,e){return this.list.has(t)||this.list.set(t,[]),this.list.get(t).push(e),this},off:function(t,e){if(e){var n=this.list.get(t).filter((function(t){return t!==e}));return this.list.set(t,n),this}return this.list.delete(t),this},cancelEmit:function(t){var e=this.emitQueue.get(t);return e&&(e.forEach((function(t){return clearTimeout(t)})),this.emitQueue.delete(t)),this},emit:function(t){for(var e=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(t)&&this.list.get(t).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);e.emitQueue.has(t)||e.emitQueue.set(t,[]),e.emitQueue.get(t).push(r)}))}};function E(t,n){void 0===n&&(n=!1);var o=e.useRef(t);return e.useEffect((function(){n&&(o.current=t)})),o.current}function b(t,e){switch(e.type){case"ADD":return[].concat(t,[e.toastId]).filter((function(t){return t!==e.staleId}));case"REMOVE":return f(e.toastId)?t.filter((function(t){return t!==e.toastId})):[]}}function O(t){var n=e.useReducer((function(t){return t+1}),0)[1],o=e.useReducer(b,[]),r=o[0],s=o[1],p=e.useRef(null),v=E(0),y=E([]),g=E({}),T=E({toastKey:1,displayedToast:0,props:t,containerId:null,isToastActive:O,getToast:function(t){return g[t]||null}});function O(t){return-1!==r.indexOf(t)}function C(t){var e=t.containerId,n=T.props;n.limit&&(!e||T.containerId===e&&n.enableMultiContainer)&&(v-=y.length,y=[])}function _(t){var e=y.length;if((v=f(t)?v-1:v-T.displayedToast)<0&&(v=0),e>0){var n=f(t)?1:T.props.limit;if(1===e||1===n)T.displayedToast++,I();else{var o=n>e?e:n;T.displayedToast=o;for(var r=0;r<o;r++)I()}}s({type:"REMOVE",toastId:t})}function I(){var t=y.shift(),e=t.toastContent,n=t.toastProps,o=t.staleId;setTimeout((function(){x(e,n,o)}),500)}function R(t,o){var r=o.delay,s=o.staleId,f=i(o,["delay","staleId"]);if(m(t)&&!function(t){var e=t.updateId;return!!(!p.current||T.props.enableMultiContainer&&t.containerId!==T.props.containerId||T.isToastActive(t.toastId)&&null==e)}(f)){var h=f.toastId,E=f.updateId,b=T.props,O=function(){return _(h)},C=!(0,T.isToastActive)(h);C&&v++;var I,R,N={toastId:h,updateId:E,key:f.key||T.toastKey++,type:f.type,closeToast:O,closeButton:f.closeButton,rtl:b.rtl,position:f.position||b.position,transition:f.transition||b.transition,className:d(f.className||b.toastClassName),bodyClassName:d(f.bodyClassName||b.bodyClassName),style:f.style||b.toastStyle,bodyStyle:f.bodyStyle||b.bodyStyle,onClick:f.onClick||b.onClick,pauseOnHover:c(f.pauseOnHover)?f.pauseOnHover:b.pauseOnHover,pauseOnFocusLoss:c(f.pauseOnFocusLoss)?f.pauseOnFocusLoss:b.pauseOnFocusLoss,draggable:c(f.draggable)?f.draggable:b.draggable,draggablePercent:a(f.draggablePercent)?f.draggablePercent:b.draggablePercent,closeOnClick:c(f.closeOnClick)?f.closeOnClick:b.closeOnClick,progressClassName:d(f.progressClassName||b.progressClassName),progressStyle:f.progressStyle||b.progressStyle,autoClose:(I=f.autoClose,R=b.autoClose,!1===I||a(I)&&I>0?I:R),hideProgressBar:c(f.hideProgressBar)?f.hideProgressBar:b.hideProgressBar,progress:f.progress,role:u(f.role)?f.role:b.role,deleteToast:function(){!function(t){delete g[t],n()}(h)}};l(f.onOpen)&&(N.onOpen=f.onOpen),l(f.onClose)&&(N.onClose=f.onClose);var L=b.closeButton;!1===f.closeButton||m(f.closeButton)?L=f.closeButton:!0===f.closeButton&&(L=!m(b.closeButton)||b.closeButton),N.closeButton=L;var w=t;e.isValidElement(t)&&!u(t.type)?w=e.cloneElement(t,{closeToast:O}):l(t)&&(w=t({closeToast:O})),b.limit&&b.limit>0&&v>b.limit&&C?y.push({toastContent:w,toastProps:N,staleId:s}):a(r)&&r>0?setTimeout((function(){x(w,N,s)}),r):x(w,N,s)}}function x(t,e,n){var o=e.toastId;g[o]={content:t,props:e},s({type:"ADD",toastId:o,staleId:n})}return e.useEffect((function(){return T.containerId=t.containerId,h.cancelEmit(3).on(0,R).on(1,(function(t){return p.current&&_(t)})).on(5,C).emit(2,T),function(){return h.emit(3,T)}}),[]),e.useEffect((function(){T.isToastActive=O,T.displayedToast=r.length,h.emit(4,r.length,t.containerId)}),[r]),e.useEffect((function(){T.props=t})),{getToastToRender:function(e){for(var n={},o=t.newestOnTop?Object.keys(g).reverse():Object.keys(g),r=0;r<o.length;r++){var s=g[o[r]],i=s.props.position;n[i]||(n[i]=[]),n[i].push(s)}return Object.keys(n).map((function(t){return e(t,n[t])}))},collection:g,containerRef:p,isToastActive:O}}function C(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientX:t.clientX}function _(t){var n=e.useState(!0),o=n[0],r=n[1],s=e.useState(!1),i=s[0],a=s[1],c=e.useRef(null),u=E({start:0,x:0,y:0,deltaX:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=E(t,!0),f=t.autoClose,p=t.pauseOnHover,m=t.closeToast,v=t.onClick,y=t.closeOnClick;function g(e){var n=c.current;u.canCloseOnClick=!0,u.canDrag=!0,u.boundingRect=n.getBoundingClientRect(),n.style.transition="",u.start=u.x=C(e.nativeEvent),u.removalDistance=n.offsetWidth*(t.draggablePercent/100)}function T(){if(u.boundingRect){var e=u.boundingRect;t.pauseOnHover&&u.x>=e.left&&u.x<=e.right&&u.y>=e.top&&u.y<=e.bottom?b():h()}}function h(){r(!0)}function b(){r(!1)}function O(t){var e=c.current;u.canDrag&&(o&&b(),u.x=C(t),u.deltaX=u.x-u.start,u.y=function(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientY:t.clientY}(t),u.start!==u.x&&(u.canCloseOnClick=!1),e.style.transform="translateX("+u.deltaX+"px)",e.style.opacity=""+(1-Math.abs(u.deltaX/u.removalDistance)))}function _(){var e=c.current;if(u.canDrag){if(u.canDrag=!1,Math.abs(u.deltaX)>u.removalDistance)return a(!0),void t.closeToast();e.style.transition="transform 0.2s, opacity 0.2s",e.style.transform="translateX(0)",e.style.opacity="1"}}e.useEffect((function(){return l(t.onOpen)&&t.onOpen(e.isValidElement(t.children)&&t.children.props),function(){l(d.onClose)&&d.onClose(e.isValidElement(d.children)&&d.children.props)}}),[]),e.useEffect((function(){return t.draggable&&(document.addEventListener("mousemove",O),document.addEventListener("mouseup",_),document.addEventListener("touchmove",O),document.addEventListener("touchend",_)),function(){t.draggable&&(document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",_))}}),[t.draggable]),e.useEffect((function(){return t.pauseOnFocusLoss&&(window.addEventListener("focus",h),window.addEventListener("blur",b)),function(){t.pauseOnFocusLoss&&(window.removeEventListener("focus",h),window.removeEventListener("blur",b))}}),[t.pauseOnFocusLoss]);var I={onMouseDown:g,onTouchStart:g,onMouseUp:T,onTouchEnd:T};return f&&p&&(I.onMouseEnter=b,I.onMouseLeave=h),y&&(I.onClick=function(t){v&&v(t),u.canCloseOnClick&&m()}),{playToast:h,pauseToast:b,isRunning:o,preventExitTransition:i,toastRef:c,eventHandlers:I}}function I(t){var n=t.closeToast,o=t.ariaLabel;return e.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+t.type,type:"button",onClick:function(t){t.stopPropagation(),n(t)},"aria-label":void 0===o?"close":o},e.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},e.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 R(t){var n,r,i=t.closeToast,a=t.type,c=t.className,u=t.controlledProgress,d=t.progress,f=t.rtl,p=t.isIn,m=s({},t.style,{animationDuration:t.delay+"ms",animationPlayState:t.isRunning?"running":"paused",opacity:t.hide?0:1});u&&(m.transform="scaleX("+d+")");var v=["Toastify__progress-bar",u?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+a,(n={},n["Toastify__progress-bar--rtl"]=f,n)],y=l(c)?c({rtl:f,type:a,defaultClassName:o.apply(void 0,v)}):o.apply(void 0,[].concat(v,[c])),g=((r={})[u&&d>=1?"onTransitionEnd":"onAnimationEnd"]=u&&d<1?null:function(){p&&i()},r);return e.createElement("div",Object.assign({className:y,style:m},g))}R.defaultProps={type:y.DEFAULT,hide:!1};var x=function(t){var n,r=_(t),s=r.isRunning,i=r.preventExitTransition,a=r.toastRef,c=r.eventHandlers,u=t.closeButton,d=t.children,f=t.autoClose,p=t.onClick,m=t.type,v=t.hideProgressBar,y=t.closeToast,g=t.transition,T=t.position,h=t.className,E=t.style,b=t.bodyClassName,O=t.bodyStyle,C=t.progressClassName,I=t.progressStyle,x=t.updateId,N=t.role,L=t.progress,w=t.rtl,P=t.toastId,k=t.deleteToast,B=["Toastify__toast","Toastify__toast--"+m,(n={},n["Toastify__toast--rtl"]=w,n)],A=l(h)?h({rtl:w,position:T,type:m,defaultClassName:o.apply(void 0,B)}):o.apply(void 0,[].concat(B,[h])),D=!!L;return e.createElement(g,{in:t.in,appear:!0,done:k,position:T,preventExitTransition:i,nodeRef:a},e.createElement("div",Object.assign({id:P,onClick:p,className:A||void 0},c,{style:E,ref:a}),e.createElement("div",Object.assign({},t.in&&{role:N},{className:l(b)?b({type:m}):o("Toastify__toast-body",b),style:O}),d),function(t){if(t){var n={closeToast:y,type:m};return l(t)?t(n):e.isValidElement(t)?e.cloneElement(t,n):void 0}}(u),(f||D)&&e.createElement(R,Object.assign({},x&&!D?{key:"pb-"+x}:{},{rtl:w,delay:f,isRunning:s,isIn:t.in,closeToast:y,hide:v,type:m,style:I,className:C,controlledProgress:D,progress:L}))))},N=T({enter:"Toastify__bounce-enter",exit:"Toastify__bounce-exit",appendPosition:!0}),L=T({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit",duration:[450,750],appendPosition:!0}),w=T({enter:"Toastify__zoom-enter",exit:"Toastify__zoom-exit"}),P=T({enter:"Toastify__flip-enter",exit:"Toastify__flip-exit"}),k=function(t){var n=t.children,o=t.className,r=t.style,s=i(t,["children","className","style"]);return delete s.in,e.createElement("div",{className:o,style:r},e.Children.map(n,(function(t){return e.cloneElement(t,s)})))},B=function(t){var n=O(t),r=n.isToastActive,i=t.className,a=t.style,c=t.rtl;return e.createElement("div",{ref:n.containerRef,className:"Toastify",id:t.containerId},(0,n.getToastToRender)((function(t,n){var u,f,p={className:l(i)?i({position:t,rtl:c,defaultClassName:o("Toastify__toast-container","Toastify__toast-container--"+t,(u={},u["Toastify__toast-container--rtl"]=c,u))}):o("Toastify__toast-container","Toastify__toast-container--"+t,(f={},f["Toastify__toast-container--rtl"]=c,f),d(i)),style:0===n.length?s({},a,{pointerEvents:"none"}):s({},a)};return e.createElement(k,Object.assign({},p,{key:"container-"+t}),n.map((function(t){var n=t.content,o=t.props;return e.createElement(x,Object.assign({},o,{in:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?I:o.closeButton}),n)})))})))};B.defaultProps={position:v.TOP_RIGHT,transition:N,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:I,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,role:"alert"};var A,D,S,M=new Map,F=[],j=!1;function H(){return M.size>0}function X(){return(Math.random().toString(36)+Date.now().toString(36)).substr(2,10)}function q(t){return t&&(u(t.toastId)||a(t.toastId))?t.toastId:X()}function Q(t,n){return H()?h.emit(0,t,n):(F.push({content:t,options:n}),j&&p&&(j=!1,D=document.createElement("div"),document.body.appendChild(D),r.render(e.createElement(B,Object.assign({},S)),D))),n.toastId}function V(t,e){return s({},e,{type:e&&e.type||t,toastId:q(e)})}var U=function(t,e){return Q(t,V(y.DEFAULT,e))};U.success=function(t,e){return Q(t,V(y.SUCCESS,e))},U.info=function(t,e){return Q(t,V(y.INFO,e))},U.error=function(t,e){return Q(t,V(y.ERROR,e))},U.warning=function(t,e){return Q(t,V(y.WARNING,e))},U.dark=function(t,e){return Q(t,V(y.DARK,e))},U.warn=U.warning,U.dismiss=function(t){return H()&&h.emit(1,t)},U.clearWaitingQueue=function(t){return void 0===t&&(t={}),H()&&h.emit(5,t)},U.isActive=function(t){var e=!1;return M.forEach((function(n){n.isToastActive&&n.isToastActive(t)&&(e=!0)})),e},U.update=function(t,e){void 0===e&&(e={}),setTimeout((function(){var n=function(t,e){var n,o=(n=e.containerId,H()?M.get(n||A):null);return o?o.getToast(t):null}(t,e);if(n){var o=n.content,r=s({},n.props,e,{toastId:e.toastId||t,updateId:X()});r.toastId!==t&&(r.staleId=t);var i=void 0!==r.render?r.render:o;delete r.render,Q(i,r)}}),0)},U.done=function(t){U.update(t,{progress:1})},U.onChange=function(t){return l(t)&&h.on(4,t),function(){l(t)&&h.off(4,t)}},U.configure=function(t){void 0===t&&(t={}),j=!0,S=t},U.POSITION=v,U.TYPE=y,h.on(2,(function(t){M.set(A=t.containerId||t,t),F.forEach((function(t){h.emit(0,t.content,t.options)})),F=[]})).on(3,(function(t){M.delete(t.containerId||t),0===M.size&&h.off(0).off(1).off(5),p&&D&&document.body.removeChild(D)})),exports.Bounce=N,exports.Flip=P,exports.Slide=L,exports.ToastContainer=B,exports.Zoom=w,exports.collapseToast=g,exports.cssTransition=T,exports.toast=U,exports.useToast=_,exports.useToastContainer=O;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=require("react-transition-group"),o=(t=require("clsx"))&&"object"==typeof t&&"default"in t?t.default:t;require("prop-types");var r=require("react-dom");function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function i(t,e){if(null==t)return{};var n,o,r={},s=Object.keys(t);for(o=0;o<s.length;o++)e.indexOf(n=s[o])>=0||(r[n]=t[n]);return r}function a(t){return"number"==typeof t&&!isNaN(t)}function c(t){return"boolean"==typeof t}function u(t){return"string"==typeof t}function l(t){return"function"==typeof t}function d(t){return u(t)||l(t)?t:null}function f(t){return 0===t||t}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function m(t){return e.isValidElement(t)||u(t)||l(t)||a(t)}var v={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},y={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default",DARK:"dark"};function g(t,e,n){void 0===n&&(n=300);var o=t.scrollHeight,r=t.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((function(){return e()}),n)}))}))}function T(t){var o,r,s=t.enter,a=t.exit,c=t.duration,u=void 0===c?750:c,l=t.appendPosition,d=void 0!==l&&l,f=t.collapse,p=void 0===f||f,m=t.collapseDuration,v=void 0===m?300:m;return Array.isArray(u)&&2===u.length?(o=u[0],r=u[1]):o=r=u,function(t){var c=t.children,u=t.position,l=t.preventExitTransition,f=t.done,m=i(t,["children","position","preventExitTransition","done"]),y=d?s+"--"+u:s,T=d?a+"--"+u:a,h=function t(){var e=m.nodeRef.current;e&&(e.removeEventListener("animationend",t),p?g(e,f,v):f())};return e.createElement(n.Transition,Object.assign({},m,{timeout:l?p?v:50:{enter:o,exit:p?r+v:r+50},onEnter:function(){var t=m.nodeRef.current;t&&(t.classList.add(y),t.style.animationFillMode="forwards",t.style.animationDuration=o+"ms")},onEntered:function(){var t=m.nodeRef.current;t&&(t.classList.remove(y),t.style.removeProperty("animationFillMode"),t.style.removeProperty("animationDuration"))},onExit:l?h:function(){var t=m.nodeRef.current;t&&(t.classList.add(T),t.style.animationFillMode="forwards",t.style.animationDuration=r+"ms",t.addEventListener("animationend",h))},unmountOnExit:!0}),c)}}var h={list:new Map,emitQueue:new Map,on:function(t,e){return this.list.has(t)||this.list.set(t,[]),this.list.get(t).push(e),this},off:function(t,e){if(e){var n=this.list.get(t).filter((function(t){return t!==e}));return this.list.set(t,n),this}return this.list.delete(t),this},cancelEmit:function(t){var e=this.emitQueue.get(t);return e&&(e.forEach((function(t){return clearTimeout(t)})),this.emitQueue.delete(t)),this},emit:function(t){for(var e=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(t)&&this.list.get(t).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);e.emitQueue.has(t)||e.emitQueue.set(t,[]),e.emitQueue.get(t).push(r)}))}};function E(t,n){void 0===n&&(n=!1);var o=e.useRef(t);return e.useEffect((function(){n&&(o.current=t)})),o.current}function b(t,e){switch(e.type){case"ADD":return[].concat(t,[e.toastId]).filter((function(t){return t!==e.staleId}));case"REMOVE":return f(e.toastId)?t.filter((function(t){return t!==e.toastId})):[]}}function O(t){var n=e.useReducer((function(t){return t+1}),0)[1],o=e.useReducer(b,[]),r=o[0],s=o[1],p=e.useRef(null),v=E(0),y=E([]),g=E({}),T=E({toastKey:1,displayedToast:0,props:t,containerId:null,isToastActive:O,getToast:function(t){return g[t]||null}});function O(t){return-1!==r.indexOf(t)}function C(t){var e=t.containerId,n=T.props;n.limit&&(!e||T.containerId===e&&n.enableMultiContainer)&&(v-=y.length,y=[])}function _(t){var e=y.length;if((v=f(t)?v-1:v-T.displayedToast)<0&&(v=0),e>0){var n=f(t)?1:T.props.limit;if(1===e||1===n)T.displayedToast++,I();else{var o=n>e?e:n;T.displayedToast=o;for(var r=0;r<o;r++)I()}}s({type:"REMOVE",toastId:t})}function I(){var t=y.shift(),e=t.toastContent,n=t.toastProps,o=t.staleId;setTimeout((function(){x(e,n,o)}),500)}function R(t,o){var r=o.delay,s=o.staleId,f=i(o,["delay","staleId"]);if(m(t)&&!function(t){var e=t.updateId;return!!(!p.current||T.props.enableMultiContainer&&t.containerId!==T.props.containerId||T.isToastActive(t.toastId)&&null==e)}(f)){var h=f.toastId,E=f.updateId,b=T.props,O=function(){return _(h)},C=!(0,T.isToastActive)(h);C&&v++;var I,R,N={toastId:h,updateId:E,key:f.key||T.toastKey++,type:f.type,closeToast:O,closeButton:f.closeButton,rtl:b.rtl,position:f.position||b.position,transition:f.transition||b.transition,className:d(f.className||b.toastClassName),bodyClassName:d(f.bodyClassName||b.bodyClassName),style:f.style||b.toastStyle,bodyStyle:f.bodyStyle||b.bodyStyle,onClick:f.onClick||b.onClick,pauseOnHover:c(f.pauseOnHover)?f.pauseOnHover:b.pauseOnHover,pauseOnFocusLoss:c(f.pauseOnFocusLoss)?f.pauseOnFocusLoss:b.pauseOnFocusLoss,draggable:c(f.draggable)?f.draggable:b.draggable,draggablePercent:a(f.draggablePercent)?f.draggablePercent:b.draggablePercent,closeOnClick:c(f.closeOnClick)?f.closeOnClick:b.closeOnClick,progressClassName:d(f.progressClassName||b.progressClassName),progressStyle:f.progressStyle||b.progressStyle,autoClose:(I=f.autoClose,R=b.autoClose,!1===I||a(I)&&I>0?I:R),hideProgressBar:c(f.hideProgressBar)?f.hideProgressBar:b.hideProgressBar,progress:f.progress,role:u(f.role)?f.role:b.role,deleteToast:function(){!function(t){delete g[t],n()}(h)}};l(f.onOpen)&&(N.onOpen=f.onOpen),l(f.onClose)&&(N.onClose=f.onClose);var L=b.closeButton;!1===f.closeButton||m(f.closeButton)?L=f.closeButton:!0===f.closeButton&&(L=!m(b.closeButton)||b.closeButton),N.closeButton=L;var P=t;e.isValidElement(t)&&!u(t.type)?P=e.cloneElement(t,{closeToast:O,toastProps:N}):l(t)&&(P=t({closeToast:O,toastProps:N})),b.limit&&b.limit>0&&v>b.limit&&C?y.push({toastContent:P,toastProps:N,staleId:s}):a(r)&&r>0?setTimeout((function(){x(P,N,s)}),r):x(P,N,s)}}function x(t,e,n){var o=e.toastId;g[o]={content:t,props:e},s({type:"ADD",toastId:o,staleId:n})}return e.useEffect((function(){return T.containerId=t.containerId,h.cancelEmit(3).on(0,R).on(1,(function(t){return p.current&&_(t)})).on(5,C).emit(2,T),function(){return h.emit(3,T)}}),[]),e.useEffect((function(){T.isToastActive=O,T.displayedToast=r.length,h.emit(4,r.length,t.containerId)}),[r]),e.useEffect((function(){T.props=t})),{getToastToRender:function(e){for(var n={},o=t.newestOnTop?Object.keys(g).reverse():Object.keys(g),r=0;r<o.length;r++){var s=g[o[r]],i=s.props.position;n[i]||(n[i]=[]),n[i].push(s)}return Object.keys(n).map((function(t){return e(t,n[t])}))},collection:g,containerRef:p,isToastActive:O}}function C(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientX:t.clientX}function _(t){var n=e.useState(!0),o=n[0],r=n[1],s=e.useState(!1),i=s[0],a=s[1],c=e.useRef(null),u=E({start:0,x:0,y:0,deltaX:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=E(t,!0),f=t.autoClose,p=t.pauseOnHover,m=t.closeToast,v=t.onClick,y=t.closeOnClick;function g(e){var n=c.current;u.canCloseOnClick=!0,u.canDrag=!0,u.boundingRect=n.getBoundingClientRect(),n.style.transition="",u.start=u.x=C(e.nativeEvent),u.removalDistance=n.offsetWidth*(t.draggablePercent/100)}function T(){if(u.boundingRect){var e=u.boundingRect;t.pauseOnHover&&u.x>=e.left&&u.x<=e.right&&u.y>=e.top&&u.y<=e.bottom?b():h()}}function h(){r(!0)}function b(){r(!1)}function O(t){t.preventDefault();var e=c.current;u.canDrag&&(o&&b(),u.x=C(t),u.deltaX=u.x-u.start,u.y=function(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientY:t.clientY}(t),u.start!==u.x&&(u.canCloseOnClick=!1),e.style.transform="translateX("+u.deltaX+"px)",e.style.opacity=""+(1-Math.abs(u.deltaX/u.removalDistance)))}function _(){var e=c.current;if(u.canDrag){if(u.canDrag=!1,Math.abs(u.deltaX)>u.removalDistance)return a(!0),void t.closeToast();e.style.transition="transform 0.2s, opacity 0.2s",e.style.transform="translateX(0)",e.style.opacity="1"}}e.useEffect((function(){return l(t.onOpen)&&t.onOpen(e.isValidElement(t.children)&&t.children.props),function(){l(d.onClose)&&d.onClose(e.isValidElement(d.children)&&d.children.props)}}),[]),e.useEffect((function(){return t.draggable&&(document.addEventListener("mousemove",O),document.addEventListener("mouseup",_),document.addEventListener("touchmove",O),document.addEventListener("touchend",_)),function(){t.draggable&&(document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",_))}}),[t.draggable]),e.useEffect((function(){return t.pauseOnFocusLoss&&(window.addEventListener("focus",h),window.addEventListener("blur",b)),function(){t.pauseOnFocusLoss&&(window.removeEventListener("focus",h),window.removeEventListener("blur",b))}}),[t.pauseOnFocusLoss]);var I={onMouseDown:g,onTouchStart:g,onMouseUp:T,onTouchEnd:T};return f&&p&&(I.onMouseEnter=b,I.onMouseLeave=h),y&&(I.onClick=function(t){v&&v(t),u.canCloseOnClick&&m()}),{playToast:h,pauseToast:b,isRunning:o,preventExitTransition:i,toastRef:c,eventHandlers:I}}function I(t){var n=t.closeToast,o=t.ariaLabel;return e.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+t.type,type:"button",onClick:function(t){t.stopPropagation(),n(t)},"aria-label":void 0===o?"close":o},e.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},e.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 R(t){var n,r,i=t.closeToast,a=t.type,c=t.className,u=t.controlledProgress,d=t.progress,f=t.rtl,p=t.isIn,m=s({},t.style,{animationDuration:t.delay+"ms",animationPlayState:t.isRunning?"running":"paused",opacity:t.hide?0:1});u&&(m.transform="scaleX("+d+")");var v=["Toastify__progress-bar",u?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+a,(n={},n["Toastify__progress-bar--rtl"]=f,n)],y=l(c)?c({rtl:f,type:a,defaultClassName:o.apply(void 0,v)}):o.apply(void 0,[].concat(v,[c])),g=((r={})[u&&d>=1?"onTransitionEnd":"onAnimationEnd"]=u&&d<1?null:function(){p&&i()},r);return e.createElement("div",Object.assign({className:y,style:m},g))}R.defaultProps={type:y.DEFAULT,hide:!1};var x=function(t){var n,r=_(t),s=r.isRunning,i=r.preventExitTransition,a=r.toastRef,c=r.eventHandlers,u=t.closeButton,d=t.children,f=t.autoClose,p=t.onClick,m=t.type,v=t.hideProgressBar,y=t.closeToast,g=t.transition,T=t.position,h=t.className,E=t.style,b=t.bodyClassName,O=t.bodyStyle,C=t.progressClassName,I=t.progressStyle,x=t.updateId,N=t.role,L=t.progress,P=t.rtl,w=t.toastId,k=t.deleteToast,B=["Toastify__toast","Toastify__toast--"+m,(n={},n["Toastify__toast--rtl"]=P,n)],D=l(h)?h({rtl:P,position:T,type:m,defaultClassName:o.apply(void 0,B)}):o.apply(void 0,[].concat(B,[h])),A=!!L;return e.createElement(g,{in:t.in,appear:!0,done:k,position:T,preventExitTransition:i,nodeRef:a},e.createElement("div",Object.assign({id:w,onClick:p,className:D||void 0},c,{style:E,ref:a}),e.createElement("div",Object.assign({},t.in&&{role:N},{className:l(b)?b({type:m}):o("Toastify__toast-body",b),style:O}),d),function(t){if(t){var n={closeToast:y,type:m};return l(t)?t(n):e.isValidElement(t)?e.cloneElement(t,n):void 0}}(u),(f||A)&&e.createElement(R,Object.assign({},x&&!A?{key:"pb-"+x}:{},{rtl:P,delay:f,isRunning:s,isIn:t.in,closeToast:y,hide:v,type:m,style:I,className:C,controlledProgress:A,progress:L}))))},N=T({enter:"Toastify__bounce-enter",exit:"Toastify__bounce-exit",appendPosition:!0}),L=T({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit",duration:[450,750],appendPosition:!0}),P=T({enter:"Toastify__zoom-enter",exit:"Toastify__zoom-exit"}),w=T({enter:"Toastify__flip-enter",exit:"Toastify__flip-exit"}),k=function(t){var n=t.children,o=t.className,r=t.style,s=i(t,["children","className","style"]);return delete s.in,e.createElement("div",{className:o,style:r},e.Children.map(n,(function(t){return e.cloneElement(t,s)})))},B=function(t){var n=O(t),r=n.isToastActive,i=t.className,a=t.style,c=t.rtl;return e.createElement("div",{ref:n.containerRef,className:"Toastify",id:t.containerId},(0,n.getToastToRender)((function(t,n){var u,f,p={className:l(i)?i({position:t,rtl:c,defaultClassName:o("Toastify__toast-container","Toastify__toast-container--"+t,(u={},u["Toastify__toast-container--rtl"]=c,u))}):o("Toastify__toast-container","Toastify__toast-container--"+t,(f={},f["Toastify__toast-container--rtl"]=c,f),d(i)),style:0===n.length?s({},a,{pointerEvents:"none"}):s({},a)};return e.createElement(k,Object.assign({},p,{key:"container-"+t}),n.map((function(t){var n=t.content,o=t.props;return e.createElement(x,Object.assign({},o,{in:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?I:o.closeButton}),n)})))})))};B.defaultProps={position:v.TOP_RIGHT,transition:N,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:I,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,role:"alert"};var D,A,S,M=new Map,F=[],j=!1;function H(){return M.size>0}function X(){return(Math.random().toString(36)+Date.now().toString(36)).substr(2,10)}function q(t){return t&&(u(t.toastId)||a(t.toastId))?t.toastId:X()}function Q(t,n){return H()?h.emit(0,t,n):(F.push({content:t,options:n}),j&&p&&(j=!1,A=document.createElement("div"),document.body.appendChild(A),r.render(e.createElement(B,Object.assign({},S)),A))),n.toastId}function V(t,e){return s({},e,{type:e&&e.type||t,toastId:q(e)})}var U=function(t,e){return Q(t,V(y.DEFAULT,e))};U.success=function(t,e){return Q(t,V(y.SUCCESS,e))},U.info=function(t,e){return Q(t,V(y.INFO,e))},U.error=function(t,e){return Q(t,V(y.ERROR,e))},U.warning=function(t,e){return Q(t,V(y.WARNING,e))},U.dark=function(t,e){return Q(t,V(y.DARK,e))},U.warn=U.warning,U.dismiss=function(t){return H()&&h.emit(1,t)},U.clearWaitingQueue=function(t){return void 0===t&&(t={}),H()&&h.emit(5,t)},U.isActive=function(t){var e=!1;return M.forEach((function(n){n.isToastActive&&n.isToastActive(t)&&(e=!0)})),e},U.update=function(t,e){void 0===e&&(e={}),setTimeout((function(){var n=function(t,e){var n,o=(n=e.containerId,H()?M.get(n||D):null);return o?o.getToast(t):null}(t,e);if(n){var o=n.content,r=s({},n.props,e,{toastId:e.toastId||t,updateId:X()});r.toastId!==t&&(r.staleId=t);var i=void 0!==r.render?r.render:o;delete r.render,Q(i,r)}}),0)},U.done=function(t){U.update(t,{progress:1})},U.onChange=function(t){return l(t)&&h.on(4,t),function(){l(t)&&h.off(4,t)}},U.configure=function(t){void 0===t&&(t={}),j=!0,S=t},U.POSITION=v,U.TYPE=y,h.on(2,(function(t){M.set(D=t.containerId||t,t),F.forEach((function(t){h.emit(0,t.content,t.options)})),F=[]})).on(3,(function(t){M.delete(t.containerId||t),0===M.size&&h.off(0).off(1).off(5),p&&A&&document.body.removeChild(A)})),exports.Bounce=N,exports.Flip=w,exports.Slide=L,exports.ToastContainer=B,exports.Zoom=P,exports.collapseToast=g,exports.cssTransition=T,exports.toast=U,exports.useToast=_,exports.useToastContainer=O;
//# sourceMappingURL=react-toastify.cjs.production.min.js.map

@@ -160,3 +160,4 @@ import { isValidElement, createElement, useRef, useEffect, useReducer, cloneElement, useState, Children } from 'react';

node.classList.remove(enterClassName);
node.style.cssText = '';
node.style.removeProperty('animationFillMode');
node.style.removeProperty('animationDuration');
}

@@ -482,7 +483,9 @@ };

toastContent = cloneElement(content, {
closeToast: closeToast
closeToast: closeToast,
toastProps: toastProps
});
} else if (isFn(content)) {
toastContent = content({
closeToast: closeToast
closeToast: closeToast,
toastProps: toastProps
});

@@ -661,2 +664,3 @@ } // not handling limit + delay by design. Waiting for user feedback first

function onDragMove(e) {
e.preventDefault();
var toast = toastRef.current;

@@ -663,0 +667,0 @@

@@ -9,2 +9,3 @@ import * as React from 'react';

closeToast?: () => void;
toastProps: ToastProps;
}

@@ -11,0 +12,0 @@ export declare type ToastContent = React.ReactNode | ((props: ToastContentProps) => React.ReactNode);

{
"version": "6.1.0",
"version": "6.2.0",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc