"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.NextTable = void 0;
var _loading = _interopRequireDefault(require("@alifd/next/lib/loading"));
var _configProvider = _interopRequireDefault(require("@alifd/next/lib/config-provider"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _table = _interopRequireDefault(require("@alifd/next/lib/table"));
var _classnames = _interopRequireDefault(require("classnames"));
var _react = _interopRequireDefault(require("react"));
var _webTable = _interopRequireDefault(require("./table/webTable"));
var _tableProps = require("./utils/tableProps");
var _buildNextTableMethod = _interopRequireDefault(require("./utils/buildNextTableMethod"));
var _delegateFunctions = _interopRequireDefault(require("./utils/delegateFunctions"));
var _getColumnsFromChildern = _interopRequireDefault(require("./utils/getColumnsFromChildern"));
var _zhCn = _interopRequireDefault(require("./locale/zh-cn"));
require("./index.scss");
var GroupHeader = _table["default"].GroupHeader,
  GroupFooter = _table["default"].GroupFooter,
  Column = _table["default"].Column,
  ColumnGroup = _table["default"].ColumnGroup;
var NextTable = /*#__PURE__*/function (_React$Component) {
  (0, _inheritsLoose2["default"])(NextTable, _React$Component);
  function NextTable(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    _this.tableRef = void 0;
    _this.tableRef = /*#__PURE__*/_react["default"].createRef();
    (0, _buildNextTableMethod["default"])((0, _assertThisInitialized2["default"])(_this));
    return _this;
  }
  var _proto = NextTable.prototype;
  _proto.renderTable = function renderTable() {
    var _this$props = this.props,
      clsPrefix = _this$props.clsPrefix,
      tablePrefix = _this$props.tablePrefix;
    var myProps = (0, _tableProps.fetchKey)(this.props, _tableProps.tableProps);
    var children = myProps.children;
    if (children) {
      myProps.columns = (0, _getColumnsFromChildern["default"])(children);
    }
    myProps.nextTablePrefix = "" + clsPrefix + tablePrefix;
    myProps.actionColumn = (0, _delegateFunctions["default"])(myProps.actionColumn, 'callback', this, 2);
    myProps.actionBar = (0, _delegateFunctions["default"])(myProps.actionBar, 'callback', this);
    myProps.linkBar = (0, _delegateFunctions["default"])(myProps.linkBar, 'callback', this);
    return /*#__PURE__*/_react["default"].createElement(_webTable["default"], (0, _extends2["default"])({}, myProps, {
      ref: this.tableRef
    }));
  };
  _proto.render = function render() {
    var _this$props2 = this.props,
      clsPrefix = _this$props2.clsPrefix,
      tablePrefix = _this$props2.tablePrefix,
      className = _this$props2.className;
    var nextTablePrefix = "" + clsPrefix + tablePrefix;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])(nextTablePrefix + "full-wrap", className)
    }, this.renderTable());
  };
  return NextTable;
}(_react["default"].Component);
exports.NextTable = NextTable;
NextTable.Column = Column;
NextTable.ColumnGroup = ColumnGroup;
NextTable.GroupHeader = GroupHeader;
NextTable.GroupFooter = GroupFooter;
NextTable.defaultProps = {
  columns: [],
  clsPrefix: 'deep-',
  locale: _zhCn["default"],
  tablePrefix: 'table-',
  primaryKey: 'id',
  maxWebShownActionCount: 3,
  expandedIndexSimulate: false,
  loadingComponent: function loadingComponent(props) {
    return /*#__PURE__*/_react["default"].createElement(_loading["default"], (0, _extends2["default"])({
      indicator: /*#__PURE__*/_react["default"].createElement("img", {
        src: "https://g.alicdn.com/uxcore/pic/loading.svg",
        width: "45",
        alt: ""
      })
    }, props));
  }
};
var _default = _configProvider["default"].config(NextTable);
exports["default"] = _default;