function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/*
 * @Author: codingfly
 * @Description:
 * @Date: 2021-08-05 14:55:52
 * @LastEditTime: 2021-09-08 15:50:00
 * @FilePath: \annar-master\components\row\index.tsx
 */
import React, { useMemo } from 'react';
import { View } from 'remax/one';
import classNames from 'classnames';
import { getPrefixCls } from './../common';
var prefixCls = getPrefixCls('row');

var renderCols = function renderCols(columns, halfGutter) {
  var cols = React.Children.map(columns, function (column) {
    var style = halfGutter ? {
      paddingLeft: "".concat(halfGutter, "px"),
      paddingRight: "".concat(halfGutter, "px")
    } : null;
    return Object.assign(Object.assign({}, column), {
      props: Object.assign(Object.assign({}, column.props), {
        style: Object.assign(Object.assign({}, column.props.style), style)
      })
    });
  });
  return cols;
};

var Row = function Row(props) {
  var _classNames;

  var _props$gutter = props.gutter,
      gutter = _props$gutter === void 0 ? 0 : _props$gutter,
      _props$justify = props.justify,
      justify = _props$justify === void 0 ? 'start' : _props$justify,
      _props$align = props.align,
      align = _props$align === void 0 ? 'top' : _props$align,
      style = props.style,
      className = props.className,
      children = props.children;
  var halfGutter = useMemo(function () {
    return gutter / 2;
  }, [gutter]);
  return /*#__PURE__*/React.createElement(View, {
    className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-justify-").concat(justify), justify), _defineProperty(_classNames, "".concat(prefixCls, "-align-").concat(align), align), _classNames), className),
    style: Object.assign(Object.assign({}, style), {
      marginLeft: "-".concat(halfGutter, "px"),
      marginRight: "-".concat(halfGutter, "px")
    })
  }, renderCols(children, halfGutter));
};

export default Row;