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

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

const defaultProps = {
  className: '',
  defaultClassName: 'sui-a-form-options-group',
  isInline: false,
  tag: 'div',
};

export const FormOptionsGroup = ({
  className,
  defaultClassName,
  isInline,
  tag: Tag,
  ...attributes
}) => {
  const classes = classnames(
    className,
    defaultClassName,
    isInline ? 'as--inline' : ''
  );

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

FormOptionsGroup.propTypes = propTypes;
FormOptionsGroup.defaultProps = defaultProps;
