import { TldrawUiButton, TldrawUiDropdownMenuContent, TldrawUiDropdownMenuRoot, TldrawUiDropdownMenuTrigger, TldrawUiMenuCheckboxItem, TldrawUiMenuContextProvider, TldrawUiMenuGroup, useEditor, useTranslation, useValue, } from 'tldraw' import { MoreMenuIcon } from '../ui/icons' import { SidebarFilters } from './sidebar-filters' import { sidebarFilters } from './state' /** @public */ export interface CommentsFilterMenuProps { /** Whether to offer the "only your threads" toggle (needs a known current user). */ canFilterByAuthor?: boolean /** Whether to offer the "only unread" toggle (needs a read-status source). */ canFilterByUnread?: boolean } /** The funnel dropdown in the sidebar header: toggles for which threads the list shows. * @public @react */ export function CommentsFilterMenu({ canFilterByAuthor, canFilterByUnread, }: CommentsFilterMenuProps) { const editor = useEditor() const msg = useTranslation() const filters = useValue('sidebar filters', () => sidebarFilters.get(editor), [editor]) const toggle = (key: keyof SidebarFilters) => { sidebarFilters.update(editor, (f) => ({ ...f, [key]: !f[key] })) } return ( {/* No tlui-cmt-menu here: the rows are tldraw menu items, which carry their own insets — the extra padding would set this menu apart from the canvas menus it should match. */} toggle('onlyCurrentPage')} /> {canFilterByAuthor && ( toggle('onlyMine')} /> )} {canFilterByUnread && ( toggle('onlyUnread')} /> )} toggle('showResolved')} /> ) }