import { AnimatePresence, motion } from 'motion/react'; import { useTranslation } from 'react-i18next'; import styles from './selection-dialog.module.css'; import i18n from '/@/i18n/i18n'; import { ItemListStateActions, useItemListStateSubscription, } from '/@/renderer/components/item-list/helpers/item-list-state'; import { ContextMenuController } from '/@/renderer/features/context-menu/context-menu-controller'; import { ActionIcon } from '/@/shared/components/action-icon/action-icon'; import { animationProps } from '/@/shared/components/animations/animation-props'; import { Group } from '/@/shared/components/group/group'; import { HoverCard } from '/@/shared/components/hover-card/hover-card'; import { Icon } from '/@/shared/components/icon/icon'; import { Kbd } from '/@/shared/components/kbd/kbd'; import { Table } from '/@/shared/components/table/table'; import { Text } from '/@/shared/components/text/text'; const controls = [ { control1: CTRL, control2: A, label: i18n.t('action.selectAll', { postProcess: 'sentenceCase' }), }, { control1: CTRL, control2: , label: i18n.t('action.addOrRemoveFromSelection', { postProcess: 'sentenceCase' }), }, { control1: SHIFT, control2: , label: i18n.t('action.selectRangeOfItems', { postProcess: 'sentenceCase' }), }, ]; export const SelectionDialog = ({ internalState }: { internalState: ItemListStateActions }) => { const { t } = useTranslation(); const isListExpanded = useItemListStateSubscription(internalState, (state) => state ? state.expanded.size > 0 : false, ); const selectedCount = useItemListStateSubscription(internalState, (state) => state ? state.selected.size : 0, ); const handleClearSelection = () => { internalState.clearSelected(); }; const handleOpenMoreActions = (event: React.MouseEvent) => { event.preventDefault(); event.stopPropagation(); const selectedItems = internalState.getSelected(); if (selectedItems.length === 0) { return; } ContextMenuController.call({ cmd: { items: selectedItems as any[], type: (selectedItems[0] as any)._itemType }, event, }); }; const isOpen = selectedCount > 0; return ( {isOpen && ( {controls.map((control) => ( {control.control1} + {control.control2} {control.label} ))}
{t('common.countSelected', { count: selectedCount })}
)}
); };