UNPKG

tdesign-pro-component

Version:

ProComponents tdesign-vue-next + Vue3 + TS

90 lines (89 loc) 2.39 kB
import "lodash-es"; import { g as p, w as S } from "./utils-CIySOLoe.js"; import { defineComponent as q, ref as F, useTemplateRef as V, watch as b, createVNode as a, Fragment as x, mergeProps as h } from "vue"; import { Dialog as M } from "tdesign-vue-next"; import { P as j } from "./ProForm-BQFTe4Ag.js"; /* empty css */ const y = /* @__PURE__ */ q((o, { emit: r, slots: i, expose: P }) => { var m, f, c, v; const n = F(!1), t = V("proFormRef"), u = F(void 0), d = p("title", i, o)(), s = p("footer", i, o)(); function R() { u.value = o.request, setTimeout(() => { var e; (e = t.value) == null || e.resetRequest(); }); } function w() { var e; (e = t.value) == null || e.validate().then((l) => { var g; l === !0 && r("confirm", (g = t.value) == null ? void 0 : g.getFormValue()); }); } function C() { var e; (e = t.value) == null || e.reset(), r("cancel"); } function O() { var e; (e = t.value) == null || e.reset(), r("close"); } return b(() => o.visible, (e) => { n.value = e; }), b(n, (e) => { r("update:visible", e); }), P({ reset: (m = t.value) == null ? void 0 : m.reset, submit: (f = t.value) == null ? void 0 : f.submit, validate: (c = t.value) == null ? void 0 : c.validate, getFormValue: (v = t.value) == null ? void 0 : v.getFormValue }), () => { var e; return a(x, null, [a(M, h({ width: o.width, onConfirm: w, dialogStyle: { padding: "16px 24px", overFlowX: "hidden", borderRadius: "4px", ...(e = o.dialogProps) == null ? void 0 : e.dialogStyle }, onCancel: C, onClose: O, onOpened: R, visible: n.value, "onUpdate:visible": (l) => n.value = l }, o.dialogProps), { //@ts-ignore default: () => a(j, h(o.formProps, { ref: "proFormRef", gap: 24, options: o.options || [], request: u.value, hideFooter: !0 }), null), header: d ? () => d : void 0, footer: s ? () => s : void 0, ...i })]); }; }, { name: "ModalForm", emits: ["update:visible", "confirm"], props: { title: String, visible: Boolean, options: Array, request: Function, formProps: Object, dialogProps: Object, width: [String, Object] } }), J = S(y); export { J as M };