UNPKG

vuestic-ui

Version:
59 lines (58 loc) 2.45 kB
import { c as cloneDeep } from "../../utils/clone-deep.js"; import { ref, getCurrentInstance } from "vue"; import { g as getBreakpointDefaultConfig } from "../breakpoint/index.js"; import { g as getCurrentApp } from "../current-app.js"; import { m as mergeDeep } from "../../utils/merge-deep.js"; import { g as getColorsClassesDefaultConfig } from "../colors-classes/config/default.js"; import { g as getColorDefaultConfig } from "../color/config/default.js"; import { g as getIconDefaultConfig } from "../icon/config/default.js"; import { g as getComponentsDefaultConfig } from "../component-config/config/default.js"; import { g as getI18nConfigDefaults } from "../i18n/config/default.js"; const GLOBAL_CONFIG = Symbol("GLOBAL_CONFIG"); const getDefaultConfig = () => ({ colors: getColorDefaultConfig(), icons: getIconDefaultConfig(), components: getComponentsDefaultConfig(), breakpoint: getBreakpointDefaultConfig(), i18n: getI18nConfigDefaults(), colorsClasses: getColorsClassesDefaultConfig(), /** * global config variable to pass nuxt-link component to vuestic-ui via @vuestic/nuxt * TODO: give a try to integrate inertia js router components via this option * TODO: if this try won't be success, may be remake to provide/inject */ routerComponent: void 0 }); const createGlobalConfig = (defaultConfig = {}) => { const globalConfig = ref(mergeDeep(getDefaultConfig(), defaultConfig)); const getGlobalConfig = () => globalConfig.value; const setGlobalConfig = (updater) => { const config = typeof updater === "function" ? updater(globalConfig.value) : updater; globalConfig.value = cloneDeep(config); }; const mergeGlobalConfig = (updater) => { const config = typeof updater === "function" ? updater(globalConfig.value) : updater; globalConfig.value = mergeDeep(cloneDeep(globalConfig.value), config); }; return { getGlobalConfig, setGlobalConfig, mergeGlobalConfig, globalConfig }; }; const provideForCurrentApp = (provide) => { var _a, _b; const provides = ((_a = getCurrentInstance()) == null ? void 0 : _a.appContext.provides) || ((_b = getCurrentApp()) == null ? void 0 : _b._context.provides); if (!provides) { throw new Error("Vue app not found for provide"); } provides[GLOBAL_CONFIG] = provide; return provide; }; export { GLOBAL_CONFIG as G, createGlobalConfig as c, provideForCurrentApp as p }; //# sourceMappingURL=global-config.js.map