import _Loading from "@alifd/next/es/loading";
import _ConfigProvider from "@alifd/next/es/config-provider";
import _extends from "@babel/runtime/helpers/extends";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _Table from "@alifd/next/es/table";
import classnames from 'classnames';
import React from 'react';
import WebTable from "./table/webTable";
import { fetchKey, tableProps } from "./utils/tableProps";
import buildNextTableMethod from "./utils/buildNextTableMethod";
import delegateFunctions from "./utils/delegateFunctions";
import getColumnsFromChildren from "./utils/getColumnsFromChildern";
import zhCN from "./locale/zh-cn";
import "./index.scss";
var GroupHeader = _Table.GroupHeader,
  GroupFooter = _Table.GroupFooter,
  Column = _Table.Column,
  ColumnGroup = _Table.ColumnGroup;
var NextTable = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(NextTable, _React$Component);
  function NextTable(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    _this.tableRef = void 0;
    _this.tableRef = /*#__PURE__*/React.createRef();
    buildNextTableMethod(_assertThisInitialized(_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 = fetchKey(this.props, tableProps);
    var children = myProps.children;
    if (children) {
      myProps.columns = getColumnsFromChildren(children);
    }
    myProps.nextTablePrefix = "" + clsPrefix + tablePrefix;
    myProps.actionColumn = delegateFunctions(myProps.actionColumn, 'callback', this, 2);
    myProps.actionBar = delegateFunctions(myProps.actionBar, 'callback', this);
    myProps.linkBar = delegateFunctions(myProps.linkBar, 'callback', this);
    return /*#__PURE__*/React.createElement(WebTable, _extends({}, 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.createElement("div", {
      className: classnames(nextTablePrefix + "full-wrap", className)
    }, this.renderTable());
  };
  return NextTable;
}(React.Component);
NextTable.Column = Column;
NextTable.ColumnGroup = ColumnGroup;
NextTable.GroupHeader = GroupHeader;
NextTable.GroupFooter = GroupFooter;
NextTable.defaultProps = {
  columns: [],
  clsPrefix: 'deep-',
  locale: zhCN,
  tablePrefix: 'table-',
  primaryKey: 'id',
  maxWebShownActionCount: 3,
  expandedIndexSimulate: false,
  loadingComponent: function loadingComponent(props) {
    return /*#__PURE__*/React.createElement(_Loading, _extends({
      indicator: /*#__PURE__*/React.createElement("img", {
        src: "https://g.alicdn.com/uxcore/pic/loading.svg",
        width: "45",
        alt: ""
      })
    }, props));
  }
};
export { NextTable };
export default _ConfigProvider.config(NextTable);