MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / createNodeItems

Function createNodeItems

app/hooks/useVirtualTree.ts:608–631  ·  view source on GitHub ↗
(
  nodes: T[],
  depth = 0,
  collapsedState: Record<string, boolean> = {}
)

Source from the content-addressed store, hash-verified

606}
607
608function createNodeItems<T extends { id: string; children?: T[] }>(
609 nodes: T[],
610 depth = 0,
611 collapsedState: Record<string, boolean> = {}
612): TreeNodeItem<T>[] {
613 return nodes.flatMap((node, index) => {
614 const children = node.children
615 ? collapsedState[node.id]
616 ? []
617 : createNodeItems(node.children, depth + 1, collapsedState)
618 : [];
619 return [
620 {
621 id: node.id,
622 depth,
623 node,
624 pos: index + 1,
625 size: nodes.length,
626 isCollapsed: !!collapsedState[node.id],
627 },
628 ...children,
629 ];
630 });
631}
632
633function createTreeProps<T extends { id: string; children?: T[] }>(
634 dispatch: Dispatch<TreeAction>

Callers 4

expandNodeFunction · 0.85
collapseNodeFunction · 0.85
toggleAllChildrenFunction · 0.85
useVirtualTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected