@arco-design/web-vue
Version:
Arco Design Vue 2.0: A Vue.js 3 UI Library
144 lines (143 loc) • 5.12 kB
JavaScript
;
var vue = require("vue");
var globalConfig = require("../_utils/global-config.js");
var iconHover = require("../_components/icon-hover.js");
var index$4 = require("../icon/icon-close/index.js");
var index = require("../icon/icon-info-circle-fill/index.js");
var index$1 = require("../icon/icon-check-circle-fill/index.js");
var index$2 = require("../icon/icon-exclamation-circle-fill/index.js");
var index$3 = require("../icon/icon-close-circle-fill/index.js");
var index$5 = require("../icon/icon-loading/index.js");
var pluginVue_exportHelper = require("../_virtual/plugin-vue_export-helper.js");
const _sfc_main = vue.defineComponent({
name: "Message",
components: {
AIconHover: iconHover,
IconInfoCircleFill: index,
IconCheckCircleFill: index$1,
IconExclamationCircleFill: index$2,
IconCloseCircleFill: index$3,
IconClose: index$4,
IconLoading: index$5
},
props: {
type: {
type: String,
default: "info"
},
closable: {
type: Boolean,
default: false
},
showIcon: {
type: Boolean,
default: true
},
duration: {
type: Number,
default: 3e3
},
resetOnUpdate: {
type: Boolean,
default: false
},
resetOnHover: {
type: Boolean,
default: false
}
},
emits: ["close"],
setup(props, { emit }) {
const prefixCls = globalConfig.getPrefixCls("message");
let timer = 0;
const handleClose = () => {
emit("close");
};
const startTimer = () => {
if (props.duration > 0) {
timer = window.setTimeout(handleClose, props.duration);
}
};
const clearTimer = () => {
if (timer) {
window.clearTimeout(timer);
timer = 0;
}
};
vue.onMounted(() => {
startTimer();
});
vue.onUpdated(() => {
if (props.resetOnUpdate) {
clearTimer();
startTimer();
}
});
vue.onUnmounted(() => {
clearTimer();
});
const handleMouseEnter = () => {
if (props.resetOnHover) {
clearTimer();
}
};
const handleMouseLeave = () => {
if (props.resetOnHover) {
startTimer();
}
};
return {
handleMouseEnter,
handleMouseLeave,
prefixCls,
handleClose
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_icon_info_circle_fill = vue.resolveComponent("icon-info-circle-fill");
const _component_icon_check_circle_fill = vue.resolveComponent("icon-check-circle-fill");
const _component_icon_exclamation_circle_fill = vue.resolveComponent("icon-exclamation-circle-fill");
const _component_icon_close_circle_fill = vue.resolveComponent("icon-close-circle-fill");
const _component_icon_loading = vue.resolveComponent("icon-loading");
const _component_icon_close = vue.resolveComponent("icon-close");
const _component_a_icon_hover = vue.resolveComponent("a-icon-hover");
return vue.openBlock(), vue.createElementBlock("li", {
role: "alert",
class: vue.normalizeClass([
_ctx.prefixCls,
`${_ctx.prefixCls}-${_ctx.type}`,
{ [`${_ctx.prefixCls}-closable`]: _ctx.closable }
]),
onMouseenter: _cache[1] || (_cache[1] = (...args) => _ctx.handleMouseEnter && _ctx.handleMouseEnter(...args)),
onMouseleave: _cache[2] || (_cache[2] = (...args) => _ctx.handleMouseLeave && _ctx.handleMouseLeave(...args))
}, [
_ctx.showIcon && !(_ctx.type === "normal" && !_ctx.$slots.icon) ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
class: vue.normalizeClass(`${_ctx.prefixCls}-icon`)
}, [
vue.renderSlot(_ctx.$slots, "icon", {}, () => [
_ctx.type === "info" ? (vue.openBlock(), vue.createBlock(_component_icon_info_circle_fill, { key: 0 })) : _ctx.type === "success" ? (vue.openBlock(), vue.createBlock(_component_icon_check_circle_fill, { key: 1 })) : _ctx.type === "warning" ? (vue.openBlock(), vue.createBlock(_component_icon_exclamation_circle_fill, { key: 2 })) : _ctx.type === "error" ? (vue.openBlock(), vue.createBlock(_component_icon_close_circle_fill, { key: 3 })) : _ctx.type === "loading" ? (vue.openBlock(), vue.createBlock(_component_icon_loading, { key: 4 })) : vue.createCommentVNode("v-if", true)
])
], 2)) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("span", {
class: vue.normalizeClass(`${_ctx.prefixCls}-content`)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2),
_ctx.closable ? (vue.openBlock(), vue.createElementBlock("span", {
key: 1,
class: vue.normalizeClass(`${_ctx.prefixCls}-close-btn`),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClose && _ctx.handleClose(...args))
}, [
vue.createVNode(_component_a_icon_hover, null, {
default: vue.withCtx(() => [
vue.createVNode(_component_icon_close)
]),
_: 1
})
], 2)) : vue.createCommentVNode("v-if", true)
], 34);
}
var Message = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]);
module.exports = Message;