@aplus-frontend/ui
Version:
63 lines (62 loc) • 2.22 kB
JavaScript
import { isVNode as p, ref as G, defineComponent as M, computed as o, unref as a, watch as u, onActivated as P, createVNode as h, renderSlot as A } from "vue";
import { ConfigProvider as w } from "@aplus-frontend/antdv";
import { useGlobalConfig as D, provideGlobalConfig as F } from "./hooks/use-global-config.mjs";
import { configProviderProps as U } from "./config-provider-props.mjs";
import { mergeAntdProviderConfigWithCache as l, mergeAntdProvideConfig as c } from "../utils/config-provider-preset.mjs";
import { DEFAULT_NAMESPACE as b, DEFAULT_UIMODE as E } from "./constants.mjs";
function N(e) {
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !p(e);
}
const n = G({}), j = /* @__PURE__ */ M({
name: "AplusConfigProvider",
props: U(),
setup(e, {
slots: f
}) {
const t = D();
let r = !0;
const m = o(() => e.namespace !== void 0 ? e.namespace : t.value?.namespace || b), d = o(() => e.uiMode !== void 0 ? e.uiMode : t.value?.uiMode || E), g = o(() => e.apGrid !== void 0 ? e.apGrid : t.value?.apGrid), v = o(() => e.agGrid !== void 0 ? e.agGrid : t.value?.agGrid), C = o(() => ({
namespace: a(m),
aplusLocale: e.aplusLocale,
api: e.api,
uiMode: a(d),
apUpload: e.apUpload,
apDescriptions: e.apDescriptions,
valueTypeMap: e.valueTypeMap,
downloadCenterTriggerConfig: e.downloadCenterTriggerConfig,
exportField: e.exportField,
scrollYDomName: e.scrollYDomName,
viewCacheOption: e.viewCacheOption,
searchForm: e.searchForm,
apGrid: a(g),
agGrid: a(v)
})), s = F(C);
return u(() => e, (i) => {
n.value = l(c(i), n.value);
}, {
deep: !0,
immediate: !0
}), P(() => {
if (r) {
r = !1;
return;
}
n.value = l(c(e), n.value);
}), typeof window < "u" && u(() => a(d), (i) => {
document.documentElement.dataset.aplusUiMode = i;
}, {
immediate: !0
}), () => {
let i;
return h(w, n.value, N(i = A(f, "default", {
config: s?.value
})) ? i : {
default: () => [i]
});
};
}
});
export {
j as ConfigProvider,
n as globalConfigCached
};