/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var helper = require('../../../chunks/helper.js');
var VueCompositionAPI = require('@vue/composition-api');
var debounce = require('lodash/debounce');
var utils_renderNode = require('../../../utils/render-node.js');
var utils_dom = require('../../../utils/dom.js');
var components_tooltip_index = require('../../tooltip/index.js');
require('vue');
require('lodash');
require('raf');
require('lodash/isString');
require('../../../chunks/log.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../utils/easing.js');
require('../../../utils/map-props.js');
require('../../../utils/with-install.js');
require('../../../config.js');
require('../../tooltip/tooltip.js');
require('lodash/isFunction');
require('../../popup/props.js');
require('../../popup/popup.js');
require('@popperjs/core');
require('../../../chunks/set-style.js');
require('../../../utils/helper.js');
require('lodash/camelCase');
require('../../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../config-provider/context.js');
require('../../../chunks/zh_CN.js');
require('../../../utils/mixins.js');
require('../../popup/container.js');
require('../../tooltip/props.js');

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

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

var TEllipsis = VueCompositionAPI.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 = VueCompositionAPI.ref();
    const isOverflow = VueCompositionAPI.ref(false);
    const ellipsisClasses = VueCompositionAPI.computed(() => [`${props.classPrefix}-table__ellipsis`, `${props.classPrefix}-text-ellipsis`]);
    const innerEllipsisClassName = VueCompositionAPI.computed(() => [`${props.classPrefix}-table__ellipsis-content`, props.overlayClassName]);
    const onTriggerMouseenter = () => {
      if (!root.value) return;
      isOverflow.value = utils_dom.isNodeOverflow(root.value);
    };
    const onTriggerMouseleave = () => {
      isOverflow.value = utils_dom.isNodeOverflow(root.value);
    };
    const onMouseAround = debounce__default["default"](e => {
      e.type === "mouseleave" ? onTriggerMouseleave() : onTriggerMouseenter();
    }, 80);
    return {
      root,
      isOverflow,
      ellipsisClasses,
      innerEllipsisClassName,
      onMouseAround
    };
  },
  render() {
    const h = arguments[0];
    const cellNode = utils_renderNode.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 !== null && tooltipProps !== void 0 && tooltipProps.overlayClassName ? this.innerEllipsisClassName.concat(tooltipProps.overlayClassName) : this.innerEllipsisClassName,
        ...tooltipProps
      };
      content = h(components_tooltip_index.Tooltip, helper.helper([{}, {
        "props": rProps
      }]), [ellipsisContent]);
    } else {
      content = ellipsisContent;
    }
    return content;
  }
});

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