/* eslint prefer-const: 0 */
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

const propTypes = {
  /**
   * The component used for the root node.
   * Either a string to use a DOM element or a component.
   */
  tag: PropTypes.elementType,
  defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
  className: PropTypes.string,
};

const defaultProps = {
  tag: 'hr',
  defaultClassName: 'sui-o-dropdown__spacer',
  className: '',
};

export const DropdownSpacer = ({
  className,
  defaultClassName,
  tag: Tag,
  ...attributes
}) => {
  const classes = classnames(
    defaultClassName,
    className,
  );

  return (
    <Tag
      className={classes}
      tabIndex="-1"
      {...attributes}
    />
  );
};

DropdownSpacer.propTypes = propTypes;
DropdownSpacer.defaultProps = defaultProps;
