comic-plus
Version:
<p align="center"> <img width="200px" src="./logo.png"/> </p>
120 lines (119 loc) • 5.1 kB
JavaScript
import { defineComponent, computed, onMounted, openBlock, createBlock, unref, withCtx, createVNode, Transition, createElementBlock, normalizeClass, createElementVNode, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, Fragment } from "vue";
import { onKeyStroke } from "@vueuse/core";
import "../../style/message-box.css";
import { CuMode } from "../../../mode/index.mjs";
import "../../../../utils/config.mjs";
import { isVueComponent, isString } from "../../../../utils/typescript.mjs";
import { usePopup } from "../../../../hooks/popup.mjs";
import { CuButton } from "../../../button/index.mjs";
import { alertProps } from "./main.props.mjs";
import "../../../../icons/index.mjs";
import { Close, Tips, Info, Success, Caution, WarningFilled } from "../../../../icons/components/components.mjs";
const _hoisted_1 = { class: "cu-popup__head" };
const _hoisted_2 = { class: "cu-popup__title" };
const _hoisted_3 = { class: "cu-popup__content" };
const _hoisted_4 = ["innerHTML"];
const _hoisted_5 = {
key: 0,
class: "cu-popup__footer"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "CuAlert"
},
__name: "main",
props: alertProps,
setup(__props) {
const typeList = {
primary: Tips,
info: Info,
success: Success,
warning: Caution,
error: WarningFilled
};
const props = __props;
const { visible, showMode, onAfterEnter, modeHandleClick, close, onAfterLeave } = usePopup(props);
const headIcon = computed(() => {
if (!props.showIcon) return null;
if (isVueComponent(props.icon)) return props.icon;
return props.type ? typeList[props.type] : null;
});
onMounted(() => {
showMode.value = true;
if (props.escClose) {
onKeyStroke("Escape", (e) => {
e.preventDefault();
close();
});
}
});
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(CuMode), {
show: unref(showMode),
"lock-scroll": _ctx.lockScroll,
"custom-class": ["cu-mode__flex", _ctx.modeClass],
onClose: _cache[1] || (_cache[1] = ($event) => _ctx.destroy()),
onOpen: unref(onAfterEnter),
onModeClick: unref(modeHandleClick)
}, {
default: withCtx(() => [
createVNode(Transition, {
name: "cu-fade-top",
onAfterLeave: _cache[0] || (_cache[0] = ($event) => unref(onAfterLeave)())
}, {
default: withCtx(() => [
unref(visible) ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass(["cu-popup", [_ctx.type ? "cu-popup--" + _ctx.type : void 0, { "is-center": _ctx.center }, _ctx.customClass]])
}, [
createElementVNode("div", _hoisted_1, [
createElementVNode("span", _hoisted_2, [
headIcon.value ? (openBlock(), createBlock(resolveDynamicComponent(headIcon.value), {
key: 0,
class: "cu-popup__head--icon",
color: _ctx.color
}, null, 8, ["color"])) : createCommentVNode("", true),
createTextVNode(toDisplayString(_ctx.title), 1)
]),
_ctx.showClose ? (openBlock(), createBlock(unref(Close), {
key: 0,
class: "close-icon",
onClick: unref(close)
}, null, 8, ["onClick"])) : createCommentVNode("", true)
]),
createElementVNode("div", _hoisted_3, [
_ctx.isVNode ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
unref(isString)(_ctx.content) ? (openBlock(), createElementBlock("div", {
key: 0,
innerHTML: _ctx.content
}, null, 8, _hoisted_4)) : (openBlock(), createBlock(resolveDynamicComponent(_ctx.content), { key: 1 }))
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
createTextVNode(toDisplayString(_ctx.content), 1)
], 64))
]),
_ctx.showButton ? (openBlock(), createElementBlock("div", _hoisted_5, [
createVNode(unref(CuButton), {
size: "small",
type: _ctx.color ? void 0 : _ctx.type === "error" ? "danger" : _ctx.type,
color: _ctx.color,
onClick: unref(close)
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(_ctx.closeButtonText), 1)
]),
_: 1
}, 8, ["type", "color", "onClick"])
])) : createCommentVNode("", true)
], 2)) : createCommentVNode("", true)
]),
_: 1
})
]),
_: 1
}, 8, ["show", "lock-scroll", "custom-class", "onOpen", "onModeClick"]);
};
}
});
export {
_sfc_main as default
};