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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { CloseIcon } from 'tdesign-icons-vue';
import mixins from '../utils/mixins.js';
import { prefix } from '../config.js';
import { emitEvent } from '../utils/event.js';
import Ripple from '../utils/ripple.js';
import props from './props.js';
import tabPanelProps from './tab-panel-props.js';
import { getKeepAnimationMixins } from '../config-provider/config-receiver.js';
import 'vue';
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 '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 '../config-provider/type.js';

var keepAnimationMixins = getKeepAnimationMixins();
var TTabNavItem = mixins(keepAnimationMixins).extend({
  name: "TTabNavItem",
  components: {
    CloseIcon: CloseIcon
  },
  directives: {
    ripple: Ripple
  },
  props: {
    index: Number,
    active: {
      type: Boolean
    },
    theme: props.theme,
    size: props.size,
    placement: props.placement,
    label: {
      type: null
    },
    disabled: tabPanelProps.disabled,
    removable: tabPanelProps.removable,
    value: tabPanelProps.value
  },
  computed: {
    navItemClass: function navItemClass() {
      var _ref;

      return _ref = {}, _defineProperty(_ref, "".concat(prefix, "-tabs__nav-item"), true), _defineProperty(_ref, "".concat(prefix, "-tabs__nav--card"), this.theme === "card"), _defineProperty(_ref, "".concat(prefix, "-is-disabled"), this.disabled), _defineProperty(_ref, "".concat(prefix, "-is-active"), this.active), _defineProperty(_ref, "".concat(prefix, "-is-left"), this.placement === "left"), _defineProperty(_ref, "".concat(prefix, "-is-right"), this.placement === "right"), _defineProperty(_ref, "".concat(prefix, "-size-m"), this.size === "medium"), _defineProperty(_ref, "".concat(prefix, "-size-l"), this.size === "large"), _ref;
    }
  },
  methods: {
    removeBtnClick: function removeBtnClick(e) {
      e.stopPropagation();
      emitEvent(this, "remove", {
        e: e,
        value: this.value,
        index: this.index
      });
    },
    onClickNav: function onClickNav(_ref2) {
      var e = _ref2.e;
      if (this.disabled) return;
      emitEvent(this, "click", e);
    },
    renderCardItem: function renderCardItem() {
      var h = this.$createElement;
      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        },
        "directives": [{
          name: "ripple",
          value: this.keepAnimation.ripple
        }]
      }, [h("span", {
        "class": "".concat(prefix, "-tabs__nav-item-text-wrapper")
      }, [this.label]), this.removable && !this.disabled ? h(CloseIcon, {
        "class": "remove-btn",
        "nativeOn": {
          "click": this.removeBtnClick
        }
      }) : null]);
    },
    renderNormalItem: function renderNormalItem() {
      var _ref3;

      var h = this.$createElement;
      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        }
      }, [h("div", {
        "class": ["".concat(prefix, "-tabs__nav-item-wrapper"), (_ref3 = {}, _defineProperty(_ref3, "".concat(prefix, "-is-disabled"), this.disabled), _defineProperty(_ref3, "".concat(prefix, "-is-active"), this.active), _ref3)],
        "directives": [{
          name: "ripple",
          value: this.keepAnimation.ripple
        }]
      }, [h("span", {
        "class": "".concat(prefix, "-tabs__nav-item-text-wrapper")
      }, [this.label])])]);
    }
  },
  render: function render() {
    return this.theme === "card" ? this.renderCardItem() : this.renderNormalItem();
  }
});

export { TTabNavItem as default };
//# sourceMappingURL=tab-nav-item.js.map
