@@ -43,17 +43,21 @@ function Language({
4343} ) : React . JSX . Element | null {
4444 const scopeSupport = languageScopeSupport [ languageId ] ?? { } ;
4545
46- const unsupportedFacets = scopeSupportFacets . filter (
47- ( facet ) => scopeSupport [ facet ] === ScopeSupportFacetLevel . unsupported ,
48- ) ;
49- const unspecifiedFacets = scopeSupportFacets . filter (
50- ( facet ) => scopeSupport [ facet ] == null ,
51- ) ;
46+ let unsupportedFacets = scopeSupportFacets
47+ . filter (
48+ ( facet ) => scopeSupport [ facet ] === ScopeSupportFacetLevel . unsupported ,
49+ )
50+ . sort ( ) ;
51+ let unspecifiedFacets = scopeSupportFacets
52+ . filter ( ( facet ) => scopeSupport [ facet ] == null )
53+ . sort ( ) ;
5254
53- const unsupportedScopes = facetsToScopes ( unsupportedFacets , showPrivate ) ;
54- const unspecifiedScopes = facetsToScopes ( unspecifiedFacets , showPrivate ) ;
55+ if ( ! showPrivate ) {
56+ unsupportedFacets = unsupportedFacets . filter ( ( f ) => ! isPrivate ( f ) ) ;
57+ unspecifiedFacets = unspecifiedFacets . filter ( ( f ) => ! isPrivate ( f ) ) ;
58+ }
5559
56- if ( unsupportedScopes . length === 0 && unspecifiedScopes . length === 0 ) {
60+ if ( unsupportedFacets . length === 0 && unspecifiedFacets . length === 0 ) {
5761 return null ;
5862 }
5963
@@ -67,19 +71,19 @@ function Language({
6771 </ small >
6872 </ h3 >
6973
70- { renderFacets ( "Unsupported" , unsupportedScopes ) }
71- { renderFacets ( "Unspecified" , unspecifiedScopes ) }
74+ { renderFacets ( "Unsupported" , unsupportedFacets ) }
75+ { renderFacets ( "Unspecified" , unspecifiedFacets ) }
7276 </ >
7377 ) ;
7478}
7579
7680function renderFacets (
7781 title : string ,
78- scopes : string [ ] ,
82+ facets : string [ ] ,
7983) : React . JSX . Element | null {
80- const [ open , setOpen ] = useState ( scopes . length < 4 ) ;
84+ const [ open , setOpen ] = useState ( facets . length < 10 ) ;
8185
82- if ( scopes . length === 0 ) {
86+ if ( facets . length === 0 ) {
8387 return null ;
8488 }
8589
@@ -91,7 +95,7 @@ function renderFacets(
9195 return (
9296 < div className = "card__body" >
9397 < ul >
94- { scopes . map ( ( scope ) => {
98+ { facets . map ( ( scope ) => {
9599 return < li key = { scope } > { scope } </ li > ;
96100 } ) }
97101 </ ul >
@@ -102,22 +106,15 @@ function renderFacets(
102106 return (
103107 < div className = { "card" + ( open ? " open" : "" ) } >
104108 < div className = "card__header pointer" onClick = { ( ) => setOpen ( ! open ) } >
105- { title } ({ scopes . length } )
109+ { title } ({ facets . length } )
106110 </ div >
107111
108112 { renderBody ( ) }
109113 </ div >
110114 ) ;
111115}
112116
113- function facetsToScopes ( facets : ScopeSupportFacet [ ] , showPrivate : boolean ) {
114- return Array . from (
115- new Set (
116- facets . map ( ( f ) =>
117- serializeScopeType ( scopeSupportFacetInfos [ f ] . scopeType ) ,
118- ) ,
119- ) ,
120- )
121- . filter ( ( scope ) => showPrivate || ! scope . startsWith ( "private." ) )
122- . sort ( ) ;
117+ function isPrivate ( facet : ScopeSupportFacet ) : boolean {
118+ const scopeType = serializeScopeType ( scopeSupportFacetInfos [ facet ] . scopeType ) ;
119+ return scopeType . startsWith ( "private." ) ;
123120}
0 commit comments