UNPKG

@blocklet/payment-react

Version:

Reusable react components for payment kit v2

24 lines (23 loc) 982 B
import { jsx } from "react/jsx-runtime"; import { Tooltip, Typography } from "@mui/material"; import { tooltipClasses } from "@mui/material/Tooltip"; import { styled } from "@mui/system"; import { truncateText } from "../libs/util.js"; const CustomTooltip = styled(({ className, ...props }) => /* @__PURE__ */ jsx(Tooltip, { ...props, classes: { popper: className } }))({ [`& .${tooltipClasses.tooltip}`]: { fontSize: 11, maxHeight: 120, maxWidth: 500, overflowY: "auto" } }); export default function TruncatedText({ text = "", maxLength = 100, useWidth = false }) { if (!text) { return null; } const truncatedText = truncateText(text, maxLength, useWidth); if (!truncatedText.endsWith("...")) { return /* @__PURE__ */ jsx(Typography, { children: truncatedText }); } return /* @__PURE__ */ jsx(CustomTooltip, { title: text, placement: "bottom", enterTouchDelay: 0, children: /* @__PURE__ */ jsx(Typography, { children: truncatedText }) }); }