@tamagui/next-theme 2.0.0-rc.3 → 2.0.0-rc.30
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/NextThemeProvider.cjs +1 -1
- package/dist/cjs/index.js +12 -9
- package/dist/esm/NextThemeProvider.mjs +1 -1
- package/dist/esm/NextThemeProvider.mjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- 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/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
|
@@ -89,7 +89,7 @@ const NextThemeProvider = (0, import_react.memo)(({
|
|
|
89
89
|
};
|
|
90
90
|
}, []);
|
|
91
91
|
const set = (0, import_use_event.useEvent)(newTheme => {
|
|
92
|
-
forcedTheme
|
|
92
|
+
forcedTheme || (handleChangeTheme(newTheme), setThemeState(newTheme));
|
|
93
93
|
});
|
|
94
94
|
(0, import_react.useEffect)(() => {
|
|
95
95
|
const handleStorage = e => {
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,14 +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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
12
16
|
var index_exports = {};
|
|
13
17
|
module.exports = __toCommonJS(index_exports);
|
|
14
|
-
__reExport(index_exports, require("./NextTheme"), module.exports);
|
|
15
|
-
__reExport(index_exports, require("./types"), module.exports);
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
18
|
+
__reExport(index_exports, require("./NextTheme.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./types.cjs"), module.exports);
|
|
@@ -53,7 +53,7 @@ const NextThemeProvider = memo(({
|
|
|
53
53
|
};
|
|
54
54
|
}, []);
|
|
55
55
|
const set = useEvent(newTheme => {
|
|
56
|
-
forcedTheme
|
|
56
|
+
forcedTheme || (handleChangeTheme(newTheme), setThemeState(newTheme));
|
|
57
57
|
});
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
const handleStorage = e => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","useEvent","Script","React","memo","useEffect","useMemo","useState","MEDIA","colorSchemes","getSystemTheme","getTheme","ThemeSettingContext","jsx","jsxs","NextThemeProvider","forcedTheme","disableTransitionOnChange","enableSystem","enableColorScheme","storageKey","themes","defaultTheme","attribute","skipNextHead","onChangeTheme","value","dark","light","children","theme","setThemeState","resolvedTheme","setResolvedTheme","attrs","Object","values","handleMediaQuery","e","_","update","startTransition","handleChangeTheme","theme2","updateStorage","updateDOM","name","localStorage","setItem","resolved","replace","d","document","documentElement","classList","remove","add","setAttribute","media","window","matchMedia","addListener","removeListener","set","newTheme","handleStorage","key","newValue","addEventListener","removeEventListener","colorScheme","includes","matches","style","setProperty","toggle","order","next","indexOf","length","systemTheme","contextValue","current","Provider","ThemeScript","optimization","map","t","join","literal","val","defaultSystem","scriptContent","JSON","stringify","dangerouslySetInnerHTML","__html","id","strategy","prevProps","nextProps"],"sources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A,IACzB0B,iBAAA,CAAkBH,CAAA,EAAG,EAAK;MAE9B,CAAC;MAEKG,iBAAA,GAAoBzC,QAAA,CACxB,CAAC0C,MAAA,EAAOC,aAAA,GAAgB,IAAMC,SAAA,GAAY,OAAS;QACjD,IAAIC,IAAA,GAAOpB,KAAA,GAAQiB,MAAK,KAAKA,MAAA;QAE7B,IAAIC,aAAA,EACF,IAAI;UACFG,YAAA,CAAaC,OAAA,CAAQ5B,UAAA,EAAYuB,MAAK;QACxC,QAAY,CAEZ;QAGF,IAAIA,MAAA,KAAU,YAAYzB,YAAA,EAAc;UACtC,MAAM+B,QAAA,GAAWvC,cAAA,CAAe;UAChCoC,IAAA,GAAOpB,KAAA,GAAQuB,QAAQ,KAAKA,QAAA;QAC9B;QAIA,IAFAxB,aAAA,GAAgBqB,IAAA,CAAKI,OAAA,CAAQ,MAAM,EAAE,CAAC,GAElCL,SAAA,EAAW;UACb,MAAMM,CAAA,GAAIC,QAAA,CAASC,eAAA;UACf9B,SAAA,KAAc,WAChB4B,CAAA,CAAEG,SAAA,CAAUC,MAAA,CAAO,GAAGrB,KAAK,GAC3BiB,CAAA,CAAEG,SAAA,CAAUE,GAAA,CAAIV,IAAI,KAEpBK,CAAA,CAAEM,YAAA,CAAalC,SAAA,EAAWuB,IAAI;QAElC;MACF,CACF;IAEA9C,yBAAA,CAA0B,MAAM;MAE9B,MAAM0D,KAAA,GAAQC,MAAA,CAAOC,UAAA,CAAWpD,KAAK;MAErC,OAAAkD,KAAA,CAAMG,WAAA,CAAYxB,gBAAgB,GAClCA,gBAAA,CAAiBqB,KAAK,GACf,MAAM;QACXA,KAAA,CAAMI,cAAA,CAAezB,gBAAgB;MACvC;IACF,GAAG,EAAE;IAEL,MAAM0B,GAAA,GAAM9D,QAAA,CAAU+D,QAAA,IAAa;MAC7BhD,WAAA,
|
|
1
|
+
{"version":3,"names":["useIsomorphicLayoutEffect","useEvent","Script","React","memo","useEffect","useMemo","useState","MEDIA","colorSchemes","getSystemTheme","getTheme","ThemeSettingContext","jsx","jsxs","NextThemeProvider","forcedTheme","disableTransitionOnChange","enableSystem","enableColorScheme","storageKey","themes","defaultTheme","attribute","skipNextHead","onChangeTheme","value","dark","light","children","theme","setThemeState","resolvedTheme","setResolvedTheme","attrs","Object","values","handleMediaQuery","e","_","update","startTransition","handleChangeTheme","theme2","updateStorage","updateDOM","name","localStorage","setItem","resolved","replace","d","document","documentElement","classList","remove","add","setAttribute","media","window","matchMedia","addListener","removeListener","set","newTheme","handleStorage","key","newValue","addEventListener","removeEventListener","colorScheme","includes","matches","style","setProperty","toggle","order","next","indexOf","length","systemTheme","contextValue","current","Provider","ThemeScript","optimization","map","t","join","literal","val","defaultSystem","scriptContent","JSON","stringify","dangerouslySetInnerHTML","__html","id","strategy","prevProps","nextProps"],"sources":["../../src/NextThemeProvider.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,yBAAA,QAAiC;AAC1C,SAASC,QAAA,QAAgB;AACzB,OAAOC,MAAA,MAAY;AACnB,YAAYC,KAAA,MAAW;AACvB,SAASC,IAAA,EAAMC,SAAA,EAAWC,OAAA,EAASC,QAAA,QAAgB;AAEnD,SAASC,KAAA,EAAOC,YAAA,QAAoB;AACpC,SAASC,cAAA,EAAgBC,QAAA,QAAgB;AACzC,SAASC,mBAAA,QAA2B;AAiL9B,SACEC,GAAA,EADFC,IAAA;AA7KC,MAAMC,iBAAA,GAAiEX,IAAA,CAC5E,CAAC;IACCY,WAAA;IACAC,yBAAA,GAA4B;IAC5BC,YAAA,GAAe;IACfC,iBAAA,GAAoB;IACpBC,UAAA,GAAa;IACbC,MAAA,GAASZ,YAAA;IACTa,YAAA,GAAeJ,YAAA,GAAe,WAAW;IACzCK,SAAA,GAAY;IACZC,YAAA;IACAC,aAAA;IACAC,KAAA,GAAQ;MACNC,IAAA,EAAM;MACNC,KAAA,EAAO;IACT;IACAC;EACF,MAAM;IACJ,MAAM,CAACC,KAAA,EAAOC,aAAa,IAAIxB,QAAA,CAAS,M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,CAAC,SAASmB,SAAA,CAC/CvB,YACF,CAAC;IAGP,OAAIE,YAAA,GAEA,eAAAX,GAAA,CAAC;MAECkF,uBAAA,EAAyB;QAAEC,MAAA,EAAQJ;MAAc;IAAA,GAD7C,oBAEN,IAKF,eAAA/E,GAAA,CAACX,MAAA;MACC+F,EAAA,EAAG;MACHC,QAAA,EAAS;MACTH,uBAAA,EAAyB;QAAEC,MAAA,EAAQJ;MAAc;IAAA,CACnD;EAEJ,GACA,CAACO,SAAA,EAAWC,SAAA,KAGND,SAAA,CAAUnF,WAAA,KAAgBoF,SAAA,CAAUpF,WAG5C","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./NextTheme";
|
|
2
|
-
export * from "./types";
|
|
1
|
+
export * from "./NextTheme.mjs";
|
|
2
|
+
export * from "./types.mjs";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-theme",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.30",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./types/index.d.ts",
|
|
18
|
+
"browser": "./dist/esm/index.mjs",
|
|
18
19
|
"module": "./dist/esm/index.mjs",
|
|
19
20
|
"import": "./dist/esm/index.mjs",
|
|
20
21
|
"require": "./dist/cjs/index.cjs",
|
|
@@ -31,11 +32,11 @@
|
|
|
31
32
|
"clean:build": "tamagui-build clean:build"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@tamagui/constants": "2.0.0-rc.
|
|
35
|
-
"@tamagui/use-event": "2.0.0-rc.
|
|
35
|
+
"@tamagui/constants": "2.0.0-rc.30",
|
|
36
|
+
"@tamagui/use-event": "2.0.0-rc.30"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@tamagui/build": "2.0.0-rc.
|
|
39
|
+
"@tamagui/build": "2.0.0-rc.30",
|
|
39
40
|
"next": "16.1.1",
|
|
40
41
|
"react": ">=19"
|
|
41
42
|
},
|
|
@@ -89,10 +89,10 @@ export const NextThemeProvider: React.FunctionComponent<ThemeProviderProps> = me
|
|
|
89
89
|
|
|
90
90
|
const set = useEvent((newTheme) => {
|
|
91
91
|
if (forcedTheme) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
handleChangeTheme(newTheme)
|
|
92
|
+
// when forcedTheme is active, block all updates to avoid desync
|
|
93
|
+
return
|
|
95
94
|
}
|
|
95
|
+
handleChangeTheme(newTheme)
|
|
96
96
|
setThemeState(newTheme)
|
|
97
97
|
})
|
|
98
98
|
|
package/types/NextTheme.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/NextTheme.tsx"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"// 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"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAGA,YAAY,WAAW;AAOvB,cAAc,0BAAyC;AAEvD,OAAO,
|
|
3
|
-
"names": [
|
|
4
|
-
"NextThemeProvider: React.FunctionComponent<ThemeProviderProps>"
|
|
5
|
-
],
|
|
2
|
+
"mappings": "AAGA,YAAY,WAAW;AAOvB,cAAc,0BAAyC;AAEvD,OAAO,cAAM,mBAAmB,MAAM,kBAAkB",
|
|
3
|
+
"names": [],
|
|
6
4
|
"sources": [
|
|
7
5
|
"src/NextThemeProvider.tsx"
|
|
8
6
|
],
|
|
7
|
+
"version": 3,
|
|
9
8
|
"sourcesContent": [
|
|
10
|
-
"import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useEvent } from '@tamagui/use-event'\nimport Script from 'next/script'\nimport * as React from 'react'\nimport { memo, useEffect, useMemo, useState } from 'react'\n\nimport { MEDIA, colorSchemes } from './constants'\nimport { getSystemTheme, getTheme } from './helpers'\nimport { ThemeSettingContext } from './ThemeSettingContext'\nimport type { ValueObject } from './types'\nimport type { ThemeProviderProps, UseThemeProps } from './UseThemeProps'\n\nexport const NextThemeProvider: React.FunctionComponent<ThemeProviderProps> = memo(\n ({\n forcedTheme,\n disableTransitionOnChange = false,\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 attrs = !value ? themes : Object.values(value)\n\n const handleMediaQuery = useEvent((e?) => {\n const _ = getSystemTheme(e)\n const update = () => setResolvedTheme(_)\n if (disableTransitionOnChange) {\n update()\n } else {\n React.startTransition(() => update())\n }\n if (theme === 'system' && !forcedTheme) {\n handleChangeTheme(_, false)\n }\n })\n\n const handleChangeTheme = useEvent(\n (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\n useIsomorphicLayoutEffect(() => {\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(handleMediaQuery)\n handleMediaQuery(media)\n return () => {\n media.removeListener(handleMediaQuery)\n }\n }, [])\n\n const set = useEvent((newTheme) => {\n if (forcedTheme) {\n
|
|
11
|
-
]
|
|
12
|
-
"version": 3
|
|
9
|
+
"import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useEvent } from '@tamagui/use-event'\nimport Script from 'next/script'\nimport * as React from 'react'\nimport { memo, useEffect, useMemo, useState } from 'react'\n\nimport { MEDIA, colorSchemes } from './constants'\nimport { getSystemTheme, getTheme } from './helpers'\nimport { ThemeSettingContext } from './ThemeSettingContext'\nimport type { ValueObject } from './types'\nimport type { ThemeProviderProps, UseThemeProps } from './UseThemeProps'\n\nexport const NextThemeProvider: React.FunctionComponent<ThemeProviderProps> = memo(\n ({\n forcedTheme,\n disableTransitionOnChange = false,\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 attrs = !value ? themes : Object.values(value)\n\n const handleMediaQuery = useEvent((e?) => {\n const _ = getSystemTheme(e)\n const update = () => setResolvedTheme(_)\n if (disableTransitionOnChange) {\n update()\n } else {\n React.startTransition(() => update())\n }\n if (theme === 'system' && !forcedTheme) {\n handleChangeTheme(_, false)\n }\n })\n\n const handleChangeTheme = useEvent(\n (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\n useIsomorphicLayoutEffect(() => {\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(handleMediaQuery)\n handleMediaQuery(media)\n return () => {\n media.removeListener(handleMediaQuery)\n }\n }, [])\n\n const set = useEvent((newTheme) => {\n if (forcedTheme) {\n // when forcedTheme is active, block all updates to avoid desync\n return\n }\n handleChangeTheme(newTheme)\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 as 'light' | 'dark')\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) {\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'\n ? ['system', 'light', 'dark']\n : ['system', 'dark', 'light']\n const next = order[(order.indexOf(theme) + 1) % order.length]\n set(next)\n })\n\n const systemTheme = (enableSystem ? resolvedTheme : undefined) as\n | 'light'\n | 'dark'\n | undefined\n\n const contextValue = useMemo(() => {\n const value: UseThemeProps = {\n theme,\n current: theme,\n set,\n toggle,\n forcedTheme,\n resolvedTheme: theme === 'system' ? resolvedTheme : theme,\n themes: enableSystem ? [...themes, 'system'] : (themes as string[]),\n systemTheme,\n } as const\n return value\n }, [\n theme,\n set,\n toggle,\n forcedTheme,\n resolvedTheme,\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 {children}\n </ThemeSettingContext.Provider>\n )\n }\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 }\n return `var d=document.documentElement;`\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 scriptContent = forcedTheme\n ? `!function(){${optimization}${updateDOM(forcedTheme)}}()`\n : enableSystem\n ? `!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(\n 'dark'\n )}:${updateDOM('light')}}else if(e){${\n value ? `var x=${JSON.stringify(value)};` : ''\n }${updateDOM(value ? 'x[e]' : 'e', true)}}${\n !defaultSystem ? `else{${updateDOM(defaultTheme)}}` : ''\n }}catch(e){}}()`\n : `!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 // skipNextHead returns raw script for useServerInsertedHTML usage\n if (skipNextHead) {\n return (\n <script\n key=\"next-themes-script\"\n dangerouslySetInnerHTML={{ __html: scriptContent }}\n />\n )\n }\n\n return (\n <Script\n id=\"next-themes-script\"\n strategy=\"beforeInteractive\"\n dangerouslySetInnerHTML={{ __html: scriptContent }}\n />\n )\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 !== nextProps.forcedTheme) return false\n return true\n }\n)\n"
|
|
10
|
+
]
|
|
13
11
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,cAA6B,eAAe;AAE5C,cAAc,qBAAqB;AAEnC,OAAO,
|
|
3
|
-
"names": [
|
|
4
|
-
"ThemeSettingContext: Context<UseThemeProps>"
|
|
5
|
-
],
|
|
2
|
+
"mappings": "AAAA,cAA6B,eAAe;AAE5C,cAAc,qBAAqB;AAEnC,OAAO,cAAM,qBAAqB,QAAQ",
|
|
3
|
+
"names": [],
|
|
6
4
|
"sources": [
|
|
7
5
|
"src/ThemeSettingContext.tsx"
|
|
8
6
|
],
|
|
7
|
+
"version": 3,
|
|
9
8
|
"sourcesContent": [
|
|
10
9
|
"import { createContext, type Context } from 'react'\n\nimport type { UseThemeProps } from './UseThemeProps'\n\nexport const ThemeSettingContext: Context<UseThemeProps> = createContext<UseThemeProps>({\n toggle: () => {},\n set: (_) => {},\n themes: [],\n})\n"
|
|
11
|
-
]
|
|
12
|
-
"version": 3
|
|
10
|
+
]
|
|
13
11
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/UseThemeProps.tsx"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"import type { ValueObject } from './types'\n\nexport interface UseThemeProps {\n /** List of all available theme names */\n themes: string[]\n /** Forced theme name for the current page */\n forcedTheme?: string\n /** Update the theme */\n set: (theme: string) => void\n toggle: () => void\n /** Active theme name - will return \"system\" if not overriden, see \"resolvedTheme\" for getting resolved system value */\n current?: string\n /** @deprecated Use `current` instead (deprecating avoid confusion with useTheme) */\n theme?: string\n /** If `enableSystem` is true and the active theme is \"system\", this returns whether the system preference resolved to \"dark\" or \"light\". Otherwise, identical to `theme` */\n resolvedTheme?: string\n /** If enableSystem is true, returns the System theme preference (\"dark\" or \"light\"), regardless what the active theme is */\n systemTheme?: 'dark' | 'light'\n}\n\nexport interface ThemeProviderProps {\n children?: any\n /** List of all available theme names */\n themes?: string[]\n /** Forced theme name for the current page */\n forcedTheme?: string\n /** Whether to switch between dark and light themes based on prefers-color-scheme */\n enableSystem?: boolean\n systemTheme?: string\n /** Disable all CSS transitions when switching themes */\n disableTransitionOnChange?: boolean\n /** Whether to indicate to browsers which color scheme is used (dark or light) for built-in UI like inputs and buttons */\n enableColorScheme?: boolean\n /** Key used to store theme setting in localStorage */\n storageKey?: string\n /** Default theme name (for v0.0.12 and lower the default was light). If `enableSystem` is false, the default theme is light */\n defaultTheme?: string\n /** HTML attribute modified based on the active theme. Accepts `class` and `data-*` (meaning any data attribute, `data-mode`, `data-color`, etc.) */\n attribute?: string | 'class'\n /** Mapping of theme name to HTML attribute value. Object where key is the theme name and value is the attribute value */\n value?: ValueObject\n onChangeTheme?: (name: string) => void\n\n // avoids warning\n skipNextHead?: boolean\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
package/types/constants.d.ts.map
CHANGED
package/types/helpers.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/helpers.tsx"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"import { MEDIA } from './constants'\n\nexport const helpers = {}\n// Helpers\n\nexport const getTheme = (key: string, fallback?: string): any => {\n if (typeof window === 'undefined') return undefined\n let theme\n try {\n theme = localStorage.getItem(key) || undefined\n } catch (e) {\n // Unsupported\n }\n return theme || fallback\n}\n\nexport const getSystemTheme = (e?: MediaQueryList): 'dark' | 'light' => {\n if (!e) {\n e = window.matchMedia(MEDIA)\n }\n\n const isDark = e.matches\n const systemTheme = isDark ? 'dark' : 'light'\n return systemTheme\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
package/types/index.d.ts.map
CHANGED
package/types/types.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/useRootTheme.tsx"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"import { useState, type Dispatch, type SetStateAction } from 'react'\nimport { isClient } from '@tamagui/constants'\n\nimport type { ColorScheme } from './types'\n\nexport const useRootTheme = ({ fallback = 'light' }: { fallback?: ColorScheme } = {}): [\n ColorScheme,\n Dispatch<SetStateAction<ColorScheme>>,\n] => {\n let initialVal = fallback\n\n if (isClient) {\n const classes = document.documentElement.classList\n initialVal = classes.contains('t_dark')\n ? 'dark'\n : classes.contains('t_light')\n ? 'light'\n : fallback\n }\n\n return useState<ColorScheme>(initialVal)\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
package/types/useTheme.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/useTheme.tsx"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"import { useContext } from 'react'\n\nimport { ThemeSettingContext } from './ThemeSettingContext'\nimport type { UseThemeProps } from './UseThemeProps'\n\n/**\n * @deprecated renamed to `useThemeSetting` to avoid confusion with core `useTheme` hook\n */\n\nexport const useTheme = (): UseThemeProps => useContext(ThemeSettingContext)\n\nexport const useThemeSetting = (): UseThemeProps => useContext(ThemeSettingContext)\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
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, !0, !1) : 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;AA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AQ,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,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, !0, !1) : 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
|
-
//# sourceMappingURL=NextThemeProvider.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/NextThemeProvider.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,OAAO,YAAY;AACnB,YAAY,WAAW;AACvB,SAAS,MAAM,WAAW,SAAS,gBAAgB;AAEnD,SAAS,OAAO,oBAAoB;AACpC,SAAS,gBAAgB,gBAAgB;AACzC,SAAS,2BAA2B;AAiL9B,SACE,KADF;AA7KC,MAAM,oBAAiE;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;AAAA,EACF,MAAM;AACJ,UAAM,CAAC,OAAO,aAAa,IAAI,SAAS,MAAM,SAAS,YAAY,YAAY,CAAC,GAC1E,CAAC,eAAe,gBAAgB,IAAI,SAAS,MAAM,SAAS,UAAU,CAAC,GACvE,QAAS,QAAiB,OAAO,OAAO,KAAK,IAA5B,QAEjB,mBAAmB,SAAS,CAAC,MAAO;AACxC,YAAM,IAAI,eAAe,CAAC,GACpB,SAAS,MAAM,iBAAiB,CAAC;AACvC,MAAI,4BACF,OAAO,IAEP,MAAM,gBAAgB,MAAM,OAAO,CAAC,GAElC,UAAU,YAAY,CAAC,eACzB,kBAAkB,GAAG,EAAK;AAAA,IAE9B,CAAC,GAEK,oBAAoB;AAAA,MACxB,CAACA,QA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/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
|