UNPKG

bootstrap-vue

Version:

BootstrapVue, with over 40 plugins and more than 75 custom components, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated WAI-ARIA accessibility markup.

83 lines (79 loc) 2.26 kB
import { htmlOrText } from '../../../utils/html' import { isFunction } from '../../../utils/inspect' export default { props: { showEmpty: { type: Boolean, default: false }, emptyText: { type: String, default: 'There are no records to show' }, emptyHtml: { type: String }, emptyFilteredText: { type: String, default: 'There are no records matching your request' }, emptyFilteredHtml: { type: String } }, methods: { renderEmpty() { const h = this.$createElement const items = this.computedItems let $empty if ( this.showEmpty && (!items || items.length === 0) && !(this.computedBusy && this.hasNormalizedSlot('table-busy')) ) { $empty = this.normalizeSlot(this.isFiltered ? 'emptyfiltered' : 'empty', { emptyFilteredHtml: this.emptyFilteredHtml, emptyFilteredText: this.emptyFilteredText, emptyHtml: this.emptyHtml, emptyText: this.emptyText, fields: this.computedFields, // Not sure why this is included, as it will always be an empty array items: this.computedItems }) if (!$empty) { $empty = h('div', { class: ['text-center', 'my-2'], domProps: this.isFiltered ? htmlOrText(this.emptyFilteredHtml, this.emptyFilteredText) : htmlOrText(this.emptyHtml, this.emptyText) }) } $empty = h( 'td', { attrs: { colspan: String(this.computedFields.length), role: 'cell' } }, [h('div', { attrs: { role: 'alert', 'aria-live': 'polite' } }, [$empty])] ) $empty = h( 'tr', { key: this.isFiltered ? '_b-table-empty-filtered-row_' : '_b-table-empty-row_', staticClass: 'b-table-empty-row', class: [ isFunction(this.tbodyTrClass) ? this.tbodyTrClass(null, 'row-empty') : this.tbodyTrClass ], attrs: { role: 'row' } }, [$empty] ) } return $empty || h(false) } } }