import { Tooltip, Typography } from "antd";

const TextEllipsisMiddle: React.FC<{ suffixCount?: number; children: string }> = ({
    suffixCount,
    children,
}) => {
    const sc = suffixCount ?? 3;
    const start = children.slice(0, children.length - sc).trim();
    const suffix = children.slice(-sc).trim();
    return (
        <Tooltip title={children}>
            <Typography.Text style={{ maxWidth: '100%' }} ellipsis={{ suffix }}>
                {start}
            </Typography.Text>
        </Tooltip>
    );
};

export default TextEllipsisMiddle;
