/**
 * tdesign v0.39.1-alpha.1
 * (c) 2022 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-1ec74b8b.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, computed } from '@vue/composition-api';
import { renderContent } from '../utils/render-tnode.js';
import { isNodeOverflow } from '../utils/dom.js';
import { Popup } from '../popup/index.js';
import { useConfig } from '../config-provider/useConfig.js';
import '@babel/runtime/helpers/typeof';
import 'vue';
import 'lodash/isObject';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../config.js';
import '../utils/classnames.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '../_common/js/utils/set-style.js';
import '../popup/props.js';
import '../popup/container.js';
import '../utils/map-props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../popup/type.js';
import 'lodash/cloneDeep';
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';

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]
    },
    popupContent: {
      type: [String, Number, Function]
    },
    placement: String,
    attach: Function,
    popupProps: 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 updateIsOverflow = function updateIsOverflow() {
      if (!root.value) return;
      isOverflow.value = isNodeOverflow(root.value);
    };

    var onMouseleave = function onMouseleave() {
      isOverflow.value = false;
    };

    return {
      root: root,
      isOverflow: isOverflow,
      ellipsisClasses: ellipsisClasses,
      updateIsOverflow: updateIsOverflow,
      onMouseleave: onMouseleave
    };
  },
  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.updateIsOverflow,
        "mouseleave": this.onMouseleave
      }
    }, [cellNode]);

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

      return h(Popup, helper([{}, {
        "props": rProps
      }]), [ellipsisContent]);
    }

    return ellipsisContent;
  }
});

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