/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var components_loading_index = require('../loading/index.js');
var utils_renderNode = require('../../utils/render-node.js');
var components_configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../../utils/mixins.js');
var components_list_const = require('./const.js');
var components_list_props = require('./props.js');
require('../../utils/with-install.js');
require('vue');
require('lodash');
require('../../config.js');
require('../loading/loading.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../loading/plugin.js');

const classPrefixMixins = components_configProvider_configReceiver.getClassPrefixMixins("list");
var _List = utils_mixins["default"](classPrefixMixins).extend({
  name: "LList",
  props: {
    ...components_list_props.ListProps
  },
  computed: {
    listClass() {
      return [`${this.componentName}`, this.commonSizeClassName[this.size], {
        [`${this.componentName}--split`]: this.split,
        [`${this.componentName}--stripe`]: this.stripe,
        [`${this.componentName}--vertical-action`]: this.layout === "vertical"
      }];
    },
    loadingClass() {
      if (this.asyncLoading === "loading") return this.commonStatusClassName.loading;
      if (this.asyncLoading === "load-more") return this.commonStatusClassName.loadMore;
      return "";
    }
  },
  components: {
    LLoading: components_loading_index.Loading
  },
  methods: {
    renderLoading() {
      const h = this.$createElement;
      if (this.asyncLoading && typeof this.asyncLoading === "string") {
        const text = {
          [components_list_const.LOADING]: "\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u540E",
          [components_list_const.LOAD_MORE]: "\u70B9\u51FB\u52A0\u8F7D\u66F4\u591A"
        }[this.asyncLoading];
        const loading = this.asyncLoading === components_list_const.LOADING;
        return h("l-loading", {
          "class": this.loadingClass,
          "attrs": {
            "loading": loading,
            "text": text
          }
        });
      }
      return utils_renderNode.renderLNodeJSX(this, "asyncLoading");
    },
    handleScroll(e) {
      const listElement = this.$el;
      const {
        scrollTop,
        scrollHeight,
        clientHeight
      } = listElement;
      this.$emit("scroll", {
        $event: e,
        scrollTop,
        scrollBottom: scrollHeight - clientHeight - scrollTop
      });
      if (this.onScroll) {
        this.onScroll({
          e,
          scrollTop,
          scrollBottom: scrollHeight - clientHeight - scrollTop
        });
      }
    },
    handleLoadMore(e) {
      if (typeof this.asyncLoading === "string" && this.asyncLoading !== components_list_const.LOAD_MORE) return;
      this.$emit("load-more", {
        e
      });
      if (this.onLoadMore) {
        this.onLoadMore({
          e
        });
      }
    },
    renderContent() {
      const h = this.$createElement;
      const propsHeaderContent = utils_renderNode.renderLNodeJSX(this, "header");
      const propsFooterContent = utils_renderNode.renderLNodeJSX(this, "footer");
      return [propsHeaderContent && h("div", {
        "class": `${this.componentName}__header`
      }, [propsHeaderContent]), h("ul", {
        "class": `${this.componentName}__inner`
      }, [utils_renderNode.renderLNodeJSX(this, "default")]), propsFooterContent && h("div", {
        "class": `${this.componentName}__footer`
      }, [propsFooterContent])];
    }
  },
  render() {
    const h = arguments[0];
    let listContent = this.renderContent();
    listContent = [listContent, h("div", {
      "class": `${this.componentName}__load`,
      "on": {
        "click": this.handleLoadMore
      }
    }, [this.renderLoading()])];
    return h("div", {
      "class": this.listClass,
      "on": {
        "scroll": this.handleScroll
      }
    }, [listContent]);
  }
});

exports["default"] = _List;
//# sourceMappingURL=list.js.map
