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