MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / computeNodeState

Function computeNodeState

packages/core/src/widgets/tree.ts:123–143  ·  view source on GitHub ↗
(
  flatNode: FlattenedNode<T>,
  expanded: readonly string[],
  selected: string | undefined,
  focused: string | undefined,
  loading: ReadonlySet<string>,
  expandedSet?: ReadonlySet<string>,
)

Source from the content-addressed store, hash-verified

121 * @returns NodeState for the node
122 */
123export function computeNodeState<T>(
124 flatNode: FlattenedNode<T>,
125 expanded: readonly string[],
126 selected: string | undefined,
127 focused: string | undefined,
128 loading: ReadonlySet<string>,
129 expandedSet?: ReadonlySet<string>,
130): NodeState {
131 const expandedLookup = expandedSet ?? new Set(expanded);
132
133 return Object.freeze({
134 expanded: expandedLookup.has(flatNode.key),
135 selected: flatNode.key === selected,
136 focused: flatNode.key === focused,
137 loading: loading.has(flatNode.key),
138 depth: flatNode.depth,
139 isFirst: flatNode.siblingIndex === 0,
140 isLast: flatNode.siblingIndex === flatNode.siblingCount - 1,
141 hasChildren: flatNode.hasChildren,
142 });
143}
144
145/* ========== Tree Line Characters ========== */
146

Callers 2

renderCollectionWidgetFunction · 0.85

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected