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

/**
 * `SwitchesPanel` component is used for grouping several [SwitchesPanelItems](#!/SwitchesPanelItem) into one set.
 * @since 0.3.0
 */
const SwitchesPanel = ({
  baseClassName,
  className,
  children,
  ...props
}) => /*#__PURE__*/React.createElement(Section, _extends({
  className: classNames(baseClassName, className)
}, props), /*#__PURE__*/React.createElement("div", {
  className: "".concat(baseClassName, "__items")
}, Children.map(children, child => /*#__PURE__*/cloneElement(child, {
  className: classNames(child.props.className, "".concat(baseClassName, "__item"))
}))));

SwitchesPanel.propTypes = {
  /**
   * Content of the `SwitchesPanel`. Recommended to use [SwitchesPanelItem](#!/SwitchesPanelItem) components.
   * @since 0.3.0
   */
  children: PropTypes.node,

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

  /**
   * @ignore
   */
  baseClassName: PropTypes.string
};
SwitchesPanel.defaultProps = {
  children: null,
  className: null,
  baseClassName: "".concat(CLS_PREFIX, "switches-panel")
};
export default SwitchesPanel;