UNPKG

tdesign-vue

Version:
140 lines (136 loc) 5.27 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { isFunction } from 'lodash-es'; import { InfoCircleFilledIcon, CheckCircleFilledIcon, CloseIcon } from 'tdesign-icons-vue'; import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js'; import props from './props.js'; import { getClassPrefixMixins, getGlobalIconMixins } from '../config-provider/config-receiver.js'; import mixins from '../utils/mixins.js'; import '@babel/runtime/helpers/readOnlyError'; import '@babel/runtime/helpers/typeof'; import 'vue'; 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-d2f11e9e.js'; import '../_chunks/dep-05dc6583.js'; import 'dayjs'; import '../_chunks/dep-62386ed0.js'; import '../config-provider/type.js'; import '../_common/js/global-config/t.js'; import '@babel/runtime/helpers/slicedToArray'; 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("notification"); var _Notification = mixins(classPrefixMixins, getGlobalIconMixins()).extend({ name: "TNotification", props: _objectSpread({}, props), data: function data() { return { timer: null }; }, created: function created() { this.duration && this.setTimer(); }, methods: { setTimer: function setTimer() { var _this = this; if (!this.duration) { return; } this.timer = Number(setTimeout(function () { _this.clearTimer(); _this.$emit("duration-end"); if (_this.onDurationEnd) { _this.onDurationEnd(); } }, this.duration)); }, clearTimer: function clearTimer() { this.duration && clearTimeout(this.timer); }, close: function close(e) { this.$emit("close-btn-click", { e: e }); if (this.onCloseBtnClick) { this.onCloseBtnClick({ e: e }); } }, renderIcon: function renderIcon(h) { var icon; if (this.icon === false) return null; if (isFunction(this.icon)) { icon = this.icon(h); } else if (this.$scopedSlots.icon) { icon = this.$scopedSlots.icon(null); } else if (this.theme) { var _this$useGlobalIcon = this.useGlobalIcon({ InfoCircleFilledIcon: InfoCircleFilledIcon, CheckCircleFilledIcon: CheckCircleFilledIcon }), InfoCircleFilledIcon$1 = _this$useGlobalIcon.InfoCircleFilledIcon, CheckCircleFilledIcon$1 = _this$useGlobalIcon.CheckCircleFilledIcon; var iconType = this.theme === "success" ? h(CheckCircleFilledIcon$1, { "class": "".concat(this.classPrefix, "-is-").concat(this.theme) }) : h(InfoCircleFilledIcon$1, { "class": "".concat(this.classPrefix, "-is-").concat(this.theme) }); icon = h("div", { "class": "".concat(this.componentName, "__icon") }, [iconType]); } return icon; }, renderClose: function renderClose() { var h = this.$createElement; var _this$useGlobalIcon2 = this.useGlobalIcon({ CloseIcon: CloseIcon }), CloseIcon$1 = _this$useGlobalIcon2.CloseIcon; var defaultClose = h(CloseIcon$1); return h("span", { "class": "".concat(this.classPrefix, "-message__close"), "on": { "click": this.close } }, [renderTNodeJSX(this, "closeBtn", defaultClose)]); }, renderContent: function renderContent$1() { var h = this.$createElement; return h("div", { "class": "".concat(this.componentName, "__content") }, [renderContent(this, "default", "content")]); } }, render: function render(h) { var icon = this.renderIcon(h); var close = this.renderClose(); var content = this.renderContent(); var footer = renderTNodeJSX(this, "footer"); var title = renderTNodeJSX(this, "title"); return h("div", { "class": "".concat(this.componentName), "on": { "mouseenter": this.clearTimer, "mouseleave": this.setTimer } }, [icon, h("div", { "class": "".concat(this.componentName, "__main") }, [h("div", { "class": "".concat(this.componentName, "__title__wrap") }, [h("span", { "class": "".concat(this.componentName, "__title") }, [title]), close]), content, footer])]); } }); export { _Notification as default }; //# sourceMappingURL=notification.js.map