rc-notification
Advanced tools
Comparing version 1.1.0 to 1.2.0
'use strict'; | ||
module.exports = require('./Notification'); | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _Notification = require('./Notification'); | ||
var _Notification2 = _interopRequireDefault(_Notification); | ||
exports['default'] = _Notification2['default']; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
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; }; | ||
@@ -13,2 +17,6 @@ | ||
var _reactDom = require('react-dom'); | ||
var _reactDom2 = _interopRequireDefault(_reactDom); | ||
var _rcAnimate = require('rc-animate'); | ||
@@ -20,69 +28,6 @@ | ||
var Notice = _react2['default'].createClass({ | ||
displayName: 'Notice', | ||
var _Notice = require('./Notice'); | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
onEnd: function onEnd() {}, | ||
duration: 1.5, | ||
style: { | ||
right: '50%' | ||
} | ||
}; | ||
}, | ||
var _Notice2 = _interopRequireDefault(_Notice); | ||
clearCloseTimer: function clearCloseTimer() { | ||
if (this.closeTimer) { | ||
clearTimeout(this.closeTimer); | ||
this.closeTimer = null; | ||
} | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
this.componentDidMount(); | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
var _this = this; | ||
this.clearCloseTimer(); | ||
if (this.props.duration) { | ||
this.closeTimer = setTimeout(function () { | ||
_this.close(); | ||
}, this.props.duration * 1000); | ||
} | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.clearCloseTimer(); | ||
}, | ||
close: function close() { | ||
this.clearCloseTimer(); | ||
this.props.onClose(); | ||
}, | ||
render: function render() { | ||
var _className; | ||
var props = this.props; | ||
var componentClass = props.prefixCls + '-notice'; | ||
var className = (_className = {}, _defineProperty(_className, '' + componentClass, 1), _defineProperty(_className, componentClass + '-closable', props.closable), _defineProperty(_className, props.className, !!props.className), _className); | ||
return _react2['default'].createElement( | ||
'div', | ||
{ className: (0, _rcUtil.classSet)(className), style: props.style }, | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: componentClass + '-content' }, | ||
this.props.children | ||
), | ||
props.closable ? _react2['default'].createElement( | ||
'a', | ||
{ tabIndex: "0", onClick: this.close, className: componentClass + '-close' }, | ||
_react2['default'].createElement('span', { className: componentClass + '-close-x' }) | ||
) : null | ||
); | ||
} | ||
}); | ||
var seed = 0; | ||
@@ -98,8 +43,2 @@ var now = Date.now(); | ||
getInitialState: function getInitialState() { | ||
return { | ||
notices: [] | ||
}; | ||
}, | ||
getDefaultProps: function getDefaultProps() { | ||
@@ -116,11 +55,17 @@ return { | ||
remove: function remove(key) { | ||
var notices = this.state.notices.filter(function (notice) { | ||
return notice.key !== key; | ||
}); | ||
this.setState({ | ||
notices: notices | ||
}); | ||
getInitialState: function getInitialState() { | ||
return { | ||
notices: [] | ||
}; | ||
}, | ||
getTransitionName: function getTransitionName() { | ||
var props = this.props; | ||
var transitionName = props.transitionName; | ||
if (!transitionName && props.animation) { | ||
transitionName = props.prefixCls + '-' + props.animation; | ||
} | ||
return transitionName; | ||
}, | ||
add: function add(notice) { | ||
@@ -138,20 +83,20 @@ var key = notice.key = notice.key || getUuid(); | ||
getTransitionName: function getTransitionName() { | ||
var props = this.props; | ||
var transitionName = props.transitionName; | ||
if (!transitionName && props.animation) { | ||
transitionName = props.prefixCls + '-' + props.animation; | ||
} | ||
return transitionName; | ||
remove: function remove(key) { | ||
var notices = this.state.notices.filter(function (notice) { | ||
return notice.key !== key; | ||
}); | ||
this.setState({ | ||
notices: notices | ||
}); | ||
}, | ||
render: function render() { | ||
var _className2, | ||
_this2 = this; | ||
var _className, | ||
_this = this; | ||
var props = this.props; | ||
var noticeNodes = this.state.notices.map(function (notice) { | ||
var onClose = (0, _rcUtil.createChainedFunction)(_this2.remove.bind(_this2, notice.key), notice.onClose); | ||
var onClose = (0, _rcUtil.createChainedFunction)(_this.remove.bind(_this, notice.key), notice.onClose); | ||
return _react2['default'].createElement( | ||
Notice, | ||
_Notice2['default'], | ||
_extends({ prefixCls: props.prefixCls }, notice, { onClose: onClose }), | ||
@@ -161,3 +106,3 @@ notice.content | ||
}); | ||
var className = (_className2 = {}, _defineProperty(_className2, props.prefixCls, 1), _defineProperty(_className2, props.className, !!props.className), _className2); | ||
var className = (_className = {}, _defineProperty(_className, props.prefixCls, 1), _defineProperty(_className, props.className, !!props.className), _className); | ||
return _react2['default'].createElement( | ||
@@ -175,7 +120,7 @@ 'div', | ||
Notification.newInstance = function (props) { | ||
props = props || {}; | ||
Notification.newInstance = function (properties) { | ||
var props = properties || {}; | ||
var div = document.createElement('div'); | ||
document.body.appendChild(div); | ||
var notification = _react2['default'].render(_react2['default'].createElement(Notification, props), div); | ||
var notification = _reactDom2['default'].render(_react2['default'].createElement(Notification, props), div); | ||
return { | ||
@@ -190,3 +135,3 @@ notice: function notice(noticeProps) { | ||
destroy: function destroy() { | ||
_react2['default'].unmountComponentAtNode(div); | ||
_reactDom2['default'].unmountComponentAtNode(div); | ||
document.body.removeChild(div); | ||
@@ -197,2 +142,3 @@ } | ||
module.exports = Notification; | ||
exports['default'] = Notification; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-notification", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "notification ui component for react", | ||
@@ -16,2 +16,6 @@ "keywords": [ | ||
], | ||
"files": [ | ||
"lib", | ||
"assets/*.css" | ||
], | ||
"repository": { | ||
@@ -31,12 +35,10 @@ "type": "git", | ||
"build": "rc-tools run build", | ||
"precommit": "rc-tools run precommit", | ||
"less": "rc-tools run less", | ||
"gh-pages": "rc-tools run gh-pages", | ||
"history": "rc-tools run history", | ||
"start": "node --harmony node_modules/.bin/rc-server", | ||
"publish": "rc-tools run tag", | ||
"start": "rc-server", | ||
"pub": "rc-tools run pub", | ||
"lint": "rc-tools run lint", | ||
"saucelabs": "node --harmony node_modules/.bin/rc-tools run saucelabs", | ||
"browser-test": "node --harmony node_modules/.bin/rc-tools run browser-test", | ||
"browser-test-cover": "node --harmony node_modules/.bin/rc-tools run browser-test-cover" | ||
"karma": "rc-tools run karma", | ||
"saucelabs": "rc-tools run saucelabs", | ||
"browser-test": "rc-tools run browser-test", | ||
"browser-test-cover": "rc-tools run browser-test-cover" | ||
}, | ||
@@ -47,12 +49,14 @@ "devDependencies": { | ||
"rc-server": "3.x", | ||
"rc-tools": "3.x", | ||
"react": "~0.13.2" | ||
"rc-tools": "4.x", | ||
"react": "~0.14.0", | ||
"react-addons-test-utils": "~0.14.1", | ||
"react-dom": "~0.14.0" | ||
}, | ||
"precommit": [ | ||
"precommit" | ||
"pre-commit": [ | ||
"lint" | ||
], | ||
"dependencies": { | ||
"rc-animate": "1.x", | ||
"rc-animate": "2.x", | ||
"rc-util": "2.x" | ||
} | ||
} |
# rc-notification | ||
--- | ||
notification ui component for react. | ||
React Notification UI Component | ||
@@ -12,6 +12,3 @@ [![NPM version][npm-image]][npm-url] | ||
[![npm download][download-image]][download-url] | ||
[![Sauce Test Status](https://saucelabs.com/buildstatus/rc-notification)](https://saucelabs.com/u/rc-notification) | ||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/rc-notification.svg)](https://saucelabs.com/u/rc-notification) | ||
[npm-image]: http://img.shields.io/npm/v/rc-notification.svg?style=flat-square | ||
@@ -18,0 +15,0 @@ [npm-url]: http://npmjs.org/package/rc-notification |
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
14987
7
298
7
163
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedraf@3.4.1(transitive)
+ Addedrc-animate@2.11.1(transitive)
+ Addedrc-util@4.21.1(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedreact-lifecycles-compat@3.0.4(transitive)
+ Addedshallowequal@1.1.0(transitive)
- Removedrc-animate@1.3.0(transitive)
Updatedrc-animate@2.x