UNPKG

tdesign-vue

Version:
174 lines (170 loc) 6.83 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { CloseIcon, InfoCircleFilledIcon, CheckCircleFilledIcon, ErrorCircleFilledIcon, HelpCircleFilledIcon } from 'tdesign-icons-vue'; import { Loading } from '../loading/index.js'; import { THEME_LIST } from './const.js'; import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js'; import props from './props.js'; import { fadeIn, fadeOut } from './animation.js'; import { getClassPrefixMixins, getGlobalIconMixins } from '../config-provider/config-receiver.js'; import mixins from '../utils/mixins.js'; import '../loading/directive.js'; import 'lodash-es'; import '../loading/plugin.js'; import 'vue'; import '../loading/loading.js'; import '../loading/icon/gradient.js'; import '../_common/js/loading/circle-adapter.js'; import '../_common/js/utils/setStyle.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/slicedToArray'; import '../utils/dom.js'; import 'raf'; import '../utils/easing.js'; import '../utils/transfer-dom.js'; import '../loading/props.js'; import '@babel/runtime/helpers/readOnlyError'; import '@babel/runtime/helpers/typeof'; import '@vue/composition-api'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-c44a474d.js'; import '../_chunks/dep-d639fbd7.js'; import 'dayjs'; import '../_chunks/dep-3c66615e.js'; import '../config-provider/type.js'; import '../_common/js/global-config/t.js'; import '../config.js'; import '../utils/withInstall.js'; import './style/index.js'; import '../loading/type.js'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var classPrefixMixins = getClassPrefixMixins("message"); var _Message = mixins(classPrefixMixins, getGlobalIconMixins()).extend({ name: "TMessage", props: _objectSpread(_objectSpread({}, props), {}, { placement: String }), data: function data() { return { timer: null }; }, computed: { classes: function classes() { var _this = this; var status = {}; THEME_LIST.forEach(function (t) { status["".concat(_this.classPrefix, "-is-").concat(t)] = _this.theme === t; }); return [this.componentName, status, _defineProperty({}, "".concat(this.classPrefix, "-is-closable"), this.closeBtn || this.$scopedSlots.closeBtn)]; } }, created: function created() { this.duration && this.setTimer(); }, mounted: function mounted() { var msgDom = this.$refs.msg; fadeIn(msgDom, this.$props.placement); }, methods: { setTimer: function setTimer() { var _this2 = this; if (!this.duration) { return; } this.timer = Number(setTimeout(function () { var _this2$onDurationEnd, _this2$onClose; _this2.clearTimer(); var msgDom = _this2.$refs.msg; fadeOut(msgDom, _this2.$props.placement, function () { _this2.$emit("duration-end"); _this2.$emit("close"); }); (_this2$onDurationEnd = _this2.onDurationEnd) === null || _this2$onDurationEnd === void 0 || _this2$onDurationEnd.call(_this2); (_this2$onClose = _this2.onClose) === null || _this2$onClose === void 0 || _this2$onClose.call(_this2, { trigger: "duration-end" }); }, this.duration)); }, clearTimer: function clearTimer() { this.duration && clearTimeout(this.timer); }, close: function close(e) { var _this$onCloseBtnClick, _this$onClose; this.$emit("close-btn-click", { e: e }); this.$emit("close"); (_this$onCloseBtnClick = this.onCloseBtnClick) === null || _this$onCloseBtnClick === void 0 || _this$onCloseBtnClick.call(this, { e: e }); (_this$onClose = this.onClose) === null || _this$onClose === void 0 || _this$onClose.call(this, { trigger: "close-click", e: e }); }, renderClose: function renderClose() { var h = this.$createElement; var _this$useGlobalIcon = this.useGlobalIcon({ CloseIcon: CloseIcon }), CloseIcon$1 = _this$useGlobalIcon.CloseIcon; var defaultClose = h(CloseIcon$1); return h("span", { "class": "".concat(this.componentName, "__close"), "on": { "click": this.close } }, [renderTNodeJSX(this, "closeBtn", defaultClose)]); }, renderIcon: function renderIcon() { var h = this.$createElement; if (this.icon === false) return; if (typeof this.icon === "function") return this.icon(this.$createElement); if (this.$scopedSlots.icon) { return this.$scopedSlots.icon(null); } var _this$useGlobalIcon2 = this.useGlobalIcon({ InfoCircleFilledIcon: InfoCircleFilledIcon, CheckCircleFilledIcon: CheckCircleFilledIcon, ErrorCircleFilledIcon: ErrorCircleFilledIcon, HelpCircleFilledIcon: HelpCircleFilledIcon }), InfoCircleFilledIcon$1 = _this$useGlobalIcon2.InfoCircleFilledIcon, CheckCircleFilledIcon$1 = _this$useGlobalIcon2.CheckCircleFilledIcon, ErrorCircleFilledIcon$1 = _this$useGlobalIcon2.ErrorCircleFilledIcon, HelpCircleFilledIcon$1 = _this$useGlobalIcon2.HelpCircleFilledIcon; var component = { info: InfoCircleFilledIcon$1, success: CheckCircleFilledIcon$1, warning: ErrorCircleFilledIcon$1, error: ErrorCircleFilledIcon$1, question: HelpCircleFilledIcon$1, loading: Loading }[this.theme]; return h(component); } }, render: function render() { var h = arguments[0]; return h("div", { "ref": "msg", "class": this.classes, "on": { "mouseenter": this.clearTimer, "mouseleave": this.setTimer } }, [this.renderIcon(), renderContent(this, "default", "content"), this.renderClose()]); } }); export { _Message as default }; //# sourceMappingURL=message.js.map