UNPKG

@serendie/ui

Version:

Adaptive UI component library as part of Serendie Design System by Mitsubishi Electric

36 lines (35 loc) 1.03 kB
import { jsx as s } from "react/jsx-runtime"; import { useMemo as m, useEffect as u, createContext as f } from "react"; import { resolveTheme as c, ThemeContext as v } from "../theme/ThemeContext.js"; import { useSystemColorScheme as h } from "../theme/useSystemColorScheme.js"; const l = f(void 0); function p({ lang: d, colorTheme: t = "konjo", colorMode: o, children: i }) { const r = h() === "dark", e = m(() => c(t, o ?? "light", r), [t, o, r]); u(() => { if (typeof document > "u") return; const n = document.documentElement; return e ? n.dataset.pandaTheme = e : delete n.dataset.pandaTheme, () => { }; }, [e]); const a = m( () => ({ colorTheme: t, colorMode: o ?? "light", resolvedTheme: e, systemPrefersDark: r }), [t, o, e, r] ); return /* @__PURE__ */ s(l.Provider, { value: d, children: /* @__PURE__ */ s(v.Provider, { value: a, children: i }) }); } const S = p; export { l as LanguageContext, S as LanguageProvider, p as SerendieProvider };