ant-design/components/typography/Base/EllipsisTooltip.tsx
yykoypj 43d45330c5
feat: switch visible to open for Tooltip & Popover & Popconfirm (#36807)
* feat: switch visible to open for Tooltip

* feat: switch visible to open for Popover

* feat: switch visible to open for Popconfirm

* fix

* chore: resolve conflict

* test: fix test case

Co-authored-by: 二货机器人 <smith3816@gmail.com>
2022-08-24 21:34:17 +08:00

34 lines
726 B
TypeScript

import * as React from 'react';
import Tooltip from '../../tooltip';
import type { TooltipProps } from '../../tooltip';
export interface EllipsisTooltipProps {
tooltipProps?: TooltipProps;
enabledEllipsis: boolean;
isEllipsis?: boolean;
children: React.ReactElement;
}
const EllipsisTooltip = ({
enabledEllipsis,
isEllipsis,
children,
tooltipProps,
}: EllipsisTooltipProps) => {
if (!tooltipProps?.title || !enabledEllipsis) {
return children;
}
return (
<Tooltip open={isEllipsis ? undefined : false} {...tooltipProps}>
{children}
</Tooltip>
);
};
if (process.env.NODE_ENV !== 'production') {
EllipsisTooltip.displayName = 'EllipsisTooltip';
}
export default EllipsisTooltip;