2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
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;
|
2022-01-18 14:13:41 +08:00
|
|
|
enabledEllipsis: boolean;
|
|
|
|
isEllipsis?: boolean;
|
|
|
|
children: React.ReactElement;
|
|
|
|
}
|
|
|
|
|
2023-07-28 12:15:30 +08:00
|
|
|
const EllipsisTooltip: React.FC<EllipsisTooltipProps> = ({
|
2022-01-18 14:13:41 +08:00
|
|
|
enabledEllipsis,
|
|
|
|
isEllipsis,
|
|
|
|
children,
|
2022-07-25 13:09:39 +08:00
|
|
|
tooltipProps,
|
2023-07-28 12:15:30 +08:00
|
|
|
}) => {
|
2022-07-25 13:09:39 +08:00
|
|
|
if (!tooltipProps?.title || !enabledEllipsis) {
|
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;
|