@@ -43,17 +43,21 @@ function Language({
43
43
} ) : React . JSX . Element | null {
44
44
const scopeSupport = languageScopeSupport [ languageId ] ?? { } ;
45
45
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 ( ) ;
52
54
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
+ }
55
59
56
- if ( unsupportedScopes . length === 0 && unspecifiedScopes . length === 0 ) {
60
+ if ( unsupportedFacets . length === 0 && unspecifiedFacets . length === 0 ) {
57
61
return null ;
58
62
}
59
63
@@ -67,19 +71,19 @@ function Language({
67
71
</ small >
68
72
</ h3 >
69
73
70
- { renderFacets ( "Unsupported" , unsupportedScopes ) }
71
- { renderFacets ( "Unspecified" , unspecifiedScopes ) }
74
+ { renderFacets ( "Unsupported" , unsupportedFacets ) }
75
+ { renderFacets ( "Unspecified" , unspecifiedFacets ) }
72
76
</ >
73
77
) ;
74
78
}
75
79
76
80
function renderFacets (
77
81
title : string ,
78
- scopes : string [ ] ,
82
+ facets : string [ ] ,
79
83
) : React . JSX . Element | null {
80
- const [ open , setOpen ] = useState ( scopes . length < 4 ) ;
84
+ const [ open , setOpen ] = useState ( facets . length < 10 ) ;
81
85
82
- if ( scopes . length === 0 ) {
86
+ if ( facets . length === 0 ) {
83
87
return null ;
84
88
}
85
89
@@ -91,7 +95,7 @@ function renderFacets(
91
95
return (
92
96
< div className = "card__body" >
93
97
< ul >
94
- { scopes . map ( ( scope ) => {
98
+ { facets . map ( ( scope ) => {
95
99
return < li key = { scope } > { scope } </ li > ;
96
100
} ) }
97
101
</ ul >
@@ -102,22 +106,15 @@ function renderFacets(
102
106
return (
103
107
< div className = { "card" + ( open ? " open" : "" ) } >
104
108
< div className = "card__header pointer" onClick = { ( ) => setOpen ( ! open ) } >
105
- { title } ({ scopes . length } )
109
+ { title } ({ facets . length } )
106
110
</ div >
107
111
108
112
{ renderBody ( ) }
109
113
</ div >
110
114
) ;
111
115
}
112
116
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." ) ;
123
120
}
0 commit comments