/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var helper = require('../../_chunks/dep-44e6bdf6.js');
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var table_baseTableProps = require('../base-table-props.js');
var table_primaryTableProps = require('../primary-table-props.js');
var table_baseTable_index = require('../base-table/index.js');
var utils_mixins = require('../../utils/mixins.js');
var table_primaryTable_mixins_expand = require('./mixins/expand.js');
var table_primaryTable_mixins_select = require('./mixins/select.js');
var table_primaryTable_mixins_sort = require('./mixins/sort.js');
var table_primaryTable_mixins_rowDraggable = require('./mixins/row-draggable.js');
var table_primaryTable_mixins_filter = require('./mixins/filter.js');
var table_primaryTable_mixins_showColumns = require('./mixins/show-columns.js');
var table_primaryTable_mixins_asyncLoading = require('./mixins/async-loading.js');
var utils_event = require('../../utils/event.js');
require('lodash/throttle');
require('../../config-provider/config-receiver.js');
require('vue');
require('../../config-provider/zh_CN_config.js');
require('../../config.js');
require('../util/props-util.js');
require('../base-table/table-body.js');
require('lodash/get');
require('../base-table/table-row.js');
require('../base-table/table-cell.js');
require('../../popup/index.js');
require('../../popup/popup.js');
require('@babel/runtime/helpers/typeof');
require('@popperjs/core');
require('../../_chunks/dep-939cdc39.js');
require('../../utils/classnames.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../popup/props.js');
require('../../utils/render-tnode.js');
require('../../utils/set-style.js');
require('../../utils/map-props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../../utils/withInstall.js');
require('lodash/capitalize');
require('../util/common.js');
require('lodash/isFunction');
require('../base-table/table-header.js');
require('../base-table/col-group.js');
require('../../pagination/index.js');
require('../../pagination/pagination.js');
require('tdesign-icons-vue');
require('../../input-number/index.js');
require('../../input-number/input-number.js');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('../../button/index.js');
require('../../button/button.js');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../loading/icon/gradient.js');
require('../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../loading/plugin.js');
require('../../button/props.js');
require('../../utils/ripple.js');
require('../../input-number/props.js');
require('../../utils/helper.js');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../../select/index.js');
require('../../select/select.js');
require('lodash/debounce');
require('lodash/set');
require('../../input/index.js');
require('../../input/addon.js');
require('../../input/input.js');
require('../../input/props.js');
require('../../input/input-group.js');
require('../../tag/index.js');
require('../../tag/tag.js');
require('../../tag/props.js');
require('../../tag/check-tag.js');
require('../../tag/check-tag-props.js');
require('../../common-components/fake-arrow.js');
require('../../select/option.js');
require('../../select/option-props.js');
require('../../checkbox/index.js');
require('../../checkbox/group.js');
require('lodash/intersection');
require('../../checkbox/checkbox.js');
require('../../checkbox/props.js');
require('../../checkbox/checkbox-group-props.js');
require('../../select/props.js');
require('../../select/optionGroup.js');
require('../../select/option-group-props.js');
require('../../pagination/props.js');
require('../util/interface.js');
require('./expand-box.js');
require('./select-box.js');
require('../../radio/index.js');
require('../../radio/radio.js');
require('../../radio/props.js');
require('../../radio/group.js');
require('lodash/isNumber');
require('../../radio/radio-group-props.js');
require('../../radio/radio-button.js');
require('./sorter-button.js');
require('../../tooltip/index.js');
require('../../tooltip/tooltip.js');
require('../../tooltip/props.js');
require('../../dialog/index.js');
require('../../dialog/dialog.js');
require('../../dialog/actions.js');
require('lodash/isObject');
require('../../dialog/props.js');
require('../../dialog/plugin.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _PrimaryTable = utils_mixins["default"](table_primaryTable_mixins_expand["default"], table_primaryTable_mixins_select["default"], table_primaryTable_mixins_sort["default"], table_primaryTable_mixins_rowDraggable["default"], table_primaryTable_mixins_filter["default"], table_primaryTable_mixins_showColumns["default"], table_primaryTable_mixins_asyncLoading["default"]).extend({
  name: "TTable",
  props: _objectSpread(_objectSpread({}, table_baseTableProps["default"]), table_primaryTableProps["default"]),
  computed: {
    rehandleData: function rehandleData() {
      return this.asyncLoadingHandler(_toConsumableArray__default["default"](this.data));
    },
    rehandleColumns: function rehandleColumns() {
      var columns = this.columns.map(function (col) {
        return _objectSpread({}, col);
      });
      columns = this.getShowColumns(_toConsumableArray__default["default"](this.columns));
      columns = this.getSorterColumns(columns);
      columns = this.getFilterColumns(columns);
      columns = this.getSelectColumns(columns);
      columns = this.getExpandColumns(columns);
      return columns;
    }
  },
  created: function created() {
    if (typeof this.$attrs["expanded-row-render"] !== "undefined") {
      console.warn("The expandedRowRender prop is deprecated. Use expandedRow instead.");
    }
  },
  methods: {
    renderRows: function renderRows(params) {
      var row = params.row,
          rowIndex = params.rowIndex,
          rows = params.rows;

      if (row.colKey === "async-loading-row") {
        rows.splice(rowIndex, 1, this.renderAsyncLoadingRow());
        return;
      }

      this.renderExpandedRow(params);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var $props = this.$props,
        $scopedSlots = this.$scopedSlots,
        rehandleColumns = this.rehandleColumns;

    var scopedSlots = _objectSpread({}, $scopedSlots);

    var on = _objectSpread(_objectSpread({}, this.$listeners), {}, {
      "page-change": function pageChange(pageInfo, newDataSource) {
        utils_event.emitEvent(_this, "page-change", pageInfo, newDataSource);
        utils_event.emitEvent(_this, "change", {
          pagination: pageInfo
        }, {
          trigger: "pagination",
          currentData: newDataSource
        });
      },
      "row-dragstart": this.onDragStart,
      "row-dragover": this.onDragOver
    });

    if (this.expandOnRowClick) {
      on["row-click"] = function (params) {
        _this.handleExpandChange(params.row);
      };
    }

    var baseTableProps2 = {
      props: _objectSpread(_objectSpread({}, $props), {}, {
        data: this.rehandleData,
        columns: rehandleColumns,
        provider: {
          renderRows: this.renderRows,
          sortOnRowDraggable: this.sortOnRowDraggable,
          dragging: this.dragging
        },
        firstFullRow: this.hasFilterCondition ? this.renderFirstFilterRow : void 0,
        empty: this.empty
      }),
      scopedSlots: scopedSlots,
      on: on
    };

    if (this.hasFilterCondition) {
      baseTableProps2.props.empty = null;
    }

    return h(table_baseTable_index["default"], helper.helper([{}, baseTableProps2]));
  }
});

exports["default"] = _PrimaryTable;
//# sourceMappingURL=index.js.map
