@aplus-frontend/ui
Version:
98 lines (97 loc) • 2.55 kB
JavaScript
import { defineComponent as C, ref as P, createVNode as n, mergeProps as w } from "vue";
import { isFunction as y, isEmpty as f, omitBy as I, isUndefined as A, omit as H } from "lodash-unified";
import "../../../ag-grid/index.mjs";
import { ApModal as M } from "../../../ap-modal/index.mjs";
import { genRequest as _ } from "../utils.mjs";
import "../wrapper/index.vue.mjs";
import { useAgGridInstance as q } from "./use-ag-grid-instance.mjs";
import G from "../wrapper/index.vue2.mjs";
import x from "../../../ag-grid/index.vue.mjs";
function j(r) {
let a = null, l = null;
const [o, c] = q(), s = _(r.api, r.getRowKey, o.setDataSourceLength), u = (t) => {
const {
title: e,
width: i,
modalProps: v,
...d
} = y(t) ? t(r) : t;
f(d) || l?.(d);
const m = I({
title: e,
width: i,
modalProps: v
}, A);
f(m) || a?.update(m);
}, g = /* @__PURE__ */ C({
name: "AgGridModalPreviewContent",
props: {
modalConfig: {
type: Object,
required: !0
}
},
setup(t) {
const e = P(t.modalConfig);
return l = (i) => {
e.value = {
...e.value,
...i
};
}, () => n(c, null, {
default: () => [n(G, {
height: e.value.height,
rowHeight: e.value.rowHeight
}, {
default: () => [e.value.renderHeader?.(H(o, "setInstance"), {
updateProps: u
}), n(x, w({
ref: o.setInstance,
searchForm: {
sortable: !1,
resize: {
target: "form"
}
},
rowKey: e.value.getRowKey,
request: s.request,
style: {
padding: "0px"
},
rowHeight: e.value.rowHeight,
columns: e.value.columns,
autoHeight: !!e.value.height
}, r.gridProps), e.value.gridSlots)]
})]
});
}
});
function h() {
a = M.createModal({
title: r.title,
width: r.width,
destroyOnClose: !0,
maskClosable: !1,
footer: null,
afterOpenChange(t) {
t === !1 && (o.setInstance(void 0), o.setDataSourceLength(0), a = null);
},
content: n(g, {
modalConfig: r
}, null),
...r.modalProps || {}
});
}
function p(t) {
s.setExtraParams(t?.extraParams), h();
}
return {
open: p,
refresh: o.refresh,
getAgGridInstance: o.getInstance,
updateProps: u
};
}
export {
j as useAgGridModal
};