tdesign-vue-next
Version:
TDesign Component for vue-next
115 lines (111 loc) • 4.28 kB
JavaScript
/**
* tdesign v1.20.2
* (c) 2026 tdesign
* @license MIT
*/
import { defineComponent, inject, computed, createVNode, mergeProps, Fragment } from 'vue';
import { u as usePrefixClass } from '../_chunks/dep-9ce910b6.mjs';
import { descriptionsKey } from './constants/index.mjs';
import { i as itemTypeIsProps, a as renderVNodeTNode } from '../_chunks/dep-73f6632a.mjs';
import { useConfig } from '../config-provider/hooks/useConfig.mjs';
import 'lodash-es';
import '../_chunks/dep-557b68dd.mjs';
import '../_chunks/dep-26d65784.mjs';
import '../_chunks/dep-f038e2b4.mjs';
import '../_chunks/dep-05bddb06.mjs';
import '../_chunks/dep-57027bda.mjs';
import '../_chunks/dep-192d0c88.mjs';
import '../_chunks/dep-ea5fbe21.mjs';
import '../_chunks/dep-652c99fe.mjs';
import '../_chunks/dep-5b369203.mjs';
import '../config-provider/utils/context.mjs';
import '../_chunks/dep-57949dcd.mjs';
import '../_chunks/dep-cafb5eac.mjs';
import '../_chunks/dep-f1da7269.mjs';
import '../_chunks/dep-a4f55e3b.mjs';
import '../_chunks/dep-98dac781.mjs';
import '../_chunks/dep-920eff5b.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