@itools-front/ifrontui
Version:
Vue Material Component Framework
77 lines (61 loc) • 2.07 kB
JavaScript
import OurVue from 'vue';
import { consoleError } from './util/console';
export function install(Vue, args = {}) {
if (install.installed) return;
install.installed = true;
if (OurVue !== Vue) {
consoleError(`Multiple instances of Vue detected
See https://github.com/vuetifyjs/vuetify/issues/4068
If you're seeing "$attrs is readonly", it's caused by this`);
}
const components = args.components || {};
const directives = args.directives || {};
for (const name in directives) {
const directive = directives[name];
Vue.directive(name, directive);
}
(function registerComponents(components) {
if (components) {
for (const key in components) {
const component = components[key];
if (component && !registerComponents(component.$_ifrontui_subcomponents)) {
Vue.component(key, component);
}
}
return true;
}
return false;
})(components); // Used to avoid multiple mixins being setup
// when in dev mode and hot module reload
// https://github.com/vuejs/vue/issues/5089#issuecomment-284260111
if (Vue.$_vuetify_installed) return;
Vue.$_vuetify_installed = true;
Vue.mixin({
beforeCreate() {
const options = this.$options;
if (options.ifrontui) {
options.ifrontui.init(this, this.$ssrContext);
this.$ifrontui = Vue.observable(options.ifrontui.framework);
} else {
this.$ifrontui = options.parent && options.parent.$ifrontui || this;
}
},
beforeMount() {
// @ts-ignore
if (this.$options.ifrontui && this.$el && this.$el.hasAttribute('data-server-rendered')) {
// @ts-ignore
this.$ifrontui.isHydrating = true; // @ts-ignore
this.$ifrontui.breakpoint.update(true);
}
},
mounted() {
// @ts-ignore
if (this.$options.ifrontui && this.$ifrontui.isHydrating) {
// @ts-ignore
this.$ifrontui.isHydrating = false; // @ts-ignore
this.$ifrontui.breakpoint.update();
}
}
});
}
//# sourceMappingURL=install.js.map