import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import debounce from 'lodash.debounce';
import merge from '../util/merge';
import ItemTable from './ItemTable';
import pubsub from '../util/observer';
import { isObject } from '../util/isType';
import measureScrollbar from '../util/measureScrollbar';
import Loading from '../loading';
import Pagination from '../pagination';
import listenCssRender from '../util/listenCssRender';
import getByteLen from '../util/getByteLen';

var Table =
/*#__PURE__*/
function (_PureComponent) {
  _inherits(Table, _PureComponent);

  /** *
   *  params:
   *  columns: 表格设定。
   *  title: string类型，标题，非可选
   *  key: string类型，键值，非可选
   *  style: object类型，样式，可选
   *  render: func类型，渲染自定义html，可选
   *  dataSource: array类型，表格渲染的数据，可选。
   *  onClickTh: 函数类型，点击标题触发的回调函数。
   *  loading: bool类型，当图表未加载到数据时候使用，显示正在加载数据状态。
   *  filterData: array类型，表单过滤，可选。
   *  selectSort: array类型，表单排序，可选。
   *  checkboxCallback: func类型，表单选择回调函数，参数：selectDatas, array类型，选择的行数据。
   *  allBorder: bool类型，是否显示全边框，true为显示，false为只显示下边框，可选，默认为false
   *  stripe: bool类型，是否显示条纹表格，true为显示，false为不显示，可选，默认为不显示。
   * */
  function Table(props, context) {
    var _this;

    _classCallCheck(this, Table);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Table).call(this, props, context));

    _defineProperty(_assertThisInitialized(_this), "expandDataSourceRow", function (dataSource, expandOpt) {
      if (expandOpt) {
        dataSource = dataSource.map(function (item, index) {
          var tempItem = _objectSpread({}, item);

          if (item._tableExpandRow) {
            tempItem._tableExpandRow = '错误，重复定义展开栏字段';
          } else {
            tempItem._tableExpandRow = function () {
              return expandOpt.render(item, index);
            };
          }

          return tempItem;
        });
      }

      return dataSource;
    });

    _defineProperty(_assertThisInitialized(_this), "activeMouse", function (position) {
      _this.activeMouseType = position;
    });

    _defineProperty(_assertThisInitialized(_this), "initItemTableWidthHeight", function () {
      var _this$props = _this.props,
          leftFixed = _this$props.leftFixed,
          rightFixed = _this$props.rightFixed;

      if (leftFixed || rightFixed) {
        var tdWidthArray = {};
        var rowHeightArray = {};

        var getElementChildrenArray = function getElementChildrenArray(elm, tag) {
          return [].slice.call(elm.getElementsByTagName(tag));
        };

        var tbodyChildren = getElementChildrenArray(_this.mainTbody, 'tr');
        var theadChildren = getElementChildrenArray(_this.mainThead, 'th');
        var leftTbodyChildren;
        var leftTheadChildren;
        var rightTbodyChildren;
        var rightTheadChildren;

        if (leftFixed) {
          leftTbodyChildren = getElementChildrenArray(_this.leftFixColumnTbody, 'tr');
          leftTheadChildren = getElementChildrenArray(_this.leftFixColumnThead, 'th');
        }

        if (rightFixed) {
          rightTbodyChildren = getElementChildrenArray(_this.rightFixColumnTbody, 'tr');
          rightTheadChildren = getElementChildrenArray(_this.rightFixColumnThead, 'th');
        } // 设置均等高度


        tbodyChildren.forEach(function (item, id) {
          var _item$getBoundingClie = item.getBoundingClientRect(),
              height = _item$getBoundingClie.height;

          rowHeightArray[id] = height;

          if (leftFixed && leftTbodyChildren[id]) {
            leftTbodyChildren[id].style.height = "".concat(height, "px");
          }

          if (rightFixed && rightTbodyChildren[id]) {
            rightTbodyChildren[id].style.height = "".concat(height, "px");
          }
        }); // 设置均等宽度

        theadChildren.forEach(function (item, id) {
          var _item$getBoundingClie2 = item.getBoundingClientRect(),
              width = _item$getBoundingClie2.width;

          tdWidthArray[id] = width;

          if (leftFixed && leftTheadChildren[id]) {
            leftTheadChildren[id].style.width = width;
          }

          if (rightFixed && rightTheadChildren[id]) {
            rightTheadChildren[id].style.width = width;
          }
        });
        listenCssRender(_this.setState({
          baseHeaderHeight: _this.mainThead.getBoundingClientRect().height
        }));

        _this.setState({
          tdWidthArray: tdWidthArray,
          rowHeightArray: rowHeightArray,
          showFixTable: true
        });
      }
    });

    _defineProperty(_assertThisInitialized(_this), "handleResizeEvent", debounce(function () {
      _this.initItemTableWidthHeight();

      if (_this.innerTable) {
        pubsub.publish('handleResizeEvent');

        var _this$innerTable$getB = _this.innerTable.getBoundingClientRect(),
            width = _this$innerTable$getB.width;

        _this.setState({
          tableConatinerWidth: width
        });
      }
    }, 300));

    _defineProperty(_assertThisInitialized(_this), "initFixedColumns", function () {
      var _this$props2 = _this.props,
          columns = _this$props2.columns,
          leftFixed = _this$props2.leftFixed,
          rightFixed = _this$props2.rightFixed,
          checkbox = _this$props2.checkbox,
          expandOpt = _this$props2.expandOpt,
          children = _this$props2.children;
      var dataSource = _this.state.dataSource;

      var fixedProps = function fixedProps(position) {
        return {
          position: position,
          columns: [],
          dataSource: [],
          width: '0px',
          columnsId: []
        };
      };

      var leftFixedProps = fixedProps('left');
      var rightFixedProps = fixedProps('right');
      var mainProps = {
        columns: merge(columns),
        dataSource: merge(dataSource)
      };
      /**
       * 初始化左侧固定栏和右侧固定栏
       * */

      var initFixedProps = function initFixedProps(itemColumns, id) {
        var type = itemColumns.fixed;

        var renderItemData = function renderItemData(originalData) {
          var columnId = id;
          mainProps.columns[id].title = '';
          originalData.columns.push(itemColumns);
          originalData.width = "".concat(parseInt(originalData.width.replace('px', ''), 10) + itemColumns.width, "px");
          mainProps.dataSource.forEach(function (itemData, index) {
            originalData.dataSource[index] = originalData.dataSource[index] || {};

            if (expandOpt || children) {
              originalData.dataSource[index]._tableExpandRow = dataSource[index]._tableExpandRow;
            }

            Object.assign(originalData.dataSource[index], _defineProperty({}, itemColumns.key, itemData[itemColumns.key]));
          });

          if (checkbox) {
            columnId += 1;
          }

          if (expandOpt && expandOpt.display || children && children.display) {
            columnId += 1;
          }

          originalData.columnsId.push(columnId);
        };

        if (type === 'left' && leftFixed) {
          renderItemData(leftFixedProps);
        } else if (type === 'right' && rightFixed) {
          renderItemData(rightFixedProps);
        }
      };

      columns.forEach(function (item, index) {
        initFixedProps(item, index);
      });
      return {
        leftFixedProps: leftFixedProps,
        rightFixedProps: rightFixedProps,
        mainProps: mainProps
      };
    });

    _defineProperty(_assertThisInitialized(_this), "getScrollTableWidth", function () {
      var _this$props3 = _this.props,
          columns = _this$props3.columns,
          checkbox = _this$props3.checkbox,
          expandOpt = _this$props3.expandOpt,
          children = _this$props3.children;
      var tableInnerWidth = 0;
      columns.forEach(function (item) {
        tableInnerWidth += item.width;
      });

      if (checkbox) {
        tableInnerWidth += 50;
      }

      if (expandOpt && expandOpt.display || children && children.display) {
        tableInnerWidth += 50;
      }

      return tableInnerWidth;
    });

    _defineProperty(_assertThisInitialized(_this), "handlePassScrollPosition", function (scrollTop) {
      _this.setState({
        scrollTop: scrollTop
      });
    });

    _defineProperty(_assertThisInitialized(_this), "handleBodyScrollVertical", function (elm, type) {
      var _this$props4 = _this.props,
          leftFixed = _this$props4.leftFixed,
          rightFixed = _this$props4.rightFixed;
      var target = elm.target;
      var scrollTop = target.scrollTop;

      if (_this.activeMouseType === type) {
        if (type !== 'main') {
          _this.mainTbody.scrollTop = scrollTop;
        }

        if (leftFixed && type !== 'left') {
          _this.leftFixColumnTbody.scrollTop = scrollTop;
        }

        if (rightFixed && type !== 'right') {
          _this.rightFixColumnTbody.scrollTop = scrollTop;
        }
      }
    });

    _this.pubsubEventString = {
      token: new Date().getTime()
    };
    var _this$props5 = _this.props,
        _columns = _this$props5.columns,
        _expandOpt = _this$props5.expandOpt,
        _children = _this$props5.children,
        _dataSource = _this$props5.dataSource;
    _this.dataSource = _this.expandDataSourceRow(_dataSource, _expandOpt || _children);

    _columns.forEach(function (item) {
      var width;

      if (!item.width) {
        width = 16 * getByteLen(item.title) * 2;

        if (item.sort) {
          width += 25;
        }

        if (item.filters) {
          width += 25;
        }

        item.width = width;
      }
    });

    _this.state = {
      tableConatinerWidth: '100%',
      tdWidthArray: {},
      rowHeightArray: {},
      dataSource: _this.dataSource,
      showFixTable: false
    };
    return _this;
  }

  _createClass(Table, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      /**
       * 监听scroll滚动事件，判断存在固定栏的表格的滚动位置
       * */
      var _this$props6 = this.props,
          leftFixed = _this$props6.leftFixed,
          rightFixed = _this$props6.rightFixed,
          prefixCls = _this$props6.prefixCls;

      if (leftFixed || rightFixed) {
        var timer = 0;

        var fixBorderDelCls = function fixBorderDelCls(currentCls, position) {
          var shadowCls = "".concat(prefixCls, "-").concat(position, "-fixed-shadow-border");
          return currentCls.match(shadowCls) ? currentCls.split(shadowCls)[0] : currentCls;
        };

        var fixBorderAddCls = function fixBorderAddCls(currentCls, position) {
          var shadowCls = "".concat(prefixCls, "-").concat(position, "-fixed-shadow-border");
          return currentCls.match(shadowCls) ? currentCls : "".concat(currentCls, " ").concat(shadowCls);
        };

        this.innerTable.addEventListener('scroll', function (event) {
          var targetNode = event.target;
          var targetScroll = targetNode.getBoundingClientRect().width - 2 + targetNode.scrollLeft;
          var leftCls = _this2.leftTableItem ? _this2.leftTableItem.className : null;
          var rightCls = _this2.rightTableItem ? _this2.rightTableItem.className : null;

          if (leftFixed) {
            if (targetNode.scrollLeft === 0) {
              _this2.leftTableItem.className = fixBorderDelCls(leftCls, 'left');
            } else {
              _this2.leftTableItem.className = fixBorderAddCls(leftCls, 'left');
            }
          }

          if (rightFixed) {
            if (targetScroll + 10 >= _this2.getScrollTableWidth()) {
              _this2.rightTableItem.className = fixBorderDelCls(rightCls, 'right');
            } else {
              _this2.rightTableItem.className = fixBorderAddCls(rightCls, 'right');
            }
          }

          timer && clearTimeout(timer);
          timer = setTimeout(function () {
            if (leftFixed) {
              _this2.leftTableItem.className = fixBorderDelCls(leftCls, 'left');
            }

            if (rightFixed) {
              _this2.rightTableItem.className = fixBorderDelCls(rightCls, 'right');
            }
          }, 500);
        }, false);
      }

      var initInnerTableWidth = function initInnerTableWidth() {
        var _this2$innerTable$get = _this2.innerTable.getBoundingClientRect(),
            width = _this2$innerTable$get.width;

        _this2.setState({
          tableConatinerWidth: width
        });
      };

      listenCssRender(initInnerTableWidth);
      listenCssRender(this.handleResizeEvent);
      window.addEventListener('resize', this.handleResizeEvent, false);
    }
  }, {
    key: "componentWillReceiveProps",
    value: function componentWillReceiveProps(nextProps) {
      var _this$props7 = this.props,
          dataSource = _this$props7.dataSource,
          stripe = _this$props7.stripe,
          allBorder = _this$props7.allBorder,
          warpBorder = _this$props7.warpBorder,
          expandOpt = _this$props7.expandOpt,
          children = _this$props7.children,
          scroll = _this$props7.scroll;
      var reRenderWidthHeight = false;

      if (dataSource !== nextProps.dataSource) {
        var scrollToFirstRowOnChange = scroll.scrollToFirstRowOnChange;
        if (scrollToFirstRowOnChange !== false) this.mainTbody.scrollTop = 0;
        this.setState({
          dataSource: this.expandDataSourceRow(nextProps.dataSource, expandOpt || children)
        });
        this.initFixedColumns();
        reRenderWidthHeight = true;
      }

      if (stripe !== nextProps.stripe || allBorder !== nextProps.allBorder || warpBorder !== nextProps.warpBorder) {
        reRenderWidthHeight = true;
      }

      if (reRenderWidthHeight) {
        listenCssRender(this.initItemTableWidthHeight);
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      window.removeEventListener('resize', this.handleResizeEvent, false);
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;

      var _this$props8 = this.props,
          onClickTh = _this$props8.onClickTh,
          styles = _this$props8.styles,
          className = _this$props8.className,
          allBorder = _this$props8.allBorder,
          stripe = _this$props8.stripe,
          textCenter = _this$props8.textCenter,
          rowHeight = _this$props8.rowHeight,
          prefixCls = _this$props8.prefixCls,
          checkboxCallback = _this$props8.checkboxCallback,
          checkbox = _this$props8.checkbox,
          expandOpt = _this$props8.expandOpt,
          children = _this$props8.children,
          width = _this$props8.width,
          hideTableTitle = _this$props8.hideTableTitle,
          leftFixed = _this$props8.leftFixed,
          rightFixed = _this$props8.rightFixed,
          onSort = _this$props8.onSort,
          warpBorder = _this$props8.warpBorder,
          pagination = _this$props8.pagination,
          scroll = _this$props8.scroll,
          loading = _this$props8.loading,
          hover = _this$props8.hover,
          loadingCls = _this$props8.loadingCls,
          scrollBarWidth = _this$props8.scrollBarWidth,
          noDataRender = _this$props8.noDataRender;
      var _this$state = this.state,
          tableConatinerWidth = _this$state.tableConatinerWidth,
          scrollPosition = _this$state.scrollPosition,
          scrollTop = _this$state.scrollTop,
          rowHeightArray = _this$state.rowHeightArray,
          tdWidthArray = _this$state.tdWidthArray,
          baseHeaderHeight = _this$state.baseHeaderHeight,
          showFixTable = _this$state.showFixTable;
      var containerCN = "".concat(prefixCls, " ").concat(className);
      /**
       * 是否具有区分背景
       * */

      if (stripe) {
        containerCN += ' stripe';
      } else {
        containerCN += " ".concat(prefixCls, "-border-row");
      }
      /**
       * border样式
       * */


      if (warpBorder) {
        containerCN += " ".concat(prefixCls, "-warp-border");
      }

      if (!warpBorder && allBorder) {
        containerCN += " ".concat(prefixCls, "-all-border");
      }

      if (textCenter) {
        containerCN += ' text-center';
      }

      var _this$initFixedColumn = this.initFixedColumns(),
          leftFixedProps = _this$initFixedColumn.leftFixedProps,
          rightFixedProps = _this$initFixedColumn.rightFixedProps,
          mainProps = _this$initFixedColumn.mainProps;

      var leftStyles = _objectSpread({}, styles, {
        width: leftFixedProps.width
      });

      var rightStyles = _objectSpread({}, styles, {
        width: rightFixedProps.width
      });

      var tableInnerWidth = this.getScrollTableWidth();
      var shouldScroll = tableConatinerWidth < tableInnerWidth;
      var warpWidth = null;
      var finalWidth = tableConatinerWidth;

      if (shouldScroll) {
        warpWidth = scrollBarWidth ? tableConatinerWidth - scrollBarWidth : null;
        finalWidth = tableInnerWidth;
      }

      var mainTableProps = {
        hover: hover,
        scroll: scroll,
        onSort: onSort,
        leftFixed: leftFixed,
        rightFixed: rightFixed,
        onClickTh: onClickTh,
        textCenter: textCenter,
        rowHeight: rowHeight,
        prefixCls: prefixCls,
        checkbox: checkbox,
        checkboxCallback: checkboxCallback,
        expandOpt: expandOpt,
        children: children,
        hideTableTitle: hideTableTitle,
        stripe: stripe,
        baseHeaderHeight: baseHeaderHeight,
        shouldScroll: shouldScroll,
        scrollTop: scrollTop,
        scrollBarWidth: scrollBarWidth,
        rowHeightArray: rowHeightArray,
        tdWidthArray: tdWidthArray,
        warpBorder: warpBorder,
        allBorder: allBorder,
        activeMouse: this.activeMouse,
        columns: mainProps.columns,
        dataSource: mainProps.dataSource,
        handlePassScrollPosition: this.handlePassScrollPosition,
        handleBodyScrollVertical: this.handleBodyScrollVertical,
        theadRef: function theadRef(el) {
          _this3.mainThead = el;
        },
        tbodyRef: function tbodyRef(el) {
          _this3.mainTbody = el;
        },
        tableRef: function tableRef(el) {
          _this3.mainTableItem = el;
        },
        pubsubEventString: this.pubsubEventString,
        handleInnerScrollEvent: function handleInnerScrollEvent(elm) {
          return _this3.innerTable = elm;
        },
        noDataRender: noDataRender,
        styles: styles,
        warpWidth: warpWidth,
        position: 'main',
        width: finalWidth
      };
      var leftTableProps = {
        hover: hover,
        scroll: scroll,
        onSort: onSort,
        leftFixed: leftFixed,
        rightFixed: rightFixed,
        onClickTh: onClickTh,
        textCenter: textCenter,
        rowHeight: rowHeight,
        prefixCls: prefixCls,
        checkbox: checkbox,
        checkboxCallback: checkboxCallback,
        expandOpt: expandOpt,
        children: children,
        hideTableTitle: hideTableTitle,
        stripe: stripe,
        baseHeaderHeight: baseHeaderHeight,
        shouldScroll: shouldScroll,
        scrollTop: scrollTop,
        scrollBarWidth: scrollBarWidth,
        rowHeightArray: rowHeightArray,
        tdWidthArray: tdWidthArray,
        warpBorder: warpBorder,
        allBorder: allBorder,
        activeMouse: this.activeMouse,
        columns: leftFixedProps.columns,
        dataSource: leftFixedProps.dataSource,
        handlePassScrollPosition: this.handlePassScrollPosition,
        handleBodyScrollVertical: this.handleBodyScrollVertical,
        theadRef: function theadRef(el) {
          _this3.leftFixColumnThead = el;
        },
        tbodyRef: function tbodyRef(el) {
          _this3.leftFixColumnTbody = el;
        },
        tableRef: function tableRef(el) {
          _this3.leftTableItem = el;
        },
        pubsubEventString: this.pubsubEventString,
        mainTbody: this.mainTbody,
        showFixTable: showFixTable,
        mainDataSource: mainProps.dataSource,
        columnsId: leftFixedProps.columnsId,
        position: leftFixedProps.position,
        styles: leftStyles,
        scrollPosition: scrollPosition
      };
      var rightTableProps = {
        hover: hover,
        scroll: scroll,
        onSort: onSort,
        position: rightFixedProps.position,
        dataSource: rightFixedProps.dataSource,
        columns: rightFixedProps.columns,
        columnsId: rightFixedProps.columnsId,
        leftFixed: leftFixed,
        rightFixed: rightFixed,
        onClickTh: onClickTh,
        styles: rightStyles,
        textCenter: textCenter,
        rowHeight: rowHeight,
        prefixCls: prefixCls,
        hideTableTitle: hideTableTitle,
        stripe: stripe,
        width: width,
        scrollPosition: scrollPosition,
        shouldScroll: shouldScroll,
        scrollTop: scrollTop,
        scrollBarWidth: scrollBarWidth,
        baseHeaderHeight: baseHeaderHeight,
        expandOpt: expandOpt,
        children: children,
        rowHeightArray: rowHeightArray,
        tdWidthArray: tdWidthArray,
        warpBorder: warpBorder,
        allBorder: allBorder,
        activeMouse: this.activeMouse,
        theadRef: function theadRef(el) {
          _this3.rightFixColumnThead = el;
        },
        tbodyRef: function tbodyRef(el) {
          _this3.rightFixColumnTbody = el;
        },
        tableRef: function tableRef(el) {
          _this3.rightTableItem = el;
        },
        handlePassScrollPosition: this.handlePassScrollPosition,
        handleBodyScrollVertical: this.handleBodyScrollVertical,
        pubsubEventString: this.pubsubEventString,
        mainTbody: this.mainTbody,
        showFixTable: showFixTable,
        mainDataSource: mainProps.dataSource
      };
      return React.createElement(Loading, {
        show: loading,
        className: loadingCls
      }, React.createElement("div", {
        className: containerCN,
        style: {
          width: width || scroll.x
        },
        ref: function ref(table) {
          return _this3.neTable = table;
        }
      }, React.createElement(ItemTable, mainTableProps), leftFixed && React.createElement(ItemTable, leftTableProps), rightFixed && React.createElement(ItemTable, rightTableProps)), isObject(pagination) ? React.createElement("div", {
        className: "".concat(prefixCls, "-pagination")
      }, React.createElement(Pagination, _extends({
        isCompact: true
      }, pagination))) : null);
    }
  }]);

  return Table;
}(PureComponent);

