/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var tdesignIconsVue = require('tdesign-icons-vue');
var config = require('../config.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');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../utils/set-style.js');

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

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

var TTabNavItem = Vue__default["default"].extend({
  name: "TTabNavItem",
  components: {
    TIconClose: tdesignIconsVue.CloseIcon
  },
  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(config.prefix, "-tabs__nav-item"), true), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-tabs__nav--card"), this.theme === "card"), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-is-disabled"), this.disabled), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-is-active"), this.active), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-is-left"), this.placement === "left"), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-is-right"), this.placement === "right"), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-size-m"), this.size === "medium"), _defineProperty__default["default"](_ref, "".concat(config.prefix, "-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;
      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        },
        "directives": [{
          name: "ripple",
          value: true
        }]
      }, [h("span", {
        "class": "".concat(config.prefix, "-tabs__nav-item-text-wrapper")
      }, [this.label]), this.removable && !this.disabled ? h(tdesignIconsVue.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(config.prefix, "-tabs__nav-item-wrapper"), (_ref3 = {}, _defineProperty__default["default"](_ref3, "".concat(config.prefix, "-is-disabled"), this.disabled), _defineProperty__default["default"](_ref3, "".concat(config.prefix, "-is-active"), this.active), _ref3)],
        "directives": [{
          name: "ripple",
          value: true
        }]
      }, [h("span", {
        "class": "".concat(config.prefix, "-tabs__nav-item-text-wrapper")
      }, [this.label])])]);
    }
  },
  render: function render() {
    return this.theme === "card" ? this.renderCardItem() : this.renderNormalItem();
  }
});

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