hy-checkbox
Version:
checkbox & radio ui components for react
132 lines (108 loc) • 5.48 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames2 = require('classnames');
var _classnames3 = _interopRequireDefault(_classnames2);
require('./notificationRoot.less');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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) : subClass.__proto__ = superClass; }
var Notice = function (_React$Component) {
_inherits(Notice, _React$Component);
function Notice() {
var _ref;
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, (_ref = Notice.__proto__ || Object.getPrototypeOf(Notice)).call.apply(_ref, [this].concat(args))), _this), _this.clearCloseTimer = function () {
if (_this.closeTimer) {
clearTimeout(_this.closeTimer);
_this.closeTimer = null;
}
}, _this.close = function () {
_this.clearCloseTimer();
_this.props.onClose();
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Notice, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
if (this.props.duration) {
this.closeTimer = setTimeout(function () {
_this2.close();
}, this.props.duration * 1000);
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.clearCloseTimer();
}
}, {
key: 'render',
value: function render() {
var props = this.props;
var prefixCls = props.prefixCls,
iconNode = props.iconNode,
warning = props.warning,
duration = props.duration,
closable = props.closable;
var keyClass = props.ClassName;
// console.log("关闭时是-----------",duration);
return _react2.default.createElement(
'dd',
null,
_react2.default.createElement(
'div',
{ className: (0, _classnames3.default)(prefixCls + '-ui-notification', _defineProperty({}, '' + keyClass, true)) },
_react2.default.createElement(
'div',
{ className: (0, _classnames3.default)(prefixCls + '-notification-form') },
_react2.default.createElement('i', { className: (0, _classnames3.default)('iconfont ' + iconNode) }),
_react2.default.createElement(
'h3',
{ className: (0, _classnames3.default)(prefixCls + '-notification-title') },
props.title
),
_react2.default.createElement(
'div',
{ className: (0, _classnames3.default)(prefixCls + '-notification-content') },
props.content
),
_react2.default.createElement('div', { className: (0, _classnames3.default)(prefixCls + '-notification-progress'), style: { animationDuration: duration + 's' } })
),
closable ? _react2.default.createElement(
'a',
{ tabIndex: '0', onClick: this.close, className: prefixCls + '-notification-close' },
_react2.default.createElement(
'span',
{ className: prefixCls + '-close-x' },
_react2.default.createElement('i', { className: 'iconfont icon-error' })
)
) : null
)
);
}
}]);
return Notice;
}(_react2.default.Component);
Notice.propTypes = {
children: _react2.default.PropTypes.any,
onClose: _react2.default.PropTypes.func
};
Notice.defaultProps = {
prefixCls: 'ult',
onClose: function onClose() {},
duration: 3,
closable: true
};
exports.default = Notice;
;