@adyen/adyen-platform-experience-web
Version:

45 lines (44 loc) • 1.8 kB
JavaScript
import { jsx as e } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import c from "../Popover/Popover.js";
import { PopoverContainerVariant as g } from "../Popover/types.js";
import { useTooltipListeners as T } from "./useTooltipListeners.js";
import { TypographyVariant as d, TypographyElement as y } from "../Typography/types.js";
import v from "../Typography/Typography.js";
import E from "../../../hooks/element/useUniqueIdentifier.js";
import P from "classnames";
import { cloneElement as b, Fragment as I } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
import { useState as N, useMemo as x } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
/* empty css */
const h = (o) => typeof o == "string", D = ({ content: o, children: t, showTooltip: i, position: m, isUnderlineVisible: r = !1 }) => {
const [a, n] = N(null), { isVisible: l, listeners: f } = T(), s = E(), p = l || !!i, u = x(
() => P(t?.props?.className, "adyen-pe-tooltip-target", { "adyen-pe-tooltip-target--underlined": r }),
[t?.props?.className, r]
);
return /* @__PURE__ */ e(I, { children: [
t ? b(t, {
...t.props,
...f,
...p && a?.id ? { "aria-describedby": a.id } : {},
className: u,
ref: s,
role: "button",
tabIndex: 0
}) : null,
p && /* @__PURE__ */ e(
c,
{
position: m,
variant: g.TOOLTIP,
targetElement: s,
setPopoverElement: n,
fitPosition: !0,
open: !0,
disableFocusTrap: !0,
children: o && h(o) ? /* @__PURE__ */ e(v, { el: y.DIV, variant: d.CAPTION, children: o }) : o
}
)
] });
};
export {
D as Tooltip
};