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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import primaryTableProps from '../../primary-table-props.js';
import TableRow from '../../base-table/table-row.js';
import { Loading } from '../../../loading/index.js';
import { prefix } from '../../../config.js';
import { STATUS_CLASSNAMES } from '../../../utils/classnames.js';
import { emitEvent } from '../../../utils/event.js';
import '../../../_chunks/dep-42d5c87e.js';
import 'lodash/get';
import '../../base-table-props.js';
import '../../base-table/table-cell.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../../popup/index.js';
import '../../../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../../../_chunks/dep-1db5c91c.js';
import '../../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../../utils/easing.js';
import '../../../popup/props.js';
import '../../../utils/render-tnode.js';
import '../../../utils/set-style.js';
import '../../../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../../../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../../../popup/type.js';
import '../../util/common.js';
import 'lodash/isFunction';
import '../../../loading/loading.js';
import '../../../loading/icon/gradient.js';
import '../../../utils/transfer-dom.js';
import '../../../loading/props.js';
import '../../../loading/type.js';
import '../../../loading/plugin.js';
import '../../../utils/helper.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';

var ASYNC_LOADING_ROW = "async-loading-row";
var asyncLoadingMixin = Vue.extend({
  name: "".concat(prefix, "-primary-table-async-loading"),
  props: {
    columns: primaryTableProps.columns,
    asyncLoading: primaryTableProps.asyncLoading
  },
  data: function data() {
    return {
      pullDownLoading: false
    };
  },
  computed: {
    classes: function classes() {
      var _ref;

      return ["".concat(prefix, "-table__async-loading"), (_ref = {}, _defineProperty(_ref, STATUS_CLASSNAMES.loading, this.asyncLoading === "loading"), _defineProperty(_ref, STATUS_CLASSNAMES.loadMore, this.asyncLoading === "load-more"), _ref)];
    }
  },
  methods: {
    asyncLoadingHandler: function asyncLoadingHandler(data) {
      if (this.asyncLoading || typeof this.$scopedSlots.asyncLoading === "function") {
        return data.concat({
          colKey: ASYNC_LOADING_ROW
        });
      }

      return data;
    },
    onLoadClick: function onLoadClick() {
      if (typeof this.asyncLoading !== "string") return;
      emitEvent(this, "async-loading-click", {
        status: this.asyncLoading
      });
    },
    renderAsyncLoadingRow: function renderAsyncLoadingRow() {
      var _this = this;

      var h = this.$createElement;
      var asyncLoading = this.asyncLoading;
      var columns = [{
        colKey: ASYNC_LOADING_ROW,
        attrs: {
          colSpan: this.columns.length
        },
        render: function render(h) {
          if (typeof asyncLoading === "function") {
            return asyncLoading(h);
          }

          if (typeof _this.$scopedSlots.asyncLoading === "function") {
            return _this.$scopedSlots.asyncLoading(h);
          }

          var loadingText = {
            "load-more": "\u70B9\u51FB\u52A0\u8F7D\u66F4\u591A",
            loading: "\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u540E"
          }[String(asyncLoading)];

          if (!loadingText) {
            return "";
          }

          return h("div", {
            "class": _this.classes,
            "on": {
              "click": _this.onLoadClick
            }
          }, [h(Loading, {
            "attrs": {
              "loading": asyncLoading === "loading",
              "text": loadingText
            }
          })]);
        }
      }];
      return h(TableRow, {
        "attrs": {
          "rowKey": ASYNC_LOADING_ROW,
          "columns": columns
        }
      });
    }
  }
});

export { ASYNC_LOADING_ROW, asyncLoadingMixin as default };
//# sourceMappingURL=async-loading.js.map
