2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
2022-01-18 14:13:41 +08:00
|
|
|
import Tooltip from '../../tooltip';
|
2022-07-25 13:09:39 +08:00
|
|
|
import type { TooltipProps } from '../../tooltip';
|
2022-01-18 14:13:41 +08:00
|
|
|
|
|
|
|
export interface EllipsisTooltipProps {
|
2022-07-25 13:09:39 +08:00
|
|
|
tooltipProps?: TooltipProps;
|
2024-03-11 10:33:05 +08:00
|
|
|
enableEllipsis: boolean;
|
2022-01-18 14:13:41 +08:00
|
|
|
isEllipsis?: boolean;
|
|
|
|
children: React.ReactElement;
|
|
|
|
}
|
|
|
|
|
2023-07-28 12:15:30 +08:00
|
|
|
const EllipsisTooltip: React.FC<EllipsisTooltipProps> = ({
|
2024-03-11 10:33:05 +08:00
|
|
|
enableEllipsis,
|
2022-01-18 14:13:41 +08:00
|
|
|
isEllipsis,
|
|
|
|
children,
|
2022-07-25 13:09:39 +08:00
|
|
|
tooltipProps,
|
2023-07-28 12:15:30 +08:00
|
|
|
}) => {
|
2024-03-11 10:33:05 +08:00
|
|
|
if (!tooltipProps?.title || !enableEllipsis) {
|
2022-01-18 14:13:41 +08:00
|
|
|
return children;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-08-26 17:17:13 +08:00
|
|
|
<Tooltip open={isEllipsis ? undefined : false} {...tooltipProps}>
|
2022-01-18 14:13:41 +08:00
|
|
|
{children}
|
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
EllipsisTooltip.displayName = 'EllipsisTooltip';
|
|
|
|
}
|
|
|
|
|
|
|
|
export default EllipsisTooltip;
|