"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _comp = require("../../ui/src/comp");
var _ui = require("../../ui");
var _loading = _interopRequireDefault(require("../../loading"));
var _backtop = _interopRequireDefault(require("../../backtop"));
var _xeUtils = _interopRequireDefault(require("xe-utils"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function createInternalData() {
  return {};
}
function createReactData() {
  return {};
}
var _default2 = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeLayoutBody',
  mixins: [_ui.globalMixins.sizeMixin],
  props: {
    loading: Boolean,
    padding: Boolean,
    showBacktop: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().layoutBody.showBacktop;
      }
    },
    backtopConfig: Object,
    size: {
      type: String,
      default: function _default() {
        return (0, _ui.getConfig)().layoutBody.size || (0, _ui.getConfig)().size;
      }
    }
  },
  data: function data() {
    var xID = _xeUtils.default.uniqueId();
    var backtopId = "vxe_layout_body_backtop_".concat(xID);
    var reactData = createReactData();
    return Object.assign(Object.assign({}, {}), {
      xID: xID,
      backtopId: backtopId,
      reactData: reactData
    });
  },
  computed: Object.assign(Object.assign({}, {}), {
    computeBacktopOpts: function computeBacktopOpts() {
      var $xeLayoutBody = this;
      var props = $xeLayoutBody;
      var backtopId = $xeLayoutBody.backtopId;
      return Object.assign({}, (0, _ui.getConfig)().layoutBody.backtopConfig, props.backtopConfig, {
        target: '#' + backtopId
      });
    }
  }),
  methods: {
    //
    // Method
    //
    dispatchEvent: function dispatchEvent(type, params, evnt) {
      var $xeLayoutBody = this;
      $xeLayoutBody.$emit(type, (0, _ui.createEvent)(evnt, {
        $layoutBody: $xeLayoutBody
      }, params));
    },
    //
    // Render
    //
    renderVN: function renderVN(h) {
      var $xeLayoutBody = this;
      var props = $xeLayoutBody;
      var slots = $xeLayoutBody.$scopedSlots;
      var backtopId = $xeLayoutBody.backtopId;
      var loading = props.loading,
        padding = props.padding,
        showBacktop = props.showBacktop;
      var backtopOpts = $xeLayoutBody.computeBacktopOpts;
      var vSize = $xeLayoutBody.computeSize;
      var defaultSlot = slots.default;
      var backtopSlot = slots.backtop;
      var backtopTopSlot = slots.backtopTop || slots['backtop-top'];
      var backtopBottomSlot = slots.backtopBottom || slots['backtop-bottom'];
      var backtopScopeSlots = {};
      if (backtopSlot) {
        backtopScopeSlots.default = backtopSlot;
      }
      if (backtopTopSlot) {
        backtopScopeSlots.top = backtopTopSlot;
      }
      if (backtopBottomSlot) {
        backtopScopeSlots.bottom = backtopBottomSlot;
      }
      return h('div', {
        class: ['vxe-layout-body', _defineProperty(_defineProperty(_defineProperty({}, "size--".concat(vSize), vSize), 'is--loading', loading), 'is--padding', padding)]
      }, [h('div', {
        attrs: {
          id: showBacktop ? backtopId : ''
        },
        class: 'vxe-layout-body--inner'
      }, defaultSlot ? defaultSlot({}) : []),
      /**
       * 加载中
       */
      h(_loading.default, {
        class: 'vxe-list-view--loading',
        props: {
          value: loading
        }
      }),
      /**
       * 回到顶部
       */
      showBacktop ? h(_backtop.default, {
        props: backtopOpts,
        scopedSlots: backtopScopeSlots
      }) : (0, _ui.renderEmptyElement)($xeLayoutBody)]);
    }
  },
  created: function created() {
    var $xeLayoutBody = this;
    $xeLayoutBody.internalData = createInternalData();
  },
  beforeDestroy: function beforeDestroy() {
    var $xeLayoutBody = this;
    var reactData = $xeLayoutBody.reactData;
    var internalData = $xeLayoutBody.internalData;
    _xeUtils.default.assign(reactData, createReactData());
    _xeUtils.default.assign(internalData, createInternalData());
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */