UNPKG

bootstrap-vue

Version:

BootstrapVue, with over 40 plugins and more than 80 custom components, custom directives, and over 300 icons, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated WAI-AR

150 lines (140 loc) 3.58 kB
import Vue from '../../utils/vue'; import idMixin from '../../mixins/id'; import normalizeSlotMixin from '../../mixins/normalize-slot'; import { hasTouchSupport } from '../../utils/env'; import { htmlOrText } from '../../utils/html'; import { BImg } from '../image/img'; export var props = { imgSrc: { type: String // default: undefined }, imgAlt: { type: String // default: undefined }, imgWidth: { type: [Number, String] // default: undefined }, imgHeight: { type: [Number, String] // default: undefined }, imgBlank: { type: Boolean, default: false }, imgBlankColor: { type: String, default: 'transparent' }, contentVisibleUp: { type: String }, contentTag: { type: String, default: 'div' }, caption: { type: String }, captionHtml: { type: String }, captionTag: { type: String, default: 'h3' }, text: { type: String }, textHtml: { type: String }, textTag: { type: String, default: 'p' }, background: { type: String } }; // @vue/component export var BCarouselSlide = /*#__PURE__*/ Vue.extend({ name: 'BCarouselSlide', mixins: [idMixin, normalizeSlotMixin], inject: { bvCarousel: { default: function _default() { return { // Explicitly disable touch if not a child of carousel noTouch: true }; } } }, props: props, computed: { contentClasses: function contentClasses() { return [this.contentVisibleUp ? 'd-none' : '', this.contentVisibleUp ? "d-".concat(this.contentVisibleUp, "-block") : '']; }, computedWidth: function computedWidth() { // Use local width, or try parent width return this.imgWidth || this.bvCarousel.imgWidth || null; }, computedHeight: function computedHeight() { // Use local height, or try parent height return this.imgHeight || this.bvCarousel.imgHeight || null; } }, render: function render(h) { var noDrag = !this.bvCarousel.noTouch && hasTouchSupport; var img = this.normalizeSlot('img'); if (!img && (this.imgSrc || this.imgBlank)) { img = h(BImg, { props: { fluidGrow: true, block: true, src: this.imgSrc, blank: this.imgBlank, blankColor: this.imgBlankColor, width: this.computedWidth, height: this.computedHeight, alt: this.imgAlt }, // Touch support event handler on: noDrag ? { dragstart: function dragstart(e) { /* istanbul ignore next: difficult to test in JSDOM */ e.preventDefault(); } } : {} }); } if (!img) { img = h(); } var content = h(); var contentChildren = [this.caption || this.captionHtml ? h(this.captionTag, { domProps: htmlOrText(this.captionHtml, this.caption) }) : false, this.text || this.textHtml ? h(this.textTag, { domProps: htmlOrText(this.textHtml, this.text) }) : false, this.normalizeSlot('default') || false]; if (contentChildren.some(Boolean)) { content = h(this.contentTag, { staticClass: 'carousel-caption', class: this.contentClasses }, contentChildren.map(function (i) { return i || h(); })); } return h('div', { staticClass: 'carousel-item', style: { background: this.background || this.bvCarousel.background || null }, attrs: { id: this.safeId(), role: 'listitem' } }, [img, content]); } });