1 import type { FC, MouseEvent } from 'react';
3 import { c } from 'ttag';
5 import { Button, type ButtonLikeShape, type ButtonProps } from '@proton/atoms';
6 import { Icon, Tooltip } from '@proton/components';
7 import { usePassCore } from '@proton/pass/components/Core/PassCoreProvider';
9 type Props = ButtonProps & {
14 shape?: ButtonLikeShape;
17 export const Copy: FC<Props> = ({ children, value, onCopy, tooltipText, shape = 'outline', ...rest }) => {
18 const { writeToClipboard } = usePassCore();
20 const handleClick = async (e: MouseEvent<HTMLButtonElement>) => {
22 await writeToClipboard(value);
27 <Tooltip title={tooltipText || c('Label').t`Copy`}>
28 <Button icon color="weak" shape={shape} {...rest} onClick={handleClick}>
29 {children || <Icon name="squares" alt={c('Label').t`Copy`} />}