@tamagui/next-theme 2.0.0-rc.4 → 2.0.0-rc.40

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.
Files changed (70) hide show
  1. package/dist/cjs/NextTheme.cjs +7 -5
  2. package/dist/cjs/NextThemeProvider.cjs +197 -146
  3. package/dist/cjs/ThemeSettingContext.cjs +12 -10
  4. package/dist/cjs/UseThemeProps.cjs +7 -5
  5. package/dist/cjs/constants.cjs +15 -13
  6. package/dist/cjs/helpers.cjs +29 -20
  7. package/dist/cjs/index.cjs +7 -5
  8. package/dist/cjs/types.cjs +7 -5
  9. package/dist/cjs/useRootTheme.cjs +14 -12
  10. package/dist/cjs/useTheme.cjs +16 -14
  11. package/dist/esm/NextThemeProvider.mjs +164 -115
  12. package/dist/esm/NextThemeProvider.mjs.map +1 -1
  13. package/dist/esm/constants.mjs +3 -3
  14. package/dist/esm/constants.mjs.map +1 -1
  15. package/dist/esm/helpers.mjs +17 -10
  16. package/dist/esm/helpers.mjs.map +1 -1
  17. package/dist/esm/index.js +2 -2
  18. package/dist/esm/index.js.map +1 -6
  19. package/dist/esm/useTheme.mjs +2 -2
  20. package/dist/esm/useTheme.mjs.map +1 -1
  21. package/package.json +5 -4
  22. package/src/NextThemeProvider.tsx +3 -3
  23. package/types/NextTheme.d.ts.map +2 -2
  24. package/types/NextThemeProvider.d.ts.map +5 -7
  25. package/types/ThemeSettingContext.d.ts.map +4 -6
  26. package/types/UseThemeProps.d.ts.map +2 -2
  27. package/types/constants.d.ts.map +2 -2
  28. package/types/helpers.d.ts.map +2 -2
  29. package/types/index.d.ts.map +2 -2
  30. package/types/types.d.ts.map +2 -2
  31. package/types/useRootTheme.d.ts.map +2 -2
  32. package/types/useTheme.d.ts.map +2 -2
  33. package/dist/cjs/NextTheme.js +0 -22
  34. package/dist/cjs/NextTheme.js.map +0 -6
  35. package/dist/cjs/NextThemeProvider.js +0 -178
  36. package/dist/cjs/NextThemeProvider.js.map +0 -6
  37. package/dist/cjs/ThemeSettingContext.js +0 -28
  38. package/dist/cjs/ThemeSettingContext.js.map +0 -6
  39. package/dist/cjs/UseThemeProps.js +0 -14
  40. package/dist/cjs/UseThemeProps.js.map +0 -6
  41. package/dist/cjs/constants.js +0 -23
  42. package/dist/cjs/constants.js.map +0 -6
  43. package/dist/cjs/helpers.js +0 -32
  44. package/dist/cjs/helpers.js.map +0 -6
  45. package/dist/cjs/index.js +0 -16
  46. package/dist/cjs/index.js.map +0 -6
  47. package/dist/cjs/types.js +0 -14
  48. package/dist/cjs/types.js.map +0 -6
  49. package/dist/cjs/useRootTheme.js +0 -29
  50. package/dist/cjs/useRootTheme.js.map +0 -6
  51. package/dist/cjs/useTheme.js +0 -23
  52. package/dist/cjs/useTheme.js.map +0 -6
  53. package/dist/esm/NextTheme.js +0 -9
  54. package/dist/esm/NextTheme.js.map +0 -6
  55. package/dist/esm/NextThemeProvider.js +0 -162
  56. package/dist/esm/NextThemeProvider.js.map +0 -6
  57. package/dist/esm/ThemeSettingContext.js +0 -12
  58. package/dist/esm/ThemeSettingContext.js.map +0 -6
  59. package/dist/esm/UseThemeProps.js +0 -1
  60. package/dist/esm/UseThemeProps.js.map +0 -6
  61. package/dist/esm/constants.js +0 -7
  62. package/dist/esm/constants.js.map +0 -6
  63. package/dist/esm/helpers.js +0 -16
  64. package/dist/esm/helpers.js.map +0 -6
  65. package/dist/esm/types.js +0 -1
  66. package/dist/esm/types.js.map +0 -6
  67. package/dist/esm/useRootTheme.js +0 -14
  68. package/dist/esm/useRootTheme.js.map +0 -6
  69. package/dist/esm/useTheme.js +0 -8
  70. package/dist/esm/useTheme.js.map +0 -6
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
7
8
  get: () => from[key],
