77 MarkdownIcon ,
88 Plus ,
99 Popover ,
10+ PopoverProps ,
1011 RichTextArea ,
1112 RichTextProvider ,
1213 RichTextToolbar ,
@@ -41,6 +42,7 @@ export function InlineBadgePopover({
4142 text,
4243 invalid,
4344 showOptional,
45+ align = "start" ,
4446 disabled,
4547 children,
4648 buttonClassName,
@@ -49,6 +51,7 @@ export function InlineBadgePopover({
4951 text : ReactNode ;
5052 invalid ?: boolean ;
5153 showOptional ?: boolean ;
54+ align ?: PopoverProps [ "align" ] ;
5255 disabled ?: boolean ;
5356 buttonClassName ?: string ;
5457 contentClassName ?: string ;
@@ -59,7 +62,7 @@ export function InlineBadgePopover({
5962 < Popover
6063 openPopover = { isOpen }
6164 setOpenPopover = { setIsOpen }
62- align = "start"
65+ align = { align }
6366 content = {
6467 < InlineBadgePopoverContext . Provider value = { { isOpen, setIsOpen } } >
6568 < AnimatedSizeContainer height width >
@@ -95,9 +98,10 @@ export function InlineBadgePopover({
9598 ) ;
9699}
97100
98- type MenuItem < T > = {
101+ export type InlineBadgePopoverMenuItem < T > = {
99102 icon ?: ReactNode ;
100103 text : string ;
104+ description ?: string ;
101105 value : T ;
102106 onSelect ?: ( ) => void ;
103107 preventClose ?: boolean ;
@@ -109,7 +113,7 @@ export function InlineBadgePopoverMenu<T extends any>({
109113 selectedValue,
110114 search,
111115} : {
112- items : MenuItem < T > [ ] ;
116+ items : InlineBadgePopoverMenuItem < T > [ ] ;
113117 onSelect ?: ( value : T ) => void ;
114118 selectedValue ?: T | T [ ] ;
115119 search ?: boolean ;
@@ -146,7 +150,9 @@ export function InlineBadgePopoverMenu<T extends any>({
146150 ) ;
147151
148152 const [ displayedItems , setDisplayedItems ] =
149- useState < MenuItem < T > [ ] > ( sortedItems ) ;
153+ useState < InlineBadgePopoverMenuItem < T > [ ] > ( sortedItems ) ;
154+
155+ const hasDescriptions = items . some ( ( item ) => item . description ) ;
150156
151157 // Update the displayed items to sorted when closed
152158 useEffect ( ( ) => {
@@ -166,32 +172,66 @@ export function InlineBadgePopoverMenu<T extends any>({
166172 < AnimatedSizeContainer height >
167173 < div className = "relative" >
168174 < Command . List
169- className = "scrollbar-hide flex max-h-64 max-w-52 flex-col gap-1 overflow-y-auto transition-all"
175+ className = { cn (
176+ "scrollbar-hide flex max-h-64 flex-col gap-1 overflow-y-auto transition-all" ,
177+ hasDescriptions ? "max-w-72" : "max-w-52" ,
178+ ) }
170179 ref = { scrollRef }
171180 onScroll = { updateScrollProgress }
172181 >
173182 { displayedItems . map (
174- ( { icon, text, value, onSelect : itemOnSelect , preventClose } ) => (
183+ ( {
184+ icon,
185+ text,
186+ description,
187+ value,
188+ onSelect : itemOnSelect ,
189+ preventClose,
190+ } ) => (
175191 < Command . Item
176- key = { text }
177- value = { `${ text } ${ value } ` }
192+ key = { String ( value ) }
193+ value = { `${ text } ${ description ?? "" } ${ value } ` }
178194 onSelect = { ( ) => {
179195 itemOnSelect ?.( ) ;
180196 onSelect ?.( value ) ;
181197 ! isMultiSelect && ! preventClose && setIsOpen ( false ) ;
182198 } }
183- className = "flex cursor-pointer items-center justify-between rounded-md px-1.5 py-1 transition-colors duration-150 data-[selected=true]:bg-neutral-100"
199+ className = { cn (
200+ "flex cursor-pointer justify-between rounded-md px-1.5 py-1 transition-colors duration-150 data-[selected=true]:bg-neutral-100" ,
201+ description ? "items-start gap-2 py-1.5" : "items-center" ,
202+ ) }
184203 >
185- < div className = "flex items-center gap-2" >
204+ < div
205+ className = { cn (
206+ "flex min-w-0 gap-2" ,
207+ description ? "items-start" : "items-center" ,
208+ ) }
209+ >
186210 { icon }
187- < span className = "text-content-default pr-3 text-left text-sm font-medium" >
188- { text }
189- </ span >
211+ { description ? (
212+ < div className = "flex min-w-0 flex-col gap-0.5 pr-2" >
213+ < span className = "text-content-default text-left text-sm font-medium" >
214+ { text }
215+ </ span >
216+ < span className = "text-content-subtle text-left text-xs font-normal leading-snug" >
217+ { description }
218+ </ span >
219+ </ div >
220+ ) : (
221+ < span className = "text-content-default pr-3 text-left text-sm font-medium" >
222+ { text }
223+ </ span >
224+ ) }
190225 </ div >
191226 { ( Array . isArray ( selectedValue )
192227 ? selectedValue . includes ( value )
193228 : selectedValue === value ) && (
194- < Check2 className = "text-content-emphasis size-3.5 shrink-0" />
229+ < Check2
230+ className = { cn (
231+ "text-content-emphasis size-3.5 shrink-0" ,
232+ description && "mt-0.5" ,
233+ ) }
234+ />
195235 ) }
196236 </ Command . Item >
197237 ) ,
0 commit comments