@aplus-frontend/ui
Version:
82 lines (81 loc) • 2.32 kB
JavaScript
import { render as m, defineComponent as g, createVNode as l, mergeProps as b, h as v } from "vue";
import { Drawer as w } from "@aplus-frontend/antdv";
import { ConfigProvider as P, globalConfigCached as y } from "../../config-provider/config-provider.mjs";
import { omit as A } from "lodash-unified";
import "../components/ApDrawerClose.vue.mjs";
import { getModalGlobalAppContext as D } from "../../ap-modal/utils/util.mjs";
import O from "../components/ApDrawerClose.vue2.mjs";
const N = (n) => {
let o, s;
const {
destroyOnClose: r = !0
} = n;
function p() {
o && o(!1), setTimeout(() => {
m(null, t), t.parentElement?.removeChild(t);
}, 500);
}
function f() {
o && o(!0);
}
function i() {
o && o(!1);
}
function h(e) {
s && s(e);
}
const C = /* @__PURE__ */ g({
data() {
return {
open: r,
props: n
};
},
created() {
o = (e) => {
this.open = e;
}, s = (e) => {
this.props = {
...this.props,
...e
};
};
},
methods: {
async handleClose() {
if (this.props?.onClose) {
const e = this.props?.content?.component?.exposed ?? void 0;
await this.props?.onClose(e);
}
r ? p() : i();
}
},
render() {
const e = A(this.props, ["onClose", "extra", "footer", "visible", "onUpdate:visible", "afterVisibleChange", "onAfterVisibleOChange", "open", "onUpdate:open", "getContainer"]), d = this.props?.content?.component?.exposed ?? void 0, c = () => r ? p() : i();
return l(P, y.value, {
default: () => [l(w, b({
open: this.open,
onClose: this.handleClose,
closeIcon: this.props?.closeIcon ?? null,
extra: this.props?.extra ? this.props?.extra?.(d, c) : l(O, {
onClose: this.handleClose
}, null),
footer: this.props?.footer?.(d, c)
}, e), {
default: () => [this.props?.content]
})]
});
}
}), u = n.getContainer || document.body, t = document.createElement("div");
u.appendChild(t);
const a = v(C), x = D();
return a.appContext = n.appContext || x || a.appContext, m(a, t), {
destroy: p,
update: h,
open: f,
close: i
};
};
export {
N as createDrawer
};