@tamagui/next-theme 1.88.13 → 1.88.14
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/LICENSE +21 -0
- package/dist/cjs/useRootTheme.js +6 -7
- package/dist/cjs/useRootTheme.js.map +2 -2
- package/dist/cjs/useRootTheme.native.js +6 -7
- package/dist/cjs/useRootTheme.native.js.map +2 -2
- package/dist/esm/NextTheme.mjs +8 -0
- package/dist/esm/NextThemeProvider.mjs +146 -0
- package/dist/esm/ThemeSettingContext.mjs +7 -0
- package/dist/esm/UseThemeProps.mjs +0 -0
- package/dist/esm/constants.mjs +4 -0
- package/dist/esm/helpers.mjs +12 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/useRootTheme.js +8 -9
- package/dist/esm/useRootTheme.js.map +2 -2
- package/dist/esm/useRootTheme.mjs +13 -0
- package/dist/esm/useRootTheme.native.js +6 -7
- package/dist/esm/useRootTheme.native.js.map +2 -2
- package/dist/esm/useTheme.mjs +5 -0
- package/package.json +4 -4
- package/src/NextThemeProvider.tsx +2 -2
- package/src/ThemeSettingContext.tsx +1 -1
- package/src/UseThemeProps.tsx +1 -1
- package/src/useRootTheme.tsx +8 -15
- package/types/NextThemeProvider.d.ts +1 -1
- package/types/NextThemeProvider.d.ts.map +1 -1
- package/types/ThemeSettingContext.d.ts +1 -1
- package/types/ThemeSettingContext.d.ts.map +1 -1
- package/types/UseThemeProps.d.ts +1 -1
- package/types/UseThemeProps.d.ts.map +1 -1
- package/types/useRootTheme.d.ts +2 -2
- package/types/useRootTheme.d.ts.map +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cjs/useRootTheme.js
CHANGED
|
@@ -19,12 +19,11 @@ __export(useRootTheme_exports, {
|
|
|
19
19
|
module.exports = __toCommonJS(useRootTheme_exports);
|
|
20
20
|
var import_constants = require("@tamagui/constants"), import_react = require("react");
|
|
21
21
|
const useRootTheme = ({ fallback = "light" } = {}) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const classes = [...document.documentElement.classList]
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, []), [val, setVal];
|
|
22
|
+
let initialVal = fallback;
|
|
23
|
+
if (import_constants.isClient) {
|
|
24
|
+
const classes = [...document.documentElement.classList];
|
|
25
|
+
initialVal = classes.includes("t_dark") ? "dark" : classes.includes("t_light") ? "light" : fallback;
|
|
26
|
+
}
|
|
27
|
+
return (0, import_react.useState)(initialVal);
|
|
29
28
|
};
|
|
30
29
|
//# sourceMappingURL=useRootTheme.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB,+BACzB,eAAyB;AAIlB,MAAM,eAAe,CAAC,EAAE,WAAW,QAAQ,IAAgC,CAAC,MAAM;AACvF,MAAI,aAAa;AAEjB,MAAI,2BAAU;AAEZ,UAAM,UAAU,CAAC,GAAG,SAAS,gBAAgB,SAAS;AACtD,iBAAa,QAAQ,SAAS,QAAQ,IAClC,SACA,QAAQ,SAAS,SAAS,IACxB,UACA;AAAA,EACR;AAEA,aAAO,uBAAsB,UAAU;AACzC;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
|
@@ -20,13 +20,12 @@ __export(useRootTheme_exports, {
|
|
|
20
20
|
module.exports = __toCommonJS(useRootTheme_exports);
|
|
21
21
|
var import_constants = require("@tamagui/constants"), import_react = require("react");
|
|
22
22
|
const useRootTheme = ({ fallback = "light" } = {}) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const classes = [...document.documentElement.classList]
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, []), [val, setVal];
|
|
23
|
+
let initialVal = fallback;
|
|
24
|
+
if (import_constants.isClient) {
|
|
25
|
+
const classes = [...document.documentElement.classList];
|
|
26
|
+
initialVal = classes.includes("t_dark") ? "dark" : classes.includes("t_light") ? "light" : fallback;
|
|
27
|
+
}
|
|
28
|
+
return (0, import_react.useState)(initialVal);
|
|
30
29
|
};
|
|
31
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
31
|
0 && (module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB,+BACzB,eAAyB;AAIlB,MAAM,eAAe,CAAC,EAAE,WAAW,QAAQ,IAAgC,CAAC,MAAM;AACvF,MAAI,aAAa;AAEjB,MAAI,2BAAU;AAEZ,UAAM,UAAU,CAAC,GAAG,SAAS,gBAAgB,SAAS;AACtD,iBAAa,QAAQ,SAAS,QAAQ,IAClC,SACA,QAAQ,SAAS,SAAS,IACxB,UACA;AAAA,EACR;AAEA,aAAO,uBAAsB,UAAU;AACzC;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./NextThemeProvider.mjs";
|
|
2
|
+
export * from "./ThemeSettingContext.mjs";
|
|
3
|
+
export * from "./UseThemeProps.mjs";
|
|
4
|
+
export * from "./helpers.mjs";
|
|
5
|
+
export * from "./constants.mjs";
|
|
6
|
+
export * from "./useTheme.mjs";
|
|
7
|
+
export * from "./types.mjs";
|
|
8
|
+
export * from "./useRootTheme.mjs";
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { useEvent } from "@tamagui/use-event";
|
|
3
|
+
import NextHead from "next/head";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { memo, useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { MEDIA, colorSchemes } from "./constants.mjs";
|
|
7
|
+
import { getSystemTheme, getTheme } from "./helpers.mjs";
|
|
8
|
+
import { ThemeSettingContext } from "./ThemeSettingContext.mjs";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
const NextThemeProvider = memo(({
|
|
11
|
+
forcedTheme,
|
|
12
|
+
disableTransitionOnChange = !1,
|
|
13
|
+
enableSystem = !0,
|
|
14
|
+
enableColorScheme = !0,
|
|
15
|
+
storageKey = "theme",
|
|
16
|
+
themes = colorSchemes,
|
|
17
|
+
defaultTheme = enableSystem ? "system" : "light",
|
|
18
|
+
attribute = "class",
|
|
19
|
+
skipNextHead,
|
|
20
|
+
onChangeTheme,
|
|
21
|
+
value = {
|
|
22
|
+
dark: "t_dark",
|
|
23
|
+
light: "t_light"
|
|
24
|
+
},
|
|
25
|
+
children
|
|
26
|
+
}) => {
|
|
27
|
+
const [theme, setThemeState] = useState(() => getTheme(storageKey, defaultTheme)),
|
|
28
|
+
[resolvedTheme, setResolvedTheme] = useState(() => getTheme(storageKey)),
|
|
29
|
+
attrs = value ? Object.values(value) : themes,
|
|
30
|
+
handleMediaQuery = useEvent(e => {
|
|
31
|
+
const _ = getSystemTheme(e),
|
|
32
|
+
update = () => setResolvedTheme(_);
|
|
33
|
+
disableTransitionOnChange ? update() : React.startTransition(() => update()), theme === "system" && !forcedTheme && handleChangeTheme(_, !1);
|
|
34
|
+
}),
|
|
35
|
+
handleChangeTheme = useEvent((theme2, updateStorage = !0, updateDOM = !0) => {
|
|
36
|
+
let name = value?.[theme2] || theme2;
|
|
37
|
+
if (updateStorage) try {
|
|
38
|
+
localStorage.setItem(storageKey, theme2);
|
|
39
|
+
} catch {}
|
|
40
|
+
if (theme2 === "system" && enableSystem) {
|
|
41
|
+
const resolved = getSystemTheme();
|
|
42
|
+
name = value?.[resolved] || resolved;
|
|
43
|
+
}
|
|
44
|
+
if (onChangeTheme?.(name.replace("t_", "")), updateDOM) {
|
|
45
|
+
const d = document.documentElement;
|
|
46
|
+
attribute === "class" ? (d.classList.remove(...attrs), d.classList.add(name)) : d.setAttribute(attribute, name);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
useIsomorphicLayoutEffect(() => {
|
|
50
|
+
const media = window.matchMedia(MEDIA);
|
|
51
|
+
return media.addListener(handleMediaQuery), handleMediaQuery(media), () => {
|
|
52
|
+
media.removeListener(handleMediaQuery);
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
const set = useEvent(newTheme => {
|
|
56
|
+
forcedTheme ? handleChangeTheme(newTheme, !0, !1) : handleChangeTheme(newTheme), setThemeState(newTheme);
|
|
57
|
+
});
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const handleStorage = e => {
|
|
60
|
+
if (e.key !== storageKey) return;
|
|
61
|
+
const theme2 = e.newValue || defaultTheme;
|
|
62
|
+
set(theme2);
|
|
63
|
+
};
|
|
64
|
+
return window.addEventListener("storage", handleStorage), () => {
|
|
65
|
+
window.removeEventListener("storage", handleStorage);
|
|
66
|
+
};
|
|
67
|
+
}, [defaultTheme, set, storageKey]), useIsomorphicLayoutEffect(() => {
|
|
68
|
+
if (!enableColorScheme) return;
|
|
69
|
+
const colorScheme =
|
|
70
|
+
// If theme is forced to light or dark, use that
|
|
71
|
+
forcedTheme && colorSchemes.includes(forcedTheme) ? forcedTheme :
|
|
72
|
+
// If regular theme is light or dark
|
|
73
|
+
theme && colorSchemes.includes(theme) ? theme :
|
|
74
|
+
// If theme is system, use the resolved version
|
|
75
|
+
theme === "system" && resolvedTheme || null;
|
|
76
|
+
(typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") !== (colorScheme || "light") && document.documentElement.style.setProperty("color-scheme", colorScheme);
|
|
77
|
+
}, [enableColorScheme, theme, resolvedTheme, forcedTheme]);
|
|
78
|
+
const toggle = useEvent(() => {
|
|
79
|
+
const order = resolvedTheme === "dark" ? ["system", "light", "dark"] : ["system", "dark", "light"],
|
|
80
|
+
next = order[(order.indexOf(theme) + 1) % order.length];
|
|
81
|
+
set(next);
|
|
82
|
+
}),
|
|
83
|
+
systemTheme = enableSystem ? resolvedTheme : void 0,
|
|
84
|
+
contextValue = useMemo(() => ({
|
|
85
|
+
theme,
|
|
86
|
+
current: theme,
|
|
87
|
+
set,
|
|
88
|
+
toggle,
|
|
89
|
+
forcedTheme,
|
|
90
|
+
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
91
|
+
themes: enableSystem ? [...themes, "system"] : themes,
|
|
92
|
+
systemTheme
|
|
93
|
+
}), [theme, set, toggle, forcedTheme, resolvedTheme, enableSystem, themes, systemTheme]);
|
|
94
|
+
return /* @__PURE__ */jsxs(ThemeSettingContext.Provider, {
|
|
95
|
+
value: contextValue,
|
|
96
|
+
children: [/* @__PURE__ */jsx(ThemeScript, {
|
|
97
|
+
forcedTheme,
|
|
98
|
+
storageKey,
|
|
99
|
+
systemTheme: resolvedTheme,
|
|
100
|
+
attribute,
|
|
101
|
+
value,
|
|
102
|
+
enableSystem,
|
|
103
|
+
defaultTheme,
|
|
104
|
+
attrs,
|
|
105
|
+
skipNextHead
|
|
106
|
+
}), useMemo(() => children, [children])]
|
|
107
|
+
});
|
|
108
|
+
}),
|
|
109
|
+
ThemeScript = memo(({
|
|
110
|
+
forcedTheme,
|
|
111
|
+
storageKey,
|
|
112
|
+
attribute,
|
|
113
|
+
enableSystem,
|
|
114
|
+
defaultTheme,
|
|
115
|
+
value,
|
|
116
|
+
attrs,
|
|
117
|
+
skipNextHead
|
|
118
|
+
}) => {
|
|
119
|
+
const optimization = attribute === "class" ? `var d=document.documentElement.classList;${attrs.map(t => `d.remove('${t}')`).join(";")};` : "var d=document.documentElement;",
|
|
120
|
+
updateDOM = (name, literal) => {
|
|
121
|
+
name = value?.[name] || name;
|
|
122
|
+
const val = literal ? name : `'${name}'`;
|
|
123
|
+
return attribute === "class" ? `d.add(${val})` : `d.setAttribute('${attribute}', ${val})`;
|
|
124
|
+
},
|
|
125
|
+
defaultSystem = defaultTheme === "system",
|
|
126
|
+
contents = /* @__PURE__ */jsx(Fragment, {
|
|
127
|
+
children: forcedTheme ? /* @__PURE__ */jsx("script", {
|
|
128
|
+
dangerouslySetInnerHTML: {
|
|
129
|
+
// These are minified via Terser and then updated by hand, don't recommend
|
|
130
|
+
__html: `!function(){${optimization}${updateDOM(forcedTheme)}}()`
|
|
131
|
+
}
|
|
132
|
+
}, "next-themes-script") : enableSystem ? /* @__PURE__ */jsx("script", {
|
|
133
|
+
dangerouslySetInnerHTML: {
|
|
134
|
+
__html: `!function(){try {${optimization}var e=localStorage.getItem('${storageKey}');${defaultSystem ? "" : updateDOM(defaultTheme) + ";"}if("system"===e||(!e&&${defaultSystem})){var t="${MEDIA}",m=window.matchMedia(t);m.media!==t||m.matches?${updateDOM("dark")}:${updateDOM("light")}}else if(e) ${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? "x[e]" : "e", !0)}}catch(e){}}()`
|
|
135
|
+
}
|
|
136
|
+
}, "next-themes-script") : /* @__PURE__ */jsx("script", {
|
|
137
|
+
dangerouslySetInnerHTML: {
|
|
138
|
+
__html: `!function(){try{${optimization}var e=localStorage.getItem("${storageKey}");if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? "x[e]" : "e", !0)}}else{${updateDOM(defaultTheme)};}}catch(t){}}();`
|
|
139
|
+
}
|
|
140
|
+
}, "next-themes-script")
|
|
141
|
+
});
|
|
142
|
+
return skipNextHead ? contents : /* @__PURE__ */jsx(NextHead, {
|
|
143
|
+
children: contents
|
|
144
|
+
});
|
|
145
|
+
}, (prevProps, nextProps) => prevProps.forcedTheme === nextProps.forcedTheme);
|
|
146
|
+
export { NextThemeProvider };
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MEDIA } from "./constants.mjs";
|
|
2
|
+
const helpers = {},
|
|
3
|
+
getTheme = (key, fallback) => {
|
|
4
|
+
if (typeof window > "u") return;
|
|
5
|
+
let theme;
|
|
6
|
+
try {
|
|
7
|
+
theme = localStorage.getItem(key) || void 0;
|
|
8
|
+
} catch {}
|
|
9
|
+
return theme || fallback;
|
|
10
|
+
},
|
|
11
|
+
getSystemTheme = e => (e || (e = window.matchMedia(MEDIA)), e.matches ? "dark" : "light");
|
|
12
|
+
export { getSystemTheme, getTheme, helpers };
|
|
File without changes
|
package/dist/esm/useRootTheme.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isClient } from "@tamagui/constants";
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
const useRootTheme = ({ fallback = "light" } = {}) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const classes = [...document.documentElement.classList]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, []), [val, setVal];
|
|
4
|
+
let initialVal = fallback;
|
|
5
|
+
if (isClient) {
|
|
6
|
+
const classes = [...document.documentElement.classList];
|
|
7
|
+
initialVal = classes.includes("t_dark") ? "dark" : classes.includes("t_light") ? "light" : fallback;
|
|
8
|
+
}
|
|
9
|
+
return useState(initialVal);
|
|
11
10
|
};
|
|
12
11
|
export {
|
|
13
12
|
useRootTheme
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AAIlB,MAAM,eAAe,CAAC,EAAE,WAAW,QAAQ,IAAgC,CAAC,MAAM;AACvF,MAAI,aAAa;AAEjB,MAAI,UAAU;AAEZ,UAAM,UAAU,CAAC,GAAG,SAAS,gBAAgB,SAAS;AACtD,iBAAa,QAAQ,SAAS,QAAQ,IAClC,SACA,QAAQ,SAAS,SAAS,IACxB,UACA;AAAA,EACR;AAEA,SAAO,SAAsB,UAAU;AACzC;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isClient } from "@tamagui/constants";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
const useRootTheme = ({
|
|
4
|
+
fallback = "light"
|
|
5
|
+
} = {}) => {
|
|
6
|
+
let initialVal = fallback;
|
|
7
|
+
if (isClient) {
|
|
8
|
+
const classes = [...document.documentElement.classList];
|
|
9
|
+
initialVal = classes.includes("t_dark") ? "dark" : classes.includes("t_light") ? "light" : fallback;
|
|
10
|
+
}
|
|
11
|
+
return useState(initialVal);
|
|
12
|
+
};
|
|
13
|
+
export { useRootTheme };
|
|
@@ -20,13 +20,12 @@ __export(useRootTheme_exports, {
|
|
|
20
20
|
module.exports = __toCommonJS(useRootTheme_exports);
|
|
21
21
|
var import_constants = require("@tamagui/constants"), import_react = require("react");
|
|
22
22
|
const useRootTheme = ({ fallback = "light" } = {}) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const classes = [...document.documentElement.classList]
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, []), [val, setVal];
|
|
23
|
+
let initialVal = fallback;
|
|
24
|
+
if (import_constants.isClient) {
|
|
25
|
+
const classes = [...document.documentElement.classList];
|
|
26
|
+
initialVal = classes.includes("t_dark") ? "dark" : classes.includes("t_light") ? "light" : fallback;
|
|
27
|
+
}
|
|
28
|
+
return (0, import_react.useState)(initialVal);
|
|
30
29
|
};
|
|
31
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
31
|
0 && (module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB,+BACzB,eAAyB;AAIlB,MAAM,eAAe,CAAC,EAAE,WAAW,QAAQ,IAAgC,CAAC,MAAM;AACvF,MAAI,aAAa;AAEjB,MAAI,2BAAU;AAEZ,UAAM,UAAU,CAAC,GAAG,SAAS,gBAAgB,SAAS;AACtD,iBAAa,QAAQ,SAAS,QAAQ,IAClC,SACA,QAAQ,SAAS,SAAS,IACxB,UACA;AAAA,EACR;AAEA,aAAO,uBAAsB,UAAU;AACzC;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-theme",
|
|
3
|
-
"version": "1.88.
|
|
3
|
+
"version": "1.88.14",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"clean:build": "tamagui-build clean:build"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tamagui/constants": "1.88.
|
|
24
|
-
"@tamagui/use-event": "1.88.
|
|
23
|
+
"@tamagui/constants": "1.88.14",
|
|
24
|
+
"@tamagui/use-event": "1.88.14"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "*"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@tamagui/build": "1.88.
|
|
30
|
+
"@tamagui/build": "1.88.14",
|
|
31
31
|
"react": "^18.2.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
@@ -7,8 +7,8 @@ import { memo, useEffect, useMemo, useState } from 'react'
|
|
|
7
7
|
import { MEDIA, colorSchemes } from './constants'
|
|
8
8
|
import { getSystemTheme, getTheme } from './helpers'
|
|
9
9
|
import { ThemeSettingContext } from './ThemeSettingContext'
|
|
10
|
-
import { ValueObject } from './types'
|
|
11
|
-
import { ThemeProviderProps, UseThemeProps } from './UseThemeProps'
|
|
10
|
+
import type { ValueObject } from './types'
|
|
11
|
+
import type { ThemeProviderProps, UseThemeProps } from './UseThemeProps'
|
|
12
12
|
|
|
13
13
|
export const NextThemeProvider = memo(
|
|
14
14
|
({
|
package/src/UseThemeProps.tsx
CHANGED
package/src/useRootTheme.tsx
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isClient } from '@tamagui/constants'
|
|
2
|
+
import { useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import { ColorScheme } from './types'
|
|
4
|
+
import type { ColorScheme } from './types'
|
|
5
5
|
|
|
6
6
|
export const useRootTheme = ({ fallback = 'light' }: { fallback?: ColorScheme } = {}) => {
|
|
7
|
-
|
|
7
|
+
let initialVal = fallback
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
if (isClient) {
|
|
10
10
|
// @ts-ignore
|
|
11
11
|
const classes = [...document.documentElement.classList]
|
|
12
|
-
|
|
13
|
-
const val: ColorScheme = classes.includes(`t_dark`)
|
|
12
|
+
initialVal = classes.includes(`t_dark`)
|
|
14
13
|
? 'dark'
|
|
15
14
|
: classes.includes(`t_light`)
|
|
16
15
|
? 'light'
|
|
17
16
|
: fallback
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
// you may regress some peoples apps
|
|
21
|
-
startTransition(() => {
|
|
22
|
-
setVal(val)
|
|
23
|
-
})
|
|
24
|
-
}, [])
|
|
25
|
-
|
|
26
|
-
return [val, setVal] as const
|
|
19
|
+
return useState<ColorScheme>(initialVal)
|
|
27
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ThemeProviderProps } from './UseThemeProps';
|
|
2
|
+
import type { ThemeProviderProps } from './UseThemeProps';
|
|
3
3
|
export declare const NextThemeProvider: React.MemoExoticComponent<({ forcedTheme, disableTransitionOnChange, enableSystem, enableColorScheme, storageKey, themes, defaultTheme, attribute, skipNextHead, onChangeTheme, value, children, }: ThemeProviderProps) => JSX.Element>;
|
|
4
4
|
//# sourceMappingURL=NextThemeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextThemeProvider.d.ts","sourceRoot":"","sources":["../src/NextThemeProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"NextThemeProvider.d.ts","sourceRoot":"","sources":["../src/NextThemeProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAA;AAExE,eAAO,MAAM,iBAAiB,sMAiBzB,kBAAkB,iBA+KtB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { UseThemeProps } from './UseThemeProps';
|
|
2
|
+
import type { UseThemeProps } from './UseThemeProps';
|
|
3
3
|
export declare const ThemeSettingContext: import("react").Context<UseThemeProps>;
|
|
4
4
|
//# sourceMappingURL=ThemeSettingContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeSettingContext.d.ts","sourceRoot":"","sources":["../src/ThemeSettingContext.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"ThemeSettingContext.d.ts","sourceRoot":"","sources":["../src/ThemeSettingContext.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,eAAO,MAAM,mBAAmB,wCAI9B,CAAA"}
|
package/types/UseThemeProps.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseThemeProps.d.ts","sourceRoot":"","sources":["../src/UseThemeProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"UseThemeProps.d.ts","sourceRoot":"","sources":["../src/UseThemeProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uBAAuB;IACvB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5B,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,uHAAuH;IACvH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4KAA4K;IAC5K,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,4HAA4H;IAC5H,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oFAAoF;IACpF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wDAAwD;IACxD,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,yHAAyH;IACzH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+HAA+H;IAC/H,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oJAAoJ;IACpJ,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC5B,yHAAyH;IACzH,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAGtC,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB"}
|
package/types/useRootTheme.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ColorScheme } from './types';
|
|
2
|
+
import type { ColorScheme } from './types';
|
|
3
3
|
export declare const useRootTheme: ({ fallback }?: {
|
|
4
4
|
fallback?: ColorScheme | undefined;
|
|
5
|
-
}) =>
|
|
5
|
+
}) => [ColorScheme, import("react").Dispatch<import("react").SetStateAction<ColorScheme>>];
|
|
6
6
|
//# sourceMappingURL=useRootTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRootTheme.d.ts","sourceRoot":"","sources":["../src/useRootTheme.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"useRootTheme.d.ts","sourceRoot":"","sources":["../src/useRootTheme.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,YAAY;;0FAcxB,CAAA"}
|