@primer/react 0.0.0-20260717162651 → 0.0.0-20260720205022
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -25
- package/dist/ActionBar/ActionBar-e63def3c.css +2 -0
- package/dist/ActionBar/ActionBar-e63def3c.css.map +1 -0
- package/dist/ActionBar/ActionBar.js +1 -1
- package/dist/ActionBar/ActionBar.module.css.js +1 -1
- package/dist/ActionList/Group.js +2 -2
- package/dist/ActionList/Item.js +1 -1
- package/dist/ActionList/List.js +21 -15
- package/dist/ActionMenu/ActionMenu.js +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +7 -5
- package/dist/Autocomplete/AutocompleteInput.js +10 -7
- package/dist/Autocomplete/AutocompleteMenu.js +2 -3
- package/dist/Breadcrumbs/Breadcrumbs.js +1 -4
- package/dist/ButtonGroup/ButtonGroup.js +15 -8
- package/dist/Checkbox/Checkbox.js +16 -9
- package/dist/Dialog/Dialog.js +13 -6
- package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
- package/dist/FeatureFlags/useFeatureFlag.js +1 -2
- package/dist/FilteredActionList/FilteredActionList.js +31 -20
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/FilteredActionList/useAnnouncements.js +14 -20
- package/dist/LabelGroup/LabelGroup-7d19205a.css +2 -0
- package/dist/LabelGroup/LabelGroup-7d19205a.css.map +1 -0
- package/dist/LabelGroup/LabelGroup.module.css.js +1 -1
- package/dist/NavList/NavList.js +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/PageHeader/PageHeader.js +31 -22
- package/dist/PageLayout/PageLayout.js +248 -54
- package/dist/PageLayout/index.d.ts +1 -3
- package/dist/PageLayout/usePaneWidth.d.ts +1 -63
- package/dist/PageLayout/usePaneWidth.js +36 -52
- package/dist/SelectPanel/SelectPanel.js +1 -1
- package/dist/TextInput/TextInput.js +13 -6
- package/dist/TextInputWithTokens/TextInputWithTokens.js +1 -1
- package/dist/Timeline/Timeline-ff81db92.css +2 -0
- package/dist/Timeline/Timeline-ff81db92.css.map +1 -0
- package/dist/Timeline/Timeline.module.css.js +1 -1
- package/dist/TooltipV2/Tooltip.js +19 -13
- package/dist/TreeView/TreeView.js +3 -6
- package/dist/experimental/SelectPanel2/SelectPanel.js +2 -2
- package/dist/experimental/Tabs/types.d.ts +2 -2
- package/dist/experimental/Tabs/useTabList.js +18 -10
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +1 -1
- package/dist/experimental/index.js +4 -4
- package/dist/hooks/useAnchoredPosition.js +1 -14
- package/dist/hooks/useDialog.js +1 -2
- package/dist/hooks/useMergedRefs.d.ts +4 -4
- package/dist/hooks/useMergedRefs.js +8 -5
- package/dist/hooks/useProvidedRefOrCreate.d.ts +7 -10
- package/dist/hooks/useProvidedRefOrCreate.js +7 -10
- package/dist/hooks/useScrollFlash.js +1 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.js +5 -7
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +1 -1
- package/dist/internal/components/UnderlineTabbedInterface-25587345.css +2 -0
- package/dist/internal/components/UnderlineTabbedInterface-25587345.css.map +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
- package/dist/utils/warning.js +2 -3
- package/generated/components.json +1 -1
- package/package.json +2 -2
- package/dist/ActionBar/ActionBar-3767d551.css +0 -2
- package/dist/ActionBar/ActionBar-3767d551.css.map +0 -1
- package/dist/LabelGroup/LabelGroup-db41f443.css +0 -2
- package/dist/LabelGroup/LabelGroup-db41f443.css.map +0 -1
- package/dist/PageLayout/DragHandle.d.ts +0 -45
- package/dist/PageLayout/DragHandle.js +0 -224
- package/dist/Timeline/Timeline-b7e6685b.css +0 -2
- package/dist/Timeline/Timeline-b7e6685b.css.map +0 -1
- package/dist/internal/components/UnderlineTabbedInterface-3b4961a4.css +0 -2
- package/dist/internal/components/UnderlineTabbedInterface-3b4961a4.css.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- [#8160](https://github.com/primer/react/pull/8160) [`f8e7cf2`](https://github.com/primer/react/commit/f8e7cf2e1bd3eb02d4106b4932b487bb8ff108e6) Thanks [@TylerJDev](https://github.com/TylerJDev)! - PageLayout: Export the resize primitives `usePaneWidth` and `DragHandle` (with `defaultPaneWidth` and related types) so pane-resize behavior can be reused outside of `PageLayout`.
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- [#8064](https://github.com/primer/react/pull/8064) [`eb447fe`](https://github.com/primer/react/commit/eb447fef0f1565934dc38d09df21d8063957aa9d) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Update the ActionBar overflow menu anchor label to `More items`
|
|
12
|
-
|
|
13
|
-
- [#8166](https://github.com/primer/react/pull/8166) [`4045abe`](https://github.com/primer/react/commit/4045abea621d0940edcd1120fc70e6ed5f797205) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Add `contain: layout` to high-churn overflow containers (`ActionBar`, `UnderlineNav`, `UnderlinePanels`, and `LabelGroup`) so their frequent reflows no longer invalidate ancestor layout.
|
|
14
|
-
|
|
15
|
-
- Fake entry to force publishing
|
|
16
|
-
|
|
17
|
-
- [#8176](https://github.com/primer/react/pull/8176) [`f061bc4`](https://github.com/primer/react/commit/f061bc41483211bef1ec8b1dfe07937f20a9ddd6) Thanks [@francinelucca](https://github.com/francinelucca)! - FeatureFlags: Guard against missing context in `useFeatureFlag` so it returns `false` instead of throwing when used outside a provider
|
|
18
|
-
|
|
19
|
-
- [#8116](https://github.com/primer/react/pull/8116) [`cade4af`](https://github.com/primer/react/commit/cade4af9a70f3fd2622031af585dc07dccd79e11) 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.
|
|
20
|
-
|
|
21
|
-
- [#8169](https://github.com/primer/react/pull/8169) [`bae1840`](https://github.com/primer/react/commit/bae1840a1f3a8e126bbb8c96ae2b1bb00b20ae33) 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.
|
|
22
|
-
|
|
23
|
-
- [#8164](https://github.com/primer/react/pull/8164) [`f86e5a6`](https://github.com/primer/react/commit/f86e5a6420e857e7476c3954d419f4e228bdcf1a) Thanks [@jonrohan](https://github.com/jonrohan)! - Fix `UnderlineNav` tab list not filling the full width of the underline nav in Safari
|
|
24
|
-
|
|
25
|
-
- [#8165](https://github.com/primer/react/pull/8165) [`d60d05b`](https://github.com/primer/react/commit/d60d05b2684056b653cb605418d6f1cae0ba38e2) Thanks [@jonrohan](https://github.com/jonrohan)! - Pin the underline tabbed interface wrapper's vertical box model in wrap mode so external border and padding overrides can no longer offset its height and incorrectly trigger the overflow "more" menu
|
|
26
|
-
|
|
27
|
-
## 38.32.0
|
|
3
|
+
## 0.0.0-20260720205022
|
|
28
4
|
|
|
29
5
|
### Minor Changes
|
|
30
6
|
|
|
@@ -43,6 +19,8 @@
|
|
|
43
19
|
|
|
44
20
|
### Patch Changes
|
|
45
21
|
|
|
22
|
+
- Fake entry to force publishing
|
|
23
|
+
|
|
46
24
|
- [#7901](https://github.com/primer/react/pull/7901) [`8288ed9`](https://github.com/primer/react/commit/8288ed9d88668f93cf3b1eb70ee61edac6217367) Thanks [@mattcosta7](https://github.com/mattcosta7)! - PageHeader: improve rendering performance by removing expensive `:has()` selectors. No visual or API changes.
|
|
47
25
|
|
|
48
26
|
- [#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.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.prc-ActionBar-List-9uz46{align-items:flex-start;animation:prc-ActionBar-detect-overflow-mAuJu linear;display:flex;gap:var(--actionbar-gap,var(--stack-gap-condensed,.5rem));height:var(--actionbar-height,var(--control-small-size,1.75rem));list-style:none;margin-bottom:-1px;min-width:0;overflow:hidden;position:relative;animation-timeline:scroll(self block)}.prc-ActionBar-List-9uz46[data-has-overflow=true]{--morebutton-display:flex}.prc-ActionBar-List-9uz46:where([data-size=small]){--actionbar-height:var(--control-small-size,1.75rem)}.prc-ActionBar-List-9uz46:where([data-size=medium]){--actionbar-height:var(--control-medium-size,2rem)}.prc-ActionBar-List-9uz46:where([data-size=large]){--actionbar-height:var(--control-large-size,2.5rem)}.prc-ActionBar-List-9uz46:where([data-gap=none]){--actionbar-gap:0}.prc-ActionBar-List-9uz46:where([data-gap=none]) .prc-ActionBar-Divider-6V8yH{padding:0 var(--base-size-8,.5rem)}.prc-ActionBar-List-9uz46:where([data-gap=condensed]){--actionbar-gap:var(--stack-gap-condensed,0.5rem)}.prc-ActionBar-List-9uz46 [data-overflowing]{visibility:hidden!important}@keyframes prc-ActionBar-detect-overflow-mAuJu{0%,to{--morebutton-display:flex}}.prc-ActionBar-Nav-9spON{align-items:center;display:flex;justify-content:flex-end;padding-inline:var(--base-size-16,1rem)}.prc-ActionBar-Nav-9spON:where([data-flush=true]){padding-inline:0}.prc-ActionBar-Divider-6V8yH:before{background:var(--borderColor-muted,#d1d9e0b3);content:"";display:block;height:var(--base-size-20,1.25rem);margin-top:calc((var(--actionbar-height) - var(--base-size-20,1.25rem))/2);width:var(--borderWidth-thin,.0625rem)}.prc-ActionBar-Group-peNCk,.prc-ActionBar-OverflowContainer-AkYZs{display:flex;gap:inherit}.prc-ActionBar-OverflowContainer-AkYZs{flex-wrap:wrap;justify-content:flex-end;overflow:hidden}.prc-ActionBar-OverflowContainer-AkYZs .prc-ActionBar-OverflowSpacer-tbHkV{height:var(--actionbar-height)}.prc-ActionBar-MoreButton-RHqpx{display:var(--morebutton-display,none)}
|
|
2
|
+
/*# sourceMappingURL=ActionBar-e63def3c.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ActionBar/ActionBar.module.css.js"],"names":[],"mappings":"AAAA,0BASE,sBAAuB,CASvB,oDAAiC,CAhBjC,YAAa,CAQb,yDAAqD,CAGrD,gEAA0D,CAL1D,eAAgB,CADhB,kBAAmB,CAJnB,WAAY,CAQZ,eAAgB,CAVhB,iBAAkB,CAkBlB,qCAsCF,CAnCE,kDACE,yBACF,CAEA,mDACE,oDACF,CAEA,oDACE,kDACF,CAEA,mDACE,mDACF,CAGA,iDACE,iBAKF,CAHE,8EACE,kCACF,CAGF,sDACE,iDACF,CAEA,6CAIE,2BACF,CAGF,+CACE,MAEE,yBACF,CACF,CAEA,yBAIE,kBAAmB,CAHnB,YAAa,CAEb,wBAAyB,CADzB,uCAOF,CAHE,kDACE,gBACF,CAIA,oCAME,6CAAoC,CAFpC,UAAW,CAHX,aAAc,CAEd,kCAA2B,CAK3B,0EAAqE,CANrE,sCAOF,CAQF,kEAJE,YAAa,CACb,WAaF,CAVA,uCAEE,cAAe,CAEf,wBAAyB,CACzB,eAKF,CAHE,2EACE,8BACF,CAGF,gCACE,sCACF","file":"ActionBar-e63def3c.css","sourcesContent":[".List {\n position: relative;\n display: flex;\n min-width: 0;\n\n /* wonder why this is here */\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n list-style: none;\n align-items: flex-start;\n gap: var(--actionbar-gap, var(--stack-gap-condensed));\n overflow: hidden;\n /* Explicit height is required to clip wrapped items */\n height: var(--actionbar-height, var(--control-small-size));\n\n /* Scroll-based animations have no effect unless the container is scrollable (has overflow, even with overflow:hidden)\n so we can use them to detect overflow. It would be cleaner to use scroll-state container queries for this, but\n browser support for scroll-driven animations is slightly better. */\n animation: detect-overflow linear;\n animation-timeline: scroll(self block);\n\n /* After initial render, JS is used to control visibility which provides progressive enhancement for unsupported browsers */\n &[data-has-overflow='true'] {\n --morebutton-display: flex;\n }\n\n &:where([data-size='small']) {\n --actionbar-height: var(--control-small-size);\n }\n\n &:where([data-size='medium']) {\n --actionbar-height: var(--control-medium-size);\n }\n\n &:where([data-size='large']) {\n --actionbar-height: var(--control-large-size);\n }\n\n /* Gap scale (mirrors Stack) */\n &:where([data-gap='none']) {\n --actionbar-gap: 0;\n\n .Divider {\n padding: 0 var(--base-size-8);\n }\n }\n\n &:where([data-gap='condensed']) {\n --actionbar-gap: var(--stack-gap-condensed);\n }\n\n & [data-overflowing] {\n /* Hide overflowing items. Even though they are clipped by `overflow: hidden`, setting `visibility: hidden` ensures\n they can't accidentally be shown and also hides them from screen readers / keyboard nav. `!important` prevents\n consumers from unintentionally overriding this and breaking accessibility. */\n visibility: hidden !important;\n }\n}\n\n@keyframes detect-overflow {\n 0%,\n 100% {\n --morebutton-display: flex;\n }\n}\n\n.Nav {\n display: flex;\n padding-inline: var(--base-size-16);\n justify-content: flex-end;\n align-items: center;\n\n &:where([data-flush='true']) {\n padding-inline: 0;\n }\n}\n\n.Divider {\n &::before {\n display: block;\n width: var(--borderWidth-thin);\n height: var(--base-size-20);\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background: var(--borderColor-muted);\n /* stylelint-disable-next-line primer/spacing */\n margin-top: calc((var(--actionbar-height) - var(--base-size-20)) / 2);\n }\n}\n\n.Group {\n display: flex;\n gap: inherit;\n}\n\n.OverflowContainer {\n display: flex;\n flex-wrap: wrap;\n gap: inherit;\n justify-content: flex-end;\n overflow: hidden;\n\n .OverflowSpacer {\n height: var(--actionbar-height);\n }\n}\n\n.MoreButton {\n display: var(--morebutton-display, none);\n}\n"]}
|
|
@@ -74,7 +74,7 @@ const ActionBar = ({ size = "medium", children, "aria-label": ariaLabel, "aria-l
|
|
|
74
74
|
})]
|
|
75
75
|
}), /*#__PURE__*/ jsxs(ActionMenu, { children: [/*#__PURE__*/ jsx(ActionMenu.Anchor, { children: /*#__PURE__*/ jsx(IconButton, {
|
|
76
76
|
variant: "invisible",
|
|
77
|
-
"aria-label":
|
|
77
|
+
"aria-label": `More ${ariaLabel} items ${overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.length}`,
|
|
78
78
|
icon: KebabHorizontalIcon,
|
|
79
79
|
className: ActionBar_module_css_default.MoreButton,
|
|
80
80
|
"data-more-button-inactive": overflowItems !== null && overflowItems !== void 0 && overflowItems.length ? void 0 : true,
|
package/dist/ActionList/Group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
3
3
|
import { invariant } from "../utils/invariant.js";
|
|
4
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
4
5
|
import { ListContext } from "./shared.js";
|
|
5
6
|
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/Item.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
2
|
-
import { useSlots } from "../hooks/useSlots.js";
|
|
3
2
|
import { ConditionalWrapper } from "../internal/components/ConditionalWrapper.js";
|
|
4
3
|
import { invariant } from "../utils/invariant.js";
|
|
5
4
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
6
5
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
7
6
|
import { TooltipContext } from "../TooltipV2/TooltipContext.js";
|
|
8
7
|
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
8
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
9
9
|
import { ActionListContainerContext } from "./ActionListContainerContext.js";
|
|
10
10
|
import { ItemContext, ListContext } from "./shared.js";
|
|
11
11
|
import ActionList_module_css_default from "./ActionList.module.css.js";
|
package/dist/ActionList/List.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
3
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
4
|
-
import {
|
|
5
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
6
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
7
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
6
8
|
import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
|
|
7
9
|
import { ActionListContainerContext } from "./ActionListContainerContext.js";
|
|
8
10
|
import { ListContext } from "./shared.js";
|
|
9
11
|
import { Heading } from "./Heading.js";
|
|
10
12
|
import ActionList_module_css_default from "./ActionList.module.css.js";
|
|
11
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
12
13
|
import { c } from "react-compiler-runtime";
|
|
13
14
|
import { clsx } from "clsx";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import React from "react";
|
|
16
|
+
import React, { useRef } from "react";
|
|
16
17
|
//#region src/ActionList/List.tsx
|
|
17
18
|
const UnwrappedList = (props, forwardedRef) => {
|
|
18
19
|
var _slots$heading$props$;
|
|
@@ -60,7 +61,12 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
60
61
|
const { listRole: listRoleFromContainer, listLabelledBy, selectionVariant: containerSelectionVariant, enableFocusZone: enableFocusZoneFromContainer, container } = React.useContext(ActionListContainerContext);
|
|
61
62
|
const ariaLabelledBy = slots.heading ? (_slots$heading$props$ = slots.heading.props.id) !== null && _slots$heading$props$ !== void 0 ? _slots$heading$props$ : headingId : listLabelledBy;
|
|
62
63
|
const listRole = role || listRoleFromContainer;
|
|
63
|
-
const
|
|
64
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
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;
|
|
64
70
|
const itemGapEnabled = useFeatureFlag("primer_react_action_list_item_gap") && container === "NavList";
|
|
65
71
|
let enableFocusZone = false;
|
|
66
72
|
if (enableFocusZoneFromContainer !== void 0) enableFocusZone = enableFocusZoneFromContainer;
|
|
@@ -79,14 +85,14 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
79
85
|
const t5 = !enableFocusZone;
|
|
80
86
|
const t6 = listRole === "menu" || container === "SelectPanel" || container === "FilteredActionList" ? "wrap" : void 0;
|
|
81
87
|
let t7;
|
|
82
|
-
if ($[11] !==
|
|
88
|
+
if ($[11] !== readRef || $[12] !== t5 || $[13] !== t6) {
|
|
83
89
|
t7 = {
|
|
84
90
|
disabled: t5,
|
|
85
|
-
containerRef:
|
|
91
|
+
containerRef: readRef,
|
|
86
92
|
bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
|
|
87
93
|
focusOutBehavior: t6
|
|
88
94
|
};
|
|
89
|
-
$[11] =
|
|
95
|
+
$[11] = readRef;
|
|
90
96
|
$[12] = t5;
|
|
91
97
|
$[13] = t6;
|
|
92
98
|
$[14] = t7;
|
|
@@ -111,16 +117,16 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
111
117
|
} else t9 = $[20];
|
|
112
118
|
const listContextValue = t9;
|
|
113
119
|
let t10;
|
|
114
|
-
if ($[21] !==
|
|
120
|
+
if ($[21] !== readRef.current) {
|
|
115
121
|
t10 = () => {
|
|
116
|
-
const list =
|
|
122
|
+
const list = readRef.current;
|
|
117
123
|
if (!list) return;
|
|
118
124
|
const hasMixed = list.querySelector("[data-has-description=\"true\"]") !== null && list.querySelector("[data-has-description=\"false\"]") !== null;
|
|
119
125
|
const current = list.getAttribute("data-mixed-descriptions");
|
|
120
126
|
if (hasMixed && current !== "true") list.setAttribute("data-mixed-descriptions", "true");
|
|
121
127
|
else if (!hasMixed && current !== null) list.removeAttribute("data-mixed-descriptions");
|
|
122
128
|
};
|
|
123
|
-
$[21] =
|
|
129
|
+
$[21] = readRef.current;
|
|
124
130
|
$[22] = t10;
|
|
125
131
|
} else t10 = $[22];
|
|
126
132
|
useIsomorphicLayoutEffect(t10);
|
|
@@ -133,12 +139,12 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
133
139
|
} else t12 = $[24];
|
|
134
140
|
const t13 = itemGapEnabled ? "" : void 0;
|
|
135
141
|
let t14;
|
|
136
|
-
if ($[25] !== Component || $[26] !==
|
|
142
|
+
if ($[25] !== Component || $[26] !== appliedRef || $[27] !== ariaLabelledBy || $[28] !== childrenWithoutSlots || $[29] !== listRole || $[30] !== restProps || $[31] !== showDividers || $[32] !== t12 || $[33] !== t13 || $[34] !== variant) {
|
|
137
143
|
t14 = /*#__PURE__*/ jsx(Component, {
|
|
138
144
|
className: t12,
|
|
139
145
|
role: listRole,
|
|
140
146
|
"aria-labelledby": ariaLabelledBy,
|
|
141
|
-
ref:
|
|
147
|
+
ref: appliedRef,
|
|
142
148
|
"data-component": "ActionList",
|
|
143
149
|
"data-dividers": showDividers,
|
|
144
150
|
"data-variant": variant,
|
|
@@ -147,9 +153,9 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
147
153
|
children: childrenWithoutSlots
|
|
148
154
|
});
|
|
149
155
|
$[25] = Component;
|
|
150
|
-
$[26] =
|
|
151
|
-
$[27] =
|
|
152
|
-
$[28] =
|
|
156
|
+
$[26] = appliedRef;
|
|
157
|
+
$[27] = ariaLabelledBy;
|
|
158
|
+
$[28] = childrenWithoutSlots;
|
|
153
159
|
$[29] = listRole;
|
|
154
160
|
$[30] = restProps;
|
|
155
161
|
$[31] = showDividers;
|
|
@@ -2,10 +2,10 @@ import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
|
2
2
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
3
3
|
import { useMenuKeyboardNavigation } from "../hooks/useMenuKeyboardNavigation.js";
|
|
4
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
|
-
import { isSlot } from "../utils/is-slot.js";
|
|
6
5
|
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
7
6
|
import { ButtonComponent } from "../Button/Button.js";
|
|
8
7
|
import { useResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
8
|
+
import { isSlot } from "../utils/is-slot.js";
|
|
9
9
|
import { DialogContext } from "../Dialog/DialogContext.js";
|
|
10
10
|
import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
|
|
11
11
|
import { Divider } from "../ActionList/Divider.js";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { reactMajorVersion } from "../utils/environment.js";
|
|
2
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
2
3
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
4
|
import { useAnchoredPosition } from "../hooks/useAnchoredPosition.js";
|
|
4
5
|
import { useRenderForcingRef } from "../hooks/useRenderForcingRef.js";
|
|
5
6
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
7
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
6
8
|
import { IconButton } from "../Button/IconButton.js";
|
|
7
9
|
import { useFocusTrap } from "../hooks/useFocusTrap.js";
|
|
8
10
|
import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
9
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
10
11
|
import Overlay from "../Overlay/Overlay.js";
|
|
11
12
|
import AnchoredOverlay_module_css_default from "./AnchoredOverlay.module.css.js";
|
|
12
13
|
import { widthMap } from "../Overlay/constants.js";
|
|
@@ -33,7 +34,9 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
33
34
|
const [anchorElement, setAnchorElement] = useState(null);
|
|
34
35
|
if (anchorRef.current !== anchorElement) setAnchorElement(anchorRef.current);
|
|
35
36
|
const [overlayRef, updateOverlayRef] = useRenderForcingRef();
|
|
37
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
36
38
|
const [overlayElement, setOverlayElement] = useState(null);
|
|
39
|
+
const mergedOverlayRef = useMergedRefs(updateOverlayRef, useMergedRefs(overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.ref, setOverlayElement));
|
|
37
40
|
const anchorId = useId$1(externalAnchorId);
|
|
38
41
|
const onClickOutside = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("click-outside"), [onClose]);
|
|
39
42
|
const onEscape = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("escape"), [onClose]);
|
|
@@ -122,8 +125,7 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
122
125
|
else currentOverlay.style.removeProperty("position-try-fallbacks");
|
|
123
126
|
pendingPositionFrame = requestAnimationFrame(() => {
|
|
124
127
|
pendingPositionFrame = null;
|
|
125
|
-
const
|
|
126
|
-
const result = getDefaultPosition(anchorElement, currentOverlay, fallbackWidth);
|
|
128
|
+
const result = getDefaultPosition(anchorElement, currentOverlay, width ? parseInt(widthMap[width]) : parseInt(widthMap.small));
|
|
127
129
|
currentOverlay.setAttribute("data-align", result.horizontal);
|
|
128
130
|
if (result.suggestedSide) currentOverlay.setAttribute("data-side", result.suggestedSide);
|
|
129
131
|
const offset = result.horizontal === "left" ? result.leftOffset : result.rightOffset;
|
|
@@ -190,10 +192,10 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
|
|
|
190
192
|
...shouldRenderAsPopover ? { popover: "manual" } : {},
|
|
191
193
|
...restOverlayProps,
|
|
192
194
|
...shouldRenderAsPopover ? { id: popoverId } : {},
|
|
193
|
-
ref: (node) => {
|
|
195
|
+
ref: mergedRefEnabled ? mergedOverlayRef : (node) => {
|
|
196
|
+
setOverlayElement(node);
|
|
194
197
|
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) assignRef(overlayProps.ref, node);
|
|
195
198
|
updateOverlayRef(node);
|
|
196
|
-
setOverlayElement(node);
|
|
197
199
|
},
|
|
198
200
|
"data-anchor-position": cssAnchorPositioning,
|
|
199
201
|
"data-side": cssAnchorPositioning ? side : position === null || position === void 0 ? void 0 : position.anchorSide,
|
|
@@ -20,9 +20,11 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
20
20
|
if (openOnFocus) setShowMenu(true);
|
|
21
21
|
};
|
|
22
22
|
const handleInputBlur = useCallback((event) => {
|
|
23
|
-
onBlur
|
|
23
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
24
24
|
safeSetTimeout(() => {
|
|
25
|
-
|
|
25
|
+
const nextFocusedElement = event.relatedTarget;
|
|
26
|
+
const menuElement = document.getElementById(`${id}-listbox`);
|
|
27
|
+
if (!nextFocusedElement || nextFocusedElement !== menuElement && !(menuElement !== null && menuElement !== void 0 && menuElement.contains(nextFocusedElement))) {
|
|
26
28
|
setShowMenu(false);
|
|
27
29
|
if (inputRef.current && autocompleteSuggestion && inputRef.current.value !== inputValue) inputRef.current.value = inputValue;
|
|
28
30
|
}
|
|
@@ -33,16 +35,17 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
33
35
|
inputRef,
|
|
34
36
|
safeSetTimeout,
|
|
35
37
|
autocompleteSuggestion,
|
|
36
|
-
inputValue
|
|
38
|
+
inputValue,
|
|
39
|
+
id
|
|
37
40
|
]);
|
|
38
41
|
const handleInputChange = (event) => {
|
|
39
|
-
onChange
|
|
42
|
+
onChange === null || onChange === void 0 || onChange(event);
|
|
40
43
|
setInputValue(event.currentTarget.value);
|
|
41
44
|
if (!showMenu) setShowMenu(true);
|
|
42
45
|
};
|
|
43
46
|
const handleInputKeyDown = useCallback((event) => {
|
|
44
47
|
var _inputRef$current;
|
|
45
|
-
onKeyDown
|
|
48
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
46
49
|
if (event.key === "Backspace") setHighlightRemainingText(false);
|
|
47
50
|
if (event.key === "Escape" && (_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) {
|
|
48
51
|
setInputValue("");
|
|
@@ -58,11 +61,11 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
58
61
|
setShowMenu
|
|
59
62
|
]);
|
|
60
63
|
const handleInputKeyUp = useCallback((event) => {
|
|
61
|
-
onKeyUp
|
|
64
|
+
onKeyUp === null || onKeyUp === void 0 || onKeyUp(event);
|
|
62
65
|
if (event.key === "Backspace") setHighlightRemainingText(true);
|
|
63
66
|
}, [setHighlightRemainingText, onKeyUp]);
|
|
64
67
|
const onInputKeyPress = useCallback((event) => {
|
|
65
|
-
onKeyPress
|
|
68
|
+
onKeyPress === null || onKeyPress === void 0 || onKeyPress(event);
|
|
66
69
|
if (showMenu && event.key === "Enter" && activeDescendantRef.current) {
|
|
67
70
|
event.preventDefault();
|
|
68
71
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -193,11 +193,10 @@ function AutocompleteMenu(props) {
|
|
|
193
193
|
t12 = (current, _previous, directlyActivated) => {
|
|
194
194
|
activeDescendantRef.current = current || null;
|
|
195
195
|
if (current) {
|
|
196
|
-
|
|
196
|
+
setHighlightedItem(allItemsToRenderRef.current.find((item_1) => {
|
|
197
197
|
var _current$closest;
|
|
198
198
|
return item_1.id === ((_current$closest = current.closest("li")) === null || _current$closest === void 0 ? void 0 : _current$closest.getAttribute("data-id"));
|
|
199
|
-
});
|
|
200
|
-
setHighlightedItem(selectedItem);
|
|
199
|
+
}));
|
|
201
200
|
setIsMenuDirectlyActivated(directlyActivated);
|
|
202
201
|
}
|
|
203
202
|
if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) scrollIntoView(current, customScrollContainerRef.current, menuScrollMargins);
|
|
@@ -250,10 +250,7 @@ function Breadcrumbs(t0) {
|
|
|
250
250
|
const measuredContainerWidth = containerElement.offsetWidth;
|
|
251
251
|
setContainerWidth((prev_0) => prev_0 === measuredContainerWidth ? prev_0 : measuredContainerWidth);
|
|
252
252
|
const listElement = containerElement.querySelector("ol");
|
|
253
|
-
if (listElement && listElement.children.length > 0 && listElement.children.length === childArray.length)
|
|
254
|
-
const widths = Array.from(listElement.children).map(_temp3);
|
|
255
|
-
setChildArrayWidths(widths);
|
|
256
|
-
}
|
|
253
|
+
if (listElement && listElement.children.length > 0 && listElement.children.length === childArray.length) setChildArrayWidths(Array.from(listElement.children).map(_temp3));
|
|
257
254
|
};
|
|
258
255
|
$[3] = childArray.length;
|
|
259
256
|
$[4] = overflow;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
3
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
2
4
|
import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
|
|
3
5
|
import ButtonGroup_module_css_default from "./ButtonGroup.module.css.js";
|
|
4
6
|
import { c } from "react-compiler-runtime";
|
|
5
7
|
import { clsx } from "clsx";
|
|
6
8
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import React from "react";
|
|
9
|
+
import React, { useRef } from "react";
|
|
8
10
|
//#region src/ButtonGroup/ButtonGroup.tsx
|
|
9
11
|
const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forwardRef) {
|
|
10
12
|
const $ = c(20);
|
|
@@ -29,6 +31,12 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
29
31
|
t1 = $[5];
|
|
30
32
|
}
|
|
31
33
|
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;
|
|
32
40
|
let t2;
|
|
33
41
|
if ($[6] !== children) {
|
|
34
42
|
t2 = React.Children.map(children, _temp);
|
|
@@ -36,17 +44,16 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
36
44
|
$[7] = t2;
|
|
37
45
|
} else t2 = $[7];
|
|
38
46
|
const buttons = t2;
|
|
39
|
-
const buttonRef = useProvidedRefOrCreate(forwardRef);
|
|
40
47
|
const t3 = role !== "toolbar";
|
|
41
48
|
let t4;
|
|
42
|
-
if ($[8] !==
|
|
49
|
+
if ($[8] !== readRef || $[9] !== t3) {
|
|
43
50
|
t4 = {
|
|
44
|
-
containerRef:
|
|
51
|
+
containerRef: readRef,
|
|
45
52
|
disabled: t3,
|
|
46
53
|
bindKeys: FocusKeys.ArrowHorizontal,
|
|
47
54
|
focusOutBehavior: "wrap"
|
|
48
55
|
};
|
|
49
|
-
$[8] =
|
|
56
|
+
$[8] = readRef;
|
|
50
57
|
$[9] = t3;
|
|
51
58
|
$[10] = t4;
|
|
52
59
|
} else t4 = $[10];
|
|
@@ -58,9 +65,9 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
58
65
|
$[12] = t5;
|
|
59
66
|
} else t5 = $[12];
|
|
60
67
|
let t6;
|
|
61
|
-
if ($[13] !== BaseComponent || $[14] !==
|
|
68
|
+
if ($[13] !== BaseComponent || $[14] !== appliedRef || $[15] !== buttons || $[16] !== rest || $[17] !== role || $[18] !== t5) {
|
|
62
69
|
t6 = /*#__PURE__*/ jsx(BaseComponent, {
|
|
63
|
-
ref:
|
|
70
|
+
ref: appliedRef,
|
|
64
71
|
className: t5,
|
|
65
72
|
role,
|
|
66
73
|
...rest,
|
|
@@ -68,7 +75,7 @@ const ButtonGroup = /*#__PURE__*/ React.forwardRef(function ButtonGroup(t0, forw
|
|
|
68
75
|
children: buttons
|
|
69
76
|
});
|
|
70
77
|
$[13] = BaseComponent;
|
|
71
|
-
$[14] =
|
|
78
|
+
$[14] = appliedRef;
|
|
72
79
|
$[15] = buttons;
|
|
73
80
|
$[16] = rest;
|
|
74
81
|
$[17] = role;
|
|
@@ -1,30 +1,37 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
4
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
3
5
|
import shared_module_css_default from "./shared.module.css.js";
|
|
4
6
|
import { CheckboxGroupContext } from "../CheckboxGroup/CheckboxGroupContext.js";
|
|
5
7
|
import Checkbox_module_css_default from "./Checkbox.module.css.js";
|
|
6
8
|
import { clsx } from "clsx";
|
|
7
9
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import React, { useContext, useEffect } from "react";
|
|
10
|
+
import React, { useContext, useEffect, useRef } from "react";
|
|
9
11
|
//#region src/Checkbox/Checkbox.tsx
|
|
10
12
|
/**
|
|
11
13
|
* An accessible, native checkbox component
|
|
12
14
|
*/
|
|
13
15
|
const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultChecked, indeterminate, disabled, onChange, required, validationStatus, value, ["data-component"]: dataComponent, ...rest }, ref) => {
|
|
14
|
-
const
|
|
16
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
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;
|
|
15
22
|
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
16
23
|
const handleOnChange = (e) => {
|
|
17
24
|
checkboxGroupContext.onChange && checkboxGroupContext.onChange(e);
|
|
18
25
|
onChange && onChange(e);
|
|
19
|
-
if (indeterminate &&
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
if (indeterminate && readRef.current) {
|
|
27
|
+
readRef.current.indeterminate = true;
|
|
28
|
+
readRef.current.setAttribute("aria-checked", "mixed");
|
|
22
29
|
}
|
|
23
30
|
};
|
|
24
31
|
const inputProps = {
|
|
25
32
|
type: "checkbox",
|
|
26
33
|
disabled,
|
|
27
|
-
ref:
|
|
34
|
+
ref: appliedRef,
|
|
28
35
|
checked: indeterminate ? false : checked,
|
|
29
36
|
defaultChecked,
|
|
30
37
|
required,
|
|
@@ -36,14 +43,14 @@ const Checkbox = /*#__PURE__*/ React.forwardRef(({ checked, className, defaultCh
|
|
|
36
43
|
...rest
|
|
37
44
|
};
|
|
38
45
|
useIsomorphicLayoutEffect(() => {
|
|
39
|
-
if (
|
|
46
|
+
if (readRef.current) readRef.current.indeterminate = indeterminate || false;
|
|
40
47
|
}, [
|
|
41
48
|
indeterminate,
|
|
42
49
|
checked,
|
|
43
|
-
|
|
50
|
+
readRef
|
|
44
51
|
]);
|
|
45
52
|
useEffect(() => {
|
|
46
|
-
const { current: checkbox } =
|
|
53
|
+
const { current: checkbox } = readRef;
|
|
47
54
|
if (!checkbox) return;
|
|
48
55
|
if (indeterminate) checkbox.setAttribute("aria-checked", "mixed");
|
|
49
56
|
else checkbox.setAttribute("aria-checked", checkbox.checked ? "true" : "false");
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -3,9 +3,10 @@ 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 {
|
|
6
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
7
|
import { IconButton } from "../Button/IconButton.js";
|
|
8
8
|
import { ButtonComponent } from "../Button/Button.js";
|
|
9
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
9
10
|
import { useFocusTrap } from "../hooks/useFocusTrap.js";
|
|
10
11
|
import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
11
12
|
import Portal_default from "../Portal/index.js";
|
|
@@ -244,22 +245,28 @@ const Footer = /*#__PURE__*/ React.forwardRef(function Footer({ className, ...re
|
|
|
244
245
|
Footer.displayName = "Dialog.Footer";
|
|
245
246
|
const Buttons = ({ buttons }) => {
|
|
246
247
|
var _buttons$find;
|
|
247
|
-
const
|
|
248
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
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;
|
|
248
255
|
let autoFocusCount = 0;
|
|
249
256
|
const [hasRendered, setHasRendered] = useState(0);
|
|
250
257
|
useEffect(() => {
|
|
251
258
|
if (hasRendered === 1) {
|
|
252
|
-
var
|
|
253
|
-
(
|
|
259
|
+
var _readRef$current;
|
|
260
|
+
(_readRef$current = readRef.current) === null || _readRef$current === void 0 || _readRef$current.focus();
|
|
254
261
|
} else setHasRendered(hasRendered + 1);
|
|
255
|
-
}, [
|
|
262
|
+
}, [readRef, hasRendered]);
|
|
256
263
|
return /*#__PURE__*/ jsx(Fragment, { children: buttons.map((dialogButtonProps, index) => {
|
|
257
264
|
const { content, buttonType = "default", autoFocus = false, ...buttonProps } = dialogButtonProps;
|
|
258
265
|
return /*#__PURE__*/ jsx(ButtonComponent, {
|
|
259
266
|
"data-component": "Dialog.FooterButton",
|
|
260
267
|
...buttonProps,
|
|
261
268
|
variant: buttonType === "normal" ? "default" : buttonType,
|
|
262
|
-
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++,
|
|
269
|
+
ref: autoFocus && autoFocusCount === 0 ? (autoFocusCount++, appliedRef) : null,
|
|
263
270
|
children: content
|
|
264
271
|
}, index);
|
|
265
272
|
}) });
|
|
@@ -7,7 +7,8 @@ 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
|
|
10
|
+
primer_react_timeline_list_semantics: false,
|
|
11
|
+
primer_react_merged_forwarded_refs: false
|
|
11
12
|
});
|
|
12
13
|
//#endregion
|
|
13
14
|
export { DefaultFeatureFlags };
|
|
@@ -10,8 +10,7 @@ function useFeatureFlag(flag) {
|
|
|
10
10
|
const context = useContext(FeatureFlagContext);
|
|
11
11
|
let t0;
|
|
12
12
|
if ($[0] !== context || $[1] !== flag) {
|
|
13
|
-
|
|
14
|
-
t0 = (_context$enabled = context === null || context === void 0 ? void 0 : context.enabled(flag)) !== null && _context$enabled !== void 0 ? _context$enabled : false;
|
|
13
|
+
t0 = context.enabled(flag);
|
|
15
14
|
$[0] = context;
|
|
16
15
|
$[1] = flag;
|
|
17
16
|
$[2] = t0;
|