/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { Loading } from '../loading/index.js';
import { renderTNodeJSX } from '../utils/render-tnode.js';
import { getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../utils/mixins.js';
import { LOADING, LOAD_MORE } from './const.js';
import props from './props.js';
import '../utils/withInstall.js';
import 'vue';
import 'lodash/capitalize';
import '../loading/directive.js';
import 'lodash/isObject';
import 'lodash/mapKeys';
import 'lodash/isEqual';
import '../loading/plugin.js';
import '../config.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../loading/loading.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import 'lodash/isArray';
import '@babel/runtime/helpers/typeof';
import '@vue/composition-api';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';
import '../loading/style/css.js';
import '../loading/type.js';

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(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 classPrefixMixins = getClassPrefixMixins("list");
var _List = mixins(classPrefixMixins).extend({
  name: "TList",
  props: _objectSpread({}, props),
  computed: {
    listClass: function listClass() {
      var _ref;
      return ["".concat(this.componentName), this.commonSizeClassName[this.size], (_ref = {}, _defineProperty(_ref, "".concat(this.componentName, "--split"), this.split), _defineProperty(_ref, "".concat(this.componentName, "--stripe"), this.stripe), _defineProperty(_ref, "".concat(this.componentName, "--vertical-action"), this.layout === "vertical"), _ref)];
    },
    loadingClass: function loadingClass() {
      if (this.asyncLoading === "loading") return this.commonStatusClassName.loading;
      if (this.asyncLoading === "load-more") return this.commonStatusClassName.loadMore;
      return "";
    }
  },
  components: {
    Loading: Loading
  },
  methods: {
    renderLoading: function renderLoading() {
      var h = this.$createElement;
      if (this.asyncLoading && typeof this.asyncLoading === "string") {
        var _LOADING$LOAD_MORE$th;
        var text = (_LOADING$LOAD_MORE$th = {}, _defineProperty(_LOADING$LOAD_MORE$th, LOADING, "\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u540E"), _defineProperty(_LOADING$LOAD_MORE$th, LOAD_MORE, "\u70B9\u51FB\u52A0\u8F7D\u66F4\u591A"), _LOADING$LOAD_MORE$th)[this.asyncLoading];
        var loading = this.asyncLoading === LOADING;
        return h(Loading, {
          "class": this.loadingClass,
          "attrs": {
            "loading": loading,
            "text": text
          }
        });
      }
      return renderTNodeJSX(this, "asyncLoading");
    },
    handleScroll: function handleScroll(e) {
      var listElement = this.$el;
      var scrollTop = listElement.scrollTop,
        scrollHeight = listElement.scrollHeight,
        clientHeight = listElement.clientHeight;
      this.$emit("scroll", {
        $event: e,
        scrollTop: scrollTop,
        scrollBottom: scrollHeight - clientHeight - scrollTop
      });
      if (this.onScroll) {
        this.onScroll({
          e: e,
          scrollTop: scrollTop,
          scrollBottom: scrollHeight - clientHeight - scrollTop
        });
      }
    },
    handleLoadMore: function handleLoadMore(e) {
      if (typeof this.asyncLoading === "string" && this.asyncLoading !== LOAD_MORE) return;
      this.$emit("load-more", {
        e: e
      });
      if (this.onLoadMore) {
        this.onLoadMore({
          e: e
        });
      }
    },
    renderContent: function renderContent() {
      var h = this.$createElement;
      var propsHeaderContent = renderTNodeJSX(this, "header");
      var propsFooterContent = renderTNodeJSX(this, "footer");
      return [propsHeaderContent && h("div", {
        "class": "".concat(this.componentName, "__header")
      }, [propsHeaderContent]), h("ul", {
        "class": "".concat(this.componentName, "__inner")
      }, [renderTNodeJSX(this, "default")]), propsFooterContent && h("div", {
        "class": "".concat(this.componentName, "__footer")
      }, [propsFooterContent])];
    }
  },
  render: function render() {
    var h = arguments[0];
    var listContent = this.renderContent();
    listContent = [listContent, h("div", {
      "class": "".concat(this.componentName, "__load"),
      "on": {
        "click": this.handleLoadMore
      }
    }, [this.renderLoading()])];
    return h("div", {
      "class": this.listClass,
      "on": {
        "scroll": this.handleScroll
      }
    }, [listContent]);
  }
});

export { _List as default };
//# sourceMappingURL=list.js.map
