import _extends from "@babel/runtime/helpers/extends";
// Copyright 1999-2020. Plesk International GmbH. All rights reserved.
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import VerticalContext from '../VerticalContext';

/**
 * `SectionItem` component is used for showing parameters and its values in [Section](#!/Section).
 * @since 0.0.54
 */
const SectionItem = ({
  baseClassName,
  className,
  children,
  title,
  actions,
  vertical,
  ...props
}) => {
  const verticalContext = useContext(VerticalContext);
  return /*#__PURE__*/React.createElement("div", _extends({
    className: classNames(baseClassName, {
      ["".concat(baseClassName, "--actions")]: actions,
      ["".concat(baseClassName, "--vertical")]: vertical === undefined ? verticalContext : vertical
    }, className)
  }, props), title === undefined || title === null ? null : /*#__PURE__*/React.createElement("div", {
    className: "".concat(baseClassName, "__title")
  }, title), /*#__PURE__*/React.createElement("div", {
    className: "".concat(baseClassName, "__value")
  }, children));
};

SectionItem.propTypes = {
  /**
   * Content of the `SectionItem`.
   * @since 0.0.54
   */
  children: PropTypes.node,

  /**
   * @ignore
   */
  className: PropTypes.string,

  /**
   * @ignore
   */
  baseClassName: PropTypes.string,

  /**
   * Title of the section item.
   * @since 0.0.54
   */
  title: PropTypes.node,

  /**
   * Is this section item contains actions? If it so than there should be extra whitespaces.
   * @since 0.0.54
   */
  actions: PropTypes.bool,

  /**
   * @ignore
   */
  vertical: PropTypes.bool
};
SectionItem.defaultProps = {
  children: undefined,
  className: undefined,
  baseClassName: "".concat(CLS_PREFIX, "section-item"),
  title: undefined,
  actions: false,
  vertical: undefined
};
export default SectionItem;