function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
import React, { forwardRef } from 'react';
import classnames from 'classnames';
export var Tab = /*#__PURE__*/forwardRef(function (props, ref) {
  var defaultProps = {
    selected: false
  };
  var href = props.href || "#".concat(props.panelId);
  var classes = classnames('ds-c-tabs__item', props.className);
  var sharedTabProps = {
    role: 'tab',
    className: classes,
    id: props.id,
    ref: ref
  };
  var handleClick = function handleClick(evt) {
    var onClick = props.onClick,
      panelId = props.panelId,
      id = props.id;
    if (onClick) {
      onClick(evt, panelId, id, href);
    }
  };
  var handleKeyDown = function handleKeyDown(evt) {
    var onKeyDown = props.onKeyDown,
      panelId = props.panelId,
      id = props.id;
    if (onKeyDown) {
      onKeyDown(evt, panelId, id, href);
    }
  };
  return !props.disabled ? /*#__PURE__*/React.createElement("a", _extends({
    "aria-selected": props.selected || defaultProps.selected,
    "aria-controls": props.panelId,
    href: href,
    onClick: handleClick,
    onKeyDown: handleKeyDown
  }, sharedTabProps), props.children) : /*#__PURE__*/React.createElement("span", _extends({
    "aria-disabled": "true"
  }, sharedTabProps), props.children);
});
Tab.displayName = 'Tab';
export default Tab;