@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.
- package/dist/cjs/NextTheme.cjs +7 -5
- package/dist/cjs/NextThemeProvider.cjs +197 -146
- package/dist/cjs/ThemeSettingContext.cjs +12 -10
- package/dist/cjs/UseThemeProps.cjs +7 -5
- package/dist/cjs/constants.cjs +15 -13
- package/dist/cjs/helpers.cjs +29 -20
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/useRootTheme.cjs +14 -12
- package/dist/cjs/useTheme.cjs +16 -14
- package/dist/esm/NextThemeProvider.mjs +164 -115
- package/dist/esm/NextThemeProvider.mjs.map +1 -1
- package/dist/esm/constants.mjs +3 -3
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/helpers.mjs +17 -10
- package/dist/esm/helpers.mjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useTheme.mjs +2 -2
- package/dist/esm/useTheme.mjs.map +1 -1
- package/package.json +5 -4
- package/src/NextThemeProvider.tsx +3 -3
- package/types/NextTheme.d.ts.map +2 -2
- package/types/NextThemeProvider.d.ts.map +5 -7
- package/types/ThemeSettingContext.d.ts.map +4 -6
- package/types/UseThemeProps.d.ts.map +2 -2
- package/types/constants.d.ts.map +2 -2
- package/types/helpers.d.ts.map +2 -2
- package/types/index.d.ts.map +2 -2
- package/types/types.d.ts.map +2 -2
- package/types/useRootTheme.d.ts.map +2 -2
- package/types/useTheme.d.ts.map +2 -2
- package/dist/cjs/NextTheme.js +0 -22
- package/dist/cjs/NextTheme.js.map +0 -6
- package/dist/cjs/NextThemeProvider.js +0 -178
- package/dist/cjs/NextThemeProvider.js.map +0 -6
- package/dist/cjs/ThemeSettingContext.js +0 -28
- package/dist/cjs/ThemeSettingContext.js.map +0 -6
- package/dist/cjs/UseThemeProps.js +0 -14
- package/dist/cjs/UseThemeProps.js.map +0 -6
- package/dist/cjs/constants.js +0 -23
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/helpers.js +0 -32
- package/dist/cjs/helpers.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useRootTheme.js +0 -29
- package/dist/cjs/useRootTheme.js.map +0 -6
- package/dist/cjs/useTheme.js +0 -23
- package/dist/cjs/useTheme.js.map +0 -6
- package/dist/esm/NextTheme.js +0 -9
- package/dist/esm/NextTheme.js.map +0 -6
- package/dist/esm/NextThemeProvider.js +0 -162
- package/dist/esm/NextThemeProvider.js.map +0 -6
- package/dist/esm/ThemeSettingContext.js +0 -12
- package/dist/esm/ThemeSettingContext.js.map +0 -6
- package/dist/esm/UseThemeProps.js +0 -1
- package/dist/esm/UseThemeProps.js.map +0 -6
- package/dist/esm/constants.js +0 -7
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/helpers.js +0 -16
- package/dist/esm/helpers.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useRootTheme.js +0 -14
- package/dist/esm/useRootTheme.js.map +0 -6
- package/dist/esm/useTheme.js +0 -8
- package/dist/esm/useTheme.js.map +0 -6
package/dist/cjs/NextTheme.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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:
|
|
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
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
(
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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:
|
|
15
|
+
value: true
|
|
14
16
|
}), mod);
|
|
15
17
|
var UseThemeProps_exports = {};
|
|
16
18
|
module.exports = __toCommonJS(UseThemeProps_exports);
|
package/dist/cjs/constants.cjs
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
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
|
-
|
|
30
|
-
|
|
30
|
+
const constants = {};
|
|
31
|
+
const colorSchemes = ["light", "dark"];
|
|
32
|
+
const MEDIA = "(prefers-color-scheme: dark)";
|
package/dist/cjs/helpers.cjs
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
};
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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:
|
|
16
|
+
value: true
|
|
15
17
|
}), mod);
|
|
16
18
|
var index_exports = {};
|
|
17
19
|
module.exports = __toCommonJS(index_exports);
|
package/dist/cjs/types.cjs
CHANGED
|
@@ -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
|
|
7
|
-
|
|
8
|
-
|
|
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:
|
|
15
|
+
value: true
|
|
14
16
|
}), mod);
|
|
15
17
|
var types_exports = {};
|
|
16
18
|
module.exports = __toCommonJS(types_exports);
|