UNPKG

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

74 lines (68 loc) 3.65 kB
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } import { extend } from '../../vue'; import { NAME_ASPECT } from '../../constants/components'; import { PROP_TYPE_NUMBER_STRING, PROP_TYPE_STRING } from '../../constants/props'; import { RX_ASPECT, RX_ASPECT_SEPARATOR } from '../../constants/regex'; import { mathAbs } from '../../utils/math'; import { toFloat } from '../../utils/number'; import { makeProp, makePropsConfigurable } from '../../utils/props'; import { normalizeSlotMixin } from '../../mixins/normalize-slot'; // --- Constants --- var CLASS_NAME = 'b-aspect'; // --- Props --- export var props = makePropsConfigurable({ // Accepts a number (i.e. `16 / 9`, `1`, `4 / 3`) // Or a string (i.e. '16/9', '16:9', '4:3' '1:1') aspect: makeProp(PROP_TYPE_NUMBER_STRING, '1:1'), tag: makeProp(PROP_TYPE_STRING, 'div') }, NAME_ASPECT); // --- Main component --- // @vue/component export var BAspect = /*#__PURE__*/extend({ name: NAME_ASPECT, mixins: [normalizeSlotMixin], props: props, computed: { padding: function padding() { var aspect = this.aspect; var ratio = 1; if (RX_ASPECT.test(aspect)) { // Width and/or Height can be a decimal value below `1`, so // we only fallback to `1` if the value is `0` or `NaN` var _aspect$split$map = aspect.split(RX_ASPECT_SEPARATOR).map(function (v) { return toFloat(v) || 1; }), _aspect$split$map2 = _slicedToArray(_aspect$split$map, 2), width = _aspect$split$map2[0], height = _aspect$split$map2[1]; ratio = width / height; } else { ratio = toFloat(aspect) || 1; } return "".concat(100 / mathAbs(ratio), "%"); } }, render: function render(h) { var $sizer = h('div', { staticClass: "".concat(CLASS_NAME, "-sizer flex-grow-1"), style: { paddingBottom: this.padding, height: 0 } }); var $content = h('div', { staticClass: "".concat(CLASS_NAME, "-content flex-grow-1 w-100 mw-100"), style: { marginLeft: '-100%' } }, this.normalizeSlot()); return h(this.tag, { staticClass: "".concat(CLASS_NAME, " d-flex") }, [$sizer, $content]); } });