数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.1 KiB

2 years ago
import { defineComponent, inject, withDirectives, h } from 'vue';
2 years ago
import { isNil } from 'lodash-unified';
import '../../../utils/index.mjs';
import '../../../hooks/index.mjs';
import { descriptionsKey } from './token.mjs';
import { getNormalizedProps } from '../../../utils/vue/vnode.mjs';
import { addUnit } from '../../../utils/dom/style.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
var ElDescriptionsCell = defineComponent({
name: "ElDescriptionsCell",
props: {
cell: {
type: Object
},
tag: {
2 years ago
type: String,
default: "td"
2 years ago
},
type: {
type: String
}
},
setup() {
const descriptions = inject(descriptionsKey, {});
return {
descriptions
};
},
render() {
2 years ago
var _a, _b, _c, _d, _e, _f, _g;
2 years ago
const item = getNormalizedProps(this.cell);
2 years ago
const directives = (((_a = this.cell) == null ? void 0 : _a.dirs) || []).map((dire) => {
const { dir, arg, modifiers, value } = dire;
return [dir, value, arg, modifiers];
});
2 years ago
const { border, direction } = this.descriptions;
const isVertical = direction === "vertical";
2 years ago
const label = ((_d = (_c = (_b = this.cell) == null ? void 0 : _b.children) == null ? void 0 : _c.label) == null ? void 0 : _d.call(_c)) || item.label;
const content = (_g = (_f = (_e = this.cell) == null ? void 0 : _e.children) == null ? void 0 : _f.default) == null ? void 0 : _g.call(_f);
2 years ago
const span = item.span;
const align = item.align ? `is-${item.align}` : "";
const labelAlign = item.labelAlign ? `is-${item.labelAlign}` : align;
const className = item.className;
const labelClassName = item.labelClassName;
const style = {
width: addUnit(item.width),
minWidth: addUnit(item.minWidth)
};
const ns = useNamespace("descriptions");
switch (this.type) {
case "label":
2 years ago
return withDirectives(h(this.tag, {
2 years ago
style,
class: [
ns.e("cell"),
ns.e("label"),
ns.is("bordered-label", border),
ns.is("vertical-label", isVertical),
labelAlign,
labelClassName
],
colSpan: isVertical ? span : 1
2 years ago
}, label), directives);
2 years ago
case "content":
2 years ago
return withDirectives(h(this.tag, {
2 years ago
style,
class: [
ns.e("cell"),
ns.e("content"),
ns.is("bordered-content", border),
ns.is("vertical-content", isVertical),
align,
className
],
colSpan: isVertical ? span : span * 2 - 1
2 years ago
}, content), directives);
2 years ago
default:
2 years ago
return withDirectives(h("td", {
2 years ago
style,
class: [ns.e("cell"), align],
colSpan: span
}, [
!isNil(label) ? h("span", {
class: [ns.e("label"), labelClassName]
}, label) : void 0,
h("span", {
class: [ns.e("content"), className]
}, content)
2 years ago
]), directives);
2 years ago
}
}
});
export { ElDescriptionsCell as default };
//# sourceMappingURL=descriptions-cell.mjs.map