tdesign-vue
Version:
172 lines (164 loc) • 6.25 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var helper = require('../_chunks/dep-4009cfe4.js');
var VueCompositionAPI = require('@vue/composition-api');
var hooks_useConfig = require('../hooks/useConfig.js');
var descriptions_const_index = require('./const/index.js');
var descriptions_utils_index = require('./utils/index.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
require('../_chunks/dep-8eddb350.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-0c37520c.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-c13dcbfd.js');
require('dayjs');
require('../_chunks/dep-6f4e680e.js');
require('../_chunks/dep-bb0ececf.js');
require('../_chunks/dep-3b2292ce.js');
require('../_chunks/dep-ba7f5924.js');
require('../_chunks/dep-10fcb46d.js');
require('../_chunks/dep-6eba4d23.js');
require('../_chunks/dep-010db548.js');
require('../_chunks/dep-8d206316.js');
require('../_chunks/dep-2bc87cc8.js');
require('../_chunks/dep-f77d6ad5.js');
require('../_chunks/dep-9dae8101.js');
require('../_chunks/dep-7c84d9a0.js');
require('../_chunks/dep-733a2279.js');
require('../_chunks/dep-d844c9ed.js');
require('../_chunks/dep-c05a9033.js');
require('../_chunks/dep-efe55b82.js');
require('../_chunks/dep-7da70ee1.js');
require('../_chunks/dep-124386d4.js');
require('../_chunks/dep-f5b14344.js');
require('../_chunks/dep-36c2788b.js');
require('../_chunks/dep-fa353fbb.js');
require('../_chunks/dep-d66ab3a4.js');
require('../_chunks/dep-d4d8c513.js');
require('../_common/js/global-config/t.js');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-a2217d56.js');
require('./interface.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var DescriptionsBody = VueCompositionAPI.defineComponent({
name: "TDescriptionsBody",
props: {
rows: Array,
itemType: String
},
setup: function setup() {
var descriptionsProps = VueCompositionAPI.inject(descriptions_const_index["default"]);
var COMPONENT_NAME = hooks_useConfig.usePrefixClass("descriptions");
var _useCommonClassName = hooks_useConfig.useCommonClassName(),
SIZE = _useCommonClassName.SIZE;
var _useConfig = configProvider_useConfig.useConfig("descriptions"),
global = _useConfig.global;
return {
descriptionsProps: descriptionsProps,
COMPONENT_NAME: COMPONENT_NAME,
SIZE: SIZE,
global: global
};
},
render: function render() {
var _this = this;
var h = arguments[0];
var props = this.$props;
var label = function label(node) {
var layout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "horizontal";
var labelClass = ["".concat(_this.COMPONENT_NAME, "__label")];
var label2 = null;
var span = null;
if (descriptions_utils_index.itemTypeIsProps(props.itemType)) {
label2 = node.label;
span = node.span;
} else {
label2 = descriptions_utils_index.renderVNodeTNode(node, "label");
var propsData = node.componentOptions.propsData || {};
span = propsData.span;
}
var labelSpan = layout === "horizontal" ? 1 : span;
return h("td", helper.helper([{
"attrs": {
"colspan": labelSpan
},
"class": labelClass
}, {
style: _this.descriptionsProps.labelStyle
}]), [label2, _this.descriptionsProps.colon && _this.global.colonText]);
};
var content = function content(node) {
var layout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "horizontal";
var contentClass = ["".concat(_this.COMPONENT_NAME, "__content")];
var content2 = null;
var span = null;
if (descriptions_utils_index.itemTypeIsProps(props.itemType)) {
content2 = node.content;
span = node.span;
} else {
content2 = descriptions_utils_index.renderVNodeTNode(node, "content", "default");
var propsData = node.componentOptions.propsData || {};
span = propsData.span;
}
var contentSpan = span > 1 && layout === "horizontal" ? span * 2 - 1 : span;
return h("td", helper.helper([{
"attrs": {
"colspan": contentSpan
},
"class": contentClass
}, {
style: _this.descriptionsProps.contentStyle
}]), [content2]);
};
var hh = function hh(row) {
return h("tr", [row.map(function (node) {
return [label(node), content(node)];
})]);
};
var hv = function hv(row) {
return [h("tr", [row.map(function (node) {
return label(node, "vertical");
})]), h("tr", [row.map(function (node) {
return content(node, "vertical");
})])];
};
var vh = function vh(row) {
return row.map(function (node) {
return h("tr", [label(node), content(node)]);
});
};
var vv = function vv(row) {
return row.map(function (node) {
return [h("tr", [label(node)]), h("tr", [content(node)])];
});
};
var renderRow = function renderRow(row) {
if (_this.descriptionsProps.layout === "horizontal") {
if (_this.descriptionsProps.itemLayout === "horizontal") {
return hh(row);
}
return hv(row);
}
if (_this.descriptionsProps.itemLayout === "horizontal") {
return vh(row);
}
return vv(row);
};
var tableClass = ["".concat(this.COMPONENT_NAME, "__body"), this.SIZE[this.descriptionsProps.size], _defineProperty__default["default"]({}, "".concat(this.COMPONENT_NAME, "__body--border"), this.descriptionsProps.bordered)];
return h("table", {
"class": tableClass
}, [h("tbody", [props.rows.map(function (row) {
return renderRow(row);
})])]);
}
});
exports["default"] = DescriptionsBody;
//# sourceMappingURL=descriptions-body.js.map