@primer/react 0.0.0-20260526182004 → 0.0.0-20260526190633

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +7 -11
  2. package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
  3. package/dist/FilteredActionList/FilteredActionList.js +4 -0
  4. package/dist/UnderlineNav/UnderlineNav-4c80468c.css +2 -0
  5. package/dist/UnderlineNav/UnderlineNav-4c80468c.css.map +1 -0
  6. package/dist/UnderlineNav/UnderlineNav.d.ts +1 -1
  7. package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
  8. package/dist/UnderlineNav/UnderlineNav.js +41 -484
  9. package/dist/UnderlineNav/UnderlineNav.module.css.js +2 -2
  10. package/dist/UnderlineNav/UnderlineNavContext.d.ts +0 -1
  11. package/dist/UnderlineNav/UnderlineNavContext.d.ts.map +1 -1
  12. package/dist/UnderlineNav/UnderlineNavContext.js +1 -2
  13. package/dist/UnderlineNav/UnderlineNavItem.d.ts +1 -3
  14. package/dist/UnderlineNav/UnderlineNavItem.d.ts.map +1 -1
  15. package/dist/UnderlineNav/UnderlineNavItem.js +41 -23
  16. package/dist/UnderlineNav/index.d.ts +1 -1
  17. package/dist/UnderlineNav/types.d.ts +5 -1
  18. package/dist/UnderlineNav/types.d.ts.map +1 -1
  19. package/dist/experimental/UnderlinePanels/UnderlinePanels-162f9aed.css +2 -0
  20. package/dist/experimental/UnderlinePanels/UnderlinePanels-162f9aed.css.map +1 -0
  21. package/dist/experimental/UnderlinePanels/UnderlinePanels.js +1 -1
  22. package/dist/experimental/UnderlinePanels/UnderlinePanels.module.css.js +1 -1
  23. package/dist/internal/components/UnderlineTabbedInterface-7317470b.css +2 -0
  24. package/dist/internal/components/UnderlineTabbedInterface-7317470b.css.map +1 -0
  25. package/dist/internal/components/UnderlineTabbedInterface.d.ts +0 -1
  26. package/dist/internal/components/UnderlineTabbedInterface.d.ts.map +1 -1
  27. package/dist/internal/components/UnderlineTabbedInterface.js +66 -60
  28. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
  29. package/generated/components.json +2 -2
  30. package/package.json +1 -1
  31. package/dist/UnderlineNav/UnderlineNav-4344d9b0.css +0 -2
  32. package/dist/UnderlineNav/UnderlineNav-4344d9b0.css.map +0 -1
  33. package/dist/UnderlineNav/styles.d.ts +0 -16
  34. package/dist/UnderlineNav/styles.d.ts.map +0 -1
  35. package/dist/UnderlineNav/styles.js +0 -19
  36. package/dist/experimental/UnderlinePanels/UnderlinePanels-e4b325b9.css +0 -2
  37. package/dist/experimental/UnderlinePanels/UnderlinePanels-e4b325b9.css.map +0 -1
  38. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +0 -2
  39. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260526182004
