UNPKG

ucc-ui

Version:

ucc-ui components library

49 lines (48 loc) 1.46 kB
import { ref as C, getCurrentInstance as m, computed as f, unref as d, inject as b, provide as x, defineComponent as G, renderSlot as L } from "vue"; import { g as v, n as A, o as g } from "./vendors-PY6Ic9FA.js"; import { D as s } from "./locale-BeqhBZQs.js"; const p = Symbol(), i = "zh-cn", t = C(); function D(e, c = void 0) { return m() ? b(p, t) : t; } const I = (e) => { var o, r, n; const c = (l) => v(l, (e == null ? void 0 : e.extendsI18nMsg) ?? {}); return e != null && e.locale ? g({ locale: ((o = e.locale) == null ? void 0 : o.name) || i, messages: c({ [i]: s.el, [(r = e.locale) == null ? void 0 : r.name]: ((n = e.locale) == null ? void 0 : n.el) ?? {} }) }) : g({ locale: i, messages: c({ DEFAULT_LANG: s.el }) }); }; function h(e = { locale: s }, c, o = !1) { const r = m(), n = r ? D() : void 0, l = r ? x : void 0; if (!l) throw new Error("ucc-ui: provideGlobalConfig must be called in setup or app.use"); const a = f(() => { const u = d(e); return n != null && n.value ? v(n.value, u) : u; }), _ = f(() => I(a.value)); return l(p, a), l(A, _.value), (o || !t.value) && (t.value = a.value), a; } const M = /* @__PURE__ */ G({ name: "UConfigProvider", __name: "ConfigProvider", props: { locale: {}, extendsI18nMsg: {} }, setup(e) { const o = h(e); return (r, n) => L(r.$slots, "default", { config: d(o) }); } }); export { M as _ };