import { Button } from '@documenso/ui/primitives/button'; import { Trans, useLingui } from '@lingui/react/macro'; import { DownloadIcon, FolderInputIcon, Trash2Icon, XCircleIcon, XIcon } from 'lucide-react'; import { useEffect } from 'react'; export type EnvelopesTableBulkActionBarProps = { selectedCount: number; onDownloadClick?: () => void; onMoveClick: () => void; onDeleteClick: () => void; onCancelClick?: () => void; onClearSelection: () => void; }; export const EnvelopesTableBulkActionBar = ({ selectedCount, onDownloadClick, onMoveClick, onDeleteClick, onCancelClick, onClearSelection, }: EnvelopesTableBulkActionBarProps) => { const { t } = useLingui(); useEffect(() => { if (selectedCount === 0) { return; } const onKeyDown = (event: KeyboardEvent) => { // Radix dismissable layers (dialogs, dropdowns, etc) call preventDefault // when handling Escape, so this only clears the selection when nothing // else consumed the key press. if (event.key === 'Escape' && !event.defaultPrevented) { onClearSelection(); } }; window.addEventListener('keydown', onKeyDown); return () => window.removeEventListener('keydown', onKeyDown); }, [selectedCount, onClearSelection]); if (selectedCount === 0) { return null; } return (