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 2.0.0-rc.1 to 2.0.0-rc.2

2

dist/ReactToastify.min.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("react-transition-group/TransitionGroup")):"function"==typeof define&&define.amd?define(["react","prop-types","react-transition-group/TransitionGroup"],t):"object"==typeof exports?exports.ReactOnScreen=t(require("react"),require("prop-types"),require("react-transition-group/TransitionGroup")):e.ReactOnScreen=t(e.react,e["prop-types"],e["react-transition-group/TransitionGroup"])}(this,function(e,t,n){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={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:"SHOW_TOAST",CLEAR:"CLEAR_TOAST",MOUNTED:"CONTAINER_MOUNTED"}}},function(e,n){e.exports=t},function(e,t,n){"use strict";function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var r={eventList:new Map,on:function(e,t){return this.eventList.has(e)||this.eventList.set(e,[]),this.eventList.get(e).push(t),this},off:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.eventList.delete(e)},emit:function(e){for(var t=this,n=arguments.length,r=Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return this.eventList.has(e)?(this.eventList.get(e).forEach(function(e){return setTimeout(function(){return e.call.apply(e,[t].concat(o(r)))},0)}),!0):(console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=[];return Object.keys(e).forEach(function(n){return t.push(e[n])}),t}},function(e,t,n){"use strict";function o(e){return Object.prototype.toString.call(e).slice(8,-1)}function r(e){return"Number"===o(e)&&!isNaN(e)&&e>0}function s(e){return e.isRequired=function(t,n,o){if(void 0===t[n])return new Error("The prop "+n+" is marked as required in \n "+o+", but its value is undefined.");e(t,n,o)},e}Object.defineProperty(t,"__esModule",{value:!0}),t.falseOrElement=t.falseOrNumber=void 0,t.typeOf=o,t.isValidDelay=r;var i=n(0);t.falseOrNumber=s(function(e,t,n){var o=e[t];return!1===o||r(o)?null:new Error(n+" expect "+t+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),t.falseOrElement=s(function(e,t,n){var o=e[t];return!1===o||(0,i.isValidElement)(o)?null:new Error(n+" expect "+t+" \n to be a valid react element or equal to false. "+o+" given.")})},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=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},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),p=n(0),d=o(p),y=n(2),h=o(y),m=n(12),O=o(m),v=n(10),b=o(v),T=n(8),g=o(T),C=n(1),N=o(C),_=n(3),E=o(_),P=n(4),k=o(P),R=n(5),j=function(e){function t(e){i(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.isToastActive=function(e){return-1!==n.state.toast.indexOf(parseInt(e,10))},n.state={toast:[]},n.collection={},n}return u(t,e),f(t,[{key:"componentDidMount",value:function(){var e=this,t=N.default.ACTION,n=t.SHOW,o=t.CLEAR,r=t.MOUNTED;E.default.on(n,function(t,n){return e.show(t,n)}).on(o,function(t){return null!==t?e.removeToast(t):e.clear()}).emit(r,this)}},{key:"componentWillUnmount",value:function(){E.default.off(N.default.ACTION.SHOW),E.default.off(N.default.ACTION.CLEAR)}},{key:"removeToast",value:function(e){this.setState({toast:this.state.toast.filter(function(t){return t!==parseInt(e,10)})})}},{key:"with",value:function(e,t){return(0,p.cloneElement)(e,c({},t,e.props))}},{key:"makeCloseButton",value:function(e,t){var n=this,o=this.props.closeButton;return((0,p.isValidElement)(e)||!1===e)&&(o=e),!1!==o&&this.with(o,{closeToast:function(){return n.removeToast(t)}})}},{key:"getAutoCloseDelay",value:function(e){return!1===e||(0,R.isValidDelay)(e)?e:this.props.autoClose}},{key:"isFunction",value:function(e){return!!(e&&e.constructor&&e.call&&e.apply)}},{key:"canBeRendered",value:function(e){return(0,p.isValidElement)(e)||"String"===(0,R.typeOf)(e)||"Number"===(0,R.typeOf)(e)}},{key:"show",value:function(e,t){var n=this;if(!this.canBeRendered(e))throw new Error("The element you provided cannot be rendered. You provided an element of type "+(void 0===e?"undefined":l(e)));var o=t.toastId,i=function(){return n.removeToast(o)},a={id:o,type:t.type,closeButton:this.makeCloseButton(t.closeButton,o),position:t.position||this.props.position,pauseOnHover:null!==t.pauseOnHover?t.pauseOnHover:this.props.pauseOnHover,closeOnClick:null!==t.closeOnClick?t.closeOnClick:this.props.closeOnClick,className:t.className||this.props.toastClassName,bodyClassName:t.bodyClassName||this.props.bodyClassName,progressClassName:t.progressClassName||this.props.progressClassName};this.isFunction(t.onOpen)&&(a.onOpen=t.onOpen),this.isFunction(t.onClose)&&(a.onClose=t.onClose),a.autoClose=this.getAutoCloseDelay(!1!==t.autoClose?parseInt(t.autoClose,10):t.autoClose),a.hideProgressBar="boolean"==typeof t.hideProgressBar?t.hideProgressBar:this.props.hideProgressBar,a.closeToast=i,(0,p.isValidElement)(e)&&"String"!==(0,R.typeOf)(e.type)&&(e=this.with(e,{closeToast:i})),this.collection=Object.assign({},this.collection,s({},o,{content:this.makeToast(e,a),position:a.position})),this.setState({toast:[].concat(r(this.state.toast),[o])})}},{key:"makeToast",value:function(e,t){return d.default.createElement(b.default,c({},t,{key:"toast-"+t.id+" "}),e)}},{key:"clear",value:function(){this.setState({toast:[]})}},{key:"hasToast",value:function(){return this.state.toast.length>0}},{key:"getContainerProps",value:function(e,t){var n={className:"toastify toastify--"+e,style:t?{pointerEvents:"none"}:{}};return null!==this.props.className&&(n.className=n.className+" "+this.props.className),null!==this.props.style&&(n.style=Object.assign({},this.props.style,n.style)),n}},{key:"renderToast",value:function(){var e=this,t={},n=this.props.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection);return n.forEach(function(o){var r=e.collection[o];t[r.position]||(t[r.position]=[]),-1!==e.state.toast.indexOf(parseInt(o,10))?t[r.position].push(r.content):(t[r.position].push(null),setTimeout(function(){return delete e.collection[o]},10*n.length))}),Object.keys(t).map(function(n){var o=1===t[n].length&&null===t[n][0];return d.default.createElement(O.default,c({component:"div"},e.getContainerProps(n,o),{key:"container-"+n}),t[n].map(function(e){return e}))})}},{key:"render",value:function(){return d.default.createElement("div",null,this.renderToast())}}]),t}(p.Component);j.propTypes={position:h.default.oneOf((0,k.default)(N.default.POSITION)),autoClose:R.falseOrNumber,closeButton:R.falseOrElement,hideProgressBar:h.default.bool,pauseOnHover:h.default.bool,closeOnClick:h.default.bool,newestOnTop:h.default.bool,className:h.default.string,style:h.default.object,toastClassName:h.default.string,bodyClassName:h.default.string,progressClassName:h.default.string},j.defaultProps={position:N.default.POSITION.TOP_RIGHT,autoClose:5e3,hideProgressBar:!1,closeButton:d.default.createElement(g.default,null),pauseOnHover:!0,closeOnClick:!0,newestOnTop:!1,className:null,style:null,toastClassName:"",bodyClassName:"",progressClassName:""},t.default=j},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){return Object.assign({},d,e,{toastId:++m})}function s(e,t){return null!==y?a.default.emit(p.SHOW,e,t):h.push({action:p.SHOW,content:e,options:t}),t.toastId}Object.defineProperty(t,"__esModule",{value:!0});var i=n(3),a=o(i),u=n(1),l=o(u),c=l.default.POSITION,f=l.default.TYPE,p=l.default.ACTION,d={type:f.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null,position:null,pauseOnHover:null,closeOnClick:null,className:null,bodyClassName:null,progressClassName:null},y=null,h=[],m=0,O=Object.assign(function(e,t){return s(e,r(t))},{success:function(e,t){return s(e,Object.assign(r(t),{type:f.SUCCESS}))},info:function(e,t){return s(e,Object.assign(r(t),{type:f.INFO}))},warn:function(e,t){return s(e,Object.assign(r(t),{type:f.WARNING}))},warning:function(e,t){return s(e,Object.assign(r(t),{type:f.WARNING}))},error:function(e,t){return s(e,Object.assign(r(t),{type:f.ERROR}))},dismiss:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return a.default.emit(p.CLEAR,e)},isActive:function(){return!1}},{POSITION:c,TYPE:f});a.default.on(p.MOUNTED,function(e){y=e,O.isActive=function(e){return y.isToastActive(e)},h.forEach(function(e){a.default.emit(e.action,e.content,e.options)}),h=[]}),t.default=O},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.closeToast;return i.default.createElement("button",{className:"toastify__close",type:"button",onClick:t},"✖")}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),i=o(s),a=n(2),u=o(a);r.propTypes={closeToast:u.default.func},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.delay,n=e.isRunning,o=e.closeToast,r=e.type,s=e.hide,a=e.className,u={animationDuration:t+"ms",animationPlayState:n?"running":"paused"};return u.WebkitAnimationPlayState=u.animationPlayState,s&&(u.opacity=0),i.default.createElement("div",{className:"toastify__progress toastify__progress--"+r+" "+a,style:u,onAnimationEnd:o})}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),i=o(s),a=n(2),u=o(a),l=n(1),c=o(l);r.propTypes={delay:u.default.number.isRequired,isRunning:u.default.bool.isRequired,closeToast:u.default.func.isRequired,type:u.default.string,hide:u.default.bool,className:u.default.string},r.defaultProps={type:c.default.TYPE.DEFAULT,hide:!1,className:""},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(0),l=o(u),c=n(2),f=o(c),p=n(9),d=o(p),y=n(1),h=o(y),m=n(4),O=o(m),v=n(5),b=function(e){function t(e){r(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.setRef=function(e){n.ref=e},n.pauseToast=function(){n.setState({isRunning:!1})},n.playToast=function(){n.setState({isRunning:!0})},n.ref=null,n.state={isRunning:!0},n}return i(t,e),a(t,[{key:"componentDidMount",value:function(){null!==this.props.onOpen&&this.props.onOpen(this.getChildrenProps())}},{key:"componentWillUnmount",value:function(){null!==this.props.onClose&&this.props.onClose(this.getChildrenProps())}},{key:"getChildrenProps",value:function(){return this.props.children.props}},{key:"getToastProps",value:function(){var e={className:"toastify-content toastify-content--"+this.props.type+" "+this.props.className,ref:this.setRef};return!1!==this.props.autoClose&&!0===this.props.pauseOnHover&&(e.onMouseEnter=this.pauseToast,e.onMouseLeave=this.playToast),this.props.closeOnClick&&(e.onClick=this.props.closeToast),e}},{key:"componentWillAppear",value:function(e){this.ref.classList.add("toast-enter--"+this.props.position,"toastify-animated"),e()}},{key:"componentWillEnter",value:function(e){this.ref.classList.add("toast-enter--"+this.props.position,"toastify-animated"),e()}},{key:"componentWillLeave",value:function(e){this.ref.classList.remove("toast-enter--"+this.props.position,"toastify-animated"),this.ref.classList.add("toast-exit--"+this.props.position,"toastify-animated"),setTimeout(function(){return e()},750)}},{key:"render",value:function(){var e=this.props,t=e.closeButton,n=e.children,o=e.autoClose,r=e.type,s=e.hideProgressBar,i=e.closeToast;return l.default.createElement("div",this.getToastProps(),l.default.createElement("div",{className:"toastify__body "+this.props.bodyClassName},n),!1!==t&&t,!1!==o&&l.default.createElement(d.default,{delay:o,isRunning:this.state.isRunning,closeToast:i,hide:s,type:r,className:this.props.progressClassName}))}}]),t}(u.Component);b.propTypes={closeButton:v.falseOrElement.isRequired,autoClose:v.falseOrNumber.isRequired,children:f.default.node.isRequired,closeToast:f.default.func.isRequired,position:f.default.oneOf((0,O.default)(h.default.POSITION)).isRequired,pauseOnHover:f.default.bool.isRequired,closeOnClick:f.default.bool.isRequired,hideProgressBar:f.default.bool,onOpen:f.default.func,onClose:f.default.func,type:f.default.oneOf((0,O.default)(h.default.TYPE)),className:f.default.string,bodyClassName:f.default.string,progressClassName:f.default.string},b.defaultProps={type:h.default.TYPE.DEFAULT,hideProgressBar:!1,onOpen:null,onClose:null,className:"",bodyClassName:"",progressClassName:""},t.default=b},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.toast=t.ToastContainer=void 0;var r=n(6),s=o(r),i=n(7),a=o(i);t.ToastContainer=s.default,t.toast=a.default},function(e,t){e.exports=n}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("react-transition-group/TransitionGroup")):"function"==typeof define&&define.amd?define(["react","prop-types","react-transition-group/TransitionGroup"],t):"object"==typeof exports?exports.ReactOnScreen=t(require("react"),require("prop-types"),require("react-transition-group/TransitionGroup")):e.ReactOnScreen=t(e.react,e["prop-types"],e["react-transition-group/TransitionGroup"])}(this,function(e,t,n){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={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:"SHOW_TOAST",CLEAR:"CLEAR_TOAST",MOUNTED:"CONTAINER_MOUNTED"}}},function(e,n){e.exports=t},function(e,t,n){"use strict";function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var r={eventList:new Map,on:function(e,t){return this.eventList.has(e)||this.eventList.set(e,[]),this.eventList.get(e).push(t),this},off:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.eventList.delete(e)},emit:function(e){for(var t=this,n=arguments.length,r=Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return this.eventList.has(e)?(this.eventList.get(e).forEach(function(e){return setTimeout(function(){return e.call.apply(e,[t].concat(o(r)))},0)}),!0):(console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=[];return Object.keys(e).forEach(function(n){return t.push(e[n])}),t}},function(e,t,n){"use strict";function o(e){return Object.prototype.toString.call(e).slice(8,-1)}function r(e){return"Number"===o(e)&&!isNaN(e)&&e>0}function s(e){return e.isRequired=function(t,n,o){if(void 0===t[n])return new Error("The prop "+n+" is marked as required in \n "+o+", but its value is undefined.");e(t,n,o)},e}Object.defineProperty(t,"__esModule",{value:!0}),t.falseOrElement=t.falseOrNumber=void 0,t.typeOf=o,t.isValidDelay=r;var a=n(0);t.falseOrNumber=s(function(e,t,n){var o=e[t];return!1===o||r(o)?null:new Error(n+" expect "+t+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),t.falseOrElement=s(function(e,t,n){var o=e[t];return!1===o||(0,a.isValidElement)(o)?null:new Error(n+" expect "+t+" \n to be a valid react element or equal to false. "+o+" given.")})},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=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},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),p=n(0),d=o(p),y=n(2),h=o(y),m=n(12),O=o(m),v=n(10),b=o(v),T=n(8),g=o(T),C=n(1),N=o(C),_=n(3),E=o(_),P=n(4),k=o(P),R=n(5),S=function(e){function t(e){a(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.isToastActive=function(e){return-1!==n.state.toast.indexOf(parseInt(e,10))},n.state={toast:[]},n.collection={},n}return u(t,e),f(t,[{key:"componentDidMount",value:function(){var e=this,t=N.default.ACTION,n=t.SHOW,o=t.CLEAR,r=t.MOUNTED;E.default.on(n,function(t,n){return e.show(t,n)}).on(o,function(t){return null!==t?e.removeToast(t):e.clear()}).emit(r,this)}},{key:"componentWillUnmount",value:function(){E.default.off(N.default.ACTION.SHOW),E.default.off(N.default.ACTION.CLEAR)}},{key:"removeToast",value:function(e){this.setState({toast:this.state.toast.filter(function(t){return t!==parseInt(e,10)})})}},{key:"with",value:function(e,t){return(0,p.cloneElement)(e,c({},t,e.props))}},{key:"makeCloseButton",value:function(e,t){var n=this,o=this.props.closeButton;return((0,p.isValidElement)(e)||!1===e)&&(o=e),!1!==o&&this.with(o,{closeToast:function(){return n.removeToast(t)}})}},{key:"getAutoCloseDelay",value:function(e){return!1===e||(0,R.isValidDelay)(e)?e:this.props.autoClose}},{key:"isFunction",value:function(e){return!!(e&&e.constructor&&e.call&&e.apply)}},{key:"canBeRendered",value:function(e){return(0,p.isValidElement)(e)||"String"===(0,R.typeOf)(e)||"Number"===(0,R.typeOf)(e)}},{key:"show",value:function(e,t){var n=this;if(!this.canBeRendered(e))throw new Error("The element you provided cannot be rendered. You provided an element of type "+(void 0===e?"undefined":l(e)));var o=t.toastId,a=function(){return n.removeToast(o)},i={id:o,type:t.type,closeButton:this.makeCloseButton(t.closeButton,o),position:t.position||this.props.position,pauseOnHover:null!==t.pauseOnHover?t.pauseOnHover:this.props.pauseOnHover,closeOnClick:null!==t.closeOnClick?t.closeOnClick:this.props.closeOnClick,className:t.className||this.props.toastClassName,bodyClassName:t.bodyClassName||this.props.bodyClassName,progressClassName:t.progressClassName||this.props.progressClassName};this.isFunction(t.onOpen)&&(i.onOpen=t.onOpen),this.isFunction(t.onClose)&&(i.onClose=t.onClose),i.autoClose=this.getAutoCloseDelay(!1!==t.autoClose?parseInt(t.autoClose,10):t.autoClose),i.hideProgressBar="boolean"==typeof t.hideProgressBar?t.hideProgressBar:this.props.hideProgressBar,i.closeToast=a,(0,p.isValidElement)(e)&&"String"!==(0,R.typeOf)(e.type)&&(e=this.with(e,{closeToast:a})),this.collection=c({},this.collection,s({},o,{content:this.makeToast(e,i),position:i.position})),this.setState({toast:[].concat(r(this.state.toast),[o])})}},{key:"makeToast",value:function(e,t){return d.default.createElement(b.default,c({},t,{key:"toast-"+t.id+" "}),e)}},{key:"clear",value:function(){this.setState({toast:[]})}},{key:"hasToast",value:function(){return this.state.toast.length>0}},{key:"getContainerProps",value:function(e,t){var n={className:"toastify toastify--"+e,style:t?{pointerEvents:"none"}:{}};return null!==this.props.className&&(n.className=n.className+" "+this.props.className),null!==this.props.style&&(n.style=c({},this.props.style,n.style)),n}},{key:"renderToast",value:function(){var e=this,t={},n=this.props.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection);return n.forEach(function(o){var r=e.collection[o];t[r.position]||(t[r.position]=[]),-1!==e.state.toast.indexOf(parseInt(o,10))?t[r.position].push(r.content):(t[r.position].push(null),setTimeout(function(){return delete e.collection[o]},10*n.length))}),Object.keys(t).map(function(n){var o=1===t[n].length&&null===t[n][0];return d.default.createElement(O.default,c({component:"div"},e.getContainerProps(n,o),{key:"container-"+n}),t[n].map(function(e){return e}))})}},{key:"render",value:function(){return d.default.createElement("div",null,this.renderToast())}}]),t}(p.Component);S.propTypes={position:h.default.oneOf((0,k.default)(N.default.POSITION)),autoClose:R.falseOrNumber,closeButton:R.falseOrElement,hideProgressBar:h.default.bool,pauseOnHover:h.default.bool,closeOnClick:h.default.bool,newestOnTop:h.default.bool,className:h.default.string,style:h.default.object,toastClassName:h.default.string,bodyClassName:h.default.string,progressClassName:h.default.string},S.defaultProps={position:N.default.POSITION.TOP_RIGHT,autoClose:5e3,hideProgressBar:!1,closeButton:d.default.createElement(g.default,null),pauseOnHover:!0,closeOnClick:!0,newestOnTop:!1,className:null,style:null,toastClassName:"",bodyClassName:"",progressClassName:""},t.default=S},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){return a({},y,e,{toastId:++O})}function s(e,t){return null!==h?u.default.emit(d.SHOW,e,t):m.push({action:d.SHOW,content:e,options:t}),t.toastId}Object.defineProperty(t,"__esModule",{value:!0});var 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},i=n(3),u=o(i),l=n(1),c=o(l),f=c.default.POSITION,p=c.default.TYPE,d=c.default.ACTION,y={type:p.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null,position:null,pauseOnHover:null,closeOnClick:null,className:null,bodyClassName:null,progressClassName:null},h=null,m=[],O=0,v=a(function(e,t){return s(e,r(t))},{success:function(e,t){return s(e,a(r(t),{type:p.SUCCESS}))},info:function(e,t){return s(e,a(r(t),{type:p.INFO}))},warn:function(e,t){return s(e,a(r(t),{type:p.WARNING}))},warning:function(e,t){return s(e,a(r(t),{type:p.WARNING}))},error:function(e,t){return s(e,a(r(t),{type:p.ERROR}))},dismiss:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return u.default.emit(d.CLEAR,e)},isActive:function(){return!1}},{POSITION:f,TYPE:p});u.default.on(d.MOUNTED,function(e){h=e,v.isActive=function(e){return h.isToastActive(e)},m.forEach(function(e){u.default.emit(e.action,e.content,e.options)}),m=[]}),t.default=v},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.closeToast;return a.default.createElement("button",{className:"toastify__close",type:"button",onClick:t},"✖")}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),a=o(s),i=n(2),u=o(i);r.propTypes={closeToast:u.default.func},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.delay,n=e.isRunning,o=e.closeToast,r=e.type,s=e.hide,i=e.className,u={animationDuration:t+"ms",animationPlayState:n?"running":"paused"};return u.WebkitAnimationPlayState=u.animationPlayState,s&&(u.opacity=0),a.default.createElement("div",{className:"toastify__progress toastify__progress--"+r+" "+i,style:u,onAnimationEnd:o})}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),a=o(s),i=n(2),u=o(i),l=n(1),c=o(l);r.propTypes={delay:u.default.number.isRequired,isRunning:u.default.bool.isRequired,closeToast:u.default.func.isRequired,type:u.default.string,hide:u.default.bool,className:u.default.string},r.defaultProps={type:c.default.TYPE.DEFAULT,hide:!1,className:""},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(0),l=o(u),c=n(2),f=o(c),p=n(9),d=o(p),y=n(1),h=o(y),m=n(4),O=o(m),v=n(5),b=function(e){function t(e){r(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.setRef=function(e){n.ref=e},n.pauseToast=function(){n.setState({isRunning:!1})},n.playToast=function(){n.setState({isRunning:!0})},n.ref=null,n.state={isRunning:!0},n}return a(t,e),i(t,[{key:"componentDidMount",value:function(){null!==this.props.onOpen&&this.props.onOpen(this.getChildrenProps())}},{key:"componentWillUnmount",value:function(){null!==this.props.onClose&&this.props.onClose(this.getChildrenProps())}},{key:"getChildrenProps",value:function(){return this.props.children.props}},{key:"getToastProps",value:function(){var e={className:"toastify-content toastify-content--"+this.props.type+" "+this.props.className,ref:this.setRef};return!1!==this.props.autoClose&&!0===this.props.pauseOnHover&&(e.onMouseEnter=this.pauseToast,e.onMouseLeave=this.playToast),this.props.closeOnClick&&(e.onClick=this.props.closeToast),e}},{key:"componentWillAppear",value:function(e){this.ref.classList.add("toast-enter--"+this.props.position,"toastify-animated"),e()}},{key:"componentWillEnter",value:function(e){this.ref.classList.add("toast-enter--"+this.props.position,"toastify-animated"),e()}},{key:"componentWillLeave",value:function(e){this.ref.classList.remove("toast-enter--"+this.props.position,"toastify-animated"),this.ref.classList.add("toast-exit--"+this.props.position,"toastify-animated"),setTimeout(function(){return e()},750)}},{key:"render",value:function(){var e=this.props,t=e.closeButton,n=e.children,o=e.autoClose,r=e.type,s=e.hideProgressBar,a=e.closeToast;return l.default.createElement("div",this.getToastProps(),l.default.createElement("div",{className:"toastify__body "+this.props.bodyClassName},n),!1!==t&&t,!1!==o&&l.default.createElement(d.default,{delay:o,isRunning:this.state.isRunning,closeToast:a,hide:s,type:r,className:this.props.progressClassName}))}}]),t}(u.Component);b.propTypes={closeButton:v.falseOrElement.isRequired,autoClose:v.falseOrNumber.isRequired,children:f.default.node.isRequired,closeToast:f.default.func.isRequired,position:f.default.oneOf((0,O.default)(h.default.POSITION)).isRequired,pauseOnHover:f.default.bool.isRequired,closeOnClick:f.default.bool.isRequired,hideProgressBar:f.default.bool,onOpen:f.default.func,onClose:f.default.func,type:f.default.oneOf((0,O.default)(h.default.TYPE)),className:f.default.string,bodyClassName:f.default.string,progressClassName:f.default.string},b.defaultProps={type:h.default.TYPE.DEFAULT,hideProgressBar:!1,onOpen:null,onClose:null,className:"",bodyClassName:"",progressClassName:""},t.default=b},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.toast=t.ToastContainer=void 0;var r=n(6),s=o(r),a=n(7),i=o(a);t.ToastContainer=s.default,t.toast=i.default},function(e,t){e.exports=n}])});
//# sourceMappingURL=ReactToastify.min.js.map

