import type { FC, TeactNode } from '../../lib/teact/teact'; import React, { memo, useCallback, useRef } from '../../lib/teact/teact'; import type { TextPart } from '../../types'; import useLang from '../../hooks/useLang'; import useKeyboardListNavigation from '../../hooks/useKeyboardListNavigation'; import Modal from './Modal'; import Button from './Button'; type OwnProps = { isOpen: boolean; onClose: () => void; onCloseAnimationEnd?: () => void; title?: string; header?: TeactNode; textParts?: TextPart; text?: string; confirmLabel?: string; confirmHandler: () => void; confirmIsDestructive?: boolean; areButtonsInColumn?: boolean; children?: React.ReactNode; }; const ConfirmDialog: FC = ({ isOpen, onClose, onCloseAnimationEnd, title, header, text, textParts, confirmLabel = 'Confirm', confirmHandler, confirmIsDestructive, areButtonsInColumn, children, }) => { const lang = useLang(); // eslint-disable-next-line no-null/no-null const containerRef = useRef(null); const handleSelectWithEnter = useCallback((index: number) => { if (index === -1) confirmHandler(); }, [confirmHandler]); const handleKeyDown = useKeyboardListNavigation(containerRef, isOpen, handleSelectWithEnter, '.Button'); return ( {text && text.split('\\n').map((textPart) => (

{textPart}

))} {textParts || children}
); }; export default memo(ConfirmDialog);