element-plus
Version:
A Component Library for Vue 3
145 lines (140 loc) • 5.74 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index$1 = require('../../icon/index.js');
var alert = require('./alert.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var icon = require('../../../utils/vue/icon.js');
var index = require('../../../hooks/use-namespace/index.js');
var error = require('../../../utils/error.js');
const _sfc_main = vue.defineComponent({
...{
name: "ElAlert"
},
__name: "alert",
props: alert.alertProps,
emits: alert.alertEmits,
setup(__props, { emit: __emit }) {
const { Close } = icon.TypeComponents;
const props = __props;
const emit = __emit;
const slots = vue.useSlots();
const ns = index.useNamespace("alert");
const visible = vue.ref(true);
const iconComponent = vue.computed(() => icon.TypeComponentsMap[props.type]);
const hasDesc = vue.computed(() => !!(props.description || slots.default));
const close = (evt) => {
visible.value = false;
emit("close", evt);
};
if (props.showAfter || props.hideAfter || props.autoClose) {
error.debugWarn(
"el-alert",
"The `show-after`, `hide-after`, and `auto-close` attributes were removed after 2.11.8. Please use `v-if` and `v-show` to manually replace them, visit: https://github.com/element-plus/element-plus/pull/22560"
);
}
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.Transition, {
name: vue.unref(ns).b("fade"),
persisted: ""
}, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createElementVNode(
"div",
{
class: vue.normalizeClass([vue.unref(ns).b(), vue.unref(ns).m(_ctx.type), vue.unref(ns).is("center", _ctx.center), vue.unref(ns).is(_ctx.effect)]),
role: "alert"
},
[
_ctx.showIcon && (_ctx.$slots.icon || iconComponent.value) ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("icon"), vue.unref(ns).is("big", hasDesc.value)])
}, {
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "icon", {}, () => [
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(iconComponent.value)))
])
]),
_: 3
}, 8, ["class"])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode(
"div",
{
class: vue.normalizeClass(vue.unref(ns).e("content"))
},
[
_ctx.title || _ctx.$slots.title ? (vue.openBlock(), vue.createElementBlock(
"span",
{
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("title"), { "with-description": hasDesc.value }])
},
[
vue.renderSlot(_ctx.$slots, "title", {}, () => [
vue.createTextVNode(
vue.toDisplayString(_ctx.title),
1
)
])
],
2
)) : vue.createCommentVNode("v-if", true),
hasDesc.value ? (vue.openBlock(), vue.createElementBlock(
"p",
{
key: 1,
class: vue.normalizeClass(vue.unref(ns).e("description"))
},
[
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createTextVNode(
vue.toDisplayString(_ctx.description),
1
)
])
],
2
)) : vue.createCommentVNode("v-if", true),
_ctx.closable ? (vue.openBlock(), vue.createElementBlock(
vue.Fragment,
{ key: 2 },
[
_ctx.closeText ? (vue.openBlock(), vue.createElementBlock(
"div",
{
key: 0,
class: vue.normalizeClass([vue.unref(ns).e("close-btn"), vue.unref(ns).is("customed")]),
onClick: close
},
vue.toDisplayString(_ctx.closeText),
3
)) : (vue.openBlock(), vue.createBlock(vue.unref(index$1.ElIcon), {
key: 1,
class: vue.normalizeClass(vue.unref(ns).e("close-btn")),
onClick: close
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(Close))
]),
_: 1
}, 8, ["class"]))
],
64
)) : vue.createCommentVNode("v-if", true)
],
2
)
],
2
), [
[vue.vShow, visible.value]
])
]),
_: 3
}, 8, ["name"]);
};
}
});
var Alert = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/alert/src/alert.vue"]]);
exports["default"] = Alert;
//# sourceMappingURL=alert2.js.map