@primer/react 0.0.0-20260715132522 → 0.0.0-20260715132544
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,17 +1,17 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260715132544
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- [#8064](https://github.com/primer/react/pull/8064) [`eb447fe`](https://github.com/primer/react/commit/eb447fef0f1565934dc38d09df21d8063957aa9d) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Update the ActionBar overflow menu anchor label to `More items`
|
|
8
8
|
|
|
9
|
-
- [#8005](https://github.com/primer/react/pull/8005) [`5d24be4`](https://github.com/primer/react/commit/5d24be483f2fdfa305970907984d04522e2aa13c) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Derive `AutocompleteMenu` close-time re-sorting and `LabelGroup` numeric truncation during render instead of in effects, removing redundant render passes. No public API or visual changes.
|
|
10
|
-
|
|
11
9
|
- Fake entry to force publishing
|
|
12
10
|
|
|
13
11
|
- [#8116](https://github.com/primer/react/pull/8116) [`cade4af`](https://github.com/primer/react/commit/cade4af9a70f3fd2622031af585dc07dccd79e11) Thanks [@mattcosta7](https://github.com/mattcosta7)! - `useAnchoredPosition`: improve performance by caching the scrollable-ancestor walk per anchor, reducing repositioning work for overlays, menus, and tooltips.
|
|
14
12
|
|
|
13
|
+
- [#8025](https://github.com/primer/react/pull/8025) [`5abc62f`](https://github.com/primer/react/commit/5abc62f90cac33cd67396d78f01bf91b703db45c) Thanks [@mattcosta7](https://github.com/mattcosta7)! - SelectPanel: Reset the single-select modal's intermediate selection during render instead of in an effect, avoiding an extra re-render when the panel opens or the selection changes.
|
|
14
|
+
|
|
15
15
|
- [#8164](https://github.com/primer/react/pull/8164) [`f86e5a6`](https://github.com/primer/react/commit/f86e5a6420e857e7476c3954d419f4e228bdcf1a) Thanks [@jonrohan](https://github.com/jonrohan)! - Fix `UnderlineNav` tab list not filling the full width of the underline nav in Safari
|
|
16
16
|
|
|
17
17
|
## 38.32.0
|
|
@@ -43,7 +43,7 @@ const debounceAnnouncement = debounce((announcement) => {
|
|
|
43
43
|
announce(announcement);
|
|
44
44
|
}, 250);
|
|
45
45
|
function AutocompleteMenu(props) {
|
|
46
|
-
const $ = c(
|
|
46
|
+
const $ = c(78);
|
|
47
47
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
48
48
|
const deferredInputContext = useContext(AutocompleteDeferredInputContext);
|
|
49
49
|
if (autocompleteContext === null || deferredInputContext === null) throw new Error("AutocompleteContext returned null values");
|
|
@@ -254,46 +254,54 @@ function AutocompleteMenu(props) {
|
|
|
254
254
|
t16 = $[54];
|
|
255
255
|
}
|
|
256
256
|
useEffect(t15, t16);
|
|
257
|
-
if (showMenu === false) {
|
|
258
|
-
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
259
|
-
if (!(itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]))) setSortedItemIds(itemIdSortResult);
|
|
260
|
-
}
|
|
261
257
|
let t17;
|
|
262
258
|
let t18;
|
|
263
|
-
if ($[55] !== onOpenChange || $[56] !== showMenu) {
|
|
259
|
+
if ($[55] !== onOpenChange || $[56] !== selectedItemIds || $[57] !== showMenu || $[58] !== sortOnCloseFn || $[59] !== sortedItemIds) {
|
|
264
260
|
t17 = () => {
|
|
261
|
+
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
262
|
+
const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]);
|
|
263
|
+
if (showMenu === false && !sortResultMatchesState) setSortedItemIds(itemIdSortResult);
|
|
265
264
|
onOpenChange && onOpenChange(Boolean(showMenu));
|
|
266
265
|
};
|
|
267
|
-
t18 = [
|
|
266
|
+
t18 = [
|
|
267
|
+
showMenu,
|
|
268
|
+
onOpenChange,
|
|
269
|
+
selectedItemIds,
|
|
270
|
+
sortOnCloseFn,
|
|
271
|
+
sortedItemIds
|
|
272
|
+
];
|
|
268
273
|
$[55] = onOpenChange;
|
|
269
|
-
$[56] =
|
|
270
|
-
$[57] =
|
|
271
|
-
$[58] =
|
|
274
|
+
$[56] = selectedItemIds;
|
|
275
|
+
$[57] = showMenu;
|
|
276
|
+
$[58] = sortOnCloseFn;
|
|
277
|
+
$[59] = sortedItemIds;
|
|
278
|
+
$[60] = t17;
|
|
279
|
+
$[61] = t18;
|
|
272
280
|
} else {
|
|
273
|
-
t17 = $[
|
|
274
|
-
t18 = $[
|
|
281
|
+
t17 = $[60];
|
|
282
|
+
t18 = $[61];
|
|
275
283
|
}
|
|
276
284
|
useEffect(t17, t18);
|
|
277
285
|
let t19;
|
|
278
|
-
if ($[
|
|
286
|
+
if ($[62] !== selectedItemIds.length || $[63] !== setSelectedItemLength) {
|
|
279
287
|
t19 = () => {
|
|
280
288
|
if (selectedItemIds.length) setSelectedItemLength(selectedItemIds.length);
|
|
281
289
|
};
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
284
|
-
$[
|
|
285
|
-
} else t19 = $[
|
|
290
|
+
$[62] = selectedItemIds.length;
|
|
291
|
+
$[63] = setSelectedItemLength;
|
|
292
|
+
$[64] = t19;
|
|
293
|
+
} else t19 = $[64];
|
|
286
294
|
let t20;
|
|
287
|
-
if ($[
|
|
295
|
+
if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
|
|
288
296
|
t20 = [selectedItemIds, setSelectedItemLength];
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
292
|
-
} else t20 = $[
|
|
297
|
+
$[65] = selectedItemIds;
|
|
298
|
+
$[66] = setSelectedItemLength;
|
|
299
|
+
$[67] = t20;
|
|
300
|
+
} else t20 = $[67];
|
|
293
301
|
useEffect(t19, t20);
|
|
294
302
|
if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
295
303
|
let t21;
|
|
296
|
-
if ($[
|
|
304
|
+
if ($[68] !== allItemsToRender || $[69] !== ariaLabelledBy || $[70] !== emptyStateText || $[71] !== id || $[72] !== loading || $[73] !== selectionVariant) {
|
|
297
305
|
t21 = loading ? /*#__PURE__*/ jsx("div", {
|
|
298
306
|
className: AutocompleteMenu_module_css_default.SpinnerWrapper,
|
|
299
307
|
children: /*#__PURE__*/ jsx(Spinner, {})
|
|
@@ -311,24 +319,24 @@ function AutocompleteMenu(props) {
|
|
|
311
319
|
children: emptyStateText
|
|
312
320
|
}) : null
|
|
313
321
|
});
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
} else t21 = $[
|
|
322
|
+
$[68] = allItemsToRender;
|
|
323
|
+
$[69] = ariaLabelledBy;
|
|
324
|
+
$[70] = emptyStateText;
|
|
325
|
+
$[71] = id;
|
|
326
|
+
$[72] = loading;
|
|
327
|
+
$[73] = selectionVariant;
|
|
328
|
+
$[74] = t21;
|
|
329
|
+
} else t21 = $[74];
|
|
322
330
|
let t22;
|
|
323
|
-
if ($[
|
|
331
|
+
if ($[75] !== showMenu || $[76] !== t21) {
|
|
324
332
|
t22 = /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
325
333
|
isVisible: showMenu,
|
|
326
334
|
children: t21
|
|
327
335
|
});
|
|
328
|
-
$[
|
|
329
|
-
$[
|
|
330
|
-
$[
|
|
331
|
-
} else t22 = $[
|
|
336
|
+
$[75] = showMenu;
|
|
337
|
+
$[76] = t21;
|
|
338
|
+
$[77] = t22;
|
|
339
|
+
} else t22 = $[77];
|
|
332
340
|
return t22;
|
|
333
341
|
}
|
|
334
342
|
function _temp5(item_2) {
|
|
@@ -13,16 +13,6 @@ const getOverlayWidth = (buttonClientRect, containerRef, overlayPaddingPx) => {
|
|
|
13
13
|
var _containerRef$current;
|
|
14
14
|
return overlayPaddingPx + buttonClientRect.right - (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getBoundingClientRect().left) || 0);
|
|
15
15
|
};
|
|
16
|
-
const getVisibilityMapAfterIndex = (childCount, truncateAfter) => {
|
|
17
|
-
const updatedEntries = {};
|
|
18
|
-
for (let index = 0; index < childCount; index++) updatedEntries[index.toString()] = index < truncateAfter;
|
|
19
|
-
return updatedEntries;
|
|
20
|
-
};
|
|
21
|
-
const visibilityMapsMatch = (left, right) => {
|
|
22
|
-
const leftKeys = Object.keys(left);
|
|
23
|
-
const rightKeys = Object.keys(right);
|
|
24
|
-
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && left[key] === right[key]);
|
|
25
|
-
};
|
|
26
16
|
const InlineToggle = ({ collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline }) => isOverflowShown ? /*#__PURE__*/ jsx(ButtonComponent, {
|
|
27
17
|
ref: collapseButtonRef,
|
|
28
18
|
onClick: collapseInlineExpandedChildren,
|
|
@@ -109,7 +99,6 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
109
99
|
bottom: 0,
|
|
110
100
|
toJSON: () => void 0
|
|
111
101
|
});
|
|
112
|
-
const childArray = React.Children.toArray(children);
|
|
113
102
|
const overlayPaddingPx = 8;
|
|
114
103
|
const hiddenItemIds = Object.keys(visibilityMap).filter((key) => !visibilityMap[key]);
|
|
115
104
|
const overlayWidth = hiddenItemIds.length && overflowStyle === "overlay" ? getOverlayWidth(buttonClientRect, containerRef, overlayPaddingPx) : void 0;
|
|
@@ -121,8 +110,15 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
121
110
|
}
|
|
122
111
|
}, [buttonClientRect]);
|
|
123
112
|
const hideChildrenAfterIndex = React.useCallback((truncateAfter) => {
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
var _containerRef$current2;
|
|
114
|
+
const containerChildren = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children) || [];
|
|
115
|
+
const updatedEntries = {};
|
|
116
|
+
for (const child of containerChildren) {
|
|
117
|
+
const targetId = child.getAttribute("data-index");
|
|
118
|
+
if (targetId) updatedEntries[targetId] = parseInt(targetId, 10) < truncateAfter;
|
|
119
|
+
}
|
|
120
|
+
setVisibilityMap(updatedEntries);
|
|
121
|
+
}, []);
|
|
126
122
|
const openOverflowOverlay = React.useCallback(() => setIsOverflowShown(true), [setIsOverflowShown]);
|
|
127
123
|
const closeOverflowOverlay = React.useCallback(() => {
|
|
128
124
|
setIsOverflowShown(false);
|
|
@@ -143,12 +139,6 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
143
139
|
setVisibilityMap({});
|
|
144
140
|
setIsOverflowShown(true);
|
|
145
141
|
}, [setVisibilityMap, setIsOverflowShown]);
|
|
146
|
-
const numericVisibilityMap = React.useMemo(() => visibleChildCount && typeof visibleChildCount === "number" && !isOverflowShown ? getVisibilityMapAfterIndex(childArray.length, visibleChildCount) : void 0, [
|
|
147
|
-
childArray.length,
|
|
148
|
-
isOverflowShown,
|
|
149
|
-
visibleChildCount
|
|
150
|
-
]);
|
|
151
|
-
if (numericVisibilityMap && !visibilityMapsMatch(visibilityMap, numericVisibilityMap)) setVisibilityMap(numericVisibilityMap);
|
|
152
142
|
React.useEffect(() => {
|
|
153
143
|
if (!visibleChildCount || isOverflowShown) return;
|
|
154
144
|
if (visibleChildCount === "auto") {
|
|
@@ -167,15 +157,16 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
167
157
|
rootMargin: `0px -${buttonClientRect.width}px 0px 0px`,
|
|
168
158
|
threshold: 1
|
|
169
159
|
});
|
|
170
|
-
for (const item of ((_containerRef$
|
|
171
|
-
var _containerRef$
|
|
160
|
+
for (const item of ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []) {
|
|
161
|
+
var _containerRef$current3;
|
|
172
162
|
if (item.getAttribute("data-index")) observer.observe(item);
|
|
173
163
|
}
|
|
174
164
|
return () => observer.disconnect();
|
|
175
|
-
}
|
|
165
|
+
} else hideChildrenAfterIndex(visibleChildCount);
|
|
176
166
|
}, [
|
|
177
167
|
buttonClientRect,
|
|
178
168
|
visibleChildCount,
|
|
169
|
+
hideChildrenAfterIndex,
|
|
179
170
|
isOverflowShown
|
|
180
171
|
]);
|
|
181
172
|
React.useEffect(() => {
|
|
@@ -205,7 +196,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
205
196
|
"data-list": isList || void 0,
|
|
206
197
|
className: clsx(className, LabelGroup_module_css_default.Container),
|
|
207
198
|
"data-component": "LabelGroup",
|
|
208
|
-
children: [
|
|
199
|
+
children: [React.Children.map(children, (child, index) => /*#__PURE__*/ jsx(ItemWrapperComponent, {
|
|
209
200
|
"data-index": index,
|
|
210
201
|
className: clsx(LabelGroup_module_css_default.ItemWrapper, { [LabelGroup_module_css_default["ItemWrapper--hidden"]]: hiddenItemIds.includes(index.toString()) }),
|
|
211
202
|
children: child
|
|
@@ -218,7 +209,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
218
209
|
hiddenItemIds,
|
|
219
210
|
isOverflowShown,
|
|
220
211
|
showAllTokensInline,
|
|
221
|
-
totalLength:
|
|
212
|
+
totalLength: React.Children.toArray(children).length
|
|
222
213
|
}) : /*#__PURE__*/ jsx(OverlayToggle, {
|
|
223
214
|
closeOverflowOverlay,
|
|
224
215
|
expandButtonRef,
|
|
@@ -227,7 +218,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
227
218
|
openOverflowOverlay,
|
|
228
219
|
overlayPaddingPx,
|
|
229
220
|
overlayWidth,
|
|
230
|
-
totalLength:
|
|
221
|
+
totalLength: React.Children.toArray(children).length,
|
|
231
222
|
children
|
|
232
223
|
})
|
|
233
224
|
})]
|
|
@@ -99,13 +99,20 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
|
|
|
99
99
|
const selectedValueId = id ? `${id}-selected-value` : void 0;
|
|
100
100
|
const isSingleSelectModal = variant === "modal" && !isMultiSelectVariant(selected);
|
|
101
101
|
const [intermediateSelected, setIntermediateSelected] = useState(isSingleSelectModal ? selected : void 0);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, [
|
|
105
|
-
isSingleSelectModal,
|
|
102
|
+
const nextIntermediateSelected = isSingleSelectModal ? selected : void 0;
|
|
103
|
+
const [intermediateSelectedResetKey, setIntermediateSelectedResetKey] = useState({
|
|
106
104
|
open,
|
|
107
|
-
selected
|
|
108
|
-
|
|
105
|
+
selected,
|
|
106
|
+
isSingleSelectModal
|
|
107
|
+
});
|
|
108
|
+
if (intermediateSelectedResetKey.open !== open || intermediateSelectedResetKey.selected !== selected || intermediateSelectedResetKey.isSingleSelectModal !== isSingleSelectModal) {
|
|
109
|
+
setIntermediateSelectedResetKey({
|
|
110
|
+
open,
|
|
111
|
+
selected,
|
|
112
|
+
isSingleSelectModal
|
|
113
|
+
});
|
|
114
|
+
if (intermediateSelected !== nextIntermediateSelected) setIntermediateSelected(nextIntermediateSelected);
|
|
115
|
+
}
|
|
109
116
|
const onListContainerRefChanged = useCallback((node) => {
|
|
110
117
|
setListContainerElement(node);
|
|
111
118
|
if (!node && needsNoItemsAnnouncement) setNeedsNoItemsAnnouncement(false);
|
package/package.json
CHANGED