"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.ButtonType = exports.ButtonSize = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _excluded = ["btnType", "className", "disabled", "size", "children", "href"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var ButtonSize = /*#__PURE__*/function (ButtonSize) {
  ButtonSize["Large"] = "lg";
  ButtonSize["Small"] = "sm";
  return ButtonSize;
}({});
exports.ButtonSize = ButtonSize;
var ButtonType = /*#__PURE__*/function (ButtonType) {
  ButtonType["Primary"] = "primary";
  ButtonType["Default"] = "default";
  ButtonType["Danger"] = "danger";
  ButtonType["Link"] = "link";
  return ButtonType;
}({});
exports.ButtonType = ButtonType;
var Button = function Button(props) {
  var _classNames;
  var btnType = props.btnType,
    className = props.className,
    disabled = props.disabled,
    size = props.size,
    children = props.children,
    href = props.href,
    restProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
  // 默认都有btn，之后有 btn-lg btn-primary
  var classes = (0, _classnames["default"])('btn', className, (_classNames = {}, _classNames["btn-" + btnType] = btnType, _classNames["btn-" + size] = size, _classNames['disabled'] = btnType === ButtonType.Link && disabled, _classNames));
  if (btnType === ButtonType.Link) {
    return /*#__PURE__*/React.createElement("a", (0, _extends2["default"])({}, restProps, {
      href: href,
      className: classes
    }), children);
  } else {
    return /*#__PURE__*/React.createElement("button", (0, _extends2["default"])({}, restProps, {
      className: classes,
      disabled: disabled
    }), children);
  }
};
Button.defaultProps = {
  disabled: false,
  btnType: ButtonType.Default
};
var _default = Button;
exports["default"] = _default;