@primer/react 38.34.0-rc.9bc993c30 → 38.34.0-rc.ac0faffd6
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 +0 -6
- package/dist/ActionList/Group.js +1 -1
- package/dist/ActionList/List.js +14 -20
- package/dist/AnchoredOverlay/AnchoredOverlay.js +3 -6
- package/dist/Autocomplete/AutocompleteInput.js +7 -10
- package/dist/ButtonGroup/ButtonGroup.js +8 -15
- package/dist/Checkbox/Checkbox.js +9 -16
- package/dist/Dialog/Dialog.js +5 -12
- package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
- package/dist/FilteredActionList/FilteredActionList.js +20 -31
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/Link/Link.js +33 -33
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/PageHeader/PageHeader.js +21 -30
- 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 +6 -13
- package/dist/TooltipV2/Tooltip.js +11 -18
- package/dist/experimental/Tabs/Tabs.js +2 -3
- package/dist/experimental/Tabs/types.d.ts +3 -10
- package/dist/experimental/Tabs/useTabList.js +10 -18
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +42 -69
- package/dist/experimental/index.js +5 -5
- package/dist/hooks/useMergedRefs.d.ts +4 -4
- package/dist/hooks/useMergedRefs.js +5 -8
- package/dist/hooks/useProvidedRefOrCreate.d.ts +10 -7
- package/dist/hooks/useProvidedRefOrCreate.js +10 -7
- package/generated/components.json +5 -5
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,14 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
-
- [#8211](https://github.com/primer/react/pull/8211) [`a3e669f`](https://github.com/primer/react/commit/a3e669fa551a7d07841ce20224199d172905860f) Thanks [@francinelucca](https://github.com/francinelucca)! - Link: Remove unnecessary `data-hover-color` attribute from rendered DOM element
|
|
12
|
-
|
|
13
|
-
- [#8196](https://github.com/primer/react/pull/8196) [`e24effd`](https://github.com/primer/react/commit/e24effd440d69f0068a89aba26bae9e39fb3254e) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Use `aria-pressed` instead of `aria-current` on `SegmentedControl.Button` and `SegmentedControl.IconButton` so JAWS announces the selected state when a segment is activated.
|
|
14
|
-
|
|
15
11
|
- [#8169](https://github.com/primer/react/pull/8169) [`1d6f559`](https://github.com/primer/react/commit/1d6f5593f5e482d1d03027522bc882560c7b1f06) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Timeline: `Timeline.Actions` now wraps onto a new row below `Timeline.Body`, left-aligned with the body content, when `Timeline.Item` is narrower than 480px.
|
|
16
12
|
|
|
17
|
-
- [#8214](https://github.com/primer/react/pull/8214) [`41705f4`](https://github.com/primer/react/commit/41705f430ce0f64eb61c2665313f36a88cf6f16c) Thanks [@rickyzhangca](https://github.com/rickyzhangca)! - UnderlinePanels: The experimental `UnderlinePanels` component is now built on the experimental `Tabs` component instead of `@github/tab-container-element`. Its public API and behavior are unchanged.
|
|
18
|
-
|
|
19
13
|
## 38.33.0
|
|
20
14
|
|
|
21
15
|
### Minor Changes
|
package/dist/ActionList/Group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
2
2
|
import { useSlots } from "../hooks/useSlots.js";
|
|
3
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
4
3
|
import { invariant } from "../utils/invariant.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,19 +1,18 @@
|
|
|
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
4
|
import { useSlots } from "../hooks/useSlots.js";
|
|
6
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
5
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
8
6
|
import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
|
|
9
7
|
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 listRef = useRef(null);
|
|
66
|
-
const mergedRef = useMergedRefs(listRef, forwardedRef);
|
|
67
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
68
|
-
const readRef = mergedRefEnabled ? listRef : 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;
|
|
@@ -85,14 +79,14 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
85
79
|
const t5 = !enableFocusZone;
|
|
86
80
|
const t6 = listRole === "menu" || container === "SelectPanel" || container === "FilteredActionList" ? "wrap" : void 0;
|
|
87
81
|
let t7;
|
|
88
|
-
if ($[11] !==
|
|
82
|
+
if ($[11] !== listRef || $[12] !== t5 || $[13] !== t6) {
|
|
89
83
|
t7 = {
|
|
90
84
|
disabled: t5,
|
|
91
|
-
containerRef:
|
|
85
|
+
containerRef: listRef,
|
|
92
86
|
bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
|
|
93
87
|
focusOutBehavior: t6
|
|
94
88
|
};
|
|
95
|
-
$[11] =
|
|
89
|
+
$[11] = listRef;
|
|
96
90
|
$[12] = t5;
|
|
97
91
|
$[13] = t6;
|
|
98
92
|
$[14] = t7;
|
|
@@ -117,16 +111,16 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
117
111
|
} else t9 = $[20];
|
|
118
112
|
const listContextValue = t9;
|
|
119
113
|
let t10;
|
|
120
|
-
if ($[21] !==
|
|
114
|
+
if ($[21] !== listRef) {
|
|
121
115
|
t10 = () => {
|
|
122
|
-
const list =
|
|
116
|
+
const list = listRef.current;
|
|
123
117
|
if (!list) return;
|
|
124
118
|
const hasMixed = list.querySelector("[data-has-description=\"true\"]") !== null && list.querySelector("[data-has-description=\"false\"]") !== null;
|
|
125
119
|
const current = list.getAttribute("data-mixed-descriptions");
|
|
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] =
|
|
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,9 +33,7 @@ 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
36
|
const [overlayElement, setOverlayElement] = useState(null);
|
|
39
|
-
const mergedOverlayRef = useMergedRefs(updateOverlayRef, useMergedRefs(overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.ref, setOverlayElement));
|
|
40
37
|
const anchorId = useId$1(externalAnchorId);
|
|
41
38
|
const onClickOutside = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("click-outside"), [onClose]);
|
|
42
39
|
const onEscape = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("escape"), [onClose]);
|
|
@@ -193,10 +190,10 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
193
190
|
...shouldRenderAsPopover ? { popover: "manual" } : {},
|
|
194
191
|
...restOverlayProps,
|
|
195
192
|
...shouldRenderAsPopover ? { id: popoverId } : {},
|
|
196
|
-
ref:
|
|
197
|
-
setOverlayElement(node);
|
|
193
|
+
ref: (node) => {
|
|
198
194
|
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) assignRef(overlayProps.ref, node);
|
|
199
195
|
updateOverlayRef(node);
|
|
196
|
+
setOverlayElement(node);
|
|
200
197
|
},
|
|
201
198
|
"data-anchor-position": cssAnchorPositioning,
|
|
202
199
|
"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 buttonRef = useRef(null);
|
|
36
|
-
const mergedRef = useMergedRefs(buttonRef, forwardRef);
|
|
37
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(forwardRef);
|
|
38
|
-
const readRef = mergedRefEnabled ? buttonRef : 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,16 +36,17 @@ 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
|
-
if ($[8] !==
|
|
42
|
+
if ($[8] !== buttonRef || $[9] !== t3) {
|
|
50
43
|
t4 = {
|
|
51
|
-
containerRef:
|
|
44
|
+
containerRef: buttonRef,
|
|
52
45
|
disabled: t3,
|
|
53
46
|
bindKeys: FocusKeys.ArrowHorizontal,
|
|
54
47
|
focusOutBehavior: "wrap"
|
|
55
48
|
};
|
|
56
|
-
$[8] =
|
|
49
|
+
$[8] = buttonRef;
|
|
57
50
|
$[9] = t3;
|
|
58
51
|
$[10] = t4;
|
|
59
52
|
} else t4 = $[10];
|
|
@@ -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,37 +1,30 @@
|
|
|
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 checkboxRef = useRef(null);
|
|
18
|
-
const mergedRef = useMergedRefs(checkboxRef, ref);
|
|
19
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
20
|
-
const readRef = mergedRefEnabled ? checkboxRef : 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);
|
|
25
18
|
onChange && onChange(e);
|
|
26
|
-
if (indeterminate &&
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
if (indeterminate && checkboxRef.current) {
|
|
20
|
+
checkboxRef.current.indeterminate = true;
|
|
21
|
+
checkboxRef.current.setAttribute("aria-checked", "mixed");
|
|
29
22
|
}
|
|
30
23
|
};
|
|
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,
|
|
@@ -43,14 +36,14 @@ const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultCh
|
|
|
43
36
|
...rest
|
|
44
37
|
};
|
|
45
38
|
useIsomorphicLayoutEffect(() => {
|
|
46
|
-
if (
|
|
39
|
+
if (checkboxRef.current) checkboxRef.current.indeterminate = indeterminate || false;
|
|
47
40
|
}, [
|
|
48
41
|
indeterminate,
|
|
49
42
|
checked,
|
|
50
|
-
|
|
43
|
+
checkboxRef
|
|
51
44
|
]);
|
|
52
45
|
useEffect(() => {
|
|
53
|
-
const { current: checkbox } =
|
|
46
|
+
const { current: checkbox } = checkboxRef;
|
|
54
47
|
if (!checkbox) return;
|
|
55
48
|
if (indeterminate) checkbox.setAttribute("aria-checked", "mixed");
|
|
56
49
|
else checkbox.setAttribute("aria-checked", checkbox.checked ? "true" : "false");
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -4,7 +4,6 @@ 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
6
|
import { useSlots } from "../hooks/useSlots.js";
|
|
7
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
8
7
|
import { IconButton } from "../Button/IconButton.js";
|
|
9
8
|
import { ButtonComponent } from "../Button/Button.js";
|
|
10
9
|
import { useFocusTrap } from "../hooks/useFocusTrap.js";
|
|
@@ -245,28 +244,22 @@ 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 autoFocusRef = useRef(null);
|
|
251
|
-
const mergedRef = useMergedRefs(autoFocusRef, providedButtonRef);
|
|
252
|
-
const providedOrCreatedRef = useProvidedRefOrCreate(providedButtonRef);
|
|
253
|
-
const readRef = mergedRefEnabled ? autoFocusRef : 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(() => {
|
|
258
251
|
if (hasRendered === 1) {
|
|
259
|
-
var
|
|
260
|
-
(
|
|
252
|
+
var _autoFocusRef$current;
|
|
253
|
+
(_autoFocusRef$current = autoFocusRef.current) === null || _autoFocusRef$current === void 0 || _autoFocusRef$current.focus();
|
|
261
254
|
} else setHasRendered(hasRendered + 1);
|
|
262
|
-
}, [
|
|
255
|
+
}, [autoFocusRef, hasRendered]);
|
|
263
256
|
return /*#__PURE__*/ jsx(Fragment, { children: buttons.map((dialogButtonProps, index) => {
|
|
264
257
|
const { content, buttonType = "default", autoFocus = false, ...buttonProps } = dialogButtonProps;
|
|
265
258
|
return /*#__PURE__*/ jsx(ButtonComponent, {
|
|
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 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;
|
|
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();
|
|
@@ -100,12 +89,12 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
100
89
|
onListContainerRefChanged === null || onListContainerRefChanged === void 0 || onListContainerRefChanged(node);
|
|
101
90
|
}, [onListContainerRefChanged]);
|
|
102
91
|
useEffect(() => {
|
|
103
|
-
onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(
|
|
104
|
-
}, [
|
|
92
|
+
onInputRefChanged === null || onInputRefChanged === void 0 || onInputRefChanged(inputRef);
|
|
93
|
+
}, [inputRef, onInputRefChanged]);
|
|
105
94
|
const DEFAULT_VIRTUAL_ITEM_HEIGHT = 32;
|
|
106
95
|
const virtualizer = useVirtualizer({
|
|
107
96
|
count: items.length,
|
|
108
|
-
getScrollElement: () =>
|
|
97
|
+
getScrollElement: () => scrollContainerRef.current,
|
|
109
98
|
estimateSize: () => DEFAULT_VIRTUAL_ITEM_HEIGHT,
|
|
110
99
|
overscan: 10,
|
|
111
100
|
enabled: isVirtualized,
|
|
@@ -139,7 +128,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
139
128
|
focusableElementFilter: (element) => {
|
|
140
129
|
return !(element instanceof HTMLInputElement);
|
|
141
130
|
},
|
|
142
|
-
activeDescendantFocus:
|
|
131
|
+
activeDescendantFocus: inputRef,
|
|
143
132
|
onActiveDescendantChanged: (current, previous, directlyActivated) => {
|
|
144
133
|
activeDescendantRef.current = current;
|
|
145
134
|
if (isVirtualized && current) {
|
|
@@ -147,7 +136,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
147
136
|
const range = virtualizer.range;
|
|
148
137
|
if (index !== null && range && (Number(index) < range.startIndex || Number(index) >= range.endIndex)) virtualizer.scrollToIndex(Number(index), { align: "auto" });
|
|
149
138
|
}
|
|
150
|
-
if (current &&
|
|
139
|
+
if (current && scrollContainerRef.current && (directlyActivated || focusPrependedElements)) scrollIntoView(current, scrollContainerRef.current, {
|
|
151
140
|
...menuScrollMargins,
|
|
152
141
|
behavior: scrollBehavior
|
|
153
142
|
});
|
|
@@ -164,14 +153,14 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
164
153
|
isVirtualized
|
|
165
154
|
]);
|
|
166
155
|
useEffect(() => {
|
|
167
|
-
if (activeDescendantRef.current &&
|
|
156
|
+
if (activeDescendantRef.current && scrollContainerRef.current) scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, {
|
|
168
157
|
...menuScrollMargins,
|
|
169
158
|
behavior: scrollBehavior
|
|
170
159
|
});
|
|
171
160
|
}, [
|
|
172
161
|
items,
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
inputRef,
|
|
163
|
+
scrollContainerRef,
|
|
175
164
|
scrollBehavior
|
|
176
165
|
]);
|
|
177
166
|
useEffect(() => {
|
|
@@ -181,7 +170,7 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
181
170
|
const list = listRef.current;
|
|
182
171
|
if (!list) return;
|
|
183
172
|
const handleFocusIn = (event) => {
|
|
184
|
-
if (event.target ===
|
|
173
|
+
if (event.target === inputRef.current || list.contains(event.target)) setIsInputFocused(inputRef.current && inputRef.current === document.activeElement ? true : false);
|
|
185
174
|
};
|
|
186
175
|
inputAndListContainerElement.addEventListener("focusin", handleFocusIn);
|
|
187
176
|
return () => {
|
|
@@ -190,26 +179,26 @@ function FilteredActionList({ loading = false, placeholderText, filterValue: ext
|
|
|
190
179
|
}
|
|
191
180
|
}, [
|
|
192
181
|
items,
|
|
193
|
-
|
|
182
|
+
inputRef,
|
|
194
183
|
listContainerElement,
|
|
195
184
|
usingRovingTabindex
|
|
196
185
|
]);
|
|
197
186
|
useEffect(() => {
|
|
198
|
-
if (usingRovingTabindex && !loading) setIsInputFocused(
|
|
187
|
+
if (usingRovingTabindex && !loading) setIsInputFocused(inputRef.current && inputRef.current === document.activeElement ? true : false);
|
|
199
188
|
}, [
|
|
200
189
|
loading,
|
|
201
|
-
|
|
190
|
+
inputRef,
|
|
202
191
|
usingRovingTabindex
|
|
203
192
|
]);
|
|
204
|
-
useAnnouncements(items, usingRovingTabindex ? listRef : { current: listContainerElement },
|
|
205
|
-
useScrollFlash(
|
|
193
|
+
useAnnouncements(items, usingRovingTabindex ? listRef : { current: listContainerElement }, inputRef, announcementsEnabled, loading, messageText, _PrivateFocusManagement);
|
|
194
|
+
useScrollFlash(scrollContainerRef);
|
|
206
195
|
const handleSelectAllChange = useCallback((e) => {
|
|
207
196
|
if (onSelectAllChange) onSelectAllChange(e.target.checked);
|
|
208
197
|
}, [onSelectAllChange]);
|
|
209
198
|
function getBodyContent() {
|
|
210
|
-
if (loading &&
|
|
199
|
+
if (loading && scrollContainerRef.current && loadingType.appearsInBody) return /*#__PURE__*/ jsx(FilteredActionListBodyLoader, {
|
|
211
200
|
loadingType,
|
|
212
|
-
height:
|
|
201
|
+
height: scrollContainerRef.current.clientHeight
|
|
213
202
|
});
|
|
214
203
|
if (message) return message;
|
|
215
204
|
let firstGroupIndex = 0;
|
|
@@ -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>;
|