tdesign-vue
Version:
169 lines (161 loc) • 6.12 kB
JavaScript
/**
* tdesign v1.11.2
* (c) 2025 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var helper = require('../_chunks/dep-ece3c062.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-07fb8c0e.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-a4a18104.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-27dd8cc6.js');
require('dayjs');
require('../_chunks/dep-87c765cc.js');
require('../_chunks/dep-75cd6d52.js');
require('../_chunks/dep-b1a02818.js');
require('../_chunks/dep-3d8ab37d.js');
require('../_chunks/dep-ecccff93.js');
require('../_chunks/dep-a4308f57.js');
require('../_chunks/dep-a4cecac4.js');
require('../_chunks/dep-ab142eaf.js');
require('../_chunks/dep-6ad3de7c.js');
require('../_chunks/dep-e4278c54.js');
require('../_chunks/dep-fcf0662d.js');
require('../_chunks/dep-8b1e056e.js');
require('../_chunks/dep-5db8defc.js');
require('../_chunks/dep-6e4c473c.js');
require('../_chunks/dep-234b7c02.js');
require('../_chunks/dep-a4747856.js');
require('../_chunks/dep-932dd69e.js');
require('../_chunks/dep-9f4caea4.js');
require('../_chunks/dep-dbd838d6.js');
require('../_chunks/dep-b3120c1b.js');
require('../_chunks/dep-68ba2357.js');
require('../_chunks/dep-173eb46c.js');
require('./interface.js');
require('../_chunks/dep-738b4f21.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