UNPKG

zxreact-components

Version:

react 组件库

2 lines (1 loc) 1.23 kB
"use strict";const i=require("../jsx-runtime-CFFZ3DPA.js"),n=require("react"),x=require("antd");function d(l){return console.log("is not dist"),l==null}function f(l){console.log(d(23232),d(null),"isUndef");const{content:t}=l,[a,p]=n.useState(!1),s=n.useRef(null),o=n.useMemo(()=>d(t)?"------":t,[t]);return n.useEffect(()=>{if(!s?.current)return;let m=window.getComputedStyle(s.current).fontSize,r=window.getComputedStyle(s.current).width.replace("px",""),e=document.createElement("p");e.style.fontSize=m,e.style.whiteSpace="nowrap",e.style.position="fixed",e.style.top="-100px",e.style.opacity="0",e.innerHTML=t,document.body.appendChild(e);const c=document.createRange();c.setStart(e,0),c.setEnd(e,e.childNodes.length);let u=c.getBoundingClientRect().width;document.body.removeChild(e),e=null,console.log(r,"width"),console.log(u,"textWidth"),r&&u&&parseInt(r)<u?(console.log(111),p(!0)):p(!1)},[t]),i.jsxRuntimeExports.jsx("div",{className:"mt-ui-ellipsis",ref:s,children:a?i.jsxRuntimeExports.jsx(x.Tooltip,{title:o,placement:"topLeft",children:i.jsxRuntimeExports.jsx("span",{className:"mt-ui-ellipsis",children:o})}):i.jsxRuntimeExports.jsx("span",{className:"screen-min",children:o})})}const h=n.memo(f);module.exports=h;