/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var tdesignIconsVue = require('tdesign-icons-vue');
var utils_mixins = require('../utils/mixins.js');
var utils_event = require('../utils/event.js');
var utils_ripple = require('../utils/ripple.js');
var tabs_props = require('./props.js');
var tabs_tabPanelProps = require('./tab-panel-props.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
require('vue');
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('../config.js');
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);

var classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("tab-nav__item");
var keepAnimationMixins = configProvider_configReceiver.getKeepAnimationMixins();
var TTabNavItem = utils_mixins["default"](keepAnimationMixins, classPrefixMixins, configProvider_configReceiver.getGlobalIconMixins()).extend({
  name: "TTabNavItem",
  directives: {
    ripple: utils_ripple["default"]
  },
  props: {
    index: Number,
    active: {
      type: Boolean
    },
    theme: tabs_props["default"].theme,
    size: tabs_props["default"].size,
    placement: tabs_props["default"].placement,
    label: {
      type: null
    },
    disabled: tabs_tabPanelProps["default"].disabled,
    removable: tabs_tabPanelProps["default"].removable,
    value: tabs_tabPanelProps["default"].value
  },
  computed: {
    navItemClass: function navItemClass() {
      var _ref;

      return _ref = {}, _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-tabs__nav-item"), true), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-tabs__nav--card"), this.theme === "card"), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-is-disabled"), this.disabled), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-is-active"), this.active), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-is-left"), this.placement === "left"), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-is-right"), this.placement === "right"), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-size-m"), this.size === "medium"), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-size-l"), this.size === "large"), _ref;
    }
  },
  methods: {
    removeBtnClick: function removeBtnClick(e) {
      e.stopPropagation();
      utils_event.emitEvent(this, "remove", {
        e: e,
        value: this.value,
        index: this.index
      });
    },
    onClickNav: function onClickNav(_ref2) {
      var e = _ref2.e;
      if (this.disabled) return;
      utils_event.emitEvent(this, "click", e);
    },
    renderCardItem: function renderCardItem() {
      var h = this.$createElement;

      var _this$useGlobalIcon = this.useGlobalIcon({
        CloseIcon: tdesignIconsVue.CloseIcon
      }),
          CloseIcon = _this$useGlobalIcon.CloseIcon;

      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        },
        "directives": [{
          name: "ripple",
          value: this.keepAnimation.ripple
        }]
      }, [h("span", {
        "class": "".concat(this.classPrefix, "-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;

      var _this$useGlobalIcon2 = this.useGlobalIcon({
        CloseIcon: tdesignIconsVue.CloseIcon
      }),
          CloseIcon = _this$useGlobalIcon2.CloseIcon;

      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        }
      }, [h("div", {
        "class": ["".concat(this.classPrefix, "-tabs__nav-item-wrapper"), (_ref3 = {}, _defineProperty__default["default"](_ref3, "".concat(this.classPrefix, "-is-disabled"), this.disabled), _defineProperty__default["default"](_ref3, "".concat(this.classPrefix, "-is-active"), this.active), _ref3)],
        "directives": [{
          name: "ripple",
          value: this.keepAnimation.ripple
        }]
      }, [h("span", {
        "class": "".concat(this.classPrefix, "-tabs__nav-item-text-wrapper")
      }, [this.label])]), this.removable && !this.disabled ? h(CloseIcon, {
        "class": "remove-btn",
        "nativeOn": {
          "click": this.removeBtnClick
        }
      }) : null]);
    }
  },
  render: function render() {
    return this.theme === "card" ? this.renderCardItem() : this.renderNormalItem();
  }
});

exports["default"] = TTabNavItem;
//# sourceMappingURL=tab-nav-item.js.map
