@primer/react 0.0.0-20260720195637 → 0.0.0-20260720205022
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 +3 -31
- package/dist/ActionBar/ActionBar-e63def3c.css +2 -0
- package/dist/ActionBar/ActionBar-e63def3c.css.map +1 -0
- package/dist/ActionBar/ActionBar.js +1 -1
- package/dist/ActionBar/ActionBar.module.css.js +1 -1
- package/dist/ActionList/Group.js +2 -2
- package/dist/ActionList/Item.js +1 -1
- package/dist/ActionList/List.js +21 -15
- package/dist/ActionMenu/ActionMenu.js +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +7 -5
- package/dist/Autocomplete/AutocompleteInput.js +10 -7
- package/dist/Autocomplete/AutocompleteMenu.js +2 -3
- package/dist/Breadcrumbs/Breadcrumbs.js +1 -4
- package/dist/ButtonGroup/ButtonGroup.js +15 -8
- package/dist/Checkbox/Checkbox.js +16 -9
- package/dist/Dialog/Dialog.js +13 -6
- package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
- package/dist/FeatureFlags/useFeatureFlag.js +1 -2
- package/dist/FilteredActionList/FilteredActionList.js +31 -20
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/FilteredActionList/useAnnouncements.js +14 -20
- package/dist/LabelGroup/LabelGroup-7d19205a.css +2 -0
- package/dist/LabelGroup/LabelGroup-7d19205a.css.map +1 -0
- package/dist/LabelGroup/LabelGroup.module.css.js +1 -1
- package/dist/NavList/NavList.js +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/PageHeader/PageHeader.js +31 -22
- package/dist/PageLayout/PageLayout.js +248 -54
- package/dist/PageLayout/index.d.ts +1 -3
- package/dist/PageLayout/usePaneWidth.d.ts +1 -63
- package/dist/PageLayout/usePaneWidth.js +36 -52
- package/dist/SegmentedControl/{SegmentedControl-de65527b.css → SegmentedControl-a004561f.css} +2 -2
- package/dist/SegmentedControl/{SegmentedControl-de65527b.css.map → SegmentedControl-a004561f.css.map} +1 -1
- package/dist/SegmentedControl/SegmentedControl.module.css.js +1 -1
- package/dist/SegmentedControl/SegmentedControlButton.js +1 -1
- package/dist/SegmentedControl/SegmentedControlIconButton.js +1 -1
- package/dist/SelectPanel/SelectPanel.js +1 -1
- package/dist/TextInput/TextInput.js +13 -6
- package/dist/TextInputWithTokens/TextInputWithTokens.js +1 -1
- package/dist/TooltipV2/Tooltip.js +19 -13
- package/dist/TreeView/TreeView.js +3 -6
- package/dist/experimental/SelectPanel2/SelectPanel.js +2 -2
- package/dist/experimental/Tabs/types.d.ts +2 -2
- package/dist/experimental/Tabs/useTabList.js +18 -10
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +1 -1
- package/dist/experimental/index.js +4 -4
- package/dist/hooks/useAnchoredPosition.js +1 -14
- package/dist/hooks/useDialog.js +1 -2
- package/dist/hooks/useMergedRefs.d.ts +4 -4
- package/dist/hooks/useMergedRefs.js +8 -5
- package/dist/hooks/useProvidedRefOrCreate.d.ts +7 -10
- package/dist/hooks/useProvidedRefOrCreate.js +7 -10
- package/dist/hooks/useScrollFlash.js +1 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.js +5 -7
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +1 -1
- package/dist/internal/components/OverflowObserverProvider.js +5 -5
- package/dist/internal/components/UnderlineTabbedInterface-25587345.css +2 -0
- package/dist/internal/components/UnderlineTabbedInterface-25587345.css.map +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
- package/dist/utils/warning.js +2 -3
- package/generated/components.json +8 -2
- package/package.json +2 -2
- package/dist/ActionBar/ActionBar-3767d551.css +0 -2
- package/dist/ActionBar/ActionBar-3767d551.css.map +0 -1
- package/dist/LabelGroup/LabelGroup-db41f443.css +0 -2
- package/dist/LabelGroup/LabelGroup-db41f443.css.map +0 -1
- package/dist/PageLayout/DragHandle.d.ts +0 -45
- package/dist/PageLayout/DragHandle.js +0 -224
- package/dist/internal/components/UnderlineTabbedInterface-798ef3cb.css +0 -2
- package/dist/internal/components/UnderlineTabbedInterface-798ef3cb.css.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
2
3
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
4
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
4
5
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
6
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
7
|
import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
6
8
|
import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
|
|
7
9
|
import { ActionList } from "../ActionList/index.js";
|
|
@@ -34,8 +36,17 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
34
36
|
}, [onFilterChange, setInternalFilterValue]);
|
|
35
37
|
const inputAndListContainerRef = useRef(null);
|
|
36
38
|
const listRef = useRef(null);
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
40
|
+
const scrollContainerRef = useRef(null);
|
|
41
|
+
const mergedScrollContainerRef = useMergedRefs(scrollContainerRef, providedScrollContainerRef);
|
|
42
|
+
const providedOrCreatedScrollContainerRef = useProvidedRefOrCreate(providedScrollContainerRef);
|
|
43
|
+
const readScrollContainerRef = mergedRefEnabled ? scrollContainerRef : providedOrCreatedScrollContainerRef;
|
|
44
|
+
const appliedScrollContainerRef = mergedRefEnabled ? mergedScrollContainerRef : providedOrCreatedScrollContainerRef;
|
|
45
|
+
const inputRef = useRef(null);
|
|
46
|
+
const mergedInputRef = useMergedRefs(inputRef, providedInputRef);
|
|
47
|
+
const providedOrCreatedInputRef = useProvidedRefOrCreate(providedInputRef);
|
|
48
|
+
const readInputRef = mergedRefEnabled ? inputRef : providedOrCreatedInputRef;
|
|
49
|
+
const appliedInputRef = mergedRefEnabled ? mergedInputRef : providedOrCreatedInputRef;
|
|
39
50
|
const usingRovingTabindex = _PrivateFocusManagement === "roving-tabindex";
|
|
40
51
|
const [listContainerElement, setListContainerElement] = useState(null);
|
|
41
52
|
const activeDescendantRef = useRef();
|
|
@@ -89,12 +100,12 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
89
100
|
onListContainerRefChanged === null || onListContainerRefChanged === void 0 || onListContainerRefChanged(node);
|
|
90
101
|
}, [onListContainerRefChanged]);
|
|
91
102
|
useEffect(() => {
|
|
92
|
-
onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(
|
|
93
|
-
}, [
|
|
103
|
+
onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(readInputRef);
|
|
104
|
+
}, [readInputRef, onInputRefChanged]);
|
|
94
105
|
const DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
|
|
95
106
|
const virtualizer = useVirtualizer({
|
|
96
107
|
count: items.length,
|
|
97
|
-
getScrollElement: () =>
|
|
108
|
+
getScrollElement: () => readScrollContainerRef.current,
|
|
98
109
|
estimateSize: () => DEFAULT_VIRTUAL_ITEM_HEIGHT,
|
|
99
110
|
overscan: 10,
|
|
100
111
|
enabled: isVirtualized,
|
|
@@ -128,7 +139,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
128
139
|
focusableElementFilter: (element) => {
|
|
129
140
|
return !(element instanceof HTMLInputElement);
|
|
130
141
|
},
|
|
131
|
-
activeDescendantFocus:
|
|
142
|
+
activeDescendantFocus: readInputRef,
|
|
132
143
|
onActiveDescendantChanged: (current, previous, directlyActivated) => {
|
|
133
144
|
activeDescendantRef.current = current;
|
|
134
145
|
if (isVirtualized && current) {
|
|
@@ -136,7 +147,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
136
147
|
const range = virtualizer.range;
|
|
137
148
|
if (index !== null && range && (Number(index) < range.startIndex || Number(index) >= range.endIndex)) virtualizer.scrollToIndex(Number(index), { align: "auto" });
|
|
138
149
|
}
|
|
139
|
-
if (current &&
|
|
150
|
+
if (current && readScrollContainerRef.current && (directlyActivated || focusPrependedElements)) scrollIntoView(current, readScrollContainerRef.current, {
|
|
140
151
|
...menuScrollMargins,
|
|
141
152
|
behavior: scrollBehavior
|
|
142
153
|
});
|
|
@@ -153,14 +164,14 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
153
164
|
isVirtualized
|
|
154
165
|
]);
|
|
155
166
|
useEffect(() => {
|
|
156
|
-
if (activeDescendantRef.current &&
|
|
167
|
+
if (activeDescendantRef.current && readScrollContainerRef.current) scrollIntoView(activeDescendantRef.current, readScrollContainerRef.current, {
|
|
157
168
|
...menuScrollMargins,
|
|
158
169
|
behavior: scrollBehavior
|
|
159
170
|
});
|
|
160
171
|
}, [
|
|
161
172
|
items,
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
readInputRef,
|
|
174
|
+
readScrollContainerRef,
|
|
164
175
|
scrollBehavior
|
|
165
176
|
]);
|
|
166
177
|
useEffect(() => {
|
|
@@ -170,7 +181,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
170
181
|
const list = listRef.current;
|
|
171
182
|
if (!list) return;
|
|
172
183
|
const handleFocusIn = (event) => {
|
|
173
|
-
if (event.target ===
|
|
184
|
+
if (event.target === readInputRef.current || list.contains(event.target)) setIsInputFocused(readInputRef.current && readInputRef.current === document.activeElement ? true : false);
|
|
174
185
|
};
|
|
175
186
|
inputAndListContainerElement.addEventListener("focusin", handleFocusIn);
|
|
176
187
|
return () => {
|
|
@@ -179,26 +190,26 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
179
190
|
}
|
|
180
191
|
}, [
|
|
181
192
|
items,
|
|
182
|
-
|
|
193
|
+
readInputRef,
|
|
183
194
|
listContainerElement,
|
|
184
195
|
usingRovingTabindex
|
|
185
196
|
]);
|
|
186
197
|
useEffect(() => {
|
|
187
|
-
if (usingRovingTabindex && !loading) setIsInputFocused(
|
|
198
|
+
if (usingRovingTabindex && !loading) setIsInputFocused(readInputRef.current && readInputRef.current === document.activeElement ? true : false);
|
|
188
199
|
}, [
|
|
189
200
|
loading,
|
|
190
|
-
|
|
201
|
+
readInputRef,
|
|
191
202
|
usingRovingTabindex
|
|
192
203
|
]);
|
|
193
|
-
useAnnouncements(items, usingRovingTabindex ? listRef : { current: listContainerElement },
|
|
194
|
-
useScrollFlash(
|
|
204
|
+
useAnnouncements(items, usingRovingTabindex ? listRef : { current: listContainerElement }, readInputRef, announcementsEnabled, loading, messageText, _PrivateFocusManagement);
|
|
205
|
+
useScrollFlash(readScrollContainerRef);
|
|
195
206
|
const handleSelectAllChange = useCallback((e) => {
|
|
196
207
|
if (onSelectAllChange) onSelectAllChange(e.target.checked);
|
|
197
208
|
}, [onSelectAllChange]);
|
|
198
209
|
function getBodyContent() {
|
|
199
|
-
if (loading &&
|
|
210
|
+
if (loading && readScrollContainerRef.current && loadingType.appearsInBody) return /*#__PURE__*/ jsx(FilteredActionListBodyLoader, {
|
|
200
211
|
loadingType,
|
|
201
|
-
height:
|
|
212
|
+
height: readScrollContainerRef.current.clientHeight
|
|
202
213
|
});
|
|
203
214
|
if (message) return message;
|
|
204
215
|
let firstGroupIndex = 0;
|
|
@@ -290,7 +301,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
290
301
|
"data-component": "FilteredActionList",
|
|
291
302
|
children: [
|
|
292
303
|
/*#__PURE__*/ jsx(FilteredActionListInput, {
|
|
293
|
-
inputRef,
|
|
304
|
+
inputRef: appliedInputRef,
|
|
294
305
|
value: filterValue,
|
|
295
306
|
onInputChange,
|
|
296
307
|
onInputKeyPress,
|
|
@@ -324,7 +335,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
324
335
|
})]
|
|
325
336
|
}),
|
|
326
337
|
/*#__PURE__*/ jsx("div", {
|
|
327
|
-
ref:
|
|
338
|
+
ref: appliedScrollContainerRef,
|
|
328
339
|
className: FilteredActionList_module_css_default.Container,
|
|
329
340
|
children: getBodyContent()
|
|
330
341
|
})
|
|
@@ -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>;
|
|
@@ -31,23 +31,20 @@ const useAnnouncements = (items, listContainerRef, inputRef, enabled = true, loa
|
|
|
31
31
|
}, [enabled]);
|
|
32
32
|
useEffect(function announceInitialFocus() {
|
|
33
33
|
const focusHandler = () => {
|
|
34
|
-
if (usingRovingTabindex) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
} else window.requestAnimationFrame(() => {
|
|
34
|
+
if (usingRovingTabindex) announce$1(`${items.length} item${items.length > 1 ? "s" : ""} available, ${selectedItems} selected.`, {
|
|
35
|
+
delayMs,
|
|
36
|
+
from: liveRegion ? liveRegion : void 0
|
|
37
|
+
});
|
|
38
|
+
else window.requestAnimationFrame(() => {
|
|
41
39
|
const activeItem = getItemWithActiveDescendant(listContainerRef, items);
|
|
42
40
|
if (!activeItem) return;
|
|
43
41
|
const { index, text, selected } = activeItem;
|
|
44
|
-
|
|
42
|
+
announce$1([
|
|
45
43
|
`Focus on filter text box and list of items`,
|
|
46
44
|
`Focused item: ${text}`,
|
|
47
45
|
`${selected ? "selected" : "not selected"}`,
|
|
48
46
|
`${index + 1} of ${items.length}`
|
|
49
|
-
].join(", ")
|
|
50
|
-
announce$1(announcementText, {
|
|
47
|
+
].join(", "), {
|
|
51
48
|
delayMs,
|
|
52
49
|
from: liveRegion ? liveRegion : void 0
|
|
53
50
|
});
|
|
@@ -73,23 +70,20 @@ const useAnnouncements = (items, listContainerRef, inputRef, enabled = true, loa
|
|
|
73
70
|
announce$1(`${message === null || message === void 0 ? void 0 : message.title}. ${message === null || message === void 0 ? void 0 : message.description}`, { delayMs });
|
|
74
71
|
return;
|
|
75
72
|
}
|
|
76
|
-
if (usingRovingTabindex) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
} else window.requestAnimationFrame(() => {
|
|
73
|
+
if (usingRovingTabindex) announce$1(`${items.length} item${items.length > 1 ? "s" : ""} available, ${selectedItems} selected.`, {
|
|
74
|
+
delayMs,
|
|
75
|
+
from: liveRegion ? liveRegion : void 0
|
|
76
|
+
});
|
|
77
|
+
else window.requestAnimationFrame(() => {
|
|
83
78
|
const activeItem = getItemWithActiveDescendant(listContainerRef, items);
|
|
84
79
|
if (!activeItem) return;
|
|
85
80
|
const { index, text, selected } = activeItem;
|
|
86
|
-
|
|
81
|
+
announce$1([
|
|
87
82
|
`List updated`,
|
|
88
83
|
`Focused item: ${text}`,
|
|
89
84
|
`${selected ? "selected" : "not selected"}`,
|
|
90
85
|
`${index + 1} of ${items.length}`
|
|
91
|
-
].join(", ")
|
|
92
|
-
announce$1(announcementText, {
|
|
86
|
+
].join(", "), {
|
|
93
87
|
delayMs,
|
|
94
88
|
from: liveRegion ? liveRegion : void 0
|
|
95
89
|
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.prc-LabelGroup-Container-E-ePP{display:flex;flex-wrap:nowrap;gap:var(--base-size-4,.25rem);line-height:1;max-width:100%;overflow:hidden}.prc-LabelGroup-Container-E-ePP:where([data-overflow=inline]){flex-wrap:wrap}.prc-LabelGroup-Container-E-ePP:where([data-list]){list-style-type:none;margin-block-end:0;margin-block-start:0;padding-inline-start:0}.prc-LabelGroup-ItemWrapper-GkO4t{align-items:center;display:flex;min-height:28px}.prc-LabelGroup-ItemWrapper--hidden-mdrB0{order:9999;pointer-events:none;visibility:hidden}.prc-LabelGroup-OverlayContainer-duQvd{align-items:flex-start;display:flex}.prc-LabelGroup-OverlayInner-nDXRC{display:flex;flex-wrap:wrap;gap:var(--base-size-4,.25rem)}.prc-LabelGroup-CloseButton-IyLno{flex-shrink:0}
|
|
2
|
+
/*# sourceMappingURL=LabelGroup-7d19205a.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/LabelGroup/LabelGroup.module.css.js"],"names":[],"mappings":"AAAA,gCACE,YAAa,CACb,gBAAiB,CACjB,6BAAuB,CAEvB,aAAc,CACd,cAAe,CACf,eAYF,CAVE,8DACE,cACF,CAEA,mDAIE,oBAAqB,CADrB,kBAAmB,CADnB,oBAAqB,CADrB,sBAIF,CAGF,kCAEE,kBAAmB,CADnB,YAAa,CAOb,eACF,CAEA,0CACE,UAAW,CACX,mBAAoB,CACpB,iBACF,CAEA,uCACE,sBAAuB,CACvB,YACF,CAEA,mCACE,YAAa,CACb,cAAe,CACf,6BACF,CAEA,kCACE,aACF","file":"LabelGroup-7d19205a.css","sourcesContent":[".Container {\n display: flex;\n flex-wrap: nowrap;\n gap: var(--base-size-4);\n /* stylelint-disable-next-line primer/typography */\n line-height: 1;\n max-width: 100%;\n overflow: hidden;\n\n &:where([data-overflow='inline']) {\n flex-wrap: wrap;\n }\n\n &:where([data-list]) {\n padding-inline-start: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n list-style-type: none;\n }\n}\n\n.ItemWrapper {\n display: flex;\n align-items: center;\n /* This min-height matches the height of the expand/collapse button.\n Without it, the labels/tokens will do a slight layout shift when expanded.\n This is because the height of the first row will match the token sizes,\n but the height of the second row will be the height of the collapse button.\n */\n min-height: 28px;\n}\n\n.ItemWrapper--hidden {\n order: 9999;\n pointer-events: none;\n visibility: hidden;\n}\n\n.OverlayContainer {\n align-items: flex-start;\n display: flex;\n}\n\n.OverlayInner {\n display: flex;\n flex-wrap: wrap;\n gap: var(--base-size-4);\n}\n\n.CloseButton {\n flex-shrink: 0;\n}\n"]}
|
package/dist/NavList/NavList.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
2
2
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
3
|
-
import { useSlots } from "../hooks/useSlots.js";
|
|
4
3
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
5
4
|
import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
|
|
5
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
6
6
|
import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
|
|
7
7
|
import Heading$1 from "../Heading/Heading.js";
|
|
8
8
|
import ActionList_module_css_default from "../ActionList/ActionList.module.css.js";
|
package/dist/Overlay/Overlay.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
2
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
3
3
|
import { useOverlay } from "../hooks/useOverlay.js";
|
|
4
|
-
import Portal_default from "../Portal/index.js";
|
|
5
4
|
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
|
+
import Portal_default from "../Portal/index.js";
|
|
6
6
|
import Overlay_module_css_default from "./Overlay.module.css.js";
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import { warning } from "../utils/warning.js";
|
|
3
|
-
import {
|
|
4
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
4
5
|
import { isResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
6
|
+
import { isSlot } from "../utils/is-slot.js";
|
|
5
7
|
import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttributes.js";
|
|
6
8
|
import Heading from "../Heading/Heading.js";
|
|
7
9
|
import Link from "../Link/Link.js";
|
|
@@ -10,7 +12,7 @@ import PageHeader_module_css_default from "./PageHeader.module.css.js";
|
|
|
10
12
|
import { c } from "react-compiler-runtime";
|
|
11
13
|
import { clsx } from "clsx";
|
|
12
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React, { useEffect } from "react";
|
|
15
|
+
import React, { useEffect, useRef } from "react";
|
|
14
16
|
import { ArrowLeftIcon } from "@primer/octicons-react";
|
|
15
17
|
//#region src/PageHeader/PageHeader.tsx
|
|
16
18
|
const hiddenOnRegularAndWide = {
|
|
@@ -27,7 +29,12 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
27
29
|
const $ = c(17);
|
|
28
30
|
const { children, className, as: t1, "aria-label": ariaLabel, role, hasBorder } = t0;
|
|
29
31
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
30
|
-
const
|
|
32
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
33
|
+
const rootRef = useRef(null);
|
|
34
|
+
const mergedRef = useMergedRefs(rootRef, forwardedRef);
|
|
35
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
36
|
+
const readRef = mergedRefEnabled ? rootRef : providedOrCreatedRef;
|
|
37
|
+
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
31
38
|
const hoistChildState = (nodes) => {
|
|
32
39
|
const result = { hasNavigation: false };
|
|
33
40
|
for (const child of React.Children.toArray(nodes)) {
|
|
@@ -54,12 +61,12 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
54
61
|
const isInteractive = _temp;
|
|
55
62
|
let t2;
|
|
56
63
|
let t3;
|
|
57
|
-
if ($[0] !== children || $[1] !==
|
|
64
|
+
if ($[0] !== children || $[1] !== readRef) {
|
|
58
65
|
t2 = function validateInteractiveElementsInTitle() {
|
|
59
66
|
let hasContextArea = false;
|
|
60
67
|
let hasLeadingAction = false;
|
|
61
|
-
if (!
|
|
62
|
-
const titleArea = Array.from(
|
|
68
|
+
if (!readRef.current || readRef.current.children.length <= 0) return;
|
|
69
|
+
const titleArea = Array.from(readRef.current.children).find(_temp2);
|
|
63
70
|
if (!titleArea) return;
|
|
64
71
|
for (const child_1 of React.Children.toArray(children)) {
|
|
65
72
|
if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === ContextArea || isSlot(child_1, ContextArea))) hasContextArea = true;
|
|
@@ -67,9 +74,9 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
67
74
|
}
|
|
68
75
|
warning(Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3))) && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
|
|
69
76
|
};
|
|
70
|
-
t3 = [children,
|
|
77
|
+
t3 = [children, readRef];
|
|
71
78
|
$[0] = children;
|
|
72
|
-
$[1] =
|
|
79
|
+
$[1] = readRef;
|
|
73
80
|
$[2] = t2;
|
|
74
81
|
$[3] = t3;
|
|
75
82
|
} else {
|
|
@@ -89,9 +96,9 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
89
96
|
const t8 = getResponsiveAttributes("title-size-variant", titleVariant);
|
|
90
97
|
const t9 = getNavHiddenDataAttributes(navigationHidden);
|
|
91
98
|
let t10;
|
|
92
|
-
if ($[6] !== BaseComponent || $[7] !==
|
|
99
|
+
if ($[6] !== BaseComponent || $[7] !== appliedRef || $[8] !== ariaLabel || $[9] !== children || $[10] !== role || $[11] !== t4 || $[12] !== t6 || $[13] !== t7 || $[14] !== t8 || $[15] !== t9) {
|
|
93
100
|
t10 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
94
|
-
ref:
|
|
101
|
+
ref: appliedRef,
|
|
95
102
|
className: t4,
|
|
96
103
|
"data-component": t5,
|
|
97
104
|
"data-has-border": t6,
|
|
@@ -103,10 +110,10 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
103
110
|
children
|
|
104
111
|
});
|
|
105
112
|
$[6] = BaseComponent;
|
|
106
|
-
$[7] =
|
|
107
|
-
$[8] =
|
|
108
|
-
$[9] =
|
|
109
|
-
$[10] =
|
|
113
|
+
$[7] = appliedRef;
|
|
114
|
+
$[8] = ariaLabel;
|
|
115
|
+
$[9] = children;
|
|
116
|
+
$[10] = role;
|
|
110
117
|
$[11] = t4;
|
|
111
118
|
$[12] = t6;
|
|
112
119
|
$[13] = t7;
|
|
@@ -295,7 +302,9 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
295
302
|
const { children, className, hidden: t1, variant: t2 } = t0;
|
|
296
303
|
const hidden = t1 === void 0 ? false : t1;
|
|
297
304
|
const variant = t2 === void 0 ? "medium" : t2;
|
|
298
|
-
const
|
|
305
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
306
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
307
|
+
const appliedRef = mergedRefEnabled ? forwardedRef : providedOrCreatedRef;
|
|
299
308
|
let t3;
|
|
300
309
|
if ($[0] !== className) {
|
|
301
310
|
t3 = clsx(PageHeader_module_css_default.TitleArea, className);
|
|
@@ -315,20 +324,20 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
315
324
|
$[5] = t5;
|
|
316
325
|
} else t5 = $[5];
|
|
317
326
|
let t6;
|
|
318
|
-
if ($[6] !==
|
|
327
|
+
if ($[6] !== appliedRef || $[7] !== children || $[8] !== t3 || $[9] !== t4 || $[10] !== t5) {
|
|
319
328
|
t6 = /*#__PURE__*/ jsx("div", {
|
|
320
329
|
className: t3,
|
|
321
|
-
ref:
|
|
330
|
+
ref: appliedRef,
|
|
322
331
|
"data-component": "TitleArea",
|
|
323
332
|
...t4,
|
|
324
333
|
...t5,
|
|
325
334
|
children
|
|
326
335
|
});
|
|
327
|
-
$[6] =
|
|
328
|
-
$[7] =
|
|
329
|
-
$[8] =
|
|
330
|
-
$[9] =
|
|
331
|
-
$[10] =
|
|
336
|
+
$[6] = appliedRef;
|
|
337
|
+
$[7] = children;
|
|
338
|
+
$[8] = t3;
|
|
339
|
+
$[9] = t4;
|
|
340
|
+
$[10] = t5;
|
|
332
341
|
$[11] = t6;
|
|
333
342
|
} else t6 = $[11];
|
|
334
343
|
return t6;
|