winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
119 lines (118 loc) • 4.37 kB
JavaScript
;
var vue = require("vue");
var globalConfig = require("../_utils/global-config.js");
var constant = require("../_utils/constant.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");
const _sfc_main = vue.defineComponent({
name: "Message",
components: {
IconInfoCircleFill: index,
IconCheckCircleFill: index$1,
IconExclamationCircleFill: index$2,
IconCloseCircleFill: index$3,
IconClose: index$4,
IconLoading: index$5
},
props: {
type: {
type: String,
default: "info",
validator: (value) => {
return constant.MESSAGE_TYPES.includes(value);
}
},
closable: {
type: Boolean,
default: false
},
showIcon: {
type: Boolean,
default: true
},
duration: {
type: Number,
default: 3e3
},
resetOnUpdate: {
type: Boolean,
default: false
}
},
emits: ["close"],
setup(props, { emit }) {
const prefixCls = globalConfig.getPrefixCls("message");
let timer = 0;
const handleClose = () => {
emit("close");
};
vue.onMounted(() => {
if (props.duration > 0) {
timer = window.setTimeout(handleClose, props.duration);
}
});
vue.onUpdated(() => {
if (props.resetOnUpdate) {
if (timer) {
window.clearTimeout(timer);
timer = 0;
}
if (props.duration > 0) {
timer = window.setTimeout(handleClose, props.duration);
}
}
});
vue.onUnmounted(() => {
if (timer) {
window.clearTimeout(timer);
}
});
return {
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");
return vue.openBlock(), vue.createElementBlock("li", {
class: vue.normalizeClass([
_ctx.prefixCls,
`${_ctx.prefixCls}-${_ctx.type}`,
{ [`${_ctx.prefixCls}-closable`]: _ctx.closable }
])
}, [
_ctx.showIcon ? (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_icon_close)
], 2)) : vue.createCommentVNode("v-if", true)
], 2);
}
var Message = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]);
module.exports = Message;