import "./tooltip.css";
import type * as React from "react";
import { Tooltip as Base } from "@base-ui/react/tooltip";
import { type StyleProps } from "./style_props";
export type TooltipSide = "top" | "bottom" | "left" | "right";
/**
* The kit's tooltip timing, mounted once at the app root. It is no longer a
* PORTAL host — every tooltip portals itself — so a tree that forgets it still
* shows tooltips, on the same timing each root states for itself.
*
* What it is still worth mounting for is a RAW Base UI tooltip in the same tree:
* one written without a `delay` reads the provider's, so a hint the kit did not
* render still appears when the kit's would.
*/
export declare function TooltipProvider({ children }: {
children: React.ReactNode;
}): React.JSX.Element;
export interface UseTooltipOptions {
text?: string;
side?: TooltipSide;
offset?: number;
}
/**
* The `tooltip` prop, normalised: a bare string is the text, an object may also
* place it, and either may be empty — which is NO tooltip rather than an empty
* one. Every control that takes a `tooltip` reads it through here, so "what does
* a blank tooltip mean" has one answer.
*/
export declare function tooltipHint(tooltip: string | UseTooltipOptions | undefined): {
text: string;
side?: TooltipSide;
offset?: number;
} | undefined;
interface TooltipBaseProps {
/** Controlled open state. */
open?: boolean;
onOpenChange?: (open: boolean) => void;
defaultOpen?: boolean;
/** Which side of the trigger the popup takes. */
side?: TooltipSide;
/** Gap between trigger and popup, in px. */
offset?: number;
}
/**
* `label` collapses the whole of the common case — a short hint on one control —
* into one element, and switches what `children` MEANS: the trigger itself,
* rather than the composed parts. Both shapes are the same component because a
* hint is a mode of a tooltip, not a second component.
*/
export type TooltipProps = TooltipBaseProps & ({
label: string;
children: React.ReactElement;
} | {
label?: undefined;
children: React.ReactNode;
});
/**
* A hint on hover or keyboard focus.
*
* ```tsx
* {button}
*
*
* {button}
* Longer hint
*
* ```
*
* A tooltip is SUPPLEMENTARY: it never carries information a touch user or a
* screen reader needs, because it is suppressed on touch. Where the trigger's
* whole purpose is to open the popup, that is an `InfoPopover`.
*/
export declare function Tooltip(props: TooltipProps): React.JSX.Element;
export interface TooltipTriggerProps {
children: React.ReactElement;
}
/**
* The element the tooltip describes. It is rendered AS the trigger rather than
* wrapped in one, so nothing is added to the layout — which means the child has
* to forward the props it is handed.
*/
export declare function TooltipTrigger({ children }: TooltipTriggerProps): React.JSX.Element;
export interface TooltipContentProps extends StyleProps {
children: React.ReactNode;
ref?: React.Ref;
render?: Base.Popup.Props["render"];
testID?: string;
}
/**
* The popup. `className`/`style` land on it; the positioner — which carries the
* overlay rung — is `lotics-tooltip__positioner`.
*
* `role="tooltip"` is the KIT'S, because Base UI writes no role on this part at
* all: it treats a tooltip as paint for sighted users and leaves the trigger's
* own `aria-label` to carry the meaning. A popup with no role is a `div` — it
* announces as nothing, and nothing that audits a page (or asserts one) can find
* a hint to check. WAI-ARIA names the element `tooltip`, so it says so.
*
* It stops at the role. `aria-describedby` on the trigger is deliberately NOT
* written: the kit's `tooltip` prop is also the accessible NAME of an icon-only
* control (`IconButton`), so a description pointing at the same words would
* announce the control twice — and Base UI unmounts the popup when it closes, so
* the reference would dangle for all but the moment it is open.
*/
export declare function TooltipContent({ children, ref, render, testID, ...props }: TooltipContentProps): React.JSX.Element;
export {};