@primer/react 0.0.0-20260710131553 → 0.0.0-20260710171225
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 +1 -3
- package/dist/ActionList/List.js +45 -46
- package/dist/AnchoredOverlay/AnchoredOverlay.js +4 -2
- package/dist/Autocomplete/AutocompleteInput.js +10 -7
- package/dist/Autocomplete/AutocompleteMenu.js +44 -36
- package/dist/ButtonGroup/ButtonGroup.js +23 -23
- package/dist/Checkbox/Checkbox.js +5 -4
- package/dist/Dialog/Dialog.js +3 -3
- package/dist/FilteredActionList/FilteredActionList.js +7 -5
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/LabelGroup/LabelGroup.js +16 -25
- package/dist/PageHeader/PageHeader.js +33 -34
- package/dist/TextInput/TextInput.js +5 -4
- package/dist/TooltipV2/Tooltip.js +4 -3
- package/dist/experimental/Tabs/types.d.ts +2 -2
- package/dist/experimental/Tabs/useTabList.js +16 -15
- package/dist/hooks/useMergedRefs.js +4 -1
- package/dist/hooks/useProvidedRefOrCreate.d.ts +7 -10
- package/dist/hooks/useProvidedRefOrCreate.js +7 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260710171225
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
### Patch Changes
|
|
21
21
|
|
|
22
|
-
- [#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.
|
|
23
|
-
|
|
24
22
|
- Fake entry to force publishing
|
|
25
23
|
|
|
26
24
|
- [#7901](https://github.com/primer/react/pull/7901) [`8288ed9`](https://github.com/primer/react/commit/8288ed9d88668f93cf3b1eb70ee61edac6217367) Thanks [@mattcosta7](https://github.com/mattcosta7)! - PageHeader: improve rendering performance by removing expensive `:has()` selectors. No visual or API changes.
|
package/dist/ActionList/List.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
3
3
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
4
4
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
@@ -12,11 +12,11 @@ import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
|
12
12
|
import { c } from "react-compiler-runtime";
|
|
13
13
|
import { clsx } from "clsx";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import React from "react";
|
|
15
|
+
import React, { useRef } from "react";
|
|
16
16
|
//#region src/ActionList/List.tsx
|
|
17
17
|
const UnwrappedList = (props, forwardedRef) => {
|
|
18
18
|
var _slots$heading$props$;
|
|
19
|
-
const $ = c(
|
|
19
|
+
const $ = c(38);
|
|
20
20
|
let className;
|
|
21
21
|
let restProps;
|
|
22
22
|
let role;
|
|
@@ -60,7 +60,8 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
60
60
|
const { listRole: listRoleFromContainer, listLabelledBy, selectionVariant: containerSelectionVariant, enableFocusZone: enableFocusZoneFromContainer, container } = React.useContext(ActionListContainerContext);
|
|
61
61
|
const ariaLabelledBy = slots.heading ? (_slots$heading$props$ = slots.heading.props.id) !== null && _slots$heading$props$ !== void 0 ? _slots$heading$props$ : headingId : listLabelledBy;
|
|
62
62
|
const listRole = role || listRoleFromContainer;
|
|
63
|
-
const listRef =
|
|
63
|
+
const listRef = useRef(null);
|
|
64
|
+
const mergedRef = useMergedRefs(forwardedRef, listRef);
|
|
64
65
|
const itemGapEnabled = useFeatureFlag("primer_react_action_list_item_gap") && container === "NavList";
|
|
65
66
|
let enableFocusZone = false;
|
|
66
67
|
if (enableFocusZoneFromContainer !== void 0) enableFocusZone = enableFocusZoneFromContainer;
|
|
@@ -79,22 +80,21 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
79
80
|
const t5 = !enableFocusZone;
|
|
80
81
|
const t6 = listRole === "menu" || container === "SelectPanel" || container === "FilteredActionList" ? "wrap" : void 0;
|
|
81
82
|
let t7;
|
|
82
|
-
if ($[11] !==
|
|
83
|
+
if ($[11] !== t5 || $[12] !== t6) {
|
|
83
84
|
t7 = {
|
|
84
85
|
disabled: t5,
|
|
85
86
|
containerRef: listRef,
|
|
86
87
|
bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
|
|
87
88
|
focusOutBehavior: t6
|
|
88
89
|
};
|
|
89
|
-
$[11] =
|
|
90
|
-
$[12] =
|
|
91
|
-
$[13] =
|
|
92
|
-
|
|
93
|
-
} else t7 = $[14];
|
|
90
|
+
$[11] = t5;
|
|
91
|
+
$[12] = t6;
|
|
92
|
+
$[13] = t7;
|
|
93
|
+
} else t7 = $[13];
|
|
94
94
|
useFocusZone(t7);
|
|
95
95
|
const t8 = selectionVariant || containerSelectionVariant;
|
|
96
96
|
let t9;
|
|
97
|
-
if ($[
|
|
97
|
+
if ($[14] !== headingId || $[15] !== listRole || $[16] !== showDividers || $[17] !== t8 || $[18] !== variant) {
|
|
98
98
|
t9 = {
|
|
99
99
|
variant,
|
|
100
100
|
selectionVariant: t8,
|
|
@@ -102,16 +102,16 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
102
102
|
role: listRole,
|
|
103
103
|
headingId
|
|
104
104
|
};
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
} else t9 = $[
|
|
105
|
+
$[14] = headingId;
|
|
106
|
+
$[15] = listRole;
|
|
107
|
+
$[16] = showDividers;
|
|
108
|
+
$[17] = t8;
|
|
109
|
+
$[18] = variant;
|
|
110
|
+
$[19] = t9;
|
|
111
|
+
} else t9 = $[19];
|
|
112
112
|
const listContextValue = t9;
|
|
113
113
|
let t10;
|
|
114
|
-
if ($[
|
|
114
|
+
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
115
115
|
t10 = () => {
|
|
116
116
|
const list = listRef.current;
|
|
117
117
|
if (!list) return;
|
|
@@ -120,25 +120,24 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
120
120
|
if (hasMixed && current !== "true") list.setAttribute("data-mixed-descriptions", "true");
|
|
121
121
|
else if (!hasMixed && current !== null) list.removeAttribute("data-mixed-descriptions");
|
|
122
122
|
};
|
|
123
|
-
$[
|
|
124
|
-
|
|
125
|
-
} else t10 = $[22];
|
|
123
|
+
$[20] = t10;
|
|
124
|
+
} else t10 = $[20];
|
|
126
125
|
useIsomorphicLayoutEffect(t10);
|
|
127
126
|
const t11 = slots.heading;
|
|
128
127
|
let t12;
|
|
129
|
-
if ($[
|
|
128
|
+
if ($[21] !== className) {
|
|
130
129
|
t12 = clsx(ActionList_module_css_default.ActionList, className);
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
133
|
-
} else t12 = $[
|
|
130
|
+
$[21] = className;
|
|
131
|
+
$[22] = t12;
|
|
132
|
+
} else t12 = $[22];
|
|
134
133
|
const t13 = itemGapEnabled ? "" : void 0;
|
|
135
134
|
let t14;
|
|
136
|
-
if ($[
|
|
135
|
+
if ($[23] !== Component || $[24] !== ariaLabelledBy || $[25] !== childrenWithoutSlots || $[26] !== listRole || $[27] !== mergedRef || $[28] !== restProps || $[29] !== showDividers || $[30] !== t12 || $[31] !== t13 || $[32] !== variant) {
|
|
137
136
|
t14 = /*#__PURE__*/ jsx(Component, {
|
|
138
137
|
className: t12,
|
|
139
138
|
role: listRole,
|
|
140
139
|
"aria-labelledby": ariaLabelledBy,
|
|
141
|
-
ref:
|
|
140
|
+
ref: mergedRef,
|
|
142
141
|
"data-component": "ActionList",
|
|
143
142
|
"data-dividers": showDividers,
|
|
144
143
|
"data-variant": variant,
|
|
@@ -146,29 +145,29 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
146
145
|
...restProps,
|
|
147
146
|
children: childrenWithoutSlots
|
|
148
147
|
});
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
} else t14 = $[
|
|
148
|
+
$[23] = Component;
|
|
149
|
+
$[24] = ariaLabelledBy;
|
|
150
|
+
$[25] = childrenWithoutSlots;
|
|
151
|
+
$[26] = listRole;
|
|
152
|
+
$[27] = mergedRef;
|
|
153
|
+
$[28] = restProps;
|
|
154
|
+
$[29] = showDividers;
|
|
155
|
+
$[30] = t12;
|
|
156
|
+
$[31] = t13;
|
|
157
|
+
$[32] = variant;
|
|
158
|
+
$[33] = t14;
|
|
159
|
+
} else t14 = $[33];
|
|
161
160
|
let t15;
|
|
162
|
-
if ($[
|
|
161
|
+
if ($[34] !== listContextValue || $[35] !== slots.heading || $[36] !== t14) {
|
|
163
162
|
t15 = /*#__PURE__*/ jsxs(ListContext.Provider, {
|
|
164
163
|
value: listContextValue,
|
|
165
164
|
children: [t11, t14]
|
|
166
165
|
});
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
} else t15 = $[
|
|
166
|
+
$[34] = listContextValue;
|
|
167
|
+
$[35] = slots.heading;
|
|
168
|
+
$[36] = t14;
|
|
169
|
+
$[37] = t15;
|
|
170
|
+
} else t15 = $[37];
|
|
172
171
|
return t15;
|
|
173
172
|
};
|
|
174
173
|
const List = fixedForwardRef(UnwrappedList);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { reactMajorVersion } from "../utils/environment.js";
|
|
2
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
3
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
4
|
import { useAnchoredPosition } from "../hooks/useAnchoredPosition.js";
|
|
4
5
|
import { useRenderForcingRef } from "../hooks/useRenderForcingRef.js";
|
|
@@ -33,6 +34,7 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
33
34
|
const [anchorElement, setAnchorElement] = useState(null);
|
|
34
35
|
if (anchorRef.current !== anchorElement) setAnchorElement(anchorRef.current);
|
|
35
36
|
const [overlayRef, updateOverlayRef] = useRenderForcingRef();
|
|
37
|
+
const mergedOverlayRef = useMergedRefs(updateOverlayRef, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.ref);
|
|
36
38
|
const [overlayElement, setOverlayElement] = useState(null);
|
|
37
39
|
const anchorId = useId$1(externalAnchorId);
|
|
38
40
|
const onClickOutside = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("click-outside"), [onClose]);
|
|
@@ -189,10 +191,10 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
189
191
|
...shouldRenderAsPopover ? { popover: "manual" } : {},
|
|
190
192
|
...restOverlayProps,
|
|
191
193
|
...shouldRenderAsPopover ? { id: popoverId } : {},
|
|
194
|
+
...cssAnchorPositioning ? { id: popoverId } : {},
|
|
192
195
|
ref: (node) => {
|
|
193
|
-
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) assignRef(overlayProps.ref, node);
|
|
194
|
-
updateOverlayRef(node);
|
|
195
196
|
setOverlayElement(node);
|
|
197
|
+
assignRef(mergedOverlayRef, node);
|
|
196
198
|
},
|
|
197
199
|
"data-anchor-position": cssAnchorPositioning,
|
|
198
200
|
"data-side": cssAnchorPositioning ? side : position === null || position === void 0 ? void 0 : position.anchorSide,
|
|
@@ -20,9 +20,11 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
20
20
|
if (openOnFocus) setShowMenu(true);
|
|
21
21
|
};
|
|
22
22
|
const handleInputBlur = useCallback((event) => {
|
|
23
|
-
onBlur
|
|
23
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
24
24
|
safeSetTimeout(() => {
|
|
25
|
-
|
|
25
|
+
const nextFocusedElement = event.relatedTarget;
|
|
26
|
+
const menuElement = document.getElementById(`${id}-listbox`);
|
|
27
|
+
if (!nextFocusedElement || nextFocusedElement !== menuElement && !(menuElement !== null && menuElement !== void 0 && menuElement.contains(nextFocusedElement))) {
|
|
26
28
|
setShowMenu(false);
|
|
27
29
|
if (inputRef.current && autocompleteSuggestion && inputRef.current.value !== inputValue) inputRef.current.value = inputValue;
|
|
28
30
|
}
|
|
@@ -33,16 +35,17 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
33
35
|
inputRef,
|
|
34
36
|
safeSetTimeout,
|
|
35
37
|
autocompleteSuggestion,
|
|
36
|
-
inputValue
|
|
38
|
+
inputValue,
|
|
39
|
+
id
|
|
37
40
|
]);
|
|
38
41
|
const handleInputChange = (event) => {
|
|
39
|
-
onChange
|
|
42
|
+
onChange === null || onChange === void 0 || onChange(event);
|
|
40
43
|
setInputValue(event.currentTarget.value);
|
|
41
44
|
if (!showMenu) setShowMenu(true);
|
|
42
45
|
};
|
|
43
46
|
const handleInputKeyDown = useCallback((event) => {
|
|
44
47
|
var _inputRef$current;
|
|
45
|
-
onKeyDown
|
|
48
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
46
49
|
if (event.key === "Backspace") setHighlightRemainingText(false);
|
|
47
50
|
if (event.key === "Escape" && (_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) {
|
|
48
51
|
setInputValue("");
|
|
@@ -58,11 +61,11 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
58
61
|
setShowMenu
|
|
59
62
|
]);
|
|
60
63
|
const handleInputKeyUp = useCallback((event) => {
|
|
61
|
-
onKeyUp
|
|
64
|
+
onKeyUp === null || onKeyUp === void 0 || onKeyUp(event);
|
|
62
65
|
if (event.key === "Backspace") setHighlightRemainingText(true);
|
|
63
66
|
}, [setHighlightRemainingText, onKeyUp]);
|
|
64
67
|
const onInputKeyPress = useCallback((event) => {
|
|
65
|
-
onKeyPress
|
|
68
|
+
onKeyPress === null || onKeyPress === void 0 || onKeyPress(event);
|
|
66
69
|
if (showMenu && event.key === "Enter" && activeDescendantRef.current) {
|
|
67
70
|
event.preventDefault();
|
|
68
71
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -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");
|
|
@@ -253,46 +253,54 @@ function AutocompleteMenu(props) {
|
|
|
253
253
|
t16 = $[54];
|
|
254
254
|
}
|
|
255
255
|
useEffect(t15, t16);
|
|
256
|
-
if (showMenu === false) {
|
|
257
|
-
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
258
|
-
if (!(itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]))) setSortedItemIds(itemIdSortResult);
|
|
259
|
-
}
|
|
260
256
|
let t17;
|
|
261
257
|
let t18;
|
|
262
|
-
if ($[55] !== onOpenChange || $[56] !== showMenu) {
|
|
258
|
+
if ($[55] !== onOpenChange || $[56] !== selectedItemIds || $[57] !== showMenu || $[58] !== sortOnCloseFn || $[59] !== sortedItemIds) {
|
|
263
259
|
t17 = () => {
|
|
260
|
+
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
261
|
+
const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]);
|
|
262
|
+
if (showMenu === false && !sortResultMatchesState) setSortedItemIds(itemIdSortResult);
|
|
264
263
|
onOpenChange && onOpenChange(Boolean(showMenu));
|
|
265
264
|
};
|
|
266
|
-
t18 = [
|
|
265
|
+
t18 = [
|
|
266
|
+
showMenu,
|
|
267
|
+
onOpenChange,
|
|
268
|
+
selectedItemIds,
|
|
269
|
+
sortOnCloseFn,
|
|
270
|
+
sortedItemIds
|
|
271
|
+
];
|
|
267
272
|
$[55] = onOpenChange;
|
|
268
|
-
$[56] =
|
|
269
|
-
$[57] =
|
|
270
|
-
$[58] =
|
|
273
|
+
$[56] = selectedItemIds;
|
|
274
|
+
$[57] = showMenu;
|
|
275
|
+
$[58] = sortOnCloseFn;
|
|
276
|
+
$[59] = sortedItemIds;
|
|
277
|
+
$[60] = t17;
|
|
278
|
+
$[61] = t18;
|
|
271
279
|
} else {
|
|
272
|
-
t17 = $[
|
|
273
|
-
t18 = $[
|
|
280
|
+
t17 = $[60];
|
|
281
|
+
t18 = $[61];
|
|
274
282
|
}
|
|
275
283
|
useEffect(t17, t18);
|
|
276
284
|
let t19;
|
|
277
|
-
if ($[
|
|
285
|
+
if ($[62] !== selectedItemIds.length || $[63] !== setSelectedItemLength) {
|
|
278
286
|
t19 = () => {
|
|
279
287
|
if (selectedItemIds.length) setSelectedItemLength(selectedItemIds.length);
|
|
280
288
|
};
|
|
281
|
-
$[
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
284
|
-
} else t19 = $[
|
|
289
|
+
$[62] = selectedItemIds.length;
|
|
290
|
+
$[63] = setSelectedItemLength;
|
|
291
|
+
$[64] = t19;
|
|
292
|
+
} else t19 = $[64];
|
|
285
293
|
let t20;
|
|
286
|
-
if ($[
|
|
294
|
+
if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
|
|
287
295
|
t20 = [selectedItemIds, setSelectedItemLength];
|
|
288
|
-
$[
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
} else t20 = $[
|
|
296
|
+
$[65] = selectedItemIds;
|
|
297
|
+
$[66] = setSelectedItemLength;
|
|
298
|
+
$[67] = t20;
|
|
299
|
+
} else t20 = $[67];
|
|
292
300
|
useEffect(t19, t20);
|
|
293
301
|
if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
294
302
|
let t21;
|
|
295
|
-
if ($[
|
|
303
|
+
if ($[68] !== allItemsToRender || $[69] !== ariaLabelledBy || $[70] !== emptyStateText || $[71] !== id || $[72] !== loading || $[73] !== selectionVariant) {
|
|
296
304
|
t21 = loading ? /*#__PURE__*/ jsx("div", {
|
|
297
305
|
className: AutocompleteMenu_module_css_default.SpinnerWrapper,
|
|
298
306
|
children: /*#__PURE__*/ jsx(Spinner, {})
|
|
@@ -310,24 +318,24 @@ function AutocompleteMenu(props) {
|
|
|
310
318
|
children: emptyStateText
|
|
311
319
|
}) : null
|
|
312
320
|
});
|
|
313
|
-
$[
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
$[
|
|
320
|
-
} else t21 = $[
|
|
321
|
+
$[68] = allItemsToRender;
|
|
322
|
+
$[69] = ariaLabelledBy;
|
|
323
|
+
$[70] = emptyStateText;
|
|
324
|
+
$[71] = id;
|
|
325
|
+
$[72] = loading;
|
|
326
|
+
$[73] = selectionVariant;
|
|
327
|
+
$[74] = t21;
|
|
328
|
+
} else t21 = $[74];
|
|
321
329
|
let t22;
|
|
322
|
-
if ($[
|
|
330
|
+
if ($[75] !== showMenu || $[76] !== t21) {
|
|
323
331
|
t22 = /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
324
332
|
isVisible: showMenu,
|
|
325
333
|
children: t21
|
|
326
334
|
});
|
|
327
|
-
$[
|
|
328
|
-
$[
|
|
329
|
-
$[
|
|
330
|
-
} else t22 = $[
|
|
335
|
+
$[75] = showMenu;
|
|
336
|
+
$[76] = t21;
|
|
337
|
+
$[77] = t22;
|
|
338
|
+
} else t22 = $[77];
|
|
331
339
|
return t22;
|
|
332
340
|
}
|
|
333
341
|
function _temp5(item_2) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
|
|
3
3
|
import ButtonGroup_module_css_default from "./ButtonGroup.module.css.js";
|
|
4
4
|
import { c } from "react-compiler-runtime";
|
|
5
5
|
import { clsx } from "clsx";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import React from "react";
|
|
7
|
+
import React, { useRef } from "react";
|
|
8
8
|
//#region src/ButtonGroup/ButtonGroup.tsx
|
|
9
9
|
const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forwardRef) {
|
|
10
|
-
const $ = c(
|
|
10
|
+
const $ = c(19);
|
|
11
11
|
let children;
|
|
12
12
|
let className;
|
|
13
13
|
let rest;
|
|
@@ -29,6 +29,8 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
29
29
|
t1 = $[5];
|
|
30
30
|
}
|
|
31
31
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
32
|
+
const buttonRef = useRef(null);
|
|
33
|
+
const mergedRef = useMergedRefs(buttonRef, forwardRef);
|
|
32
34
|
let t2;
|
|
33
35
|
if ($[6] !== children) {
|
|
34
36
|
t2 = React.Children.map(children, _temp);
|
|
@@ -36,45 +38,43 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
36
38
|
$[7] = t2;
|
|
37
39
|
} else t2 = $[7];
|
|
38
40
|
const buttons = t2;
|
|
39
|
-
const buttonRef = useProvidedRefOrCreate(forwardRef);
|
|
40
41
|
const t3 = role !== "toolbar";
|
|
41
42
|
let t4;
|
|
42
|
-
if ($[8] !==
|
|
43
|
+
if ($[8] !== t3) {
|
|
43
44
|
t4 = {
|
|
44
45
|
containerRef: buttonRef,
|
|
45
46
|
disabled: t3,
|
|
46
47
|
bindKeys: FocusKeys.ArrowHorizontal,
|
|
47
48
|
focusOutBehavior: "wrap"
|
|
48
49
|
};
|
|
49
|
-
$[8] =
|
|
50
|
-
$[9] =
|
|
51
|
-
|
|
52
|
-
} else t4 = $[10];
|
|
50
|
+
$[8] = t3;
|
|
51
|
+
$[9] = t4;
|
|
52
|
+
} else t4 = $[9];
|
|
53
53
|
useFocusZone(t4);
|
|
54
54
|
let t5;
|
|
55
|
-
if ($[
|
|
55
|
+
if ($[10] !== className) {
|
|
56
56
|
t5 = clsx(className, ButtonGroup_module_css_default.ButtonGroup);
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
} else t5 = $[
|
|
57
|
+
$[10] = className;
|
|
58
|
+
$[11] = t5;
|
|
59
|
+
} else t5 = $[11];
|
|
60
60
|
let t6;
|
|
61
|
-
if ($[
|
|
61
|
+
if ($[12] !== BaseComponent || $[13] !== buttons || $[14] !== mergedRef || $[15] !== rest || $[16] !== role || $[17] !== t5) {
|
|
62
62
|
t6 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
63
|
-
ref:
|
|
63
|
+
ref: mergedRef,
|
|
64
64
|
className: t5,
|
|
65
65
|
role,
|
|
66
66
|
...rest,
|
|
67
67
|
"data-component": "ButtonGroup",
|
|
68
68
|
children: buttons
|
|
69
69
|
});
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
} else t6 = $[
|
|
70
|
+
$[12] = BaseComponent;
|
|
71
|
+
$[13] = buttons;
|
|
72
|
+
$[14] = mergedRef;
|
|
73
|
+
$[15] = rest;
|
|
74
|
+
$[16] = role;
|
|
75
|
+
$[17] = t5;
|
|
76
|
+
$[18] = t6;
|
|
77
|
+
} else t6 = $[18];
|
|
78
78
|
return t6;
|
|
79
79
|
});
|
|
80
80
|
ButtonGroup.displayName = "ButtonGroup";
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
3
3
|
import shared_module_css_default from "./shared.module.css.js";
|
|
4
4
|
import { CheckboxGroupContext } from "../CheckboxGroup/CheckboxGroupContext.js";
|
|
5
5
|
import Checkbox_module_css_default from "./Checkbox.module.css.js";
|
|
6
6
|
import { clsx } from "clsx";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import React, { useContext, useEffect } from "react";
|
|
8
|
+
import React, { useContext, useEffect, useRef } from "react";
|
|
9
9
|
//#region src/Checkbox/Checkbox.tsx
|
|
10
10
|
/**
|
|
11
11
|
* An accessible, native checkbox component
|
|
12
12
|
*/
|
|
13
13
|
const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultChecked, indeterminate, disabled, onChange, required, validationStatus, value, ["data-component"]: dataComponent, ...rest }, ref) => {
|
|
14
|
-
const checkboxRef =
|
|
14
|
+
const checkboxRef = useRef(null);
|
|
15
|
+
const mergedRef = useMergedRefs(checkboxRef, ref);
|
|
15
16
|
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
16
17
|
const handleOnChange = (e) => {
|
|
17
18
|
checkboxGroupContext.onChange && checkboxGroupContext.onChange(e);
|
|
@@ -24,7 +25,7 @@ const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultCh
|
|
|
24
25
|
const inputProps = {
|
|
25
26
|
type: "checkbox",
|
|
26
27
|
disabled,
|
|
27
|
-
ref:
|
|
28
|
+
ref: mergedRef,
|
|
28
29
|
checked: indeterminate ? false : checked,
|
|
29
30
|
defaultChecked,
|
|
30
31
|
required,
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
|
-
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
4
3
|
import { useResizeObserver } from "../hooks/useResizeObserver.js";
|
|
5
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
@@ -244,7 +243,8 @@ const Footer = /*#__PURE__*/ React.forwardRef(function Footer({ className, ...re
|
|
|
244
243
|
Footer.displayName = "Dialog.Footer";
|
|
245
244
|
const Buttons = ({ buttons }) => {
|
|
246
245
|
var _buttons$find;
|
|
247
|
-
const autoFocusRef =
|
|
246
|
+
const autoFocusRef = useRef(null);
|
|
247
|
+
const mergedRef = useMergedRefs(autoFocusRef, (_buttons$find = buttons.find((button) => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref);
|
|
248
248
|
let autoFocusCount = 0;
|
|
249
249
|
const [hasRendered, setHasRendered] = useState(0);
|
|
250
250
|
useEffect(() => {
|
|
@@ -259,7 +259,7 @@ const Buttons = ({ buttons }) => {
|
|
|
259
259
|
"data-component": "Dialog.FooterButton",
|
|
260
260
|
...buttonProps,
|
|
261
261
|
variant: buttonType === "normal" ? "default" : buttonType,
|
|
262
|
-
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++,
|
|
262
|
+
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++, mergedRef) : null,
|
|
263
263
|
children: content
|
|
264
264
|
}, index);
|
|
265
265
|
}) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
2
|
-
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
3
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
4
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
5
|
import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
@@ -34,8 +34,10 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
34
34
|
}, [onFilterChange, setInternalFilterValue]);
|
|
35
35
|
const inputAndListContainerRef = useRef(null);
|
|
36
36
|
const listRef = useRef(null);
|
|
37
|
-
const scrollContainerRef =
|
|
38
|
-
const
|
|
37
|
+
const scrollContainerRef = useRef(null);
|
|
38
|
+
const combinedScrollContainerRef = useMergedRefs(scrollContainerRef, providedScrollContainerRef);
|
|
39
|
+
const inputRef = useRef(null);
|
|
40
|
+
const combinedInputRef = useMergedRefs(inputRef, providedInputRef);
|
|
39
41
|
const usingRovingTabindex = _PrivateFocusManagement === "roving-tabindex";
|
|
40
42
|
const [listContainerElement, setListContainerElement] = useState(null);
|
|
41
43
|
const activeDescendantRef = useRef();
|
|
@@ -290,7 +292,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
290
292
|
"data-component": "FilteredActionList",
|
|
291
293
|
children: [
|
|
292
294
|
/*#__PURE__*/ jsx(FilteredActionListInput, {
|
|
293
|
-
inputRef,
|
|
295
|
+
inputRef: combinedInputRef,
|
|
294
296
|
value: filterValue,
|
|
295
297
|
onInputChange,
|
|
296
298
|
onInputKeyPress,
|
|
@@ -324,7 +326,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
324
326
|
})]
|
|
325
327
|
}),
|
|
326
328
|
/*#__PURE__*/ jsx("div", {
|
|
327
|
-
ref:
|
|
329
|
+
ref: combinedScrollContainerRef,
|
|
328
330
|
className: FilteredActionList_module_css_default.Container,
|
|
329
331
|
children: getBodyContent()
|
|
330
332
|
})
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
|
|
4
4
|
//#region src/FilteredActionList/FilteredActionListInput.d.ts
|
|
5
5
|
interface FilteredActionListInputProps extends Partial<Omit<TextInputProps, 'onChange' | 'onKeyDown'>> {
|
|
6
|
-
inputRef: React.
|
|
6
|
+
inputRef: React.Ref<HTMLInputElement | null>;
|
|
7
7
|
onInputChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
8
8
|
onInputKeyPress?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
9
9
|
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
@@ -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
|
})]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import { warning } from "../utils/warning.js";
|
|
3
3
|
import { isResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
4
4
|
import { isSlot } from "../utils/is-slot.js";
|
|
@@ -10,7 +10,7 @@ import PageHeader_module_css_default from "./PageHeader.module.css.js";
|
|
|
10
10
|
import { c } from "react-compiler-runtime";
|
|
11
11
|
import { clsx } from "clsx";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React, { useEffect } from "react";
|
|
13
|
+
import React, { useEffect, useRef } from "react";
|
|
14
14
|
import { ArrowLeftIcon } from "@primer/octicons-react";
|
|
15
15
|
//#region src/PageHeader/PageHeader.tsx
|
|
16
16
|
const hiddenOnRegularAndWide = {
|
|
@@ -24,10 +24,11 @@ const hiddenOnNarrow = {
|
|
|
24
24
|
wide: false
|
|
25
25
|
};
|
|
26
26
|
const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
27
|
-
const $ = c(
|
|
27
|
+
const $ = c(16);
|
|
28
28
|
const { children, className, as: t1, "aria-label": ariaLabel, role, hasBorder } = t0;
|
|
29
29
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
30
|
-
const rootRef =
|
|
30
|
+
const rootRef = useRef(null);
|
|
31
|
+
const mergedRef = useMergedRefs(rootRef, forwardedRef);
|
|
31
32
|
const hoistChildState = (nodes) => {
|
|
32
33
|
const result = { hasNavigation: false };
|
|
33
34
|
for (const child of React.Children.toArray(nodes)) {
|
|
@@ -54,7 +55,7 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
54
55
|
const isInteractive = _temp;
|
|
55
56
|
let t2;
|
|
56
57
|
let t3;
|
|
57
|
-
if ($[0] !== children
|
|
58
|
+
if ($[0] !== children) {
|
|
58
59
|
t2 = function validateInteractiveElementsInTitle() {
|
|
59
60
|
let hasContextArea = false;
|
|
60
61
|
let hasLeadingAction = false;
|
|
@@ -69,29 +70,28 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
69
70
|
};
|
|
70
71
|
t3 = [children, rootRef];
|
|
71
72
|
$[0] = children;
|
|
72
|
-
$[1] =
|
|
73
|
-
$[2] =
|
|
74
|
-
$[3] = t3;
|
|
73
|
+
$[1] = t2;
|
|
74
|
+
$[2] = t3;
|
|
75
75
|
} else {
|
|
76
|
-
t2 = $[
|
|
77
|
-
t3 = $[
|
|
76
|
+
t2 = $[1];
|
|
77
|
+
t3 = $[2];
|
|
78
78
|
}
|
|
79
79
|
useEffect(t2, t3);
|
|
80
80
|
let t4;
|
|
81
|
-
if ($[
|
|
81
|
+
if ($[3] !== className) {
|
|
82
82
|
t4 = clsx(PageHeader_module_css_default.PageHeader, className);
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
} else t4 = $[
|
|
83
|
+
$[3] = className;
|
|
84
|
+
$[4] = t4;
|
|
85
|
+
} else t4 = $[4];
|
|
86
86
|
const t5 = "PageHeader";
|
|
87
87
|
const t6 = hasBorder ? "true" : void 0;
|
|
88
88
|
const t7 = hasNavigation ? "" : void 0;
|
|
89
89
|
const t8 = getResponsiveAttributes("title-size-variant", titleVariant);
|
|
90
90
|
const t9 = getNavHiddenDataAttributes(navigationHidden);
|
|
91
91
|
let t10;
|
|
92
|
-
if ($[
|
|
92
|
+
if ($[5] !== BaseComponent || $[6] !== ariaLabel || $[7] !== children || $[8] !== mergedRef || $[9] !== role || $[10] !== t4 || $[11] !== t6 || $[12] !== t7 || $[13] !== t8 || $[14] !== t9) {
|
|
93
93
|
t10 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
94
|
-
ref:
|
|
94
|
+
ref: mergedRef,
|
|
95
95
|
className: t4,
|
|
96
96
|
"data-component": t5,
|
|
97
97
|
"data-has-border": t6,
|
|
@@ -102,18 +102,18 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
102
102
|
role,
|
|
103
103
|
children
|
|
104
104
|
});
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
105
|
+
$[5] = BaseComponent;
|
|
106
|
+
$[6] = ariaLabel;
|
|
107
|
+
$[7] = children;
|
|
108
|
+
$[8] = mergedRef;
|
|
108
109
|
$[9] = role;
|
|
109
|
-
$[10] =
|
|
110
|
-
$[11] =
|
|
111
|
-
$[12] =
|
|
112
|
-
$[13] =
|
|
113
|
-
$[14] =
|
|
114
|
-
$[15] =
|
|
115
|
-
|
|
116
|
-
} else t10 = $[16];
|
|
110
|
+
$[10] = t4;
|
|
111
|
+
$[11] = t6;
|
|
112
|
+
$[12] = t7;
|
|
113
|
+
$[13] = t8;
|
|
114
|
+
$[14] = t9;
|
|
115
|
+
$[15] = t10;
|
|
116
|
+
} else t10 = $[15];
|
|
117
117
|
return t10;
|
|
118
118
|
});
|
|
119
119
|
const ContextArea = (t0) => {
|
|
@@ -295,7 +295,6 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
295
295
|
const { children, className, hidden: t1, variant: t2 } = t0;
|
|
296
296
|
const hidden = t1 === void 0 ? false : t1;
|
|
297
297
|
const variant = t2 === void 0 ? "medium" : t2;
|
|
298
|
-
const titleAreaRef = useProvidedRefOrCreate(forwardedRef);
|
|
299
298
|
let t3;
|
|
300
299
|
if ($[0] !== className) {
|
|
301
300
|
t3 = clsx(PageHeader_module_css_default.TitleArea, className);
|
|
@@ -315,20 +314,20 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
315
314
|
$[5] = t5;
|
|
316
315
|
} else t5 = $[5];
|
|
317
316
|
let t6;
|
|
318
|
-
if ($[6] !== children || $[7] !==
|
|
317
|
+
if ($[6] !== children || $[7] !== forwardedRef || $[8] !== t3 || $[9] !== t4 || $[10] !== t5) {
|
|
319
318
|
t6 = /*#__PURE__*/ jsx("div", {
|
|
320
319
|
className: t3,
|
|
321
|
-
ref:
|
|
320
|
+
ref: forwardedRef,
|
|
322
321
|
"data-component": "TitleArea",
|
|
323
322
|
...t4,
|
|
324
323
|
...t5,
|
|
325
324
|
children
|
|
326
325
|
});
|
|
327
326
|
$[6] = children;
|
|
328
|
-
$[7] =
|
|
329
|
-
$[8] =
|
|
330
|
-
$[9] =
|
|
331
|
-
$[10] =
|
|
327
|
+
$[7] = forwardedRef;
|
|
328
|
+
$[8] = t3;
|
|
329
|
+
$[9] = t4;
|
|
330
|
+
$[10] = t5;
|
|
332
331
|
$[11] = t6;
|
|
333
332
|
} else t6 = $[11];
|
|
334
333
|
return t6;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
3
3
|
import Text_default from "../Text/Text.js";
|
|
4
4
|
import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
|
|
@@ -11,14 +11,15 @@ import UnstyledTextInput from "../internal/components/UnstyledTextInput.js";
|
|
|
11
11
|
import { getCharacterCountState } from "../utils/character-counter.js";
|
|
12
12
|
import { clsx } from "clsx";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import React, { useCallback, useId, useState } from "react";
|
|
14
|
+
import React, { useCallback, useId, useRef, useState } from "react";
|
|
15
15
|
import { isValidElementType } from "react-is";
|
|
16
16
|
import { AlertFillIcon } from "@primer/octicons-react";
|
|
17
17
|
//#region src/TextInput/TextInput.tsx
|
|
18
18
|
const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, trailingAction, block, className, contrast, disabled, loading, loaderPosition = "auto", loaderText = "Loading", monospace, validationStatus, size: sizeProp, onFocus, onBlur, variant: variantProp, width: widthProp, minWidth: minWidthProp, maxWidth: maxWidthProp, type = "text", required, characterLimit, onChange, value, defaultValue, "data-component": dataComponent, ...inputProps }, ref) => {
|
|
19
19
|
var _counter$isOverLimit;
|
|
20
20
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
21
|
-
const inputRef =
|
|
21
|
+
const inputRef = useRef(null);
|
|
22
|
+
const mergedRef = useMergedRefs(inputRef, ref);
|
|
22
23
|
const isControlled = value !== void 0;
|
|
23
24
|
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== void 0 ? String(defaultValue).length : 0);
|
|
24
25
|
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
@@ -88,7 +89,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
88
89
|
children: typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /*#__PURE__*/ jsx(LeadingVisual, {}) : LeadingVisual
|
|
89
90
|
}),
|
|
90
91
|
/*#__PURE__*/ jsx(UnstyledTextInput, {
|
|
91
|
-
ref:
|
|
92
|
+
ref: mergedRef,
|
|
92
93
|
disabled,
|
|
93
94
|
onFocus: handleInputFocus,
|
|
94
95
|
onBlur: handleInputBlur,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
3
3
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
4
4
|
import { warning } from "../utils/warning.js";
|
|
@@ -80,7 +80,8 @@ const emptyKeybindingHints = [];
|
|
|
80
80
|
const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
|
|
81
81
|
const tooltipId = useId$1(id);
|
|
82
82
|
const child = Children.only(children);
|
|
83
|
-
const triggerRef =
|
|
83
|
+
const triggerRef = useRef(null);
|
|
84
|
+
const mergedTriggerRef = useMergedRefs(triggerRef, forwardedRef);
|
|
84
85
|
const tooltipElRef = useRef(null);
|
|
85
86
|
const [calculatedDirection, setCalculatedDirection] = useState(direction);
|
|
86
87
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
@@ -157,7 +158,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
157
158
|
return /*#__PURE__*/ jsx(TooltipContext.Provider, {
|
|
158
159
|
value,
|
|
159
160
|
children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
|
|
160
|
-
ref:
|
|
161
|
+
ref: mergedTriggerRef,
|
|
161
162
|
"aria-describedby": (() => {
|
|
162
163
|
if (type !== "description") return child.props["aria-describedby"];
|
|
163
164
|
const existingDescribedBy = child.props["aria-describedby"];
|
|
@@ -73,7 +73,7 @@ type TabPanelProps = {
|
|
|
73
73
|
value: string;
|
|
74
74
|
};
|
|
75
75
|
type TabListHookProps<T extends HTMLElement> = TabListProps & {
|
|
76
|
-
/** Optional ref to use for the tablist. If none is provided, one will be generated automatically */ref?: React.
|
|
76
|
+
/** Optional ref to use for the tablist. If none is provided, one will be generated automatically */ref?: React.Ref<T | null>;
|
|
77
77
|
};
|
|
78
78
|
type TabListHookResult<T extends HTMLElement> = {
|
|
79
79
|
/** Props to be spread onto the tablist element */tabListProps: {
|
|
@@ -81,7 +81,7 @@ type TabListHookResult<T extends HTMLElement> = {
|
|
|
81
81
|
'aria-orientation': AriaAttributes['aria-orientation'];
|
|
82
82
|
'aria-label': AriaAttributes['aria-label'];
|
|
83
83
|
'aria-labelledby': AriaAttributes['aria-labelledby'];
|
|
84
|
-
ref: React.
|
|
84
|
+
ref: React.Ref<T | null>;
|
|
85
85
|
role: 'tablist';
|
|
86
86
|
};
|
|
87
87
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMergedRefs } from "../../hooks/useMergedRefs.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
3
4
|
//#region src/experimental/Tabs/useTabList.ts
|
|
4
5
|
function useTabList(props) {
|
|
5
|
-
const $ = c(
|
|
6
|
+
const $ = c(8);
|
|
6
7
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": ariaOrientation } = props;
|
|
7
|
-
const ref =
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const mergedRef = useMergedRefs(ref, props.ref);
|
|
8
10
|
let t0;
|
|
9
|
-
if ($[0] !== ariaOrientation
|
|
11
|
+
if ($[0] !== ariaOrientation) {
|
|
10
12
|
t0 = (event) => {
|
|
11
13
|
const { current: tablist } = ref;
|
|
12
14
|
if (tablist === null) return;
|
|
@@ -33,28 +35,27 @@ function useTabList(props) {
|
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
37
|
$[0] = ariaOrientation;
|
|
36
|
-
$[1] =
|
|
37
|
-
|
|
38
|
-
} else t0 = $[2];
|
|
38
|
+
$[1] = t0;
|
|
39
|
+
} else t0 = $[1];
|
|
39
40
|
const onKeyDown = t0;
|
|
40
41
|
const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
|
|
41
42
|
let t2;
|
|
42
|
-
if ($[
|
|
43
|
+
if ($[2] !== ariaLabel || $[3] !== ariaLabelledby || $[4] !== mergedRef || $[5] !== onKeyDown || $[6] !== t1) {
|
|
43
44
|
t2 = { tabListProps: {
|
|
44
|
-
ref,
|
|
45
|
+
ref: mergedRef,
|
|
45
46
|
"aria-label": ariaLabel,
|
|
46
47
|
"aria-labelledby": ariaLabelledby,
|
|
47
48
|
"aria-orientation": t1,
|
|
48
49
|
role: "tablist",
|
|
49
50
|
onKeyDown
|
|
50
51
|
} };
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
52
|
+
$[2] = ariaLabel;
|
|
53
|
+
$[3] = ariaLabelledby;
|
|
54
|
+
$[4] = mergedRef;
|
|
53
55
|
$[5] = onKeyDown;
|
|
54
|
-
$[6] =
|
|
55
|
-
$[7] =
|
|
56
|
-
|
|
57
|
-
} else t2 = $[8];
|
|
56
|
+
$[6] = t1;
|
|
57
|
+
$[7] = t2;
|
|
58
|
+
} else t2 = $[7];
|
|
58
59
|
return t2;
|
|
59
60
|
}
|
|
60
61
|
function _temp2(tab_0) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isExperimentalReactVersion, reactMajorVersion } from "../utils/environment.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import "react";
|
|
3
|
+
import { version } from "react";
|
|
4
4
|
//#region src/hooks/useMergedRefs.ts
|
|
5
|
+
var _version$split$;
|
|
6
|
+
const majorReactVersion = parseInt((_version$split$ = version.split(".")[0]) !== null && _version$split$ !== void 0 ? _version$split$ : "18", 10);
|
|
5
7
|
/**
|
|
6
8
|
* Cleanup functions for refs were introduced in React 19. For feature detection,
|
|
7
9
|
* we look to see if current version of React is >= 19 or if it is an
|
|
@@ -48,6 +50,7 @@ function useMergedRefs(refA, refB) {
|
|
|
48
50
|
const cleanupA = setRef(refA, value);
|
|
49
51
|
const cleanupB = setRef(refB, value);
|
|
50
52
|
if (!supportsRefCleanup) return;
|
|
53
|
+
if (majorReactVersion <= 18) return;
|
|
51
54
|
return () => {
|
|
52
55
|
if (cleanupA) cleanupA();
|
|
53
56
|
else setRef(refA, null);
|
|
@@ -9,17 +9,14 @@ import React from "react";
|
|
|
9
9
|
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
|
|
10
10
|
* @type TRef The type of the RefObject which should be created.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
12
|
+
* @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
|
|
13
|
+
* In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
|
|
14
|
+
* {@linkcode useMergedRefs} instead.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - return <div ref={ref} />
|
|
21
|
-
* + return <div ref={mergedRef} />
|
|
22
|
-
* ```
|
|
16
|
+
* The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
|
|
17
|
+
* element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
|
|
18
|
+
* consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
|
|
19
|
+
* internal element.
|
|
23
20
|
*/
|
|
24
21
|
declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
|
|
25
22
|
//#endregion
|
|
@@ -8,17 +8,14 @@ import React from "react";
|
|
|
8
8
|
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
|
|
9
9
|
* @type TRef The type of the RefObject which should be created.
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
11
|
+
* @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
|
|
12
|
+
* In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
|
|
13
|
+
* {@linkcode useMergedRefs} instead.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - return <div ref={ref} />
|
|
20
|
-
* + return <div ref={mergedRef} />
|
|
21
|
-
* ```
|
|
15
|
+
* The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
|
|
16
|
+
* element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
|
|
17
|
+
* consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
|
|
18
|
+
* internal element.
|
|
22
19
|
*/
|
|
23
20
|
function useProvidedRefOrCreate(providedRef) {
|
|
24
21
|
const createdRef = React.useRef(null);
|
package/package.json
CHANGED