New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-toastify

Package Overview
Dependencies
Maintainers
1
Versions
166
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 5.0.0-rc.1 to 5.0.0-rc.2

20

cjs/react-toastify.js

@@ -265,12 +265,14 @@ 'use strict';

_this.onDragTransitionEnd = function () {
var _this$boundingRect = _this.boundingRect,
top = _this$boundingRect.top,
bottom = _this$boundingRect.bottom,
left = _this$boundingRect.left,
right = _this$boundingRect.right;
if (_this.boundingRect) {
var _this$boundingRect = _this.boundingRect,
top = _this$boundingRect.top,
bottom = _this$boundingRect.bottom,
left = _this$boundingRect.left,
right = _this$boundingRect.right;
if (_this.props.pauseOnHover && _this.drag.x >= left && _this.drag.x <= right && _this.drag.y >= top && _this.drag.y <= bottom) {
_this.pauseToast();
} else {
_this.playToast();
if (_this.props.pauseOnHover && _this.drag.x >= left && _this.drag.x <= right && _this.drag.y >= top && _this.drag.y <= bottom) {
_this.pauseToast();
} else {
_this.playToast();
}
}

@@ -277,0 +279,0 @@ };

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

"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=_interopDefault(require("@babel/runtime/helpers/extends")),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")),_inheritsLoose=_interopDefault(require("@babel/runtime/helpers/inheritsLoose")),React=require("react"),React__default=_interopDefault(React),cx=_interopDefault(require("classnames")),TransitionGroup=_interopDefault(require("react-transition-group/TransitionGroup")),Transition=_interopDefault(require("react-transition-group/Transition")),reactDom=require("react-dom"),POSITION={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},TYPE={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},ACTION={SHOW:0,CLEAR:1,DID_MOUNT:2,WILL_UNMOUNT:3,ON_CHANGE:4},NOOP=function(){};function isValidDelay(t){return"number"==typeof t&&!isNaN(t)&&0<t}var canUseDom=!("undefined"==typeof window||!window.document||!window.document.createElement);function withRequired(o){return o.isRequired=function(t,e,n){if(void 0===t[e])return new Error("The prop "+e+" is marked as required in \n "+n+", but its value is undefined.");o(t,e,n)},o}var falseOrDelay=withRequired(function(t,e,n){var o=t[e];return!1===o||isValidDelay(o)?null:new Error(n+" expect "+e+" \n to be a valid Number > 0 or equal to false. "+o+" given.")});function ProgressBar(t){var e,n=t.delay,o=t.isRunning,s=t.closeToast,a=t.type,r=t.hide,i=t.className,l=t.style,u=t.controlledProgress,c=t.progress,p=t.isProgressDone,d=t.rtl,f=_extends({},l,{animationDuration:n+"ms",animationPlayState:o?"running":"paused",opacity:r?0:1,transform:u?"scaleX("+c+")":null}),g=cx("Toastify__progress-bar",u?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+a,{"Toastify__progress-bar--rtl":d},i),h=((e={})[u&&p?"onTransitionEnd":"onAnimationEnd"]=u&&!p?null:s,e);return React__default.createElement("div",_extends({className:g,style:f},h))}function getX(t){return t.targetTouches&&1<=t.targetTouches.length?t.targetTouches[0].clientX:t.clientX}function getY(t){return t.targetTouches&&1<=t.targetTouches.length?t.targetTouches[0].clientY:t.clientY}ProgressBar.defaultProps={type:TYPE.DEFAULT,hide:!1};var iLoveInternetExplorer=canUseDom&&/(msie|trident)/i.test(navigator.userAgent),Toast=function(o){function t(){for(var a,t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return(a=o.call.apply(o,[this].concat(e))||this).state={isRunning:!0,preventExitTransition:!1},a.flag={canCloseOnClick:!0,canDrag:!1},a.drag={start:0,x:0,y:0,deltaX:0,removalDistance:0},a.boundingRect=null,a.ref=null,a.pauseToast=function(){a.props.autoClose&&a.setState({isRunning:!1})},a.playToast=function(){a.props.autoClose&&a.setState({isRunning:!0})},a.onDragStart=function(t){a.flag.canCloseOnClick=!0,a.flag.canDrag=!0,a.boundingRect=a.ref.getBoundingClientRect(),a.ref.style.transition="",a.drag.start=a.drag.x=getX(t.nativeEvent),a.drag.removalDistance=a.ref.offsetWidth*(a.props.draggablePercent/100)},a.onDragMove=function(t){a.flag.canDrag&&(a.state.isRunning&&a.pauseToast(),a.drag.x=getX(t),a.drag.deltaX=a.drag.x-a.drag.start,a.drag.y=getY(t),a.drag.start!==a.drag.x&&(a.flag.canCloseOnClick=!1),a.ref.style.transform="translateX("+a.drag.deltaX+"px)",a.ref.style.opacity=1-Math.abs(a.drag.deltaX/a.drag.removalDistance))},a.onDragEnd=function(t){if(a.flag.canDrag){if(a.flag.canDrag=!1,Math.abs(a.drag.deltaX)>a.drag.removalDistance)return void a.setState({preventExitTransition:!0},a.props.closeToast);a.ref.style.transition="transform 0.2s, opacity 0.2s",a.ref.style.transform="translateX(0)",a.ref.style.opacity=1}},a.onDragTransitionEnd=function(){var t=a.boundingRect,e=t.top,n=t.bottom,o=t.left,s=t.right;a.props.pauseOnHover&&a.drag.x>=o&&a.drag.x<=s&&a.drag.y>=e&&a.drag.y<=n?a.pauseToast():a.playToast()},a.onExitTransitionEnd=function(){if(iLoveInternetExplorer)a.props.onExited();else{var t=a.ref.scrollHeight,e=a.ref.style;requestAnimationFrame(function(){e.minHeight="initial",e.height=t+"px",e.transition="all 0.4s ",requestAnimationFrame(function(){e.height=0,e.padding=0,e.margin=0}),setTimeout(function(){return a.props.onExited()},400)})}},a}_inheritsLoose(t,o);var e=t.prototype;return e.componentDidMount=function(){this.props.onOpen(this.props.children.props),this.props.draggable&&this.bindDragEvents(),this.props.pauseOnFocusLoss&&this.bindFocusEvents()},e.componentDidUpdate=function(t){t.draggable!==this.props.draggable&&(this.props.draggable?this.bindDragEvents():this.unbindDragEvents()),t.pauseOnFocusLoss!==this.props.pauseOnFocusLoss&&(this.props.pauseOnFocusLoss?this.bindFocusEvents():this.unbindFocusEvents())},e.componentWillUnmount=function(){this.props.onClose(this.props.children.props),this.props.draggable&&this.unbindDragEvents(),this.props.pauseOnFocusLoss&&this.unbindFocusEvents()},e.bindFocusEvents=function(){window.addEventListener("focus",this.playToast),window.addEventListener("blur",this.pauseToast)},e.unbindFocusEvents=function(){window.removeEventListener("focus",this.playToast),window.removeEventListener("blur",this.pauseToast)},e.bindDragEvents=function(){document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd)},e.unbindDragEvents=function(){document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd)},e.render=function(){var e=this,t=this.props,n=t.closeButton,o=t.children,s=t.autoClose,a=t.pauseOnHover,r=t.closeOnClick,i=t.type,l=t.hideProgressBar,u=t.closeToast,c=t.transition,p=t.position,d=t.className,f=t.bodyClassName,g=t.progressClassName,h=t.progressStyle,T=t.updateId,m=t.role,y=t.progress,v=t.isProgressDone,_=t.rtl,E={className:cx("Toastify__toast","Toastify__toast--"+i,{"Toastify__toast--rtl":_},d)};s&&a&&(E.onMouseEnter=this.pauseToast,E.onMouseLeave=this.playToast),r&&(E.onClick=function(){return e.flag.canCloseOnClick&&u()});var O=parseFloat(y)===y;return React__default.createElement(c,{in:this.props.in,appear:!0,onExited:this.onExitTransitionEnd,position:p,preventExitTransition:this.state.preventExitTransition},React__default.createElement("div",_extends({},E,{ref:function(t){return e.ref=t},onMouseDown:this.onDragStart,onTouchStart:this.onDragStart,onMouseUp:this.onDragTransitionEnd,onTouchEnd:this.onDragTransitionEnd}),React__default.createElement("div",_extends({},this.props.in&&{role:m},{className:cx("Toastify__toast-body",f)}),o),n&&n,(s||O)&&React__default.createElement(ProgressBar,_extends({},T&&!O?{key:"pb-"+T}:{},{rtl:_,delay:s,isRunning:this.state.isRunning,closeToast:u,hide:l,type:i,style:h,className:g,controlledProgress:O,isProgressDone:v,progress:y}))))},t}(React.Component);function CloseButton(t){var e=t.closeToast,n=t.type,o=t.ariaLabel;return React__default.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+n,type:"button",onClick:e,"aria-label":o},"✖")}function cssTransition(t){var u=t.enter,c=t.exit,e=t.duration,p=void 0===e?750:e,n=t.appendPosition,d=void 0!==n&&n;return function(t){var e,n,o=t.children,s=t.position,a=t.preventExitTransition,r=_objectWithoutPropertiesLoose(t,["children","position","preventExitTransition"]),i=d?u+"--"+s:u,l=d?c+"--"+s:c;Array.isArray(p)&&2===p.length?(e=p[0],n=p[1]):e=n=p;return React__default.createElement(Transition,_extends({},r,{timeout:a?0:{enter:e,exit:n},onEnter:function(t){t.classList.add(i),t.style.animationFillMode="forwards",t.style.animationDuration=.001*e+"s"},onEntered:function(t){t.classList.remove(i),t.style.cssText=""},onExit:a?NOOP:function(t){t.classList.add(l),t.style.animationFillMode="forwards",t.style.animationDuration=.001*n+"s"}}),o)}}Toast.defaultProps={type:TYPE.DEFAULT,in:!0,onOpen:NOOP,onClose:NOOP,className:null,bodyClassName:null,progressClassName:null,updateId:null,role:"alert"},CloseButton.defaultProps={ariaLabel:"close"};var Bounce=cssTransition({enter:"Toastify__bounce-enter",exit:"Toastify__bounce-exit",appendPosition:!0}),Slide=cssTransition({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit",duration:[450,750],appendPosition:!0}),Zoom=cssTransition({enter:"Toastify__zoom-enter",exit:"Toastify__zoom-exit"}),Flip=cssTransition({enter:"Toastify__flip-enter",exit:"Toastify__flip-exit"}),eventManager={list: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){return this.list.delete(t),this},emit:function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];this.list.has(t)&&this.list.get(t).forEach(function(t){return setTimeout(function(){t.apply(void 0,n)},0)})}},ToastContainer=function(s){function t(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=s.call.apply(s,[this].concat(n))||this).state={toast:[]},e.toastKey=1,e.collection={},e.isToastActive=function(t){return-1!==e.state.toast.indexOf(t)},e}_inheritsLoose(t,s);var e=t.prototype;return e.componentDidMount=function(){var n=this;eventManager.on(ACTION.SHOW,function(t,e){return n.buildToast(t,e)}).on(ACTION.CLEAR,function(t){return null==t?n.clear():n.removeToast(t)}).emit(ACTION.DID_MOUNT,this)},e.componentWillUnmount=function(){eventManager.off(ACTION.SHOW).off(ACTION.CLEAR).emit(ACTION.WILL_UNMOUNT)},e.removeToast=function(e){this.setState({toast:this.state.toast.filter(function(t){return t!==e})},this.dispatchChange)},e.dispatchChange=function(){eventManager.emit(ACTION.ON_CHANGE,this.state.toast.length)},e.makeCloseButton=function(t,e,n){var o=this,s=this.props.closeButton;return React.isValidElement(t)||!1===t?s=t:!0===t&&(s=React__default.createElement(CloseButton,null)),!1!==s&&React.cloneElement(s,{closeToast:function(){return o.removeToast(e)},type:n})},e.getAutoCloseDelay=function(t){return!1===t||isValidDelay(t)?t:this.props.autoClose},e.canBeRendered=function(t){return React.isValidElement(t)||"string"==typeof t||"number"==typeof t||"function"==typeof t},e.parseClassName=function(t){return"string"==typeof t?t:null!==t&&"object"==typeof t&&"toString"in t?t.toString():null},e.buildToast=function(t,e){var n=this,o=e.delay,s=_objectWithoutPropertiesLoose(e,["delay"]);if(!this.canBeRendered(t))throw new Error("The element you provided cannot be rendered. You provided an element of type "+typeof t);var a=s.toastId,r=function(){return n.removeToast(a)},i={id:a,key:s.key||this.toastKey++,type:s.type,closeToast:r,updateId:s.updateId,rtl:this.props.rtl,position:s.position||this.props.position,transition:s.transition||this.props.transition,className:this.parseClassName(s.className||this.props.toastClassName),bodyClassName:this.parseClassName(s.bodyClassName||this.props.bodyClassName),closeButton:this.makeCloseButton(s.closeButton,a,s.type),pauseOnHover:"boolean"==typeof s.pauseOnHover?s.pauseOnHover:this.props.pauseOnHover,pauseOnFocusLoss:"boolean"==typeof s.pauseOnFocusLoss?s.pauseOnFocusLoss:this.props.pauseOnFocusLoss,draggable:"boolean"==typeof s.draggable?s.draggable:this.props.draggable,draggablePercent:"number"!=typeof s.draggablePercent||isNaN(s.draggablePercent)?this.props.draggablePercent:s.draggablePercent,closeOnClick:"boolean"==typeof s.closeOnClick?s.closeOnClick:this.props.closeOnClick,progressClassName:this.parseClassName(s.progressClassName||this.props.progressClassName),progressStyle:this.props.progressStyle,autoClose:this.getAutoCloseDelay(s.autoClose),hideProgressBar:"boolean"==typeof s.hideProgressBar?s.hideProgressBar:this.props.hideProgressBar,progress:parseFloat(s.progress),isProgressDone:s.isProgressDone};"function"==typeof s.onOpen&&(i.onOpen=s.onOpen),"function"==typeof s.onClose&&(i.onClose=s.onClose),React.isValidElement(t)&&"string"!=typeof t.type&&"number"!=typeof t.type?t=React.cloneElement(t,{closeToast:r}):"function"==typeof t&&(t=t({closeToast:r})),isValidDelay(o)?setTimeout(function(){n.appendToast(i,t,s.staleToastId)},o):this.appendToast(i,t,s.staleToastId)},e.appendToast=function(t,e,n){var o,s=t.id,a=t.updateId;this.collection=_extends({},this.collection,((o={})[s]={options:t,content:e,position:t.position},o)),this.setState({toast:(a?[].concat(this.state.toast):[].concat(this.state.toast,[s])).filter(function(t){return t!==n})},this.dispatchChange)},e.clear=function(){this.setState({toast:[]})},e.renderToast=function(){var a=this,r={},t=this.props,o=t.className,s=t.style;return(t.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(t){var e=a.collection[t],n=e.position,o=e.options,s=e.content;r[n]||(r[n]=[]),-1!==a.state.toast.indexOf(o.id)?r[n].push(React__default.createElement(Toast,_extends({},o,{isDocumentHidden:a.state.isDocumentHidden,key:"toast-"+o.key}),s)):(r[n].push(null),delete a.collection[t])}),Object.keys(r).map(function(t){var e=1===r[t].length&&null===r[t][0],n={className:cx("Toastify__toast-container","Toastify__toast-container--"+t,{"Toastify__toast-container--rtl":a.props.rtl},a.parseClassName(o)),style:e?_extends({},s,{pointerEvents:"none"}):_extends({},s)};return React__default.createElement(TransitionGroup,_extends({},n,{key:"container-"+t}),r[t])})},e.render=function(){return React__default.createElement("div",{className:"Toastify"},this.renderToast())},t}(React.Component);ToastContainer.defaultProps={position:POSITION.TOP_RIGHT,transition:Bounce,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:React__default.createElement(CloseButton,null),pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,className:null,style:null,toastClassName:null,bodyClassName:null,progressClassName:null,progressStyle:null};var container=null,containerDomNode=null,containerConfig={},queue=[],lazy=!0;function mergeOptions(t,e){return _extends({},t,{type:e,toastId:getToastId(t)})}function generateToastId(){return(Math.random().toString(36)+Date.now().toString(36)).substr(2,10)}function getToastId(t){return t&&("string"==typeof t.toastId||"number"==typeof t.toastId&&!isNaN(t.toastId))?t.toastId:generateToastId()}function dispatchToast(t,e){return container?eventManager.emit(ACTION.SHOW,t,e):(queue.push({action:ACTION.SHOW,content:t,options:e}),lazy&&canUseDom&&(containerDomNode=document.createElement("div"),document.body.appendChild(containerDomNode),reactDom.render(React__default.createElement(ToastContainer,containerConfig),containerDomNode))),e.toastId}var toast=function(t,e){return dispatchToast(t,mergeOptions(e,e&&e.type||TYPE.DEFAULT))},_loop=function(n){TYPE[n]!==TYPE.DEFAULT&&(toast[TYPE[n].toLowerCase()]=function(t,e){return dispatchToast(t,mergeOptions(e,e&&e.type||TYPE[n]))})};for(var pos in TYPE)_loop(pos);toast.warn=toast.warning,toast.dismiss=function(t){return void 0===t&&(t=null),container&&eventManager.emit(ACTION.CLEAR,t)},toast.isActive=NOOP,toast.update=function(a,r){setTimeout(function(){if(container&&void 0!==container.collection[a]){var t=container.collection[a],e=t.options,n=t.content,o=_extends({},e,r,{toastId:r.toastId||a});r.toastId&&r.toastId!==a?o.staleToastId=a:o.updateId=generateToastId();var s=void 0!==o.render?o.render:n;delete o.render,dispatchToast(s,o)}},0)},toast.done=function(t,e){void 0===e&&(e=1),toast.update(t,{progress:e,isProgressDone:!0})},toast.onChange=function(t){"function"==typeof t&&eventManager.on(ACTION.ON_CHANGE,t)},toast.configure=function(t){containerConfig=t},toast.useLazyContainer=function(t){lazy=t},toast.POSITION=POSITION,toast.TYPE=TYPE,eventManager.on(ACTION.DID_MOUNT,function(t){container=t,toast.isActive=function(t){return container.isToastActive(t)},queue.forEach(function(t){eventManager.emit(t.action,t.content,t.options)}),queue=[]}).on(ACTION.WILL_UNMOUNT,function(){container=null,toast.isActive=NOOP,canUseDom&&containerDomNode&&document.body.removeChild(containerDomNode)}),exports.Bounce=Bounce,exports.Flip=Flip,exports.Slide=Slide,exports.ToastContainer=ToastContainer,exports.ToastPosition=POSITION,exports.ToastType=TYPE,exports.Zoom=Zoom,exports.cssTransition=cssTransition,exports.toast=toast;
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=_interopDefault(require("@babel/runtime/helpers/extends")),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")),_inheritsLoose=_interopDefault(require("@babel/runtime/helpers/inheritsLoose")),React=require("react"),React__default=_interopDefault(React),cx=_interopDefault(require("classnames")),TransitionGroup=_interopDefault(require("react-transition-group/TransitionGroup")),Transition=_interopDefault(require("react-transition-group/Transition")),reactDom=require("react-dom"),POSITION={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},TYPE={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},ACTION={SHOW:0,CLEAR:1,DID_MOUNT:2,WILL_UNMOUNT:3,ON_CHANGE:4},NOOP=function(){};function isValidDelay(t){return"number"==typeof t&&!isNaN(t)&&0<t}var canUseDom=!("undefined"==typeof window||!window.document||!window.document.createElement);function withRequired(o){return o.isRequired=function(t,e,n){if(void 0===t[e])return new Error("The prop "+e+" is marked as required in \n "+n+", but its value is undefined.");o(t,e,n)},o}var falseOrDelay=withRequired(function(t,e,n){var o=t[e];return!1===o||isValidDelay(o)?null:new Error(n+" expect "+e+" \n to be a valid Number > 0 or equal to false. "+o+" given.")});function ProgressBar(t){var e,n=t.delay,o=t.isRunning,s=t.closeToast,a=t.type,r=t.hide,i=t.className,l=t.style,u=t.controlledProgress,c=t.progress,p=t.isProgressDone,d=t.rtl,f=_extends({},l,{animationDuration:n+"ms",animationPlayState:o?"running":"paused",opacity:r?0:1,transform:u?"scaleX("+c+")":null}),g=cx("Toastify__progress-bar",u?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+a,{"Toastify__progress-bar--rtl":d},i),h=((e={})[u&&p?"onTransitionEnd":"onAnimationEnd"]=u&&!p?null:s,e);return React__default.createElement("div",_extends({className:g,style:f},h))}function getX(t){return t.targetTouches&&1<=t.targetTouches.length?t.targetTouches[0].clientX:t.clientX}function getY(t){return t.targetTouches&&1<=t.targetTouches.length?t.targetTouches[0].clientY:t.clientY}ProgressBar.defaultProps={type:TYPE.DEFAULT,hide:!1};var iLoveInternetExplorer=canUseDom&&/(msie|trident)/i.test(navigator.userAgent),Toast=function(o){function t(){for(var a,t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return(a=o.call.apply(o,[this].concat(e))||this).state={isRunning:!0,preventExitTransition:!1},a.flag={canCloseOnClick:!0,canDrag:!1},a.drag={start:0,x:0,y:0,deltaX:0,removalDistance:0},a.boundingRect=null,a.ref=null,a.pauseToast=function(){a.props.autoClose&&a.setState({isRunning:!1})},a.playToast=function(){a.props.autoClose&&a.setState({isRunning:!0})},a.onDragStart=function(t){a.flag.canCloseOnClick=!0,a.flag.canDrag=!0,a.boundingRect=a.ref.getBoundingClientRect(),a.ref.style.transition="",a.drag.start=a.drag.x=getX(t.nativeEvent),a.drag.removalDistance=a.ref.offsetWidth*(a.props.draggablePercent/100)},a.onDragMove=function(t){a.flag.canDrag&&(a.state.isRunning&&a.pauseToast(),a.drag.x=getX(t),a.drag.deltaX=a.drag.x-a.drag.start,a.drag.y=getY(t),a.drag.start!==a.drag.x&&(a.flag.canCloseOnClick=!1),a.ref.style.transform="translateX("+a.drag.deltaX+"px)",a.ref.style.opacity=1-Math.abs(a.drag.deltaX/a.drag.removalDistance))},a.onDragEnd=function(t){if(a.flag.canDrag){if(a.flag.canDrag=!1,Math.abs(a.drag.deltaX)>a.drag.removalDistance)return void a.setState({preventExitTransition:!0},a.props.closeToast);a.ref.style.transition="transform 0.2s, opacity 0.2s",a.ref.style.transform="translateX(0)",a.ref.style.opacity=1}},a.onDragTransitionEnd=function(){if(a.boundingRect){var t=a.boundingRect,e=t.top,n=t.bottom,o=t.left,s=t.right;a.props.pauseOnHover&&a.drag.x>=o&&a.drag.x<=s&&a.drag.y>=e&&a.drag.y<=n?a.pauseToast():a.playToast()}},a.onExitTransitionEnd=function(){if(iLoveInternetExplorer)a.props.onExited();else{var t=a.ref.scrollHeight,e=a.ref.style;requestAnimationFrame(function(){e.minHeight="initial",e.height=t+"px",e.transition="all 0.4s ",requestAnimationFrame(function(){e.height=0,e.padding=0,e.margin=0}),setTimeout(function(){return a.props.onExited()},400)})}},a}_inheritsLoose(t,o);var e=t.prototype;return e.componentDidMount=function(){this.props.onOpen(this.props.children.props),this.props.draggable&&this.bindDragEvents(),this.props.pauseOnFocusLoss&&this.bindFocusEvents()},e.componentDidUpdate=function(t){t.draggable!==this.props.draggable&&(this.props.draggable?this.bindDragEvents():this.unbindDragEvents()),t.pauseOnFocusLoss!==this.props.pauseOnFocusLoss&&(this.props.pauseOnFocusLoss?this.bindFocusEvents():this.unbindFocusEvents())},e.componentWillUnmount=function(){this.props.onClose(this.props.children.props),this.props.draggable&&this.unbindDragEvents(),this.props.pauseOnFocusLoss&&this.unbindFocusEvents()},e.bindFocusEvents=function(){window.addEventListener("focus",this.playToast),window.addEventListener("blur",this.pauseToast)},e.unbindFocusEvents=function(){window.removeEventListener("focus",this.playToast),window.removeEventListener("blur",this.pauseToast)},e.bindDragEvents=function(){document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd)},e.unbindDragEvents=function(){document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd)},e.render=function(){var e=this,t=this.props,n=t.closeButton,o=t.children,s=t.autoClose,a=t.pauseOnHover,r=t.closeOnClick,i=t.type,l=t.hideProgressBar,u=t.closeToast,c=t.transition,p=t.position,d=t.className,f=t.bodyClassName,g=t.progressClassName,h=t.progressStyle,T=t.updateId,m=t.role,y=t.progress,v=t.isProgressDone,_=t.rtl,E={className:cx("Toastify__toast","Toastify__toast--"+i,{"Toastify__toast--rtl":_},d)};s&&a&&(E.onMouseEnter=this.pauseToast,E.onMouseLeave=this.playToast),r&&(E.onClick=function(){return e.flag.canCloseOnClick&&u()});var O=parseFloat(y)===y;return React__default.createElement(c,{in:this.props.in,appear:!0,onExited:this.onExitTransitionEnd,position:p,preventExitTransition:this.state.preventExitTransition},React__default.createElement("div",_extends({},E,{ref:function(t){return e.ref=t},onMouseDown:this.onDragStart,onTouchStart:this.onDragStart,onMouseUp:this.onDragTransitionEnd,onTouchEnd:this.onDragTransitionEnd}),React__default.createElement("div",_extends({},this.props.in&&{role:m},{className:cx("Toastify__toast-body",f)}),o),n&&n,(s||O)&&React__default.createElement(ProgressBar,_extends({},T&&!O?{key:"pb-"+T}:{},{rtl:_,delay:s,isRunning:this.state.isRunning,closeToast:u,hide:l,type:i,style:h,className:g,controlledProgress:O,isProgressDone:v,progress:y}))))},t}(React.Component);function CloseButton(t){var e=t.closeToast,n=t.type,o=t.ariaLabel;return React__default.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+n,type:"button",onClick:e,"aria-label":o},"✖")}function cssTransition(t){var u=t.enter,c=t.exit,e=t.duration,p=void 0===e?750:e,n=t.appendPosition,d=void 0!==n&&n;return function(t){var e,n,o=t.children,s=t.position,a=t.preventExitTransition,r=_objectWithoutPropertiesLoose(t,["children","position","preventExitTransition"]),i=d?u+"--"+s:u,l=d?c+"--"+s:c;Array.isArray(p)&&2===p.length?(e=p[0],n=p[1]):e=n=p;return React__default.createElement(Transition,_extends({},r,{timeout:a?0:{enter:e,exit:n},onEnter:function(t){t.classList.add(i),t.style.animationFillMode="forwards",t.style.animationDuration=.001*e+"s"},onEntered:function(t){t.classList.remove(i),t.style.cssText=""},onExit:a?NOOP:function(t){t.classList.add(l),t.style.animationFillMode="forwards",t.style.animationDuration=.001*n+"s"}}),o)}}Toast.defaultProps={type:TYPE.DEFAULT,in:!0,onOpen:NOOP,onClose:NOOP,className:null,bodyClassName:null,progressClassName:null,updateId:null,role:"alert"},CloseButton.defaultProps={ariaLabel:"close"};var Bounce=cssTransition({enter:"Toastify__bounce-enter",exit:"Toastify__bounce-exit",appendPosition:!0}),Slide=cssTransition({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit",duration:[450,750],appendPosition:!0}),Zoom=cssTransition({enter:"Toastify__zoom-enter",exit:"Toastify__zoom-exit"}),Flip=cssTransition({enter:"Toastify__flip-enter",exit:"Toastify__flip-exit"}),eventManager={list: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){return this.list.delete(t),this},emit:function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];this.list.has(t)&&this.list.get(t).forEach(function(t){return setTimeout(function(){t.apply(void 0,n)},0)})}},ToastContainer=function(s){function t(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=s.call.apply(s,[this].concat(n))||this).state={toast:[]},e.toastKey=1,e.collection={},e.isToastActive=function(t){return-1!==e.state.toast.indexOf(t)},e}_inheritsLoose(t,s);var e=t.prototype;return e.componentDidMount=function(){var n=this;eventManager.on(ACTION.SHOW,function(t,e){return n.buildToast(t,e)}).on(ACTION.CLEAR,function(t){return null==t?n.clear():n.removeToast(t)}).emit(ACTION.DID_MOUNT,this)},e.componentWillUnmount=function(){eventManager.off(ACTION.SHOW).off(ACTION.CLEAR).emit(ACTION.WILL_UNMOUNT)},e.removeToast=function(e){this.setState({toast:this.state.toast.filter(function(t){return t!==e})},this.dispatchChange)},e.dispatchChange=function(){eventManager.emit(ACTION.ON_CHANGE,this.state.toast.length)},e.makeCloseButton=function(t,e,n){var o=this,s=this.props.closeButton;return React.isValidElement(t)||!1===t?s=t:!0===t&&(s=React__default.createElement(CloseButton,null)),!1!==s&&React.cloneElement(s,{closeToast:function(){return o.removeToast(e)},type:n})},e.getAutoCloseDelay=function(t){return!1===t||isValidDelay(t)?t:this.props.autoClose},e.canBeRendered=function(t){return React.isValidElement(t)||"string"==typeof t||"number"==typeof t||"function"==typeof t},e.parseClassName=function(t){return"string"==typeof t?t:null!==t&&"object"==typeof t&&"toString"in t?t.toString():null},e.buildToast=function(t,e){var n=this,o=e.delay,s=_objectWithoutPropertiesLoose(e,["delay"]);if(!this.canBeRendered(t))throw new Error("The element you provided cannot be rendered. You provided an element of type "+typeof t);var a=s.toastId,r=function(){return n.removeToast(a)},i={id:a,key:s.key||this.toastKey++,type:s.type,closeToast:r,updateId:s.updateId,rtl:this.props.rtl,position:s.position||this.props.position,transition:s.transition||this.props.transition,className:this.parseClassName(s.className||this.props.toastClassName),bodyClassName:this.parseClassName(s.bodyClassName||this.props.bodyClassName),closeButton:this.makeCloseButton(s.closeButton,a,s.type),pauseOnHover:"boolean"==typeof s.pauseOnHover?s.pauseOnHover:this.props.pauseOnHover,pauseOnFocusLoss:"boolean"==typeof s.pauseOnFocusLoss?s.pauseOnFocusLoss:this.props.pauseOnFocusLoss,draggable:"boolean"==typeof s.draggable?s.draggable:this.props.draggable,draggablePercent:"number"!=typeof s.draggablePercent||isNaN(s.draggablePercent)?this.props.draggablePercent:s.draggablePercent,closeOnClick:"boolean"==typeof s.closeOnClick?s.closeOnClick:this.props.closeOnClick,progressClassName:this.parseClassName(s.progressClassName||this.props.progressClassName),progressStyle:this.props.progressStyle,autoClose:this.getAutoCloseDelay(s.autoClose),hideProgressBar:"boolean"==typeof s.hideProgressBar?s.hideProgressBar:this.props.hideProgressBar,progress:parseFloat(s.progress),isProgressDone:s.isProgressDone};"function"==typeof s.onOpen&&(i.onOpen=s.onOpen),"function"==typeof s.onClose&&(i.onClose=s.onClose),React.isValidElement(t)&&"string"!=typeof t.type&&"number"!=typeof t.type?t=React.cloneElement(t,{closeToast:r}):"function"==typeof t&&(t=t({closeToast:r})),isValidDelay(o)?setTimeout(function(){n.appendToast(i,t,s.staleToastId)},o):this.appendToast(i,t,s.staleToastId)},e.appendToast=function(t,e,n){var o,s=t.id,a=t.updateId;this.collection=_extends({},this.collection,((o={})[s]={options:t,content:e,position:t.position},o)),this.setState({toast:(a?[].concat(this.state.toast):[].concat(this.state.toast,[s])).filter(function(t){return t!==n})},this.dispatchChange)},e.clear=function(){this.setState({toast:[]})},e.renderToast=function(){var a=this,r={},t=this.props,o=t.className,s=t.style;return(t.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(t){var e=a.collection[t],n=e.position,o=e.options,s=e.content;r[n]||(r[n]=[]),-1!==a.state.toast.indexOf(o.id)?r[n].push(React__default.createElement(Toast,_extends({},o,{isDocumentHidden:a.state.isDocumentHidden,key:"toast-"+o.key}),s)):(r[n].push(null),delete a.collection[t])}),Object.keys(r).map(function(t){var e=1===r[t].length&&null===r[t][0],n={className:cx("Toastify__toast-container","Toastify__toast-container--"+t,{"Toastify__toast-container--rtl":a.props.rtl},a.parseClassName(o)),style:e?_extends({},s,{pointerEvents:"none"}):_extends({},s)};return React__default.createElement(TransitionGroup,_extends({},n,{key:"container-"+t}),r[t])})},e.render=function(){return React__default.createElement("div",{className:"Toastify"},this.renderToast())},t}(React.Component);ToastContainer.defaultProps={position:POSITION.TOP_RIGHT,transition:Bounce,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:React__default.createElement(CloseButton,null),pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,className:null,style:null,toastClassName:null,bodyClassName:null,progressClassName:null,progressStyle:null};var container=null,containerDomNode=null,containerConfig={},queue=[],lazy=!0;function mergeOptions(t,e){return _extends({},t,{type:e,toastId:getToastId(t)})}function generateToastId(){return(Math.random().toString(36)+Date.now().toString(36)).substr(2,10)}function getToastId(t){return t&&("string"==typeof t.toastId||"number"==typeof t.toastId&&!isNaN(t.toastId))?t.toastId:generateToastId()}function dispatchToast(t,e){return container?eventManager.emit(ACTION.SHOW,t,e):(queue.push({action:ACTION.SHOW,content:t,options:e}),lazy&&canUseDom&&(containerDomNode=document.createElement("div"),document.body.appendChild(containerDomNode),reactDom.render(React__default.createElement(ToastContainer,containerConfig),containerDomNode))),e.toastId}var toast=function(t,e){return dispatchToast(t,mergeOptions(e,e&&e.type||TYPE.DEFAULT))},_loop=function(n){TYPE[n]!==TYPE.DEFAULT&&(toast[TYPE[n].toLowerCase()]=function(t,e){return dispatchToast(t,mergeOptions(e,e&&e.type||TYPE[n]))})};for(var pos in TYPE)_loop(pos);toast.warn=toast.warning,toast.dismiss=function(t){return void 0===t&&(t=null),container&&eventManager.emit(ACTION.CLEAR,t)},toast.isActive=NOOP,toast.update=function(a,r){setTimeout(function(){if(container&&void 0!==container.collection[a]){var t=container.collection[a],e=t.options,n=t.content,o=_extends({},e,r,{toastId:r.toastId||a});r.toastId&&r.toastId!==a?o.staleToastId=a:o.updateId=generateToastId();var s=void 0!==o.render?o.render:n;delete o.render,dispatchToast(s,o)}},0)},toast.done=function(t,e){void 0===e&&(e=1),toast.update(t,{progress:e,isProgressDone:!0})},toast.onChange=function(t){"function"==typeof t&&eventManager.on(ACTION.ON_CHANGE,t)},toast.configure=function(t){containerConfig=t},toast.useLazyContainer=function(t){lazy=t},toast.POSITION=POSITION,toast.TYPE=TYPE,eventManager.on(ACTION.DID_MOUNT,function(t){container=t,toast.isActive=function(t){return container.isToastActive(t)},queue.forEach(function(t){eventManager.emit(t.action,t.content,t.options)}),queue=[]}).on(ACTION.WILL_UNMOUNT,function(){container=null,toast.isActive=NOOP,canUseDom&&containerDomNode&&document.body.removeChild(containerDomNode)}),exports.Bounce=Bounce,exports.Flip=Flip,exports.Slide=Slide,exports.ToastContainer=ToastContainer,exports.ToastPosition=POSITION,exports.ToastType=TYPE,exports.Zoom=Zoom,exports.cssTransition=cssTransition,exports.toast=toast;

