import { MantineSize, Input } from "@mantine/core"; import { useState, useEffect } from "react"; import { IconCopy, IconCheck } from "@tabler/icons-react"; export interface CopyInputProps { value: string; caption: string; timeout?: number; size?: MantineSize; fullWidth?: boolean; onClick?: () => void; style?: React.CSSProperties; } export function CopyInput(props : CopyInputProps) { const { value, caption, timeout = 1200, size = 'sm', fullWidth = true, onClick, style } = props; const [copied, setCopied] = useState(false); useEffect(() => { if (!copied) return; const t = setTimeout(() => setCopied(false), timeout); return () => clearTimeout(t); }, [copied, timeout]); const handleCopy = async () => { try { await navigator.clipboard.writeText(value); setCopied(true); onClick?.(); } catch { // noop } }; return (