UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

21 lines (20 loc) 631 B
import { useEvent } from "@1771technologies/lytenyte-core/internal"; export function useRowLeafs(tree) { const rowLeafs = useEvent((id) => { const node = tree.rowIdToNode.get(id); if (!node || !node.row.expandable) return []; const rows = []; const stack = [...node.children.values()]; while (stack.length) { const next = stack.pop(); if (!next.row.expandable) rows.push(next.row.id); else { stack.push(...next.children.values()); } } return rows; }); return rowLeafs; }