import { DocumentTextIcon, SpeakerWaveIcon, XMarkIcon, } from '@heroicons/react/24/outline'; import { MessageExtra } from '../utils/types'; import { useState } from 'react'; import { classNames } from '../utils/misc'; export default function ChatInputExtraContextItem({ items, removeItem, clickToShow, }: { items?: MessageExtra[]; removeItem?: (index: number) => void; clickToShow?: boolean; }) { const [show, setShow] = useState(-1); const showingItem = show >= 0 ? items?.[show] : undefined; if (!items) return null; return (
{items.map((item, i) => (
clickToShow && setShow(i)} tabIndex={0} aria-description={ clickToShow ? `Click to show: ${item.name}` : undefined } role={clickToShow ? 'button' : 'menuitem'} > {removeItem && (
)}
{item.type === 'imageFile' ? ( <> {`Preview ) : ( <>
{item.type === 'audioFile' ? ( ) : ( )}
{item.name ?? 'Extra content'}
)}
))} {showingItem && (
{showingItem.name ?? 'Extra content'}
{showingItem.type === 'imageFile' ? ( {`Preview ) : showingItem.type === 'audioFile' ? ( ) : (
                  {showingItem.content}
                
)}
setShow(-1)}>
)}
); }