tdesign-vue
Version:
82 lines (78 loc) • 2.64 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import { getTNode } from '../util.js';
import { usePrefixClass } from '../../hooks/useConfig.js';
import '@babel/runtime/helpers/defineProperty';
import 'lodash-es';
import '@vue/composition-api';
import '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '../../_chunks/dep-b0659553.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-79359026.js';
import 'dayjs';
import '../../_common/js/global-config/t.js';
import '@babel/runtime/helpers/slicedToArray';
function useRenderLine(state) {
var componentName = usePrefixClass("tree").value;
var renderLine = function renderLine(h) {
var node = state.node,
treeScope = state.treeScope;
var scopedSlots = treeScope.scopedSlots;
var treeProps = (treeScope === null || treeScope === void 0 ? void 0 : treeScope.treeProps) || {};
var line = treeProps.line;
var iconVisible = !!treeProps.icon;
var lineNode = null;
if (line === true) {
if (scopedSlots !== null && scopedSlots !== void 0 && scopedSlots.line) {
lineNode = scopedSlots.line({
node: node === null || node === void 0 ? void 0 : node.getModel()
});
} else if (node.parent && node.tree) {
var vmIsLeaf = node.vmIsLeaf,
vmIsFirst = node.vmIsFirst,
level = node.level;
var lineClasses = [];
lineClasses.push("".concat(componentName, "__line"));
if (vmIsLeaf || !iconVisible) {
lineClasses.push("".concat(componentName, "__line--leaf"));
}
if (vmIsFirst && iconVisible) {
lineClasses.push("".concat(componentName, "__line--first"));
}
var shadowStyles = [];
var parents = node.getParents();
parents.pop();
parents.forEach(function (pnode, index) {
if (!pnode.vmIsLast) {
shadowStyles.push("calc(-".concat(index + 1, " * var(--space)) 0 var(--color)"));
}
});
var styles = {
"--level": level ? String(level) : void 0,
"box-shadow": shadowStyles.join(",")
};
lineNode = h("span", {
"class": lineClasses,
"style": styles
});
}
} else {
lineNode = getTNode(line, {
createElement: h,
node: node
});
}
return lineNode;
};
return {
renderLine: renderLine
};
}
export { useRenderLine as default };
//# sourceMappingURL=useRenderLine.js.map