/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var debounce = require('lodash/debounce');
var utils_renderTnode = require('../utils/render-tnode.js');
var utils_dom = require('../utils/dom.js');
var tooltip_index = require('../tooltip/index.js');
require('lodash/isEmpty');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isObject');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../_chunks/dep-7f0559c3.js');
require('lodash/isArray');
require('../utils/easing.js');
require('../utils/withInstall.js');
require('../tooltip/tooltip.js');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/omit');
require('../popup/props.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('dayjs');
require('../hooks/useVModel.js');
require('../_common/js/utils/set-style.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../hooks/useResizeObserver.js');
require('../hooks/tnode.js');
require('../tooltip/util.js');
require('../tooltip/props.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
}
var TEllipsis = vue.defineComponent({
  name: "TEllipsis",
  props: {
    content: {
      type: [String, Function]
    },
    "default": {
      type: [String, Function]
    },
    tooltipContent: {
      type: [String, Number, Function]
    },
    placement: String,
    attach: [String, Function],
    tooltipProps: Object,
    zIndex: Number,
    overlayClassName: String,
    classPrefix: {
      type: String,
      "default": "t"
    }
  },
  setup: function setup(props) {
    var root = vue.ref();
    var isOverflow = vue.ref(false);
    var ellipsisClasses = vue.computed(function () {
      return ["".concat(props.classPrefix, "-table__ellipsis"), "".concat(props.classPrefix, "-text-ellipsis")];
    });
    var innerEllipsisClassName = vue.computed(function () {
      return ["".concat(props.classPrefix, "-table__ellipsis-content"), props.overlayClassName];
    });
    var onTriggerMouseenter = function onTriggerMouseenter() {
      if (!root.value) return;
      isOverflow.value = utils_dom.isNodeOverflow(root.value);
    };
    var onTriggerMouseleave = function onTriggerMouseleave() {
      isOverflow.value = utils_dom.isNodeOverflow(root.value);
    };
    var onMouseAround = debounce__default["default"](function (e) {
      e.type === "mouseleave" ? onTriggerMouseleave() : onTriggerMouseenter();
    }, 80);
    return {
      root: root,
      isOverflow: isOverflow,
      ellipsisClasses: ellipsisClasses,
      innerEllipsisClassName: innerEllipsisClassName,
      onMouseAround: onMouseAround
    };
  },
  render: function render() {
    var cellNode = utils_renderTnode.renderContent(this, "default", "content");
    var ellipsisContent = vue.createVNode("div", {
      "ref": "root",
      "class": this.ellipsisClasses,
      "onMouseenter": this.onMouseAround,
      "onMouseleave": this.onMouseAround
    }, [cellNode]);
    var content = null;
    var tooltipProps = this.tooltipProps;
    if (this.isOverflow) {
      var rProps = _objectSpread({
        content: this.tooltipContent || function () {
          return cellNode;
        },
        destroyOnClose: true,
        zIndex: this.zIndex,
        attach: this.attach,
        placement: this.placement,
        overlayClassName: tooltipProps !== null && tooltipProps !== void 0 && tooltipProps.overlayClassName ? this.innerEllipsisClassName.concat(tooltipProps.overlayClassName) : this.innerEllipsisClassName
      }, tooltipProps);
      content = vue.createVNode(tooltip_index.Tooltip, rProps, _isSlot(ellipsisContent) ? ellipsisContent : {
        "default": function _default() {
          return [ellipsisContent];
        }
      });
    } else {
      content = ellipsisContent;
    }
    return content;
  }
});

exports["default"] = TEllipsis;
//# sourceMappingURL=ellipsis.js.map
