vuestic-ui
Version:
Vue 3 UI Framework
59 lines (58 loc) • 2.46 kB
JavaScript
import { c as cloneDeep } from "../../utils/clone-deep.mjs";
import { ref, getCurrentInstance } from "vue";
import { g as getBreakpointDefaultConfig } from "../breakpoint/index.mjs";
import { g as getCurrentApp } from "../current-app.mjs";
import { m as mergeDeep } from "../../utils/merge-deep.mjs";
import { g as getColorsClassesDefaultConfig } from "../colors-classes/config/default.mjs";
import { g as getColorDefaultConfig } from "../color/config/default.mjs";
import { g as getIconDefaultConfig } from "../icon/config/default.mjs";
import { g as getComponentsDefaultConfig } from "../component-config/config/default.mjs";
import { g as getI18nConfigDefaults } from "../i18n/config/default.mjs";
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.mjs.map