function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

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; }

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
var breakPoints = ['xxs', 'xs', 's', 'm', 'l', 'xl'];
/**
 * Grid.Col
 * @order 2
 */

var Col =
/*#__PURE__*/
function (_Component) {
  _inherits(Col, _Component);

  function Col() {
    _classCallCheck(this, Col);

    return _possibleConstructorReturn(this, _getPrototypeOf(Col).apply(this, arguments));
  }

  _createClass(Col, [{
    key: "render",
    value: function render() {
      var _this = this,
          _objectSpread2;

      /* eslint-disable no-unused-vars */
      var _this$props = this.props,
          prefix = _this$props.prefix,
          pure = _this$props.pure,
          span = _this$props.span,
          offset = _this$props.offset,
          fixedSpan = _this$props.fixedSpan,
          fixedOffset = _this$props.fixedOffset,
          hidden = _this$props.hidden,
          align = _this$props.align,
          xxs = _this$props.xxs,
          xs = _this$props.xs,
          s = _this$props.s,
          m = _this$props.m,
          l = _this$props.l,
          xl = _this$props.xl,
          Tag = _this$props.component,
          className = _this$props.className,
          children = _this$props.children,
          rtl = _this$props.rtl,
          others = _objectWithoutProperties(_this$props, ["prefix", "pure", "span", "offset", "fixedSpan", "fixedOffset", "hidden", "align", "xxs", "xs", "s", "m", "l", "xl", "component", "className", "children", "rtl"]);
      /* eslint-enable no-unused-vars */


      var pointClassObj = breakPoints.reduce(function (ret, point) {
        var pointProps = {};

        if (_typeof(_this.props[point]) === 'object') {
          pointProps = _this.props[point];
        } else {
          pointProps.span = _this.props[point];
        }

        ret["".concat(prefix, "col-").concat(point, "-").concat(pointProps.span)] = !!pointProps.span;
        ret["".concat(prefix, "col-").concat(point, "-offset-").concat(pointProps.offset)] = !!pointProps.offset;
        return ret;
      }, {});
      var hiddenClassObj;

      if (hidden === true) {
        hiddenClassObj = _defineProperty({}, "".concat(prefix, "col-hidden"), true);
      } else if (typeof hidden === 'string') {
        hiddenClassObj = _defineProperty({}, "".concat(prefix, "col-").concat(hidden, "-hidden"), !!hidden);
      } else if (Array.isArray(hidden)) {
        hiddenClassObj = hidden.reduce(function (ret, point) {
          ret["".concat(prefix, "col-").concat(point, "-hidden")] = !!point;
          return ret;
        }, {});
      }

      var classes = cx(_objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, "".concat(prefix, "col"), true), _defineProperty(_objectSpread2, "".concat(prefix, "col-").concat(span), !!span), _defineProperty(_objectSpread2, "".concat(prefix, "col-fixed-").concat(fixedSpan), !!fixedSpan), _defineProperty(_objectSpread2, "".concat(prefix, "col-offset-").concat(offset), !!offset), _defineProperty(_objectSpread2, "".concat(prefix, "col-offset-fixed-").concat(fixedOffset), !!fixedOffset), _defineProperty(_objectSpread2, "".concat(prefix, "col-").concat(align), !!align), _objectSpread2), pointClassObj, {}, hiddenClassObj, _defineProperty({}, className, className)));
      return React.createElement(Tag, _extends({
        dir: rtl ? 'rtl' : 'ltr',
        role: "gridcell",
        className: classes
      }, others), children);
    }
  }]);

  return Col;
}(Component);

_defineProperty(Col, "isNextCol", true);

_defineProperty(Col, "propTypes", {
  prefix: PropTypes.string,
  pure: PropTypes.bool,
  rtl: PropTypes.bool,
  className: PropTypes.string,

  /**
   * 列内容
   */
  children: PropTypes.node,

  /**
   * 列宽度<br><br>**可选值**:<br>1, 2, 3, ..., 22, 23, 24
   */
  span: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

  /**
   * 固定列宽度，宽度值为20 * 栅格数<br><br>**可选值**:<br>1, 2, 3, ..., 28, 29, 30
   */
  fixedSpan: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

  /**
   * （不支持IE9浏览器）列偏移<br><br>**可选值**:<br>1, 2, 3, ..., 22, 23, 24
   */
  offset: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

  /**
   * （不支持IE9浏览器）固定列偏移，宽度值为20 * 栅格数<br><br>**可选值**:<br>1, 2, 3, ..., 28, 29, 30
   */
  fixedOffset: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

  /**
   * （不支持IE9浏览器）多列垂直方向对齐方式，可覆盖Row的align属性
   */
  align: PropTypes.oneOf(['top', 'center', 'bottom', 'baseline', 'stretch']),

  /**
   * 列在不同断点下的显示与隐藏<br><br>**可选值**:<br>true(在所有断点下隐藏)<br>false(在所有断点下显示)<br>'xs'(在 xs 断点下隐藏）<br>['xxs', 'xs', 's', 'm', 'l', 'xl'](在 xxs, xs, s, m, l, xl 断点下隐藏）
   */
  hidden: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.array]),

  /**
   * >=320px，响应式栅格，可为栅格数（span）或一个包含栅格数（span）和偏移栅格数（offset）对象
   */
  xxs: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),

  /**
   * >=480px，响应式栅格，可为栅格数（span）或一个包含栅格数（span）和偏移栅格数（offset）对象
   */
  xs: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),

  /**
   * >=720px，响应式栅格，可为栅格数（span）或一个包含栅格数（span）和偏移栅格数（offset）对象
   */
  s: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),

  /**
   * >=990px，响应式栅格，可为栅格数（span）或一个包含栅格数（span）和偏移栅格数（offset）对象
   */
  m: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),

  /**
   * >=1200px，响应式栅格，可为栅格数（span）或一个包含栅格数（span）和偏移栅格数（offset）对象
   */
  l: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),

  /**
   * >=1500px，响应式栅格，可为栅格数（span）或一个包含栅格数（span）和偏移栅格数（offset）对象
   */
  xl: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]),

  /**
   * 指定以何种元素渲染该节点，默认为 'div'
   */
  component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
});

_defineProperty(Col, "defaultProps", {
  prefix: 'next-',
  pure: false,
  component: 'div'
});

export { Col as default };