@tamagui/next-theme 1.13.2 → 1.13.4
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.js +1 -25
- package/dist/cjs/NextTheme.js.map +2 -2
- package/dist/cjs/NextThemeProvider.js +1 -266
- package/dist/cjs/NextThemeProvider.js.map +2 -2
- package/dist/cjs/ThemeSettingContext.js +1 -35
- package/dist/cjs/ThemeSettingContext.js.map +2 -2
- package/dist/cjs/UseThemeProps.js +1 -16
- package/dist/cjs/UseThemeProps.js.map +2 -2
- package/dist/cjs/constants.js +1 -34
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/helpers.js +1 -51
- package/dist/cjs/helpers.js.map +2 -2
- package/dist/cjs/index.js +1 -18
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +1 -16
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/useIsomorphicLayoutEffect.js +1 -29
- package/dist/cjs/useIsomorphicLayoutEffect.js.map +2 -2
- package/dist/cjs/useRootTheme.js +1 -52
- package/dist/cjs/useRootTheme.js.map +2 -2
- package/dist/cjs/useTheme.js +1 -33
- package/dist/cjs/useTheme.js.map +2 -2
- package/dist/esm/NextTheme.js +1 -8
- package/dist/esm/NextTheme.js.map +1 -1
- package/dist/esm/NextTheme.mjs +1 -8
- package/dist/esm/NextTheme.mjs.map +1 -1
- package/dist/esm/NextThemeProvider.js +1 -232
- package/dist/esm/NextThemeProvider.js.map +2 -2
- package/dist/esm/NextThemeProvider.mjs +1 -232
- package/dist/esm/NextThemeProvider.mjs.map +2 -2
- package/dist/esm/ThemeSettingContext.js +1 -11
- package/dist/esm/ThemeSettingContext.js.map +2 -2
- package/dist/esm/ThemeSettingContext.mjs +1 -11
- package/dist/esm/ThemeSettingContext.mjs.map +2 -2
- package/dist/esm/constants.js +1 -8
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/constants.mjs +1 -8
- package/dist/esm/constants.mjs.map +2 -2
- package/dist/esm/helpers.js +1 -25
- package/dist/esm/helpers.js.map +2 -2
- package/dist/esm/helpers.mjs +1 -25
- package/dist/esm/helpers.mjs.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/useIsomorphicLayoutEffect.js +1 -5
- package/dist/esm/useIsomorphicLayoutEffect.js.map +2 -2
- package/dist/esm/useIsomorphicLayoutEffect.mjs +1 -5
- package/dist/esm/useIsomorphicLayoutEffect.mjs.map +2 -2
- package/dist/esm/useRootTheme.js +1 -18
- package/dist/esm/useRootTheme.js.map +2 -2
- package/dist/esm/useRootTheme.mjs +1 -18
- package/dist/esm/useRootTheme.mjs.map +2 -2
- package/dist/esm/useTheme.js +1 -8
- package/dist/esm/useTheme.js.map +2 -2
- package/dist/esm/useTheme.mjs +1 -8
- package/dist/esm/useTheme.mjs.map +2 -2
- package/package.json +3 -3
package/dist/cjs/types.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
"use strict";var a=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var g=(t,e,i,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!c.call(t,r)&&r!==i&&a(t,r,{get:()=>e[r],enumerable:!(p=n(e,r))||p.enumerable});return t};var m=t=>g(a({},"__esModule",{value:!0}),t);var o={};module.exports=m(o);
|
|
17
2
|
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.tsx"],
|
|
4
4
|
"sourcesContent": ["export type types = {}\n\nexport interface ValueObject {\n [themeName: string]: string\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["types_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useIsomorphicLayoutEffect_exports = {};
|
|
20
|
-
__export(useIsomorphicLayoutEffect_exports, {
|
|
21
|
-
useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useIsomorphicLayoutEffect_exports);
|
|
24
|
-
var import_react = require("react");
|
|
25
|
-
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react.useLayoutEffect : import_react.useEffect;
|
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
-
0 && (module.exports = {
|
|
28
|
-
useIsomorphicLayoutEffect
|
|
29
|
-
});
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var r=(o,e)=>{for(var t in e)c(o,t,{get:e[t],enumerable:!0})},d=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of n(e))!p.call(o,f)&&f!==t&&c(o,f,{get:()=>e[f],enumerable:!(s=i(e,f))||s.enumerable});return o};var m=o=>d(c({},"__esModule",{value:!0}),o);var E={};r(E,{useIsomorphicLayoutEffect:()=>y});module.exports=m(E);var u=require("react");const y=typeof window<"u"?u.useLayoutEffect:u.useEffect;0&&(module.exports={useIsomorphicLayoutEffect});
|
|
30
2
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useIsomorphicLayoutEffect.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\n\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2C,iBAEpC,MAAMF,EACX,OAAO,OAAW,IAAc,kBAAkB",
|
|
6
|
+
"names": ["useIsomorphicLayoutEffect_exports", "__export", "useIsomorphicLayoutEffect", "__toCommonJS", "import_react"]
|
|
7
7
|
}
|
package/dist/cjs/useRootTheme.js
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
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", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var useRootTheme_exports = {};
|
|
30
|
-
__export(useRootTheme_exports, {
|
|
31
|
-
useRootTheme: () => useRootTheme
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(useRootTheme_exports);
|
|
34
|
-
var React = __toESM(require("react"));
|
|
35
|
-
var import_react = require("react");
|
|
36
|
-
const useRootTheme = () => {
|
|
37
|
-
const [val, setVal] = (0, import_react.useState)("light");
|
|
38
|
-
if (typeof document !== "undefined") {
|
|
39
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
40
|
-
const classes = [...document.documentElement.classList];
|
|
41
|
-
const isDark = classes.includes("t_dark");
|
|
42
|
-
React.startTransition(() => {
|
|
43
|
-
setVal(isDark ? "dark" : "light");
|
|
44
|
-
});
|
|
45
|
-
}, []);
|
|
46
|
-
}
|
|
47
|
-
return [val, setVal];
|
|
48
|
-
};
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
useRootTheme
|
|
52
|
-
});
|
|
1
|
+
"use strict";var i=Object.create;var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var f=(t,s)=>{for(var e in s)n(t,e,{get:s[e],enumerable:!0})},r=(t,s,e,a)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of l(s))!d.call(t,o)&&o!==e&&n(t,o,{get:()=>s[o],enumerable:!(a=u(s,o))||a.enumerable});return t};var p=(t,s,e)=>(e=t!=null?i(m(t)):{},r(s||!t||!t.__esModule?n(e,"default",{value:t,enumerable:!0}):e,t)),h=t=>r(n({},"__esModule",{value:!0}),t);var y={};f(y,{useRootTheme:()=>g});module.exports=h(y);var k=p(require("react")),c=require("react");const g=()=>{const[t,s]=(0,c.useState)("light");return typeof document<"u"&&(0,c.useLayoutEffect)(()=>{const a=[...document.documentElement.classList].includes("t_dark");k.startTransition(()=>{s(a?"dark":"light")})},[]),[t,s]};0&&(module.exports={useRootTheme});
|
|
53
2
|
//# sourceMappingURL=useRootTheme.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useRootTheme.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react'\nimport { useLayoutEffect, useState } from 'react'\n\n// note this only works for light being default for now...\n\nexport const useRootTheme = () => {\n const [val, setVal] = useState('light')\n\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n // @ts-ignore\n const classes = [...document.documentElement.classList]\n const isDark = classes.includes('t_dark')\n React.startTransition(() => {\n setVal(isDark ? 'dark' : 'light')\n })\n }, [])\n }\n\n return [val, setVal] as const\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAuB,oBACvBC,EAA0C,iBAInC,MAAMH,EAAe,IAAM,CAChC,KAAM,CAACI,EAAKC,CAAM,KAAI,YAAS,OAAO,EAEtC,OAAI,OAAO,SAAa,QACtB,mBAAgB,IAAM,CAGpB,MAAMC,EADU,CAAC,GAAG,SAAS,gBAAgB,SAAS,EAC/B,SAAS,QAAQ,EACxCJ,EAAM,gBAAgB,IAAM,CAC1BG,EAAOC,EAAS,OAAS,OAAO,CAClC,CAAC,CACH,EAAG,CAAC,CAAC,EAGA,CAACF,EAAKC,CAAM,CACrB",
|
|
6
|
+
"names": ["useRootTheme_exports", "__export", "useRootTheme", "__toCommonJS", "React", "import_react", "val", "setVal", "isDark"]
|
|
7
7
|
}
|
package/dist/cjs/useTheme.js
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useTheme_exports = {};
|
|
20
|
-
__export(useTheme_exports, {
|
|
21
|
-
useTheme: () => useTheme,
|
|
22
|
-
useThemeSetting: () => useThemeSetting
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useTheme_exports);
|
|
25
|
-
var import_react = require("react");
|
|
26
|
-
var import_ThemeSettingContext = require("./ThemeSettingContext");
|
|
27
|
-
const useTheme = () => (0, import_react.useContext)(import_ThemeSettingContext.ThemeSettingContext);
|
|
28
|
-
const useThemeSetting = () => (0, import_react.useContext)(import_ThemeSettingContext.ThemeSettingContext);
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
useTheme,
|
|
32
|
-
useThemeSetting
|
|
33
|
-
});
|
|
1
|
+
"use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var m in e)n(t,m,{get:e[m],enumerable:!0})},T=(t,e,m,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of x(e))!h.call(t,o)&&o!==m&&n(t,o,{get:()=>e[o],enumerable:!(i=p(e,o))||i.enumerable});return t};var c=t=>T(n({},"__esModule",{value:!0}),t);var C={};u(C,{useTheme:()=>f,useThemeSetting:()=>g});module.exports=c(C);var r=require("react"),s=require("./ThemeSettingContext");const f=()=>(0,r.useContext)(s.ThemeSettingContext),g=()=>(0,r.useContext)(s.ThemeSettingContext);0&&(module.exports={useTheme,useThemeSetting});
|
|
34
2
|
//# sourceMappingURL=useTheme.js.map
|
package/dist/cjs/useTheme.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useTheme.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useContext } from 'react'\n\nimport { ThemeSettingContext } from './ThemeSettingContext'\n\n/**\n * @deprecated renamed to `useThemeSetting` to avoid confusion with core `useTheme` hook\n */\n\nexport const useTheme = () => useContext(ThemeSettingContext)\n\nexport const useThemeSetting = () => useContext(ThemeSettingContext)\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAA2B,iBAE3BC,EAAoC,iCAM7B,MAAMJ,EAAW,OAAM,cAAW,qBAAmB,EAE/CC,EAAkB,OAAM,cAAW,qBAAmB",
|
|
6
|
+
"names": ["useTheme_exports", "__export", "useTheme", "useThemeSetting", "__toCommonJS", "import_react", "import_ThemeSettingContext"]
|
|
7
7
|
}
|
package/dist/esm/NextTheme.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export
|
|
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";
|
|
1
|
+
export*from"./NextThemeProvider";export*from"./ThemeSettingContext";export*from"./UseThemeProps";export*from"./helpers";export*from"./constants";export*from"./useTheme";export*from"./types";export*from"./useRootTheme";
|
|
9
2
|
//# sourceMappingURL=NextTheme.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/NextTheme.tsx"],
|
|
4
4
|
"sourcesContent": ["// https://raw.githubusercontent.com/pacocoursey/next-themes/master/index.tsx\n// forked temporarily\n\nexport * from './NextThemeProvider'\nexport * from './ThemeSettingContext'\nexport * from './UseThemeProps'\nexport * from './helpers'\nexport * from './constants'\nexport * from './useTheme'\nexport * from './types'\nexport * from './useRootTheme'\n"],
|
|
5
|
-
"mappings": "AAGA,
|
|
5
|
+
"mappings": "AAGA,WAAc,sBACd,WAAc,wBACd,WAAc,kBACd,WAAc,YACd,WAAc,cACd,WAAc,aACd,WAAc,UACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/NextTheme.mjs
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export
|
|
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";
|
|
1
|
+
export*from"./NextThemeProvider";export*from"./ThemeSettingContext";export*from"./UseThemeProps";export*from"./helpers";export*from"./constants";export*from"./useTheme";export*from"./types";export*from"./useRootTheme";
|
|
9
2
|
//# sourceMappingURL=NextTheme.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/NextTheme.tsx"],
|
|
4
4
|
"sourcesContent": ["// https://raw.githubusercontent.com/pacocoursey/next-themes/master/index.tsx\n// forked temporarily\n\nexport * from './NextThemeProvider'\nexport * from './ThemeSettingContext'\nexport * from './UseThemeProps'\nexport * from './helpers'\nexport * from './constants'\nexport * from './useTheme'\nexport * from './types'\nexport * from './useRootTheme'\n"],
|
|
5
|
-
"mappings": "AAGA,
|
|
5
|
+
"mappings": "AAGA,WAAc,sBACd,WAAc,wBACd,WAAc,kBACd,WAAc,YACd,WAAc,cACd,WAAc,aACd,WAAc,UACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,233 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEvent } from "@tamagui/use-event";
|
|
3
|
-
import NextHead from "next/head";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
-
import { MEDIA, colorSchemes } from "./constants";
|
|
7
|
-
import { getSystemTheme, getTheme } from "./helpers";
|
|
8
|
-
import { ThemeSettingContext } from "./ThemeSettingContext";
|
|
9
|
-
import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
10
|
-
const NextThemeProvider = ({
|
|
11
|
-
forcedTheme,
|
|
12
|
-
disableTransitionOnChange = true,
|
|
13
|
-
enableSystem = true,
|
|
14
|
-
enableColorScheme = true,
|
|
15
|
-
storageKey = "theme",
|
|
16
|
-
themes = colorSchemes,
|
|
17
|
-
defaultTheme = enableSystem ? "system" : "light",
|
|
18
|
-
attribute = "class",
|
|
19
|
-
skipNextHead,
|
|
20
|
-
onChangeTheme,
|
|
21
|
-
value = {
|
|
22
|
-
dark: "t_dark",
|
|
23
|
-
light: "t_light"
|
|
24
|
-
},
|
|
25
|
-
children
|
|
26
|
-
}) => {
|
|
27
|
-
const [theme, setThemeState] = useState(() => getTheme(storageKey, defaultTheme));
|
|
28
|
-
const [resolvedTheme, setResolvedTheme] = useState(() => getTheme(storageKey));
|
|
29
|
-
const attrs = !value ? themes : Object.values(value);
|
|
30
|
-
const handleMediaQuery = useEvent((e) => {
|
|
31
|
-
const systemTheme2 = getSystemTheme(e);
|
|
32
|
-
React.startTransition(() => {
|
|
33
|
-
setResolvedTheme(systemTheme2);
|
|
34
|
-
});
|
|
35
|
-
if (theme === "system" && !forcedTheme) {
|
|
36
|
-
handleChangeTheme(systemTheme2, false);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const mediaListener = useRef(handleMediaQuery);
|
|
40
|
-
mediaListener.current = handleMediaQuery;
|
|
41
|
-
const handleChangeTheme = useEvent((theme2, updateStorage = true, updateDOM = true) => {
|
|
42
|
-
let name = (value == null ? void 0 : value[theme2]) || theme2;
|
|
43
|
-
if (updateStorage) {
|
|
44
|
-
try {
|
|
45
|
-
localStorage.setItem(storageKey, theme2);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (theme2 === "system" && enableSystem) {
|
|
50
|
-
const resolved = getSystemTheme();
|
|
51
|
-
name = (value == null ? void 0 : value[resolved]) || resolved;
|
|
52
|
-
}
|
|
53
|
-
onChangeTheme == null ? void 0 : onChangeTheme(name.replace("t_", ""));
|
|
54
|
-
if (updateDOM) {
|
|
55
|
-
const d = document.documentElement;
|
|
56
|
-
if (attribute === "class") {
|
|
57
|
-
d.classList.remove(...attrs);
|
|
58
|
-
d.classList.add(name);
|
|
59
|
-
} else {
|
|
60
|
-
d.setAttribute(attribute, name);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
useIsomorphicLayoutEffect(() => {
|
|
65
|
-
const handler = (...args) => mediaListener.current(...args);
|
|
66
|
-
const media = window.matchMedia(MEDIA);
|
|
67
|
-
media.addListener(handler);
|
|
68
|
-
handler(media);
|
|
69
|
-
return () => {
|
|
70
|
-
media.removeListener(handler);
|
|
71
|
-
};
|
|
72
|
-
}, []);
|
|
73
|
-
const set = useEvent((newTheme) => {
|
|
74
|
-
if (forcedTheme) {
|
|
75
|
-
handleChangeTheme(newTheme, true, false);
|
|
76
|
-
} else {
|
|
77
|
-
handleChangeTheme(newTheme);
|
|
78
|
-
}
|
|
79
|
-
setThemeState(newTheme);
|
|
80
|
-
});
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
const handleStorage = (e) => {
|
|
83
|
-
if (e.key !== storageKey) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const theme2 = e.newValue || defaultTheme;
|
|
87
|
-
set(theme2);
|
|
88
|
-
};
|
|
89
|
-
window.addEventListener("storage", handleStorage);
|
|
90
|
-
return () => {
|
|
91
|
-
window.removeEventListener("storage", handleStorage);
|
|
92
|
-
};
|
|
93
|
-
}, [defaultTheme, set, storageKey]);
|
|
94
|
-
useIsomorphicLayoutEffect(() => {
|
|
95
|
-
if (!enableColorScheme)
|
|
96
|
-
return;
|
|
97
|
-
const colorScheme = (
|
|
98
|
-
// If theme is forced to light or dark, use that
|
|
99
|
-
forcedTheme && colorSchemes.includes(forcedTheme) ? forcedTheme : (
|
|
100
|
-
// If regular theme is light or dark
|
|
101
|
-
theme && colorSchemes.includes(theme) ? theme : (
|
|
102
|
-
// If theme is system, use the resolved version
|
|
103
|
-
theme === "system" ? resolvedTheme || null : null
|
|
104
|
-
)
|
|
105
|
-
)
|
|
106
|
-
);
|
|
107
|
-
const userPrefers = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
108
|
-
const wePrefer = colorScheme || "light";
|
|
109
|
-
if (userPrefers !== wePrefer || wePrefer === "dark") {
|
|
110
|
-
document.documentElement.style.setProperty("color-scheme", colorScheme);
|
|
111
|
-
}
|
|
112
|
-
}, [enableColorScheme, theme, resolvedTheme, forcedTheme]);
|
|
113
|
-
const toggle = useEvent(() => {
|
|
114
|
-
const order = resolvedTheme === "dark" ? ["system", "light", "dark"] : ["system", "dark", "light"];
|
|
115
|
-
const next = order[(order.indexOf(theme) + 1) % order.length];
|
|
116
|
-
set(next);
|
|
117
|
-
});
|
|
118
|
-
const contextResolvedTheme = theme === "system" ? resolvedTheme : theme;
|
|
119
|
-
const systemTheme = enableSystem ? resolvedTheme : void 0;
|
|
120
|
-
const contextValue = useMemo(() => {
|
|
121
|
-
const value2 = {
|
|
122
|
-
theme,
|
|
123
|
-
current: theme,
|
|
124
|
-
set,
|
|
125
|
-
toggle,
|
|
126
|
-
forcedTheme,
|
|
127
|
-
resolvedTheme: contextResolvedTheme,
|
|
128
|
-
themes: enableSystem ? [...themes, "system"] : themes,
|
|
129
|
-
systemTheme
|
|
130
|
-
};
|
|
131
|
-
return value2;
|
|
132
|
-
}, [
|
|
133
|
-
theme,
|
|
134
|
-
set,
|
|
135
|
-
toggle,
|
|
136
|
-
forcedTheme,
|
|
137
|
-
contextResolvedTheme,
|
|
138
|
-
enableSystem,
|
|
139
|
-
themes,
|
|
140
|
-
systemTheme
|
|
141
|
-
]);
|
|
142
|
-
return /* @__PURE__ */ jsxs(ThemeSettingContext.Provider, { value: contextValue, children: [
|
|
143
|
-
/* @__PURE__ */ jsx(
|
|
144
|
-
ThemeScript,
|
|
145
|
-
{
|
|
146
|
-
...{
|
|
147
|
-
forcedTheme,
|
|
148
|
-
storageKey,
|
|
149
|
-
systemTheme: resolvedTheme,
|
|
150
|
-
attribute,
|
|
151
|
-
value,
|
|
152
|
-
enableSystem,
|
|
153
|
-
defaultTheme,
|
|
154
|
-
attrs,
|
|
155
|
-
skipNextHead
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
useMemo(() => children, [children])
|
|
160
|
-
] });
|
|
161
|
-
};
|
|
162
|
-
const ThemeScript = memo(
|
|
163
|
-
({
|
|
164
|
-
forcedTheme,
|
|
165
|
-
storageKey,
|
|
166
|
-
attribute,
|
|
167
|
-
enableSystem,
|
|
168
|
-
defaultTheme,
|
|
169
|
-
value,
|
|
170
|
-
attrs,
|
|
171
|
-
skipNextHead
|
|
172
|
-
}) => {
|
|
173
|
-
const optimization = (() => {
|
|
174
|
-
if (attribute === "class") {
|
|
175
|
-
const removeClasses = attrs.map((t) => `d.remove('${t}')`).join(";");
|
|
176
|
-
return `var d=document.documentElement.classList;${removeClasses};`;
|
|
177
|
-
} else {
|
|
178
|
-
return `var d=document.documentElement;`;
|
|
179
|
-
}
|
|
180
|
-
})();
|
|
181
|
-
const updateDOM = (name, literal) => {
|
|
182
|
-
name = (value == null ? void 0 : value[name]) || name;
|
|
183
|
-
const val = literal ? name : `'${name}'`;
|
|
184
|
-
if (attribute === "class") {
|
|
185
|
-
return `d.add(${val})`;
|
|
186
|
-
}
|
|
187
|
-
return `d.setAttribute('${attribute}', ${val})`;
|
|
188
|
-
};
|
|
189
|
-
const defaultSystem = defaultTheme === "system";
|
|
190
|
-
const contents = /* @__PURE__ */ jsx(Fragment, { children: forcedTheme ? /* @__PURE__ */ jsx(
|
|
191
|
-
"script",
|
|
192
|
-
{
|
|
193
|
-
dangerouslySetInnerHTML: {
|
|
194
|
-
// These are minified via Terser and then updated by hand, don't recommend
|
|
195
|
-
__html: `!function(){${optimization}${updateDOM(forcedTheme)}}()`
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
"next-themes-script"
|
|
199
|
-
) : enableSystem ? /* @__PURE__ */ jsx(
|
|
200
|
-
"script",
|
|
201
|
-
{
|
|
202
|
-
dangerouslySetInnerHTML: {
|
|
203
|
-
__html: `!function(){try {${optimization}var e=localStorage.getItem('${storageKey}');${!defaultSystem ? updateDOM(defaultTheme) + ";" : ""}if("system"===e||(!e&&${defaultSystem})){var t="${MEDIA}",m=window.matchMedia(t);m.media!==t||m.matches?${updateDOM(
|
|
204
|
-
"dark"
|
|
205
|
-
)}:${updateDOM("light")}}else if(e) ${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? "x[e]" : "e", true)}}catch(e){}}()`
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
"next-themes-script"
|
|
209
|
-
) : /* @__PURE__ */ jsx(
|
|
210
|
-
"script",
|
|
211
|
-
{
|
|
212
|
-
dangerouslySetInnerHTML: {
|
|
213
|
-
__html: `!function(){try{${optimization}var e=localStorage.getItem("${storageKey}");if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? "x[e]" : "e", true)}}else{${updateDOM(
|
|
214
|
-
defaultTheme
|
|
215
|
-
)};}}catch(t){}}();`
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"next-themes-script"
|
|
219
|
-
) });
|
|
220
|
-
if (skipNextHead)
|
|
221
|
-
return contents;
|
|
222
|
-
return /* @__PURE__ */ jsx(NextHead, { children: contents });
|
|
223
|
-
},
|
|
224
|
-
(prevProps, nextProps) => {
|
|
225
|
-
if (prevProps.forcedTheme !== nextProps.forcedTheme)
|
|
226
|
-
return false;
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
export {
|
|
231
|
-
NextThemeProvider
|
|
232
|
-
};
|
|
1
|
+
import{Fragment as B,jsx as f,jsxs as q}from"react/jsx-runtime";import{useEvent as S}from"@tamagui/use-event";import D from"next/head";import*as J from"react";import{memo as U,useEffect as b,useMemo as T,useRef as z,useState as H}from"react";import{MEDIA as N,colorSchemes as P}from"./constants";import{getSystemTheme as R,getTheme as V}from"./helpers";import{ThemeSettingContext as F}from"./ThemeSettingContext";import{useIsomorphicLayoutEffect as j}from"./useIsomorphicLayoutEffect";const it=({forcedTheme:r,disableTransitionOnChange:h=!0,enableSystem:c=!0,enableColorScheme:k=!0,storageKey:m="theme",themes:n=P,defaultTheme:u=c?"system":"light",attribute:p="class",skipNextHead:g,onChangeTheme:i,value:o={dark:"t_dark",light:"t_light"},children:y})=>{const[e,$]=H(()=>V(m,u)),[d,A]=H(()=>V(m)),v=o?Object.values(o):n,E=S(t=>{const s=R(t);J.startTransition(()=>{A(s)}),e==="system"&&!r&&L(s,!1)}),M=z(E);M.current=E;const L=S((t,s=!0,a=!0)=>{let w=(o==null?void 0:o[t])||t;if(s)try{localStorage.setItem(m,t)}catch{}if(t==="system"&&c){const l=R();w=(o==null?void 0:o[l])||l}if(i==null||i(w.replace("t_","")),a){const l=document.documentElement;p==="class"?(l.classList.remove(...v),l.classList.add(w)):l.setAttribute(p,w)}});j(()=>{const t=(...a)=>M.current(...a),s=window.matchMedia(N);return s.addListener(t),t(s),()=>{s.removeListener(t)}},[]);const x=S(t=>{r?L(t,!0,!1):L(t),$(t)});b(()=>{const t=s=>{if(s.key!==m)return;const a=s.newValue||u;x(a)};return window.addEventListener("storage",t),()=>{window.removeEventListener("storage",t)}},[u,x,m]),j(()=>{if(!k)return;const t=r&&P.includes(r)?r:e&&P.includes(e)?e:e==="system"&&d||null,s=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",a=t||"light";(s!==a||a==="dark")&&document.documentElement.style.setProperty("color-scheme",t)},[k,e,d,r]);const _=S(()=>{const t=d==="dark"?["system","light","dark"]:["system","dark","light"],s=t[(t.indexOf(e)+1)%t.length];x(s)}),I=e==="system"?d:e,O=c?d:void 0,C=T(()=>({theme:e,current:e,set:x,toggle:_,forcedTheme:r,resolvedTheme:I,themes:c?[...n,"system"]:n,systemTheme:O}),[e,x,_,r,I,c,n,O]);return q(F.Provider,{value:C,children:[f(Q,{forcedTheme:r,storageKey:m,systemTheme:d,attribute:p,value:o,enableSystem:c,defaultTheme:u,attrs:v,skipNextHead:g}),T(()=>y,[y])]})},Q=U(({forcedTheme:r,storageKey:h,attribute:c,enableSystem:k,defaultTheme:m,value:n,attrs:u,skipNextHead:p})=>{const g=(()=>c==="class"?`var d=document.documentElement.classList;${u.map($=>`d.remove('${$}')`).join(";")};`:"var d=document.documentElement;")(),i=(e,$)=>{e=(n==null?void 0:n[e])||e;const d=$?e:`'${e}'`;return c==="class"?`d.add(${d})`:`d.setAttribute('${c}', ${d})`},o=m==="system",y=f(B,{children:r?f("script",{dangerouslySetInnerHTML:{__html:`!function(){${g}${i(r)}}()`}},"next-themes-script"):k?f("script",{dangerouslySetInnerHTML:{__html:`!function(){try {${g}var e=localStorage.getItem('${h}');${o?"":i(m)+";"}if("system"===e||(!e&&${o})){var t="${N}",m=window.matchMedia(t);m.media!==t||m.matches?${i("dark")}:${i("light")}}else if(e) ${n?`var x=${JSON.stringify(n)};`:""}${i(n?"x[e]":"e",!0)}}catch(e){}}()`}},"next-themes-script"):f("script",{dangerouslySetInnerHTML:{__html:`!function(){try{${g}var e=localStorage.getItem("${h}");if(e){${n?`var x=${JSON.stringify(n)};`:""}${i(n?"x[e]":"e",!0)}}else{${i(m)};}}catch(t){}}();`}},"next-themes-script")});return p?y:f(D,{children:y})},(r,h)=>r.forcedTheme===h.forcedTheme);export{it as NextThemeProvider};
|
|
233
2
|
//# sourceMappingURL=NextThemeProvider.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/NextThemeProvider.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useEvent } from '@tamagui/use-event'\nimport NextHead from 'next/head'\nimport * as React from 'react'\nimport { memo, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { MEDIA, colorSchemes } from './constants'\nimport { getSystemTheme, getTheme } from './helpers'\nimport { ThemeSettingContext } from './ThemeSettingContext'\nimport { ValueObject } from './types'\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'\nimport { ThemeProviderProps, UseThemeProps } from './UseThemeProps'\n\nexport const NextThemeProvider: React.FC<ThemeProviderProps> = ({\n forcedTheme,\n disableTransitionOnChange = true,\n enableSystem = true,\n enableColorScheme = true,\n storageKey = 'theme',\n themes = colorSchemes,\n defaultTheme = enableSystem ? 'system' : 'light',\n attribute = 'class',\n skipNextHead,\n onChangeTheme,\n value = {\n dark: 't_dark',\n light: 't_light',\n },\n children,\n}) => {\n const [theme, setThemeState] = useState(() => getTheme(storageKey, defaultTheme))\n const [resolvedTheme, setResolvedTheme] = useState(() => getTheme(storageKey))\n // const resolvedTheme = React.useDeferredValue(resolvedThemeFast)\n const attrs = !value ? themes : Object.values(value)\n\n const handleMediaQuery = useEvent((e?) => {\n const systemTheme = getSystemTheme(e)\n React.startTransition(() => {\n setResolvedTheme(systemTheme)\n })\n if (theme === 'system' && !forcedTheme) {\n handleChangeTheme(systemTheme, false)\n }\n })\n\n // Ref hack to avoid adding handleMediaQuery as a dep\n const mediaListener = useRef(handleMediaQuery)\n mediaListener.current = handleMediaQuery\n\n const handleChangeTheme = useEvent((theme, updateStorage = true, updateDOM = true) => {\n let name = value?.[theme] || theme\n\n if (updateStorage) {\n try {\n localStorage.setItem(storageKey, theme)\n } catch (e) {\n // Unsupported\n }\n }\n\n if (theme === 'system' && enableSystem) {\n const resolved = getSystemTheme()\n name = value?.[resolved] || resolved\n }\n\n onChangeTheme?.(name.replace('t_', ''))\n\n if (updateDOM) {\n const d = document.documentElement\n if (attribute === 'class') {\n d.classList.remove(...attrs)\n d.classList.add(name)\n } else {\n d.setAttribute(attribute, name)\n }\n }\n })\n\n useIsomorphicLayoutEffect(() => {\n const handler = (...args: any) => mediaListener.current(...args)\n // Always listen to System preference\n const media = window.matchMedia(MEDIA)\n // Intentionally use deprecated listener methods to support iOS & old browsers\n media.addListener(handler)\n handler(media)\n return () => {\n media.removeListener(handler)\n }\n }, [])\n\n const set = useEvent((newTheme) => {\n if (forcedTheme) {\n handleChangeTheme(newTheme, true, false)\n } else {\n handleChangeTheme(newTheme)\n }\n setThemeState(newTheme)\n })\n\n // localStorage event handling\n useEffect(() => {\n const handleStorage = (e: StorageEvent) => {\n if (e.key !== storageKey) {\n return\n }\n // If default theme set, use it if localstorage === null (happens on local storage manual deletion)\n const theme = e.newValue || defaultTheme\n set(theme)\n }\n window.addEventListener('storage', handleStorage)\n return () => {\n window.removeEventListener('storage', handleStorage)\n }\n }, [defaultTheme, set, storageKey])\n\n // color-scheme handling\n useIsomorphicLayoutEffect(() => {\n if (!enableColorScheme) return\n\n const colorScheme =\n // If theme is forced to light or dark, use that\n forcedTheme && colorSchemes.includes(forcedTheme)\n ? forcedTheme\n : // If regular theme is light or dark\n theme && colorSchemes.includes(theme)\n ? theme\n : // If theme is system, use the resolved version\n theme === 'system'\n ? resolvedTheme || null\n : null\n\n // color-scheme tells browser how to render built-in elements like forms, scrollbars, etc.\n // if color-scheme is null, this will remove the property\n const userPrefers =\n typeof window !== 'undefined' &&\n window.matchMedia &&\n window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light'\n\n const wePrefer = colorScheme || 'light'\n\n // avoid running this because it causes full page reflow\n if (userPrefers !== wePrefer || wePrefer === 'dark') {\n document.documentElement.style.setProperty('color-scheme', colorScheme)\n }\n }, [enableColorScheme, theme, resolvedTheme, forcedTheme])\n\n const toggle = useEvent(() => {\n const order =\n resolvedTheme === 'dark' ? ['system', 'light', 'dark'] : ['system', 'dark', 'light']\n const next = order[(order.indexOf(theme) + 1) % order.length]\n set(next)\n })\n\n const contextResolvedTheme = theme === 'system' ? resolvedTheme : theme\n const systemTheme = (enableSystem ? resolvedTheme : undefined) as\n | 'light'\n | 'dark'\n | undefined\n const contextValue = useMemo(() => {\n const value: UseThemeProps = {\n theme,\n current: theme,\n set,\n toggle,\n forcedTheme,\n resolvedTheme: contextResolvedTheme,\n themes: enableSystem ? [...themes, 'system'] : themes,\n systemTheme,\n } as const\n return value\n }, [\n theme,\n set,\n toggle,\n forcedTheme,\n contextResolvedTheme,\n enableSystem,\n themes,\n systemTheme,\n ])\n\n return (\n <ThemeSettingContext.Provider value={contextValue}>\n <ThemeScript\n {...{\n forcedTheme,\n storageKey,\n systemTheme: resolvedTheme,\n attribute,\n value,\n enableSystem,\n defaultTheme,\n attrs,\n skipNextHead,\n }}\n />\n {/* because on SSR we re-run and can avoid whole tree re-render */}\n {useMemo(() => children, [children])}\n </ThemeSettingContext.Provider>\n )\n}\nconst ThemeScript = memo(\n ({\n forcedTheme,\n storageKey,\n attribute,\n enableSystem,\n defaultTheme,\n value,\n attrs,\n skipNextHead,\n }: {\n forcedTheme?: string\n storageKey: string\n attribute?: string\n enableSystem?: boolean\n defaultTheme: string\n value?: ValueObject\n attrs: any\n skipNextHead?: boolean\n }) => {\n // Code-golfing the amount of characters in the script\n const optimization = (() => {\n if (attribute === 'class') {\n const removeClasses = attrs.map((t: string) => `d.remove('${t}')`).join(';')\n return `var d=document.documentElement.classList;${removeClasses};`\n } else {\n return `var d=document.documentElement;`\n }\n })()\n\n const updateDOM = (name: string, literal?: boolean) => {\n name = value?.[name] || name\n const val = literal ? name : `'${name}'`\n\n if (attribute === 'class') {\n return `d.add(${val})`\n }\n\n return `d.setAttribute('${attribute}', ${val})`\n }\n\n const defaultSystem = defaultTheme === 'system'\n\n const contents = (\n <>\n {forcedTheme ? (\n <script\n // nonce={nonce}\n key=\"next-themes-script\"\n dangerouslySetInnerHTML={{\n // These are minified via Terser and then updated by hand, don't recommend\n __html: `!function(){${optimization}${updateDOM(forcedTheme)}}()`,\n }}\n />\n ) : enableSystem ? (\n <script\n // nonce={nonce}\n key=\"next-themes-script\"\n dangerouslySetInnerHTML={{\n __html: `!function(){try {${optimization}var e=localStorage.getItem('${storageKey}');${\n !defaultSystem ? updateDOM(defaultTheme) + ';' : ''\n }if(\"system\"===e||(!e&&${defaultSystem})){var t=\"${MEDIA}\",m=window.matchMedia(t);m.media!==t||m.matches?${updateDOM(\n 'dark'\n )}:${updateDOM('light')}}else if(e) ${\n value ? `var x=${JSON.stringify(value)};` : ''\n }${updateDOM(value ? 'x[e]' : 'e', true)}}catch(e){}}()`,\n }}\n />\n ) : (\n <script\n // nonce={nonce}\n key=\"next-themes-script\"\n dangerouslySetInnerHTML={{\n __html: `!function(){try{${optimization}var e=localStorage.getItem(\"${storageKey}\");if(e){${\n value ? `var x=${JSON.stringify(value)};` : ''\n }${updateDOM(value ? 'x[e]' : 'e', true)}}else{${updateDOM(\n defaultTheme\n )};}}catch(t){}}();`,\n }}\n />\n )}\n </>\n )\n\n if (skipNextHead) return contents\n\n return <NextHead>{contents}</NextHead>\n },\n (prevProps, nextProps) => {\n // Only re-render when forcedTheme changes\n // the rest of the props should be completely stable\n if (prevProps.forcedTheme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,EACA,MAAAI,EACA,MAAAM,EACA,aAAAR,CACF,IASM,CAEJ,MAAMkC,GAAgB,IAChBnC,IAAc,QAET,4CADeS,EAAM,IAAK2B,GAAc,aAAaA,KAAK,EAAE,KAAK,GAAG,KAGpE,mCAER,EAEGpB,EAAY,CAACC,EAAcoB,IAAsB,CACrDpB,GAAOd,GAAA,YAAAA,EAAQc,KAASA,EACxB,MAAMqB,EAAMD,EAAUpB,EAAO,IAAIA,KAEjC,OAAIjB,IAAc,QACT,SAASsC,KAGX,mBAAmBtC,OAAesC,IAC3C,EAEMC,EAAgBxC,IAAiB,SAEjCyC,EACJhE,EAAAD,EAAA,CACG,SAAAkB,EACCjB,EAAC,UAGC,wBAAyB,CAEvB,OAAQ,eAAe2D,IAAenB,EAAUvB,CAAW,MAC7D,GAJI,oBAKN,EACEE,EACFnB,EAAC,UAGC,wBAAyB,CACvB,OAAQ,oBAAoB2D,gCAA2CtC,OACpE0C,EAAgD,GAAhCvB,EAAUjB,CAAY,EAAI,4BACpBwC,cAA0BrD,oDAAwD8B,EACzG,MACF,KAAKA,EAAU,OAAO,gBACpBb,EAAQ,SAAS,KAAK,UAAUA,CAAK,KAAO,KAC3Ca,EAAUb,EAAQ,OAAS,IAAK,EAAI,iBACzC,GATI,oBAUN,EAEA3B,EAAC,UAGC,wBAAyB,CACvB,OAAQ,mBAAmB2D,gCAA2CtC,aACpEM,EAAQ,SAAS,KAAK,UAAUA,CAAK,KAAO,KAC3Ca,EAAUb,EAAQ,OAAS,IAAK,EAAI,UAAUa,EAC/CjB,CACF,oBACF,GAPI,oBAQN,EAEJ,EAGF,OAAIE,EAAqBuC,EAElBhE,EAACG,EAAA,CAAU,SAAA6D,EAAS,CAC7B,EACA,CAACC,EAAWC,IAGND,EAAU,cAAgBC,EAAU,WAG5C",
|
|
6
|
+
"names": ["Fragment", "jsx", "jsxs", "useEvent", "NextHead", "React", "memo", "useEffect", "useMemo", "useRef", "useState", "MEDIA", "colorSchemes", "getSystemTheme", "getTheme", "ThemeSettingContext", "useIsomorphicLayoutEffect", "NextThemeProvider", "forcedTheme", "disableTransitionOnChange", "enableSystem", "enableColorScheme", "storageKey", "themes", "defaultTheme", "attribute", "skipNextHead", "onChangeTheme", "value", "children", "theme", "setThemeState", "resolvedTheme", "setResolvedTheme", "attrs", "handleMediaQuery", "e", "systemTheme", "handleChangeTheme", "mediaListener", "updateStorage", "updateDOM", "name", "resolved", "d", "handler", "args", "media", "set", "newTheme", "handleStorage", "colorScheme", "userPrefers", "wePrefer", "toggle", "order", "next", "contextResolvedTheme", "contextValue", "ThemeScript", "optimization", "t", "literal", "val", "defaultSystem", "contents", "prevProps", "nextProps"]
|
|
7
7
|
}
|