@@ -14,8 +14,7 @@ import type { Range } from "@tanstack/react-virtual";
1414import { DeclarationsContext } from "./schema/DeclarationsContext" ;
1515import { Declaration } from "../data/types" ;
1616import { DeclarationSidebarElement , SidebarGroupHeader , SidebarWrapper } from "./layout/Sidebar" ;
17- import { SidebarFilterContext } from "./layout/SidebarFilterContext" ;
18- import { SearchInput } from "./search/SearchBox" ;
17+ import { matchesWords , useParsedSearch } from "../utils/filtering" ;
1918import { GameSwitcher , S2VLogo } from "./layout/NavBar" ;
2019
2120type SidebarRow =
@@ -188,7 +187,7 @@ export const DeclarationsSidebar = ({
188187 sidebarOpen ?: boolean ;
189188} ) => {
190189 const { declarations, game } = useContext ( DeclarationsContext ) ;
191- const { filter , setFilter } = useContext ( SidebarFilterContext ) ;
190+ const { nameWords , moduleWords } = useParsedSearch ( ) ;
192191 const { module : activeModule = "" , scope = "" } = useParams ( ) ;
193192 const [ collapsed , setCollapsed ] = useState < Set < string > > ( ( ) => new Set ( ) ) ;
194193 const [ hydrated , setHydrated ] = useState ( false ) ;
@@ -197,14 +196,19 @@ export const DeclarationsSidebar = ({
197196 const { rows, stickyIndexes } = useMemo ( ( ) => {
198197 const rows : SidebarRow [ ] = [ ] ;
199198 const stickyIndexes : number [ ] = [ ] ;
200- const lower = filter ?. toLowerCase ( ) ;
199+ const hasNameFilter = nameWords . length > 0 ;
200+ const hasModuleFilter = moduleWords . length > 0 ;
201201 for ( const [ module , moduleMap ] of declarations ) {
202+ // Module filter (OR across module words, same as main search)
203+ if ( hasModuleFilter ) {
204+ const mod = module . toLowerCase ( ) ;
205+ if ( ! moduleWords . some ( ( w ) => mod . includes ( w ) ) ) continue ;
206+ }
202207 // Collect matching items (or all items if no filter)
203208 const items : Declaration [ ] = [ ] ;
204209 for ( const d of moduleMap . values ( ) ) {
205- if ( ! lower || d . name . toLowerCase ( ) . includes ( lower ) ) {
206- items . push ( d ) ;
207- }
210+ if ( hasNameFilter && ! matchesWords ( d . name , nameWords ) ) continue ;
211+ items . push ( d ) ;
208212 }
209213 if ( items . length === 0 ) continue ;
210214 stickyIndexes . push ( rows . length ) ;
@@ -216,7 +220,7 @@ export const DeclarationsSidebar = ({
216220 }
217221 }
218222 return { rows, stickyIndexes } ;
219- } , [ declarations , filter , collapsed ] ) ;
223+ } , [ declarations , nameWords , moduleWords , collapsed ] ) ;
220224
221225 const activeIndex = useMemo ( ( ) => {
222226 if ( ! scope || ! activeModule ) return - 1 ;
@@ -272,17 +276,6 @@ export const DeclarationsSidebar = ({
272276 </ SidebarBrand >
273277 < GameSwitcher currentGame = { game } />
274278 </ SidebarBrandRow >
275- < SidebarSearchInput
276- id = "sidebar-filter"
277- type = "search"
278- placeholder = "Filter…"
279- value = { filter }
280- onChange = { ( e ) => setFilter ( e . target . value ) }
281- aria-label = "Filter classes and enums"
282- spellCheck = { false }
283- autoCorrect = "off"
284- autoCapitalize = "off"
285- />
286279 </ SidebarHeader >
287280 { hydrated ? (
288281 < VirtualizedList
@@ -345,10 +338,6 @@ const SidebarBrand = styled.a`
345338 white-space: nowrap;
346339` ;
347340
348- const SidebarSearchInput = styled ( SearchInput ) `
349- background: var(--background);
350- ` ;
351-
352341const SidebarList = styled . div `
353342 flex: 1;
354343 overflow: auto;
0 commit comments