UNPKG

@oruga-ui/oruga-next

Version:

UI components for Vue.js and CSS framework agnostic

90 lines (89 loc) 2.34 kB
/*! Oruga v0.11.0 | MIT License | github.com/oruga-ui/oruga */ import { ref, toRaw } from "vue"; import { merge, setValueByPath, getValueByPath } from "./helpers.mjs"; const oruga = ref({}); function addProgrammatic(property, component) { oruga.value[property] = component; } function useOruga() { return oruga.value; } let VueInstance; const setVueInstance = (Vue) => { VueInstance = Vue; }; const registerPlugin = (app, plugin) => { app.use(plugin); }; const registerComponent = (app, component) => { app.component(component.name, component); }; const registerComponentProgrammatic = (app, property, component) => { setVueInstance(app); const oruga2 = useOruga(); addProgrammatic(property, component); if (!(app._context.provides && app._context.provides.oruga)) app.provide("oruga", oruga2); if (!app.config.globalProperties.$oruga) app.config.globalProperties.$oruga = oruga2; }; const isClient = typeof window !== "undefined"; const isSSR = typeof window === "undefined"; const globalOptions = ref({ iconPack: "mdi", useHtml5Validation: true, statusIcon: true, transformClasses: void 0, mobileBreakpoint: "1023px", teleportTarget: () => isClient ? document.body : "body" }); const setOptions = (options) => { globalOptions.value = options; }; const getOptions = () => { return Object.assign({}, toRaw(globalOptions.value)); }; function getOption(path, defaultValue) { return getValueByPath( globalOptions.value, path, defaultValue ); } const getDefault = (path, defaultValue) => { return getValueByPath(globalOptions.value, path, defaultValue); }; const setOption = (path, value) => { setValueByPath(globalOptions.value, path, value); }; const ConfigProgrammatic = { getOption, getOptions, setOption, setOptions(options) { setOptions(merge(getOptions(), options, true)); } }; const OrugaConfig = { install(app, options) { setVueInstance(app); setOptions(merge(getOptions(), options, true)); } }; export { ConfigProgrammatic as C, OrugaConfig as O, VueInstance as V, registerComponentProgrammatic as a, registerComponent as b, getOption as c, getOptions as d, isSSR as e, setOption as f, getDefault as g, isClient as i, registerPlugin as r, setOptions as s, useOruga as u }; //# sourceMappingURL=config-Dl7tu_Ly.mjs.map