Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.2 KB
Raw Blame
import React from 'react';
import { Copy } from 'lucide';
import ActionButton from '~/components/Messages/Content/ActionButton';
import { useLocalize } from '~/hooks';

interface CopyButtonProps {
  isCopied: boolean;
  iconOnly?: boolean;
  onClick: () => void;
  tabIndex?: number;
  className?: string;
  label?: string;
  copiedLabel?: string;
  portalElement?: HTMLElement | null;
  disabled?: boolean;
}

const CopyButton = React.forwardRef<HTMLButtonElement, CopyButtonProps>(
  (
    {
      isCopied,
      iconOnly = false,
      onClick,
      tabIndex,
      className,
      label,
      copiedLabel,
      portalElement,
      disabled,
    },
    ref,
  ) => {
    const localize = useLocalize();

    return (
      <ActionButton
        ref={ref}
        icon={Copy}
        isActive={isCopied}
        label={label ?? localize('com_ui_copy')}
        activeLabel={copiedLabel ?? localize('com_ui_copied')}
        iconOnly={iconOnly}
        onClick={onClick}
        tabIndex={tabIndex}
        className={className}
        portalElement={portalElement}
        disabled={disabled}
      />
    );
  },
);

CopyButton.displayName = 'CopyButton';

export default CopyButton;