zent
Version:
一套前端设计语言和基于React的实现
38 lines (37 loc) • 1.88 kB
JavaScript
import { __assign, __extends, __rest } from "tslib";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Component } from 'react';
import { CSSTransition } from 'react-transition-group';
import Portal from '../portal';
import Icon from '../icon';
var NotifyTransition = function (_a) {
var children = _a.children, props = __rest(_a, ["children"]);
return (_jsx(CSSTransition, __assign({}, props, { timeout: 800, classNames: "notify" }, { children: children }), void 0));
};
var ICON_TYPE = {
success: 'check-circle',
warn: 'warning',
error: 'close-circle',
info: 'info-circle',
};
var NotifyContent = (function (_super) {
__extends(NotifyContent, _super);
function NotifyContent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.onExited = function () {
_this.props.close();
};
return _this;
}
NotifyContent.prototype.render = function () {
var _a = this.props, text = _a.text, status = _a.status, selector = _a.selector, isIn = _a.isIn;
return (_jsx(Portal, __assign({ selector: selector }, { children: _jsx(NotifyTransition, __assign({ appear: true, unmountOnExit: true, in: isIn, onExited: this.onExited }, { children: _jsx("div", __assign({ className: "zent-notify", "data-zv": '10.0.17' }, { children: _jsxs("div", __assign({ className: "zent-notify-content zent-notify-content-" + status, "data-zv": '10.0.17' }, { children: [_jsx(Icon, { className: "zent-notify-content-icon", type: ICON_TYPE[status] }, void 0), _jsx("div", __assign({ "data-zv": '10.0.17' }, { children: text }), void 0)] }), void 0) }), void 0) }), void 0) }), void 0));
};
NotifyContent.defaultProps = {
text: '',
status: '',
className: '',
};
return NotifyContent;
}(Component));
export default NotifyContent;