mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 16:24:33 +00:00
Add buffer, skip-hover, will-change, and CSS contain properties to all RecycleScroller instances (DataGrid, ConnectionTree, ObjectBrowser, RedisKeyBrowser). Disable pointer-events during scroll in DataGrid to reduce repaint overhead.
32 lines
824 B
TypeScript
32 lines
824 B
TypeScript
import type { TreeNode, TreeNodeType } from "@/types/database";
|
|
|
|
export const SIDEBAR_TREE_ROW_HEIGHT = 28;
|
|
export const SIDEBAR_TREE_SCROLL_BUFFER = 600;
|
|
export const SIDEBAR_TREE_PRERENDER_COUNT = 48;
|
|
|
|
export interface FlatTreeNode {
|
|
node: TreeNode;
|
|
depth: number;
|
|
id: string;
|
|
type: TreeNodeType;
|
|
}
|
|
|
|
function walk(children: TreeNode[], depth: number, result: FlatTreeNode[]) {
|
|
for (const node of children) {
|
|
result.push({ node, depth, id: node.id, type: node.type });
|
|
if (node.isExpanded && node.children) {
|
|
walk(node.children, depth + 1, result);
|
|
}
|
|
}
|
|
}
|
|
|
|
export function flattenTree(nodes: TreeNode[]): FlatTreeNode[] {
|
|
const result: FlatTreeNode[] = [];
|
|
walk(nodes, 0, result);
|
|
return result;
|
|
}
|
|
|
|
export function shouldVirtualizeFlatTree(count: number): boolean {
|
|
return count > 0;
|
|
}
|