@aplus-frontend/ui
Version:
93 lines (92 loc) • 3.35 kB
JavaScript
import { defineComponent as N, useSlots as T, createVNode as l, createTextVNode as D, Fragment as V, shallowRef as w, watch as E, createElementBlock as _, openBlock as k, normalizeStyle as A, normalizeClass as B, unref as n, mergeProps as I } from "vue";
import { Descriptions as R } from "@aplus-frontend/antdv";
import { get as p } from "lodash-unified";
import "../../config-provider/index.mjs";
import "./help-message/index.vue.mjs";
import { mixinsAttachmentExtraProps as j, transformValue as z, isEmptyWithType as F } from "./helper.mjs";
import G from "./style/index.mjs";
import { useGlobalConfig as u } from "../../config-provider/hooks/use-global-config.mjs";
import { useNamespace as M } from "../../config-provider/hooks/use-namespace.mjs";
import L from "./help-message/index.vue2.mjs";
const Z = /* @__PURE__ */ N({
name: "ApDescriptions",
__name: "ap-descriptions",
props: {
descriptionsProps: {},
schemas: {},
dataSource: {},
style: {
type: [Boolean, null, String, Object, Array]
},
className: {}
},
setup(f) {
const o = f, c = u("apDescriptions"), d = u("downloadCenterTriggerConfig"), {
b: y,
be: m
} = M("ap-descriptions"), b = G("ap-descriptions"), g = T(), S = (e = {}) => {
let r = "";
return o.descriptionsProps?.layout === "vertical" && (r = "start"), {
justifyContent: r,
...e
};
}, s = (e) => {
const r = p(o.dataSource, e.field);
if (e.customRender)
return e.customRender(o.dataSource);
e.valueType === "attachment" && (e.extraProps = j(e.extraProps, {
fromConfig: c.value?.downloadFile,
fromGlobal: d.value?.trigger
}));
const t = e.format ? e.format(r, o.dataSource || {}) : r;
return z({
value: t,
record: o.dataSource
}, e);
}, v = (e) => e.valueType === "text" && !!e.extraProps?.ellipsis, C = (e, r) => {
if (e.visible != null) {
if (typeof e.visible == "boolean")
return e.visible;
if (typeof e.visible == "function")
return e.visible({
record: r || {},
schema: e
});
}
return !0;
}, P = (e, r, t) => e.valueType === "empty" ? null : F(p(t, e.field), e) ? l("span", null, [D("--")]) : e.contentSlotName ? g?.[e.contentSlotName]?.({
index: r,
record: t,
item: s(e)
}) : l(V, null, [e.prefix, s(e), e.suffix]), x = (e = [], r) => e.filter((t) => C(t, r)).map((t, a) => ({
label: t.label && l(L, {
helpMessage: t.helpMessage,
label: t.label
}, null),
span: t.span,
style: t.style,
contentStyle: t.contentStyle,
labelStyle: t.labelStyle,
key: t.field?.toString() || "empty" + a,
class: v(t) ? m("item", "ellipsis") : "",
children: P(t, a, r)
})), i = w([]);
return E([() => o.schemas, () => o.dataSource], () => {
i.value = x(o.schemas, o.dataSource);
}, {
immediate: !0,
deep: !0
}), (e, r) => (k(), _("div", {
class: B([e.className, n(y)(), n(b)]),
style: A(e.style)
}, [l(n(R), I(e.descriptionsProps, {
"label-style": S({
...e.descriptionsProps?.labelStyle || {}
}),
items: i.value
}), null, 16, ["label-style", "items"])], 6));
}
});
export {
Z as default
};