"use strict";

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

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

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

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

var _ToolbarButton = _interopRequireDefault(require("./ToolbarButton"));

var _ToolbarLink = _interopRequireDefault(require("./ToolbarLink"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var Left = function Left(props) {
  return _react["default"].createElement("div", {
    className: "toolbar__left"
  }, props.children);
};

Left.propTypes = {
  children: _propTypes["default"].node.isRequired
};

var Right = function Right(props) {
  return _react["default"].createElement("div", {
    className: "toolbar__right"
  }, props.children);
};

Right.propTypes = {
  children: _propTypes["default"].node.isRequired
};
/**
 *
 * @param {Object} props - Properties passed to component
 * @returns {ReactElement}
 */

var Toolbar = function Toolbar(_ref) {
  var children = _ref.children,
      className = _ref.className,
      isBottomToolbar = _ref.isBottomToolbar,
      testSection = _ref.testSection,
      toolbarStyle = _ref.toolbarStyle,
      props = _objectWithoutProperties(_ref, ["children", "className", "isBottomToolbar", "testSection", "toolbarStyle"]);

  var toolbarContentClasses = (0, _classnames["default"])({
    toolbar__content: true,
    "toolbar__content--bare": toolbarStyle.includes("bare"),
    "toolbar__content--tight": toolbarStyle.includes("tight"),
    "background--white": isBottomToolbar,
    "border--top": isBottomToolbar,
    "no-border--bottom": isBottomToolbar || toolbarStyle.includes("bare"),
    "hard--left": isBottomToolbar
  }, className);
  return _react["default"].createElement("div", _extends({
    "data-oui-component": true,
    className: (0, _classnames["default"])("toolbar", className),
    "data-test-section": testSection
  }, props), _react["default"].createElement("div", {
    className: toolbarContentClasses
  }, children));
};

Toolbar.defaultProps = {
  isBottomToolbar: false,
  toolbarStyle: []
};
Toolbar.propTypes = {
  /** Items to render for the toolbar */
  children: _propTypes["default"].node.isRequired,

  /** CSS class names. */
  className: _propTypes["default"].string,

  /** Whether this toolbar sits at the bottom of a page */
  isBottomToolbar: _propTypes["default"].bool,

  /** Hook to uze for automated testing */
  testSection: _propTypes["default"].string,

  /** The style to use for this toolbar */
  toolbarStyle: _propTypes["default"].arrayOf(_propTypes["default"].oneOf(["bare", "tight"]))
};
Toolbar.Button = _ToolbarButton["default"];
Toolbar.Link = _ToolbarLink["default"];
Toolbar.Right = Right;
Toolbar.Left = Left;
var _default = Toolbar;
exports["default"] = _default;