@primer/react 38.36.0-rc.bd3520b7c → 38.36.0-rc.e29d259bd
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 +8 -0
- package/dist/ActionBar/ActionBar.js +10 -8
- 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/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 +2 -0
- package/dist/NavList/NavList.js +15 -11
- package/dist/PageHeader/PageHeader.js +2 -1
- package/dist/Portal/Portal.js +91 -29
- package/dist/SelectPanel/SelectPanel.js +26 -25
- 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/generated/components.json +7 -1
- package/package.json +2 -2
|
@@ -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 };
|
|
@@ -9042,7 +9042,7 @@
|
|
|
9042
9042
|
},
|
|
9043
9043
|
{
|
|
9044
9044
|
"id": "components-underlinenav-features--overflow-template",
|
|
9045
|
-
"code": "({ initialSelectedIndex = 1 }: { initialSelectedIndex?: number }) => {\n const [selectedIndex, setSelectedIndex] = React.useState<number | null>(\n initialSelectedIndex,\n )\n return (\n <UnderlineNav aria-label=\"Repository\">\n {items.map((item, index) => (\n <UnderlineNav.Item\n key={item.navigation}\n leadingVisual={item.icon}\n aria-current={index === selectedIndex ? 'page' : undefined}\n // Set so that navigation in interaction tests does not cause the\n // page to load the storybook iframe URL and instead keeps the test in\n // the local preview\n target=\"_self\"\n onSelect={(event) => {\n event.preventDefault()\n setSelectedIndex(index)\n }}\n counter={item.counter}\n href={item.href}\n >\n {item.navigation}\n </UnderlineNav.Item>\n ))}\n </UnderlineNav>\n )\n}"
|
|
9045
|
+
"code": "({ initialSelectedIndex = 1 }: { initialSelectedIndex?: number }) => {\n const [selectedIndex, setSelectedIndex] = React.useState<number | null>(\n initialSelectedIndex,\n )\n return (\n <UnderlineNav aria-label=\"Repository\" hideIconsBreakpoint=\"medium\">\n {items.map((item, index) => (\n <UnderlineNav.Item\n key={item.navigation}\n leadingVisual={item.icon}\n aria-current={index === selectedIndex ? 'page' : undefined}\n // Set so that navigation in interaction tests does not cause the\n // page to load the storybook iframe URL and instead keeps the test in\n // the local preview\n target=\"_self\"\n onSelect={(event) => {\n event.preventDefault()\n setSelectedIndex(index)\n }}\n counter={item.counter}\n href={item.href}\n >\n {item.navigation}\n </UnderlineNav.Item>\n ))}\n </UnderlineNav>\n )\n}"
|
|
9046
9046
|
},
|
|
9047
9047
|
{
|
|
9048
9048
|
"id": "components-underlinenav-features--overflow-on-narrow-screen",
|
|
@@ -9078,6 +9078,12 @@
|
|
|
9078
9078
|
"defaultValue": "false",
|
|
9079
9079
|
"description": "Whether the navigation items are in loading state. Component waits for all the counters to finish loading to prevent multiple layout shifts."
|
|
9080
9080
|
},
|
|
9081
|
+
{
|
|
9082
|
+
"name": "hideIconsBreakpoint",
|
|
9083
|
+
"type": "'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | null",
|
|
9084
|
+
"defaultValue": "'medium'",
|
|
9085
|
+
"description": "Controls the container width below which icons are hidden to save space. To keep icons visible in a narrow container, use a smaller breakpoint such as `xsmall`, or set to `null` to always show icons."
|
|
9086
|
+
},
|
|
9081
9087
|
{
|
|
9082
9088
|
"name": "variant",
|
|
9083
9089
|
"type": "'inset' | 'flush'",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "38.36.0-rc.
|
|
4
|
+
"version": "38.36.0-rc.e29d259bd",
|
|
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",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
"react-is": "18.3.1",
|
|
167
167
|
"recast": "0.23.7",
|
|
168
168
|
"rimraf": "5.0.5",
|
|
169
|
-
"rolldown": "^1.2.
|
|
169
|
+
"rolldown": "^1.2.2",
|
|
170
170
|
"rolldown-plugin-dts": "^0.26.0",
|
|
171
171
|
"rolldown-plugin-import-css": "^0.0.0",
|
|
172
172
|
"rolldown-plugin-preserve-directives": "^0.0.0",
|