_defineProperty(Table, "propTypes", {
  /**
   * 加载数据的时候是否显示loading
   * */
  loading: PropTypes.bool,

  /**
   * 表格列设定
   * */
  columns: PropTypes.array,

  /**
   * 普通表格数据源，
   * */
  dataSource: PropTypes.array,

  /**
   * 点击标题回调函数，
   * */
  onClickTh: PropTypes.func,

  /**
   * 自定义类名
   * */
  className: PropTypes.string,

  /**
   * 表格的高度，不设定则为自定义
   * */
  rowHeight: PropTypes.string,

  /**
   * 文字内容是否居中
   * */
  textCenter: PropTypes.bool,

  /**
   * 是否显示选择框
   * */
  checkbox: PropTypes.bool,

  /**
   * 触发选择框的回调函数
   * */
  checkboxCallback: PropTypes.func,

  /**
   * 表格边框设置
   * */
  allBorder: PropTypes.bool,

  /**
   * 表格斑马线设置
   * */
  stripe: PropTypes.bool,

  /**
   * 是否设定hover
   * */
  // hover: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),

  /**
   * 表格左侧固定栏
   * */
  leftFixed: PropTypes.bool,

  /**
   * 表格右侧固定栏
   * */
  rightFixed: PropTypes.bool,

  /**
   * 是否隐藏表头
   * */
  hideTableTitle: PropTypes.bool,

  /**
   * 自定义样式设定
   * */
  styles: PropTypes.object,

  /**
   * 类名前缀设定
   * */
  prefixCls: PropTypes.string,

  /**
   * 最外层loading层类名设定
   * */
  loadingCls: PropTypes.string,

  /**
   * 显示分页，参数同 Pagination 组件
   * 传 false 不显示分页
   * */
  pagination: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),

  /**
   * 排序回调函数
   * */
  onSort: PropTypes.func,

  /**
   * 排序回调函数
   * */
  warpBorder: PropTypes.bool,

  /**
   * 表头固定和列固定滚动距离
   * */
  scroll: PropTypes.object,

  /**
   * 展开栏的配置项
   * expandOpt = {
   *      display: true,
   *      icon: <Icon type="xx" />,
   *      render: (data) => {
   *          // data 为当前行数据
   *          return (
   *              <div>展开栏目</div>
   *          )
   *      }
   * }
   * */
  expandOpt: PropTypes.object,

  /**
   * 展开子配置项
   * children = {
   *      display: true,
   *      icon: <Icon type="xx" />,
   *      render: (data) => {
   *          // data 为当前行数据
   *          return (
   *              <div>展开栏目</div>
   *          )
   *      }
   * }
   * */
  children: PropTypes.object,

  /**
   * 当表格为空的时候渲染的函数
   * */
  noDataRender: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.element]),

  /**
   * 设置表格的宽度
   * */
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
});

_defineProperty(Table, "defaultProps", {
  onClickTh: function onClickTh() {},
  // width: '100%',
  className: '',
  checkbox: false,
  checkboxCallback: function checkboxCallback(selectDatas) {
    return console.log(selectDatas);
  },
  allBorder: false,
  stripe: false,
  textCenter: false,
  styles: {},
  prefixCls: 'ne-table',
  leftFixed: false,
  rightFixed: false,
  columns: [],
  dataSource: [],
  hideTableTitle: false,
  loading: false,
  pagination: false,
  scroll: {},
  scrollBarWidth: measureScrollbar(),
  noDataRender: '暂无数据'
});

export default Table;