'use strict';

exports.__esModule = true;

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');

var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _ = require('./..');

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

var CollapseButton = function CollapseButton(props) {
  var collapse = props.collapse,
      alignment = props.alignment,
      onClick = props.onClick,
      className = props.className,
      otherProps = (0, _objectWithoutProperties3.default)(props, ['collapse', 'alignment', 'onClick', 'className']);


  var handleClick = function handleClick() {
    onClick && onClick();
  };

  var getIconName = function getIconName() {
    return collapse ? 'arrow-right-optical_14' : 'arrow-left-optical_14';
  };

  return _react2.default.createElement(_.Button, (0, _extends3.default)({
    ariaLabel: collapse ? 'expand' : 'collapse',
    className: 'cui-collapse-button' + (' cui-collapse-button--' + alignment) + ('' + (className && ' ' + className || '')),
    children: _react2.default.createElement(_.Icon, { name: getIconName() }),
    onClick: function onClick() {
      return handleClick();
    }
  }, otherProps));
};

CollapseButton.displayName = 'CollapseButton';

CollapseButton.defaultProps = {
  collapse: true,
  alignment: 'left',
  onClick: null,
  className: ''
};

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