import { cn } from '@langgenius/dify-ui/cn' import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from '@langgenius/dify-ui/dropdown-menu' import { RiArrowDownSLine, RiCheckLine, RiSortAsc, RiSortDesc } from '@remixicon/react' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' type Item = { value: number | string name: string } & Record type Props = Readonly<{ order?: string value: number | string items: Item[] onSelect: (value: string) => void }> function Sort({ order, value, items, onSelect, }: Props) { const { t } = useTranslation() const triggerContent = useMemo(() => { return items.find(item => item.value === value)?.name || '' }, [items, value]) return (
{t('filter.sortBy', { ns: 'appLog' })}
{triggerContent}
onSelect(`${order}${nextValue}`)} className="max-h-72 overflow-auto p-1" > {items.map(item => (
{item.name}
{value === item.value && }
))}
) } export default Sort