UNPKG

@cgi-learning-hub/ui

Version:

@cgi-learning-hub/ui is an open-source React component library that implements UI for HUB's features

46 lines (45 loc) 997 B
import { jsx as i } from "react/jsx-runtime"; import { Tooltip as p, Typography as d } from "@mui/material"; import { useState as a, useRef as h, useEffect as m } from "react"; const E = ({ children: t, tooltipProps: o, typographyProps: l }) => { const [n, c] = a(!1), e = h(null); return m(() => { const r = () => { if (e.current) { const { scrollWidth: f, clientWidth: u } = e.current; c(f > u); } }, s = new ResizeObserver(() => { r(); }); return e.current && s.observe(e.current), r(), () => { e.current && s.unobserve(e.current); }; }, []), /* @__PURE__ */ i( p, { disableHoverListener: !n, title: t, ...o, children: /* @__PURE__ */ i( d, { ref: e, noWrap: !0, overflow: "hidden", textOverflow: "ellipsis", ...l, maxWidth: "100%", children: t } ) } ); }; export { E as default };