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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { isVNode, defineComponent, ref, computed, createVNode } from 'vue';
import debounce from 'lodash/debounce';
import { renderContent } from '../utils/render-tnode.js';
import { isNodeOverflow } from '../utils/dom.js';
import { Tooltip } from '../tooltip/index.js';
import 'lodash/isEmpty';
import 'lodash/isString';
import 'lodash/isFunction';
import 'lodash/isObject';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../_chunks/dep-512eb181.js';
import 'lodash/isArray';
import '../utils/easing.js';
import '../utils/withInstall.js';
import '../tooltip/tooltip.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/omit';
import '../popup/props.js';
import '../popup/index.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import 'dayjs';
import '../_chunks/dep-ac28b67c.js';
import '../config-provider/type.js';
import '../_common/js/utils/set-style.js';
import '../hooks/useVModel.js';
import '../popup/container.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'lodash/isUndefined';
import '../hooks/useResizeObserver.js';
import '../popup/style';
import '../popup/type.js';
import '../hooks/tnode.js';
import '../tooltip/util.js';
import '../tooltip/props.js';
import '../tooltip/style';
import '../tooltip/type.js';

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(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]' && !isVNode(s);
}
var TEllipsis = 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 = ref();
    var isOverflow = ref(false);
    var ellipsisClasses = computed(function () {
      return ["".concat(props.classPrefix, "-table__ellipsis"), "".concat(props.classPrefix, "-text-ellipsis")];
    });
    var innerEllipsisClassName = computed(function () {
      return ["".concat(props.classPrefix, "-table__ellipsis-content"), props.overlayClassName];
    });
    var onTriggerMouseenter = function onTriggerMouseenter() {
      if (!root.value) return;
      isOverflow.value = isNodeOverflow(root.value);
    };
    var onTriggerMouseleave = function onTriggerMouseleave() {
      isOverflow.value = isNodeOverflow(root.value);
    };
    var onMouseAround = debounce(function (e) {
      e.type === "mouseleave" ? onTriggerMouseleave() : onTriggerMouseenter();
    }, 80);
    return {
      root: root,
      isOverflow: isOverflow,
      ellipsisClasses: ellipsisClasses,
      innerEllipsisClassName: innerEllipsisClassName,
      onMouseAround: onMouseAround
    };
  },
  render: function render() {
    var cellNode = renderContent(this, "default", "content");
    var ellipsisContent = 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 = createVNode(Tooltip, rProps, _isSlot(ellipsisContent) ? ellipsisContent : {
        "default": function _default() {
          return [ellipsisContent];
        }
      });
    } else {
      content = ellipsisContent;
    }
    return content;
  }
});

export { TEllipsis as default };
//# sourceMappingURL=ellipsis.js.map
