/** * This component is a light wrapper for react-popper, allowing us to position * and control the tooltip bubble location and visibility as we need. */ import * as React from "react"; import type { PopperChildrenProps } from "react-popper"; import type { RootBoundary } from "@popperjs/core"; import type { Placement, PopperElementProps, PopperUpdateFn } from "../util/types"; import RefTracker from "../util/ref-tracker"; type Props = { /** * This uses the children-as-a-function approach, mirroring react-popper's * implementation. * * TODO(WB-624): figure out to only allow TooltipBubble and PopoverDialog */ children: (arg1: PopperElementProps) => React.ReactNode; /** * The element that anchors the tooltip bubble. * This is used to position the bubble. */ anchorElement?: HTMLElement; /** Where should the bubble try to go with respect to its anchor. */ placement: Placement; /** * Whether the tooltip should automatically update its position when the * anchor element changes. */ autoUpdate?: boolean; /** * Optional property to set what the root boundary is for the popper behavior. * This is set to "viewport" by default, causing the popper to be positioned based * on the user's viewport. If set to "document", it will position itself based * on where there is available room within the document body. */ rootBoundary?: RootBoundary; /** * If `rootBoundary` is `viewport`, this padding value is used to provide * spacing between the popper and the viewport. If not provided, default * spacing of 12px is applied. */ viewportPadding?: number; }; type State = { /** * If the popper is ready to show content. */ isReady: boolean; }; type DefaultProps = { rootBoundary: Props["rootBoundary"]; viewportPadding: Props["viewportPadding"]; }; /** * A component that wraps react-popper's Popper component to provide a * consistent interface for positioning floating elements. */ export default class TooltipPopper extends React.Component { static defaultProps: DefaultProps; constructor(props: Props); /** * Automatically updates the position of the floating element when necessary * to ensure it stays anchored. * * NOTE: This is a temporary solution that checks for changes in the anchor * element's DOM. This is not a perfect solution and may not work in all * cases. It is recommended to use the autoUpdate prop only when necessary. * * TODO(WB-1680): Replace this with floating-ui's autoUpdate feature. * @see https://floating-ui.com/docs/autoupdate */ componentDidMount(): void; componentWillUnmount(): void; /** * A ref tracker for the bubble element. */ _bubbleRefTracker: RefTracker; /** * A ref tracker for the tail element. */ _tailRefTracker: RefTracker; /** * A MutationObserver that watches for changes to the anchor element. */ _observer: MutationObserver | null; /** * A function that can be called to update the popper. * @see https://popper.js.org/docs/v2/lifecycle/#manual-update */ _popperUpdate: PopperUpdateFn | null; _renderPositionedContent(popperProps: PopperChildrenProps): React.ReactNode; handleFirstUpdate: () => void; render(): React.ReactNode; } export {};