/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { CloseIcon } from '@ldesign/icons-vue';
import mixins from '../../utils/mixins.js';
import { emitEvent } from '../../utils/event.js';
import Ripple from '../../utils/ripple.js';
import { TabsProps, TabsPanelProps } from './props.js';
import { getKeepAnimationMixins, getClassPrefixMixins, getGlobalIconMixins } 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 '../../chunks/set-style.js';
import '../../config.js';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';

var LTabNavItem = mixins(getKeepAnimationMixins(), getClassPrefixMixins("tab-nav__item"), getGlobalIconMixins()).extend({
  name: "LTabNavItem",
  directives: {
    ripple: Ripple
  },
  props: {
    index: Number,
    active: {
      type: Boolean
    },
    theme: TabsProps.theme,
    size: TabsProps.size,
    placement: TabsProps.placement,
    label: {
      type: null
    },
    disabled: TabsPanelProps.disabled,
    removable: TabsPanelProps.removable,
    value: TabsPanelProps.value
  },
  computed: {
    navItemClass: function navItemClass() {
      var _ref;

      var SIZE = this.commonSizeClassName,
          STATUS = this.commonStatusClassName,
          PREFIX = this.classPrefix;
      return _ref = {}, _defineProperty(_ref, "".concat(this.classPrefix, "-tabs__nav-item"), true), _defineProperty(_ref, "".concat(this.classPrefix, "-tabs__nav--card"), this.theme === "card"), _defineProperty(_ref, STATUS.disabled, this.disabled), _defineProperty(_ref, "".concat(this.classPrefix, "-is-active"), this.active), _defineProperty(_ref, "".concat(this.classPrefix, "-is-left"), this.placement === "left"), _defineProperty(_ref, "".concat(this.classPrefix, "-is-right"), this.placement === "right"), _defineProperty(_ref, SIZE.medium, this.size === "medium"), _defineProperty(_ref, SIZE.large, 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;

      var _this$useGlobalIcon = this.useGlobalIcon({
        CloseIcon: CloseIcon
      }),
          CloseIcon$1 = _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$1, {
        "class": "remove-btn",
        "nativeOn": {
          "click": this.removeBtnClick
        }
      }) : null]);
    },
    renderNormalItem: function renderNormalItem() {
      var _ref3;

      var h = this.$createElement;

      var _this$useGlobalIcon2 = this.useGlobalIcon({
        CloseIcon: CloseIcon
      }),
          CloseIcon$1 = _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(_ref3, "".concat(this.classPrefix, "-is-disabled"), this.disabled), _defineProperty(_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$1, {
        "class": "remove-btn",
        "nativeOn": {
          "click": this.removeBtnClick
        }
      }) : null]);
    }
  },
  render: function render() {
    return this.theme === "card" ? this.renderCardItem() : this.renderNormalItem();
  }
});

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