UNPKG

vxe-table

Version:

A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.

117 lines (116 loc) • 3.53 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var tree_exports = {}; __export(tree_exports, { getTreeNodeLines: () => getTreeNodeLines }); module.exports = __toCommonJS(tree_exports); function getTreeNodeLines(isExpandable, depth, linesMask, isFirstRow, isLastRow, showRootLine) { const lines = []; for (let col = 1; col <= depth; col++) { const leftVal = `var(--vxe-ui-table-tree-node-btn-width) + var(--vxe-ui-table-current-tree-node-indent) * ${col - 1}`; const through = (linesMask & 1 << col - 1) !== 0; if (col === 1 && !showRootLine) { continue; } if (col < depth) { if (through) { let top = "0"; let height = "100%"; if (isFirstRow) { top = "50%"; height = "50%"; } else if (isLastRow) { top = "0"; height = "50%"; } lines.push({ type: "v", style: { left: `calc(${leftVal})`, top, height } }); } } else { let vTop = "0"; let vHeight = through ? "100%" : "50%"; if (isFirstRow && isLastRow) { vTop = "50%"; vHeight = "0px"; } else if (isFirstRow) { vTop = "50%"; vHeight = "50%"; } else if (isLastRow) { vTop = "0"; vHeight = "50%"; } if (isExpandable && vHeight !== "0px") { let cutType = "v cut"; if (vTop === "0" && vHeight === "50%") { cutType = "v cut-top"; } else if (vTop === "50%" && vHeight === "50%") { cutType = "v cut-bottom"; } else if (vHeight === "100%") { cutType = "v cut-full"; } lines.push({ type: cutType, style: { left: `calc(${leftVal})`, top: vTop, height: vHeight } }); } else { if (vHeight !== "0px") { lines.push({ type: "v", style: { left: `calc(${leftVal})`, top: vTop, height: vHeight } }); } } if (isExpandable) { lines.push({ type: "h", style: { left: `calc(${leftVal} + var(--vxe-ui-table-tree-node-btn-width) / 2 + 1px)`, top: "50%", width: "calc(var(--vxe-ui-table-current-tree-node-indent) - var(--vxe-ui-table-tree-node-btn-width) - 0.2em)" } }); } else { lines.push({ type: "h", style: { left: `calc(${leftVal})`, top: "50%", width: "calc(var(--vxe-ui-table-current-tree-node-indent) - var(--vxe-ui-table-tree-node-btn-width) / 2 - 0.1em)" } }); } } } return lines; }