tdesign-pro-component
Version:
ProComponents tdesign-vue-next + Vue3 + TS
92 lines (91 loc) • 2.45 kB
JavaScript
import "lodash-es";
import { g as p, w as S } from "./utils-CIySOLoe.js";
import { defineComponent as q, ref as h, useTemplateRef as x, watch as F, createVNode as i, Fragment as V, mergeProps as b } from "vue";
import { Dialog as y } from "tdesign-vue-next";
import { P as M } from "./ProForm-CmfXXRwc.js";
/* empty css */
const j = /* @__PURE__ */ q((o, {
emit: r,
slots: l,
expose: w
}) => {
var m, f, v, c;
const n = h(!1), t = x("proFormRef"), d = h(void 0), u = p("title", l, o)(), s = p("footer", l, o)();
function P() {
d.value = o.request, setTimeout(() => {
var e;
(e = t.value) == null || e.resetRequest();
});
}
function R() {
var e;
(e = t.value) == null || e.validate().then((a) => {
var g;
a === !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 F(() => o.visible, (e) => {
n.value = e;
}), F(n, (e) => {
r("update:visible", e);
}), w({
reset: (m = t.value) == null ? void 0 : m.reset,
submit: (f = t.value) == null ? void 0 : f.submit,
validate: (v = t.value) == null ? void 0 : v.validate,
getFormValue: (c = t.value) == null ? void 0 : c.getFormValue
}), () => {
var e;
return i(V, null, [i(y, b({
width: o.width,
onConfirm: R,
dialogStyle: {
padding: "16px 24px",
overFlowX: "hidden",
borderRadius: "4px",
...(e = o.dialogProps) == null ? void 0 : e.dialogStyle
},
onCancel: C,
onClose: O,
onOpened: P,
visible: n.value,
"onUpdate:visible": (a) => n.value = a
}, o.dialogProps), {
//@ts-ignore
default: () => i("div", {
style: "overflow-x:hidden;"
}, [i(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
};