@tamagui/next-theme 2.0.0-rc.26 → 2.0.0-rc.26-1773452370596
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/package.json +4 -4
- 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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-theme",
|
|
3
|
-
"version": "2.0.0-rc.26",
|
|
3
|
+
"version": "2.0.0-rc.26-1773452370596",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"clean:build": "tamagui-build clean:build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tamagui/constants": "2.0.0-rc.26",
|
|
36
|
-
"@tamagui/use-event": "2.0.0-rc.26"
|
|
35
|
+
"@tamagui/constants": "2.0.0-rc.26-1773452370596",
|
|
36
|
+
"@tamagui/use-event": "2.0.0-rc.26-1773452370596"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@tamagui/build": "2.0.0-rc.26",
|
|
39
|
+
"@tamagui/build": "2.0.0-rc.26-1773452370596",
|
|
40
40
|
"next": "16.1.1",
|
|
41
41
|
"react": ">=19"
|
|
42
42
|
},
|
package/dist/cjs/NextTheme.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var NextTheme_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(NextTheme_exports);
|
|
14
|
-
__reExport(NextTheme_exports, require("./NextThemeProvider"), module.exports);
|
|
15
|
-
__reExport(NextTheme_exports, require("./ThemeSettingContext"), module.exports);
|
|
16
|
-
__reExport(NextTheme_exports, require("./UseThemeProps"), module.exports);
|
|
17
|
-
__reExport(NextTheme_exports, require("./helpers"), module.exports);
|
|
18
|
-
__reExport(NextTheme_exports, require("./constants"), module.exports);
|
|
19
|
-
__reExport(NextTheme_exports, require("./useTheme"), module.exports);
|
|
20
|
-
__reExport(NextTheme_exports, require("./types"), module.exports);
|
|
21
|
-
__reExport(NextTheme_exports, require("./useRootTheme"), module.exports);
|
|
22
|
-
//# sourceMappingURL=NextTheme.js.map
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var NextThemeProvider_exports = {};
|
|
24
|
-
__export(NextThemeProvider_exports, {
|
|
25
|
-
NextThemeProvider: () => NextThemeProvider
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(NextThemeProvider_exports);
|
|
28
|
-
var import_constants = require("@tamagui/constants"), import_use_event = require("@tamagui/use-event"), import_script = __toESM(require("next/script"), 1), React = __toESM(require("react"), 1), import_react = require("react"), import_constants2 = require("./constants"), import_helpers = require("./helpers"), import_ThemeSettingContext = require("./ThemeSettingContext"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
const NextThemeProvider = (0, import_react.memo)(
|
|
30
|
-
({
|
|
31
|
-
forcedTheme,
|
|
32
|
-
disableTransitionOnChange = !1,
|
|
33
|
-
enableSystem = !0,
|
|
34
|
-
enableColorScheme = !0,
|
|
35
|
-
storageKey = "theme",
|
|
36
|
-
themes = import_constants2.colorSchemes,
|
|
37
|
-
defaultTheme = enableSystem ? "system" : "light",
|
|
38
|
-
attribute = "class",
|
|
39
|
-
skipNextHead,
|
|
40
|
-
onChangeTheme,
|
|
41
|
-
value = {
|
|
42
|
-
dark: "t_dark",
|
|
43
|
-
light: "t_light"
|
|
44
|
-
},
|
|
45
|
-
children
|
|
46
|
-
}) => {
|
|
47
|
-
const [theme, setThemeState] = (0, import_react.useState)(() => (0, import_helpers.getTheme)(storageKey, defaultTheme)), [resolvedTheme, setResolvedTheme] = (0, import_react.useState)(() => (0, import_helpers.getTheme)(storageKey)), attrs = value ? Object.values(value) : themes, handleMediaQuery = (0, import_use_event.useEvent)((e) => {
|
|
48
|
-
const _ = (0, import_helpers.getSystemTheme)(e), update = () => setResolvedTheme(_);
|
|
49
|
-
disableTransitionOnChange ? update() : React.startTransition(() => update()), theme === "system" && !forcedTheme && handleChangeTheme(_, !1);
|
|
50
|
-
}), handleChangeTheme = (0, import_use_event.useEvent)(
|
|
51
|
-
(theme2, updateStorage = !0, updateDOM = !0) => {
|
|
52
|
-
let name = value?.[theme2] || theme2;
|
|
53
|
-
if (updateStorage)
|
|
54
|
-
try {
|
|
55
|
-
localStorage.setItem(storageKey, theme2);
|
|
56
|
-
} catch {
|
|
57
|
-
}
|
|
58
|
-
if (theme2 === "system" && enableSystem) {
|
|
59
|
-
const resolved = (0, import_helpers.getSystemTheme)();
|
|
60
|
-
name = value?.[resolved] || resolved;
|
|
61
|
-
}
|
|
62
|
-
if (onChangeTheme?.(name.replace("t_", "")), updateDOM) {
|
|
63
|
-
const d = document.documentElement;
|
|
64
|
-
attribute === "class" ? (d.classList.remove(...attrs), d.classList.add(name)) : d.setAttribute(attribute, name);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
69
|
-
const media = window.matchMedia(import_constants2.MEDIA);
|
|
70
|
-
return media.addListener(handleMediaQuery), handleMediaQuery(media), () => {
|
|
71
|
-
media.removeListener(handleMediaQuery);
|
|
72
|
-
};
|
|
73
|
-
}, []);
|
|
74
|
-
const set = (0, import_use_event.useEvent)((newTheme) => {
|
|
75
|
-
forcedTheme || (handleChangeTheme(newTheme), setThemeState(newTheme));
|
|
76
|
-
});
|
|
77
|
-
(0, import_react.useEffect)(() => {
|
|
78
|
-
const handleStorage = (e) => {
|
|
79
|
-
if (e.key !== storageKey)
|
|
80
|
-
return;
|
|
81
|
-
const theme2 = e.newValue || defaultTheme;
|
|
82
|
-
set(theme2);
|
|
83
|
-
};
|
|
84
|
-
return window.addEventListener("storage", handleStorage), () => {
|
|
85
|
-
window.removeEventListener("storage", handleStorage);
|
|
86
|
-
};
|
|
87
|
-
}, [defaultTheme, set, storageKey]), (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
88
|
-
if (!enableColorScheme) return;
|
|
89
|
-
const colorScheme = (
|
|
90
|
-
// If theme is forced to light or dark, use that
|
|
91
|
-
forcedTheme && import_constants2.colorSchemes.includes(forcedTheme) ? forcedTheme : (
|
|
92
|
-
// If regular theme is light or dark
|
|
93
|
-
theme && import_constants2.colorSchemes.includes(theme) ? theme : (
|
|
94
|
-
// If theme is system, use the resolved version
|
|
95
|
-
theme === "system" && resolvedTheme || null
|
|
96
|
-
)
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
(typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") !== (colorScheme || "light") && document.documentElement.style.setProperty("color-scheme", colorScheme);
|
|
100
|
-
}, [enableColorScheme, theme, resolvedTheme, forcedTheme]);
|
|
101
|
-
const toggle = (0, import_use_event.useEvent)(() => {
|
|
102
|
-
const order = resolvedTheme === "dark" ? ["system", "light", "dark"] : ["system", "dark", "light"], next = order[(order.indexOf(theme) + 1) % order.length];
|
|
103
|
-
set(next);
|
|
104
|
-
}), systemTheme = enableSystem ? resolvedTheme : void 0, contextValue = (0, import_react.useMemo)(() => ({
|
|
105
|
-
theme,
|
|
106
|
-
current: theme,
|
|
107
|
-
set,
|
|
108
|
-
toggle,
|
|
109
|
-
forcedTheme,
|
|
110
|
-
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
111
|
-
themes: enableSystem ? [...themes, "system"] : themes,
|
|
112
|
-
systemTheme
|
|
113
|
-
}), [
|
|
114
|
-
theme,
|
|
115
|
-
set,
|
|
116
|
-
toggle,
|
|
117
|
-
forcedTheme,
|
|
118
|
-
resolvedTheme,
|
|
119
|
-
enableSystem,
|
|
120
|
-
themes,
|
|
121
|
-
systemTheme
|
|
122
|
-
]);
|
|
123
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ThemeSettingContext.ThemeSettingContext.Provider, { value: contextValue, children: [
|
|
124
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
-
ThemeScript,
|
|
126
|
-
{
|
|
127
|
-
forcedTheme,
|
|
128
|
-
storageKey,
|
|
129
|
-
systemTheme: resolvedTheme,
|
|
130
|
-
attribute,
|
|
131
|
-
value,
|
|
132
|
-
enableSystem,
|
|
133
|
-
defaultTheme,
|
|
134
|
-
attrs,
|
|
135
|
-
skipNextHead
|
|
136
|
-
}
|
|
137
|
-
),
|
|
138
|
-
children
|
|
139
|
-
] });
|
|
140
|
-
}
|
|
141
|
-
), ThemeScript = (0, import_react.memo)(
|
|
142
|
-
({
|
|
143
|
-
forcedTheme,
|
|
144
|
-
storageKey,
|
|
145
|
-
attribute,
|
|
146
|
-
enableSystem,
|
|
147
|
-
defaultTheme,
|
|
148
|
-
value,
|
|
149
|
-
attrs,
|
|
150
|
-
skipNextHead
|
|
151
|
-
}) => {
|
|
152
|
-
const optimization = attribute === "class" ? `var d=document.documentElement.classList;${attrs.map((t) => `d.remove('${t}')`).join(";")};` : "var d=document.documentElement;", updateDOM = (name, literal) => {
|
|
153
|
-
name = value?.[name] || name;
|
|
154
|
-
const val = literal ? name : `'${name}'`;
|
|
155
|
-
return attribute === "class" ? `d.add(${val})` : `d.setAttribute('${attribute}', ${val})`;
|
|
156
|
-
}, defaultSystem = defaultTheme === "system", 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(
|
|
157
|
-
"dark"
|
|
158
|
-
)}:${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(
|
|
159
|
-
defaultTheme
|
|
160
|
-
)};}}catch(t){}}();`;
|
|
161
|
-
return skipNextHead ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
|
-
"script",
|
|
163
|
-
{
|
|
164
|
-
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
165
|
-
},
|
|
166
|
-
"next-themes-script"
|
|
167
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
-
import_script.default,
|
|
169
|
-
{
|
|
170
|
-
id: "next-themes-script",
|
|
171
|
-
strategy: "beforeInteractive",
|
|
172
|
-
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
},
|
|
176
|
-
(prevProps, nextProps) => prevProps.forcedTheme === nextProps.forcedTheme
|
|
177
|
-
);
|
|
178
|
-
//# sourceMappingURL=NextThemeProvider.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/NextThemeProvider.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C,+BAC1C,mBAAyB,+BACzB,gBAAmB,oCACnB,QAAuB,8BACvB,eAAmD,kBAEnDA,oBAAoC,wBACpC,iBAAyC,sBACzC,6BAAoC,kCAiL9B;AA7KC,MAAM,wBAAiE;AAAA,EAC5E,CAAC;AAAA,IACC;AAAA,IACA,4BAA4B;AAAA,IAC5B,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,aAAa;AAAA,IACb,SAAS;AAAA,IACT,eAAe,eAAe,WAAW;AAAA,IACzC,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,IACA;A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,MAC/C;AAAA,IACF,CAAC;AAGP,WAAI,eAEA;AAAA,MAAC;AAAA;AAAA,QAEC,yBAAyB,EAAE,QAAQ,cAAc;AAAA;AAAA,MAD7C;AAAA,IAEN,IAKF;AAAA,MAAC,cAAAC;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB,EAAE,QAAQ,cAAc;AAAA;AAAA,IACnD;AAAA,EAEJ;AAAA,EACA,CAAC,WAAW,cAGN,UAAU,gBAAgB,UAAU;AAG5C;",
|
|
5
|
-
"names": ["import_constants", "theme", "Script"]
|
|
6
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var ThemeSettingContext_exports = {};
|
|
16
|
-
__export(ThemeSettingContext_exports, {
|
|
17
|
-
ThemeSettingContext: () => ThemeSettingContext
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(ThemeSettingContext_exports);
|
|
20
|
-
var import_react = require("react");
|
|
21
|
-
const ThemeSettingContext = (0, import_react.createContext)({
|
|
22
|
-
toggle: () => {
|
|
23
|
-
},
|
|
24
|
-
set: (_) => {
|
|
25
|
-
},
|
|
26
|
-
themes: []
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=ThemeSettingContext.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/ThemeSettingContext.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAIrC,MAAM,0BAA8C,4BAA6B;AAAA,EACtF,QAAQ,MAAM;AAAA,EAAC;AAAA,EACf,KAAK,CAAC,MAAM;AAAA,EAAC;AAAA,EACb,QAAQ,CAAC;AACX,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
};
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var UseThemeProps_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(UseThemeProps_exports);
|
|
14
|
-
//# sourceMappingURL=UseThemeProps.js.map
|
package/dist/cjs/constants.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var constants_exports = {};
|
|
16
|
-
__export(constants_exports, {
|
|
17
|
-
MEDIA: () => MEDIA,
|
|
18
|
-
colorSchemes: () => colorSchemes,
|
|
19
|
-
constants: () => constants
|
|
20
|
-
});
|
|
21
|
-
module.exports = __toCommonJS(constants_exports);
|
|
22
|
-
const constants = {}, colorSchemes = ["light", "dark"], MEDIA = "(prefers-color-scheme: dark)";
|
|
23
|
-
//# sourceMappingURL=constants.js.map
|
package/dist/cjs/helpers.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var helpers_exports = {};
|
|
16
|
-
__export(helpers_exports, {
|
|
17
|
-
getSystemTheme: () => getSystemTheme,
|
|
18
|
-
getTheme: () => getTheme,
|
|
19
|
-
helpers: () => helpers
|
|
20
|
-
});
|
|
21
|
-
module.exports = __toCommonJS(helpers_exports);
|
|
22
|
-
var import_constants = require("./constants");
|
|
23
|
-
const helpers = {}, getTheme = (key, fallback) => {
|
|
24
|
-
if (typeof window > "u") return;
|
|
25
|
-
let theme;
|
|
26
|
-
try {
|
|
27
|
-
theme = localStorage.getItem(key) || void 0;
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
return theme || fallback;
|
|
31
|
-
}, getSystemTheme = (e) => (e || (e = window.matchMedia(import_constants.MEDIA)), e.matches ? "dark" : "light");
|
|
32
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/cjs/helpers.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AAEf,MAAM,UAAU,CAAC,GAGX,WAAW,CAAC,KAAa,aAA2B;AAC/D,MAAI,OAAO,SAAW,IAAa;AACnC,MAAI;AACJ,MAAI;AACF,YAAQ,aAAa,QAAQ,GAAG,KAAK;AAAA,EACvC,QAAY;AAAA,EAEZ;AACA,SAAO,SAAS;AAClB,GAEa,iBAAiB,CAAC,OACxB,MACH,IAAI,OAAO,WAAW,sBAAK,IAGd,EAAE,UACY,SAAS;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/cjs/types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
};
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var types_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(types_exports);
|
|
14
|
-
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
DELETED
package/dist/cjs/useRootTheme.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var useRootTheme_exports = {};
|
|
16
|
-
__export(useRootTheme_exports, {
|
|
17
|
-
useRootTheme: () => useRootTheme
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(useRootTheme_exports);
|
|
20
|
-
var import_react = require("react"), import_constants = require("@tamagui/constants");
|
|
21
|
-
const useRootTheme = ({ fallback = "light" } = {}) => {
|
|
22
|
-
let initialVal = fallback;
|
|
23
|
-
if (import_constants.isClient) {
|
|
24
|
-
const classes = document.documentElement.classList;
|
|
25
|
-
initialVal = classes.contains("t_dark") ? "dark" : classes.contains("t_light") ? "light" : fallback;
|
|
26
|
-
}
|
|
27
|
-
return (0, import_react.useState)(initialVal);
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=useRootTheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6D,kBAC7D,mBAAyB;AAIlB,MAAM,eAAe,CAAC,EAAE,WAAW,QAAQ,IAAgC,CAAC,MAG9E;AACH,MAAI,aAAa;AAEjB,MAAI,2BAAU;AACZ,UAAM,UAAU,SAAS,gBAAgB;AACzC,iBAAa,QAAQ,SAAS,QAAQ,IAClC,SACA,QAAQ,SAAS,SAAS,IACxB,UACA;AAAA,EACR;AAEA,aAAO,uBAAsB,UAAU;AACzC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/cjs/useTheme.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var useTheme_exports = {};
|
|
16
|
-
__export(useTheme_exports, {
|
|
17
|
-
useTheme: () => useTheme,
|
|
18
|
-
useThemeSetting: () => useThemeSetting
|
|
19
|
-
});
|
|
20
|
-
module.exports = __toCommonJS(useTheme_exports);
|
|
21
|
-
var import_react = require("react"), import_ThemeSettingContext = require("./ThemeSettingContext");
|
|
22
|
-
const useTheme = () => (0, import_react.useContext)(import_ThemeSettingContext.ThemeSettingContext), useThemeSetting = () => (0, import_react.useContext)(import_ThemeSettingContext.ThemeSettingContext);
|
|
23
|
-
//# sourceMappingURL=useTheme.js.map
|
package/dist/cjs/useTheme.js.map
DELETED
package/dist/esm/NextTheme.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./NextThemeProvider";
|
|
2
|
-
export * from "./ThemeSettingContext";
|
|
3
|
-
export * from "./UseThemeProps";
|
|
4
|
-
export * from "./helpers";
|
|
5
|
-
export * from "./constants";
|
|
6
|
-
export * from "./useTheme";
|
|
7
|
-
export * from "./types";
|
|
8
|
-
export * from "./useRootTheme";
|
|
9
|
-
//# sourceMappingURL=NextTheme.js.map
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
-
import { useEvent } from "@tamagui/use-event";
|
|
3
|
-
import Script from "next/script";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { memo, useEffect, useMemo, useState } from "react";
|
|
6
|
-
import { MEDIA, colorSchemes } from "./constants";
|
|
7
|
-
import { getSystemTheme, getTheme } from "./helpers";
|
|
8
|
-
import { ThemeSettingContext } from "./ThemeSettingContext";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
const NextThemeProvider = memo(
|
|
11
|
-
({
|
|
12
|
-
forcedTheme,
|
|
13
|
-
disableTransitionOnChange = !1,
|
|
14
|
-
enableSystem = !0,
|
|
15
|
-
enableColorScheme = !0,
|
|
16
|
-
storageKey = "theme",
|
|
17
|
-
themes = colorSchemes,
|
|
18
|
-
defaultTheme = enableSystem ? "system" : "light",
|
|
19
|
-
attribute = "class",
|
|
20
|
-
skipNextHead,
|
|
21
|
-
onChangeTheme,
|
|
22
|
-
value = {
|
|
23
|
-
dark: "t_dark",
|
|
24
|
-
light: "t_light"
|
|
25
|
-
},
|
|
26
|
-
children
|
|
27
|
-
}) => {
|
|
28
|
-
const [theme, setThemeState] = useState(() => getTheme(storageKey, defaultTheme)), [resolvedTheme, setResolvedTheme] = useState(() => getTheme(storageKey)), attrs = value ? Object.values(value) : themes, handleMediaQuery = useEvent((e) => {
|
|
29
|
-
const _ = getSystemTheme(e), update = () => setResolvedTheme(_);
|
|
30
|
-
disableTransitionOnChange ? update() : React.startTransition(() => update()), theme === "system" && !forcedTheme && handleChangeTheme(_, !1);
|
|
31
|
-
}), handleChangeTheme = useEvent(
|
|
32
|
-
(theme2, updateStorage = !0, updateDOM = !0) => {
|
|
33
|
-
let name = value?.[theme2] || theme2;
|
|
34
|
-
if (updateStorage)
|
|
35
|
-
try {
|
|
36
|
-
localStorage.setItem(storageKey, theme2);
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
if (theme2 === "system" && enableSystem) {
|
|
40
|
-
const resolved = getSystemTheme();
|
|
41
|
-
name = value?.[resolved] || resolved;
|
|
42
|
-
}
|
|
43
|
-
if (onChangeTheme?.(name.replace("t_", "")), updateDOM) {
|
|
44
|
-
const d = document.documentElement;
|
|
45
|
-
attribute === "class" ? (d.classList.remove(...attrs), d.classList.add(name)) : d.setAttribute(attribute, name);
|
|
46
|
-
}
|
|
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), setThemeState(newTheme));
|
|
57
|
-
});
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const handleStorage = (e) => {
|
|
60
|
-
if (e.key !== storageKey)
|
|
61
|
-
return;
|
|
62
|
-
const theme2 = e.newValue || defaultTheme;
|
|
63
|
-
set(theme2);
|
|
64
|
-
};
|
|
65
|
-
return window.addEventListener("storage", handleStorage), () => {
|
|
66
|
-
window.removeEventListener("storage", handleStorage);
|
|
67
|
-
};
|
|
68
|
-
}, [defaultTheme, set, storageKey]), useIsomorphicLayoutEffect(() => {
|
|
69
|
-
if (!enableColorScheme) return;
|
|
70
|
-
const colorScheme = (
|
|
71
|
-
// If theme is forced to light or dark, use that
|
|
72
|
-
forcedTheme && colorSchemes.includes(forcedTheme) ? forcedTheme : (
|
|
73
|
-
// If regular theme is light or dark
|
|
74
|
-
theme && colorSchemes.includes(theme) ? theme : (
|
|
75
|
-
// If theme is system, use the resolved version
|
|
76
|
-
theme === "system" && resolvedTheme || null
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
(typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") !== (colorScheme || "light") && document.documentElement.style.setProperty("color-scheme", colorScheme);
|
|
81
|
-
}, [enableColorScheme, theme, resolvedTheme, forcedTheme]);
|
|
82
|
-
const toggle = useEvent(() => {
|
|
83
|
-
const order = resolvedTheme === "dark" ? ["system", "light", "dark"] : ["system", "dark", "light"], next = order[(order.indexOf(theme) + 1) % order.length];
|
|
84
|
-
set(next);
|
|
85
|
-
}), systemTheme = enableSystem ? resolvedTheme : void 0, contextValue = useMemo(() => ({
|
|
86
|
-
theme,
|
|
87
|
-
current: theme,
|
|
88
|
-
set,
|
|
89
|
-
toggle,
|
|
90
|
-
forcedTheme,
|
|
91
|
-
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
92
|
-
themes: enableSystem ? [...themes, "system"] : themes,
|
|
93
|
-
systemTheme
|
|
94
|
-
}), [
|
|
95
|
-
theme,
|
|
96
|
-
set,
|
|
97
|
-
toggle,
|
|
98
|
-
forcedTheme,
|
|
99
|
-
resolvedTheme,
|
|
100
|
-
enableSystem,
|
|
101
|
-
themes,
|
|
102
|
-
systemTheme
|
|
103
|
-
]);
|
|
104
|
-
return /* @__PURE__ */ jsxs(ThemeSettingContext.Provider, { value: contextValue, children: [
|
|
105
|
-
/* @__PURE__ */ jsx(
|
|
106
|
-
ThemeScript,
|
|
107
|
-
{
|
|
108
|
-
forcedTheme,
|
|
109
|
-
storageKey,
|
|
110
|
-
systemTheme: resolvedTheme,
|
|
111
|
-
attribute,
|
|
112
|
-
value,
|
|
113
|
-
enableSystem,
|
|
114
|
-
defaultTheme,
|
|
115
|
-
attrs,
|
|
116
|
-
skipNextHead
|
|
117
|
-
}
|
|
118
|
-
),
|
|
119
|
-
children
|
|
120
|
-
] });
|
|
121
|
-
}
|
|
122
|
-
), ThemeScript = memo(
|
|
123
|
-
({
|
|
124
|
-
forcedTheme,
|
|
125
|
-
storageKey,
|
|
126
|
-
attribute,
|
|
127
|
-
enableSystem,
|
|
128
|
-
defaultTheme,
|
|
129
|
-
value,
|
|
130
|
-
attrs,
|
|
131
|
-
skipNextHead
|
|
132
|
-
}) => {
|
|
133
|
-
const optimization = attribute === "class" ? `var d=document.documentElement.classList;${attrs.map((t) => `d.remove('${t}')`).join(";")};` : "var d=document.documentElement;", updateDOM = (name, literal) => {
|
|
134
|
-
name = value?.[name] || name;
|
|
135
|
-
const val = literal ? name : `'${name}'`;
|
|
136
|
-
return attribute === "class" ? `d.add(${val})` : `d.setAttribute('${attribute}', ${val})`;
|
|
137
|
-
}, defaultSystem = defaultTheme === "system", scriptContent = forcedTheme ? `!function(){${optimization}${updateDOM(forcedTheme)}}()` : enableSystem ? `!function(){try {${optimization}var e=localStorage.getItem('${storageKey}');if("system"===e||(!e&&${defaultSystem})){var t="${MEDIA}",m=window.matchMedia(t);m.media!==t||m.matches?${updateDOM(
|
|
138
|
-
"dark"
|
|
139
|
-
)}:${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(
|
|
140
|
-
defaultTheme
|
|
141
|
-
)};}}catch(t){}}();`;
|
|
142
|
-
return skipNextHead ? /* @__PURE__ */ jsx(
|
|
143
|
-
"script",
|
|
144
|
-
{
|
|
145
|
-
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
146
|
-
},
|
|
147
|
-
"next-themes-script"
|
|
148
|
-
) : /* @__PURE__ */ jsx(
|
|
149
|
-
Script,
|
|
150
|
-
{
|
|
151
|
-
id: "next-themes-script",
|
|
152
|
-
strategy: "beforeInteractive",
|
|
153
|
-
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
},
|
|
157
|
-
(prevProps, nextProps) => prevProps.forcedTheme === nextProps.forcedTheme
|
|
158
|
-
);
|
|
159
|
-
export {
|
|
160
|
-
NextThemeProvider
|
|
161
|
-
};
|
|
162
|
-
//# sourceM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B,YAAM,MAAM,UAAU,OAAO,IAAI,IAAI;AAErC,aAAI,cAAc,UACT,SAAS,GAAG,MAGd,mBAAmB,SAAS,MAAM,GAAG;AAAA,IAC9C,GAEM,gBAAgB,iBAAiB,UAEjC,gBAAgB,cAClB,eAAe,YAAY,GAAG,UAAU,WAAW,CAAC,QACpD,eACE,oBAAoB,YAAY,+BAA+B,UAAU,4BAA4B,aAAa,aAAa,KAAK,mDAAmD;AAAA,MACrL;AAAA,IACF,CAAC,IAAI,UAAU,OAAO,CAAC,eACrB,QAAQ,SAAS,KAAK,UAAU,KAAK,CAAC,MAAM,EAC9C,GAAG,UAAU,QAAQ,SAAS,KAAK,EAAI,CAAC,IACrC,gBAAqD,KAArC,QAAQ,UAAU,YAAY,CAAC,GAClD,mBACA,mBAAmB,YAAY,+BAA+B,UAAU,YACtE,QAAQ,SAAS,KAAK,UAAU,KAAK,CAAC,MAAM,EAC9C,GAAG,UAAU,QAAQ,SAAS,KAAK,EAAI,CAAC,SAAS;AAAA,MAC/C;AAAA,IACF,CAAC;AAGP,WAAI,eAEA;AAAA,MAAC;AAAA;AAAA,QAEC,yBAAyB,EAAE,QAAQ,cAAc;AAAA;AAAA,MAD7C;AAAA,IAEN,IAKF;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QACH,UAAS;AAAA,QACT,yBAAyB,EAAE,QAAQ,cAAc;AAAA;AAAA,IACnD;AAAA,EAEJ;AAAA,EACA,CAAC,WAAW,cAGN,UAAU,gBAAgB,UAAU;AAG5C;",
|
|
5
|
-
"names": ["theme"]
|
|
6
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=UseThemeProps.js.map
|
package/dist/esm/constants.js
DELETED
package/dist/esm/helpers.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MEDIA } from "./constants";
|
|
2
|
-
const helpers = {}, getTheme = (key, fallback) => {
|
|
3
|
-
if (typeof window > "u") return;
|
|
4
|
-
let theme;
|
|
5
|
-
try {
|
|
6
|
-
theme = localStorage.getItem(key) || void 0;
|
|
7
|
-
} catch {
|
|
8
|
-
}
|
|
9
|
-
return theme || fallback;
|
|
10
|
-
}, getSystemTheme = (e) => (e || (e = window.matchMedia(MEDIA)), e.matches ? "dark" : "light");
|
|
11
|
-
export {
|
|
12
|
-
getSystemTheme,
|
|
13
|
-
getTheme,
|
|
14
|
-
helpers
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/esm/helpers.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,aAAa;AAEf,MAAM,UAAU,CAAC,GAGX,WAAW,CAAC,KAAa,aAA2B;AAC/D,MAAI,OAAO,SAAW,IAAa;AACnC,MAAI;AACJ,MAAI;AACF,YAAQ,aAAa,QAAQ,GAAG,KAAK;AAAA,EACvC,QAAY;AAAA,EAEZ;AACA,SAAO,SAAS;AAClB,GAEa,iBAAiB,CAAC,OACxB,MACH,IAAI,OAAO,WAAW,KAAK,IAGd,EAAE,UACY,SAAS;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/dist/esm/types.js.map
DELETED
package/dist/esm/useRootTheme.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { isClient } from "@tamagui/constants";
|
|
3
|
-
const useRootTheme = ({ fallback = "light" } = {}) => {
|
|
4
|
-
let initialVal = fallback;
|
|
5
|
-
if (isClient) {
|
|
6
|
-
const classes = document.documentElement.classList;
|
|
7
|
-
initialVal = classes.contains("t_dark") ? "dark" : classes.contains("t_light") ? "light" : fallback;
|
|
8
|
-
}
|
|
9
|
-
return useState(initialVal);
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
useRootTheme
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=useRootTheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,gBAAoD;AAC7D,SAAS,gBAAgB;AAIlB,MAAM,eAAe,CAAC,EAAE,WAAW,QAAQ,IAAgC,CAAC,MAG9E;AACH,MAAI,aAAa;AAEjB,MAAI,UAAU;AACZ,UAAM,UAAU,SAAS,gBAAgB;AACzC,iBAAa,QAAQ,SAAS,QAAQ,IAClC,SACA,QAAQ,SAAS,SAAS,IACxB,UACA;AAAA,EACR;AAEA,SAAO,SAAsB,UAAU;AACzC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/useTheme.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { ThemeSettingContext } from "./ThemeSettingContext";
|
|
3
|
-
const useTheme = () => useContext(ThemeSettingContext), useThemeSetting = () => useContext(ThemeSettingContext);
|
|
4
|
-
export {
|
|
5
|
-
useTheme,
|
|
6
|
-
useThemeSetting
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=useTheme.js.map
|