@primer/react 0.0.0-20260702163627 → 0.0.0-20260702195104
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 -1
- package/dist/ActionList/List.js +46 -45
- package/dist/AnchoredOverlay/AnchoredOverlay.js +2 -4
- package/dist/Autocomplete/AutocompleteInput.js +7 -10
- package/dist/ButtonGroup/ButtonGroup.js +23 -23
- package/dist/Checkbox/Checkbox.js +4 -5
- package/dist/Dialog/Dialog.js +3 -3
- package/dist/FilteredActionList/FilteredActionList.js +5 -7
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/PageHeader/PageHeader.js +31 -30
- package/dist/TextInput/TextInput.js +4 -5
- package/dist/experimental/Tabs/types.d.ts +2 -2
- package/dist/experimental/Tabs/useTabList.js +15 -16
- 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
package/dist/ActionList/List.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.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
|
|
15
|
+
import React 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(40);
|
|
20
20
|
let className;
|
|
21
21
|
let restProps;
|
|
22
22
|
let role;
|
|
@@ -60,8 +60,7 @@ 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 =
|
|
64
|
-
const mergedRef = useMergedRefs(forwardedRef, listRef);
|
|
63
|
+
const listRef = useProvidedRefOrCreate(forwardedRef);
|
|
65
64
|
const itemGapEnabled = useFeatureFlag("primer_react_action_list_item_gap") && container === "NavList";
|
|
66
65
|
let enableFocusZone = false;
|
|
67
66
|
if (enableFocusZoneFromContainer !== void 0) enableFocusZone = enableFocusZoneFromContainer;
|
|
@@ -80,21 +79,22 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
80
79
|
const t5 = !enableFocusZone;
|
|
81
80
|
const t6 = listRole === "menu" || container === "SelectPanel" || container === "FilteredActionList" ? "wrap" : void 0;
|
|
82
81
|
let t7;
|
|
83
|
-
if ($[11] !==
|
|
82
|
+
if ($[11] !== listRef || $[12] !== t5 || $[13] !== t6) {
|
|
84
83
|
t7 = {
|
|
85
84
|
disabled: t5,
|
|
86
85
|
containerRef: listRef,
|
|
87
86
|
bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
|
|
88
87
|
focusOutBehavior: t6
|
|
89
88
|
};
|
|
90
|
-
$[11] =
|
|
91
|
-
$[12] =
|
|
92
|
-
$[13] =
|
|
93
|
-
|
|
89
|
+
$[11] = listRef;
|
|
90
|
+
$[12] = t5;
|
|
91
|
+
$[13] = t6;
|
|
92
|
+
$[14] = t7;
|
|
93
|
+
} else t7 = $[14];
|
|
94
94
|
useFocusZone(t7);
|
|
95
95
|
const t8 = selectionVariant || containerSelectionVariant;
|
|
96
96
|
let t9;
|
|
97
|
-
if ($[
|
|
97
|
+
if ($[15] !== headingId || $[16] !== listRole || $[17] !== showDividers || $[18] !== t8 || $[19] !== 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
|
+
$[15] = headingId;
|
|
106
|
+
$[16] = listRole;
|
|
107
|
+
$[17] = showDividers;
|
|
108
|
+
$[18] = t8;
|
|
109
|
+
$[19] = variant;
|
|
110
|
+
$[20] = t9;
|
|
111
|
+
} else t9 = $[20];
|
|
112
112
|
const listContextValue = t9;
|
|
113
113
|
let t10;
|
|
114
|
-
if ($[
|
|
114
|
+
if ($[21] !== listRef) {
|
|
115
115
|
t10 = () => {
|
|
116
116
|
const list = listRef.current;
|
|
117
117
|
if (!list) return;
|
|
@@ -120,24 +120,25 @@ 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
|
-
|
|
123
|
+
$[21] = listRef;
|
|
124
|
+
$[22] = t10;
|
|
125
|
+
} else t10 = $[22];
|
|
125
126
|
useIsomorphicLayoutEffect(t10);
|
|
126
127
|
const t11 = slots.heading;
|
|
127
128
|
let t12;
|
|
128
|
-
if ($[
|
|
129
|
+
if ($[23] !== className) {
|
|
129
130
|
t12 = clsx(ActionList_module_css_default.ActionList, className);
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
} else t12 = $[
|
|
131
|
+
$[23] = className;
|
|
132
|
+
$[24] = t12;
|
|
133
|
+
} else t12 = $[24];
|
|
133
134
|
const t13 = itemGapEnabled ? "" : void 0;
|
|
134
135
|
let t14;
|
|
135
|
-
if ($[
|
|
136
|
+
if ($[25] !== Component || $[26] !== ariaLabelledBy || $[27] !== childrenWithoutSlots || $[28] !== listRef || $[29] !== listRole || $[30] !== restProps || $[31] !== showDividers || $[32] !== t12 || $[33] !== t13 || $[34] !== variant) {
|
|
136
137
|
t14 = /*#__PURE__*/ jsx(Component, {
|
|
137
138
|
className: t12,
|
|
138
139
|
role: listRole,
|
|
139
140
|
"aria-labelledby": ariaLabelledBy,
|
|
140
|
-
ref:
|
|
141
|
+
ref: listRef,
|
|
141
142
|
"data-component": "ActionList",
|
|
142
143
|
"data-dividers": showDividers,
|
|
143
144
|
"data-variant": variant,
|
|
@@ -145,29 +146,29 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
145
146
|
...restProps,
|
|
146
147
|
children: childrenWithoutSlots
|
|
147
148
|
});
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
} else t14 = $[
|
|
149
|
+
$[25] = Component;
|
|
150
|
+
$[26] = ariaLabelledBy;
|
|
151
|
+
$[27] = childrenWithoutSlots;
|
|
152
|
+
$[28] = listRef;
|
|
153
|
+
$[29] = listRole;
|
|
154
|
+
$[30] = restProps;
|
|
155
|
+
$[31] = showDividers;
|
|
156
|
+
$[32] = t12;
|
|
157
|
+
$[33] = t13;
|
|
158
|
+
$[34] = variant;
|
|
159
|
+
$[35] = t14;
|
|
160
|
+
} else t14 = $[35];
|
|
160
161
|
let t15;
|
|
161
|
-
if ($[
|
|
162
|
+
if ($[36] !== listContextValue || $[37] !== slots.heading || $[38] !== t14) {
|
|
162
163
|
t15 = /*#__PURE__*/ jsxs(ListContext.Provider, {
|
|
163
164
|
value: listContextValue,
|
|
164
165
|
children: [t11, t14]
|
|
165
166
|
});
|
|
166
|
-
$[
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
} else t15 = $[
|
|
167
|
+
$[36] = listContextValue;
|
|
168
|
+
$[37] = slots.heading;
|
|
169
|
+
$[38] = t14;
|
|
170
|
+
$[39] = t15;
|
|
171
|
+
} else t15 = $[39];
|
|
171
172
|
return t15;
|
|
172
173
|
};
|
|
173
174
|
const List = fixedForwardRef(UnwrappedList);
|
|
@@ -1,5 +1,4 @@
|
|
|
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";
|
|
@@ -34,7 +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 mergedOverlayRef = useMergedRefs(updateOverlayRef, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.ref);
|
|
38
36
|
const [overlayElement, setOverlayElement] = useState(null);
|
|
39
37
|
const anchorId = useId$1(externalAnchorId);
|
|
40
38
|
const onClickOutside = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("click-outside"), [onClose]);
|
|
@@ -191,10 +189,10 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
191
189
|
...shouldRenderAsPopover ? { popover: "manual" } : {},
|
|
192
190
|
...restOverlayProps,
|
|
193
191
|
...shouldRenderAsPopover ? { id: popoverId } : {},
|
|
194
|
-
...cssAnchorPositioning ? { id: popoverId } : {},
|
|
195
192
|
ref: (node) => {
|
|
193
|
+
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) assignRef(overlayProps.ref, node);
|
|
194
|
+
updateOverlayRef(node);
|
|
196
195
|
setOverlayElement(node);
|
|
197
|
-
assignRef(mergedOverlayRef, node);
|
|
198
196
|
},
|
|
199
197
|
"data-anchor-position": cssAnchorPositioning,
|
|
200
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,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.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
|
|
7
|
+
import React 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(20);
|
|
11
11
|
let children;
|
|
12
12
|
let className;
|
|
13
13
|
let rest;
|
|
@@ -29,8 +29,6 @@ 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);
|
|
34
32
|
let t2;
|
|
35
33
|
if ($[6] !== children) {
|
|
36
34
|
t2 = React.Children.map(children, _temp);
|
|
@@ -38,43 +36,45 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
38
36
|
$[7] = t2;
|
|
39
37
|
} else t2 = $[7];
|
|
40
38
|
const buttons = t2;
|
|
39
|
+
const buttonRef = useProvidedRefOrCreate(forwardRef);
|
|
41
40
|
const t3 = role !== "toolbar";
|
|
42
41
|
let t4;
|
|
43
|
-
if ($[8] !== t3) {
|
|
42
|
+
if ($[8] !== buttonRef || $[9] !== t3) {
|
|
44
43
|
t4 = {
|
|
45
44
|
containerRef: buttonRef,
|
|
46
45
|
disabled: t3,
|
|
47
46
|
bindKeys: FocusKeys.ArrowHorizontal,
|
|
48
47
|
focusOutBehavior: "wrap"
|
|
49
48
|
};
|
|
50
|
-
$[8] =
|
|
51
|
-
$[9] =
|
|
52
|
-
|
|
49
|
+
$[8] = buttonRef;
|
|
50
|
+
$[9] = t3;
|
|
51
|
+
$[10] = t4;
|
|
52
|
+
} else t4 = $[10];
|
|
53
53
|
useFocusZone(t4);
|
|
54
54
|
let t5;
|
|
55
|
-
if ($[
|
|
55
|
+
if ($[11] !== className) {
|
|
56
56
|
t5 = clsx(className, ButtonGroup_module_css_default.ButtonGroup);
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
} else t5 = $[
|
|
57
|
+
$[11] = className;
|
|
58
|
+
$[12] = t5;
|
|
59
|
+
} else t5 = $[12];
|
|
60
60
|
let t6;
|
|
61
|
-
if ($[
|
|
61
|
+
if ($[13] !== BaseComponent || $[14] !== buttonRef || $[15] !== buttons || $[16] !== rest || $[17] !== role || $[18] !== t5) {
|
|
62
62
|
t6 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
63
|
-
ref:
|
|
63
|
+
ref: buttonRef,
|
|
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
|
+
$[13] = BaseComponent;
|
|
71
|
+
$[14] = buttonRef;
|
|
72
|
+
$[15] = buttons;
|
|
73
|
+
$[16] = rest;
|
|
74
|
+
$[17] = role;
|
|
75
|
+
$[18] = t5;
|
|
76
|
+
$[19] = t6;
|
|
77
|
+
} else t6 = $[19];
|
|
78
78
|
return t6;
|
|
79
79
|
});
|
|
80
80
|
ButtonGroup.displayName = "ButtonGroup";
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.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
|
|
8
|
+
import React, { useContext, useEffect } 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 =
|
|
15
|
-
const mergedRef = useMergedRefs(checkboxRef, ref);
|
|
14
|
+
const checkboxRef = useProvidedRefOrCreate(ref);
|
|
16
15
|
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
17
16
|
const handleOnChange = (e) => {
|
|
18
17
|
checkboxGroupContext.onChange && checkboxGroupContext.onChange(e);
|
|
@@ -25,7 +24,7 @@ const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultCh
|
|
|
25
24
|
const inputProps = {
|
|
26
25
|
type: "checkbox",
|
|
27
26
|
disabled,
|
|
28
|
-
ref:
|
|
27
|
+
ref: checkboxRef,
|
|
29
28
|
checked: indeterminate ? false : checked,
|
|
30
29
|
defaultChecked,
|
|
31
30
|
required,
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
|
+
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
3
4
|
import { useResizeObserver } from "../hooks/useResizeObserver.js";
|
|
4
5
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
@@ -243,8 +244,7 @@ const Footer = /*#__PURE__*/ React.forwardRef(function Footer({ className, ...re
|
|
|
243
244
|
Footer.displayName = "Dialog.Footer";
|
|
244
245
|
const Buttons = ({ buttons }) => {
|
|
245
246
|
var _buttons$find;
|
|
246
|
-
const autoFocusRef =
|
|
247
|
-
const mergedRef = useMergedRefs(autoFocusRef, (_buttons$find = buttons.find((button) => button.autoFocus)) === null || _buttons$find === void 0 ? void 0 : _buttons$find.ref);
|
|
247
|
+
const autoFocusRef = useProvidedRefOrCreate((_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++, autoFocusRef) : null,
|
|
263
263
|
children: content
|
|
264
264
|
}, index);
|
|
265
265
|
}) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
1
|
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";
|
|
@@ -35,10 +35,8 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
35
35
|
}, [onFilterChange, setInternalFilterValue]);
|
|
36
36
|
const inputAndListContainerRef = useRef(null);
|
|
37
37
|
const listRef = useRef(null);
|
|
38
|
-
const scrollContainerRef =
|
|
39
|
-
const
|
|
40
|
-
const inputRef = useRef(null);
|
|
41
|
-
const combinedInputRef = useMergedRefs(inputRef, providedInputRef);
|
|
38
|
+
const scrollContainerRef = useProvidedRefOrCreate(providedScrollContainerRef);
|
|
39
|
+
const inputRef = useProvidedRefOrCreate(providedInputRef);
|
|
42
40
|
const usingRovingTabindex = _PrivateFocusManagement === "roving-tabindex";
|
|
43
41
|
const [listContainerElement, setListContainerElement] = useState(null);
|
|
44
42
|
const activeDescendantRef = useRef();
|
|
@@ -293,7 +291,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
293
291
|
"data-component": "FilteredActionList",
|
|
294
292
|
children: [
|
|
295
293
|
/*#__PURE__*/ jsx(FilteredActionListInput, {
|
|
296
|
-
inputRef
|
|
294
|
+
inputRef,
|
|
297
295
|
value: filterValue,
|
|
298
296
|
onInputChange,
|
|
299
297
|
onInputKeyPress,
|
|
@@ -327,7 +325,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
327
325
|
})]
|
|
328
326
|
}),
|
|
329
327
|
/*#__PURE__*/ jsx("div", {
|
|
330
|
-
ref:
|
|
328
|
+
ref: scrollContainerRef,
|
|
331
329
|
className: FilteredActionList_module_css_default.Container,
|
|
332
330
|
children: getBodyContent()
|
|
333
331
|
})
|
|
@@ -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>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.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
|
|
13
|
+
import React, { useEffect } from "react";
|
|
14
14
|
import { ArrowLeftIcon } from "@primer/octicons-react";
|
|
15
15
|
//#region src/PageHeader/PageHeader.tsx
|
|
16
16
|
const hiddenOnRegularAndWide = {
|
|
@@ -24,15 +24,14 @@ const hiddenOnNarrow = {
|
|
|
24
24
|
wide: false
|
|
25
25
|
};
|
|
26
26
|
const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
27
|
-
const $ = c(
|
|
27
|
+
const $ = c(14);
|
|
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 =
|
|
31
|
-
const mergedRef = useMergedRefs(rootRef, forwardedRef);
|
|
30
|
+
const rootRef = useProvidedRefOrCreate(forwardedRef);
|
|
32
31
|
const isInteractive = _temp;
|
|
33
32
|
let t2;
|
|
34
33
|
let t3;
|
|
35
|
-
if ($[0] !== children) {
|
|
34
|
+
if ($[0] !== children || $[1] !== rootRef) {
|
|
36
35
|
t2 = function validateInteractiveElementsInTitle() {
|
|
37
36
|
let hasContextArea = false;
|
|
38
37
|
let hasLeadingAction = false;
|
|
@@ -47,24 +46,25 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
47
46
|
};
|
|
48
47
|
t3 = [children, rootRef];
|
|
49
48
|
$[0] = children;
|
|
50
|
-
$[1] =
|
|
51
|
-
$[2] =
|
|
49
|
+
$[1] = rootRef;
|
|
50
|
+
$[2] = t2;
|
|
51
|
+
$[3] = t3;
|
|
52
52
|
} else {
|
|
53
|
-
t2 = $[
|
|
54
|
-
t3 = $[
|
|
53
|
+
t2 = $[2];
|
|
54
|
+
t3 = $[3];
|
|
55
55
|
}
|
|
56
56
|
useEffect(t2, t3);
|
|
57
57
|
let t4;
|
|
58
|
-
if ($[
|
|
58
|
+
if ($[4] !== className) {
|
|
59
59
|
t4 = clsx(PageHeader_module_css_default.PageHeader, className);
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
} else t4 = $[
|
|
60
|
+
$[4] = className;
|
|
61
|
+
$[5] = t4;
|
|
62
|
+
} else t4 = $[5];
|
|
63
63
|
const t5 = hasBorder ? "true" : void 0;
|
|
64
64
|
let t6;
|
|
65
|
-
if ($[
|
|
65
|
+
if ($[6] !== BaseComponent || $[7] !== ariaLabel || $[8] !== children || $[9] !== role || $[10] !== rootRef || $[11] !== t4 || $[12] !== t5) {
|
|
66
66
|
t6 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
67
|
-
ref:
|
|
67
|
+
ref: rootRef,
|
|
68
68
|
className: t4,
|
|
69
69
|
"data-component": "PageHeader",
|
|
70
70
|
"data-has-border": t5,
|
|
@@ -72,15 +72,15 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
72
72
|
role,
|
|
73
73
|
children
|
|
74
74
|
});
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
$[8] = mergedRef;
|
|
75
|
+
$[6] = BaseComponent;
|
|
76
|
+
$[7] = ariaLabel;
|
|
77
|
+
$[8] = children;
|
|
79
78
|
$[9] = role;
|
|
80
|
-
$[10] =
|
|
81
|
-
$[11] =
|
|
82
|
-
$[12] =
|
|
83
|
-
|
|
79
|
+
$[10] = rootRef;
|
|
80
|
+
$[11] = t4;
|
|
81
|
+
$[12] = t5;
|
|
82
|
+
$[13] = t6;
|
|
83
|
+
} else t6 = $[13];
|
|
84
84
|
return t6;
|
|
85
85
|
});
|
|
86
86
|
const ContextArea = (t0) => {
|
|
@@ -262,6 +262,7 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
262
262
|
const { children, className, hidden: t1, variant: t2 } = t0;
|
|
263
263
|
const hidden = t1 === void 0 ? false : t1;
|
|
264
264
|
const variant = t2 === void 0 ? "medium" : t2;
|
|
265
|
+
const titleAreaRef = useProvidedRefOrCreate(forwardedRef);
|
|
265
266
|
let t3;
|
|
266
267
|
if ($[0] !== className) {
|
|
267
268
|
t3 = clsx(PageHeader_module_css_default.TitleArea, className);
|
|
@@ -281,20 +282,20 @@ const TitleArea = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
281
282
|
$[5] = t5;
|
|
282
283
|
} else t5 = $[5];
|
|
283
284
|
let t6;
|
|
284
|
-
if ($[6] !== children || $[7] !==
|
|
285
|
+
if ($[6] !== children || $[7] !== t3 || $[8] !== t4 || $[9] !== t5 || $[10] !== titleAreaRef) {
|
|
285
286
|
t6 = /*#__PURE__*/ jsx("div", {
|
|
286
287
|
className: t3,
|
|
287
|
-
ref:
|
|
288
|
+
ref: titleAreaRef,
|
|
288
289
|
"data-component": "TitleArea",
|
|
289
290
|
...t4,
|
|
290
291
|
...t5,
|
|
291
292
|
children
|
|
292
293
|
});
|
|
293
294
|
$[6] = children;
|
|
294
|
-
$[7] =
|
|
295
|
-
$[8] =
|
|
296
|
-
$[9] =
|
|
297
|
-
$[10] =
|
|
295
|
+
$[7] = t3;
|
|
296
|
+
$[8] = t4;
|
|
297
|
+
$[9] = t5;
|
|
298
|
+
$[10] = titleAreaRef;
|
|
298
299
|
$[11] = t6;
|
|
299
300
|
} else t6 = $[11];
|
|
300
301
|
return t6;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.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,15 +11,14 @@ 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,
|
|
14
|
+
import React, { useCallback, useId, 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 =
|
|
22
|
-
const mergedRef = useMergedRefs(inputRef, ref);
|
|
21
|
+
const inputRef = useProvidedRefOrCreate(ref);
|
|
23
22
|
const isControlled = value !== void 0;
|
|
24
23
|
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== void 0 ? String(defaultValue).length : 0);
|
|
25
24
|
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
@@ -89,7 +88,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
89
88
|
children: typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /*#__PURE__*/ jsx(LeadingVisual, {}) : LeadingVisual
|
|
90
89
|
}),
|
|
91
90
|
/*#__PURE__*/ jsx(UnstyledTextInput, {
|
|
92
|
-
ref:
|
|
91
|
+
ref: inputRef,
|
|
93
92
|
disabled,
|
|
94
93
|
onFocus: handleInputFocus,
|
|
95
94
|
onBlur: handleInputBlur,
|
|
@@ -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,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProvidedRefOrCreate } from "../../hooks/useProvidedRefOrCreate.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { useRef } from "react";
|
|
4
3
|
//#region src/experimental/Tabs/useTabList.ts
|
|
5
4
|
function useTabList(props) {
|
|
6
|
-
const $ = c(
|
|
5
|
+
const $ = c(9);
|
|
7
6
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": ariaOrientation } = props;
|
|
8
|
-
const ref =
|
|
9
|
-
const mergedRef = useMergedRefs(ref, props.ref);
|
|
7
|
+
const ref = useProvidedRefOrCreate(props.ref);
|
|
10
8
|
let t0;
|
|
11
|
-
if ($[0] !== ariaOrientation) {
|
|
9
|
+
if ($[0] !== ariaOrientation || $[1] !== ref) {
|
|
12
10
|
t0 = (event) => {
|
|
13
11
|
const { current: tablist } = ref;
|
|
14
12
|
if (tablist === null) return;
|
|
@@ -35,27 +33,28 @@ function useTabList(props) {
|
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
35
|
$[0] = ariaOrientation;
|
|
38
|
-
$[1] =
|
|
39
|
-
|
|
36
|
+
$[1] = ref;
|
|
37
|
+
$[2] = t0;
|
|
38
|
+
} else t0 = $[2];
|
|
40
39
|
const onKeyDown = t0;
|
|
41
40
|
const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
|
|
42
41
|
let t2;
|
|
43
|
-
if ($[
|
|
42
|
+
if ($[3] !== ariaLabel || $[4] !== ariaLabelledby || $[5] !== onKeyDown || $[6] !== ref || $[7] !== t1) {
|
|
44
43
|
t2 = { tabListProps: {
|
|
45
|
-
ref
|
|
44
|
+
ref,
|
|
46
45
|
"aria-label": ariaLabel,
|
|
47
46
|
"aria-labelledby": ariaLabelledby,
|
|
48
47
|
"aria-orientation": t1,
|
|
49
48
|
role: "tablist",
|
|
50
49
|
onKeyDown
|
|
51
50
|
} };
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
$[4] = mergedRef;
|
|
51
|
+
$[3] = ariaLabel;
|
|
52
|
+
$[4] = ariaLabelledby;
|
|
55
53
|
$[5] = onKeyDown;
|
|
56
|
-
$[6] =
|
|
57
|
-
$[7] =
|
|
58
|
-
|
|
54
|
+
$[6] = ref;
|
|
55
|
+
$[7] = t1;
|
|
56
|
+
$[8] = t2;
|
|
57
|
+
} else t2 = $[8];
|
|
59
58
|
return t2;
|
|
60
59
|
}
|
|
61
60
|
function _temp2(tab_0) {
|
|
@@ -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