@@ -6,14 +6,10 @@ import type { GroupNode, HierarchyConfig, HierarchyNode } from "./types";
66// probe needs a home in the config.
77const UNGROUPED_LABEL = "Ungrouped" ;
88
9- // Top-level default when a node does not set `collapsible` and has no parent.
10- const ROOT_COLLAPSIBLE = true ;
11-
129// Resolves the explicit hierarchy against the given (already search-filtered)
1310// entries: attaches each entry to the node that lists its model id, prunes
1411// empty branches, and gathers anything unplaced into a trailing "Ungrouped"
15- // group. `collapsible` is resolved per node, inheriting the parent's value when
16- // the node does not set its own.
12+ // group. `collapsible` is per node and defaults to true.
1713export function groupEntries (
1814 entries : ManifestEntry [ ] ,
1915 config : HierarchyConfig ,
@@ -22,12 +18,12 @@ export function groupEntries(
2218 for ( const entry of entries ) byModel . set ( entry . model , entry ) ;
2319 const placed = new Set < string > ( ) ;
2420
25- const walk = ( node : HierarchyNode , inherited : boolean ) : GroupNode | null => {
26- const collapsible = node . collapsible ?? inherited ;
21+ const walk = ( node : HierarchyNode ) : GroupNode | null => {
22+ const collapsible = node . collapsible ?? true ;
2723
2824 if ( node . children ) {
2925 const children = node . children
30- . map ( ( child ) => walk ( child , collapsible ) )
26+ . map ( ( child ) => walk ( child ) )
3127 . filter ( ( child ) : child is GroupNode => child !== null ) ;
3228 if ( children . length === 0 ) return null ;
3329 const count = children . reduce ( ( sum , child ) => sum + child . count , 0 ) ;
@@ -47,7 +43,7 @@ export function groupEntries(
4743 } ;
4844
4945 const groups = config . hierarchy
50- . map ( ( node ) => walk ( node , ROOT_COLLAPSIBLE ) )
46+ . map ( ( node ) => walk ( node ) )
5147 . filter ( ( group ) : group is GroupNode => group !== null ) ;
5248
5349 const leftovers = entries . filter ( ( entry ) => ! placed . has ( entry . model ) ) ;
0 commit comments