tdesign-vue
Version:
171 lines (163 loc) • 6.21 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var helper = require('../_chunks/dep-882fe8fa.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-6247fdbf.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-3ed0c42e.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-53935099.js');
require('dayjs');
require('../_chunks/dep-403352a7.js');
require('../_chunks/dep-cca66fee.js');
require('../_chunks/dep-4361b357.js');
require('../_chunks/dep-887c649b.js');
require('../_chunks/dep-411a10dd.js');
require('../_chunks/dep-5ea2b00f.js');
require('../_chunks/dep-51fe98f1.js');
require('../_chunks/dep-3d682642.js');
require('../_chunks/dep-dea23841.js');
require('../_chunks/dep-d7270eaf.js');
require('../_chunks/dep-9b72cbc5.js');
require('../_chunks/dep-4aa08166.js');
require('../_chunks/dep-ddc1429e.js');
require('../_chunks/dep-65896ff9.js');
require('../_chunks/dep-b65b2f55.js');
require('../_chunks/dep-6e7b8cda.js');
require('../_chunks/dep-98f48ff2.js');
require('../_chunks/dep-80e3757f.js');
require('../_chunks/dep-08d7842c.js');
require('../_chunks/dep-1ca3138c.js');
require('../_chunks/dep-e6ed4b1f.js');
require('../_chunks/dep-c44b2462.js');
require('../_common/js/global-config/t.js');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-6b60413b.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