@primer/react 0.0.0-20260805210748 → 0.0.0-20260807144044
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 +3 -6
- package/dist/Portal/Portal.js +91 -29
- package/dist/ThemeProvider.d.ts +0 -3
- package/dist/ThemeProvider.js +129 -39
- package/dist/hooks/useMenuInitialFocus.js +72 -57
- package/dist/legacy-theme/ts/color-schemes.js +3942 -3942
- package/dist/next/index.d.ts +1 -4
- package/dist/next/index.js +1 -3
- package/dist/theme.d.ts +54 -16
- package/dist/useTheme.d.ts +14 -2
- package/generated/hooks.json +7 -2
- package/package.json +3 -1
- package/dist/ThemeContext.d.ts +0 -20
- package/dist/internal/components/ThemeProviderBase.js +0 -50
- package/dist/internal/hooks/useThemeProvider.js +0 -71
- package/dist/next/ThemeProvider.d.ts +0 -7
- package/dist/next/ThemeProvider.js +0 -35
package/dist/next/index.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { ThemeProviderProps } from "../ThemeProvider.js";
|
|
2
|
-
import { useColorSchemeVar, useTheme } from "../useTheme.js";
|
|
3
1
|
import { Tooltip, TooltipProps } from "../TooltipV2/Tooltip.js";
|
|
4
|
-
|
|
5
|
-
export { ThemeProvider, type ThemeProviderProps, Tooltip, type TooltipProps, useColorSchemeVar, useTheme };
|
|
2
|
+
export { Tooltip, type TooltipProps };
|
package/dist/next/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useColorSchemeVar, useTheme } from "../useTheme.js";
|
|
3
2
|
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
4
|
-
|
|
5
|
-
export { ThemeProvider, Tooltip, useColorSchemeVar, useTheme };
|
|
3
|
+
export { Tooltip };
|
package/dist/theme.d.ts
CHANGED
|
@@ -1082,7 +1082,6 @@ declare const theme: {
|
|
|
1082
1082
|
}>;
|
|
1083
1083
|
}>;
|
|
1084
1084
|
};
|
|
1085
|
-
/** @deprecated Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values. */
|
|
1086
1085
|
type ThemeColors = {
|
|
1087
1086
|
fg: {
|
|
1088
1087
|
default: string;
|
|
@@ -1107,21 +1106,60 @@ type ThemeColors = {
|
|
|
1107
1106
|
muted: string;
|
|
1108
1107
|
subtle: string;
|
|
1109
1108
|
};
|
|
1110
|
-
accent:
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1109
|
+
accent: {
|
|
1110
|
+
fg: string;
|
|
1111
|
+
emphasis: string;
|
|
1112
|
+
muted: string;
|
|
1113
|
+
subtle: string;
|
|
1114
|
+
};
|
|
1115
|
+
success: {
|
|
1116
|
+
fg: string;
|
|
1117
|
+
emphasis: string;
|
|
1118
|
+
muted: string;
|
|
1119
|
+
subtle: string;
|
|
1120
|
+
};
|
|
1121
|
+
attention: {
|
|
1122
|
+
fg: string;
|
|
1123
|
+
emphasis: string;
|
|
1124
|
+
muted: string;
|
|
1125
|
+
subtle: string;
|
|
1126
|
+
};
|
|
1127
|
+
severe: {
|
|
1128
|
+
fg: string;
|
|
1129
|
+
emphasis: string;
|
|
1130
|
+
muted: string;
|
|
1131
|
+
subtle: string;
|
|
1132
|
+
};
|
|
1133
|
+
danger: {
|
|
1134
|
+
fg: string;
|
|
1135
|
+
emphasis: string;
|
|
1136
|
+
muted: string;
|
|
1137
|
+
subtle: string;
|
|
1138
|
+
};
|
|
1139
|
+
open: {
|
|
1140
|
+
fg: string;
|
|
1141
|
+
emphasis: string;
|
|
1142
|
+
muted: string;
|
|
1143
|
+
subtle: string;
|
|
1144
|
+
};
|
|
1145
|
+
closed: {
|
|
1146
|
+
fg: string;
|
|
1147
|
+
emphasis: string;
|
|
1148
|
+
muted: string;
|
|
1149
|
+
subtle: string;
|
|
1150
|
+
};
|
|
1151
|
+
done: {
|
|
1152
|
+
fg: string;
|
|
1153
|
+
emphasis: string;
|
|
1154
|
+
muted: string;
|
|
1155
|
+
subtle: string;
|
|
1156
|
+
};
|
|
1157
|
+
sponsors: {
|
|
1158
|
+
fg: string;
|
|
1159
|
+
emphasis: string;
|
|
1160
|
+
muted: string;
|
|
1161
|
+
subtle: string;
|
|
1162
|
+
};
|
|
1125
1163
|
};
|
|
1126
1164
|
type ThemeShadows = {
|
|
1127
1165
|
shadow: {
|
package/dist/useTheme.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/useTheme.d.ts
|
|
4
|
-
declare function useTheme():
|
|
5
|
+
declare function useTheme(): {
|
|
6
|
+
theme?: Theme;
|
|
7
|
+
colorScheme?: string;
|
|
8
|
+
colorMode?: ColorModeWithAuto;
|
|
9
|
+
resolvedColorMode?: ColorMode;
|
|
10
|
+
resolvedColorScheme?: string;
|
|
11
|
+
dayScheme?: string;
|
|
12
|
+
nightScheme?: string;
|
|
13
|
+
setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
|
|
14
|
+
setDayScheme: React.Dispatch<React.SetStateAction<string>>;
|
|
15
|
+
setNightScheme: React.Dispatch<React.SetStateAction<string>>;
|
|
16
|
+
};
|
|
5
17
|
declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
|
|
6
18
|
//#endregion
|
|
7
19
|
export { useColorSchemeVar, useTheme };
|
package/generated/hooks.json
CHANGED
|
@@ -960,6 +960,11 @@
|
|
|
960
960
|
{
|
|
961
961
|
"name": "ThemeProviderProps",
|
|
962
962
|
"properties": [
|
|
963
|
+
{
|
|
964
|
+
"name": "theme",
|
|
965
|
+
"type": "{[key: string]: any}",
|
|
966
|
+
"description": "The theme object to be applied."
|
|
967
|
+
},
|
|
963
968
|
{
|
|
964
969
|
"name": "colorMode",
|
|
965
970
|
"type": "'auto' | 'day' | 'night' | 'light' | 'dark'",
|
|
@@ -988,7 +993,7 @@
|
|
|
988
993
|
{
|
|
989
994
|
"name": "theme",
|
|
990
995
|
"type": "Theme",
|
|
991
|
-
"description": "
|
|
996
|
+
"description": "The theme object that is applied."
|
|
992
997
|
},
|
|
993
998
|
{
|
|
994
999
|
"name": "colorScheme",
|
|
@@ -1003,7 +1008,7 @@
|
|
|
1003
1008
|
{
|
|
1004
1009
|
"name": "resolvedColorScheme",
|
|
1005
1010
|
"type": "string",
|
|
1006
|
-
"description": "
|
|
1011
|
+
"description": "The name of the current color scheme."
|
|
1007
1012
|
},
|
|
1008
1013
|
{
|
|
1009
1014
|
"name": "resolvedColorMode",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-20260807144044",
|
|
5
5
|
"description": "An implementation of GitHub's Primer Design System using React",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"build:docs:preview": "NODE_OPTIONS=--openssl-legacy-provider script/build-docs preview",
|
|
46
46
|
"build:components.json": "tsx script/components-json/build.ts",
|
|
47
47
|
"build:hooks.json": "tsx script/hooks-json/build.ts",
|
|
48
|
+
"build:precompile-color-schemes": "tsx script/precompile-color-schemes.ts",
|
|
48
49
|
"lint:npm": "publint --types",
|
|
49
50
|
"lint:react-compiler": "node script/lint-react-compiler.ts",
|
|
50
51
|
"storybook": "storybook",
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
],
|
|
64
65
|
"files": [
|
|
65
66
|
"dist",
|
|
67
|
+
"!dist/legacy-theme/ts/colors",
|
|
66
68
|
"generated",
|
|
67
69
|
"CHANGELOG.md"
|
|
68
70
|
],
|
package/dist/ThemeContext.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/ThemeContext.d.ts
|
|
5
|
-
interface ThemeContextValue {
|
|
6
|
-
/** @deprecated Use `ThemeProvider` and `useTheme` from `@primer/react/next` to migrate away from JavaScript theme values. */
|
|
7
|
-
theme?: Theme;
|
|
8
|
-
colorScheme?: string;
|
|
9
|
-
colorMode?: ColorModeWithAuto;
|
|
10
|
-
resolvedColorMode?: ColorMode;
|
|
11
|
-
/** @deprecated Use `ThemeProvider` and `useTheme` from `@primer/react/next` to migrate away from JavaScript theme values. */
|
|
12
|
-
resolvedColorScheme?: string;
|
|
13
|
-
dayScheme?: string;
|
|
14
|
-
nightScheme?: string;
|
|
15
|
-
setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
|
|
16
|
-
setDayScheme: React.Dispatch<React.SetStateAction<string>>;
|
|
17
|
-
setNightScheme: React.Dispatch<React.SetStateAction<string>>;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { ThemeContextValue };
|
|
@@ -1,50 +0,0 @@
|
|
|
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 };
|
|
@@ -1,71 +0,0 @@
|
|
|
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,7 +0,0 @@
|
|
|
1
|
-
import { ThemeProviderProps } from "../ThemeProvider.js";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/next/ThemeProvider.d.ts
|
|
5
|
-
declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { ThemeProvider, ThemeProvider as default };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ThemeProviderBase } from "../internal/components/ThemeProviderBase.js";
|
|
2
|
-
import { useThemeProvider } from "../internal/hooks/useThemeProvider.js";
|
|
3
|
-
import { c } from "react-compiler-runtime";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region src/next/ThemeProvider.tsx
|
|
6
|
-
const ThemeProvider = (t0) => {
|
|
7
|
-
const $ = c(7);
|
|
8
|
-
let children;
|
|
9
|
-
let props;
|
|
10
|
-
if ($[0] !== t0) {
|
|
11
|
-
({children, ...props} = t0);
|
|
12
|
-
$[0] = t0;
|
|
13
|
-
$[1] = children;
|
|
14
|
-
$[2] = props;
|
|
15
|
-
} else {
|
|
16
|
-
children = $[1];
|
|
17
|
-
props = $[2];
|
|
18
|
-
}
|
|
19
|
-
const { value } = useThemeProvider(props);
|
|
20
|
-
let t1;
|
|
21
|
-
if ($[3] !== children || $[4] !== props.contextOnly || $[5] !== value) {
|
|
22
|
-
t1 = /*#__PURE__*/ jsx(ThemeProviderBase, {
|
|
23
|
-
contextOnly: props.contextOnly,
|
|
24
|
-
value,
|
|
25
|
-
children
|
|
26
|
-
});
|
|
27
|
-
$[3] = children;
|
|
28
|
-
$[4] = props.contextOnly;
|
|
29
|
-
$[5] = value;
|
|
30
|
-
$[6] = t1;
|
|
31
|
-
} else t1 = $[6];
|
|
32
|
-
return t1;
|
|
33
|
-
};
|
|
34
|
-
//#endregion
|
|
35
|
-
export { ThemeProvider, ThemeProvider as default };
|