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-04 14:29:13
 * @LastEditTime: 2021-09-06 09:04:07
 * @FilePath: \young\components\space\index.tsx
 */
import React from 'react';
import classNames from 'classnames';
import { View } from 'remax/one';
import { getPrefixCls } from './../common';
var prefixCls = getPrefixCls('space');

var renderItems = function renderItems(children, size, direction) {
  var itemStyle = undefined;

  if (typeof size === 'number') {
    itemStyle = direction === 'vertical' ? {
      marginBottom: size
    } : {
      marginRight: size
    };
  }

  var items = [];
  React.Children.forEach(children, function (child, index) {
    var itemCn = classNames("".concat(prefixCls, "-item"), _defineProperty({}, "".concat(prefixCls, "-").concat(direction, "-").concat(size), typeof size === 'string' && size));

    if (child === undefined || child === null) {
      return;
    }

    items.push( /*#__PURE__*/React.createElement(View, {
      key: index,
      className: itemCn,
      style: itemStyle
    }, child));
  });
  return items;
};

var Space = function Space(props) {
  var _classNames2;

  var _props$size = props.size,
      size = _props$size === void 0 ? 'small' : _props$size,
      _props$direction = props.direction,
      direction = _props$direction === void 0 ? 'horizontal' : _props$direction,
      _props$align = props.align,
      align = _props$align === void 0 ? direction === 'horizontal' ? 'center' : undefined : _props$align,
      justify = props.justify,
      style = props.style,
      className = props.className,
      children = props.children;
  var cn = classNames(prefixCls, "".concat(prefixCls, "-").concat(direction), (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-align-").concat(align), align), _defineProperty(_classNames2, "".concat(prefixCls, "-justify-").concat(justify), justify), _classNames2), className);
  return /*#__PURE__*/React.createElement(View, {
    className: cn,
    style: style
  }, renderItems(children, size, direction));
};

export default Space;