@@ -7,9 +7,17 @@ import {
77import { useOnChange } from 'fumadocs-core/utils/use-on-change' ;
88import {
99 SearchDialog ,
10+ SearchDialogClose ,
11+ SearchDialogContent ,
12+ SearchDialogFooter ,
13+ SearchDialogHeader ,
14+ SearchDialogIcon ,
15+ SearchDialogInput ,
16+ SearchDialogList ,
17+ SearchDialogOverlay ,
1018 type SharedProps ,
11- type TagItem ,
1219 TagsList ,
20+ TagsListItem ,
1321} from 'fumadocs-ui/components/dialog/search' ;
1422import { type ReactNode , useState } from 'react' ;
1523
@@ -20,7 +28,7 @@ export interface OramaSearchDialogProps extends SharedProps {
2028 footer ?: ReactNode ;
2129 defaultTag ?: string ;
2230 whereTag ?: string ;
23- tags ?: TagItem [ ] ;
31+ tags ?: { name : string ; value : string } [ ] ;
2432
2533 /**
2634 * Add the "Powered by Orama" label
@@ -49,13 +57,14 @@ export default function OramaSearchDialog({
4957 showOrama = false ,
5058 allowClear = false ,
5159 index,
60+ footer,
5261 ...props
5362} : OramaSearchDialogProps ) : ReactNode {
5463 const [ tag , setTag ] = useState ( defaultTag ) ;
5564 let where = { } ;
5665 if ( whereTag ) {
5766 where = {
58- tag : { in : [ ...new Set ( [ tag , whereTag ] ) ] } ,
67+ tag : [ ...new Set ( [ tag , whereTag ] ) ] ,
5968 } ;
6069 }
6170 const { search, setSearch, query } = useDocsSearch (
@@ -80,27 +89,34 @@ export default function OramaSearchDialog({
8089 < SearchDialog
8190 search = { search }
8291 onSearchChange = { setSearch }
83- results = { query . data ?? [ ] }
8492 isLoading = { query . isLoading }
8593 { ...props }
86- footer = {
87- tags ? (
88- < >
89- < TagsList
90- tag = { tag }
91- onTagChange = { setTag }
92- items = { tags }
93- allowClear = { allowClear }
94- >
95- { showOrama ? < Label /> : null }
94+ >
95+ < SearchDialogOverlay />
96+ < SearchDialogContent >
97+ < SearchDialogHeader >
98+ < SearchDialogIcon />
99+ < SearchDialogInput />
100+ < SearchDialogClose />
101+ </ SearchDialogHeader >
102+ { query . data !== 'empty' && query . data && (
103+ < SearchDialogList items = { query . data } />
104+ ) }
105+ < SearchDialogFooter className = "flex flex-row" >
106+ { tags ? (
107+ < TagsList tag = { tag } onTagChange = { setTag } allowClear = { allowClear } >
108+ { tags . map ( ( { name, value } ) => (
109+ < TagsListItem key = { name } value = { value } >
110+ { name }
111+ </ TagsListItem >
112+ ) ) }
96113 </ TagsList >
97- { props . footer }
98- </ >
99- ) : (
100- props . footer
101- )
102- }
103- />
114+ ) : null }
115+ { showOrama ? < Label /> : null }
116+ { footer }
117+ </ SearchDialogFooter >
118+ </ SearchDialogContent >
119+ </ SearchDialog >
104120 ) ;
105121}
106122
0 commit comments