@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 CHANGED
@@ -1,14 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260623191506
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,2 @@
1
+ .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-5dc067e3.css.map */
@@ -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,4BA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,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"}
@@ -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 visuallyHiddenClasses from '../_VisuallyHidden.module.css.js';
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
- var _heading$props$id, _ariaLabelledby;
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] = ariaLabel;
51
- $[2] = ariaLabelledby;
52
- $[3] = children;
53
- $[4] = props;
27
+ $[1] = children;
28
+ $[2] = props;
54
29
  } else {
55
- ariaLabel = $[1];
56
- ariaLabelledby = $[2];
57
- children = $[3];
58
- props = $[4];
30
+ children = $[1];
31
+ props = $[2];
59
32
  }
60
33
  let t1;
61
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
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
- $[11] = t4;
38
+ $[3] = t1;
101
39
  } else {
102
- t4 = $[11];
40
+ t1 = $[3];
103
41
  }
104
- let t5;
105
- if ($[12] !== childrenWithoutHeading) {
106
- t5 = /*#__PURE__*/jsx(ActionListContainerContext.Provider, {
107
- value: t4,
42
+ let t2;
43
+ if ($[4] !== children) {
44
+ t2 = /*#__PURE__*/jsx(ActionListContainerContext.Provider, {
45
+ value: t1,
108
46
  children: /*#__PURE__*/jsx(ActionList, {
109
- children: childrenWithoutHeading
47
+ children: children
110
48
  })
111
49
  });
112
- $[12] = childrenWithoutHeading;
113
- $[13] = t5;
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
- t6 = $[17];
53
+ t2 = $[5];
129
54
  }
130
- let t7;
131
- if ($[18] !== ariaLabel || $[19] !== navLabelledby || $[20] !== props || $[21] !== ref || $[22] !== t6) {
132
- t7 = /*#__PURE__*/jsx("nav", {
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: t6
61
+ children: t2
139
62
  });
140
- $[18] = ariaLabel;
141
- $[19] = navLabelledby;
142
- $[20] = props;
143
- $[21] = ref;
144
- $[22] = t6;
145
- $[23] = t7;
63
+ $[6] = props;
64
+ $[7] = ref;
65
+ $[8] = t2;
66
+ $[9] = t3;
146
67
  } else {
147
- t7 = $[23];
68
+ t3 = $[9];
148
69
  }
149
- return t7;
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(14);
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] !== headingLevel) {
568
- t1 = headingLevel ? levelToHeadingTag(headingLevel + 1) : "h3";
569
- $[4] = headingLevel;
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 = $[5];
425
+ t1 = $[4];
573
426
  }
574
- const groupHeadingAs = t1;
575
427
  let t2;
576
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
577
- t2 = /*#__PURE__*/jsx(ActionList.Divider, {});
578
- $[6] = t2;
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
- $[7] = groupHeadingAs;
590
- $[8] = title;
591
- $[9] = t3;
434
+ $[5] = title;
435
+ $[6] = t2;
592
436
  } else {
593
- t3 = $[9];
437
+ t2 = $[6];
594
438
  }
595
- let t4;
596
- if ($[10] !== children || $[11] !== props || $[12] !== t3) {
597
- t4 = /*#__PURE__*/jsxs(Fragment, {
598
- children: [t2, /*#__PURE__*/jsxs(ActionList.Group, {
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: [t3, children]
444
+ children: [t2, children]
601
445
  })]
602
446
  });
603
- $[10] = children;
604
- $[11] = props;
605
- $[12] = t3;
606
- $[13] = t4;
447
+ $[7] = children;
448
+ $[8] = props;
449
+ $[9] = t2;
450
+ $[10] = t3;
607
451
  } else {
608
- t4 = $[13];
452
+ t3 = $[10];
609
453
  }
610
- return t4;
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(13);
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] = as;
764
- $[2] = className;
765
- $[3] = rest;
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
- t1 = $[6];
611
+ className = $[1];
612
+ rest = $[2];
613
+ t1 = $[3];
781
614
  }
782
- const resolvedAs = t1;
615
+ const as = t1 === undefined ? "h3" : t1;
783
616
  let t2;
784
- if ($[7] !== className) {
617
+ if ($[4] !== className) {
785
618
  t2 = clsx(navListClasses.GroupHeading, className);
786
- $[7] = className;
787
- $[8] = t2;
619
+ $[4] = className;
620
+ $[5] = t2;
788
621
  } else {
789
- t2 = $[8];
622
+ t2 = $[5];
790
623
  }
791
624
  let t3;
792
- if ($[9] !== resolvedAs || $[10] !== rest || $[11] !== t2) {
625
+ if ($[6] !== as || $[7] !== rest || $[8] !== t2) {
793
626
  t3 = /*#__PURE__*/jsx(ActionList.GroupHeading, {
794
- as: resolvedAs,
627
+ as: as,
795
628
  className: t2,
796
629
  "data-component": "NavList.GroupHeading",
797
630
  headingWrapElement: "li",
798
631
  ...rest
799
632
  });
800
- $[9] = resolvedAs;
801
- $[10] = rest;
802
- $[11] = t2;
803
- $[12] = t3;
633
+ $[6] = as;
634
+ $[7] = rest;
635
+ $[8] = t2;
636
+ $[9] = t3;
804
637
  } else {
805
- t3 = $[12];
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-b50d982b.css';
1
+ import './NavList-5dc067e3.css';
2
2
 
3
- var navListClasses = {"Heading":"prc-NavList-Heading--JQMj","GroupHeading":"prc-NavList-GroupHeading-mN50z"};
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,mFA0SxB,CAAA"}
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. Defaults to one level below a `NavList.Heading` (h3 under an h2, h4 under an h3), or `h3` when there is no `NavList.Heading`.",
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260623191506",
4
+ "version": "0.0.0-20260623204153",
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",
@@ -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"]}