import React from 'react'; interface FabOutputCopyProps { text: string, onCopy?: () => void, label?: string, } /** * This component shows a read-only input text filled with the provided text. A button allows to copy the text to the clipboard. */ export const FabOutputCopy: React.FC = ({ label, text, onCopy }) => { const [copied, setCopied] = React.useState(false); /** * Copy the given text to the clipboard. */ const textToClipboard = () => { if (navigator?.clipboard?.writeText) { navigator.clipboard.writeText(text).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1000); if (onCopy) { onCopy(); } }); } }; return (
); };