/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @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 { getClassPrefixMixins, getKeepAnimationMixins, getGlobalIconMixins } from '../config-provider/config-receiver.js';
import props from './props.js';
import tabPanelProps from './tab-panel-props.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 '../config.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 '@babel/runtime/helpers/typeof';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';

var classPrefixMixins = getClassPrefixMixins("tab-nav__item");
var keepAnimationMixins = getKeepAnimationMixins();
var TTabNavItem = mixins(keepAnimationMixins, classPrefixMixins, getGlobalIconMixins()).extend({
  name: "TTabNavItem",
  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(this.classPrefix, "-tabs__nav-item"), true), _defineProperty(_ref, "".concat(this.classPrefix, "-tabs__nav--card"), this.theme === "card"), _defineProperty(_ref, "".concat(this.classPrefix, "-is-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, "".concat(this.classPrefix, "-size-m"), this.size === "medium"), _defineProperty(_ref, "".concat(this.classPrefix, "-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(e) {
      if (this.disabled) return;
      e.stopPropagation();
      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 _ref2;
      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"), (_ref2 = {}, _defineProperty(_ref2, "".concat(this.classPrefix, "-is-disabled"), this.disabled), _defineProperty(_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$1, {
        "class": "remove-btn",
        "nativeOn": {
          "click": this.removeBtnClick
        }
      }) : null]);
    }
  },
  render: function render() {
    return this.theme === "card" ? this.renderCardItem() : this.renderNormalItem();
  }
});

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