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

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 React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import ButtonWithIcon from '../ButtonWithIcon';
import Icon from '../../../base/Icon';
// 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 = classNames((_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: React.createElement(Icon, { name: 'chevron', svgHeight: 10, svgWidth: 10 })
  }, rest);
  return React.createElement(ButtonWithIcon, buttonProps);
};

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

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

export default ButtonAlert;