@primer/react 0.0.0-20261112223856 → 0.0.0-20261113153150
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,6 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20261113153150
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
### Patch Changes
|
|
12
12
|
|
|
13
|
+
- [#8748](https://github.com/primer/react/pull/8748) [`a3d58eb`](https://github.com/primer/react/commit/a3d58ebf31ce2c36c3ae5d16899bea6da2d7bbcc) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Breadcrumbs: Collapse crumbs that render more than one element (such as a link with a sibling button) when they no longer fit, instead of overflowing the container.
|
|
14
|
+
|
|
13
15
|
- [#8683](https://github.com/primer/react/pull/8683) [`32d5061`](https://github.com/primer/react/commit/32d50618c58cceddf66d83716ac9742c2134b790) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Breadcrumbs: Improve the performance of `overflow="menu"` and `"menu-with-root"` on mount, resize and navigation. Server-rendered markup now applies the collapse rules before hydration, and the overflow menu trigger is a `<button>`.
|
|
14
16
|
|
|
15
17
|
- [#8592](https://github.com/primer/react/pull/8592) [`0ae18d3`](https://github.com/primer/react/commit/0ae18d38f09044c40c1a181288c2783e93629b4e) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Card: Improve shrinking and equal-height layouts, keep secondary controls accessible in custom whole-card compositions, and keep images edge-to-edge across padding options.
|
|
@@ -18,8 +20,6 @@
|
|
|
18
20
|
|
|
19
21
|
- Fake entry to force publishing
|
|
20
22
|
|
|
21
|
-
- [#8725](https://github.com/primer/react/pull/8725) [`155203f`](https://github.com/primer/react/commit/155203f2eac0987a1e588d020c7969d284c9b01f) Thanks [@mattcosta7](https://github.com/mattcosta7)! - useAnchoredPosition: Skip re-renders when the overlay position is unchanged, and reposition when `side` or `align` changes while open. This reduces re-renders in ActionMenu, SelectPanel, Autocomplete and AnchoredOverlay.
|
|
22
|
-
|
|
23
23
|
- [#8628](https://github.com/primer/react/pull/8628) [`41f29c8`](https://github.com/primer/react/commit/41f29c845663936043618af29dcb71de4c9384b2) Thanks [@joshblack](https://github.com/joshblack)! - SkeletonAvatar, SkeletonText: Preserve the requested size and shape regardless of stylesheet load order
|
|
24
24
|
|
|
25
25
|
- [#8681](https://github.com/primer/react/pull/8681) [`8a9013e`](https://github.com/primer/react/commit/8a9013ea48359ad60a60e194783c865c08d3b7db) Thanks [@mattcosta7](https://github.com/mattcosta7)! - SkeletonBox, SkeletonText, SkeletonAvatar, ProgressBar: Run the loading shimmer animation on the compositor to reduce main-thread work while skeletons are visible
|
|
@@ -61,6 +61,12 @@ function getContentWidth(nav) {
|
|
|
61
61
|
const { paddingLeft, paddingRight } = getComputedStyle(nav);
|
|
62
62
|
return nav.clientWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
63
63
|
}
|
|
64
|
+
function getCrumbWidth(li, range) {
|
|
65
|
+
range.selectNodeContents(li);
|
|
66
|
+
const last = li.lastElementChild;
|
|
67
|
+
if (last !== null && last !== void 0 && last.classList.contains(Breadcrumbs_module_css_default.ItemSeparator)) range.setEndBefore(last);
|
|
68
|
+
return range.getBoundingClientRect().width;
|
|
69
|
+
}
|
|
64
70
|
const sameFit = (a, b) => a.extra === b.extra && a.rootCollapsed === b.rootCollapsed && a.narrow === b.narrow;
|
|
65
71
|
function getValidChildren(children) {
|
|
66
72
|
return React.Children.toArray(children).filter((child) => /*#__PURE__*/ React.isValidElement(child));
|
|
@@ -245,6 +251,7 @@ function Breadcrumbs(t0) {
|
|
|
245
251
|
const previous = widthsRef.current;
|
|
246
252
|
const widths_0 = /* @__PURE__ */ new Map();
|
|
247
253
|
let separators = separatorsRef.current;
|
|
254
|
+
const range = nav.ownerDocument.createRange();
|
|
248
255
|
for (const item_0 of items) {
|
|
249
256
|
var _item_0$key;
|
|
250
257
|
const width = previous.get((_item_0$key = item_0.key) !== null && _item_0$key !== void 0 ? _item_0$key : "");
|
|
@@ -256,9 +263,8 @@ function Breadcrumbs(t0) {
|
|
|
256
263
|
for (const li of nav.querySelectorAll(":scope > ol > li[data-index]")) {
|
|
257
264
|
var _items$Number;
|
|
258
265
|
const key = (_items$Number = items[Number(li.getAttribute("data-index"))]) === null || _items$Number === void 0 ? void 0 : _items$Number.key;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const crumbWidth = crumb.getBoundingClientRect().width;
|
|
266
|
+
if (key == null) continue;
|
|
267
|
+
const crumbWidth = getCrumbWidth(li, range);
|
|
262
268
|
widths_0.set(key, crumbWidth);
|
|
263
269
|
if (li.nextElementSibling && !li.hasAttribute("data-collapsed")) {
|
|
264
270
|
const separator = li.getBoundingClientRect().width - crumbWidth;
|
|
@@ -38,36 +38,38 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
38
38
|
const enabled = (_settings$enabled = settings === null || settings === void 0 ? void 0 : settings.enabled) !== null && _settings$enabled !== void 0 ? _settings$enabled : true;
|
|
39
39
|
const savedOnPositionChange = React.useRef(settings === null || settings === void 0 ? void 0 : settings.onPositionChange);
|
|
40
40
|
const [position, setPosition] = React.useState(void 0);
|
|
41
|
-
const
|
|
41
|
+
const [_, setPrevHeight] = React.useState(void 0);
|
|
42
42
|
const topPositionChanged = (prevPosition, newPosition) => {
|
|
43
43
|
return prevPosition && ["outside-top", "inside-top"].includes(prevPosition.anchorSide) && (prevPosition.anchorSide !== newPosition.anchorSide || prevPosition.top < newPosition.top);
|
|
44
44
|
};
|
|
45
|
-
const updateElementHeight = (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
const updateElementHeight = () => {
|
|
46
|
+
let heightUpdated = false;
|
|
47
|
+
setPrevHeight((prevHeight) => {
|
|
48
|
+
var _floatingElementRef$c, _floatingElementRef$c2;
|
|
49
|
+
if (prevHeight && prevHeight > ((_floatingElementRef$c = (_floatingElementRef$c2 = floatingElementRef.current) === null || _floatingElementRef$c2 === void 0 ? void 0 : _floatingElementRef$c2.clientHeight) !== null && _floatingElementRef$c !== void 0 ? _floatingElementRef$c : 0)) {
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
floatingElementRef.current.style.height = `${prevHeight}px`;
|
|
52
|
+
});
|
|
53
|
+
heightUpdated = true;
|
|
54
|
+
}
|
|
55
|
+
return prevHeight;
|
|
56
|
+
});
|
|
57
|
+
return heightUpdated;
|
|
54
58
|
};
|
|
55
59
|
const updatePosition = React.useCallback(() => {
|
|
60
|
+
var _floatingElementRef$c5;
|
|
56
61
|
if (!enabled) return;
|
|
57
|
-
const prevMeasured = prevHeightRef.current;
|
|
58
|
-
const prevHeight = (prevMeasured === null || prevMeasured === void 0 ? void 0 : prevMeasured.element) === floatingElementRef.current ? prevMeasured.height : void 0;
|
|
59
62
|
if (floatingElementRef.current instanceof Element && anchorElementRef.current instanceof Element) {
|
|
60
63
|
const newPosition = getAnchoredPosition(floatingElementRef.current, anchorElementRef.current, settings);
|
|
61
64
|
setPosition((prev) => {
|
|
62
65
|
if (settings !== null && settings !== void 0 && settings.pinPosition && topPositionChanged(prev, newPosition)) {
|
|
63
66
|
var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$c3, _floatingElementRef$c4;
|
|
64
|
-
if (((_anchorElementRef$cur = (_anchorElementRef$cur2 = anchorElementRef.current) === null || _anchorElementRef$cur2 === void 0 ? void 0 : _anchorElementRef$cur2.getBoundingClientRect().top) !== null && _anchorElementRef$cur !== void 0 ? _anchorElementRef$cur : 0) > ((_floatingElementRef$c3 = (_floatingElementRef$c4 = floatingElementRef.current) === null || _floatingElementRef$c4 === void 0 ? void 0 : _floatingElementRef$c4.clientHeight) !== null && _floatingElementRef$c3 !== void 0 ? _floatingElementRef$c3 : 0) && updateElementHeight(
|
|
67
|
+
if (((_anchorElementRef$cur = (_anchorElementRef$cur2 = anchorElementRef.current) === null || _anchorElementRef$cur2 === void 0 ? void 0 : _anchorElementRef$cur2.getBoundingClientRect().top) !== null && _anchorElementRef$cur !== void 0 ? _anchorElementRef$cur : 0) > ((_floatingElementRef$c3 = (_floatingElementRef$c4 = floatingElementRef.current) === null || _floatingElementRef$c4 === void 0 ? void 0 : _floatingElementRef$c4.clientHeight) !== null && _floatingElementRef$c3 !== void 0 ? _floatingElementRef$c3 : 0) && updateElementHeight()) return prev;
|
|
65
68
|
}
|
|
66
69
|
if (prev && prev.anchorSide === newPosition.anchorSide) {
|
|
67
70
|
var _savedOnPositionChang;
|
|
68
71
|
(_savedOnPositionChang = savedOnPositionChange.current) === null || _savedOnPositionChang === void 0 || _savedOnPositionChang.call(savedOnPositionChange, newPosition);
|
|
69
72
|
}
|
|
70
|
-
if (prev && prev.top === newPosition.top && prev.left === newPosition.left && prev.anchorSide === newPosition.anchorSide && prev.anchorAlign === newPosition.anchorAlign) return prev;
|
|
71
73
|
return newPosition;
|
|
72
74
|
});
|
|
73
75
|
} else {
|
|
@@ -75,21 +77,11 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
75
77
|
setPosition(void 0);
|
|
76
78
|
(_savedOnPositionChang2 = savedOnPositionChange.current) === null || _savedOnPositionChang2 === void 0 || _savedOnPositionChang2.call(savedOnPositionChange, void 0);
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
element: floatingElementRef.current,
|
|
80
|
-
height: floatingElementRef.current.clientHeight
|
|
81
|
-
} : void 0;
|
|
80
|
+
setPrevHeight((_floatingElementRef$c5 = floatingElementRef.current) === null || _floatingElementRef$c5 === void 0 ? void 0 : _floatingElementRef$c5.clientHeight);
|
|
82
81
|
}, [
|
|
83
82
|
floatingElementRef,
|
|
84
83
|
anchorElementRef,
|
|
85
84
|
enabled,
|
|
86
|
-
settings === null || settings === void 0 ? void 0 : settings.side,
|
|
87
|
-
settings === null || settings === void 0 ? void 0 : settings.align,
|
|
88
|
-
settings === null || settings === void 0 ? void 0 : settings.anchorOffset,
|
|
89
|
-
settings === null || settings === void 0 ? void 0 : settings.alignmentOffset,
|
|
90
|
-
settings === null || settings === void 0 ? void 0 : settings.allowOutOfBounds,
|
|
91
|
-
settings === null || settings === void 0 ? void 0 : settings.displayInViewport,
|
|
92
|
-
settings === null || settings === void 0 ? void 0 : settings.pinPosition,
|
|
93
85
|
...dependencies
|
|
94
86
|
]);
|
|
95
87
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -113,11 +105,6 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
113
105
|
}
|
|
114
106
|
}, [updatePosition]);
|
|
115
107
|
useResizeObserver(updatePosition, void 0, [], enabled);
|
|
116
|
-
React.useEffect(() => {
|
|
117
|
-
if (!enabled) return;
|
|
118
|
-
window.addEventListener("resize", updatePosition);
|
|
119
|
-
return () => window.removeEventListener("resize", updatePosition);
|
|
120
|
-
}, [enabled, updatePosition]);
|
|
121
108
|
useResizeObserver(updatePosition, floatingElementRef, [], enabled);
|
|
122
109
|
const scrollAncestorsCacheRef = React.useRef({
|
|
123
110
|
anchor: null,
|
package/package.json
CHANGED