UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

35 lines (34 loc) 1.35 kB
import { jsx as e, jsxs as t } from "react/jsx-runtime"; import { S as i } from "../../index-B5MIi2tR.js"; import { forwardRef as v, useRef as N, useImperativeHandle as w, useMemo as h, isValidElement as x } from "react"; import { cn as o } from "../../utils/index.js"; import { arrowVariants as R, tooltipVariants as V } from "./Tooltip.variants.js"; import { useTooltip as b } from "./hooks/useTooltip.js"; const I = v( ({ children: r, content: l, className: m, theme: n, position: a, wrapperClassName: c }, p) => { const f = N(null), { isVisible: d, componentRef: s } = b(); w(p, () => s.current, [s]); const u = h( () => x(r) ? r : /* @__PURE__ */ e("p", { className: "p-2", children: r }), [r] ); return /* @__PURE__ */ e("div", { className: o("w-full", c), "data-theme": n, children: /* @__PURE__ */ t("div", { className: "relative w-max", children: [ /* @__PURE__ */ e(i, { ref: s, className: o("cursor-pointer ", m), children: u }), /* @__PURE__ */ t( "div", { ref: f, className: o(V({ position: a })), "data-visible": d, children: [ /* @__PURE__ */ e("span", { className: o(R({ position: a })) }), /* @__PURE__ */ e(i, { children: l }) ] } ) ] }) }); } ); export { I as Tooltip };