@primer/react 0.0.0-20260805195449 → 0.0.0-20260805202041
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/CHANGELOG.md
CHANGED
package/dist/ThemeProvider.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import theme from "./theme.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useTheme } from "./useTheme.js";
|
|
2
|
+
import { ThemeProviderBase } from "./internal/components/ThemeProviderBase.js";
|
|
3
|
+
import { useThemeProvider } from "./internal/hooks/useThemeProvider.js";
|
|
5
4
|
import { c } from "react-compiler-runtime";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import
|
|
6
|
+
import "react";
|
|
8
7
|
import deepmerge from "deepmerge";
|
|
9
|
-
|
|
10
|
-
const defaultNightScheme = "dark";
|
|
8
|
+
//#region src/ThemeProvider.tsx
|
|
11
9
|
/**
|
|
12
10
|
* @deprecated Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values.
|
|
13
11
|
*/
|
|
14
12
|
const ThemeProvider = (t0) => {
|
|
15
|
-
var
|
|
16
|
-
const $ = c(
|
|
13
|
+
var _parentValue$theme;
|
|
14
|
+
const $ = c(14);
|
|
17
15
|
let children;
|
|
18
16
|
let props;
|
|
19
17
|
if ($[0] !== t0) {
|
|
@@ -25,134 +23,43 @@ const ThemeProvider = (t0) => {
|
|
|
25
23
|
children = $[1];
|
|
26
24
|
props = $[2];
|
|
27
25
|
}
|
|
28
|
-
const {
|
|
29
|
-
const theme$1 =
|
|
30
|
-
const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : "day");
|
|
31
|
-
const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
|
|
32
|
-
const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
|
|
33
|
-
const systemColorMode = useSystemColorMode();
|
|
34
|
-
let resolvedColorMode;
|
|
26
|
+
const { parentValue, value } = useThemeProvider(props);
|
|
27
|
+
const theme$1 = (_parentValue$theme = parentValue.theme) !== null && _parentValue$theme !== void 0 ? _parentValue$theme : theme;
|
|
35
28
|
let t1;
|
|
36
|
-
if ($[3] !==
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
$[
|
|
40
|
-
$[
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
$[7] = resolvedColorMode;
|
|
44
|
-
$[8] = t1;
|
|
45
|
-
} else {
|
|
46
|
-
resolvedColorMode = $[7];
|
|
47
|
-
t1 = $[8];
|
|
48
|
-
}
|
|
49
|
-
const colorScheme = t1;
|
|
29
|
+
if ($[3] !== theme$1 || $[4] !== value.colorScheme) {
|
|
30
|
+
t1 = applyColorScheme(theme$1, value.colorScheme);
|
|
31
|
+
$[3] = theme$1;
|
|
32
|
+
$[4] = value.colorScheme;
|
|
33
|
+
$[5] = t1;
|
|
34
|
+
} else t1 = $[5];
|
|
35
|
+
const { resolvedTheme, resolvedColorScheme } = t1;
|
|
50
36
|
let t2;
|
|
51
|
-
if ($[
|
|
52
|
-
t2 =
|
|
53
|
-
|
|
54
|
-
$[10] = theme$1;
|
|
55
|
-
$[11] = t2;
|
|
56
|
-
} else t2 = $[11];
|
|
57
|
-
const { resolvedTheme, resolvedColorScheme } = t2;
|
|
58
|
-
let t3;
|
|
59
|
-
if ($[12] !== colorMode || $[13] !== colorScheme || $[14] !== dayScheme || $[15] !== nightScheme || $[16] !== resolvedColorMode || $[17] !== resolvedColorScheme || $[18] !== resolvedTheme || $[19] !== setColorMode || $[20] !== setDayScheme || $[21] !== setNightScheme) {
|
|
60
|
-
t3 = {
|
|
37
|
+
if ($[6] !== resolvedColorScheme || $[7] !== resolvedTheme || $[8] !== value) {
|
|
38
|
+
t2 = {
|
|
39
|
+
...value,
|
|
61
40
|
theme: resolvedTheme,
|
|
62
|
-
|
|
63
|
-
colorMode,
|
|
64
|
-
resolvedColorMode,
|
|
65
|
-
resolvedColorScheme,
|
|
66
|
-
dayScheme,
|
|
67
|
-
nightScheme,
|
|
68
|
-
setColorMode,
|
|
69
|
-
setDayScheme,
|
|
70
|
-
setNightScheme
|
|
41
|
+
resolvedColorScheme
|
|
71
42
|
};
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
$[22] = t3;
|
|
83
|
-
} else t3 = $[22];
|
|
84
|
-
const contextValue = t3;
|
|
85
|
-
if (props.contextOnly) {
|
|
86
|
-
let t4;
|
|
87
|
-
if ($[23] !== children || $[24] !== contextValue) {
|
|
88
|
-
t4 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
89
|
-
value: contextValue,
|
|
90
|
-
children
|
|
91
|
-
});
|
|
92
|
-
$[23] = children;
|
|
93
|
-
$[24] = contextValue;
|
|
94
|
-
$[25] = t4;
|
|
95
|
-
} else t4 = $[25];
|
|
96
|
-
return t4;
|
|
97
|
-
}
|
|
98
|
-
const t4 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
|
|
99
|
-
let t5;
|
|
100
|
-
if ($[26] !== children || $[27] !== dayScheme || $[28] !== nightScheme || $[29] !== t4) {
|
|
101
|
-
t5 = /*#__PURE__*/ jsx("div", {
|
|
102
|
-
"data-component": "ThemeProvider",
|
|
103
|
-
"data-color-mode": t4,
|
|
104
|
-
"data-light-theme": dayScheme,
|
|
105
|
-
"data-dark-theme": nightScheme,
|
|
106
|
-
children
|
|
107
|
-
});
|
|
108
|
-
$[26] = children;
|
|
109
|
-
$[27] = dayScheme;
|
|
110
|
-
$[28] = nightScheme;
|
|
111
|
-
$[29] = t4;
|
|
112
|
-
$[30] = t5;
|
|
113
|
-
} else t5 = $[30];
|
|
114
|
-
let t6;
|
|
115
|
-
if ($[31] !== contextValue || $[32] !== t5) {
|
|
116
|
-
t6 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
43
|
+
$[6] = resolvedColorScheme;
|
|
44
|
+
$[7] = resolvedTheme;
|
|
45
|
+
$[8] = value;
|
|
46
|
+
$[9] = t2;
|
|
47
|
+
} else t2 = $[9];
|
|
48
|
+
const contextValue = t2;
|
|
49
|
+
let t3;
|
|
50
|
+
if ($[10] !== children || $[11] !== contextValue || $[12] !== props.contextOnly) {
|
|
51
|
+
t3 = /*#__PURE__*/ jsx(ThemeProviderBase, {
|
|
52
|
+
contextOnly: props.contextOnly,
|
|
117
53
|
value: contextValue,
|
|
118
|
-
children
|
|
54
|
+
children
|
|
119
55
|
});
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
|
|
124
|
-
|
|
56
|
+
$[10] = children;
|
|
57
|
+
$[11] = contextValue;
|
|
58
|
+
$[12] = props.contextOnly;
|
|
59
|
+
$[13] = t3;
|
|
60
|
+
} else t3 = $[13];
|
|
61
|
+
return t3;
|
|
125
62
|
};
|
|
126
|
-
function subscribeToSystemColorMode(callback) {
|
|
127
|
-
var _window, _window$matchMedia;
|
|
128
|
-
const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-color-scheme: dark)");
|
|
129
|
-
media === null || media === void 0 || media.addEventListener("change", callback);
|
|
130
|
-
return () => media === null || media === void 0 ? void 0 : media.removeEventListener("change", callback);
|
|
131
|
-
}
|
|
132
|
-
function useSystemColorMode() {
|
|
133
|
-
return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, _temp);
|
|
134
|
-
}
|
|
135
|
-
function _temp() {
|
|
136
|
-
return "day";
|
|
137
|
-
}
|
|
138
|
-
function getSystemColorMode() {
|
|
139
|
-
var _window2, _window2$matchMedia, _window2$matchMedia$c;
|
|
140
|
-
return (_window2 = window) !== null && _window2 !== void 0 && (_window2$matchMedia = _window2.matchMedia) !== null && _window2$matchMedia !== void 0 && (_window2$matchMedia$c = _window2$matchMedia.call(_window2, "(prefers-color-scheme: dark)")) !== null && _window2$matchMedia$c !== void 0 && _window2$matchMedia$c.matches ? "night" : "day";
|
|
141
|
-
}
|
|
142
|
-
function resolveColorMode(colorMode, systemColorMode) {
|
|
143
|
-
switch (colorMode) {
|
|
144
|
-
case "auto": return systemColorMode;
|
|
145
|
-
default: return colorMode;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function chooseColorScheme(colorMode, dayScheme, nightScheme) {
|
|
149
|
-
switch (colorMode) {
|
|
150
|
-
case "day":
|
|
151
|
-
case "light": return dayScheme;
|
|
152
|
-
case "dark":
|
|
153
|
-
case "night": return nightScheme;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
63
|
function applyColorScheme(theme, colorScheme) {
|
|
157
64
|
if (!theme.colorSchemes) return {
|
|
158
65
|
resolvedTheme: theme,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ThemeContext } from "../../ThemeContext.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/internal/components/ThemeProviderBase.tsx
|
|
5
|
+
const ThemeProviderBase = (t0) => {
|
|
6
|
+
const $ = c(11);
|
|
7
|
+
const { children, contextOnly, value } = t0;
|
|
8
|
+
if (contextOnly) {
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== children || $[1] !== value) {
|
|
11
|
+
t1 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
12
|
+
value,
|
|
13
|
+
children
|
|
14
|
+
});
|
|
15
|
+
$[0] = children;
|
|
16
|
+
$[1] = value;
|
|
17
|
+
$[2] = t1;
|
|
18
|
+
} else t1 = $[2];
|
|
19
|
+
return t1;
|
|
20
|
+
}
|
|
21
|
+
const t1 = value.colorMode === "auto" ? "auto" : value.colorScheme.includes("dark") ? "dark" : "light";
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[3] !== children || $[4] !== t1 || $[5] !== value.dayScheme || $[6] !== value.nightScheme) {
|
|
24
|
+
t2 = /*#__PURE__*/ jsx("div", {
|
|
25
|
+
"data-component": "ThemeProvider",
|
|
26
|
+
"data-color-mode": t1,
|
|
27
|
+
"data-light-theme": value.dayScheme,
|
|
28
|
+
"data-dark-theme": value.nightScheme,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
$[3] = children;
|
|
32
|
+
$[4] = t1;
|
|
33
|
+
$[5] = value.dayScheme;
|
|
34
|
+
$[6] = value.nightScheme;
|
|
35
|
+
$[7] = t2;
|
|
36
|
+
} else t2 = $[7];
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[8] !== t2 || $[9] !== value) {
|
|
39
|
+
t3 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
40
|
+
value,
|
|
41
|
+
children: t2
|
|
42
|
+
});
|
|
43
|
+
$[8] = t2;
|
|
44
|
+
$[9] = value;
|
|
45
|
+
$[10] = t3;
|
|
46
|
+
} else t3 = $[10];
|
|
47
|
+
return t3;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ThemeProviderBase };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useSyncedState } from "../../hooks/useSyncedState.js";
|
|
2
|
+
import { useTheme } from "../../useTheme.js";
|
|
3
|
+
import { c } from "react-compiler-runtime";
|
|
4
|
+
import React from "react";
|
|
5
|
+
//#region src/internal/hooks/useThemeProvider.ts
|
|
6
|
+
const defaultColorMode = "day";
|
|
7
|
+
const defaultDayScheme = "light";
|
|
8
|
+
const defaultNightScheme = "dark";
|
|
9
|
+
function useThemeProvider(props) {
|
|
10
|
+
var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
|
|
11
|
+
const $ = c(12);
|
|
12
|
+
const parentValue = useTheme();
|
|
13
|
+
const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : parentValue.colorMode) !== null && _ref !== void 0 ? _ref : defaultColorMode);
|
|
14
|
+
const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : parentValue.dayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
|
|
15
|
+
const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : parentValue.nightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
|
|
16
|
+
const systemColorMode = useSystemColorMode();
|
|
17
|
+
const resolvedColorMode = colorMode === "auto" ? systemColorMode : colorMode;
|
|
18
|
+
const colorScheme = resolvedColorMode === "day" || resolvedColorMode === "light" ? dayScheme : nightScheme;
|
|
19
|
+
let t0;
|
|
20
|
+
if ($[0] !== colorMode || $[1] !== colorScheme || $[2] !== dayScheme || $[3] !== nightScheme || $[4] !== resolvedColorMode || $[5] !== setColorMode || $[6] !== setDayScheme || $[7] !== setNightScheme) {
|
|
21
|
+
t0 = {
|
|
22
|
+
colorScheme,
|
|
23
|
+
colorMode,
|
|
24
|
+
resolvedColorMode,
|
|
25
|
+
dayScheme,
|
|
26
|
+
nightScheme,
|
|
27
|
+
setColorMode,
|
|
28
|
+
setDayScheme,
|
|
29
|
+
setNightScheme
|
|
30
|
+
};
|
|
31
|
+
$[0] = colorMode;
|
|
32
|
+
$[1] = colorScheme;
|
|
33
|
+
$[2] = dayScheme;
|
|
34
|
+
$[3] = nightScheme;
|
|
35
|
+
$[4] = resolvedColorMode;
|
|
36
|
+
$[5] = setColorMode;
|
|
37
|
+
$[6] = setDayScheme;
|
|
38
|
+
$[7] = setNightScheme;
|
|
39
|
+
$[8] = t0;
|
|
40
|
+
} else t0 = $[8];
|
|
41
|
+
const value = t0;
|
|
42
|
+
let t1;
|
|
43
|
+
if ($[9] !== parentValue || $[10] !== value) {
|
|
44
|
+
t1 = {
|
|
45
|
+
parentValue,
|
|
46
|
+
value
|
|
47
|
+
};
|
|
48
|
+
$[9] = parentValue;
|
|
49
|
+
$[10] = value;
|
|
50
|
+
$[11] = t1;
|
|
51
|
+
} else t1 = $[11];
|
|
52
|
+
return t1;
|
|
53
|
+
}
|
|
54
|
+
function subscribeToSystemColorMode(callback) {
|
|
55
|
+
var _window, _window$matchMedia;
|
|
56
|
+
const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-color-scheme: dark)");
|
|
57
|
+
media === null || media === void 0 || media.addEventListener("change", callback);
|
|
58
|
+
return () => media === null || media === void 0 ? void 0 : media.removeEventListener("change", callback);
|
|
59
|
+
}
|
|
60
|
+
function useSystemColorMode() {
|
|
61
|
+
return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, _temp);
|
|
62
|
+
}
|
|
63
|
+
function _temp() {
|
|
64
|
+
return "day";
|
|
65
|
+
}
|
|
66
|
+
function getSystemColorMode() {
|
|
67
|
+
var _window2, _window2$matchMedia, _window2$matchMedia$c;
|
|
68
|
+
return (_window2 = window) !== null && _window2 !== void 0 && (_window2$matchMedia = _window2.matchMedia) !== null && _window2$matchMedia !== void 0 && (_window2$matchMedia$c = _window2$matchMedia.call(_window2, "(prefers-color-scheme: dark)")) !== null && _window2$matchMedia$c !== void 0 && _window2$matchMedia$c.matches ? "night" : "day";
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { useThemeProvider };
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useTheme } from "../useTheme.js";
|
|
1
|
+
import { ThemeProviderBase } from "../internal/components/ThemeProviderBase.js";
|
|
2
|
+
import { useThemeProvider } from "../internal/hooks/useThemeProvider.js";
|
|
4
3
|
import { c } from "react-compiler-runtime";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import React from "react";
|
|
7
5
|
//#region src/next/ThemeProvider.tsx
|
|
8
|
-
const defaultColorMode = "day";
|
|
9
|
-
const defaultDayScheme = "light";
|
|
10
|
-
const defaultNightScheme = "dark";
|
|
11
6
|
const ThemeProvider = (t0) => {
|
|
12
|
-
|
|
13
|
-
const $ = c(23);
|
|
7
|
+
const $ = c(7);
|
|
14
8
|
let children;
|
|
15
9
|
let props;
|
|
16
10
|
if ($[0] !== t0) {
|
|
@@ -22,92 +16,20 @@ const ThemeProvider = (t0) => {
|
|
|
22
16
|
children = $[1];
|
|
23
17
|
props = $[2];
|
|
24
18
|
}
|
|
25
|
-
const {
|
|
26
|
-
const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : defaultColorMode);
|
|
27
|
-
const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
|
|
28
|
-
const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
|
|
29
|
-
const systemColorMode = useSystemColorMode();
|
|
30
|
-
const resolvedColorMode = colorMode === "auto" ? systemColorMode : colorMode;
|
|
31
|
-
const colorScheme = resolvedColorMode === "day" || resolvedColorMode === "light" ? dayScheme : nightScheme;
|
|
19
|
+
const { value } = useThemeProvider(props);
|
|
32
20
|
let t1;
|
|
33
|
-
if ($[3] !==
|
|
34
|
-
t1 = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
resolvedColorMode,
|
|
38
|
-
dayScheme,
|
|
39
|
-
nightScheme,
|
|
40
|
-
setColorMode,
|
|
41
|
-
setDayScheme,
|
|
42
|
-
setNightScheme
|
|
43
|
-
};
|
|
44
|
-
$[3] = colorMode;
|
|
45
|
-
$[4] = colorScheme;
|
|
46
|
-
$[5] = dayScheme;
|
|
47
|
-
$[6] = nightScheme;
|
|
48
|
-
$[7] = resolvedColorMode;
|
|
49
|
-
$[8] = setColorMode;
|
|
50
|
-
$[9] = setDayScheme;
|
|
51
|
-
$[10] = setNightScheme;
|
|
52
|
-
$[11] = t1;
|
|
53
|
-
} else t1 = $[11];
|
|
54
|
-
const contextValue = t1;
|
|
55
|
-
if (props.contextOnly) {
|
|
56
|
-
let t2;
|
|
57
|
-
if ($[12] !== children || $[13] !== contextValue) {
|
|
58
|
-
t2 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
59
|
-
value: contextValue,
|
|
60
|
-
children
|
|
61
|
-
});
|
|
62
|
-
$[12] = children;
|
|
63
|
-
$[13] = contextValue;
|
|
64
|
-
$[14] = t2;
|
|
65
|
-
} else t2 = $[14];
|
|
66
|
-
return t2;
|
|
67
|
-
}
|
|
68
|
-
const t2 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
|
|
69
|
-
let t3;
|
|
70
|
-
if ($[15] !== children || $[16] !== dayScheme || $[17] !== nightScheme || $[18] !== t2) {
|
|
71
|
-
t3 = /*#__PURE__*/ jsx("div", {
|
|
72
|
-
"data-component": "ThemeProvider",
|
|
73
|
-
"data-color-mode": t2,
|
|
74
|
-
"data-light-theme": dayScheme,
|
|
75
|
-
"data-dark-theme": nightScheme,
|
|
21
|
+
if ($[3] !== children || $[4] !== props.contextOnly || $[5] !== value) {
|
|
22
|
+
t1 = /*#__PURE__*/ jsx(ThemeProviderBase, {
|
|
23
|
+
contextOnly: props.contextOnly,
|
|
24
|
+
value,
|
|
76
25
|
children
|
|
77
26
|
});
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let t4;
|
|
85
|
-
if ($[20] !== contextValue || $[21] !== t3) {
|
|
86
|
-
t4 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
87
|
-
value: contextValue,
|
|
88
|
-
children: t3
|
|
89
|
-
});
|
|
90
|
-
$[20] = contextValue;
|
|
91
|
-
$[21] = t3;
|
|
92
|
-
$[22] = t4;
|
|
93
|
-
} else t4 = $[22];
|
|
94
|
-
return t4;
|
|
27
|
+
$[3] = children;
|
|
28
|
+
$[4] = props.contextOnly;
|
|
29
|
+
$[5] = value;
|
|
30
|
+
$[6] = t1;
|
|
31
|
+
} else t1 = $[6];
|
|
32
|
+
return t1;
|
|
95
33
|
};
|
|
96
|
-
function subscribeToSystemColorMode(callback) {
|
|
97
|
-
var _window, _window$matchMedia;
|
|
98
|
-
const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-color-scheme: dark)");
|
|
99
|
-
media === null || media === void 0 || media.addEventListener("change", callback);
|
|
100
|
-
return () => media === null || media === void 0 ? void 0 : media.removeEventListener("change", callback);
|
|
101
|
-
}
|
|
102
|
-
function useSystemColorMode() {
|
|
103
|
-
return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, _temp);
|
|
104
|
-
}
|
|
105
|
-
function _temp() {
|
|
106
|
-
return "day";
|
|
107
|
-
}
|
|
108
|
-
function getSystemColorMode() {
|
|
109
|
-
var _window2, _window2$matchMedia, _window2$matchMedia$c;
|
|
110
|
-
return (_window2 = window) !== null && _window2 !== void 0 && (_window2$matchMedia = _window2.matchMedia) !== null && _window2$matchMedia !== void 0 && (_window2$matchMedia$c = _window2$matchMedia.call(_window2, "(prefers-color-scheme: dark)")) !== null && _window2$matchMedia$c !== void 0 && _window2$matchMedia$c.matches ? "night" : "day";
|
|
111
|
-
}
|
|
112
34
|
//#endregion
|
|
113
35
|
export { ThemeProvider, ThemeProvider as default };
|
package/package.json
CHANGED