@primer/react 0.0.0-20260724222002 → 0.0.0-20260803202204
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 +5 -7
- package/dist/Avatar/Avatar-fa0ccdca.css +2 -0
- package/dist/Avatar/Avatar-fa0ccdca.css.map +1 -0
- package/dist/Avatar/Avatar.module.css.js +1 -1
- package/dist/Popover/Popover.d.ts +1 -0
- package/dist/Popover/Popover.js +84 -47
- package/dist/Radio/Radio.js +1 -1
- package/dist/ThemeProvider.d.ts +4 -1
- package/dist/ThemeProvider.js +76 -43
- package/dist/index.d.ts +2 -2
- package/dist/legacy-theme/ts/color-schemes.js +4252 -0
- package/dist/theme.d.ts +1142 -1
- package/dist/theme.js +3 -1
- package/dist/useTheme.d.ts +3 -1
- package/dist/utils/types/KeyPaths.d.ts +4 -0
- package/generated/components.json +5 -0
- package/generated/hooks.json +15 -0
- package/package.json +11 -8
- package/dist/Avatar/Avatar-61b19061.css +0 -2
- package/dist/Avatar/Avatar-61b19061.css.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260803202204
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
8
|
-
color scheme values into the theme context. Color schemes are applied via CSS
|
|
9
|
-
variables instead, and passing an unknown color scheme no longer logs an error.
|
|
10
|
-
`useTheme()` no longer returns `theme` or `resolvedColorScheme`. The
|
|
11
|
-
`ThemeColorPaths` and `ThemeShadowPaths` types are also no longer exported.
|
|
7
|
+
- [#8253](https://github.com/primer/react/pull/8253) [`da3df9a`](https://github.com/primer/react/commit/da3df9aba582c7bcedbe69f1bdc5ab64ac90d32b) Thanks [@llastflowers](https://github.com/llastflowers)! - Add default Esc-to-dismiss support to `Popover` component
|
|
12
8
|
|
|
13
9
|
### Patch Changes
|
|
14
10
|
|
|
15
11
|
- Fake entry to force publishing
|
|
16
12
|
|
|
13
|
+
- [#8259](https://github.com/primer/react/pull/8259) [`a92c9ef`](https://github.com/primer/react/commit/a92c9ef1fccf12cd7fa192c62384062aa670a065) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Prevent `Avatar` from shrinking in min-content slots such as `Button` leading visuals.
|
|
14
|
+
|
|
17
15
|
## 38.34.0
|
|
18
16
|
|
|
19
17
|
### Minor Changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
:where(.prc-Avatar-Avatar-0xaUi){border-radius:50%;box-shadow:0 0 0 1px var(--avatar-borderColor,#1f232826);display:inline-block;height:var(--avatarSize-regular);line-height:1;min-width:var(--avatarSize-regular);overflow:hidden;vertical-align:middle;width:var(--avatarSize-regular)}:where(.prc-Avatar-Avatar-0xaUi):where([data-square]){border-radius:clamp(4px,calc(var(--avatarSize-regular) - 24px),var(--borderRadius-medium,.375rem))}@media screen and (max-width:calc(48rem - 0.02px)){:where(.prc-Avatar-Avatar-0xaUi):where([data-responsive]){height:var(--avatarSize-narrow);min-width:var(--avatarSize-narrow);width:var(--avatarSize-narrow)}}@media screen and (min-width:48rem){:where(.prc-Avatar-Avatar-0xaUi):where([data-responsive]){height:var(--avatarSize-regular);min-width:var(--avatarSize-regular);width:var(--avatarSize-regular)}}@media screen and (min-width:87.5rem){:where(.prc-Avatar-Avatar-0xaUi):where([data-responsive]){height:var(--avatarSize-wide);min-width:var(--avatarSize-wide);width:var(--avatarSize-wide)}}
|
|
2
|
+
/*# sourceMappingURL=Avatar-fa0ccdca.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Avatar/Avatar.module.css.js"],"names":[],"mappings":"AAAA,iCASE,iBAAkB,CAElB,wDAA+C,CAV/C,oBAAqB,CAGrB,gCAAiC,CAGjC,aAAc,CAJd,mCAAoC,CAEpC,eAAgB,CAGhB,qBAAsB,CANtB,+BAmCF,CAxBE,sDAEE,kGACF,CAGE,mDADF,0DAII,+BAAgC,CADhC,kCAAmC,CADnC,8BAgBJ,CAbE,CAEA,oCAPF,0DAUI,gCAAiC,CADjC,mCAAoC,CADpC,+BAUJ,CAPE,CAEA,sCAbF,0DAgBI,6BAA8B,CAD9B,gCAAiC,CADjC,4BAIJ,CADE","file":"Avatar-fa0ccdca.css","sourcesContent":[":where(.Avatar) {\n display: inline-block;\n width: var(--avatarSize-regular);\n min-width: var(--avatarSize-regular);\n height: var(--avatarSize-regular);\n overflow: hidden; /* Ensure page layout in Firefox should images fail to load */\n /* stylelint-disable-next-line primer/typography */\n line-height: 1;\n vertical-align: middle;\n border-radius: 50%;\n /* stylelint-disable-next-line primer/box-shadow */\n box-shadow: 0 0 0 1px var(--avatar-borderColor);\n\n &:where([data-square]) {\n /* stylelint-disable-next-line primer/borders */\n border-radius: clamp(4px, calc(var(--avatarSize-regular) - 24px), var(--borderRadius-medium));\n }\n\n &:where([data-responsive]) {\n @media screen and (--viewportRange-narrow) {\n width: var(--avatarSize-narrow);\n min-width: var(--avatarSize-narrow);\n height: var(--avatarSize-narrow);\n }\n\n @media screen and (--viewportRange-regular) {\n width: var(--avatarSize-regular);\n min-width: var(--avatarSize-regular);\n height: var(--avatarSize-regular);\n }\n\n @media screen and (--viewportRange-wide) {\n width: var(--avatarSize-wide);\n min-width: var(--avatarSize-wide);\n height: var(--avatarSize-wide);\n }\n }\n}\n"]}
|
|
@@ -16,6 +16,7 @@ type PopoverContentProps = {
|
|
|
16
16
|
height?: 'small' | 'large' | 'medium' | 'auto' | 'xlarge' | 'fit-content';
|
|
17
17
|
overflow?: 'auto' | 'hidden' | 'scroll' | 'visible';
|
|
18
18
|
onClickOutside?: (event: MouseEvent | TouchEvent) => void;
|
|
19
|
+
onEscape?: (event: KeyboardEvent) => void;
|
|
19
20
|
ignoreClickRefs?: React.RefObject<HTMLElement>[];
|
|
20
21
|
} & HTMLProps<HTMLDivElement>;
|
|
21
22
|
declare const _default: React.ForwardRefExoticComponent<Omit<PopoverProps, "ref"> & React.RefAttributes<HTMLDivElement>> & {
|
package/dist/Popover/Popover.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useOnOutsideClick } from "../hooks/useOnOutsideClick.js";
|
|
2
|
+
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
2
3
|
import Popover_module_css_default from "./Popover.module.css.js";
|
|
3
4
|
import { c } from "react-compiler-runtime";
|
|
4
5
|
import { clsx } from "clsx";
|
|
@@ -6,8 +7,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
7
|
import React, { useRef } from "react";
|
|
7
8
|
//#region src/Popover/Popover.tsx
|
|
8
9
|
const EMPTY_IGNORE_CLICK_REFS = [];
|
|
10
|
+
const PopoverContext = /*#__PURE__*/ React.createContext(false);
|
|
9
11
|
const Popover = /*#__PURE__*/ React.forwardRef(function Popover(t0, forwardRef) {
|
|
10
|
-
|
|
12
|
+
var _open;
|
|
13
|
+
const $ = c(18);
|
|
11
14
|
let className;
|
|
12
15
|
let open;
|
|
13
16
|
let props;
|
|
@@ -29,102 +32,136 @@ const Popover = /*#__PURE__*/ React.forwardRef(function Popover(t0, forwardRef)
|
|
|
29
32
|
t1 = $[5];
|
|
30
33
|
}
|
|
31
34
|
const caret = t1 === void 0 ? "top" : t1;
|
|
32
|
-
const t2 = open
|
|
33
|
-
const t3 =
|
|
34
|
-
|
|
35
|
+
const t2 = (_open = open) !== null && _open !== void 0 ? _open : false;
|
|
36
|
+
const t3 = open ? "" : void 0;
|
|
37
|
+
const t4 = relative ? "" : void 0;
|
|
38
|
+
let t5;
|
|
35
39
|
if ($[6] !== className) {
|
|
36
|
-
|
|
40
|
+
t5 = clsx(className, Popover_module_css_default.Popover);
|
|
37
41
|
$[6] = className;
|
|
38
|
-
$[7] =
|
|
39
|
-
} else
|
|
40
|
-
let
|
|
41
|
-
if ($[8] !== caret || $[9] !== forwardRef || $[10] !== props || $[11] !==
|
|
42
|
-
|
|
42
|
+
$[7] = t5;
|
|
43
|
+
} else t5 = $[7];
|
|
44
|
+
let t6;
|
|
45
|
+
if ($[8] !== caret || $[9] !== forwardRef || $[10] !== props || $[11] !== t3 || $[12] !== t4 || $[13] !== t5) {
|
|
46
|
+
t6 = /*#__PURE__*/ jsx("div", {
|
|
43
47
|
...props,
|
|
44
48
|
ref: forwardRef,
|
|
45
49
|
"data-component": "Popover",
|
|
46
|
-
"data-open":
|
|
47
|
-
"data-relative":
|
|
50
|
+
"data-open": t3,
|
|
51
|
+
"data-relative": t4,
|
|
48
52
|
"data-caret": caret,
|
|
49
|
-
className:
|
|
53
|
+
className: t5
|
|
50
54
|
});
|
|
51
55
|
$[8] = caret;
|
|
52
56
|
$[9] = forwardRef;
|
|
53
57
|
$[10] = props;
|
|
54
|
-
$[11] =
|
|
55
|
-
$[12] =
|
|
56
|
-
$[13] =
|
|
57
|
-
$[14] =
|
|
58
|
-
} else
|
|
59
|
-
|
|
58
|
+
$[11] = t3;
|
|
59
|
+
$[12] = t4;
|
|
60
|
+
$[13] = t5;
|
|
61
|
+
$[14] = t6;
|
|
62
|
+
} else t6 = $[14];
|
|
63
|
+
let t7;
|
|
64
|
+
if ($[15] !== t2 || $[16] !== t6) {
|
|
65
|
+
t7 = /*#__PURE__*/ jsx(PopoverContext.Provider, {
|
|
66
|
+
value: t2,
|
|
67
|
+
children: t6
|
|
68
|
+
});
|
|
69
|
+
$[15] = t2;
|
|
70
|
+
$[16] = t6;
|
|
71
|
+
$[17] = t7;
|
|
72
|
+
} else t7 = $[17];
|
|
73
|
+
return t7;
|
|
60
74
|
});
|
|
61
75
|
Popover.displayName = "Popover";
|
|
62
76
|
const PopoverContent = (t0) => {
|
|
63
77
|
var _onClickOutside, _ignoreClickRefs;
|
|
64
|
-
const $ = c(
|
|
78
|
+
const $ = c(22);
|
|
65
79
|
let className;
|
|
66
80
|
let ignoreClickRefs;
|
|
67
81
|
let onClickOutside;
|
|
82
|
+
let onEscape;
|
|
68
83
|
let props;
|
|
69
84
|
let t1;
|
|
70
85
|
let t2;
|
|
71
86
|
if ($[0] !== t0) {
|
|
72
|
-
({className, width: t1, height: t2, onClickOutside, ignoreClickRefs, ...props} = t0);
|
|
87
|
+
({className, width: t1, height: t2, onClickOutside, onEscape, ignoreClickRefs, ...props} = t0);
|
|
73
88
|
$[0] = t0;
|
|
74
89
|
$[1] = className;
|
|
75
90
|
$[2] = ignoreClickRefs;
|
|
76
91
|
$[3] = onClickOutside;
|
|
77
|
-
$[4] =
|
|
78
|
-
$[5] =
|
|
79
|
-
$[6] =
|
|
92
|
+
$[4] = onEscape;
|
|
93
|
+
$[5] = props;
|
|
94
|
+
$[6] = t1;
|
|
95
|
+
$[7] = t2;
|
|
80
96
|
} else {
|
|
81
97
|
className = $[1];
|
|
82
98
|
ignoreClickRefs = $[2];
|
|
83
99
|
onClickOutside = $[3];
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
onEscape = $[4];
|
|
101
|
+
props = $[5];
|
|
102
|
+
t1 = $[6];
|
|
103
|
+
t2 = $[7];
|
|
87
104
|
}
|
|
88
105
|
const width = t1 === void 0 ? "small" : t1;
|
|
89
106
|
const height = t2 === void 0 ? "fit-content" : t2;
|
|
90
107
|
const divRef = useRef(null);
|
|
108
|
+
const open = React.useContext(PopoverContext);
|
|
91
109
|
const outsideClickHandler = (_onClickOutside = onClickOutside) !== null && _onClickOutside !== void 0 ? _onClickOutside : _temp;
|
|
92
110
|
const t3 = (_ignoreClickRefs = ignoreClickRefs) !== null && _ignoreClickRefs !== void 0 ? _ignoreClickRefs : EMPTY_IGNORE_CLICK_REFS;
|
|
93
111
|
let t4;
|
|
94
|
-
if ($[
|
|
112
|
+
if ($[8] !== outsideClickHandler || $[9] !== t3) {
|
|
95
113
|
t4 = {
|
|
96
114
|
onClickOutside: outsideClickHandler,
|
|
97
115
|
containerRef: divRef,
|
|
98
116
|
ignoreClickRefs: t3
|
|
99
117
|
};
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
} else t4 = $[
|
|
118
|
+
$[8] = outsideClickHandler;
|
|
119
|
+
$[9] = t3;
|
|
120
|
+
$[10] = t4;
|
|
121
|
+
} else t4 = $[10];
|
|
104
122
|
useOnOutsideClick(t4);
|
|
105
123
|
let t5;
|
|
106
|
-
if ($[10] !== className) {
|
|
107
|
-
t5 = clsx(className, Popover_module_css_default.PopoverContent);
|
|
108
|
-
$[10] = className;
|
|
109
|
-
$[11] = t5;
|
|
110
|
-
} else t5 = $[11];
|
|
111
124
|
let t6;
|
|
112
|
-
if ($[
|
|
113
|
-
|
|
125
|
+
if ($[11] !== onEscape || $[12] !== open) {
|
|
126
|
+
t5 = (event) => {
|
|
127
|
+
if (open && onEscape) {
|
|
128
|
+
onEscape(event);
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
t6 = [open, onEscape];
|
|
133
|
+
$[11] = onEscape;
|
|
134
|
+
$[12] = open;
|
|
135
|
+
$[13] = t5;
|
|
136
|
+
$[14] = t6;
|
|
137
|
+
} else {
|
|
138
|
+
t5 = $[13];
|
|
139
|
+
t6 = $[14];
|
|
140
|
+
}
|
|
141
|
+
useOnEscapePress(t5, t6);
|
|
142
|
+
let t7;
|
|
143
|
+
if ($[15] !== className) {
|
|
144
|
+
t7 = clsx(className, Popover_module_css_default.PopoverContent);
|
|
145
|
+
$[15] = className;
|
|
146
|
+
$[16] = t7;
|
|
147
|
+
} else t7 = $[16];
|
|
148
|
+
let t8;
|
|
149
|
+
if ($[17] !== height || $[18] !== props || $[19] !== t7 || $[20] !== width) {
|
|
150
|
+
t8 = /*#__PURE__*/ jsx("div", {
|
|
114
151
|
ref: divRef,
|
|
115
152
|
"data-component": "Popover.Content",
|
|
116
153
|
"data-width": width,
|
|
117
154
|
"data-height": height,
|
|
118
|
-
className:
|
|
155
|
+
className: t7,
|
|
119
156
|
...props
|
|
120
157
|
});
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
} else
|
|
127
|
-
return
|
|
158
|
+
$[17] = height;
|
|
159
|
+
$[18] = props;
|
|
160
|
+
$[19] = t7;
|
|
161
|
+
$[20] = width;
|
|
162
|
+
$[21] = t8;
|
|
163
|
+
} else t8 = $[21];
|
|
164
|
+
return t8;
|
|
128
165
|
};
|
|
129
166
|
PopoverContent.displayName = "Popover.Content";
|
|
130
167
|
var Popover_default = Object.assign(Popover, { Content: PopoverContent });
|
package/dist/Radio/Radio.js
CHANGED
|
@@ -48,7 +48,7 @@ const Radio = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
48
48
|
let t2;
|
|
49
49
|
if ($[10] !== onChange || $[11] !== radioGroupContext) {
|
|
50
50
|
t2 = (e) => {
|
|
51
|
-
|
|
51
|
+
radioGroupContext !== null && radioGroupContext !== void 0 && radioGroupContext.onChange && radioGroupContext.onChange(e);
|
|
52
52
|
onChange && onChange(e);
|
|
53
53
|
};
|
|
54
54
|
$[10] = onChange;
|
package/dist/ThemeProvider.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/ThemeProvider.d.ts
|
|
4
|
+
type Theme = {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
4
7
|
type ColorMode = 'day' | 'night' | 'light' | 'dark';
|
|
5
8
|
type ColorModeWithAuto = ColorMode | 'auto';
|
|
6
9
|
type ThemeProviderProps = {
|
|
@@ -20,4 +23,4 @@ type ThemeProviderProps = {
|
|
|
20
23
|
};
|
|
21
24
|
declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
|
|
22
25
|
//#endregion
|
|
23
|
-
export { ColorMode, ColorModeWithAuto, ThemeProvider, ThemeProvider as default, ThemeProviderProps };
|
|
26
|
+
export { ColorMode, ColorModeWithAuto, Theme, ThemeProvider, ThemeProvider as default, ThemeProviderProps };
|
package/dist/ThemeProvider.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import theme from "./theme.js";
|
|
1
2
|
import { useSyncedState } from "./hooks/useSyncedState.js";
|
|
2
3
|
import { ThemeContext } from "./ThemeContext.js";
|
|
3
4
|
import { useTheme } from "./useTheme.js";
|
|
4
5
|
import { c } from "react-compiler-runtime";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import React from "react";
|
|
8
|
+
import deepmerge from "deepmerge";
|
|
7
9
|
const defaultDayScheme = "light";
|
|
8
10
|
const defaultNightScheme = "dark";
|
|
9
11
|
const ThemeProvider = (t0) => {
|
|
10
12
|
var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
|
|
11
|
-
const $ = c(
|
|
13
|
+
const $ = c(34);
|
|
12
14
|
let children;
|
|
13
15
|
let props;
|
|
14
16
|
if ($[0] !== t0) {
|
|
@@ -20,7 +22,8 @@ const ThemeProvider = (t0) => {
|
|
|
20
22
|
children = $[1];
|
|
21
23
|
props = $[2];
|
|
22
24
|
}
|
|
23
|
-
const { colorMode: fallbackColorMode, dayScheme: fallbackDayScheme, nightScheme: fallbackNightScheme } = useTheme();
|
|
25
|
+
const { theme: fallbackTheme, colorMode: fallbackColorMode, dayScheme: fallbackDayScheme, nightScheme: fallbackNightScheme } = useTheme();
|
|
26
|
+
const theme$1 = fallbackTheme !== null && fallbackTheme !== void 0 ? fallbackTheme : theme;
|
|
24
27
|
const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : "day");
|
|
25
28
|
const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
|
|
26
29
|
const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
|
|
@@ -42,68 +45,80 @@ const ThemeProvider = (t0) => {
|
|
|
42
45
|
}
|
|
43
46
|
const colorScheme = t1;
|
|
44
47
|
let t2;
|
|
45
|
-
if ($[9] !==
|
|
46
|
-
t2 =
|
|
48
|
+
if ($[9] !== colorScheme || $[10] !== theme$1) {
|
|
49
|
+
t2 = applyColorScheme(theme$1, colorScheme);
|
|
50
|
+
$[9] = colorScheme;
|
|
51
|
+
$[10] = theme$1;
|
|
52
|
+
$[11] = t2;
|
|
53
|
+
} else t2 = $[11];
|
|
54
|
+
const { resolvedTheme, resolvedColorScheme } = t2;
|
|
55
|
+
let t3;
|
|
56
|
+
if ($[12] !== colorMode || $[13] !== colorScheme || $[14] !== dayScheme || $[15] !== nightScheme || $[16] !== resolvedColorMode || $[17] !== resolvedColorScheme || $[18] !== resolvedTheme || $[19] !== setColorMode || $[20] !== setDayScheme || $[21] !== setNightScheme) {
|
|
57
|
+
t3 = {
|
|
58
|
+
theme: resolvedTheme,
|
|
47
59
|
colorScheme,
|
|
48
60
|
colorMode,
|
|
49
61
|
resolvedColorMode,
|
|
62
|
+
resolvedColorScheme,
|
|
50
63
|
dayScheme,
|
|
51
64
|
nightScheme,
|
|
52
65
|
setColorMode,
|
|
53
66
|
setDayScheme,
|
|
54
67
|
setNightScheme
|
|
55
68
|
};
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
$[12] = colorMode;
|
|
70
|
+
$[13] = colorScheme;
|
|
71
|
+
$[14] = dayScheme;
|
|
72
|
+
$[15] = nightScheme;
|
|
73
|
+
$[16] = resolvedColorMode;
|
|
74
|
+
$[17] = resolvedColorScheme;
|
|
75
|
+
$[18] = resolvedTheme;
|
|
76
|
+
$[19] = setColorMode;
|
|
77
|
+
$[20] = setDayScheme;
|
|
78
|
+
$[21] = setNightScheme;
|
|
79
|
+
$[22] = t3;
|
|
80
|
+
} else t3 = $[22];
|
|
81
|
+
const contextValue = t3;
|
|
67
82
|
if (props.contextOnly) {
|
|
68
|
-
let
|
|
69
|
-
if ($[
|
|
70
|
-
|
|
83
|
+
let t4;
|
|
84
|
+
if ($[23] !== children || $[24] !== contextValue) {
|
|
85
|
+
t4 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
71
86
|
value: contextValue,
|
|
72
87
|
children
|
|
73
88
|
});
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
} else
|
|
78
|
-
return
|
|
89
|
+
$[23] = children;
|
|
90
|
+
$[24] = contextValue;
|
|
91
|
+
$[25] = t4;
|
|
92
|
+
} else t4 = $[25];
|
|
93
|
+
return t4;
|
|
79
94
|
}
|
|
80
|
-
const
|
|
81
|
-
let
|
|
82
|
-
if ($[
|
|
83
|
-
|
|
95
|
+
const t4 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
|
|
96
|
+
let t5;
|
|
97
|
+
if ($[26] !== children || $[27] !== dayScheme || $[28] !== nightScheme || $[29] !== t4) {
|
|
98
|
+
t5 = /*#__PURE__*/ jsx("div", {
|
|
84
99
|
"data-component": "ThemeProvider",
|
|
85
|
-
"data-color-mode":
|
|
100
|
+
"data-color-mode": t4,
|
|
86
101
|
"data-light-theme": dayScheme,
|
|
87
102
|
"data-dark-theme": nightScheme,
|
|
88
103
|
children
|
|
89
104
|
});
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
} else
|
|
96
|
-
let
|
|
97
|
-
if ($[
|
|
98
|
-
|
|
105
|
+
$[26] = children;
|
|
106
|
+
$[27] = dayScheme;
|
|
107
|
+
$[28] = nightScheme;
|
|
108
|
+
$[29] = t4;
|
|
109
|
+
$[30] = t5;
|
|
110
|
+
} else t5 = $[30];
|
|
111
|
+
let t6;
|
|
112
|
+
if ($[31] !== contextValue || $[32] !== t5) {
|
|
113
|
+
t6 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
99
114
|
value: contextValue,
|
|
100
|
-
children:
|
|
115
|
+
children: t5
|
|
101
116
|
});
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
} else
|
|
106
|
-
return
|
|
117
|
+
$[31] = contextValue;
|
|
118
|
+
$[32] = t5;
|
|
119
|
+
$[33] = t6;
|
|
120
|
+
} else t6 = $[33];
|
|
121
|
+
return t6;
|
|
107
122
|
};
|
|
108
123
|
function subscribeToSystemColorMode(callback) {
|
|
109
124
|
var _window, _window$matchMedia;
|
|
@@ -135,5 +150,23 @@ function chooseColorScheme(colorMode, dayScheme, nightScheme) {
|
|
|
135
150
|
case "night": return nightScheme;
|
|
136
151
|
}
|
|
137
152
|
}
|
|
153
|
+
function applyColorScheme(theme, colorScheme) {
|
|
154
|
+
if (!theme.colorSchemes) return {
|
|
155
|
+
resolvedTheme: theme,
|
|
156
|
+
resolvedColorScheme: void 0
|
|
157
|
+
};
|
|
158
|
+
if (!theme.colorSchemes[colorScheme]) {
|
|
159
|
+
console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``);
|
|
160
|
+
const defaultColorScheme = Object.keys(theme.colorSchemes)[0];
|
|
161
|
+
return {
|
|
162
|
+
resolvedTheme: deepmerge(theme, theme.colorSchemes[defaultColorScheme]),
|
|
163
|
+
resolvedColorScheme: defaultColorScheme
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
resolvedTheme: deepmerge(theme, theme.colorSchemes[colorScheme]),
|
|
168
|
+
resolvedColorScheme: colorScheme
|
|
169
|
+
};
|
|
170
|
+
}
|
|
138
171
|
//#endregion
|
|
139
172
|
export { ThemeProvider, ThemeProvider as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { useOnEscapePress } from "./hooks/useOnEscapePress.js";
|
|
|
5
5
|
import { useOpenAndCloseFocus } from "./hooks/useOpenAndCloseFocus.js";
|
|
6
6
|
import { AnchoredPositionHookSettings, useAnchoredPosition } from "./hooks/useAnchoredPosition.js";
|
|
7
7
|
import { useOverlay } from "./hooks/useOverlay.js";
|
|
8
|
-
import theme from "./theme.js";
|
|
8
|
+
import theme, { ThemeColorPaths, ThemeShadowPaths } from "./theme.js";
|
|
9
9
|
import BaseStyles, { BaseStylesProps } from "./BaseStyles.js";
|
|
10
10
|
import { ThemeProvider, ThemeProviderProps } from "./ThemeProvider.js";
|
|
11
11
|
import { useColorSchemeVar, useTheme } from "./useTheme.js";
|
|
@@ -119,4 +119,4 @@ import { ActionsProps, ChildrenPropTypes, PageHeader, PageHeaderProps, TitleArea
|
|
|
119
119
|
import { SkeletonBox, SkeletonBoxProps } from "./Skeleton/SkeletonBox.js";
|
|
120
120
|
import { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps } from "./ActionMenu/ActionMenu.js";
|
|
121
121
|
import Overlay, { OverlayProps } from "./Overlay/Overlay.js";
|
|
122
|
-
export { ActionBar, type ActionBarProps, ActionList, type ActionListDescriptionProps, type ActionListDividerProps, type ActionListGroupHeadingProps, type ActionListGroupHeadingTrailingActionProps, type ActionListGroupProps, type ActionListItemProps, type ActionListLeadingVisualProps, type ActionListLinkItemProps, type ActionListProps, type ActionListTrailingActionProps, type ActionListTrailingVisualProps, ActionMenu, type ActionMenuAnchorProps, type ActionMenuButtonProps, type ActionMenuProps, AnchoredOverlay, type AnchoredOverlayProps, type AnchoredPositionHookSettings, _default as Autocomplete, type AutocompleteInputProps, type AutocompleteMenuProps, type AutocompleteOverlayProps, Avatar, type AvatarProps, AvatarStack, type AvatarStackProps, Banner, type BannerProps, BaseStyles, type BaseStylesProps, _default$1 as BranchName, type BranchNameProps, Breadcrumb, type BreadcrumbItemProps, type BreadcrumbProps, _default$2 as Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, ButtonComponent as Button, ButtonBase, type ButtonBaseProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, _default$3 as Checkbox, _default$4 as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _default$5 as CircleBadge, type CircleBadgeIconProps, type CircleBadgeProps, ConfirmationDialog, type ConfirmationDialogProps, CounterLabel, type CounterLabelProps, type CustomWidthOptions, Details, type DetailsProps, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, DragHandle, type DragHandleProps, type FCWithSlotMarker, Flash, type FlashProps, FocusKeys, type FocusTrapHookSettings, type FocusZoneHookSettings, _default$6 as FormControl, type FormControlCaptionProps, type Props as FormControlLabelProps, type FormControlProps, type FormControlValidationProps, _default$7 as Header, type HeaderItemProps, type HeaderLinkProps, type HeaderProps, Heading, type HeadingProps, IconButton, type IconButtonProps, IssueLabelToken, type IssueLabelTokenProps, Label, type LabelColorOptions, LabelGroup, type LabelGroupProps, type LabelProps, Link, LinkButton, type LinkButtonProps, type LinkProps, NavList, type NavListDividerProps, type NavListGroupHeadingProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, Overlay, type OverlayProps, PageHeader, type ActionsProps as PageHeaderActionsProps, type ChildrenPropTypes as PageHeaderChildrenPropTypes, type PageHeaderProps, type TitleAreaProps as PageHeaderTitleAreaProps, type TitleProps as PageHeaderTitleProps, PageLayout, type PageLayoutContentProps, type PageLayoutFooterProps, type PageLayoutHeaderProps, type PageLayoutPaneProps, type PageLayoutProps, Pagination, type PaginationProps, type PaneWidth, type PaneWidthValue, _default$8 as Popover, type PopoverContentProps, type PopoverProps, Portal, PortalContext, type PortalProps, ProgressBar, type ProgressBarItemProps, type ProgressBarProps, _default$9 as Radio, _default$10 as RadioGroup, type RadioGroupProps, type RadioProps, RelativeTime, type RelativeTimeProps, type ResponsiveValue, SegmentedControl, type SegmentedControlButtonProps, type SegmentedControlIconButtonProps, type SegmentedControlProps, _default$11 as Select, SelectPanel, type GroupedListProps as SelectPanelGroupedListProps, type ItemInput as SelectPanelItemInput, type FilteredActionListItemProps as SelectPanelItemProps, type SelectPanelProps, type SelectProps, _default$12 as SideNav, type SideNavLinkProps, type SideNavProps, SkeletonBox, type SkeletonBoxProps, type SlotMarker, Spinner, type SpinnerProps, SplitPageLayout, type SplitPageLayoutContentProps, type SplitPageLayoutFooterProps, type SplitPageLayoutHeaderProps, type SplitPageLayoutPaneProps, type SplitPageLayoutProps, Stack, type StackItemProps, type StackProps, StateLabel, type StateLabelProps, _default$13 as SubNav, type SubNavLinkProps, type SubNavLinksProps, type SubNavProps, _default$14 as Text, _default$15 as TextInput, type TextInputActionProps, type TextInputProps, _default$16 as TextInputWithTokens, type TextInputWithTokensProps, type TextProps, _default$17 as Textarea, type TextareaProps, ThemeProvider, type ThemeProviderProps, _default$18 as Timeline, type TimelineActionsProps, type TimelineAvatarProps, type TimelineBadgeProps, type TimelineBadgeVariant, type TimelineBodyProps, type TimelineBreakProps, type TimelineItemProps, type TimelineItemsProps, type TimelineProps, ToggleSwitch, type ToggleSwitchProps, Token, type TokenProps, Tooltip, type TooltipProps, type TouchOrMouseEvent, TreeView, type TreeViewErrorDialogProps, type TreeViewItemProps, type TreeViewProps, type TreeViewSubTreeProps, type TreeViewVisualProps, Truncate, type TruncateProps, UnderlineNav, type UnderlineNavItemProps, type UnderlineNavProps, type UsePaneWidthOptions, type UsePaneWidthResult, VisuallyHidden, type VisuallyHiddenProps, type WithSlotMarker, asSlot, createComponent, defaultPaneWidth, isSlot, registerPortalRoot, theme, useAnchoredPosition, useColorSchemeVar, useConfirm, useDetails, useFocusTrap, useFocusZone, useFormControlForwardedProps, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnEscapePress, useOnOutsideClick, useOpenAndCloseFocus, useOverlay, usePaneWidth, useProvidedRefOrCreate, useRefObjectAsForwardedRef, useResizeObserver, useResponsiveValue, useRovingTabIndex, useSafeTimeout, useSlots, useSyncedState, useTheme };
|
|
122
|
+
export { ActionBar, type ActionBarProps, ActionList, type ActionListDescriptionProps, type ActionListDividerProps, type ActionListGroupHeadingProps, type ActionListGroupHeadingTrailingActionProps, type ActionListGroupProps, type ActionListItemProps, type ActionListLeadingVisualProps, type ActionListLinkItemProps, type ActionListProps, type ActionListTrailingActionProps, type ActionListTrailingVisualProps, ActionMenu, type ActionMenuAnchorProps, type ActionMenuButtonProps, type ActionMenuProps, AnchoredOverlay, type AnchoredOverlayProps, type AnchoredPositionHookSettings, _default as Autocomplete, type AutocompleteInputProps, type AutocompleteMenuProps, type AutocompleteOverlayProps, Avatar, type AvatarProps, AvatarStack, type AvatarStackProps, Banner, type BannerProps, BaseStyles, type BaseStylesProps, _default$1 as BranchName, type BranchNameProps, Breadcrumb, type BreadcrumbItemProps, type BreadcrumbProps, _default$2 as Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, ButtonComponent as Button, ButtonBase, type ButtonBaseProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, _default$3 as Checkbox, _default$4 as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _default$5 as CircleBadge, type CircleBadgeIconProps, type CircleBadgeProps, ConfirmationDialog, type ConfirmationDialogProps, CounterLabel, type CounterLabelProps, type CustomWidthOptions, Details, type DetailsProps, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, DragHandle, type DragHandleProps, type FCWithSlotMarker, Flash, type FlashProps, FocusKeys, type FocusTrapHookSettings, type FocusZoneHookSettings, _default$6 as FormControl, type FormControlCaptionProps, type Props as FormControlLabelProps, type FormControlProps, type FormControlValidationProps, _default$7 as Header, type HeaderItemProps, type HeaderLinkProps, type HeaderProps, Heading, type HeadingProps, IconButton, type IconButtonProps, IssueLabelToken, type IssueLabelTokenProps, Label, type LabelColorOptions, LabelGroup, type LabelGroupProps, type LabelProps, Link, LinkButton, type LinkButtonProps, type LinkProps, NavList, type NavListDividerProps, type NavListGroupHeadingProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, Overlay, type OverlayProps, PageHeader, type ActionsProps as PageHeaderActionsProps, type ChildrenPropTypes as PageHeaderChildrenPropTypes, type PageHeaderProps, type TitleAreaProps as PageHeaderTitleAreaProps, type TitleProps as PageHeaderTitleProps, PageLayout, type PageLayoutContentProps, type PageLayoutFooterProps, type PageLayoutHeaderProps, type PageLayoutPaneProps, type PageLayoutProps, Pagination, type PaginationProps, type PaneWidth, type PaneWidthValue, _default$8 as Popover, type PopoverContentProps, type PopoverProps, Portal, PortalContext, type PortalProps, ProgressBar, type ProgressBarItemProps, type ProgressBarProps, _default$9 as Radio, _default$10 as RadioGroup, type RadioGroupProps, type RadioProps, RelativeTime, type RelativeTimeProps, type ResponsiveValue, SegmentedControl, type SegmentedControlButtonProps, type SegmentedControlIconButtonProps, type SegmentedControlProps, _default$11 as Select, SelectPanel, type GroupedListProps as SelectPanelGroupedListProps, type ItemInput as SelectPanelItemInput, type FilteredActionListItemProps as SelectPanelItemProps, type SelectPanelProps, type SelectProps, _default$12 as SideNav, type SideNavLinkProps, type SideNavProps, SkeletonBox, type SkeletonBoxProps, type SlotMarker, Spinner, type SpinnerProps, SplitPageLayout, type SplitPageLayoutContentProps, type SplitPageLayoutFooterProps, type SplitPageLayoutHeaderProps, type SplitPageLayoutPaneProps, type SplitPageLayoutProps, Stack, type StackItemProps, type StackProps, StateLabel, type StateLabelProps, _default$13 as SubNav, type SubNavLinkProps, type SubNavLinksProps, type SubNavProps, _default$14 as Text, _default$15 as TextInput, type TextInputActionProps, type TextInputProps, _default$16 as TextInputWithTokens, type TextInputWithTokensProps, type TextProps, _default$17 as Textarea, type TextareaProps, type ThemeColorPaths, ThemeProvider, type ThemeProviderProps, type ThemeShadowPaths, _default$18 as Timeline, type TimelineActionsProps, type TimelineAvatarProps, type TimelineBadgeProps, type TimelineBadgeVariant, type TimelineBodyProps, type TimelineBreakProps, type TimelineItemProps, type TimelineItemsProps, type TimelineProps, ToggleSwitch, type ToggleSwitchProps, Token, type TokenProps, Tooltip, type TooltipProps, type TouchOrMouseEvent, TreeView, type TreeViewErrorDialogProps, type TreeViewItemProps, type TreeViewProps, type TreeViewSubTreeProps, type TreeViewVisualProps, Truncate, type TruncateProps, UnderlineNav, type UnderlineNavItemProps, type UnderlineNavProps, type UsePaneWidthOptions, type UsePaneWidthResult, VisuallyHidden, type VisuallyHiddenProps, type WithSlotMarker, asSlot, createComponent, defaultPaneWidth, isSlot, registerPortalRoot, theme, useAnchoredPosition, useColorSchemeVar, useConfirm, useDetails, useFocusTrap, useFocusZone, useFormControlForwardedProps, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnEscapePress, useOnOutsideClick, useOpenAndCloseFocus, useOverlay, usePaneWidth, useProvidedRefOrCreate, useRefObjectAsForwardedRef, useResizeObserver, useResponsiveValue, useRovingTabIndex, useSafeTimeout, useSlots, useSyncedState, useTheme };
|