diff --git a/src/components/copyable-input.tsx b/src/components/copyable-input.tsx index 2422c8276..90089927c 100644 --- a/src/components/copyable-input.tsx +++ b/src/components/copyable-input.tsx @@ -6,10 +6,14 @@ import { Button, HStack, Input } from './ui'; interface ICopyableInput { /** Text to be copied. */ value: string; + /** Input type. */ + type?: 'text' | 'password'; + /** Callback after the value has been copied. */ + onCopy?(): void; } /** An input with copy abilities. */ -const CopyableInput: React.FC = ({ value }) => { +const CopyableInput: React.FC = ({ value, type = 'text', onCopy }) => { const input = useRef(null); const selectInput = () => { @@ -20,13 +24,15 @@ const CopyableInput: React.FC = ({ value }) => { } else { document.execCommand('copy'); } + + onCopy?.(); }; return ( = ({ setSigner, setStep, onClose }) => { const [downloaded, setDownloaded] = useState(false); const handleDownload = () => { - download(nsec, `${slugify(instance.title)}-${npub.slice(5, 9)}.nsec`); + download(nsec, `${slugify(instance.title)}-${npub.slice(5, 9)}.nsec.txt`); setDownloaded(true); }; + const handleCopy = () => setDownloaded(true); + const handleNext = () => { const signer = NKeys.add(secretKey); setSigner(signer); @@ -50,8 +53,18 @@ const KeygenStep: React.FC = ({ setSigner, setStep, onClose }) => { - -