@@ -186,3 +186,3 @@ "use strict";

this.collection = Object.assign({}, this.collection, _defineProperty({}, toastId, {
this.collection = _extends({}, this.collection, _defineProperty({}, toastId, {
content: this.makeToast(content, toastOptions),

@@ -228,3 +228,3 @@ position: toastOptions.position

if (this.props.style !== null) {
props.style = Object.assign({}, this.props.style, props.style);
props.style = _extends({}, this.props.style, props.style);
}

@@ -231,0 +231,0 @@

@@ -7,2 +7,10 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /*
* TODO: Add validation here :
* - Validate type
* - Maybe autoClose
* - Maybe closeButton as well
* */
var _EventManager = require('./util/EventManager');

@@ -18,8 +26,2 @@

/*
* TODO: Add validation here :
* - Validate type
* - Maybe autoClose
* - Maybe closeButton as well
* */
var POSITION = _config2.default.POSITION,

@@ -52,3 +54,3 @@ TYPE = _config2.default.TYPE,

function mergeOptions(options) {
return Object.assign({}, defaultOptions, options, { toastId: ++toastId });
return _extends({}, defaultOptions, options, { toastId: ++toastId });
}

@@ -71,19 +73,19 @@

var toaster = Object.assign(function (content, options) {
var toaster = _extends(function (content, options) {
return emitEvent(content, mergeOptions(options));
}, {
success: function success(content, options) {
return emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.SUCCESS }));
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.SUCCESS }));
},
info: function info(content, options) {
return emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.INFO }));
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.INFO }));
},
warn: function warn(content, options) {
return emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.WARNING }));
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.WARNING }));
},
warning: function warning(content, options) {
return emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.WARNING }));
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.WARNING }));
},
error: function error(content, options) {
return emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.ERROR }));
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.ERROR }));
},

@@ -90,0 +92,0 @@ dismiss: function dismiss() {

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

@@ -45,2 +45,3 @@ "keywords": [

"babel-loader": "^7.0.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-env": "^1.4.0",

@@ -47,0 +48,0 @@ "babel-preset-react": "^6.11.1",

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