import React from 'react';
import Const from './Const';
import classSet from 'classnames';

export default {
  renderReactSortCaret(order) {
    const orderClass = classSet('order', {
      'dropup': order === Const.SORT_ASC
    });
    return (
      <span className={ orderClass }>
        <span className='caret' style={ { margin: '10px 5px' } }></span>
      </span>
    );
  },

  getScrollBarWidth() {
    const inner = document.createElement('p');
    inner.style.width = '100%';
    inner.style.height = '200px';

    const outer = document.createElement('div');
    outer.style.position = 'absolute';
    outer.style.top = '0px';
    outer.style.left = '0px';
    outer.style.visibility = 'hidden';
    outer.style.width = '200px';
    outer.style.height = '150px';
    outer.style.overflow = 'hidden';
    outer.appendChild(inner);

    document.body.appendChild(outer);
    const w1 = inner.offsetWidth;
    outer.style.overflow = 'scroll';
    let w2 = inner.offsetWidth;
    if (w1 === w2) w2 = outer.clientWidth;

    document.body.removeChild(outer);

    return (w1 - w2);
  },

  canUseDOM() {
    return typeof window !== 'undefined' && typeof window.document !== 'undefined';
  }
};

@@ -1,12 +1,47 @@
+/* eslint react/display-name: 0 */%0A
 import React
@@ -1223,15 +1223,1017 @@
 fined';%0A
+  %7D,%0A%0A  renderColGroup(columns, selectRow) %7B%0A    let selectRowHeader = null;%0A    const isSelectRowDefined = selectRow.mode === Const.ROW_SELECT_SINGLE %7C%7C%0A      selectRow.mode === Const.ROW_SELECT_MULTI;%0A    if (isSelectRowDefined) %7B%0A      const style = %7B%0A        width: 30,%0A        minWidth: 30%0A      %7D;%0A      if (!selectRow.hideSelectColumn) %7B%0A        selectRowHeader = (%3Ccol style=%7B style %7D key=%7B -1 %7D%3E%3C/col%3E);%0A      %7D%0A    %7D%0A    const theader = columns.map(function(column, i) %7B%0A      const style = %7B%0A        display: column.hidden ? 'none' : null%0A      %7D;%0A      if (column.width) %7B%0A        const width = parseInt(column.width, 10);%0A        style.width = width;%0A        /** add min-wdth to fix user assign column width%0A        not eq offsetWidth in large column table **/%0A        style.minWidth = width;%0A      %7D%0A      return (%3Ccol style=%7B style %7D key=%7B i %7D className=%7B column.className %7D%3E%3C/col%3E);%0A    %7D);%0A%0A    return (%0A      %3Ccolgroup%3E%0A        %7B selectRowHeader %7D%7B theader %7D%0A      %3C/colgroup%3E%0A    );%0A
   %7D%0A%7D;%0A

add render colgroup function