@deriv-com/quill-ui
Advanced tools
Comparing version 1.0.3 to 1.0.4
export declare const UseTheme: () => { | ||
theme: import("../providers/theme/themeContext").Theme; | ||
toggleTheme: (theme: import("../providers/theme/themeContext").Theme) => void; | ||
toggleTheme: () => void; | ||
}; | ||
export default UseTheme; |
@@ -0,7 +1,8 @@ | ||
import React from "react"; | ||
export type Theme = "dark" | "light"; | ||
export type ThemeContextValue = { | ||
theme: Theme; | ||
toggleTheme: (theme: Theme) => void; | ||
toggleTheme: () => void; | ||
}; | ||
export declare const ThemeContext: import("react").Context<ThemeContextValue>; | ||
export declare const ThemeContext: React.Context<ThemeContextValue>; | ||
export default ThemeContext; |
@@ -1,3 +0,3 @@ | ||
import { createContext as e } from "react"; | ||
const o = e({ | ||
import e from "react"; | ||
const o = e.createContext({ | ||
theme: "light", | ||
@@ -4,0 +4,0 @@ toggleTheme: () => { |
@@ -1,16 +0,16 @@ | ||
import { jsx as l } from "react/jsx-runtime"; | ||
import { useState as f, useLayoutEffect as h, useEffect as m } from "react"; | ||
import { jsx as d } from "react/jsx-runtime"; | ||
import { useState as f, useLayoutEffect as m, useEffect as h } from "react"; | ||
import { ThemeContext as u } from "./themeContext.js"; | ||
var c = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, v = typeof c == "object" && c && c.Object === Object && c, p = typeof self == "object" && self && self.Object === Object && self; | ||
v || p || Function("return this")(); | ||
var b = typeof window < "u" ? h : m, g = typeof window > "u"; | ||
function w(n, { | ||
defaultValue: r = !1, | ||
initializeWithValue: a = !0 | ||
var a = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, p = typeof a == "object" && a && a.Object === Object && a, w = typeof self == "object" && self && self.Object === Object && self; | ||
p || w || Function("return this")(); | ||
var g = typeof window < "u" ? m : h, v = typeof window > "u"; | ||
function b(n, { | ||
defaultValue: o = !1, | ||
initializeWithValue: s = !0 | ||
} = {}) { | ||
const i = (e) => g ? r : window.matchMedia(e).matches, [o, d] = f(() => a ? i(n) : r); | ||
const i = (e) => v ? o : window.matchMedia(e).matches, [r, c] = f(() => s ? i(n) : o); | ||
function t() { | ||
d(i(n)); | ||
c(i(n)); | ||
} | ||
return b(() => { | ||
return g(() => { | ||
const e = window.matchMedia(n); | ||
@@ -20,20 +20,17 @@ return t(), e.addListener ? e.addListener(t) : e.addEventListener("change", t), () => { | ||
}; | ||
}, [n]), o; | ||
}, [n]), r; | ||
} | ||
const j = ({ children: n, theme: r }) => { | ||
const [a, i] = f( | ||
r | ||
), [o, d] = f(r ?? "light"), t = w("(prefers-color-scheme: dark)"), e = (s) => { | ||
i(s); | ||
const L = ({ children: n, theme: o }) => { | ||
const [s, i] = f( | ||
o | ||
), [r, c] = f(o ?? "light"), t = b("(prefers-color-scheme: dark)"), e = () => { | ||
i(r === "dark" ? "light" : "dark"); | ||
}; | ||
return m(() => { | ||
d(a || (t ? "dark" : "light")); | ||
}, [a, t]), m(() => { | ||
const s = document.documentElement; | ||
o === "dark" ? s.classList.add("theme--dark") : s.classList.remove("theme--dark"); | ||
}, [o]), /* @__PURE__ */ l(u.Provider, { value: { theme: o, toggleTheme: e }, children: /* @__PURE__ */ l("div", { className: `theme--${o}`, children: n }) }); | ||
return h(() => { | ||
c(s || (t ? "dark" : "light")); | ||
}, [s, t]), /* @__PURE__ */ d(u.Provider, { value: { theme: r, toggleTheme: e }, children: /* @__PURE__ */ d("section", { className: `theme--${r}`, children: n }) }); | ||
}; | ||
export { | ||
j as ThemeProvider, | ||
j as default | ||
L as ThemeProvider, | ||
L as default | ||
}; |
{ | ||
"name": "@deriv-com/quill-ui", | ||
"private": false, | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "main": "dist/main.js", |
514884
2529