qt-public-ui
Version:
新设计规范下业务组件库
24 lines • 889 B
JavaScript
import React from 'react';
import { Tooltip } from 'antd';
import './style';
var TextOverflow = function TextOverflow(props) {
var text = props.text,
_props$length = props.length,
length = _props$length === void 0 ? 10 : _props$length;
var textOverId = "umuiTextOver" + Math.round(Math.random() * 10000);
return /*#__PURE__*/React.createElement("div", {
className: "umui-text-overflow",
id: textOverId
}, text && text.length > length ? /*#__PURE__*/React.createElement(Tooltip, {
title: text,
getPopupContainer: function getPopupContainer() {
return document.getElementById(textOverId);
}
}, /*#__PURE__*/React.createElement("span", {
style: {
cursor: 'pointer'
}
}, text.slice(0, length), "...")) : /*#__PURE__*/React.createElement("span", null, text));
};
TextOverflow.displayName = 'TextOverflow';
export default TextOverflow;