"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _bem = require("@zarm-design/bem");

var _react = _interopRequireDefault(require("react"));

var _badge = _interopRequireDefault(require("../badge"));

var _configProvider = require("../config-provider");

var TabBarItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var _React$useContext = _react.default.useContext(_configProvider.ConfigContext),
      prefixCls = _React$useContext.prefixCls;

  var bem = (0, _bem.createBEM)('tab-bar', {
    prefixCls: prefixCls
  });
  var title = props.title,
      icon = props.icon,
      badge = props.badge,
      selected = props.selected,
      _props$activeIcon = props.activeIcon,
      activeIcon = _props$activeIcon === void 0 ? icon : _props$activeIcon,
      onClick = props.onClick,
      itemKey = props.itemKey,
      restProps = (0, _objectWithoutProperties2.default)(props, ["title", "icon", "badge", "selected", "activeIcon", "onClick", "itemKey"]);

  var contentRender = (activeIcon || icon) && /*#__PURE__*/_react.default.createElement("div", {
    className: bem('icon')
  }, selected ? activeIcon : icon);

  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    className: bem('item', [{
      active: selected
    }]),
    ref: ref,
    onClick: onClick
  }, restProps), badge ? /*#__PURE__*/_react.default.createElement(_badge.default, badge, contentRender) : contentRender, /*#__PURE__*/_react.default.createElement("div", {
    className: bem('title')
  }, title));
});

TabBarItem.displayName = 'TabBarItem';
var _default = TabBarItem;
exports.default = _default;