import React, { useEffect, useState } from 'react'; import { strings } from '../res/strings'; import { stringsEn } from '../res/strings.en'; import { useAppStrings } from '@/os/useAppStrings'; export const InputDialog: React.FC<{ open: boolean; title: string; defaultValue?: string; placeholder?: string; inputType?: React.HTMLInputTypeAttribute; confirmText?: string; /** Allow confirming empty string */ allowEmpty?: boolean; onClose: () => void; onConfirm: (value: string) => void; }> = ({ open, title, defaultValue = '', placeholder, inputType = 'text', confirmText, allowEmpty = false, onClose, onConfirm, }) => { const s = useAppStrings(strings, stringsEn); const [value, setValue] = useState(defaultValue); useEffect(() => { if (open) setValue(defaultValue); }, [open, defaultValue]); if (!open) return null; const trimmed = value.trim(); const canConfirm = allowEmpty ? true : !!trimmed; const confirmValue = allowEmpty ? value : trimmed; return (