import React, { useState } from 'react'; import { ActionIcon, Group, Modal, Text, Tooltip } from '@mantine/core'; import InformationOutlineIcon from 'mdi-react/InformationOutlineIcon'; import { iconMStyle } from '~/styles.ts'; interface TruncatedTextProps { text: string; maxLength?: number; maxTooltipLength?: number; title?: string; } export function TruncatedText({ text, maxLength = 20, maxTooltipLength = 200, title = 'Details' }: TruncatedTextProps) { const [opened, setOpened] = useState(false); if (!text) return -; if (text.length <= maxLength) { return {text}; } const truncatedText = `${text.substring(0, maxLength)}...`; const tooltipText = text.length > maxTooltipLength ? `${text.substring(0, maxTooltipLength)}...` : text return ( <> {truncatedText} setOpened(true)} title="Show full content" > setOpened(false)} title={title} size="md" centered > {text} ); }