import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

const propTypes = {
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.array]).isRequired,
  /**
   * 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: 'div',
  defaultClassName: 'sui-prj-pipeline__item',
  className: '',
};

export const PipelineItem = (props) => {
  const {
    tag: Tag,
    defaultClassName,
    className,
    children,
  } = props;

  const classes = classnames(
    defaultClassName,
    className,
  );

  return (
    <Tag className={classes}>
      {children}
    </Tag>
  );
};

PipelineItem.propTypes = propTypes;
PipelineItem.defaultProps = defaultProps;
