'use strict';

exports.__esModule = true;

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 _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _ButtonWithIcon = require('../ButtonWithIcon');

var _ButtonWithIcon2 = _interopRequireDefault(_ButtonWithIcon);

var _Icon = require('../../../base/Icon');

var _Icon2 = _interopRequireDefault(_Icon);

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; }

// import './style.css';

var ButtonAlert = function ButtonAlert(props) {
  var _classNames;

  var text = props.text,
      hideText = props.hideText,
      showText = props.showText,
      classes = props.classes,
      isOpen = props.isOpen,
      rest = _objectWithoutProperties(props, ['text', 'hideText', 'showText', 'classes', 'isOpen']);

  var buttonClasses = (0, _classnames2.default)((_classNames = {
    'ma__button-alert': true
  }, _classNames['' + classes] = classes && classes.length > 0, _classNames['is-open'] = isOpen, _classNames));
  var buttonProps = _extends({
    className: buttonClasses,
    expanded: isOpen,
    text: isOpen ? hideText + ' ' + text : showText + ' ' + text,
    usage: 'alert',
    icon: _react2.default.createElement(_Icon2.default, { name: 'chevron', svgHeight: 10, svgWidth: 10 })
  }, rest);
  return _react2.default.createElement(_ButtonWithIcon2.default, buttonProps);
};

ButtonAlert.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The text that will display on the button alert. */
  text: _propTypes2.default.string,
  /** Optional class(es) to pass to the button alert */
  classes: _propTypes2.default.string,
  /** An optional onClick function */
  onClick: _propTypes2.default.func,
  /** Text for showing alert */
  showText: _propTypes2.default.string.isRequired,
  /** Text for hiding alert */
  hideText: _propTypes2.default.string.isRequired,
  /** Adds is-open class to button if true. */
  isOpen: _propTypes2.default.bool,
  /** HTML <button> 'type' attribute  */
  type: _propTypes2.default.oneOf(['submit', 'reset', 'button', '']),
  /** Theme of the button */
  theme: _propTypes2.default.oneOf(['', 'c-primary', 'c-highlight', 'c-gray-dark', 'c-black'])
} : {};

ButtonAlert.defaultProps = {
  isOpen: false,
  type: 'button',
  theme: 'c-black'
};

exports.default = ButtonAlert;
module.exports = exports['default'];