{"size": 1294, "ext": "js", "max_stars_repo_path": "js/Col.js", "max_stars_repo_name": "JackEasons/amazeui-touch", "max_stars_repo_stars_event_min_datetime": "2015-10-28T06:15:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T05:02:30.000Z", "max_issues_repo_path": "js/Col.js", "max_issues_repo_name": "mengxiangtong/amazeui-touch", "max_issues_repo_issues_event_min_datetime": "2015-09-30T08:16:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-11T09:52:50.000Z", "max_forks_repo_path": "js/Col.js", "max_forks_repo_name": "mengxiangtong/amazeui-touch", "max_forks_repo_forks_event_min_datetime": "2015-11-18T03:47:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-16T16:52:34.000Z"}
{"max_stars_count": 1093, "max_issues_count": 130, "max_forks_count": 379, "avg_line_length": 20.21875, "max_line_length": 67, "alphanum_fraction": 0.6244204019}
import PropTypes from 'prop-types';
import React from 'react';
import createReactClass from 'create-react-class';
import cx from 'classnames';
import {component as componentPropType} from './InternalPropTypes';
import ClassNameMixin from './mixins/ClassNameMixin';

import '../scss/components/_grid.scss';

const Col = createReactClass({
  displayName: 'Col',
  mixins: [ClassNameMixin],

  propTypes: {
    classPrefix: PropTypes.string.isRequired,
    component: componentPropType.isRequired,
    cols: PropTypes.number,
    offset: PropTypes.number,
    shrink: PropTypes.bool,
  },

  getDefaultProps() {
    return {
      classPrefix: 'col',
      component: 'div'
    };
  },

  render() {
    let {
      component: Component,
      cols,
      offset,
      shrink,
      className,
      ...props,
    } = this.props;
    let classSet = this.getClassSet();

    delete props.classPrefix;

    if (cols) {
      classSet[this.prefixClass(cols)] = true;
    }

    if (offset) {
      classSet[this.prefixClass('offset-' + offset)] = true;
    }

    classSet[this.prefixClass('shrink')] = shrink;

    return (
      <Component
        {...props}
        className={cx(className, classSet)}
      >
        {this.props.children}
      </Component>
    );
  },
});

export default Col;
