2022-01-18 14:13:41 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
const EllipsisTooltip = ({
|
|
|
|
enabledEllipsis,
|
|
|
|
isEllipsis,
|
|
|
|
children,
|
2022-07-25 13:09:39 +08:00
|
|
|
tooltipProps,
|
2022-01-18 14:13:41 +08:00
|
|
|
}: EllipsisTooltipProps) => {
|
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;
|