"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ExpandRow = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _ = require(".");
var _shared = require("../../shared");
var _FlexTableProvider = require("../../shared/FlexTableProvider");
var _excluded = ["expandItems", "expandChildren", "separatorColor"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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 getExpandableStyles = function getExpandableStyles(_ref) {
  var expandable = _ref.expandable;
  if (expandable) {
    return 'display: block;';
  }
  return 'display: none;';
};
var StyledExpandedRow = (0, _styledComponents.default)('div').withConfig({
  displayName: "ExpandRow__StyledExpandedRow",
  componentId: "sc-wqa9y6-0"
})(["border-left:", "px solid ", ";border-bottom:1px solid ", ";", ""], function (p) {
  return p.theme.spacing.unit(0.5);
}, function (p) {
  return p.theme.color.cta;
}, function (p) {
  return p.$separatorColor(p.theme);
}, (0, _shared.getStylesForSizes)(function (p) {
  return {
    xs: p.$xs,
    sm: p.$sm,
    md: p.$md,
    lg: p.$lg,
    xl: p.$xl
  };
}, {
  expandable: getExpandableStyles
}));
var ExpandRow = exports.ExpandRow = function ExpandRow(_ref2) {
  var expandItems = _ref2.expandItems,
    expandChildren = _ref2.expandChildren,
    _ref2$separatorColor = _ref2.separatorColor,
    separatorColor = _ref2$separatorColor === void 0 ? function (theme) {
      return theme.color.divider;
    } : _ref2$separatorColor,
    htmlProps = _objectWithoutProperties(_ref2, _excluded);
  var _useFlexTable = (0, _FlexTableProvider.useFlexTable)('expandable'),
    $xs = _useFlexTable.xs,
    $sm = _useFlexTable.sm,
    $md = _useFlexTable.md,
    $lg = _useFlexTable.lg,
    $xl = _useFlexTable.xl;
  return _react.default.createElement(StyledExpandedRow, _extends({
    role: "row",
    $separatorColor: separatorColor
  }, htmlProps, {
    $xs: $xs,
    $sm: $sm,
    $md: $md,
    $lg: $lg,
    $xl: $xl
  }), _react.default.createElement(_.ExpandArea, {
    expandItems: expandItems,
    expandChildren: expandChildren
  }));
};