"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

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

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _Grid = require("../../Grid");

var _Pane = require("../../Pane");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var Group = (0, _styledComponents["default"])(_Grid.Grid).withConfig({
  displayName: "src__Group",
  componentId: "sc-1l6zb8b-0"
})(["", ":first-child{padding-left:0 !important;}"], _Pane.Pane);

var ButtonGroup = function ButtonGroup(_ref) {
  var halign = _ref.halign,
      children = _ref.children,
      size = _ref.size,
      props = (0, _objectWithoutProperties2["default"])(_ref, ["halign", "children", "size"]);

  var count = _react["default"].Children.count(children);

  return (// eslint-disable-next-line react/jsx-props-no-spreading
    _react["default"].createElement(Group, (0, _extends2["default"])({
      halign: halign
    }, props), _react["default"].Children.map(children, function (button) {
      return _react["default"].createElement(_Grid.Grid.Shrink, {
        as: _Pane.Pane,
        spacing: {
          pl: 1
        },
        size: size || 1 / count
      }, button);
    }))
  );
};

exports.ButtonGroup = ButtonGroup;
ButtonGroup.displayName = "ButtonGroup";
ButtonGroup.propTypes = _objectSpread({}, _Grid.Grid.propTypes, {
  children: _propTypes["default"].arrayOf(_propTypes["default"].element).isRequired,
  size: _propTypes["default"].number
});
ButtonGroup.defaultProps = {
  size: 1
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2xpYi9jb21wb25lbnRzL0J1dHRvbkdyb3VwL3NyYy9pbmRleC5qc3giXSwibmFtZXMiOlsiR3JvdXAiLCJHcmlkIiwiUGFuZSIsIkJ1dHRvbkdyb3VwIiwiaGFsaWduIiwiY2hpbGRyZW4iLCJzaXplIiwicHJvcHMiLCJjb3VudCIsIlJlYWN0IiwiQ2hpbGRyZW4iLCJtYXAiLCJidXR0b24iLCJwbCIsInByb3BUeXBlcyIsIlByb3BUeXBlcyIsImFycmF5T2YiLCJlbGVtZW50IiwiaXNSZXF1aXJlZCIsIm51bWJlciIsImRlZmF1bHRQcm9wcyJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7O0FBQUE7O0FBQ0E7O0FBQ0E7O0FBRUE7O0FBQ0E7Ozs7OztBQUVBLElBQU1BLEtBQUssR0FBRyxrQ0FBT0MsVUFBUCxDQUFIO0FBQUE7QUFBQTtBQUFBLHFEQUNQQyxVQURPLENBQVg7O0FBTU8sSUFBTUMsV0FBVyxHQUFHLFNBQWRBLFdBQWMsT0FBMEM7QUFBQSxNQUF2Q0MsTUFBdUMsUUFBdkNBLE1BQXVDO0FBQUEsTUFBL0JDLFFBQStCLFFBQS9CQSxRQUErQjtBQUFBLE1BQXJCQyxJQUFxQixRQUFyQkEsSUFBcUI7QUFBQSxNQUFaQyxLQUFZOztBQUNuRSxNQUFNQyxLQUFLLEdBQUdDLGtCQUFNQyxRQU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