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

'use strict';

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

var helper = require('../_chunks/dep-33ee4bce.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var utils_renderTnode = require('../utils/render-tnode.js');
var utils_dom = require('../utils/dom.js');
var popup_index = require('../popup/index.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
require('@babel/runtime/helpers/typeof');
require('vue');
require('lodash/isObject');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../config.js');
require('../utils/classnames.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../_common/js/utils/set-style.js');
require('../popup/props.js');
require('../popup/container.js');
require('../utils/map-props.js');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('lodash/cloneDeep');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');

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

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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 = VueCompositionAPI.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 = configProvider_useConfig.useConfig(),
        classPrefix = _useConfig.classPrefix;

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

    var updateIsOverflow = function updateIsOverflow() {
      if (!root.value) return;
      isOverflow.value = utils_dom.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 = utils_renderTnode.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_index.Popup, helper.helper([{}, {
        "props": rProps
      }]), [ellipsisContent]);
    }

    return ellipsisContent;
  }
});

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