UNPKG

tdesign-pro-component

Version:

ProComponents tdesign-vue-next + Vue3 + TS

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