UNPKG

@1771technologies/lytenyte-pro

Version:

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

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