@@ -104,7 +104,8 @@ function showContent(content_id) {
104104function setPackageName ( name ) {
105105 setTextByClassName ( 'package-name' , name )
106106 if ( specData ) {
107- currentSpecs = packageData [ packageName ] . specs . map ( ( hash ) => specData [ hash ] ) ;
107+ const allSpecHashes = Object . values ( packageData [ name ] . specs ) . flat ( ) ;
108+ currentSpecs = allSpecHashes . map ( ( hash ) => specData [ hash ] ) ;
108109 setTextByClassName ( 'num-specs' , currentSpecs . length . toLocaleString ( ) )
109110 updateBadgeOptions ( ) ;
110111 }
@@ -130,7 +131,8 @@ function computePackageAttrValueSpecs() {
130131 packageAttrValueSpecs = { } ;
131132 for ( const pName in packageData ) {
132133 packageAttrValueSpecs [ pName ] = { } ;
133- for ( const specHash of packageData [ pName ] . specs ) {
134+ const allSpecHashes = Object . values ( packageData [ pName ] . specs ) . flat ( ) ;
135+ for ( const specHash of allSpecHashes ) {
134136 for ( const key in specData [ specHash ] ) {
135137 if ( ! packageAttrValueSpecs [ pName ] [ key ] ) packageAttrValueSpecs [ pName ] [ key ] = { } ;
136138 let values = specData [ specHash ] [ key ] ;
@@ -330,7 +332,12 @@ function filterSidebar() {
330332 match &&= matchComplete && matchingSpecs && matchingSpecs . size > 0 ;
331333 specCount . innerHTML = matchComplete && matchingSpecs ? matchingSpecs . size : 0
332334 } else {
333- specCount . innerHTML = packageData [ item . package ] . specs . length ;
335+ if ( item . release ) {
336+ specCount . innerHTML = packageData [ item . package ] . specs [ item . release ] . length ;
337+ } else {
338+ const allSpecHashes = Object . values ( packageData [ item . package ] . specs ) . flat ( ) ;
339+ specCount . innerHTML = allSpecHashes . length ;
340+ }
334341 }
335342 if ( match ) {
336343 resultsFound = true ;
@@ -342,11 +349,12 @@ function filterSidebar() {
342349 }
343350 } )
344351 Array . from ( document . getElementsByClassName ( 'sidebar-group' ) ) . forEach ( ( group ) => {
345- const childContainer = $ ( group ) . find ( 'ul' ) . get ( 0 ) ;
346- const childCounter = $ ( group ) . find ( '.child-counter' ) . get ( 0 ) ;
347- const matchedChildren = Array . from ( childContainer . children ) . filter ( ( child ) => ! child . classList . contains ( 'hidden' ) ) ;
348- childCounter . innerHTML = matchedChildren . length . toLocaleString ( ) ;
349- if ( matchedChildren . length && ( showDevs || ! group . release . includes ( 'develop' ) ) ) {
352+ const specCounts = $ ( group ) . find ( 'ul' ) . children ( ) . not ( '.hidden' ) . find ( '.spec-counter' ) . map (
353+ ( _ , item ) => parseInt ( $ ( item ) . text ( ) )
354+ ) . get ( )
355+ const specSum = specCounts . reduce ( ( acc , curr ) => acc + curr , 0 ) ;
356+ $ ( group ) . find ( '.child-counter' ) . text ( specSum ) ;
357+ if ( specCounts . length && ( showDevs || ! group . release . includes ( 'develop' ) ) ) {
350358 group . classList . remove ( 'hidden' ) ;
351359 if ( emphasisString . length > 0 ) group . classList . remove ( 'collapsed' ) ;
352360 } else {
@@ -406,9 +414,13 @@ function createSidebarItem(pkg, releaseName) {
406414 nameLabel . innerHTML = pkg . uid ;
407415 item . appendChild ( nameLabel ) ;
408416 const numSpecsLabel = document . createElement ( 'span' ) ;
409- numSpecsLabel . classList . add ( 'text-muted-foreground' ) ;
410- numSpecsLabel . innerHTML = pkg . specs . length ;
411- if ( releaseName ) numSpecsLabel . classList . add ( 'hidden' ) ;
417+ numSpecsLabel . classList . add ( 'text-muted-foreground' , 'spec-counter' ) ;
418+ if ( releaseName ) {
419+ numSpecsLabel . innerHTML = pkg . specs [ releaseName ] . length ;
420+ } else {
421+ const allSpecHashes = Object . values ( pkg . specs ) . flat ( ) ;
422+ numSpecsLabel . innerHTML = allSpecHashes . length ;
423+ }
412424 item . appendChild ( numSpecsLabel ) ;
413425 item . onclick = ( e ) => {
414426 e . stopPropagation ( ) ;
@@ -451,9 +463,9 @@ function createSidebarGroup(groupName) {
451463 groupNameLabel . classList . add ( 'truncate' , 'font-medium' , 'text-sm' ) ;
452464 groupNameLabel . innerHTML = groupName ;
453465 groupButton . appendChild ( groupNameLabel ) ;
454- const groupPackageCountLabel = document . createElement ( 'span' ) ;
455- groupPackageCountLabel . classList . add ( 'ml-auto' , 'text-xs' , 'text-muted-foreground' , 'child-counter' ) ;
456- groupButton . appendChild ( groupPackageCountLabel ) ;
466+ const groupSpecCountLabel = document . createElement ( 'span' ) ;
467+ groupSpecCountLabel . classList . add ( 'ml-auto' , 'text-xs' , 'text-muted-foreground' , 'child-counter' ) ;
468+ groupButton . appendChild ( groupSpecCountLabel ) ;
457469 groupContainer . appendChild ( groupButton ) ;
458470 group . appendChild ( groupContainer ) ;
459471 const childrenContainer = document . createElement ( 'ul' ) ;
0 commit comments