react-toastify
Advanced tools
Comparing version 4.4.3 to 4.5.0-rc.1
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("prop-types"),require("react"),require("classnames"),require("react-dom")):"function"==typeof define&&define.amd?define(["prop-types","react","classnames","react-dom"],e):"object"==typeof exports?exports.ReactToastify=e(require("prop-types"),require("react"),require("classnames"),require("react-dom")):t.ReactToastify=e(t["prop-types"],t.react,t.classnames,t["react-dom"])}(window,function(t,e,n,o){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";function o(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==t&&void 0!==t&&this.setState(t)}function r(t){this.setState(function(e){var n=this.constructor.getDerivedStateFromProps(t,e);return null!==n&&void 0!==n?n:null}.bind(this))}function i(t,e){try{var n=this.props,o=this.state;this.props=t,this.state=e,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,o)}finally{this.props=n,this.state=o}}function a(t){var e=t.prototype;if(!e||!e.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate)return t;var n=null,a=null,s=null;if("function"==typeof e.componentWillMount?n="componentWillMount":"function"==typeof e.UNSAFE_componentWillMount&&(n="UNSAFE_componentWillMount"),"function"==typeof e.componentWillReceiveProps?a="componentWillReceiveProps":"function"==typeof e.UNSAFE_componentWillReceiveProps&&(a="UNSAFE_componentWillReceiveProps"),"function"==typeof e.componentWillUpdate?s="componentWillUpdate":"function"==typeof e.UNSAFE_componentWillUpdate&&(s="UNSAFE_componentWillUpdate"),null!==n||null!==a||null!==s){var u=t.displayName||t.name,l="function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+u+" uses "+l+" but also contains the following legacy lifecycles:"+(null!==n?"\n "+n:"")+(null!==a?"\n "+a:"")+(null!==s?"\n "+s:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof t.getDerivedStateFromProps&&(e.componentWillMount=o,e.componentWillReceiveProps=r),"function"==typeof e.getSnapshotBeforeUpdate){if("function"!=typeof e.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");e.componentWillUpdate=i;var c=e.componentDidUpdate;e.componentDidUpdate=function(t,e,n){var o=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:n;c.call(this,t,e,o)}}return t}n.r(e),n.d(e,"polyfill",function(){return a}),o.__suppressDeprecationWarning=!0,r.__suppressDeprecationWarning=!0,i.__suppressDeprecationWarning=!0},function(t,e,n){"use strict";e.__esModule=!0;var o=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},r=u(n(0)),i=u(n(1)),a=n(3),s=n(6);function u(t){return t&&t.__esModule?t:{default:t}}var l=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},c=(r.default.any,r.default.node,r.default.bool,r.default.bool,r.default.bool,r.default.func,function(t){function e(n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(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}(this,t.call(this,n,o)),i=r.handleExited.bind(r);return r.state={handleExited:i,firstRender:!0},r}return function(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,t),e.prototype.getChildContext=function(){return{transitionGroup:{isMounting:!this.appeared}}},e.prototype.componentDidMount=function(){this.appeared=!0},e.getDerivedStateFromProps=function(t,e){var n=e.children,o=e.handleExited;return{children:e.firstRender?(0,s.getInitialChildMapping)(t,o):(0,s.getNextChildMapping)(t,n,o),firstRender:!1}},e.prototype.handleExited=function(t,e){var n=(0,s.getChildMapping)(this.props.children);t.key in n||(t.props.onExited&&t.props.onExited(e),this.setState(function(e){var n=o({},e.children);return delete n[t.key],{children:n}}))},e.prototype.render=function(){var t=this.props,e=t.component,n=t.childFactory,o=function(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}(t,["component","childFactory"]),r=l(this.state.children).map(n);return delete o.appear,delete o.enter,delete o.exit,null===e?r:i.default.createElement(e,o,r)},e}(i.default.Component));c.childContextTypes={transitionGroup:r.default.object.isRequired},c.propTypes={},c.defaultProps={component:"div",childFactory:function(t){return t}},e.default=(0,a.polyfill)(c),t.exports=e.default},function(t,e,n){"use strict";e.__esModule=!0,e.EXITING=e.ENTERED=e.ENTERING=e.EXITED=e.UNMOUNTED=void 0;var o=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}(n(0)),r=s(n(1)),i=s(n(7)),a=n(3);n(8);function s(t){return t&&t.__esModule?t:{default:t}}var u=e.UNMOUNTED="unmounted",l=e.EXITED="exited",c=e.ENTERING="entering",p=e.ENTERED="entered",f=e.EXITING="exiting",d=function(t){function e(n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(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}(this,t.call(this,n,o)),i=o.transitionGroup,a=i&&!i.isMounting?n.enter:n.appear,s=void 0;return r.appearStatus=null,n.in?a?(s=l,r.appearStatus=c):s=p:s=n.unmountOnExit||n.mountOnEnter?u:l,r.state={status:s},r.nextCallback=null,r}return function(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,t),e.prototype.getChildContext=function(){return{transitionGroup:null}},e.getDerivedStateFromProps=function(t,e){return t.in&&e.status===u?{status:l}:null},e.prototype.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},e.prototype.componentDidUpdate=function(t){var e=null;if(t!==this.props){var n=this.state.status;this.props.in?n!==c&&n!==p&&(e=c):n!==c&&n!==p||(e=f)}this.updateStatus(!1,e)},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=arguments[1];if(null!==e){this.cancelNextCallback();var n=i.default.findDOMNode(this);e===c?this.performEnter(n,t):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===l&&this.setState({status:u})},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();e||o?(this.props.onEnter(t,r),this.safeSetState({status:c},function(){n.props.onEntering(t,r),n.onTransitionEnd(t,i.enter,function(){n.safeSetState({status:p},function(){n.props.onEntered(t,r)})})})):this.safeSetState({status:p},function(){n.props.onEntered(t)})},e.prototype.performExit=function(t){var e=this,n=this.props.exit,o=this.getTimeouts();n?(this.props.onExit(t),this.safeSetState({status:f},function(){e.props.onExiting(t),e.onTransitionEnd(t,o.exit,function(){e.safeSetState({status:l},function(){e.props.onExited(t)})})})):this.safeSetState({status:l},function(){e.props.onExited(t)})},e.prototype.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},e.prototype.safeSetState=function(t,e){e=this.setNextCallback(e),this.setState(t,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===u)return null;var e=this.props,n=e.children,o=function(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}(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=r.default.Children.only(n);return r.default.cloneElement(i,o)},e}(r.default.Component);function h(){}d.contextTypes={transitionGroup:o.object},d.childContextTypes={transitionGroup:function(){}},d.propTypes={},d.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:h,onEntering:h,onEntered:h,onExit:h,onExiting:h,onExited:h},d.UNMOUNTED=0,d.EXITED=1,d.ENTERING=2,d.ENTERED=3,d.EXITING=4,e.default=(0,a.polyfill)(d)},function(t,e,n){"use strict";e.__esModule=!0,e.getChildMapping=r,e.mergeChildMappings=i,e.getInitialChildMapping=function(t,e){return r(t.children,function(n){return(0,o.cloneElement)(n,{onExited:e.bind(null,n),in:!0,appear:a(n,"appear",t),enter:a(n,"enter",t),exit:a(n,"exit",t)})})},e.getNextChildMapping=function(t,e,n){var s=r(t.children),u=i(e,s);return Object.keys(u).forEach(function(r){var i=u[r];if((0,o.isValidElement)(i)){var l=r in e,c=r in s,p=e[r],f=(0,o.isValidElement)(p)&&!p.props.in;!c||l&&!f?c||!l||f?c&&l&&(0,o.isValidElement)(p)&&(u[r]=(0,o.cloneElement)(i,{onExited:n.bind(null,i),in:p.props.in,exit:a(i,"exit",t),enter:a(i,"enter",t)})):u[r]=(0,o.cloneElement)(i,{in:!1}):u[r]=(0,o.cloneElement)(i,{onExited:n.bind(null,i),in:!0,exit:a(i,"exit",t),enter:a(i,"enter",t)})}}),u};var o=n(1);function r(t,e){var n=Object.create(null);return t&&o.Children.map(t,function(t){return t}).forEach(function(t){n[t.key]=function(t){return e&&(0,o.isValidElement)(t)?e(t):t}(t)}),n}function i(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 a=void 0,s={};for(var u in e){if(o[u])for(a=0;a<o[u].length;a++){var l=o[u][a];s[o[u][a]]=n(l)}s[u]=n(u)}for(a=0;a<r.length;a++)s[r[a]]=n(r[a]);return s}function a(t,e,n){return null!=n[e]?n[e]:t.props[e]}},function(t,e){t.exports=o},function(t,e,n){"use strict";e.__esModule=!0,e.classNamesShape=e.timeoutsShape=void 0,e.transitionTimeout=function(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}};var o=function(t){return t&&t.__esModule?t:{default:t}}(n(0));e.timeoutsShape=o.default.oneOfType([o.default.number,o.default.shape({enter:o.default.number,exit:o.default.number}).isRequired]),e.classNamesShape=o.default.oneOfType([o.default.string,o.default.shape({enter:o.default.string,exit:o.default.string,active:o.default.string}),o.default.shape({enter:o.default.string,enterDone:o.default.string,enterActive:o.default.string,exit:o.default.string,exitDone:o.default.string,exitActive:o.default.string})])},function(t,e,n){"use strict";n.r(e);var o=n(1),r=n.n(o),i=n(0),a=n.n(i),s=n(2),u=n.n(s),l=n(4),c=n.n(l),p={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},f={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},d={SHOW:0,CLEAR:1,DID_MOUNT:2,WILL_UNMOUNT:3,ON_CHANGE:4};function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function y(t){var e=t.delay,n=t.isRunning,o=t.closeToast,i=t.type,a=t.hide,s=t.className,l=t.style,c=t.rtl,p=h({},l,{animationDuration:e+"ms",animationPlayState:n?"running":"paused",opacity:a?0:1}),f=u()("Toastify__progress-bar","Toastify__progress-bar--"+i,{"Toastify__progress-bar--rtl":c},s);return r.a.createElement("div",{className:f,style:p,onAnimationEnd:o})}y.propTypes={delay:a.a.number.isRequired,isRunning:a.a.bool.isRequired,closeToast:a.a.func.isRequired,rtl:a.a.bool.isRequired,type:a.a.string,hide:a.a.bool,className:a.a.oneOfType([a.a.string,a.a.object])},y.defaultProps={type:f.DEFAULT,hide:!1};var m=y;function g(t){return"number"==typeof t&&!isNaN(t)&&t>0}function v(t){return Object.keys(t).map(function(e){return t[e]})}function b(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}var E=b(function(t,e,n){var o=t[e];return!1===o||g(o)?null:new Error(n+" expect "+e+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),T=b(function(t,e,n){var r=t[e];return!1===r||Object(o.isValidElement)(r)?null:new Error(n+" expect "+e+" \n to be a valid react element or equal to false. "+r+" given.")});function O(){return(O=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function x(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientX:t.clientX}var C=function(){},_=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),r=0;r<n;r++)o[r]=arguments[r];return(e=t.call.apply(t,[this].concat(o))||this).state={isRunning:!0,preventExitTransition:!1},e.flag={canCloseOnClick:!0,canDrag:!1},e.drag={start:0,x:0,y:0,deltaX:0,removalDistance:0},e.ref=null,e.pauseToast=function(){e.props.autoClose&&e.setState({isRunning:!1})},e.playToast=function(){e.props.autoClose&&e.setState({isRunning:!0})},e.onDragStart=function(t){e.flag.canCloseOnClick=!0,e.flag.canDrag=!0,e.ref.style.transition="",e.drag.start=e.drag.x=x(t.nativeEvent),e.drag.removalDistance=e.ref.offsetWidth*(e.props.draggablePercent/100)},e.onDragMove=function(t){e.flag.canDrag&&(e.state.isRunning&&e.pauseToast(),e.drag.x=x(t),e.drag.deltaX=e.drag.x-e.drag.start,e.drag.start!==e.drag.x&&(e.flag.canCloseOnClick=!1),e.ref.style.transform="translateX("+e.drag.deltaX+"px)",e.ref.style.opacity=1-Math.abs(e.drag.deltaX/e.drag.removalDistance))},e.onDragEnd=function(t){if(e.flag.canDrag){if(e.flag.canDrag=!1,Math.abs(e.drag.deltaX)>e.drag.removalDistance)return void e.setState({preventExitTransition:!0},e.props.closeToast);e.drag.y=function(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientY:t.clientY}(t),e.ref.style.transition="transform 0.2s, opacity 0.2s",e.ref.style.transform="translateX(0)",e.ref.style.opacity=1}},e.onDragTransitionEnd=function(){var t=e.ref.getBoundingClientRect(),n=t.top,o=t.bottom,r=t.left,i=t.right;e.props.pauseOnHover&&e.drag.x>=r&&e.drag.x<=i&&e.drag.y>=n&&e.drag.y<=o?e.pauseToast():e.playToast()},e}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.componentDidMount=function(){this.props.onOpen(this.props.children.props),this.props.draggable&&this.bindDragEvents(),this.props.pauseOnFocusLoss&&this.bindFocusEvents()},n.componentDidUpdate=function(t){t.draggable!==this.props.draggable&&(this.props.draggable?this.bindDragEvents():this.unbindDragEvents()),t.pauseOnFocusLoss!==this.props.pauseOnFocusLoss&&(this.props.pauseOnFocusLoss?this.bindFocusEvents():this.unbindFocusEvents())},n.componentWillUnmount=function(){this.props.onClose(this.props.children.props),this.props.draggable&&this.unbindDragEvents(),this.props.pauseOnFocusLoss&&this.unbindFocusEvents()},n.bindFocusEvents=function(){window.addEventListener("focus",this.playToast),window.addEventListener("blur",this.pauseToast)},n.unbindFocusEvents=function(){window.removeEventListener("focus",this.playToast),window.removeEventListener("blur",this.pauseToast)},n.bindDragEvents=function(){document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd)},n.unbindDragEvents=function(){document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd)},n.render=function(){var t=this,e=this.props,n=e.closeButton,o=e.children,i=e.autoClose,a=e.pauseOnHover,s=e.closeOnClick,l=e.type,c=e.hideProgressBar,p=e.closeToast,f=e.transition,d=e.position,h=e.onExited,y=e.className,g=e.bodyClassName,v=e.progressClassName,b=e.progressStyle,E=e.updateId,T=e.role,x=e.rtl,C={className:u()("Toastify__toast","Toastify__toast--"+l,{"Toastify__toast--rtl":x},y)};return i&&a&&(C.onMouseEnter=this.pauseToast,C.onMouseLeave=this.playToast),s&&(C.onClick=function(){return t.flag.canCloseOnClick&&p()}),r.a.createElement(f,{in:this.props.in,appear:!0,unmountOnExit:!0,onExited:h,position:d,preventExitTransition:this.state.preventExitTransition},r.a.createElement("div",O({},C,{ref:function(e){return t.ref=e},onMouseDown:this.onDragStart,onTouchStart:this.onDragStart,onTransitionEnd:this.onDragTransitionEnd}),r.a.createElement("div",O({},this.props.in&&{role:T},{className:u()("Toastify__toast-body",g)}),o),n&&n,i&&r.a.createElement(m,O({},E?{key:"pb-"+E}:{},{rtl:x,delay:i,isRunning:this.state.isRunning,closeToast:p,hide:c,type:l,style:b,className:v}))))},e}(o.Component);_.propTypes={closeButton:T.isRequired,autoClose:E.isRequired,children:a.a.node.isRequired,closeToast:a.a.func.isRequired,position:a.a.oneOf(v(p)).isRequired,pauseOnHover:a.a.bool.isRequired,pauseOnFocusLoss:a.a.bool.isRequired,closeOnClick:a.a.bool.isRequired,transition:a.a.func.isRequired,rtl:a.a.bool.isRequired,hideProgressBar:a.a.bool.isRequired,draggable:a.a.bool.isRequired,draggablePercent:a.a.number.isRequired,in:a.a.bool,onExited:a.a.func,onOpen:a.a.func,onClose:a.a.func,type:a.a.oneOf(v(f)),className:a.a.oneOfType([a.a.string,a.a.object]),bodyClassName:a.a.oneOfType([a.a.string,a.a.object]),progressClassName:a.a.oneOfType([a.a.string,a.a.object]),progressStyle:a.a.object,updateId:a.a.number,ariaLabel:a.a.string},_.defaultProps={type:f.DEFAULT,in:!0,onOpen:C,onClose:C,className:null,bodyClassName:null,progressClassName:null,updateId:null,role:"alert"};var N=_;function S(t){var e=t.closeToast,n=t.type,o=t.ariaLabel;return r.a.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+n,type:"button",onClick:e,"aria-label":o},"✖")}S.propTypes={closeToast:a.a.func,arialLabel:a.a.string},S.defaultProps={ariaLabel:"close"};var D=S,w=n(5),R=n.n(w);function j(){return(j=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var P=function(){},M=function(t){var e=t.enter,n=t.exit,o=t.duration,i=void 0===o?750:o,a=t.appendPosition,s=void 0!==a&&a;return function(t){var o,a,u=t.children,l=t.position,c=t.preventExitTransition,p=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,["children","position","preventExitTransition"]),f=s?e+"--"+l:e,d=s?n+"--"+l:n;Array.isArray(i)&&2===i.length?(o=i[0],a=i[1]):o=a=i;return r.a.createElement(R.a,j({},p,{timeout:c?0:{enter:o,exit:a},onEnter:function(t){t.classList.add(f),t.style.animationFillMode="forwards",t.style.animationDuration=.001*o+"s"},onEntered:function(t){t.classList.remove(f),t.style.cssText=""},onExit:c?P:function(t){t.classList.add(d),t.style.animationFillMode="forwards",t.style.animationDuration=.001*a+"s"}}),u)}},I=M({enter:"Toastify__bounce-enter",exit:"Toastify__bounce-exit",appendPosition:!0}),L=M({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit",duration:[450,750],appendPosition:!0}),k=M({enter:"Toastify__zoom-enter",exit:"Toastify__zoom-exit"}),F=M({enter:"Toastify__flip-enter",exit:"Toastify__flip-exit"}),U={list:new Map,on:function(t,e){return this.list.has(t)||this.list.set(t,[]),this.list.get(t).push(e),this},off:function(t){return void 0===t&&(t=null),this.list.delete(t),this},emit:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];return!!this.list.has(t)&&(this.list.get(t).forEach(function(t){return setTimeout(function(){return t.call.apply(t,[null].concat(n))},0)}),!0)}};function A(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function W(){return(W=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var q=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),r=0;r<n;r++)o[r]=arguments[r];return(e=t.call.apply(t,[this].concat(o))||this).state={toast:[]},e.collection={},e.isToastActive=function(t){return-1!==e.state.toast.indexOf(t)},e}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this;U.on(d.SHOW,function(e,n){return t.show(e,n)}).on(d.CLEAR,function(e){return null!==e?t.removeToast(e):t.clear()}).emit(d.DID_MOUNT,this)},n.componentWillUnmount=function(){U.off(d.SHOW).off(d.CLEAR).emit(d.WILL_UNMOUNT)},n.removeToast=function(t){this.setState({toast:this.state.toast.filter(function(e){return e!==t})},this.dispatchChange)},n.dispatchChange=function(){U.emit(d.ON_CHANGE,this.state.toast.length)},n.makeCloseButton=function(t,e,n){var r=this,i=this.props.closeButton;return(Object(o.isValidElement)(t)||!1===t)&&(i=t),!1!==i&&Object(o.cloneElement)(i,{closeToast:function(){return r.removeToast(e)},type:n})},n.getAutoCloseDelay=function(t){return!1===t||g(t)?t:this.props.autoClose},n.canBeRendered=function(t){return Object(o.isValidElement)(t)||"string"==typeof t||"number"==typeof t||"function"==typeof t},n.parseClassName=function(t){return"string"==typeof t?t:null!==t&&"object"==typeof t&&"toString"in t?t.toString():null},n.show=function(t,e){var n,r=this;if(!this.canBeRendered(t))throw new Error("The element you provided cannot be rendered. You provided an element of type "+typeof t);var i=e.toastId,a=function(){return r.removeToast(i)},s={id:i,type:e.type,closeToast:a,updateId:e.updateId,rtl:this.props.rtl,position:e.position||this.props.position,transition:e.transition||this.props.transition,className:this.parseClassName(e.className||this.props.toastClassName),bodyClassName:this.parseClassName(e.bodyClassName||this.props.bodyClassName),closeButton:this.makeCloseButton(e.closeButton,i,e.type),pauseOnHover:"boolean"==typeof e.pauseOnHover?e.pauseOnHover:this.props.pauseOnHover,pauseOnFocusLoss:"boolean"==typeof e.pauseOnFocusLoss?e.pauseOnFocusLoss:this.props.pauseOnFocusLoss,draggable:"boolean"==typeof e.draggable?e.draggable:this.props.draggable,draggablePercent:"number"!=typeof e.draggablePercent||isNaN(e.draggablePercent)?this.props.draggablePercent:e.draggablePercent,closeOnClick:"boolean"==typeof e.closeOnClick?e.closeOnClick:this.props.closeOnClick,progressClassName:this.parseClassName(e.progressClassName||this.props.progressClassName),progressStyle:this.props.progressStyle,autoClose:this.getAutoCloseDelay(e.autoClose),hideProgressBar:"boolean"==typeof e.hideProgressBar?e.hideProgressBar:this.props.hideProgressBar};"function"==typeof e.onOpen&&(s.onOpen=e.onOpen),"function"==typeof e.onClose&&(s.onClose=e.onClose),Object(o.isValidElement)(t)&&"string"!=typeof t.type&&"number"!=typeof t.type?t=Object(o.cloneElement)(t,{closeToast:a}):"function"==typeof t&&(t=t({closeToast:a})),this.collection=W({},this.collection,((n={})[i]={position:s.position,options:s,content:t},n)),this.setState({toast:s.updateId?A(this.state.toast):A(this.state.toast).concat([i])},this.dispatchChange)},n.makeToast=function(t,e){return r.a.createElement(N,W({},e,{isDocumentHidden:this.state.isDocumentHidden,key:"toast-"+e.id}),t)},n.clear=function(){this.setState({toast:[]})},n.renderToast=function(){var t=this,e={},n=this.props,o=n.className,i=n.style;return(n.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(n){var o=t.collection[n],r=o.position,i=o.options,a=o.content;e[r]||(e[r]=[]),-1!==t.state.toast.indexOf(i.id)?e[r].push(t.makeToast(a,i)):(e[r].push(null),delete t.collection[n])}),Object.keys(e).map(function(n){var a=1===e[n].length&&null===e[n][0],s={className:u()("Toastify__toast-container","Toastify__toast-container--"+n,{"Toastify__toast-container--rtl":t.props.rtl},t.parseClassName(o)),style:a?W({},i,{pointerEvents:"none"}):W({},i)};return r.a.createElement(c.a,W({},s,{key:"container-"+n}),e[n])})},n.render=function(){return r.a.createElement("div",{className:"Toastify"},this.renderToast())},e}(o.Component);q.propTypes={position:a.a.oneOf(v(p)),autoClose:E,closeButton:T,hideProgressBar:a.a.bool,pauseOnHover:a.a.bool,closeOnClick:a.a.bool,newestOnTop:a.a.bool,className:a.a.oneOfType([a.a.string,a.a.object]),style:a.a.object,toastClassName:a.a.oneOfType([a.a.string,a.a.object]),bodyClassName:a.a.oneOfType([a.a.string,a.a.object]),progressClassName:a.a.oneOfType([a.a.string,a.a.object]),progressStyle:a.a.object,transition:a.a.func,rtl:a.a.bool,draggable:a.a.bool,draggablePercent:a.a.number,pauseOnFocusLoss:a.a.bool},q.defaultProps={position:p.TOP_RIGHT,transition:I,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:r.a.createElement(D,null),pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,className:null,style:null,toastClassName:null,bodyClassName:null,progressClassName:null,progressStyle:null};var B=q;function G(){return(G=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var H=null,X=[],V=0,Y=function(){return!1};function z(t,e){return G({},t,{type:e,toastId:function(t){if(t&&("number"==typeof t.toastId&&!isNaN(t.toastId)||"string"==typeof t.toastId))return t.toastId;return++V}(t)})}function Z(t,e){return null!==H?U.emit(d.SHOW,t,e):X.push({action:d.SHOW,content:t,options:e}),e.toastId}var J=G(function(t,e){return Z(t,z(e,e&&e.type||f.DEFAULT))},{success:function(t,e){return Z(t,z(e,f.SUCCESS))},info:function(t,e){return Z(t,z(e,f.INFO))},warn:function(t,e){return Z(t,z(e,f.WARNING))},warning:function(t,e){return Z(t,z(e,f.WARNING))},error:function(t,e){return Z(t,z(e,f.ERROR))},dismiss:function(t){return void 0===t&&(t=null),H&&U.emit(d.CLEAR,t)},isActive:Y,update:function(t,e){setTimeout(function(){if(H&&void 0!==H.collection[t]){var n=H.collection[t],o=n.options,r=n.content,i=o.updateId?o.updateId+1:1,a=G({},o,e,{toastId:t,updateId:i}),s=void 0!==a.render?a.render:r;delete a.render,Z(s,a)}},0)},onChange:function(t){"function"==typeof t&&U.on(d.ON_CHANGE,t)},POSITION:p,TYPE:f});U.on(d.DID_MOUNT,function(t){H=t,J.isActive=function(t){return H.isToastActive(t)},X.forEach(function(t){U.emit(t.action,t.content,t.options)}),X=[]}).on(d.WILL_UNMOUNT,function(){H=null,J.isActive=Y,V=0});var K=J;n.d(e,"ToastContainer",function(){return B}),n.d(e,"toast",function(){return K}),n.d(e,"cssTransition",function(){return M}),n.d(e,"Bounce",function(){return I}),n.d(e,"Slide",function(){return L}),n.d(e,"Zoom",function(){return k}),n.d(e,"Flip",function(){return F}),n.d(e,"ToastPosition",function(){return p}),n.d(e,"ToastType",function(){return f})}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("prop-types"),require("react"),require("classnames"),require("react-dom")):"function"==typeof define&&define.amd?define(["prop-types","react","classnames","react-dom"],e):"object"==typeof exports?exports.ReactToastify=e(require("prop-types"),require("react"),require("classnames"),require("react-dom")):t.ReactToastify=e(t["prop-types"],t.react,t.classnames,t["react-dom"])}(window,function(t,e,n,o){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";function o(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==t&&void 0!==t&&this.setState(t)}function r(t){this.setState(function(e){var n=this.constructor.getDerivedStateFromProps(t,e);return null!==n&&void 0!==n?n:null}.bind(this))}function s(t,e){try{var n=this.props,o=this.state;this.props=t,this.state=e,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,o)}finally{this.props=n,this.state=o}}function i(t){var e=t.prototype;if(!e||!e.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate)return t;var n=null,i=null,a=null;if("function"==typeof e.componentWillMount?n="componentWillMount":"function"==typeof e.UNSAFE_componentWillMount&&(n="UNSAFE_componentWillMount"),"function"==typeof e.componentWillReceiveProps?i="componentWillReceiveProps":"function"==typeof e.UNSAFE_componentWillReceiveProps&&(i="UNSAFE_componentWillReceiveProps"),"function"==typeof e.componentWillUpdate?a="componentWillUpdate":"function"==typeof e.UNSAFE_componentWillUpdate&&(a="UNSAFE_componentWillUpdate"),null!==n||null!==i||null!==a){var l=t.displayName||t.name,u="function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+l+" uses "+u+" but also contains the following legacy lifecycles:"+(null!==n?"\n "+n:"")+(null!==i?"\n "+i:"")+(null!==a?"\n "+a:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof t.getDerivedStateFromProps&&(e.componentWillMount=o,e.componentWillReceiveProps=r),"function"==typeof e.getSnapshotBeforeUpdate){if("function"!=typeof e.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");e.componentWillUpdate=s;var c=e.componentDidUpdate;e.componentDidUpdate=function(t,e,n){var o=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:n;c.call(this,t,e,o)}}return t}n.r(e),n.d(e,"polyfill",function(){return i}),o.__suppressDeprecationWarning=!0,r.__suppressDeprecationWarning=!0,s.__suppressDeprecationWarning=!0},function(t,e,n){"use strict";e.__esModule=!0;var o=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},r=l(n(0)),s=l(n(1)),i=n(3),a=n(6);function l(t){return t&&t.__esModule?t:{default:t}}var u=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},c=(r.default.any,r.default.node,r.default.bool,r.default.bool,r.default.bool,r.default.func,function(t){function e(n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(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}(this,t.call(this,n,o)),s=r.handleExited.bind(r);return r.state={handleExited:s,firstRender:!0},r}return function(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,t),e.prototype.getChildContext=function(){return{transitionGroup:{isMounting:!this.appeared}}},e.prototype.componentDidMount=function(){this.appeared=!0},e.getDerivedStateFromProps=function(t,e){var n=e.children,o=e.handleExited;return{children:e.firstRender?(0,a.getInitialChildMapping)(t,o):(0,a.getNextChildMapping)(t,n,o),firstRender:!1}},e.prototype.handleExited=function(t,e){var n=(0,a.getChildMapping)(this.props.children);t.key in n||(t.props.onExited&&t.props.onExited(e),this.setState(function(e){var n=o({},e.children);return delete n[t.key],{children:n}}))},e.prototype.render=function(){var t=this.props,e=t.component,n=t.childFactory,o=function(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}(t,["component","childFactory"]),r=u(this.state.children).map(n);return delete o.appear,delete o.enter,delete o.exit,null===e?r:s.default.createElement(e,o,r)},e}(s.default.Component));c.childContextTypes={transitionGroup:r.default.object.isRequired},c.propTypes={},c.defaultProps={component:"div",childFactory:function(t){return t}},e.default=(0,i.polyfill)(c),t.exports=e.default},function(t,e,n){"use strict";e.__esModule=!0,e.EXITING=e.ENTERED=e.ENTERING=e.EXITED=e.UNMOUNTED=void 0;var o=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}(n(0)),r=a(n(1)),s=a(n(7)),i=n(3);n(8);function a(t){return t&&t.__esModule?t:{default:t}}var l=e.UNMOUNTED="unmounted",u=e.EXITED="exited",c=e.ENTERING="entering",p=e.ENTERED="entered",f=e.EXITING="exiting",d=function(t){function e(n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(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}(this,t.call(this,n,o)),s=o.transitionGroup,i=s&&!s.isMounting?n.enter:n.appear,a=void 0;return r.appearStatus=null,n.in?i?(a=u,r.appearStatus=c):a=p:a=n.unmountOnExit||n.mountOnEnter?l:u,r.state={status:a},r.nextCallback=null,r}return function(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,t),e.prototype.getChildContext=function(){return{transitionGroup:null}},e.getDerivedStateFromProps=function(t,e){return t.in&&e.status===l?{status:u}:null},e.prototype.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},e.prototype.componentDidUpdate=function(t){var e=null;if(t!==this.props){var n=this.state.status;this.props.in?n!==c&&n!==p&&(e=c):n!==c&&n!==p||(e=f)}this.updateStatus(!1,e)},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=arguments[1];if(null!==e){this.cancelNextCallback();var n=s.default.findDOMNode(this);e===c?this.performEnter(n,t):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===u&&this.setState({status:l})},e.prototype.performEnter=function(t,e){var n=this,o=this.props.enter,r=this.context.transitionGroup?this.context.transitionGroup.isMounting:e,s=this.getTimeouts();e||o?(this.props.onEnter(t,r),this.safeSetState({status:c},function(){n.props.onEntering(t,r),n.onTransitionEnd(t,s.enter,function(){n.safeSetState({status:p},function(){n.props.onEntered(t,r)})})})):this.safeSetState({status:p},function(){n.props.onEntered(t)})},e.prototype.performExit=function(t){var e=this,n=this.props.exit,o=this.getTimeouts();n?(this.props.onExit(t),this.safeSetState({status:f},function(){e.props.onExiting(t),e.onTransitionEnd(t,o.exit,function(){e.safeSetState({status:u},function(){e.props.onExited(t)})})})):this.safeSetState({status:u},function(){e.props.onExited(t)})},e.prototype.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},e.prototype.safeSetState=function(t,e){e=this.setNextCallback(e),this.setState(t,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===l)return null;var e=this.props,n=e.children,o=function(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}(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 s=r.default.Children.only(n);return r.default.cloneElement(s,o)},e}(r.default.Component);function h(){}d.contextTypes={transitionGroup:o.object},d.childContextTypes={transitionGroup:function(){}},d.propTypes={},d.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:h,onEntering:h,onEntered:h,onExit:h,onExiting:h,onExited:h},d.UNMOUNTED=0,d.EXITED=1,d.ENTERING=2,d.ENTERED=3,d.EXITING=4,e.default=(0,i.polyfill)(d)},function(t,e,n){"use strict";e.__esModule=!0,e.getChildMapping=r,e.mergeChildMappings=s,e.getInitialChildMapping=function(t,e){return r(t.children,function(n){return(0,o.cloneElement)(n,{onExited:e.bind(null,n),in:!0,appear:i(n,"appear",t),enter:i(n,"enter",t),exit:i(n,"exit",t)})})},e.getNextChildMapping=function(t,e,n){var a=r(t.children),l=s(e,a);return Object.keys(l).forEach(function(r){var s=l[r];if((0,o.isValidElement)(s)){var u=r in e,c=r in a,p=e[r],f=(0,o.isValidElement)(p)&&!p.props.in;!c||u&&!f?c||!u||f?c&&u&&(0,o.isValidElement)(p)&&(l[r]=(0,o.cloneElement)(s,{onExited:n.bind(null,s),in:p.props.in,exit:i(s,"exit",t),enter:i(s,"enter",t)})):l[r]=(0,o.cloneElement)(s,{in:!1}):l[r]=(0,o.cloneElement)(s,{onExited:n.bind(null,s),in:!0,exit:i(s,"exit",t),enter:i(s,"enter",t)})}}),l};var o=n(1);function r(t,e){var n=Object.create(null);return t&&o.Children.map(t,function(t){return t}).forEach(function(t){n[t.key]=function(t){return e&&(0,o.isValidElement)(t)?e(t):t}(t)}),n}function s(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 s in t)s in e?r.length&&(o[s]=r,r=[]):r.push(s);var i=void 0,a={};for(var l in e){if(o[l])for(i=0;i<o[l].length;i++){var u=o[l][i];a[o[l][i]]=n(u)}a[l]=n(l)}for(i=0;i<r.length;i++)a[r[i]]=n(r[i]);return a}function i(t,e,n){return null!=n[e]?n[e]:t.props[e]}},function(t,e){t.exports=o},function(t,e,n){"use strict";e.__esModule=!0,e.classNamesShape=e.timeoutsShape=void 0,e.transitionTimeout=function(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}};var o=function(t){return t&&t.__esModule?t:{default:t}}(n(0));e.timeoutsShape=o.default.oneOfType([o.default.number,o.default.shape({enter:o.default.number,exit:o.default.number}).isRequired]),e.classNamesShape=o.default.oneOfType([o.default.string,o.default.shape({enter:o.default.string,exit:o.default.string,active:o.default.string}),o.default.shape({enter:o.default.string,enterDone:o.default.string,enterActive:o.default.string,exit:o.default.string,exitDone:o.default.string,exitActive:o.default.string})])},function(t,e,n){"use strict";n.r(e);var o=n(1),r=n.n(o),s=n(0),i=n.n(s),a=n(2),l=n.n(a),u=n(4),c=n.n(u),p={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},f={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},d={SHOW:0,CLEAR:1,DID_MOUNT:2,WILL_UNMOUNT:3,ON_CHANGE:4};function h(t){return"number"==typeof t&&!isNaN(t)&&t>0}function y(t){return Object.keys(t).map(function(e){return t[e]})}function g(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}var m=g(function(t,e,n){var o=t[e];return!1===o||h(o)?null:new Error(n+" expect "+e+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),b=g(function(t,e,n){var r=t[e];return!1===r||Object(o.isValidElement)(r)?null:new Error(n+" expect "+e+" \n to be a valid react element or equal to false. "+r+" given.")});function v(){return(v=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function E(t){var e,n=t.delay,o=t.isRunning,s=t.closeToast,i=t.type,a=t.hide,u=t.className,c=t.style,p=t.controlledProgress,f=t.progress,d=t.isProgressDone,h=t.rtl,y=v({},c,{animationDuration:n+"ms",animationPlayState:o?"running":"paused",opacity:a?0:1,transform:p?"scaleX("+f+")":null}),g=l()("Toastify__progress-bar",p?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+i,{"Toastify__progress-bar--rtl":h},u),m=((e={})[p&&d?"onTransitionEnd":"onAnimationEnd"]=p&&!d?null:s,e);return r.a.createElement("div",v({className:g,style:y},m))}E.propTypes={delay:m.isRequired,isRunning:i.a.bool.isRequired,closeToast:i.a.func.isRequired,rtl:i.a.bool.isRequired,type:i.a.string,hide:i.a.bool,className:i.a.oneOfType([i.a.string,i.a.object]),progress:i.a.number,controlledProgress:i.a.bool,isProgressDone:i.a.bool},E.defaultProps={type:f.DEFAULT,hide:!1};var T=E;function O(){return(O=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function x(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientX:t.clientX}var C=function(){},_=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),r=0;r<n;r++)o[r]=arguments[r];return(e=t.call.apply(t,[this].concat(o))||this).state={isRunning:!0,preventExitTransition:!1},e.flag={canCloseOnClick:!0,canDrag:!1},e.drag={start:0,x:0,y:0,deltaX:0,removalDistance:0},e.ref=null,e.pauseToast=function(){e.props.autoClose&&e.setState({isRunning:!1})},e.playToast=function(){e.props.autoClose&&e.setState({isRunning:!0})},e.onDragStart=function(t){e.flag.canCloseOnClick=!0,e.flag.canDrag=!0,e.ref.style.transition="",e.drag.start=e.drag.x=x(t.nativeEvent),e.drag.removalDistance=e.ref.offsetWidth*(e.props.draggablePercent/100)},e.onDragMove=function(t){e.flag.canDrag&&(e.state.isRunning&&e.pauseToast(),e.drag.x=x(t),e.drag.deltaX=e.drag.x-e.drag.start,e.drag.start!==e.drag.x&&(e.flag.canCloseOnClick=!1),e.ref.style.transform="translateX("+e.drag.deltaX+"px)",e.ref.style.opacity=1-Math.abs(e.drag.deltaX/e.drag.removalDistance))},e.onDragEnd=function(t){if(e.flag.canDrag){if(e.flag.canDrag=!1,Math.abs(e.drag.deltaX)>e.drag.removalDistance)return void e.setState({preventExitTransition:!0},e.props.closeToast);e.drag.y=function(t){return t.targetTouches&&t.targetTouches.length>=1?t.targetTouches[0].clientY:t.clientY}(t),e.ref.style.transition="transform 0.2s, opacity 0.2s",e.ref.style.transform="translateX(0)",e.ref.style.opacity=1}},e.onDragTransitionEnd=function(){var t=e.ref.getBoundingClientRect(),n=t.top,o=t.bottom,r=t.left,s=t.right;e.props.pauseOnHover&&e.drag.x>=r&&e.drag.x<=s&&e.drag.y>=n&&e.drag.y<=o?e.pauseToast():e.playToast()},e}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.componentDidMount=function(){this.props.onOpen(this.props.children.props),this.props.draggable&&this.bindDragEvents(),this.props.pauseOnFocusLoss&&this.bindFocusEvents()},n.componentDidUpdate=function(t){t.draggable!==this.props.draggable&&(this.props.draggable?this.bindDragEvents():this.unbindDragEvents()),t.pauseOnFocusLoss!==this.props.pauseOnFocusLoss&&(this.props.pauseOnFocusLoss?this.bindFocusEvents():this.unbindFocusEvents())},n.componentWillUnmount=function(){this.props.onClose(this.props.children.props),this.props.draggable&&this.unbindDragEvents(),this.props.pauseOnFocusLoss&&this.unbindFocusEvents()},n.bindFocusEvents=function(){window.addEventListener("focus",this.playToast),window.addEventListener("blur",this.pauseToast)},n.unbindFocusEvents=function(){window.removeEventListener("focus",this.playToast),window.removeEventListener("blur",this.pauseToast)},n.bindDragEvents=function(){document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd)},n.unbindDragEvents=function(){document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd)},n.render=function(){var t=this,e=this.props,n=e.closeButton,o=e.children,s=e.autoClose,i=e.pauseOnHover,a=e.closeOnClick,u=e.type,c=e.hideProgressBar,p=e.closeToast,f=e.transition,d=e.position,h=e.onExited,y=e.className,g=e.bodyClassName,m=e.progressClassName,b=e.progressStyle,v=e.updateId,E=e.role,x=e.progress,C=e.isProgressDone,_=e.rtl,N={className:l()("Toastify__toast","Toastify__toast--"+u,{"Toastify__toast--rtl":_},y)};s&&i&&(N.onMouseEnter=this.pauseToast,N.onMouseLeave=this.playToast),a&&(N.onClick=function(){return t.flag.canCloseOnClick&&p()});var S=parseFloat(x)===x;return r.a.createElement(f,{in:this.props.in,appear:!0,unmountOnExit:!0,onExited:h,position:d,preventExitTransition:this.state.preventExitTransition},r.a.createElement("div",O({},N,{ref:function(e){return t.ref=e},onMouseDown:this.onDragStart,onTouchStart:this.onDragStart,onTransitionEnd:this.onDragTransitionEnd}),r.a.createElement("div",O({},this.props.in&&{role:E},{className:l()("Toastify__toast-body",g)}),o),n&&n,(s||S)&&r.a.createElement(T,O({},v&&!S?{key:"pb-"+v}:{},{rtl:_,delay:s,isRunning:this.state.isRunning,closeToast:p,hide:c,type:u,style:b,className:m,controlledProgress:S,isProgressDone:C,progress:x}))))},e}(o.Component);_.propTypes={closeButton:b.isRequired,autoClose:m.isRequired,children:i.a.node.isRequired,closeToast:i.a.func.isRequired,position:i.a.oneOf(y(p)).isRequired,pauseOnHover:i.a.bool.isRequired,pauseOnFocusLoss:i.a.bool.isRequired,closeOnClick:i.a.bool.isRequired,transition:i.a.func.isRequired,rtl:i.a.bool.isRequired,hideProgressBar:i.a.bool.isRequired,draggable:i.a.bool.isRequired,draggablePercent:i.a.number.isRequired,in:i.a.bool,onExited:i.a.func,onOpen:i.a.func,onClose:i.a.func,type:i.a.oneOf(y(f)),className:i.a.oneOfType([i.a.string,i.a.object]),bodyClassName:i.a.oneOfType([i.a.string,i.a.object]),progressClassName:i.a.oneOfType([i.a.string,i.a.object]),progressStyle:i.a.object,progress:i.a.number,isProgressDone:i.a.bool,updateId:i.a.oneOfType([i.a.string,i.a.number]),ariaLabel:i.a.string},_.defaultProps={type:f.DEFAULT,in:!0,onOpen:C,onClose:C,className:null,bodyClassName:null,progressClassName:null,updateId:null,role:"alert"};var N=_;function S(t){var e=t.closeToast,n=t.type,o=t.ariaLabel;return r.a.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+n,type:"button",onClick:e,"aria-label":o},"✖")}S.propTypes={closeToast:i.a.func,arialLabel:i.a.string},S.defaultProps={ariaLabel:"close"};var D=S,P=n(5),w=n.n(P);function R(){return(R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var j=function(){},M=function(t){var e=t.enter,n=t.exit,o=t.duration,s=void 0===o?750:o,i=t.appendPosition,a=void 0!==i&&i;return function(t){var o,i,l=t.children,u=t.position,c=t.preventExitTransition,p=function(t,e){if(null==t)return{};var n,o,r={},s=Object.keys(t);for(o=0;o<s.length;o++)n=s[o],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,["children","position","preventExitTransition"]),f=a?e+"--"+u:e,d=a?n+"--"+u:n;Array.isArray(s)&&2===s.length?(o=s[0],i=s[1]):o=i=s;return r.a.createElement(w.a,R({},p,{timeout:c?0:{enter:o,exit:i},onEnter:function(t){t.classList.add(f),t.style.animationFillMode="forwards",t.style.animationDuration=.001*o+"s"},onEntered:function(t){t.classList.remove(f),t.style.cssText=""},onExit:c?j:function(t){t.classList.add(d),t.style.animationFillMode="forwards",t.style.animationDuration=.001*i+"s"}}),l)}},I=M({enter:"Toastify__bounce-enter",exit:"Toastify__bounce-exit",appendPosition:!0}),k=M({enter:"Toastify__slide-enter",exit:"Toastify__slide-exit",duration:[450,750],appendPosition:!0}),L=M({enter:"Toastify__zoom-enter",exit:"Toastify__zoom-exit"}),F=M({enter:"Toastify__flip-enter",exit:"Toastify__flip-exit"}),U={list:new Map,on:function(t,e){return this.list.has(t)||this.list.set(t,[]),this.list.get(t).push(e),this},off:function(t){return this.list.delete(t),this},emit:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];return!!this.list.has(t)&&(this.list.get(t).forEach(function(t){return setTimeout(function(){return t.call.apply(t,[null].concat(n))},0)}),!0)}};function A(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function W(){return(W=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var q=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),r=0;r<n;r++)o[r]=arguments[r];return(e=t.call.apply(t,[this].concat(o))||this).state={toast:[]},e.toastKey=0,e.collection={},e.isToastActive=function(t){return-1!==e.state.toast.indexOf(t)},e}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this;U.on(d.SHOW,function(e,n){return t.show(e,n)}).on(d.CLEAR,function(e){return e?t.removeToast(e):t.clear()}).emit(d.DID_MOUNT,this)},n.componentWillUnmount=function(){U.off(d.SHOW).off(d.CLEAR).emit(d.WILL_UNMOUNT)},n.removeToast=function(t){this.setState({toast:this.state.toast.filter(function(e){return e!==t})},this.dispatchChange)},n.dispatchChange=function(){U.emit(d.ON_CHANGE,this.state.toast.length)},n.makeCloseButton=function(t,e,n){var r=this,s=this.props.closeButton;return(Object(o.isValidElement)(t)||!1===t)&&(s=t),!1!==s&&Object(o.cloneElement)(s,{closeToast:function(){return r.removeToast(e)},type:n})},n.getAutoCloseDelay=function(t){return!1===t||h(t)?t:this.props.autoClose},n.canBeRendered=function(t){return Object(o.isValidElement)(t)||"string"==typeof t||"number"==typeof t||"function"==typeof t},n.parseClassName=function(t){return"string"==typeof t?t:null!==t&&"object"==typeof t&&"toString"in t?t.toString():null},n.show=function(t,e){var n,r=this;if(!this.canBeRendered(t))throw new Error("The element you provided cannot be rendered. You provided an element of type "+typeof t);var s=e.toastId,i=function(){return r.removeToast(s)},a={id:s,key:e.key||this.toastKey++,type:e.type,closeToast:i,updateId:e.updateId,rtl:this.props.rtl,position:e.position||this.props.position,transition:e.transition||this.props.transition,className:this.parseClassName(e.className||this.props.toastClassName),bodyClassName:this.parseClassName(e.bodyClassName||this.props.bodyClassName),closeButton:this.makeCloseButton(e.closeButton,s,e.type),pauseOnHover:"boolean"==typeof e.pauseOnHover?e.pauseOnHover:this.props.pauseOnHover,pauseOnFocusLoss:"boolean"==typeof e.pauseOnFocusLoss?e.pauseOnFocusLoss:this.props.pauseOnFocusLoss,draggable:"boolean"==typeof e.draggable?e.draggable:this.props.draggable,draggablePercent:"number"!=typeof e.draggablePercent||isNaN(e.draggablePercent)?this.props.draggablePercent:e.draggablePercent,closeOnClick:"boolean"==typeof e.closeOnClick?e.closeOnClick:this.props.closeOnClick,progressClassName:this.parseClassName(e.progressClassName||this.props.progressClassName),progressStyle:this.props.progressStyle,autoClose:this.getAutoCloseDelay(e.autoClose),hideProgressBar:"boolean"==typeof e.hideProgressBar?e.hideProgressBar:this.props.hideProgressBar,progress:Number.parseFloat(e.progress),isProgressDone:e.isProgressDone};"function"==typeof e.onOpen&&(a.onOpen=e.onOpen),"function"==typeof e.onClose&&(a.onClose=e.onClose),Object(o.isValidElement)(t)&&"string"!=typeof t.type&&"number"!=typeof t.type?t=Object(o.cloneElement)(t,{closeToast:i}):"function"==typeof t&&(t=t({closeToast:i})),this.collection=W({},this.collection,((n={})[s]={position:a.position,options:a,content:t},n)),this.setState({toast:(a.updateId?A(this.state.toast):A(this.state.toast).concat([s])).filter(function(t){return t!==e.staleToastId})},this.dispatchChange)},n.makeToast=function(t,e){return r.a.createElement(N,W({},e,{isDocumentHidden:this.state.isDocumentHidden,key:"toast-"+e.key}),t)},n.clear=function(){this.setState({toast:[]})},n.renderToast=function(){var t=this,e={},n=this.props,o=n.className,s=n.style;return(n.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(n){var o=t.collection[n],r=o.position,s=o.options,i=o.content;e[r]||(e[r]=[]),-1!==t.state.toast.indexOf(s.id)?e[r].push(t.makeToast(i,s)):(e[r].push(null),delete t.collection[n])}),Object.keys(e).map(function(n){var i=1===e[n].length&&null===e[n][0],a={className:l()("Toastify__toast-container","Toastify__toast-container--"+n,{"Toastify__toast-container--rtl":t.props.rtl},t.parseClassName(o)),style:i?W({},s,{pointerEvents:"none"}):W({},s)};return r.a.createElement(c.a,W({},a,{key:"container-"+n}),e[n])})},n.render=function(){return r.a.createElement("div",{className:"Toastify"},this.renderToast())},e}(o.Component);q.propTypes={position:i.a.oneOf(y(p)),autoClose:m,closeButton:b,hideProgressBar:i.a.bool,pauseOnHover:i.a.bool,closeOnClick:i.a.bool,newestOnTop:i.a.bool,className:i.a.oneOfType([i.a.string,i.a.object]),style:i.a.object,toastClassName:i.a.oneOfType([i.a.string,i.a.object]),bodyClassName:i.a.oneOfType([i.a.string,i.a.object]),progressClassName:i.a.oneOfType([i.a.string,i.a.object]),progressStyle:i.a.object,transition:i.a.func,rtl:i.a.bool,draggable:i.a.bool,draggablePercent:i.a.number,pauseOnFocusLoss:i.a.bool},q.defaultProps={position:p.TOP_RIGHT,transition:I,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:r.a.createElement(D,null),pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,className:null,style:null,toastClassName:null,bodyClassName:null,progressClassName:null,progressStyle:null};var B=q;function G(){return(G=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var H=null,X=[],V=function(){return!1};function Y(t,e){return G({},t,{type:e,toastId:function(t){if(t&&("string"==typeof t.toastId||"number"==typeof t.toastId&&!isNaN(t.toastId)))return t.toastId;return z()}(t)})}function z(){return(Math.random().toString(36)+Date.now().toString(36)).substr(2,10)}function K(t,e){return null!==H?U.emit(d.SHOW,t,e):X.push({action:d.SHOW,content:t,options:e}),e.toastId}var Z=G(function(t,e){return K(t,Y(e,e&&e.type||f.DEFAULT))},{success:function(t,e){return K(t,Y(e,f.SUCCESS))},info:function(t,e){return K(t,Y(e,f.INFO))},warn:function(t,e){return K(t,Y(e,f.WARNING))},warning:function(t,e){return K(t,Y(e,f.WARNING))},error:function(t,e){return K(t,Y(e,f.ERROR))},dismiss:function(t){return void 0===t&&(t=null),H&&U.emit(d.CLEAR,t)},isActive:V,update:function(t,e){setTimeout(function(){if(H&&void 0!==H.collection[t]){var n=H.collection[t],o=n.options,r=n.content,s=G({},o,e,{toastId:e.toastId||t});e.toastId&&e.toastId!==t?s.staleToastId=t:s.updateId=z();var i=void 0!==s.render?s.render:r;delete s.render,K(i,s)}},0)},done:function(t,e){void 0===e&&(e=1),Z.update(t,{progress:e,isProgressDone:!0})},onChange:function(t){"function"==typeof t&&U.on(d.ON_CHANGE,t)},POSITION:p,TYPE:f});U.on(d.DID_MOUNT,function(t){H=t,Z.isActive=function(t){return H.isToastActive(t)},X.forEach(function(t){U.emit(t.action,t.content,t.options)}),X=[]}).on(d.WILL_UNMOUNT,function(){H=null,Z.isActive=V});var J=Z;n.d(e,"ToastContainer",function(){return B}),n.d(e,"toast",function(){return J}),n.d(e,"cssTransition",function(){return M}),n.d(e,"Bounce",function(){return I}),n.d(e,"Slide",function(){return k}),n.d(e,"Zoom",function(){return L}),n.d(e,"Flip",function(){return F}),n.d(e,"ToastPosition",function(){return p}),n.d(e,"ToastType",function(){return f})}])}); | ||
//# sourceMappingURL=ReactToastify.js.map |
@@ -74,2 +74,4 @@ import * as React from 'react'; | ||
type ToastId = number | string; | ||
interface cssTransitionProps { | ||
@@ -203,3 +205,8 @@ /** | ||
*/ | ||
toastId?: number | string; | ||
toastId?: ToastId; | ||
/** | ||
* Set the percentage for the controlled progress bar. `Value must be between 0 and 1.` | ||
*/ | ||
progress?: number; | ||
} | ||
@@ -264,3 +271,3 @@ | ||
*/ | ||
isActive(toastId: number): boolean; | ||
isActive(toastId: ToastId): boolean; | ||
@@ -271,3 +278,3 @@ /** | ||
*/ | ||
dismiss(toastId?: number): void; | ||
dismiss(toastId?: ToastId): void; | ||
@@ -277,3 +284,3 @@ /** | ||
*/ | ||
update(toastId: number, options?: UpdateOptions): void; | ||
update(toastId: ToastId, options?: UpdateOptions): void; | ||
@@ -286,2 +293,7 @@ /** | ||
/** | ||
* Set a controlled progress bar value to 100% then close the toast | ||
*/ | ||
done(toastId: ToastId, progress?: number): void; | ||
/** | ||
* Display a toast without a specific type. | ||
@@ -288,0 +300,0 @@ */ |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _propValidator = require("../utils/propValidator"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,2 +22,4 @@ | ||
function ProgressBar(_ref) { | ||
var _animationEvent; | ||
var delay = _ref.delay, | ||
@@ -28,2 +32,5 @@ isRunning = _ref.isRunning, | ||
userStyle = _ref.style, | ||
controlledProgress = _ref.controlledProgress, | ||
progress = _ref.progress, | ||
isProgressDone = _ref.isProgressDone, | ||
rtl = _ref.rtl; | ||
@@ -34,13 +41,14 @@ | ||
animationPlayState: isRunning ? 'running' : 'paused', | ||
opacity: hide ? 0 : 1 | ||
opacity: hide ? 0 : 1, | ||
transform: controlledProgress ? "scaleX(" + progress + ")" : null | ||
}); | ||
var classNames = (0, _classnames.default)('Toastify__progress-bar', "Toastify__progress-bar--" + type, { | ||
var classNames = (0, _classnames.default)('Toastify__progress-bar', controlledProgress ? 'Toastify__progress-bar--controlled' : 'Toastify__progress-bar--animated', "Toastify__progress-bar--" + type, { | ||
'Toastify__progress-bar--rtl': rtl | ||
}, className); | ||
return _react.default.createElement("div", { | ||
var animationEvent = (_animationEvent = {}, _animationEvent[controlledProgress && isProgressDone ? 'onTransitionEnd' : 'onAnimationEnd'] = controlledProgress && !isProgressDone ? null : closeToast, _animationEvent); | ||
return _react.default.createElement("div", _extends({ | ||
className: classNames, | ||
style: style, | ||
onAnimationEnd: closeToast | ||
}); | ||
style: style | ||
}, animationEvent)); | ||
} | ||
@@ -52,3 +60,3 @@ | ||
*/ | ||
delay: _propTypes.default.number.isRequired, | ||
delay: _propValidator.falseOrDelay.isRequired, | ||
@@ -83,3 +91,18 @@ /** | ||
*/ | ||
className: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]) | ||
className: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]), | ||
/** | ||
* Controlled progress value | ||
*/ | ||
progress: _propTypes.default.number, | ||
/** | ||
* Tell wether or not controlled progress bar is used | ||
*/ | ||
controlledProgress: _propTypes.default.bool, | ||
/** | ||
* Helper to close the toast when using controlled progress value | ||
*/ | ||
isProgressDone: _propTypes.default.bool | ||
}; | ||
@@ -86,0 +109,0 @@ ProgressBar.defaultProps = { |
@@ -231,2 +231,4 @@ "use strict"; | ||
role = _this$props.role, | ||
progress = _this$props.progress, | ||
isProgressDone = _this$props.isProgressDone, | ||
rtl = _this$props.rtl; | ||
@@ -251,2 +253,3 @@ var toastProps = { | ||
var controlledProgress = parseFloat(progress) === progress; | ||
return _react.default.createElement(Transition, { | ||
@@ -270,3 +273,3 @@ in: this.props.in, | ||
className: (0, _classnames.default)('Toastify__toast-body', bodyClassName) | ||
}), children), closeButton && closeButton, autoClose && _react.default.createElement(_ProgressBar.default, _extends({}, updateId ? { | ||
}), children), closeButton && closeButton, (autoClose || controlledProgress) && _react.default.createElement(_ProgressBar.default, _extends({}, updateId && !controlledProgress ? { | ||
key: "pb-" + updateId | ||
@@ -281,3 +284,6 @@ } : {}, { | ||
style: progressStyle, | ||
className: progressClassName | ||
className: progressClassName, | ||
controlledProgress: controlledProgress, | ||
isProgressDone: isProgressDone, | ||
progress: progress | ||
})))); | ||
@@ -312,3 +318,5 @@ }; | ||
progressStyle: _propTypes.default.object, | ||
updateId: _propTypes.default.number, | ||
progress: _propTypes.default.number, | ||
isProgressDone: _propTypes.default.bool, | ||
updateId: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]), | ||
ariaLabel: _propTypes.default.string | ||
@@ -315,0 +323,0 @@ }; |
@@ -58,2 +58,3 @@ "use strict"; | ||
}; | ||
_this.toastKey = 0; | ||
_this.collection = {}; | ||
@@ -76,3 +77,3 @@ | ||
}).on(_constant.ACTION.CLEAR, function (id) { | ||
return id !== null ? _this2.removeToast(id) : _this2.clear(); | ||
return !id ? _this2.clear() : _this2.removeToast(id); | ||
}).emit(_constant.ACTION.DID_MOUNT, this); | ||
@@ -148,2 +149,3 @@ }; | ||
id: toastId, | ||
key: options.key || this.toastKey++, | ||
type: options.type, | ||
@@ -166,3 +168,5 @@ closeToast: closeToast, | ||
autoClose: this.getAutoCloseDelay(options.autoClose), | ||
hideProgressBar: typeof options.hideProgressBar === 'boolean' ? options.hideProgressBar : this.props.hideProgressBar | ||
hideProgressBar: typeof options.hideProgressBar === 'boolean' ? options.hideProgressBar : this.props.hideProgressBar, | ||
progress: Number.parseFloat(options.progress), | ||
isProgressDone: options.isProgressDone | ||
}; | ||
@@ -188,3 +192,5 @@ typeof options.onOpen === 'function' && (toastOptions.onOpen = options.onOpen); | ||
this.setState({ | ||
toast: toastOptions.updateId ? _toConsumableArray(this.state.toast) : _toConsumableArray(this.state.toast).concat([toastId]) | ||
toast: (toastOptions.updateId ? _toConsumableArray(this.state.toast) : _toConsumableArray(this.state.toast).concat([toastId])).filter(function (id) { | ||
return id !== options.staleToastId; | ||
}) | ||
}, this.dispatchChange); | ||
@@ -196,3 +202,3 @@ }; | ||
isDocumentHidden: this.state.isDocumentHidden, | ||
key: "toast-" + options.id | ||
key: "toast-" + options.key | ||
}), content); | ||
@@ -199,0 +205,0 @@ }; |
@@ -16,3 +16,2 @@ "use strict"; | ||
var queue = []; | ||
var toastId = 0; | ||
@@ -30,6 +29,14 @@ var noop = function noop() { | ||
type: type, | ||
toastId: generateToastId(options) | ||
toastId: getToastId(options) | ||
}); | ||
} | ||
/** | ||
* Generate a random toastId | ||
*/ | ||
function generateToastId() { | ||
return (Math.random().toString(36) + Date.now().toString(36)).substr(2, 10); | ||
} | ||
/** | ||
* Generate the toastId either automatically or by provided toastId | ||
@@ -39,8 +46,8 @@ */ | ||
function generateToastId(options) { | ||
if (options && (typeof options.toastId === 'number' && !isNaN(options.toastId) || typeof options.toastId === 'string')) { | ||
function getToastId(options) { | ||
if (options && (typeof options.toastId === 'string' || typeof options.toastId === 'number' && !isNaN(options.toastId))) { | ||
return options.toastId; | ||
} | ||
return ++toastId; | ||
return generateToastId(); | ||
} | ||
@@ -98,9 +105,13 @@ /** | ||
oldContent = _container$collection.content; | ||
var updateId = oldOptions.updateId ? oldOptions.updateId + 1 : 1; | ||
var nextOptions = _extends({}, oldOptions, options, { | ||
toastId: toastId, | ||
updateId: updateId | ||
toastId: options.toastId || toastId | ||
}); | ||
if (!options.toastId || options.toastId === toastId) { | ||
nextOptions.updateId = generateToastId(); | ||
} else { | ||
nextOptions.staleToastId = toastId; | ||
} | ||
var content = typeof nextOptions.render !== 'undefined' ? nextOptions.render : oldContent; | ||
@@ -112,2 +123,12 @@ delete nextOptions.render; | ||
}, | ||
done: function done(id, progress) { | ||
if (progress === void 0) { | ||
progress = 1; | ||
} | ||
toast.update(id, { | ||
progress: progress, | ||
isProgressDone: true | ||
}); | ||
}, | ||
onChange: function onChange(callback) { | ||
@@ -141,3 +162,2 @@ if (typeof callback === 'function') { | ||
toast.isActive = noop; | ||
toastId = 0; | ||
}); | ||
@@ -144,0 +164,0 @@ |
@@ -13,6 +13,2 @@ "use strict"; | ||
off: function off(event) { | ||
if (event === void 0) { | ||
event = null; | ||
} | ||
this.list.delete(event); | ||
@@ -19,0 +15,0 @@ return this; |
{ | ||
"name": "react-toastify", | ||
"version": "4.4.3", | ||
"version": "4.5.0-rc.1", | ||
"description": "React notification made easy", | ||
@@ -104,2 +104,3 @@ "keywords": [ | ||
"rimraf": "^2.6.2", | ||
"sass-loader": "^7.1.0", | ||
"style-loader": "^0.23.0", | ||
@@ -106,0 +107,0 @@ "webpack": "^4.17.1", |
101
README.md
@@ -22,5 +22,7 @@ # 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)]() [![Coverage Status](https://coveralls.io/repos/github/fkhadra/react-toastify/badge.svg?branch=master)](https://coveralls.io/github/fkhadra/react-toastify?branch=master) | ||
- [Prevent duplicate](#prevent-duplicate) | ||
- [Use a controlled progress bar](#use-a-controlled-progress-bar) | ||
- [Update a toast](#update-a-toast) | ||
- [Basic example](#basic-example) | ||
- [Update the content](#update-the-content) | ||
- [Update the toast id](#update-the-toast-id) | ||
- [Apply a transition](#apply-a-transition) | ||
@@ -83,2 +85,3 @@ - [Reset option or inherit from ToastContainer](#reset-option-or-inherit-from-toastcontainer) | ||
- Possibility to update a toast | ||
- You can controll the progress bar a la npgrogress 😲 | ||
@@ -122,9 +125,12 @@ ## From v3 to v4 | ||
Remember to render the `ToastContainer` *once* in your application tree. | ||
If you can't figure out where to put it, rendering it in the application root would be the best bet. | ||
### Positioning toast | ||
By default, all the toasts will be positionned on the top right of your browser. If a position is set on a toast, the one defined on ToastContainer will be replaced. | ||
By default, all the toasts will be positioned on the top right of your browser. If a position is set on a `toast`, the one defined on ToastContainer will be replaced. | ||
The following values are allowed: **top-right, top-center, top-left, bottom-right, bottom-center, bottom-left** | ||
For convenience, toast expose a POSITION property to avoid any typo. | ||
For convenience, `toast` expose a POSITION property to avoid any typo. | ||
@@ -282,7 +288,7 @@ ```javascript | ||
#### Usage with redux | ||
### Usage with redux | ||
"Talk is cheap. Show me the code" | ||
[![Edit react+redux+react-toastify](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/r0kv8km1pp) | ||
[![Edit react+redux+react-toastify](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/2485wxy78j) | ||
@@ -360,2 +366,52 @@ ### Pause toast timer when the window loses focus | ||
### Use a controlled progress bar | ||
Imagine you want to see the progress of a file upload. The example below feature axios, but it works with anything! | ||
```javascript | ||
import React, { Component } from 'react'; | ||
import { toast } from 'react-toastify'; | ||
import axios from 'axios'; | ||
class Example extends Component { | ||
upload = () => { | ||
// we need to keep a reference of the toastId to be able to update it | ||
let toastId = null; | ||
axios.request({ | ||
method: "post", | ||
url: "/foobar", | ||
data: myData, | ||
onUploadProgress: p => { | ||
const progress = p.loaded / p.total; | ||
// check if we already displayed a toast | ||
if(toastId === null){ | ||
toastId = toast('Upload in Progress', { | ||
progress: progress | ||
}); | ||
} else { | ||
toast.update(toastId, { | ||
progress: progress | ||
}) | ||
} | ||
} | ||
}).then (data => { | ||
// Upload is done! | ||
// The remaining progress bar will be filled up | ||
// The toast will be closed when the transition end | ||
toast.done(toast.id) | ||
}) | ||
} | ||
render(){ | ||
return ( | ||
<div> | ||
<button onClick={this.upload}>Upload something</button> | ||
</div> | ||
); | ||
} | ||
} | ||
``` | ||
### Update a toast | ||
@@ -409,4 +465,22 @@ | ||
}); | ||
``` | ||
#### Update the toast id | ||
If you want to update the `toastId` it can be done. But don't forget to use the new id! | ||
```js | ||
const myNewToastId = 'loremIpsum'; | ||
toast.update(this.toastId, { | ||
render: "New content", | ||
type: toast.TYPE.INFO, | ||
autoClose: 5000, | ||
toastId: myNewToastId | ||
}); | ||
toast.update(myNewToastId, { | ||
render: <MyComponent /> | ||
autoClose: 6000 | ||
}); | ||
``` | ||
@@ -453,3 +527,3 @@ | ||
If you want to inherit props from the `ToastContainer`, you can reset an option by passing null. | ||
It's particulary usefull when you remove the `closeButton` from a toast and you want it back during the update: | ||
It's particulary useful when you remove the `closeButton` from a toast and you want it back during the update: | ||
@@ -484,3 +558,3 @@ ```js | ||
You can define two callback on toast. They are really useful when the toast are not used only to display messages. | ||
You can define two callbacks on `toast`. They are really useful when the toast are not used only to display messages. | ||
@@ -693,3 +767,3 @@ - onOpen is called inside componentDidMount | ||
There is 4 built-in transition provided: | ||
There is 4 built-in transitions provided: | ||
@@ -1072,2 +1146,3 @@ <details> | ||
- `toastId`: optional integer or string to manually set a toastId. If an invalid type is provided a generated toastId will be used | ||
- `progress`: a value between 0..1 to control the progress bar | ||
- `render`: string or React Element, only available when calling update | ||
@@ -1079,3 +1154,3 @@ | ||
```javascript | ||
```js | ||
const Img = ({ src }) => <div><img width={48} src={src} /></div>; | ||
@@ -1092,2 +1167,3 @@ const options = { | ||
transition: MyCustomTransition, | ||
progress: 0.2 | ||
// and so on ... | ||
@@ -1109,2 +1185,3 @@ }; | ||
}); | ||
toast.done(toastId); | ||
``` | ||
@@ -1154,12 +1231,6 @@ | ||
Show your ❤️ and support by giving a ⭐. Any suggestions and pull request are welcome ! | ||
Show your ❤️ and support by giving a ⭐. Any suggestions are welcome ! Take a look at the contributing guide. | ||
Try the playground: | ||
```js | ||
npm start | ||
``` | ||
## License | ||
Licensed under MIT |
@@ -41,2 +41,9 @@ /* eslint-env jest */ | ||
}); | ||
it('Should render controlled progress bar', () => { | ||
const component = shallow( | ||
<ProgressBar {...REQUIRED_PROPS} controlledProgress progress={0.7} /> | ||
); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
@@ -179,2 +179,25 @@ /* eslint-env jest */ | ||
it('Should render toast with controlled progress bar', () => { | ||
const component = shallow( | ||
<Toast {...REQUIRED_PROPS} progress={0.3} controlledProgress> | ||
FooBar | ||
</Toast> | ||
); | ||
expect(component.html()).toMatch(/transform:(\s)?scaleX\(0.3\)/); | ||
}); | ||
it('Should render toast with controlled progress bar even if autoClose is false', () => { | ||
const component = shallow( | ||
<Toast | ||
{...REQUIRED_PROPS} | ||
progress={0.3} | ||
autoClose={false} | ||
controlledProgress | ||
> | ||
FooBar | ||
</Toast> | ||
); | ||
expect(component.html()).toMatch(/transform:(\s)?scaleX\(0.3\)/); | ||
}); | ||
describe('Drag event', () => { | ||
@@ -181,0 +204,0 @@ it('Should handle drag start on mousedown', () => { |
@@ -158,2 +158,18 @@ /* eslint-env jest */ | ||
}); | ||
it('Should be able to update the toastId', () => { | ||
const component = mount(<ToastContainer />); | ||
const id = toast('hello'); | ||
const updateId = 'foo'; | ||
jest.runAllTimers(); | ||
expect(component.html()).toMatch(/hello/); | ||
toast.update(id, { | ||
toastId: updateId | ||
}); | ||
jest.runAllTimers(); | ||
expect(component.html()).toMatch(/hello/); | ||
expect(toast.isActive(id)).toBe(false); | ||
expect(toast.isActive(updateId)).toBe(true); | ||
}); | ||
}); | ||
@@ -217,2 +233,42 @@ | ||
}); | ||
describe('Controlled progress bar', () => { | ||
it('Should be possible to use a controlled progress bar', () => { | ||
const component = mount(<ToastContainer />); | ||
toast('Hello', { | ||
progress: 0.5 | ||
}); | ||
jest.runAllTimers(); | ||
expect(component.html()).toMatch(/transform:(\s)?scaleX\(0.5\)/); | ||
}); | ||
it('It should close the toast when `toast.done` is called', () => { | ||
const component = mount(<ToastContainer />); | ||
const id = toast('Hello', { | ||
progress: 0.5 | ||
}); | ||
jest.runAllTimers(); | ||
expect(component.html()).toMatch(/Hello/); | ||
toast.done(id); | ||
jest.runAllTimers(); | ||
// Ok I cheated here 💩, I'm not testing if onTransitionEnd is triggered | ||
// Shame on me 😭 | ||
expect(component.html()).toMatch(/transform:(\s)?scaleX\(1\)/); | ||
}); | ||
it('It should be possible to define a percentage when `toast.done` is called', () => { | ||
const component = mount(<ToastContainer />); | ||
const id = toast('Hello', { | ||
progress: 1 | ||
}); | ||
jest.runAllTimers(); | ||
expect(component.html()).toMatch(/transform:(\s)?scaleX\(1\)/); | ||
toast.done(id, 0); | ||
jest.runAllTimers(); | ||
expect(component.html()).toMatch(/transform:(\s)?scaleX\(0\)/); | ||
}); | ||
}); | ||
}); |
@@ -6,2 +6,3 @@ import React from 'react'; | ||
import { TYPE } from './../utils/constant'; | ||
import { falseOrDelay } from '../utils/propValidator'; | ||
@@ -16,2 +17,5 @@ function ProgressBar({ | ||
style: userStyle, | ||
controlledProgress, | ||
progress, | ||
isProgressDone, | ||
rtl | ||
@@ -23,3 +27,4 @@ }) { | ||
animationPlayState: isRunning ? 'running' : 'paused', | ||
opacity: hide ? 0 : 1 | ||
opacity: hide ? 0 : 1, | ||
transform: controlledProgress ? `scaleX(${progress})` : null | ||
}; | ||
@@ -29,2 +34,5 @@ | ||
'Toastify__progress-bar', | ||
controlledProgress | ||
? 'Toastify__progress-bar--controlled' | ||
: 'Toastify__progress-bar--animated', | ||
`Toastify__progress-bar--${type}`, | ||
@@ -37,5 +45,10 @@ { | ||
return ( | ||
<div className={classNames} style={style} onAnimationEnd={closeToast} /> | ||
); | ||
const animationEvent = { | ||
[controlledProgress && isProgressDone | ||
? 'onTransitionEnd' | ||
: 'onAnimationEnd']: | ||
controlledProgress && !isProgressDone ? null : closeToast | ||
}; | ||
return <div className={classNames} style={style} {...animationEvent} />; | ||
} | ||
@@ -47,3 +60,3 @@ | ||
*/ | ||
delay: PropTypes.number.isRequired, | ||
delay: falseOrDelay.isRequired, | ||
@@ -78,3 +91,18 @@ /** | ||
*/ | ||
className: PropTypes.oneOfType([PropTypes.string, PropTypes.object]) | ||
className: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
/** | ||
* Controlled progress value | ||
*/ | ||
progress: PropTypes.number, | ||
/** | ||
* Tell wether or not controlled progress bar is used | ||
*/ | ||
controlledProgress: PropTypes.bool, | ||
/** | ||
* Helper to close the toast when using controlled progress value | ||
*/ | ||
isProgressDone: PropTypes.bool | ||
}; | ||
@@ -81,0 +109,0 @@ |
@@ -54,3 +54,5 @@ import React, { Component } from 'react'; | ||
progressStyle: PropTypes.object, | ||
updateId: PropTypes.number, | ||
progress: PropTypes.number, | ||
isProgressDone: PropTypes.bool, | ||
updateId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
ariaLabel: PropTypes.string | ||
@@ -257,2 +259,4 @@ }; | ||
role, | ||
progress, | ||
isProgressDone, | ||
rtl | ||
@@ -282,2 +286,4 @@ } = this.props; | ||
const controlledProgress = parseFloat(progress) === progress; | ||
return ( | ||
@@ -306,5 +312,7 @@ <Transition | ||
{closeButton && closeButton} | ||
{autoClose && ( | ||
{(autoClose || controlledProgress) && ( | ||
<ProgressBar | ||
{...(updateId ? { key: `pb-${updateId}` } : {})} | ||
{...(updateId && !controlledProgress | ||
? { key: `pb-${updateId}` } | ||
: {})} | ||
rtl={rtl} | ||
@@ -318,2 +326,5 @@ delay={autoClose} | ||
className={progressClassName} | ||
controlledProgress={controlledProgress} | ||
isProgressDone={isProgressDone} | ||
progress={progress} | ||
/> | ||
@@ -320,0 +331,0 @@ )} |
@@ -143,2 +143,7 @@ import React, { Component, isValidElement, cloneElement } from 'react'; | ||
/** | ||
* Keep reference for toastKey | ||
*/ | ||
toastKey = 0; | ||
/** | ||
* Hold toast's informations: | ||
@@ -155,6 +160,3 @@ * - what to render | ||
.on(ACTION.SHOW, (content, options) => this.show(content, options)) | ||
.on( | ||
ACTION.CLEAR, | ||
id => (id !== null ? this.removeToast(id) : this.clear()) | ||
) | ||
.on(ACTION.CLEAR, id => (!id ? this.clear() : this.removeToast(id))) | ||
.emit(ACTION.DID_MOUNT, this); | ||
@@ -239,2 +241,3 @@ } | ||
id: toastId, | ||
key: options.key || this.toastKey++, | ||
type: options.type, | ||
@@ -286,3 +289,5 @@ closeToast: closeToast, | ||
? options.hideProgressBar | ||
: this.props.hideProgressBar | ||
: this.props.hideProgressBar, | ||
progress: Number.parseFloat(options.progress), | ||
isProgressDone: options.isProgressDone | ||
}; | ||
@@ -320,5 +325,6 @@ | ||
{ | ||
toast: toastOptions.updateId | ||
toast: (toastOptions.updateId | ||
? [...this.state.toast] | ||
: [...this.state.toast, toastId] | ||
).filter(id => id !== options.staleToastId) | ||
}, | ||
@@ -334,3 +340,3 @@ this.dispatchChange | ||
isDocumentHidden={this.state.isDocumentHidden} | ||
key={`toast-${options.id}`} | ||
key={`toast-${options.key}`} | ||
> | ||
@@ -337,0 +343,0 @@ {content} |
@@ -6,3 +6,2 @@ import eventManager from './utils/eventManager'; | ||
let queue = []; | ||
let toastId = 0; | ||
const noop = () => false; | ||
@@ -14,13 +13,20 @@ | ||
function mergeOptions(options, type) { | ||
return { ...options, type, toastId: generateToastId(options) }; | ||
return { ...options, type, toastId: getToastId(options) }; | ||
} | ||
/** | ||
* Generate a random toastId | ||
*/ | ||
function generateToastId() { | ||
return (Math.random().toString(36) + Date.now().toString(36)).substr(2, 10); | ||
} | ||
/** | ||
* Generate the toastId either automatically or by provided toastId | ||
*/ | ||
function generateToastId(options) { | ||
function getToastId(options) { | ||
if ( | ||
options && | ||
((typeof options.toastId === 'number' && !isNaN(options.toastId)) || | ||
typeof options.toastId === 'string') | ||
(typeof options.toastId === 'string' || | ||
(typeof options.toastId === 'number' && !isNaN(options.toastId))) | ||
) { | ||
@@ -30,3 +36,3 @@ return options.toastId; | ||
return ++toastId; | ||
return generateToastId(); | ||
} | ||
@@ -73,3 +79,2 @@ | ||
} = container.collection[toastId]; | ||
const updateId = oldOptions.updateId ? oldOptions.updateId + 1 : 1; | ||
@@ -79,6 +84,11 @@ const nextOptions = { | ||
...options, | ||
toastId, | ||
updateId | ||
toastId: options.toastId || toastId | ||
}; | ||
if (!options.toastId || options.toastId === toastId) { | ||
nextOptions.updateId = generateToastId(); | ||
} else { | ||
nextOptions.staleToastId = toastId; | ||
} | ||
const content = | ||
@@ -93,2 +103,8 @@ typeof nextOptions.render !== 'undefined' | ||
}, | ||
done(id, progress = 1) { | ||
toast.update(id, { | ||
progress, | ||
isProgressDone: true | ||
}); | ||
}, | ||
onChange(callback) { | ||
@@ -122,5 +138,4 @@ if (typeof callback === 'function') { | ||
toast.isActive = noop; | ||
toastId = 0; | ||
}); | ||
export default toast; |
@@ -12,3 +12,3 @@ const eventManager = { | ||
off(event = null) { | ||
off(event) { | ||
this.list.delete(event); | ||
@@ -15,0 +15,0 @@ return this; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
346232
3635
1223
46
2