"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.instance = exports["default"] = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));

var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _tslib = require("tslib");

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));

var _raf = _interopRequireDefault(require("raf"));

var _mobxReact = require("mobx-react");

var _pick = _interopRequireDefault(require("lodash/pick"));

var _omit = _interopRequireDefault(require("lodash/omit"));

var _isString = _interopRequireDefault(require("lodash/isString"));

var _isNil = _interopRequireDefault(require("lodash/isNil"));

var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));

var _noop = _interopRequireDefault(require("lodash/noop"));

var _defer = _interopRequireDefault(require("lodash/defer"));

var _mobx = require("mobx");

var _reactBeautifulDnd = require("react-beautiful-dnd");

var _warning = _interopRequireDefault(require("../../../lib/_util/warning"));

var _UnitConvertor = require("../../../lib/_util/UnitConvertor");

var _measureScrollbar = _interopRequireDefault(require("../../../lib/_util/measureScrollbar"));

var _KeyCode = _interopRequireDefault(require("../../../lib/_util/KeyCode"));

var _resizeObserver = _interopRequireDefault(require("../../../lib/_util/resizeObserver"));

var _Column = _interopRequireDefault(require("./Column"));

var _TableRow = _interopRequireDefault(require("./TableRow"));

var _TableHeaderCell = _interopRequireDefault(require("./TableHeaderCell"));

var _TableStore = _interopRequireWildcard(require("./TableStore"));

var _TableHeader = _interopRequireDefault(require("./TableHeader"));

var _autobind = _interopRequireDefault(require("../_util/autobind"));

var _Pagination = _interopRequireDefault(require("../pagination/Pagination"));

var _spin = _interopRequireDefault(require("../spin"));

var _DataSetComponent2 = _interopRequireDefault(require("../data-set/DataSetComponent"));

var _TableContext = require("./TableContext");

var _TableWrapper = _interopRequireDefault(require("./TableWrapper"));

var _Profiler = _interopRequireDefault(require("./Profiler"));

var _TableTBody = _interopRequireDefault(require("./TableTBody"));

var _ExpandableTableTBody = _interopRequireDefault(require("./ExpandableTableTBody"));

var _TableFooter = _interopRequireDefault(require("./TableFooter"));

var _enum = require("./enum");

var _queryBar = _interopRequireDefault(require("./query-bar"));

var _TableToolBar = _interopRequireDefault(require("./query-bar/TableToolBar"));

var _TableFilterBar = _interopRequireDefault(require("./query-bar/TableFilterBar"));

var _TableAdvancedQueryBar = _interopRequireDefault(require("./query-bar/TableAdvancedQueryBar"));

var _TableProfessionalBar = _interopRequireDefault(require("./query-bar/TableProfessionalBar"));

var _TableComboBar = _interopRequireDefault(require("./query-bar/TableComboBar"));

var _TableDynamicFilterBar = _interopRequireDefault(require("./query-bar/TableDynamicFilterBar"));

var _FilterSelect = _interopRequireDefault(require("./query-bar/FilterSelect"));

var _utils = require("./utils");

var _TableBody = _interopRequireDefault(require("./TableBody"));

var _VirtualWrapper = _interopRequireDefault(require("./VirtualWrapper"));

var _SelectionTips = _interopRequireDefault(require("./SelectionTips"));

var _enum2 = require("../data-set/enum");

var _enum3 = require("../core/enum");

var _StickyShadow = _interopRequireDefault(require("./StickyShadow"));

var _utils2 = require("../data-set/utils");

var _mergeProps = _interopRequireDefault(require("../_util/mergeProps"));

var _ErrorBar = _interopRequireDefault(require("./ErrorBar"));

var _TableSibling = _interopRequireDefault(require("./TableSibling"));

var _instance; // 构造一个单例table来防止body下不能有table元素的报错


var instance = function instance(wrapperClassName, prefixCls) {
  // Using a table as the portal so that we do not get react
  // warnings when mounting a tr element
  var _tableContain = function _tableContain() {
    var table = document.createElement('table');

    if (wrapperClassName) {
      table.className = wrapperClassName;
    }

    var thead = document.createElement('thead');
    thead.className = "".concat(prefixCls, "-thead");
    table.appendChild(thead);
    var headtr = document.createElement('tr');
    thead.appendChild(headtr);
    var tbody = document.createElement('tbody');
    tbody.className = "".concat(prefixCls, "-tbody");
    table.appendChild(tbody);

    if (!document.body) {
      throw new Error('document.body required a body to append');
    }

    document.body.appendChild(table);
    return {
      tbody: tbody,
      headtr: headtr
    };
  };

  if (_instance) {
    return _instance;
  }

  return _instance = _tableContain();
};

exports.instance = instance;

