2022-07-13 23:06:28 +08:00
|
|
|
import classNames from 'classnames';
|
2023-02-15 10:21:28 +08:00
|
|
|
import { Popup } from 'rc-tooltip';
|
2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2022-07-13 23:06:28 +08:00
|
|
|
import type { TooltipProps } from '.';
|
|
|
|
import { ConfigContext } from '../config-provider';
|
|
|
|
|
2022-07-14 12:06:18 +08:00
|
|
|
import useStyle from './style';
|
2022-09-22 16:55:55 +08:00
|
|
|
import { parseColor } from './util';
|
2022-07-14 12:06:18 +08:00
|
|
|
|
|
|
|
export interface PurePanelProps extends Omit<TooltipProps, 'children'> {}
|
2022-07-13 23:06:28 +08:00
|
|
|
|
|
|
|
// ant-tooltip css-dev-only-do-not-override-w2s56n ant-tooltip-placement-top ant-tooltip-hidden
|
|
|
|
|
|
|
|
export default function PurePanel(props: PurePanelProps) {
|
2022-09-22 16:55:55 +08:00
|
|
|
const {
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
className,
|
|
|
|
placement = 'top',
|
|
|
|
title,
|
|
|
|
color,
|
|
|
|
overlayInnerStyle,
|
|
|
|
} = props;
|
2022-07-13 23:06:28 +08:00
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
|
|
|
|
const prefixCls = getPrefixCls('tooltip', customizePrefixCls);
|
|
|
|
const [wrapSSR, hashId] = useStyle(prefixCls, true);
|
|
|
|
|
2022-09-22 16:55:55 +08:00
|
|
|
// Color
|
|
|
|
const colorInfo = parseColor(prefixCls, color);
|
|
|
|
const formattedOverlayInnerStyle = { ...overlayInnerStyle, ...colorInfo.overlayStyle };
|
|
|
|
const arrowContentStyle = colorInfo.arrowStyle;
|
|
|
|
|
2022-07-13 23:06:28 +08:00
|
|
|
return wrapSSR(
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
hashId,
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-pure`,
|
|
|
|
`${prefixCls}-placement-${placement}`,
|
|
|
|
className,
|
2022-09-22 16:55:55 +08:00
|
|
|
colorInfo.className,
|
2022-07-13 23:06:28 +08:00
|
|
|
)}
|
2022-09-22 16:55:55 +08:00
|
|
|
style={arrowContentStyle}
|
2022-07-13 23:06:28 +08:00
|
|
|
>
|
2023-02-15 10:21:28 +08:00
|
|
|
<div className={`${prefixCls}-arrow`} />
|
2022-09-22 16:55:55 +08:00
|
|
|
<Popup
|
|
|
|
{...props}
|
|
|
|
className={hashId}
|
|
|
|
prefixCls={prefixCls}
|
|
|
|
overlayInnerStyle={formattedOverlayInnerStyle}
|
|
|
|
>
|
2022-07-14 12:06:18 +08:00
|
|
|
{title}
|
|
|
|
</Popup>
|
2022-07-13 23:06:28 +08:00
|
|
|
</div>,
|
|
|
|
);
|
|
|
|
}
|