'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = CancelButton;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactIntl = require('react-intl');

var _cspaceInput = require('cspace-input');

var _CancelButton = require('../../../styles/cspace-ui/CancelButton.css');

var _CancelButton2 = _interopRequireDefault(_CancelButton);

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

const Button = _cspaceInput.components.Button;


const messages = (0, _reactIntl.defineMessages)({
  label: {
    'id': 'cancelButton.label',
    'defaultMessage': 'Cancel'
  }
});

const propTypes = {
  disabled: _propTypes2.default.bool,
  label: _propTypes2.default.node,
  onClick: _propTypes2.default.func
};

function CancelButton(props) {
  const disabled = props.disabled,
        onClick = props.onClick;
  let label = props.label;


  if (!label) {
    label = _react2.default.createElement(_reactIntl.FormattedMessage, messages.label);
  }

  return _react2.default.createElement(
    Button,
    {
      className: _CancelButton2.default.common,
      disabled: disabled,
      icon: true,
      name: 'cancel',
      onClick: onClick
    },
    label
  );
}

CancelButton.propTypes = propTypes;