/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-a4bd011a.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, computed } from '@vue/composition-api';
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 { useConfig } from '../config-provider/useConfig.js';
import '@babel/runtime/helpers/typeof';
import 'vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../tooltip/tooltip.js';
import 'lodash/isFunction';
import '../tooltip/props.js';
import '../popup/props.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../_common/js/utils/set-style.js';
import '../popup/container.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '../utils/mixins.js';
import '../utils/map-props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
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; }
var TEllipsis = defineComponent({
  name: "TEllipsis",
  props: {
    content: {
      type: [String, Function]
    },
    "default": {
      type: [String, Function]
    },
    tooltipContent: {
      type: [String, Number, Function]
    },
    placement: String,
    attach: Function,
    tooltipProps: Object,
    zIndex: Number
  },
  setup: function setup(props) {
    var _useConfig = useConfig(),
        classPrefix = _useConfig.classPrefix;

    var root = ref();
    var isOverflow = ref(false);
    var ellipsisClasses = computed(function () {
      return ["".concat(classPrefix.value, "-table__ellipsis"), "".concat(classPrefix.value, "-text-ellipsis")];
    });

    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,
      onMouseAround: onMouseAround
    };
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var cellNode = renderContent(this, "default", "content");
    var ellipsisContent = h("div", {
      "ref": "root",
      "class": this.ellipsisClasses,
      "on": {
        "mouseenter": this.onMouseAround,
        "mouseleave": this.onMouseAround
      }
    }, [cellNode]);
    var content = null;

    if (this.isOverflow) {
      var rProps = _objectSpread({
        content: this.tooltipContent || function () {
          return cellNode;
        },
        destroyOnClose: true,
        zIndex: this.zIndex,
        attach: this.attach || function () {
          return _this.root;
        },
        placement: this.placement
      }, this.tooltipProps || {});

      content = h(Tooltip, helper([{}, {
        "props": rProps
      }]), [ellipsisContent]);
    } else {
      content = ellipsisContent;
    }

    return content;
  }
});

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