/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

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

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(e) {
      if (this.disabled) return;
      e.stopPropagation();
      utils_event.emitEvent(this, "click", e);
    },
    renderCardItem: function renderCardItem() {
      var h = this.$createElement;
      var _this$useGlobalIcon = this.useGlobalIcon({
          CloseIcon: iconsVue.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 _ref2;
      var h = this.$createElement;
      var _this$useGlobalIcon2 = this.useGlobalIcon({
          CloseIcon: iconsVue.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"), (_ref2 = {}, _defineProperty__default["default"](_ref2, "".concat(this.classPrefix, "-is-disabled"), this.disabled), _defineProperty__default["default"](_ref2, "".concat(this.classPrefix, "-is-active"), this.active), _ref2)],
        "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