var Table = /*#__PURE__*/function (_DataSetComponent) {
  (0, _inherits2["default"])(Table, _DataSetComponent);

  var _super = (0, _createSuper2["default"])(Table);

  function Table() {
    var _this;

    (0, _classCallCheck2["default"])(this, Table);
    _this = _super.apply(this, arguments);
    _this.tableStore = new _TableStore["default"]((0, _assertThisInitialized2["default"])(_this));
    _this.wrapperWidth = [];
    return _this;
  }

  (0, _createClass2["default"])(Table, [{
    key: "currentRow",
    get: function get() {
      var prefixCls = this.prefixCls,
          element = this.element;
      return element ? element.querySelector(".".concat(prefixCls, "-row-current")) : null;
    }
  }, {
    key: "firstRow",
    get: function get() {
      var prefixCls = this.prefixCls,
          element = this.element;
      return element ? element.querySelector(".".concat(prefixCls, "-row:first-child")) : null;
    }
  }, {
    key: "lastRow",
    get: function get() {
      var prefixCls = this.prefixCls,
          element = this.element;
      return element ? element.querySelector(".".concat(prefixCls, "-row:last-child")) : null;
    }
  }, {
    key: "saveResizeRef",
    value: function saveResizeRef(node) {
      this.resizeLine = node;
    }
  }, {
    key: "saveContentRef",
    value: function saveContentRef(node) {
      this.tableContentWrap = node;
    }
  }, {
    key: "useFocusedClassName",
    value: function useFocusedClassName() {
      return false;
    }
  }, {
    key: "setCode",
    value: function setCode(props) {
      var customizedCode = props.customizedCode;

      if (customizedCode) {
        this.code = customizedCode;
      } else {
        (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "setCode", this).call(this, props);
      }
    }
  }, {
    key: "handleResize",
    value: function handleResize(width) {
      var element = this.element,
          tableStore = this.tableStore,
          wrapperWidth = this.wrapperWidth;

      if (width !== undefined) {
        var duplicate = wrapperWidth.includes(width);
        wrapperWidth.unshift(width);
        window.clearTimeout(this.wrapperWidthTimer);
        this.wrapperWidthTimer = window.setTimeout(function () {
          wrapperWidth.pop();
        }, 500);

        if (wrapperWidth.length > 2) {
          wrapperWidth.pop();
        }

        if (duplicate) {
          return;
        }
      }

      if (element && !element.offsetParent) {
        tableStore.styledHidden = true;
      } else if (!tableStore.hidden) {
        this.syncSizeInFrame(width);
      } else {
        tableStore.styledHidden = false;
      }
    }
  }, {
    key: "handleWindowResize",
    value: function handleWindowResize() {
      this.handleResize();
    }
  }, {
    key: "handleDataSetLoad",
    value: function handleDataSetLoad() {
      var tableStore = this.tableStore;

      if (tableStore.performanceEnabled) {
        tableStore.performanceOn = true;
      }

      this.initDefaultExpandedRows();
    }
  }, {
    key: "handleDataSetCreate",
    value: function handleDataSetCreate(_ref) {
      var record = _ref.record,
          dataSet = _ref.dataSet;
      var tableStore = this.tableStore;

      if (tableStore.inlineEdit) {
        if (tableStore.currentEditRecord) {
          tableStore.currentEditRecord.reset();
          dataSet.remove(record);
        } else {
          tableStore.currentEditRecord = record;
        }
      }
    }
  }, {
    key: "handleDataSetReset",
    value: function handleDataSetReset(_ref2) {
      var record = _ref2.record,
          dataSet = _ref2.dataSet;

      if (record) {
        var errors = dataSet.getAllValidationErrors();
        this.bubbleValidationReport(errors.dataSet.length > 0 || errors.records.length > 0);
      } else {
        this.bubbleValidationReport(false);
      }
    }
  }, {
    key: "handleDataSetRemove",
    value: function handleDataSetRemove(_ref3) {
      var records = _ref3.records,
          dataSet = _ref3.dataSet;

      if (records) {
        var errors = dataSet.getAllValidationErrors();
        this.bubbleValidationReport(errors.dataSet.length > 0 || errors.records.length > 0);
      }
    }
  }, {
    key: "handleDataSetValidateSelf",
    value: function handleDataSetValidateSelf(props) {
      var dataSet = props.dataSet;
      var errors = dataSet.getAllValidationErrors();
      this.bubbleValidationReport(errors.dataSet.length > 0 || errors.records.length > 0);
    }
  }, {
    key: "handleDataSetValidate",
    value: function handleDataSetValidate(props) {
      var valid = props.valid,
          dataSet = props.dataSet,
          validationErrors = props.errors,
          noLocate = props.noLocate;
      var autoValidationLocate = this.props.autoValidationLocate;
      var errors = dataSet.getAllValidationErrors();
      this.bubbleValidationReport(errors.dataSet.length > 0 || errors.records.length > 0);

      if (autoValidationLocate !== false && !noLocate && !valid) {
        var tableStore = this.tableStore;

        var _validationErrors = (0, _slicedToArray2["default"])(validationErrors, 1),
            firstInvalidRecord = _validationErrors[0];

        if (firstInvalidRecord) {
          var _errors = firstInvalidRecord.errors,
              record = firstInvalidRecord.record;

          if (_errors.length) {
            if (!tableStore.showCachedSelection) {
              if (dataSet.cachedRecords.includes(record)) {
                (0, _mobx.runInAction)(function () {
                  tableStore.showCachedSelection = true;
                });
              }
            }

            var _errors2 = (0, _slicedToArray2["default"])(_errors, 1),
                name = _errors2[0].field.name;

            if (tableStore.virtual && !(0, _utils.findRow)(tableStore, record)) {
              var tableBodyWrap = this.tableBodyWrap;

              if (tableBodyWrap) {
                var rowMetaData = tableStore.rowMetaData;

                if (rowMetaData) {
                  var metaData = rowMetaData.find(function (m) {
                    return m.record === record;
                  });

                  if (metaData) {
                    tableBodyWrap.scrollTop = metaData.offset;
                  }
                } else {
                  tableBodyWrap.scrollTop = record.index * tableStore.virtualRowHeight;
                }
              }
            }

            (0, _raf["default"])(function () {
              var cell = (0, _utils.findCell)(tableStore, name, undefined, record);

              if (cell) {
                cell.focus();
              }
            });
          }
        }
      }
    }
  }, {
    key: "handleKeyDown",
    value: function handleKeyDown(e) {
      var tableStore = this.tableStore;
      var keyboard = tableStore.keyboard;

      if (!tableStore.editing) {
        try {
          var dataSet = this.props.dataSet;
          var ctrlKey = e.ctrlKey || e.metaKey;
          var altKey = e.altKey;
          var shiftKey = e.shiftKey;

          switch (e.keyCode) {
            case _KeyCode["default"].UP:
              if (shiftKey && keyboard) {
                this.handleKeyDownUpShift(e);
              } else {
                this.handleKeyDownUp(e);
              }

              break;

            case _KeyCode["default"].DOWN:
              if (shiftKey && keyboard) {
                this.handleKeyDownDownShift(e);
              } else {
                this.handleKeyDownDown(e);
              }

              break;

            case _KeyCode["default"].RIGHT:
              this.handleKeyDownRight(e);
              break;

            case _KeyCode["default"].LEFT:
              this.handleKeyDownLeft(e);
              break;

            case _KeyCode["default"].PAGE_UP:
              e.preventDefault();
              dataSet.prePage();
              break;

            case _KeyCode["default"].PAGE_DOWN:
              e.preventDefault();
              dataSet.nextPage();
              break;

            case _KeyCode["default"].HOME:
              this.handleKeyDownHome(e);
              break;

            case _KeyCode["default"].END:
              this.handleKeyDownEnd(e);
              break;

            case _KeyCode["default"].S:
              if (ctrlKey === true && keyboard) this.handleKeyDownCTRLS(e);
              break;

            case _KeyCode["default"].N:
              if (altKey === true && keyboard) this.handleKeyDownCTRLN(e);
              break;

            case _KeyCode["default"].D:
              if (ctrlKey === true && keyboard) this.handleKeyDownCTRLD(e);
              break;

            case _KeyCode["default"].DELETE:
              if (altKey === true && keyboard) this.handleKeyDownCTRLDELETE(e);
              break;

            default:
          }
        } catch (error) {
          (0, _warning["default"])(false, error.message);
        }
      }

      var _this$props$onKeyDown = this.props.onKeyDown,
          onKeyDown = _this$props$onKeyDown === void 0 ? _noop["default"] : _this$props$onKeyDown;
      onKeyDown(e);
    }
  }, {
    key: "focusRow",
    value: function focusRow(row) {
      if (row) {
        var index = row.dataset.index;

        if (index) {
          var dataSet = this.props.dataSet;
          var record = dataSet.findRecordById(index);

          if (record) {
            dataSet.current = record;
            return record;
          }
        }
      }
    }
  }, {
    key: "handleKeyDownHome",
    value: function () {
      var _handleKeyDownHome = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(e) {
        var dataSet;
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                e.preventDefault();
                dataSet = this.props.dataSet;

                if (this.tableStore.isTree) {
                  _context.next = 5;
                  break;
                }

                _context.next = 5;
                return dataSet.first();

              case 5:
                this.focusRow(this.firstRow);

              case 6:
              case "end":
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

      function handleKeyDownHome(_x) {
        return _handleKeyDownHome.apply(this, arguments);
      }

      return handleKeyDownHome;
    }()
  }, {
    key: "handleKeyDownEnd",
    value: function () {
      var _handleKeyDownEnd = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(e) {
        var dataSet;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                e.preventDefault();
                dataSet = this.props.dataSet;

                if (this.tableStore.isTree) {
                  _context2.next = 5;
                  break;
                }

                _context2.next = 5;
                return dataSet.last();

              case 5:
                this.focusRow(this.lastRow);

              case 6:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2, this);
      }));

      function handleKeyDownEnd(_x2) {
        return _handleKeyDownEnd.apply(this, arguments);
      }

      return handleKeyDownEnd;
    }()
  }, {
    key: "handleKeyDownCTRLS",
    value: function () {
      var _handleKeyDownCTRLS = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(e) {
        var dataSet;
        return _regenerator["default"].wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                e.preventDefault();
                dataSet = this.tableStore.dataSet;
                dataSet.submit();

              case 3:
              case "end":
                return _context3.stop();
            }
          }
        }, _callee3, this);
      }));

      function handleKeyDownCTRLS(_x3) {
        return _handleKeyDownCTRLS.apply(this, arguments);
      }

      return handleKeyDownCTRLS;
    }()
  }, {
    key: "handleKeyDownCTRLN",
    value: function () {
      var _handleKeyDownCTRLN = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(e) {
        var _this$tableStore, dataSet, editors;

        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                _this$tableStore = this.tableStore, dataSet = _this$tableStore.dataSet, editors = _this$tableStore.editors;

                if (editors.size) {
                  e.preventDefault();
                  dataSet.create({}, 0);
                }

              case 2:
              case "end":
                return _context4.stop();
            }
          }
        }, _callee4, this);
      }));

      function handleKeyDownCTRLN(_x4) {
        return _handleKeyDownCTRLN.apply(this, arguments);
      }

      return handleKeyDownCTRLN;
    }() // TODO: To be optimized

  }, {
    key: "handleKeyDownCTRLD",
    value: function () {
      var _handleKeyDownCTRLD = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(e) {
        var currentRow, tableStore, dataSet, currentElementSibling, previousElementSibling, index, currentIndex, record, currentRecord, cloneRecodData, dealCloneRecodData, editeColumn, uniqueFieldNames;
        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) {
            switch (_context5.prev = _context5.next) {
              case 0:
                e.preventDefault();
                currentRow = this.currentRow, tableStore = this.tableStore;
                dataSet = tableStore.dataSet;
                currentElementSibling = null; // to justice it can be change or standards compliant

                if ((0, _utils.isCanEdictingRow)(currentRow)) {
                  currentElementSibling = currentRow;
                }

                if (currentElementSibling && tableStore && dataSet) {
                  previousElementSibling = (0, _utils.findIndexedSibling)(currentElementSibling, -1);

                  if (previousElementSibling) {
                    index = previousElementSibling.dataset.index;
                    currentIndex = currentElementSibling.dataset.index;

                    if (index && currentIndex) {
                      record = dataSet.findRecordById(index);
                      currentRecord = dataSet.findRecordById(currentIndex); // exculde the primery key and merge has columns which has edictor

                      if (record && currentRecord && tableStore) {
                        cloneRecodData = record.clone().toData() || {};
                        dealCloneRecodData = {};
                        editeColumn = tableStore.columns.filter(function (column) {
                          return !!column.editor;
                        }).reduce(function (accumulator, nowValue) {
                          return [].concat((0, _toConsumableArray2["default"])(accumulator), [nowValue.name]);
                        }, []).filter(function (v) {
                          return !(v === null || v === undefined || v === '');
                        });

                        if (editeColumn && editeColumn.length > 0) {
                          editeColumn.forEach(function (element) {
                            if (element) {
                              dealCloneRecodData[element] = cloneRecodData[element];
                            }
                          });
                        } // remove the unique name of fields


                        uniqueFieldNames = (0, _utils2.getUniqueFieldNames)(dataSet);

                        if (uniqueFieldNames && uniqueFieldNames.length > 0) {
                          uniqueFieldNames.forEach(function (element) {
                            if (element) {
                              delete dealCloneRecodData[element];
                            }
                          });
                        }

                        currentRecord.set(dealCloneRecodData);
                      }
                    }
                  }
                }

              case 6:
              case "end":
                return _context5.stop();
            }
          }
        }, _callee5, this);
      }));

      function handleKeyDownCTRLD(_x5) {
        return _handleKeyDownCTRLD.apply(this, arguments);
      }

      return handleKeyDownCTRLD;
    }()
  }, {
    key: "handleKeyDownCTRLDELETE",
    value: function () {
      var _handleKeyDownCTRLDELETE = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(e) {
        var dataSet;
        return _regenerator["default"].wrap(function _callee6$(_context6) {
          while (1) {
            switch (_context6.prev = _context6.next) {
              case 0:
                e.preventDefault();
                dataSet = this.tableStore.dataSet;
                dataSet["delete"](dataSet.selected);

              case 3:
              case "end":
                return _context6.stop();
            }
          }
        }, _callee6, this);
      }));

      function handleKeyDownCTRLDELETE(_x6) {
        return _handleKeyDownCTRLDELETE.apply(this, arguments);
      }

      return handleKeyDownCTRLDELETE;
    }()
  }, {
    key: "handleKeyDownUp",
    value: function () {
      var _handleKeyDownUp = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(e) {
        var currentRow, returnRecod, previousElementSibling, dataSet;
        return _regenerator["default"].wrap(function _callee7$(_context7) {
          while (1) {
            switch (_context7.prev = _context7.next) {
              case 0:
                e.preventDefault();
                currentRow = this.currentRow;

                if (!currentRow) {
                  _context7.next = 14;
                  break;
                }

                previousElementSibling = (0, _utils.findIndexedSibling)(currentRow, -1);

                if (!previousElementSibling) {
                  _context7.next = 8;
                  break;
                }

                returnRecod = this.focusRow(previousElementSibling);
                _context7.next = 12;
                break;

              case 8:
                dataSet = this.props.dataSet;
                _context7.next = 11;
                return dataSet.prePage();

              case 11:
                returnRecod = this.focusRow(this.lastRow);

              case 12:
                if (!returnRecod) {
                  _context7.next = 14;
                  break;
                }

                return _context7.abrupt("return", Promise.resolve(returnRecod));

              case 14:
                return _context7.abrupt("return", Promise.reject());

              case 15:
              case "end":
                return _context7.stop();
            }
          }
        }, _callee7, this);
      }));

      function handleKeyDownUp(_x7) {
        return _handleKeyDownUp.apply(this, arguments);
      }

      return handleKeyDownUp;
    }()
  }, {
    key: "handleKeyDownDown",
    value: function () {
      var _handleKeyDownDown = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(e) {
        var currentRow, returnRecod, nextElementSibling, dataSet;
        return _regenerator["default"].wrap(function _callee8$(_context8) {
          while (1) {
            switch (_context8.prev = _context8.next) {
              case 0:
                e.preventDefault();
                currentRow = this.currentRow;

                if (!currentRow) {
                  _context8.next = 14;
                  break;
                }

                nextElementSibling = (0, _utils.findIndexedSibling)(currentRow, 1);

                if (!nextElementSibling) {
                  _context8.next = 8;
                  break;
                }

                returnRecod = this.focusRow(nextElementSibling);
                _context8.next = 12;
                break;

              case 8:
                dataSet = this.props.dataSet;
                _context8.next = 11;
                return dataSet.nextPage();

              case 11:
                returnRecod = this.focusRow(this.firstRow);

              case 12:
                if (!returnRecod) {
                  _context8.next = 14;
                  break;
                }

                return _context8.abrupt("return", Promise.resolve(returnRecod));

              case 14:
                return _context8.abrupt("return", Promise.reject());

              case 15:
              case "end":
                return _context8.stop();
            }
          }
        }, _callee8, this);
      }));

      function handleKeyDownDown(_x8) {
        return _handleKeyDownDown.apply(this, arguments);
      }

      return handleKeyDownDown;
    }()
  }, {
    key: "handleKeyDownDownShift",
    value: function () {
      var _handleKeyDownDownShift = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(e) {
        var dataSet, currentRow, index, record, currentRecord;
        return _regenerator["default"].wrap(function _callee9$(_context9) {
          while (1) {
            switch (_context9.prev = _context9.next) {
              case 0:
                e.preventDefault();
                dataSet = this.tableStore.dataSet;
                currentRow = this.currentRow;

                if (!(currentRow && (0, _utils.isCanEdictingRow)(currentRow))) {
                  _context9.next = 22;
                  break;
                }

                index = currentRow.dataset.index;

                if (!index) {
                  _context9.next = 20;
                  break;
                }

                record = dataSet.findRecordById(index);

                if (!record) {
                  _context9.next = 20;
                  break;
                }

                if (record.selectable) {
                  _context9.next = 12;
                  break;
                }

                this.handleKeyDownDown(e);
                _context9.next = 20;
                break;

              case 12:
                if (record.isSelected) {
                  _context9.next = 16;
                  break;
                }

                dataSet.select(record);
                _context9.next = 20;
                break;

              case 16:
                _context9.next = 18;
                return this.handleKeyDownDown(e);

              case 18:
                currentRecord = _context9.sent;

                if (currentRecord && dataSet) {
                  dataSet.select(currentRecord);
                }

              case 20:
                _context9.next = 23;
                break;

              case 22:
                this.handleKeyDownDown(e);

              case 23:
              case "end":
                return _context9.stop();
            }
          }
        }, _callee9, this);
      }));

      function handleKeyDownDownShift(_x9) {
        return _handleKeyDownDownShift.apply(this, arguments);
      }

      return handleKeyDownDownShift;
    }()
  }, {
    key: "handleKeyDownUpShift",
    value: function () {
      var _handleKeyDownUpShift = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(e) {
        var dataSet, currentRow, index, record, currentRecord;
        return _regenerator["default"].wrap(function _callee10$(_context10) {
          while (1) {
            switch (_context10.prev = _context10.next) {
              case 0:
                e.preventDefault();
                dataSet = this.tableStore.dataSet;
                currentRow = this.currentRow;

                if (!(currentRow && (0, _utils.isCanEdictingRow)(currentRow))) {
                  _context10.next = 22;
                  break;
                }

                index = currentRow.dataset.index;

                if (!index) {
                  _context10.next = 20;
                  break;
                }

                record = dataSet.findRecordById(index);

                if (!record) {
                  _context10.next = 20;
                  break;
                }

                if (record.selectable) {
                  _context10.next = 12;
                  break;
                }

                this.handleKeyDownUp(e);
                _context10.next = 20;
                break;

              case 12:
                if (record.isSelected) {
                  _context10.next = 16;
                  break;
                }

                dataSet.select(record);
                _context10.next = 20;
                break;

              case 16:
                _context10.next = 18;
                return this.handleKeyDownUp(e);

              case 18:
                currentRecord = _context10.sent;

                if (currentRecord) {
                  dataSet.select(currentRecord);
                }

              case 20:
                _context10.next = 23;
                break;

              case 22:
                this.handleKeyDownUp(e);

              case 23:
              case "end":
                return _context10.stop();
            }
          }
        }, _callee10, this);
      }));

      function handleKeyDownUpShift(_x10) {
        return _handleKeyDownUpShift.apply(this, arguments);
      }

      return handleKeyDownUpShift;
    }()
  }, {
    key: "handleKeyDownRight",
    value: function handleKeyDownRight(e) {
      var tableStore = this.tableStore,
          _this$props = this.props,
          expandedRowRenderer = _this$props.expandedRowRenderer,
          dataSet = _this$props.dataSet;

      if (tableStore.isTree || expandedRowRenderer) {
        var current = dataSet.current;

        if (current) {
          e.preventDefault();
          tableStore.setRowExpanded(current, true);
        }
      }
    }
  }, {
    key: "handleKeyDownLeft",
    value: function handleKeyDownLeft(e) {
      var tableStore = this.tableStore,
          _this$props2 = this.props,
          expandedRowRenderer = _this$props2.expandedRowRenderer,
          dataSet = _this$props2.dataSet;

      if (tableStore.isTree || expandedRowRenderer) {
        var current = dataSet.current;

        if (current) {
          e.preventDefault();
          tableStore.setRowExpanded(current, false);
        }
      }
    }
  }, {
    key: "getOmitPropsKeys",
    value: function getOmitPropsKeys() {
      return (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "getOmitPropsKeys", this).call(this).concat(['columns', 'header', 'showHeader', 'footer', 'border', 'columnEditorBorder', 'selectionMode', 'rowBoxPlacement', 'alwaysShowRowBox', 'showSelectionTips', 'showSelectionCachedButton', 'showCachedSelection', 'onShowCachedSelectionChange', 'showAllPageSelectionButton', 'onRow', 'onColumnResize', 'rowRenderer', 'buttons', 'buttonsLimit', 'rowHeight', 'headerRowHeight', 'footerRowHeight', 'queryFields', 'queryFieldsLimit', 'summaryFieldsLimit', 'summaryBarFieldWidth', 'queryBar', 'queryBarProps', 'autoFocus', 'summaryBar', 'defaultRowExpanded', 'expandRowByClick', 'expandedRowRenderer', 'expandIconColumnIndex', 'indentSize', 'filter', 'treeFilter', 'mode', 'editMode', 'filterBarFieldName', 'filterBarPlaceholder', 'pagination', 'highLightRow', 'selectedHighLightRow', 'columnResizable', 'columnTitleEditable', 'pristine', 'expandIcon', 'spin', 'virtual', 'virtualCell', 'virtualSpin', 'columnBuffer', 'columnThreshold', 'autoWidth', 'autoHeight', 'autoFootHeight', 'useMouseBatchChoose', 'autoMaxWidth', 'dragColumnAlign', 'columnDraggable', 'rowDraggable', 'pageSizeChangeable', 'onCustomizedLoad', 'onDragEnd', 'rowDragRender', 'columnsDragRender', 'editorNextKeyEnterDown', 'onDragEndBefore', 'keyboard', 'dynamicFilterBar', 'parityRow', 'rowNumber', 'treeAsync', 'treeLoadData', 'customizable', 'customizedBtn', 'customizedCode', 'dragColumn', 'dragRow', 'clientExportQuantity', 'treeQueryExpanded', 'summary', 'aggregation', 'onAggregationChange', 'showRemovedRow', 'searchCode', 'groups', 'onScrollLeft', 'onScrollTop', 'bodyExpandable', 'defaultBodyExpanded', 'bodyExpanded', 'onBodyExpanded', 'selectionBoxRenderer', 'boxSizing', 'fullColumnWidth']);
    }
  }, {
    key: "getWrapperProps",
    value: function getWrapperProps() {
      var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var autoWidth = this.props.autoWidth;
      var wrapperProps = (0, _objectSpread2["default"])({}, props);

      if (autoWidth) {
        var _this$tableStore2 = this.tableStore,
            columnGroups = _this$tableStore2.columnGroups,
            overflowY = _this$tableStore2.overflowY,
            border = _this$tableStore2.border;
        wrapperProps.style = {
          width: columnGroups.width + (overflowY ? (0, _measureScrollbar["default"])() : 0) + (border ? 2 : 0)
        };
      }

      return (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "getWrapperProps", this).call(this, wrapperProps);
    }
  }, {
    key: "getOtherProps",
    value: function getOtherProps() {
      var otherProps = (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "getOtherProps", this).call(this);
      otherProps.onKeyDown = this.handleKeyDown;
      var rowHeight = this.tableStore.rowHeight;

      if (rowHeight === 'auto') {
        delete otherProps.style;
      } else {
        otherProps.style = {
          lineHeight: (0, _UnitConvertor.pxToRem)(rowHeight)
        };
      }

      return otherProps;
    }
  }, {
    key: "getClassName",
    value: function getClassName() {
      var _get$call;

      var _this$tableStore3 = this.tableStore,
          border = _this$tableStore3.border,
          parityRow = _this$tableStore3.parityRow,
          aggregation = _this$tableStore3.aggregation,
          size = _this$tableStore3.size,
          isCombinedColumn = _this$tableStore3.isCombinedColumn,
          prefixCls = this.prefixCls;
      return (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "getClassName", this).call(this, (_get$call = {}, (0, _defineProperty2["default"])(_get$call, "".concat(prefixCls, "-").concat(size), size !== _enum3.Size["default"]), (0, _defineProperty2["default"])(_get$call, "".concat(prefixCls, "-bordered"), border), (0, _defineProperty2["default"])(_get$call, "".concat(prefixCls, "-parity-row"), parityRow), (0, _defineProperty2["default"])(_get$call, "".concat(prefixCls, "-aggregation"), aggregation), (0, _defineProperty2["default"])(_get$call, "".concat(prefixCls, "-combined-column"), isCombinedColumn), _get$call));
    }
    /**
     * 获取传入的 Spin props
     */

  }, {
    key: "getSpinProps",
    value: function getSpinProps() {
      var _this$props3 = this.props,
          spin = _this$props3.spin,
          dataSet = _this$props3.dataSet;
      var spinProps = (0, _objectSpread2["default"])({}, spin);
      if (spinProps && !(0, _isUndefined["default"])(spinProps.spinning)) return (0, _objectSpread2["default"])({}, spinProps);
      var loading = this.tableStore.loading;

      if (loading) {
        return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, spinProps), {}, {
          spinning: true
        });
      }

      return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, spinProps), {}, {
        dataSet: dataSet
      });
    }
  }, {
    key: "componentWillMount",
    value: function componentWillMount() {
      this.initDefaultExpandedRows();
    }
  }, {
    key: "componentDidMount",
    value: function componentDidMount() {
      (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "componentDidMount", this).call(this);
      this.connect();
      this.syncSize();
      this.syncSizeInFrame();
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate() {
      var tableStore = this.tableStore;

      if (tableStore.currentEditorName) {
        var length = tableStore.columns.length;

        if (length !== this.columnsSize) {
          this.columnsSize = length;
          tableStore.alignEditor();
        }
      }
    }
  }, {
    key: "componentWillReceiveProps",
    value: function componentWillReceiveProps(nextProps, nextContext) {
      (0, _get2["default"])((0, _getPrototypeOf2["default"])(Table.prototype), "componentWillReceiveProps", this).call(this, nextProps, nextContext);
      this.disconnect();
      this.columnsSize = this.tableStore.columns.length;
      this.tableStore.updateProps(nextProps);
      this.connect();
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.disconnect();

      if (this.scrollId !== undefined) {
        _raf["default"].cancel(this.scrollId);
      }

      this.bubbleValidationReport(false);
      this.tableStore.dispose();
    }
  }, {
    key: "bubbleValidationReport",
    value: function bubbleValidationReport(showInvalid) {
      var pristine = this.props.pristine;

      if (!pristine) {
        var onComponentValidationReport = this.getContextConfig('onComponentValidationReport');

        if (onComponentValidationReport) {
          onComponentValidationReport({
            showInvalid: showInvalid,
            component: this
          });
        }
      }
    }
  }, {
    key: "syncParentSize",
    value: function syncParentSize(height, target) {
      var tableStore = this.tableStore,
          element = this.element,
          wrapper = this.wrapper;

      if (element) {
        var wrapperHeight = Math.round(wrapper.getBoundingClientRect().height);

        if (wrapperHeight !== height) {
          tableStore.parentHeight = height;
          tableStore.parentPaddingTop = Math.round(element.getBoundingClientRect().top) - Math.round(target.getBoundingClientRect().top);
        }
      }
    }
  }, {
    key: "handleParentResize",
    value: function handleParentResize(entries) {
      var _entries = (0, _slicedToArray2["default"])(entries, 1),
          entry = _entries[0];

      var height = Math.round(entry.contentRect.height);
      this.syncParentSize(height, entry.target);
    }
  }, {
    key: "connect",
    value: function connect() {
      this.processDataSetListener(true);
      var _this$tableStore4 = this.tableStore,
          styleMaxHeight = _this$tableStore4.styleMaxHeight,
          styleMinHeight = _this$tableStore4.styleMinHeight,
          styleHeight = _this$tableStore4.styleHeight,
          heightType = _this$tableStore4.heightType;

      if ((0, _isString["default"])(styleHeight) && (0, _UnitConvertor.isPercentSize)(styleHeight) || (0, _isString["default"])(styleMaxHeight) && (0, _UnitConvertor.isPercentSize)(styleMaxHeight) || (0, _isString["default"])(styleMinHeight) && (0, _UnitConvertor.isPercentSize)(styleMinHeight)) {
        var wrapper = this.wrapper;

        if (wrapper) {
          var parentNode = wrapper.parentNode;

          if (parentNode) {
            var resizeObserver = new _resizeObserverPolyfill["default"](this.handleParentResize);
            resizeObserver.observe(parentNode);
            this.resizeObserver = resizeObserver;
            this.syncParentSize(parentNode.offsetHeight, parentNode);
          }
        }
      }

      if (heightType === _enum.TableHeightType.flex || (0, _isString["default"])(styleMaxHeight) && (0, _UnitConvertor.isCalcSize)(styleMaxHeight) || (0, _isString["default"])(styleMinHeight) && (0, _UnitConvertor.isCalcSize)(styleMinHeight)) {
        window.addEventListener('resize', this.handleWindowResize, false);
      }
    }
  }, {
    key: "disconnect",
    value: function disconnect() {
      var resizeObserver = this.resizeObserver;

      if (resizeObserver) {
        resizeObserver.disconnect();
        delete this.resizeObserver;
      }

      this.processDataSetListener(false);
      window.removeEventListener('resize', this.handleWindowResize, false);
    }
  }, {
    key: "processDataSetListener",
    value: function processDataSetListener(flag) {
      var _this$tableStore5 = this.tableStore,
          dataSet = _this$tableStore5.dataSet,
          inlineEdit = _this$tableStore5.inlineEdit;

      if (dataSet) {
        var handler = flag ? dataSet.addEventListener : dataSet.removeEventListener;
        handler.call(dataSet, _enum2.DataSetEvents.load, this.handleDataSetLoad);

        if (inlineEdit) {
          handler.call(dataSet, _enum2.DataSetEvents.create, this.handleDataSetCreate);
        }

        handler.call(dataSet, _enum2.DataSetEvents.validate, this.handleDataSetValidate);
        handler.call(dataSet, _enum2.DataSetEvents.validateSelf, this.handleDataSetValidateSelf);
        handler.call(dataSet, _enum2.DataSetEvents.reset, this.handleDataSetReset);
        handler.call(dataSet, _enum2.DataSetEvents.remove, this.handleDataSetRemove);
      }
    }
  }, {
    key: "render",
    value: function render() {
      var _this$tableStore6 = this.tableStore,
          overflowX = _this$tableStore6.overflowX,
          isAnyColumnsLeftLock = _this$tableStore6.isAnyColumnsLeftLock,
          isAnyColumnsRightLock = _this$tableStore6.isAnyColumnsRightLock,
          _this$props4 = this.props,
          dataSet = _this$props4.dataSet,
          treeQueryExpanded = _this$props4.treeQueryExpanded,
          virtualSpin = _this$props4.virtualSpin,
          buttons = _this$props4.buttons,
          buttonsLimit = _this$props4.buttonsLimit,
          queryFields = _this$props4.queryFields,
          queryFieldsLimit = _this$props4.queryFieldsLimit,
          summaryFieldsLimit = _this$props4.summaryFieldsLimit,
          summaryBarFieldWidth = _this$props4.summaryBarFieldWidth,
          filterBarFieldName = _this$props4.filterBarFieldName,
          filterBarPlaceholder = _this$props4.filterBarPlaceholder,
          summaryBar = _this$props4.summaryBar,
          dynamicFilterBar = _this$props4.dynamicFilterBar,
          clientExportQuantity = _this$props4.clientExportQuantity,
          indentSize = _this$props4.indentSize,
          selectionMode = _this$props4.selectionMode,
          rowRenderer = _this$props4.rowRenderer,
          onRow = _this$props4.onRow,
          onColumnResize = _this$props4.onColumnResize,
          expandedRowRenderer = _this$props4.expandedRowRenderer,
          expandRowByClick = _this$props4.expandRowByClick,
          rowDragRender = _this$props4.rowDragRender,
          columnsDragRender = _this$props4.columnsDragRender,
          mode = _this$props4.mode,
          pristine = _this$props4.pristine,
          showSelectionCachedButton = _this$props4.showSelectionCachedButton,
          onShowCachedSelectionChange = _this$props4.onShowCachedSelectionChange,
          autoMaxWidth = _this$props4.autoMaxWidth,
          summary = _this$props4.summary,
          searchCode = _this$props4.searchCode,
          boxSizing = _this$props4.boxSizing,
          fullColumnWidth = _this$props4.fullColumnWidth,
          tableStore = this.tableStore,
          prefixCls = this.prefixCls;
      var content = this.getTable();
      var pagination = this.getPagination(_enum.TablePaginationPosition.top);
      var globalTableSpinProps = this.getContextConfig('tableSpinProps');
      var localTableSpinProps = this.getSpinProps();
      var tableSpinProps = globalTableSpinProps ? (0, _mergeProps["default"])((0, _mergeProps["default"])({}, globalTableSpinProps), localTableSpinProps) : localTableSpinProps;
      var tableButtonsLimit = (0, _isNil["default"])(buttonsLimit) ? this.getContextConfig('tableButtonsLimit') : buttonsLimit;
      return /*#__PURE__*/_react["default"].createElement(_resizeObserver["default"], {
        resizeProp: "width",
        onResize: this.handleResize
      }, /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, this.getWrapperProps()), /*#__PURE__*/_react["default"].createElement(_TableContext.TableContextProvider, {
        code: this.code,
        prefixCls: prefixCls,
        dataSet: dataSet,
        tableStore: tableStore,
        indentSize: indentSize,
        selectionMode: selectionMode,
        onRow: onRow,
        onColumnResize: onColumnResize,
        rowRenderer: rowRenderer,
        expandedRowRenderer: expandedRowRenderer,
        expandRowByClick: expandRowByClick,
        rowDragRender: rowDragRender,
        columnsDragRender: columnsDragRender,
        showSelectionCachedButton: showSelectionCachedButton,
        onShowCachedSelectionChange: onShowCachedSelectionChange,
        autoMaxWidth: autoMaxWidth,
        pristine: pristine,
        summary: summary,
        virtualSpin: virtualSpin,
        spinProps: tableSpinProps,
        fullColumnWidth: fullColumnWidth,
        isTree: mode === _enum.TableMode.tree
      }, /*#__PURE__*/_react["default"].createElement(_TableSibling["default"], {
        position: "before",
        boxSizing: boxSizing
      }, this.getHeader(), /*#__PURE__*/_react["default"].createElement(_queryBar["default"], {
        buttons: buttons,
        buttonsLimit: tableButtonsLimit,
        pagination: pagination,
        queryFields: queryFields,
        clientExportQuantity: clientExportQuantity,
        summaryBar: summaryBar,
        dynamicFilterBar: dynamicFilterBar,
        queryFieldsLimit: queryFieldsLimit,
        summaryBarFieldWidth: summaryBarFieldWidth,
        summaryFieldsLimit: summaryFieldsLimit,
        filterBarFieldName: filterBarFieldName,
        filterBarPlaceholder: filterBarPlaceholder,
        treeQueryExpanded: treeQueryExpanded,
        searchCode: searchCode
      }), /*#__PURE__*/_react["default"].createElement(_ErrorBar["default"], {
        dataSet: dataSet,
        prefixCls: prefixCls
      })), /*#__PURE__*/_react["default"].createElement(_spin["default"], (0, _extends2["default"])({}, tableSpinProps, {
        key: "content"
      }), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, this.getOtherProps()), /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _classnames["default"])("".concat(prefixCls, "-content"), (0, _defineProperty2["default"])({}, "".concat(prefixCls, "-content-overflow"), (0, _utils.isStickySupport)() && overflowX && tableStore.height === undefined)),
        ref: this.saveContentRef,
        onScroll: this.handleBodyScroll
      }, !(0, _utils.isStickySupport)() && isAnyColumnsLeftLock && overflowX && this.getLeftFixedTable(), content, !(0, _utils.isStickySupport)() && isAnyColumnsRightLock && overflowX && this.getRightFixedTable()), (0, _utils.isStickySupport)() && overflowX && /*#__PURE__*/_react["default"].createElement(_StickyShadow["default"], {
        position: "left"
      }), (0, _utils.isStickySupport)() && overflowX && /*#__PURE__*/_react["default"].createElement(_StickyShadow["default"], {
        position: "right"
      }), /*#__PURE__*/_react["default"].createElement("div", {
        ref: this.saveResizeRef,
        className: "".concat(prefixCls, "-split-line")
      }))), /*#__PURE__*/_react["default"].createElement(_TableSibling["default"], {
        position: "after",
        boxSizing: boxSizing
      }, this.getFooter(), this.getPagination(_enum.TablePaginationPosition.bottom)))));
    }
  }, {
    key: "reorderDataSet",
    value: function reorderDataSet(startIndex, endIndex) {
      var dataSet = this.tableStore.dataSet;
      dataSet.move(startIndex, endIndex);
    }
    /**
     * 触发组合或拖拽排序, 移除原纪录
     * @param currentRecord
     */

  }, {
    key: "removeSourceRecord",
    value: function removeSourceRecord(currentRecord) {
      var parent = currentRecord.parent;

      if (parent) {
        var children = parent.children;

        if (children) {
          var index = children.indexOf(currentRecord);

          if (index !== -1) {
            children.splice(index, 1);
          }

          if (!children.length) {
            parent.children = undefined;
          }
        }
      }
    }
  }, {
    key: "handleDragStart",
    value: function handleDragStart(initial, provided) {
      var dragDropContextProps = this.props.dragDropContextProps;
      var _this$tableStore7 = this.tableStore,
          rowMetaData = _this$tableStore7.rowMetaData,
          isTree = _this$tableStore7.isTree,
          currentEditorName = _this$tableStore7.currentEditorName;

      if (isTree && rowMetaData) {
        var source = initial.source;
        var currentRecord = rowMetaData[source.index].record;

        if (currentRecord && currentRecord.children && currentRecord.children.length) {
          currentRecord.isExpanded = false;
        }
      }

      if (dragDropContextProps && dragDropContextProps.onDragStart) {
        dragDropContextProps.onDragStart(initial, provided);
      }

      if (currentEditorName) {
        this.tableStore.blurEditor();
      }
    }
  }, {
    key: "handleDragEnd",
    value: function handleDragEnd(resultDrag, provided) {
      var _rowMetaData$resultBe, _rowMetaData$resultBe2;

      var _this$tableStore8 = this.tableStore,
          dataSet = _this$tableStore8.dataSet,
          rowMetaData = _this$tableStore8.rowMetaData,
          isTree = _this$tableStore8.isTree,
          showRemovedRow = _this$tableStore8.showRemovedRow;
      var _dataSet$props = dataSet.props,
          parentField = _dataSet$props.parentField,
          idField = _dataSet$props.idField,
          childrenField = _dataSet$props.childrenField;
      var _this$props5 = this.props,
          onDragEnd = _this$props5.onDragEnd,
          onDragEndBefore = _this$props5.onDragEndBefore,
          dragDropContextProps = _this$props5.dragDropContextProps;
      var resultBefore = resultDrag;
      var recordFromIndex = rowMetaData ? (_rowMetaData$resultBe = rowMetaData[resultBefore.source.index].record) === null || _rowMetaData$resultBe === void 0 ? void 0 : _rowMetaData$resultBe.index : undefined;
      var recordToIndex = rowMetaData && resultBefore.destination ? (_rowMetaData$resultBe2 = rowMetaData[resultBefore.destination.index].record) === null || _rowMetaData$resultBe2 === void 0 ? void 0 : _rowMetaData$resultBe2.index : undefined;

      if (onDragEndBefore) {
        var result = onDragEndBefore(this.tableStore.dataSet, (0, _mobx.toJS)(this.tableStore.columns), resultDrag, provided, [recordFromIndex, recordToIndex]);

        if (result === false) {
          return;
        }

        if ((0, _utils.isDropresult)(result)) {
          resultBefore = result;
        }
      }

      if (resultBefore && isTree && rowMetaData) {
        var _resultBefore = resultBefore,
            destination = _resultBefore.destination,
            source = _resultBefore.source,
            combine = _resultBefore.combine;
        var currentRecord = rowMetaData[source.index].record;

        if (currentRecord) {
          // 平铺数据
          if (!childrenField && parentField && idField) {
            // 拖拽组合关联
            if (combine) {
              var parentRecord = dataSet.find(function (record) {
                return String(record.key) === combine.draggableId;
              });
              currentRecord.set(parentField, parentRecord.get(idField));
              parentRecord.isExpanded = true;
            } // 拖拽排序更新


            if (destination && destination.index !== source.index && rowMetaData) {
              var destinationRecord = rowMetaData[destination.index].record;

              if (destinationRecord) {
                var parent = destinationRecord.parent;

                if (parent) {
                  if (currentRecord.parent !== parent && parent !== currentRecord && parent.children) {
                    currentRecord.set(parentField, parent.get(idField));
                  } else if (parent.children) {
                    var childIndex = parent.children.indexOf(destinationRecord);
                    this.removeSourceRecord(currentRecord);
                    parent.children.splice(childIndex, 0, currentRecord);
                  }
                } else {
                  currentRecord.set(parentField, undefined);
                  dataSet.move(currentRecord.index, destinationRecord.index);
                }
              }
            }
          } // 树形数据


          if (childrenField) {
            // 拖拽组合关联
            if (combine) {
              var _parentRecord = dataSet.find(function (record) {
                return String(record.key) === combine.draggableId;
              });

              this.removeSourceRecord(currentRecord);
              currentRecord.parent = _parentRecord;

              if (_parentRecord.children && _parentRecord.children.length) {
                _parentRecord.children.unshift(currentRecord);
              } else {
                _parentRecord.children = [currentRecord];
              }

              _parentRecord.isExpanded = true;
            } // 拖拽排序更新


            if (destination && destination.index !== source.index && rowMetaData) {
              var _destinationRecord = rowMetaData[destination.index].record;

              if (_destinationRecord) {
                var _parent = _destinationRecord.parent;

                if (_parent) {
                  if (currentRecord.parent !== _parent && _parent !== currentRecord && _parent.children) {
                    var _childIndex = _parent.children.indexOf(_destinationRecord);

                    this.removeSourceRecord(currentRecord);
                    currentRecord.parent = _parent;

                    _parent.children.splice(_childIndex, 0, currentRecord);
                  } else if (_parent.children) {
                    var _childIndex2 = _parent.children.indexOf(_destinationRecord);

                    this.removeSourceRecord(currentRecord);

                    _parent.children.splice(_childIndex2, 0, currentRecord);
                  }
                } else {
                  if (currentRecord.parent) {
                    this.removeSourceRecord(currentRecord);
                    currentRecord.parent = undefined;
                  }

                  dataSet.move(currentRecord.index, _destinationRecord.index);
                }
              }
            }
          }
        }
      } else if (resultBefore && resultBefore.destination) {
        if (resultBefore.source.index !== resultBefore.destination.index) {
          // 非树形拖拽排序
          var records = dataSet.records,
              data = dataSet.data; // 若存在没有展示的 delete 数据，则需要对数据的起点落点做校正

          if (!showRemovedRow && records.length !== data.length) {
            var destinationIndex = resultBefore.destination.index; // 操作的数据在 records 中的真实起落点索引

            var recordsSourceIndex;
            var recordsToIndex;
            var findSourceFlag = false;
            var findDestinationFlag = false;
            var showedRecordsCount = 0;

            for (var i = 0; i < records.length; i++) {
              if (!findSourceFlag && records[i].key === resultBefore.draggableId) {
                recordsSourceIndex = i;
                findSourceFlag = true;
              }

              if (!findDestinationFlag) {
                if (records[i].status !== _enum2.RecordStatus["delete"]) {
                  if (showedRecordsCount === destinationIndex) {
                    recordsToIndex = destinationIndex + (i - showedRecordsCount);
                    findDestinationFlag = true;
                  }

                  showedRecordsCount++;
                }
              }

              if (findSourceFlag && findDestinationFlag) {
                break;
              }
            }

            this.reorderDataSet(recordsSourceIndex, recordsToIndex);
          } else {
            this.reorderDataSet(resultBefore.source.index, resultBefore.destination.index);
          }
        }
      }
      /**
       * 相应变化后的数据
       */


      var onDragEndFun = onDragEnd || (dragDropContextProps ? dragDropContextProps.onDragEnd : undefined);

      if (onDragEndFun) {
        onDragEndFun(this.tableStore.dataSet, (0, _mobx.toJS)(this.tableStore.columns), resultBefore, provided);
      }
    }
  }, {
    key: "handleBodyScroll",
    value: function handleBodyScroll(e) {
      var _this2 = this;

      var currentTarget = e.currentTarget;

      var handle = function handle() {
        _this2.handleBodyScrollTop(e, currentTarget);

        _this2.handleBodyScrollLeft(e, currentTarget);
      };

      if ((0, _utils.isStickySupport)()) {
        handle();
      } else {
        e.persist();
        this.scrollId = (0, _raf["default"])(handle);
      }
    }
  }, {
    key: "handleBodyScrollTop",
    value: function handleBodyScrollTop(e, currentTarget) {
      var target = e.target;
      var tableStore = this.tableStore;

      if ( // (isStickySupport() && !tableStore.virtual) ||
      // (![TableHeightType.fixed, TableHeightType.flex].includes(tableStore.heightType)) ||
      !tableStore.overflowY || currentTarget !== target || target === this.tableFootWrap) {
        return;
      }

      var scrollTop = target.scrollTop;
      this.setScrollTop(scrollTop, target);
    }
  }, {
    key: "handleBodyScrollLeft",
    value: function handleBodyScrollLeft(e, currentTarget) {
      var target = e.target;
      var tableStore = this.tableStore;

      if (!tableStore.overflowX || currentTarget !== target || target === this.fixedColumnsBodyRight || target === this.fixedColumnsBodyLeft) {
        return;
      }

      var scrollLeft = target.scrollLeft;
      this.setScrollLeft(scrollLeft, target);
    }
  }, {
    key: "setScrollPositionClassName",
    value: function setScrollPositionClassName(target) {
      var tableStore = this.tableStore;

      if (tableStore.isAnyColumnsLock && tableStore.overflowX) {
        var node = target || this.tableBodyWrap || this.tableContentWrap;

        if (node) {
          var scrollToLeft = node.scrollLeft === 0;
          var table = node.querySelector('table');
          var scrollToRight = table && node.scrollLeft >= table.offsetWidth - node.offsetWidth;

          if (scrollToLeft && scrollToRight) {
            this.setScrollPosition(_enum.ScrollPosition.both);
          } else if (scrollToLeft) {
            this.setScrollPosition(_enum.ScrollPosition.left);
          } else if (scrollToRight) {
            this.setScrollPosition(_enum.ScrollPosition.right);
          } else {
            this.setScrollPosition(_enum.ScrollPosition.middle);
          }
        }
      }
    }
  }, {
    key: "setScrollPosition",
    value: function setScrollPosition(position) {
      var tableStore = this.tableStore;

      if (tableStore.scrollPosition !== position) {
        tableStore.scrollPosition = position;
      }
    }
  }, {
    key: "renderTable",
    value: function renderTable(hasHeader, hasBody, hasFooter, lock, virtual) {
      var _this3 = this;

      var tableStore = this.tableStore;

      var columnGroups = function () {
        if (lock === _enum.ColumnLock.right) {
          return tableStore.rightColumnGroups;
        }

        if (lock) {
          return tableStore.leftColumnGroups;
        }

        return tableStore.columnGroups;
      }();
      /* eslint-disable react/no-this-in-sfc */


      var wrapper = function wrapper(snapshot, dragRowHeight) {
        return /*#__PURE__*/_react["default"].createElement(_TableWrapper["default"], {
          key: "tableWrapper",
          lock: lock,
          hasBody: hasBody,
          hasHeader: hasHeader,
          hasFooter: hasFooter,
          columnGroups: columnGroups
        }, hasHeader && _this3.getTableHeader(lock), hasBody && _this3.getTableBody(columnGroups, lock, snapshot, dragRowHeight), hasFooter && _this3.getTableFooter(columnGroups, lock));
      };
      /* eslint-enable react/no-this-in-sfc */


      var virtualWrapper = virtual ? /*#__PURE__*/_react["default"].createElement(_VirtualWrapper["default"], null, wrapper) : wrapper();

      if (hasBody && tableStore.rowDraggable) {
        var dragDropContextProps = this.props.dragDropContextProps;
        return /*#__PURE__*/_react["default"].createElement(_reactBeautifulDnd.DragDropContext, (0, _extends2["default"])({}, dragDropContextProps, {
          onDragStart: this.handleDragStart,
          onDragEnd: this.handleDragEnd,
          key: 'drag-drop-context'
        }), virtualWrapper);
      }

      return virtualWrapper;
    }
  }, {
    key: "getHeader",
    value: function getHeader() {
      var _this$props6 = this.props,
          header = _this$props6.header,
          dataSet = _this$props6.dataSet;

      if (header) {
        var prefixCls = this.prefixCls;
        var data = dataSet ? dataSet.records : [];
        return /*#__PURE__*/_react["default"].createElement("div", {
          key: "header",
          className: "".concat(prefixCls, "-header")
        }, typeof header === 'function' ? header(data) : header);
      }
    }
  }, {
    key: "getFooter",
    value: function getFooter() {
      var _this$props7 = this.props,
          footer = _this$props7.footer,
          dataSet = _this$props7.dataSet;

      if (footer) {
        var prefixCls = this.prefixCls;
        var data = dataSet ? dataSet.records : [];
        return /*#__PURE__*/_react["default"].createElement("div", {
          key: "footer",
          className: "".concat(prefixCls, "-footer")
        }, typeof footer === 'function' ? footer(data) : footer);
      }
    }
  }, {
    key: "getPagination",
    value: function getPagination(position) {
      var _this$props8 = this.props,
          dataSet = _this$props8.dataSet,
          selectionMode = _this$props8.selectionMode,
          prefixCls = this.prefixCls,
          _this$tableStore9 = this.tableStore,
          pagination = _this$tableStore9.pagination,
          showSelectionTips = _this$tableStore9.showSelectionTips,
          showCachedTips = _this$tableStore9.showCachedTips;

      if (pagination !== false && dataSet && dataSet.paging) {
        var paginationPosition = (0, _utils.getPaginationPosition)(pagination);

        if (paginationPosition === _enum.TablePaginationPosition.both || paginationPosition === position) {
          var paginationProps = (0, _omit["default"])(pagination, 'position');
          return /*#__PURE__*/_react["default"].createElement(_Pagination["default"], (0, _extends2["default"])({
            key: "pagination-".concat(position)
          }, paginationProps, {
            className: (0, _classnames["default"])("".concat(prefixCls, "-pagination"), paginationProps.className, (0, _defineProperty2["default"])({}, "".concat(prefixCls, "-pagination-with-selection-tips"), showSelectionTips || showCachedTips)),
            dataSet: dataSet
          }), selectionMode !== _enum.SelectionMode.none && dataSet.selection === _enum2.DataSetSelection.multiple && /*#__PURE__*/_react["default"].createElement(_SelectionTips["default"], null));
        }
      }
    }
  }, {
    key: "getTable",
    value: function getTable(lock) {
      var _this4 = this;

      var props = this.props,
          tableStore = this.tableStore;
      var overflowX = tableStore.overflowX,
          heightType = tableStore.heightType,
          footer = tableStore.hasFooter,
          virtual = tableStore.virtual;
      var tableHead;
      var tableBody;
      var tableFooter;

      if (virtual || !(0, _utils.isStickySupport)() && overflowX || [_enum.TableHeightType.flex, _enum.TableHeightType.fixed].includes(heightType) || tableStore.height !== undefined) {
        var prefixCls = this.prefixCls;
        var tableHeadRef;
        var tableBodyRef;
        var tableFootRef;

        if (!lock) {
          tableHeadRef = function tableHeadRef(node) {
            return _this4.tableHeadWrap = node;
          };

          tableFootRef = function tableFootRef(node) {
            return _this4.tableFootWrap = node;
          };

          tableBodyRef = function tableBodyRef(node) {
            return _this4.tableBodyWrap = node;
          };
        } else if (lock === _enum.ColumnLock.right) {
          tableBodyRef = function tableBodyRef(node) {
            _this4.fixedColumnsBodyRight = node;

            if (node) {
              _this4.syncSize();
            }
          };
        } else {
          tableBodyRef = function tableBodyRef(node) {
            _this4.fixedColumnsBodyLeft = node;

            if (node) {
              _this4.syncSize();
            }
          };
        }

        var style = lock ? {
          width: (0, _UnitConvertor.pxToRem)(lock === _enum.ColumnLock.right ? tableStore.rightColumnGroups.width - 1 + (tableStore.overflowY ? (0, _measureScrollbar["default"])() : 0) : tableStore.leftColumnGroups.width, true),
          marginLeft: lock === _enum.ColumnLock.right ? (0, _UnitConvertor.pxToRem)(1) : undefined
        } : undefined;
        tableHead = /*#__PURE__*/_react["default"].createElement("div", {
          key: "tableHead",
          ref: tableHeadRef,
          className: "".concat(prefixCls, "-head"),
          style: style
        }, this.renderTable(true, false, false, lock));

        if (lock !== _enum.ColumnLock.right || !(0, _utils.onlyCustomizedColumn)(tableStore)) {
          var body = this.renderTable(false, true, false, lock, virtual);
          tableBody = /*#__PURE__*/_react["default"].createElement(_TableBody["default"], {
            key: "tableBody",
            getRef: tableBodyRef,
            lock: lock,
            onScroll: this.handleBodyScroll,
            style: (0, _pick["default"])(props.style, ['maxHeight', 'minHeight'])
          }, body);
        }

        if (footer) {
          tableFooter = /*#__PURE__*/_react["default"].createElement("div", {
            key: "tableFooter",
            ref: tableFootRef,
            className: "".concat(prefixCls, "-foot"),
            style: style,
            onScroll: this.handleBodyScroll
          }, this.renderTable(false, false, true, lock));
        }
      } else {
        tableBody = this.renderTable(true, true, footer, lock);
      }

      return [tableHead, tableBody, tableFooter];
    }
  }, {
    key: "getLeftFixedTable",
    value: function getLeftFixedTable() {
      return /*#__PURE__*/_react["default"].createElement(_StickyShadow["default"], {
        position: "left"
      }, this.getTable(_enum.ColumnLock.left));
    }
  }, {
    key: "getRightFixedTable",
    value: function getRightFixedTable() {
      return /*#__PURE__*/_react["default"].createElement(_StickyShadow["default"], {
        position: "right"
      }, this.getTable(_enum.ColumnLock.right));
    }
  }, {
    key: "getTableBody",
    value: function getTableBody(columnGroups, lock, snapshot, dragRowHeight) {
      var performanceEnabled = this.tableStore.performanceEnabled,
          bodyExpandable = this.props.bodyExpandable;
      var tBodyProps = {
        key: 'tbody',
        lock: lock,
        columnGroups: columnGroups,
        snapshot: snapshot,
        dragRowHeight: dragRowHeight
      };
      var body = bodyExpandable ? /*#__PURE__*/_react["default"].createElement(_ExpandableTableTBody["default"], (0, _extends2["default"])({}, tBodyProps)) : /*#__PURE__*/_react["default"].createElement(_TableTBody["default"], (0, _extends2["default"])({}, tBodyProps));
      return performanceEnabled ? /*#__PURE__*/_react["default"].createElement(_Profiler["default"], null, body) : body;
    }
  }, {
    key: "getTableHeader",
    value: function getTableHeader(lock) {
      var _this$props9 = this.props,
          showHeader = _this$props9.showHeader,
          queryFields = _this$props9.queryFields;
      return showHeader || this.tableStore.customizable ? /*#__PURE__*/_react["default"].createElement(_TableHeader["default"], {
        key: "thead",
        lock: lock,
        queryFields: queryFields
      }) : undefined;
    }
  }, {
    key: "getTableFooter",
    value: function getTableFooter(columnGroups, lock) {
      return /*#__PURE__*/_react["default"].createElement(_TableFooter["default"], {
        key: "tfoot",
        lock: lock,
        columnGroups: columnGroups
      });
    }
  }, {
    key: "getStyleHeight",
    value: function getStyleHeight() {
      var style = this.props.style;

      if (style) {
        return (0, _UnitConvertor.toPx)(style.height);
      }
    }
  }, {
    key: "syncSizeInFrame",
    value: function syncSizeInFrame() {
      var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getWidth();

      if (this.nextFrameActionId !== undefined) {
        _raf["default"].cancel(this.nextFrameActionId);
      }

      this.nextFrameActionId = (0, _raf["default"])(this.syncSize.bind(this, width));
    }
  }, {
    key: "syncSize",
    value: function syncSize() {
      var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getWidth();
      var element = this.element,
          tableStore = this.tableStore;

      if (tableStore.hidden || !element || !element.offsetParent) {
        return;
      }

      tableStore.width = Math.floor(width);
      var prefixCls = this.prefixCls;
      var tableHeader = tableStore.props.showHeader ? element.querySelector(".".concat(prefixCls, "-thead")) : null;
      var tableFooter = tableStore.hasFooter ? element.querySelector(".".concat(prefixCls, "-tfoot")) : null;

      if (tableStore.cellVerticalSize === undefined) {
        tableStore.cellVerticalSize = (0, _utils.getCellVerticalSize)(element, prefixCls);
      }

      tableStore.screenHeight = document.documentElement.clientHeight;
      tableStore.headerHeight = tableHeader ? (0, _utils.getHeight)(tableHeader) : 0;
      tableStore.footerHeight = tableFooter ? (0, _utils.getHeight)(tableFooter) : 0;
      this.setScrollPositionClassName();
    }
  }, {
    key: "initDefaultExpandedRows",
    value: function initDefaultExpandedRows() {
      var tableStore = this.tableStore,
          _this$props10 = this.props,
          dataSet = _this$props10.dataSet,
          defaultRowExpanded = _this$props10.defaultRowExpanded;

      if (tableStore.isTree && defaultRowExpanded) {
        dataSet.forEach(function (record) {
          if (record.children) {
            record.isExpanded = true;
          }
        });
      }
    }
  }, {
    key: "handleHeightTypeChange",
    value: function handleHeightTypeChange(immediate) {
      this.disconnect();

      if (immediate) {
        this.syncSize();
      } else {
        this.syncSizeInFrame();
      }

      this.connect();
    }
  }, {
    key: "getWidth",
    value: function getWidth() {
      var wrapper = this.wrapper;

      if (wrapper) {
        return wrapper.offsetWidth;
      }

      return 0;
    }
  }, {
    key: "getHeaderGroups",
    value: function getHeaderGroups() {
      return this.tableStore.groupedDataWithHeader;
    }
  }, {
    key: "getGroups",
    value: function getGroups() {
      return this.tableStore.groupedData;
    }
  }, {
    key: "setColumnWidth",
    value: function setColumnWidth(width, indexOrKeyOrName) {
      var saveToCustomization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
      var tableStore = this.tableStore;
      var target = tableStore.findColumnGroup(indexOrKeyOrName);

      if (target) {
        tableStore.setColumnWidth(target, width, saveToCustomization);
      }
    }
  }, {
    key: "setScrollTop",
    value: function setScrollTop(scrollTop, target) {
      if (scrollTop !== this.lastScrollTop) {
        var tableStore = this.tableStore,
            fixedColumnsBodyLeft = this.fixedColumnsBodyLeft,
            tableBodyWrap = this.tableBodyWrap,
            fixedColumnsBodyRight = this.fixedColumnsBodyRight,
            tableContentWrap = this.tableContentWrap;

        if (fixedColumnsBodyLeft && target !== fixedColumnsBodyLeft) {
          fixedColumnsBodyLeft.scrollTop = scrollTop;
        }

        if (tableBodyWrap && target !== tableBodyWrap) {
          tableBodyWrap.scrollTop = scrollTop;
        }

        if (fixedColumnsBodyRight && target !== fixedColumnsBodyRight) {
          fixedColumnsBodyRight.scrollTop = scrollTop;
        }

        if (tableContentWrap && target !== tableContentWrap) {
          tableContentWrap.scrollTop = scrollTop;
        } // 修复行内编辑开启虚拟滚动，编辑框会跟着滚动条移动的问题。


        if ((0, _utils.isStickySupport)() && tableStore.virtual && tableStore.inlineEdit) {
          tableStore.editors.forEach(function (editor) {
            if (editor.cellNode) {
              (0, _defer["default"])(function () {
                return editor.alignEditor(editor.cellNode);
              });
            }
          });
        }

        this.lastScrollTop = scrollTop;
        tableStore.setLastScrollTop(scrollTop);

        if (target) {
          var onScrollTop = this.props.onScrollTop;

          if (onScrollTop) {
            onScrollTop(scrollTop, function () {
              var groupedData = tableStore.groupedData,
                  rowMetaData = tableStore.rowMetaData;
              var start = -1;
              var end = -1;
              var index = 0;

              if (rowMetaData) {
                rowMetaData.some(function (meta) {
                  var offset = meta.offset,
                      height = meta.height;

                  if (start === -1 && offset + height >= scrollTop) {
                    start = index;
                  }

                  if (end === -1 && offset >= target.clientHeight + scrollTop) {
                    end = index;
                    return true;
                  }

                  index += 1;
                  return false;
                });
              } else {
                var trs = Array.from(target.querySelectorAll('tr'));
                trs.some(function (tr) {
                  var offsetTop = tr.offsetTop,
                      offsetHeight = tr.offsetHeight;

                  if (start === -1 && offsetTop + offsetHeight >= scrollTop) {
                    start = index;
                  }

                  if (end === -1 && offsetTop >= target.clientHeight + scrollTop) {
                    end = index;
                    return true;
                  }

                  index += 1;
                  return false;
                });
              }

              if (end === -1) {
                end = index;
              }

              return {
                groups: groupedData,
                start: start,
                end: end
              };
            });
          }
        }
      }
    }
  }, {
    key: "setScrollLeft",
    value: function setScrollLeft(scrollLeft, target) {
      if (scrollLeft !== this.lastScrollLeft) {
        var tableStore = this.tableStore;
        var tableHeadWrap = this.tableHeadWrap,
            tableBodyWrap = this.tableBodyWrap,
            tableFootWrap = this.tableFootWrap,
            tableContentWrap = this.tableContentWrap;

        if ((0, _utils.isStickySupport)()) {
          tableStore.editors.forEach(function (editor) {
            if (editor.lock && editor.cellNode) {
              if (tableStore.inlineEdit) {
                editor.alignEditor(editor.cellNode);
              } else {
                editor.hideEditor();
              }
            }
          });
        }

        if (tableHeadWrap && target !== tableHeadWrap) {
          tableHeadWrap.scrollLeft = scrollLeft;
        }

        if (tableBodyWrap && target !== tableBodyWrap) {
          tableBodyWrap.scrollLeft = scrollLeft;
        }

        if (tableFootWrap && target !== tableFootWrap) {
          tableFootWrap.scrollLeft = scrollLeft;
        }

        if (tableContentWrap && target !== tableContentWrap) {
          tableContentWrap.scrollLeft = scrollLeft;
        }

        this.setScrollPositionClassName(target);
        this.lastScrollLeft = scrollLeft;
        tableStore.setLastScrollLeft(scrollLeft);

        if (target) {
          var onScrollLeft = this.props.onScrollLeft;

          if (onScrollLeft) {
            onScrollLeft(scrollLeft, function () {
              var groupedDataWithHeader = tableStore.groupedDataWithHeader,
                  columnGroups = tableStore.columnGroups;
              var start = -1;
              var end = -1;
              var leftLocks = 0;
              var leftWidth = 0;
              var index = 0;
              var rightWidth = tableStore.rightColumnGroups.columns.reduce(function (width, column) {
                return column.key === _TableStore.CUSTOMIZED_KEY ? width : width + column.width;
              }, 0);
              columnGroups.columns.some(function (colGroup) {
                if (colGroup.lock !== _enum.ColumnLock.right) {
                  if (colGroup.lock === _enum.ColumnLock.left) {
                    leftLocks += 1;
                    leftWidth += colGroup.width;
                  } else {
                    if (start === -1 && colGroup.left + colGroup.width - leftWidth >= scrollLeft) {
                      start = index;
                    }

                    if (end === -1 && colGroup.left >= target.clientWidth - rightWidth + scrollLeft) {
                      end = index;
                      return true;
                    }
                  }

                  index += 1;
                }

                return false;
              });

              if (end === -1) {
                end = index;
              }

              return {
                groups: groupedDataWithHeader,
                start: start - leftLocks,
                end: end - leftLocks
              };
            });
          }
        }
      }
    }
  }]);
  return Table;
}(_DataSetComponent2["default"]);

