/* action-button.tsx generated by @compiled/babel-plugin v0.38.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./action-button.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { useCallback } from 'react';
import { cx } from '@atlaskit/css';
import { Box, Inline, Pressable } from '@atlaskit/primitives/compiled';
import Spinner from '@atlaskit/spinner';
import { getPrimitivesInlineSpaceBySize } from '../../../utils';
import ActionIcon from '../action-icon';
var styles = {
  button: "_bfhksm61 _ca0q1b66 _u5f31b66 _n3td1b66 _19bv1b66 _1bsb1osq _1ah31i6y _irr31dpa _1di6fcek",
  content: "_11c81o8v _syazi7uo"
};
var ActionButton = function ActionButton(_ref) {
  var content = _ref.content,
    iconOption = _ref.icon,
    isDisabled = _ref.isDisabled,
    isLoading = _ref.isLoading,
    onClickCallback = _ref.onClick,
    size = _ref.size,
    spaceOption = _ref.space,
    testId = _ref.testId,
    tooltipProps = _ref.tooltipProps,
    style = _ref.style;
  var space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
  var onClick = useCallback(function () {
    if (!isDisabled && !isLoading && onClickCallback) {
      onClickCallback();
    }
  }, [isDisabled, isLoading, onClickCallback]);
  var icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
    icon: /*#__PURE__*/React.createElement(Spinner, {
      testId: "".concat(testId, "-loading")
    })
  }) : iconOption;
  return /*#__PURE__*/React.createElement(Pressable, _extends({
    xcss: cx(styles.button)
  }, tooltipProps, {
    onClick: onClick,
    testId: testId
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
    ,
    style: style
  }), /*#__PURE__*/React.createElement(Inline, {
    alignBlock: "center",
    grow: "fill",
    space: space
  }, icon, /*#__PURE__*/React.createElement(Box, {
    xcss: cx(styles.content)
  }, content)));
};
export default ActionButton;