UNPKG

@ishitatsuyuki/oruga-next

Version:

UI components for Vue.js and CSS framework agnostic

31 lines (28 loc) 1.16 kB
// oruga object for programmatic components const oruga = {}; // add components to the oruga object function addProgrammatic(property, component) { oruga[property] = component; } // composable for internal and external usage function useProgrammatic() { return { oruga, addProgrammatic }; } const registerPlugin = (app, plugin) => { app.use(plugin); }; const registerComponent = (app, component) => { app.component(component.name, component); }; const registerComponentProgrammatic = (app, property, component) => { // use composable for unified access to programmatic oruga object const { oruga, addProgrammatic } = useProgrammatic(); // add component (manipulates the programmatic oruga object) addProgrammatic(property, component); // add provide and $oruga (only needed once) if (!(app._context.provides && app._context.provides.oruga)) app.provide('oruga', oruga); if (!app.config.globalProperties.$oruga) app.config.globalProperties.$oruga = oruga; }; export { registerComponentProgrammatic as a, registerComponent as b, registerPlugin as r, useProgrammatic as u };