diff --git a/dist/react-notifications.css b/dist/react-notifications.css index 8467214..3772b68 100644 --- a/dist/react-notifications.css +++ b/dist/react-notifications.css @@ -1 +1 @@ -@charset "UTF-8";@font-face{font-family:Notification;src:url(fonts/notification.eot?s3g3t9);src:url(fonts/notification.eot?#iefixs3g3t9) format("embedded-opentype"),url(fonts/notification.woff?s3g3t9) format("woff"),url(fonts/notification.ttf?s3g3t9) format("truetype"),url(fonts/notification.svg?s3g3t9#notification) format("svg");font-weight:400;font-style:normal}.notification-container{position:fixed;top:0;right:0;z-index:999999;width:320px;padding:0 15px;max-height:calc(100% - 30px);overflow-x:hidden;overflow-y:auto}.notification,.notification-container{-webkit-box-sizing:border-box;box-sizing:border-box}.notification{padding:15px 15px 15px 58px;border-radius:2px;color:#fff;background-color:#ccc;-webkit-box-shadow:0 0 12px #999;box-shadow:0 0 12px #999;cursor:pointer;font-size:1em;line-height:1.2em;position:relative;opacity:.9;margin-top:15px}.notification .title{font-size:1em;line-height:1.2em;font-weight:700;margin:0 0 5px}.notification:focus,.notification:hover{opacity:1}.notification-enter{visibility:hidden;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.notification-enter.notification-enter-active{-webkit-transition:all .4s;transition:all .4s}.notification-enter.notification-enter-active,.notification-leave{visibility:visible;-webkit-transform:translateZ(0);transform:translateZ(0)}.notification-leave.notification-leave-active{visibility:hidden;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);-webkit-transition:all .4s;transition:all .4s}.notification:before{position:absolute;top:50%;left:15px;margin-top:-14px;display:block;font-family:Notification;width:28px;height:28px;font-size:28px;text-align:center;line-height:28px}.notification-info{background-color:#2f96b4}.notification-info:before{content:""}.notification-success{background-color:#51a351}.notification-success:before{content:""}.notification-warning{background-color:#f89406}.notification-warning:before{content:""}.notification-error{background-color:#bd362f}.notification-error:before{content:""} \ No newline at end of file +@charset "UTF-8";@font-face{font-family:Notification;src:url(fonts/notification.eot?s3g3t9);src:url(fonts/notification.eot?#iefixs3g3t9) format("embedded-opentype"),url(fonts/notification.woff?s3g3t9) format("woff"),url(fonts/notification.ttf?s3g3t9) format("truetype"),url(fonts/notification.svg?s3g3t9#notification) format("svg");font-weight:400;font-style:normal}.notification-container{position:fixed;top:0;right:0;z-index:999999;width:320px;padding:0 15px;max-height:calc(100% - 30px);overflow-x:hidden;overflow-y:auto}.notification,.notification-container{-webkit-box-sizing:border-box;box-sizing:border-box}.notification{padding:15px 15px 15px 58px;border-radius:2px;color:#fff;background-color:#ccc;-webkit-box-shadow:0 0 12px #999;box-shadow:0 0 12px #999;cursor:pointer;font-size:1em;line-height:1.2em;position:relative;opacity:.9;margin-top:15px}.notification .title{font-size:1em;line-height:1.2em;font-weight:700;margin:0 0 5px}.notification:focus,.notification:hover{opacity:1}.notification-enter{visibility:hidden;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.notification-enter.notification-enter-active{-webkit-transition:all .4s;transition:all .4s}.notification-enter.notification-enter-active,.notification-exit{visibility:visible;-webkit-transform:translateZ(0);transform:translateZ(0)}.notification-exit.notification-exit-active{visibility:hidden;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);-webkit-transition:all .4s;transition:all .4s}.notification:before{position:absolute;top:50%;left:15px;margin-top:-14px;display:block;font-family:Notification;width:28px;height:28px;font-size:28px;text-align:center;line-height:28px}.notification-info{background-color:#2f96b4}.notification-info:before{content:""}.notification-success{background-color:#51a351}.notification-success:before{content:""}.notification-warning{background-color:#f89406}.notification-warning:before{content:""}.notification-error{background-color:#bd362f}.notification-error:before{content:""} \ No newline at end of file diff --git a/dist/react-notifications.js b/dist/react-notifications.js index d470739..1c472a9 100644 --- a/dist/react-notifications.js +++ b/dist/react-notifications.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("prop-types"),require("react"),require("react-transition-group")):"function"==typeof define&&define.amd?define(["prop-types","react","react-transition-group"],t):"object"==typeof exports?exports.ReactNotifications=t(require("prop-types"),require("react"),require("react-transition-group")):e.ReactNotifications=t(e.PropTypes,e.React,e.ReactTransitionGroup)}(this,function(e,t,n){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},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=7)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";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 o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-- >0;)if(n[u]===t||n[u].listener&&n[u].listener===t){i=u;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t){e.exports=n}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("prop-types"),require("react"),require("react-transition-group")):"function"==typeof define&&define.amd?define(["prop-types","react","react-transition-group"],t):"object"==typeof exports?exports.ReactNotifications=t(require("prop-types"),require("react"),require("react-transition-group")):e.ReactNotifications=t(e.PropTypes,e.React,e.ReactTransitionGroup)}(this,function(e,t,n){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},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=7)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";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 o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-- >0;)if(n[u]===t||n[u].listener&&n[u].listener===t){i=u;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t){e.exports=n}])}); \ No newline at end of file diff --git a/example/src/app.js b/example/src/app.js index b3a48b7..c9ac779 100644 --- a/example/src/app.js +++ b/example/src/app.js @@ -1,7 +1,7 @@ import 'babel-polyfill'; import React from 'react'; -import ReactDOM from 'react-dom'; +import { render } from 'react-dom'; import App from 'components/App'; import 'bootstrap/dist/css/bootstrap.css'; @@ -9,7 +9,12 @@ import 'react-notifications/src/notifications.scss'; import 'assets/styles/app.scss'; const run = () => { - ReactDOM.render(, document.getElementById('app')); + render( + + + , + document.getElementById('app') + ); }; window.addEventListener('DOMContentLoaded', run); diff --git a/example/webpack.config.babel.js b/example/webpack.config.babel.js index 19ba43f..155060d 100644 --- a/example/webpack.config.babel.js +++ b/example/webpack.config.babel.js @@ -23,7 +23,7 @@ const sassLoader = { } }; -const hmr = HOT ? ['webpack-hot-middleware/client?reload=true'] : []; +const hmr = HOT ? ['webpack-hot-middleware/client?reload=true', 'react-hot-loader/patch'] : []; const webpackConfig = { entry: { @@ -61,7 +61,7 @@ const webpackConfig = { { test: /\.(js|jsx)$/, exclude: /node_modules/, - use: ['react-hot-loader', 'babel-loader'] + use: ['babel-loader'] }, { test: /\.css$/, diff --git a/lib/NotificationContainer.js b/lib/NotificationContainer.js index c9e0865..39abe76 100644 --- a/lib/NotificationContainer.js +++ b/lib/NotificationContainer.js @@ -46,7 +46,7 @@ var NotificationContainer = function (_React$Component) { return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = NotificationContainer.__proto__ || Object.getPrototypeOf(NotificationContainer)).call.apply(_ref, [this].concat(args))), _this), _this.state = { notifications: [] - }, _this.componentWillMount = function () { + }, _this.componentDidMount = function () { _NotificationManager2.default.addChangeListener(_this.handleStoreChange); }, _this.componentWillUnmount = function () { _NotificationManager2.default.removeChangeListener(_this.handleStoreChange); @@ -65,11 +65,11 @@ var NotificationContainer = function (_React$Component) { var notifications = this.state.notifications; var _props = this.props, enterTimeout = _props.enterTimeout, - leaveTimeout = _props.leaveTimeout; + exitTimeout = _props.exitTimeout; return _react2.default.createElement(_Notifications2.default, { enterTimeout: enterTimeout, - leaveTimeout: leaveTimeout, + exitTimeout: exitTimeout, notifications: notifications, onRequestHide: this.handleRequestHide }); @@ -81,11 +81,11 @@ var NotificationContainer = function (_React$Component) { NotificationContainer.propTypes = { enterTimeout: _propTypes2.default.number, - leaveTimeout: _propTypes2.default.number + exitTimeout: _propTypes2.default.number }; NotificationContainer.defaultProps = { enterTimeout: 400, - leaveTimeout: 400 + exitTimeout: 400 }; exports.default = NotificationContainer; module.exports = exports['default']; \ No newline at end of file diff --git a/lib/Notifications.js b/lib/Notifications.js index e8569d4..3de8d74 100644 --- a/lib/Notifications.js +++ b/lib/Notifications.js @@ -65,7 +65,7 @@ var Notifications = function (_React$Component) { var _props = this.props, notifications = _props.notifications, enterTimeout = _props.enterTimeout, - leaveTimeout = _props.leaveTimeout; + exitTimeout = _props.exitTimeout; var className = (0, _classnames2.default)('notification-container', { 'notification-container-empty': notifications.length === 0 @@ -74,23 +74,26 @@ var Notifications = function (_React$Component) { 'div', { className: className }, _react2.default.createElement( - _reactTransitionGroup.CSSTransitionGroup, - { - transitionName: 'notification', - transitionEnterTimeout: enterTimeout, - transitionLeaveTimeout: leaveTimeout - }, + _reactTransitionGroup.TransitionGroup, + null, notifications.map(function (notification) { var key = notification.id || new Date().getTime(); - return _react2.default.createElement(_Notification2.default, { - key: key, - type: notification.type, - title: notification.title, - message: notification.message, - timeOut: notification.timeOut, - onClick: notification.onClick, - onRequestHide: _this2.handleRequestHide(notification) - }); + return _react2.default.createElement( + _reactTransitionGroup.CSSTransition, + { + key: key, + classNames: 'notification', + timeout: { enter: enterTimeout, exit: exitTimeout } + }, + _react2.default.createElement(_Notification2.default, { + type: notification.type, + title: notification.title, + message: notification.message, + timeOut: notification.timeOut, + onClick: notification.onClick, + onRequestHide: _this2.handleRequestHide(notification) + }) + ); }) ) ); @@ -104,13 +107,13 @@ Notifications.propTypes = { notifications: _propTypes2.default.array.isRequired, onRequestHide: _propTypes2.default.func, enterTimeout: _propTypes2.default.number, - leaveTimeout: _propTypes2.default.number + exitTimeout: _propTypes2.default.number }; Notifications.defaultProps = { notifications: [], onRequestHide: function onRequestHide() {}, enterTimeout: 400, - leaveTimeout: 400 + exitTimeout: 400 }; exports.default = Notifications; module.exports = exports['default']; \ No newline at end of file diff --git a/lib/notifications.css b/lib/notifications.css index aa4e28f..9661215 100644 --- a/lib/notifications.css +++ b/lib/notifications.css @@ -57,12 +57,12 @@ transition: all 0.4s; } -.notification-leave { +.notification-exit { visibility: visible; transform: translate3d(0, 0, 0); } -.notification-leave.notification-leave-active { +.notification-exit.notification-exit-active { visibility: hidden; transform: translate3d(100%, 0, 0); transition: all 0.4s; diff --git a/package.json b/package.json index 31b16d1..f52a8a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-notifications", - "version": "1.4.3", + "version": "2.0.0", "description": "Notification component for ReactJS", "main": "lib/index.js", "scripts": { @@ -18,7 +18,7 @@ "dependencies": { "classnames": "^2.1.1", "prop-types": "^15.5.10", - "react-transition-group": "^1.2.0" + "react-transition-group": "^2.5.2" }, "devDependencies": { "autoprefixer": "^7.0.1", @@ -58,9 +58,9 @@ "http-proxy": "^1.16.2", "node-sass": "^4.5.0", "postcss-loader": "^2.0.5", - "react": "^15.5.4", - "react-dom": "^15.5.4", - "react-hot-loader": "^1.3.1", + "react": "^16.7.0", + "react-dom": "^16.7.0", + "react-hot-loader": "^4.6.3", "react-router-dom": "^4.1.1", "run-sequence": "^1.2.2", "sass-loader": "^6.0.1", diff --git a/src/NotificationContainer.js b/src/NotificationContainer.js index 431d11b..c681b1a 100644 --- a/src/NotificationContainer.js +++ b/src/NotificationContainer.js @@ -6,19 +6,19 @@ import Notifications from './Notifications'; class NotificationContainer extends React.Component { static propTypes = { enterTimeout: PropTypes.number, - leaveTimeout: PropTypes.number + exitTimeout: PropTypes.number }; static defaultProps = { enterTimeout: 400, - leaveTimeout: 400 + exitTimeout: 400 }; state = { notifications: [] }; - componentWillMount = () => { + componentDidMount = () => { NotificationManager.addChangeListener(this.handleStoreChange); }; @@ -38,11 +38,11 @@ class NotificationContainer extends React.Component { render() { const { notifications } = this.state; - const { enterTimeout, leaveTimeout } = this.props; + const { enterTimeout, exitTimeout } = this.props; return ( diff --git a/src/Notifications.js b/src/Notifications.js index eb77d3d..79cde7e 100644 --- a/src/Notifications.js +++ b/src/Notifications.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { CSSTransitionGroup } from 'react-transition-group'; +import { TransitionGroup, CSSTransition } from 'react-transition-group'; import classnames from 'classnames'; import Notification from './Notification'; @@ -9,7 +9,7 @@ class Notifications extends React.Component { notifications: PropTypes.array.isRequired, onRequestHide: PropTypes.func, enterTimeout: PropTypes.number, - leaveTimeout: PropTypes.number + exitTimeout: PropTypes.number }; static defaultProps = { @@ -17,7 +17,7 @@ class Notifications extends React.Component { onRequestHide: () => { }, enterTimeout: 400, - leaveTimeout: 400 + exitTimeout: 400 }; handleRequestHide = notification => () => { @@ -28,32 +28,33 @@ class Notifications extends React.Component { }; render() { - const { notifications, enterTimeout, leaveTimeout } = this.props; + const { notifications, enterTimeout, exitTimeout } = this.props; const className = classnames('notification-container', { 'notification-container-empty': notifications.length === 0 }); return (
- + {notifications.map((notification) => { const key = notification.id || new Date().getTime(); return ( - + classNames="notification" + timeout={{ enter: enterTimeout, exit: exitTimeout }} + > + + ); })} - +
); } diff --git a/src/notifications.scss b/src/notifications.scss index eb601a8..232061f 100644 --- a/src/notifications.scss +++ b/src/notifications.scss @@ -59,12 +59,12 @@ transition: all $react-notifications-transition-time; } -.notification-leave { +.notification-exit { visibility: visible; transform: translate3d(0, 0, 0); } -.notification-leave.notification-leave-active { +.notification-exit.notification-exit-active { visibility: hidden; transform: translate3d(100%, 0, 0); transition: all $react-notifications-transition-time;