@aster-ui/prefixed 0.12.89 → 0.12.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Chart.js +91 -88
- package/dist/components/Chart.js.map +1 -1
- package/dist/components/QRCode.js +12 -12
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/Terminal.js +96 -93
- package/dist/components/Terminal.js.map +1 -1
- package/dist/components/ThemeController.js +1 -1
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/Watermark.js +12 -12
- package/dist/components/Watermark.js.map +1 -1
- package/dist/hooks/useTheme.d.ts +11 -21
- package/dist/hooks/useTheme.js +63 -94
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +45 -44
- package/dist/providers/ThemeProvider.d.ts +5 -13
- package/dist/providers/ThemeProvider.js +61 -64
- package/dist/providers/ThemeProvider.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Affix as e } from "./components/Affix.js";
|
|
2
2
|
import { AspectRatio as p } from "./components/AspectRatio.js";
|
|
3
|
-
import { Anchor as
|
|
3
|
+
import { Anchor as f } from "./components/Anchor.js";
|
|
4
4
|
import { Alert as a } from "./components/Alert.js";
|
|
5
5
|
import { Autocomplete as n } from "./components/Autocomplete.js";
|
|
6
6
|
import { Avatar as u, AvatarGroup as l } from "./components/Avatar.js";
|
|
7
7
|
import { Badge as C } from "./components/Badge.js";
|
|
8
8
|
import { Breadcrumb as g } from "./components/Breadcrumb.js";
|
|
9
9
|
import { Button as S } from "./components/Button.js";
|
|
10
|
-
import { SizeContext as
|
|
10
|
+
import { SizeContext as P, SizeProvider as k, useSize as v } from "./contexts/SizeContext.js";
|
|
11
11
|
import { CopyButton as D } from "./components/CopyButton.js";
|
|
12
12
|
import { Checkbox as B } from "./components/Checkbox.js";
|
|
13
13
|
import { Chat as w } from "./components/Chat.js";
|
|
@@ -23,14 +23,14 @@ import { ContextMenu as Z } from "./components/ContextMenu.js";
|
|
|
23
23
|
import { Countdown as $ } from "./components/Countdown.js";
|
|
24
24
|
import { DatePicker as ro } from "./components/DatePicker.js";
|
|
25
25
|
import { DateOfBirth as to, dateOfBirthRequired as po } from "./components/DateOfBirth.js";
|
|
26
|
-
import { MonthCalendar as
|
|
26
|
+
import { MonthCalendar as fo } from "./components/MonthCalendar.js";
|
|
27
27
|
import { WeekCalendar as ao } from "./components/WeekCalendar.js";
|
|
28
28
|
import { Descriptions as no } from "./components/Descriptions.js";
|
|
29
29
|
import { Diff as uo } from "./components/Diff.js";
|
|
30
30
|
import { Dock as Co } from "./components/Dock.js";
|
|
31
31
|
import { Divider as go } from "./components/Divider.js";
|
|
32
32
|
import { Drawer as So } from "./components/Drawer.js";
|
|
33
|
-
import { ResponsiveDrawer as
|
|
33
|
+
import { ResponsiveDrawer as Po } from "./components/ResponsiveDrawer.js";
|
|
34
34
|
import { Fieldset as vo } from "./components/Fieldset.js";
|
|
35
35
|
import { FileInput as Do } from "./components/FileInput.js";
|
|
36
36
|
import { Filter as Bo } from "./components/Filter.js";
|
|
@@ -47,14 +47,14 @@ import { Empty as Zo } from "./components/Empty.js";
|
|
|
47
47
|
import { Input as $o } from "./components/Input.js";
|
|
48
48
|
import { InputNumber as rr } from "./components/InputNumber.js";
|
|
49
49
|
import { Join as tr } from "./components/Join.js";
|
|
50
|
-
import { Kbd as
|
|
50
|
+
import { Kbd as mr } from "./components/Kbd.js";
|
|
51
51
|
import { Layout as xr, useSiderContext as ar } from "./components/Layout.js";
|
|
52
52
|
import { List as nr } from "./components/List.js";
|
|
53
53
|
import { Loading as ur } from "./components/Loading.js";
|
|
54
54
|
import { Mask as dr } from "./components/Mask.js";
|
|
55
55
|
import { Masonry as cr } from "./components/Masonry.js";
|
|
56
56
|
import { Mention as Tr } from "./components/Mention.js";
|
|
57
|
-
import { Menu as
|
|
57
|
+
import { Menu as hr } from "./components/Menu.js";
|
|
58
58
|
import { Browser as kr } from "./components/Browser.js";
|
|
59
59
|
import { Code as Rr } from "./components/Code.js";
|
|
60
60
|
import { Phone as br } from "./components/Phone.js";
|
|
@@ -73,7 +73,7 @@ import { RadialProgress as Zr } from "./components/RadialProgress.js";
|
|
|
73
73
|
import { Range as $r } from "./components/Range.js";
|
|
74
74
|
import { Rating as re } from "./components/Rating.js";
|
|
75
75
|
import { Result as te } from "./components/Result.js";
|
|
76
|
-
import { Select as
|
|
76
|
+
import { Select as me } from "./components/Select.js";
|
|
77
77
|
import { Segmented as xe } from "./components/Segmented.js";
|
|
78
78
|
import { Skeleton as se } from "./components/Skeleton.js";
|
|
79
79
|
import { Space as ie } from "./components/Space.js";
|
|
@@ -81,7 +81,7 @@ import { Splitter as le } from "./components/Splitter.js";
|
|
|
81
81
|
import { Stats as Ce } from "./components/Stat.js";
|
|
82
82
|
import { Status as ge } from "./components/Status.js";
|
|
83
83
|
import { Steps as Se } from "./components/Steps.js";
|
|
84
|
-
import { Table as
|
|
84
|
+
import { Table as Pe } from "./components/Table.js";
|
|
85
85
|
import { Tabs as ve } from "./components/Tabs.js";
|
|
86
86
|
import { Textarea as De } from "./components/Textarea.js";
|
|
87
87
|
import { TextRotate as Be } from "./components/TextRotate.js";
|
|
@@ -98,34 +98,34 @@ import { Tree as Ze } from "./components/Tree.js";
|
|
|
98
98
|
import { TreeSelect as $e, TreeSelectComponent as ot } from "./components/TreeSelect.js";
|
|
99
99
|
import { Typography as et } from "./components/Typography.js";
|
|
100
100
|
import { Upload as pt } from "./components/Upload.js";
|
|
101
|
-
import { Watermark as
|
|
101
|
+
import { Watermark as ft } from "./components/Watermark.js";
|
|
102
102
|
import { Hide as at, Show as st } from "./components/Responsive.js";
|
|
103
103
|
import { useBreakpoint as it } from "./hooks/useBreakpoint.js";
|
|
104
104
|
import { useDisclosure as lt } from "./hooks/useDisclosure.js";
|
|
105
105
|
import { useClipboard as Ct } from "./hooks/useClipboard.js";
|
|
106
106
|
import { useLocalStorage as gt } from "./hooks/useLocalStorage.js";
|
|
107
107
|
import { useDebounce as St } from "./hooks/useDebounce.js";
|
|
108
|
-
import { useClickOutside as
|
|
108
|
+
import { useClickOutside as Pt } from "./hooks/useClickOutside.js";
|
|
109
109
|
import { usePrevious as vt } from "./hooks/usePrevious.js";
|
|
110
110
|
import { useHover as Dt } from "./hooks/useHover.js";
|
|
111
111
|
import { useKeyPress as Bt, useKeyPressCallback as Ft } from "./hooks/useKeyPress.js";
|
|
112
112
|
import { useWindowSize as yt } from "./hooks/useWindowSize.js";
|
|
113
|
-
import {
|
|
114
|
-
import { default as
|
|
115
|
-
import { default as
|
|
116
|
-
import { default as
|
|
117
|
-
import { default as
|
|
118
|
-
import { default as
|
|
119
|
-
import { default as
|
|
120
|
-
import { default as
|
|
121
|
-
import { default as
|
|
122
|
-
import { default as
|
|
123
|
-
import { default as
|
|
124
|
-
import { useWatch as
|
|
113
|
+
import { getThemeColors as At, useTheme as Lt } from "./hooks/useTheme.js";
|
|
114
|
+
import { default as zt } from "./locale/en-US.js";
|
|
115
|
+
import { default as Wt } from "./locale/en-GB.js";
|
|
116
|
+
import { default as Kt } from "./locale/en-CA.js";
|
|
117
|
+
import { default as Et } from "./locale/zh-CN.js";
|
|
118
|
+
import { default as Jt } from "./locale/es-ES.js";
|
|
119
|
+
import { default as jt } from "./locale/ja-JP.js";
|
|
120
|
+
import { default as Qt } from "./locale/pt-BR.js";
|
|
121
|
+
import { default as Xt } from "./locale/de-DE.js";
|
|
122
|
+
import { default as Zt } from "./locale/fr-FR.js";
|
|
123
|
+
import { default as $t } from "./locale/ko-KR.js";
|
|
124
|
+
import { useWatch as rp } from "react-hook-form";
|
|
125
125
|
export {
|
|
126
126
|
e as Affix,
|
|
127
127
|
a as Alert,
|
|
128
|
-
|
|
128
|
+
f as Anchor,
|
|
129
129
|
p as AspectRatio,
|
|
130
130
|
n as Autocomplete,
|
|
131
131
|
u as Avatar,
|
|
@@ -175,17 +175,17 @@ export {
|
|
|
175
175
|
$o as Input,
|
|
176
176
|
rr as InputNumber,
|
|
177
177
|
tr as Join,
|
|
178
|
-
|
|
178
|
+
mr as Kbd,
|
|
179
179
|
xr as Layout,
|
|
180
180
|
nr as List,
|
|
181
181
|
ur as Loading,
|
|
182
182
|
dr as Mask,
|
|
183
183
|
cr as Masonry,
|
|
184
184
|
Tr as Mention,
|
|
185
|
-
|
|
185
|
+
hr as Menu,
|
|
186
186
|
Hr as MessageManager,
|
|
187
187
|
yr as Modal,
|
|
188
|
-
|
|
188
|
+
fo as MonthCalendar,
|
|
189
189
|
Ar as Navbar,
|
|
190
190
|
Kr as OTPInput,
|
|
191
191
|
Er as Pagination,
|
|
@@ -197,13 +197,13 @@ export {
|
|
|
197
197
|
Xr as Radio,
|
|
198
198
|
$r as Range,
|
|
199
199
|
re as Rating,
|
|
200
|
-
|
|
200
|
+
Po as ResponsiveDrawer,
|
|
201
201
|
te as Result,
|
|
202
202
|
Eo as Row,
|
|
203
203
|
xe as Segmented,
|
|
204
|
-
|
|
204
|
+
me as Select,
|
|
205
205
|
st as Show,
|
|
206
|
-
|
|
206
|
+
P as SizeContext,
|
|
207
207
|
k as SizeProvider,
|
|
208
208
|
se as Skeleton,
|
|
209
209
|
ie as Space,
|
|
@@ -211,7 +211,7 @@ export {
|
|
|
211
211
|
Ce as Stats,
|
|
212
212
|
ge as Status,
|
|
213
213
|
Se as Steps,
|
|
214
|
-
|
|
214
|
+
Pe as Table,
|
|
215
215
|
ve as Tabs,
|
|
216
216
|
ye as Tag,
|
|
217
217
|
Me as TagLiveRegion,
|
|
@@ -230,23 +230,24 @@ export {
|
|
|
230
230
|
ot as TreeSelectComponent,
|
|
231
231
|
et as Typography,
|
|
232
232
|
pt as Upload,
|
|
233
|
-
|
|
233
|
+
ft as Watermark,
|
|
234
234
|
ao as WeekCalendar,
|
|
235
235
|
Fr as Window,
|
|
236
236
|
po as dateOfBirthRequired,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
Xt as deDE,
|
|
238
|
+
Kt as enCA,
|
|
239
|
+
Wt as enGB,
|
|
240
|
+
zt as enUS,
|
|
241
|
+
Jt as esES,
|
|
242
|
+
Zt as frFR,
|
|
243
|
+
At as getThemeColors,
|
|
244
|
+
jt as jaJP,
|
|
245
|
+
$t as koKR,
|
|
245
246
|
Wr as message,
|
|
246
247
|
Ir as notification,
|
|
247
|
-
|
|
248
|
+
Qt as ptBR,
|
|
248
249
|
it as useBreakpoint,
|
|
249
|
-
|
|
250
|
+
Pt as useClickOutside,
|
|
250
251
|
Ct as useClipboard,
|
|
251
252
|
E as useComponentLocale,
|
|
252
253
|
N as useConfig,
|
|
@@ -263,10 +264,10 @@ export {
|
|
|
263
264
|
vt as usePrevious,
|
|
264
265
|
ar as useSiderContext,
|
|
265
266
|
v as useSize,
|
|
266
|
-
|
|
267
|
+
Lt as useTheme,
|
|
267
268
|
We as useThemeContext,
|
|
268
|
-
|
|
269
|
+
rp as useWatch,
|
|
269
270
|
yt as useWindowSize,
|
|
270
|
-
|
|
271
|
+
Et as zhCN
|
|
271
272
|
};
|
|
272
273
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,12 +5,6 @@ export interface ThemeProviderProps {
|
|
|
5
5
|
defaultTheme?: string;
|
|
6
6
|
/** localStorage key for persisting theme. Set to false to disable persistence. */
|
|
7
7
|
storageKey?: string | false;
|
|
8
|
-
/** Light theme to use when system preference is light */
|
|
9
|
-
lightTheme?: string;
|
|
10
|
-
/** Dark theme to use when system preference is dark */
|
|
11
|
-
darkTheme?: string;
|
|
12
|
-
/** Custom function to determine if a theme is dark */
|
|
13
|
-
isDarkTheme?: (theme: string) => boolean;
|
|
14
8
|
}
|
|
15
9
|
export interface ThemeColors {
|
|
16
10
|
background: string;
|
|
@@ -25,11 +19,9 @@ export interface ThemeColors {
|
|
|
25
19
|
error: string;
|
|
26
20
|
}
|
|
27
21
|
export interface ThemeContextValue {
|
|
28
|
-
/** The theme setting (what user selected
|
|
29
|
-
theme: string;
|
|
30
|
-
/**
|
|
31
|
-
resolvedTheme: string;
|
|
32
|
-
/** Whether the resolved theme is dark */
|
|
22
|
+
/** The theme setting (what user selected) */
|
|
23
|
+
theme: string | undefined;
|
|
24
|
+
/** Whether the current theme is dark */
|
|
33
25
|
isDark: boolean;
|
|
34
26
|
/** Set the theme */
|
|
35
27
|
setTheme: (theme: string) => void;
|
|
@@ -38,10 +30,10 @@ export interface ThemeContextValue {
|
|
|
38
30
|
/** The system preference ("light" or "dark") */
|
|
39
31
|
systemTheme: 'light' | 'dark';
|
|
40
32
|
}
|
|
41
|
-
export declare function ThemeProvider({ children, defaultTheme, storageKey,
|
|
33
|
+
export declare function ThemeProvider({ children, defaultTheme, storageKey, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
42
34
|
/**
|
|
43
35
|
* Hook to access theme context.
|
|
44
|
-
*
|
|
36
|
+
* Works with or without ThemeProvider.
|
|
45
37
|
*/
|
|
46
38
|
export declare function useThemeContext(): ThemeContextValue;
|
|
47
39
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { useState as l, useEffect as a, useCallback as f, useMemo as p, createContext as S, useContext as k } from "react";
|
|
3
|
+
const w = /* @__PURE__ */ new Set([
|
|
4
4
|
"dark",
|
|
5
5
|
"synthwave",
|
|
6
6
|
"halloween",
|
|
@@ -13,76 +13,73 @@ const C = /* @__PURE__ */ new Set([
|
|
|
13
13
|
"coffee",
|
|
14
14
|
"dim",
|
|
15
15
|
"sunset"
|
|
16
|
-
]),
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!t || typeof window > "u") return null;
|
|
22
|
-
try {
|
|
23
|
-
return localStorage.getItem(t);
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function b(t, f) {
|
|
29
|
-
if (!(!t || typeof window > "u"))
|
|
30
|
-
try {
|
|
31
|
-
localStorage.setItem(t, f);
|
|
32
|
-
} catch {
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function V({
|
|
36
|
-
children: t,
|
|
37
|
-
defaultTheme: f = "system",
|
|
38
|
-
storageKey: r = "asterui-theme",
|
|
39
|
-
lightTheme: c = "light",
|
|
40
|
-
darkTheme: d = "dark",
|
|
41
|
-
isDarkTheme: s
|
|
16
|
+
]), d = S(null);
|
|
17
|
+
function I({
|
|
18
|
+
children: s,
|
|
19
|
+
defaultTheme: v,
|
|
20
|
+
storageKey: t = "asterui-theme"
|
|
42
21
|
}) {
|
|
43
|
-
const [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
const [o, T] = l(
|
|
23
|
+
() => typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
|
24
|
+
), [n, i] = l(() => {
|
|
25
|
+
if (t && typeof window < "u")
|
|
26
|
+
try {
|
|
27
|
+
const e = localStorage.getItem(t);
|
|
28
|
+
if (e) return e;
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
return v ?? o;
|
|
32
|
+
}), u = n ? w.has(n) : o === "dark";
|
|
33
|
+
a(() => {
|
|
34
|
+
n ? document.documentElement.setAttribute("data-theme", n) : document.documentElement.removeAttribute("data-theme");
|
|
35
|
+
}, [n]), a(() => {
|
|
47
36
|
if (typeof window > "u") return;
|
|
48
|
-
const e = window.matchMedia("(prefers-color-scheme: dark)"),
|
|
49
|
-
return e.addEventListener("change",
|
|
50
|
-
}, []),
|
|
51
|
-
if (!
|
|
52
|
-
const e = (
|
|
53
|
-
|
|
37
|
+
const e = window.matchMedia("(prefers-color-scheme: dark)"), r = (c) => T(c.matches ? "dark" : "light");
|
|
38
|
+
return e.addEventListener("change", r), () => e.removeEventListener("change", r);
|
|
39
|
+
}, []), a(() => {
|
|
40
|
+
if (!t || typeof window > "u") return;
|
|
41
|
+
const e = (r) => {
|
|
42
|
+
r.key === t && r.newValue && i(r.newValue);
|
|
54
43
|
};
|
|
55
44
|
return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
}, [t]);
|
|
46
|
+
const m = f((e) => {
|
|
47
|
+
if (i(e), t)
|
|
48
|
+
try {
|
|
49
|
+
localStorage.setItem(t, e);
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
}, [t]), h = f(() => {
|
|
53
|
+
i((e) => {
|
|
54
|
+
const c = (e ? w.has(e) : o === "dark") ? "light" : "dark";
|
|
55
|
+
if (t)
|
|
56
|
+
try {
|
|
57
|
+
localStorage.setItem(t, c);
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
return c;
|
|
63
61
|
});
|
|
64
|
-
}, [
|
|
65
|
-
theme:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return /* @__PURE__ */ M(w.Provider, { value: L, children: t });
|
|
62
|
+
}, [o, t]), x = p(() => ({
|
|
63
|
+
theme: n,
|
|
64
|
+
isDark: u,
|
|
65
|
+
setTheme: m,
|
|
66
|
+
toggleTheme: h,
|
|
67
|
+
systemTheme: o
|
|
68
|
+
}), [n, u, m, h, o]);
|
|
69
|
+
return /* @__PURE__ */ E(d.Provider, { value: x, children: s });
|
|
73
70
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
71
|
+
function g() {
|
|
72
|
+
const s = k(d);
|
|
73
|
+
if (!s)
|
|
77
74
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
78
|
-
return
|
|
75
|
+
return s;
|
|
79
76
|
}
|
|
80
|
-
function
|
|
81
|
-
return
|
|
77
|
+
function D() {
|
|
78
|
+
return k(d) !== null;
|
|
82
79
|
}
|
|
83
80
|
export {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
I as ThemeProvider,
|
|
82
|
+
D as useHasThemeProvider,
|
|
83
|
+
g as useThemeContext
|
|
87
84
|
};
|
|
88
85
|
//# sourceMappingURL=ThemeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sources":["../../src/providers/ThemeProvider.tsx"],"sourcesContent":["import React, { createContext, useContext,
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","sources":["../../src/providers/ThemeProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, useState, useEffect, useCallback, useMemo } from 'react'\n\n// Common dark themes in DaisyUI\nconst DARK_THEMES = new Set([\n 'dark', 'synthwave', 'halloween', 'forest', 'black', 'luxury', 'dracula',\n 'business', 'night', 'coffee', 'dim', 'sunset'\n])\n\nexport interface ThemeProviderProps {\n children: React.ReactNode\n /** Default theme. Use \"system\" to follow browser preference. */\n defaultTheme?: string\n /** localStorage key for persisting theme. Set to false to disable persistence. */\n storageKey?: string | false\n}\n\nexport interface ThemeColors {\n background: string\n foreground: string\n primary: string\n primaryContent: string\n secondary: string\n accent: string\n info: string\n success: string\n warning: string\n error: string\n}\n\nexport interface ThemeContextValue {\n /** The theme setting (what user selected) */\n theme: string | undefined\n /** Whether the current theme is dark */\n isDark: boolean\n /** Set the theme */\n setTheme: (theme: string) => void\n /** Toggle between light and dark */\n toggleTheme: () => void\n /** The system preference (\"light\" or \"dark\") */\n systemTheme: 'light' | 'dark'\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null)\n\nexport function ThemeProvider({\n children,\n defaultTheme,\n storageKey = 'asterui-theme',\n}: ThemeProviderProps) {\n const [systemTheme, setSystemTheme] = useState<'dark' | 'light'>(() =>\n typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark' : 'light'\n )\n\n const [theme, setThemeState] = useState<string | undefined>(() => {\n if (storageKey && typeof window !== 'undefined') {\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored) return stored\n } catch { /* ignore */ }\n }\n return defaultTheme ?? systemTheme\n })\n\n const isDark = theme ? DARK_THEMES.has(theme) : systemTheme === 'dark'\n\n // Set data-theme on <html>\n useEffect(() => {\n if (theme) {\n document.documentElement.setAttribute('data-theme', theme)\n } else {\n document.documentElement.removeAttribute('data-theme')\n }\n }, [theme])\n\n // Listen for system preference changes\n useEffect(() => {\n if (typeof window === 'undefined') return\n const mq = window.matchMedia('(prefers-color-scheme: dark)')\n const handler = (e: MediaQueryListEvent) => setSystemTheme(e.matches ? 'dark' : 'light')\n mq.addEventListener('change', handler)\n return () => mq.removeEventListener('change', handler)\n }, [])\n\n // Cross-tab sync\n useEffect(() => {\n if (!storageKey || typeof window === 'undefined') return\n const handler = (e: StorageEvent) => {\n if (e.key === storageKey && e.newValue) setThemeState(e.newValue)\n }\n window.addEventListener('storage', handler)\n return () => window.removeEventListener('storage', handler)\n }, [storageKey])\n\n const setTheme = useCallback((t: string) => {\n setThemeState(t)\n if (storageKey) {\n try { localStorage.setItem(storageKey, t) } catch { /* ignore */ }\n }\n }, [storageKey])\n\n const toggleTheme = useCallback(() => {\n setThemeState((current) => {\n const currentIsDark = current ? DARK_THEMES.has(current) : systemTheme === 'dark'\n const next = currentIsDark ? 'light' : 'dark'\n if (storageKey) {\n try { localStorage.setItem(storageKey, next) } catch { /* ignore */ }\n }\n return next\n })\n }, [systemTheme, storageKey])\n\n const value = useMemo(() => ({\n theme, isDark, setTheme, toggleTheme, systemTheme,\n }), [theme, isDark, setTheme, toggleTheme, systemTheme])\n\n return (\n <ThemeContext.Provider value={value}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\n/**\n * Hook to access theme context.\n * Works with or without ThemeProvider.\n */\nexport function useThemeContext(): ThemeContextValue {\n const ctx = useContext(ThemeContext)\n if (!ctx) {\n throw new Error('useThemeContext must be used within a ThemeProvider')\n }\n return ctx\n}\n\n/**\n * Check if ThemeProvider is present in the tree.\n */\nexport function useHasThemeProvider(): boolean {\n return useContext(ThemeContext) !== null\n}\n"],"names":["DARK_THEMES","ThemeContext","createContext","ThemeProvider","children","defaultTheme","storageKey","systemTheme","setSystemTheme","useState","theme","setThemeState","stored","isDark","useEffect","mq","handler","e","setTheme","useCallback","t","toggleTheme","current","next","value","useMemo","jsx","useThemeContext","ctx","useContext","useHasThemeProvider"],"mappings":"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"}
|