bootstrap-view
Version:
With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens
81 lines (73 loc) • 3.38 kB
JavaScript
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); }
import { extend } from '../../../vue';
import { MODEL_EVENT_NAME_PREFIX } from '../../../constants/events';
import { PROP_TYPE_BOOLEAN } from '../../../constants/props';
import { SLOT_NAME_TABLE_BUSY } from '../../../constants/slots';
import { stopEvent } from '../../../utils/events';
import { isFunction } from '../../../utils/inspect';
import { makeProp } from '../../../utils/props';
import { BTr } from '../tr';
import { BTd } from '../td';
// --- Constants ---
var MODEL_PROP_NAME_BUSY = 'busy';
var MODEL_EVENT_NAME_BUSY = MODEL_EVENT_NAME_PREFIX + MODEL_PROP_NAME_BUSY;
// --- Props ---
export var props = _defineProperty({}, MODEL_PROP_NAME_BUSY, makeProp(PROP_TYPE_BOOLEAN, false));
// --- Mixin ---
// @vue/component
export var busyMixin = extend({
props: props,
data: function data() {
return {
localBusy: false
};
},
computed: {
computedBusy: function computedBusy() {
return this[MODEL_PROP_NAME_BUSY] || this.localBusy;
}
},
watch: {
localBusy: function localBusy(newValue, oldValue) {
if (newValue !== oldValue) {
this.$emit(MODEL_EVENT_NAME_BUSY, newValue);
}
}
},
methods: {
// Event handler helper
stopIfBusy: function stopIfBusy(event) {
// If table is busy (via provider) then don't propagate
if (this.computedBusy) {
stopEvent(event);
return true;
}
return false;
},
// Render the busy indicator or return `null` if not busy
renderBusy: function renderBusy() {
var tbodyTrClass = this.tbodyTrClass,
tbodyTrAttr = this.tbodyTrAttr;
var h = this.$createElement;
// Return a busy indicator row, or `null` if not busy
if (this.computedBusy && this.hasNormalizedSlot(SLOT_NAME_TABLE_BUSY)) {
return h(BTr, {
staticClass: 'b-table-busy-slot',
class: [isFunction(tbodyTrClass) ? /* istanbul ignore next */tbodyTrClass(null, SLOT_NAME_TABLE_BUSY) : tbodyTrClass],
attrs: isFunction(tbodyTrAttr) ? /* istanbul ignore next */tbodyTrAttr(null, SLOT_NAME_TABLE_BUSY) : tbodyTrAttr,
key: 'table-busy-slot'
}, [h(BTd, {
props: {
colspan: this.computedFields.length || null
}
}, [this.normalizeSlot(SLOT_NAME_TABLE_BUSY)])]);
}
// We return `null` here so that we can determine if we need to
// render the table items rows or not
return null;
}
}
});