import { ReactNode, useState } from 'react'; import { useTranslator } from '@luckystack/core/client'; export interface ConfirmMenuProps { title: string; content?: string | ReactNode; /** When set, the user must type this exact string before the confirm button enables. */ input?: string; /** Called with `true` (confirm) or `false` (cancel). The caller is responsible for closing the menu. */ resolve: (confirmed: boolean) => void; } export function ConfirmMenu({ title, content, input, resolve }: ConfirmMenuProps) { const translate = useTranslator(); const [inputValue, setInputValue] = useState(''); const inputRequiredAndInvalid = input ? input !== inputValue : false; return (
{ event.preventDefault(); if (inputRequiredAndInvalid) return; resolve(true); }} >

{title}

{typeof content === 'string' ? (

{content}

) : content} {input && (
{ setInputValue(e.target.value); }} className="h-9 px-3 rounded-md border border-container1-border bg-container1 text-title text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/30 transition-colors" />
)}
); }