import { useEffect, useRef, type KeyboardEvent as ReactKeyboardEvent } from 'react' import { useTranslation } from 'react-i18next' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { parseShortcutKeys } from './utils' import { ShortcutKbdList } from './shortcut-kbd-list' interface ShortcutEditDialogProps { open: boolean draftShortcutValue: string isCaptureActive: boolean onCancel: () => void onConfirm: () => void onCaptureActivate: () => void onCaptureBlur: () => void onCaptureKeyDown: (event: ReactKeyboardEvent) => void } export function ShortcutEditDialog({ open, draftShortcutValue, isCaptureActive, onCancel, onConfirm, onCaptureActivate, onCaptureBlur, onCaptureKeyDown, }: ShortcutEditDialogProps) { const { t } = useTranslation() const captureRef = useRef(null) useEffect(() => { if (!open) { return } captureRef.current?.focus() }, [open]) const handleCaptureClick = () => { onCaptureActivate() captureRef.current?.focus() } return ( !nextOpen && onCancel()}> {t('SETTINGS_SET_SHORTCUT')} {t('SHORTCUT_BIND')}
) }