"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Grid", {
    enumerable: true,
    get: function() {
        return Grid;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _define_property = require("@swc/helpers/_/_define_property");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _components = require("@tarojs/components");
var _context = /*#__PURE__*/ _interop_require_default._(require("./context"));
var _griditem = require("../griditem/griditem");
var defaultProps = {
    columns: 4,
    gap: 9,
    center: true,
    square: true,
    reverse: false,
    direction: 'vertical'
};
var Grid = function Grid(props) {
    var _ref = (0, _object_spread._)({}, defaultProps, props), children = _ref.children, columns = _ref.columns, gap = _ref.gap, center = _ref.center, square = _ref.square, reverse = _ref.reverse, direction = _ref.direction, style = _ref.style, className = _ref.className, onClick = _ref.onClick, rest = (0, _object_without_properties._)(_ref, [
        "children",
        "columns",
        "gap",
        "center",
        "square",
        "reverse",
        "direction",
        "style",
        "className",
        "onClick"
    ]);
    var childrenDom = _react.default.Children.toArray(children);
    var classPrefix = 'nut-grid';
    var rootClass = function rootClass() {
        return (0, _classnames.default)(classPrefix, (0, _define_property._)({}, "".concat(classPrefix, "-border"), !gap), className);
    };
    var rootStyle = function rootStyle() {
        var styleSelf = {};
        if (style) {
            styleSelf = style;
        }
        return styleSelf;
    };
    return(// @ts-ignore
    /*#__PURE__*/ /*#__PURE__*/ _react.default.createElement(_components.View, (0, _object_spread._)({
        className: rootClass(),
        style: rootStyle()
    }, rest), /*#__PURE__*/ _react.default.createElement(_context.default.Provider, {
        value: {
            onClick: onClick
        }
    }, childrenDom.map(function(item, idex) {
        return /*#__PURE__*/ _react.default.cloneElement(item, {
            index: idex,
            columns: columns,
            center: center,
            gap: gap,
            square: square,
            reverse: reverse,
            direction: direction
        });
    }))));
};
Grid.displayName = 'NutGrid';
Grid.Item = _griditem.GridItem;
