"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _Button = _interopRequireDefault(require("@material-ui/core/Button"));

var _Fab = _interopRequireDefault(require("@material-ui/core/Fab"));

var _common = _interopRequireDefault(require("@material-ui/core/colors/common"));

var _styles = require("@material-ui/core/styles");

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

function _extends() { _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; }; return _extends.apply(this, arguments); }

const styles = theme => ({
  root: {
    color: _common.default.white,
    width: '25px',
    minWidth: '50px'
  },
  standalone: {
    position: 'fixed',
    bottom: theme.spacing(2),
    right: theme.spacing(2),
    zIndex: 100
  }
});

const ActionButton = props => {
  let Component = _Button.default;
  const coreProps = {
    color: props.color || 'primary',
    onClick: props.action,
    'aria-label': props.label
  };
  if (props.disabled) coreProps.disabled = true;

  if (props.fab) {
    // coreProps.variant = "fab";
    Component = _Fab.default;
    if (props.standalone) coreProps.classes = {
      root: props.classes.standalone
    };
  } else coreProps.classes = {
    root: props.classes.root
  };

  if (props.is) {
    coreProps.component = ({
      className,
      ...coreProps
    }) => /*#__PURE__*/_react.default.createElement("button", _extends({}, coreProps, {
      class: className,
      is: props.is
    }));
  }

  return /*#__PURE__*/_react.default.createElement(Component, _extends({}, coreProps, {
    className: props.buttonClassName
  }), props.children);
};

var _default = (0, _styles.withStyles)(styles)(ActionButton);

exports.default = _default;