import { Check, Copy } from 'lucide-react'; import { MouseEvent, PropsWithChildren } from 'react'; import { useCopyToClipboard } from '../hooks/useCopyToClipboard'; import { cn } from '../utils/cn'; type JsonTreeCopyableItemProps = PropsWithChildren<{ getCopyableValue: () => string; className?: string; }>; export const JsonTreeCopyableItem = ({ children, getCopyableValue, className, }: JsonTreeCopyableItemProps) => { const { isCopied, copy } = useCopyToClipboard(); const handleCopy = (event: MouseEvent) => { event.stopPropagation(); copy(getCopyableValue()); }; const Icon = isCopied ? Check : Copy; return ( {children}
); };