import _extends from "@babel/runtime/helpers/extends";
// Copyright 1999-2020. Plesk International GmbH. All rights reserved.
import classNames from 'classnames';
import React from 'react';
import { wrapFunction } from '../utils';
import { CLS_PREFIX } from '../../constants';

/**
 * `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 = `${CLS_PREFIX}item-link`,
  className,
  children,
  hoverable,
  ...props
}) => {
  if (props.onClick) {
    props.tabIndex = props.tabIndex || 0;
    props.role = props.role || 'button';
    props.onKeyDown = wrapFunction(props.onKeyDown, e => {
      if (e.key === 'Enter') {
        e.preventDefault();
        e.currentTarget.click();
      }
    });
  }

  return /*#__PURE__*/React.createElement("div", _extends({
    className: classNames(baseClassName, className)
  }, props), /*#__PURE__*/React.createElement("div", {
    className: `${baseClassName}__content`
  }, children));
};

export default ItemLink;