synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
62 lines (61 loc) • 1.77 kB
JavaScript
import { jsx as t, Fragment as d, jsxs as O } from "react/jsx-runtime";
import { Tooltip as x, Menu as L } from "@mui/material";
import { useState as _ } from "react";
import y from "../IconSvg/IconSvg.js";
import "../../utils/functions/EntityTypeUtils.js";
import A from "../Icon/Icon.js";
import { TOOLTIP_DELAY_SHOW as P } from "../SynapseTable/SynapseTableConstants.js";
const R = {
place: "top"
};
function b(o, e, r) {
return "svgImg" in o ? o.svgImg : /* @__PURE__ */ t(y, { ...o, sx: { color: e, width: r } });
}
const w = ({
image: o,
callbackFn: e,
tooltipText: r,
className: g = "",
imageColor: h,
tooltipVisualProps: T = R,
children: l,
darkTheme: u,
size: f,
icon: n,
menuItems: c
}) => {
const { place: C } = T, p = n ? typeof n == "string" ? /* @__PURE__ */ t(A, { type: n }) : n : void 0, S = p || (o ? b(o, h, f) : l || /* @__PURE__ */ t(d, {})), [a, m] = _(null), E = !!a, I = (i) => {
m(i.currentTarget);
}, v = () => {
m(null);
};
let s;
return l ? s = /* @__PURE__ */ t("div", { className: "SRC-hand-cursor", children: l }) : s = /* @__PURE__ */ t(
"button",
{
tabIndex: 0,
className: `ElementWithTooltip SRC-hand-cursor SRC-grey-background-hover ${g} ${u ? "dark-theme" : ""} `,
onClick: (i) => {
e ? e() : I(i);
},
"aria-label": r,
children: S
}
), /* @__PURE__ */ O(d, { children: [
/* @__PURE__ */ t(
x,
{
title: r,
enterNextDelay: P,
placement: C,
"data-testid": "ElementTooltip",
children: s
}
),
c && /* @__PURE__ */ t(L, { anchorEl: a, open: E, onClose: v, children: c })
] });
};
export {
w as ElementWithTooltip
};
//# sourceMappingURL=ElementWithTooltip.js.map