"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames = _interopRequireDefault(require("classnames"));

var _constants = require("../../constants");

var _VerticalContext = _interopRequireDefault(require("../VerticalContext"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

// Copyright 1999-2020. Plesk International GmbH. All rights reserved.

/**
 * `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 = (0, _react.useContext)(_VerticalContext.default);
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    className: (0, _classnames.default)(baseClassName, {
      [`${baseClassName}--actions`]: actions,
      [`${baseClassName}--vertical`]: vertical === undefined ? verticalContext : vertical
    }, className)
  }, props), title === undefined || title === null ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: `${baseClassName}__title`
  }, title), /*#__PURE__*/_react.default.createElement("div", {
    className: `${baseClassName}__value`
  }, children));
};

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

  /**
   * @ignore
   */
  className: _propTypes.default.string,

  /**
   * @ignore
   */
  baseClassName: _propTypes.default.string,

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

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

  /**
   * @ignore
   */
  vertical: _propTypes.default.bool
};
SectionItem.defaultProps = {
  children: undefined,
  className: undefined,
  baseClassName: `${_constants.CLS_PREFIX}section-item`,
  title: undefined,
  actions: false,
  vertical: undefined
};
var _default = SectionItem;
exports.default = _default;