import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

const propTypes = {
  /**
   * The logs content.
   */
  children: PropTypes.node,
  /**
   * The className property allows you to add more classes to the component.
   */
  className: PropTypes.string,
  /**
   * The component default class.
   */
  defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),

  /**
   * The component used for the root node.
   * Either a string to use a DOM element or a component.
   */
  tag: PropTypes.elementType,
};

const defaultProps = {
  children: '',
  className: '',
  defaultClassName: 'sui-m-logs',
  tag: 'div',
};

export const Logs = forwardRef(({
  children,
  className,
  defaultClassName,
  tag: Tag,
}, ref) => {
  const classes = classnames(
    defaultClassName,
    className
  );

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

Logs.propTypes = propTypes;
Logs.defaultProps = defaultProps;
