import clsx from 'clsx'; import classes from './MRT_CopyButton.module.css'; import { type ReactNode } from 'react'; import { CopyButton, Tooltip, UnstyledButton, type UnstyledButtonProps, } from '@mantine/core'; import { type MRT_Cell, type MRT_CellValue, type MRT_RowData, type MRT_TableInstance, } from '../../types'; import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends UnstyledButtonProps { cell: MRT_Cell; children: ReactNode; table: MRT_TableInstance; } export const MRT_CopyButton = ({ cell, children, table, ...rest }: Props) => { 'use no memo'; const { options: { localization: { clickToCopy, copiedToClipboard }, mantineCopyButtonProps, }, } = table; const { column, row } = cell; const { columnDef } = column; const arg = { cell, column, row, table }; const buttonProps = { ...parseFromValuesOrFunc(mantineCopyButtonProps, arg), ...parseFromValuesOrFunc(columnDef.mantineCopyButtonProps, arg), ...rest, }; return ( ()}> {({ copied, copy }) => ( { e.stopPropagation(); copy(); }} role="presentation" title={undefined} > {children} )} ); };