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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var iconsVueNext = require('@ldesign/icons-vue-next');
var hooks_useRipple = require('../hooks/useRipple.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../hooks/useGlobalIcon.js');
var tabs_tabPanelProps = require('./tab-panel-props.js');
var tabs_props = require('./props.js');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
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-7f0559c3.js');
require('dayjs');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('lodash/isString');

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

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

var TTabNavItem = vue.defineComponent({
  name: "TTabNavItem",
  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,
    onClick: Function,
    onRemove: Function
  },
  setup: function setup(props) {
    var itemRef = vue.ref();
    hooks_useRipple["default"](itemRef);
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("tabs__nav-item");
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        CloseIcon: iconsVueNext.CloseIcon
      }),
      CloseIcon = _useGlobalIcon.CloseIcon;
    var classPrefix = hooks_useConfig.usePrefixClass();
    var _useCommonClassName = hooks_useConfig.useCommonClassName(),
      STATUS = _useCommonClassName.STATUS,
      SIZE = _useCommonClassName.SIZE;
    var removeBtnClick = function removeBtnClick(_ref) {
      var e = _ref.e;
      e.stopPropagation();
      props.onRemove({
        e: e,
        value: props.value,
        index: props.index
      });
    };
    var onClickNav = function onClickNav(e) {
      if (props.disabled) return;
      props.onClick(e);
    };
    var navItemClass = vue.computed(function () {
      var _ref2;
      return _ref2 = {}, _defineProperty__default["default"](_ref2, COMPONENT_NAME.value, true), _defineProperty__default["default"](_ref2, "".concat(classPrefix.value, "-tabs__nav--card"), props.theme === "card"), _defineProperty__default["default"](_ref2, STATUS.value.disabled, props.disabled), _defineProperty__default["default"](_ref2, STATUS.value.active, props.active), _defineProperty__default["default"](_ref2, "".concat(classPrefix.value, "-is-left"), props.placement === "left"), _defineProperty__default["default"](_ref2, "".concat(classPrefix.value, "-is-right"), props.placement === "right"), _defineProperty__default["default"](_ref2, SIZE.value.medium, props.size === "medium"), _defineProperty__default["default"](_ref2, SIZE.value.large, props.size === "large"), _ref2;
    });
    var renderCardItem = function renderCardItem() {
      return vue.createVNode("div", {
        "class": navItemClass.value,
        "onClick": onClickNav,
        "ref": itemRef
      }, [vue.createVNode("span", {
        "class": "".concat(COMPONENT_NAME.value, "-text-wrapper")
      }, [props.label]), props.removable && !props.disabled ? vue.createVNode(CloseIcon, {
        "class": "remove-btn",
        "onClick": removeBtnClick
      }, null) : null]);
    };
    var renderNormalItem = function renderNormalItem() {
      var _ref3;
      return vue.createVNode("div", {
        "class": navItemClass.value,
        "onClick": onClickNav
      }, [vue.createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "-wrapper"), (_ref3 = {}, _defineProperty__default["default"](_ref3, STATUS.value.disabled, props.disabled), _defineProperty__default["default"](_ref3, STATUS.value.active, props.active), _ref3)],
        "ref": itemRef
      }, [vue.createVNode("span", {
        "class": "".concat(COMPONENT_NAME.value, "-text-wrapper")
      }, [props.label])]), props.removable && !props.disabled ? vue.createVNode(CloseIcon, {
        "class": "remove-btn",
        "onClick": removeBtnClick
      }, null) : null]);
    };
    return function () {
      return props.theme === "card" ? renderCardItem() : renderNormalItem();
    };
  }
});

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