"use strict";

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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

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

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

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }

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 GridContainer = (0, _react.forwardRef)(function (_ref, ref) {
  var children = _ref.children,
      className = _ref.className,
      layout = _ref.layout,
      _ref$tag = _ref.tag,
      Tag = _ref$tag === void 0 ? "div" : _ref$tag,
      props = _objectWithoutProperties(_ref, ["children", "className", "layout", "tag"]);

  var layoutClass = layout ? "-layout" : "";
  return _react["default"].createElement(Tag, _extends({
    className: (0, _classnames["default"])("axiom".concat(layoutClass, "-grid-container"), className),
    ref: ref
  }, props), children);
});
exports.GridContainer = GridContainer;
GridContainer.displayName = "GridContainer";
var Grid = (0, _react.forwardRef)(function (_ref2, ref) {
  var children = _ref2.children,
      className = _ref2.className,
      layout = _ref2.layout,
      _ref2$tag = _ref2.tag,
      Tag = _ref2$tag === void 0 ? "div" : _ref2$tag,
      props = _objectWithoutProperties(_ref2, ["children", "className", "layout", "tag"]);

  var layoutClass = layout ? "-layout" : "";
  return _react["default"].createElement(Tag, _extends({
    className: (0, _classnames["default"])("axiom".concat(layoutClass, "-grid"), className),
    ref: ref
  }, props), children);
});
exports.Grid = Grid;
Grid.displayName = "Grid";
var GridCell = (0, _react.forwardRef)(function (_ref3, ref) {
  var className = _ref3.className,
      children = _ref3.children,
      large = _ref3.large,
      layout = _ref3.layout,
      medium = _ref3.medium,
      small = _ref3.small,
      _ref3$tag = _ref3.tag,
      Tag = _ref3$tag === void 0 ? "div" : _ref3$tag,
      props = _objectWithoutProperties(_ref3, ["className", "children", "large", "layout", "medium", "small", "tag"]);

  var spanClasses = [];
  var layoutClass = layout ? "-layout" : "";

  if (small) {
    spanClasses.push("axiom".concat(layoutClass, "-grid__cell--span-").concat(small, "-small"));
  }

  if (medium) {
    spanClasses.push("axiom".concat(layoutClass, "-grid__cell--span-").concat(medium, "-medium"));
  }

  if (large) {
    spanClasses.push("axiom".concat(layoutClass, "-grid__cell--span-").concat(large, "-large"));
  }

  return _react["default"].createElement(Tag, _extends({
    className: (0, _classnames["default"])("axiom".concat(layoutClass, "-grid__cell"), spanClasses, className),
    ref: ref
  }, props), children);
});
exports.GridCell = GridCell;
GridCell.displayName = "GridCell";