import React, { useState, useRef, useEffect } from 'react'; import { Popover } from 'antd'; import classNames from 'classnames'; import s from './index.less'; import extendIcon from '../../../../assets/extend.png'; export const ApolloLinkDetail = (props: any) => { const { value, origin } = props; if (!Array.isArray(value) || value.length === 0) return null; 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 (
{value.map((item, i) => { return ( {item.text || item.value} ); })}
{dotVisible && ( { e.stopPropagation(); }} placement="left" overlayClassName={s.popContainer} content={
{ e.stopPropagation(); }} > {value.map((item, i) => { return (
{item.text || item.value}
); })}
} >
)}
); };