@primer/react 0.0.0-20260602154623 → 0.0.0-20260602172019
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqC,MAAM,OAAO,CAAA;AAczD,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,mFAwIxB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useRef, useState
|
|
1
|
+
import React, { forwardRef, useRef, useState } from 'react';
|
|
2
2
|
import VisuallyHidden from '../_VisuallyHidden.js';
|
|
3
3
|
import { ActionList } from '../ActionList/index.js';
|
|
4
4
|
import { UnderlineWrapper, UnderlineItemList, LoadingCounter } from '../internal/components/UnderlineTabbedInterface.js';
|
|
@@ -7,6 +7,7 @@ import classes from './UnderlineNav.module.css.js';
|
|
|
7
7
|
import { UnderlineNavContext } from './UnderlineNavContext.js';
|
|
8
8
|
import { UnderlineNavItemsRegistry } from './UnderlineNavItem.js';
|
|
9
9
|
import { clsx } from 'clsx';
|
|
10
|
+
import { useDevOnlyEffect } from '../internal/hooks/useDevOnlyEffect.js';
|
|
10
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
12
|
import { SkeletonText } from '../SkeletonText/SkeletonText.js';
|
|
12
13
|
import CounterLabel from '../CounterLabel/CounterLabel.js';
|
|
@@ -39,20 +40,15 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
39
40
|
// Find the current item if it has overflowed into the menu, so we can reflect
|
|
40
41
|
// its "current" state on the overflow menu anchor.
|
|
41
42
|
const overflowingCurrentItem = (_menuItems$find = menuItems.find(([, itemProps]) => itemProps['aria-current'] !== undefined && itemProps['aria-current'] !== false && itemProps['aria-current'] !== 'false')) === null || _menuItems$find === void 0 ? void 0 : _menuItems$find[1];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
!(activeElements.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Only one current element is allowed') : invariant(false) : void 0;
|
|
53
|
-
!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;
|
|
54
|
-
}, [validChildren, ariaLabel]);
|
|
55
|
-
}
|
|
43
|
+
const validChildren = getValidChildren(children);
|
|
44
|
+
useDevOnlyEffect(() => {
|
|
45
|
+
// Address illegal state where there are multiple items that have `aria-current='page'` attribute
|
|
46
|
+
const activeElements = validChildren.filter(child => {
|
|
47
|
+
return child.props['aria-current'] !== undefined;
|
|
48
|
+
});
|
|
49
|
+
!(activeElements.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Only one current element is allowed') : invariant(false) : void 0;
|
|
50
|
+
!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;
|
|
51
|
+
}, [validChildren, ariaLabel]);
|
|
56
52
|
return /*#__PURE__*/jsxs(UnderlineNavContext.Provider, {
|
|
57
53
|
value: {
|
|
58
54
|
loadingCounters
|
package/package.json
CHANGED