react-toastify
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -1,2 +0,2 @@ | ||
!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(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.toast=e.ToastContainer=void 0,n(23);var o=n(25),i=r(o),u=n(26),a=r(u);e.ToastContainer=i.default,e.toast=a.default},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(t){if(s===setTimeout)return setTimeout(t,0);if((s===n||!s)&&setTimeout)return s=setTimeout,setTimeout(t,0);try{return s(t,0)}catch(e){try{return s.call(null,t,0)}catch(e){return s.call(this,t,0)}}}function i(t){if(f===clearTimeout)return clearTimeout(t);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(t);try{return f(t)}catch(e){try{return f.call(null,t)}catch(e){return f.call(this,t)}}}function u(){h&&y&&(h=!1,y.length?d=y.concat(d):b=-1,d.length&&a())}function a(){if(!h){var t=o(u);h=!0;for(var e=d.length;e;){for(y=d,d=[];++b<e;)y&&y[b].run();b=-1,e=d.length}y=null,h=!1,i(t)}}function c(t,e){this.fun=t,this.array=e}function l(){}var s,f,p=t.exports={};!function(){try{s="function"==typeof setTimeout?setTimeout:n}catch(t){s=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(t){f=r}}();var y,d=[],h=!1,b=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];d.push(new c(t,e)),1!==d.length||h||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=l,p.addListener=l,p.once=l,p.off=l,p.removeListener=l,p.removeAllListeners=l,p.emit=l,p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},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 r=n(34);t.exports=Function.prototype.bind||r},function(t,e){"use strict";var n=Function.prototype.toString,r=/^\s*class /,o=function(t){try{var e=n.call(t),o=e.replace(/\/\/.*\n/g,""),i=o.replace(/\/\*[.\s\S]*\*\//g,""),u=i.replace(/\n/gm," ").replace(/ {2}/g," ");return r.test(u)}catch(t){return!1}},i=function(t){try{return!o(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,a="[object Function]",c="[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(o(t))return!1;var e=u.call(t);return e===a||e===c}},function(t,e,n){function r(t){return"object"==typeof t&&null!==t&&t.$$typeof===i}var o=n(43),i="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;t.exports=o(r)},function(e,n){e.exports=t},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 r=this.eventList.get(t),o=r.length-1;return r[o].once=!0,this},emit:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(!this.eventList.has(t))return console.warn("<"+t+"> Event is not registered. Did you forgot to bind the event ?"),!1;var o=this.eventList.get(t);return this.eventList.set(t,o.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 r=n(38),o=n(33),i="function"==typeof Symbol&&"symbol"==typeof Symbol(),u=Object.prototype.toString,a=function(t){return"function"==typeof t&&"[object Function]"===u.call(t)},c=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&&c(),s=function(t,e,n,r){(!(e in t)||a(r)&&r())&&(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=r(e);i&&(u=u.concat(Object.getOwnPropertySymbols(e))),o(u,function(r){s(t,r,e[r],n[r])})};f.supportsDescriptors=!!l,t.exports=f},function(t,e){var n=Object.prototype.hasOwnProperty;t.exports=Object.assign||function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);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){"use strict";function n(t){return function(){return t}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(t){return t},t.exports=r},function(t,e,n){(function(e){"use strict";function n(t,e,n,o,i,u,a,c){if(r(e),!t){var l;if(void 0===e)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,o,i,u,a,c],f=0;l=new Error(e.replace(/%s/g,function(){return s[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var r=function(t){};"production"!==e.env.NODE_ENV&&(r=function(t){if(void 0===t)throw new Error("invariant requires an error message argument")}),t.exports=n}).call(e,n(1))},function(t,e,n){(function(e){"use strict";var r=n(15),o=r;"production"!==e.env.NODE_ENV&&!function(){var t=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+t.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(t){}};o=function(e,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!e){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];t.apply(void 0,[n].concat(o))}}}(),t.exports=o}).call(e,n(1))},function(t,e,n){var r=n(3);t.exports=r.call(Function.call,Object.prototype.hasOwnProperty)},function(t,e,n){"use strict";var r=n(29),o=n(18),i=n(3),u=i.call(Function.call,Object.prototype.propertyIsEnumerable);t.exports=function(t){var e=r.RequireObjectCoercible(t),n=[];for(var i in e)o(e,i)&&u(e,i)&&n.push(e[i]);return n}},function(t,e,n){"use strict";var r=n(19);t.exports=function(){return"function"==typeof Object.values?Object.values:r}},function(t,e){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(6),i=r(o),u=n(5),a=r(u),c=function(t){var e=t.closeToast;return i.default.createElement("button",{className:"toastify__close",type:"button",onClick:e},"×")};c.propTypes={closeToast:a.default.func},e.default=c},function(t,e,n){"use strict";var r=n(40);Object.values||r.shim()},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(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 a=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),c=n(6),l=r(c),s=n(5),f=r(s),p=n(2),y=r(p),d={id:f.default.number.isRequired,closeButton:f.default.element.isRequired,children:f.default.node.isRequired,autoCloseId:f.default.number,autoCloseDelay:f.default.number,handleMouseEnter:f.default.func,handleMouseLeave:f.default.func,onOpen:f.default.func,onClose:f.default.func,type:f.default.oneOf(Object.values(y.default.TYPE)),position:f.default.oneOf(Object.values(y.default.POSITION))},h={type:y.default.TYPE.DEFAULT},b=function(t){function e(t){o(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 this.props.children.props}},{key:"getToastProps",value:function(){var t=this.props,e=t.autoCloseId,n=t.autoCloseDelay,r=t.handleMouseEnter,o=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=r,i.onMouseLeave=o),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 l.default.createElement("div",this.getToastProps(),this.props.closeButton,l.default.createElement("div",{className:"toastify__body"},this.props.children))}}]),e}(c.Component);b.defaultProps=h,b.propTypes=d,e.default=b},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}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 a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),p=n(6),y=r(p),d=n(5),h=r(d),b=n(44),v=r(b),m=n(7),g=r(m),O=n(24),T=r(O),w=n(22),j=r(w),E=n(2),S=r(E),x={position:h.default.oneOf(Object.values(S.default.POSITION)),autoClose:h.default.oneOfType([h.default.bool,h.default.number]),closeButton:h.default.element,className:h.default.string,style:h.default.object},N={position:S.default.POSITION.TOP_RIGHT,autoClose:5e3,closeButton:null},I=function(t){function e(t){u(this,e);var n=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.state={toast:[]},n.toastId=0,n.collection={},n.handleMouseEnter=n.handleMouseEnter.bind(n),n.handleMouseLeave=n.handleMouseLeave.bind(n),n}return c(e,t),f(e,[{key:"componentDidMount",value:function(){var t=this;g.default.on(S.default.ACTION.SHOW,function(e,n){return t.show(e,n)}).on(S.default.ACTION.CLEAR,function(){return t.clear()})}},{key:"componentWillUnmount",value:function(){g.default.off(S.default.ACTION.SHOW),g.default.off(S.default.ACTION.CLEAR)}},{key:"setAutoClose",value:function(t,e){var n=this;return setTimeout(function(){return n.removeToast(t)},e)}},{key:"isFunction",value:function(t){return!!(t&&t.constructor&&t.call&&t.apply)}},{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:"withClose",value:function(t,e){return(0,p.cloneElement)(t,s({},e,t.props))}},{key:"validateCloseButton",value:function(t){if(!(0,p.isValidElement)(t))throw new Error("CloseButton must be a valid react element instead of "+("undefined"==typeof t?"undefined":l(t)))}},{key:"makeCloseButton",value:function(t,e){var n=this,r=y.default.createElement(j.default,null);return null===t&&null!==this.props.closeButton?r=this.props.closeButton:null!==t&&(this.validateCloseButton(t),r=t),this.withClose(r,{closeToast:function(){return n.removeToast(e)}})}},{key:"show",value:function(t,e){if(t="string"==typeof t?y.default.createElement("div",null,t):t,(0,p.isValidElement)(t)){var n=++this.toastId,r=e.autoClose,u=function(){},a={id:n,type:e.type,onOpen:this.isFunction(e.onOpen)?e.onOpen:u,onClose:this.isFunction(e.onClose)?e.onClose:u,closeButton:this.makeCloseButton(e.closeButton,n)};if(this.shouldAutoClose(r)){var c=null!==r?parseInt(r,10):this.props.autoClose;a.autoCloseId=this.setAutoClose(n,c),a.autoCloseDelay=c,a.handleMouseEnter=this.handleMouseEnter,a.handleMouseLeave=this.handleMouseLeave}this.collection=Object.assign({},this.collection,i({},n,this.makeToast(t,a))),this.setState({toast:[].concat(o(this.state.toast),[n])})}}},{key:"makeToast",value:function(t,e){return y.default.createElement(T.default,s({},e,{position:this.props.position,key:"toast-"+e.id+" "}),t)}},{key:"clear",value:function(){this.collection={},this.setState({toast:[]})}},{key:"handleMouseEnter",value:function(t){clearTimeout(t.currentTarget.dataset.autoCloseId)}},{key:"handleMouseLeave",value:function(t){var e=t.currentTarget.dataset,n=e.toastId,r=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,r)}),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(v.default,null,this.isObjectEmpty()?null:this.renderToast()))}}]),e}(p.Component);I.defaultProps=N,I.propTypes=x,e.default=I},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(t){return Object.assign({},p,t)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(7),u=r(i),a=n(2),c=r(a),l=c.default.POSITION,s=c.default.TYPE,f=c.default.ACTION,p={type:s.DEFAULT,autoClose:null,closeButton:null},y=function(t,e){return u.default.emit(f.SHOW,t,e)};e.default=Object.assign(function(t,e){return y(t,o(e))},{success:function(t,e){return y(t,Object.assign(o(e),{type:s.SUCCESS}))},info:function(t,e){return y(t,Object.assign(o(e),{type:s.INFO}))},warn:function(t,e){return y(t,Object.assign(o(e),{type:s.WARNING}))},error:function(t,e){return y(t,Object.assign(o(e),{type:s.ERROR}))},dismiss:function(){return u.default.emit(f.CLEAR)}},{POSITION:l,TYPE:s})},function(t,e,n){"use strict";var r=n(11),o=n(10),i=n(13),u=n(12),a=n(4),c=n(31),l={ToPrimitive:c,ToBoolean:function(t){return Boolean(t)},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return r(e)?0:0!==e&&o(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(r(e)||0===e||!o(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:a,SameValue:function(t,e){return t===e?0!==t||1/t===1/e:r(t)&&r(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 r=Object.prototype.toString,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,i=o?Symbol.prototype.toString:r,u=n(11),a=n(10),c=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=n(9),s=n(13),f=n(12),p=n(30),y=n(32),d=parseInt,h=n(3),b=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),g=[" ","",""].join(""),O=new RegExp("["+g+"]","g"),T=h.call(Function.call,RegExp.prototype.test,O),w=/^[-+]0x[0-9a-f]+$/i,j=h.call(Function.call,RegExp.prototype.test,w),E=["\t\n\v\f\r "," \u2028","\u2029\ufeff"].join(""),S=new RegExp("(^["+E+"]+)|(["+E+"]+$)","g"),x=h.call(Function.call,String.prototype.replace),N=function(t){return x(t,S,"")},I=n(27),C=n(36),P=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(d(b(e,2),2));if(m(e))return this.ToNumber(d(b(e,2),8));if(T(e)||j(e))return NaN;var n=N(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||!a(e))return 0;var n=s(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>c?c:e},CanonicalNumericIndexString:function(t){if("[object String]"!==r.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]"===r.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)||!a(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(o){var e=t[Symbol.match];if("undefined"!=typeof e)return I.ToBoolean(e)}return C(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 r=o&&Symbol.species?n[Symbol.species]:void 0;if(null==r)return e;if(this.IsConstructor(r))return r;throw new TypeError("no constructor found")}});delete P.CheckObjectCoercible,t.exports=P},function(t,e,n){"use strict";var r=n(28),o=n(9),i=o(r,{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 r=Object.prototype.toString,o=n(14),i=n(4),u={"[[DefaultValue]]":function(t,e){var n=e||("[object Date]"===r.call(t)?String:Number);if(n===String||n===Number){var u,a,c=n===String?["toString","valueOf"]:["valueOf","toString"];for(a=0;a<c.length;++a)if(i(t[c[a]])&&(u=t[c[a]](),o(u)))return u;throw new TypeError("No default value")}throw new TypeError("invalid [[DefaultValue]] hint supplied")}};t.exports=function(t,e){return o(t)?t:u["[[DefaultValue]]"](t,e)}},function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,o=n(14),i=n(4),u=n(35),a=n(37),c=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,r,u,a="string"===e?["toString","valueOf"]:["valueOf","toString"];for(u=0;u<a.length;++u)if(n=t[a[u]],i(n)&&(r=n.call(t),o(r)))return r;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(o(t))return t;var n="default";arguments.length>1&&(e===String?n="string":e===Number&&(n="number"));var i;if(r&&(Symbol.toPrimitive?i=l(t,Symbol.toPrimitive):a(t)&&(i=Symbol.prototype.valueOf)),"undefined"!=typeof i){var s=i.call(t,n);if(o(s))return s;throw new TypeError("unable to convert exotic object to primitive")}return"default"===n&&(u(t)||a(t))&&(n="string"),c(t,"default"===n?"number":n)}},function(t,e){var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString;t.exports=function(t,e,o){if("[object Function]"!==r.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(o,t[u],u,t);else for(var a in t)n.call(t,a)&&e.call(o,t[a],a,t)}},function(t,e){var n="Function.prototype.bind called on incompatible ",r=Array.prototype.slice,o=Object.prototype.toString,i="[object Function]";t.exports=function(t){var e=this;if("function"!=typeof e||o.call(e)!==i)throw new TypeError(n+e);for(var u,a=r.call(arguments,1),c=function(){if(this instanceof u){var n=e.apply(this,a.concat(r.call(arguments)));return Object(n)===n?n:this}return e.apply(t,a.concat(r.call(arguments)))},l=Math.max(0,e.length-a.length),s=[],f=0;f<l;f++)s.push("$"+f);if(u=Function("binder","return function ("+s.join(",")+"){ return binder.apply(this,arguments); }")(c),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,r=function(t){try{return n.call(t),!0}catch(t){return!1}},o=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?r(t):o.call(t)===i)}},function(t,e,n){"use strict";var r=n(18),o=RegExp.prototype.exec,i=Object.getOwnPropertyDescriptor,u=function(t){try{var e=t.lastIndex;return t.lastIndex=0,o.call(t),!0}catch(t){return!1}finally{t.lastIndex=e}},a=Object.prototype.toString,c="[object RegExp]",l="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!l)return a.call(t)===c;var e=i(t,"lastIndex"),n=e&&r(e,"value");return!!n&&u(t)}},function(t,e){"use strict";var n=Object.prototype.toString,r="function"==typeof Symbol&&"symbol"==typeof Symbol();if(r){var o=Symbol.prototype.toString,i=/^Symbol\(.*\)$/,u=function(t){return"symbol"==typeof t.valueOf()&&i.test(o.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 r=Object.prototype.hasOwnProperty,o=Object.prototype.toString,i=Array.prototype.slice,u=n(39),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),l=a.call(function(){},"prototype"),s=["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]&&r.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{f(window[t])}catch(t){return!0}}catch(t){return!0}return!1}(),d=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]"===o.call(t),i=u(t),a=e&&"[object String]"===o.call(t),f=[];if(!e&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var p=l&&n;if(a&&t.length>0&&!r.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 b in t)p&&"prototype"===b||!r.call(t,b)||f.push(String(b));if(c)for(var v=d(t),m=0;m<s.length;++m)v&&"constructor"===s[m]||!r.call(t,s[m])||f.push(s[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),r="[object Arguments]"===e;return r||(r="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===n.call(t.callee)),r}},function(t,e,n){"use strict";var r=n(8),o=n(19),i=n(20),u=n(41),a=i();r(a,{getPolyfill:i,implementation:o,shim:u}),t.exports=a},function(t,e,n){"use strict";var r=n(20),o=n(8);t.exports=function(){var t=r();return o(Object,{values:t},{values:function(){return Object.values!==t}}),t}},function(t,e,n){(function(e){"use strict";function r(t,n,r,c,l){if("production"!==e.env.NODE_ENV)for(var s in t)if(t.hasOwnProperty(s)){var f;try{o("function"==typeof t[s],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",c||"React class",r,s),f=t[s](n,s,c,r,null,u)}catch(t){f=t}if("production"!==e.env.NODE_ENV?i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",r,s,typeof f):void 0,f instanceof Error&&!(f.message in a)){a[f.message]=!0;var p=l?l():"";"production"!==e.env.NODE_ENV?i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:""):void 0}}}var o=n(16),i=n(17),u=n(21),a={};t.exports=r}).call(e,n(1))},function(t,e,n){(function(e){"use strict";var r=n(15),o=n(16),i=n(17),u=n(21),a=n(42);t.exports=function(t){function n(t){var e=t&&(N&&t[N]||t[I]);if("function"==typeof e)return e}function c(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e}function l(t){this.message=t,this.stack=""}function s(t){function n(n,o,a,c,s,f,p){if(c=c||C,f=f||a,"production"!==e.env.NODE_ENV&&p!==u&&"undefined"!=typeof console){var y=c+":"+a;r[y]||("production"!==e.env.NODE_ENV?i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will not work in production with the next major version. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",f,c):void 0,r[y]=!0)}return null==o[a]?n?new l(null===o[a]?"The "+s+" `"+f+"` is marked as required "+("in `"+c+"`, but its value is `null`."):"The "+s+" `"+f+"` is marked as required in "+("`"+c+"`, but its value is `undefined`.")):null:t(o,a,c,s,f)}if("production"!==e.env.NODE_ENV)var r={};var o=n.bind(null,!1);return o.isRequired=n.bind(null,!0),o}function f(t){function e(e,n,r,o,i,u){var a=e[n],c=j(a);if(c!==t){var s=E(a);return new l("Invalid "+o+" `"+i+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("`"+t+"`."))}return null}return s(e)}function p(){return s(r.thatReturnsNull)}function y(t){function e(e,n,r,o,i){if("function"!=typeof t)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=e[n];if(!Array.isArray(a)){ | ||
var c=j(a);return new l("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an array."))}for(var s=0;s<a.length;s++){var f=t(a,s,r,o,i+"["+s+"]",u);if(f instanceof Error)return f}return null}return s(e)}function d(){function e(e,n,r,o,i){var u=e[n];if(!t(u)){var a=j(u);return new l("Invalid "+o+" `"+i+"` of type "+("`"+a+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return s(e)}function h(t){function e(e,n,r,o,i){if(!(e[n]instanceof t)){var u=t.name||C,a=S(e[n]);return new l("Invalid "+o+" `"+i+"` of type "+("`"+a+"` supplied to `"+r+"`, expected ")+("instance of `"+u+"`."))}return null}return s(e)}function b(t){function n(e,n,r,o,i){for(var u=e[n],a=0;a<t.length;a++)if(c(u,t[a]))return null;var s=JSON.stringify(t);return new l("Invalid "+o+" `"+i+"` of value `"+u+"` "+("supplied to `"+r+"`, expected one of "+s+"."))}return Array.isArray(t)?s(n):("production"!==e.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOf, expected an instance of array."):void 0,r.thatReturnsNull)}function v(t){function e(e,n,r,o,i){if("function"!=typeof t)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=e[n],c=j(a);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an object."));for(var s in a)if(a.hasOwnProperty(s)){var f=t(a,s,r,o,i+"."+s,u);if(f instanceof Error)return f}return null}return s(e)}function m(t){function n(e,n,r,o,i){for(var a=0;a<t.length;a++){var c=t[a];if(null==c(e,n,r,o,i,u))return null}return new l("Invalid "+o+" `"+i+"` supplied to "+("`"+r+"`."))}return Array.isArray(t)?s(n):("production"!==e.env.NODE_ENV?i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."):void 0,r.thatReturnsNull)}function g(){function t(t,e,n,r,o){return T(t[e])?null:new l("Invalid "+r+" `"+o+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return s(t)}function O(t){function e(e,n,r,o,i){var a=e[n],c=j(a);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type `"+c+"` "+("supplied to `"+r+"`, expected `object`."));for(var s in t){var f=t[s];if(f){var p=f(a,s,r,o,i+"."+s,u);if(p)return p}}return null}return s(e)}function T(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(T);if(null===e||t(e))return!0;var r=n(e);if(!r)return!1;var o,i=r.call(e);if(r!==e.entries){for(;!(o=i.next()).done;)if(!T(o.value))return!1}else for(;!(o=i.next()).done;){var u=o.value;if(u&&!T(u[1]))return!1}return!0;default:return!1}}function w(t,e){return"symbol"===t||"Symbol"===e["@@toStringTag"]||"function"==typeof Symbol&&e instanceof Symbol}function j(t){var e=typeof t;return Array.isArray(t)?"array":t instanceof RegExp?"object":w(e,t)?"symbol":e}function E(t){var e=j(t);if("object"===e){if(t instanceof Date)return"date";if(t instanceof RegExp)return"regexp"}return e}function S(t){return t.constructor&&t.constructor.name?t.constructor.name:C}var x,N="function"==typeof Symbol&&Symbol.iterator,I="@@iterator",C="<<anonymous>>";if("production"!==e.env.NODE_ENV)x={array:f("array"),bool:f("boolean"),func:f("function"),number:f("number"),object:f("object"),string:f("string"),symbol:f("symbol"),any:p(),arrayOf:y,element:d(),instanceOf:h,node:g(),objectOf:v,oneOf:b,oneOfType:m,shape:O};else{var P=function(){o(!1,"React.PropTypes type checking code is stripped in production.")};P.isRequired=P;var _=function(){return P};x={array:P,bool:P,func:P,number:P,object:P,string:P,symbol:P,any:P,arrayOf:_,element:P,instanceOf:_,node:P,objectOf:_,oneOf:_,oneOfType:_,shape:_}}return l.prototype=Error.prototype,x.checkPropTypes=a,x.PropTypes=x,x}}).call(e,n(1))},function(t,n){t.exports=e}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("react-transition-group/TransitionGroup")):"function"==typeof define&&define.amd?define(["react","prop-types","react-transition-group/TransitionGroup"],t):"object"==typeof exports?exports.ReactOnScreen=t(require("react"),require("prop-types"),require("react-transition-group/TransitionGroup")):e.ReactOnScreen=t(e.react,e["prop-types"],e["react-transition-group/TransitionGroup"])}(this,function(e,t,n){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={POSITION:{TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},TYPE:{INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},ACTION:{SHOW:"SHOW_TOAST",CLEAR:"CLEAR_TOAST"}}},function(e,n){e.exports=t},function(e,t,n){"use strict";function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var r={eventList:new Map,on:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.eventList.has(e)||this.eventList.set(e,[]),this.eventList.get(e).push({callback:t,context:n||this}),this},off:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!=e&&null==t)return this.eventList.delete(e);if(null!=e&&null!=t){var n=this.eventList.get(e);return this.eventList.set(e,n.filter(function(e){return!(e.callback===t||e.callback.toString()===t.toString())})),n.length>0||this.eventList.delete(e),!0}return null===e&&null===t&&(this.eventList.clear(),!0)},once:function(e,t,n){this.on(e,t,n);var o=this.eventList.get(e);return o[o.length-1].once=!0,this},emit:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(!this.eventList.has(e))return console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1;var s=this.eventList.get(e);return this.eventList.set(e,s.filter(function(e){var t;return(t=e.callback).call.apply(t,[e.context].concat(o(n))),!e.once})),!0}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=[];return Object.keys(e).forEach(function(n){return t.push(e[n])}),t}},function(e,t,n){"use strict";function o(e){return Object.prototype.toString.call(e).slice(8,-1)}function r(e){return"Number"===o(e)&&!isNaN(e)&&e>0}function s(e){return e.isRequired=function(t,n,o){if(void 0===t[n])return new Error("The prop "+n+" is marked as required in \n "+o+", but its value is undefined.");e(t,n,o)},e}Object.defineProperty(t,"__esModule",{value:!0}),t.falseOrElement=t.falseOrNumber=void 0,t.typeOf=o,t.isValidDelay=r;var i=n(0);t.falseOrNumber=s(function(e,t,n){var o=e[t];return!1===o||r(o)?null:new Error(n+" expect "+t+" \n to be a valid Number > 0 or equal to false. "+o+" given.")}),t.falseOrElement=s(function(e,t,n){var o=e[t];return!1===o||(0,i.isValidElement)(o)?null:new Error(n+" expect "+t+" \n to be a valid react element or equal to false. "+o+" given.")})},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),f=n(0),p=o(f),d=n(2),h=o(d),y=n(12),v=o(y),O=n(10),b=o(O),m=n(8),T=o(m),g=n(1),_=o(g),P=n(3),E=o(P),C=n(4),j=o(C),R=n(5),N=function(e){function t(e){i(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={toast:[]},n.toastId=0,n.collection={},n}return a(t,e),c(t,[{key:"componentDidMount",value:function(){var e=this;E.default.on(_.default.ACTION.SHOW,function(t,n){return e.show(t,n)}).on(_.default.ACTION.CLEAR,function(){return e.clear()})}},{key:"componentWillUnmount",value:function(){E.default.off(_.default.ACTION.SHOW),E.default.off(_.default.ACTION.CLEAR)}},{key:"removeToast",value:function(e){this.setState({toast:this.state.toast.filter(function(t){return t!==parseInt(e,10)})})}},{key:"with",value:function(e,t){return(0,f.cloneElement)(e,l({},t,e.props))}},{key:"makeCloseButton",value:function(e,t){var n=this,o=this.props.closeButton;return((0,f.isValidElement)(e)||!1===e)&&(o=e),!1!==o&&this.with(o,{closeToast:function(){return n.removeToast(t)}})}},{key:"getAutoCloseDelay",value:function(e){return!1===e||(0,R.isValidDelay)(e)?e:this.props.autoClose}},{key:"isFunction",value:function(e){return!!(e&&e.constructor&&e.call&&e.apply)}},{key:"canBeRendered",value:function(e){return(0,f.isValidElement)(e)||"String"!==(0,R.typeOf)(e)||"Number"!==(0,R.typeOf)(e)}},{key:"show",value:function(e,t){var n=this;if(this.canBeRendered(e)){var o=++this.toastId,i={id:o,type:t.type,closeButton:this.makeCloseButton(t.closeButton,o)};this.isFunction(t.onOpen)&&(i.onOpen=t.onOpen),this.isFunction(t.onClose)&&(i.onClose=t.onClose),i.autoClose=this.getAutoCloseDelay(!1!==t.autoClose?parseInt(t.autoClose,10):t.autoClose),i.hideProgressBar="boolean"==typeof t.hideProgressBar?t.hideProgressBar:this.props.hideProgressBar,i.closeToast=function(){return n.removeToast(o)},(0,f.isValidElement)(e)&&(e=this.with(e,{closeToast:function(){return n.removeToast(o)}})),this.collection=Object.assign({},this.collection,s({},o,this.makeToast(e,i))),this.setState({toast:[].concat(r(this.state.toast),[o])})}}},{key:"makeToast",value:function(e,t){return p.default.createElement(b.default,l({},t,{position:this.props.position,key:"toast-"+t.id+" "}),e)}},{key:"clear",value:function(){this.collection={},this.setState({toast:[]})}},{key:"hasToast",value:function(){return this.state.toast.length>0}},{key:"renderProps",value:function(){var e={className:"toastify toastify--"+this.props.position};return this.hasToast()||(e.style={pointerEvents:"none"}),null!==this.props.className&&(e.className=e.className+" "+this.props.className),null!==this.props.style&&(e.style=Object.assign({},this.props.style,void 0!==e.style?e.style:{})),e}},{key:"renderToast",value:function(){var e=this,t=[];return Object.keys(this.collection).forEach(function(n){e.state.toast.includes(parseInt(n,10))?t.push(e.collection[n]):delete e.collection[n]}),t}},{key:"render",value:function(){return p.default.createElement("div",this.renderProps(),p.default.createElement(v.default,null,this.hasToast()?this.renderToast():null))}}]),t}(f.Component);N.propTypes={position:h.default.oneOf((0,j.default)(_.default.POSITION)),autoClose:R.falseOrNumber,closeButton:R.falseOrElement,hideProgressBar:h.default.bool,className:h.default.string,style:h.default.object},N.defaultProps={position:_.default.POSITION.TOP_RIGHT,autoClose:5e3,hideProgressBar:!1,closeButton:p.default.createElement(T.default,null),className:null,style:null},t.default=N},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){return Object.assign({},p,e)}Object.defineProperty(t,"__esModule",{value:!0});var s=n(3),i=o(s),u=n(1),a=o(u),l=a.default.POSITION,c=a.default.TYPE,f=a.default.ACTION,p={type:c.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null},d=function(e,t){return i.default.emit(f.SHOW,e,t)};t.default=Object.assign(function(e,t){return d(e,r(t))},{success:function(e,t){return d(e,Object.assign(r(t),{type:c.SUCCESS}))},info:function(e,t){return d(e,Object.assign(r(t),{type:c.INFO}))},warn:function(e,t){return d(e,Object.assign(r(t),{type:c.WARNING}))},error:function(e,t){return d(e,Object.assign(r(t),{type:c.ERROR}))},dismiss:function(){return i.default.emit(f.CLEAR)}},{POSITION:l,TYPE:c})},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.closeToast;return i.default.createElement("button",{className:"toastify__close",type:"button",onClick:t},"✖")}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),i=o(s),u=n(2),a=o(u);r.propTypes={closeToast:a.default.func},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.delay,n=e.isRunning,o=e.closeToast,r=e.type,s=e.hide,u={animationDuration:t+"ms",animationPlayState:n?"running":"paused"};return u.WebkitAnimationPlayState=u.animationPlayState,s&&(u.opacity=0),i.default.createElement("div",{className:"toastify__progress toastify__progress--"+r,style:u,onAnimationEnd:o})}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),i=o(s),u=n(2),a=o(u),l=n(1),c=o(l);r.propTypes={delay:a.default.number.isRequired,isRunning:a.default.bool.isRequired,closeToast:a.default.func.isRequired,type:a.default.string,hide:a.default.bool},r.defaultProps={type:c.default.TYPE.DEFAULT,hide:!1},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),a=n(0),l=o(a),c=n(2),f=o(c),p=n(9),d=o(p),h=n(1),y=o(h),v=n(4),O=o(v),b=n(5),m=function(e){function t(e){r(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.setRef=function(e){n.ref=e},n.pauseToast=function(){n.setState({isRunning:!1})},n.playToast=function(){n.setState({isRunning:!0})},n.ref=null,n.state={isRunning:!0},n}return i(t,e),u(t,[{key:"componentDidMount",value:function(){null!==this.props.onOpen&&this.props.onOpen(this.getChildrenProps())}},{key:"componentWillUnmount",value:function(){null!==this.props.onClose&&this.props.onClose(this.getChildrenProps())}},{key:"getChildrenProps",value:function(){return this.props.children.props}},{key:"getToastProps",value:function(){var e={className:"toastify-content toastify-content--"+this.props.type,ref:this.setRef};return!1!==this.props.autoClose&&(e.onMouseEnter=this.pauseToast,e.onMouseLeave=this.playToast),e}},{key:"componentWillEnter",value:function(e){this.ref.classList.add("toast-enter--"+this.props.position,"animated"),e()}},{key:"componentWillLeave",value:function(e){this.ref.classList.remove("toast-enter--"+this.props.position,"animated"),this.ref.classList.add("toast-exit--"+this.props.position,"animated"),setTimeout(function(){return e()},750)}},{key:"render",value:function(){var e=this.props,t=e.closeButton,n=e.children,o=e.autoClose,r=e.type,s=e.hideProgressBar,i=e.closeToast;return l.default.createElement("div",this.getToastProps(),!1!==t&&t,l.default.createElement("div",{className:"toastify__body"},n),!1!==o&&l.default.createElement(d.default,{delay:o,isRunning:this.state.isRunning,closeToast:i,hide:s,type:r}))}}]),t}(a.Component);m.propTypes={closeButton:b.falseOrElement.isRequired,autoClose:b.falseOrNumber.isRequired,children:f.default.node.isRequired,closeToast:f.default.func.isRequired,position:f.default.oneOf((0,O.default)(y.default.POSITION)).isRequired,hideProgressBar:f.default.bool,onOpen:f.default.func,onClose:f.default.func,type:f.default.oneOf((0,O.default)(y.default.TYPE))},m.defaultProps={type:y.default.TYPE.DEFAULT,hideProgressBar:!1,onOpen:null,onClose:null},t.default=m},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.toast=t.ToastContainer=void 0;var r=n(6),s=o(r),i=n(7),u=o(i);t.ToastContainer=s.default,t.toast=u.default},function(e,t){e.exports=n}])}); | ||
//# sourceMappingURL=ReactToastify.min.js.map |
@@ -17,4 +17,6 @@ 'use strict'; | ||
var DefaultCloseButton = function DefaultCloseButton(_ref) { | ||
/* eslint react/require-default-props: 0 */ | ||
function DefaultCloseButton(_ref) { | ||
var closeToast = _ref.closeToast; | ||
return _react2.default.createElement( | ||
@@ -27,5 +29,5 @@ 'button', | ||
}, | ||
'\xD7' | ||
'\u2716' | ||
); | ||
}; | ||
} | ||
@@ -32,0 +34,0 @@ DefaultCloseButton.propTypes = { |
@@ -8,4 +8,2 @@ 'use strict'; | ||
require('./ObjectValuesPolyfill'); | ||
var _ToastContainer = require('./ToastContainer'); | ||
@@ -12,0 +10,0 @@ |
122
lib/Toast.js
@@ -17,2 +17,6 @@ 'use strict'; | ||
var _ProgressBar = require('./ProgressBar'); | ||
var _ProgressBar2 = _interopRequireDefault(_ProgressBar); | ||
var _config = require('./config'); | ||
@@ -22,2 +26,8 @@ | ||
var _objectValues = require('./util/objectValues'); | ||
var _objectValues2 = _interopRequireDefault(_objectValues); | ||
var _propValidator = require('./util/propValidator'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,20 +41,2 @@ | ||
var propTypes = { | ||
id: _propTypes2.default.number.isRequired, | ||
closeButton: _propTypes2.default.element.isRequired, | ||
children: _propTypes2.default.node.isRequired, | ||
autoCloseId: _propTypes2.default.number, | ||
autoCloseDelay: _propTypes2.default.number, | ||
handleMouseEnter: _propTypes2.default.func, | ||
handleMouseLeave: _propTypes2.default.func, | ||
onOpen: _propTypes2.default.func, | ||
onClose: _propTypes2.default.func, | ||
type: _propTypes2.default.oneOf(Object.values(_config2.default.TYPE)), | ||
position: _propTypes2.default.oneOf(Object.values(_config2.default.POSITION)) | ||
}; | ||
var defaultProps = { | ||
type: _config2.default.TYPE.DEFAULT | ||
}; | ||
var Toast = function (_Component) { | ||
@@ -58,4 +50,18 @@ _inherits(Toast, _Component); | ||
_this.setRef = _this.setRef.bind(_this); | ||
_this.setRef = function (ref) { | ||
_this.ref = ref; | ||
}; | ||
_this.pauseToast = function () { | ||
_this.setState({ isRunning: false }); | ||
}; | ||
_this.playToast = function () { | ||
_this.setState({ isRunning: true }); | ||
}; | ||
_this.ref = null; | ||
_this.state = { | ||
isRunning: true | ||
}; | ||
return _this; | ||
@@ -67,3 +73,3 @@ } | ||
value: function componentDidMount() { | ||
this.props.onOpen(this.getChildrenProps()); | ||
this.props.onOpen !== null && this.props.onOpen(this.getChildrenProps()); | ||
} | ||
@@ -73,10 +79,5 @@ }, { | ||
value: function componentWillUnmount() { | ||
this.props.onClose(this.getChildrenProps()); | ||
this.props.onClose !== null && this.props.onClose(this.getChildrenProps()); | ||
} | ||
}, { | ||
key: 'setRef', | ||
value: function setRef(ref) { | ||
this.ref = ref; | ||
} | ||
}, { | ||
key: 'getChildrenProps', | ||
@@ -89,10 +90,3 @@ value: function getChildrenProps() { | ||
value: function getToastProps() { | ||
var _props = this.props, | ||
autoCloseId = _props.autoCloseId, | ||
autoCloseDelay = _props.autoCloseDelay, | ||
handleMouseEnter = _props.handleMouseEnter, | ||
handleMouseLeave = _props.handleMouseLeave; | ||
var props = { | ||
'data-toast-id': this.props.id, | ||
var toastProps = { | ||
className: 'toastify-content toastify-content--' + this.props.type, | ||
@@ -102,10 +96,8 @@ ref: this.setRef | ||
if (this.props.autoCloseId) { | ||
props['data-auto-close-id'] = autoCloseId; | ||
props['data-auto-close-delay'] = autoCloseDelay; | ||
props.onMouseEnter = handleMouseEnter; | ||
props.onMouseLeave = handleMouseLeave; | ||
if (this.props.autoClose !== false) { | ||
toastProps.onMouseEnter = this.pauseToast; | ||
toastProps.onMouseLeave = this.playToast; | ||
} | ||
return props; | ||
return toastProps; | ||
} | ||
@@ -115,3 +107,3 @@ }, { | ||
value: function componentWillEnter(callback) { | ||
this.ref.classList.add('bounceIn--' + this.props.position, 'animated'); | ||
this.ref.classList.add('toast-enter--' + this.props.position, 'animated'); | ||
callback(); | ||
@@ -122,7 +114,7 @@ } | ||
value: function componentWillLeave(callback) { | ||
this.ref.classList.remove('bounceIn--' + this.props.position, 'animated'); | ||
this.ref.classList.add('bounceOut--' + this.props.position, 'animated'); | ||
this.ref.classList.remove('toast-enter--' + this.props.position, 'animated'); | ||
this.ref.classList.add('toast-exit--' + this.props.position, 'animated'); | ||
setTimeout(function () { | ||
return callback(); | ||
}, 1000); | ||
}, 750); | ||
} | ||
@@ -132,11 +124,27 @@ }, { | ||
value: function render() { | ||
var _props = this.props, | ||
closeButton = _props.closeButton, | ||
children = _props.children, | ||
autoClose = _props.autoClose, | ||
type = _props.type, | ||
hideProgressBar = _props.hideProgressBar, | ||
closeToast = _props.closeToast; | ||
return _react2.default.createElement( | ||
'div', | ||
this.getToastProps(), | ||
this.props.closeButton, | ||
closeButton !== false && closeButton, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'toastify__body' }, | ||
this.props.children | ||
) | ||
children | ||
), | ||
autoClose !== false && _react2.default.createElement(_ProgressBar2.default, { | ||
delay: autoClose, | ||
isRunning: this.state.isRunning, | ||
closeToast: closeToast, | ||
hide: hideProgressBar, | ||
type: type | ||
}) | ||
); | ||
@@ -149,5 +157,19 @@ } | ||
Toast.defaultProps = defaultProps; | ||
Toast.propTypes = propTypes; | ||
Toast.propTypes = { | ||
closeButton: _propValidator.falseOrElement.isRequired, | ||
autoClose: _propValidator.falseOrNumber.isRequired, | ||
children: _propTypes2.default.node.isRequired, | ||
closeToast: _propTypes2.default.func.isRequired, | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_config2.default.POSITION)).isRequired, | ||
hideProgressBar: _propTypes2.default.bool, | ||
onOpen: _propTypes2.default.func, | ||
onClose: _propTypes2.default.func, | ||
type: _propTypes2.default.oneOf((0, _objectValues2.default)(_config2.default.TYPE)) | ||
}; | ||
Toast.defaultProps = { | ||
type: _config2.default.TYPE.DEFAULT, | ||
hideProgressBar: false, | ||
onOpen: null, | ||
onClose: null | ||
}; | ||
exports.default = Toast; |
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -22,10 +20,6 @@ | ||
var _reactAddonsTransitionGroup = require('react-addons-transition-group'); | ||
var _TransitionGroup = require('react-transition-group/TransitionGroup'); | ||
var _reactAddonsTransitionGroup2 = _interopRequireDefault(_reactAddonsTransitionGroup); | ||
var _TransitionGroup2 = _interopRequireDefault(_TransitionGroup); | ||
var _EventManager = require('./util/EventManager'); | ||
var _EventManager2 = _interopRequireDefault(_EventManager); | ||
var _Toast = require('./Toast'); | ||
@@ -43,2 +37,12 @@ | ||
var _EventManager = require('./util/EventManager'); | ||
var _EventManager2 = _interopRequireDefault(_EventManager); | ||
var _objectValues = require('./util/objectValues'); | ||
var _objectValues2 = _interopRequireDefault(_objectValues); | ||
var _propValidator = require('./util/propValidator'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -56,16 +60,2 @@ | ||
var propTypes = { | ||
position: _propTypes2.default.oneOf(Object.values(_config2.default.POSITION)), | ||
autoClose: _propTypes2.default.oneOfType([_propTypes2.default.bool, _propTypes2.default.number]), | ||
closeButton: _propTypes2.default.element, | ||
className: _propTypes2.default.string, | ||
style: _propTypes2.default.object | ||
}; | ||
var defaultProps = { | ||
position: _config2.default.POSITION.TOP_RIGHT, | ||
autoClose: 5000, | ||
closeButton: null | ||
}; | ||
var ToastContainer = function (_Component) { | ||
@@ -84,4 +74,2 @@ _inherits(ToastContainer, _Component); | ||
_this.collection = {}; | ||
_this.handleMouseEnter = _this.handleMouseEnter.bind(_this); | ||
_this.handleMouseLeave = _this.handleMouseLeave.bind(_this); | ||
return _this; | ||
@@ -108,56 +96,52 @@ } | ||
}, { | ||
key: 'setAutoClose', | ||
value: function setAutoClose(toastId, delay) { | ||
var _this3 = this; | ||
return setTimeout(function () { | ||
return _this3.removeToast(toastId); | ||
}, delay); | ||
} | ||
}, { | ||
key: 'isFunction', | ||
value: function isFunction(object) { | ||
return !!(object && object.constructor && object.call && object.apply); | ||
} | ||
}, { | ||
key: 'shouldAutoClose', | ||
value: function shouldAutoClose(autoCloseOpt) { | ||
return !!(this.props.autoClose !== false && autoCloseOpt !== false || this.props.autoClose === false && autoCloseOpt !== false && autoCloseOpt !== null); | ||
} | ||
}, { | ||
key: 'removeToast', | ||
value: function removeToast(id) { | ||
this.setState({ toast: this.state.toast.filter(function (v) { | ||
this.setState({ | ||
toast: this.state.toast.filter(function (v) { | ||
return v !== parseInt(id, 10); | ||
}) }); | ||
}) | ||
}); | ||
} | ||
}, { | ||
key: 'withClose', | ||
value: function withClose(component, props) { | ||
key: 'with', | ||
value: function _with(component, props) { | ||
return (0, _react.cloneElement)(component, _extends({}, props, component.props)); | ||
} | ||
}, { | ||
key: 'validateCloseButton', | ||
value: function validateCloseButton(closeButton) { | ||
if (!(0, _react.isValidElement)(closeButton)) { | ||
throw new Error('CloseButton must be a valid react element instead of ' + (typeof closeButton === 'undefined' ? 'undefined' : _typeof(closeButton))); | ||
key: 'makeCloseButton', | ||
value: function makeCloseButton(toastClose, toastId) { | ||
var _this3 = this; | ||
var closeButton = this.props.closeButton; | ||
if ((0, _react.isValidElement)(toastClose) || toastClose === false) { | ||
closeButton = toastClose; | ||
} | ||
return closeButton === false ? false : this.with(closeButton, { | ||
closeToast: function closeToast() { | ||
return _this3.removeToast(toastId); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'makeCloseButton', | ||
value: function makeCloseButton(optCloseButton, toastId) { | ||
var _this4 = this; | ||
key: 'getAutoCloseDelay', | ||
value: function getAutoCloseDelay(toastAutoClose) { | ||
var closeButton = _react2.default.createElement(_DefaultCloseButton2.default, null); | ||
return toastAutoClose === false || (0, _propValidator.isValidDelay)(toastAutoClose) ? toastAutoClose : this.props.autoClose; | ||
} | ||
}, { | ||
key: 'isFunction', | ||
value: function isFunction(object) { | ||
return !!(object && object.constructor && object.call && object.apply); | ||
} | ||
if (optCloseButton === null && this.props.closeButton !== null) { | ||
closeButton = this.props.closeButton; | ||
} else if (optCloseButton !== null) { | ||
this.validateCloseButton(optCloseButton); | ||
closeButton = optCloseButton; | ||
} | ||
/** | ||
* TODO: check if throwing an error can be helpful | ||
*/ | ||
return this.withClose(closeButton, { closeToast: function closeToast() { | ||
return _this4.removeToast(toastId); | ||
} }); | ||
}, { | ||
key: 'canBeRendered', | ||
value: function canBeRendered(content) { | ||
return (0, _react.isValidElement)(content) || (0, _propValidator.typeOf)(content) !== 'String' || (0, _propValidator.typeOf)(content) !== 'Number'; | ||
} | ||
@@ -167,27 +151,30 @@ }, { | ||
value: function show(content, options) { | ||
content = typeof content === 'string' ? _react2.default.createElement( | ||
'div', | ||
null, | ||
content | ||
) : content; | ||
var _this4 = this; | ||
if ((0, _react.isValidElement)(content)) { | ||
if (this.canBeRendered(content)) { | ||
var toastId = ++this.toastId; | ||
var autoCloseOpt = options.autoClose; | ||
var fn = function fn() {}; | ||
var toastOptions = { | ||
id: toastId, | ||
type: options.type, | ||
onOpen: this.isFunction(options.onOpen) ? options.onOpen : fn, | ||
onClose: this.isFunction(options.onClose) ? options.onClose : fn, | ||
closeButton: this.makeCloseButton(options.closeButton, toastId) | ||
}; | ||
if (this.shouldAutoClose(autoCloseOpt)) { | ||
var delay = autoCloseOpt !== null ? parseInt(autoCloseOpt, 10) : this.props.autoClose; | ||
this.isFunction(options.onOpen) && (toastOptions.onOpen = options.onOpen); | ||
toastOptions.autoCloseId = this.setAutoClose(toastId, delay); | ||
toastOptions.autoCloseDelay = delay; | ||
toastOptions.handleMouseEnter = this.handleMouseEnter; | ||
toastOptions.handleMouseLeave = this.handleMouseLeave; | ||
this.isFunction(options.onClose) && (toastOptions.onClose = options.onClose); | ||
toastOptions.autoClose = this.getAutoCloseDelay(options.autoClose !== false ? parseInt(options.autoClose, 10) : options.autoClose); | ||
toastOptions.hideProgressBar = typeof options.hideProgressBar === 'boolean' ? options.hideProgressBar : this.props.hideProgressBar; | ||
toastOptions.closeToast = function () { | ||
return _this4.removeToast(toastId); | ||
}; | ||
if ((0, _react.isValidElement)(content)) { | ||
content = this.with(content, { | ||
closeToast: function closeToast() { | ||
return _this4.removeToast(toastId); | ||
} | ||
}); | ||
} | ||
@@ -221,27 +208,7 @@ | ||
}, { | ||
key: 'handleMouseEnter', | ||
value: function handleMouseEnter(e) { | ||
clearTimeout(e.currentTarget.dataset.autoCloseId); | ||
key: 'hasToast', | ||
value: function hasToast() { | ||
return this.state.toast.length > 0; | ||
} | ||
}, { | ||
key: 'handleMouseLeave', | ||
value: function handleMouseLeave(e) { | ||
var _e$currentTarget$data = e.currentTarget.dataset, | ||
toastId = _e$currentTarget$data.toastId, | ||
autoCloseDelay = _e$currentTarget$data.autoCloseDelay; | ||
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) | ||
}); | ||
this.forceUpdate(); | ||
} | ||
} | ||
}, { | ||
key: 'isObjectEmpty', | ||
value: function isObjectEmpty() { | ||
return this.state.toast.length === 0; | ||
} | ||
}, { | ||
key: 'renderProps', | ||
@@ -253,8 +220,12 @@ value: function renderProps() { | ||
if (this.props.className) { | ||
if (!this.hasToast()) { | ||
props.style = { pointerEvents: 'none' }; | ||
} | ||
if (this.props.className !== null) { | ||
props.className = props.className + ' ' + this.props.className; | ||
} | ||
if (this.props.style) { | ||
props.style = this.props.style; | ||
if (this.props.style !== null) { | ||
props.style = Object.assign({}, this.props.style, typeof props.style !== 'undefined' ? props.style : {}); | ||
} | ||
@@ -269,9 +240,7 @@ | ||
return Object.keys(this.collection).map(function (idx) { | ||
if (_this5.state.toast.includes(parseInt(idx, 10))) { | ||
return _this5.collection[idx]; | ||
} else { | ||
delete _this5.collection[idx]; | ||
} | ||
var toastToRender = []; | ||
Object.keys(this.collection).forEach(function (idx) { | ||
_this5.state.toast.includes(parseInt(idx, 10)) ? toastToRender.push(_this5.collection[idx]) : delete _this5.collection[idx]; | ||
}); | ||
return toastToRender; | ||
} | ||
@@ -285,5 +254,5 @@ }, { | ||
_react2.default.createElement( | ||
_reactAddonsTransitionGroup2.default, | ||
_TransitionGroup2.default, | ||
null, | ||
this.isObjectEmpty() ? null : this.renderToast() | ||
this.hasToast() ? this.renderToast() : null | ||
) | ||
@@ -297,5 +266,41 @@ ); | ||
ToastContainer.defaultProps = defaultProps; | ||
ToastContainer.propTypes = propTypes; | ||
ToastContainer.propTypes = { | ||
/** | ||
* Set toast position | ||
*/ | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_config2.default.POSITION)), | ||
/** | ||
* Disable or set autoClose delay | ||
*/ | ||
autoClose: _propValidator.falseOrNumber, | ||
/** | ||
* Disable or set a custom react element for the close button | ||
*/ | ||
closeButton: _propValidator.falseOrElement, | ||
/** | ||
* Hide or not progress bar when autoClose is enabled | ||
*/ | ||
hideProgressBar: _propTypes2.default.bool, | ||
/** | ||
* An optional className | ||
*/ | ||
className: _propTypes2.default.string, | ||
/** | ||
* An optional style | ||
*/ | ||
style: _propTypes2.default.object | ||
}; | ||
ToastContainer.defaultProps = { | ||
position: _config2.default.POSITION.TOP_RIGHT, | ||
autoClose: 5000, | ||
hideProgressBar: false, | ||
closeButton: _react2.default.createElement(_DefaultCloseButton2.default, null), | ||
className: null, | ||
style: null | ||
}; | ||
exports.default = ToastContainer; |
@@ -17,2 +17,8 @@ 'use strict'; | ||
/* | ||
* TODO: Add validation here : | ||
* - Validate type | ||
* - Maybe autoClose | ||
* - Maybe closeButton as well | ||
* */ | ||
var POSITION = _config2.default.POSITION, | ||
@@ -26,3 +32,4 @@ TYPE = _config2.default.TYPE, | ||
autoClose: null, | ||
closeButton: null | ||
closeButton: null, | ||
hideProgressBar: null | ||
}; | ||
@@ -29,0 +36,0 @@ |
@@ -7,2 +7,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); } } | ||
var eventManager = { | ||
@@ -88,2 +90,3 @@ eventList: new Map(), | ||
if (!this.eventList.has(event)) { | ||
/* eslint no-console: 0 */ | ||
console.warn("<" + event + "> Event is not registered. Did you forgot to bind the event ?"); | ||
@@ -97,3 +100,3 @@ return false; | ||
(_listener$callback = listener.callback).call.apply(_listener$callback, [listener.context].concat(args)); | ||
(_listener$callback = listener.callback).call.apply(_listener$callback, [listener.context].concat(_toConsumableArray(args))); | ||
return !listener.once; | ||
@@ -100,0 +103,0 @@ })); |
{ | ||
"name": "react-toastify", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "React notification made easy", | ||
@@ -17,6 +17,3 @@ "keywords": [ | ||
"lint": "eslint src/", | ||
"pretest": "npm run lint", | ||
"test": "mocha --compilers js:babel-core/register --require jsdomSetup.js --recursive test/", | ||
"prebuild": "npm run lint", | ||
"build": "./scripts/build.sh", | ||
"build": "NODE_ENV=production ./scripts/build.sh", | ||
"postbuild": "npm run style", | ||
@@ -37,6 +34,5 @@ "prestyle": "sass src/scss/main.scss dist/ReactToastify.css", | ||
"dependencies": { | ||
"object.values": "^1.0.3", | ||
"prop-types": "^15.5.6", | ||
"react": "^15.3.2", | ||
"react-addons-transition-group": "^15.3.2" | ||
"prop-types": "^15.5.8", | ||
"react": "^15.5.4", | ||
"react-transition-group": "^1.1.2" | ||
}, | ||
@@ -46,4 +42,5 @@ "devDependencies": { | ||
"babel-cli": "^6.11.4", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.13.2", | ||
"babel-eslint": "^7.2.3", | ||
"babel-loader": "^7.0.0", | ||
"babel-preset-env": "^1.4.0", | ||
"babel-preset-react": "^6.11.1", | ||
@@ -55,17 +52,16 @@ "babel-preset-stage-0": "^6.5.0", | ||
"eslint": "^3.2.2", | ||
"eslint-config-airbnb": "^10.0.0", | ||
"eslint-plugin-import": "^1.13.0", | ||
"eslint-plugin-jsx-a11y": "^2.1.0", | ||
"eslint-config-airbnb": "^14.1.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jsx-a11y": "^4.0.0", | ||
"eslint-plugin-react": "^6.0.0", | ||
"extract-text-webpack-plugin": "^1.0.1", | ||
"jsdom": "^9.4.2", | ||
"jsdom": "^10.1.0", | ||
"karma": "^1.2.0", | ||
"mocha": "^3.0.2", | ||
"postcss": "^5.2.5", | ||
"postcss-cli": "^2.6.0", | ||
"postcss-cli": "^3.2.0", | ||
"react-addons-test-utils": "^15.3.0", | ||
"react-dom": "^15.3.0", | ||
"sinon": "^1.17.5", | ||
"webpack": "^1.13.1" | ||
"sinon": "^2.1.0", | ||
"webpack": "^2.4.1" | ||
} | ||
} |
# 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)]() | ||
React-Toastify allow you to add toast notification to your app with ease. | ||
* [Demo](#demo) | ||
* [Installation](#installation) | ||
* [Features](#features) | ||
* [How it works ?](#how-it-works-) | ||
* [Api](#api) | ||
* [Release Notes](#release-notes) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
## Demo | ||
Check the demo [here](https://sniphpet.github.io/react-toastify/) | ||
Live demo [here](https://sniphpet.github.io/react-toastify/) | ||
@@ -25,5 +34,7 @@ ## Installation | ||
- Can display a react component inside the toast ! | ||
- Don't rely on `findDOMNode` | ||
- Has ```onOpen``` and ```onClose``` hooks. Both can access the props passed to the react component rendered inside the toast | ||
- Can be positioned | ||
- Define behavior per toast | ||
- Easy to setup | ||
- Super easy to customize | ||
@@ -33,7 +44,8 @@ | ||
The component use a dead simple pubsub(observer pattern) to listen and trigger event. The pubsub allow us to display a toast from everywhere in your app. | ||
The component use a dead simple pubsub(observer pattern) to listen and trigger event. The pubsub allow us to display a toast from everywhere in our app. | ||
- Add a ToastContainer to your app | ||
```javascript | ||
//index.js | ||
import React from 'react'; | ||
@@ -48,3 +60,3 @@ import { render } from 'react-dom'; | ||
{/*Your others component*/} | ||
<ToastContainer autoClose={3000} position="top-center"/> | ||
<ToastContainer /> | ||
</div> | ||
@@ -64,2 +76,3 @@ ); | ||
```javascript | ||
//foo.js | ||
import React from 'react'; | ||
@@ -71,5 +84,3 @@ import { toast } from 'react-toastify'; | ||
function handleClick() { | ||
toast(<Greet name="John" />, { | ||
type: toast.TYPE.INFO | ||
}); | ||
toast(<Greet name="John" />); | ||
} | ||
@@ -86,3 +97,3 @@ | ||
### ToastContainer (Type : React Component) | ||
### ToastContainer (Type : React Component) | ||
@@ -93,7 +104,9 @@ |Props|Type|Default|Description| | ||
|autoClose|false\|int|5000|Delay in ms to close the toast. If set to false, the notification need to be closed manualy| | ||
|className|string|-|Add classes to the container| | ||
|style|object|-|Add inline style to the container| | ||
|className|string|-|Add optional classes to the container| | ||
|style|object|-|Add optional inline style to the container| | ||
|closeButton|React Element|-|A React Component to replace the default close button| | ||
|hideProgressBar|bool|false|Display or not the progress bar below the toast(remaining time)| | ||
|removeCloseButton|bool|false|If you don't want the toast to render a close button| | ||
Position accept the following value : | ||
- Position accept the following value : | ||
@@ -113,3 +126,3 @@ ```javascript | ||
When using a custom close button, the component will receive a prop ```closeToast```. You need to call it to close the toast. | ||
- When using a custom close button, the component will receive a prop ```closeToast```. You need to call it to close the toast. | ||
@@ -131,3 +144,3 @@ ```javascript | ||
### toast (Type: Object) | ||
### toast (Type: Object) | ||
@@ -139,15 +152,23 @@ All the function inside toast can take 2 parameters : | ||
|content|string\|React Element|✓|Element that will be displayed| | ||
|options|object|✘|Possible keys : autoClose, type, closeButton | ||
The autoClose and closeButton both take precedence over the container's props. | ||
|options|object|✘|Possible keys : autoClose, type, closeButton, hideProgressBar|| | ||
- Available options : | ||
- `type`: Kind of notification. One of "default", "success", "info", "warning", "error". You can use `toast.TYPE.INFO` and so on to avoid any typo. | ||
- `onOpen`: callback before showing the notification. If you display a component its props will be passed to the callback as first parameter. | ||
- `onClose`: callback after closing the notification. If you display a component its props will be passed to the callback as first parameter. | ||
- `autoClose`: same as ToastContainer. | ||
- `closeButton`: same as ToastContainer. | ||
- `hideProgressBar`: same as ToastContainer. | ||
:warning:️ *autoClose, closeButton, hideProgressBar, supersede ToastContainer props* :warning: | ||
```javascript | ||
const Img = (props) => <div><img width={48} src={props.foo} /></div>; | ||
const Img = ({ src }) => <div><img width={48} src={src} /></div>; | ||
const options = { | ||
//callback can access props passed to the component | ||
onOpen: (props) => {console.log(props.foo)}, | ||
onClose: (props) => {console.log(props.foo)}, | ||
autoClose: false, //The user need to close the toast to remove it | ||
onOpen: props => console.log(props.foo), | ||
onClose: props => console.log(props.foo), | ||
autoClose: 6000, | ||
closeButton: <FontAwesomeCloseButton />, | ||
type: toast.TYPE.INFO | ||
type: toast.TYPE.INFO, | ||
hideProgressBar: false | ||
}; | ||
@@ -163,4 +184,20 @@ | ||
## Release Notes | ||
### v1.4.0 | ||
- React v16 ready : moving to prop-types and react-transition-group | ||
- Internal rewrite of components. The implementation wasn't bad but it wasn't good either. A better props validation has been added has well. | ||
- Removed useless dependencies. I was using the Object.values polyfill when a one line forEach can do the same is my case. | ||
- Now I believe it's even easier to style the components. The sass sources files are now included when you install the package via yarn or npm | ||
- The default close button has been replaced. | ||
#### New Features | ||
- A progress bar is now visible to track the remaining time before the notification is closed. Of course if you don't like it, you are free to disable it. | ||
- You can choose to display a close button or not. | ||
- Event pointer is set to none to avoid losing pointer events on everything beneath the toast container when no toast are displayed | ||
- The `closeToast` callback is also passed down to your component. | ||
### v1.3.0 | ||
@@ -171,3 +208,3 @@ | ||
#### Features | ||
#### New Features | ||
@@ -199,3 +236,3 @@ - Possibility to use a custom close button. Check the api docs of ToastContainer and toast. | ||
#### Features | ||
#### New Features | ||
@@ -207,3 +244,3 @@ - Passing prop using toast option will be removed at the next release. It doesn't | ||
#### Features | ||
#### New Features | ||
@@ -215,3 +252,3 @@ - Added onOpen callback | ||
Any suggestions and pull request are welcome ! | ||
Any suggestions and pull request are welcome ! | ||
@@ -218,0 +255,0 @@ ## License |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
359282
3
41
1527
243
- Removedobject.values@^1.0.3
- Removedcall-bind@1.0.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.values@1.2.0(transitive)
- Removedreact-addons-transition-group@15.6.2(transitive)
- Removedset-function-length@1.2.2(transitive)
Updatedprop-types@^15.5.8
Updatedreact@^15.5.4