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

* fix lint

* fix: merge state

* chore: Update ts part

* test: add legacy test

* test: fix test case

Co-authored-by: 二货机器人 <smith3816@gmail.com>
2022-08-26 17:17:13 +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;