"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
var _excluded = ["selectedBGColor", "selectedFontColor", "size", "onClickHandle", "unreadCount"];
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var Tab = function Tab(_ref) {
  var selectedBGColor = _ref.selectedBGColor,
    selectedFontColor = _ref.selectedFontColor,
    size = _ref.size,
    onClickHandle = _ref.onClickHandle,
    unreadCount = _ref.unreadCount,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var tabList = [{
    key: [0, 1],
    label: '全部'
  }, {
    key: [1],
    label: '已读'
  }, {
    key: [0],
    label: '未读'
  }];
  var _React$useState = React.useState([0, 1]),
    tab = _React$useState[0],
    setTab = _React$useState[1];
  var handleClick = function handleClick(key) {
    console.log(key);
    // 切换tab
    setTab(key);
    // 触发父组件传递的点击处理函数
    onClickHandle && onClickHandle(key);
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "tab-message"
  }, tabList.map(function (item) {
    return /*#__PURE__*/React.createElement("span", (0, _extends2["default"])({
      className: "tabs__container\n         " + (tab.toString() === item.key.toString() ? 'tabs__container--selected' : '') + "\n         " + (size == 'large' ? 'tabs__container--large' : 'tabs__container--small')
    }, otherProps, {
      onClick: function onClick() {
        return handleClick(item.key);
      },
      style: {
        backgroundColor: tab.toString() === item.key.toString() ? selectedBGColor : '',
        color: tab.toString() === item.key.toString() ? selectedFontColor : ''
      }
    }), item.label, item.key.toString() === '0' && unreadCount > 0 && /*#__PURE__*/React.createElement("span", {
      className: "badge"
    }, unreadCount) // 条件渲染badge
    );
  }));
};
var _default = exports["default"] = Tab;