import React, { FocusEvent, MouseEvent, KeyboardEvent, ReactElement } from 'react'; import { Placement } from '@floating-ui/react'; import * as CSS from 'csstype'; import { CommonProps } from '@contentful/f36-core'; type TooltipPlacement = Placement | 'auto'; type WithEnhancedContent = { /** * Content of the tooltip */ content?: ReactElement | string; /** * Accessible label property, only required when using a ReactElement as content */ label?: string; }; type TooltipInternalProps = { /** * Child nodes to be rendered as the trigger of the tooltip component. The tooltip will be displayed on hover or focus of the child element */ children: React.ReactNode; /** * HTML element used to wrap the target of the tooltip */ as?: React.ElementType; /** * A unique id of the tooltip */ id?: string; /** * It controls the initial visibility of the tooltip */ isVisible?: boolean; /** * It sets a max-width for the tooltip */ maxWidth?: number | CSS.Property.MaxWidth; /** * Set a delay period in milliseconds before hiding the tooltip */ hideDelay?: number; /** * Function that will be called when target gets blurred */ onBlur?: (evt: FocusEvent) => void; /** * Function that will be called when target gets focused */ onFocus?: (evt: FocusEvent) => void; /** * Function that will be called when the user move the mouse out of the target */ onMouseLeave?: (evt: MouseEvent) => void; /** * Function that will be called when the user move the mouse over of the target */ onMouseOver?: (evt: MouseEvent) => void; /** * Function that will be called when the user uses a keyboard key on the target */ onKeyDown?: (evt: KeyboardEvent) => void; /** * It sets the "preferred" position of the tooltip */ placement?: TooltipPlacement; /** * Set a delay period in milliseconds before showing the tooltip */ showDelay?: number; /** * Class names to be appended to the className prop of the tooltip’s target wrapper */ targetWrapperClassName?: string; /** * Boolean to control whether or not to render the tooltip in a React Portal. * Rendering content inside a Portal allows the tooltip to escape the bounds * of its parent while still being positioned correctly. Using a Portal is * necessary if an ancestor of the tooltip hides overflow. * * Defaults to `false` */ usePortal?: boolean; /** * Prevents showing the tooltip * @default false */ isDisabled?: boolean; /** * Whether the trigger should be wrapped in an element. * @default true */ withTriggerWrapper?: boolean; }; interface TooltipProps extends CommonProps, TooltipInternalProps, WithEnhancedContent { } declare const Tooltip: ({ children, className, as: HtmlTag, withTriggerWrapper, content, label, id, isVisible, hideDelay, onBlur, onFocus, onMouseLeave, onMouseOver, onKeyDown, showDelay, targetWrapperClassName, maxWidth, testId, placement, usePortal, isDisabled, ...otherProps }: TooltipProps) => React.JSX.Element; export { Tooltip, type TooltipInternalProps, type TooltipProps, type WithEnhancedContent };