@@ -7,9 +7,17 @@ import {
7
7
import { useOnChange } from 'fumadocs-core/utils/use-on-change' ;
8
8
import {
9
9
SearchDialog ,
10
+ SearchDialogClose ,
11
+ SearchDialogContent ,
12
+ SearchDialogFooter ,
13
+ SearchDialogHeader ,
14
+ SearchDialogIcon ,
15
+ SearchDialogInput ,
16
+ SearchDialogList ,
17
+ SearchDialogOverlay ,
10
18
type SharedProps ,
11
- type TagItem ,
12
19
TagsList ,
20
+ TagsListItem ,
13
21
} from 'fumadocs-ui/components/dialog/search' ;
14
22
import { type ReactNode , useState } from 'react' ;
15
23
@@ -20,7 +28,7 @@ export interface OramaSearchDialogProps extends SharedProps {
20
28
footer ?: ReactNode ;
21
29
defaultTag ?: string ;
22
30
whereTag ?: string ;
23
- tags ?: TagItem [ ] ;
31
+ tags ?: { name : string ; value : string } [ ] ;
24
32
25
33
/**
26
34
* Add the "Powered by Orama" label
@@ -49,13 +57,14 @@ export default function OramaSearchDialog({
49
57
showOrama = false ,
50
58
allowClear = false ,
51
59
index,
60
+ footer,
52
61
...props
53
62
} : OramaSearchDialogProps ) : ReactNode {
54
63
const [ tag , setTag ] = useState ( defaultTag ) ;
55
64
let where = { } ;
56
65
if ( whereTag ) {
57
66
where = {
58
- tag : { in : [ ...new Set ( [ tag , whereTag ] ) ] } ,
67
+ tag : [ ...new Set ( [ tag , whereTag ] ) ] ,
59
68
} ;
60
69
}
61
70
const { search, setSearch, query } = useDocsSearch (
@@ -80,27 +89,34 @@ export default function OramaSearchDialog({
80
89
< SearchDialog
81
90
search = { search }
82
91
onSearchChange = { setSearch }
83
- results = { query . data ?? [ ] }
84
92
isLoading = { query . isLoading }
85
93
{ ...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
+ ) ) }
96
113
</ 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 >
104
120
) ;
105
121
}
106
122
0 commit comments