UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

128 lines (127 loc) 5.41 kB
import { defineComponent, ref, computed, resolveComponent, openBlock, createBlock, Transition, withCtx, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createVNode, normalizeProps, guardReactiveProps, createCommentVNode, createElementVNode, createTextVNode, toDisplayString, mergeProps } from "vue"; import { ElIcon } from "element-plus"; import { CloseOutlined, InfoCircleFilled, CheckCircleFilled, ExclamationCircleFilled, CloseCircleFilled } from "../icons"; import { alertProps, alertEmits } from "./props"; const _sfc_main = defineComponent({ name: "EleAlert", components: { ElIcon, CloseOutlined, InfoCircleFilled, CheckCircleFilled, ExclamationCircleFilled, CloseCircleFilled }, props: alertProps, emits: alertEmits, setup(props, { emit, slots }) { const visible = ref(true); const isRich = computed(() => { return props.description !== false && (!!props.description || !!slots.default); }); const handleClose = (e) => { if (!visible.value || !props.closable) { return; } visible.value = false; emit("close", e); }; const open = () => { if (!visible.value) { visible.value = true; } }; return { visible, isRich, handleClose, open }; } }); const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; const _hoisted_1 = { key: 0 }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_CheckCircleFilled = resolveComponent("CheckCircleFilled"); const _component_ExclamationCircleFilled = resolveComponent("ExclamationCircleFilled"); const _component_CloseCircleFilled = resolveComponent("CloseCircleFilled"); const _component_InfoCircleFilled = resolveComponent("InfoCircleFilled"); const _component_ElIcon = resolveComponent("ElIcon"); const _component_CloseOutlined = resolveComponent("CloseOutlined"); return openBlock(), createBlock(Transition, { name: _ctx.transitionName }, { default: withCtx(() => [ _ctx.visible ? (openBlock(), createElementBlock("div", { key: 0, class: normalizeClass([ "ele-alert", { "is-success": _ctx.type === "success" }, { "is-warning": _ctx.type === "warning" }, { "is-error": _ctx.type === "error" }, { "is-dark": _ctx.effect === "dark" }, { "is-center": _ctx.center }, { "is-rich": _ctx.isRich } ]) }, [ _ctx.showIcon ? (openBlock(), createElementBlock("div", { key: 0, class: "ele-alert-icon", style: normalizeStyle(_ctx.iconStyle) }, [ renderSlot(_ctx.$slots, "icon", {}, () => [ createVNode(_component_ElIcon, normalizeProps(guardReactiveProps(_ctx.iconProps || {})), { default: withCtx(() => [ _ctx.type === "success" ? (openBlock(), createBlock(_component_CheckCircleFilled, { key: 0 })) : _ctx.type === "warning" ? (openBlock(), createBlock(_component_ExclamationCircleFilled, { key: 1 })) : _ctx.type === "error" ? (openBlock(), createBlock(_component_CloseCircleFilled, { key: 2 })) : (openBlock(), createBlock(_component_InfoCircleFilled, { key: 3 })) ]), _: 1 }, 16) ]) ], 4)) : createCommentVNode("", true), createElementVNode("div", { class: "ele-alert-body", style: normalizeStyle(_ctx.bodyStyle) }, [ _ctx.title || _ctx.$slots.title ? (openBlock(), createElementBlock("div", { key: 0, class: "ele-alert-title", style: normalizeStyle(_ctx.titleStyle) }, [ renderSlot(_ctx.$slots, "title", {}, () => [ createTextVNode(toDisplayString(_ctx.title), 1) ]) ], 4)) : createCommentVNode("", true), _ctx.isRich ? (openBlock(), createElementBlock("div", { key: 1, class: "ele-alert-text", style: normalizeStyle(_ctx.descriptionStyle) }, [ renderSlot(_ctx.$slots, "default", {}, () => [ createTextVNode(toDisplayString(_ctx.description === true ? "" : _ctx.description), 1) ]) ], 4)) : createCommentVNode("", true) ], 4), renderSlot(_ctx.$slots, "action"), _ctx.closable ? (openBlock(), createElementBlock("div", { key: 1, class: "ele-alert-close", style: normalizeStyle(_ctx.closeIconStyle), onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClose && _ctx.handleClose(...args)) }, [ renderSlot(_ctx.$slots, "closeIcon", {}, () => [ _ctx.closeText ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(_ctx.closeText), 1)) : (openBlock(), createBlock(_component_ElIcon, normalizeProps(mergeProps({ key: 1 }, _ctx.closeIconProps || {})), { default: withCtx(() => [ createVNode(_component_CloseOutlined) ]), _: 1 }, 16)) ]) ], 4)) : createCommentVNode("", true) ], 2)) : createCommentVNode("", true) ]), _: 3 }, 8, ["name"]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };