import React, { useRef } from 'react'; import { FormattedMessage } from 'react-intl'; 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, type = 'text', onCopy }) => { const input = useRef(null); const selectInput = () => { input.current?.select(); if (navigator.clipboard) { navigator.clipboard.writeText(value); } else { document.execCommand('copy'); } onCopy?.(); }; return ( ); }; export { CopyableInput as default };