88 type ReactNode ,
99} from "react" ;
1010import type { ChatCircleIcon } from "../../shared/design-system/icons/index" ;
11+ import { Avatar } from "../../shared/design-system/ui/Avatar" ;
1112import { NavigationItem } from "../../shared/design-system/ui/NavigationItem" ;
1213import { NavigationSection } from "../../shared/design-system/ui/NavigationSection" ;
1314import { SearchField } from "../../shared/design-system/ui/SearchField" ;
@@ -23,6 +24,9 @@ export type SearchDestination = {
2324 matches ?: readonly number [ ] ;
2425 icon : typeof ChatCircleIcon ;
2526 image ?: string | undefined ;
27+ avatar ?:
28+ | { src ?: string | undefined ; shape : "circle" | "squircle" }
29+ | undefined ;
2630 run : ( ) => void ;
2731} ;
2832
@@ -144,12 +148,20 @@ export type SearchInputProps = {
144148 label ?: string ;
145149 placeholder ?: string | undefined ;
146150 scope ?: { label : string ; onRemove : ( ) => void } | undefined ;
151+ authorChip ?:
152+ | { label : string ; title : string ; onRemove : ( ) => void }
153+ | undefined ;
154+ displayQuery ?: string | undefined ;
155+ onDisplayQueryChange ?: ( ( value : string ) => void ) | undefined ;
147156} ;
148157
149158export function SearchChoices ( {
150159 groups,
151160 query,
152161 onQueryChange,
162+ authorChip,
163+ displayQuery,
164+ onDisplayQueryChange,
153165 input,
154166 label = "Search Buzz" ,
155167 placeholder = "Search pages, conversations and messages…" ,
@@ -220,6 +232,21 @@ export function SearchChoices({
220232 </ button >
221233 ) }
222234 < SearchField
235+ prefix = {
236+ authorChip ? (
237+ < span className = "search-palette-author-prefix" >
238+ < button
239+ type = "button"
240+ className = "search-palette-author-chip"
241+ aria-label = { `Remove author ${ authorChip . label } ` }
242+ title = { authorChip . title }
243+ onClick = { authorChip . onRemove }
244+ >
245+ < span aria-hidden = "true" > ×</ span > from:@{ authorChip . label }
246+ </ button >
247+ </ span >
248+ ) : undefined
249+ }
223250 inputRef = { input }
224251 role = "combobox"
225252 aria-controls = { id }
@@ -228,8 +255,8 @@ export function SearchChoices({
228255 aria-activedescendant = { selected ? optionId ( selected ) : undefined }
229256 label = { label }
230257 placeholder = { placeholder }
231- value = { query }
232- onValueChange = { onQueryChange }
258+ value = { displayQuery ?? query }
259+ onValueChange = { onDisplayQueryChange ?? onQueryChange }
233260 spellCheck = { false }
234261 autoCorrect = "off"
235262 autoCapitalize = "off"
@@ -308,7 +335,16 @@ export function SearchChoices({
308335 >
309336 < NavigationSection label = { label } >
310337 { destinations . map (
311- ( { key, label, detail, matches, icon, image, run } ) => (
338+ ( {
339+ key,
340+ label,
341+ detail,
342+ matches,
343+ icon,
344+ image,
345+ avatar,
346+ run,
347+ } ) => (
312348 < NavigationItem
313349 key = { key }
314350 id = { optionId ( key ) }
@@ -325,7 +361,17 @@ export function SearchChoices({
325361 }
326362 icon = {
327363 < span className = "grid size-6 shrink-0 place-items-center" >
328- < PageIcon icon = { icon } image = { image } size = { 17 } />
364+ { avatar ? (
365+ < Avatar
366+ alt = ""
367+ fallback = { label }
368+ src = { avatar . src }
369+ size = "small"
370+ shape = { avatar . shape }
371+ />
372+ ) : (
373+ < PageIcon icon = { icon } image = { image } size = { 17 } />
374+ ) }
329375 </ span >
330376 }
331377 label = {
0 commit comments