@@ -101,6 +101,10 @@ export default function stateModelFactory(
101101 * #volatile
102102 */
103103 volatileTree : undefined as any ,
104+ /**
105+ * #volatile
106+ */
107+ highlightedRowNames : undefined as string [ ] | undefined ,
104108 } ) )
105109 . actions ( self => ( {
106110 /**
@@ -150,6 +154,12 @@ export default function stateModelFactory(
150154 setShowAsUpperCase ( arg : boolean ) {
151155 self . showAsUpperCase = arg
152156 } ,
157+ /**
158+ * #action
159+ */
160+ setHighlightedRowNames ( names ?: string [ ] ) {
161+ self . highlightedRowNames = names
162+ } ,
153163 } ) )
154164 . views ( self => ( {
155165 /**
@@ -238,6 +248,38 @@ export default function stateModelFactory(
238248 get leaves ( ) {
239249 return self . root ?. leaves ( )
240250 } ,
251+ /**
252+ * #getter
253+ */
254+ get leafMap ( ) {
255+ return new Map ( this . leaves ?. map ( leaf => [ leaf . data . name , leaf ] ) )
256+ } ,
257+ /**
258+ * #getter
259+ * Precomputed map from hierarchy node to its descendant leaf names
260+ */
261+ get nodeDescendantNames ( ) {
262+ const map = new Map < unknown , string [ ] > ( )
263+ function computeDescendants (
264+ node : HierarchyNode < NodeWithIdsAndLength > ,
265+ ) : string [ ] {
266+ if ( ! node . children || node . children . length === 0 ) {
267+ const names = [ node . data . name ]
268+ map . set ( node , names )
269+ return names
270+ }
271+ const names : string [ ] = [ ]
272+ for ( const child of node . children ) {
273+ names . push ( ...computeDescendants ( child ) )
274+ }
275+ map . set ( node , names )
276+ return names
277+ }
278+ if ( this . hierarchy ) {
279+ computeDescendants ( this . hierarchy )
280+ }
281+ return map
282+ } ,
241283 /**
242284 * #getter
243285 */
@@ -377,6 +419,12 @@ export default function stateModelFactory(
377419 0 ,
378420 )
379421 } ,
422+ /**
423+ * #getter
424+ */
425+ get sidebarWidth ( ) {
426+ return this . labelWidth + 5 + self . treeWidth
427+ } ,
380428 } ) )
381429 . actions ( self => ( {
382430 afterCreate ( ) {
0 commit comments