"use client" import * as React from "react" import { IconCheck, IconCopy } from "@tabler/icons-react" import { trackEvent, type Event } from "@/lib/events" import { cn } from "@/lib/utils" import { Button } from "@/registry/new-york-v4/ui/button" import { Tooltip, TooltipContent, TooltipTrigger, } from "@/registry/new-york-v4/ui/tooltip" export function copyToClipboardWithMeta(value: string, event?: Event) { navigator.clipboard.writeText(value) if (event) { trackEvent(event) } } export function CopyButton({ value, className, variant = "ghost", event, tooltip = "Copy to Clipboard", ...props }: React.ComponentProps & { value: string src?: string event?: Event["name"] tooltip?: string }) { const [hasCopied, setHasCopied] = React.useState(false) React.useEffect(() => { setTimeout(() => { setHasCopied(false) }, 2000) }, []) return ( {hasCopied ? "Copied" : tooltip} ) }