'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _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; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _Sidebar = require('./Sidebar');

var _Sidebar2 = _interopRequireDefault(_Sidebar);

var _Item = require('./Sidebar/Item');

var _Item2 = _interopRequireDefault(_Item);

var _Submenu = require('./Sidebar/Submenu');

var _Submenu2 = _interopRequireDefault(_Submenu);

var _Footer = require('./Sidebar/Footer');

var _Footer2 = _interopRequireDefault(_Footer);

var _Topbar = require('./Topbar');

var _Topbar2 = _interopRequireDefault(_Topbar);

var _Main = require('./Main');

var _Main2 = _interopRequireDefault(_Main);

var _Content = require('./Main/Content');

var _Content2 = _interopRequireDefault(_Content);

var _TopWarning = require('./TopWarning');

var _TopWarning2 = _interopRequireDefault(_TopWarning);

var _Header = require('./Main/Header');

var _Header2 = _interopRequireDefault(_Header);

var _Title = require('./Main/Header/Title');

var _Title2 = _interopRequireDefault(_Title);

var _Controls = require('./Main/Header/Controls');

var _Controls2 = _interopRequireDefault(_Controls);

var _LayoutContext = require('./LayoutContext');

var _LayoutContext2 = _interopRequireDefault(_LayoutContext);

var _Wizard = require('./Wizard');

var _Wizard2 = _interopRequireDefault(_Wizard);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var Layout = function (_Component) {
  _inherits(Layout, _Component);

  function Layout() {
    var _ref;

    var _temp, _this, _ret;

    _classCallCheck(this, Layout);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Layout.__proto__ || Object.getPrototypeOf(Layout)).call.apply(_ref, [this].concat(args))), _this), _this.ref = _react2.default.createRef(), _this.state = {
      withWarning: false
    }, _this.handleWarningMount = function () {
      _this.setState({ withWarning: true });
    }, _temp), _possibleConstructorReturn(_this, _ret);
  }

  _createClass(Layout, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          children = _props.children,
          className = _props.className,
          color = _props.color,
          noSidebar = _props.noSidebar,
          otherProps = _objectWithoutProperties(_props, ['children', 'className', 'color', 'noSidebar']);

      var withWarning = this.state.withWarning;

      var classes = (0, _classnames2.default)('inloco-layout', className, { noSidebar: noSidebar, withWarning: withWarning });
      return _react2.default.createElement(
        'div',
        _extends({ className: classes }, otherProps, { ref: this.ref }),
        _react2.default.createElement(
          _LayoutContext2.default.Provider,
          {
            value: {
              color: color,
              withWarning: withWarning,
              onWarningMount: this.handleWarningMount,
              ref: this.ref
            } },
          children
        )
      );
    }
  }]);

  return Layout;
}(_react.Component);

Layout.propTypes = {
  children: _propTypes2.default.node.isRequired,
  className: _propTypes2.default.string,
  color: _propTypes2.default.string,
  noSidebar: _propTypes2.default.bool
};
Layout.Sidebar = _Sidebar2.default;
Layout.SidebarItem = _Item2.default;
Layout.SidebarSubmenu = _Submenu2.default;
Layout.SidebarFooter = _Footer2.default;
Layout.Topbar = _Topbar2.default;
Layout.TopWarning = _TopWarning2.default;
Layout.Main = _Main2.default;
Layout.MainContent = _Content2.default;
Layout.Header = _Header2.default;
Layout.HeaderTitle = _Title2.default;
Layout.HeaderControls = _Controls2.default;
Layout.Wizard = _Wizard2.default;
exports.default = Layout;