"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

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

var _Button = _interopRequireDefault(require("../Button"));

var _Menu = require("../Menu");

// Copyright 1999-2020. Plesk International GmbH. All rights reserved.

/**
 * `ListAction` component is a part of [ListActions](#!/ListActions) component.
 * It accepts the props of [Button](#!/Button) and [MenuItem](#!/MenuItem) components.
 * @since 3.3.0
 */
const ListAction = ({
  primary,
  children,
  tooltip,
  ...props
}) => {
  const render = children => {
    if (primary) {
      return /*#__PURE__*/_react.default.createElement(_Button.default, (0, _extends2.default)({
        ghost: true,
        tooltip: children
      }, props));
    }

    return /*#__PURE__*/_react.default.createElement(_Menu.MenuItem, (0, _extends2.default)({
      tooltip: tooltip
    }, props), children);
  };

  const unwrap = cb => cb({
    wrap: children => render(children)
  });

  if (typeof children === 'function') {
    return unwrap(children);
  }

  return render(children);
};

var _default = ListAction;
exports.default = _default;