'use strict';

exports.__esModule = true;
exports.default = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _BEM = require('../../../core/utils/BEM');

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

require('./style.scss');

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var Button = (_temp = _class = function (_Component) {
  _inherits(Button, _Component);

  function Button(props) {
    _classCallCheck(this, Button);

    return _possibleConstructorReturn(this, _Component.call(this, props, 'Button'));
  }

  Button.prototype.render = function render() {
    var _props = this.props,
        bem = _props.bem,
        children = _props.children,
        circular = _props.circular,
        className = _props.className,
        ghost = _props.ghost,
        size = _props.size,
        text = _props.text,
        type = _props.type,
        attrs = _objectWithoutProperties(_props, ['bem', 'children', 'circular', 'className', 'ghost', 'size', 'text', 'type']);

    var ButtonClasses = [this.bem(bem), 'Button_' + size, className, circular && 'Button_circular', ghost && 'Button_ghost', text && 'Button_text'].filter(function (e) {
      return e;
    }).join(' ');

    return _react2.default.createElement(
      this.Tag,
      _extends({}, attrs, { className: ButtonClasses, type: type }),
      children
    );
  };

  _createClass(Button, [{
    key: 'Tag',
    get: function get() {
      return 'href' in this.props && this.props.href ? 'a' : 'button';
    }
  }]);

  return Button;
}(_BEM.Component), _class.defaultProps = {
  size: 'md',
  type: 'button'
}, _temp);
exports.default = Button;
Button.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, _BEM.Component.propTypes, {
  circular: _propTypes2.default.bool,
  ghost: _propTypes2.default.bool,
  href: _propTypes2.default.string,
  size: _propTypes2.default.oneOf(['sm', 'md', 'lg']),
  text: _propTypes2.default.bool,
  type: _propTypes2.default.oneOf(['submit', 'reset', 'button'])
}) : {};
module.exports = exports['default'];