@aplus-frontend/ui
Version:
33 lines (32 loc) • 1.04 kB
JavaScript
import { ref as p, getCurrentInstance as a, inject as m, computed as s, provide as d, unref as g } from "vue";
import { configProviderContextKey as v } from "../constants.mjs";
import { localeContextKey as C } from "./use-locale.mjs";
import { namespaceContextKey as y } from "./use-namespace.mjs";
const l = (e) => Object.keys(e), f = p();
function x(e, o = void 0) {
const t = a() ? m(v, f) : f;
return e ? s(() => t.value?.[e] ?? o) : t;
}
const O = (e, o, t = !1) => {
const r = !!a(), n = r ? x() : void 0, c = o?.provide ?? (r ? d : void 0);
if (!c)
return;
const i = s(() => {
const u = g(e);
return n?.value ? b(n.value, u) : u;
});
return c(v, i), c(y, i.value.namespace), c(
C,
s(() => i.value.aplusLocale)
), (t || !f.value) && (f.value = i.value), i;
}, b = (e, o) => {
const t = [.../* @__PURE__ */ new Set([...l(e), ...l(o)])], r = {};
for (const n of t)
r[n] = o[n] !== void 0 ? o[n] : e[n];
return r;
};
export {
l as keysOf,
O as provideGlobalConfig,
x as useGlobalConfig
};