Table.displayName = 'Table';
Table.Column = _Column["default"];
Table.FilterBar = _TableFilterBar["default"];
Table.AdvancedQueryBar = _TableAdvancedQueryBar["default"];
Table.ProfessionalBar = _TableProfessionalBar["default"];
Table.ComboBar = _TableComboBar["default"];
Table.DynamicFilterBar = _TableDynamicFilterBar["default"];
Table.FilterSelect = _FilterSelect["default"];
Table.ToolBar = _TableToolBar["default"];
Table.TableRow = _TableRow["default"];
Table.TableHeaderCell = _TableHeaderCell["default"];
Table.defaultProps = {
  suffixCls: 'table',
  tabIndex: 0,
  selectionMode: _enum.SelectionMode.rowbox,
  rowBoxPlacement: _enum.RowBoxPlacement.start,
  queryFields: {},
  defaultRowExpanded: false,
  expandRowByClick: false,
  indentSize: 15,
  summaryFieldsLimit: 3,
  summaryBarFieldWidth: 170,
  filterBarFieldName: 'params',
  virtualSpin: false,
  autoHeight: false,
  autoMaxWidth: true,
  autoFootHeight: false,
  clientExportQuantity: 100,
  showSelectionCachedButton: true,
  showHeader: true,
  fullColumnWidth: true
};
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "saveResizeRef", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "saveContentRef", null);
(0, _tslib.__decorate)([_autobind["default"], _mobx.action], Table.prototype, "handleResize", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleWindowResize", null);
(0, _tslib.__decorate)([_autobind["default"], _mobx.action], Table.prototype, "handleDataSetLoad", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleDataSetCreate", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleDataSetReset", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleDataSetRemove", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleDataSetValidateSelf", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleDataSetValidate", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleKeyDown", null);
(0, _tslib.__decorate)([_mobx.action], Table.prototype, "syncParentSize", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleParentResize", null);
(0, _tslib.__decorate)([_mobx.action], Table.prototype, "reorderDataSet", null);
(0, _tslib.__decorate)([_mobx.action], Table.prototype, "removeSourceRecord", null);
(0, _tslib.__decorate)([_autobind["default"], _mobx.action], Table.prototype, "handleDragStart", null);
(0, _tslib.__decorate)([_autobind["default"], _mobx.action], Table.prototype, "handleDragEnd", null);
(0, _tslib.__decorate)([_autobind["default"]], Table.prototype, "handleBodyScroll", null);
(0, _tslib.__decorate)([_mobx.action], Table.prototype, "setScrollPosition", null);
(0, _tslib.__decorate)([_autobind["default"], _mobx.action], Table.prototype, "syncSize", null);
(0, _tslib.__decorate)([_mobx.action], Table.prototype, "initDefaultExpandedRows", null);
Table = (0, _tslib.__decorate)([_mobxReact.observer], Table);
var _default = Table;
exports["default"] = _default;
//# sourceMappingURL=Table.js.map
