"use strict";

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

var _ = require("..");

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

var _utils = require("../../../utils");

var _Flex = _interopRequireDefault(require("../Flex"));

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); }

const addonsDefaultStyle = {
  p: 3,
  borderColor: 'gray.300',
  borderWidth: 1
};

const InputLeftAddon = props => {
  return /*#__PURE__*/_react.default.createElement(_.Box, _extends({}, addonsDefaultStyle, {
    borderRightWidth: 0,
    roundedLeft: 4,
    bg: "gray.200"
  }, props), /*#__PURE__*/_react.default.createElement(_.Box, {
    m: "auto"
  }, props.children));
};

exports.InputLeftAddon = InputLeftAddon;

const InputRightAddon = props => {
  return /*#__PURE__*/_react.default.createElement(_.Box, _extends({}, addonsDefaultStyle, {
    borderLeftWidth: 0,
    roundedRight: 4,
    bg: "gray.200"
  }, props), /*#__PURE__*/_react.default.createElement(_.Box, {
    m: "auto"
  }, props.children));
};

exports.InputRightAddon = InputRightAddon;

const supplyPropsToChildren = (children, props) => {
  return _react.default.Children.map(children, child => {
    return /*#__PURE__*/_react.default.cloneElement(child, props, child.props.children);
  });
};

const InputGroup = ({
  children,
  ...props
}) => {
  return /*#__PURE__*/_react.default.createElement(_Flex.default, {
    direction: "row",
    wrap: "wrap"
  }, supplyPropsToChildren((0, _utils.getAttachedChildren)(children), props));
};

exports.InputGroup = InputGroup;
//# sourceMappingURL=InputGroup.js.map