@primer/react 0.0.0-20260710200316 → 0.0.0-20260710212146
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 -1
- package/dist/ActionList/Group.js +1 -1
- package/dist/ActionList/List.js +10 -16
- package/dist/AnchoredOverlay/AnchoredOverlay.js +3 -10
- package/dist/Autocomplete/AutocompleteInput.js +7 -10
- package/dist/ButtonGroup/ButtonGroup.js +5 -12
- package/dist/Checkbox/Checkbox.js +3 -10
- package/dist/Dialog/Dialog.js +2 -9
- package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
- package/dist/FilteredActionList/FilteredActionList.js +4 -15
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/PageHeader/PageHeader.js +9 -18
- package/dist/SelectPanel/SelectPanel.js +1 -1
- package/dist/TextInput/TextInput.js +3 -10
- package/dist/TooltipV2/Tooltip.js +2 -9
- package/dist/experimental/Tabs/types.d.ts +2 -2
- package/dist/experimental/Tabs/useTabList.js +7 -15
- package/dist/experimental/index.js +3 -3
- package/dist/hooks/useAnchoredPosition.js +14 -1
- package/dist/hooks/useMergedRefs.js +1 -4
- package/dist/hooks/useProvidedRefOrCreate.d.ts +10 -7
- package/dist/hooks/useProvidedRefOrCreate.js +10 -7
- 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-20260710212146
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
- Fake entry to force publishing
|
|
23
23
|
|
|
24
|
+
- [#8116](https://github.com/primer/react/pull/8116) [`064b105`](https://github.com/primer/react/commit/064b105604e31486806b8f4ab432540aaca10465) 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.
|
|
25
|
+
|
|
24
26
|
- [#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.
|
|
25
27
|
|
|
26
28
|
- [#8115](https://github.com/primer/react/pull/8115) [`07c530a`](https://github.com/primer/react/commit/07c530a1686ef16b68b2f2fe692b7a3327bdc02b) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Improve rendering performance in Safari by removing expensive `:has()` selectors from ActionList/NavList, Breadcrumbs, SelectPanel, and SegmentedControl. No visual or API changes.
|
package/dist/ActionList/Group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
2
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
3
2
|
import { invariant } from "../utils/invariant.js";
|
|
4
3
|
import { useSlots } from "../hooks/useSlots.js";
|
|
5
4
|
import { ListContext } from "./shared.js";
|
|
6
5
|
import ActionList_module_css_default from "./ActionList.module.css.js";
|
|
6
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
7
|
import Group_module_css_default from "./Group.module.css.js";
|
|
8
8
|
import { GroupHeadingTrailingAction } from "./GroupHeadingTrailingAction.js";
|
|
9
9
|
import { GroupContext } from "./GroupContext.js";
|
package/dist/ActionList/List.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
4
3
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
6
4
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
7
5
|
import { useSlots } from "../hooks/useSlots.js";
|
|
8
6
|
import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
|
|
@@ -10,10 +8,11 @@ import { ActionListContainerContext } from "./ActionListContainerContext.js";
|
|
|
10
8
|
import { ListContext } from "./shared.js";
|
|
11
9
|
import { Heading } from "./Heading.js";
|
|
12
10
|
import ActionList_module_css_default from "./ActionList.module.css.js";
|
|
11
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
13
12
|
import { c } from "react-compiler-runtime";
|
|
14
13
|
import { clsx } from "clsx";
|
|
15
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
import React
|
|
15
|
+
import React from "react";
|
|
17
16
|
//#region src/ActionList/List.tsx
|
|
18
17
|
const UnwrappedList = (props, forwardedRef) => {
|
|
19
18
|
var _slots$heading$props$;
|
|
@@ -61,12 +60,7 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
61
60
|
const { listRole: listRoleFromContainer, listLabelledBy, selectionVariant: containerSelectionVariant, enableFocusZone: enableFocusZoneFromContainer, container } = React.useContext(ActionListContainerContext);
|
|
62
61
|
const ariaLabelledBy = slots.heading ? (_slots$heading$props$ = slots.heading.props.id) !== null && _slots$heading$props$ !== void 0 ? _slots$heading$props$ : headingId : listLabelledBy;
|
|
63
62
|
const listRole = role || listRoleFromContainer;
|
|
64
|
-
const
|
|
65
|
-
const internalRef = useRef(null);
|
|
66
|
-
const mergedRef = useMergedRefs(forwardedRef, internalRef);
|
|
67
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
68
|
-
const listRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
69
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
63
|
+
const listRef = useProvidedRefOrCreate(forwardedRef);
|
|
70
64
|
const itemGapEnabled = useFeatureFlag("primer_react_action_list_item_gap") && container === "NavList";
|
|
71
65
|
let enableFocusZone = false;
|
|
72
66
|
if (enableFocusZoneFromContainer !== void 0) enableFocusZone = enableFocusZoneFromContainer;
|
|
@@ -117,7 +111,7 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
117
111
|
} else t9 = $[20];
|
|
118
112
|
const listContextValue = t9;
|
|
119
113
|
let t10;
|
|
120
|
-
if ($[21] !== listRef
|
|
114
|
+
if ($[21] !== listRef) {
|
|
121
115
|
t10 = () => {
|
|
122
116
|
const list = listRef.current;
|
|
123
117
|
if (!list) return;
|
|
@@ -126,7 +120,7 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
126
120
|
if (hasMixed && current !== "true") list.setAttribute("data-mixed-descriptions", "true");
|
|
127
121
|
else if (!hasMixed && current !== null) list.removeAttribute("data-mixed-descriptions");
|
|
128
122
|
};
|
|
129
|
-
$[21] = listRef
|
|
123
|
+
$[21] = listRef;
|
|
130
124
|
$[22] = t10;
|
|
131
125
|
} else t10 = $[22];
|
|
132
126
|
useIsomorphicLayoutEffect(t10);
|
|
@@ -139,12 +133,12 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
139
133
|
} else t12 = $[24];
|
|
140
134
|
const t13 = itemGapEnabled ? "" : void 0;
|
|
141
135
|
let t14;
|
|
142
|
-
if ($[25] !== Component || $[26] !==
|
|
136
|
+
if ($[25] !== Component || $[26] !== ariaLabelledBy || $[27] !== childrenWithoutSlots || $[28] !== listRef || $[29] !== listRole || $[30] !== restProps || $[31] !== showDividers || $[32] !== t12 || $[33] !== t13 || $[34] !== variant) {
|
|
143
137
|
t14 = /*#__PURE__*/ jsx(Component, {
|
|
144
138
|
className: t12,
|
|
145
139
|
role: listRole,
|
|
146
140
|
"aria-labelledby": ariaLabelledBy,
|
|
147
|
-
ref:
|
|
141
|
+
ref: listRef,
|
|
148
142
|
"data-component": "ActionList",
|
|
149
143
|
"data-dividers": showDividers,
|
|
150
144
|
"data-variant": variant,
|
|
@@ -153,9 +147,9 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
153
147
|
children: childrenWithoutSlots
|
|
154
148
|
});
|
|
155
149
|
$[25] = Component;
|
|
156
|
-
$[26] =
|
|
157
|
-
$[27] =
|
|
158
|
-
$[28] =
|
|
150
|
+
$[26] = ariaLabelledBy;
|
|
151
|
+
$[27] = childrenWithoutSlots;
|
|
152
|
+
$[28] = listRef;
|
|
159
153
|
$[29] = listRole;
|
|
160
154
|
$[30] = restProps;
|
|
161
155
|
$[31] = showDividers;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { reactMajorVersion } from "../utils/environment.js";
|
|
2
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
3
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
4
3
|
import { useAnchoredPosition } from "../hooks/useAnchoredPosition.js";
|
|
5
4
|
import { useRenderForcingRef } from "../hooks/useRenderForcingRef.js";
|
|
6
5
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
7
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
8
6
|
import { IconButton } from "../Button/IconButton.js";
|
|
9
7
|
import { useFocusTrap } from "../hooks/useFocusTrap.js";
|
|
10
8
|
import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
9
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
11
10
|
import Overlay from "../Overlay/Overlay.js";
|
|
12
11
|
import AnchoredOverlay_module_css_default from "./AnchoredOverlay.module.css.js";
|
|
13
12
|
import { widthMap } from "../Overlay/constants.js";
|
|
@@ -34,8 +33,6 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
34
33
|
const [anchorElement, setAnchorElement] = useState(null);
|
|
35
34
|
if (anchorRef.current !== anchorElement) setAnchorElement(anchorRef.current);
|
|
36
35
|
const [overlayRef, updateOverlayRef] = useRenderForcingRef();
|
|
37
|
-
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
38
|
-
const mergedOverlayRef = useMergedRefs(updateOverlayRef, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.ref);
|
|
39
36
|
const [overlayElement, setOverlayElement] = useState(null);
|
|
40
37
|
const anchorId = useId$1(externalAnchorId);
|
|
41
38
|
const onClickOutside = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("click-outside"), [onClose]);
|
|
@@ -192,14 +189,10 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
192
189
|
...shouldRenderAsPopover ? { popover: "manual" } : {},
|
|
193
190
|
...restOverlayProps,
|
|
194
191
|
...shouldRenderAsPopover ? { id: popoverId } : {},
|
|
195
|
-
...cssAnchorPositioning ? { id: popoverId } : {},
|
|
196
192
|
ref: (node) => {
|
|
193
|
+
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) assignRef(overlayProps.ref, node);
|
|
194
|
+
updateOverlayRef(node);
|
|
197
195
|
setOverlayElement(node);
|
|
198
|
-
if (mergedRefEnabled) assignRef(mergedOverlayRef, node);
|
|
199
|
-
else {
|
|
200
|
-
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) assignRef(overlayProps.ref, node);
|
|
201
|
-
updateOverlayRef(node);
|
|
202
|
-
}
|
|
203
196
|
},
|
|
204
197
|
"data-anchor-position": cssAnchorPositioning,
|
|
205
198
|
"data-side": cssAnchorPositioning ? side : position === null || position === void 0 ? void 0 : position.anchorSide,
|
|
@@ -20,11 +20,9 @@ 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 && onBlur(event);
|
|
24
24
|
safeSetTimeout(() => {
|
|
25
|
-
|
|
26
|
-
const menuElement = document.getElementById(`${id}-listbox`);
|
|
27
|
-
if (!nextFocusedElement || nextFocusedElement !== menuElement && !(menuElement !== null && menuElement !== void 0 && menuElement.contains(nextFocusedElement))) {
|
|
25
|
+
if (document.activeElement !== inputRef.current) {
|
|
28
26
|
setShowMenu(false);
|
|
29
27
|
if (inputRef.current && autocompleteSuggestion && inputRef.current.value !== inputValue) inputRef.current.value = inputValue;
|
|
30
28
|
}
|
|
@@ -35,17 +33,16 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
35
33
|
inputRef,
|
|
36
34
|
safeSetTimeout,
|
|
37
35
|
autocompleteSuggestion,
|
|
38
|
-
inputValue
|
|
39
|
-
id
|
|
36
|
+
inputValue
|
|
40
37
|
]);
|
|
41
38
|
const handleInputChange = (event) => {
|
|
42
|
-
onChange
|
|
39
|
+
onChange && onChange(event);
|
|
43
40
|
setInputValue(event.currentTarget.value);
|
|
44
41
|
if (!showMenu) setShowMenu(true);
|
|
45
42
|
};
|
|
46
43
|
const handleInputKeyDown = useCallback((event) => {
|
|
47
44
|
var _inputRef$current;
|
|
48
|
-
onKeyDown
|
|
45
|
+
onKeyDown && onKeyDown(event);
|
|
49
46
|
if (event.key === "Backspace") setHighlightRemainingText(false);
|
|
50
47
|
if (event.key === "Escape" && (_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) {
|
|
51
48
|
setInputValue("");
|
|
@@ -61,11 +58,11 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
61
58
|
setShowMenu
|
|
62
59
|
]);
|
|
63
60
|
const handleInputKeyUp = useCallback((event) => {
|
|
64
|
-
onKeyUp
|
|
61
|
+
onKeyUp && onKeyUp(event);
|
|
65
62
|
if (event.key === "Backspace") setHighlightRemainingText(true);
|
|
66
63
|
}, [setHighlightRemainingText, onKeyUp]);
|
|
67
64
|
const onInputKeyPress = useCallback((event) => {
|
|
68
|
-
onKeyPress
|
|
65
|
+
onKeyPress && onKeyPress(event);
|
|
69
66
|
if (showMenu && event.key === "Enter" && activeDescendantRef.current) {
|
|
70
67
|
event.preventDefault();
|
|
71
68
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
4
2
|
import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
|
|
5
3
|
import ButtonGroup_module_css_default from "./ButtonGroup.module.css.js";
|
|
6
4
|
import { c } from "react-compiler-runtime";
|
|
7
5
|
import { clsx } from "clsx";
|
|
8
6
|
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
import React
|
|
7
|
+
import React from "react";
|
|
10
8
|
//#region src/ButtonGroup/ButtonGroup.tsx
|
|
11
9
|
const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forwardRef) {
|
|
12
10
|
const $ = c(20);
|
|
@@ -31,12 +29,6 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
31
29
|
t1 = $[5];
|
|
32
30
|
}
|
|
33
31
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
34
|
-
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
35
|
-
const internalRef = useRef(null);
|
|
36
|
-
const mergedRef = useMergedRefs(internalRef, forwardRef);
|
|
37
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardRef);
|
|
38
|
-
const buttonRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
39
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
40
32
|
let t2;
|
|
41
33
|
if ($[6] !== children) {
|
|
42
34
|
t2 = React.Children.map(children, _temp);
|
|
@@ -44,6 +36,7 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
44
36
|
$[7] = t2;
|
|
45
37
|
} else t2 = $[7];
|
|
46
38
|
const buttons = t2;
|
|
39
|
+
const buttonRef = useProvidedRefOrCreate(forwardRef);
|
|
47
40
|
const t3 = role !== "toolbar";
|
|
48
41
|
let t4;
|
|
49
42
|
if ($[8] !== buttonRef || $[9] !== t3) {
|
|
@@ -65,9 +58,9 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
65
58
|
$[12] = t5;
|
|
66
59
|
} else t5 = $[12];
|
|
67
60
|
let t6;
|
|
68
|
-
if ($[13] !== BaseComponent || $[14] !==
|
|
61
|
+
if ($[13] !== BaseComponent || $[14] !== buttonRef || $[15] !== buttons || $[16] !== rest || $[17] !== role || $[18] !== t5) {
|
|
69
62
|
t6 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
70
|
-
ref:
|
|
63
|
+
ref: buttonRef,
|
|
71
64
|
className: t5,
|
|
72
65
|
role,
|
|
73
66
|
...rest,
|
|
@@ -75,7 +68,7 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
75
68
|
children: buttons
|
|
76
69
|
});
|
|
77
70
|
$[13] = BaseComponent;
|
|
78
|
-
$[14] =
|
|
71
|
+
$[14] = buttonRef;
|
|
79
72
|
$[15] = buttons;
|
|
80
73
|
$[16] = rest;
|
|
81
74
|
$[17] = role;
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
4
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
3
|
import shared_module_css_default from "./shared.module.css.js";
|
|
6
4
|
import { CheckboxGroupContext } from "../CheckboxGroup/CheckboxGroupContext.js";
|
|
7
5
|
import Checkbox_module_css_default from "./Checkbox.module.css.js";
|
|
8
6
|
import { clsx } from "clsx";
|
|
9
7
|
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
import React, { useContext, useEffect
|
|
8
|
+
import React, { useContext, useEffect } from "react";
|
|
11
9
|
//#region src/Checkbox/Checkbox.tsx
|
|
12
10
|
/**
|
|
13
11
|
* An accessible, native checkbox component
|
|
14
12
|
*/
|
|
15
13
|
const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultChecked, indeterminate, disabled, onChange, required, validationStatus, value, ["data-component"]: dataComponent, ...rest }, ref) => {
|
|
16
|
-
const
|
|
17
|
-
const internalRef = useRef(null);
|
|
18
|
-
const mergedRef = useMergedRefs(internalRef, ref);
|
|
19
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
20
|
-
const checkboxRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
21
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
14
|
+
const checkboxRef = useProvidedRefOrCreate(ref);
|
|
22
15
|
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
23
16
|
const handleOnChange = (e) => {
|
|
24
17
|
checkboxGroupContext.onChange && checkboxGroupContext.onChange(e);
|
|
@@ -31,7 +24,7 @@ const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultCh
|
|
|
31
24
|
const inputProps = {
|
|
32
25
|
type: "checkbox",
|
|
33
26
|
disabled,
|
|
34
|
-
ref:
|
|
27
|
+
ref: checkboxRef,
|
|
35
28
|
checked: indeterminate ? false : checked,
|
|
36
29
|
defaultChecked,
|
|
37
30
|
required,
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -3,7 +3,6 @@ import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
|
3
3
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
4
4
|
import { useResizeObserver } from "../hooks/useResizeObserver.js";
|
|
5
5
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
6
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
6
|
import { IconButton } from "../Button/IconButton.js";
|
|
8
7
|
import { ButtonComponent } from "../Button/Button.js";
|
|
9
8
|
import { useSlots } from "../hooks/useSlots.js";
|
|
@@ -245,13 +244,7 @@ const Footer = /*#__PURE__*/ React.forwardRef(function Footer({ className, ...re
|
|
|
245
244
|
Footer.displayName = "Dialog.Footer";
|
|
246
245
|
const Buttons = ({ buttons }) => {
|
|
247
246
|
var _buttons$find;
|
|
248
|
-
const
|
|
249
|
-
const providedButtonRef = (_buttons$find = buttons.find((button) => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref;
|
|
250
|
-
const internalRef = useRef(null);
|
|
251
|
-
const mergedRef = useMergedRefs(internalRef, providedButtonRef);
|
|
252
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(providedButtonRef);
|
|
253
|
-
const autoFocusRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
254
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
247
|
+
const autoFocusRef = useProvidedRefOrCreate((_buttons$find = buttons.find((button) => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref);
|
|
255
248
|
let autoFocusCount = 0;
|
|
256
249
|
const [hasRendered, setHasRendered] = useState(0);
|
|
257
250
|
useEffect(() => {
|
|
@@ -266,7 +259,7 @@ const Buttons = ({ buttons }) => {
|
|
|
266
259
|
"data-component": "Dialog.FooterButton",
|
|
267
260
|
...buttonProps,
|
|
268
261
|
variant: buttonType === "normal" ? "default" : buttonType,
|
|
269
|
-
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++,
|
|
262
|
+
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null,
|
|
270
263
|
children: content
|
|
271
264
|
}, index);
|
|
272
265
|
}) });
|
|
@@ -7,8 +7,7 @@ const DefaultFeatureFlags = FeatureFlagScope.create({
|
|
|
7
7
|
primer_react_styled_react_use_primer_theme_providers: false,
|
|
8
8
|
primer_react_action_list_group_heading_trailing_action: false,
|
|
9
9
|
primer_react_action_list_item_gap: false,
|
|
10
|
-
primer_react_timeline_list_semantics: false
|
|
11
|
-
primer_react_merged_forwarded_refs: false
|
|
10
|
+
primer_react_timeline_list_semantics: false
|
|
12
11
|
});
|
|
13
12
|
//#endregion
|
|
14
13
|
export { DefaultFeatureFlags };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
3
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
4
3
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
5
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
6
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
5
|
import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
8
6
|
import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
|
|
9
7
|
import { ActionList } from "../ActionList/index.js";
|
|
@@ -36,17 +34,8 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
36
34
|
}, [onFilterChange, setInternalFilterValue]);
|
|
37
35
|
const inputAndListContainerRef = useRef(null);
|
|
38
36
|
const listRef = useRef(null);
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const combinedScrollContainerRef = useMergedRefs(internalScrollContainerRef, providedScrollContainerRef);
|
|
42
|
-
const providedOrCreatedScrollContainerRef = useProvidedRefOrCreate(providedScrollContainerRef);
|
|
43
|
-
const scrollContainerRef = mergedRefEnabled ? internalScrollContainerRef : providedOrCreatedScrollContainerRef;
|
|
44
|
-
const appliedScrollContainerRef = mergedRefEnabled ? combinedScrollContainerRef : providedOrCreatedScrollContainerRef;
|
|
45
|
-
const internalInputRef = useRef(null);
|
|
46
|
-
const combinedInputRef = useMergedRefs(internalInputRef, providedInputRef);
|
|
47
|
-
const providedOrCreatedInputRef = useProvidedRefOrCreate(providedInputRef);
|
|
48
|
-
const inputRef = mergedRefEnabled ? internalInputRef : providedOrCreatedInputRef;
|
|
49
|
-
const appliedInputRef = mergedRefEnabled ? combinedInputRef : providedOrCreatedInputRef;
|
|
37
|
+
const scrollContainerRef = useProvidedRefOrCreate(providedScrollContainerRef);
|
|
38
|
+
const inputRef = useProvidedRefOrCreate(providedInputRef);
|
|
50
39
|
const usingRovingTabindex = _PrivateFocusManagement === "roving-tabindex";
|
|
51
40
|
const [listContainerElement, setListContainerElement] = useState(null);
|
|
52
41
|
const activeDescendantRef = useRef();
|
|
@@ -301,7 +290,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
301
290
|
"data-component": "FilteredActionList",
|
|
302
291
|
children: [
|
|
303
292
|
/*#__PURE__*/ jsx(FilteredActionListInput, {
|
|
304
|
-
inputRef
|
|
293
|
+
inputRef,
|
|
305
294
|
value: filterValue,
|
|
306
295
|
onInputChange,
|
|
307
296
|
onInputKeyPress,
|
|
@@ -335,7 +324,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
335
324
|
})]
|
|
336
325
|
}),
|
|
337
326
|
/*#__PURE__*/ jsx("div", {
|
|
338
|
-
ref:
|
|
327
|
+
ref: scrollContainerRef,
|
|
339
328
|
className: FilteredActionList_module_css_default.Container,
|
|
340
329
|
children: getBodyContent()
|
|
341
330
|
})
|
|
@@ -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.RefObject<HTMLInputElement | null>;
|
|
7
7
|
onInputChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
8
8
|
onInputKeyPress?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
9
9
|
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
|
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 { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
4
|
import Portal_default from "../Portal/index.js";
|
|
5
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.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,5 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { warning } from "../utils/warning.js";
|
|
4
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
3
|
import { isResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
6
4
|
import { isSlot } from "../utils/is-slot.js";
|
|
7
5
|
import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttributes.js";
|
|
@@ -12,7 +10,7 @@ import PageHeader_module_css_default from "./PageHeader.module.css.js";
|
|
|
12
10
|
import { c } from "react-compiler-runtime";
|
|
13
11
|
import { clsx } from "clsx";
|
|
14
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import React, { useEffect
|
|
13
|
+
import React, { useEffect } from "react";
|
|
16
14
|
import { ArrowLeftIcon } from "@primer/octicons-react";
|
|
17
15
|
//#region src/PageHeader/PageHeader.tsx
|
|
18
16
|
const hiddenOnRegularAndWide = {
|
|
@@ -29,12 +27,7 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
29
27
|
const $ = c(17);
|
|
30
28
|
const { children, className, as: t1, "aria-label": ariaLabel, role, hasBorder } = t0;
|
|
31
29
|
const BaseComponent = t1 === void 0 ? "div" : t1;
|
|
32
|
-
const
|
|
33
|
-
const internalRef = useRef(null);
|
|
34
|
-
const mergedRef = useMergedRefs(internalRef, forwardedRef);
|
|
35
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
36
|
-
const rootRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
37
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
30
|
+
const rootRef = useProvidedRefOrCreate(forwardedRef);
|
|
38
31
|
const hoistChildState = (nodes) => {
|
|
39
32
|
const result = { hasNavigation: false };
|
|
40
33
|
for (const child of React.Children.toArray(nodes)) {
|
|
@@ -96,9 +89,9 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
96
89
|
const t8 = getResponsiveAttributes("title-size-variant", titleVariant);
|
|
97
90
|
const t9 = getNavHiddenDataAttributes(navigationHidden);
|
|
98
91
|
let t10;
|
|
99
|
-
if ($[6] !== BaseComponent || $[7] !==
|
|
92
|
+
if ($[6] !== BaseComponent || $[7] !== ariaLabel || $[8] !== children || $[9] !== role || $[10] !== rootRef || $[11] !== t4 || $[12] !== t6 || $[13] !== t7 || $[14] !== t8 || $[15] !== t9) {
|
|
100
93
|
t10 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
101
|
-
ref:
|
|
94
|
+
ref: rootRef,
|
|
102
95
|
className: t4,
|
|
103
96
|
"data-component": t5,
|
|
104
97
|
"data-has-border": t6,
|
|
@@ -110,10 +103,10 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
110
103
|
children
|
|
111
104
|
});
|
|
112
105
|
$[6] = BaseComponent;
|
|
113
|
-
$[7] =
|
|
114
|
-
$[8] =
|
|
115
|
-
$[9] =
|
|
116
|
-
$[10] =
|
|
106
|
+
$[7] = ariaLabel;
|
|
107
|
+
$[8] = children;
|
|
108
|
+
$[9] = role;
|
|
109
|
+
$[10] = rootRef;
|
|
117
110
|
$[11] = t4;
|
|
118
111
|
$[12] = t6;
|
|
119
112
|
$[13] = t7;
|
|
@@ -302,9 +295,7 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
302
295
|
const { children, className, hidden: t1, variant: t2 } = t0;
|
|
303
296
|
const hidden = t1 === void 0 ? false : t1;
|
|
304
297
|
const variant = t2 === void 0 ? "medium" : t2;
|
|
305
|
-
const
|
|
306
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
307
|
-
const titleAreaRef = mergedRefEnabled ? forwardedRef : providedOrCreatedRef;
|
|
298
|
+
const titleAreaRef = useProvidedRefOrCreate(forwardedRef);
|
|
308
299
|
let t3;
|
|
309
300
|
if ($[0] !== className) {
|
|
310
301
|
t3 = clsx(PageHeader_module_css_default.TitleArea, className);
|
|
@@ -2,13 +2,13 @@ import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
|
2
2
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
3
3
|
import { isAlphabetKey } from "../hooks/useMnemonics.js";
|
|
4
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
6
5
|
import useSafeTimeout from "../hooks/useSafeTimeout.js";
|
|
7
6
|
import { IconButton } from "../Button/IconButton.js";
|
|
8
7
|
import { LinkButton } from "../Button/LinkButton.js";
|
|
9
8
|
import { ButtonComponent } from "../Button/Button.js";
|
|
10
9
|
import { useResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
11
10
|
import Heading from "../Heading/Heading.js";
|
|
11
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
12
12
|
import { AnchoredOverlay } from "../AnchoredOverlay/AnchoredOverlay.js";
|
|
13
13
|
import { Banner } from "../Banner/index.js";
|
|
14
14
|
import { useFormControlContext } from "../FormControl/_FormControlContext.js";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
4
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
3
|
import Text_default from "../Text/Text.js";
|
|
6
4
|
import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
|
|
7
5
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -13,19 +11,14 @@ import UnstyledTextInput from "../internal/components/UnstyledTextInput.js";
|
|
|
13
11
|
import { getCharacterCountState } from "../utils/character-counter.js";
|
|
14
12
|
import { clsx } from "clsx";
|
|
15
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
import React, { useCallback, useId,
|
|
14
|
+
import React, { useCallback, useId, useState } from "react";
|
|
17
15
|
import { isValidElementType } from "react-is";
|
|
18
16
|
import { AlertFillIcon } from "@primer/octicons-react";
|
|
19
17
|
//#region src/TextInput/TextInput.tsx
|
|
20
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) => {
|
|
21
19
|
var _counter$isOverLimit;
|
|
22
20
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
23
|
-
const
|
|
24
|
-
const internalRef = useRef(null);
|
|
25
|
-
const mergedRef = useMergedRefs(internalRef, ref);
|
|
26
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
27
|
-
const inputRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
28
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
21
|
+
const inputRef = useProvidedRefOrCreate(ref);
|
|
29
22
|
const isControlled = value !== void 0;
|
|
30
23
|
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== void 0 ? String(defaultValue).length : 0);
|
|
31
24
|
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
@@ -95,7 +88,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
95
88
|
children: typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /*#__PURE__*/ jsx(LeadingVisual, {}) : LeadingVisual
|
|
96
89
|
}),
|
|
97
90
|
/*#__PURE__*/ jsx(UnstyledTextInput, {
|
|
98
|
-
ref:
|
|
91
|
+
ref: inputRef,
|
|
99
92
|
disabled,
|
|
100
93
|
onFocus: handleInputFocus,
|
|
101
94
|
onBlur: handleInputBlur,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
2
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
4
3
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
4
|
import { warning } from "../utils/warning.js";
|
|
6
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
5
|
import { invariant } from "../utils/invariant.js";
|
|
8
6
|
import Tooltip_module_css_default from "./Tooltip.module.css.js";
|
|
9
7
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -82,12 +80,7 @@ const emptyKeybindingHints = [];
|
|
|
82
80
|
const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
|
|
83
81
|
const tooltipId = useId$1(id);
|
|
84
82
|
const child = Children.only(children);
|
|
85
|
-
const
|
|
86
|
-
const internalRef = useRef(null);
|
|
87
|
-
const mergedTriggerRef = useMergedRefs(internalRef, forwardedRef);
|
|
88
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
89
|
-
const triggerRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
90
|
-
const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
|
|
83
|
+
const triggerRef = useProvidedRefOrCreate(forwardedRef);
|
|
91
84
|
const tooltipElRef = useRef(null);
|
|
92
85
|
const [calculatedDirection, setCalculatedDirection] = useState(direction);
|
|
93
86
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
@@ -164,7 +157,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
164
157
|
return /*#__PURE__*/ jsx(TooltipContext.Provider, {
|
|
165
158
|
value,
|
|
166
159
|
children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
|
|
167
|
-
ref:
|
|
160
|
+
ref: triggerRef,
|
|
168
161
|
"aria-describedby": (() => {
|
|
169
162
|
if (type !== "description") return child.props["aria-describedby"];
|
|
170
163
|
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.RefObject<T>;
|
|
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.RefObject<T | null>;
|
|
85
85
|
role: 'tablist';
|
|
86
86
|
};
|
|
87
87
|
};
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import { useMergedRefs } from "../../hooks/useMergedRefs.js";
|
|
2
1
|
import { useProvidedRefOrCreate } from "../../hooks/useProvidedRefOrCreate.js";
|
|
3
|
-
import { useFeatureFlag } from "../../FeatureFlags/useFeatureFlag.js";
|
|
4
2
|
import { c } from "react-compiler-runtime";
|
|
5
|
-
import { useRef } from "react";
|
|
6
3
|
//#region src/experimental/Tabs/useTabList.ts
|
|
7
4
|
function useTabList(props) {
|
|
8
5
|
const $ = c(9);
|
|
9
6
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": ariaOrientation } = props;
|
|
10
|
-
const
|
|
11
|
-
const internalRef = useRef(null);
|
|
12
|
-
const mergedRef = useMergedRefs(internalRef, props.ref);
|
|
13
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(props.ref);
|
|
14
|
-
const ref = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
15
|
-
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
7
|
+
const ref = useProvidedRefOrCreate(props.ref);
|
|
16
8
|
let t0;
|
|
17
9
|
if ($[0] !== ariaOrientation || $[1] !== ref) {
|
|
18
10
|
t0 = (event) => {
|
|
@@ -47,19 +39,19 @@ function useTabList(props) {
|
|
|
47
39
|
const onKeyDown = t0;
|
|
48
40
|
const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
|
|
49
41
|
let t2;
|
|
50
|
-
if ($[3] !==
|
|
42
|
+
if ($[3] !== ariaLabel || $[4] !== ariaLabelledby || $[5] !== onKeyDown || $[6] !== ref || $[7] !== t1) {
|
|
51
43
|
t2 = { tabListProps: {
|
|
52
|
-
ref
|
|
44
|
+
ref,
|
|
53
45
|
"aria-label": ariaLabel,
|
|
54
46
|
"aria-labelledby": ariaLabelledby,
|
|
55
47
|
"aria-orientation": t1,
|
|
56
48
|
role: "tablist",
|
|
57
49
|
onKeyDown
|
|
58
50
|
} };
|
|
59
|
-
$[3] =
|
|
60
|
-
$[4] =
|
|
61
|
-
$[5] =
|
|
62
|
-
$[6] =
|
|
51
|
+
$[3] = ariaLabel;
|
|
52
|
+
$[4] = ariaLabelledby;
|
|
53
|
+
$[5] = onKeyDown;
|
|
54
|
+
$[6] = ref;
|
|
63
55
|
$[7] = t1;
|
|
64
56
|
$[8] = t2;
|
|
65
57
|
} else t2 = $[8];
|
|
@@ -3,9 +3,6 @@ import { Announce } from "../live-region/Announce.js";
|
|
|
3
3
|
import { AriaAlert } from "../live-region/AriaAlert.js";
|
|
4
4
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
5
5
|
import { ButtonBase } from "../Button/ButtonBase.js";
|
|
6
|
-
import { DefaultFeatureFlags } from "../FeatureFlags/DefaultFeatureFlags.js";
|
|
7
|
-
import { FeatureFlags } from "../FeatureFlags/FeatureFlags.js";
|
|
8
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
9
6
|
import { KeybindingHint } from "../KeybindingHint/KeybindingHint.js";
|
|
10
7
|
import { getAccessibleKeybindingHintString } from "../KeybindingHint/utils.js";
|
|
11
8
|
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
@@ -13,6 +10,9 @@ import { useSlots } from "../hooks/useSlots.js";
|
|
|
13
10
|
import { useOverflow } from "../hooks/useOverflow.js";
|
|
14
11
|
import { ScrollableRegion } from "../ScrollableRegion/ScrollableRegion.js";
|
|
15
12
|
import { Dialog } from "../Dialog/Dialog.js";
|
|
13
|
+
import { DefaultFeatureFlags } from "../FeatureFlags/DefaultFeatureFlags.js";
|
|
14
|
+
import { FeatureFlags } from "../FeatureFlags/FeatureFlags.js";
|
|
15
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
16
16
|
import { Stack } from "../Stack/index.js";
|
|
17
17
|
import { SkeletonBox } from "../Skeleton/SkeletonBox.js";
|
|
18
18
|
import { FilteredActionListLoadingTypes } from "../FilteredActionList/constants.js";
|
|
@@ -106,6 +106,10 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
106
106
|
}, [updatePosition]);
|
|
107
107
|
useResizeObserver(updatePosition, void 0, [], enabled);
|
|
108
108
|
useResizeObserver(updatePosition, floatingElementRef, [], enabled);
|
|
109
|
+
const scrollAncestorsCacheRef = React.useRef({
|
|
110
|
+
anchor: null,
|
|
111
|
+
scrollables: []
|
|
112
|
+
});
|
|
109
113
|
React.useEffect(() => {
|
|
110
114
|
if (!enabled) return;
|
|
111
115
|
const anchorEl = anchorElementRef.current;
|
|
@@ -118,7 +122,16 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
118
122
|
updatePosition();
|
|
119
123
|
});
|
|
120
124
|
};
|
|
121
|
-
const
|
|
125
|
+
const cache = scrollAncestorsCacheRef.current;
|
|
126
|
+
let scrollables;
|
|
127
|
+
if (cache.anchor === anchorEl) scrollables = cache.scrollables;
|
|
128
|
+
else {
|
|
129
|
+
scrollables = getScrollableAncestors(anchorEl);
|
|
130
|
+
scrollAncestorsCacheRef.current = {
|
|
131
|
+
anchor: anchorEl,
|
|
132
|
+
scrollables
|
|
133
|
+
};
|
|
134
|
+
}
|
|
122
135
|
for (const scrollable of scrollables) scrollable.addEventListener("scroll", handleScroll);
|
|
123
136
|
return () => {
|
|
124
137
|
for (const scrollable of scrollables) scrollable.removeEventListener("scroll", handleScroll);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { isExperimentalReactVersion, reactMajorVersion } from "../utils/environment.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import
|
|
3
|
+
import "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);
|
|
7
5
|
/**
|
|
8
6
|
* Cleanup functions for refs were introduced in React 19. For feature detection,
|
|
9
7
|
* we look to see if current version of React is >= 19 or if it is an
|
|
@@ -50,7 +48,6 @@ function useMergedRefs(refA, refB) {
|
|
|
50
48
|
const cleanupA = setRef(refA, value);
|
|
51
49
|
const cleanupB = setRef(refB, value);
|
|
52
50
|
if (!supportsRefCleanup) return;
|
|
53
|
-
if (majorReactVersion <= 18) return;
|
|
54
51
|
return () => {
|
|
55
52
|
if (cleanupA) cleanupA();
|
|
56
53
|
else setRef(refA, null);
|
|
@@ -9,14 +9,17 @@ 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
|
-
*
|
|
14
|
-
* {@linkcode useMergedRefs} instead.
|
|
12
|
+
* @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
|
|
13
|
+
* created ref instead.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* ```diff
|
|
16
|
+
* - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
|
|
17
|
+
* + const ref = useRef(null)
|
|
18
|
+
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
19
|
+
*
|
|
20
|
+
* - return <div ref={ref} />
|
|
21
|
+
* + return <div ref={mergedRef} />
|
|
22
|
+
* ```
|
|
20
23
|
*/
|
|
21
24
|
declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
|
|
22
25
|
//#endregion
|
|
@@ -8,14 +8,17 @@ 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
|
-
*
|
|
13
|
-
* {@linkcode useMergedRefs} instead.
|
|
11
|
+
* @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
|
|
12
|
+
* created ref instead.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* ```diff
|
|
15
|
+
* - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
|
|
16
|
+
* + const ref = useRef(null)
|
|
17
|
+
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
18
|
+
*
|
|
19
|
+
* - return <div ref={ref} />
|
|
20
|
+
* + return <div ref={mergedRef} />
|
|
21
|
+
* ```
|
|
19
22
|
*/
|
|
20
23
|
function useProvidedRefOrCreate(providedRef) {
|
|
21
24
|
const createdRef = React.useRef(null);
|
package/package.json
CHANGED