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