@aplus-frontend/ui
Version:
64 lines (63 loc) • 2.48 kB
JavaScript
import { isVNode as P, ref as G, defineComponent as T, computed as a, unref as n, watch as h, onActivated as b, createVNode as w, renderSlot as A } from "vue";
import { ConfigProvider as D } from "@aplus-frontend/antdv";
import { useGlobalConfig as F, provideGlobalConfig as N } from "./hooks/use-global-config.mjs";
import { configProviderProps as I } from "./config-provider-props.mjs";
import { mergeAntdProviderConfigWithCache as d, mergeAntdProvideConfig as l } from "../utils/config-provider-preset.mjs";
import { DEFAULT_NAMESPACE as M } from "./constants.mjs";
import { useDevWarning as k } from "../utils/warning.mjs";
function y(e) {
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !P(e);
}
const r = G({}), V = /* @__PURE__ */ T({
name: "AplusConfigProvider",
props: I(),
setup(e, {
slots: u
}) {
k("ConfigProvider")(!e.uiMode, "breaking", "uiMode has been remove, see migrate guild https://aplus.aplnk.com/aplus-ui/guild/migrate-7.2.html");
const i = F();
let t = !0;
const c = a(() => e.namespace !== void 0 ? e.namespace : i.value?.namespace || M), g = a(() => e.apGrid !== void 0 ? e.apGrid : i.value?.apGrid), m = a(() => e.agGrid !== void 0 ? e.agGrid : i.value?.agGrid), f = a(() => e.apProCard !== void 0 ? e.apProCard : i.value?.apProCard), v = a(() => e.apImage !== void 0 ? e.apImage : i.value?.apImage), C = a(() => e.apTitle !== void 0 ? e.apTitle : i.value?.apTitle), p = a(() => ({
namespace: n(c),
aplusLocale: e.aplusLocale,
aplusToken: e.aplusToken,
api: e.api,
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: n(g),
agGrid: n(m),
apProCard: n(f),
apImage: n(v),
apTitle: n(C)
})), s = N(p);
return h(() => e, (o) => {
r.value = d(l(o), r.value);
}, {
deep: !0,
immediate: !0
}), b(() => {
if (t) {
t = !1;
return;
}
r.value = d(l(e), r.value);
}), () => {
let o;
return w(D, r.value, y(o = A(u, "default", {
config: s?.value
})) ? o : {
default: () => [o]
});
};
}
});
export {
V as ConfigProvider,
r as globalConfigCached
};