tdesign-pro-component
Version:
ProComponents tdesign-vue-next + Vue3 + TS
92 lines (91 loc) • 2.46 kB
JavaScript
import "lodash-es";
import { g, w as O } from "./utils-CIySOLoe.js";
import { defineComponent as q, ref as F, useTemplateRef as V, watch as b, createVNode as r, Fragment as x, mergeProps as h } from "vue";
import { Dialog as M, Space as j } from "tdesign-vue-next";
import { P as y } from "./ProForm-zJW4qA6n.js";
/* empty css */
const T = /* @__PURE__ */ q((o, {
emit: l,
slots: a,
expose: P
}) => {
var m, f, c, v;
const n = F(!1), t = V("proFormRef"), u = F(void 0), d = g("title", a, o)(), s = g("footer", a, 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((i) => {
var p;
i === !0 && l("confirm", (p = t.value) == null ? void 0 : p.getFormValue());
});
}
function C() {
var e;
(e = t.value) == null || e.reset(), l("cancel");
}
function S() {
var e;
(e = t.value) == null || e.reset(), l("close");
}
return b(() => o.visible, (e) => {
n.value = e;
}), b(n, (e) => {
l("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(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: S,
onOpened: R,
visible: n.value,
"onUpdate:visible": (i) => n.value = i
}, o.dialogProps), {
//@ts-ignore
default: () => r(j, null, {
default: () => [r(y, 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,
...a
})]);
};
}, {
name: "ModalForm",
emits: ["update:visible", "confirm"],
props: {
title: String,
visible: Boolean,
options: Array,
request: Function,
formProps: Object,
dialogProps: Object,
width: [String, Object]
}
}), N = O(T);
export {
N as M
};