/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

import { h as helper } from '../../../chunks/helper.js';
import { defineComponent, ref, computed } from '@vue/composition-api';
import debounce from 'lodash/debounce';
import { renderContent } from '../../../utils/render-node.js';
import { isNodeOverflow } from '../../../utils/dom.js';
import { Tooltip } from '../../tooltip/index.js';
import '../../../chunks/_commonjsHelpers.js';
import 'vue';
import 'lodash';
import 'raf';
import 'lodash/isString';
import '../../../chunks/index.js';
import '../../../chunks/log.js';
import '../../../chunks/_commonjsHelpers-fe796db6.js';
import '../../../utils/easing.js';
import '../../../utils/map-props.js';
import '../../../utils/withInstall.js';
import 'lodash/capitalize';
import '../../../config.js';
import '../../tooltip/tooltip.js';
import 'lodash/isFunction';
import '../../popup/props.js';
import '../../popup/popup.js';
import '@popperjs/core';
import '../../../chunks/set-style.js';
import '../../../utils/helper.js';
import 'lodash/camelCase';
import '../../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../config-provider/context.js';
import 'lodash/merge';
import '../../../chunks/zh_CN.js';
import '../../config-provider/type.js';
import '../../../utils/mixins.js';
import '../../popup/container.js';
import '../../tooltip/props.js';
import '../../tooltip/style/css.js';
import '../../tooltip/type.js';

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,
    overlayClassName: String,
    classPrefix: {
      type: String
    }
  },
  setup(props) {
    const root = ref();
    const isOverflow = ref(false);
    const ellipsisClasses = computed(() => [`${props.classPrefix}-table__ellipsis`, `${props.classPrefix}-text-ellipsis`]);
    const innerEllipsisClassName = computed(() => [`${props.classPrefix}-table__ellipsis-content`, props.overlayClassName]);
    const onTriggerMouseenter = () => {
      if (!root.value) return;
      isOverflow.value = isNodeOverflow(root.value);
    };
    const onTriggerMouseleave = () => {
      isOverflow.value = isNodeOverflow(root.value);
    };
    const onMouseAround = debounce(e => {
      e.type === "mouseleave" ? onTriggerMouseleave() : onTriggerMouseenter();
    }, 80);
    return {
      root,
      isOverflow,
      ellipsisClasses,
      innerEllipsisClassName,
      onMouseAround
    };
  },
  render() {
    const h = arguments[0];
    const cellNode = renderContent(this, "default", "content");
    const ellipsisContent = h("div", {
      "ref": "root",
      "class": this.ellipsisClasses,
      "on": {
        "mouseenter": this.onMouseAround,
        "mouseleave": this.onMouseAround
      }
    }, [cellNode]);
    let content = null;
    const tooltipProps = this.tooltipProps;
    if (this.isOverflow) {
      const rProps = {
        content: this.tooltipContent || (() => cellNode),
        destroyOnClose: true,
        zIndex: this.zIndex,
        attach: this.attach || (() => this.root),
        placement: this.placement,
        overlayClassName: 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
