/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

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 { getKeepAnimationMixins, getClassPrefixMixins, getGlobalIconMixins } from '../config-provider/config-receiver.js';
import { TabsProps, TabsPanelProps } from './props.js';
import 'vue';
import '../../utils/helper.js';
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() {
      const {
        commonSizeClassName: SIZE,
        commonStatusClassName: STATUS
      } = this;
      return {
        [`${this.classPrefix}-tabs__nav-item`]: true,
        [`${this.classPrefix}-tabs__nav--card`]: this.theme === "card",
        [STATUS.disabled]: this.disabled,
        [`${this.classPrefix}-is-active`]: this.active,
        [`${this.classPrefix}-is-left`]: this.placement === "left",
        [`${this.classPrefix}-is-right`]: this.placement === "right",
        [SIZE.medium]: this.size === "medium",
        [SIZE.large]: this.size === "large"
      };
    }
  },
  methods: {
    removeBtnClick(e) {
      e.stopPropagation();
      emitEvent(this, "remove", {
        e,
        value: this.value,
        index: this.index
      });
    },
    onClickNav(e) {
      if (this.disabled) return;
      e.stopPropagation();
      emitEvent(this, "click", e);
    },
    renderCardItem() {
      const h = this.$createElement;
      const {
        CloseIcon: CloseIcon$1
      } = this.useGlobalIcon({
        CloseIcon: CloseIcon
      });
      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        },
        "directives": [{
          name: "ripple",
          value: this.keepAnimation.ripple
        }]
      }, [h("span", {
        "class": `${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() {
      const h = this.$createElement;
      const {
        CloseIcon: CloseIcon$1
      } = this.useGlobalIcon({
        CloseIcon: CloseIcon
      });
      return h("div", {
        "class": this.navItemClass,
        "on": {
          "click": this.onClickNav
        }
      }, [h("div", {
        "class": [`${this.classPrefix}-tabs__nav-item-wrapper`, {
          [`${this.classPrefix}-is-disabled`]: this.disabled,
          [`${this.classPrefix}-is-active`]: this.active
        }],
        "directives": [{
          name: "ripple",
          value: this.keepAnimation.ripple
        }]
      }, [h("span", {
        "class": `${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() {
    return this.theme === "card" ? this.renderCardItem() : this.renderNormalItem();
  }
});

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