UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

46 lines (45 loc) 2.06 kB
import { jsx as a } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import v from "../Popover/Popover.js"; import { PopoverContainerVariant as y } from "../Popover/types.js"; import { useTooltipListeners as P } from "./useTooltipListeners.js"; import { TypographyVariant as x } from "../Typography/types.js"; import _ from "../Typography/Typography.js"; import l from "../../../hooks/element/useUniqueIdentifier.js"; import g from "classnames"; import { Fragment as s, cloneElement as b } from "../../../external/preact/dist/preact.module.js"; /* empty css */ const w = (t) => typeof t == "string"; function h() { const t = "ontouchstart" in window, o = navigator.maxTouchPoints && navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints && navigator.msMaxTouchPoints > 0, r = window.matchMedia && window.matchMedia("(pointer: coarse)").matches; return t || o || r; } const $ = ({ content: t, children: o, triggerRef: r, showTooltip: i, position: c, isContainerHovered: p = !1 }) => { var m, u, f; const e = l(), { isVisible: n, listeners: T } = P(); return h() ? /* @__PURE__ */ a(s, { children: o }) : /* @__PURE__ */ a(s, { children: [ o ? b(o, { ...o == null ? void 0 : o.props, role: "button", tabIndex: -1, ref: e, className: (m = o == null ? void 0 : o.props) != null && m.className ? g(`${(u = o == null ? void 0 : o.props) == null ? void 0 : u.className} adyen-pe__tooltip-target`, { " adyen-pe__tooltip-target--hovered": p }) : g("adyen-pe__tooltip-target", { "adyen-pe__tooltip-target--hovered": p }), ...T, "aria-describedby": `tooltip-${(f = e.current) == null ? void 0 : f.id}` }) : null, (n || i) && /* @__PURE__ */ a( v, { variant: y.TOOLTIP, targetElement: r ?? e, position: c, open: n || i, children: /* @__PURE__ */ a(s, { children: t && w(t) ? /* @__PURE__ */ a(_, { variant: x.CAPTION, children: t }) : { content: t } }) } ) ] }); }; export { $ as Tooltip };