@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
41 lines (40 loc) • 1.52 kB
JavaScript
import { jsx as e, jsxs as i } from "react/jsx-runtime";
import { forwardRef as N, useRef as w, useImperativeHandle as x, useMemo as R, isValidElement as T } from "react";
import { S as a } from "../../index-B_6_jmOO.js";
import { cn as o } from "../../utils/index.js";
import { arrowVariants as V, tooltipVariants as b } from "./Tooltip.variants.js";
import { useTooltip as j } from "./hooks/useTooltip.js";
import { useTheme as C } from "../../contexts/theme.hook.js";
const q = N(
({ children: t, content: l, className: n, theme: c, position: s, wrapperClassName: p }, f) => {
const d = w(null), { theme: h } = C(), m = c ?? h, { isVisible: u, componentRef: r } = j();
x(f, () => r.current, [r]);
const v = R(
() => T(t) ? t : /* @__PURE__ */ e("p", { className: "p-2", children: t }),
[t]
);
return /* @__PURE__ */ e("div", { className: o("w-full", p), children: /* @__PURE__ */ i("div", { className: "relative w-max", children: [
/* @__PURE__ */ e(a, { ref: r, className: o("cursor-pointer ", n), children: v }),
/* @__PURE__ */ i(
"div",
{
ref: d,
className: o(b({ theme: m, position: s })),
"data-visible": u,
children: [
/* @__PURE__ */ e(
"span",
{
className: o(V({ theme: m, position: s }))
}
),
/* @__PURE__ */ e(a, { children: l })
]
}
)
] }) });
}
);
export {
q as Tooltip
};