'use strict'

import React from 'react'
import classNames from 'classnames'

module.exports = React.createClass({

    render() {

        //TODO: 此处需要以后处理
        var column = React.Children.count(Array.isArray(this.props.children[0]) ? this.props.children[0] : this.props.children)

        return (
            <div {...this.props}
                className={classNames(this.props.className, 'am-g am-g-fixed')}>
                {this.renderChildren(column)}
            </div>
        )
    },

    renderChildren(column){
        return React.Children.map(this.props.children, (child) => {
            if (child && child.props.componentsType === 'GridInner') {
                return React.cloneElement(child, {column: column})
            } else {
                return child
            }
        })
    }
})