@primer/react 0.0.0-20260623191506 → 0.0.0-20260623204153
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 -9
- package/dist/NavList/NavList-5dc067e3.css +2 -0
- package/dist/NavList/NavList-5dc067e3.css.map +1 -0
- package/dist/NavList/NavList.d.ts +4 -17
- package/dist/NavList/NavList.d.ts.map +1 -1
- package/dist/NavList/NavList.js +70 -238
- package/dist/NavList/NavList.module.css.js +2 -2
- package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNav.js +36 -4
- package/generated/components.json +3 -37
- package/package.json +1 -1
- package/dist/NavList/NavList-b50d982b.css +0 -2
- package/dist/NavList/NavList-b50d982b.css.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- [#8031](https://github.com/primer/react/pull/8031) [`10048b5`](https://github.com/primer/react/commit/10048b5d5e02dfc7bdb595683b43d2d26cb82ccd) Thanks [@janmaarten-a11y](https://github.com/janmaarten-a11y)! - Add a `NavList.Heading` slot that names the navigation region. It renders an `h2`
|
|
8
|
-
by default (configurable to `h3` via `as`), supports a `visuallyHidden` variant,
|
|
9
|
-
labels the `nav` landmark via `aria-labelledby`, and makes `NavList.Group`
|
|
10
|
-
headings default to one level deeper (`h3`, or `h4` under an `h3` heading) for a
|
|
11
|
-
correct heading hierarchy.
|
|
3
|
+
## 0.0.0-20260623204153
|
|
12
4
|
|
|
13
5
|
### Patch Changes
|
|
14
6
|
|
|
@@ -22,6 +14,8 @@
|
|
|
22
14
|
|
|
23
15
|
- [#8021](https://github.com/primer/react/pull/8021) [`6131a94`](https://github.com/primer/react/commit/6131a9424b5bd5bb98b7ae05771d8187fe2f58cd) Thanks [@mattcosta7](https://github.com/mattcosta7)! - TextInput: Improve typing performance by deriving the character counter in render instead of in effects, removing extra re-renders on each keystroke.
|
|
24
16
|
|
|
17
|
+
- [#8037](https://github.com/primer/react/pull/8037) [`7749e0d`](https://github.com/primer/react/commit/7749e0da6eaf7baec66a106846e8159880cd434f) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Fix `UnderlineNav` not re-rendering when child tabs are added, removed, or reordered.
|
|
18
|
+
|
|
25
19
|
## 38.29.0
|
|
26
20
|
|
|
27
21
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/NavList/NavList.module.css.js"],"names":[],"mappings":"AAAA,kCACE,oCAA6B,CAC7B,uBACF,CAEA,wCACE,iCAA0B,CAA1B,yBACF","file":"NavList-5dc067e3.css","sourcesContent":[".GroupHeading > a {\n color: var(--fgColor-default);\n text-decoration: inherit;\n}\n\n.GroupHeading > a:hover {\n text-decoration: underline;\n}\n"]}
|
|
@@ -3,21 +3,9 @@ import type { ForwardRefComponent as PolymorphicForwardRefComponent } from '../u
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import type { ActionListTrailingActionProps, ActionListDividerProps, ActionListLeadingVisualProps, ActionListTrailingVisualProps, ActionListGroupHeadingProps } from '../ActionList';
|
|
5
5
|
import { type PolymorphicProps } from '../utils/modern-polymorphic';
|
|
6
|
-
import type { FCWithSlotMarker } from '../utils/types/Slots';
|
|
7
|
-
type NavListHeadingLevels = 'h2' | 'h3';
|
|
8
6
|
export type NavListProps = {
|
|
9
7
|
children: React.ReactNode;
|
|
10
8
|
} & React.ComponentProps<'nav'>;
|
|
11
|
-
export type NavListHeadingProps = {
|
|
12
|
-
/** Semantic heading level for the NavList. Also sets the default level for child group headings, which render one level deeper. */
|
|
13
|
-
as?: NavListHeadingLevels;
|
|
14
|
-
/** Visually hide the heading while keeping it available to assistive technology. */
|
|
15
|
-
visuallyHidden?: boolean;
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
className?: string;
|
|
18
|
-
id?: string;
|
|
19
|
-
style?: React.CSSProperties;
|
|
20
|
-
};
|
|
21
9
|
export type NavListItemProps<As extends React.ElementType = React.ElementType> = PolymorphicProps<As, 'a', {
|
|
22
10
|
children: React.ReactNode;
|
|
23
11
|
defaultOpen?: boolean;
|
|
@@ -52,8 +40,7 @@ export type NavListGroupExpandProps = {
|
|
|
52
40
|
export declare const GroupExpand: React.ForwardRefExoticComponent<NavListGroupExpandProps & React.RefAttributes<HTMLButtonElement>>;
|
|
53
41
|
export type NavListGroupHeadingProps = ActionListGroupHeadingProps;
|
|
54
42
|
export declare const NavList: React.ForwardRefExoticComponent<Omit<NavListProps, "ref"> & React.RefAttributes<HTMLElement>> & {
|
|
55
|
-
Description: FCWithSlotMarker<React.PropsWithChildren<import("..").ActionListDescriptionProps>>;
|
|
56
|
-
Heading: FCWithSlotMarker<NavListHeadingProps>;
|
|
43
|
+
Description: import("..").FCWithSlotMarker<React.PropsWithChildren<import("..").ActionListDescriptionProps>>;
|
|
57
44
|
Item: (<As extends React.ElementType = "a">(props: import("../utils/modern-polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
|
|
58
45
|
children: React.ReactNode;
|
|
59
46
|
defaultOpen?: boolean;
|
|
@@ -66,10 +53,10 @@ export declare const NavList: React.ForwardRefExoticComponent<Omit<NavListProps,
|
|
|
66
53
|
displayName: string;
|
|
67
54
|
};
|
|
68
55
|
SubNav: PolymorphicForwardRefComponent<"ul", NavListSubNavProps>;
|
|
69
|
-
LeadingVisual: FCWithSlotMarker<React.PropsWithChildren<import("../ActionList/Visuals").VisualProps>>;
|
|
70
|
-
TrailingVisual: FCWithSlotMarker<React.PropsWithChildren<import("../ActionList/Visuals").VisualProps>>;
|
|
56
|
+
LeadingVisual: import("..").FCWithSlotMarker<React.PropsWithChildren<import("../ActionList/Visuals").VisualProps>>;
|
|
57
|
+
TrailingVisual: import("..").FCWithSlotMarker<React.PropsWithChildren<import("../ActionList/Visuals").VisualProps>>;
|
|
71
58
|
TrailingAction: PolymorphicForwardRefComponent<"a" | "button", ActionListTrailingActionProps>;
|
|
72
|
-
Divider: FCWithSlotMarker<React.PropsWithChildren<ActionListDividerProps>>;
|
|
59
|
+
Divider: import("..").FCWithSlotMarker<React.PropsWithChildren<ActionListDividerProps>>;
|
|
73
60
|
Group: React.FC<NavListGroupProps>;
|
|
74
61
|
GroupExpand: React.ForwardRefExoticComponent<NavListGroupExpandProps & React.RefAttributes<HTMLButtonElement>>;
|
|
75
62
|
GroupHeading: React.FC<ActionListGroupHeadingProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavList.d.ts","sourceRoot":"","sources":["../../src/NavList/NavList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,IAAI,EAAC,MAAM,wBAAwB,CAAA;AAC3E,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAC/F,OAAO,KAAuB,MAAM,OAAO,CAAA;AAE3C,OAAO,KAAK,EACV,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,eAAe,CAAA;AAUtB,OAAO,EAAkB,KAAK,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"NavList.d.ts","sourceRoot":"","sources":["../../src/NavList/NavList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,IAAI,EAAC,MAAM,wBAAwB,CAAA;AAC3E,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAC/F,OAAO,KAAuB,MAAM,OAAO,CAAA;AAE3C,OAAO,KAAK,EACV,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,eAAe,CAAA;AAUtB,OAAO,EAAkB,KAAK,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAKlF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;AAqB/B,MAAM,MAAM,gBAAgB,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,gBAAgB,CAC/F,EAAE,EACF,GAAG,EACH;IACE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CACF,CAAA;AAkJD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAwCD,MAAM,MAAM,yBAAyB,GAAG,4BAA4B,CAAA;AASpE,MAAM,MAAM,0BAA0B,GAAG,6BAA6B,CAAA;AAStE,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,CAAA;AAQxD,MAAM,MAAM,0BAA0B,GAAG,6BAA6B,CAAA;AAStE,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG;IACpE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAqBD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IAC9B,aAAa,CAAC,EAAE,IAAI,CAAA;IACpB,cAAc,CAAC,EAAE,6BAA6B,CAAA;IAC9C,0BAA0B,CAAC,EAAE,MAAM,CAAA;CACpC,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;AAEtC,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,KAAK,CAAC,SAAS,CAAA;CAClD,CAAA;AAED,eAAO,MAAM,WAAW,mGAgFvB,CAAA;AAKD,MAAM,MAAM,wBAAwB,GAAG,2BAA2B,CAAA;AAqBlE,eAAO,MAAM,OAAO;;YA7WjB,EAAE,SAAS,KAAK,CAAC,WAAW;kBATjB,KAAK,CAAC,SAAS;sBACX,OAAO;eACd,MAAM;yBACI,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO;uBAC7E,MAAM;;;;;;;;;;;;;;CA6XvB,CAAA"}
|
package/dist/NavList/NavList.js
CHANGED
|
@@ -12,210 +12,65 @@ import navListClasses from './NavList.module.css.js';
|
|
|
12
12
|
import { flushSync } from 'react-dom';
|
|
13
13
|
import { useSlots } from '../hooks/useSlots.js';
|
|
14
14
|
import { fixedForwardRef } from '../utils/modern-polymorphic.js';
|
|
15
|
-
import
|
|
16
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
17
|
-
import Heading$1 from '../Heading/Heading.js';
|
|
18
|
-
|
|
19
|
-
// Publishes the resolved numeric level of a NavList.Heading (e.g. 2 for an h2) so
|
|
20
|
-
// NavList.Group/NavList.GroupHeading can default to one level deeper. `null` when
|
|
21
|
-
// there is no NavList.Heading, in which case groups keep their historical h3 default.
|
|
22
|
-
const NavListHeadingLevelContext = /*#__PURE__*/React.createContext(null);
|
|
23
|
-
function headingTagToLevel(as) {
|
|
24
|
-
return Number.parseInt(as.slice(1), 10);
|
|
25
|
-
}
|
|
26
|
-
function levelToHeadingTag(level) {
|
|
27
|
-
// Clamp to h4 so group headings never go deeper than the supported hierarchy.
|
|
28
|
-
const clamped = Math.min(Math.max(level, 1), 4);
|
|
29
|
-
return `h${clamped}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ----------------------------------------------------------------------------
|
|
33
|
-
// NavList
|
|
15
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
34
16
|
|
|
35
17
|
const Root = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
36
|
-
|
|
37
|
-
const $ = c(24);
|
|
38
|
-
let ariaLabel;
|
|
39
|
-
let ariaLabelledby;
|
|
18
|
+
const $ = c(10);
|
|
40
19
|
let children;
|
|
41
20
|
let props;
|
|
42
21
|
if ($[0] !== t0) {
|
|
43
22
|
({
|
|
44
23
|
children,
|
|
45
|
-
"aria-label": ariaLabel,
|
|
46
|
-
"aria-labelledby": ariaLabelledby,
|
|
47
24
|
...props
|
|
48
25
|
} = t0);
|
|
49
26
|
$[0] = t0;
|
|
50
|
-
$[1] =
|
|
51
|
-
$[2] =
|
|
52
|
-
$[3] = children;
|
|
53
|
-
$[4] = props;
|
|
27
|
+
$[1] = children;
|
|
28
|
+
$[2] = props;
|
|
54
29
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
children = $[3];
|
|
58
|
-
props = $[4];
|
|
30
|
+
children = $[1];
|
|
31
|
+
props = $[2];
|
|
59
32
|
}
|
|
60
33
|
let t1;
|
|
61
|
-
if ($[
|
|
34
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
62
35
|
t1 = {
|
|
63
|
-
heading: Heading
|
|
64
|
-
};
|
|
65
|
-
$[5] = t1;
|
|
66
|
-
} else {
|
|
67
|
-
t1 = $[5];
|
|
68
|
-
}
|
|
69
|
-
const [slots, childrenWithoutHeading] = useSlots(children, t1);
|
|
70
|
-
const fallbackHeadingId = useId();
|
|
71
|
-
const heading = slots.heading;
|
|
72
|
-
const headingId = heading ? (_heading$props$id = heading.props.id) !== null && _heading$props$id !== void 0 ? _heading$props$id : fallbackHeadingId : undefined;
|
|
73
|
-
let t2;
|
|
74
|
-
if ($[6] !== heading) {
|
|
75
|
-
var _heading$props$as;
|
|
76
|
-
t2 = heading ? headingTagToLevel((_heading$props$as = heading.props.as) !== null && _heading$props$as !== void 0 ? _heading$props$as : "h2") : null;
|
|
77
|
-
$[6] = heading;
|
|
78
|
-
$[7] = t2;
|
|
79
|
-
} else {
|
|
80
|
-
t2 = $[7];
|
|
81
|
-
}
|
|
82
|
-
const headingLevel = t2;
|
|
83
|
-
const navLabelledby = (_ariaLabelledby = ariaLabelledby) !== null && _ariaLabelledby !== void 0 ? _ariaLabelledby : ariaLabel ? undefined : headingId;
|
|
84
|
-
let t3;
|
|
85
|
-
if ($[8] !== heading || $[9] !== headingId) {
|
|
86
|
-
t3 = heading ? /*#__PURE__*/React.cloneElement(heading, {
|
|
87
|
-
id: headingId
|
|
88
|
-
}) : null;
|
|
89
|
-
$[8] = heading;
|
|
90
|
-
$[9] = headingId;
|
|
91
|
-
$[10] = t3;
|
|
92
|
-
} else {
|
|
93
|
-
t3 = $[10];
|
|
94
|
-
}
|
|
95
|
-
let t4;
|
|
96
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
97
|
-
t4 = {
|
|
98
36
|
container: "NavList"
|
|
99
37
|
};
|
|
100
|
-
$[
|
|
38
|
+
$[3] = t1;
|
|
101
39
|
} else {
|
|
102
|
-
|
|
40
|
+
t1 = $[3];
|
|
103
41
|
}
|
|
104
|
-
let
|
|
105
|
-
if ($[
|
|
106
|
-
|
|
107
|
-
value:
|
|
42
|
+
let t2;
|
|
43
|
+
if ($[4] !== children) {
|
|
44
|
+
t2 = /*#__PURE__*/jsx(ActionListContainerContext.Provider, {
|
|
45
|
+
value: t1,
|
|
108
46
|
children: /*#__PURE__*/jsx(ActionList, {
|
|
109
|
-
children:
|
|
47
|
+
children: children
|
|
110
48
|
})
|
|
111
49
|
});
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
} else {
|
|
115
|
-
t5 = $[13];
|
|
116
|
-
}
|
|
117
|
-
let t6;
|
|
118
|
-
if ($[14] !== headingLevel || $[15] !== t3 || $[16] !== t5) {
|
|
119
|
-
t6 = /*#__PURE__*/jsxs(NavListHeadingLevelContext.Provider, {
|
|
120
|
-
value: headingLevel,
|
|
121
|
-
children: [t3, t5]
|
|
122
|
-
});
|
|
123
|
-
$[14] = headingLevel;
|
|
124
|
-
$[15] = t3;
|
|
125
|
-
$[16] = t5;
|
|
126
|
-
$[17] = t6;
|
|
50
|
+
$[4] = children;
|
|
51
|
+
$[5] = t2;
|
|
127
52
|
} else {
|
|
128
|
-
|
|
53
|
+
t2 = $[5];
|
|
129
54
|
}
|
|
130
|
-
let
|
|
131
|
-
if ($[
|
|
132
|
-
|
|
55
|
+
let t3;
|
|
56
|
+
if ($[6] !== props || $[7] !== ref || $[8] !== t2) {
|
|
57
|
+
t3 = /*#__PURE__*/jsx("nav", {
|
|
133
58
|
...props,
|
|
134
|
-
"aria-label": ariaLabel,
|
|
135
|
-
"aria-labelledby": navLabelledby,
|
|
136
59
|
ref: ref,
|
|
137
60
|
"data-component": "NavList",
|
|
138
|
-
children:
|
|
61
|
+
children: t2
|
|
139
62
|
});
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[22] = t6;
|
|
145
|
-
$[23] = t7;
|
|
63
|
+
$[6] = props;
|
|
64
|
+
$[7] = ref;
|
|
65
|
+
$[8] = t2;
|
|
66
|
+
$[9] = t3;
|
|
146
67
|
} else {
|
|
147
|
-
|
|
68
|
+
t3 = $[9];
|
|
148
69
|
}
|
|
149
|
-
return
|
|
70
|
+
return t3;
|
|
150
71
|
});
|
|
151
72
|
Root.displayName = 'NavList';
|
|
152
73
|
|
|
153
|
-
// ----------------------------------------------------------------------------
|
|
154
|
-
// NavList.Heading
|
|
155
|
-
|
|
156
|
-
const Heading = t0 => {
|
|
157
|
-
const $ = c(14);
|
|
158
|
-
let children;
|
|
159
|
-
let className;
|
|
160
|
-
let props;
|
|
161
|
-
let t1;
|
|
162
|
-
let t2;
|
|
163
|
-
if ($[0] !== t0) {
|
|
164
|
-
({
|
|
165
|
-
as: t1,
|
|
166
|
-
visuallyHidden: t2,
|
|
167
|
-
className,
|
|
168
|
-
children,
|
|
169
|
-
...props
|
|
170
|
-
} = t0);
|
|
171
|
-
$[0] = t0;
|
|
172
|
-
$[1] = children;
|
|
173
|
-
$[2] = className;
|
|
174
|
-
$[3] = props;
|
|
175
|
-
$[4] = t1;
|
|
176
|
-
$[5] = t2;
|
|
177
|
-
} else {
|
|
178
|
-
children = $[1];
|
|
179
|
-
className = $[2];
|
|
180
|
-
props = $[3];
|
|
181
|
-
t1 = $[4];
|
|
182
|
-
t2 = $[5];
|
|
183
|
-
}
|
|
184
|
-
const as = t1 === undefined ? "h2" : t1;
|
|
185
|
-
const visuallyHidden = t2 === undefined ? false : t2;
|
|
186
|
-
const t3 = visuallyHidden ? visuallyHiddenClasses.InternalVisuallyHidden : navListClasses.Heading;
|
|
187
|
-
let t4;
|
|
188
|
-
if ($[6] !== className || $[7] !== t3) {
|
|
189
|
-
t4 = clsx(t3, className);
|
|
190
|
-
$[6] = className;
|
|
191
|
-
$[7] = t3;
|
|
192
|
-
$[8] = t4;
|
|
193
|
-
} else {
|
|
194
|
-
t4 = $[8];
|
|
195
|
-
}
|
|
196
|
-
let t5;
|
|
197
|
-
if ($[9] !== as || $[10] !== children || $[11] !== props || $[12] !== t4) {
|
|
198
|
-
t5 = /*#__PURE__*/jsx(Heading$1, {
|
|
199
|
-
as: as,
|
|
200
|
-
variant: "small",
|
|
201
|
-
className: t4,
|
|
202
|
-
"data-component": "NavList.Heading",
|
|
203
|
-
...props,
|
|
204
|
-
children: children
|
|
205
|
-
});
|
|
206
|
-
$[9] = as;
|
|
207
|
-
$[10] = children;
|
|
208
|
-
$[11] = props;
|
|
209
|
-
$[12] = t4;
|
|
210
|
-
$[13] = t5;
|
|
211
|
-
} else {
|
|
212
|
-
t5 = $[13];
|
|
213
|
-
}
|
|
214
|
-
return t5;
|
|
215
|
-
};
|
|
216
|
-
Heading.displayName = 'NavList.Heading';
|
|
217
|
-
Heading.__SLOT__ = Symbol('NavList.Heading');
|
|
218
|
-
|
|
219
74
|
// ----------------------------------------------------------------------------
|
|
220
75
|
// NavList.Item
|
|
221
76
|
|
|
@@ -543,7 +398,7 @@ TrailingAction.displayName = 'NavList.TrailingAction';
|
|
|
543
398
|
// NavList.Group
|
|
544
399
|
|
|
545
400
|
const Group = t0 => {
|
|
546
|
-
const $ = c(
|
|
401
|
+
const $ = c(11);
|
|
547
402
|
let children;
|
|
548
403
|
let props;
|
|
549
404
|
let title;
|
|
@@ -562,52 +417,41 @@ const Group = t0 => {
|
|
|
562
417
|
props = $[2];
|
|
563
418
|
title = $[3];
|
|
564
419
|
}
|
|
565
|
-
const headingLevel = React.useContext(NavListHeadingLevelContext);
|
|
566
420
|
let t1;
|
|
567
|
-
if ($[4]
|
|
568
|
-
t1 =
|
|
569
|
-
$[4] =
|
|
570
|
-
$[5] = t1;
|
|
421
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
422
|
+
t1 = /*#__PURE__*/jsx(ActionList.Divider, {});
|
|
423
|
+
$[4] = t1;
|
|
571
424
|
} else {
|
|
572
|
-
t1 = $[
|
|
425
|
+
t1 = $[4];
|
|
573
426
|
}
|
|
574
|
-
const groupHeadingAs = t1;
|
|
575
427
|
let t2;
|
|
576
|
-
if ($[
|
|
577
|
-
t2 = /*#__PURE__*/jsx(ActionList.
|
|
578
|
-
|
|
579
|
-
} else {
|
|
580
|
-
t2 = $[6];
|
|
581
|
-
}
|
|
582
|
-
let t3;
|
|
583
|
-
if ($[7] !== groupHeadingAs || $[8] !== title) {
|
|
584
|
-
t3 = title ? /*#__PURE__*/jsx(ActionList.GroupHeading, {
|
|
585
|
-
as: groupHeadingAs,
|
|
428
|
+
if ($[5] !== title) {
|
|
429
|
+
t2 = title ? /*#__PURE__*/jsx(ActionList.GroupHeading, {
|
|
430
|
+
as: "h3",
|
|
586
431
|
"data-component": "ActionList.GroupHeading",
|
|
587
432
|
children: title
|
|
588
433
|
}) : null;
|
|
589
|
-
$[
|
|
590
|
-
$[
|
|
591
|
-
$[9] = t3;
|
|
434
|
+
$[5] = title;
|
|
435
|
+
$[6] = t2;
|
|
592
436
|
} else {
|
|
593
|
-
|
|
437
|
+
t2 = $[6];
|
|
594
438
|
}
|
|
595
|
-
let
|
|
596
|
-
if ($[
|
|
597
|
-
|
|
598
|
-
children: [
|
|
439
|
+
let t3;
|
|
440
|
+
if ($[7] !== children || $[8] !== props || $[9] !== t2) {
|
|
441
|
+
t3 = /*#__PURE__*/jsxs(Fragment, {
|
|
442
|
+
children: [t1, /*#__PURE__*/jsxs(ActionList.Group, {
|
|
599
443
|
...props,
|
|
600
|
-
children: [
|
|
444
|
+
children: [t2, children]
|
|
601
445
|
})]
|
|
602
446
|
});
|
|
603
|
-
$[
|
|
604
|
-
$[
|
|
605
|
-
$[
|
|
606
|
-
$[
|
|
447
|
+
$[7] = children;
|
|
448
|
+
$[8] = props;
|
|
449
|
+
$[9] = t2;
|
|
450
|
+
$[10] = t3;
|
|
607
451
|
} else {
|
|
608
|
-
|
|
452
|
+
t3 = $[10];
|
|
609
453
|
}
|
|
610
|
-
return
|
|
454
|
+
return t3;
|
|
611
455
|
};
|
|
612
456
|
// ----------------------------------------------------------------------------
|
|
613
457
|
// NavList.GroupExpand
|
|
@@ -749,60 +593,49 @@ const GroupExpand = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
749
593
|
* It was primarily added to allow links in group headings.
|
|
750
594
|
*/
|
|
751
595
|
const GroupHeading = t0 => {
|
|
752
|
-
const $ = c(
|
|
753
|
-
let as;
|
|
596
|
+
const $ = c(10);
|
|
754
597
|
let className;
|
|
755
598
|
let rest;
|
|
599
|
+
let t1;
|
|
756
600
|
if ($[0] !== t0) {
|
|
757
601
|
({
|
|
758
|
-
as,
|
|
602
|
+
as: t1,
|
|
759
603
|
className,
|
|
760
604
|
...rest
|
|
761
605
|
} = t0);
|
|
762
606
|
$[0] = t0;
|
|
763
|
-
$[1] =
|
|
764
|
-
$[2] =
|
|
765
|
-
$[3] =
|
|
766
|
-
} else {
|
|
767
|
-
as = $[1];
|
|
768
|
-
className = $[2];
|
|
769
|
-
rest = $[3];
|
|
770
|
-
}
|
|
771
|
-
const headingLevel = React.useContext(NavListHeadingLevelContext);
|
|
772
|
-
let t1;
|
|
773
|
-
if ($[4] !== as || $[5] !== headingLevel) {
|
|
774
|
-
var _as;
|
|
775
|
-
t1 = (_as = as) !== null && _as !== void 0 ? _as : headingLevel ? levelToHeadingTag(headingLevel + 1) : "h3";
|
|
776
|
-
$[4] = as;
|
|
777
|
-
$[5] = headingLevel;
|
|
778
|
-
$[6] = t1;
|
|
607
|
+
$[1] = className;
|
|
608
|
+
$[2] = rest;
|
|
609
|
+
$[3] = t1;
|
|
779
610
|
} else {
|
|
780
|
-
|
|
611
|
+
className = $[1];
|
|
612
|
+
rest = $[2];
|
|
613
|
+
t1 = $[3];
|
|
781
614
|
}
|
|
782
|
-
const
|
|
615
|
+
const as = t1 === undefined ? "h3" : t1;
|
|
783
616
|
let t2;
|
|
784
|
-
if ($[
|
|
617
|
+
if ($[4] !== className) {
|
|
785
618
|
t2 = clsx(navListClasses.GroupHeading, className);
|
|
786
|
-
$[
|
|
787
|
-
$[
|
|
619
|
+
$[4] = className;
|
|
620
|
+
$[5] = t2;
|
|
788
621
|
} else {
|
|
789
|
-
t2 = $[
|
|
622
|
+
t2 = $[5];
|
|
790
623
|
}
|
|
791
624
|
let t3;
|
|
792
|
-
if ($[
|
|
625
|
+
if ($[6] !== as || $[7] !== rest || $[8] !== t2) {
|
|
793
626
|
t3 = /*#__PURE__*/jsx(ActionList.GroupHeading, {
|
|
794
|
-
as:
|
|
627
|
+
as: as,
|
|
795
628
|
className: t2,
|
|
796
629
|
"data-component": "NavList.GroupHeading",
|
|
797
630
|
headingWrapElement: "li",
|
|
798
631
|
...rest
|
|
799
632
|
});
|
|
800
|
-
$[
|
|
801
|
-
$[
|
|
802
|
-
$[
|
|
803
|
-
$[
|
|
633
|
+
$[6] = as;
|
|
634
|
+
$[7] = rest;
|
|
635
|
+
$[8] = t2;
|
|
636
|
+
$[9] = t3;
|
|
804
637
|
} else {
|
|
805
|
-
t3 = $[
|
|
638
|
+
t3 = $[9];
|
|
806
639
|
}
|
|
807
640
|
return t3;
|
|
808
641
|
};
|
|
@@ -812,7 +645,6 @@ const GroupHeading = t0 => {
|
|
|
812
645
|
|
|
813
646
|
const NavList = Object.assign(Root, {
|
|
814
647
|
Description: ActionList.Description,
|
|
815
|
-
Heading,
|
|
816
648
|
Item,
|
|
817
649
|
SubNav,
|
|
818
650
|
LeadingVisual,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './NavList-
|
|
1
|
+
import './NavList-5dc067e3.css';
|
|
2
2
|
|
|
3
|
-
var navListClasses = {"
|
|
3
|
+
var navListClasses = {"GroupHeading":"prc-NavList-GroupHeading-mN50z"};
|
|
4
4
|
|
|
5
5
|
export { navListClasses as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAqBtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAsGhC,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAqBtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAsGhC,eAAO,MAAM,YAAY,mFAqUxB,CAAA"}
|
|
@@ -142,19 +142,46 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
142
142
|
menuItems: []
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
+
// The ordered signature drives `useResizeObserver` deps below so it re-fires whenever
|
|
146
|
+
// children are added, removed, or reordered.
|
|
147
|
+
const childrenSignature = validChildren.map(child => {
|
|
148
|
+
var _child$key;
|
|
149
|
+
return String((_child$key = child.key) !== null && _child$key !== void 0 ? _child$key : '');
|
|
150
|
+
}).join('|');
|
|
151
|
+
|
|
152
|
+
// `childrenChanged` only tracks membership (set of keys), not order. This is intentional
|
|
153
|
+
// because `swapMenuItemWithListItem` legitimately reorders `responsiveProps.items` (to keep
|
|
154
|
+
// the selected item visible), and we don't want that to be treated as a stale-children
|
|
155
|
+
// situation. We only need to fall back to rendering `validChildren` directly when a child
|
|
156
|
+
// was actually added or removed (so a new item isn't missed and a removed item isn't kept).
|
|
157
|
+
const responsiveKeys = new Set();
|
|
158
|
+
for (const item of responsiveProps.items) {
|
|
159
|
+
var _item$key;
|
|
160
|
+
responsiveKeys.add(String((_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : ''));
|
|
161
|
+
}
|
|
162
|
+
for (const item of responsiveProps.menuItems) {
|
|
163
|
+
var _item$key2;
|
|
164
|
+
responsiveKeys.add(String((_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : ''));
|
|
165
|
+
}
|
|
166
|
+
const validKeys = validChildren.map(child => {
|
|
167
|
+
var _child$key2;
|
|
168
|
+
return String((_child$key2 = child.key) !== null && _child$key2 !== void 0 ? _child$key2 : '');
|
|
169
|
+
});
|
|
170
|
+
const childrenChanged = validKeys.length !== responsiveKeys.size || validKeys.some(key => !responsiveKeys.has(key));
|
|
171
|
+
|
|
145
172
|
// Make sure to have the fresh props data for list items when children are changed (keeping aria-current up-to-date)
|
|
146
|
-
const listItems = responsiveProps.items.map(item => {
|
|
173
|
+
const listItems = childrenChanged ? validChildren : responsiveProps.items.map(item => {
|
|
147
174
|
var _validChildren$find;
|
|
148
175
|
return (_validChildren$find = validChildren.find(child => child.key === item.key)) !== null && _validChildren$find !== void 0 ? _validChildren$find : item;
|
|
149
176
|
});
|
|
150
177
|
|
|
151
178
|
// Make sure to have the fresh props data for menu items when children are changed (keeping aria-current up-to-date)
|
|
152
|
-
const menuItems = responsiveProps.menuItems.map(menuItem => {
|
|
179
|
+
const menuItems = childrenChanged ? [] : responsiveProps.menuItems.map(menuItem => {
|
|
153
180
|
var _validChildren$find2;
|
|
154
181
|
return (_validChildren$find2 = validChildren.find(child => child.key === menuItem.key)) !== null && _validChildren$find2 !== void 0 ? _validChildren$find2 : menuItem;
|
|
155
182
|
});
|
|
156
183
|
// This is the case where the viewport is too narrow to show any list item with the more menu. In this case, we only show the dropdown
|
|
157
|
-
const onlyMenuVisible = responsiveProps.items.length === 0;
|
|
184
|
+
const onlyMenuVisible = !childrenChanged && responsiveProps.items.length === 0;
|
|
158
185
|
useDevOnlyEffect(() => {
|
|
159
186
|
// Address illegal state where there are multiple items that have `aria-current='page'` attribute
|
|
160
187
|
const activeElements = validChildren.filter(child => {
|
|
@@ -248,12 +275,17 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
248
275
|
containerRef,
|
|
249
276
|
ignoreClickRefs: [moreMenuBtnRef]
|
|
250
277
|
});
|
|
278
|
+
|
|
279
|
+
// The resize observer fires when the nav element resizes, and re-observes (firing the
|
|
280
|
+
// callback again with current size) whenever its deps change. Passing `childrenSignature`
|
|
281
|
+
// ensures the overflow calculation re-runs when child tabs are added, removed, or
|
|
282
|
+
// reordered. See https://github.com/github/primer/issues/6389.
|
|
251
283
|
useResizeObserver(resizeObserverEntries => {
|
|
252
284
|
var _moreMenuRef$current$, _moreMenuRef$current;
|
|
253
285
|
const navWidth = resizeObserverEntries[0].contentRect.width;
|
|
254
286
|
const moreMenuWidth = (_moreMenuRef$current$ = (_moreMenuRef$current = moreMenuRef.current) === null || _moreMenuRef$current === void 0 ? void 0 : _moreMenuRef$current.getBoundingClientRect().width) !== null && _moreMenuRef$current$ !== void 0 ? _moreMenuRef$current$ : 0;
|
|
255
287
|
navWidth !== 0 && overflowEffect(navWidth, moreMenuWidth, validChildren, childWidthArray, noIconChildWidthArray, updateListAndMenu);
|
|
256
|
-
}, navRef);
|
|
288
|
+
}, navRef, [childrenSignature]);
|
|
257
289
|
|
|
258
290
|
// Compute menuInlineStyles if needed
|
|
259
291
|
let menuInlineStyles = {
|
|
@@ -4169,41 +4169,6 @@
|
|
|
4169
4169
|
}
|
|
4170
4170
|
],
|
|
4171
4171
|
"subcomponents": [
|
|
4172
|
-
{
|
|
4173
|
-
"name": "NavList.Heading",
|
|
4174
|
-
"props": [
|
|
4175
|
-
{
|
|
4176
|
-
"name": "as",
|
|
4177
|
-
"type": "'h2' | 'h3'",
|
|
4178
|
-
"defaultValue": "\"h2\"",
|
|
4179
|
-
"required": false,
|
|
4180
|
-
"description": "Semantic heading level for the NavList. Also sets the default level for child group headings, which render one level deeper (h3 under an h2, h4 under an h3). Constrained to h2/h3 so the hierarchy stays shallow."
|
|
4181
|
-
},
|
|
4182
|
-
{
|
|
4183
|
-
"name": "visuallyHidden",
|
|
4184
|
-
"type": "boolean",
|
|
4185
|
-
"defaultValue": "false",
|
|
4186
|
-
"required": false,
|
|
4187
|
-
"description": "Visually hide the heading while keeping it available to assistive technology and as the accessible name for the `nav` landmark."
|
|
4188
|
-
},
|
|
4189
|
-
{
|
|
4190
|
-
"name": "children",
|
|
4191
|
-
"type": "ReactNode",
|
|
4192
|
-
"required": true,
|
|
4193
|
-
"description": "The text rendered as the NavList's heading."
|
|
4194
|
-
},
|
|
4195
|
-
{
|
|
4196
|
-
"name": "className",
|
|
4197
|
-
"type": "string",
|
|
4198
|
-
"description": "Custom CSS class name."
|
|
4199
|
-
},
|
|
4200
|
-
{
|
|
4201
|
-
"name": "style",
|
|
4202
|
-
"type": "React.CSSProperties",
|
|
4203
|
-
"description": "Custom CSS styles."
|
|
4204
|
-
}
|
|
4205
|
-
]
|
|
4206
|
-
},
|
|
4207
4172
|
{
|
|
4208
4173
|
"name": "NavList.Item",
|
|
4209
4174
|
"props": [
|
|
@@ -4350,9 +4315,10 @@
|
|
|
4350
4315
|
},
|
|
4351
4316
|
{
|
|
4352
4317
|
"name": "as",
|
|
4353
|
-
"description": "Heading level for the group heading. Sets the semantic heading tag.
|
|
4318
|
+
"description": "Heading level for the group heading. Sets the semantic heading tag.",
|
|
4354
4319
|
"required": false,
|
|
4355
|
-
"type": "'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'"
|
|
4320
|
+
"type": "'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'",
|
|
4321
|
+
"defaultValue": "\"h3\""
|
|
4356
4322
|
}
|
|
4357
4323
|
]
|
|
4358
4324
|
},
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
.prc-NavList-Heading--JQMj{margin-block-end:var(--base-size-8,.5rem);margin-inline-start:calc(var(--control-medium-paddingInline-condensed,.5rem) + var(--base-size-8,.5rem))}.prc-NavList-GroupHeading-mN50z>a{color:var(--fgColor-default,#1f2328);text-decoration:inherit}.prc-NavList-GroupHeading-mN50z>a:hover{-webkit-text-decoration:underline;text-decoration:underline}
|
|
2
|
-
/*# sourceMappingURL=NavList-b50d982b.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/NavList/NavList.module.css.js"],"names":[],"mappings":"AAAA,2BACE,yCAAoC,CAEpC,wGACF,CAEA,kCACE,oCAA6B,CAC7B,uBACF,CAEA,wCACE,iCAA0B,CAA1B,yBACF","file":"NavList-b50d982b.css","sourcesContent":[".Heading {\n margin-block-end: var(--base-size-8);\n /* stylelint-disable-next-line primer/spacing */\n margin-inline-start: calc(var(--control-medium-paddingInline-condensed) + var(--base-size-8));\n}\n\n.GroupHeading > a {\n color: var(--fgColor-default);\n text-decoration: inherit;\n}\n\n.GroupHeading > a:hover {\n text-decoration: underline;\n}\n"]}
|