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

import { h as helper } from '../_chunks/dep-c89aafbb.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 '@babel/runtime/helpers/typeof';
import 'vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../tooltip/tooltip.js';
import 'lodash/isFunction';
import '../popup/props.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../utils/helper.js';
import '@babel/runtime/helpers/slicedToArray';
import '../_common/js/utils/set-style.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 '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';
import '../utils/mixins.js';
import '../utils/event.js';
import '../popup/container.js';
import '../popup/utils.js';
import '../popup/trigger.js';
import '../tooltip/props.js';
import '../tooltip/style/css.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: [String, Function],
    tooltipProps: Object,
    zIndex: Number,
    overlayClassName: String,
    classPrefix: {
      type: String
    }
  },
  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 _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;
    var tooltipProps = this.tooltipProps;
    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,
        overlayClassName: tooltipProps !== null && tooltipProps !== void 0 && tooltipProps.overlayClassName ? this.innerEllipsisClassName.concat(tooltipProps.overlayClassName) : this.innerEllipsisClassName
      }, tooltipProps);
      content = h(Tooltip, helper([{}, {
        "props": rProps
      }]), [ellipsisContent]);
    } else {
      content = ellipsisContent;
    }
    return content;
  }
});

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