8
9
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
10
  });
10
- return to;
11
- },
12
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
15
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
- value: !0
16
+ value: true
15
17
  }), mod);
16
18
  var NextTheme_exports = {};
17
19
  module.exports = __toCommonJS(NextTheme_exports);
@@ -2,134 +2,169 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var NextThemeProvider_exports = {};
33
35
  __export(NextThemeProvider_exports, {
34
36
  NextThemeProvider: () => NextThemeProvider
35
37
  });
36
38
  module.exports = __toCommonJS(NextThemeProvider_exports);
37
- var import_constants = require("@tamagui/constants"),
38
- import_use_event = require("@tamagui/use-event"),
39
- import_script = __toESM(require("next/script"), 1),
40
- React = __toESM(require("react"), 1),
41
- import_react = require("react"),
42
- import_constants2 = require("./constants.cjs"),
43
- import_helpers = require("./helpers.cjs"),
44
- import_ThemeSettingContext = require("./ThemeSettingContext.cjs"),
45
- import_jsx_runtime = require("react/jsx-runtime");
39
+ var import_constants = require("@tamagui/constants");
40
+ var import_use_event = require("@tamagui/use-event");
41
+ var import_script = __toESM(require("next/script"), 1);
42
+ var React = __toESM(require("react"), 1);
43
+ var import_react = require("react");
44
+ var import_constants2 = require("./constants.cjs");
45
+ var import_helpers = require("./helpers.cjs");
46
+ var import_ThemeSettingContext = require("./ThemeSettingContext.cjs");
47
+ var import_jsx_runtime = require("react/jsx-runtime");
46
48
  const NextThemeProvider = (0, import_react.memo)(({
47
- forcedTheme,
48
- disableTransitionOnChange = !1,
49
- enableSystem = !0,
50
- enableColorScheme = !0,
51
- storageKey = "theme",
52
- themes = import_constants2.colorSchemes,
53
- defaultTheme = enableSystem ? "system" : "light",
54
- attribute = "class",
55
- skipNextHead,
56
- onChangeTheme,
57
- value = {
58
- dark: "t_dark",
59
- light: "t_light"
60
- },
61
- children
62
- }) => {
63
- const [theme, setThemeState] = (0, import_react.useState)(() => (0, import_helpers.getTheme)(storageKey, defaultTheme)),
64
- [resolvedTheme, setResolvedTheme] = (0, import_react.useState)(() => (0, import_helpers.getTheme)(storageKey)),
65
- attrs = value ? Object.values(value) : themes,
66
- handleMediaQuery = (0, import_use_event.useEvent)(e => {
67
- const _ = (0, import_helpers.getSystemTheme)(e),
68
- update = () => setResolvedTheme(_);
69
- disableTransitionOnChange ? update() : React.startTransition(() => update()), theme === "system" && !forcedTheme && handleChangeTheme(_, !1);
70
- }),
71
- handleChangeTheme = (0, import_use_event.useEvent)((theme2, updateStorage = !0, updateDOM = !0) => {
72
- let name = value?.[theme2] || theme2;
73
- if (updateStorage) try {
74
- localStorage.setItem(storageKey, theme2);
75
- } catch {}
76
- if (theme2 === "system" && enableSystem) {
77
- const resolved = (0, import_helpers.getSystemTheme)();
78
- name = value?.[resolved] || resolved;
79
- }
80
- if (onChangeTheme?.(name.replace("t_", "")), updateDOM) {
81
- const d = document.documentElement;
82
- attribute === "class" ? (d.classList.remove(...attrs), d.classList.add(name)) : d.setAttribute(attribute, name);
83
- }
84
- });
85
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
86
- const media = window.matchMedia(import_constants2.MEDIA);
87
- return media.addListener(handleMediaQuery), handleMediaQuery(media), () => {
88
- media.removeListener(handleMediaQuery);
89
- };
90
- }, []);
91
- const set = (0, import_use_event.useEvent)(newTheme => {
92
- forcedTheme ? handleChangeTheme(newTheme, !0, !1) : handleChangeTheme(newTheme), setThemeState(newTheme);
93
- });
94
- (0, import_react.useEffect)(() => {
95
- const handleStorage = e => {
96
- if (e.key !== storageKey) return;
97
- const theme2 = e.newValue || defaultTheme;
98
- set(theme2);
99
- };
100
- return window.addEventListener("storage", handleStorage), () => {
101
- window.removeEventListener("storage", handleStorage);
102
- };
103
- }, [defaultTheme, set, storageKey]), (0, import_constants.useIsomorphicLayoutEffect)(() => {
104
- if (!enableColorScheme) return;
105
- const colorScheme =
106
- // If theme is forced to light or dark, use that
107
- forcedTheme && import_constants2.colorSchemes.includes(forcedTheme) ? forcedTheme :
108
- // If regular theme is light or dark
109
- theme && import_constants2.colorSchemes.includes(theme) ? theme :
110
- // If theme is system, use the resolved version
111
- theme === "system" && resolvedTheme || null;
112
- (typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") !== (colorScheme || "light") && document.documentElement.style.setProperty("color-scheme", colorScheme);
113
- }, [enableColorScheme, theme, resolvedTheme, forcedTheme]);
114
- const toggle = (0, import_use_event.useEvent)(() => {
115
- const order = resolvedTheme === "dark" ? ["system", "light", "dark"] : ["system", "dark", "light"],
116
- next = order[(order.indexOf(theme) + 1) % order.length];
117
- set(next);
118
- }),
119
- systemTheme = enableSystem ? resolvedTheme : void 0,
120
- contextValue = (0, import_react.useMemo)(() => ({
121
- theme,
122
- current: theme,
123
- set,
124
- toggle,
125
- forcedTheme,
126
- resolvedTheme: theme === "system" ? resolvedTheme : theme,
127
- themes: enableSystem ? [...themes, "system"] : themes,
128
- systemTheme
129
- }), [theme, set, toggle, forcedTheme, resolvedTheme, enableSystem, themes, systemTheme]);
130
- return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_ThemeSettingContext.ThemeSettingContext.Provider, {
131
- value: contextValue,
132
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ThemeScript, {
49
+ forcedTheme,
50
+ disableTransitionOnChange = false,
51
+ enableSystem = true,
52
+ enableColorScheme = true,
53
+ storageKey = "theme",
54
+ themes = import_constants2.colorSchemes,
55
+ defaultTheme = enableSystem ? "system" : "light",
56
+ attribute = "class",
57
+ skipNextHead,
58
+ onChangeTheme,
59
+ value = {
60
+ dark: "t_dark",
61
+ light: "t_light"
62
+ },
63
+ children
64
+ }) => {
65
+ const [theme, setThemeState] = (0, import_react.useState)(() => (0, import_helpers.getTheme)(storageKey, defaultTheme));
66
+ const [resolvedTheme, setResolvedTheme] = (0, import_react.useState)(() => (0, import_helpers.getTheme)(storageKey));
67
+ const attrs = !value ? themes : Object.values(value);
68
+ const handleMediaQuery = (0, import_use_event.useEvent)(e => {
69
+ const _ = (0, import_helpers.getSystemTheme)(e);
70
+ const update = () => setResolvedTheme(_);
71
+ if (disableTransitionOnChange) {
72
+ update();
73
+ } else {
74
+ React.startTransition(() => update());
75
+ }
76
+ if (theme === "system" && !forcedTheme) {
77
+ handleChangeTheme(_, false);
78
+ }
79
+ });
80
+ const handleChangeTheme = (0, import_use_event.useEvent)((theme2, updateStorage = true, updateDOM = true) => {
81
+ let name = value?.[theme2] || theme2;
82
+ if (updateStorage) {
83
+ try {
84
+ localStorage.setItem(storageKey, theme2);
85
+ } catch (e) {}
86
+ }
87
+ if (theme2 === "system" && enableSystem) {
88
+ const resolved = (0, import_helpers.getSystemTheme)();
89
+ name = value?.[resolved] || resolved;
90
+ }
91
+ onChangeTheme?.(name.replace("t_", ""));
92
+ if (updateDOM) {
93
+ const d = document.documentElement;
94
+ if (attribute === "class") {
95
+ d.classList.remove(...attrs);
96
+ d.classList.add(name);
97
+ } else {
98
+ d.setAttribute(attribute, name);
99
+ }
100
+ }
101
+ });
102
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
103
+ const media = window.matchMedia(import_constants2.MEDIA);
104
+ media.addListener(handleMediaQuery);
105
+ handleMediaQuery(media);
106
+ return () => {
107
+ media.removeListener(handleMediaQuery);
108
+ };
109
+ }, []);
110
+ const set = (0, import_use_event.useEvent)(newTheme => {
111
+ if (forcedTheme) {
112
+ return;
113
+ }
114
+ handleChangeTheme(newTheme);
115
+ setThemeState(newTheme);
116
+ });
117
+ (0, import_react.useEffect)(() => {
118
+ const handleStorage = e => {
119
+ if (e.key !== storageKey) {
120
+ return;
121
+ }
122
+ const theme2 = e.newValue || defaultTheme;
123
+ set(theme2);
124
+ };
125
+ window.addEventListener("storage", handleStorage);
126
+ return () => {
127
+ window.removeEventListener("storage", handleStorage);
128
+ };
129
+ }, [defaultTheme, set, storageKey]);
130
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
131
+ if (!enableColorScheme) return;
132
+ const colorScheme =
133
+ // If theme is forced to light or dark, use that
134
+ forcedTheme && import_constants2.colorSchemes.includes(forcedTheme) ? forcedTheme :
135
+ // If regular theme is light or dark
136
+ theme && import_constants2.colorSchemes.includes(theme) ? theme :
137
+ // If theme is system, use the resolved version
138
+ theme === "system" ? resolvedTheme || null : null;
139
+ const userPrefers = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
140
+ const wePrefer = colorScheme || "light";
141
+ if (userPrefers !== wePrefer) {
142
+ document.documentElement.style.setProperty("color-scheme", colorScheme);
143
+ }
144
+ }, [enableColorScheme, theme, resolvedTheme, forcedTheme]);
145
+ const toggle = (0, import_use_event.useEvent)(() => {
146
+ const order = resolvedTheme === "dark" ? ["system", "light", "dark"] : ["system", "dark", "light"];
147
+ const next = order[(order.indexOf(theme) + 1) % order.length];
148
+ set(next);
149
+ });
150
+ const systemTheme = enableSystem ? resolvedTheme : void 0;
151
+ const contextValue = (0, import_react.useMemo)(() => {
152
+ const value2 = {
153
+ theme,
154
+ current: theme,
155
+ set,
156
+ toggle,
157
+ forcedTheme,
158
+ resolvedTheme: theme === "system" ? resolvedTheme : theme,
159
+ themes: enableSystem ? [...themes, "system"] : themes,
160
+ systemTheme
161
+ };
162
+ return value2;
163
+ }, [theme, set, toggle, forcedTheme, resolvedTheme, enableSystem, themes, systemTheme]);
164
+ return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_ThemeSettingContext.ThemeSettingContext.Provider, {
165
+ value: contextValue,
166
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(ThemeScript, {
167
+ ...{
133
168
  forcedTheme,
134
169
  storageKey,
135
170
  systemTheme: resolvedTheme,
@@ -139,36 +174,52 @@ const NextThemeProvider = (0, import_react.memo)(({
139
174
  defaultTheme,
140
175
  attrs,
141
176
  skipNextHead
142
- }), children]
143
- });
144
- }),
145
- ThemeScript = (0, import_react.memo)(({
146
- forcedTheme,
147
- storageKey,
148
- attribute,
149
- enableSystem,
150
- defaultTheme,
151
- value,
152
- attrs,
153
- skipNextHead
154
- }) => {
155
- const optimization = attribute === "class" ? `var d=document.documentElement.classList;${attrs.map(t => `d.remove('${t}')`).join(";")};` : "var d=document.documentElement;",
156
- updateDOM = (name, literal) => {
157
- name = value?.[name] || name;
158
- const val = literal ? name : `'${name}'`;
159
- return attribute === "class" ? `d.add(${val})` : `d.setAttribute('${attribute}', ${val})`;
160
- },
161
- defaultSystem = defaultTheme === "system",
162
- scriptContent = forcedTheme ? `!function(){${optimization}${updateDOM(forcedTheme)}}()` : enableSystem ? `!function(){try {${optimization}var e=localStorage.getItem('${storageKey}');if("system"===e||(!e&&${defaultSystem})){var t="${import_constants2.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)}}${defaultSystem ? "" : `else{${updateDOM(defaultTheme)}}`}}catch(e){}}()` : `!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){}}();`;
163
- return skipNextHead ? /* @__PURE__ */(0, import_jsx_runtime.jsx)("script", {
164
- dangerouslySetInnerHTML: {
165
- __html: scriptContent
166
177
  }
167
- }, "next-themes-script") : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_script.default, {
168
- id: "next-themes-script",
169
- strategy: "beforeInteractive",
178
+ }), children]
179
+ });
180
+ });
181
+ const ThemeScript = (0, import_react.memo)(({
182
+ forcedTheme,
183
+ storageKey,
184
+ attribute,
185
+ enableSystem,
186
+ defaultTheme,
187
+ value,
188
+ attrs,
189
+ skipNextHead
190
+ }) => {
191
+ const optimization = (() => {
192
+ if (attribute === "class") {
193
+ const removeClasses = attrs.map(t => `d.remove('${t}')`).join(";");
194
+ return `var d=document.documentElement.classList;${removeClasses};`;
195
+ }
196
+ return `var d=document.documentElement;`;
197
+ })();
198
+ const updateDOM = (name, literal) => {
199
+ name = value?.[name] || name;
200
+ const val = literal ? name : `'${name}'`;
201
+ if (attribute === "class") {
202
+ return `d.add(${val})`;
203
+ }
204
+ return `d.setAttribute('${attribute}', ${val})`;
205
+ };
206
+ const defaultSystem = defaultTheme === "system";
207
+ const scriptContent = forcedTheme ? `!function(){${optimization}${updateDOM(forcedTheme)}}()` : enableSystem ? `!function(){try {${optimization}var e=localStorage.getItem('${storageKey}');if("system"===e||(!e&&${defaultSystem})){var t="${import_constants2.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", true)}}${!defaultSystem ? `else{${updateDOM(defaultTheme)}}` : ""}}catch(e){}}()` : `!function(){try{${optimization}var e=localStorage.getItem("${storageKey}");if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? "x[e]" : "e", true)}}else{${updateDOM(defaultTheme)};}}catch(t){}}();`;
208
+ if (skipNextHead) {
209
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)("script", {
170
210
  dangerouslySetInnerHTML: {
171
211
  __html: scriptContent
172
212
  }
173
- });
174
- }, (prevProps, nextProps) => prevProps.forcedTheme === nextProps.forcedTheme);
213
+ }, "next-themes-script");
214
+ }
215
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_script.default, {
216
+ id: "next-themes-script",
217
+ strategy: "beforeInteractive",
218
+ dangerouslySetInnerHTML: {
219
+ __html: scriptContent
220
+ }
221
+ });
222
+ }, (prevProps, nextProps) => {
223
+ if (prevProps.forcedTheme !== nextProps.forcedTheme) return false;
224
+ return true;
225
+ });
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var ThemeSettingContext_exports = {};
22
24
  __export(ThemeSettingContext_exports, {
@@ -3,14 +3,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
- get: () => from[key],
8
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
- });
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
10
12
  return to;
