react-toastify
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","prop-types","react-dom"],t):"object"==typeof exports?exports.ReactToastify=t(require("react"),require("prop-types"),require("react-dom")):e.ReactToastify=t(e.react,e["prop-types"],e["react-dom"])}(this,function(e,t,n){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},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=13)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}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)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return Ue.speedy(e)}function s(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];$e=!!e}function u(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t=(0,ze.default)(t),t?$e?t.reduce(function(e,t){return e["data-simulate-"+c(t)]="",e},{}):(Je||(console.warn("can't simulate without once calling simulations(true)"),Je=!0),Ve||Xe||Ke||(console.warn("don't use simulation outside dev"),Ke=!0),{}):{}}function l(e){Qe=!!e}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e.toLowerCase().replace(/[^a-z0-9]/g,t)}function f(e){var t=JSON.stringify(e),n=(0,He.default)(t).toString(36);return e.label&&e.label.length>0&&Ve?c(e.label.join("."),"-")+"-"+n:n}function d(e){var t=Object.keys(e).filter(function(e){return"toString"!==e});return 1===t.length&&!!/data\-css\-([a-zA-Z0-9\-_]+)/.exec(t[0])}function p(e){var t=Object.keys(e).filter(function(e){return"toString"!==e});if(1!==t.length)throw new Error("not a rule");var n=/data\-css\-([a-zA-Z0-9\-_]+)/,r=n.exec(t[0]);if(!r)throw new Error("not a rule");return r[1]}function h(e){if(-1===e.indexOf(","))return[e];for(var t,n=[],r=[],o=0;t=et.exec(e);)switch(t[0]){case"(":o++;break;case")":o--;break;case",":if(o)break;n.push(t.index)}for(t=n.length;t--;)r.unshift(e.slice(n[t]+1)),e=e.slice(0,n[t]);return r.unshift(e),r}function m(e,t){if(!e)return t.replace(/\&/g,"");if(!t)return".css-"+e+",[data-css-"+e+"]";var n=h(t).map(function(t){return t.indexOf("&")>=0?[t.replace(/\&/gm,".css-"+e),t.replace(/\&/gm,"[data-css-"+e+"]")].join(","):".css-"+e+t+",[data-css-"+e+"]"+t}).join(",");return $e&&/^\&\:/.exec(t)&&!/\s/.exec(t)&&(n+=",.css-"+e+"[data-simulate-"+c(t)+"],[data-css-"+e+"][data-simulate-"+c(t)+"]"),n}function y(e){var t=e.selector,n=e.style,r=Ye.transform({selector:t,style:n});return r.selector+"{"+(0,De.createMarkupForStyles)(r.style)+"}"}function b(e){var t=void 0,n=void 0,r=void 0,o=void 0;return Object.keys(e).forEach(function(i){i.indexOf("&")>=0?(n=n||{},n[i]=e[i]):0===i.indexOf("@media")?(r=r||{},r[i]=b(e[i])):0===i.indexOf("@supports")?(o=o||{},o[i]=b(e[i])):"label"===i?e.label.length>0&&(t=t||{},t.label=Qe?e.label.join("."):""):(t=t||{},t[i]=e[i])}),{plain:t,selects:n,medias:r,supports:o}}function g(e,t){var n=[],r=t.plain,o=t.selects,i=t.medias,a=t.supports;return r&&n.push(y({style:r,selector:m(e)})),o&&Object.keys(o).forEach(function(t){return n.push(y({style:o[t],selector:m(e,t)}))}),i&&Object.keys(i).forEach(function(t){return n.push(t+"{"+g(e,i[t]).join("")+"}")}),a&&Object.keys(a).forEach(function(t){return n.push(t+"{"+g(e,a[t]).join("")+"}")}),n}function v(e){if(!tt[e.id]){tt[e.id]=!0;var t=b(e.style),n=g(e.id,t);tt[e.id]=!!Ze||n,n.forEach(function(e){return Ue.insert(e)})}}function O(e){nt[e.id]||(nt[e.id]=e)}function x(e){if(d(e)){var t=nt[p(e)];if(null==t)throw new Error("[glamor] an unexpected rule cache miss occurred. This is probably a sign of multiple glamor instances in your app. See https://github.com/threepointone/glamor/issues/79");return t}return e}function E(e){if(O(e),v(e),rt[e.id])return rt[e.id];var t=i({},"data-css-"+e.id,Qe?e.label||"":"");return Object.defineProperty(t,"toString",{enumerable:!1,value:function(){return"css-"+e.id}}),rt[e.id]=t,t}function T(e){for(var t=[":",".","[",">"," "],n=!1,r=e.charAt(0),o=0;o<t.length;o++)if(r===t[o]){n=!0;break}return n||e.indexOf("&")>=0}function k(e,t){var n=h(e).map(function(e){return e.indexOf("&")>=0?e:"&"+e});return h(t).map(function(e){return e.indexOf("&")>=0?e:"&"+e}).reduce(function(e,t){return e.concat(n.map(function(e){return t.replace(/\&/g,e)}))},[]).join(",")}function w(e,t){return e?"@media "+e.substring(6)+" and "+t.substring(6):t}function _(e){return 0===e.indexOf("@media")}function C(e){return 0===e.indexOf("@supports")}function P(e,t){return e?"@supports "+e.substring(9)+" and "+t.substring(9):t}function S(e){for(var t=[],n=0;n<e.length;n++)t=Array.isArray(e[n])?t.concat(S(e[n])):t.concat(e[n]);return t}function j(e,t){var n=t.selector,r=void 0===n?"":n,o=t.mq,i=void 0===o?"":o,a=t.supp,s=void 0===a?"":a,u=t.src,l=void 0===u?{}:u;Array.isArray(l)||(l=[l]),l=S(l),l.forEach(function(t){if(d(t)){var n=x(t);if("css"!==n.type)throw new Error("cannot merge this rule");t=n.style}t=(0,ze.default)(t),t&&t.composes&&j(e,{selector:r,mq:i,supp:s,src:t.composes}),Object.keys(t||{}).forEach(function(n){if(T(n))ot[n]&&ot[n].forEach(function(o){return j(e,{selector:k(r,o),mq:i,supp:s,src:t[n]})}),j(e,{selector:k(r,n),mq:i,supp:s,src:t[n]});else if(_(n))j(e,{selector:r,mq:w(i,n),supp:s,src:t[n]});else if(C(n))j(e,{selector:r,mq:i,supp:P(s,n),src:t[n]});else if("composes"===n);else{var o=e;s&&(o[s]=o[s]||{},o=o[s]),i&&(o[i]=o[i]||{},o=o[i]),r&&(o[r]=o[r]||{},o=o[r]),"label"===n?Qe&&(e.label=e.label.concat(t.label)):o[n]=t[n]}})})}function N(e){var t={label:[]};return j(t,{src:e}),E({id:f(t),style:t,label:Qe?t.label.join("."):"",type:"css"})}function M(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(t[0]&&t[0].length&&t[0].raw)throw new Error("you forgot to include glamor/babel in your babel plugins.");return t=(0,ze.default)(t),t?ut(t):it}function R(e){if(!tt[e.id]){var t=Object.keys(e.keyframes).map(function(t){var n=Ye.keyframes.transform({id:e.id,name:t,style:e.keyframes[t]});return n.name+"{"+(0,De.createMarkupForStyles)(n.style)+"}"}).join(""),n=["-webkit-","-moz-","-o-",""].map(function(n){return"@"+n+"keyframes "+e.name+"_"+e.id+"{"+t+"}"});n.forEach(function(e){return Ue.insert(e)}),tt[e.id]=!!Ze||n}}function A(e){if(!tt[e.id]){var t="@font-face{"+(0,De.createMarkupForStyles)(e.font)+"}";Ue.insert(t),tt[e.id]=!!Ze||[t]}}function I(e){(0,Be.default)(tt,e.reduce(function(e,t){return e[t]=!0,e},{}))}function W(){tt=Ue.inserted={},nt=Ue.registered={},rt={},Ue.flush(),Ue.inject()}function B(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e?M(i({},e,n)):lt(n)}function L(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return M(i({},e+" &",n))}function D(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return M(i({},"@media "+e,n))}function F(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return M(i({},e,n))}function z(e){return F(":active",e)}function q(e){return F(":any",e)}function G(e){return F(":checked",e)}function H(e){return F(":disabled",e)}function U(e){return F(":empty",e)}function Y(e){return F(":enabled",e)}function V(e){return F(":default",e)}function X(e){return F(":first",e)}function Z(e){return F(":first-child",e)}function $(e){return F(":first-of-type",e)}function J(e){return F(":fullscreen",e)}function K(e){return F(":focus",e)}function Q(e){return F(":hover",e)}function ee(e){return F(":indeterminate",e)}function te(e){return F(":in-range",e)}function ne(e){return F(":invalid",e)}function re(e){return F(":last-child",e)}function oe(e){return F(":last-of-type",e)}function ie(e){return F(":left",e)}function ae(e){return F(":link",e)}function se(e){return F(":only-child",e)}function ue(e){return F(":only-of-type",e)}function le(e){return F(":optional",e)}function ce(e){return F(":out-of-range",e)}function fe(e){return F(":read-only",e)}function de(e){return F(":read-write",e)}function pe(e){return F(":required",e)}function he(e){return F(":right",e)}function me(e){return F(":root",e)}function ye(e){return F(":scope",e)}function be(e){return F(":target",e)}function ge(e){return F(":valid",e)}function ve(e){return F(":visited",e)}function Oe(e,t){return F(":dir("+e+")",t)}function xe(e,t){return F(":lang("+e+")",t)}function Ee(e,t){var n=e.split(",").map(function(e){return e.trim()}).map(function(e){return":not("+e+")"});return 1===n.length?F(":not("+e+")",t):B(n.join(""),t)}function Te(e,t){return F(":nth-child("+e+")",t)}function ke(e,t){return F(":nth-last-child("+e+")",t)}function we(e,t){return F(":nth-last-of-type("+e+")",t)}function _e(e,t){return F(":nth-of-type("+e+")",t)}function Ce(e){return F("::after",e)}function Pe(e){return F("::before",e)}function Se(e){return F("::first-letter",e)}function je(e){return F("::first-line",e)}function Ne(e){return F("::selection",e)}function Me(e){return F("::backdrop",e)}function Re(e){return M({"::placeholder":e})}function Ae(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t=(0,ze.default)(t),t?t.map(function(e){var t={label:[]};return j(t,{src:e}),g(f(t),b(t)).join("")}).join(""):""}function Ie(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t=(0,ze.default)(t),t?t.map(function(e){p(e);var t=Object.keys(e)[0];return t+'="'+(e[t]||"")+'"'}).join(" "):""}Object.defineProperty(t,"__esModule",{value:!0}),t.compose=t.merge=t.$=t.style=t.presets=t.keyframes=t.fontFace=t.insertGlobal=t.insertRule=t.plugins=t.styleSheet=void 0,t.speedy=a,t.simulations=s,t.simulate=u,t.cssLabels=l,t.isLikeRule=d,t.idFor=p,t.css=M,t.rehydrate=I,t.flush=W,t.select=B,t.parent=L,t.media=D,t.pseudo=F,t.active=z,t.any=q,t.checked=G,t.disabled=H,t.empty=U,t.enabled=Y,t._default=V,t.first=X,t.firstChild=Z,t.firstOfType=$,t.fullscreen=J,t.focus=K,t.hover=Q,t.indeterminate=ee,t.inRange=te,t.invalid=ne,t.lastChild=re,t.lastOfType=oe,t.left=ie,t.link=ae,t.onlyChild=se,t.onlyOfType=ue,t.optional=le,t.outOfRange=ce,t.readOnly=fe,t.readWrite=de,t.required=pe,t.right=he,t.root=me,t.scope=ye,t.target=be,t.valid=ge,t.visited=ve,t.dir=Oe,t.lang=xe,t.not=Ee,t.nthChild=Te,t.nthLastChild=ke,t.nthLastOfType=we,t.nthOfType=_e,t.after=Ce,t.before=Pe,t.firstLetter=Se,t.firstLine=je,t.selection=Ne,t.backdrop=Me,t.placeholder=Re,t.cssFor=Ae,t.attribsFor=Ie;var We=n(6),Be=r(We),Le=n(15),De=n(7),Fe=n(24),ze=r(Fe),qe=n(25),Ge=n(42),He=r(Ge),Ue=t.styleSheet=new Le.StyleSheet;Ue.inject();var Ye=t.plugins=Ue.plugins=new qe.PluginSet([qe.prefixes,qe.contentWrap,qe.fallbacks]);Ye.media=new qe.PluginSet,Ye.fontFace=new qe.PluginSet,Ye.keyframes=new qe.PluginSet([qe.prefixes,qe.fallbacks]);var Ve=!1,Xe=!1,Ze="undefined"!=typeof window,$e=Ve,Je=!1,Ke=!1,Qe=Ve,et=/[(),]|"(?:\\.|[^"\n])*"|'(?:\\.|[^'\n])*'|\/\*[\s\S]*?\*\//g,tt=Ue.inserted={},nt=Ue.registered={},rt={},ot={"::placeholder":["::-webkit-input-placeholder","::-moz-placeholder","::-ms-input-placeholder"],":fullscreen":[":-webkit-full-screen",":-moz-full-screen",":-ms-fullscreen"]},it={};Object.defineProperty(it,"toString",{enumerable:!1,value:function(){return"css-nil"}});var at="undefined"!=typeof WeakMap?[it,new WeakMap,new WeakMap,new WeakMap]:[it],st=!1,ut="undefined"!=typeof WeakMap?function(e){return function(t){if(at[t.length]){for(var n=at[t.length],r=0;r<t.length-1;)n.has(t[r])||n.set(t[r],new WeakMap),n=n.get(t[r]),r++;if(n.has(t[t.length-1])){var i=n.get(t[r]);if(nt[i.toString().substring(4)])return i}}var a=e(t);if(at[t.length]){for(var s=0,u=at[t.length];s<t.length-1;)u=u.get(t[s]),s++;try{u.set(t[s],a)}catch(e){if(Ve&&!st){var l;st=!0,(l=console).warn.apply(l,["failed setting the WeakMap cache for args:"].concat(o(t))),console.warn("this should NOT happen, please file a bug on the github repo.")}}}return a}}(N):N;M.insert=function(e){var t={id:f(e),css:e,type:"raw"};O(t),tt[t.id]||(Ue.insert(t.css),tt[t.id]=!!Ze||[t.css])},t.insertRule=M.insert,M.global=function(e,t){if(t=(0,ze.default)(t))return M.insert(y({selector:e,style:t}))},t.insertGlobal=M.global,M.keyframes=function(e,t){t||(t=e,e="animation"),t=(0,ze.default)(t)||{};var n={id:f({name:e,kfs:t}),type:"keyframes",name:e,keyframes:t};return O(n),R(n),e+"_"+n.id},M.fontFace=function(e){e=(0,ze.default)(e);var t={id:f(e),type:"font-face",font:e};return O(t),A(t),e.fontFamily};var lt=(t.fontFace=M.fontFace,t.keyframes=M.keyframes,t.presets={mobile:"(min-width: 400px)",Mobile:"@media (min-width: 400px)",phablet:"(min-width: 550px)",Phablet:"@media (min-width: 550px)",tablet:"(min-width: 750px)",Tablet:"@media (min-width: 750px)",desktop:"(min-width: 1000px)",Desktop:"@media (min-width: 1000px)",hd:"(min-width: 1200px)",Hd:"@media (min-width: 1200px)"},t.style=M);t.$=B,t.merge=M,t.compose=M},function(e,t,n){"use strict";function r(e){return"string"==typeof e&&o.test(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=/-webkit-|-moz-|-ms-/;e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.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"},t.TYPE={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},t.ACTION={SHOW:"SHOW_TOAST",CLEAR:"CLEAR_TOAST",MOUNTED:"CONTAINER_MOUNTED"}},function(e,t,n){"use strict";function r(e){Object.keys(e).forEach(function(t){var n=e[t];o.hasOwnProperty(t)&&"string"==typeof n&&(o[t]=n)})}Object.defineProperty(t,"__esModule",{value:!0}),t.defineStyle=r;var o={width:"320px",colorDefault:"#fff",colorInfo:"#3498db",colorSuccess:"#07bc0c",colorWarning:"#f1c40f",colorError:"#e74c3c",colorProgressDefault:"linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)",mobile:"only screen and (max-width : 480px)"};t.default=o},function(e,t,n){"use strict";function r(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,u=r(e),l=1;l<arguments.length;l++){n=Object(arguments[l]);for(var c in n)i.call(n,c)&&(u[c]=n[c]);if(o){s=o(n);for(var f=0;f<s.length;f++)a.call(n,s[f])&&(u[s[f]]=n[s[f]])}}return u}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n="";for(var r in e){var o=0===r.indexOf("--");if(e.hasOwnProperty(r)&&"label"!==r){var i=e[r];null!=i&&(o?n+=r+":"+i+";":(n+=p(r)+":",n+=(0,s.default)(r,i,t)+";"))}}return n||null}Object.defineProperty(t,"__esModule",{value:!0}),t.processStyleName=void 0,t.createMarkupForStyles=o;var i=n(16),a=(r(i),n(18)),s=r(a),u=n(21),l=r(u),c=n(23),f=r(c),d=n(8),p=(r(d),t.processStyleName=(0,f.default)(l.default))},function(e,t,n){"use strict";var r=n(20),o=r;e.exports=o},function(e,t,n){"use strict";function r(e){return e.charAt(0).toUpperCase()+e.slice(1)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default},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 r(e){return Object.prototype.toString.call(e).slice(8,-1)}function o(e){return"Number"===r(e)&&!isNaN(e)&&e>0}function i(e){return e.isRequired=function(t,n,r){if(void 0===t[n])return new Error("The prop "+n+" is marked as required in \n "+r+", but its value is undefined.");e(t,n,r)},e}Object.defineProperty(t,"__esModule",{value:!0}),t.falseOrElement=t.falseOrNumber=void 0,t.typeOf=r,t.isValidDelay=o;var a=n(0);t.falseOrNumber=i(function(e,t,n){var r=e[t];return!1===r||o(r)?null:new Error(n+" expect "+t+" \n to be a valid Number > 0 or equal to false. "+r+" given.")}),t.falseOrElement=i(function(e,t,n){var r=e[t];return!1===r||(0,a.isValidElement)(r)?null:new Error(n+" expect "+t+" \n to be a valid react element or equal to false. "+r+" given.")})},function(e,t,n){"use strict";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)}Object.defineProperty(t,"__esModule",{value:!0});var o={eventList:new Map,on:function(e,t){return this.eventList.has(e)||this.eventList.set(e,[]),this.eventList.get(e).push(t),this},off:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.eventList.delete(e)},emit:function(e){for(var t=this,n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return this.eventList.has(e)?(this.eventList.get(e).forEach(function(e){return setTimeout(function(){return e.call.apply(e,[t].concat(r(o)))},0)}),!0):(console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};t.default=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.style=t.toast=t.ToastContainer=void 0;var o=n(14),i=r(o),a=n(53),s=r(a),u=n(5);t.ToastContainer=i.default,t.toast=s.default,t.style=u.defineStyle},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}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)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d=n(0),p=r(d),h=n(1),m=r(h),y=n(2),b=n(43),g=r(b),v=n(45),O=r(v),x=n(47),E=r(x),T=n(48),k=r(T),w=n(4),_=n(5),C=r(_),P=n(12),S=r(P),j=n(10),N=r(j),M=n(11),R=function(){return(0,y.css)(u({zIndex:999,position:"fixed",padding:"4px",width:C.default.width,boxSizing:"border-box",color:"#fff"},"@media "+C.default.mobile,{width:"100vw",padding:0}))},A=function(e){var t=void 0,n="-"+parseInt(C.default.width,10)/2+"px";switch(e){case w.POSITION.TOP_LEFT:t={top:"1em",left:"1em"};break;case w.POSITION.TOP_CENTER:t={top:"1em",left:"50%",marginLeft:n};break;case w.POSITION.TOP_RIGHT:default:t={top:"1em",right:"1em"};break;case w.POSITION.BOTTOM_LEFT:t={bottom:"1em",left:"1em"};break;case w.POSITION.BOTTOM_CENTER:t={bottom:"1em",left:"50%",marginLeft:n};break;case w.POSITION.BOTTOM_RIGHT:t={bottom:"1em",right:"1em"}}return(0,y.css)(t,(0,y.css)(u({},"@media "+C.default.mobile,f({left:0,margin:0,position:"fixed"},"top"===e.substring(0,3)?{top:0}:{bottom:0}))))},I=function(e){function t(){var e,n,r,o;i(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),r.state={toast:[]},r.collection={},r.isToastActive=function(e){return-1!==r.state.toast.indexOf(parseInt(e,10))},o=n,a(r,o)}return s(t,e),c(t,[{key:"componentDidMount",value:function(){var e=this,t=w.ACTION.SHOW,n=w.ACTION.CLEAR,r=w.ACTION.MOUNTED;S.default.on(t,function(t,n){return e.show(t,n)}).on(n,function(t){return null!==t?e.removeToast(t):e.clear()}).emit(r,this)}},{key:"componentWillUnmount",value:function(){S.default.off(w.ACTION.SHOW),S.default.off(w.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,d.cloneElement)(e,f({},t,e.props))}},{key:"makeCloseButton",value:function(e,t,n){var r=this,o=this.props.closeButton;return((0,d.isValidElement)(e)||!1===e)&&(o=e),!1!==o&&this.with(o,{closeToast:function(){return r.removeToast(t)},type:n})}},{key:"getAutoCloseDelay",value:function(e){return!1===e||(0,M.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,d.isValidElement)(e)||"String"===(0,M.typeOf)(e)||"Number"===(0,M.typeOf)(e)}},{key:"show",value:function(e,t){var n=this;if(!this.canBeRendered(e))throw new Error("The element you provided cannot be rendered. You provided an element of type "+(void 0===e?"undefined":l(e)));var r=t.toastId,i=function(){return n.removeToast(r)},a={id:r,type:t.type,closeButton:this.makeCloseButton(t.closeButton,r,t.type),position:t.position||this.props.position,transition:t.transition||this.props.transition,pauseOnHover:null!==t.pauseOnHover?t.pauseOnHover:this.props.pauseOnHover,closeOnClick:null!==t.closeOnClick?t.closeOnClick:this.props.closeOnClick,className:t.className||this.props.toastClassName,bodyClassName:t.bodyClassName||this.props.bodyClassName,progressClassName:t.progressClassName||this.props.progressClassName};this.isFunction(t.onOpen)&&(a.onOpen=t.onOpen),this.isFunction(t.onClose)&&(a.onClose=t.onClose),a.autoClose=this.getAutoCloseDelay(!1!==t.autoClose?parseInt(t.autoClose,10):t.autoClose),a.hideProgressBar="boolean"==typeof t.hideProgressBar?t.hideProgressBar:this.props.hideProgressBar,a.closeToast=i,(0,d.isValidElement)(e)&&"String"!==(0,M.typeOf)(e.type)&&(e=this.with(e,{closeToast:i})),this.collection=f({},this.collection,u({},r,{content:this.makeToast(e,a),position:a.position})),this.setState({toast:[].concat(o(this.state.toast),[r])})}},{key:"makeToast",value:function(e,t){return p.default.createElement(O.default,f({},t,{key:"toast-"+t.id}),e)}},{key:"clear",value:function(){this.setState({toast:[]})}},{key:"getContainerProps",value:function(e){var t={style:e?{pointerEvents:"none"}:{}};return null!==this.props.className&&(t.className=this.props.className),null!==this.props.style&&(t.style=f({},this.props.style,t.style)),t}},{key:"renderToast",value:function(){var e=this,t={};return(this.props.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(n){var r=e.collection[n];t[r.position]||(t[r.position]=[]),-1!==e.state.toast.indexOf(parseInt(n,10))?t[r.position].push(r.content):(t[r.position].push(null),delete e.collection[n])}),Object.keys(t).map(function(n){var r=1===t[n].length&&null===t[n][0];return p.default.createElement(g.default,f({},R(),A(n),e.getContainerProps(r),{key:"container-"+n}),t[n])})}},{key:"render",value:function(){return p.default.createElement("div",null,this.renderToast())}}]),t}(d.Component);I.propTypes={position:m.default.oneOf((0,N.default)(w.POSITION)),autoClose:M.falseOrNumber,closeButton:M.falseOrElement,hideProgressBar:m.default.bool,pauseOnHover:m.default.bool,closeOnClick:m.default.bool,newestOnTop:m.default.bool,className:m.default.oneOfType([m.default.string,m.default.object]),style:m.default.object,toastClassName:m.default.oneOfType([m.default.string,m.default.object]),bodyClassName:m.default.oneOfType([m.default.string,m.default.object]),progressClassName:m.default.oneOfType([m.default.string,m.default.object]),transition:m.default.func},I.defaultProps={position:w.POSITION.TOP_RIGHT,transition:k.default,autoClose:5e3,hideProgressBar:!1,closeButton:p.default.createElement(E.default,null),pauseOnHover:!0,closeOnClick:!0,newestOnTop:!1,className:null,style:null,toastClassName:"",bodyClassName:"",progressClassName:""},t.default=I},function(e,t,n){"use strict";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 o(e){return e[e.length-1]}function i(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function a(){var e=document.createElement("style");return e.type="text/css",e.setAttribute("data-glamor",""),e.appendChild(document.createTextNode("")),(document.head||document.getElementsByTagName("head")[0]).appendChild(e),e}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.speedy,n=void 0===t?!f&&!d:t,r=e.maxLength,o=void 0===r?c&&p?4e3:65e3:r;this.isSpeedy=n,this.sheet=void 0,this.tags=[],this.maxLength=o,this.ctr=0}Object.defineProperty(t,"__esModule",{value:!0}),t.StyleSheet=s;var u=n(6),l=function(e){return e&&e.__esModule?e:{default:e}}(u),c="undefined"!=typeof window,f=!1,d=!1,p=function(){if(c){var e=document.createElement("div");return e.innerHTML="\x3c!--[if lt IE 10]><i></i><![endif]--\x3e",1===e.getElementsByTagName("i").length}}();(0,l.default)(s.prototype,{getSheet:function(){return i(o(this.tags))},inject:function(){var e=this;if(this.injected)throw new Error("already injected stylesheet!");c?this.tags[0]=a():this.sheet={cssRules:[],insertRule:function(t){e.sheet.cssRules.push({cssText:t})}},this.injected=!0},speedy:function(e){if(0!==this.ctr)throw new Error("cannot change speedy mode after inserting any rule to sheet. Either call speedy("+e+") earlier in your app, or call flush() before speedy("+e+")");this.isSpeedy=!!e},_insert:function(e){try{var t=this.getSheet();t.insertRule(e,-1!==e.indexOf("@import")?0:t.cssRules.length)}catch(t){f&&console.warn("whoops, illegal rule inserted",e)}},insert:function(e){if(c)if(this.isSpeedy&&this.getSheet().insertRule)this._insert(e);else if(-1!==e.indexOf("@import")){var t=o(this.tags);t.insertBefore(document.createTextNode(e),t.firstChild)}else o(this.tags).appendChild(document.createTextNode(e));else this.sheet.insertRule(e,-1!==e.indexOf("@import")?0:this.sheet.cssRules.length);return this.ctr++,c&&this.ctr%this.maxLength==0&&this.tags.push(a()),this.ctr-1},delete:function(e){return this.replace(e,"")},flush:function(){c?(this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.sheet=null,this.ctr=0):this.sheet.cssRules=[],this.injected=!1},rules:function(){if(!c)return this.sheet.cssRules;var e=[];return this.tags.forEach(function(t){return e.splice.apply(e,[e.length,0].concat(r(Array.from(i(t).cssRules))))}),e}})},function(e,t,n){"use strict";function r(e){return o(e.replace(i,"ms-"))}var o=n(17),i=/^-ms-/;e.exports=r},function(e,t,n){"use strict";function r(e){return e.replace(o,function(e,t){return t.toUpperCase()})}var o=/-(.)/g;e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t,n){return null==t||"boolean"==typeof t||""===t?"":isNaN(t)||0===t||u.hasOwnProperty(e)&&u[e]?""+t:("string"==typeof t&&(t=t.trim()),t+"px")}Object.defineProperty(t,"__esModule",{value:!0});var i=n(19),a=r(i),s=n(8),u=(r(s),a.default.isUnitlessNumber);t.default=o},function(e,t,n){"use strict";function r(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}Object.defineProperty(t,"__esModule",{value:!0});var o={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowStart:!0,gridRowEnd:!0,gridColumn:!0,gridColumnStart:!0,gridColumnEnd:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},i=["Webkit","ms","Moz","O"];Object.keys(o).forEach(function(e){i.forEach(function(t){o[r(t,e)]=o[e]})});var a={background:{backgroundAttachment:!0,backgroundColor:!0,backgroundImage:!0,backgroundPositionX:!0,backgroundPositionY:!0,backgroundRepeat:!0},backgroundPosition:{backgroundPositionX:!0,backgroundPositionY:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0},outline:{outlineWidth:!0,outlineStyle:!0,outlineColor:!0}},s={isUnitlessNumber:o,shorthandPropertyExpansions:a};t.default=s},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){"use strict";function r(e){return o(e).replace(i,"-ms-")}var o=n(22),i=/^ms-/;e.exports=r},function(e,t,n){"use strict";function r(e){return e.replace(o,"-$1").toLowerCase()}var o=/([A-Z])/g;e.exports=r},function(e,t,n){"use strict";function r(e){var t={};return function(n){return t.hasOwnProperty(n)||(t[n]=e.call(this,n)),t[n]}}e.exports=r},function(e,t,n){"use strict";function r(e){return null===e||void 0===e||!1===e||"object"===(void 0===e?"undefined":s(e))&&0===Object.keys(e).length}function o(e){if(r(e))return null;if("object"!==(void 0===e?"undefined":s(e)))return e;for(var t={},n=Object.keys(e),o=!1,i=0;i<n.length;i++){var u=e[n[i]],l=a(u);null!==l&&l===u||(o=!0),null!==l&&(t[n[i]]=l)}return 0===Object.keys(t).length?null:o?t:e}function i(e){var t=!1,n=[];return e.forEach(function(e){var r=a(e);null!==r&&r===e||(t=!0),null!==r&&n.push(r)}),0==n.length?null:t?n:e}function a(e){return Array.isArray(e)?i(e):o(e)}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=a},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){this.fns=e||[]}function i(e){if(Object.keys(e.style).map(function(t){return Array.isArray(e.style[t])}).indexOf(!0)>=0){var t=e.style,n=Object.keys(t).reduce(function(e,n){return e[n]=Array.isArray(t[n])?t[n].join("; "+(0,f.processStyleName)(n)+": "):t[n],e},{});return(0,c.default)({},e,{style:n})}return e}function a(e){if(e.style.content){var t=e.style.content;return h.indexOf(t)>=0?e:/^(attr|calc|counters?|url)\(/.test(t)?e:t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)?u({},e,{style:u({},e.style,{content:'"'+t+'"'})}):e}return e}function s(e){return(0,c.default)({},e,{style:(0,p.default)(u({},e.style))})}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.PluginSet=o,t.fallbacks=i,t.contentWrap=a,t.prefixes=s;var l=n(6),c=r(l),f=n(7),d=n(26),p=r(d);(0,c.default)(o.prototype,{add:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach(function(t){e.fns.indexOf(t)>=0||(e.fns=[t].concat(e.fns))})},remove:function(e){this.fns=this.fns.filter(function(t){return t!==e})},clear:function(){this.fns=[]},transform:function(e){return this.fns.reduce(function(e,t){return t(e)},e)}});var h=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){for(var t in e){var n=e[t],r=(0,c.default)(N,t,n,e,M);r&&(e[t]=r),(0,u.default)(M,t,e)}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var i=n(27),a=r(i),s=n(28),u=r(s),l=n(29),c=r(l),f=n(30),d=r(f),p=n(31),h=r(p),m=n(32),y=r(m),b=n(33),g=r(b),v=n(34),O=r(v),x=n(35),E=r(x),T=n(36),k=r(T),w=n(37),_=r(w),C=n(38),P=r(C),S=n(39),j=r(S),N=[h.default,d.default,y.default,O.default,E.default,k.default,_.default,P.default,j.default,g.default],M=a.default.prefixMap},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=["Webkit"],o=["Moz"],i=["ms"],a=["Webkit","Moz"],s=["Webkit","ms"],u=["Webkit","Moz","ms"];t.default={plugins:[],prefixMap:{appearance:a,userSelect:u,textEmphasisPosition:r,textEmphasis:r,textEmphasisStyle:r,textEmphasisColor:r,boxDecorationBreak:r,clipPath:r,maskImage:r,maskMode:r,maskRepeat:r,maskPosition:r,maskClip:r,maskOrigin:r,maskSize:r,maskComposite:r,mask:r,maskBorderSource:r,maskBorderMode:r,maskBorderSlice:r,maskBorderWidth:r,maskBorderOutset:r,maskBorderRepeat:r,maskBorder:r,maskType:r,textDecorationStyle:r,textDecorationSkip:r,textDecorationLine:r,textDecorationColor:r,filter:r,fontFeatureSettings:r,breakAfter:u,breakBefore:u,breakInside:u,columnCount:a,columnFill:a,columnGap:a,columnRule:a,columnRuleColor:a,columnRuleStyle:a,columnRuleWidth:a,columns:a,columnSpan:a,columnWidth:a,writingMode:s,flex:r,flexBasis:r,flexDirection:r,flexGrow:r,flexFlow:r,flexShrink:r,flexWrap:r,alignContent:r,alignItems:r,alignSelf:r,justifyContent:r,order:r,transform:r,transformOrigin:r,transformOriginX:r,transformOriginY:r,backfaceVisibility:r,perspective:r,perspectiveOrigin:r,transformStyle:r,transformOriginZ:r,animation:r,animationDelay:r,animationDirection:r,animationFillMode:r,animationDuration:r,animationIterationCount:r,animationName:r,animationPlayState:r,animationTimingFunction:r,backdropFilter:r,fontKerning:r,scrollSnapType:s,scrollSnapPointsX:s,scrollSnapPointsY:s,scrollSnapDestination:s,scrollSnapCoordinate:s,shapeImageThreshold:r,shapeImageMargin:r,shapeImageOutside:r,hyphens:u,flowInto:s,flowFrom:s,regionFragment:s,textAlignLast:o,tabSize:o,wrapFlow:i,wrapThrough:i,wrapMargin:i,gridTemplateColumns:i,gridTemplateRows:i,gridTemplateAreas:i,gridTemplate:i,gridAutoColumns:i,gridAutoRows:i,gridAutoFlow:i,grid:i,gridRowStart:i,gridColumnStart:i,gridRowEnd:i,gridRow:i,gridColumn:i,gridColumnEnd:i,gridColumnGap:i,gridRowGap:i,gridArea:i,gridGap:i,textSizeAdjust:s,borderImage:r,borderImageOutset:r,borderImageRepeat:r,borderImageSlice:r,borderImageSource:r,borderImageWidth:r,transitionDelay:r,transitionDuration:r,transitionProperty:r,transitionTimingFunction:r}},e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n){if(e.hasOwnProperty(t))for(var r=e[t],o=0,a=r.length;o<a;++o)n[r[o]+(0,i.default)(t)]=n[t]}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(9),i=function(e){return e&&e.__esModule?e:{default:e}}(o);e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n,r,o){for(var i=0,a=e.length;i<a;++i){var s=e[i](t,n,r,o);if(s)return s}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("cursor"===e&&i.hasOwnProperty(t))return o.map(function(e){return e+t})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=["-webkit-","-moz-",""],i={"zoom-in":!0,"zoom-out":!0,grab:!0,grabbing:!0};e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("cross-fade(")>-1)return a.map(function(e){return t.replace(/cross-fade\(/g,e+"cross-fade(")})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(3),i=function(e){return e&&e.__esModule?e:{default:e}}(o),a=["-webkit-",""];e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("filter(")>-1)return a.map(function(e){return t.replace(/filter\(/g,e+"filter(")})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(3),i=function(e){return e&&e.__esModule?e:{default:e}}(o),a=["-webkit-",""];e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("display"===e&&o.hasOwnProperty(t))return o[t]}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o={flex:["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex","flex"],"inline-flex":["-webkit-inline-box","-moz-inline-box","-ms-inline-flexbox","-webkit-inline-flex","inline-flex"]};e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n){"flexDirection"===e&&"string"==typeof t&&(t.indexOf("column")>-1?n.WebkitBoxOrient="vertical":n.WebkitBoxOrient="horizontal",t.indexOf("reverse")>-1?n.WebkitBoxDirection="reverse":n.WebkitBoxDirection="normal"),i.hasOwnProperty(e)&&(n[i[e]]=o[t]||t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o={"space-around":"justify","space-between":"justify","flex-start":"start","flex-end":"end","wrap-reverse":"multiple",wrap:"multiple"},i={alignItems:"WebkitBoxAlign",justifyContent:"WebkitBoxPack",flexWrap:"WebkitBoxLines"};e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("string"==typeof t&&!(0,i.default)(t)&&s.test(t))return a.map(function(e){return e+t})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(3),i=function(e){return e&&e.__esModule?e:{default:e}}(o),a=["-webkit-","-moz-",""],s=/linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("image-set(")>-1)return a.map(function(e){return t.replace(/image-set\(/g,e+"image-set(")})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(3),i=function(e){return e&&e.__esModule?e:{default:e}}(o),a=["-webkit-",""];e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if("position"===e&&"sticky"===t)return["-webkit-sticky","sticky"]}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if(i.hasOwnProperty(e)&&a.hasOwnProperty(t))return o.map(function(e){return e+t})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=["-webkit-","-moz-",""],i={maxHeight:!0,maxWidth:!0,width:!0,height:!0,columnWidth:!0,minWidth:!0,minHeight:!0},a={"min-content":!0,"max-content":!0,"fill-available":!0,"fit-content":!0,"contain-floats":!0};e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if((0,l.default)(e))return e;for(var n=e.split(/,(?![^()]*(?:\([^()]*\))?\))/g),r=0,o=n.length;r<o;++r){var i=n[r],a=[i];for(var u in t){var c=(0,s.default)(u);if(i.indexOf(c)>-1&&"order"!==c)for(var f=t[u],d=0,h=f.length;d<h;++d)a.unshift(i.replace(c,p[f[d]]+c))}n[r]=a.join(",")}return n.join(",")}function i(e,t,n,r){if("string"==typeof t&&d.hasOwnProperty(e)){var i=o(t,r),a=i.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(e){return!/-moz-|-ms-/.test(e)}).join(",");if(e.indexOf("Webkit")>-1)return a;var s=i.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(e){return!/-webkit-|-ms-/.test(e)}).join(",");return e.indexOf("Moz")>-1?s:(n["Webkit"+(0,f.default)(e)]=a,n["Moz"+(0,f.default)(e)]=s,i)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var a=n(40),s=r(a),u=n(3),l=r(u),c=n(9),f=r(c),d={transition:!0,transitionProperty:!0,WebkitTransition:!0,WebkitTransitionProperty:!0,MozTransition:!0,MozTransitionProperty:!0},p={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-"};e.exports=t.default},function(e,t,n){"use strict";function r(e){return(0,i.default)(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(41),i=function(e){return e&&e.__esModule?e:{default:e}}(o);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e in a?a[e]:a[e]=e.replace(o,"-$&").toLowerCase().replace(i,"-ms-")}var o=/[A-Z]/g,i=/^ms-/,a={};e.exports=r},function(e,t,n){"use strict";function r(e,t){for(var n=1540483477,r=t^e.length,s=e.length,u=0;s>=4;){var l=o(e,u);l=a(l,n),l^=l>>>24,l=a(l,n),r=a(r,n),r^=l,u+=4,s-=4}switch(s){case 3:r^=i(e,u),r^=e.charCodeAt(u+2)<<16,r=a(r,n);break;case 2:r^=i(e,u),r=a(r,n);break;case 1:r^=e.charCodeAt(u),r=a(r,n)}return r^=r>>>13,r=a(r,n),(r^=r>>>15)>>>0}function o(e,t){return e.charCodeAt(t++)+(e.charCodeAt(t++)<<8)+(e.charCodeAt(t++)<<16)+(e.charCodeAt(t)<<24)}function i(e,t){return e.charCodeAt(t++)+(e.charCodeAt(t++)<<8)}function a(e,t){return e|=0,t|=0,(65535&e)*t+(((e>>>16)*t&65535)<<16)|0}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=n(1),c=r(l),f=n(0),d=r(f),p=n(44),h=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},m=(c.default.any,c.default.node,c.default.bool,c.default.bool,c.default.bool,c.default.func,{component:"div",childFactory:function(e){return e}}),y=function(e){function t(n,r){i(this,t);var o=a(this,e.call(this,n,r));return o.handleExited=function(e,t,n){var r=(0,p.getChildMapping)(o.props.children);e in r||(n&&n(t),o.setState(function(t){var n=u({},t.children);return delete n[e],{children:n}}))},o.state={children:(0,p.getChildMapping)(n.children,function(e){var t=function(t){o.handleExited(e.key,t,e.props.onExited)};return(0,f.cloneElement)(e,{onExited:t,in:!0,appear:o.getProp(e,"appear"),enter:o.getProp(e,"enter"),exit:o.getProp(e,"exit")})})},o}return s(t,e),t.prototype.getChildContext=function(){return{transitionGroup:{isMounting:!this.appeared}}},t.prototype.getProp=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props;return null!=n[t]?n[t]:e.props[t]},t.prototype.componentDidMount=function(){this.appeared=!0},t.prototype.componentWillReceiveProps=function(e){var t=this,n=this.state.children,r=(0,p.getChildMapping)(e.children),o=(0,p.mergeChildMappings)(n,r);Object.keys(o).forEach(function(i){var a=o[i];if((0,f.isValidElement)(a)){var s=function(e){t.handleExited(a.key,e,a.props.onExited)},u=i in n,l=i in r,c=n[i],d=(0,f.isValidElement)(c)&&!c.props.in;!l||u&&!d?l||!u||d?l&&u&&(0,f.isValidElement)(c)&&(o[i]=(0,f.cloneElement)(a,{onExited:s,in:c.props.in,exit:t.getProp(a,"exit",e),enter:t.getProp(a,"enter",e)})):o[i]=(0,f.cloneElement)(a,{in:!1}):o[i]=(0,f.cloneElement)(a,{onExited:s,in:!0,exit:t.getProp(a,"exit",e),enter:t.getProp(a,"enter",e)})}}),this.setState({children:o})},t.prototype.render=function(){var e=this.props,t=e.component,n=e.childFactory,r=o(e,["component","childFactory"]),i=this.state.children;return delete r.appear,delete r.enter,delete r.exit,d.default.createElement(t,r,h(i).map(n))},t}(d.default.Component);y.childContextTypes={transitionGroup:c.default.object.isRequired},y.propTypes={},y.defaultProps=m,t.default=y,e.exports=t.default},function(e,t,n){"use strict";function r(e,t){var n=function(e){return t&&(0,i.isValidElement)(e)?t(e):e},r=Object.create(null);return e&&i.Children.map(e,function(e){return e}).forEach(function(e){r[e.key]=n(e)}),r}function o(e,t){function n(n){return n in t?t[n]:e[n]}e=e||{},t=t||{};var r=Object.create(null),o=[];for(var i in e)i in t?o.length&&(r[i]=o,o=[]):o.push(i);var a=void 0,s={};for(var u in t){if(r[u])for(a=0;a<r[u].length;a++){var l=r[u][a];s[r[u][a]]=n(l)}s[u]=n(u)}for(a=0;a<o.length;a++)s[o[a]]=n(o[a]);return s}t.__esModule=!0,t.getChildMapping=r,t.mergeChildMappings=o;var i=n(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function 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)}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}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=n(0),f=r(c),d=n(1),p=r(d),h=n(2),m=n(46),y=r(m),b=n(4),g=n(5),v=r(g),O=n(10),x=r(O),E=n(11),T=function(e){return(0,h.css)(l({position:"relative",minHeight:"48px",marginBottom:"1rem",padding:"8px",borderRadius:"1px",boxShadow:"0 1px 10px 0 rgba(0, 0, 0, .1), 0 2px 15px 0 rgba(0, 0, 0, .05)",display:"flex",justifyContent:"space-between",maxHeight:"800px",overflow:"hidden",fontFamily:"sans-serif",cursor:"pointer",background:v.default["color"+e.charAt(0).toUpperCase()+e.slice(1)]},"default"===e?{color:"#aaa"}:{},s({},"@media "+v.default.mobile,{marginBottom:0})))},k=(0,h.css)({margin:"auto 0",flex:1}),w=function(e){function t(){var e,n,r,a;o(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=r=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),r.state={isRunning:!0},r.handleVisibility=function(){return r.setState({isRunning:!document.hidden})},r.pauseToast=function(){r.setState({isRunning:!1})},r.playToast=function(){r.setState({isRunning:!0})},a=n,i(r,a)}return a(t,e),u(t,[{key:"componentDidMount",value:function(){null!==this.props.onOpen&&this.props.onOpen(this.getChildrenProps()),document.addEventListener("visibilitychange",this.handleVisibility)}},{key:"componentWillUnmount",value:function(){null!==this.props.onClose&&this.props.onClose(this.getChildrenProps()),document.removeEventListener("visibilitychange",this.handleVisibility)}},{key:"getChildrenProps",value:function(){return this.props.children.props}},{key:"getToastProps",value:function(){var e={};return!1!==this.props.autoClose&&!0===this.props.pauseOnHover&&(e.onMouseEnter=this.pauseToast,e.onMouseLeave=this.playToast),this.props.closeOnClick&&(e.onClick=this.props.closeToast),e}},{key:"render",value:function(){var e=this.props,t=e.closeButton,n=e.children,r=e.autoClose,o=e.type,i=e.hideProgressBar,a=e.closeToast,s=e.transition,u=e.position,c=e.onExited,d=e.className,p=e.bodyClassName,h=e.progressClassName;return f.default.createElement(s,{in:this.props.in,appear:!0,unmountOnExit:!0,onExited:c,position:u},f.default.createElement("div",l({},T(o),this.getToastProps(),{className:d}),f.default.createElement("div",l({},k,{className:p}),n),!1!==t&&t,!1!==r&&f.default.createElement(y.default,{delay:r,isRunning:this.state.isRunning,closeToast:a,hide:i,type:o,className:h})))}}]),t}(c.Component);w.propTypes={closeButton:E.falseOrElement.isRequired,autoClose:E.falseOrNumber.isRequired,children:p.default.node.isRequired,closeToast:p.default.func.isRequired,position:p.default.oneOf((0,x.default)(b.POSITION)).isRequired,pauseOnHover:p.default.bool.isRequired,closeOnClick:p.default.bool.isRequired,transition:p.default.func.isRequired,in:p.default.bool,onExited:p.default.func,hideProgressBar:p.default.bool,onOpen:p.default.func,onClose:p.default.func,type:p.default.oneOf((0,x.default)(b.TYPE)),className:p.default.oneOfType([p.default.string,p.default.object]),bodyClassName:p.default.oneOfType([p.default.string,p.default.object]),progressClassName:p.default.oneOfType([p.default.string,p.default.object])},w.defaultProps={type:b.TYPE.DEFAULT,in:!0,hideProgressBar:!1,onOpen:null,onClose:null,className:"",bodyClassName:"",progressClassName:""},t.default=w},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){var t=e.delay,n=e.isRunning,r=e.closeToast,o=e.type,a=e.hide,u=e.className,l={animationDuration:t+"ms",animationPlayState:n?"running":"paused"};return l.WebkitAnimationPlayState=l.animationPlayState,a&&(l.opacity=0),s.default.createElement("div",i({},m(o),{className:u,style:l,onAnimationEnd:r}))}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=n(0),s=r(a),u=n(1),l=r(u),c=n(2),f=n(4),d=n(5),p=r(d),h=c.css.keyframes("track-progress",{"0%":{width:"100%"},"100%":{width:0}}),m=function(e){return(0,c.css)(i({position:"absolute",bottom:0,left:0,width:0,height:"5px",zIndex:999,opacity:.7,animation:h+" linear 1",backgroundColor:"rgba(255,255,255,.7)"},"default"===e?{background:p.default.colorProgressDefault}:{}))};o.propTypes={delay:l.default.number.isRequired,isRunning:l.default.bool.isRequired,closeToast:l.default.func.isRequired,type:l.default.string,hide:l.default.bool,className:l.default.oneOfType([l.default.string,l.default.object])},o.defaultProps={type:f.TYPE.DEFAULT,hide:!1,className:""},t.default=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){var t=e.closeToast,n=e.type;return s.default.createElement("button",i({},f("default"===n),{type:"button",onClick:t}),"✖")}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=n(0),s=r(a),u=n(1),l=r(u),c=n(2),f=function(e){return(0,c.css)({padding:0,color:e?"#000":"#fff",fontWeight:"bold",fontSize:"14px",background:"transparent",outline:"none",border:"none",cursor:"pointer",opacity:e?"0.3":"0.7",transition:".3s ease",alignSelf:"flex-start",":hover, :focus":{opacity:1}})};o.propTypes={closeToast:l.default.func},t.default=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e){var t=e.children,n=e.position,r=o(e,["children","position"]),i=m(n),s=i.enter,l=i.exit;return u.default.createElement(c.default,a({},r,{timeout:750,onEnter:function(e){e.classList.add(s)},onExit:function(e){e.classList.remove(s),e.classList.add(l)}}),t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=n(0),u=r(s),l=n(49),c=r(l),f=n(2),d=n(52),p=r(d),h={animationDuration:"0.75s",animationFillMode:"both"},m=function(e){var t=(0,p.default)(e),n=t.enter,r=t.exit,o=f.css.keyframes("enter",a({"from, 60%, 75%, 90%, to":{animationTimingFunction:"cubic-bezier(0.215, 0.610, 0.355, 1.000)"}},n)),i=f.css.keyframes("exit",r);return{enter:(0,f.css)(a({},h,{animationName:o})),exit:(0,f.css)(a({},h,{animationName:i}))}};t.default=i},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}function u(){}t.__esModule=!0,t.EXITING=t.ENTERED=t.ENTERING=t.EXITED=t.UNMOUNTED=void 0;var l=n(1),c=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(l),f=n(0),d=r(f),p=n(50),h=r(p),m=(n(51),t.UNMOUNTED="unmounted"),y=t.EXITED="exited",b=t.ENTERING="entering",g=t.ENTERED="entered",v=t.EXITING="exiting",O=function(e){function t(n,r){i(this,t);var o=a(this,e.call(this,n,r)),s=r.transitionGroup,u=s&&!s.isMounting?n.enter:n.appear,l=void 0;return o.nextStatus=null,n.in?u?(l=y,o.nextStatus=b):l=g:l=n.unmountOnExit||n.mountOnEnter?m:y,o.state={status:l},o.nextCallback=null,o}return s(t,e),t.prototype.getChildContext=function(){return{transitionGroup:null}},t.prototype.componentDidMount=function(){this.updateStatus(!0)},t.prototype.componentWillReceiveProps=function(e){var t=this.pendingState||this.state,n=t.status;e.in?(n===m&&this.setState({status:y}),n!==b&&n!==g&&(this.nextStatus=b)):n!==b&&n!==g||(this.nextStatus=v)},t.prototype.componentDidUpdate=function(){this.updateStatus()},t.prototype.componentWillUnmount=function(){this.cancelNextCallback()},t.prototype.getTimeouts=function(){var e=this.props.timeout,t=void 0,n=void 0,r=void 0;return t=n=r=e,null!=e&&"number"!=typeof e&&(t=e.exit,n=e.enter,r=e.appear),{exit:t,enter:n,appear:r}},t.prototype.updateStatus=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.nextStatus;if(null!==t){this.nextStatus=null,this.cancelNextCallback();var n=h.default.findDOMNode(this);t===b?this.performEnter(n,e):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===y&&this.setState({status:m})},t.prototype.performEnter=function(e,t){var n=this,r=this.props.enter,o=this.context.transitionGroup?this.context.transitionGroup.isMounting:t,i=this.getTimeouts();if(!t&&!r)return void this.safeSetState({status:g},function(){n.props.onEntered(e)});this.props.onEnter(e,o),this.safeSetState({status:b},function(){n.props.onEntering(e,o),n.onTransitionEnd(e,i.enter,function(){n.safeSetState({status:g},function(){n.props.onEntered(e,o)})})})},t.prototype.performExit=function(e){var t=this,n=this.props.exit,r=this.getTimeouts();if(!n)return void this.safeSetState({status:y},function(){t.props.onExited(e)});this.props.onExit(e),this.safeSetState({status:v},function(){t.props.onExiting(e),t.onTransitionEnd(e,r.exit,function(){t.safeSetState({status:y},function(){t.props.onExited(e)})})})},t.prototype.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},t.prototype.safeSetState=function(e,t){var n=this;this.pendingState=e,t=this.setNextCallback(t),this.setState(e,function(){n.pendingState=null,t()})},t.prototype.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},t.prototype.onTransitionEnd=function(e,t,n){this.setNextCallback(n),e?(this.props.addEndListener&&this.props.addEndListener(e,this.nextCallback),null!=t&&setTimeout(this.nextCallback,t)):setTimeout(this.nextCallback,0)},t.prototype.render=function(){var e=this.state.status;if(e===m)return null;var t=this.props,n=t.children,r=o(t,["children"]);if(delete r.in,delete r.mountOnEnter,delete r.unmountOnExit,delete r.appear,delete r.enter,delete r.exit,delete r.timeout,delete r.addEndListener,delete r.onEnter,delete r.onEntering,delete r.onEntered,delete r.onExit,delete r.onExiting,delete r.onExited,"function"==typeof n)return n(e,r);var i=d.default.Children.only(n);return d.default.cloneElement(i,r)},t}(d.default.Component);O.contextTypes={transitionGroup:c.object},O.childContextTypes={transitionGroup:function(){}},O.propTypes={},O.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:u,onEntering:u,onEntered:u,onExit:u,onExiting:u,onExited:u},O.UNMOUNTED=0,O.EXITED=1,O.ENTERING=2,O.ENTERED=3,O.EXITING=4,t.default=O},function(e,t){e.exports=n},function(e,t,n){"use strict";function r(e){var t="transition"+e+"Timeout",n="transition"+e;return function(e){if(e[n]){if(null==e[t])return new Error(t+" wasn't supplied to CSSTransitionGroup: this can cause unreliable animations and won't be supported in a future version of React. See https://fb.me/react-animation-transition-group-timeout for more information.");if("number"!=typeof e[t])return new Error(t+" must be a number (in milliseconds)")}return null}}t.__esModule=!0,t.classNamesShape=t.timeoutsShape=void 0,t.transitionTimeout=r;var o=n(1),i=function(e){return e&&e.__esModule?e:{default:e}}(o);t.timeoutsShape=i.default.oneOfType([i.default.number,i.default.shape({enter:i.default.number,exit:i.default.number}).isRequired]),t.classNamesShape=i.default.oneOfType([i.default.string,i.default.shape({enter:i.default.string,exit:i.default.string,active:i.default.string}),i.default.shape({enter:i.default.string,enterActive:i.default.string,exit:i.default.string,exitActive:i.default.string})])},function(e,t,n){"use strict";function r(e){switch(e){case o.POSITION.TOP_RIGHT:case o.POSITION.BOTTOM_RIGHT:default:return{enter:{from:{opacity:0,transform:"translate3d(3000px, 0, 0)"},"60%":{opacity:1,transform:"translate3d(-25px, 0, 0)"},"75%":{transform:"translate3d(10px, 0, 0)"},"90%":{transform:"translate3d(-5px, 0, 0)"},to:{transform:"none"}},exit:{"20%":{opacity:1,transform:"translate3d(-20px, 0, 0)"},to:{opacity:0,transform:"translate3d(2000px, 0, 0)"}}};case o.POSITION.TOP_LEFT:case o.POSITION.BOTTOM_LEFT:return{enter:{"0%":{opacity:0,transform:"translate3d(-3000px, 0, 0)"},"60%":{opacity:1,transform:"translate3d(25px, 0, 0)"},"75%":{transform:"translate3d(-10px, 0, 0)"},"90%":{transform:"translate3d(5px, 0, 0)"},to:{transform:"none"}},exit:{"20%":{opacity:1,transform:"translate3d(20px, 0, 0)"},to:{opacity:0,transform:"translate3d(-2000px, 0, 0)"}}};case o.POSITION.BOTTOM_CENTER:return{enter:{from:{opacity:0,transform:"translate3d(0, 3000px, 0)"},"60%":{opacity:1,transform:"translate3d(0, -20px, 0)"},"75%":{transform:"translate3d(0, 10px, 0)"},"90%":{transform:"translate3d(0, -5px, 0)"},to:{transform:"translate3d(0, 0, 0)"}},exit:{"20%":{transform:"translate3d(0, 10px, 0)"},"40%, 45%":{opacity:1,transform:"translate3d(0, -20px, 0)"},to:{opacity:0,transform:"translate3d(0, 2000px, 0)"}}};case o.POSITION.TOP_CENTER:return{enter:{"0%":{opacity:0,transform:"translate3d(0, -3000px, 0)"},"60%":{opacity:1,transform:"translate3d(0, 25px, 0)"},"75%":{transform:"translate3d(0, -10px, 0)"},"90%":{transform:"translate3d(0, 5px, 0)"},to:{transform:"none"}},exit:{"20%":{transform:"translate3d(0, -10px, 0)"},"40%, 45%":{opacity:1,transform:"translate3d(0, 20px, 0)"},to:{opacity:0,transform:"translate3d(0, -2000px, 0)"}}}}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var o=n(4)},function(e,t,n){"use strict";function r(e){return i({},l,e,{toastId:++d})}function o(e,t){return null!==c?s.default.emit(u.ACTION.SHOW,e,t):f.push({action:u.ACTION.SHOW,content:e,options:t}),t.toastId}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=n(12),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=n(4),l={type:u.TYPE.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null,position:null,pauseOnHover:null,closeOnClick:null,className:null,bodyClassName:null,progressClassName:null,transition:null},c=null,f=[],d=0,p=i(function(e,t){return o(e,r(t))},{success:function(e,t){return o(e,i(r(t),{type:u.TYPE.SUCCESS}))},info:function(e,t){return o(e,i(r(t),{type:u.TYPE.INFO}))},warn:function(e,t){return o(e,i(r(t),{type:u.TYPE.WARNING}))},warning:function(e,t){return o(e,i(r(t),{type:u.TYPE.WARNING}))},error:function(e,t){return o(e,i(r(t),{type:u.TYPE.ERROR}))},dismiss:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return c&&s.default.emit(u.ACTION.CLEAR,e)},isActive:function(){return!1}},{POSITION:u.POSITION,TYPE:u.TYPE});s.default.on(u.ACTION.MOUNTED,function(e){c=e,p.isActive=function(e){return c.isToastActive(e)},f.forEach(function(e){s.default.emit(e.action,e.content,e.options)}),f=[]}),t.default=p}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("glamor"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","prop-types","glamor","react-dom"],t):"object"==typeof exports?exports.ReactToastify=t(require("react"),require("prop-types"),require("glamor"),require("react-dom")):e.ReactToastify=t(e.react,e["prop-types"],e.glamor,e["react-dom"])}(this,function(e,t,n,o){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.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=7)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.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"},t.TYPE={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},t.ACTION={SHOW:"SHOW_TOAST",CLEAR:"CLEAR_TOAST",MOUNTED:"CONTAINER_MOUNTED"}},function(e,t,n){"use strict";function o(e){Object.keys(e).forEach(function(t){var n=e[t];r.hasOwnProperty(t)&&(r[t]=n)})}Object.defineProperty(t,"__esModule",{value:!0}),t.defineStyle=o;var r={width:"320px",colorDefault:"#fff",colorInfo:"#3498db",colorSuccess:"#07bc0c",colorWarning:"#f1c40f",colorError:"#e74c3c",colorProgressDefault:"linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)",mobile:"only screen and (max-width : 480px)",zIndex:9999};t.default=r},function(e,t,n){"use strict";function o(e){return"number"==typeof e&&!isNaN(e)&&e>0}function r(e){return Object.keys(e).map(function(t){return e[t]})}function i(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.falseOrDelay=void 0,t.isValidDelay=o,t.objectValues=r;var a=n(0);t.falseOrDelay=i(function(e,t,n){var r=e[t];return!1===r||o(r)?null:new Error(n+" expect "+t+" \n to be a valid Number > 0 or equal to false. "+r+" given.")}),t.falseOrElement=i(function(e,t,n){var o=e[t];return!1===o||(0,a.isValidElement)(o)?null:new Error(n+" expect "+t+" \n to be a valid react element or equal to false. "+o+" given.")})},function(e,t,n){"use strict";function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var r={eventList:new Map,on:function(e,t){return this.eventList.has(e)||this.eventList.set(e,[]),this.eventList.get(e).push(t),this},off:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.eventList.delete(e)},emit:function(e){for(var t=this,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return this.eventList.has(e)?(this.eventList.get(e).forEach(function(e){return setTimeout(function(){return e.call.apply(e,[t].concat(o(r)))},0)}),!0):(console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.style=t.toast=t.ToastContainer=void 0;var r=n(8),i=o(r),a=n(19),s=o(a),u=n(4);t.ToastContainer=i.default,t.toast=s.default,t.style=u.defineStyle},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 i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=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=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},p=n(0),d=o(p),h=n(1),m=o(h),y=n(2),O=n(9),b=o(O),v=n(11),T=o(v),E=n(13),g=o(E),x=n(14),C=o(x),N=n(3),P=n(4),_=o(P),I=n(6),S=o(I),j=n(5),k=function(e){return(0,y.css)(f({zIndex:_.default.zIndex,position:"fixed",padding:"4px",width:_.default.width,boxSizing:"border-box",color:"#fff"},e?{pointerEvents:"none"}:{},u({},"@media "+_.default.mobile,{width:"100vw",padding:0})))},w=function(e){var t=void 0,n="-"+parseInt(_.default.width,10)/2+"px";switch(e){case N.POSITION.TOP_LEFT:t={top:"1em",left:"1em"};break;case N.POSITION.TOP_CENTER:t={top:"1em",left:"50%",marginLeft:n};break;case N.POSITION.TOP_RIGHT:default:t={top:"1em",right:"1em"};break;case N.POSITION.BOTTOM_LEFT:t={bottom:"1em",left:"1em"};break;case N.POSITION.BOTTOM_CENTER:t={bottom:"1em",left:"50%",marginLeft:n};break;case N.POSITION.BOTTOM_RIGHT:t={bottom:"1em",right:"1em"}}return(0,y.css)(t,(0,y.css)(u({},"@media "+_.default.mobile,f({left:0,margin:0,position:"fixed"},"top"===e.substring(0,3)?{top:0}:{bottom:0}))))},R=function(e){function t(){var e,n,o,r;i(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=o=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),o.state={toast:[],isDocumentHidden:!1},o.collection={},o.isDocumentHidden=function(){return o.setState({isDocumentHidden:document.hidden})},o.isToastActive=function(e){return-1!==o.state.toast.indexOf(parseInt(e,10))},r=n,a(o,r)}return s(t,e),c(t,[{key:"componentDidMount",value:function(){var e=this,t=N.ACTION.SHOW,n=N.ACTION.CLEAR,o=N.ACTION.MOUNTED;S.default.on(t,function(t,n){return e.show(t,n)}).on(n,function(t){return null!==t?e.removeToast(t):e.clear()}).emit(o,this),document.addEventListener("visibilitychange",this.isDocumentHidden)}},{key:"componentWillUnmount",value:function(){S.default.off(N.ACTION.SHOW),S.default.off(N.ACTION.CLEAR),document.removeEventListener("visibilitychange",this.isDocumentHidden)}},{key:"removeToast",value:function(e){this.setState({toast:this.state.toast.filter(function(t){return t!==parseInt(e,10)})})}},{key:"makeCloseButton",value:function(e,t,n){var o=this,r=this.props.closeButton;return((0,p.isValidElement)(e)||!1===e)&&(r=e),!1!==r&&(0,p.cloneElement)(r,{closeToast:function(){return o.removeToast(t)},type:n})}},{key:"getAutoCloseDelay",value:function(e){return!1===e||(0,j.isValidDelay)(e)?e:this.props.autoClose}},{key:"isFunction",value:function(e){return!!(e&&e.constructor&&e.call&&e.apply)}},{key:"canBeRendered",value:function(e){return(0,p.isValidElement)(e)||"string"==typeof e||"number"==typeof e}},{key:"show",value:function(e,t){var n=this;if(!this.canBeRendered(e))throw new Error("The element you provided cannot be rendered. You provided an element of type "+(void 0===e?"undefined":l(e)));var o=t.toastId,i=function(){return n.removeToast(o)},a={id:o,type:t.type,closeToast:i,updateId:t.updateId,position:t.position||this.props.position,transition:t.transition||this.props.transition,className:t.className||this.props.toastClassName,bodyClassName:t.bodyClassName||this.props.bodyClassName,closeButton:this.makeCloseButton(t.closeButton,o,t.type),pauseOnHover:null!==t.pauseOnHover?t.pauseOnHover:this.props.pauseOnHover,closeOnClick:null!==t.closeOnClick?t.closeOnClick:this.props.closeOnClick,progressClassName:t.progressClassName||this.props.progressClassName,autoClose:this.getAutoCloseDelay(!1!==t.autoClose?parseInt(t.autoClose,10):t.autoClose),hideProgressBar:"boolean"==typeof t.hideProgressBar?t.hideProgressBar:this.props.hideProgressBar};this.isFunction(t.onOpen)&&(a.onOpen=t.onOpen),this.isFunction(t.onClose)&&(a.onClose=t.onClose),(0,p.isValidElement)(e)&&"string"!=typeof e.type&&"number"!=typeof e.type&&(e=(0,p.cloneElement)(e,{closeToast:i})),this.collection=f({},this.collection,u({},o,{position:a.position,options:a,content:e})),this.setState({toast:null!==a.updateId?[].concat(r(this.state.toast)):[].concat(r(this.state.toast),[o])})}},{key:"makeToast",value:function(e,t){return d.default.createElement(T.default,f({},t,{isDocumentHidden:this.state.isDocumentHidden,key:"toast-"+t.id}),e)}},{key:"clear",value:function(){this.setState({toast:[]})}},{key:"renderToast",value:function(){var e=this,t={},n=this.props,o=n.className,r=n.style;return(n.newestOnTop?Object.keys(this.collection).reverse():Object.keys(this.collection)).forEach(function(n){var o=e.collection[n];t[o.position]||(t[o.position]=[]),-1!==e.state.toast.indexOf(parseInt(n,10))?t[o.position].push(e.makeToast(o.content,o.options)):(t[o.position].push(null),delete e.collection[n])}),Object.keys(t).map(function(e){var n=1===t[e].length&&null===t[e][0];return d.default.createElement(b.default,f({},k(n),w(e),null!==o&&{className:o},null!==r&&{style:r},{key:"container-"+e}),t[e])})}},{key:"render",value:function(){return d.default.createElement("div",null,this.renderToast())}}]),t}(p.Component);R.propTypes={position:m.default.oneOf((0,j.objectValues)(N.POSITION)),autoClose:j.falseOrDelay,closeButton:j.falseOrElement,hideProgressBar:m.default.bool,pauseOnHover:m.default.bool,closeOnClick:m.default.bool,newestOnTop:m.default.bool,className:m.default.oneOfType([m.default.string,m.default.object]),style:m.default.object,toastClassName:m.default.oneOfType([m.default.string,m.default.object]),bodyClassName:m.default.oneOfType([m.default.string,m.default.object]),progressClassName:m.default.oneOfType([m.default.string,m.default.object]),transition:m.default.func},R.defaultProps={position:N.POSITION.TOP_RIGHT,transition:C.default,autoClose:5e3,hideProgressBar:!1,closeButton:d.default.createElement(g.default,null),pauseOnHover:!0,closeOnClick:!0,newestOnTop:!1,className:null,style:null,toastClassName:"",bodyClassName:"",progressClassName:""},t.default=R},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}t.__esModule=!0;var u=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},l=n(1),c=o(l),f=n(0),p=o(f),d=n(10),h=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},m=(c.default.any,c.default.node,c.default.bool,c.default.bool,c.default.bool,c.default.func,{component:"div",childFactory:function(e){return e}}),y=function(e){function t(n,o){i(this,t);var r=a(this,e.call(this,n,o));return r.handleExited=function(e,t,n){var o=(0,d.getChildMapping)(r.props.children);e in o||(n&&n(t),r.setState(function(t){var n=u({},t.children);return delete n[e],{children:n}}))},r.state={children:(0,d.getChildMapping)(n.children,function(e){var t=function(t){r.handleExited(e.key,t,e.props.onExited)};return(0,f.cloneElement)(e,{onExited:t,in:!0,appear:r.getProp(e,"appear"),enter:r.getProp(e,"enter"),exit:r.getProp(e,"exit")})})},r}return s(t,e),t.prototype.getChildContext=function(){return{transitionGroup:{isMounting:!this.appeared}}},t.prototype.getProp=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.props;return null!=n[t]?n[t]:e.props[t]},t.prototype.componentDidMount=function(){this.appeared=!0},t.prototype.componentWillReceiveProps=function(e){var t=this,n=this.state.children,o=(0,d.getChildMapping)(e.children),r=(0,d.mergeChildMappings)(n,o);Object.keys(r).forEach(function(i){var a=r[i];if((0,f.isValidElement)(a)){var s=function(e){t.handleExited(a.key,e,a.props.onExited)},u=i in n,l=i in o,c=n[i],p=(0,f.isValidElement)(c)&&!c.props.in;!l||u&&!p?l||!u||p?l&&u&&(0,f.isValidElement)(c)&&(r[i]=(0,f.cloneElement)(a,{onExited:s,in:c.props.in,exit:t.getProp(a,"exit",e),enter:t.getProp(a,"enter",e)})):r[i]=(0,f.cloneElement)(a,{in:!1}):r[i]=(0,f.cloneElement)(a,{onExited:s,in:!0,exit:t.getProp(a,"exit",e),enter:t.getProp(a,"enter",e)})}}),this.setState({children:r})},t.prototype.render=function(){var e=this.props,t=e.component,n=e.childFactory,o=r(e,["component","childFactory"]),i=this.state.children;return delete o.appear,delete o.enter,delete o.exit,p.default.createElement(t,o,h(i).map(n))},t}(p.default.Component);y.childContextTypes={transitionGroup:c.default.object.isRequired},y.propTypes={},y.defaultProps=m,t.default=y,e.exports=t.default},function(e,t,n){"use strict";function o(e,t){var n=function(e){return t&&(0,i.isValidElement)(e)?t(e):e},o=Object.create(null);return e&&i.Children.map(e,function(e){return e}).forEach(function(e){o[e.key]=n(e)}),o}function r(e,t){function n(n){return n in t?t[n]:e[n]}e=e||{},t=t||{};var o=Object.create(null),r=[];for(var i in e)i in t?r.length&&(o[i]=r,r=[]):r.push(i);var a=void 0,s={};for(var u in t){if(o[u])for(a=0;a<o[u].length;a++){var l=o[u][a];s[o[u][a]]=n(l)}s[u]=n(u)}for(a=0;a<r.length;a++)s[r[a]]=n(r[a]);return s}t.__esModule=!0,t.getChildMapping=o,t.mergeChildMappings=r;var i=n(0)},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 i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function 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)}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}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}}(),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=n(0),f=o(c),p=n(1),d=o(p),h=n(2),m=n(12),y=o(m),O=n(3),b=n(4),v=o(b),T=n(5),E=function(e){return(0,h.css)(l({position:"relative",minHeight:"48px",marginBottom:"1rem",padding:"8px",borderRadius:"1px",boxShadow:"0 1px 10px 0 rgba(0, 0, 0, .1), 0 2px 15px 0 rgba(0, 0, 0, .05)",display:"flex",justifyContent:"space-between",maxHeight:"800px",overflow:"hidden",fontFamily:"sans-serif",cursor:"pointer",background:v.default["color"+e.charAt(0).toUpperCase()+e.slice(1)]},"default"===e?{color:"#aaa"}:{},s({},"@media "+v.default.mobile,{marginBottom:0})))},g=(0,h.css)({margin:"auto 0",flex:1}),x=function(e){function t(){var e,n,o,a;r(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=o=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),o.state={isRunning:!0},o.pauseToast=function(){o.setState({isRunning:!1})},o.playToast=function(){o.setState({isRunning:!0})},a=n,i(o,a)}return a(t,e),u(t,[{key:"componentDidMount",value:function(){null!==this.props.onOpen&&this.props.onOpen(this.getChildrenProps())}},{key:"componentWillReceiveProps",value:function(e){this.props.isDocumentHidden!==e.isDocumentHidden&&this.setState({isRunning:!e.isDocumentHidden})}},{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={};return!1!==this.props.autoClose&&!0===this.props.pauseOnHover&&(e.onMouseEnter=this.pauseToast,e.onMouseLeave=this.playToast),this.props.closeOnClick&&(e.onClick=this.props.closeToast),e}},{key:"render",value:function(){var e=this.props,t=e.closeButton,n=e.children,o=e.autoClose,r=e.type,i=e.hideProgressBar,a=e.closeToast,s=e.transition,u=e.position,c=e.onExited,p=e.className,d=e.bodyClassName,h=e.progressClassName,m=e.updateId;return f.default.createElement(s,{in:this.props.in,appear:!0,unmountOnExit:!0,onExited:c,position:u},f.default.createElement("div",l({},E(r),this.getToastProps(),{className:p}),f.default.createElement("div",l({},g,{className:d}),n),!1!==t&&t,!1!==o&&f.default.createElement(y.default,{key:"pb-"+m,delay:o,isRunning:this.state.isRunning,closeToast:a,hide:i,type:r,className:h})))}}]),t}(c.Component);x.propTypes={closeButton:T.falseOrElement.isRequired,autoClose:T.falseOrDelay.isRequired,children:d.default.node.isRequired,closeToast:d.default.func.isRequired,position:d.default.oneOf((0,T.objectValues)(O.POSITION)).isRequired,pauseOnHover:d.default.bool.isRequired,closeOnClick:d.default.bool.isRequired,transition:d.default.func.isRequired,isDocumentHidden:d.default.bool.isRequired,in:d.default.bool,onExited:d.default.func,hideProgressBar:d.default.bool,onOpen:d.default.func,onClose:d.default.func,type:d.default.oneOf((0,T.objectValues)(O.TYPE)),className:d.default.oneOfType([d.default.string,d.default.object]),bodyClassName:d.default.oneOfType([d.default.string,d.default.object]),progressClassName:d.default.oneOfType([d.default.string,d.default.object]),updateId:d.default.number},x.defaultProps={type:O.TYPE.DEFAULT,in:!0,hideProgressBar:!1,onOpen:null,onClose:null,className:"",bodyClassName:"",progressClassName:"",updateId:null},t.default=x},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,a=e.hide,u=e.className;return s.default.createElement("div",i({},m(r,n,a,t),{className:u,onAnimationEnd:o}))}Object.defineProperty(t,"__esModule",{value:!0});var i=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},a=n(0),s=o(a),u=n(1),l=o(u),c=n(2),f=n(3),p=n(4),d=o(p),h=c.css.keyframes("track-progress",{"0%":{width:"100%"},"100%":{width:0}}),m=function(e,t,n,o){return(0,c.css)(i({position:"absolute",bottom:0,left:0,width:0,height:"5px",zIndex:d.default.zIndex,opacity:n?0:.7,animation:h+" linear 1",animationPlayState:t?"running":"paused",animationDuration:o+"ms",backgroundColor:"rgba(255,255,255,.7)"},"default"===e?{background:d.default.colorProgressDefault}:{}))};r.propTypes={delay:l.default.number.isRequired,isRunning:l.default.bool.isRequired,closeToast:l.default.func.isRequired,type:l.default.string,hide:l.default.bool,className:l.default.oneOfType([l.default.string,l.default.object])},r.defaultProps={type:f.TYPE.DEFAULT,hide:!1,className:""},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=e.closeToast,n=e.type;return s.default.createElement("button",i({},f("default"===n),{type:"button",onClick:t}),"✖")}Object.defineProperty(t,"__esModule",{value:!0});var i=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},a=n(0),s=o(a),u=n(1),l=o(u),c=n(2),f=function(e){return(0,c.css)({color:e?"#000":"#fff",fontWeight:"bold",fontSize:"14px",background:"transparent",outline:"none",border:"none",padding:0,cursor:"pointer",opacity:e?"0.3":"0.7",transition:".3s ease",alignSelf:"flex-start",":hover, :focus":{opacity:1}})};r.propTypes={closeToast:l.default.func},t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function i(e){var t=e.children,n=e.position,o=r(e,["children","position"]),i=m(n),s=i.enter,l=i.exit;return u.default.createElement(c.default,a({},o,{timeout:750,onEnter:function(e){return e.classList.add(s)},onEntered:function(e){return e.classList.remove(s)},onExit:function(e){return e.classList.add(l)}}),t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},s=n(0),u=o(s),l=n(15),c=o(l),f=n(2),p=n(18),d=o(p),h={animationDuration:"0.75s",animationFillMode:"both"},m=function(e){var t=(0,d.default)(e),n=t.enter,o=t.exit,r=f.css.keyframes("enter",a({"from, 60%, 75%, 90%, to":{animationTimingFunction:"cubic-bezier(0.215, 0.610, 0.355, 1.000)"}},n)),i=f.css.keyframes("exit",o);return{enter:(0,f.css)(a({},h,{animationName:r})),exit:(0,f.css)(a({},h,{animationName:i}))}};t.default=i},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}function u(){}t.__esModule=!0,t.EXITING=t.ENTERED=t.ENTERING=t.EXITED=t.UNMOUNTED=void 0;var l=n(1),c=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(l),f=n(0),p=o(f),d=n(16),h=o(d),m=(n(17),t.UNMOUNTED="unmounted"),y=t.EXITED="exited",O=t.ENTERING="entering",b=t.ENTERED="entered",v=t.EXITING="exiting",T=function(e){function t(n,o){i(this,t);var r=a(this,e.call(this,n,o)),s=o.transitionGroup,u=s&&!s.isMounting?n.enter:n.appear,l=void 0;return r.nextStatus=null,n.in?u?(l=y,r.nextStatus=O):l=b:l=n.unmountOnExit||n.mountOnEnter?m:y,r.state={status:l},r.nextCallback=null,r}return s(t,e),t.prototype.getChildContext=function(){return{transitionGroup:null}},t.prototype.componentDidMount=function(){this.updateStatus(!0)},t.prototype.componentWillReceiveProps=function(e){var t=this.pendingState||this.state,n=t.status;e.in?(n===m&&this.setState({status:y}),n!==O&&n!==b&&(this.nextStatus=O)):n!==O&&n!==b||(this.nextStatus=v)},t.prototype.componentDidUpdate=function(){this.updateStatus()},t.prototype.componentWillUnmount=function(){this.cancelNextCallback()},t.prototype.getTimeouts=function(){var e=this.props.timeout,t=void 0,n=void 0,o=void 0;return t=n=o=e,null!=e&&"number"!=typeof e&&(t=e.exit,n=e.enter,o=e.appear),{exit:t,enter:n,appear:o}},t.prototype.updateStatus=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.nextStatus;if(null!==t){this.nextStatus=null,this.cancelNextCallback();var n=h.default.findDOMNode(this);t===O?this.performEnter(n,e):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===y&&this.setState({status:m})},t.prototype.performEnter=function(e,t){var n=this,o=this.props.enter,r=this.context.transitionGroup?this.context.transitionGroup.isMounting:t,i=this.getTimeouts();if(!t&&!o)return void this.safeSetState({status:b},function(){n.props.onEntered(e)});this.props.onEnter(e,r),this.safeSetState({status:O},function(){n.props.onEntering(e,r),n.onTransitionEnd(e,i.enter,function(){n.safeSetState({status:b},function(){n.props.onEntered(e,r)})})})},t.prototype.performExit=function(e){var t=this,n=this.props.exit,o=this.getTimeouts();if(!n)return void this.safeSetState({status:y},function(){t.props.onExited(e)});this.props.onExit(e),this.safeSetState({status:v},function(){t.props.onExiting(e),t.onTransitionEnd(e,o.exit,function(){t.safeSetState({status:y},function(){t.props.onExited(e)})})})},t.prototype.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},t.prototype.safeSetState=function(e,t){var n=this;this.pendingState=e,t=this.setNextCallback(t),this.setState(e,function(){n.pendingState=null,t()})},t.prototype.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(o){n&&(n=!1,t.nextCallback=null,e(o))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},t.prototype.onTransitionEnd=function(e,t,n){this.setNextCallback(n),e?(this.props.addEndListener&&this.props.addEndListener(e,this.nextCallback),null!=t&&setTimeout(this.nextCallback,t)):setTimeout(this.nextCallback,0)},t.prototype.render=function(){var e=this.state.status;if(e===m)return null;var t=this.props,n=t.children,o=r(t,["children"]);if(delete o.in,delete o.mountOnEnter,delete o.unmountOnExit,delete o.appear,delete o.enter,delete o.exit,delete o.timeout,delete o.addEndListener,delete o.onEnter,delete o.onEntering,delete o.onEntered,delete o.onExit,delete o.onExiting,delete o.onExited,"function"==typeof n)return n(e,o);var i=p.default.Children.only(n);return p.default.cloneElement(i,o)},t}(p.default.Component);T.contextTypes={transitionGroup:c.object},T.childContextTypes={transitionGroup:function(){}},T.propTypes={},T.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:u,onEntering:u,onEntered:u,onExit:u,onExiting:u,onExited:u},T.UNMOUNTED=0,T.EXITED=1,T.ENTERING=2,T.ENTERED=3,T.EXITING=4,t.default=T},function(e,t){e.exports=o},function(e,t,n){"use strict";function o(e){var t="transition"+e+"Timeout",n="transition"+e;return function(e){if(e[n]){if(null==e[t])return new Error(t+" wasn't supplied to CSSTransitionGroup: this can cause unreliable animations and won't be supported in a future version of React. See https://fb.me/react-animation-transition-group-timeout for more information.");if("number"!=typeof e[t])return new Error(t+" must be a number (in milliseconds)")}return null}}t.__esModule=!0,t.classNamesShape=t.timeoutsShape=void 0,t.transitionTimeout=o;var r=n(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.timeoutsShape=i.default.oneOfType([i.default.number,i.default.shape({enter:i.default.number,exit:i.default.number}).isRequired]),t.classNamesShape=i.default.oneOfType([i.default.string,i.default.shape({enter:i.default.string,exit:i.default.string,active:i.default.string}),i.default.shape({enter:i.default.string,enterActive:i.default.string,exit:i.default.string,exitActive:i.default.string})])},function(e,t,n){"use strict";function o(e){switch(e){case r.POSITION.TOP_RIGHT:case r.POSITION.BOTTOM_RIGHT:default:return{enter:{from:{opacity:0,transform:"translate3d(3000px, 0, 0)"},"60%":{opacity:1,transform:"translate3d(-25px, 0, 0)"},"75%":{transform:"translate3d(10px, 0, 0)"},"90%":{transform:"translate3d(-5px, 0, 0)"},to:{transform:"none"}},exit:{"20%":{opacity:1,transform:"translate3d(-20px, 0, 0)"},to:{opacity:0,transform:"translate3d(2000px, 0, 0)"}}};case r.POSITION.TOP_LEFT:case r.POSITION.BOTTOM_LEFT:return{enter:{"0%":{opacity:0,transform:"translate3d(-3000px, 0, 0)"},"60%":{opacity:1,transform:"translate3d(25px, 0, 0)"},"75%":{transform:"translate3d(-10px, 0, 0)"},"90%":{transform:"translate3d(5px, 0, 0)"},to:{transform:"none"}},exit:{"20%":{opacity:1,transform:"translate3d(20px, 0, 0)"},to:{opacity:0,transform:"translate3d(-2000px, 0, 0)"}}};case r.POSITION.BOTTOM_CENTER:return{enter:{from:{opacity:0,transform:"translate3d(0, 3000px, 0)"},"60%":{opacity:1,transform:"translate3d(0, -20px, 0)"},"75%":{transform:"translate3d(0, 10px, 0)"},"90%":{transform:"translate3d(0, -5px, 0)"},to:{transform:"translate3d(0, 0, 0)"}},exit:{"20%":{transform:"translate3d(0, 10px, 0)"},"40%, 45%":{opacity:1,transform:"translate3d(0, -20px, 0)"},to:{opacity:0,transform:"translate3d(0, 2000px, 0)"}}};case r.POSITION.TOP_CENTER:return{enter:{"0%":{opacity:0,transform:"translate3d(0, -3000px, 0)"},"60%":{opacity:1,transform:"translate3d(0, 25px, 0)"},"75%":{transform:"translate3d(0, -10px, 0)"},"90%":{transform:"translate3d(0, 5px, 0)"},to:{transform:"none"}},exit:{"20%":{transform:"translate3d(0, -10px, 0)"},"40%, 45%":{opacity:1,transform:"translate3d(0, 20px, 0)"},to:{opacity:0,transform:"translate3d(0, -2000px, 0)"}}}}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var r=n(3)},function(e,t,n){"use strict";function o(e,t){return i({},l,e,{type:t,toastId:++p})}function r(e,t){return null!==c?s.default.emit(u.ACTION.SHOW,e,t):f.push({action:u.ACTION.SHOW,content:e,options:t}),t.toastId}Object.defineProperty(t,"__esModule",{value:!0});var i=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},a=n(6),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=n(3),l={type:u.TYPE.DEFAULT,autoClose:null,closeButton:null,hideProgressBar:null,position:null,pauseOnHover:null,closeOnClick:null,className:null,bodyClassName:null,progressClassName:null,transition:null,updateId:null},c=null,f=[],p=0,d=i(function(e,t){return r(e,o(t,t&&t.type||u.TYPE.DEFAULT))},{success:function(e,t){return r(e,o(t,u.TYPE.SUCCESS))},info:function(e,t){return r(e,o(t,u.TYPE.INFO))},warn:function(e,t){return r(e,o(t,u.TYPE.WARNING))},warning:function(e,t){return r(e,o(t,u.TYPE.WARNING))},error:function(e,t){return r(e,o(t,u.TYPE.ERROR))},dismiss:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return c&&s.default.emit(u.ACTION.CLEAR,e)},isActive:function(){return!1},update:function(e,t){if(c&&void 0!==c.collection[e]){var n=c.collection[e],o=n.options,a=n.content,s=null!==o.updateId?o.updateId+1:1,u=i({},o,t,{toastId:e,updateId:s}),l=void 0!==u.render?u.render:a;return delete u.render,r(l,u)}return!1}},{POSITION:u.POSITION,TYPE:u.TYPE});s.default.on(u.ACTION.MOUNTED,function(e){c=e,d.isActive=function(e){return c.isToastActive(e)},f.forEach(function(e){s.default.emit(e.action,e.content,e.options)}),f=[]}),t.default=d}])}); | ||
//# sourceMappingURL=ReactToastify.min.js.map |
import * as React from "react"; | ||
import Transition from "react-transition-group/Transition"; | ||
export let toast: Toast; | ||
type ToastType = "info" | "success" | "warning" | "error" | "default"; | ||
@@ -17,14 +15,5 @@ | ||
mobile?: string, | ||
zIndex?: string | number, | ||
} | ||
interface Toast { | ||
success(content: React.ReactNode, options?: ToastOptions): number; | ||
info(content: React.ReactNode, options?: ToastOptions): number; | ||
warn(content: React.ReactNode, options?: ToastOptions): number; | ||
error(content: React.ReactNode, options?: ToastOptions): number; | ||
isActive(toastId: number): boolean; | ||
dismiss(toastId: number): void; | ||
(content: React.ReactNode, options?: ToastOptions): number; | ||
} | ||
interface CommonOptions { | ||
@@ -49,2 +38,6 @@ pauseOnHover?: boolean; | ||
interface UpdateOptions extends ToastOptions { | ||
render?: React.ReactNode | ||
} | ||
interface ToastContainerProps extends CommonOptions { | ||
@@ -56,4 +49,17 @@ newestOnTop?: boolean; | ||
interface Toast { | ||
success(content: React.ReactNode, options?: ToastOptions): number; | ||
info(content: React.ReactNode, options?: ToastOptions): number; | ||
warn(content: React.ReactNode, options?: ToastOptions): number; | ||
error(content: React.ReactNode, options?: ToastOptions): number; | ||
isActive(toastId: number): boolean; | ||
dismiss(toastId: number): void; | ||
update(toastId: number, options?: UpdateOptions): number; | ||
(content: React.ReactNode, options?: ToastOptions): number; | ||
} | ||
export class ToastContainer extends React.Component<ToastContainerProps> {} | ||
export function style(props: styleProps): void; | ||
export let toast: Toast; |
@@ -24,3 +24,2 @@ 'use strict'; | ||
return (0, _glamor.css)({ | ||
padding: 0, | ||
color: isDefault ? "#000" : "#fff", | ||
@@ -32,2 +31,3 @@ fontWeight: "bold", | ||
border: "none", | ||
padding: 0, | ||
cursor: "pointer", | ||
@@ -34,0 +34,0 @@ opacity: isDefault ? "0.3" : "0.7", |
@@ -37,3 +37,3 @@ "use strict"; | ||
var enterAnimation = _glamor.css.keyframes('enter', _extends({ | ||
var enterAnimation = _glamor.css.keyframes("enter", _extends({ | ||
"from, 60%, 75%, 90%, to": { | ||
@@ -43,3 +43,3 @@ animationTimingFunction: "cubic-bezier(0.215, 0.610, 0.355, 1.000)" | ||
}, enter)); | ||
var exitAnimation = _glamor.css.keyframes('exit', exit); | ||
var exitAnimation = _glamor.css.keyframes("exit", exit); | ||
@@ -66,7 +66,9 @@ return { | ||
onEnter: function onEnter(node) { | ||
node.classList.add(enter); | ||
return node.classList.add(enter); | ||
}, | ||
onEntered: function onEntered(node) { | ||
return node.classList.remove(enter); | ||
}, | ||
onExit: function onExit(node) { | ||
node.classList.remove(enter); | ||
node.classList.add(exit); | ||
return node.classList.add(exit); | ||
} | ||
@@ -73,0 +75,0 @@ }), |
@@ -32,3 +32,3 @@ 'use strict'; | ||
var progress = function progress(type) { | ||
var progress = function progress(type, isRunning, hide, delay) { | ||
return (0, _glamor.css)(_extends({ | ||
@@ -40,5 +40,7 @@ position: "absolute", | ||
height: "5px", | ||
zIndex: 999, | ||
opacity: 0.7, | ||
zIndex: _style2.default.zIndex, | ||
opacity: hide ? 0 : 0.7, | ||
animation: trackProgress + ' linear 1', | ||
animationPlayState: isRunning ? 'running' : 'paused', | ||
animationDuration: delay + 'ms', | ||
backgroundColor: "rgba(255,255,255,.7)" | ||
@@ -56,15 +58,4 @@ }, type === "default" ? { background: _style2.default.colorProgressDefault } : {})); | ||
var style = { | ||
animationDuration: delay + 'ms', | ||
animationPlayState: isRunning ? 'running' : 'paused' | ||
}; | ||
style.WebkitAnimationPlayState = style.animationPlayState; | ||
if (hide) { | ||
style.opacity = 0; | ||
} | ||
return _react2.default.createElement('div', _extends({}, progress(type), { | ||
return _react2.default.createElement('div', _extends({}, progress(type, isRunning, hide, delay), { | ||
className: className, | ||
style: style, | ||
onAnimationEnd: closeToast | ||
@@ -71,0 +62,0 @@ })); |
@@ -15,3 +15,4 @@ "use strict"; | ||
colorProgressDefault: "linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)", | ||
mobile: "only screen and (max-width : 480px)" | ||
mobile: "only screen and (max-width : 480px)", | ||
zIndex: 9999 | ||
}; | ||
@@ -22,3 +23,3 @@ | ||
var val = props[k]; | ||
if (style.hasOwnProperty(k) && typeof val === 'string') { | ||
if (style.hasOwnProperty(k)) { | ||
style[k] = val; | ||
@@ -25,0 +26,0 @@ } |
@@ -31,6 +31,2 @@ "use strict"; | ||
var _objectValues = require("./util/objectValues"); | ||
var _objectValues2 = _interopRequireDefault(_objectValues); | ||
var _propValidator = require("./util/propValidator"); | ||
@@ -89,4 +85,2 @@ | ||
isRunning: true | ||
}, _this.handleVisibility = function () { | ||
return _this.setState({ isRunning: !document.hidden }); | ||
}, _this.pauseToast = function () { | ||
@@ -103,9 +97,16 @@ _this.setState({ isRunning: false }); | ||
this.props.onOpen !== null && this.props.onOpen(this.getChildrenProps()); | ||
document.addEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (this.props.isDocumentHidden !== nextProps.isDocumentHidden) { | ||
this.setState({ | ||
isRunning: !nextProps.isDocumentHidden | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
this.props.onClose !== null && this.props.onClose(this.getChildrenProps()); | ||
document.removeEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
@@ -146,3 +147,4 @@ }, { | ||
bodyClassName = _props.bodyClassName, | ||
progressClassName = _props.progressClassName; | ||
progressClassName = _props.progressClassName, | ||
updateId = _props.updateId; | ||
@@ -152,3 +154,9 @@ | ||
Transition, | ||
{ "in": this.props.in, appear: true, unmountOnExit: true, onExited: onExited, position: position }, | ||
{ | ||
"in": this.props.in, | ||
appear: true, | ||
unmountOnExit: true, | ||
onExited: onExited, | ||
position: position | ||
}, | ||
_react2.default.createElement( | ||
@@ -164,2 +172,3 @@ "div", | ||
autoClose !== false && _react2.default.createElement(_ProgressBar2.default, { | ||
key: "pb-" + updateId, | ||
delay: autoClose, | ||
@@ -182,9 +191,10 @@ isRunning: this.state.isRunning, | ||
closeButton: _propValidator.falseOrElement.isRequired, | ||
autoClose: _propValidator.falseOrNumber.isRequired, | ||
autoClose: _propValidator.falseOrDelay.isRequired, | ||
children: _propTypes2.default.node.isRequired, | ||
closeToast: _propTypes2.default.func.isRequired, | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_constant.POSITION)).isRequired, | ||
position: _propTypes2.default.oneOf((0, _propValidator.objectValues)(_constant.POSITION)).isRequired, | ||
pauseOnHover: _propTypes2.default.bool.isRequired, | ||
closeOnClick: _propTypes2.default.bool.isRequired, | ||
transition: _propTypes2.default.func.isRequired, | ||
isDocumentHidden: _propTypes2.default.bool.isRequired, | ||
in: _propTypes2.default.bool, | ||
@@ -195,6 +205,7 @@ onExited: _propTypes2.default.func, | ||
onClose: _propTypes2.default.func, | ||
type: _propTypes2.default.oneOf((0, _objectValues2.default)(_constant.TYPE)), | ||
type: _propTypes2.default.oneOf((0, _propValidator.objectValues)(_constant.TYPE)), | ||
className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), | ||
bodyClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), | ||
progressClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]) | ||
progressClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), | ||
updateId: _propTypes2.default.number | ||
}; | ||
@@ -209,4 +220,5 @@ Toast.defaultProps = { | ||
bodyClassName: "", | ||
progressClassName: "" | ||
progressClassName: "", | ||
updateId: null | ||
}; | ||
exports.default = Toast; |
@@ -49,6 +49,2 @@ "use strict"; | ||
var _objectValues = require("./util/objectValues"); | ||
var _objectValues2 = _interopRequireDefault(_objectValues); | ||
var _propValidator = require("./util/propValidator"); | ||
@@ -68,5 +64,5 @@ | ||
var container = function container() { | ||
return (0, _glamor.css)(_defineProperty({ | ||
zIndex: 999, | ||
var container = function container(disablePointer) { | ||
return (0, _glamor.css)(_extends({ | ||
zIndex: _style2.default.zIndex, | ||
position: "fixed", | ||
@@ -77,6 +73,6 @@ padding: "4px", | ||
color: "#fff" | ||
}, "@media " + _style2.default.mobile, { | ||
}, disablePointer ? { pointerEvents: "none" } : {}, _defineProperty({}, "@media " + _style2.default.mobile, { | ||
width: "100vw", | ||
padding: 0 | ||
})); | ||
}))); | ||
}; | ||
@@ -149,4 +145,7 @@ | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ToastContainer.__proto__ || Object.getPrototypeOf(ToastContainer)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
toast: [] | ||
}, _this.collection = {}, _this.isToastActive = function (id) { | ||
toast: [], | ||
isDocumentHidden: false | ||
}, _this.collection = {}, _this.isDocumentHidden = function () { | ||
return _this.setState({ isDocumentHidden: document.hidden }); | ||
}, _this.isToastActive = function (id) { | ||
return _this.state.toast.indexOf(parseInt(id, 10)) !== -1; | ||
@@ -156,2 +155,16 @@ }, _temp), _possibleConstructorReturn(_this, _ret); | ||
/** | ||
* Hold toast ids | ||
*/ | ||
/** | ||
* Hold toast's informations: | ||
* - what to render | ||
* - position | ||
* - raw content | ||
* - options | ||
*/ | ||
_createClass(ToastContainer, [{ | ||
@@ -171,2 +184,3 @@ key: "componentDidMount", | ||
}).emit(MOUNTED, this); | ||
document.addEventListener("visibilitychange", this.isDocumentHidden); | ||
} | ||
@@ -178,2 +192,3 @@ }, { | ||
_EventManager2.default.off(_constant.ACTION.CLEAR); | ||
document.removeEventListener("visibilitychange", this.isDocumentHidden); | ||
} | ||
@@ -190,7 +205,2 @@ }, { | ||
}, { | ||
key: "with", | ||
value: function _with(component, props) { | ||
return (0, _react.cloneElement)(component, _extends({}, props, component.props)); | ||
} | ||
}, { | ||
key: "makeCloseButton", | ||
@@ -206,3 +216,3 @@ value: function makeCloseButton(toastClose, toastId, type) { | ||
return closeButton === false ? false : this.with(closeButton, { | ||
return closeButton === false ? false : (0, _react.cloneElement)(closeButton, { | ||
closeToast: function closeToast() { | ||
@@ -227,3 +237,3 @@ return _this3.removeToast(toastId); | ||
value: function canBeRendered(content) { | ||
return (0, _react.isValidElement)(content) || (0, _propValidator.typeOf)(content) === "String" || (0, _propValidator.typeOf)(content) === "Number"; | ||
return (0, _react.isValidElement)(content) || typeof content === "string" || typeof content === "number"; | ||
} | ||
@@ -245,10 +255,14 @@ }, { | ||
type: options.type, | ||
closeButton: this.makeCloseButton(options.closeButton, toastId, options.type), | ||
closeToast: closeToast, | ||
updateId: options.updateId, | ||
position: options.position || this.props.position, | ||
transition: options.transition || this.props.transition, | ||
className: options.className || this.props.toastClassName, | ||
bodyClassName: options.bodyClassName || this.props.bodyClassName, | ||
closeButton: this.makeCloseButton(options.closeButton, toastId, options.type), | ||
pauseOnHover: options.pauseOnHover !== null ? options.pauseOnHover : this.props.pauseOnHover, | ||
closeOnClick: options.closeOnClick !== null ? options.closeOnClick : this.props.closeOnClick, | ||
className: options.className || this.props.toastClassName, | ||
bodyClassName: options.bodyClassName || this.props.bodyClassName, | ||
progressClassName: options.progressClassName || this.props.progressClassName | ||
progressClassName: options.progressClassName || this.props.progressClassName, | ||
autoClose: this.getAutoCloseDelay(options.autoClose !== false ? parseInt(options.autoClose, 10) : options.autoClose), | ||
hideProgressBar: typeof options.hideProgressBar === "boolean" ? options.hideProgressBar : this.props.hideProgressBar | ||
}; | ||
@@ -260,10 +274,7 @@ | ||
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 = closeToast; | ||
if ((0, _react.isValidElement)(content) && (0, _propValidator.typeOf)(content.type) !== "String") { | ||
content = this.with(content, { | ||
/** | ||
* add closeToast function to react component only | ||
*/ | ||
if ((0, _react.isValidElement)(content) && typeof content.type !== "string" && typeof content.type !== "number") { | ||
content = (0, _react.cloneElement)(content, { | ||
closeToast: closeToast | ||
@@ -274,8 +285,9 @@ }); | ||
this.collection = _extends({}, this.collection, _defineProperty({}, toastId, { | ||
content: this.makeToast(content, toastOptions), | ||
position: toastOptions.position | ||
position: toastOptions.position, | ||
options: toastOptions, | ||
content: content | ||
})); | ||
this.setState({ | ||
toast: [].concat(_toConsumableArray(this.state.toast), [toastId]) | ||
toast: toastOptions.updateId !== null ? [].concat(_toConsumableArray(this.state.toast)) : [].concat(_toConsumableArray(this.state.toast), [toastId]) | ||
}); | ||
@@ -288,3 +300,6 @@ } | ||
_Toast2.default, | ||
_extends({}, options, { key: "toast-" + options.id }), | ||
_extends({}, options, { | ||
isDocumentHidden: this.state.isDocumentHidden, | ||
key: "toast-" + options.id | ||
}), | ||
content | ||
@@ -299,19 +314,2 @@ ); | ||
}, { | ||
key: "getContainerProps", | ||
value: function getContainerProps(disablePointer) { | ||
var props = { | ||
style: disablePointer ? { pointerEvents: "none" } : {} | ||
}; | ||
if (this.props.className !== null) { | ||
props.className = this.props.className; | ||
} | ||
if (this.props.style !== null) { | ||
props.style = _extends({}, this.props.style, props.style); | ||
} | ||
return props; | ||
} | ||
}, { | ||
key: "renderToast", | ||
@@ -322,4 +320,9 @@ value: function renderToast() { | ||
var toastToRender = {}; | ||
var collection = this.props.newestOnTop ? Object.keys(this.collection).reverse() : Object.keys(this.collection); | ||
var _props = this.props, | ||
className = _props.className, | ||
style = _props.style, | ||
newestOnTop = _props.newestOnTop; | ||
var collection = newestOnTop ? Object.keys(this.collection).reverse() : Object.keys(this.collection); | ||
collection.forEach(function (toastId) { | ||
@@ -330,3 +333,3 @@ var item = _this5.collection[toastId]; | ||
if (_this5.state.toast.indexOf(parseInt(toastId, 10)) !== -1) { | ||
toastToRender[item.position].push(item.content); | ||
toastToRender[item.position].push(_this5.makeToast(item.content, item.options)); | ||
} else { | ||
@@ -343,3 +346,3 @@ toastToRender[item.position].push(null); | ||
_TransitionGroup2.default, | ||
_extends({}, container(), toastPosition(position), _this5.getContainerProps(disablePointer), { | ||
_extends({}, container(disablePointer), toastPosition(position), className !== null && { className: className }, style !== null && { style: style }, { | ||
key: "container-" + position | ||
@@ -369,3 +372,3 @@ }), | ||
*/ | ||
position: _propTypes2.default.oneOf((0, _objectValues2.default)(_constant.POSITION)), | ||
position: _propTypes2.default.oneOf((0, _propValidator.objectValues)(_constant.POSITION)), | ||
@@ -375,3 +378,3 @@ /** | ||
*/ | ||
autoClose: _propValidator.falseOrNumber, | ||
autoClose: _propValidator.falseOrDelay, | ||
@@ -444,6 +447,6 @@ /** | ||
style: null, | ||
toastClassName: '', | ||
bodyClassName: '', | ||
progressClassName: '' | ||
toastClassName: "", | ||
bodyClassName: "", | ||
progressClassName: "" | ||
}; | ||
exports.default = ToastContainer; |
@@ -7,10 +7,4 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* | ||
* TODO: Add validation here : | ||
* - Validate type | ||
* - Maybe autoClose | ||
* - Maybe closeButton as well | ||
* */ | ||
var _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; }; | ||
var _EventManager = require('./util/EventManager'); | ||
@@ -35,3 +29,4 @@ | ||
progressClassName: null, | ||
transition: null | ||
transition: null, | ||
updateId: null | ||
}; | ||
@@ -47,4 +42,4 @@ | ||
*/ | ||
function mergeOptions(options) { | ||
return _extends({}, defaultOptions, options, { toastId: ++toastId }); | ||
function mergeOptions(options, type) { | ||
return _extends({}, defaultOptions, options, { type: type, toastId: ++toastId }); | ||
} | ||
@@ -68,18 +63,18 @@ | ||
var toaster = _extends(function (content, options) { | ||
return emitEvent(content, mergeOptions(options)); | ||
return emitEvent(content, mergeOptions(options, options && options.type || _constant.TYPE.DEFAULT)); | ||
}, { | ||
success: function success(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.SUCCESS })); | ||
return emitEvent(content, mergeOptions(options, _constant.TYPE.SUCCESS)); | ||
}, | ||
info: function info(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.INFO })); | ||
return emitEvent(content, mergeOptions(options, _constant.TYPE.INFO)); | ||
}, | ||
warn: function warn(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.WARNING })); | ||
return emitEvent(content, mergeOptions(options, _constant.TYPE.WARNING)); | ||
}, | ||
warning: function warning(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.WARNING })); | ||
return emitEvent(content, mergeOptions(options, _constant.TYPE.WARNING)); | ||
}, | ||
error: function error(content, options) { | ||
return emitEvent(content, _extends(mergeOptions(options), { type: _constant.TYPE.ERROR })); | ||
return emitEvent(content, mergeOptions(options, _constant.TYPE.ERROR)); | ||
}, | ||
@@ -92,2 +87,19 @@ dismiss: function dismiss() { | ||
return false; | ||
}, | ||
update: function update(id, options) { | ||
if (container && typeof container.collection[id] !== 'undefined') { | ||
var _container$collection = container.collection[id], | ||
oldOptions = _container$collection.options, | ||
oldContent = _container$collection.content; | ||
var updateId = oldOptions.updateId !== null ? oldOptions.updateId + 1 : 1; | ||
var nextOptions = _extends({}, oldOptions, options, { toastId: id, updateId: updateId }); | ||
var content = typeof nextOptions.render !== "undefined" ? nextOptions.render : oldContent; | ||
delete nextOptions.render; | ||
return emitEvent(content, nextOptions); | ||
} | ||
return false; | ||
} | ||
@@ -94,0 +106,0 @@ }, { |
@@ -8,7 +8,5 @@ "use strict"; | ||
exports.default = function (obj) { | ||
var values = []; | ||
Object.keys(obj).forEach(function (key) { | ||
return values.push(obj[key]); | ||
return Object.keys(obj).map(function (key) { | ||
return obj[key]; | ||
}); | ||
return values; | ||
}; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,14 +6,16 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.falseOrElement = exports.falseOrNumber = undefined; | ||
exports.typeOf = typeOf; | ||
exports.falseOrElement = exports.falseOrDelay = undefined; | ||
exports.isValidDelay = isValidDelay; | ||
exports.objectValues = objectValues; | ||
var _react = require('react'); | ||
var _react = require("react"); | ||
function typeOf(obj) { | ||
return Object.prototype.toString.call(obj).slice(8, -1); | ||
function isValidDelay(val) { | ||
return typeof val === "number" && !isNaN(val) && val > 0; | ||
} | ||
function isValidDelay(val) { | ||
return typeOf(val) === 'Number' && !isNaN(val) && val > 0; | ||
function objectValues(obj) { | ||
return Object.keys(obj).map(function (key) { | ||
return obj[key]; | ||
}); | ||
} | ||
@@ -25,4 +27,4 @@ | ||
if (typeof prop === 'undefined') { | ||
return new Error('The prop ' + propName + ' is marked as required in \n ' + componentName + ', but its value is undefined.'); | ||
if (typeof prop === "undefined") { | ||
return new Error("The prop " + propName + " is marked as required in \n " + componentName + ", but its value is undefined."); | ||
} | ||
@@ -35,10 +37,7 @@ | ||
/** | ||
* TODO: Maybe rethink about the name | ||
*/ | ||
var falseOrNumber = exports.falseOrNumber = withRequired(function (props, propName, componentName) { | ||
var falseOrDelay = exports.falseOrDelay = withRequired(function (props, propName, componentName) { | ||
var prop = props[propName]; | ||
if (prop !== false && !isValidDelay(prop)) { | ||
return new Error(componentName + ' expect ' + propName + ' \n to be a valid Number > 0 or equal to false. ' + prop + ' given.'); | ||
return new Error(componentName + " expect " + propName + " \n to be a valid Number > 0 or equal to false. " + prop + " given."); | ||
} | ||
@@ -53,3 +52,3 @@ | ||
if (prop !== false && !(0, _react.isValidElement)(prop)) { | ||
return new Error(componentName + ' expect ' + propName + ' \n to be a valid react element or equal to false. ' + prop + ' given.'); | ||
return new Error(componentName + " expect " + propName + " \n to be a valid react element or equal to false. " + prop + " given."); | ||
} | ||
@@ -56,0 +55,0 @@ |
{ | ||
"name": "react-toastify", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "React notification made easy", | ||
@@ -44,2 +44,5 @@ "keywords": [ | ||
"<rootDir>/setupTests.js" | ||
], | ||
"snapshotSerializers": [ | ||
"jest-glamor-react" | ||
] | ||
@@ -60,2 +63,3 @@ }, | ||
"enzyme-adapter-react-16": "^1.0.0", | ||
"enzyme-to-json": "^3.2.2", | ||
"eslint": "^4.7.2", | ||
@@ -69,2 +73,3 @@ "eslint-config-react-app": "^2.0.1", | ||
"jest-cli": "^21.2.1", | ||
"jest-glamor-react": "^3.2.2", | ||
"raf": "^3.3.2", | ||
@@ -71,0 +76,0 @@ "react": "^16.0.0", |
215
README.md
@@ -6,6 +6,2 @@ # React Toastify [![Build Status](https://travis-ci.org/fkhadra/react-toastify.svg?branch=master)](https://travis-ci.org/fkhadra/react-toastify) [![npm](https://img.shields.io/npm/dm/react-toastify.svg)]() [![npm](https://img.shields.io/npm/v/react-toastify.svg)]() [![license](https://img.shields.io/github/license/fkhadra/react-toastify.svg?maxAge=2592000)]() [![Coverage Status](https://coveralls.io/repos/github/fkhadra/react-toastify/badge.svg?branch=master)](https://coveralls.io/github/fkhadra/react-toastify?branch=master) | ||
<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/qxxWZzh3YmHPKmwHHm79SuG4/fkhadra/react-toastify'> | ||
<img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/qxxWZzh3YmHPKmwHHm79SuG4/fkhadra/react-toastify.svg' /> | ||
</a> | ||
🎉 React-Toastify allow you to add notification to your app with ease. No bullshit ! | ||
@@ -24,2 +20,7 @@ | ||
+ [Prevent duplicate](#prevent-duplicate) | ||
+ [Update a toast](#update-a-toast) | ||
- [Basic example](#basic-example) | ||
- [Update the content](#update-the-content) | ||
- [ :sparkles: Apply a transition](#apply-a-transition) | ||
- [Reset option or inherit from ToastContainer](#reset-option-or-inherit-from-ToastContainer) | ||
+ [Define hook](#define-hook) | ||
@@ -31,3 +32,3 @@ + [Set a custom close button or simply remove it](#set-a-custom-close-button-or-simply-remove-it) | ||
+ [Add an undo option to a toast](#add-an-undo-option-to-a-toast) | ||
+ [ :fire: Define a custom enter and exit transition :fire: ](#define-a-custom-enter-and-exit-transition) | ||
+ [ :sparkles: Define a custom enter and exit transition](#define-a-custom-enter-and-exit-transition) | ||
+ [Le style](#le-style) | ||
@@ -46,7 +47,7 @@ - [Replace default style](#replace-default-style) | ||
## Demo | ||
[A demo is worth thousand word](https://fkhadra.github.io/react-toastify/) | ||
## Installation | ||
[A demo is worth thousand word](https://fkhadra.github.io/react-toastify/) | ||
## Installation | ||
``` | ||
@@ -59,3 +60,3 @@ $ npm install --save react-toastify | ||
- Easy to setup for real | ||
- Easy to setup for real, you can make it works in less than 10sec ! | ||
- Super easy to customize | ||
@@ -67,9 +68,10 @@ - Can display a react component inside the toast ! | ||
- Define behavior per toast | ||
- Use glamor for styling | ||
- Use glamor for styling 💅 | ||
- Pause toast when the browser is not visible thanks to visibility api | ||
- Fancy progress bar to display the remaining time | ||
- Possibility to update a toast | ||
## Migrate from v2 to v3 | ||
The v3 rely on glamor for styling. Using css classes is still fine but | ||
The v3 rely on glamor for styling. Using css classes is still fine but | ||
you may need to replace your css classes by a glamor rule in some case. | ||
@@ -83,3 +85,3 @@ | ||
### One component to rule them all | ||
### One component to rule them all | ||
@@ -157,4 +159,4 @@ By default all toasts will inherits ToastContainer's props. **Props defined on toast supersede ToastContainer's props.** | ||
import React from 'react'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import { ToastContainer } from 'react-toastify'; | ||
// close toast after 8 seconds | ||
@@ -170,4 +172,4 @@ const App = () => ( | ||
import React from 'react'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import { ToastContainer } from 'react-toastify'; | ||
class App extends Component { | ||
@@ -290,2 +292,103 @@ closeAfter15 = () => toast("YOLO", { autoClose: 15000 }); | ||
### Update a toast | ||
When you update a toast, the toast options and the content are inherited but don't worry you can update them. | ||
![update-without-transition](https://user-images.githubusercontent.com/5574267/33761953-1ce2e0ea-dc0b-11e7-8967-a63c1185ce0e.gif) | ||
#### Basic example | ||
```js | ||
import React, { Component } from 'react'; | ||
import { toast } from 'react-toastify'; | ||
class Update extends Component { | ||
toastId = null; | ||
notify = () => this.toastId = toast("Hello", { autoClose: false }); | ||
update = () => toast.update(this.toastId, { type: toast.TYPE.INFO, autoClose: 5000 }); | ||
render(){ | ||
return ( | ||
<div> | ||
<button onClick={this.notify}>Notify</button> | ||
<button onClick={this.update}>Update</button> | ||
</div> | ||
) | ||
} | ||
} | ||
``` | ||
#### Update the content | ||
If you want to change the content it's straightforward as well. You can render any valid element including a react component. Pass your value to a `render` option as follow: | ||
```js | ||
// With a string | ||
toast.update(this.toastId, { | ||
render: "New content" | ||
type: toast.TYPE.INFO, | ||
autoClose: 5000 | ||
}); | ||
// Or with a component | ||
toast.update(this.toastId, { | ||
render: <MyComponent /> | ||
type: toast.TYPE.INFO, | ||
autoClose: 5000 | ||
}); | ||
``` | ||
#### Apply a transition | ||
By default, when you update a toast, there is no transition applied. You can easily change this behavior by taking advantage of the `className` option. Lets rotate the toast on update: | ||
![update-with-transition](https://user-images.githubusercontent.com/5574267/33761952-1cc9d55a-dc0b-11e7-9a05-29186ea1c1f0.gif) | ||
```js | ||
toast.update(this.toastId, { | ||
render: "New Content", | ||
type: toast.TYPE.INFO, | ||
//Here the magic | ||
className: css({ | ||
transform: "rotateY(360deg)", | ||
transition: "transform 0.6s" | ||
}) | ||
}) | ||
``` | ||
#### Reset option or inherit from ToastContainer | ||
If you want to inherit props from the `ToastContainer`, you can reset an option by passing null. | ||
It's particulary usefull when you remove the `closeButton` from a toast and you want it back during the update: | ||
```js | ||
class Update extends Component { | ||
toastId = null; | ||
notify = () => this.toastId = toast("Hello", { | ||
autoClose: false, | ||
closeButton: false // Remove the closeButton | ||
}); | ||
update = () => toast.update(this.toastId, { | ||
type: toast.TYPE.INFO, | ||
autoClose: 5000, | ||
closeButton: null // The closeButton defined on ToastContainer will be used | ||
}); | ||
render(){ | ||
return ( | ||
<div> | ||
<button onClick={this.notify}>Notify</button> | ||
<button onClick={this.update}>Update</button> | ||
</div> | ||
) | ||
} | ||
} | ||
``` | ||
### Define hook | ||
@@ -404,3 +507,3 @@ | ||
function handleClick(){ | ||
undo(id); | ||
undo(id); | ||
closeToast(); | ||
@@ -421,3 +524,3 @@ } | ||
collection: data, | ||
// Buffer | ||
// Buffer | ||
toRemove: [] | ||
@@ -432,4 +535,4 @@ }; | ||
} | ||
// Remove definetly | ||
// Remove definetly | ||
cleanCollection = () => this.setState({ | ||
@@ -441,4 +544,4 @@ // Return element which are not included in toRemove | ||
}); | ||
// Remove row from render process | ||
// Remove row from render process | ||
// then display the toast with undo action available | ||
@@ -499,3 +602,3 @@ removeRow = e => { | ||
The toast rely on `react-transition-group` for the enter and exit transition. | ||
The toast rely on `react-transition-group` for the enter and exit transition. | ||
@@ -555,3 +658,3 @@ ![toastify_custom_trans](https://user-images.githubusercontent.com/5574267/31049179-0d52e14c-a62e-11e7-9abd-b0d169a0fadc.gif) | ||
// Any transition created with react-transition-group/Transition will work ! | ||
// Any transition created with react-transition-group/Transition will work ! | ||
const ZoomInAndOut = ({ children, position, ...props }) => ( | ||
@@ -579,3 +682,3 @@ <Transition | ||
}; | ||
render(){ | ||
@@ -594,3 +697,3 @@ return <button onClick={this.notify}>Notify</button>; | ||
{/*Component*/} | ||
<ToastContainer | ||
<ToastContainer | ||
transition={ZoomInAndOut} | ||
@@ -619,2 +722,3 @@ /> | ||
mobile: "only screen and (max-width : 480px)", | ||
zIndex: 9999, | ||
}); | ||
@@ -650,3 +754,3 @@ ``` | ||
}; | ||
render(){ | ||
@@ -658,3 +762,3 @@ return <button onClick={this.notify}>Notify</button>; | ||
You could define your style gloablly: | ||
You could define your style globally: | ||
@@ -666,3 +770,3 @@ | ||
{/*Component*/} | ||
<ToastContainer | ||
<ToastContainer | ||
toastClassName="dark-toast" | ||
@@ -685,5 +789,5 @@ progressClassName={css({ | ||
## Api | ||
### ToastContainer | ||
| Props | Type | Default | Description | | ||
@@ -704,10 +808,10 @@ | ----------------- | -------------- | --------- | --------------------------------------------------------------- | | ||
| progressClassName | string\|glamor rule | - | Add optional classes to the progress bar | | ||
### toast | ||
All the method of toast return a **toastId** except `dismiss` and `isActive`. | ||
The **toastId** can be used to remove a toast programmatically or to check if the toast is displayed. | ||
All the method of toast return a **toastId** except `dismiss` and `isActive`. | ||
The **toastId** can be used to remove a toast programmatically or to check if the toast is displayed. | ||
| Parameter | Type | Required | Description | | ||
@@ -732,3 +836,4 @@ | --------- | ------- | ------------- | ------------------------------------------------------------- | | ||
- `progressClassName`: same as ToastContainer | ||
- `render`: string or React Element, only available when calling update | ||
:warning:️ *Toast options supersede ToastContainer props* :warning: | ||
@@ -741,3 +846,3 @@ | ||
onClose: props => console.log(props.foo), | ||
autoClose: 6000, | ||
autoClose: 6000, | ||
closeButton: <FontAwesomeCloseButton />, | ||
@@ -759,2 +864,6 @@ type: toast.TYPE.INFO, | ||
toast.isActive(toastId) //Check if a toast is displayed or not | ||
toast.update(toastId, { | ||
type: toast.TYPE.INFO, | ||
render: <Img foo={bar}/> | ||
}); | ||
``` | ||
@@ -770,2 +879,8 @@ | ||
### V3.1.0 | ||
- Add ability to update an existing toast | ||
- Allow to define the zIndex via the style helper | ||
- Get rid of all inline style | ||
### V3.0.0 | ||
@@ -788,3 +903,3 @@ | ||
- Can now use [sass variable default](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#Variable_Defaults___default) thanks to [vikpe](https://github.com/vikpe) | ||
- Can now use [sass variable default](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#Variable_Defaults___default) thanks to [vikpe](https://github.com/vikpe) | ||
### V2.1.5 | ||
@@ -831,3 +946,3 @@ | ||
But, it brings a lots of new and exciting features ! | ||
But, it brings a lots of new and exciting features ! | ||
@@ -853,3 +968,3 @@ #### New Features | ||
- Toast can now be positioned individually ! | ||
- Toast can now be positioned individually ! | ||
@@ -868,7 +983,7 @@ ### v1.6.0 | ||
- Added --no-idents flag to cssnano to avoid animation name collision with others libs. | ||
- Tests are no longer transpiled | ||
- Tests are no longer transpiled | ||
### v1.5.0 | ||
- That version does not bring any features but it brings tests made with the amazing jest and aslo Travis CI integration. | ||
- That version does not bring any features but it brings tests made with the amazing jest and aslo Travis CI integration. | ||
@@ -885,3 +1000,3 @@ ### v1.4.3 | ||
- Fixed the test to check if the toast can be rendered | ||
- Fixed the test to check if the toast can be rendered | ||
@@ -894,3 +1009,3 @@ ### v1.4.0 | ||
- 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. | ||
- The default close button has been replaced. | ||
@@ -950,6 +1065,6 @@ #### New Features | ||
Show your 😻 and support by giving a ⭐. Any suggestions and pull request are welcome ! | ||
Show your ❤️ and support by giving a ⭐. Any suggestions and pull request are welcome ! | ||
## License | ||
Licensed under MIT |
@@ -7,3 +7,2 @@ /* eslint react/require-default-props: 0 */ | ||
const rule = isDefault => css({ | ||
padding: 0, | ||
color: isDefault ? "#000" : "#fff", | ||
@@ -15,2 +14,3 @@ fontWeight: "bold", | ||
border: "none", | ||
padding: 0, | ||
cursor: "pointer", | ||
@@ -17,0 +17,0 @@ opacity: isDefault ? "0.3" : "0.7", |
@@ -8,4 +8,4 @@ import React from "react"; | ||
const animate = { | ||
animationDuration: "0.75s", | ||
animationFillMode: "both" | ||
animationDuration: "0.75s", | ||
animationFillMode: "both" | ||
}; | ||
@@ -15,17 +15,16 @@ | ||
const { enter, exit } = getAnimation(pos); | ||
const enterAnimation = css.keyframes('enter', { | ||
const enterAnimation = css.keyframes("enter", { | ||
"from, 60%, 75%, 90%, to": { | ||
animationTimingFunction: "cubic-bezier(0.215, 0.610, 0.355, 1.000)" | ||
}, | ||
...enter, | ||
...enter | ||
}); | ||
const exitAnimation = css.keyframes('exit', exit) | ||
const exitAnimation = css.keyframes("exit", exit); | ||
return { | ||
enter: css({...animate, animationName: enterAnimation}), | ||
exit: css({...animate, animationName: exitAnimation}), | ||
enter: css({ ...animate, animationName: enterAnimation }), | ||
exit: css({ ...animate, animationName: exitAnimation }) | ||
}; | ||
} | ||
}; | ||
function DefaultTransition({ children, position, ...props }) { | ||
@@ -38,9 +37,5 @@ const { enter, exit } = animation(position); | ||
timeout={750} | ||
onEnter={node => { | ||
node.classList.add(enter); | ||
}} | ||
onExit={node => { | ||
node.classList.remove(enter); | ||
node.classList.add(exit); | ||
}} | ||
onEnter={node => node.classList.add(enter)} | ||
onEntered={node => node.classList.remove(enter)} | ||
onExit={node => node.classList.add(exit)} | ||
> | ||
@@ -47,0 +42,0 @@ {children} |
@@ -13,3 +13,3 @@ import React from 'react'; | ||
const progress = type => css({ | ||
const progress = (type, isRunning, hide, delay) => css({ | ||
position: "absolute", | ||
@@ -20,5 +20,7 @@ bottom: 0, | ||
height: "5px", | ||
zIndex: 999, | ||
opacity: 0.7, | ||
zIndex: style.zIndex, | ||
opacity: hide ? 0: 0.7, | ||
animation: `${trackProgress} linear 1`, | ||
animationPlayState: isRunning ? 'running' : 'paused', | ||
animationDuration: `${delay}ms`, | ||
backgroundColor: "rgba(255,255,255,.7)", | ||
@@ -29,17 +31,6 @@ ...type === "default" ? { background: style.colorProgressDefault } : {} | ||
function ProgressBar({ delay, isRunning, closeToast, type, hide, className }) { | ||
const style = { | ||
animationDuration: `${delay}ms`, | ||
animationPlayState: isRunning ? 'running' : 'paused' | ||
}; | ||
style.WebkitAnimationPlayState = style.animationPlayState; | ||
if (hide) { | ||
style.opacity = 0; | ||
} | ||
return ( | ||
<div | ||
{...progress(type)} | ||
{...progress(type, isRunning, hide, delay)} | ||
className={className} | ||
style={style} | ||
onAnimationEnd={closeToast} | ||
@@ -46,0 +37,0 @@ /> |
@@ -1,2 +0,2 @@ | ||
let style = { | ||
const style = { | ||
width: "320px", | ||
@@ -10,2 +10,3 @@ colorDefault: "#fff", | ||
mobile: "only screen and (max-width : 480px)", | ||
zIndex: 9999, | ||
}; | ||
@@ -16,3 +17,3 @@ | ||
const val = props[k]; | ||
if(style.hasOwnProperty(k) && typeof val === 'string'){ | ||
if(style.hasOwnProperty(k)){ | ||
style[k] = val; | ||
@@ -19,0 +20,0 @@ } |
@@ -8,24 +8,29 @@ import React, { Component } from "react"; | ||
import style from "./style"; | ||
import objectValues from "./util/objectValues"; | ||
import { falseOrElement, falseOrNumber } from "./util/propValidator"; | ||
import { | ||
falseOrElement, | ||
falseOrDelay, | ||
objectValues | ||
} from "./util/propValidator"; | ||
const toast = type => css({ | ||
position: "relative", | ||
minHeight: "48px", | ||
marginBottom: "1rem", | ||
padding: "8px", | ||
borderRadius: "1px", | ||
boxShadow: "0 1px 10px 0 rgba(0, 0, 0, .1), 0 2px 15px 0 rgba(0, 0, 0, .05)", | ||
display: "flex", | ||
justifyContent: "space-between", | ||
maxHeight: "800px", | ||
overflow: "hidden", | ||
fontFamily: "sans-serif", | ||
cursor: "pointer", | ||
background: style[`color${type.charAt(0).toUpperCase()}${type.slice(1)}`], | ||
...type === "default" ? { color: "#aaa" } : {}, | ||
[`@media ${style.mobile}`]: { | ||
marginBottom: 0 | ||
} | ||
}); | ||
const toast = type => | ||
css({ | ||
position: "relative", | ||
minHeight: "48px", | ||
marginBottom: "1rem", | ||
padding: "8px", | ||
borderRadius: "1px", | ||
boxShadow: | ||
"0 1px 10px 0 rgba(0, 0, 0, .1), 0 2px 15px 0 rgba(0, 0, 0, .05)", | ||
display: "flex", | ||
justifyContent: "space-between", | ||
maxHeight: "800px", | ||
overflow: "hidden", | ||
fontFamily: "sans-serif", | ||
cursor: "pointer", | ||
background: style[`color${type.charAt(0).toUpperCase()}${type.slice(1)}`], | ||
...(type === "default" ? { color: "#aaa" } : {}), | ||
[`@media ${style.mobile}`]: { | ||
marginBottom: 0 | ||
} | ||
}); | ||
@@ -40,3 +45,3 @@ const body = css({ | ||
closeButton: falseOrElement.isRequired, | ||
autoClose: falseOrNumber.isRequired, | ||
autoClose: falseOrDelay.isRequired, | ||
children: PropTypes.node.isRequired, | ||
@@ -48,2 +53,3 @@ closeToast: PropTypes.func.isRequired, | ||
transition: PropTypes.func.isRequired, | ||
isDocumentHidden: PropTypes.bool.isRequired, | ||
in: PropTypes.bool, | ||
@@ -57,3 +63,7 @@ onExited: PropTypes.func, | ||
bodyClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
progressClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]) | ||
progressClassName: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object | ||
]), | ||
updateId: PropTypes.number | ||
}; | ||
@@ -69,3 +79,4 @@ | ||
bodyClassName: "", | ||
progressClassName: "" | ||
progressClassName: "", | ||
updateId: null | ||
}; | ||
@@ -76,15 +87,19 @@ | ||
}; | ||
componentDidMount() { | ||
this.props.onOpen !== null && this.props.onOpen(this.getChildrenProps()); | ||
document.addEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
if (this.props.isDocumentHidden !== nextProps.isDocumentHidden) { | ||
this.setState({ | ||
isRunning: !nextProps.isDocumentHidden | ||
}); | ||
} | ||
} | ||
componentWillUnmount() { | ||
this.props.onClose !== null && this.props.onClose(this.getChildrenProps()); | ||
document.removeEventListener("visibilitychange", this.handleVisibility); | ||
} | ||
handleVisibility = () => this.setState({ isRunning: !document.hidden }); | ||
getChildrenProps() { | ||
@@ -128,7 +143,14 @@ return this.props.children.props; | ||
bodyClassName, | ||
progressClassName | ||
progressClassName, | ||
updateId | ||
} = this.props; | ||
return ( | ||
<Transition in={this.props.in} appear unmountOnExit onExited={onExited} position={position}> | ||
<Transition | ||
in={this.props.in} | ||
appear | ||
unmountOnExit | ||
onExited={onExited} | ||
position={position} | ||
> | ||
<div {...toast(type)} {...this.getToastProps()} className={className}> | ||
@@ -141,2 +163,3 @@ <div {...body} className={bodyClassName}> | ||
<ProgressBar | ||
key={`pb-${updateId}`} | ||
delay={autoClose} | ||
@@ -143,0 +166,0 @@ isRunning={this.state.isRunning} |
@@ -12,26 +12,27 @@ import React, { Component, isValidElement, cloneElement } from "react"; | ||
import EventManager from "./util/EventManager"; | ||
import objectValues from "./util/objectValues"; | ||
import { | ||
falseOrNumber, | ||
falseOrDelay, | ||
falseOrElement, | ||
isValidDelay, | ||
typeOf | ||
objectValues | ||
} from "./util/propValidator"; | ||
const container = () => css({ | ||
zIndex: 999, | ||
position: "fixed", | ||
padding: "4px", | ||
width: style.width, | ||
boxSizing: "border-box", | ||
color: "#fff", | ||
[`@media ${style.mobile}`]: { | ||
width: "100vw", | ||
padding: 0 | ||
} | ||
}); | ||
const container = disablePointer => | ||
css({ | ||
zIndex: style.zIndex, | ||
position: "fixed", | ||
padding: "4px", | ||
width: style.width, | ||
boxSizing: "border-box", | ||
color: "#fff", | ||
...(disablePointer ? { pointerEvents: "none" } : {}), | ||
[`@media ${style.mobile}`]: { | ||
width: "100vw", | ||
padding: 0 | ||
} | ||
}); | ||
const toastPosition = pos => { | ||
let rule; | ||
const marginLeft = `-${parseInt(style.width,10)/2}px`; | ||
const marginLeft = `-${parseInt(style.width, 10) / 2}px`; | ||
switch (pos) { | ||
@@ -49,3 +50,3 @@ case POSITION.TOP_LEFT: | ||
marginLeft: marginLeft | ||
}; | ||
}; | ||
break; | ||
@@ -57,5 +58,5 @@ case POSITION.TOP_RIGHT: | ||
right: "1em" | ||
}; | ||
}; | ||
break; | ||
case POSITION.BOTTOM_LEFT: | ||
case POSITION.BOTTOM_LEFT: | ||
rule = { | ||
@@ -77,12 +78,15 @@ bottom: "1em", | ||
right: "1em" | ||
}; | ||
}; | ||
} | ||
return css(rule, css({ | ||
[`@media ${style.mobile}`]: { | ||
left: 0, | ||
margin: 0, | ||
position: "fixed", | ||
...pos.substring(0,3) === "top" ? { top: 0 } : { bottom: 0 } | ||
} | ||
})); | ||
return css( | ||
rule, | ||
css({ | ||
[`@media ${style.mobile}`]: { | ||
left: 0, | ||
margin: 0, | ||
position: "fixed", | ||
...(pos.substring(0, 3) === "top" ? { top: 0 } : { bottom: 0 }) | ||
} | ||
}) | ||
); | ||
}; | ||
@@ -100,3 +104,3 @@ | ||
*/ | ||
autoClose: falseOrNumber, | ||
autoClose: falseOrDelay, | ||
@@ -151,3 +155,6 @@ /** | ||
*/ | ||
progressClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
progressClassName: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object | ||
]), | ||
@@ -171,11 +178,22 @@ /** | ||
style: null, | ||
toastClassName: '', | ||
bodyClassName: '', | ||
progressClassName: '', | ||
toastClassName: "", | ||
bodyClassName: "", | ||
progressClassName: "" | ||
}; | ||
/** | ||
* Hold toast ids | ||
*/ | ||
state = { | ||
toast: [] | ||
toast: [], | ||
isDocumentHidden: false | ||
}; | ||
/** | ||
* Hold toast's informations: | ||
* - what to render | ||
* - position | ||
* - raw content | ||
* - options | ||
*/ | ||
collection = {}; | ||
@@ -185,6 +203,6 @@ | ||
const { SHOW, CLEAR, MOUNTED } = ACTION; | ||
EventManager | ||
.on(SHOW, (content, options) => this.show(content, options)) | ||
.on(CLEAR, id => (id !== null ? this.removeToast(id) : this.clear())) | ||
.emit(MOUNTED, this); | ||
EventManager.on(SHOW, (content, options) => this.show(content, options)) | ||
.on(CLEAR, id => (id !== null ? this.removeToast(id) : this.clear())) | ||
.emit(MOUNTED, this); | ||
document.addEventListener("visibilitychange", this.isDocumentHidden); | ||
} | ||
@@ -195,4 +213,7 @@ | ||
EventManager.off(ACTION.CLEAR); | ||
document.removeEventListener("visibilitychange", this.isDocumentHidden); | ||
} | ||
isDocumentHidden = () => this.setState({ isDocumentHidden: document.hidden }); | ||
isToastActive = id => this.state.toast.indexOf(parseInt(id, 10)) !== -1; | ||
@@ -206,6 +227,2 @@ | ||
with(component, props) { | ||
return cloneElement(component, { ...props, ...component.props }); | ||
} | ||
makeCloseButton(toastClose, toastId, type) { | ||
@@ -220,6 +237,6 @@ let closeButton = this.props.closeButton; | ||
? false | ||
: this.with(closeButton, { | ||
closeToast: () => this.removeToast(toastId), | ||
type: type | ||
}); | ||
: cloneElement(closeButton, { | ||
closeToast: () => this.removeToast(toastId), | ||
type: type | ||
}); | ||
} | ||
@@ -240,4 +257,4 @@ | ||
isValidElement(content) || | ||
typeOf(content) === "String" || | ||
typeOf(content) === "Number" | ||
typeof content === "string" || | ||
typeof content === "number" | ||
); | ||
@@ -247,4 +264,6 @@ } | ||
show(content, options) { | ||
if (!(this.canBeRendered(content))) { | ||
throw new Error(`The element you provided cannot be rendered. You provided an element of type ${typeof content}`); | ||
if (!this.canBeRendered(content)) { | ||
throw new Error( | ||
`The element you provided cannot be rendered. You provided an element of type ${typeof content}` | ||
); | ||
} | ||
@@ -256,35 +275,48 @@ const toastId = options.toastId; | ||
type: options.type, | ||
closeButton: this.makeCloseButton(options.closeButton, toastId, options.type), | ||
closeToast: closeToast, | ||
updateId: options.updateId, | ||
position: options.position || this.props.position, | ||
transition: options.transition || this.props.transition, | ||
pauseOnHover: | ||
options.pauseOnHover !== null | ||
? options.pauseOnHover | ||
: this.props.pauseOnHover, | ||
closeOnClick: options.closeOnClick !== null ? options.closeOnClick : this.props.closeOnClick, | ||
className: options.className || this.props.toastClassName, | ||
bodyClassName: options.bodyClassName || this.props.bodyClassName, | ||
progressClassName: options.progressClassName || this.props.progressClassName, | ||
}; | ||
this.isFunction(options.onOpen) && (toastOptions.onOpen = options.onOpen); | ||
this.isFunction(options.onClose) && | ||
(toastOptions.onClose = options.onClose); | ||
toastOptions.autoClose = this.getAutoCloseDelay( | ||
closeButton: this.makeCloseButton( | ||
options.closeButton, | ||
toastId, | ||
options.type | ||
), | ||
pauseOnHover: | ||
options.pauseOnHover !== null | ||
? options.pauseOnHover | ||
: this.props.pauseOnHover, | ||
closeOnClick: | ||
options.closeOnClick !== null | ||
? options.closeOnClick | ||
: this.props.closeOnClick, | ||
progressClassName: | ||
options.progressClassName || this.props.progressClassName, | ||
autoClose: this.getAutoCloseDelay( | ||
options.autoClose !== false | ||
? parseInt(options.autoClose, 10) | ||
: options.autoClose | ||
); | ||
toastOptions.hideProgressBar = | ||
), | ||
hideProgressBar: | ||
typeof options.hideProgressBar === "boolean" | ||
? options.hideProgressBar | ||
: this.props.hideProgressBar; | ||
: this.props.hideProgressBar | ||
}; | ||
toastOptions.closeToast = closeToast; | ||
this.isFunction(options.onOpen) && (toastOptions.onOpen = options.onOpen); | ||
if (isValidElement(content) && typeOf(content.type) !== "String") { | ||
content = this.with(content, { | ||
this.isFunction(options.onClose) && | ||
(toastOptions.onClose = options.onClose); | ||
/** | ||
* add closeToast function to react component only | ||
*/ | ||
if ( | ||
isValidElement(content) && | ||
typeof content.type !== "string" && | ||
typeof content.type !== "number" | ||
) { | ||
content = cloneElement(content, { | ||
closeToast | ||
@@ -296,4 +328,5 @@ }); | ||
[toastId]: { | ||
content: this.makeToast(content, toastOptions), | ||
position: toastOptions.position | ||
position: toastOptions.position, | ||
options: toastOptions, | ||
content: content | ||
} | ||
@@ -303,3 +336,5 @@ }); | ||
this.setState({ | ||
toast: [...this.state.toast, toastId] | ||
toast: toastOptions.updateId !== null | ||
? [...this.state.toast] | ||
: [...this.state.toast, toastId] | ||
}); | ||
@@ -310,3 +345,7 @@ } | ||
return ( | ||
<Toast {...options} key={`toast-${options.id}`}> | ||
<Toast | ||
{...options} | ||
isDocumentHidden={this.state.isDocumentHidden} | ||
key={`toast-${options.id}`} | ||
> | ||
{content} | ||
@@ -321,23 +360,8 @@ </Toast> | ||
getContainerProps(disablePointer) { | ||
const props = { | ||
style: disablePointer ? { pointerEvents: "none" } : {} | ||
}; | ||
if (this.props.className !== null) { | ||
props.className = this.props.className; | ||
} | ||
if (this.props.style !== null) { | ||
props.style = {...this.props.style, ...props.style}; | ||
} | ||
return props; | ||
} | ||
renderToast() { | ||
const toastToRender = {}; | ||
const collection = this.props.newestOnTop | ||
? Object.keys(this.collection).reverse() | ||
: Object.keys(this.collection); | ||
const { className, style, newestOnTop } = this.props; | ||
const collection = newestOnTop | ||
? Object.keys(this.collection).reverse() | ||
: Object.keys(this.collection); | ||
@@ -349,9 +373,11 @@ collection.forEach(toastId => { | ||
if (this.state.toast.indexOf(parseInt(toastId, 10)) !== -1) { | ||
toastToRender[item.position].push(item.content); | ||
toastToRender[item.position].push( | ||
this.makeToast(item.content, item.options) | ||
); | ||
} else { | ||
toastToRender[item.position].push(null); | ||
delete this.collection[toastId] | ||
delete this.collection[toastId]; | ||
} | ||
}); | ||
return Object.keys(toastToRender).map(position => { | ||
@@ -364,5 +390,6 @@ const disablePointer = | ||
<TransitionGroup | ||
{...container()} | ||
{...container(disablePointer)} | ||
{...toastPosition(position)} | ||
{...this.getContainerProps(disablePointer)} | ||
{...className !== null && { className }} | ||
{...style !== null && { style }} | ||
key={`container-${position}`} | ||
@@ -377,7 +404,3 @@ > | ||
render() { | ||
return ( | ||
<div> | ||
{this.renderToast()} | ||
</div> | ||
); | ||
return <div>{this.renderToast()}</div>; | ||
} | ||
@@ -384,0 +407,0 @@ } |
@@ -1,7 +0,1 @@ | ||
/* | ||
* TODO: Add validation here : | ||
* - Validate type | ||
* - Maybe autoClose | ||
* - Maybe closeButton as well | ||
* */ | ||
import EventManager from './util/EventManager'; | ||
@@ -21,3 +15,4 @@ import { POSITION, TYPE, ACTION } from './constant'; | ||
progressClassName: null, | ||
transition: null | ||
transition: null, | ||
updateId: null | ||
}; | ||
@@ -33,4 +28,4 @@ | ||
*/ | ||
function mergeOptions(options) { | ||
return Object.assign({}, defaultOptions, options, { toastId: ++toastId }); | ||
function mergeOptions(options, type) { | ||
return Object.assign({}, defaultOptions, options, { type: type, toastId: ++toastId }); | ||
} | ||
@@ -54,11 +49,25 @@ | ||
const toaster = Object.assign( | ||
(content, options) => emitEvent(content, mergeOptions(options)), | ||
(content, options) => emitEvent(content, mergeOptions(options, (options && options.type) || TYPE.DEFAULT)), | ||
{ | ||
success: (content, options) => emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.SUCCESS })), | ||
info: (content, options) => emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.INFO })), | ||
warn: (content, options) => emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.WARNING })), | ||
warning: (content, options) => emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.WARNING })), | ||
error: (content, options) => emitEvent(content, Object.assign(mergeOptions(options), { type: TYPE.ERROR })), | ||
success: (content, options) => emitEvent(content, mergeOptions(options, TYPE.SUCCESS)), | ||
info: (content, options) => emitEvent(content, mergeOptions(options, TYPE.INFO)), | ||
warn: (content, options) => emitEvent(content, mergeOptions(options, TYPE.WARNING)), | ||
warning: (content, options) => emitEvent(content, mergeOptions(options, TYPE.WARNING)), | ||
error: (content, options) => emitEvent(content, mergeOptions(options, TYPE.ERROR)), | ||
dismiss: (id = null) => container && EventManager.emit(ACTION.CLEAR, id), | ||
isActive: () => false | ||
isActive: () => false, | ||
update(id, options){ | ||
if(container && typeof container.collection[id] !== 'undefined') { | ||
const {options: oldOptions, content: oldContent } = container.collection[id]; | ||
const updateId = oldOptions.updateId !== null ? oldOptions.updateId + 1 : 1; | ||
const nextOptions = Object.assign({}, oldOptions, options, { toastId: id, updateId: updateId }); | ||
const content = typeof nextOptions.render !== "undefined" ? nextOptions.render : oldContent; | ||
delete nextOptions.render; | ||
return emitEvent(content, nextOptions); | ||
} | ||
return false; | ||
} | ||
}, | ||
@@ -65,0 +74,0 @@ { |
@@ -1,16 +0,16 @@ | ||
import { isValidElement } from 'react'; | ||
import { isValidElement } from "react"; | ||
export function typeOf(obj) { | ||
return Object.prototype.toString.call(obj).slice(8, -1); | ||
export function isValidDelay(val) { | ||
return typeof val === "number" && !isNaN(val) && val > 0; | ||
} | ||
export function isValidDelay(val) { | ||
return typeOf(val) === 'Number' && !isNaN(val) && val > 0; | ||
export function objectValues(obj) { | ||
return Object.keys(obj).map(key => obj[key]); | ||
} | ||
function withRequired(fn) { | ||
fn.isRequired = function (props, propName, componentName) { | ||
fn.isRequired = function(props, propName, componentName) { | ||
const prop = props[propName]; | ||
if (typeof prop === 'undefined') { | ||
if (typeof prop === "undefined") { | ||
return new Error(`The prop ${propName} is marked as required in | ||
@@ -25,29 +25,22 @@ ${componentName}, but its value is undefined.`); | ||
/** | ||
* TODO: Maybe rethink about the name | ||
*/ | ||
export const falseOrNumber = withRequired( | ||
(props, propName, componentName) => { | ||
const prop = props[propName]; | ||
export const falseOrDelay = withRequired((props, propName, componentName) => { | ||
const prop = props[propName]; | ||
if (prop !== false && !isValidDelay(prop)) { | ||
return new Error(`${componentName} expect ${propName} | ||
if (prop !== false && !isValidDelay(prop)) { | ||
return new Error(`${componentName} expect ${propName} | ||
to be a valid Number > 0 or equal to false. ${prop} given.`); | ||
} | ||
return null; | ||
} | ||
); | ||
export const falseOrElement = withRequired( | ||
(props, propName, componentName) => { | ||
const prop = props[propName]; | ||
return null; | ||
}); | ||
if (prop !== false && !isValidElement(prop)) { | ||
return new Error(`${componentName} expect ${propName} | ||
export const falseOrElement = withRequired((props, propName, componentName) => { | ||
const prop = props[propName]; | ||
if (prop !== false && !isValidElement(prop)) { | ||
return new Error(`${componentName} expect ${propName} | ||
to be a valid react element or equal to false. ${prop} given.`); | ||
} | ||
} | ||
return null; | ||
} | ||
); | ||
return null; | ||
}); |
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
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
1036
494273
27
35
2249