import * as React from 'react'; import CheckOutlined from '@ant-design/icons/CheckOutlined'; import CopyOutlined from '@ant-design/icons/CopyOutlined'; import LoadingOutlined from '@ant-design/icons/LoadingOutlined'; import classNames from 'classnames'; import type { CopyConfig } from '.'; import type { Locale } from '../../locale'; import Tooltip from '../../tooltip'; import { getNode, toList } from './util'; export interface CopyBtnProps extends Omit { prefixCls: string; copied: boolean; locale: Locale['Text']; onCopy: React.MouseEventHandler; iconOnly: boolean; loading: boolean; } const CopyBtn: React.FC = ({ prefixCls, copied, locale, iconOnly, tooltips, icon, tabIndex, onCopy, loading: btnLoading, }) => { const tooltipNodes = toList(tooltips); const iconNodes = toList(icon); const { copied: copiedText, copy: copyText } = locale ?? {}; const systemStr = copied ? copiedText : copyText; const copyTitle = getNode(tooltipNodes[copied ? 1 : 0], systemStr); const ariaLabel = typeof copyTitle === 'string' ? copyTitle : systemStr; return ( ); }; export default CopyBtn;