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
101 lines (99 loc) • 6.58 kB
JavaScript
var _excluded = ["attrs", "props"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
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); }
import Vue from 'vue';
import { mergeData } from 'vue-functional-data-merge';
// --- Constants ---
var COMPONENT_UID_KEY = '_uid';
var isVue3 = Vue.version.startsWith('3');
export var REF_FOR_KEY = isVue3 ? 'ref_for' : 'refInFor';
var ALLOWED_FIELDS_IN_DATA = ['class', 'staticClass', 'style', 'attrs', 'props', 'domProps', 'on', 'nativeOn', 'directives', 'scopedSlots', 'slot', 'key', 'ref', 'refInFor'];
var extend = Vue.extend.bind(Vue);
if (isVue3) {
var originalExtend = Vue.extend;
var KNOWN_COMPONENTS = ['router-link', 'transition', 'transition-group'];
var originalVModelDynamicCreated = Vue.vModelDynamic.created;
var originalVModelDynamicBeforeUpdate = Vue.vModelDynamic.beforeUpdate;
// See https://github.com/vuejs/vue-next/pull/4121 for details
Vue.vModelDynamic.created = function (el, binding, vnode) {
originalVModelDynamicCreated.call(this, el, binding, vnode);
if (!el._assign) {
el._assign = function () {};
}
};
Vue.vModelDynamic.beforeUpdate = function (el, binding, vnode) {
originalVModelDynamicBeforeUpdate.call(this, el, binding, vnode);
if (!el._assign) {
el._assign = function () {};
}
};
extend = function patchedBootstrapVueExtend(definition) {
if (_typeof(definition) === 'object' && definition.render && !definition.__alreadyPatched) {
var originalRender = definition.render;
definition.__alreadyPatched = true;
definition.render = function (h) {
var patchedH = function patchedH(tag, dataObjOrChildren, rawSlots) {
var slots = rawSlots === undefined ? [] : [Array.isArray(rawSlots) ? rawSlots.filter(Boolean) : rawSlots];
var isTag = typeof tag === 'string' && !KNOWN_COMPONENTS.includes(tag);
var isSecondArgumentDataObject = dataObjOrChildren && _typeof(dataObjOrChildren) === 'object' && !Array.isArray(dataObjOrChildren);
if (!isSecondArgumentDataObject) {
return h.apply(void 0, [tag, dataObjOrChildren].concat(slots));
}
var attrs = dataObjOrChildren.attrs,
props = dataObjOrChildren.props,
restData = _objectWithoutProperties(dataObjOrChildren, _excluded);
var normalizedData = _objectSpread(_objectSpread({}, restData), {}, {
attrs: attrs,
props: isTag ? {} : props
});
if (tag === 'router-link' && !normalizedData.slots && !normalizedData.scopedSlots) {
// terrible workaround to fix router-link rendering with compat vue-router
normalizedData.scopedSlots = {
$hasNormal: function $hasNormal() {}
};
}
return h.apply(void 0, [tag, normalizedData].concat(slots));
};
if (definition.functional) {
var _ctx$children, _ctx$children$default;
var ctx = arguments[1];
var patchedCtx = _objectSpread({}, ctx);
patchedCtx.data = {
attrs: _objectSpread({}, ctx.data.attrs || {}),
props: _objectSpread({}, ctx.data.props || {})
};
Object.keys(ctx.data || {}).forEach(function (key) {
if (ALLOWED_FIELDS_IN_DATA.includes(key)) {
patchedCtx.data[key] = ctx.data[key];
} else if (key in ctx.props) {
patchedCtx.data.props[key] = ctx.data[key];
} else if (!key.startsWith('on')) {
patchedCtx.data.attrs[key] = ctx.data[key];
}
});
var IGNORED_CHILDREN_KEYS = ['_ctx'];
var children = ((_ctx$children = ctx.children) === null || _ctx$children === void 0 || (_ctx$children$default = _ctx$children.default) === null || _ctx$children$default === void 0 ? void 0 : _ctx$children$default.call(_ctx$children)) || ctx.children;
if (children && Object.keys(patchedCtx.children).filter(function (k) {
return !IGNORED_CHILDREN_KEYS.includes(k);
}).length === 0) {
delete patchedCtx.children;
} else {
patchedCtx.children = children;
}
patchedCtx.data.on = ctx.listeners;
return originalRender.call(this, patchedH, patchedCtx);
}
return originalRender.call(this, patchedH);
};
}
return originalExtend.call(this, definition);
}.bind(Vue);
}
var nextTick = Vue.nextTick;
export { COMPONENT_UID_KEY, Vue, mergeData, isVue3, nextTick, extend };