UNPKG

@wetspace/pro-components

Version:
91 lines (90 loc) 2.94 kB
import { defineComponent as $, shallowRef as u, useSlots as B, computed as E, cloneVNode as F, openBlock as f, createElementBlock as P, Fragment as D, createBlock as S, resolveDynamicComponent as x, createVNode as a, unref as l, mergeProps as p, withCtx as n, createElementVNode as i, normalizeClass as v, renderSlot as y, createTextVNode as C } from "vue"; import { useNamespace as A, ElDialog as I, ElButton as _ } from "element-plus"; import z from "./index.vue.mjs"; import { wetModalFormProps as M } from "./types.mjs"; const O = { class: "footer-slot__inner" }, j = /* @__PURE__ */ $({ __name: "modal-form", props: M, setup(b) { const t = b, s = u(!1), m = u(), d = B(), c = A("modal-form"), g = E(() => { const e = d.trigger && d.trigger({}); return () => e == null ? void 0 : e.map((o) => F(o, { onClick: () => { s.value = !0; } })); }), k = async () => { const e = await t.onCancel(); s.value = !e; }, w = async () => { var e; if (t.onFinish) { const o = await ((e = m.value) == null ? void 0 : e.submit()), r = await t.onFinish(o); s.value = !r; } }, V = async () => { const e = await t.onCancel(); s.value = !e; }; return (e, o) => { var r; return f(), P(D, null, [ (f(), S(x(g.value))), a(l(I), p(t.modalProps, { modelValue: s.value, "onUpdate:modelValue": o[0] || (o[0] = (N) => s.value = N), "before-close": V, "destroy-on-close": t.destroyOnClose, title: t.title || ((r = t.modalProps) == null ? void 0 : r.title), class: [l(c).b()] }), { footer: n(() => [ i("div", { class: v([l(c).e("footer")]) }, [ i("div", O, [ y(e.$slots, "footer") ]), i("div", null, [ a(l(_), { onClick: k }, { default: n(() => o[1] || (o[1] = [ C(" 取消 ") ])), _: 1 }), a(l(_), { type: "primary", onClick: w }, { default: n(() => o[2] || (o[2] = [ C(" 确认 ") ])), _: 1 }) ]) ], 2) ]), default: n(() => [ i("div", { class: v([l(c).e("body")]) }, [ a(z, p({ ref_key: "formInstance", ref: m }, t), { default: n(() => [ y(e.$slots, "default") ]), _: 3 }, 16) ], 2) ]), _: 3 }, 16, ["modelValue", "destroy-on-close", "title", "class"]) ], 64); }; } }); export { j as default };