|
@@ -9,7 +9,7 @@ import {
|
|
|
} from 'react';
|
|
|
import {createPortal} from 'react-dom';
|
|
|
import {Manager, Popper, PopperArrowProps, PopperProps, Reference} from 'react-popper';
|
|
|
-import {SerializedStyles} from '@emotion/react';
|
|
|
+import {SerializedStyles, useTheme} from '@emotion/react';
|
|
|
import styled from '@emotion/styled';
|
|
|
import {AnimatePresence, motion, MotionProps, MotionStyle} from 'framer-motion';
|
|
|
import * as PopperJS from 'popper.js';
|
|
@@ -96,6 +96,12 @@ export interface InternalTooltipProps {
|
|
|
*/
|
|
|
showOnlyOnOverflow?: boolean;
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether to add a dotted underline to the trigger element, to indicate the
|
|
|
+ * presence of a tooltip.
|
|
|
+ */
|
|
|
+ showUnderline?: boolean;
|
|
|
+
|
|
|
/**
|
|
|
* If child node supports ref forwarding, you can skip apply a wrapper
|
|
|
*/
|
|
@@ -137,6 +143,7 @@ export function DO_NOT_USE_TOOLTIP({
|
|
|
forceVisible,
|
|
|
isHoverable,
|
|
|
popperStyle,
|
|
|
+ showUnderline,
|
|
|
showOnlyOnOverflow,
|
|
|
skipWrapper,
|
|
|
title,
|
|
@@ -146,6 +153,7 @@ export function DO_NOT_USE_TOOLTIP({
|
|
|
}: InternalTooltipProps) {
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const tooltipId = useMemo(() => domId('tooltip-'), []);
|
|
|
+ const theme = useTheme();
|
|
|
|
|
|
// Delayed open and close time handles
|
|
|
const delayOpenTimeoutRef = useRef<number | undefined>(undefined);
|
|
@@ -234,13 +242,25 @@ export function DO_NOT_USE_TOOLTIP({
|
|
|
(skipWrapper || typeof triggerChildren.type === 'string')
|
|
|
) {
|
|
|
// Basic DOM nodes can be cloned and have more props applied.
|
|
|
- return cloneElement(triggerChildren, {...containerProps, ref: setRef});
|
|
|
+ return cloneElement(triggerChildren, {
|
|
|
+ ...containerProps,
|
|
|
+ style: {
|
|
|
+ ...triggerChildren.props.style,
|
|
|
+ ...(showUnderline && theme.tooltipUnderline),
|
|
|
+ },
|
|
|
+ ref: setRef,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
containerProps.containerDisplayMode = containerDisplayMode;
|
|
|
|
|
|
return (
|
|
|
- <Container {...containerProps} className={className} ref={setRef}>
|
|
|
+ <Container
|
|
|
+ {...containerProps}
|
|
|
+ style={showUnderline ? theme.tooltipUnderline : undefined}
|
|
|
+ className={className}
|
|
|
+ ref={setRef}
|
|
|
+ >
|
|
|
{triggerChildren}
|
|
|
</Container>
|
|
|
);
|