"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _comp = require("../../ui/src/comp");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _ui = require("../../ui");
var _dom = require("../../ui/src/dom");
var _vn = require("../../ui/src/vn");
var _loading = _interopRequireDefault(require("../../loading/src/loading"));
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); }
var _default2 = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeCard',
  mixins: [_ui.globalMixins.sizeMixin],
  props: {
    title: String,
    showTitleOverflow: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().card.showTitleOverflow;
      }
    },
    width: [String, Number],
    height: [String, Number],
    border: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().card.border;
      }
    },
    loading: Boolean,
    shadow: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().card.shadow;
      }
    },
    padding: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().card.padding;
      }
    },
    size: {
      type: String,
      default: function _default() {
        return (0, _ui.getConfig)().card.size || (0, _ui.getConfig)().size;
      }
    }
  },
  data: function data() {
    var xID = _xeUtils.default.uniqueId();
    var reactData = {};
    return {
      xID: xID,
      reactData: reactData
    };
  },
  computed: Object.assign(Object.assign({}, {}), {
    computeCardStyle: function computeCardStyle() {
      var $xeCard = this;
      var props = $xeCard;
      var height = props.height,
        width = props.width;
      var stys = {};
      if (width) {
        stys.width = (0, _dom.toCssUnit)(width);
      }
      if (height) {
        stys.height = (0, _dom.toCssUnit)(height);
      }
      return stys;
    }
  }),
  methods: {
    //
    // Method
    //
    dispatchEvent: function dispatchEvent(type, params, evnt) {
      var $xeCard = this;
      $xeCard.$emit(type, (0, _ui.createEvent)(evnt, {
        $card: $xeCard
      }, params));
    },
    //
    // Render
    //
    renderVN: function renderVN(h) {
      var $xeCard = this;
      var props = $xeCard;
      var slots = $xeCard.$scopedSlots;
      var title = props.title,
        border = props.border,
        shadow = props.shadow,
        padding = props.padding,
        loading = props.loading,
        showTitleOverflow = props.showTitleOverflow;
      var defaultSlot = slots.default;
      var headerSlot = slots.header;
      var titleSlot = slots.title;
      var extraSlot = slots.extra;
      var footerSlot = slots.footer;
      var leftSlot = slots.left;
      var rightSlot = slots.right;
      var vSize = $xeCard.computeSize;
      var cardStyle = $xeCard.computeCardStyle;
      return h('div', {
        ref: 'refElem',
        class: ['vxe-card', _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "size--".concat(vSize), vSize), 'is--border', border), 'is--shadow', shadow), 'is--padding', padding)],
        style: cardStyle
      }, [title || titleSlot || headerSlot ? h('div', {
        class: 'vxe-card--header'
      }, headerSlot ? (0, _vn.getSlotVNs)(headerSlot({})) : [h('div', {
        class: ['vxe-card--header-title', {
          'is--ellipsis': showTitleOverflow
        }]
      }, titleSlot ? (0, _vn.getSlotVNs)(titleSlot({})) : "".concat(title || '')), extraSlot ? h('div', {
        class: 'vxe-card--header-extra'
      }, (0, _vn.getSlotVNs)(extraSlot({}))) : (0, _ui.renderEmptyElement)($xeCard)]) : (0, _ui.renderEmptyElement)($xeCard), h('div', {
        class: 'vxe-card--body'
      }, [leftSlot ? h('div', {
        class: 'vxe-card--body-left'
      }, (0, _vn.getSlotVNs)(leftSlot({}))) : (0, _ui.renderEmptyElement)($xeCard), h('div', {
        class: 'vxe-card--body-content'
      }, defaultSlot ? (0, _vn.getSlotVNs)(defaultSlot({})) : []), rightSlot ? h('div', {
        class: 'vxe-card--body-right'
      }, (0, _vn.getSlotVNs)(rightSlot({}))) : (0, _ui.renderEmptyElement)($xeCard)]), footerSlot ? h('div', {
        class: 'vxe-card--footer'
      }, (0, _vn.getSlotVNs)(footerSlot({}))) : (0, _ui.renderEmptyElement)($xeCard),
      /**
       * 加载中
       */
      h(_loading.default, {
        class: 'vxe-card--loading',
        props: {
          value: loading
        }
      })]);
    }
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */