@@ -9,9 +9,10 @@ import {type Library, TAB_DEFS} from './constants';
9
9
import NoSearchResults from '@react-spectrum/s2/illustrations/linear/NoSearchResults' ;
10
10
import { OverlayTriggerStateContext , Provider , Dialog as RACDialog , DialogProps as RACDialogProps , Tab as RACTab , TabList as RACTabList , TabPanel as RACTabPanel , TabPanelProps as RACTabPanelProps , TabProps as RACTabProps , Tabs as RACTabs , SelectionIndicator , TabRenderProps } from 'react-aria-components' ;
11
11
import type { PageProps } from '@parcel/rsc' ;
12
- import React , { ReactNode , useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
12
+ import React , { ReactNode , useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
13
13
import { useId } from '@react-aria/utils' ;
14
14
15
+
15
16
interface MobileDialogProps extends Omit < RACDialogProps , 'className' | 'style' > {
16
17
size ?: 'S' | 'M' | 'L' | 'fullscreen' | 'fullscreenTakeover' ,
17
18
isDismissible ?: boolean ,
@@ -208,7 +209,7 @@ const MobileCustomDialog = function MobileCustomDialog(props: MobileDialogProps)
208
209
} ;
209
210
210
211
function MobileNav ( { pages, currentPage} : PageProps ) {
211
- let overlayTriggerState = React . useContext ( OverlayTriggerStateContext ) ;
212
+ let overlayTriggerState = useContext ( OverlayTriggerStateContext ) ;
212
213
let [ searchFocused , setSearchFocused ] = useState ( false ) ;
213
214
let [ searchValue , setSearchValue ] = useState ( '' ) ;
214
215
let [ selectedSection , setSelectedSection ] = useState < string | undefined > ( undefined ) ;
@@ -218,7 +219,7 @@ function MobileNav({pages, currentPage}: PageProps) {
218
219
219
220
let getSectionsForLibrary = useCallback ( ( libraryId : string ) => {
220
221
let sectionsMap = new Map ( ) ;
221
- let filteredPages = pages . filter ( page => getLibraryFromPage ( page ) === libraryId ) ;
222
+ let filteredPages = pages . filter ( page => getLibraryFromPage ( page ) === libraryId && ! page . exports ?. hideFromSearch ) ;
222
223
for ( let page of filteredPages ) {
223
224
let section = page . exports ?. section ?? 'Components' ;
224
225
let sectionPages = sectionsMap . get ( section ) ?? [ ] ;
@@ -243,7 +244,7 @@ function MobileNav({pages, currentPage}: PageProps) {
243
244
} ) ;
244
245
return sectionArray ;
245
246
} , [ getSectionsForLibrary , selectedLibrary ] ) ;
246
-
247
+
247
248
248
249
useEffect ( ( ) => {
249
250
// Auto-select first section initially or when library changes
@@ -296,9 +297,9 @@ function MobileNav({pages, currentPage}: PageProps) {
296
297
if ( ! searchValue . trim ( ) ) {
297
298
return pages ;
298
299
}
299
-
300
+
300
301
let searchLower = searchValue . toLowerCase ( ) ;
301
-
302
+
302
303
// Filter items where name or tags start with search value
303
304
let matchedPages = pages . filter ( page => {
304
305
let pageTitle = title ( page ) . toLowerCase ( ) ;
@@ -307,19 +308,19 @@ function MobileNav({pages, currentPage}: PageProps) {
307
308
let tagMatch = tags . some ( tag => tag . toLowerCase ( ) . startsWith ( searchLower ) ) ;
308
309
return nameMatch || tagMatch ;
309
310
} ) ;
310
-
311
+
311
312
// Sort to prioritize name matches over tag matches
312
313
return matchedPages . sort ( ( a , b ) => {
313
314
let aNameMatch = title ( a ) . toLowerCase ( ) . startsWith ( searchLower ) ;
314
315
let bNameMatch = title ( b ) . toLowerCase ( ) . startsWith ( searchLower ) ;
315
-
316
+
316
317
if ( aNameMatch && ! bNameMatch ) {
317
318
return - 1 ;
318
319
}
319
320
if ( ! aNameMatch && bNameMatch ) {
320
321
return 1 ;
321
322
}
322
-
323
+
323
324
// If both match by name or both match by tag, maintain original order
324
325
return 0 ;
325
326
} ) ;
@@ -328,9 +329,9 @@ function MobileNav({pages, currentPage}: PageProps) {
328
329
let getSectionContent = ( sectionName : string , libraryId : string , searchValue : string = '' ) : ComponentCardItem [ ] => {
329
330
let librarySections = getSectionsForLibrary ( libraryId ) ;
330
331
let pages = librarySections . get ( sectionName ) ?? [ ] ;
331
-
332
+
332
333
let filteredPages = filterPages ( pages , searchValue ) ;
333
-
334
+
334
335
return filteredPages
335
336
. sort ( ( a , b ) => title ( a ) . localeCompare ( title ( b ) ) )
336
337
. map ( page => ( { id : page . url . replace ( / ^ \/ / , '' ) , name : title ( page ) , href : page . url } ) ) ;
@@ -355,13 +356,13 @@ function MobileNav({pages, currentPage}: PageProps) {
355
356
} else {
356
357
items = getSectionContent ( section , libraryId , searchValue ) ;
357
358
}
358
-
359
+
359
360
// Sort to show "Introduction" first when search is empty
360
361
if ( searchValue . trim ( ) . length === 0 ) {
361
362
items = [ ...items ] . sort ( ( a , b ) => {
362
363
const aIsIntro = a . name === 'Introduction' ;
363
364
const bIsIntro = b . name === 'Introduction' ;
364
-
365
+
365
366
if ( aIsIntro && ! bIsIntro ) {
366
367
return - 1 ;
367
368
}
@@ -371,14 +372,14 @@ function MobileNav({pages, currentPage}: PageProps) {
371
372
return 0 ;
372
373
} ) ;
373
374
}
374
-
375
+
375
376
return items ;
376
377
} ;
377
378
378
379
let getSectionNamesForLibrary = ( libraryId : string ) => {
379
380
let librarySections = getSectionsForLibrary ( libraryId ) ;
380
381
let sectionArray = [ ...librarySections . keys ( ) ] ;
381
-
382
+
382
383
// Show 'Components' first
383
384
sectionArray . sort ( ( a , b ) => {
384
385
if ( a === 'Components' ) {
@@ -389,7 +390,7 @@ function MobileNav({pages, currentPage}: PageProps) {
389
390
}
390
391
return a . localeCompare ( b ) ;
391
392
} ) ;
392
-
393
+
393
394
return sectionArray ;
394
395
} ;
395
396
@@ -464,17 +465,17 @@ function MobileNav({pages, currentPage}: PageProps) {
464
465
{ libraries . map ( library => (
465
466
< MobileTabPanel key = { library . id } id = { library . id } >
466
467
< div className = { stickySearchContainer } >
467
- < SearchField
468
- aria-label = "Search"
468
+ < SearchField
469
+ aria-label = "Search"
469
470
value = { searchValue }
470
471
onChange = { handleSearchChange }
471
472
onFocus = { handleSearchFocus }
472
473
onBlur = { handleSearchBlur }
473
474
styles = { style ( { marginX : 16 } ) } />
474
475
< div className = { style ( { overflow : 'auto' , paddingX : 8 , paddingBottom : 8 } ) } >
475
476
< TagGroup
476
- aria-label = "Navigation sections"
477
- selectionMode = "single"
477
+ aria-label = "Navigation sections"
478
+ selectionMode = "single"
478
479
selectedKeys = { selectedSection ? [ selectedSection ] : [ ] }
479
480
onSelectionChange = { handleTagSelection }
480
481
UNSAFE_style = { { whiteSpace : 'nowrap' } }
0 commit comments