react-toastify
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","prop-types","react-dom"],e):"object"==typeof exports?exports.ReactToastify=e(require("react"),require("prop-types"),require("react-dom")):t.ReactToastify=e(t.react,t["prop-types"],t["react-dom"])}(this,function(t,e,n){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=6)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=[];return Object.keys(t).forEach(function(n){return e.push(t[n])}),e}},function(t,e,n){"use strict";function o(t){return Object.prototype.toString.call(t).slice(8,-1)}function r(t){return"Number"===o(t)&&!isNaN(t)&&t>0}function i(t){return t.isRequired=function(e,n,o){if(void 0===e[n])return new Error("The prop "+n+" is marked as required in \n "+o+", but its value is undefined.");t(e,n,o)},t}Object.defineProperty(e,"__esModule",{value:!0}),e.falseOrElement=e.falseOrNumber=void 0,e.typeOf=o,e.isValidDelay=r;var s=n(0);e.falseOrNumber=i(function(t,e,n){var o=t[e];return!1===o||r(o)?null:new Error(n+" expect "+e+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),e.falseOrElement=i(function(t,e,n){var o=t[e];return!1===o||(0,s.isValidElement)(o)?null:new Error(n+" expect "+e+" \n to be a valid react element or equal to false. "+o+" given.")})},function(t,e,n){"use strict";function o(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}Object.defineProperty(e,"__esModule",{value:!0});var r={eventList:new Map,on:function(t,e){return this.eventList.has(t)||this.eventList.set(t,[]),this.eventList.get(t).push(e),this},off:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.eventList.delete(t)},emit:function(t){for(var e=this,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return this.eventList.has(t)?(this.eventList.get(t).forEach(function(t){return setTimeout(function(){return t.call.apply(t,[e].concat(o(r)))},0)}),!0):(console.warn("<"+t+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};e.default=r},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.toast=e.ToastContainer=void 0;var r=n(7),i=o(r),s=n(17),a=o(s);e.ToastContainer=i.default,e.toast=a.default},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c=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},f=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),p=n(0),d=o(p),h=n(1),y=o(h),m=n(8),v=o(m),O=n(10),b=o(O),E=n(12),g=o(E),T=n(13),C=o(T),N=n(2),x=o(N),_=n(5),P=o(_),S=n(3),k=o(S),j=n(4),w=function(t){function e(t){s(this,e);var n=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.isToastActive=function(t){return-1!==n.state.toast.indexOf(parseInt(t,10))},n.state={toast:[]},n.collection={},n}return u(e,t),f(e,[{key:"componentDidMount",value:function(){var t=this,e=x.default.ACTION,n=e.SHOW,o=e.CLEAR,r=e.MOUNTED;P.default.on(n,function(e,n){return t.show(e,n)}).on(o,function(e){return null!==e?t.removeToast(e):t.clear()}).emit(r,this)}},{key:"componentWillUnmount",value:function(){P.default.off(x.default.ACTION.SHOW),P.default.off(x.default.ACTION.CLEAR)}},{key:"removeToast",value:function(t){this.setState({toast:this.state.toast.filter(function(e){return e!==parseInt(t,10)})})}},{key:"with",value:function(t,e){return(0,p.cloneElement)(t,c({},e,t.props))}},{key:"makeCloseButton",value:function(t,e){var n=this,o=this.props.closeButton;return((0,p.isValidElement)(t)||!1===t)&&(o=t),!1!==o&&this.with(o,{closeToast:function(){return n.removeToast(e)}})}},{key:"getAutoCloseDelay",value:function(t){return!1===t||(0,j.isValidDelay)(t)?t:this.props.autoClose}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{key:"canBeRendered",value:function(t){return(0,p.isValidElement)(t)||"String"===(0,j.typeOf)(t)||"Number"===(0,j.typeOf)(t)}},{key:"show",value:function(t,e){var n=this;if(!this.canBeRendered(t))throw new Error("The element you provided cannot be rendered. You provided an element of type "+(void 0===t?"undefined":l(t)));var o=e.toastId,s=function(){return n.removeToast(o)},a={id:o,type:e.type,closeButton:this.makeCloseButton(e.closeButton,o),position:e.position||this.props.position,transition:e.transition||this.props.transition,pauseOnHover:null!==e.pauseOnHover?e.pauseOnHover:this.props.pauseOnHover,closeOnClick:null!==e.closeOnClick?e.closeOnClick:this.props.closeOnClick,className:e.className||this.props.toastClassName,bodyClassName:e.bodyClassName||this.props.bodyClassName,progressClassName:e.progressClassName||this.props.progressClassName};this.isFunction(e.onOpen)&&(a.onOpen=e.onOpen),this.isFunction(e.onClose)&&(a.onClose=e.onClose),a.autoClose=this.getAutoCloseDelay(!1!==e.autoClose?parseInt(e.autoClose,10):e.autoClose),a.hideProgressBar="boolean"==typeof e.hideProgressBar?e.hideProgressBar:this.props.hideProgressBar,a.closeToast=s,(0,p.isValidElement)(t)&&"String"!==(0,j.typeOf)(t.type)&&(t=this.with(t,{closeToast:s})),this.collection=c({},this.collection,i({},o,{content:this.makeToast(t,a),position:a.position})),this.setState({toast:[].concat(r(this.state.toast),[o])})}},{key:"makeToast",value:function(t,e){return d.default.createElement(b.default,c({},e,{key:"toast-"+e.id}),t)}},{key:"clear",value:function(){this.setState({toast:[]})}},{key:"hasToast",value:function(){return this.state.toast.length>0}},{key:"getContainerProps",value:function(t,e){var n={className:"toastify toastify--"+t,style:e?{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 t=this,e={};return(this.props.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(n){var o=t.collection[n];e[o.position]||(e[o.position]=[]),-1!==t.state.toast.indexOf(parseInt(n,10))?e[o.position].push(o.content):(e[o.position].push(null),delete t.collection[n])}),Object.keys(e).map(function(n){var o=1===e[n].length&&null===e[n][0];return d.default.createElement(v.default,c({},t.getContainerProps(n,o),{key:"container-"+n}),e[n])})}},{key:"render",value:function(){return d.default.createElement("div",null,this.renderToast())}}]),e}(p.Component);w.propTypes={position:y.default.oneOf((0,k.default)(x.default.POSITION)),autoClose:j.falseOrNumber,closeButton:j.falseOrElement,hideProgressBar:y.default.bool,pauseOnHover:y.default.bool,closeOnClick:y.default.bool,newestOnTop:y.default.bool,className:y.default.string,style:y.default.object,toastClassName:y.default.string,bodyClassName:y.default.string,progressClassName:y.default.string,transition:y.default.func},w.defaultProps={position:x.default.POSITION.TOP_RIGHT,transition:C.default,autoClose:5e3,hideProgressBar:!1,closeButton:d.default.createElement(g.default,null),pauseOnHover:!0,closeOnClick:!0,newestOnTop:!1,className:null,style:null,toastClassName:"",bodyClassName:"",progressClassName:""},e.default=w},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var u=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},l=n(1),c=o(l),f=n(0),p=o(f),d=n(9),h=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},y=(c.default.any,c.default.node,c.default.bool,c.default.bool,c.default.bool,c.default.func,{component:"div",childFactory:function(t){return t}}),m=function(t){function e(n,o){i(this,e);var r=s(this,t.call(this,n,o));return r.handleExited=function(t,e,n){var o=(0,d.getChildMapping)(r.props.children);t in o||(n&&n(e),r.setState(function(e){var n=u({},e.children);return delete n[t],{children:n}}))},r.state={children:(0,d.getChildMapping)(n.children,function(t){var e=function(e){r.handleExited(t.key,e,t.props.onExited)};return(0,f.cloneElement)(t,{onExited:e,in:!0,appear:r.getProp(t,"appear"),enter:r.getProp(t,"enter"),exit:r.getProp(t,"exit")})})},r}return a(e,t),e.prototype.getChildContext=function(){return{transitionGroup:{isMounting:!this.appeared}}},e.prototype.getProp=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props;return null!=n[e]?n[e]:t.props[e]},e.prototype.componentDidMount=function(){this.appeared=!0},e.prototype.componentWillReceiveProps=function(t){var e=this,n=this.state.children,o=(0,d.getChildMapping)(t.children),r=(0,d.mergeChildMappings)(n,o);Object.keys(r).forEach(function(i){var s=r[i];if((0,f.isValidElement)(s)){var a=function(t){e.handleExited(s.key,t,s.props.onExited)},u=i in n,l=i in o,c=n[i],p=(0,f.isValidElement)(c)&&!c.props.in;!l||u&&!p?l||!u||p?l&&u&&(0,f.isValidElement)(c)&&(r[i]=(0,f.cloneElement)(s,{onExited:a,in:c.props.in,exit:e.getProp(s,"exit",t),enter:e.getProp(s,"enter",t)})):r[i]=(0,f.cloneElement)(s,{in:!1}):r[i]=(0,f.cloneElement)(s,{onExited:a,in:!0,exit:e.getProp(s,"exit",t),enter:e.getProp(s,"enter",t)})}}),this.setState({children:r})},e.prototype.render=function(){var t=this.props,e=t.component,n=t.childFactory,o=r(t,["component","childFactory"]),i=this.state.children;return delete o.appear,delete o.enter,delete o.exit,p.default.createElement(e,o,h(i).map(n))},e}(p.default.Component);m.childContextTypes={transitionGroup:c.default.object.isRequired},m.propTypes={},m.defaultProps=y,e.default=m,t.exports=e.default},function(t,e,n){"use strict";function o(t,e){var n=function(t){return e&&(0,i.isValidElement)(t)?e(t):t},o=Object.create(null);return t&&i.Children.map(t,function(t){return t}).forEach(function(t){o[t.key]=n(t)}),o}function r(t,e){function n(n){return n in e?e[n]:t[n]}t=t||{},e=e||{};var o=Object.create(null),r=[];for(var i in t)i in e?r.length&&(o[i]=r,r=[]):r.push(i);var s=void 0,a={};for(var u in e){if(o[u])for(s=0;s<o[u].length;s++){var l=o[u][s];a[o[u][s]]=n(l)}a[u]=n(u)}for(s=0;s<r.length;s++)a[r[s]]=n(r[s]);return a}e.__esModule=!0,e.getChildMapping=o,e.mergeChildMappings=r;var i=n(0)},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),u=n(0),l=o(u),c=n(1),f=o(c),p=n(11),d=o(p),h=n(2),y=o(h),m=n(3),v=o(m),O=n(4),b=function(t){function e(t){r(this,e);var n=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.pauseToast=function(){n.setState({isRunning:!1})},n.playToast=function(){n.setState({isRunning:!0})},n.state={isRunning:!0},n}return s(e,t),a(e,[{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 t={className:"toastify-content toastify-content--"+this.props.type+" "+this.props.className};return!1!==this.props.autoClose&&!0===this.props.pauseOnHover&&(t.onMouseEnter=this.pauseToast,t.onMouseLeave=this.playToast),this.props.closeOnClick&&(t.onClick=this.props.closeToast),t}},{key:"render",value:function(){var t=this.props,e=t.closeButton,n=t.children,o=t.autoClose,r=t.type,i=t.hideProgressBar,s=t.closeToast,a=t.transition,u=t.position,c=t.onExited,f=a;return l.default.createElement(f,{in:this.props.in,appear:!0,unmountOnExit:!0,onExited:c,position:u},l.default.createElement("div",this.getToastProps(),l.default.createElement("div",{className:"toastify__body "+this.props.bodyClassName},n),!1!==e&&e,!1!==o&&l.default.createElement(d.default,{delay:o,isRunning:this.state.isRunning,closeToast:s,hide:i,type:r,className:this.props.progressClassName})))}}]),e}(u.Component);b.propTypes={closeButton:O.falseOrElement.isRequired,autoClose:O.falseOrNumber.isRequired,children:f.default.node.isRequired,closeToast:f.default.func.isRequired,position:f.default.oneOf((0,v.default)(y.default.POSITION)).isRequired,pauseOnHover:f.default.bool.isRequired,closeOnClick:f.default.bool.isRequired,transition:f.default.func.isRequired,in:f.default.bool,onExited:f.default.func,hideProgressBar:f.default.bool,onOpen:f.default.func,onClose:f.default.func,type:f.default.oneOf((0,v.default)(y.default.TYPE)),className:f.default.string,bodyClassName:f.default.string,progressClassName:f.default.string},b.defaultProps={type:y.default.TYPE.DEFAULT,in:!0,hideProgressBar:!1,onOpen:null,onClose:null,className:"",bodyClassName:"",progressClassName:""},e.default=b},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){var e=t.delay,n=t.isRunning,o=t.closeToast,r=t.type,i=t.hide,a=t.className,u={animationDuration:e+"ms",animationPlayState:n?"running":"paused"};return u.WebkitAnimationPlayState=u.animationPlayState,i&&(u.opacity=0),s.default.createElement("div",{className:"toastify__progress toastify__progress--"+r+" "+a,style:u,onAnimationEnd:o})}Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),s=o(i),a=n(1),u=o(a),l=n(2),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:""},e.default=r},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){var e=t.closeToast;return s.default.createElement("button",{className:"toastify__close",type:"button",onClick:e},"✖")}Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),s=o(i),a=n(1),u=o(a);r.propTypes={closeToast:u.default.func},e.default=r},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t){var e=t.children,n=t.position,o=r(t,["children","position"]);return u.default.createElement(c.default,s({},o,{timeout:750,onEnter:function(t){t.classList.add("toast-enter--"+n),t.classList.add("toastify-animated")},onExit:function(t){t.classList.remove("toast-enter--"+n),t.classList.remove("toastify-animated"),t.classList.add("toast-exit--"+n),t.classList.add("toastify-animated")}}),e)}Object.defineProperty(e,"__esModule",{value:!0});var 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},a=n(0),u=o(a),l=n(14),c=o(l);e.default=i},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(){}e.__esModule=!0,e.EXITING=e.ENTERED=e.ENTERING=e.EXITED=e.UNMOUNTED=void 0;var l=n(1),c=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(l),f=n(0),p=o(f),d=n(15),h=o(d),y=(n(16),e.UNMOUNTED="unmounted"),m=e.EXITED="exited",v=e.ENTERING="entering",O=e.ENTERED="entered",b=e.EXITING="exiting",E=function(t){function e(n,o){i(this,e);var r=s(this,t.call(this,n,o)),a=o.transitionGroup,u=a&&!a.isMounting?n.enter:n.appear,l=void 0;return r.nextStatus=null,n.in?u?(l=m,r.nextStatus=v):l=O:l=n.unmountOnExit||n.mountOnEnter?y:m,r.state={status:l},r.nextCallback=null,r}return a(e,t),e.prototype.getChildContext=function(){return{transitionGroup:null}},e.prototype.componentDidMount=function(){this.updateStatus(!0)},e.prototype.componentWillReceiveProps=function(t){var e=this.pendingState||this.state,n=e.status;t.in?(n===y&&this.setState({status:m}),n!==v&&n!==O&&(this.nextStatus=v)):n!==v&&n!==O||(this.nextStatus=b)},e.prototype.componentDidUpdate=function(){this.updateStatus()},e.prototype.componentWillUnmount=function(){this.cancelNextCallback()},e.prototype.getTimeouts=function(){var t=this.props.timeout,e=void 0,n=void 0,o=void 0;return e=n=o=t,null!=t&&"number"!=typeof t&&(e=t.exit,n=t.enter,o=t.appear),{exit:e,enter:n,appear:o}},e.prototype.updateStatus=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.nextStatus;if(null!==e){this.nextStatus=null,this.cancelNextCallback();var n=h.default.findDOMNode(this);e===v?this.performEnter(n,t):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===m&&this.setState({status:y})},e.prototype.performEnter=function(t,e){var n=this,o=this.props.enter,r=this.context.transitionGroup?this.context.transitionGroup.isMounting:e,i=this.getTimeouts();if(!e&&!o)return void this.safeSetState({status:O},function(){n.props.onEntered(t)});this.props.onEnter(t,r),this.safeSetState({status:v},function(){n.props.onEntering(t,r),n.onTransitionEnd(t,i.enter,function(){n.safeSetState({status:O},function(){n.props.onEntered(t,r)})})})},e.prototype.performExit=function(t){var e=this,n=this.props.exit,o=this.getTimeouts();if(!n)return void this.safeSetState({status:m},function(){e.props.onExited(t)});this.props.onExit(t),this.safeSetState({status:b},function(){e.props.onExiting(t),e.onTransitionEnd(t,o.exit,function(){e.safeSetState({status:m},function(){e.props.onExited(t)})})})},e.prototype.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},e.prototype.safeSetState=function(t,e){var n=this;this.pendingState=t,e=this.setNextCallback(e),this.setState(t,function(){n.pendingState=null,e()})},e.prototype.setNextCallback=function(t){var e=this,n=!0;return this.nextCallback=function(o){n&&(n=!1,e.nextCallback=null,t(o))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},e.prototype.onTransitionEnd=function(t,e,n){this.setNextCallback(n),t?(this.props.addEndListener&&this.props.addEndListener(t,this.nextCallback),null!=e&&setTimeout(this.nextCallback,e)):setTimeout(this.nextCallback,0)},e.prototype.render=function(){var t=this.state.status;if(t===y)return null;var e=this.props,n=e.children,o=r(e,["children"]);if(delete o.in,delete o.mountOnEnter,delete o.unmountOnExit,delete o.appear,delete o.enter,delete o.exit,delete o.timeout,delete o.addEndListener,delete o.onEnter,delete o.onEntering,delete o.onEntered,delete o.onExit,delete o.onExiting,delete o.onExited,"function"==typeof n)return n(t,o);var i=p.default.Children.only(n);return p.default.cloneElement(i,o)},e}(p.default.Component);E.contextTypes={transitionGroup:c.object},E.childContextTypes={transitionGroup:function(){}},E.propTypes={},E.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:u,onEntering:u,onEntered:u,onExit:u,onExiting:u,onExited:u},E.UNMOUNTED=0,E.EXITED=1,E.ENTERING=2,E.ENTERED=3,E.EXITING=4,e.default=E},function(t,e){t.exports=n},function(t,e,n){"use strict";function o(t){var e="transition"+t+"Timeout",n="transition"+t;return function(t){if(t[n]){if(null==t[e])return new Error(e+" wasn't supplied to CSSTransitionGroup: this can cause unreliable animations and won't be supported in a future version of React. See https://fb.me/react-animation-transition-group-timeout for more information.");if("number"!=typeof t[e])return new Error(e+" must be a number (in milliseconds)")}return null}}e.__esModule=!0,e.classNamesShape=e.timeoutsShape=void 0,e.transitionTimeout=o;var r=n(1),i=function(t){return t&&t.__esModule?t:{default:t}}(r);e.timeoutsShape=i.default.oneOfType([i.default.number,i.default.shape({enter:i.default.number,exit:i.default.number}).isRequired]),e.classNamesShape=i.default.oneOfType([i.default.string,i.default.shape({enter:i.default.string,exit:i.default.string,active:i.default.string}),i.default.shape({enter:i.default.string,enterActive:i.default.string,exit:i.default.string,exitActive:i.default.string})])},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){return s({},h,t,{toastId:++v})}function i(t,e){return null!==y?u.default.emit(d.SHOW,t,e):m.push({action:d.SHOW,content:t,options:e}),e.toastId}Object.defineProperty(e,"__esModule",{value:!0});var 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},a=n(5),u=o(a),l=n(2),c=o(l),f=c.default.POSITION,p=c.default.TYPE,d=c.default.ACTION,h={type:p.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null,position:null,pauseOnHover:null,closeOnClick:null,className:null,bodyClassName:null,progressClassName:null,tansition:null},y=null,m=[],v=0,O=s(function(t,e){return i(t,r(e))},{success:function(t,e){return i(t,s(r(e),{type:p.SUCCESS}))},info:function(t,e){return i(t,s(r(e),{type:p.INFO}))},warn:function(t,e){return i(t,s(r(e),{type:p.WARNING}))},warning:function(t,e){return i(t,s(r(e),{type:p.WARNING}))},error:function(t,e){return i(t,s(r(e),{type:p.ERROR}))},dismiss:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return u.default.emit(d.CLEAR,t)},isActive:function(){return!1}},{POSITION:f,TYPE:p});u.default.on(d.MOUNTED,function(t){y=t,O.isActive=function(t){return y.isToastActive(t)},m.forEach(function(t){u.default.emit(t.action,t.content,t.options)}),m=[]}),e.default=O}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","prop-types","react-dom"],e):"object"==typeof exports?exports.ReactToastify=e(require("react"),require("prop-types"),require("react-dom")):t.ReactToastify=e(t.react,t["prop-types"],t["react-dom"])}(this,function(t,e,n){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=6)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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"},e.TYPE={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},e.ACTION={SHOW:"SHOW_TOAST",CLEAR:"CLEAR_TOAST",MOUNTED:"CONTAINER_MOUNTED"}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=[];return Object.keys(t).forEach(function(n){return e.push(t[n])}),e}},function(t,e,n){"use strict";function o(t){return Object.prototype.toString.call(t).slice(8,-1)}function r(t){return"Number"===o(t)&&!isNaN(t)&&t>0}function i(t){return t.isRequired=function(e,n,o){if(void 0===e[n])return new Error("The prop "+n+" is marked as required in \n "+o+", but its value is undefined.");t(e,n,o)},t}Object.defineProperty(e,"__esModule",{value:!0}),e.falseOrElement=e.falseOrNumber=void 0,e.typeOf=o,e.isValidDelay=r;var s=n(0);e.falseOrNumber=i(function(t,e,n){var o=t[e];return!1===o||r(o)?null:new Error(n+" expect "+e+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),e.falseOrElement=i(function(t,e,n){var o=t[e];return!1===o||(0,s.isValidElement)(o)?null:new Error(n+" expect "+e+" \n to be a valid react element or equal to false. "+o+" given.")})},function(t,e,n){"use strict";function o(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}Object.defineProperty(e,"__esModule",{value:!0});var r={eventList:new Map,on:function(t,e){return this.eventList.has(t)||this.eventList.set(t,[]),this.eventList.get(t).push(e),this},off:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.eventList.delete(t)},emit:function(t){for(var e=this,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return this.eventList.has(t)?(this.eventList.get(t).forEach(function(t){return setTimeout(function(){return t.call.apply(t,[e].concat(o(r)))},0)}),!0):(console.warn("<"+t+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};e.default=r},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.toast=e.ToastContainer=void 0;var r=n(7),i=o(r),s=n(17),a=o(s);e.ToastContainer=i.default,e.toast=a.default},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c=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},p=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),f=n(0),d=o(f),h=n(1),y=o(h),m=n(8),v=o(m),O=n(10),b=o(O),E=n(12),g=o(E),T=n(13),C=o(T),N=n(2),x=n(5),_=o(x),P=n(3),S=o(P),k=n(4),j=function(t){function e(){var t,n,o,r;s(this,e);for(var i=arguments.length,u=Array(i),l=0;l<i;l++)u[l]=arguments[l];return n=o=a(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(u))),o.state={toast:[]},o.collection={},o.isToastActive=function(t){return-1!==o.state.toast.indexOf(parseInt(t,10))},r=n,a(o,r)}return u(e,t),p(e,[{key:"componentDidMount",value:function(){var t=this,e=N.ACTION.SHOW,n=N.ACTION.CLEAR,o=N.ACTION.MOUNTED;_.default.on(e,function(e,n){return t.show(e,n)}).on(n,function(e){return null!==e?t.removeToast(e):t.clear()}).emit(o,this)}},{key:"componentWillUnmount",value:function(){_.default.off(N.ACTION.SHOW),_.default.off(N.ACTION.CLEAR)}},{key:"removeToast",value:function(t){this.setState({toast:this.state.toast.filter(function(e){return e!==parseInt(t,10)})})}},{key:"with",value:function(t,e){return(0,f.cloneElement)(t,c({},e,t.props))}},{key:"makeCloseButton",value:function(t,e){var n=this,o=this.props.closeButton;return((0,f.isValidElement)(t)||!1===t)&&(o=t),!1!==o&&this.with(o,{closeToast:function(){return n.removeToast(e)}})}},{key:"getAutoCloseDelay",value:function(t){return!1===t||(0,k.isValidDelay)(t)?t:this.props.autoClose}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{key:"canBeRendered",value:function(t){return(0,f.isValidElement)(t)||"String"===(0,k.typeOf)(t)||"Number"===(0,k.typeOf)(t)}},{key:"show",value:function(t,e){var n=this;if(!this.canBeRendered(t))throw new Error("The element you provided cannot be rendered. You provided an element of type "+(void 0===t?"undefined":l(t)));var o=e.toastId,s=function(){return n.removeToast(o)},a={id:o,type:e.type,closeButton:this.makeCloseButton(e.closeButton,o),position:e.position||this.props.position,transition:e.transition||this.props.transition,pauseOnHover:null!==e.pauseOnHover?e.pauseOnHover:this.props.pauseOnHover,closeOnClick:null!==e.closeOnClick?e.closeOnClick:this.props.closeOnClick,className:e.className||this.props.toastClassName,bodyClassName:e.bodyClassName||this.props.bodyClassName,progressClassName:e.progressClassName||this.props.progressClassName};this.isFunction(e.onOpen)&&(a.onOpen=e.onOpen),this.isFunction(e.onClose)&&(a.onClose=e.onClose),a.autoClose=this.getAutoCloseDelay(!1!==e.autoClose?parseInt(e.autoClose,10):e.autoClose),a.hideProgressBar="boolean"==typeof e.hideProgressBar?e.hideProgressBar:this.props.hideProgressBar,a.closeToast=s,(0,f.isValidElement)(t)&&"String"!==(0,k.typeOf)(t.type)&&(t=this.with(t,{closeToast:s})),this.collection=c({},this.collection,i({},o,{content:this.makeToast(t,a),position:a.position})),this.setState({toast:[].concat(r(this.state.toast),[o])})}},{key:"makeToast",value:function(t,e){return d.default.createElement(b.default,c({},e,{key:"toast-"+e.id}),t)}},{key:"clear",value:function(){this.setState({toast:[]})}},{key:"hasToast",value:function(){return this.state.toast.length>0}},{key:"getContainerProps",value:function(t,e){var n={className:"toastify toastify--"+t,style:e?{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 t=this,e={};return(this.props.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(n){var o=t.collection[n];e[o.position]||(e[o.position]=[]),-1!==t.state.toast.indexOf(parseInt(n,10))?e[o.position].push(o.content):(e[o.position].push(null),delete t.collection[n])}),Object.keys(e).map(function(n){var o=1===e[n].length&&null===e[n][0];return d.default.createElement(v.default,c({},t.getContainerProps(n,o),{key:"container-"+n}),e[n])})}},{key:"render",value:function(){return d.default.createElement("div",null,this.renderToast())}}]),e}(f.Component);j.propTypes={position:y.default.oneOf((0,S.default)(N.POSITION)),autoClose:k.falseOrNumber,closeButton:k.falseOrElement,hideProgressBar:y.default.bool,pauseOnHover:y.default.bool,closeOnClick:y.default.bool,newestOnTop:y.default.bool,className:y.default.string,style:y.default.object,toastClassName:y.default.string,bodyClassName:y.default.string,progressClassName:y.default.string,transition:y.default.func},j.defaultProps={position:N.POSITION.TOP_RIGHT,transition:C.default,autoClose:5e3,hideProgressBar:!1,closeButton:d.default.createElement(g.default,null),pauseOnHover:!0,closeOnClick:!0,newestOnTop:!1,className:null,style:null,toastClassName:"",bodyClassName:"",progressClassName:""},e.default=j},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var u=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},l=n(1),c=o(l),p=n(0),f=o(p),d=n(9),h=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},y=(c.default.any,c.default.node,c.default.bool,c.default.bool,c.default.bool,c.default.func,{component:"div",childFactory:function(t){return t}}),m=function(t){function e(n,o){i(this,e);var r=s(this,t.call(this,n,o));return r.handleExited=function(t,e,n){var o=(0,d.getChildMapping)(r.props.children);t in o||(n&&n(e),r.setState(function(e){var n=u({},e.children);return delete n[t],{children:n}}))},r.state={children:(0,d.getChildMapping)(n.children,function(t){var e=function(e){r.handleExited(t.key,e,t.props.onExited)};return(0,p.cloneElement)(t,{onExited:e,in:!0,appear:r.getProp(t,"appear"),enter:r.getProp(t,"enter"),exit:r.getProp(t,"exit")})})},r}return a(e,t),e.prototype.getChildContext=function(){return{transitionGroup:{isMounting:!this.appeared}}},e.prototype.getProp=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props;return null!=n[e]?n[e]:t.props[e]},e.prototype.componentDidMount=function(){this.appeared=!0},e.prototype.componentWillReceiveProps=function(t){var e=this,n=this.state.children,o=(0,d.getChildMapping)(t.children),r=(0,d.mergeChildMappings)(n,o);Object.keys(r).forEach(function(i){var s=r[i];if((0,p.isValidElement)(s)){var a=function(t){e.handleExited(s.key,t,s.props.onExited)},u=i in n,l=i in o,c=n[i],f=(0,p.isValidElement)(c)&&!c.props.in;!l||u&&!f?l||!u||f?l&&u&&(0,p.isValidElement)(c)&&(r[i]=(0,p.cloneElement)(s,{onExited:a,in:c.props.in,exit:e.getProp(s,"exit",t),enter:e.getProp(s,"enter",t)})):r[i]=(0,p.cloneElement)(s,{in:!1}):r[i]=(0,p.cloneElement)(s,{onExited:a,in:!0,exit:e.getProp(s,"exit",t),enter:e.getProp(s,"enter",t)})}}),this.setState({children:r})},e.prototype.render=function(){var t=this.props,e=t.component,n=t.childFactory,o=r(t,["component","childFactory"]),i=this.state.children;return delete o.appear,delete o.enter,delete o.exit,f.default.createElement(e,o,h(i).map(n))},e}(f.default.Component);m.childContextTypes={transitionGroup:c.default.object.isRequired},m.propTypes={},m.defaultProps=y,e.default=m,t.exports=e.default},function(t,e,n){"use strict";function o(t,e){var n=function(t){return e&&(0,i.isValidElement)(t)?e(t):t},o=Object.create(null);return t&&i.Children.map(t,function(t){return t}).forEach(function(t){o[t.key]=n(t)}),o}function r(t,e){function n(n){return n in e?e[n]:t[n]}t=t||{},e=e||{};var o=Object.create(null),r=[];for(var i in t)i in e?r.length&&(o[i]=r,r=[]):r.push(i);var s=void 0,a={};for(var u in e){if(o[u])for(s=0;s<o[u].length;s++){var l=o[u][s];a[o[u][s]]=n(l)}a[u]=n(u)}for(s=0;s<r.length;s++)a[r[s]]=n(r[s]);return a}e.__esModule=!0,e.getChildMapping=o,e.mergeChildMappings=r;var i=n(0)},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),u=n(0),l=o(u),c=n(1),p=o(c),f=n(11),d=o(f),h=n(2),y=n(3),m=o(y),v=n(4),O=function(t){function e(){var t,n,o,s;r(this,e);for(var a=arguments.length,u=Array(a),l=0;l<a;l++)u[l]=arguments[l];return n=o=i(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(u))),o.state={isRunning:!0},o.handleVisibility=function(){return o.setState({isRunning:!document.hidden})},o.pauseToast=function(){o.setState({isRunning:!1})},o.playToast=function(){o.setState({isRunning:!0})},s=n,i(o,s)}return s(e,t),a(e,[{key:"componentDidMount",value:function(){null!==this.props.onOpen&&this.props.onOpen(this.getChildrenProps()),document.addEventListener("visibilitychange",this.handleVisibility)}},{key:"componentWillUnmount",value:function(){null!==this.props.onClose&&this.props.onClose(this.getChildrenProps()),document.removeEventListener("visibilitychange",this.handleVisibility)}},{key:"getChildrenProps",value:function(){return this.props.children.props}},{key:"getToastProps",value:function(){var t={className:"toastify-content toastify-content--"+this.props.type+" "+this.props.className};return!1!==this.props.autoClose&&!0===this.props.pauseOnHover&&(t.onMouseEnter=this.pauseToast,t.onMouseLeave=this.playToast),this.props.closeOnClick&&(t.onClick=this.props.closeToast),t}},{key:"render",value:function(){var t=this.props,e=t.closeButton,n=t.children,o=t.autoClose,r=t.type,i=t.hideProgressBar,s=t.closeToast,a=t.transition,u=t.position,c=t.onExited,p=a;return l.default.createElement(p,{in:this.props.in,appear:!0,unmountOnExit:!0,onExited:c,position:u},l.default.createElement("div",this.getToastProps(),l.default.createElement("div",{className:"toastify__body "+this.props.bodyClassName},n),!1!==e&&e,!1!==o&&l.default.createElement(d.default,{delay:o,isRunning:this.state.isRunning,closeToast:s,hide:i,type:r,className:this.props.progressClassName})))}}]),e}(u.Component);O.propTypes={closeButton:v.falseOrElement.isRequired,autoClose:v.falseOrNumber.isRequired,children:p.default.node.isRequired,closeToast:p.default.func.isRequired,position:p.default.oneOf((0,m.default)(h.POSITION)).isRequired,pauseOnHover:p.default.bool.isRequired,closeOnClick:p.default.bool.isRequired,transition:p.default.func.isRequired,in:p.default.bool,onExited:p.default.func,hideProgressBar:p.default.bool,onOpen:p.default.func,onClose:p.default.func,type:p.default.oneOf((0,m.default)(h.TYPE)),className:p.default.string,bodyClassName:p.default.string,progressClassName:p.default.string},O.defaultProps={type:h.TYPE.DEFAULT,in:!0,hideProgressBar:!1,onOpen:null,onClose:null,className:"",bodyClassName:"",progressClassName:""},e.default=O},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){var e=t.delay,n=t.isRunning,o=t.closeToast,r=t.type,i=t.hide,a=t.className,u={animationDuration:e+"ms",animationPlayState:n?"running":"paused"};return u.WebkitAnimationPlayState=u.animationPlayState,i&&(u.opacity=0),s.default.createElement("div",{className:"toastify__progress toastify__progress--"+r+" "+a,style:u,onAnimationEnd:o})}Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),s=o(i),a=n(1),u=o(a),l=n(2);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:l.TYPE.DEFAULT,hide:!1,className:""},e.default=r},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){var e=t.closeToast;return s.default.createElement("button",{className:"toastify__close",type:"button",onClick:e},"✖")}Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),s=o(i),a=n(1),u=o(a);r.propTypes={closeToast:u.default.func},e.default=r},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t){var e=t.children,n=t.position,o=r(t,["children","position"]);return u.default.createElement(c.default,s({},o,{timeout:750,onEnter:function(t){t.classList.add("toast-enter--"+n),t.classList.add("toastify-animated")},onExit:function(t){t.classList.remove("toast-enter--"+n),t.classList.remove("toastify-animated"),t.classList.add("toast-exit--"+n),t.classList.add("toastify-animated")}}),e)}Object.defineProperty(e,"__esModule",{value:!0});var 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},a=n(0),u=o(a),l=n(14),c=o(l);e.default=i},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(){}e.__esModule=!0,e.EXITING=e.ENTERED=e.ENTERING=e.EXITED=e.UNMOUNTED=void 0;var l=n(1),c=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(l),p=n(0),f=o(p),d=n(15),h=o(d),y=(n(16),e.UNMOUNTED="unmounted"),m=e.EXITED="exited",v=e.ENTERING="entering",O=e.ENTERED="entered",b=e.EXITING="exiting",E=function(t){function e(n,o){i(this,e);var r=s(this,t.call(this,n,o)),a=o.transitionGroup,u=a&&!a.isMounting?n.enter:n.appear,l=void 0;return r.nextStatus=null,n.in?u?(l=m,r.nextStatus=v):l=O:l=n.unmountOnExit||n.mountOnEnter?y:m,r.state={status:l},r.nextCallback=null,r}return a(e,t),e.prototype.getChildContext=function(){return{transitionGroup:null}},e.prototype.componentDidMount=function(){this.updateStatus(!0)},e.prototype.componentWillReceiveProps=function(t){var e=this.pendingState||this.state,n=e.status;t.in?(n===y&&this.setState({status:m}),n!==v&&n!==O&&(this.nextStatus=v)):n!==v&&n!==O||(this.nextStatus=b)},e.prototype.componentDidUpdate=function(){this.updateStatus()},e.prototype.componentWillUnmount=function(){this.cancelNextCallback()},e.prototype.getTimeouts=function(){var t=this.props.timeout,e=void 0,n=void 0,o=void 0;return e=n=o=t,null!=t&&"number"!=typeof t&&(e=t.exit,n=t.enter,o=t.appear),{exit:e,enter:n,appear:o}},e.prototype.updateStatus=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.nextStatus;if(null!==e){this.nextStatus=null,this.cancelNextCallback();var n=h.default.findDOMNode(this);e===v?this.performEnter(n,t):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===m&&this.setState({status:y})},e.prototype.performEnter=function(t,e){var n=this,o=this.props.enter,r=this.context.transitionGroup?this.context.transitionGroup.isMounting:e,i=this.getTimeouts();if(!e&&!o)return void this.safeSetState({status:O},function(){n.props.onEntered(t)});this.props.onEnter(t,r),this.safeSetState({status:v},function(){n.props.onEntering(t,r),n.onTransitionEnd(t,i.enter,function(){n.safeSetState({status:O},function(){n.props.onEntered(t,r)})})})},e.prototype.performExit=function(t){var e=this,n=this.props.exit,o=this.getTimeouts();if(!n)return void this.safeSetState({status:m},function(){e.props.onExited(t)});this.props.onExit(t),this.safeSetState({status:b},function(){e.props.onExiting(t),e.onTransitionEnd(t,o.exit,function(){e.safeSetState({status:m},function(){e.props.onExited(t)})})})},e.prototype.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},e.prototype.safeSetState=function(t,e){var n=this;this.pendingState=t,e=this.setNextCallback(e),this.setState(t,function(){n.pendingState=null,e()})},e.prototype.setNextCallback=function(t){var e=this,n=!0;return this.nextCallback=function(o){n&&(n=!1,e.nextCallback=null,t(o))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},e.prototype.onTransitionEnd=function(t,e,n){this.setNextCallback(n),t?(this.props.addEndListener&&this.props.addEndListener(t,this.nextCallback),null!=e&&setTimeout(this.nextCallback,e)):setTimeout(this.nextCallback,0)},e.prototype.render=function(){var t=this.state.status;if(t===y)return null;var e=this.props,n=e.children,o=r(e,["children"]);if(delete o.in,delete o.mountOnEnter,delete o.unmountOnExit,delete o.appear,delete o.enter,delete o.exit,delete o.timeout,delete o.addEndListener,delete o.onEnter,delete o.onEntering,delete o.onEntered,delete o.onExit,delete o.onExiting,delete o.onExited,"function"==typeof n)return n(t,o);var i=f.default.Children.only(n);return f.default.cloneElement(i,o)},e}(f.default.Component);E.contextTypes={transitionGroup:c.object},E.childContextTypes={transitionGroup:function(){}},E.propTypes={},E.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:u,onEntering:u,onEntered:u,onExit:u,onExiting:u,onExited:u},E.UNMOUNTED=0,E.EXITED=1,E.ENTERING=2,E.ENTERED=3,E.EXITING=4,e.default=E},function(t,e){t.exports=n},function(t,e,n){"use strict";function o(t){var e="transition"+t+"Timeout",n="transition"+t;return function(t){if(t[n]){if(null==t[e])return new Error(e+" wasn't supplied to CSSTransitionGroup: this can cause unreliable animations and won't be supported in a future version of React. See https://fb.me/react-animation-transition-group-timeout for more information.");if("number"!=typeof t[e])return new Error(e+" must be a number (in milliseconds)")}return null}}e.__esModule=!0,e.classNamesShape=e.timeoutsShape=void 0,e.transitionTimeout=o;var r=n(1),i=function(t){return t&&t.__esModule?t:{default:t}}(r);e.timeoutsShape=i.default.oneOfType([i.default.number,i.default.shape({enter:i.default.number,exit:i.default.number}).isRequired]),e.classNamesShape=i.default.oneOfType([i.default.string,i.default.shape({enter:i.default.string,exit:i.default.string,active:i.default.string}),i.default.shape({enter:i.default.string,enterActive:i.default.string,exit:i.default.string,exitActive:i.default.string})])},function(t,e,n){"use strict";function o(t){return i({},l,t,{toastId:++f})}function r(t,e){return null!==c?a.default.emit(u.ACTION.SHOW,t,e):p.push({action:u.ACTION.SHOW,content:t,options:e}),e.toastId}Object.defineProperty(e,"__esModule",{value:!0});var i=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},s=n(5),a=function(t){return t&&t.__esModule?t:{default:t}}(s),u=n(2),l={type:u.TYPE.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null,position:null,pauseOnHover:null,closeOnClick:null,className:null,bodyClassName:null,progressClassName:null,tansition:null},c=null,p=[],f=0,d=i(function(t,e){return r(t,o(e))},{success:function(t,e){return r(t,i(o(e),{type:u.TYPE.SUCCESS}))},info:function(t,e){return r(t,i(o(e),{type:u.TYPE.INFO}))},warn:function(t,e){return r(t,i(o(e),{type:u.TYPE.WARNING}))},warning:function(t,e){return r(t,i(o(e),{type:u.TYPE.WARNING}))},error:function(t,e){return r(t,i(o(e),{type:u.TYPE.ERROR}))},dismiss:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return a.default.emit(u.ACTION.CLEAR,t)},isActive:function(){return!1}},{POSITION:u.POSITION,TYPE:u.TYPE});a.default.on(u.ACTION.MOUNTED,function(t){c=t,d.isActive=function(t){return c.isToastActive(t)},p.forEach(function(t){a.default.emit(t.action,t.content,t.options)}),p=[]}),e.default=d}])}); | ||
//# sourceMappingURL=ReactToastify.min.js.map |
@@ -15,6 +15,4 @@ 'use strict'; | ||
var _config = require('./config'); | ||
var _constant = require('./constant'); | ||
var _config2 = _interopRequireDefault(_config); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -80,3 +78,3 @@ | ||
ProgressBar.defaultProps = { | ||
type: _config2.default.TYPE.DEFAULT, | ||
type: _constant.TYPE.DEFAULT, | ||
hide: false, | ||
@@ -83,0 +81,0 @@ className: '' |
@@ -21,6 +21,4 @@ "use strict"; | ||
var _config = require("./config"); | ||
var _constant = require("./constant"); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _objectValues = require("./util/objectValues"); | ||
@@ -43,19 +41,22 @@ | ||
function Toast(props) { | ||
function Toast() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, Toast); | ||
var _this = _possibleConstructorReturn(this, (Toast.__proto__ || Object.getPrototypeOf(Toast)).call(this, props)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.pauseToast = function () { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Toast.__proto__ || Object.getPrototypeOf(Toast)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
isRunning: true | ||
}, _this.handleVisibility = function () { | ||
return _this.setState({ isRunning: !document.hidden }); | ||
}, _this.pauseToast = function () { | ||
_this.setState({ isRunning: false }); | ||
}; | ||
_this.playToast = function () { | ||
}, _this.playToast = function () { | ||
_this.setState({ isRunning: true }); | ||
}; | ||
_this.state = { | ||
isRunning: true | ||
}; | ||
return _this; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
@@ -67,2 +68,3 @@ | ||
this.props.onOpen !== null && this.props.onOpen(this.getChildrenProps()); | ||
document.addEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
@@ -73,2 +75,3 @@ }, { | ||
this.props.onClose !== null && this.props.onClose(this.getChildrenProps()); | ||
document.removeEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
@@ -146,3 +149,3 @@ }, { | ||
closeToast: _propTypes2.default.func.isRequired, | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_config2.default.POSITION)).isRequired, | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_constant.POSITION)).isRequired, | ||
pauseOnHover: _propTypes2.default.bool.isRequired, | ||
@@ -156,3 +159,3 @@ closeOnClick: _propTypes2.default.bool.isRequired, | ||
onClose: _propTypes2.default.func, | ||
type: _propTypes2.default.oneOf((0, _objectValues2.default)(_config2.default.TYPE)), | ||
type: _propTypes2.default.oneOf((0, _objectValues2.default)(_constant.TYPE)), | ||
className: _propTypes2.default.string, | ||
@@ -163,3 +166,3 @@ bodyClassName: _propTypes2.default.string, | ||
Toast.defaultProps = { | ||
type: _config2.default.TYPE.DEFAULT, | ||
type: _constant.TYPE.DEFAULT, | ||
in: true, | ||
@@ -166,0 +169,0 @@ hideProgressBar: false, |
@@ -37,6 +37,4 @@ "use strict"; | ||
var _config = require("./config"); | ||
var _constant = require("./constant"); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _EventManager = require("./util/EventManager"); | ||
@@ -67,16 +65,18 @@ | ||
function ToastContainer(props) { | ||
function ToastContainer() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, ToastContainer); | ||
var _this = _possibleConstructorReturn(this, (ToastContainer.__proto__ || Object.getPrototypeOf(ToastContainer)).call(this, props)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.isToastActive = function (id) { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ToastContainer.__proto__ || Object.getPrototypeOf(ToastContainer)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
toast: [] | ||
}, _this.collection = {}, _this.isToastActive = function (id) { | ||
return _this.state.toast.indexOf(parseInt(id, 10)) !== -1; | ||
}; | ||
_this.state = { | ||
toast: [] | ||
}; | ||
_this.collection = {}; | ||
return _this; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
@@ -89,6 +89,5 @@ | ||
var _config$ACTION = _config2.default.ACTION, | ||
SHOW = _config$ACTION.SHOW, | ||
CLEAR = _config$ACTION.CLEAR, | ||
MOUNTED = _config$ACTION.MOUNTED; | ||
var SHOW = _constant.ACTION.SHOW, | ||
CLEAR = _constant.ACTION.CLEAR, | ||
MOUNTED = _constant.ACTION.MOUNTED; | ||
@@ -104,4 +103,4 @@ _EventManager2.default.on(SHOW, function (content, options) { | ||
value: function componentWillUnmount() { | ||
_EventManager2.default.off(_config2.default.ACTION.SHOW); | ||
_EventManager2.default.off(_config2.default.ACTION.CLEAR); | ||
_EventManager2.default.off(_constant.ACTION.SHOW); | ||
_EventManager2.default.off(_constant.ACTION.CLEAR); | ||
} | ||
@@ -291,3 +290,3 @@ }, { | ||
*/ | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_config2.default.POSITION)), | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_constant.POSITION)), | ||
@@ -355,3 +354,3 @@ /** | ||
ToastContainer.defaultProps = { | ||
position: _config2.default.POSITION.TOP_RIGHT, | ||
position: _constant.POSITION.TOP_RIGHT, | ||
transition: _DefaultTransition2.default, | ||
@@ -358,0 +357,0 @@ autoClose: 5000, |
@@ -19,15 +19,8 @@ 'use strict'; | ||
var _config = require('./config'); | ||
var _constant = require('./constant'); | ||
var _config2 = _interopRequireDefault(_config); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var POSITION = _config2.default.POSITION, | ||
TYPE = _config2.default.TYPE, | ||
ACTION = _config2.default.ACTION; | ||
var defaultOptions = { | ||
type: TYPE.DEFAULT, | ||
type: _constant.TYPE.DEFAULT, | ||
autoClose: null, | ||
@@ -64,5 +57,5 @@ closeButton: null, | ||
if (container !== null) { | ||
_EventManager2.default.emit(ACTION.SHOW, content, options); | ||
_EventManager2.default.emit(_constant.ACTION.SHOW, content, options); | ||
} else { | ||
queue.push({ action: ACTION.SHOW, content: content, options: options }); | ||
queue.push({ action: _constant.ACTION.SHOW, content: content, options: options }); | ||
} | ||
@@ -77,19 +70,19 @@ | ||
success: function success(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.SUCCESS })); | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.SUCCESS })); | ||
}, | ||
info: function info(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.INFO })); | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.INFO })); | ||
}, | ||
warn: function warn(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.WARNING })); | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.WARNING })); | ||
}, | ||
warning: function warning(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.WARNING })); | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.WARNING })); | ||
}, | ||
error: function error(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: TYPE.ERROR })); | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.ERROR })); | ||
}, | ||
dismiss: function dismiss() { | ||
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; | ||
return _EventManager2.default.emit(ACTION.CLEAR, id); | ||
return _EventManager2.default.emit(_constant.ACTION.CLEAR, id); | ||
}, | ||
@@ -100,4 +93,4 @@ isActive: function isActive() { | ||
}, { | ||
POSITION: POSITION, | ||
TYPE: TYPE | ||
POSITION: _constant.POSITION, | ||
TYPE: _constant.TYPE | ||
}); | ||
@@ -109,3 +102,3 @@ | ||
*/ | ||
_EventManager2.default.on(ACTION.MOUNTED, function (containerInstance) { | ||
_EventManager2.default.on(_constant.ACTION.MOUNTED, function (containerInstance) { | ||
container = containerInstance; | ||
@@ -112,0 +105,0 @@ |
{ | ||
"name": "react-toastify", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "React notification made easy", | ||
@@ -15,2 +15,3 @@ "keywords": [ | ||
"main": "lib/index.js", | ||
"typings": "./index.d.ts", | ||
"scripts": { | ||
@@ -17,0 +18,0 @@ "test": "jest", |
@@ -6,3 +6,3 @@ # React Toastify [![Build Status](https://travis-ci.org/fkhadra/react-toastify.svg?branch=master)](https://travis-ci.org/fkhadra/react-toastify) [![npm](https://img.shields.io/npm/dm/react-toastify.svg)]() [![npm](https://img.shields.io/npm/v/react-toastify.svg)]() [![license](https://img.shields.io/github/license/fkhadra/react-toastify.svg?maxAge=2592000)]() | ||
React-Toastify allow you to add notification to your app with ease. | ||
🎉 React-Toastify allow you to add notification to your app with ease. No bullshit ! | ||
@@ -509,2 +509,7 @@ * [Demo](#demo) | ||
### V2.1.3 | ||
- Added typescript definition | ||
- Toast will pause when page is not visible thanks to page visibility api. | ||
### V2.1.2 | ||
@@ -652,3 +657,3 @@ | ||
Any suggestions and pull request are welcome ! | ||
Show your 😻 and support by giving a ⭐. Any suggestions and pull request are welcome ! | ||
@@ -655,0 +660,0 @@ ## License |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import config from './config'; | ||
import { TYPE } from './constant'; | ||
@@ -59,3 +59,3 @@ function ProgressBar({ delay, isRunning, closeToast, type, hide, className }) { | ||
ProgressBar.defaultProps = { | ||
type: config.TYPE.DEFAULT, | ||
type: TYPE.DEFAULT, | ||
hide: false, | ||
@@ -62,0 +62,0 @@ className: '' |
@@ -5,3 +5,3 @@ import React, { Component } from "react"; | ||
import ProgressBar from "./ProgressBar"; | ||
import config from "./config"; | ||
import { POSITION, TYPE } from "./constant"; | ||
import objectValues from "./util/objectValues"; | ||
@@ -16,3 +16,3 @@ import { falseOrElement, falseOrNumber } from "./util/propValidator"; | ||
closeToast: PropTypes.func.isRequired, | ||
position: PropTypes.oneOf(objectValues(config.POSITION)).isRequired, | ||
position: PropTypes.oneOf(objectValues(POSITION)).isRequired, | ||
pauseOnHover: PropTypes.bool.isRequired, | ||
@@ -26,3 +26,3 @@ closeOnClick: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func, | ||
type: PropTypes.oneOf(objectValues(config.TYPE)), | ||
type: PropTypes.oneOf(objectValues(TYPE)), | ||
className: PropTypes.string, | ||
@@ -34,3 +34,3 @@ bodyClassName: PropTypes.string, | ||
static defaultProps = { | ||
type: config.TYPE.DEFAULT, | ||
type: TYPE.DEFAULT, | ||
in: true, | ||
@@ -45,11 +45,9 @@ hideProgressBar: false, | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
isRunning: true | ||
}; | ||
} | ||
state = { | ||
isRunning: true | ||
}; | ||
componentDidMount() { | ||
this.props.onOpen !== null && this.props.onOpen(this.getChildrenProps()); | ||
document.addEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
@@ -59,4 +57,7 @@ | ||
this.props.onClose !== null && this.props.onClose(this.getChildrenProps()); | ||
document.removeEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
handleVisibility = () => this.setState({ isRunning: !document.hidden }); | ||
getChildrenProps() { | ||
@@ -63,0 +64,0 @@ return this.props.children.props; |
@@ -8,3 +8,3 @@ import React, { Component, isValidElement, cloneElement } from "react"; | ||
import DefaultTransition from "./DefaultTransition"; | ||
import config from "./config"; | ||
import { POSITION, ACTION } from "./constant"; | ||
import EventManager from "./util/EventManager"; | ||
@@ -24,3 +24,3 @@ import objectValues from "./util/objectValues"; | ||
*/ | ||
position: PropTypes.oneOf(objectValues(config.POSITION)), | ||
position: PropTypes.oneOf(objectValues(POSITION)), | ||
@@ -89,3 +89,3 @@ /** | ||
static defaultProps = { | ||
position: config.POSITION.TOP_RIGHT, | ||
position: POSITION.TOP_RIGHT, | ||
transition: DefaultTransition, | ||
@@ -105,12 +105,10 @@ autoClose: 5000, | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
toast: [] | ||
}; | ||
this.collection = {}; | ||
} | ||
state = { | ||
toast: [] | ||
}; | ||
collection = {}; | ||
componentDidMount() { | ||
const { SHOW, CLEAR, MOUNTED } = config.ACTION; | ||
const { SHOW, CLEAR, MOUNTED } = ACTION; | ||
EventManager | ||
@@ -123,4 +121,4 @@ .on(SHOW, (content, options) => this.show(content, options)) | ||
componentWillUnmount() { | ||
EventManager.off(config.ACTION.SHOW); | ||
EventManager.off(config.ACTION.CLEAR); | ||
EventManager.off(ACTION.SHOW); | ||
EventManager.off(ACTION.CLEAR); | ||
} | ||
@@ -127,0 +125,0 @@ |
@@ -8,6 +8,4 @@ /* | ||
import EventManager from './util/EventManager'; | ||
import config from './config'; | ||
import { POSITION, TYPE, ACTION } from './constant'; | ||
const { POSITION, TYPE, ACTION } = config; | ||
const defaultOptions = { | ||
@@ -14,0 +12,0 @@ type: TYPE.DEFAULT, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
482943
43
1748
660