react-toastify
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-addons-transition-group")):"function"==typeof define&&define.amd?define(["react","react-addons-transition-group"],e):"object"==typeof exports?exports.ReactToastify=e(require("react"),require("react-addons-transition-group")):t.ReactToastify=e(t.React,t.React.addons.TransitionGroup)}(this,function(t,e){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([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,n(15);var r=n(17),i=o(r),u=n(18),s=o(u);e.ToastContainer=i.default,e.toast=s.default},function(t,e){"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"}}},function(t,e,n){var o=n(26);t.exports=Function.prototype.bind||o},function(t,e){"use strict";var n=Function.prototype.toString,o=/^\s*class /,r=function(t){try{var e=n.call(t),r=e.replace(/\/\/.*\n/g,""),i=r.replace(/\/\*[.\s\S]*\*\//g,""),u=i.replace(/\n/gm," ").replace(/ {2}/g," ");return o.test(u)}catch(t){return!1}},i=function(t){try{return!r(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,s="[object Function]",a="[object GeneratorFunction]",l="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(l)return i(t);if(r(t))return!1;var e=u.call(t);return e===s||e===a}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={eventList:new Map,on:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.eventList.has(t)||this.eventList.set(t,[]),this.eventList.get(t).push({callback:e,context:n||this}),this},off:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!=t&&null==e)return this.eventList.delete(t);if(null!=t&&null!=e){var n=this.eventList.get(t);return this.eventList.set(t,n.filter(function(t){return!(t.callback===e||t.callback.toString()===e.toString())})),n.length>0||this.eventList.delete(t),!0}return null===t&&null===e&&(this.eventList.clear(),!0)},once:function(t,e,n){this.on(t,e,n);var o=this.eventList.get(t),r=o.length-1;return o[r].once=!0,this},emit:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];if(!this.eventList.has(t))return console.warn("<"+t+"> Event is not registered. Did you forgot to bind the event ?"),!1;var r=this.eventList.get(t);return this.eventList.set(t,r.filter(function(t){var e;return(e=t.callback).call.apply(e,[t.context].concat(n)),!t.once})),!0}};e.default=n},function(t,e,n){"use strict";var o=n(31),r=n(25),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),u=Object.prototype.toString,s=function(t){return"function"==typeof t&&"[object Function]"===u.call(t)},a=function(){var t={};try{Object.defineProperty(t,"x",{enumerable:!1,value:t});for(var e in t)return!1;return t.x===t}catch(t){return!1}},l=Object.defineProperty&&a(),c=function(t,e,n,o){(!(e in t)||s(o)&&o())&&(l?Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n,writable:!0}):t[e]=n)},f=function(t,e){var n=arguments.length>2?arguments[2]:{},u=o(e);i&&(u=u.concat(Object.getOwnPropertySymbols(e))),r(u,function(o){c(t,o,e[o],n[o])})};f.supportsDescriptors=!!l,t.exports=f},function(t,e){var n=Object.prototype.hasOwnProperty;t.exports=Object.assign||function(t,e){for(var o in e)n.call(e,o)&&(t[o]=e[o]);return t}},function(t,e){var n=Number.isNaN||function(t){return t!==t};t.exports=Number.isFinite||function(t){return"number"==typeof t&&!n(t)&&t!==1/0&&t!==-(1/0)}},function(t,e){t.exports=Number.isNaN||function(t){return t!==t}},function(t,e){t.exports=function(t,e){var n=t%e;return Math.floor(n>=0?n:n+e)}},function(t,e){t.exports=function(t){return t>=0?1:-1}},function(t,e){t.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},function(t,e,n){"use strict";var o=n(21),r=n(27),i=n(2),u=i.call(Function.call,Object.prototype.propertyIsEnumerable);t.exports=function(t){var e=o.RequireObjectCoercible(t),n=[];for(var i in e)r(e,i)&&u(e,i)&&n.push(e[i]);return n}},function(t,e,n){"use strict";var o=n(12);t.exports=function(){return"function"==typeof Object.values?Object.values:o}},function(e,n){e.exports=t},function(t,e,n){"use strict";var o=n(33);Object.values||o.shim()},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 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 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=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}}(),l=n(14),c=o(l),f=n(1),p=o(f),y={id:l.PropTypes.number.isRequired,handleCloseBtn:l.PropTypes.func.isRequired,children:l.PropTypes.node.isRequired,autoCloseId:l.PropTypes.number,autoCloseDelay:l.PropTypes.number,handleMouseEnter:l.PropTypes.func,handleMouseLeave:l.PropTypes.func,onOpen:l.PropTypes.func,onClose:l.PropTypes.func,type:l.PropTypes.oneOf(Object.values(p.default.TYPE)),childrenProps:l.PropTypes.object,position:l.PropTypes.oneOf(Object.values(p.default.POSITION))},b={type:p.default.TYPE.DEFAULT,childrenProps:{}},h=function(t){function e(t){r(this,e);var n=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.setRef=n.setRef.bind(n),n.ref=null,n}return u(e,t),a(e,[{key:"componentDidMount",value:function(){this.props.onOpen(this.getChildrenProps())}},{key:"componentWillUnmount",value:function(){this.props.onClose(this.getChildrenProps())}},{key:"setRef",value:function(t){this.ref=t}},{key:"getChildrenProps",value:function(){return Object.assign({},this.props.childrenProps,this.props.children.props)}},{key:"getChildren",value:function(){var t=this.props.childrenProps;return l.Children.map(this.props.children,function(e){return(0,l.cloneElement)(e,s({},t,e.props))})}},{key:"getToastProps",value:function(){var t=this.props,e=t.autoCloseId,n=t.autoCloseDelay,o=t.handleMouseEnter,r=t.handleMouseLeave,i={"data-toast-id":this.props.id,className:"toastify-content toastify-content--"+this.props.type,ref:this.setRef};return this.props.autoCloseId&&(i["data-auto-close-id"]=e,i["data-auto-close-delay"]=n,i.onMouseEnter=o,i.onMouseLeave=r),i}},{key:"componentWillEnter",value:function(t){this.ref.classList.add("bounceIn--"+this.props.position,"animated"),t()}},{key:"componentWillLeave",value:function(t){this.ref.classList.remove("bounceIn--"+this.props.position,"animated"),this.ref.classList.add("bounceOut--"+this.props.position,"animated"),setTimeout(function(){return t()},1e3)}},{key:"render",value:function(){return c.default.createElement("div",this.getToastProps(),c.default.createElement("button",{className:"toastify__close",type:"button",onClick:this.props.handleCloseBtn,value:this.props.id},"×"),c.default.createElement("div",{className:"toastify__body"},this.getChildren()))}}]),e}(l.Component);h.defaultProps=b,h.propTypes=y,e.default=h},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(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=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="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=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(14),p=o(f),y=n(35),b=o(y),h=n(4),d=o(h),v=n(16),m=o(v),O=n(1),g=o(O),T={position:f.PropTypes.oneOf(Object.values(g.default.POSITION)),autoClose:f.PropTypes.oneOfType([f.PropTypes.bool,f.PropTypes.number]),className:f.PropTypes.string,style:f.PropTypes.object},j={position:g.default.POSITION.TOP_RIGHT,autoClose:5e3},S=function(t){function e(t){i(this,e);var n=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.state={toast:{}},n.toastId=0,n.handleCloseBtn=n.handleCloseBtn.bind(n),n.handleMouseEnter=n.handleMouseEnter.bind(n),n.handleMouseLeave=n.handleMouseLeave.bind(n),n}return s(e,t),c(e,[{key:"componentDidMount",value:function(){var t=this;d.default.on(g.default.ACTION.SHOW,function(e,n){return t.show(e,n)}).on(g.default.ACTION.CLEAR,function(){return t.clear()})}},{key:"shouldComponentUpdate",value:function(t,e){return!this.isEqualToPreviousState(e)}},{key:"componentWillUnmount",value:function(){d.default.off(g.default.ACTION.SHOW),d.default.off(g.default.ACTION.CLEAR)}},{key:"setAutoClose",value:function(t,e){var n=this;return setTimeout(function(){return n.removeToast(t)},e)}},{key:"isEqualToPreviousState",value:function(t){var e=Object.keys(t.toast),n=Object.keys(this.state.toast);if(e.length!==n.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==e[o])return!1;return!0}},{key:"isContentValid",value:function(t){return(0,f.isValidElement)(t)}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{key:"childrenHasProps",value:function(t){return"object"===("undefined"==typeof t?"undefined":l(t))&&"Object"===t.constructor.name}},{key:"shouldAutoClose",value:function(t){return!!(this.props.autoClose!==!1&&t!==!1||this.props.autoClose===!1&&t!==!1&&null!==t)}},{key:"removeToast",value:function(t){var e=Object.assign({},this.state.toast);delete e[t],this.setState({toast:e})}},{key:"show",value:function(t,e){if(t="string"==typeof t?p.default.createElement("div",null,t):t,this.isContentValid(t)){var n=++this.toastId,o=e.autoClose,i=function(){},u={id:n,type:e.type,onOpen:this.isFunction(e.onOpen)?e.onOpen:i,onClose:this.isFunction(e.onClose)?e.onClose:i};if(this.childrenHasProps(e.props)&&(u.childrenProps=e.props),this.shouldAutoClose(o)){var s=null!==o?parseInt(o,10):this.props.autoClose;u.autoCloseId=this.setAutoClose(n,s),u.autoCloseDelay=s,u.handleMouseEnter=this.handleMouseEnter,u.handleMouseLeave=this.handleMouseLeave}this.setState({toast:Object.assign({},this.state.toast,r({},n,this.makeToast(t,u)))})}}},{key:"makeToast",value:function(t,e){return p.default.createElement(m.default,a({},e,{position:this.props.position,key:"toast-"+e.id+" ",handleCloseBtn:this.handleCloseBtn}),t)}},{key:"clear",value:function(){this.setState({toast:{}})}},{key:"handleCloseBtn",value:function(t){this.removeToast(t.target.value)}},{key:"handleMouseEnter",value:function(t){clearTimeout(t.currentTarget.dataset.autoCloseId)}},{key:"handleMouseLeave",value:function(t){var e=t.currentTarget.dataset,n=e.toastId,o=e.autoCloseDelay,r=(0,f.cloneElement)(this.state.toast[n],{autoCloseId:this.setAutoClose(n,o)}),i=Object.assign({},this.state.toast);delete i[n],i[n]=r,this.setState({toast:i})}},{key:"isObjectEmpty",value:function(){return 0===Object.keys(this.state.toast).length}},{key:"renderProps",value:function(){var t={className:"toastify toastify--"+this.props.position};return this.props.className&&(t.className=t.className+" "+this.props.className),this.props.style&&(t.style=this.props.style),t}},{key:"renderToast",value:function(){return Object.values(this.state.toast)}},{key:"render",value:function(){return p.default.createElement("div",this.renderProps(),p.default.createElement(b.default,null,this.isObjectEmpty()?null:this.renderToast()))}}]),e}(f.Component);S.defaultProps=j,S.propTypes=T,e.default=S},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){return Object.assign({},p,t)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),u=o(i),s=n(1),a=o(s),l=a.default.POSITION,c=a.default.TYPE,f=a.default.ACTION,p={type:c.DEFAULT,autoClose:null},y=function(t,e){return u.default.emit(f.SHOW,t,e)};e.default=Object.assign(function(t,e){return y(t,r(e))},{success:function(t,e){return y(t,Object.assign(r(e),{type:c.SUCCESS}))},info:function(t,e){return y(t,Object.assign(r(e),{type:c.INFO}))},warn:function(t,e){return y(t,Object.assign(r(e),{type:c.WARNING}))},error:function(t,e){return y(t,Object.assign(r(e),{type:c.ERROR}))},dismiss:function(){return u.default.emit(f.CLEAR)}},{POSITION:l,TYPE:c})},function(t,e,n){"use strict";var o=n(8),r=n(7),i=n(10),u=n(9),s=n(3),a=n(23),l={ToPrimitive:a,ToBoolean:function(t){return Boolean(t)},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return o(e)?0:0!==e&&r(e)?i(e)*Math.floor(Math.abs(e)):e},ToInt32:function(t){return this.ToNumber(t)>>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(o(e)||0===e||!r(e))return 0;var n=i(e)*Math.floor(Math.abs(e));return u(n,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:s,SameValue:function(t,e){return t===e?0!==t||1/t===1/e:o(t)&&o(e)},Type:function(t){return null===t?"Null":"undefined"==typeof t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0}};t.exports=l},function(t,e,n){"use strict";var o=Object.prototype.toString,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,i=r?Symbol.prototype.toString:o,u=n(8),s=n(7),a=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=n(6),c=n(10),f=n(9),p=n(22),y=n(24),b=parseInt,h=n(2),d=h.call(Function.call,String.prototype.slice),v=h.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i),m=h.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i),O=[" ","",""].join(""),g=new RegExp("["+O+"]","g"),T=h.call(Function.call,RegExp.prototype.test,g),j=/^[\-\+]0x[0-9a-f]+$/i,S=h.call(Function.call,RegExp.prototype.test,j),w=["\t\n\v\f\r "," \u2028","\u2029\ufeff"].join(""),E=new RegExp("(^["+w+"]+)|(["+w+"]+$)","g"),C=h.call(Function.call,String.prototype.replace),P=function(t){return C(t,E,"")},N=n(19),x=n(29),I=l(l({},N),{Call:function(t,e){var n=arguments.length>2?arguments[2]:[];if(!this.IsCallable(t))throw new TypeError(t+" is not a function");return t.apply(e,n)},ToPrimitive:y,ToNumber:function(t){var e=p(t)?t:y(t,"number");if("symbol"==typeof e)throw new TypeError("Cannot convert a Symbol value to a number");if("string"==typeof e){if(v(e))return this.ToNumber(b(d(e,2),2));if(m(e))return this.ToNumber(b(d(e,2),8));if(T(e)||S(e))return NaN;var n=P(e);if(n!==e)return this.ToNumber(n)}return Number(e)},ToInt16:function(t){var e=this.ToUint16(t);return e>=32768?e-65536:e},ToInt8:function(t){var e=this.ToUint8(t);return e>=128?e-256:e},ToUint8:function(t){var e=this.ToNumber(t);if(u(e)||0===e||!s(e))return 0;var n=c(e)*Math.floor(Math.abs(e));return f(n,256)},ToUint8Clamp:function(t){var e=this.ToNumber(t);if(u(e)||e<=0)return 0;if(e>=255)return 255;var n=Math.floor(t);return n+.5<e?n+1:e<n+.5?n:n%2!==0?n+1:n},ToString:function(t){if("symbol"==typeof t)throw new TypeError("Cannot convert a Symbol value to a string");return String(t)},ToObject:function(t){return this.RequireObjectCoercible(t),Object(t)},ToPropertyKey:function(t){var e=this.ToPrimitive(t,String);return"symbol"==typeof e?i.call(e):this.ToString(e)},ToLength:function(t){var e=this.ToInteger(t);return e<=0?0:e>a?a:e},CanonicalNumericIndexString:function(t){if("[object String]"!==o.call(t))throw new TypeError("must be a string");if("-0"===t)return-0;var e=this.ToNumber(t);return this.SameValue(this.ToString(e),t)?e:void 0},RequireObjectCoercible:N.CheckObjectCoercible,IsArray:Array.isArray||function(t){return"[object Array]"===o.call(t)},IsConstructor:function(t){return"function"==typeof t&&!!t.prototype},IsExtensible:function(t){return!Object.preventExtensions||!p(t)&&Object.isExtensible(t)},IsInteger:function(t){if("number"!=typeof t||u(t)||!s(t))return!1;var e=Math.abs(t);return Math.floor(e)===e},IsPropertyKey:function(t){return"string"==typeof t||"symbol"==typeof t},IsRegExp:function(t){if(!t||"object"!=typeof t)return!1;if(r){var e=t[Symbol.match];if("undefined"!=typeof e)return N.ToBoolean(e)}return x(t)},SameValueZero:function(t,e){return t===e||u(t)&&u(e)},Type:function(t){return"symbol"==typeof t?"Symbol":N.Type(t)},SpeciesConstructor:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");var n=t.constructor;if("undefined"==typeof n)return e;if("Object"!==this.Type(n))throw new TypeError("O.constructor is not an Object");var o=r&&Symbol.species?n[Symbol.species]:void 0;if(null==o)return e;if(this.IsConstructor(o))return o;throw new TypeError("no constructor found")}});delete I.CheckObjectCoercible,t.exports=I},function(t,e,n){"use strict";var o=n(20),r=n(6),i=r(o,{SameValueNonNumber:function(t,e){if("number"==typeof t||typeof t!=typeof e)throw new TypeError("SameValueNonNumber requires two non-number values of the same type.");return this.SameValue(t,e)}});t.exports=i},function(t,e){t.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},function(t,e,n){"use strict";var o=Object.prototype.toString,r=n(11),i=n(3),u={"[[DefaultValue]]":function(t,e){var n=e||("[object Date]"===o.call(t)?String:Number);if(n===String||n===Number){var u,s,a=n===String?["toString","valueOf"]:["valueOf","toString"];for(s=0;s<a.length;++s)if(i(t[a[s]])&&(u=t[a[s]](),r(u)))return u;throw new TypeError("No default value")}throw new TypeError("invalid [[DefaultValue]] hint supplied")}};t.exports=function(t,e){return r(t)?t:u["[[DefaultValue]]"](t,e)}},function(t,e,n){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,r=n(11),i=n(3),u=n(28),s=n(30),a=function(t,e){if("undefined"==typeof t||null===t)throw new TypeError("Cannot call method on "+t);if("string"!=typeof e||"number"!==e&&"string"!==e)throw new TypeError('hint must be "string" or "number"');var n,o,u,s="string"===e?["toString","valueOf"]:["valueOf","toString"];for(u=0;u<s.length;++u)if(n=t[s[u]],i(n)&&(o=n.call(t),r(o)))return o;throw new TypeError("No default value")},l=function(t,e){var n=t[e];if(null!==n&&"undefined"!=typeof n){if(!i(n))throw new TypeError(n+" returned for property "+e+" of object "+t+" is not a function");return n}};t.exports=function(t,e){if(r(t))return t;var n="default";arguments.length>1&&(e===String?n="string":e===Number&&(n="number"));var i;if(o&&(Symbol.toPrimitive?i=l(t,Symbol.toPrimitive):s(t)&&(i=Symbol.prototype.valueOf)),"undefined"!=typeof i){var c=i.call(t,n);if(r(c))return c;throw new TypeError("unable to convert exotic object to primitive")}return"default"===n&&(u(t)||s(t))&&(n="string"),a(t,"default"===n?"number":n)}},function(t,e){var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString;t.exports=function(t,e,r){if("[object Function]"!==o.call(e))throw new TypeError("iterator must be a function");var i=t.length;if(i===+i)for(var u=0;u<i;u++)e.call(r,t[u],u,t);else for(var s in t)n.call(t,s)&&e.call(r,t[s],s,t)}},function(t,e){var n="Function.prototype.bind called on incompatible ",o=Array.prototype.slice,r=Object.prototype.toString,i="[object Function]";t.exports=function(t){var e=this;if("function"!=typeof e||r.call(e)!==i)throw new TypeError(n+e);for(var u,s=o.call(arguments,1),a=function(){if(this instanceof u){var n=e.apply(this,s.concat(o.call(arguments)));return Object(n)===n?n:this}return e.apply(t,s.concat(o.call(arguments)))},l=Math.max(0,e.length-s.length),c=[],f=0;f<l;f++)c.push("$"+f);if(u=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(a),e.prototype){var p=function(){};p.prototype=e.prototype,u.prototype=new p,p.prototype=null}return u}},function(t,e,n){var o=n(2);t.exports=o.call(Function.call,Object.prototype.hasOwnProperty)},function(t,e){"use strict";var n=Date.prototype.getDay,o=function(t){try{return n.call(t),!0}catch(t){return!1}},r=Object.prototype.toString,i="[object Date]",u="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"object"==typeof t&&null!==t&&(u?o(t):r.call(t)===i)}},function(t,e){"use strict";var n=RegExp.prototype.exec,o=function(t){try{return n.call(t),!0}catch(t){return!1}},r=Object.prototype.toString,i="[object RegExp]",u="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"object"==typeof t&&(u?o(t):r.call(t)===i)}},function(t,e){"use strict";var n=Object.prototype.toString,o="function"==typeof Symbol&&"symbol"==typeof Symbol();if(o){var r=Symbol.prototype.toString,i=/^Symbol\(.*\)$/,u=function(t){return"symbol"==typeof t.valueOf()&&i.test(r.call(t))};t.exports=function(t){if("symbol"==typeof t)return!0;if("[object Symbol]"!==n.call(t))return!1;try{return u(t)}catch(t){return!1}}}else t.exports=function(t){return!1}},function(t,e,n){"use strict";var o=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Array.prototype.slice,u=n(32),s=Object.prototype.propertyIsEnumerable,a=!s.call({toString:null},"toString"),l=s.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=function(t){var e=t.constructor;return e&&e.prototype===t},p={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},y=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!p["$"+t]&&o.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{f(window[t])}catch(t){return!0}}catch(t){return!0}return!1}(),b=function(t){if("undefined"==typeof window||!y)return f(t);try{return f(t)}catch(t){return!1}},h=function(t){var e=null!==t&&"object"==typeof t,n="[object Function]"===r.call(t),i=u(t),s=e&&"[object String]"===r.call(t),f=[];if(!e&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var p=l&&n;if(s&&t.length>0&&!o.call(t,0))for(var y=0;y<t.length;++y)f.push(String(y));if(i&&t.length>0)for(var h=0;h<t.length;++h)f.push(String(h));else for(var d in t)p&&"prototype"===d||!o.call(t,d)||f.push(String(d));if(a)for(var v=b(t),m=0;m<c.length;++m)v&&"constructor"===c[m]||!o.call(t,c[m])||f.push(c[m]);return f};h.shim=function(){if(Object.keys){var t=function(){return 2===(Object.keys(arguments)||"").length}(1,2);if(!t){var e=Object.keys;Object.keys=function(t){return e(u(t)?i.call(t):t)}}}else Object.keys=h;return Object.keys||h},t.exports=h},function(t,e){"use strict";var n=Object.prototype.toString;t.exports=function(t){var e=n.call(t),o="[object Arguments]"===e;return o||(o="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===n.call(t.callee)),o}},function(t,e,n){"use strict";var o=n(5),r=n(12),i=n(13),u=n(34);o(r,{getPolyfill:i,implementation:r,shim:u}),t.exports=r},function(t,e,n){"use strict";var o=n(13),r=n(5);t.exports=function(){var t=o();return r(Object,{values:t},{values:function(){return Object.values!==t}}),t}},function(t,n){t.exports=e}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-addons-transition-group")):"function"==typeof define&&define.amd?define(["react","react-addons-transition-group"],e):"object"==typeof exports?exports.ReactToastify=e(require("react"),require("react-addons-transition-group")):t.ReactToastify=e(t.React,t.React.addons.TransitionGroup)}(this,function(t,e){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([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,n(16);var r=n(18),i=o(r),u=n(19),s=o(u);e.ToastContainer=i.default,e.toast=s.default},function(t,e){"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"}}},function(t,e,n){var o=n(27);t.exports=Function.prototype.bind||o},function(t,e){"use strict";var n=Function.prototype.toString,o=/^\s*class /,r=function(t){try{var e=n.call(t),r=e.replace(/\/\/.*\n/g,""),i=r.replace(/\/\*[.\s\S]*\*\//g,""),u=i.replace(/\n/gm," ").replace(/ {2}/g," ");return o.test(u)}catch(t){return!1}},i=function(t){try{return!r(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,s="[object Function]",a="[object GeneratorFunction]",l="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(l)return i(t);if(r(t))return!1;var e=u.call(t);return e===s||e===a}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={eventList:new Map,on:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.eventList.has(t)||this.eventList.set(t,[]),this.eventList.get(t).push({callback:e,context:n||this}),this},off:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!=t&&null==e)return this.eventList.delete(t);if(null!=t&&null!=e){var n=this.eventList.get(t);return this.eventList.set(t,n.filter(function(t){return!(t.callback===e||t.callback.toString()===e.toString())})),n.length>0||this.eventList.delete(t),!0}return null===t&&null===e&&(this.eventList.clear(),!0)},once:function(t,e,n){this.on(t,e,n);var o=this.eventList.get(t),r=o.length-1;return o[r].once=!0,this},emit:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];if(!this.eventList.has(t))return console.warn("<"+t+"> Event is not registered. Did you forgot to bind the event ?"),!1;var r=this.eventList.get(t);return this.eventList.set(t,r.filter(function(t){var e;return(e=t.callback).call.apply(e,[t.context].concat(n)),!t.once})),!0}};e.default=n},function(t,e,n){"use strict";var o=n(31),r=n(26),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),u=Object.prototype.toString,s=function(t){return"function"==typeof t&&"[object Function]"===u.call(t)},a=function(){var t={};try{Object.defineProperty(t,"x",{enumerable:!1,value:t});for(var e in t)return!1;return t.x===t}catch(t){return!1}},l=Object.defineProperty&&a(),c=function(t,e,n,o){(!(e in t)||s(o)&&o())&&(l?Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n,writable:!0}):t[e]=n)},f=function(t,e){var n=arguments.length>2?arguments[2]:{},u=o(e);i&&(u=u.concat(Object.getOwnPropertySymbols(e))),r(u,function(o){c(t,o,e[o],n[o])})};f.supportsDescriptors=!!l,t.exports=f},function(t,e){var n=Object.prototype.hasOwnProperty;t.exports=Object.assign||function(t,e){for(var o in e)n.call(e,o)&&(t[o]=e[o]);return t}},function(t,e){var n=Number.isNaN||function(t){return t!==t};t.exports=Number.isFinite||function(t){return"number"==typeof t&&!n(t)&&t!==1/0&&t!==-(1/0)}},function(t,e){t.exports=Number.isNaN||function(t){return t!==t}},function(t,e){t.exports=function(t,e){var n=t%e;return Math.floor(n>=0?n:n+e)}},function(t,e){t.exports=function(t){return t>=0?1:-1}},function(t,e){t.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},function(t,e,n){var o=n(2);t.exports=o.call(Function.call,Object.prototype.hasOwnProperty)},function(t,e,n){"use strict";var o=n(22),r=n(12),i=n(2),u=i.call(Function.call,Object.prototype.propertyIsEnumerable);t.exports=function(t){var e=o.RequireObjectCoercible(t),n=[];for(var i in e)r(e,i)&&u(e,i)&&n.push(e[i]);return n}},function(t,e,n){"use strict";var o=n(13);t.exports=function(){return"function"==typeof Object.values?Object.values:o}},function(e,n){e.exports=t},function(t,e,n){"use strict";var o=n(33);Object.values||o.shim()},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 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 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=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}}(),l=n(15),c=o(l),f=n(1),p=o(f),y={id:l.PropTypes.number.isRequired,handleCloseBtn:l.PropTypes.func.isRequired,children:l.PropTypes.node.isRequired,autoCloseId:l.PropTypes.number,autoCloseDelay:l.PropTypes.number,handleMouseEnter:l.PropTypes.func,handleMouseLeave:l.PropTypes.func,onOpen:l.PropTypes.func,onClose:l.PropTypes.func,type:l.PropTypes.oneOf(Object.values(p.default.TYPE)),childrenProps:l.PropTypes.object,position:l.PropTypes.oneOf(Object.values(p.default.POSITION))},b={type:p.default.TYPE.DEFAULT,childrenProps:{}},h=function(t){function e(t){r(this,e);var n=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.setRef=n.setRef.bind(n),n.ref=null,n}return u(e,t),a(e,[{key:"componentDidMount",value:function(){this.props.onOpen(this.getChildrenProps())}},{key:"componentWillUnmount",value:function(){this.props.onClose(this.getChildrenProps())}},{key:"setRef",value:function(t){this.ref=t}},{key:"getChildrenProps",value:function(){return Object.assign({},this.props.childrenProps,this.props.children.props)}},{key:"getChildren",value:function(){var t=this.props.childrenProps;return l.Children.map(this.props.children,function(e){return(0,l.cloneElement)(e,s({},t,e.props))})}},{key:"getToastProps",value:function(){var t=this.props,e=t.autoCloseId,n=t.autoCloseDelay,o=t.handleMouseEnter,r=t.handleMouseLeave,i={"data-toast-id":this.props.id,className:"toastify-content toastify-content--"+this.props.type,ref:this.setRef};return this.props.autoCloseId&&(i["data-auto-close-id"]=e,i["data-auto-close-delay"]=n,i.onMouseEnter=o,i.onMouseLeave=r),i}},{key:"componentWillEnter",value:function(t){this.ref.classList.add("bounceIn--"+this.props.position,"animated"),t()}},{key:"componentWillLeave",value:function(t){this.ref.classList.remove("bounceIn--"+this.props.position,"animated"),this.ref.classList.add("bounceOut--"+this.props.position,"animated"),setTimeout(function(){return t()},1e3)}},{key:"render",value:function(){return c.default.createElement("div",this.getToastProps(),c.default.createElement("button",{className:"toastify__close",type:"button",onClick:this.props.handleCloseBtn,value:this.props.id},"×"),c.default.createElement("div",{className:"toastify__body"},this.getChildren()))}}]),e}(l.Component);h.defaultProps=b,h.propTypes=y,e.default=h},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 u(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)}Object.defineProperty(e,"__esModule",{value:!0});var l=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},c="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},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(15),y=o(p),b=n(35),h=o(b),d=n(4),v=o(d),m=n(17),O=o(m),g=n(1),T=o(g),j={position:p.PropTypes.oneOf(Object.values(T.default.POSITION)),autoClose:p.PropTypes.oneOfType([p.PropTypes.bool,p.PropTypes.number]),className:p.PropTypes.string,style:p.PropTypes.object},S={position:T.default.POSITION.TOP_RIGHT,autoClose:5e3},w=function(t){function e(t){u(this,e);var n=s(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.state={toast:[]},n.toastId=0,n.collection={},n.handleCloseBtn=n.handleCloseBtn.bind(n),n.handleMouseEnter=n.handleMouseEnter.bind(n),n.handleMouseLeave=n.handleMouseLeave.bind(n),n}return a(e,t),f(e,[{key:"componentDidMount",value:function(){var t=this;v.default.on(T.default.ACTION.SHOW,function(e,n){return t.show(e,n)}).on(T.default.ACTION.CLEAR,function(){return t.clear()})}},{key:"componentWillUnmount",value:function(){v.default.off(T.default.ACTION.SHOW),v.default.off(T.default.ACTION.CLEAR)}},{key:"setAutoClose",value:function(t,e){var n=this;return setTimeout(function(){return n.removeToast(t)},e)}},{key:"isContentValid",value:function(t){return(0,p.isValidElement)(t)}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{key:"childrenHasProps",value:function(t){return"object"===("undefined"==typeof t?"undefined":c(t))&&"Object"===t.constructor.name}},{key:"shouldAutoClose",value:function(t){return!!(this.props.autoClose!==!1&&t!==!1||this.props.autoClose===!1&&t!==!1&&null!==t)}},{key:"removeToast",value:function(t){this.setState({toast:this.state.toast.filter(function(e){return e!==parseInt(t,10)})})}},{key:"show",value:function(t,e){if(t="string"==typeof t?y.default.createElement("div",null,t):t,this.isContentValid(t)){var n=++this.toastId,o=e.autoClose,u=function(){},s={id:n,type:e.type,onOpen:this.isFunction(e.onOpen)?e.onOpen:u,onClose:this.isFunction(e.onClose)?e.onClose:u};if(this.childrenHasProps(e.props)&&(s.childrenProps=e.props),this.shouldAutoClose(o)){var a=null!==o?parseInt(o,10):this.props.autoClose;s.autoCloseId=this.setAutoClose(n,a),s.autoCloseDelay=a,s.handleMouseEnter=this.handleMouseEnter,s.handleMouseLeave=this.handleMouseLeave}this.collection=Object.assign({},this.collection,i({},n,this.makeToast(t,s))),this.setState({toast:[].concat(r(this.state.toast),[n])})}}},{key:"makeToast",value:function(t,e){return y.default.createElement(O.default,l({},e,{position:this.props.position,key:"toast-"+e.id+" ",handleCloseBtn:this.handleCloseBtn}),t)}},{key:"clear",value:function(){this.collection={},this.setState({toast:[]})}},{key:"handleCloseBtn",value:function(t){this.removeToast(t.target.value)}},{key:"handleMouseEnter",value:function(t){clearTimeout(t.currentTarget.dataset.autoCloseId)}},{key:"handleMouseLeave",value:function(t){var e=t.currentTarget.dataset,n=e.toastId,o=e.autoCloseDelay;this.state.toast.length>0&&"undefined"!=typeof this.collection[n]&&(this.collection[n]=(0,p.cloneElement)(this.collection[n],{autoCloseId:this.setAutoClose(n,o)}),this.forceUpdate())}},{key:"isObjectEmpty",value:function(){return 0===this.state.toast.length}},{key:"renderProps",value:function(){var t={className:"toastify toastify--"+this.props.position};return this.props.className&&(t.className=t.className+" "+this.props.className),this.props.style&&(t.style=this.props.style),t}},{key:"renderToast",value:function(){var t=this;return Object.keys(this.collection).map(function(e){return t.state.toast.includes(parseInt(e,10))?t.collection[e]:void delete t.collection[e]})}},{key:"render",value:function(){return y.default.createElement("div",this.renderProps(),y.default.createElement(h.default,null,this.isObjectEmpty()?null:this.renderToast()))}}]),e}(p.Component);w.defaultProps=S,w.propTypes=j,e.default=w},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){return Object.assign({},p,t)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),u=o(i),s=n(1),a=o(s),l=a.default.POSITION,c=a.default.TYPE,f=a.default.ACTION,p={type:c.DEFAULT,autoClose:null},y=function(t,e){return u.default.emit(f.SHOW,t,e)};e.default=Object.assign(function(t,e){return y(t,r(e))},{success:function(t,e){return y(t,Object.assign(r(e),{type:c.SUCCESS}))},info:function(t,e){return y(t,Object.assign(r(e),{type:c.INFO}))},warn:function(t,e){return y(t,Object.assign(r(e),{type:c.WARNING}))},error:function(t,e){return y(t,Object.assign(r(e),{type:c.ERROR}))},dismiss:function(){return u.default.emit(f.CLEAR)}},{POSITION:l,TYPE:c})},function(t,e,n){"use strict";var o=n(8),r=n(7),i=n(10),u=n(9),s=n(3),a=n(24),l={ToPrimitive:a,ToBoolean:function(t){return Boolean(t)},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return o(e)?0:0!==e&&r(e)?i(e)*Math.floor(Math.abs(e)):e},ToInt32:function(t){return this.ToNumber(t)>>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(o(e)||0===e||!r(e))return 0;var n=i(e)*Math.floor(Math.abs(e));return u(n,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:s,SameValue:function(t,e){return t===e?0!==t||1/t===1/e:o(t)&&o(e)},Type:function(t){return null===t?"Null":"undefined"==typeof t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0}};t.exports=l},function(t,e,n){"use strict";var o=Object.prototype.toString,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,i=r?Symbol.prototype.toString:o,u=n(8),s=n(7),a=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=n(6),c=n(10),f=n(9),p=n(23),y=n(25),b=parseInt,h=n(2),d=h.call(Function.call,String.prototype.slice),v=h.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i),m=h.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i),O=[" ","",""].join(""),g=new RegExp("["+O+"]","g"),T=h.call(Function.call,RegExp.prototype.test,g),j=/^[-+]0x[0-9a-f]+$/i,S=h.call(Function.call,RegExp.prototype.test,j),w=["\t\n\v\f\r "," \u2028","\u2029\ufeff"].join(""),E=new RegExp("(^["+w+"]+)|(["+w+"]+$)","g"),P=h.call(Function.call,String.prototype.replace),C=function(t){return P(t,E,"")},I=n(20),x=n(29),N=l(l({},I),{Call:function(t,e){var n=arguments.length>2?arguments[2]:[];if(!this.IsCallable(t))throw new TypeError(t+" is not a function");return t.apply(e,n)},ToPrimitive:y,ToNumber:function(t){var e=p(t)?t:y(t,"number");if("symbol"==typeof e)throw new TypeError("Cannot convert a Symbol value to a number");if("string"==typeof e){if(v(e))return this.ToNumber(b(d(e,2),2));if(m(e))return this.ToNumber(b(d(e,2),8));if(T(e)||S(e))return NaN;var n=C(e);if(n!==e)return this.ToNumber(n)}return Number(e)},ToInt16:function(t){var e=this.ToUint16(t);return e>=32768?e-65536:e},ToInt8:function(t){var e=this.ToUint8(t);return e>=128?e-256:e},ToUint8:function(t){var e=this.ToNumber(t);if(u(e)||0===e||!s(e))return 0;var n=c(e)*Math.floor(Math.abs(e));return f(n,256)},ToUint8Clamp:function(t){var e=this.ToNumber(t);if(u(e)||e<=0)return 0;if(e>=255)return 255;var n=Math.floor(t);return n+.5<e?n+1:e<n+.5?n:n%2!==0?n+1:n},ToString:function(t){if("symbol"==typeof t)throw new TypeError("Cannot convert a Symbol value to a string");return String(t)},ToObject:function(t){return this.RequireObjectCoercible(t),Object(t)},ToPropertyKey:function(t){var e=this.ToPrimitive(t,String);return"symbol"==typeof e?i.call(e):this.ToString(e)},ToLength:function(t){var e=this.ToInteger(t);return e<=0?0:e>a?a:e},CanonicalNumericIndexString:function(t){if("[object String]"!==o.call(t))throw new TypeError("must be a string");if("-0"===t)return-0;var e=this.ToNumber(t);return this.SameValue(this.ToString(e),t)?e:void 0},RequireObjectCoercible:I.CheckObjectCoercible,IsArray:Array.isArray||function(t){return"[object Array]"===o.call(t)},IsConstructor:function(t){return"function"==typeof t&&!!t.prototype},IsExtensible:function(t){return!Object.preventExtensions||!p(t)&&Object.isExtensible(t)},IsInteger:function(t){if("number"!=typeof t||u(t)||!s(t))return!1;var e=Math.abs(t);return Math.floor(e)===e},IsPropertyKey:function(t){return"string"==typeof t||"symbol"==typeof t},IsRegExp:function(t){if(!t||"object"!=typeof t)return!1;if(r){var e=t[Symbol.match];if("undefined"!=typeof e)return I.ToBoolean(e)}return x(t)},SameValueZero:function(t,e){return t===e||u(t)&&u(e)},GetV:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var n=this.ToObject(t);return n[e]},GetMethod:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var n=this.GetV(t,e);if(null!=n){if(!this.IsCallable(n))throw new TypeError(e+"is not a function");return n}},Get:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return t[e]},Type:function(t){return"symbol"==typeof t?"Symbol":I.Type(t)},SpeciesConstructor:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");var n=t.constructor;if("undefined"==typeof n)return e;if("Object"!==this.Type(n))throw new TypeError("O.constructor is not an Object");var o=r&&Symbol.species?n[Symbol.species]:void 0;if(null==o)return e;if(this.IsConstructor(o))return o;throw new TypeError("no constructor found")}});delete N.CheckObjectCoercible,t.exports=N},function(t,e,n){"use strict";var o=n(21),r=n(6),i=r(o,{SameValueNonNumber:function(t,e){if("number"==typeof t||typeof t!=typeof e)throw new TypeError("SameValueNonNumber requires two non-number values of the same type.");return this.SameValue(t,e)}});t.exports=i},function(t,e){t.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},function(t,e,n){"use strict";var o=Object.prototype.toString,r=n(11),i=n(3),u={"[[DefaultValue]]":function(t,e){var n=e||("[object Date]"===o.call(t)?String:Number);if(n===String||n===Number){var u,s,a=n===String?["toString","valueOf"]:["valueOf","toString"];for(s=0;s<a.length;++s)if(i(t[a[s]])&&(u=t[a[s]](),r(u)))return u;throw new TypeError("No default value")}throw new TypeError("invalid [[DefaultValue]] hint supplied")}};t.exports=function(t,e){return r(t)?t:u["[[DefaultValue]]"](t,e)}},function(t,e,n){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,r=n(11),i=n(3),u=n(28),s=n(30),a=function(t,e){if("undefined"==typeof t||null===t)throw new TypeError("Cannot call method on "+t);if("string"!=typeof e||"number"!==e&&"string"!==e)throw new TypeError('hint must be "string" or "number"');var n,o,u,s="string"===e?["toString","valueOf"]:["valueOf","toString"];for(u=0;u<s.length;++u)if(n=t[s[u]],i(n)&&(o=n.call(t),r(o)))return o;throw new TypeError("No default value")},l=function(t,e){var n=t[e];if(null!==n&&"undefined"!=typeof n){if(!i(n))throw new TypeError(n+" returned for property "+e+" of object "+t+" is not a function");return n}};t.exports=function(t,e){if(r(t))return t;var n="default";arguments.length>1&&(e===String?n="string":e===Number&&(n="number"));var i;if(o&&(Symbol.toPrimitive?i=l(t,Symbol.toPrimitive):s(t)&&(i=Symbol.prototype.valueOf)),"undefined"!=typeof i){var c=i.call(t,n);if(r(c))return c;throw new TypeError("unable to convert exotic object to primitive")}return"default"===n&&(u(t)||s(t))&&(n="string"),a(t,"default"===n?"number":n)}},function(t,e){var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString;t.exports=function(t,e,r){if("[object Function]"!==o.call(e))throw new TypeError("iterator must be a function");var i=t.length;if(i===+i)for(var u=0;u<i;u++)e.call(r,t[u],u,t);else for(var s in t)n.call(t,s)&&e.call(r,t[s],s,t)}},function(t,e){var n="Function.prototype.bind called on incompatible ",o=Array.prototype.slice,r=Object.prototype.toString,i="[object Function]";t.exports=function(t){var e=this;if("function"!=typeof e||r.call(e)!==i)throw new TypeError(n+e);for(var u,s=o.call(arguments,1),a=function(){if(this instanceof u){var n=e.apply(this,s.concat(o.call(arguments)));return Object(n)===n?n:this}return e.apply(t,s.concat(o.call(arguments)))},l=Math.max(0,e.length-s.length),c=[],f=0;f<l;f++)c.push("$"+f);if(u=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(a),e.prototype){var p=function(){};p.prototype=e.prototype,u.prototype=new p,p.prototype=null}return u}},function(t,e){"use strict";var n=Date.prototype.getDay,o=function(t){try{return n.call(t),!0}catch(t){return!1}},r=Object.prototype.toString,i="[object Date]",u="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"object"==typeof t&&null!==t&&(u?o(t):r.call(t)===i)}},function(t,e,n){"use strict";var o=n(12),r=RegExp.prototype.exec,i=Object.getOwnPropertyDescriptor,u=function(t){try{var e=t.lastIndex;return t.lastIndex=0,r.call(t),!0}catch(t){return!1}finally{t.lastIndex=e}},s=Object.prototype.toString,a="[object RegExp]",l="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!l)return s.call(t)===a;var e=i(t,"lastIndex"),n=e&&o(e,"value");return!!n&&u(t)}},function(t,e){"use strict";var n=Object.prototype.toString,o="function"==typeof Symbol&&"symbol"==typeof Symbol();if(o){var r=Symbol.prototype.toString,i=/^Symbol\(.*\)$/,u=function(t){return"symbol"==typeof t.valueOf()&&i.test(r.call(t))};t.exports=function(t){if("symbol"==typeof t)return!0;if("[object Symbol]"!==n.call(t))return!1;try{return u(t)}catch(t){return!1}}}else t.exports=function(t){return!1}},function(t,e,n){"use strict";var o=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Array.prototype.slice,u=n(32),s=Object.prototype.propertyIsEnumerable,a=!s.call({toString:null},"toString"),l=s.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=function(t){var e=t.constructor;return e&&e.prototype===t},p={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},y=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!p["$"+t]&&o.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{f(window[t])}catch(t){return!0}}catch(t){return!0}return!1}(),b=function(t){if("undefined"==typeof window||!y)return f(t);try{return f(t)}catch(t){return!1}},h=function(t){var e=null!==t&&"object"==typeof t,n="[object Function]"===r.call(t),i=u(t),s=e&&"[object String]"===r.call(t),f=[];if(!e&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var p=l&&n;if(s&&t.length>0&&!o.call(t,0))for(var y=0;y<t.length;++y)f.push(String(y));if(i&&t.length>0)for(var h=0;h<t.length;++h)f.push(String(h));else for(var d in t)p&&"prototype"===d||!o.call(t,d)||f.push(String(d));if(a)for(var v=b(t),m=0;m<c.length;++m)v&&"constructor"===c[m]||!o.call(t,c[m])||f.push(c[m]);return f};h.shim=function(){if(Object.keys){var t=function(){return 2===(Object.keys(arguments)||"").length}(1,2);if(!t){var e=Object.keys;Object.keys=function(t){return e(u(t)?i.call(t):t)}}}else Object.keys=h;return Object.keys||h},t.exports=h},function(t,e){"use strict";var n=Object.prototype.toString;t.exports=function(t){var e=n.call(t),o="[object Arguments]"===e;return o||(o="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===n.call(t.callee)),o}},function(t,e,n){"use strict";var o=n(5),r=n(13),i=n(14),u=n(34),s=i();o(s,{getPolyfill:i,implementation:r,shim:u}),t.exports=s},function(t,e,n){"use strict";var o=n(14),r=n(5);t.exports=function(){var t=o();return r(Object,{values:t},{values:function(){return Object.values!==t}}),t}},function(t,n){t.exports=e}])}); |
@@ -35,2 +35,4 @@ 'use strict'; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -65,5 +67,6 @@ | ||
_this.state = { | ||
toast: {} | ||
toast: [] | ||
}; | ||
_this.toastId = 0; | ||
_this.collection = {}; | ||
_this.handleCloseBtn = _this.handleCloseBtn.bind(_this); | ||
@@ -87,7 +90,2 @@ _this.handleMouseEnter = _this.handleMouseEnter.bind(_this); | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return !this.isEqualToPreviousState(nextState); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
@@ -108,20 +106,2 @@ value: function componentWillUnmount() { | ||
}, { | ||
key: 'isEqualToPreviousState', | ||
value: function isEqualToPreviousState(nextState) { | ||
var nextToastIds = Object.keys(nextState.toast); | ||
var previousToastIds = Object.keys(this.state.toast); | ||
if (nextToastIds.length !== previousToastIds.length) { | ||
return false; | ||
} | ||
for (var i = 0; i < previousToastIds.length; i++) { | ||
if (previousToastIds[i] !== nextToastIds[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
}, { | ||
key: 'isContentValid', | ||
@@ -149,5 +129,5 @@ value: function isContentValid(content) { | ||
value: function removeToast(id) { | ||
var nextState = Object.assign({}, this.state.toast); | ||
delete nextState[id]; | ||
this.setState({ toast: nextState }); | ||
this.setState({ toast: this.state.toast.filter(function (v) { | ||
return v !== parseInt(id, 10); | ||
}) }); | ||
} | ||
@@ -187,4 +167,6 @@ }, { | ||
this.collection = Object.assign({}, this.collection, _defineProperty({}, toastId, this.makeToast(content, toastOptions))); | ||
this.setState({ | ||
toast: Object.assign({}, this.state.toast, _defineProperty({}, toastId, this.makeToast(content, toastOptions))) | ||
toast: [].concat(_toConsumableArray(this.state.toast), [toastId]) | ||
}); | ||
@@ -209,3 +191,4 @@ } | ||
value: function clear() { | ||
this.setState({ toast: {} }); | ||
this.collection = {}; | ||
this.setState({ toast: [] }); | ||
} | ||
@@ -229,10 +212,9 @@ }, { | ||
var toast = (0, _react.cloneElement)(this.state.toast[toastId], { autoCloseId: this.setAutoClose(toastId, autoCloseDelay) }); | ||
var nextState = Object.assign({}, this.state.toast); | ||
if (this.state.toast.length > 0 && typeof this.collection[toastId] !== 'undefined') { | ||
this.collection[toastId] = (0, _react.cloneElement)(this.collection[toastId], { | ||
autoCloseId: this.setAutoClose(toastId, autoCloseDelay) | ||
}); | ||
delete nextState[toastId]; | ||
nextState[toastId] = toast; | ||
this.setState({ | ||
toast: nextState | ||
}); | ||
this.forceUpdate(); | ||
} | ||
} | ||
@@ -242,3 +224,3 @@ }, { | ||
value: function isObjectEmpty() { | ||
return Object.keys(this.state.toast).length === 0; | ||
return this.state.toast.length === 0; | ||
} | ||
@@ -265,3 +247,11 @@ }, { | ||
value: function renderToast() { | ||
return Object.values(this.state.toast); | ||
var _this4 = this; | ||
return Object.keys(this.collection).map(function (idx) { | ||
if (_this4.state.toast.includes(parseInt(idx, 10))) { | ||
return _this4.collection[idx]; | ||
} else { | ||
delete _this4.collection[idx]; | ||
} | ||
}); | ||
} | ||
@@ -268,0 +258,0 @@ }, { |
{ | ||
"name": "react-toastify", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "React notification made easy", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -156,2 +156,12 @@ # React Toastify [![npm](https://img.shields.io/npm/dt/react-toastify.svg)]() [![npm](https://img.shields.io/npm/v/react-toastify.svg)]() [![license](https://img.shields.io/github/license/sniphpet/react-toastify.svg?maxAge=2592000)]() | ||
### 1.2.2 | ||
I was storing react component into state which is a bad practice. [What should Go in State](http://web.archive.org/web/20150419023006/http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html) | ||
This is no more the case now. The separation of concern between the data and the view is respected. | ||
#### Bug fix | ||
- Was calling cloneElement on undefined which cause your console bleed. See issue [#2](https://github.com/sniphpet/react-toastify/issues/2) | ||
### 1.2.1 | ||
@@ -158,0 +168,0 @@ |
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
73001
17
198
722