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

Function toggleExpanded

packages/core/src/widgets/tree.ts:309–326  ·  view source on GitHub ↗
(
  expanded: readonly string[],
  key: string,
)

Source from the content-addressed store, hash-verified

307 * @returns New expanded set and whether it's now expanded
308 */
309export function toggleExpanded(
310 expanded: readonly string[],
311 key: string,
312): { expanded: readonly string[]; isExpanded: boolean } {
313 const isCurrentlyExpanded = expanded.includes(key);
314
315 if (isCurrentlyExpanded) {
316 return {
317 expanded: collapseNode(expanded, key),
318 isExpanded: false,
319 };
320 }
321
322 return {
323 expanded: expandNode(expanded, key),
324 isExpanded: true,
325 };
326}
327
328/**
329 * Expand all siblings of a node (nodes at the same depth with same parent).

Callers 3

routeTreeKeyFunction · 0.50

Calls 2

collapseNodeFunction · 0.85
expandNodeFunction · 0.85

Tested by

no test coverage detected