3
+ ## 0.0.0-20260526190633
4
+
5
+ ### Minor Changes
6
+
7
+ - [#7622](https://github.com/primer/react/pull/7622) [`4d8d5e6`](https://github.com/primer/react/commit/4d8d5e6b9b0b1d394d19154369f9c37eabe7cb87) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Removes `UnderlineNav` dynamic overflow functionality, replacing with simple scroll container to simplify logic, improve performance, and remove layout shifts, especially when using server-side rendering.
4
8
 
5
9
  ### Patch Changes
6
10
 
@@ -23,17 +27,9 @@
23
27
  `src/utils/testing/profiler.tsx` so future regressions can be pinned with
24
28
  `counter.updateCount` and `counter.nestedUpdateCount` assertions.
25
29
 
26
- - Fake entry to force publishing
30
+ - [#7878](https://github.com/primer/react/pull/7878) [`8c468fd`](https://github.com/primer/react/commit/8c468fd28322456f48601f9cbf6226fc4c35b661) Thanks [@mattcosta7](https://github.com/mattcosta7)! - FilteredActionList: Guard against `undefined` items in the virtualizer's `getItemKey` callback to prevent a crash when `@tanstack/react-virtual` invokes it with an index whose item was just removed (e.g. when filtering shrinks the items list).
27
31
 
28
- - [#7875](https://github.com/primer/react/pull/7875) [`1fcc071`](https://github.com/primer/react/commit/1fcc071865a6b9b06988a84864f20a3faa9d523d) Thanks [@mattcosta7](https://github.com/mattcosta7)! - UnderlineNav: Re-architect item measurement to remove a cascading render on
29
- mount. Each `UnderlineNav.Item` no longer dispatches measurement setState calls
30
- back into its parent via context; `UnderlineNav` now walks its rendered items
31
- in a single layout effect and stores widths in refs. Overflow state is
32
- consolidated into one `useState` object (one commit per change), the context
33
- value is memoized, `UnderlineNav.Item` is wrapped in `React.memo`, and the
34
- external-`aria-current` swap was moved out of render-phase setState into a
35
- layout effect. Behavior is unchanged for consumers, but the initial mount and
36
- overflow-state transitions produce far fewer per-item renders.
32
+ - Fake entry to force publishing
37
33
 
38
34
  - [#7874](https://github.com/primer/react/pull/7874) [`8cc7e99`](https://github.com/primer/react/commit/8cc7e998d2dbde1fb927b598755810b534702a6a) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Dev-only effects (the `if (__DEV__) { useEffect(...) }` pattern with an
39
35
  `eslint-disable react-hooks/rules-of-hooks` comment at every call site) are
@@ -1 +1 @@
1
- {"version":3,"file":"FilteredActionList.d.ts","sourceRoot":"","sources":["../../src/FilteredActionList/FilteredActionList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuB,GAAG,EAAC,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,cAAc,CAAA;AAChD,OAAO,EAAa,KAAK,eAAe,EAAC,MAAM,eAAe,CAAA;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAA0B,MAAM,IAAI,CAAA;AAOhF,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,6BAA6B,CAAA;AAa9E,MAAM,WAAW,uBAAwB,SAAQ,OAAO,CAAC,IAAI,CAAC,gBAAgB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,CAAA;IAClC;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,CAC1B,mBAAmB,EAAE,WAAW,GAAG,SAAS,EAC5C,wBAAwB,EAAE,WAAW,GAAG,SAAS,EACjD,iBAAiB,EAAE,OAAO,KACvB,IAAI,CAAA;IACT;;;;;;;;;;;;;;;;;;OAkBG;IACH,uBAAuB,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,CAAA;IACjE;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,OAAe,EACf,eAAe,EACf,WAAW,EAAE,mBAAmB,EAChC,WAAwD,EACxD,cAAc,EACd,yBAAyB,EACzB,iBAAiB,EACjB,KAAK,EACL,cAAc,EACd,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,EAAE,0BAA0B,EAC9C,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,oBAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,gBAAyB,EACzB,uBAA6C,EAC7C,yBAAyB,EACzB,oBAA4B,EAC5B,eAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,WAAmB,EACnB,GAAG,SAAS,EACb,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CA4avC;yBA3ce,kBAAkB"}
1
+ {"version":3,"file":"FilteredActionList.d.ts","sourceRoot":"","sources":["../../src/FilteredActionList/FilteredActionList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuB,GAAG,EAAC,MAAM,OAAO,CAAA;AACpD,OAAO,KAA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EAC7C,yBAAyB,EACzB,oBAA4B,EAC5B,eAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,WAAmB,EACnB,GAAG,SAAS,EACb,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAgbvC;yBA/ce,kBAAkB"}
@@ -157,7 +157,11 @@ function FilteredActionList({
157
157
  enabled: isVirtualized,
158
158
  getItemKey: index => {
159
159
  var _ref, _item_3$key, _item_3$id;
160
+ // `measureElement` from @tanstack/react-virtual can invoke this with an index
161
+ // whose item has just been removed (e.g. during a filter that shrinks `items`),
162
+ // so guard against `items[index]` being undefined.
160
163
  const item_3 = items[index];
164
+ if (!item_3) return index.toString();
161
165
  return (_ref = (_item_3$key = item_3.key) !== null && _item_3$key !== void 0 ? _item_3$key : (_item_3$id = item_3.id) === null || _item_3$id === void 0 ? void 0 : _item_3$id.toString()) !== null && _ref !== void 0 ? _ref : index.toString();
162
166
  },
163
167
  measureElement: el => el.scrollHeight
@@ -0,0 +1,2 @@
1
+ .prc-UnderlineNav-ScrollContainer-kBvfS{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:auto;animation:prc-UnderlineNav-detect-overflow-6HuSH linear;scrollbar-color:var(--borderColor-muted,#d1d9e0b3) transparent;scrollbar-gutter:stable;scrollbar-width:thin;animation-timeline:scroll(self inline);--UnderlineNav_icons-display:inline}.prc-UnderlineNav-ScrollContainer-kBvfS [data-component=icon]{display:var(--UnderlineNav_icons-display)}.prc-UnderlineNav-ScrollContainer-kBvfS[data-hide-icons=true]{animation:none;animation-timeline:none;--UnderlineNav_icons-display:none}@keyframes prc-UnderlineNav-detect-overflow-6HuSH{0%,to{--UnderlineNav_icons-display:none}}
2
+ /*# sourceMappingURL=UnderlineNav-4c80468c.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/UnderlineNav/UnderlineNav.module.css.js"],"names":[],"mappings":"AAAA,wCACE,eAAgB,CAChB,iBAAkB,CAClB,+BAAgC,CAOhC,uDAAiC,CALjC,8DAAqD,CACrD,uBAAwB,CAFxB,oBAAqB,CAOrB,sCAAuC,CAEvC,mCAgBF,CAdE,8DACE,yCACF,CAMA,8DACE,cAAe,CACf,uBAAwB,CAExB,iCACF,CAGF,kDACE,MAEE,iCACF,CACF","file":"UnderlineNav-4c80468c.css","sourcesContent":[".ScrollContainer {\n overflow-x: auto;\n overflow-y: hidden;\n -webkit-overflow-scrolling: auto;\n scrollbar-width: thin;\n scrollbar-color: var(--borderColor-muted) transparent;\n scrollbar-gutter: stable;\n\n /* Progressive enhancement: Detect overflow using scroll-based animations.\n This lets us calculate the icon visibility during SSR. */\n animation: detect-overflow linear;\n animation-timeline: scroll(self inline);\n\n --UnderlineNav_icons-display: inline;\n\n [data-component='icon'] {\n display: var(--UnderlineNav_icons-display);\n }\n\n /* Even on browsers that support scroll-driven animations, we still need to\n force icons to remain hidden with JS to avoid flickering as they cause/remove\n overflow. Once they are hidden once, they remain hidden for the life of the\n component. */\n &[data-hide-icons='true'] {\n animation: none;\n animation-timeline: none;\n\n --UnderlineNav_icons-display: none;\n }\n}\n\n@keyframes detect-overflow {\n 0%,\n 100% {\n --UnderlineNav_icons-display: none;\n }\n}\n"]}
@@ -15,5 +15,5 @@ export type UnderlineNavProps = {
15
15
  */
16
16
  variant?: 'inset' | 'flush';
17
17
  };
18
- export declare const UnderlineNav: React.ForwardRefExoticComponent<UnderlineNavProps & React.RefAttributes<unknown>>;
18
+ export declare const UnderlineNav: React.ForwardRefExoticComponent<UnderlineNavProps & React.RefAttributes<HTMLElement>>;
19
19
  //# sourceMappingURL=UnderlineNav.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2D,MAAM,OAAO,CAAA;AAqB/E,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;AAkHD,eAAO,MAAM,YAAY,mFA2ZxB,CAAA"}
1
+ {"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAA;AAQpE,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;AAOD,eAAO,MAAM,YAAY,uFAsExB,CAAA"}
@@ -1,122 +1,16 @@
1
- import React, { forwardRef, useRef, useState, useCallback, useMemo } from 'react';
2
- import { useDevOnlyEffect } from '../internal/hooks/useDevOnlyEffect.js';
3
- import { UnderlineNavContext } from './UnderlineNavContext.js';
4
- import { useResizeObserver } from '../hooks/useResizeObserver.js';
5
- import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
1
+ import React, { forwardRef, useState, useRef, useEffect } from 'react';
6
2
  import VisuallyHidden from '../_VisuallyHidden.js';
7
- import { baseMenuMinWidth, dividerStyles, menuItemStyles } from './styles.js';
8
- import { UnderlineWrapper, UnderlineItemList, LoadingCounter, GAP } from '../internal/components/UnderlineTabbedInterface.js';
9
- import { TriangleDownIcon } from '@primer/octicons-react';
10
- import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
11
- import { useOnOutsideClick } from '../hooks/useOnOutsideClick.js';
12
- import { useId } from '../hooks/useId.js';
13
- import { ActionList } from '../ActionList/index.js';
3
+ import { UnderlineWrapper, UnderlineItemList } from '../internal/components/UnderlineTabbedInterface.js';
14
4
  import { invariant } from '../utils/invariant.js';
15
5
  import classes from './UnderlineNav.module.css.js';
16
- import { getAnchoredPosition } from '@primer/behaviors';
17
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
18
- import { ButtonComponent } from '../Button/Button.js';
19
- import CounterLabel from '../CounterLabel/CounterLabel.js';
20
-
21
- // When page is loaded, we don't have ref for the more button as it is not on the DOM yet.
22
- // However, we need to calculate number of possible items when the more button present as well. So using the width of the more button as a constant.
23
- const MORE_BTN_WIDTH = 86;
24
- // The height is needed to make sure we don't have a layout shift when the more button is the only item in the nav.
25
- const MORE_BTN_HEIGHT = 45;
26
- const computeOverflow = (navWidth, moreMenuWidth, childArray, childWidths, noIconChildWidths) => {
27
- let iconsVisible = true;
28
- if (childWidths.size === 0) {
29
- return {
30
- items: childArray,
31
- menuItems: [],
32
- iconsVisible
33
- };
34
- }
35
- const numberOfItemsPossible = calculatePossibleItems(childArray, childWidths, navWidth);
36
- const numberOfItemsWithoutIconPossible = calculatePossibleItems(childArray, noIconChildWidths, navWidth);
37
- // We need to take more menu width into account when calculating the number of items possible
38
- const numberOfItemsPossibleWithMoreMenu = calculatePossibleItems(childArray, noIconChildWidths, navWidth, moreMenuWidth || MORE_BTN_WIDTH);
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- const items = [];
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- const menuItems = [];
43
-
44
- // First, we check if we can fit all the items with their icons
45
- if (childArray.length <= numberOfItemsPossible) {
46
- items.push(...childArray);
47
- } else if (childArray.length <= numberOfItemsWithoutIconPossible) {
48
- // if we can't fit all the items with their icons, we check if we can fit all the items without their icons
49
- iconsVisible = false;
50
- items.push(...childArray);
51
- } else {
52
- // if we can't fit all the items without their icons, we keep the icons hidden and show the ones that doesn't fit into the list in the overflow menu
53
- iconsVisible = false;
6
+ import { UnderlineNavContext } from './UnderlineNavContext.js';
7
+ import { useDevOnlyEffect } from '../internal/hooks/useDevOnlyEffect.js';
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
54
9
 
55
- /* Below is an accessibility requirement. Never show only one item in the overflow menu.
56
- * If there is only one item left to display in the overflow menu according to the calculation,
57
- * we need to pull another item from the list into the overflow menu.
58
- */
59
- const numberOfItemsInMenu = childArray.length - numberOfItemsPossibleWithMoreMenu;
60
- const numberOfListItems = numberOfItemsInMenu === 1 ? numberOfItemsPossibleWithMoreMenu - 1 : numberOfItemsPossibleWithMoreMenu;
61
- for (const [index, child] of childArray.entries()) {
62
- if (index < numberOfListItems) {
63
- items.push(child);
64
- } else {
65
- const ariaCurrent = child.props['aria-current'];
66
- const isCurrent = Boolean(ariaCurrent) && ariaCurrent !== 'false';
67
- // We need to make sure to keep the selected item always visible.
68
- // To do that, we swap the selected item with the last item in the list to make it visible. (When there is at least 1 item in the list to swap.)
69
- if (isCurrent && numberOfListItems > 0) {
70
- // If selected item couldn't make in to the list, we swap it with the last item in the list.
71
- const indexToReplaceAt = numberOfListItems - 1; // because we are replacing the last item in the list
72
- // splice method modifies the array by removing 1 item here at the given index and replace it with the "child" element then returns the removed item.
73
- const propsectiveAction = items.splice(indexToReplaceAt, 1, child)[0];
74
- menuItems.push(propsectiveAction);
75
- } else {
76
- menuItems.push(child);
77
- }
78
- }
79
- }
80
- }
81
- return {
82
- items,
83
- menuItems,
84
- iconsVisible
85
- };
86
- };
87
10
  const getValidChildren = children => {
88
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
12
  return React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child));
90
13
  };
91
- const calculatePossibleItems = (childArray, widthMap, navWidth, moreMenuWidth = 0) => {
92
- const widthToFit = navWidth - moreMenuWidth;
93
- let breakpoint = childArray.length; // assume all items will fit
94
- let sumsOfChildWidth = 0;
95
- for (const [index, child] of childArray.entries()) {
96
- var _widthMap$get;
97
- const width = (_widthMap$get = widthMap.get(String(child.key))) !== null && _widthMap$get !== void 0 ? _widthMap$get : 0;
98
- sumsOfChildWidth = sumsOfChildWidth + width + GAP;
99
- if (sumsOfChildWidth > widthToFit) {
100
- breakpoint = index;
101
- break;
102
- }
103
- }
104
- return breakpoint;
105
- };
106
-
107
- // Inline styles converted from baseMenuStyles for use as CSSProperties
108
- const baseMenuInlineStyles = {
109
- position: 'absolute',
110
- zIndex: 1,
111
- top: '90%',
112
- boxShadow: '0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)',
113
- borderRadius: 12,
114
- background: 'var(--overlay-bgColor)',
115
- listStyle: 'none',
116
- minWidth: `${baseMenuMinWidth}px`,
117
- maxWidth: '640px',
118
- right: 0
119
- };
120
14
  const UnderlineNav = /*#__PURE__*/forwardRef(({
121
15
  as = 'nav',
122
16
  'aria-label': ariaLabel,
@@ -125,78 +19,7 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
125
19
  className,
126
20
  children
127
21
  }, forwardedRef) => {
128
- const backupRef = useRef(null);
129
- const navRef = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
130
- const listRef = useRef(null);
131
- const moreMenuRef = useRef(null);
132
- const moreMenuBtnRef = useRef(null);
133
- const containerRef = React.useRef(null);
134
- const disclosureWidgetId = useId();
135
- const [isWidgetOpen, setIsWidgetOpen] = useState(false);
136
- // Measurement results are stored in refs because only `computeOverflow` reads them;
137
- // they should not trigger re-renders. Keyed by `String(element.key)` so lookups
138
- // are O(1) and survive non-string item children.
139
- const childWidthsRef = useRef(new Map());
140
- const noIconChildWidthsRef = useRef(new Map());
141
22
  const validChildren = getValidChildren(children);
142
- // Stable signature of the children list — when it changes we re-run the
143
- // measurement pass with all items rendered (with icons) in the list. The
144
- // delimiter is U+0000 (NUL) because React rejects NUL inside element keys,
145
- // so consumer-provided keys cannot collide with the separator.
146
- const childrenKey = validChildren.map(c => String(c.key)).join('\u0000');
147
-
148
- // Single consolidated overflow state. Bundling `items`, `menuItems`,
149
- // `iconsVisible`, `measured`, and `childrenKey` together means every
150
- // overflow update — measurement, swap, resize, or children-change reset —
151
- // is exactly one setState call (one commit), instead of fanning out to
152
- // multiple back-to-back commits.
153
-
154
- const [overflowState, setOverflowState] = useState(() => ({
155
- items: validChildren,
156
- menuItems: [],
157
- iconsVisible: true,
158
- measured: false,
159
- childrenKey
160
- }));
161
-
162
- // Derived-state reset: when the children list changes, push everything back into
163
- // the list (with icons) so the next layout effect can measure all items in one
164
- // pass. This is React's recommended "store information from previous renders"
165
- // pattern — calling setState during render lets React discard the in-progress
166
- // render and re-render immediately with the reset state, before paint.
167
- if (overflowState.childrenKey !== childrenKey) {
168
- setOverflowState({
169
- items: validChildren,
170
- menuItems: [],
171
- iconsVisible: true,
172
- measured: false,
173
- childrenKey
174
- });
175
- }
176
-
177
- // Build a key-indexed view of validChildren once per render so the listItems /
178
- // menuItems prop-refresh below is O(N) instead of O(N^2) via Array.prototype.find.
179
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
180
- const validChildrenByKey = new Map();
181
- for (const c of validChildren) validChildrenByKey.set(String(c.key), c);
182
- const {
183
- iconsVisible,
184
- measured: isOverflowMeasured
185
- } = overflowState;
186
-
187
- // Make sure to have the fresh props data for list items when children are changed (keeping aria-current up-to-date)
188
- const listItems = overflowState.items.map(item => {
189
- var _validChildrenByKey$g;
190
- return (_validChildrenByKey$g = validChildrenByKey.get(String(item.key))) !== null && _validChildrenByKey$g !== void 0 ? _validChildrenByKey$g : item;
191
- });
192
-
193
- // Make sure to have the fresh props data for menu items when children are changed (keeping aria-current up-to-date)
194
- const menuItems = overflowState.menuItems.map(item => {
195
- var _validChildrenByKey$g2;
196
- return (_validChildrenByKey$g2 = validChildrenByKey.get(String(item.key))) !== null && _validChildrenByKey$g2 !== void 0 ? _validChildrenByKey$g2 : item;
197
- });
198
- // 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
199
- const onlyMenuVisible = overflowState.items.length === 0;
200
23
  useDevOnlyEffect(() => {
201
24
  // Address illegal state where there are multiple items that have `aria-current='page'` attribute
202
25
  const activeElements = validChildren.filter(child => {
@@ -205,313 +28,47 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
205
28
  !(activeElements.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Only one current element is allowed') : invariant(false) : void 0;
206
29
  !ariaLabel ? process.env.NODE_ENV !== "production" ? invariant(false, 'Use the `aria-label` prop to provide an accessible label for assistive technology') : invariant(false) : void 0;
207
30
  }, [validChildren, ariaLabel]);
208
-
209
- // Returns the measured "no icon" width for an item, looking up by element key.
210
- // Previously this was a text-based lookup, which silently returned 0 when an
211
- // item's children weren't a plain string and caused the swap math to degenerate.
212
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
- const getItemNoIconWidth = item => {
214
- var _noIconChildWidthsRef;
215
- return (_noIconChildWidthsRef = noIconChildWidthsRef.current.get(String(item.key))) !== null && _noIconChildWidthsRef !== void 0 ? _noIconChildWidthsRef : 0;
216
- };
217
-
218
- // Pure: returns the {items, menuItems} that result from promoting
219
- // `prospectiveListItem` (currently at position `indexOfProspectiveListItem`
220
- // in `currentMenuItems`) into `currentItems`. Does not call setState.
221
- const computeSwap = (currentItems, currentMenuItems, prospectiveListItem, indexOfProspectiveListItem) => {
222
- var _navRef$current$getBo, _navRef$current, _listRef$current$getB, _listRef$current;
223
- const widthToFitIntoList = getItemNoIconWidth(prospectiveListItem);
224
- const availableSpace = ((_navRef$current$getBo = (_navRef$current = navRef.current) === null || _navRef$current === void 0 ? void 0 : _navRef$current.getBoundingClientRect().width) !== null && _navRef$current$getBo !== void 0 ? _navRef$current$getBo : 0) - ((_listRef$current$getB = (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.getBoundingClientRect().width) !== null && _listRef$current$getB !== void 0 ? _listRef$current$getB : 0);
225
-
226
- // How many items at the end of the list have to move to the menu to make
227
- // room for the promoted item.
228
- let widthToSwap = 0;
229
- let breakpoint = 0;
230
- for (const [index, item] of [...currentItems].reverse().entries()) {
231
- widthToSwap += getItemNoIconWidth(item);
232
- if (widthToFitIntoList < widthToSwap + availableSpace) {
233
- breakpoint = index;
234
- break;
235
- }
236
- }
237
- const indexToSliceAt = currentItems.length - 1 - breakpoint;
238
- const itemsLeftInList = currentItems.slice(0, indexToSliceAt);
239
- const updatedItemList = [...itemsLeftInList, prospectiveListItem];
240
- const itemsToAddToMenu = currentItems.slice(indexToSliceAt);
241
- const updatedMenuItems = [...currentMenuItems];
242
- updatedMenuItems.splice(indexOfProspectiveListItem, 1, ...itemsToAddToMenu);
243
- return {
244
- items: updatedItemList,
245
- menuItems: updatedMenuItems
246
- };
247
- };
248
- const swapMenuItemWithListItem = (prospectiveListItem, indexOfProspectiveListItem) => {
249
- const swap = computeSwap(overflowState.items, menuItems, prospectiveListItem, indexOfProspectiveListItem);
250
- setOverflowState(prev => ({
251
- items: swap.items,
252
- menuItems: swap.menuItems,
253
- iconsVisible: false,
254
- measured: true,
255
- childrenKey: prev.childrenKey
256
- }));
257
- };
258
-
259
- // Single combined layout effect that performs measurement (when needed) and
260
- // the external-aria-current promotion (when needed), then commits at most
261
- // one setOverflowState per pass. Replaces the previous two effects (each of
262
- // which produced its own commit) and removes the render-phase setState that
263
- // the original component used to do the same swap from inside menuItems.map.
264
- //
265
- // Why no deps array: the swap branch depends on `aria-current` which lives
266
- // on item props (not on `overflowState`); a deps-driven effect would not
267
- // notice prop-only changes without rebuilding a signature. The body
268
- // short-circuits cheaply on every render where neither pass needs to run.
269
- useIsomorphicLayoutEffect(() => {
270
- var _next;
271
- const listEl = listRef.current;
272
- const navEl = navRef.current;
273
- if (!listEl || !navEl) return;
274
- let next = null;
275
-
276
- // Pass 1: measurement (runs once after each remeasure trigger).
277
- if (!isOverflowMeasured) {
278
- var _moreMenuRef$current$, _moreMenuRef$current;
279
- const widths = new Map();
280
- const noIconWidths = new Map();
281
- const itemEls = listEl.querySelectorAll('[data-underlinenav-item="true"]');
282
-
283
- // The N-th [data-underlinenav-item] element corresponds to validChildren[N]
284
- // because the measurement pass runs only when all items are in the list,
285
- // in render order. Pair them up positionally so we can key widths by the
286
- // element's React key.
287
- const upToBoundary = Math.min(itemEls.length, validChildren.length);
288
- for (let index = 0; index < upToBoundary; index++) {
289
- const liEl = itemEls[index];
290
- const linkEl = liEl.querySelector('a, button');
291
- if (!linkEl) continue;
292
- const child = validChildren[index];
293
- const key = String(child.key);
294
- const domRect = linkEl.getBoundingClientRect();
295
- const iconEl = linkEl.querySelector('[data-component="icon"]');
296
- let iconWidthWithMargin = 0;
297
- if (iconEl) {
298
- const style = getComputedStyle(iconEl);
299
- iconWidthWithMargin = iconEl.getBoundingClientRect().width + (parseFloat(style.marginRight) || 0) + (parseFloat(style.marginLeft) || 0);
300
- }
301
- widths.set(key, domRect.width);
302
- noIconWidths.set(key, domRect.width - iconWidthWithMargin);
303
- }
304
- childWidthsRef.current = widths;
305
- noIconChildWidthsRef.current = noIconWidths;
306
- const navWidth = navEl.getBoundingClientRect().width;
307
- if (navWidth === 0) return;
308
- 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;
309
- const result = computeOverflow(navWidth, moreMenuWidth, validChildren, widths, noIconWidths);
310
- next = {
311
- items: result.items,
312
- menuItems: result.menuItems,
313
- iconsVisible: result.iconsVisible,
314
- measured: true,
315
- childrenKey: overflowState.childrenKey
316
- };
317
- }
318
-
319
- // Pass 2: external-aria-current promotion. Operates on the freshest
320
- // (post-measurement) items so it can fold into the same setState.
321
- const considered = (_next = next) !== null && _next !== void 0 ? _next : overflowState;
322
- if (considered.measured && considered.items.length > 0) {
323
- // Look at FRESH props (current aria-current) by remapping through
324
- // validChildrenByKey (O(1) per lookup; the previous .find() pattern was
325
- // O(N) and ran inside a .map() — quadratic on every commit).
326
- const freshMenuItems = considered.menuItems.map(item => {
327
- var _validChildrenByKey$g3;
328
- return (_validChildrenByKey$g3 = validChildrenByKey.get(String(item.key))) !== null && _validChildrenByKey$g3 !== void 0 ? _validChildrenByKey$g3 : item;
329
- });
330
- const indexOfCurrent = freshMenuItems.findIndex(item => {
331
- const c = item.props['aria-current'];
332
- return Boolean(c) && c !== 'false';
333
- });
334
- if (indexOfCurrent !== -1) {
335
- const swap = computeSwap(considered.items, freshMenuItems, freshMenuItems[indexOfCurrent], indexOfCurrent);
336
- next = {
337
- items: swap.items,
338
- menuItems: swap.menuItems,
339
- iconsVisible: false,
340
- measured: true,
341
- childrenKey: considered.childrenKey
342
- };
343
- }
344
- }
345
- if (next) setOverflowState(next);
346
- });
347
- const closeOverlay = React.useCallback(() => {
348
- setIsWidgetOpen(false);
349
- }, [setIsWidgetOpen]);
350
- const focusOnMoreMenuBtn = React.useCallback(() => {
351
- var _moreMenuBtnRef$curre;
352
- (_moreMenuBtnRef$curre = moreMenuBtnRef.current) === null || _moreMenuBtnRef$curre === void 0 ? void 0 : _moreMenuBtnRef$curre.focus();
353
- }, []);
354
- const onAnchorClick = useCallback(event => {
355
- if (event.defaultPrevented || event.button !== 0) {
356
- return;
357
- }
358
- setIsWidgetOpen(isWidgetOpen => !isWidgetOpen);
359
- }, []);
360
- useOnEscapePress(event => {
361
- if (isWidgetOpen) {
362
- event.preventDefault();
363
- closeOverlay();
364
- focusOnMoreMenuBtn();
365
- }
366
- }, [isWidgetOpen]);
367
- useOnOutsideClick({
368
- onClickOutside: closeOverlay,
369
- containerRef,
370
- ignoreClickRefs: [moreMenuBtnRef]
371
- });
372
- useResizeObserver(resizeObserverEntries => {
373
- var _moreMenuRef$current$2, _moreMenuRef$current2;
374
- const navWidth = resizeObserverEntries[0].contentRect.width;
375
- if (navWidth === 0) return;
376
- const moreMenuWidth = (_moreMenuRef$current$2 = (_moreMenuRef$current2 = moreMenuRef.current) === null || _moreMenuRef$current2 === void 0 ? void 0 : _moreMenuRef$current2.getBoundingClientRect().width) !== null && _moreMenuRef$current$2 !== void 0 ? _moreMenuRef$current$2 : 0;
377
- const result = computeOverflow(navWidth, moreMenuWidth, validChildren, childWidthsRef.current, noIconChildWidthsRef.current);
378
- setOverflowState(prev => ({
379
- items: result.items,
380
- menuItems: result.menuItems,
381
- iconsVisible: result.iconsVisible,
382
- measured: childWidthsRef.current.size > 0 || prev.measured,
383
- childrenKey: prev.childrenKey
384
- }));
385
- }, navRef);
386
-
387
- // Menu anchor position. `undefined` means "use the default right: 0 from
388
- // baseMenuInlineStyles" (the list is wide enough that no anchoring is
389
- // needed). A number means the menu is anchored to that `left` coordinate,
390
- // overriding right.
391
- //
392
- // This used to be computed inline during render by reading
393
- // containerRef.current / listRef.current — refs are mutable and unsafe to
394
- // read during render under concurrent rendering (the first render saw null
395
- // refs and fell through to the unanchored fallback; subsequent renders
396
- // anchored differently, producing a perceptible reflow).
397
- const [menuAnchorLeft, setMenuAnchorLeft] = useState(undefined);
398
- useIsomorphicLayoutEffect(() => {
399
- const container = containerRef.current;
400
- const list = listRef.current;
401
- if (!container || !list) return;
402
- if (list.clientWidth >= baseMenuMinWidth) {
403
- if (menuAnchorLeft !== undefined) setMenuAnchorLeft(undefined);
404
- return;
405
- }
406
- const {
407
- left
408
- } = getAnchoredPosition(container, list, {
409
- align: 'start',
410
- side: 'outside-bottom'
31
+ const [hideIcons, setHideIcons] = useState(false);
32
+ const scrollContainer = useRef(null);
33
+ useEffect(() => {
34
+ if (hideIcons || !scrollContainer.current) return;
35
+
36
+ // Putting the resizeobserver on the list ensures it runs if the contents change;
37
+ // the container is fullwidth but the list is elastic
38
+ const list = scrollContainer.current.querySelector('ul');
39
+ if (!list) return;
40
+ const observer = new ResizeObserver(() => {
41
+ if (scrollContainer.current.scrollWidth > scrollContainer.current.clientWidth) setHideIcons(true);
411
42
  });
412
- if (menuAnchorLeft !== left) setMenuAnchorLeft(left);
413
- }, [isWidgetOpen, isOverflowMeasured, menuItems.length, menuAnchorLeft]);
414
-
415
- // Stable context value: a fresh object literal here would re-render every
416
- // consumer (UnderlineNav.Item) on every parent re-render, undoing the
417
- // React.memo on UnderlineNavItem.
418
- const contextValue = useMemo(() => ({
419
- loadingCounters,
420
- iconsVisible
421
- }), [loadingCounters, iconsVisible]);
422
- const menuStyle = menuAnchorLeft !== undefined ? {
423
- ...baseMenuInlineStyles,
424
- right: undefined,
425
- left: menuAnchorLeft,
426
- display: isWidgetOpen ? 'block' : 'none'
427
- } : {
428
- ...baseMenuInlineStyles,
429
- display: isWidgetOpen ? 'block' : 'none'
430
- };
43
+ observer.observe(list);
44
+ return () => observer.disconnect();
45
+ }, [hideIcons]);
431
46
  return /*#__PURE__*/jsxs(UnderlineNavContext.Provider, {
432
- value: contextValue,
47
+ value: {
48
+ loadingCounters
49
+ },
433
50
  children: [ariaLabel && /*#__PURE__*/jsx(VisuallyHidden, {
434
51
  as: "h2",
435
52
  children: `${ariaLabel} navigation`
436
- }), /*#__PURE__*/jsx(UnderlineWrapper, {
437
- as: as,
438
- "aria-label": ariaLabel,
439
- className: className,
440
- ref: navRef,
441
- "data-variant": variant,
442
- "data-overflow-measured": isOverflowMeasured ? 'true' : 'false',
443
- children: /*#__PURE__*/jsxs(UnderlineItemList, {
444
- ref: listRef,
445
- role: "list",
446
- children: [listItems, menuItems.length > 0 && /*#__PURE__*/jsxs("li", {
447
- ref: moreMenuRef,
448
- style: {
449
- display: 'flex',
450
- alignItems: 'center',
451
- height: `${MORE_BTN_HEIGHT}px`
452
- },
453
- children: [!onlyMenuVisible && /*#__PURE__*/jsx("div", {
454
- style: dividerStyles
455
- }), /*#__PURE__*/jsx(ButtonComponent, {
456
- ref: moreMenuBtnRef,
457
- className: classes.MoreButton,
458
- "aria-controls": disclosureWidgetId,
459
- "aria-expanded": isWidgetOpen,
460
- onClick: onAnchorClick,
461
- trailingAction: TriangleDownIcon,
462
- children: /*#__PURE__*/jsx("span", {
463
- children: onlyMenuVisible ? /*#__PURE__*/jsxs(Fragment, {
464
- children: [/*#__PURE__*/jsxs(VisuallyHidden, {
465
- as: "span",
466
- children: [`${ariaLabel}`, "\xA0"]
467
- }), "Menu"]
468
- }) : /*#__PURE__*/jsxs(Fragment, {
469
- children: ["More", /*#__PURE__*/jsxs(VisuallyHidden, {
470
- as: "span",
471
- children: ["\xA0", `${ariaLabel} items`]
472
- })]
473
- })
474
- })
475
- }), /*#__PURE__*/jsx(ActionList, {
476
- selectionVariant: "single",
477
- ref: containerRef,
478
- id: disclosureWidgetId,
479
- style: menuStyle,
480
- children: menuItems.map((menuItem, index) => {
481
- const {
482
- children: menuItemChildren,
483
- counter,
484
- // Stripped from the spread below; the swap effect reads aria-current
485
- // directly from item.props (not via these destructured locals).
486
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
487
- 'aria-current': _ariaCurrent,
488
- onSelect,
489
- ...menuItemProps
490
- } = menuItem.props;
491
- return /*#__PURE__*/jsx(ActionList.LinkItem, {
492
- style: menuItemStyles,
493
- onClick: event => {
494
- // When there are no items in the list, do not run the swap function as we want to keep everything in the menu.
495
- !onlyMenuVisible && swapMenuItemWithListItem(menuItem, index);
496
- closeOverlay();
497
- focusOnMoreMenuBtn();
498
- // fire onSelect event that comes from the UnderlineNav.Item (if it is defined)
499
- typeof onSelect === 'function' && onSelect(event);
500
- },
501
- ...menuItemProps,
502
- children: /*#__PURE__*/jsxs("span", {
503
- className: classes.MenuItemContent,
504
- children: [menuItemChildren, loadingCounters ? /*#__PURE__*/jsx(LoadingCounter, {}) : counter !== undefined && /*#__PURE__*/jsx("span", {
505
- "data-component": "counter",
506
- children: /*#__PURE__*/jsx(CounterLabel, {
507
- children: counter
508
- })
509
- })]
510
- })
511
- }, String(menuItem.key));
512
- })
513
- })]
514
- })]
53
+ }), /*#__PURE__*/jsx("div", {
54
+ className: classes.ScrollContainer,
55
+ "data-hide-icons": hideIcons,
56
+ ref: scrollContainer,
57
+ "data-component": "underlinenav-scrollcontainer",
58
+ children: /*#__PURE__*/jsx(UnderlineWrapper, {
59
+ as: as,
60
+ "aria-label": ariaLabel,
61
+ className: className,
62
+ ref: forwardedRef,
63
+ "data-variant": variant,
64
+ "data-overflow-mode": "wrap",
65
+ style: {
66
+ minWidth: 'fit-content'
67
+ },
68
+ children: /*#__PURE__*/jsx(UnderlineItemList, {
69
+ role: "list",
70
+ children: children
71
+ })
515
72
  })
516
73
  })]
517
74
  });
@@ -1,5 +1,5 @@
1
- import './UnderlineNav-4344d9b0.css';
1
+ import './UnderlineNav-4c80468c.css';
2
2
 
3
- var classes = {"MenuItemContent":"prc-UnderlineNav-MenuItemContent-3J7gB","MoreButton":"prc-UnderlineNav-MoreButton-Y8soj"};
3
+ var classes = {"ScrollContainer":"prc-UnderlineNav-ScrollContainer-kBvfS","detect-overflow":"prc-UnderlineNav-detect-overflow-6HuSH"};
4
4
 
5
5
  export { classes as default };