first commit

This commit is contained in:
DanielRamirezGe
2020-01-14 20:43:08 -06:00
parent 3557894f7f
commit 5eecfbf6cd
26326 changed files with 2434803 additions and 0 deletions
+211
View File
@@ -0,0 +1,211 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import Vue from '../../utils/vue';
import { concat } from '../../utils/array';
import { getComponentConfig } from '../../utils/config';
import { hasIntersectionObserverSupport } from '../../utils/env';
import { VBVisible } from '../../directives/visible/visible';
import { BImg } from './img';
var NAME = 'BImgLazy';
export var props = {
src: {
type: String,
default: null,
required: true
},
srcset: {
type: [String, Array],
default: null
},
sizes: {
type: [String, Array],
default: null
},
alt: {
type: String,
default: null
},
width: {
type: [Number, String],
default: null
},
height: {
type: [Number, String],
default: null
},
blankSrc: {
// If null, a blank image is generated
type: String,
default: null
},
blankColor: {
type: String,
default: function _default() {
return getComponentConfig(NAME, 'blankColor');
}
},
blankWidth: {
type: [Number, String],
default: null
},
blankHeight: {
type: [Number, String],
default: null
},
show: {
type: Boolean,
default: false
},
fluid: {
type: Boolean,
default: false
},
fluidGrow: {
type: Boolean,
default: false
},
block: {
type: Boolean,
default: false
},
thumbnail: {
type: Boolean,
default: false
},
rounded: {
type: [Boolean, String],
default: false
},
left: {
type: Boolean,
default: false
},
right: {
type: Boolean,
default: false
},
center: {
type: Boolean,
default: false
},
offset: {
// Distance away from viewport (in pixels) before being
// considered "visible"
type: [Number, String],
default: 360
}
}; // @vue/component
export var BImgLazy =
/*#__PURE__*/
Vue.extend({
name: NAME,
directives: {
bVisible: VBVisible
},
props: props,
data: function data() {
return {
isShown: this.show
};
},
computed: {
computedSrc: function computedSrc() {
return !this.blankSrc || this.isShown ? this.src : this.blankSrc;
},
computedBlank: function computedBlank() {
return !(this.isShown || this.blankSrc);
},
computedWidth: function computedWidth() {
return this.isShown ? this.width : this.blankWidth || this.width;
},
computedHeight: function computedHeight() {
return this.isShown ? this.height : this.blankHeight || this.height;
},
computedSrcset: function computedSrcset() {
var srcset = concat(this.srcset).filter(Boolean).join(',');
return !this.blankSrc || this.isShown ? srcset : null;
},
computedSizes: function computedSizes() {
var sizes = concat(this.sizes).filter(Boolean).join(',');
return !this.blankSrc || this.isShown ? sizes : null;
}
},
watch: {
show: function show(newVal, oldVal) {
if (newVal !== oldVal) {
// If IntersectionObserver support is not available, image is always shown
var visible = hasIntersectionObserverSupport ? newVal : true;
this.isShown = visible;
if (visible !== newVal) {
// Ensure the show prop is synced (when no IntersectionObserver)
this.$nextTick(this.updateShowProp);
}
}
},
isShown: function isShown(newVal, oldVal) {
if (newVal !== oldVal) {
// Update synched show prop
this.updateShowProp();
}
}
},
mounted: function mounted() {
// If IntersectionObserver is not available, image is always shown
this.isShown = hasIntersectionObserverSupport ? this.show : true;
},
methods: {
updateShowProp: function updateShowProp() {
this.$emit('update:show', this.isShown);
},
doShow: function doShow(visible) {
// If IntersectionObserver is not supported, the callback
// will be called with `null` rather than `true` or `false`
if ((visible || visible === null) && !this.isShown) {
this.isShown = true;
}
}
},
render: function render(h) {
var directives = [];
if (!this.isShown) {
var _modifiers;
// We only add the visible directive if we are not shown
directives.push({
// Visible directive will silently do nothing if
// IntersectionObserver is not supported
name: 'b-visible',
// Value expects a callback (passed one arg of `visible` = `true` or `false`)
value: this.doShow,
modifiers: (_modifiers = {}, _defineProperty(_modifiers, "".concat(parseInt(this.offset, 10) || 0), true), _defineProperty(_modifiers, "once", true), _modifiers)
});
}
return h(BImg, {
directives: directives,
props: {
// Computed value props
src: this.computedSrc,
blank: this.computedBlank,
width: this.computedWidth,
height: this.computedHeight,
srcset: this.computedSrcset || null,
sizes: this.computedSizes || null,
// Passthrough props
alt: this.alt,
blankColor: this.blankColor,
fluid: this.fluid,
fluidGrow: this.fluidGrow,
block: this.block,
thumbnail: this.thumbnail,
rounded: this.rounded,
left: this.left,
right: this.right,
center: this.center
}
});
}
});
+161
View File
@@ -0,0 +1,161 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import Vue from '../../utils/vue';
import { mergeData } from 'vue-functional-data-merge';
import { concat } from '../../utils/array';
import { getComponentConfig } from '../../utils/config';
import { isString } from '../../utils/inspect'; // --- Constants --
var NAME = 'BImg'; // Blank image with fill template
var BLANK_TEMPLATE = '<svg width="%{w}" height="%{h}" ' + 'xmlns="http://www.w3.org/2000/svg" ' + 'viewBox="0 0 %{w} %{h}" preserveAspectRatio="none">' + '<rect width="100%" height="100%" style="fill:%{f};"></rect>' + '</svg>';
export var props = {
src: {
type: String,
default: null
},
srcset: {
type: [String, Array],
default: null
},
sizes: {
type: [String, Array],
default: null
},
alt: {
type: String,
default: null
},
width: {
type: [Number, String],
default: null
},
height: {
type: [Number, String],
default: null
},
block: {
type: Boolean,
default: false
},
fluid: {
type: Boolean,
default: false
},
fluidGrow: {
// Gives fluid images class `w-100` to make them grow to fit container
type: Boolean,
default: false
},
rounded: {
// rounded can be:
// false: no rounding of corners
// true: slightly rounded corners
// 'top': top corners rounded
// 'right': right corners rounded
// 'bottom': bottom corners rounded
// 'left': left corners rounded
// 'circle': circle/oval
// '0': force rounding off
type: [Boolean, String],
default: false
},
thumbnail: {
type: Boolean,
default: false
},
left: {
type: Boolean,
default: false
},
right: {
type: Boolean,
default: false
},
center: {
type: Boolean,
default: false
},
blank: {
type: Boolean,
default: false
},
blankColor: {
type: String,
default: function _default() {
return getComponentConfig(NAME, 'blankColor');
}
}
}; // --- Helper methods ---
var makeBlankImgSrc = function makeBlankImgSrc(width, height, color) {
var src = encodeURIComponent(BLANK_TEMPLATE.replace('%{w}', String(width)).replace('%{h}', String(height)).replace('%{f}', color));
return "data:image/svg+xml;charset=UTF-8,".concat(src);
}; // @vue/component
export var BImg =
/*#__PURE__*/
Vue.extend({
name: NAME,
functional: true,
props: props,
render: function render(h, _ref) {
var _class;
var props = _ref.props,
data = _ref.data;
var src = props.src;
var width = parseInt(props.width, 10) ? parseInt(props.width, 10) : null;
var height = parseInt(props.height, 10) ? parseInt(props.height, 10) : null;
var align = null;
var block = props.block;
var srcset = concat(props.srcset).filter(Boolean).join(',');
var sizes = concat(props.sizes).filter(Boolean).join(',');
if (props.blank) {
if (!height && Boolean(width)) {
height = width;
} else if (!width && Boolean(height)) {
width = height;
}
if (!width && !height) {
width = 1;
height = 1;
} // Make a blank SVG image
src = makeBlankImgSrc(width, height, props.blankColor || 'transparent'); // Disable srcset and sizes
srcset = null;
sizes = null;
}
if (props.left) {
align = 'float-left';
} else if (props.right) {
align = 'float-right';
} else if (props.center) {
align = 'mx-auto';
block = true;
}
return h('img', mergeData(data, {
attrs: {
src: src,
alt: props.alt,
width: width ? String(width) : null,
height: height ? String(height) : null,
srcset: srcset || null,
sizes: sizes || null
},
class: (_class = {
'img-thumbnail': props.thumbnail,
'img-fluid': props.fluid || props.fluidGrow,
'w-100': props.fluidGrow,
rounded: props.rounded === '' || props.rounded === true
}, _defineProperty(_class, "rounded-".concat(props.rounded), isString(props.rounded) && props.rounded !== ''), _defineProperty(_class, align, Boolean(align)), _defineProperty(_class, 'd-block', block), _class)
}));
}
});
+14
View File
@@ -0,0 +1,14 @@
//
// Image
//
import Vue from 'vue'
import { BvPlugin, BvComponent } from '../../'
// Plugin
export declare const ImagePlugin: BvPlugin
// Component: b-img
export declare class BImg extends BvComponent {}
// Component: b-img-lazy
export declare class BImgLazy extends BvComponent {}
+12
View File
@@ -0,0 +1,12 @@
import { BImg } from './img';
import { BImgLazy } from './img-lazy';
import { pluginFactory } from '../../utils/plugins';
var ImagePlugin =
/*#__PURE__*/
pluginFactory({
components: {
BImg: BImg,
BImgLazy: BImgLazy
}
});
export { ImagePlugin, BImg, BImgLazy };