comic-plus
Version:
<p align="center"> <img width="200px" src="./logo.png"/> </p>
144 lines (143 loc) • 6.39 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const core = require("@vueuse/core");
require("../../style/message-box.css");
const index = require("../../../mode/index.js");
require("../../../../utils/config.js");
const typescript = require("../../../../utils/typescript.js");
const popup = require("../../../../hooks/popup.js");
const index$1 = require("../../../button/index.js");
const main_props = require("./main.props.js");
require("../../../../icons/index.js");
const components = require("../../../../icons/components/components.js");
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 = { class: "cu-popup__footer" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{
name: "CuConfirm"
},
__name: "main",
props: main_props.confirmProps,
setup(__props) {
const typeList = {
primary: components.Tips,
info: components.Info,
success: components.Success,
warning: components.Caution,
error: components.WarningFilled
};
const props = __props;
const { visible, showMode, onAfterEnter, close, onAfterLeave } = popup.usePopup(props);
const TYPE = vue.ref("cancel");
const headIcon = vue.computed(() => {
if (!props.showIcon) return null;
if (typescript.isVueComponent(props.icon)) return props.icon;
return props.type ? typeList[props.type] : null;
});
function handleModeClose() {
if (!props.modeClose) return;
cancel("cancel");
}
function cancel(val) {
TYPE.value = val;
close();
}
function confirm() {
close();
TYPE.value = "confirm";
}
vue.onMounted(() => {
showMode.value = true;
if (props.escClose) {
core.onKeyStroke("Escape", (e) => {
e.preventDefault();
cancel(props.distinguishCloseAndCancel ? "esc" : "cancel");
});
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.unref(index.CuMode), {
show: vue.unref(showMode),
"custom-class": ["cu-mode__flex", _ctx.modeClass],
"lock-scroll": _ctx.lockScroll,
onClose: _cache[2] || (_cache[2] = ($event) => _ctx.destroy(TYPE.value)),
onOpen: vue.unref(onAfterEnter),
onModeClick: _cache[3] || (_cache[3] = ($event) => handleModeClose())
}, {
default: vue.withCtx(() => [
vue.createVNode(vue.Transition, {
name: "cu-fade-top",
onAfterLeave: vue.unref(onAfterLeave)
}, {
default: vue.withCtx(() => [
vue.unref(visible) ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(["cu-popup", [_ctx.type ? "cu-popup--" + _ctx.type : void 0, { "is-center": _ctx.center }, _ctx.customClass]])
}, [
vue.createElementVNode("div", _hoisted_1, [
vue.createElementVNode("span", _hoisted_2, [
headIcon.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(headIcon.value), {
key: 0,
class: "cu-popup__head--icon",
color: _ctx.color
}, null, 8, ["color"])) : vue.createCommentVNode("", true),
vue.createTextVNode(vue.toDisplayString(_ctx.title), 1)
]),
_ctx.showClose ? (vue.openBlock(), vue.createBlock(vue.unref(components.Close), {
key: 0,
class: "close-icon",
onClick: _cache[0] || (_cache[0] = ($event) => cancel(_ctx.distinguishCloseAndCancel ? "close" : "cancel"))
})) : vue.createCommentVNode("", true)
]),
vue.createElementVNode("div", _hoisted_3, [
_ctx.isVNode ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.unref(typescript.isString)(_ctx.content) ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
innerHTML: _ctx.content
}, null, 8, _hoisted_4)) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.content), { key: 1 }))
], 64)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
vue.createTextVNode(vue.toDisplayString(_ctx.content), 1)
], 64))
]),
vue.createElementVNode("div", _hoisted_5, [
_ctx.showCancelButton ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.CuButton), {
key: 0,
size: "small",
plain: "",
color: _ctx.color,
type: _ctx.color ? void 0 : _ctx.type === "error" ? "danger" : _ctx.type || void 0,
onClick: _cache[1] || (_cache[1] = ($event) => cancel("cancel"))
}, {
default: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString(_ctx.cancelButtonText), 1)
]),
_: 1
}, 8, ["color", "type"])) : vue.createCommentVNode("", true),
_ctx.showConfirmButton ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.CuButton), {
key: 1,
size: "small",
type: _ctx.color ? void 0 : _ctx.type === "error" ? "danger" : _ctx.type || "primary",
color: _ctx.color,
onClick: confirm
}, {
default: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString(_ctx.confirmButtonText), 1)
]),
_: 1
}, 8, ["type", "color"])) : vue.createCommentVNode("", true)
])
], 2)) : vue.createCommentVNode("", true)
]),
_: 1
}, 8, ["onAfterLeave"])
]),
_: 1
}, 8, ["show", "custom-class", "lock-scroll", "onOpen"]);
};
}
});
exports.default = _sfc_main;