rc-notification
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -15,49 +15,56 @@ 'use strict'; | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var Notice = _react2["default"].createClass({ | ||
displayName: 'Notice', | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
propTypes: { | ||
duration: _react.PropTypes.number, | ||
onClose: _react.PropTypes.func, | ||
children: _react.PropTypes.any | ||
}, | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
onEnd: function onEnd() {}, | ||
onClose: function onClose() {}, | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
duration: 1.5, | ||
style: { | ||
right: '50%' | ||
var Notice = function (_Component) { | ||
_inherits(Notice, _Component); | ||
function Notice() { | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, Notice); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.clearCloseTimer = function () { | ||
if (_this.closeTimer) { | ||
clearTimeout(_this.closeTimer); | ||
_this.closeTimer = null; | ||
} | ||
}; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
var _this = this; | ||
}, _this.close = function () { | ||
_this.clearCloseTimer(); | ||
_this.props.onClose(); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
Notice.prototype.componentDidMount = function componentDidMount() { | ||
var _this2 = this; | ||
if (this.props.duration) { | ||
this.closeTimer = setTimeout(function () { | ||
_this.close(); | ||
_this2.close(); | ||
}, this.props.duration * 1000); | ||
} | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
}; | ||
Notice.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this.clearCloseTimer(); | ||
}, | ||
clearCloseTimer: function clearCloseTimer() { | ||
if (this.closeTimer) { | ||
clearTimeout(this.closeTimer); | ||
this.closeTimer = null; | ||
} | ||
}, | ||
close: function close() { | ||
this.clearCloseTimer(); | ||
this.props.onClose(); | ||
}, | ||
render: function render() { | ||
}; | ||
Notice.prototype.render = function render() { | ||
var _className; | ||
@@ -82,6 +89,22 @@ | ||
); | ||
}; | ||
return Notice; | ||
}(_react.Component); | ||
Notice.propTypes = { | ||
duration: _propTypes2["default"].number, | ||
onClose: _propTypes2["default"].func, | ||
children: _propTypes2["default"].any | ||
}; | ||
Notice.defaultProps = { | ||
onEnd: function onEnd() {}, | ||
onClose: function onClose() {}, | ||
duration: 1.5, | ||
style: { | ||
right: '50%' | ||
} | ||
}); | ||
}; | ||
exports["default"] = Notice; | ||
module.exports = exports['default']; |
@@ -13,2 +13,6 @@ 'use strict'; | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _reactDom = require('react-dom'); | ||
@@ -38,4 +42,12 @@ | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
var seed = 0; | ||
@@ -48,28 +60,40 @@ var now = Date.now(); | ||
var Notification = _react2["default"].createClass({ | ||
displayName: 'Notification', | ||
var Notification = function (_Component) { | ||
_inherits(Notification, _Component); | ||
propTypes: { | ||
prefixCls: _react.PropTypes.string, | ||
transitionName: _react.PropTypes.string, | ||
animation: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object]), | ||
style: _react.PropTypes.object | ||
}, | ||
function Notification() { | ||
var _temp, _this, _ret; | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
prefixCls: 'rc-notification', | ||
animation: 'fade', | ||
style: { | ||
top: 65, | ||
left: '50%' | ||
} | ||
}; | ||
}, | ||
getInitialState: function getInitialState() { | ||
return { | ||
_classCallCheck(this, Notification); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = { | ||
notices: [] | ||
}; | ||
}, | ||
getTransitionName: function getTransitionName() { | ||
}, _this.add = function (notice) { | ||
var key = notice.key = notice.key || getUuid(); | ||
_this.setState(function (previousState) { | ||
var notices = previousState.notices; | ||
if (!notices.filter(function (v) { | ||
return v.key === key; | ||
}).length) { | ||
return { | ||
notices: notices.concat(notice) | ||
}; | ||
} | ||
}); | ||
}, _this.remove = function (key) { | ||
_this.setState(function (previousState) { | ||
return { | ||
notices: previousState.notices.filter(function (notice) { | ||
return notice.key !== key; | ||
}) | ||
}; | ||
}); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
Notification.prototype.getTransitionName = function getTransitionName() { | ||
var props = this.props; | ||
@@ -81,27 +105,6 @@ var transitionName = props.transitionName; | ||
return transitionName; | ||
}, | ||
add: function add(notice) { | ||
var key = notice.key = notice.key || getUuid(); | ||
this.setState(function (previousState) { | ||
var notices = previousState.notices; | ||
if (!notices.filter(function (v) { | ||
return v.key === key; | ||
}).length) { | ||
return { | ||
notices: notices.concat(notice) | ||
}; | ||
} | ||
}); | ||
}, | ||
remove: function remove(key) { | ||
this.setState(function (previousState) { | ||
return { | ||
notices: previousState.notices.filter(function (notice) { | ||
return notice.key !== key; | ||
}) | ||
}; | ||
}); | ||
}, | ||
render: function render() { | ||
var _this = this, | ||
}; | ||
Notification.prototype.render = function render() { | ||
var _this2 = this, | ||
_className; | ||
@@ -111,3 +114,3 @@ | ||
var noticeNodes = this.state.notices.map(function (notice) { | ||
var onClose = (0, _createChainedFunction2["default"])(_this.remove.bind(_this, notice.key), notice.onClose); | ||
var onClose = (0, _createChainedFunction2["default"])(_this2.remove.bind(_this2, notice.key), notice.onClose); | ||
return _react2["default"].createElement( | ||
@@ -133,5 +136,23 @@ _Notice2["default"], | ||
); | ||
}; | ||
return Notification; | ||
}(_react.Component); | ||
Notification.propTypes = { | ||
prefixCls: _propTypes2["default"].string, | ||
transitionName: _propTypes2["default"].string, | ||
animation: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].object]), | ||
style: _propTypes2["default"].object | ||
}; | ||
Notification.defaultProps = { | ||
prefixCls: 'rc-notification', | ||
animation: 'fade', | ||
style: { | ||
top: 65, | ||
left: '50%' | ||
} | ||
}); | ||
}; | ||
Notification.newInstance = function newNotificationInstance(properties) { | ||
@@ -138,0 +159,0 @@ var _ref = properties || {}, |
{ | ||
"name": "rc-notification", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "notification ui component for react", | ||
@@ -49,3 +49,2 @@ "keywords": [ | ||
"react": "15.x", | ||
"react-addons-test-utils": "15.x", | ||
"react-dom": "15.x" | ||
@@ -58,4 +57,5 @@ }, | ||
"classnames": "2.x", | ||
"prop-types": "^15.5.8", | ||
"rc-animate": "2.x", | ||
"rc-util": "4.0.2" | ||
"rc-util": "4.x" | ||
}, | ||
@@ -62,0 +62,0 @@ "pre-commit": [ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20782
5
343
4
+ Addedprop-types@^15.5.8
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.keys@3.1.2(transitive)
- Removedrc-util@4.0.2(transitive)
- Removedshallowequal@0.2.2(transitive)
Updatedrc-util@4.x