ant-design/components/typography/Base/EllipsisTooltip.tsx

34 lines
733 B
TypeScript
Raw Normal View History

import * as React from 'react';
import Tooltip from '../../tooltip';
import type { TooltipProps } from '../../tooltip';
export interface EllipsisTooltipProps {
tooltipProps?: TooltipProps;
2024-03-11 10:33:05 +08:00
enableEllipsis: boolean;
isEllipsis?: boolean;
children: React.ReactElement;
}
const EllipsisTooltip: React.FC<EllipsisTooltipProps> = ({
2024-03-11 10:33:05 +08:00
enableEllipsis,
isEllipsis,
children,
tooltipProps,
}) => {
2024-03-11 10:33:05 +08:00
if (!tooltipProps?.title || !enableEllipsis) {
return children;
}
return (
<Tooltip open={isEllipsis ? undefined : false} {...tooltipProps}>
{children}
</Tooltip>
);
};
if (process.env.NODE_ENV !== 'production') {
EllipsisTooltip.displayName = 'EllipsisTooltip';
}
export default EllipsisTooltip;