@primer/react 0.0.0-20260814130501 → 0.0.0-20260814135639
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 +24 -1
- package/dist/ActionBar/ActionBar.js +10 -8
- package/dist/ActionList/Group-d89306a8.css +2 -0
- package/dist/ActionList/Group-d89306a8.css.map +1 -0
- package/dist/ActionList/Group.module.css.js +2 -2
- package/dist/ActionList/Heading.js +2 -1
- package/dist/ActionList/Item.js +282 -277
- package/dist/ActionList/LinkItem.js +11 -3
- package/dist/ActionList/index.d.ts +3 -0
- package/dist/ActionList/shared.d.ts +4 -0
- package/dist/AvatarStack/{AvatarStack-9bb5649f.css → AvatarStack-e6a99916.css} +2 -2
- package/dist/AvatarStack/AvatarStack-e6a99916.css.map +1 -0
- package/dist/AvatarStack/AvatarStack.module.css.js +1 -1
- package/dist/CounterLabel/CounterLabel.js +5 -2
- package/dist/Details/Details.js +2 -1
- package/dist/Dialog/Dialog.js +3 -2
- package/dist/NavList/NavList.d.ts +4 -2
- package/dist/NavList/NavList.js +87 -45
- package/dist/PageHeader/PageHeader.js +2 -1
- package/dist/Popover/Popover.d.ts +1 -0
- package/dist/Popover/Popover.js +84 -47
- package/dist/Portal/Portal.js +91 -29
- package/dist/Radio/Radio.js +1 -1
- package/dist/SelectPanel/SelectPanel.js +26 -25
- package/dist/ThemeContext.d.ts +20 -0
- package/dist/ThemeProvider.d.ts +3 -0
- package/dist/ThemeProvider.js +39 -129
- package/dist/TooltipV2/Tooltip.js +3 -2
- package/dist/TreeView/TreeView.js +0 -1
- package/dist/UnderlineNav/UnderlineNav.d.ts +3 -2
- package/dist/UnderlineNav/UnderlineNav.js +1 -1
- package/dist/deprecated/ActionList/List.js +2 -1
- package/dist/experimental/SelectPanel2/SelectPanel.js +7 -4
- package/dist/hooks/useFocusZone.js +2 -1
- package/dist/hooks/useMenuInitialFocus.js +72 -57
- package/dist/internal/components/ThemeProviderBase.js +50 -0
- package/dist/internal/hooks/useThemeProvider.js +71 -0
- package/dist/legacy-theme/ts/color-schemes.js +3942 -3942
- package/dist/next/ThemeProvider.d.ts +7 -0
- package/dist/next/ThemeProvider.js +35 -0
- package/dist/next/index.d.ts +4 -1
- package/dist/next/index.js +3 -1
- package/dist/theme.d.ts +16 -54
- package/dist/useTheme.d.ts +2 -14
- package/generated/components.json +12 -1
- package/generated/hooks.json +2 -7
- package/package.json +8 -10
- package/dist/ActionList/Group-efcb39da.css +0 -2
- package/dist/ActionList/Group-efcb39da.css.map +0 -1
- package/dist/AvatarStack/AvatarStack-9bb5649f.css.map +0 -1
|
@@ -22,7 +22,7 @@ const UnderlineNav = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
|
|
|
22
22
|
const as = t1 === void 0 ? "nav" : t1;
|
|
23
23
|
const loadingCounters = t2 === void 0 ? false : t2;
|
|
24
24
|
const variant = t3 === void 0 ? "inset" : t3;
|
|
25
|
-
const hideIconsBreakpoint = t4 === void 0 ? "
|
|
25
|
+
const hideIconsBreakpoint = t4 === void 0 ? "medium" : t4;
|
|
26
26
|
const backupRef = useRef(null);
|
|
27
27
|
const navRef = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
28
28
|
const listRef = useRef(null);
|
|
@@ -59,7 +59,8 @@ const List = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
|
|
|
59
59
|
const { firstGroupStyle, lastGroupStyle, headerStyle, itemStyle } = useListVariant(restProps.variant);
|
|
60
60
|
const renderGroup = (groupProps) => {
|
|
61
61
|
var _ref;
|
|
62
|
-
|
|
62
|
+
const GroupComponent = ((_ref = "renderGroup" in groupProps && groupProps.renderGroup) !== null && _ref !== void 0 ? _ref : restProps.renderGroup) || Group;
|
|
63
|
+
return /*#__PURE__*/ createElement(GroupComponent, {
|
|
63
64
|
...groupProps,
|
|
64
65
|
key: groupProps.groupId
|
|
65
66
|
});
|
|
@@ -43,10 +43,11 @@ const responsiveButtonSizes = {
|
|
|
43
43
|
const Panel = ({ title, description, variant: propsVariant, selectionVariant = "multiple", id, defaultOpen = false, open: propsOpen, anchorRef: providedAnchorRef, anchoredPositionSettings, onCancel: propsOnCancel, onClearSelection: propsOnClearSelection, onSubmit: propsOnSubmit, width = "medium", maxHeight = "large", className, ...props }) => {
|
|
44
44
|
var _position$top, _position$left, _slots$header;
|
|
45
45
|
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
46
|
-
const
|
|
46
|
+
const responsiveVariants = Object.assign({
|
|
47
47
|
regular: "anchored",
|
|
48
48
|
narrow: "full-screen"
|
|
49
|
-
}, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant)
|
|
49
|
+
}, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant);
|
|
50
|
+
const currentVariant = useResponsiveValue(responsiveVariants, "anchored");
|
|
50
51
|
if (propsOpen !== void 0 && internalOpen !== propsOpen) setInternalOpen(propsOpen);
|
|
51
52
|
let Anchor;
|
|
52
53
|
const anchorRef = useProvidedRefOrCreate(providedAnchorRef);
|
|
@@ -348,18 +349,20 @@ const SelectPanelFooter = ({ ...props }) => {
|
|
|
348
349
|
SelectPanelFooter.displayName = "SelectPanelFooter";
|
|
349
350
|
SelectPanelFooter.__SLOT__ = Symbol("SelectPanel.Footer");
|
|
350
351
|
const SecondaryButton = (props) => {
|
|
352
|
+
const size = useResponsiveValue(responsiveButtonSizes, "small");
|
|
351
353
|
return /*#__PURE__*/ jsx(ButtonComponent, {
|
|
352
354
|
type: "button",
|
|
353
|
-
size
|
|
355
|
+
size,
|
|
354
356
|
block: true,
|
|
355
357
|
...props
|
|
356
358
|
});
|
|
357
359
|
};
|
|
358
360
|
SecondaryButton.displayName = "SecondaryButton";
|
|
359
361
|
const SecondaryLink = ({ className, ...props }) => {
|
|
362
|
+
const size = useResponsiveValue(responsiveButtonSizes, "small");
|
|
360
363
|
return /*#__PURE__*/ jsx(ButtonComponent, {
|
|
361
364
|
as: Link,
|
|
362
|
-
size
|
|
365
|
+
size,
|
|
363
366
|
variant: "invisible",
|
|
364
367
|
block: true,
|
|
365
368
|
...props,
|
|
@@ -5,7 +5,8 @@ import { FocusKeys as FocusKeys$1, focusZone } from "@primer/behaviors";
|
|
|
5
5
|
function useFocusZone(settings = {}, dependencies = []) {
|
|
6
6
|
const containerRef = useProvidedRefOrCreate(settings.containerRef);
|
|
7
7
|
const useActiveDescendant = !!settings.activeDescendantFocus;
|
|
8
|
-
const
|
|
8
|
+
const passedActiveDescendantRef = typeof settings.activeDescendantFocus === "boolean" || !settings.activeDescendantFocus ? void 0 : settings.activeDescendantFocus;
|
|
9
|
+
const activeDescendantControlRef = useProvidedRefOrCreate(passedActiveDescendantRef);
|
|
9
10
|
const disabled = settings.disabled;
|
|
10
11
|
const abortController = React.useRef();
|
|
11
12
|
useEffect(() => {
|
|
@@ -1,68 +1,83 @@
|
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { iterateFocusableElements } from "@primer/behaviors/utils";
|
|
3
4
|
//#region src/hooks/useMenuInitialFocus.ts
|
|
4
5
|
const useMenuInitialFocus = (open, containerRef, anchorRef) => {
|
|
5
|
-
|
|
6
|
-
* We need to pick the first element to focus based on how the menu was opened,
|
|
7
|
-
* however, we need to wait for the menu to be open to set focus.
|
|
8
|
-
* This is why we use set openingKey in state and have 2 effects
|
|
9
|
-
*/
|
|
6
|
+
const $ = c(9);
|
|
10
7
|
const [openingGesture, setOpeningGesture] = React.useState(void 0);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
let t0;
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== anchorRef) {
|
|
11
|
+
t0 = function inferOpeningKey() {
|
|
12
|
+
const anchorElement = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current;
|
|
13
|
+
const clickHandler = (event) => {
|
|
14
|
+
if (event.detail !== 0) setOpeningGesture("mouse-click");
|
|
15
|
+
};
|
|
16
|
+
const keydownHandler = (event_0) => {
|
|
17
|
+
if ([
|
|
18
|
+
"Space",
|
|
19
|
+
"Enter",
|
|
20
|
+
"ArrowDown",
|
|
21
|
+
"ArrowUp"
|
|
22
|
+
].includes(event_0.code)) setOpeningGesture(event_0.code);
|
|
23
|
+
};
|
|
24
|
+
anchorElement === null || anchorElement === void 0 || anchorElement.addEventListener("click", clickHandler);
|
|
25
|
+
anchorElement === null || anchorElement === void 0 || anchorElement.addEventListener("keydown", keydownHandler);
|
|
26
|
+
return () => {
|
|
27
|
+
anchorElement === null || anchorElement === void 0 || anchorElement.removeEventListener("click", clickHandler);
|
|
28
|
+
anchorElement === null || anchorElement === void 0 || anchorElement.removeEventListener("keydown", keydownHandler);
|
|
29
|
+
};
|
|
15
30
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
t1 = [anchorRef];
|
|
32
|
+
$[0] = anchorRef;
|
|
33
|
+
$[1] = t0;
|
|
34
|
+
$[2] = t1;
|
|
35
|
+
} else {
|
|
36
|
+
t0 = $[1];
|
|
37
|
+
t1 = $[2];
|
|
38
|
+
}
|
|
39
|
+
React.useEffect(t0, t1);
|
|
40
|
+
let t2;
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[3] !== anchorRef || $[4] !== containerRef || $[5] !== open || $[6] !== openingGesture) {
|
|
43
|
+
t2 = function moveFocusOnOpen() {
|
|
44
|
+
if (!open || !(containerRef !== null && containerRef !== void 0 && containerRef.current)) return;
|
|
45
|
+
const iterable = iterateFocusableElements(containerRef.current);
|
|
46
|
+
if (openingGesture === "mouse-click") if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) anchorRef.current.focus();
|
|
47
|
+
else throw new Error("For focus management, please attach anchorRef");
|
|
48
|
+
else if (openingGesture && [
|
|
20
49
|
"ArrowDown",
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
"Space",
|
|
51
|
+
"Enter"
|
|
52
|
+
].includes(openingGesture)) {
|
|
53
|
+
const firstElement = iterable.next().value;
|
|
54
|
+
setTimeout(() => firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus());
|
|
55
|
+
} else if ("ArrowUp" === openingGesture) {
|
|
56
|
+
const elements = [...iterable];
|
|
57
|
+
const lastElement = elements[elements.length - 1];
|
|
58
|
+
setTimeout(() => lastElement.focus());
|
|
59
|
+
} else {
|
|
60
|
+
const firstElement_0 = iterable.next().value;
|
|
61
|
+
setTimeout(() => firstElement_0 === null || firstElement_0 === void 0 ? void 0 : firstElement_0.focus());
|
|
62
|
+
}
|
|
29
63
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const firstElement = iterable.next().value;
|
|
48
|
-
/** We push imperative focus to the next tick to prevent React's batching */
|
|
49
|
-
setTimeout(() => firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus());
|
|
50
|
-
} else if ("ArrowUp" === openingGesture) {
|
|
51
|
-
const elements = [...iterable];
|
|
52
|
-
const lastElement = elements[elements.length - 1];
|
|
53
|
-
setTimeout(() => lastElement.focus());
|
|
54
|
-
} else {
|
|
55
|
-
/** if the menu was not opened with the anchor, we default to the first element
|
|
56
|
-
* for example: with keyboard shortcut (see stories/fixtures)
|
|
57
|
-
*/
|
|
58
|
-
const firstElement = iterable.next().value;
|
|
59
|
-
setTimeout(() => firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus());
|
|
60
|
-
}
|
|
61
|
-
}, [
|
|
62
|
-
open,
|
|
63
|
-
openingGesture,
|
|
64
|
-
anchorRef
|
|
65
|
-
]);
|
|
64
|
+
t3 = [
|
|
65
|
+
open,
|
|
66
|
+
openingGesture,
|
|
67
|
+
anchorRef,
|
|
68
|
+
containerRef
|
|
69
|
+
];
|
|
70
|
+
$[3] = anchorRef;
|
|
71
|
+
$[4] = containerRef;
|
|
72
|
+
$[5] = open;
|
|
73
|
+
$[6] = openingGesture;
|
|
74
|
+
$[7] = t2;
|
|
75
|
+
$[8] = t3;
|
|
76
|
+
} else {
|
|
77
|
+
t2 = $[7];
|
|
78
|
+
t3 = $[8];
|
|
79
|
+
}
|
|
80
|
+
React.useEffect(t2, t3);
|
|
66
81
|
};
|
|
67
82
|
//#endregion
|
|
68
83
|
export { useMenuInitialFocus };
|
|
@@ -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 };
|