magner
Version:
Universal admin panel magnetic to any backend
74 lines (73 loc) • 2.88 kB
JavaScript
import { defineComponent as v, computed as g, shallowRef as $, ref as p, watchEffect as S, openBlock as i, createBlock as f, resolveDynamicComponent as C, mergeProps as h, withCtx as w, createCommentVNode as y } from "vue";
import { u as b, a as F, b as M, m as B, _ as O } from "./index-BxxiWOOE.mjs";
import "wretch";
const V = v({
name: "MagnerModal",
setup() {
const { t: o } = b(), n = F(), s = g(() => n.state.modalData), d = M(void 0, !0), t = $(), c = p(), u = p(!1), m = p(!1), r = p("");
return S(async () => {
var a;
if (s.value) {
const e = s.value.config;
if (e.type === "card")
t.value = (await import("./index-BxxiWOOE.mjs").then((l) => l.a7)).default, c.value = { config: e.config, ...e.props };
else if (e.type === "table")
t.value = (await import("./index-BxxiWOOE.mjs").then((l) => l.a8)).default, c.value = { config: e.config, ...e.props };
else if (e.type === "custom") {
const l = await ((a = e.component) == null ? void 0 : a.call(e));
t.value = (l == null ? void 0 : l.default) || l, c.value = { ...e.props };
}
r.value = e.customClass ?? "", m.value = e.handleBeforeClose ?? !1, u.value = !0;
} else
m.value = !1, u.value = !1;
}), {
customClass: r,
dialogComponent: d,
contentComponent: t,
contentProps: c,
modalOpen: u,
handleSuccess: (a) => {
var e, l;
(l = (e = s.value) == null ? void 0 : e.handleSuccess) == null || l.call(e, a), n.dispatch("changeModalComponent", null);
},
handleFail: () => {
var a, e;
(e = (a = s.value) == null ? void 0 : a.handleFail) == null || e.call(a, null), n.dispatch("changeModalComponent", null);
},
handleClose: (a) => {
m.value ? B({
title: o("core.card.attention"),
message: o("core.modal.before_close")
}).then(() => {
n.dispatch("changeModalComponent", null);
}).catch(() => {
}) : a();
}
};
}
});
function k(o, n, s, d, t, c) {
return i(), f(C(o.dialogComponent.component), h({
modelValue: o.modalOpen,
"onUpdate:modelValue": n[0] || (n[0] = (u) => o.modalOpen = u)
}, {
...o.dialogComponent.props,
class: `${o.dialogComponent.props.class ?? ""} ${o.customClass}`,
customClass: `${o.dialogComponent.props.customClass ?? ""} ${o.customClass}`
}, {
"before-close": o.handleClose,
onClose: o.handleFail
}), {
default: w(() => [
o.modalOpen ? (i(), f(C(o.contentComponent), h({
key: 0,
"root-template": "modal"
}, o.contentProps, { onSuccess: o.handleSuccess }), null, 16, ["onSuccess"])) : y("", !0)
]),
_: 1
}, 16, ["modelValue", "before-close", "onClose"]);
}
const U = /* @__PURE__ */ O(V, [["render", k]]);
export {
U as default
};