"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 _classnames = _interopRequireDefault(require("classnames"));

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

var _utils = require("../utils");

var _constants = require("../../constants");

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

/**
 * `ItemLink` component is a part of [ItemList](#!/ItemList) and
 * is used for specifying a special action on the list (for example, adding new item).
 * @since 2.3.0
 */
const ItemLink = ({
  baseClassName = "".concat(_constants.CLS_PREFIX, "item-link"),
  className,
  children,
  ...props
}) => {
  if (props.onClick) {
    props.tabIndex = props.tabIndex || 0;
    props.role = props.role || 'button';
    props.onKeyDown = (0, _utils.wrapFunction)(props.onKeyDown, e => {
      if (e.key === 'Enter') {
        e.preventDefault();
        e.currentTarget.click();
      }
    });
  }

  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    className: (0, _classnames.default)(baseClassName, className)
  }, props), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(baseClassName, "__content")
  }, children));
};

var _default = ItemLink;
exports.default = _default;