import { CopyOutlined } from '@ant-design/icons';
import { Button, message } from 'antd';
import copy from 'copy-to-clipboard';
import React from 'react';
import TextEllipsis from "../TextEllipsis";
import "./index.less";
var TextCopy = function TextCopy(_ref) {
  var content = _ref.content,
    text = _ref.text,
    _ref$limit = _ref.limit,
    limit = _ref$limit === void 0 ? 15 : _ref$limit,
    _ref$onlyIcon = _ref.onlyIcon,
    onlyIcon = _ref$onlyIcon === void 0 ? false : _ref$onlyIcon,
    className = _ref.className,
    _ref$hoverShow = _ref.hoverShow,
    hoverShow = _ref$hoverShow === void 0 ? true : _ref$hoverShow;
  var rootClass = ['qkd-text-copy', onlyIcon ? 'icon-only' : '', hoverShow ? '' : 'always-show', className || ''].filter(Boolean).join(' ');
  return /*#__PURE__*/React.createElement("div", {
    className: rootClass
  }, /*#__PURE__*/React.createElement("span", {
    className: "qkd-text-copy-text"
  }, limit === 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, text || content) : /*#__PURE__*/React.createElement(TextEllipsis, {
    content: text || content,
    limit: limit
  })), /*#__PURE__*/React.createElement("div", {
    className: "oper"
  }, /*#__PURE__*/React.createElement(Button, {
    type: "text",
    size: "small",
    icon: /*#__PURE__*/React.createElement(CopyOutlined, null),
    onClick: function onClick(e) {
      e.stopPropagation();
      copy(content);
      message.success('复制成功');
    }
  })));
};
export default TextCopy;