import React, { useState, useRef, useEffect } from 'react'; import { Popover } from 'antd'; import classNames from 'classnames'; import s from './index.less'; import IconFont from '@/submodule/components/IconFont'; export const ApolloTextLinkDetail = (props: any) => { const { value, origin, formatter } = props; const newValue = formatter ? formatter(value) : value; if (!newValue) return null; // 以逗号分隔 const arr = newValue.replace(/,/g, ',').split(','); const [dotVisible, setDotVisible] = useState(false); const outer = useRef(null); const inner = useRef(null); useEffect(() => { const outerTarget: any = outer.current; const innerTarget: any = inner.current; if (outerTarget && innerTarget && origin !== 'detailForm') { if (innerTarget.clientWidth > outerTarget.clientWidth) { setDotVisible(true); } else { setDotVisible(false); } } }, [value]); const outStyle: any = {}; const innerStyle: any = {}; const itemStyle: any = {}; if (origin === 'detailForm') { outStyle.width = 'auto'; innerStyle.flexWrap = 'wrap'; itemStyle.marginBottom = '5px'; itemStyle.wordBreak = 'break-all'; } return (
{arr.map((item, i) => { return ( {item} ); })}
{dotVisible && ( { e.stopPropagation(); }} placement="left" overlayClassName={s.popContainer} content={
{ e.stopPropagation(); }} > {arr.map((item, i) => { return (
{item}
); })}
} >
)}
); };