tdesign-vue-next
Version:
TDesign Component for vue-next
115 lines (111 loc) • 4.28 kB
JavaScript
/**
* tdesign v1.20.3
* (c) 2026 tdesign
* @license MIT
*/
import { defineComponent, inject, computed, createVNode, mergeProps, Fragment } from 'vue';
import { u as usePrefixClass } from '../_chunks/dep-5975d369.mjs';
import { descriptionsKey } from './constants/index.mjs';
import { i as itemTypeIsProps, a as renderVNodeTNode } from '../_chunks/dep-bc9070ef.mjs';
import { useConfig } from '../config-provider/hooks/useConfig.mjs';
import 'lodash-es';
import '../_chunks/dep-adf8ce39.mjs';
import '../_chunks/dep-390963eb.mjs';
import '../_chunks/dep-d84a2ec7.mjs';
import '../_chunks/dep-12b4e978.mjs';
import '../_chunks/dep-0841ee8f.mjs';
import '../_chunks/dep-a1cbfaae.mjs';
import '../_chunks/dep-ff183185.mjs';
import '../_chunks/dep-3f53eff0.mjs';
import '../_chunks/dep-4c65e11b.mjs';
import '../config-provider/utils/context.mjs';
import '../_chunks/dep-cf105282.mjs';
import '../_chunks/dep-dcbc09c5.mjs';
import '../_chunks/dep-9fc6972b.mjs';
import '../_chunks/dep-46776e3b.mjs';
import '../_chunks/dep-07d8f2aa.mjs';
import '../_chunks/dep-8aebe545.mjs';
var DescriptionsRow = defineComponent({
name: "TDescriptionsRow",
props: {
row: Array,
itemType: String
},
setup: function setup(props) {
var descriptionsProps = inject(descriptionsKey);
var COMPONENT_NAME = usePrefixClass("descriptions");
var _useConfig = useConfig("descriptions"),
globalConfig = _useConfig.globalConfig;
var layoutIsHorizontal = computed(function () {
return descriptionsProps.layout === "horizontal";
});
var itemLayoutIsHorizontal = computed(function () {
return descriptionsProps.itemLayout === "horizontal";
});
var label = function label(node) {
var labelClass = ["".concat(COMPONENT_NAME.value, "__label")];
var label2 = null;
var span = null;
if (itemTypeIsProps(props.itemType, node)) {
label2 = node.label;
span = node.span;
} else {
label2 = renderVNodeTNode(node, "label");
span = node.props.span;
}
var labelSpan = layoutIsHorizontal.value ? itemLayoutIsHorizontal.value ? 1 : span : 1;
return createVNode("td", mergeProps({
"colspan": labelSpan,
"class": labelClass
}, {
style: descriptionsProps.labelStyle
}), [label2, descriptionsProps.colon && globalConfig.value.colonText]);
};
var content = function content(node) {
var contentClass = ["".concat(COMPONENT_NAME.value, "__content")];
var content2 = null;
var span = null;
if (itemTypeIsProps(props.itemType, node)) {
content2 = node.content;
span = node.span;
} else {
content2 = renderVNodeTNode(node, "content", "default");
span = node.props.span;
}
var contentSpan = layoutIsHorizontal.value ? span > 1 && itemLayoutIsHorizontal.value ? span * 2 - 1 : span : 1;
return createVNode("td", mergeProps({
"colspan": contentSpan,
"class": contentClass
}, {
style: descriptionsProps.contentStyle
}), [content2]);
};
var hh = function hh() {
return createVNode("tr", null, [props.row.map(function (node) {
return createVNode(Fragment, null, [label(node), content(node)]);
})]);
};
var hv = function hv() {
return createVNode(Fragment, null, [createVNode("tr", null, [props.row.map(function (node) {
return label(node);
})]), createVNode("tr", null, [props.row.map(function (node) {
return content(node);
})])]);
};
var vh = function vh() {
return createVNode(Fragment, null, [props.row.map(function (node) {
return createVNode("tr", null, [label(node), content(node)]);
})]);
};
var vv = function vv() {
return createVNode(Fragment, null, [props.row.map(function (node) {
return createVNode(Fragment, null, [createVNode("tr", null, [label(node)]), createVNode("tr", null, [content(node)])]);
})]);
};
return function () {
return createVNode(Fragment, null, [layoutIsHorizontal.value ? itemLayoutIsHorizontal.value ? hh() : hv() : itemLayoutIsHorizontal.value ? vh() : vv()]);
};
}
});
export { DescriptionsRow as default };
//# sourceMappingURL=descriptions-row.mjs.map