"use client"; import { cloneElement, useId, useState, type CSSProperties, type ReactElement, } from "react"; export function Tooltip({ label, children, side = "top", className = "", style, }: { label: string; children: ReactElement<{ "aria-describedby"?: string }>; side?: "top" | "bottom"; className?: string; style?: CSSProperties; }) { const id = useId(); const [dismissed, setDismissed] = useState(false); return ( setDismissed(false)} onFocus={() => setDismissed(false)} onKeyDown={(e) => { if (e.key === "Escape") setDismissed(true); }} > {cloneElement(children, { "aria-describedby": [children.props["aria-describedby"], id] .filter(Boolean) .join(" "), })} {label} ); }