import { useState } from 'react'; import { Check, Copy } from 'lucide-react'; import { copyToClipboard } from 'helpers/clipboard'; // A read-only value with a copy button — addresses, invoices, txids, xpubs. // // Never used for anything secret. A mnemonic gets its own deliberately awkward treatment in // SeedBackupDialog rather than a one-tap copy, because "copied to clipboard" is where seeds go to die. type CopyFieldProps = { value: string; label?: string; /** Wrap rather than truncate — right for a bech32 address, wrong for a table cell. */ wrap?: boolean; className?: string; }; export const CopyField = ({ value, label, wrap = false, className = '' }: CopyFieldProps) => { const [copied, setCopied] = useState(false); const copy = async () => { if (!(await copyToClipboard(value))) return; setCopied(true); setTimeout(() => setCopied(false), 1_500); }; return (
{label && (
{label}
)}
{value}
); };