@@ -258,12 +258,14 @@ import _extends from '@babel/runtime/helpers/esm/extends';

_this.onDragTransitionEnd = function () {
var _this$boundingRect = _this.boundingRect,
top = _this$boundingRect.top,
bottom = _this$boundingRect.bottom,
left = _this$boundingRect.left,
right = _this$boundingRect.right;
if (_this.boundingRect) {
var _this$boundingRect = _this.boundingRect,
top = _this$boundingRect.top,
bottom = _this$boundingRect.bottom,
left = _this$boundingRect.left,
right = _this$boundingRect.right;
if (_this.props.pauseOnHover && _this.drag.x >= left && _this.drag.x <= right && _this.drag.y >= top && _this.drag.y <= bottom) {
_this.pauseToast();
} else {
_this.playToast();
if (_this.props.pauseOnHover && _this.drag.x >= left && _this.drag.x <= right && _this.drag.y >= top && _this.drag.y <= bottom) {
_this.pauseToast();
} else {
_this.playToast();
}
}

@@ -270,0 +272,0 @@ };

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

*/
success(content: ToastContent, options?: ToastOptions): number;
success(content: ToastContent, options?: ToastOptions): ToastId;

@@ -259,3 +259,3 @@ /**

*/
info(content: ToastContent, options?: ToastOptions): number;
info(content: ToastContent, options?: ToastOptions): ToastId;

@@ -265,3 +265,3 @@ /**

*/
warn(content: ToastContent, options?: ToastOptions): number;
warn(content: ToastContent, options?: ToastOptions): ToastId;

@@ -271,3 +271,3 @@ /**

*/
error(content: ToastContent, options?: ToastOptions): number;
error(content: ToastContent, options?: ToastOptions): ToastId;

@@ -315,3 +315,3 @@ /**

*/
(content: ToastContent, options?: ToastOptions): number;
(content: ToastContent, options?: ToastOptions): ToastId;

@@ -318,0 +318,0 @@ /**

{
"name": "react-toastify",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.2",
"description": "React notification made easy",

@@ -28,4 +28,4 @@ "keywords": [

"start": "npm run sass && webpack-dev-server --config ./webpack.config.dev.js",
"test": "cross-env NODE_ENV=test jest",
"test:coverage": "cross-env NODE_ENV=test jest --coverage && cat ./coverage/lcov.info | coveralls",
"test": "jest",
"test:coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls",
"lint": "eslint src/",

@@ -32,0 +32,0 @@ "lint:fix": "eslint --fix src/",

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