"use strict";

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _getLocale = require("../../../utils/getLocale");

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var precls = "titaui-text-btn";

function TextBtn(props) {
  var _props$type = props.type,
      type = _props$type === void 0 ? "default" : _props$type,
      _props$icon = props.icon,
      icon = _props$icon === void 0 ? "" : _props$icon,
      _props$text = props.text,
      text = _props$text === void 0 ? (0, _getLocale.getLocale)("OKR_MyO_Butt_Determine") : _props$text,
      _props$onClick = props.onClick,
      onClick = _props$onClick === void 0 ? function () {} : _props$onClick,
      _props$className = props.className,
      className = _props$className === void 0 ? "" : _props$className,
      _props$disabled = props.disabled,
      disabled = _props$disabled === void 0 ? false : _props$disabled,
      _props$style = props.style,
      style = _props$style === void 0 ? {} : _props$style;

  var renderIcon = function renderIcon() {
    if (typeof icon === "string") {
      return /*#__PURE__*/_react["default"].createElement("span", {
        className: "".concat(precls, "__icon")
      }, /*#__PURE__*/_react["default"].createElement("span", {
        className: icon
      }));
    }

    return /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(precls, "__icon")
    }, icon);
  };

  var onClickHandler = function onClickHandler() {
    if (disabled) return;
    onClick && onClick();
  };

  return /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])(precls, "".concat(precls, "--").concat(type), _defineProperty({}, "".concat(precls, "--disabled"), disabled), className),
    onClick: onClickHandler,
    style: style
  }, icon && renderIcon(), text);
}

var _default = TextBtn;
exports["default"] = _default;