11
13
  };
12
14
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
- value: !0
15
+ value: true
14
16
  }), mod);
15
17
  var UseThemeProps_exports = {};
16
18
  module.exports = __toCommonJS(UseThemeProps_exports);
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var constants_exports = {};
22
24
  __export(constants_exports, {
@@ -25,6 +27,6 @@ __export(constants_exports, {
25
27
  constants: () => constants
26
28
  });
27
29
  module.exports = __toCommonJS(constants_exports);
28
- const constants = {},
29
- colorSchemes = ["light", "dark"],
30
- MEDIA = "(prefers-color-scheme: dark)";
30
+ const constants = {};
31
+ const colorSchemes = ["light", "dark"];
32
+ const MEDIA = "(prefers-color-scheme: dark)";
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var helpers_exports = {};
22
24
  __export(helpers_exports, {
@@ -26,13 +28,20 @@ __export(helpers_exports, {
26
28
  });
27
29
  module.exports = __toCommonJS(helpers_exports);
28
30
  var import_constants = require("./constants.cjs");
29
- const helpers = {},
30
- getTheme = (key, fallback) => {
31
- if (typeof window > "u") return;
32
- let theme;
33
- try {
34
- theme = localStorage.getItem(key) || void 0;
35
- } catch {}
36
- return theme || fallback;
37
- },
38
- getSystemTheme = e => (e || (e = window.matchMedia(import_constants.MEDIA)), e.matches ? "dark" : "light");
31
+ const helpers = {};
32
+ const getTheme = (key, fallback) => {
33
+ if (typeof window === "undefined") return void 0;
34
+ let theme;
35
+ try {
36
+ theme = localStorage.getItem(key) || void 0;
37
+ } catch (e) {}
38
+ return theme || fallback;
39
+ };
40
+ const getSystemTheme = e => {
41
+ if (!e) {
42
+ e = window.matchMedia(import_constants.MEDIA);
43
+ }
44
+ const isDark = e.matches;
45
+ const systemTheme = isDark ? "dark" : "light";
46
+ return systemTheme;
47
+ };
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
7
8
  get: () => from[key],
8
9
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
10
  });
10
- return to;
11
- },
12
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
15
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
- value: !0
16
+ value: true
15
17
  }), mod);
16
18
  var index_exports = {};
17
19
  module.exports = __toCommonJS(index_exports);
@@ -3,14 +3,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
- get: () => from[key],
8
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
- });
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
10
12
  return to;
11
13
  };
12
14
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
- value: !0
15
+ value: true
14
16
  }), mod);
15
17
  var types_exports = {};
16
18
  module.exports = __toCommonJS(types_exports);