@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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
4
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
3
5
|
import Text_default from "../Text/Text.js";
|
|
4
6
|
import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
|
|
5
7
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -11,14 +13,19 @@ import UnstyledTextInput from "../internal/components/UnstyledTextInput.js";
|
|
|
11
13
|
import { getCharacterCountState } from "../utils/character-counter.js";
|
|
12
14
|
import { clsx } from "clsx";
|
|
13
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import React, { useCallback, useId, useState } from "react";
|
|
16
|
+
import React, { useCallback, useId, useRef, useState } from "react";
|
|
15
17
|
import { isValidElementType } from "react-is";
|
|
16
18
|
import { AlertFillIcon } from "@primer/octicons-react";
|
|
17
19
|
//#region src/TextInput/TextInput.tsx
|
|
18
20
|
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
21
|
var _counter$isOverLimit;
|
|
20
22
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
21
|
-
const
|
|
23
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
24
|
+
const inputRef = useRef(null);
|
|
25
|
+
const mergedRef = useMergedRefs(inputRef, ref);
|
|
26
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
27
|
+
const readRef = mergedRefEnabled ? inputRef : providedOrCreatedRef;
|
|
28
|
+
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
22
29
|
const isControlled = value !== void 0;
|
|
23
30
|
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== void 0 ? String(defaultValue).length : 0);
|
|
24
31
|
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
@@ -29,9 +36,9 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
29
36
|
const showTrailingLoadingIndicator = loading && (loaderPosition === "trailing" || Boolean(loaderPosition === "auto" && !LeadingVisual));
|
|
30
37
|
const isSegmentedInputType = type === "date" || type === "time" || type === "datetime-local";
|
|
31
38
|
const focusInput = (e) => {
|
|
32
|
-
if (e.target !==
|
|
33
|
-
var
|
|
34
|
-
(
|
|
39
|
+
if (e.target !== readRef.current || !isSegmentedInputType) {
|
|
40
|
+
var _readRef$current;
|
|
41
|
+
(_readRef$current = readRef.current) === null || _readRef$current === void 0 || _readRef$current.focus();
|
|
35
42
|
}
|
|
36
43
|
};
|
|
37
44
|
const leadingVisualId = useId();
|
|
@@ -88,7 +95,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
88
95
|
children: typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /*#__PURE__*/ jsx(LeadingVisual, {}) : LeadingVisual
|
|
89
96
|
}),
|
|
90
97
|
/*#__PURE__*/ jsx(UnstyledTextInput, {
|
|
91
|
-
ref:
|
|
98
|
+
ref: appliedRef,
|
|
92
99
|
disabled,
|
|
93
100
|
onFocus: handleInputFocus,
|
|
94
101
|
onBlur: handleInputBlur,
|
|
@@ -12,8 +12,8 @@ import { c } from "react-compiler-runtime";
|
|
|
12
12
|
import { clsx } from "clsx";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import React, { useRef, useState } from "react";
|
|
15
|
-
import { isFocusable } from "@primer/behaviors/utils";
|
|
16
15
|
import { FocusKeys } from "@primer/behaviors";
|
|
16
|
+
import { isFocusable } from "@primer/behaviors/utils";
|
|
17
17
|
import { isValidElementType } from "react-is";
|
|
18
18
|
//#region src/TextInputWithTokens/TextInputWithTokens.tsx
|
|
19
19
|
/**
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.prc-Timeline-Timeline-awSoC{display:flex;flex-direction:column;list-style:none;margin:0;padding:0}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=start]) .prc-Timeline-TimelineItem-QwDVH:first-child{padding-top:0}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=both]) .prc-Timeline-TimelineItem-QwDVH:first-child{padding-top:0}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=start]) .prc-Timeline-TimelineItem-QwDVH:first-child .prc-Timeline-TimelineItemAvatar-4zO8f{top:var(--base-size-16,1rem)}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=both]) .prc-Timeline-TimelineItem-QwDVH:first-child .prc-Timeline-TimelineItemAvatar-4zO8f{top:var(--base-size-16,1rem)}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=start]) .prc-Timeline-TimelineItem-QwDVH:first-child:where([data-condensed]):before{top:var(--base-size-12,.75rem)}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=both]) .prc-Timeline-TimelineItem-QwDVH:first-child:where([data-condensed]):before{top:var(--base-size-12,.75rem)}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=start]) .prc-Timeline-TimelineItem-QwDVH:first-child:where([data-condensed]) .prc-Timeline-TimelineItemAvatar-4zO8f{top:calc(var(--base-size-8,.5rem) + var(--base-size-8,.5rem))}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=both]) .prc-Timeline-TimelineItem-QwDVH:first-child:where([data-condensed]) .prc-Timeline-TimelineItemAvatar-4zO8f{top:calc(var(--base-size-8,.5rem) + var(--base-size-8,.5rem))}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=end]) .prc-Timeline-TimelineItem-QwDVH:last-child{padding-bottom:0}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=both]) .prc-Timeline-TimelineItem-QwDVH:last-child{padding-bottom:0}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=end]) .prc-Timeline-TimelineItem-QwDVH:last-child:where([data-condensed]):before{height:var(--base-size-12,.75rem)}.prc-Timeline-Timeline-awSoC:where([data-clip-sidebar=both]) .prc-Timeline-TimelineItem-QwDVH:last-child:where([data-condensed]):before{height:var(--base-size-12,.75rem)}.prc-Timeline-TimelineItem-QwDVH{display:flex;margin-left:var(--base-size-16,1rem);padding:var(--base-size-16,1rem) 0;position:relative}.prc-Timeline-TimelineItem-QwDVH:before{background-color:var(--borderColor-muted,#d1d9e0b3);bottom:0;content:"";display:block;left:0;position:absolute;top:0;width:2px}.prc-Timeline-TimelineItem-QwDVH:where([data-condensed]){padding-bottom:0;padding-top:var(--base-size-4,.25rem)}.prc-Timeline-TimelineItem-QwDVH:where([data-condensed]):last-child{padding-bottom:var(--base-size-16,1rem)}.prc-Timeline-TimelineItem-QwDVH:where([data-condensed]) .prc-Timeline-TimelineBadge-u0qSm{background-color:var(--bgColor-default,#fff);border:0;color:var(--fgColor-muted,#59636e);height:16px;margin-bottom:var(--base-size-8,.5rem);margin-top:var(--base-size-8,.5rem)}.prc-Timeline-TimelineItem-QwDVH:where([data-condensed]) .prc-Timeline-TimelineItemAvatar-4zO8f{top:calc(var(--base-size-4,.25rem) + var(--base-size-8,.5rem) + var(--base-size-8,.5rem))}.prc-Timeline-TimelineItemAvatar-4zO8f{left:calc((var(--base-size-40,2.5rem) + var(--base-size-32,2rem))*-1);position:absolute;top:calc(var(--base-size-16,1rem) + var(--base-size-16,1rem));transform:translateY(-50%);z-index:1}.prc-Timeline-TimelineBadgeWrapper-SZw4k{position:relative;z-index:1}.prc-Timeline-TimelineBadge-u0qSm{align-items:center;background-color:var(--timelineBadge-bgColor,#f6f8fa);border-color:var(--bgColor-default,#fff);border-radius:50%;border-style:solid;border-width:var(--borderWidth-thick,.125rem);color:var(--fgColor-muted,#59636e);display:flex;flex-shrink:0;height:32px;justify-content:center;margin-left:-15px;margin-right:var(--base-size-8,.5rem);overflow:hidden;width:32px}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant]){color:var(--fgColor-onEmphasis,#fff)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=accent]){background-color:var(--bgColor-accent-emphasis,#0969da)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=success]){background-color:var(--bgColor-success-emphasis,#1f883d)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=attention]){background-color:var(--bgColor-attention-emphasis,#9a6700)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=severe]){background-color:var(--bgColor-severe-emphasis,#bc4c00)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=danger]){background-color:var(--bgColor-danger-emphasis,#cf222e)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=done]){background-color:var(--bgColor-done-emphasis,#8250df)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=open]){background-color:var(--bgColor-open-emphasis,#1f883d)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=closed]){background-color:var(--bgColor-closed-emphasis,#cf222e)}.prc-Timeline-TimelineBadge-u0qSm:where([data-variant=sponsors]){background-color:var(--bgColor-sponsors-emphasis,#bf3989)}.prc-Timeline-TimelineBody-tjOtb{color:var(--fgColor-muted,#59636e);flex:auto;font-size:var(--text-body-size-medium,.875rem);margin-top:calc(var(--base-size-4,.25rem) + 1px);max-width:100%;min-width:0}.prc-Timeline-TimelineBreak-X8eti{background-color:var(--bgColor-default,#fff);border:0;border-top:var(--borderWidth-thicker,.25rem) solid var(--borderColor-default,#d1d9e0);height:var(--base-size-24,1.5rem);margin:0;margin-bottom:calc(var(--base-size-16,1rem)*-1);margin-left:0;position:relative;z-index:1}.prc-Timeline-TimelineBreak-X8eti:has(+[data-condensed]){margin-bottom:calc(var(--base-size-12,.75rem)*-1)}.prc-Timeline-TimelineItemActions-56Y7h{align-items:center;align-self:flex-start;display:flex;flex-shrink:0;gap:var(--base-size-8,.5rem);margin-left:auto;min-height:var(--base-size-32,2rem)}
|
|
2
|
+
/*# sourceMappingURL=Timeline-ff81db92.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Timeline/Timeline.module.css.js"],"names":[],"mappings":"AAAA,6BACE,YAAa,CACb,qBAAsB,CACtB,eAAgB,CAEhB,QAAS,CADT,SAkCF,CA7BI,2GACE,aAeF,CAhBA,0GACE,aAeF,CAbE,kJAEE,4BACF,CAHA,iJAEE,4BACF,CAEA,0IACE,8BACF,CAFA,yIACE,8BACF,CAEA,0KAEE,6DACF,CAHA,yKAEE,6DACF,CAMF,wGACE,gBAKF,CANA,yGACE,gBAKF,CAHE,uIACE,iCACF,CAFA,wIACE,iCACF,CAKN,iCAEE,YAAa,CAEb,oCAAgC,CADhC,kCAA8B,CAF9B,iBAuCF,CAlCE,wCASE,mDAA0C,CAN1C,QAAS,CAIT,UAAW,CAFX,aAAc,CADd,MAAO,CAHP,iBAAkB,CAClB,KAAM,CAIN,SAIF,CAEA,yDAEE,gBAAiB,CADjB,qCAoBF,CAjBE,oEACE,uCACF,CAEA,2FAKE,4CAAwC,CACxC,QAAS,CAFT,kCAA2B,CAH3B,WAAY,CAEZ,sCAAiC,CADjC,mCAKF,CAEA,gGAEE,yFACF,CAIJ,uCAGE,qEAA4D,CAF5D,iBAAkB,CAIlB,6DAAoD,CAEpD,0BAA2B,CAD3B,SAEF,CAEA,yCACE,iBAAkB,CAClB,SACF,CAEA,kCAkBE,kBAAmB,CANnB,qDAA8C,CAE9C,wCAAoC,CAGpC,iBAAkB,CAFlB,kBAAmB,CACnB,6CAAsC,CAPtC,kCAA2B,CAR3B,YAAa,CAMb,aAAc,CAJd,WAAY,CAgBZ,sBAAuB,CAbvB,iBAAkB,CAFlB,qCAAgC,CAIhC,eAAgB,CANhB,UA0DF,CAvCE,wDACE,oCACF,CAEA,+DACE,uDACF,CAEA,gEACE,wDACF,CAEA,kEACE,0DACF,CAEA,+DACE,uDACF,CAEA,+DACE,uDACF,CAEA,6DACE,qDACF,CAEA,6DACE,qDACF,CAEA,+DACE,uDACF,CAEA,iEACE,yDACF,CAGF,iCAME,kCAA2B,CAC3B,SAAU,CAFV,8CAAuC,CADvC,gDAA0C,CAF1C,cAAe,CADf,WAOF,CAEA,kCAOE,4CAAwC,CACxC,QAAS,CACT,qFAAuE,CANvE,iCAA2B,CAC3B,QAAS,CACT,+CAA6C,CAC7C,aAAc,CALd,iBAAkB,CAClB,SAaF,CAHE,yDACE,iDACF,CAGF,wCAEE,kBAAmB,CACnB,qBAAsB,CAFtB,YAAa,CAOb,aAAc,CADd,4BAAuB,CADvB,gBAAiB,CADjB,mCAIF","file":"Timeline-ff81db92.css","sourcesContent":[".Timeline {\n display: flex;\n flex-direction: column;\n list-style: none;\n padding: 0;\n margin: 0;\n\n &:where([data-clip-sidebar='start']),\n &:where([data-clip-sidebar='both']) {\n .TimelineItem:first-child {\n padding-top: 0;\n\n .TimelineItemAvatar {\n /* No padding-top on first item: badge center is at 0 + 16px (half-badge) */\n top: var(--base-size-16);\n }\n\n &:where([data-condensed])::before {\n top: var(--base-size-12);\n }\n\n &:where([data-condensed]) .TimelineItemAvatar {\n /* No padding-top + condensed: badge center is at 0 + 8px margin + 8px half-badge */\n top: calc(var(--base-size-8) + var(--base-size-8));\n }\n }\n }\n\n &:where([data-clip-sidebar='end']),\n &:where([data-clip-sidebar='both']) {\n .TimelineItem:last-child {\n padding-bottom: 0;\n\n &:where([data-condensed])::before {\n height: var(--base-size-12);\n }\n }\n }\n}\n\n.TimelineItem {\n position: relative;\n display: flex;\n padding: var(--base-size-16) 0;\n margin-left: var(--base-size-16);\n\n &::before {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: 2px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-muted);\n }\n\n &:where([data-condensed]) {\n padding-top: var(--base-size-4);\n padding-bottom: 0;\n\n &:last-child {\n padding-bottom: var(--base-size-16);\n }\n\n .TimelineBadge {\n height: 16px;\n margin-top: var(--base-size-8);\n margin-bottom: var(--base-size-8);\n color: var(--fgColor-muted);\n background-color: var(--bgColor-default);\n border: 0;\n }\n\n .TimelineItemAvatar {\n /* Vertically center against the condensed badge (4px padding-top + 8px badge top margin + 8px half-badge) */\n top: calc(var(--base-size-4) + var(--base-size-8) + var(--base-size-8));\n }\n }\n}\n\n.TimelineItemAvatar {\n position: absolute;\n /* Place avatar in the left gutter, aligned with surrounding actor avatars (~72px from item content) */\n left: calc(-1 * (var(--base-size-40) + var(--base-size-32)));\n /* Vertically center against the default badge (16px padding-top + 16px half-badge) */\n top: calc(var(--base-size-16) + var(--base-size-16));\n z-index: 1;\n transform: translateY(-50%);\n}\n\n.TimelineBadgeWrapper {\n position: relative;\n z-index: 1;\n}\n\n.TimelineBadge {\n display: flex;\n width: 32px;\n height: 32px;\n margin-right: var(--base-size-8);\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -15px;\n flex-shrink: 0;\n overflow: hidden;\n color: var(--fgColor-muted);\n\n /* TODOl not quite sure if this is the correct migration for this line */\n background-color: var(--timelineBadge-bgColor);\n /* stylelint-disable-next-line primer/colors */\n border-color: var(--bgColor-default);\n border-style: solid;\n border-width: var(--borderWidth-thick);\n border-radius: 50%;\n align-items: center;\n justify-content: center;\n\n &:where([data-variant]) {\n color: var(--fgColor-onEmphasis);\n }\n\n &:where([data-variant='accent']) {\n background-color: var(--bgColor-accent-emphasis);\n }\n\n &:where([data-variant='success']) {\n background-color: var(--bgColor-success-emphasis);\n }\n\n &:where([data-variant='attention']) {\n background-color: var(--bgColor-attention-emphasis);\n }\n\n &:where([data-variant='severe']) {\n background-color: var(--bgColor-severe-emphasis);\n }\n\n &:where([data-variant='danger']) {\n background-color: var(--bgColor-danger-emphasis);\n }\n\n &:where([data-variant='done']) {\n background-color: var(--bgColor-done-emphasis);\n }\n\n &:where([data-variant='open']) {\n background-color: var(--bgColor-open-emphasis);\n }\n\n &:where([data-variant='closed']) {\n background-color: var(--bgColor-closed-emphasis);\n }\n\n &:where([data-variant='sponsors']) {\n background-color: var(--bgColor-sponsors-emphasis);\n }\n}\n\n.TimelineBody {\n min-width: 0;\n max-width: 100%;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: calc(var(--base-size-4) + 1px);\n font-size: var(--text-body-size-medium);\n color: var(--fgColor-muted);\n flex: auto;\n}\n\n.TimelineBreak {\n position: relative;\n z-index: 1;\n height: var(--base-size-24);\n margin: 0;\n margin-bottom: calc(-1 * var(--base-size-16));\n margin-left: 0;\n background-color: var(--bgColor-default);\n border: 0;\n border-top: var(--borderWidth-thicker) solid var(--borderColor-default);\n\n /* stylelint-disable-next-line selector-pseudo-class-disallowed-list -- scoped to CSS Module, audited (github/github-ui#17224) */\n &:has(+ [data-condensed]) {\n margin-bottom: calc(-1 * var(--base-size-12));\n }\n}\n\n.TimelineItemActions {\n display: flex;\n align-items: center;\n align-self: flex-start;\n /* Match the badge wrapper height (32px in both default and condensed) so contents vertically center against the badge */\n min-height: var(--base-size-32);\n margin-left: auto;\n gap: var(--base-size-8);\n flex-shrink: 0;\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
3
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
4
5
|
import { warning } from "../utils/warning.js";
|
|
6
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
7
|
import { invariant } from "../utils/invariant.js";
|
|
6
8
|
import Tooltip_module_css_default from "./Tooltip.module.css.js";
|
|
7
9
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -80,7 +82,12 @@ const emptyKeybindingHints = [];
|
|
|
80
82
|
const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
|
|
81
83
|
const tooltipId = useId$1(id);
|
|
82
84
|
const child = Children.only(children);
|
|
83
|
-
const
|
|
85
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
86
|
+
const triggerRef = useRef(null);
|
|
87
|
+
const mergedTriggerRef = useMergedRefs(triggerRef, forwardedRef);
|
|
88
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
89
|
+
const readTriggerRef = mergedRefEnabled ? triggerRef : providedOrCreatedRef;
|
|
90
|
+
const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
|
|
84
91
|
const tooltipElRef = useRef(null);
|
|
85
92
|
const [calculatedDirection, setCalculatedDirection] = useState(direction);
|
|
86
93
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
@@ -88,9 +95,9 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
88
95
|
const { safeSetTimeout, safeClearTimeout } = useSafeTimeout();
|
|
89
96
|
const openTooltip = () => {
|
|
90
97
|
try {
|
|
91
|
-
if (tooltipElRef.current &&
|
|
98
|
+
if (tooltipElRef.current && readTriggerRef.current && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
|
|
92
99
|
const tooltip = tooltipElRef.current;
|
|
93
|
-
const trigger =
|
|
100
|
+
const trigger = readTriggerRef.current;
|
|
94
101
|
tooltip.showPopover();
|
|
95
102
|
setIsPopoverOpen(true);
|
|
96
103
|
const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, {
|
|
@@ -112,7 +119,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
112
119
|
openTimeoutRef.current = null;
|
|
113
120
|
}
|
|
114
121
|
try {
|
|
115
|
-
if (tooltipElRef.current &&
|
|
122
|
+
if (tooltipElRef.current && readTriggerRef.current && tooltipElRef.current.hasAttribute("popover") && tooltipElRef.current.matches(":popover-open")) {
|
|
116
123
|
tooltipElRef.current.hidePopover();
|
|
117
124
|
setIsPopoverOpen(false);
|
|
118
125
|
} else setIsPopoverOpen(false);
|
|
@@ -122,16 +129,16 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
122
129
|
};
|
|
123
130
|
const value = useMemo(() => ({ tooltipId }), [tooltipId]);
|
|
124
131
|
useEffect(() => {
|
|
125
|
-
if (!tooltipElRef.current || !
|
|
126
|
-
const isTriggerInteractive = isInteractive(
|
|
127
|
-
const triggerChildren =
|
|
132
|
+
if (!tooltipElRef.current || !readTriggerRef.current) return;
|
|
133
|
+
const isTriggerInteractive = isInteractive(readTriggerRef.current);
|
|
134
|
+
const triggerChildren = readTriggerRef.current.childNodes;
|
|
128
135
|
const hasInteractiveDescendant = Array.from(triggerChildren).some((child) => {
|
|
129
136
|
return child instanceof HTMLElement && isInteractive(child) || Array.from(child.childNodes).some((grandChild) => grandChild instanceof HTMLElement && isInteractive(grandChild));
|
|
130
137
|
});
|
|
131
138
|
!(isTriggerInteractive || hasInteractiveDescendant) && invariant(false, "The `Tooltip` component expects a single React element that contains interactive content. Consider using a `<button>` or equivalent interactive element instead.");
|
|
132
139
|
if (type === "label") {
|
|
133
|
-
const hasAriaLabel =
|
|
134
|
-
const hasAriaLabelInChildren = Array.from(
|
|
140
|
+
const hasAriaLabel = readTriggerRef.current.hasAttribute("aria-label");
|
|
141
|
+
const hasAriaLabelInChildren = Array.from(readTriggerRef.current.childNodes).some((child) => child instanceof HTMLElement && child.hasAttribute("aria-label"));
|
|
135
142
|
warning(hasAriaLabel || hasAriaLabelInChildren, "The label type `Tooltip` is going to be used here to label the trigger element. Please remove the aria-label from the trigger element.");
|
|
136
143
|
}
|
|
137
144
|
if (typeof window !== "undefined") {
|
|
@@ -140,7 +147,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
140
147
|
tooltipElRef.current.setAttribute("popover", "auto");
|
|
141
148
|
}, [
|
|
142
149
|
tooltipElRef,
|
|
143
|
-
|
|
150
|
+
readTriggerRef,
|
|
144
151
|
direction,
|
|
145
152
|
type
|
|
146
153
|
]);
|
|
@@ -157,7 +164,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
157
164
|
return /*#__PURE__*/ jsx(TooltipContext.Provider, {
|
|
158
165
|
value,
|
|
159
166
|
children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
|
|
160
|
-
ref:
|
|
167
|
+
ref: appliedTriggerRef,
|
|
161
168
|
"aria-describedby": (() => {
|
|
162
169
|
if (type !== "description") return child.props["aria-describedby"];
|
|
163
170
|
const existingDescribedBy = child.props["aria-describedby"];
|
|
@@ -184,13 +191,12 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
184
191
|
(_child$props$onFocus = (_child$props3 = child.props).onFocus) === null || _child$props$onFocus === void 0 || _child$props$onFocus.call(_child$props3, event);
|
|
185
192
|
},
|
|
186
193
|
onMouseOverCapture: (event) => {
|
|
187
|
-
const delayTime = delayTimeMap[delay] || 50;
|
|
188
194
|
openTimeoutRef.current = safeSetTimeout(() => {
|
|
189
195
|
var _child$props$onMouseE, _child$props4;
|
|
190
196
|
if (!openTimeoutRef.current) return;
|
|
191
197
|
openTooltip();
|
|
192
198
|
(_child$props$onMouseE = (_child$props4 = child.props).onMouseEnter) === null || _child$props$onMouseE === void 0 || _child$props$onMouseE.call(_child$props4, event);
|
|
193
|
-
},
|
|
199
|
+
}, delayTimeMap[delay] || 50);
|
|
194
200
|
},
|
|
195
201
|
onMouseLeave: (event) => {
|
|
196
202
|
var _child$props$onMouseL, _child$props5;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
2
|
-
import { isSlot } from "../utils/is-slot.js";
|
|
3
|
-
import { useSlots } from "../hooks/useSlots.js";
|
|
4
2
|
import Spinner from "../Spinner/Spinner.js";
|
|
5
3
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
6
4
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
@@ -12,6 +10,8 @@ import useSafeTimeout from "../hooks/useSafeTimeout.js";
|
|
|
12
10
|
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
13
11
|
import { IconButton } from "../Button/IconButton.js";
|
|
14
12
|
import { ButtonComponent } from "../Button/Button.js";
|
|
13
|
+
import { isSlot } from "../utils/is-slot.js";
|
|
14
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
15
15
|
import { Dialog } from "../Dialog/Dialog.js";
|
|
16
16
|
import { ConfirmationDialog } from "../ConfirmationDialog/ConfirmationDialog.js";
|
|
17
17
|
import { ActionList } from "../ActionList/index.js";
|
|
@@ -349,10 +349,7 @@ const SubTree = ({ count, state, children, "aria-label": ariaLabel }) => {
|
|
|
349
349
|
});
|
|
350
350
|
setLoadingFocused(false);
|
|
351
351
|
}
|
|
352
|
-
} else if (state === "loading") {
|
|
353
|
-
const parentName = getAccessibleName(parentElement);
|
|
354
|
-
announceUpdate(`${parentName} content loading`);
|
|
355
|
-
}
|
|
352
|
+
} else if (state === "loading") announceUpdate(`${getAccessibleName(parentElement)} content loading`);
|
|
356
353
|
}, [
|
|
357
354
|
loadingFocused,
|
|
358
355
|
previousState,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useProvidedRefOrCreate } from "../../hooks/useProvidedRefOrCreate.js";
|
|
2
2
|
import { useAnchoredPosition } from "../../hooks/useAnchoredPosition.js";
|
|
3
3
|
import { useId as useId$1 } from "../../hooks/useId.js";
|
|
4
|
-
import { isSlot } from "../../utils/is-slot.js";
|
|
5
|
-
import { useSlots } from "../../hooks/useSlots.js";
|
|
6
4
|
import Spinner from "../../Spinner/Spinner.js";
|
|
7
5
|
import { AriaStatus } from "../../live-region/AriaStatus.js";
|
|
8
6
|
import { invariant } from "../../utils/invariant.js";
|
|
9
7
|
import { IconButton } from "../../Button/IconButton.js";
|
|
10
8
|
import { ButtonComponent } from "../../Button/Button.js";
|
|
11
9
|
import { useResponsiveValue } from "../../hooks/useResponsiveValue.js";
|
|
10
|
+
import { isSlot } from "../../utils/is-slot.js";
|
|
11
|
+
import { useSlots } from "../../hooks/useSlots.js";
|
|
12
12
|
import { ActionListContainerContext } from "../../ActionList/ActionListContainerContext.js";
|
|
13
13
|
import Heading from "../../Heading/Heading.js";
|
|
14
14
|
import Link from "../../Link/Link.js";
|
|
@@ -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.Ref<T | null>;
|
|
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.Ref<T | null>;
|
|
85
85
|
role: 'tablist';
|
|
86
86
|
};
|
|
87
87
|
};
|
|
@@ -1,14 +1,22 @@
|
|
|
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 { c } from "react-compiler-runtime";
|
|
5
|
+
import { useRef } from "react";
|
|
3
6
|
//#region src/experimental/Tabs/useTabList.ts
|
|
4
7
|
function useTabList(props) {
|
|
5
8
|
const $ = c(9);
|
|
6
9
|
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-orientation": ariaOrientation } = props;
|
|
7
|
-
const
|
|
10
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
11
|
+
const tabListRef = useRef(null);
|
|
12
|
+
const mergedRef = useMergedRefs(tabListRef, props.ref);
|
|
13
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(props.ref);
|
|
14
|
+
const readRef = mergedRefEnabled ? tabListRef : providedOrCreatedRef;
|
|
15
|
+
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
8
16
|
let t0;
|
|
9
|
-
if ($[0] !== ariaOrientation || $[1] !==
|
|
17
|
+
if ($[0] !== ariaOrientation || $[1] !== readRef) {
|
|
10
18
|
t0 = (event) => {
|
|
11
|
-
const { current: tablist } =
|
|
19
|
+
const { current: tablist } = readRef;
|
|
12
20
|
if (tablist === null) return;
|
|
13
21
|
const tabs = getFocusableTabs(tablist);
|
|
14
22
|
const isVertical = ariaOrientation === "vertical";
|
|
@@ -33,25 +41,25 @@ function useTabList(props) {
|
|
|
33
41
|
}
|
|
34
42
|
};
|
|
35
43
|
$[0] = ariaOrientation;
|
|
36
|
-
$[1] =
|
|
44
|
+
$[1] = readRef;
|
|
37
45
|
$[2] = t0;
|
|
38
46
|
} else t0 = $[2];
|
|
39
47
|
const onKeyDown = t0;
|
|
40
48
|
const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
|
|
41
49
|
let t2;
|
|
42
|
-
if ($[3] !==
|
|
50
|
+
if ($[3] !== appliedRef || $[4] !== ariaLabel || $[5] !== ariaLabelledby || $[6] !== onKeyDown || $[7] !== t1) {
|
|
43
51
|
t2 = { tabListProps: {
|
|
44
|
-
ref,
|
|
52
|
+
ref: appliedRef,
|
|
45
53
|
"aria-label": ariaLabel,
|
|
46
54
|
"aria-labelledby": ariaLabelledby,
|
|
47
55
|
"aria-orientation": t1,
|
|
48
56
|
role: "tablist",
|
|
49
57
|
onKeyDown
|
|
50
58
|
} };
|
|
51
|
-
$[3] =
|
|
52
|
-
$[4] =
|
|
53
|
-
$[5] =
|
|
54
|
-
$[6] =
|
|
59
|
+
$[3] = appliedRef;
|
|
60
|
+
$[4] = ariaLabel;
|
|
61
|
+
$[5] = ariaLabelledby;
|
|
62
|
+
$[6] = onKeyDown;
|
|
55
63
|
$[7] = t1;
|
|
56
64
|
$[8] = t2;
|
|
57
65
|
} else t2 = $[8];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import useIsomorphicLayoutEffect from "../../utils/useIsomorphicLayoutEffect.js";
|
|
2
2
|
import { useResizeObserver } from "../../hooks/useResizeObserver.js";
|
|
3
3
|
import { useId as useId$1 } from "../../hooks/useId.js";
|
|
4
|
-
import { isSlot } from "../../utils/is-slot.js";
|
|
5
4
|
import { invariant } from "../../utils/invariant.js";
|
|
5
|
+
import { isSlot } from "../../utils/is-slot.js";
|
|
6
6
|
import { createComponent } from "../../utils/create-component.js";
|
|
7
7
|
import { UnderlineItem, UnderlineItemList, UnderlineWrapper } from "../../internal/components/UnderlineTabbedInterface.js";
|
|
8
8
|
import UnderlinePanels_module_css_default from "./UnderlinePanels.module.css.js";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useSlots } from "../hooks/useSlots.js";
|
|
3
2
|
import { Announce } from "../live-region/Announce.js";
|
|
4
3
|
import { AriaAlert } from "../live-region/AriaAlert.js";
|
|
5
4
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
6
5
|
import { ButtonBase } from "../Button/ButtonBase.js";
|
|
6
|
+
import { DefaultFeatureFlags } from "../FeatureFlags/DefaultFeatureFlags.js";
|
|
7
|
+
import { FeatureFlags } from "../FeatureFlags/FeatureFlags.js";
|
|
8
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
7
9
|
import { KeybindingHint } from "../KeybindingHint/KeybindingHint.js";
|
|
8
10
|
import { getAccessibleKeybindingHintString } from "../KeybindingHint/utils.js";
|
|
9
11
|
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
12
|
+
import { useSlots } from "../hooks/useSlots.js";
|
|
10
13
|
import { useOverflow } from "../hooks/useOverflow.js";
|
|
11
14
|
import { ScrollableRegion } from "../ScrollableRegion/ScrollableRegion.js";
|
|
12
15
|
import { Dialog } from "../Dialog/Dialog.js";
|
|
13
|
-
import { DefaultFeatureFlags } from "../FeatureFlags/DefaultFeatureFlags.js";
|
|
14
|
-
import { FeatureFlags } from "../FeatureFlags/FeatureFlags.js";
|
|
15
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
16
16
|
import { Stack } from "../Stack/index.js";
|
|
17
17
|
import { SkeletonBox } from "../Skeleton/SkeletonBox.js";
|
|
18
18
|
import { FilteredActionListLoadingTypes } from "../FilteredActionList/constants.js";
|
|
@@ -106,10 +106,6 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
106
106
|
}, [updatePosition]);
|
|
107
107
|
useResizeObserver(updatePosition, void 0, [], enabled);
|
|
108
108
|
useResizeObserver(updatePosition, floatingElementRef, [], enabled);
|
|
109
|
-
const scrollAncestorsCacheRef = React.useRef({
|
|
110
|
-
anchor: null,
|
|
111
|
-
scrollables: []
|
|
112
|
-
});
|
|
113
109
|
React.useEffect(() => {
|
|
114
110
|
if (!enabled) return;
|
|
115
111
|
const anchorEl = anchorElementRef.current;
|
|
@@ -122,16 +118,7 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
|
122
118
|
updatePosition();
|
|
123
119
|
});
|
|
124
120
|
};
|
|
125
|
-
const
|
|
126
|
-
let scrollables;
|
|
127
|
-
if (cache.anchor === anchorEl) scrollables = cache.scrollables;
|
|
128
|
-
else {
|
|
129
|
-
scrollables = getScrollableAncestors(anchorEl);
|
|
130
|
-
scrollAncestorsCacheRef.current = {
|
|
131
|
-
anchor: anchorEl,
|
|
132
|
-
scrollables
|
|
133
|
-
};
|
|
134
|
-
}
|
|
121
|
+
const scrollables = getScrollableAncestors(anchorEl);
|
|
135
122
|
for (const scrollable of scrollables) scrollable.addEventListener("scroll", handleScroll);
|
|
136
123
|
return () => {
|
|
137
124
|
for (const scrollable of scrollables) scrollable.removeEventListener("scroll", handleScroll);
|
package/dist/hooks/useDialog.js
CHANGED
|
@@ -91,8 +91,7 @@ function useDialog(t0) {
|
|
|
91
91
|
let t8;
|
|
92
92
|
if ($[15] !== getFocusableItem) {
|
|
93
93
|
t8 = (e_1) => {
|
|
94
|
-
const
|
|
95
|
-
const focusableItem_0 = getFocusableItem(e_1, movement_0);
|
|
94
|
+
const focusableItem_0 = getFocusableItem(e_1, e_1.shiftKey ? -1 : 1);
|
|
96
95
|
if (!focusableItem_0) return;
|
|
97
96
|
focusableItem_0.focus();
|
|
98
97
|
};
|
|
@@ -17,18 +17,18 @@ import { ForwardedRef, Ref } from "react";
|
|
|
17
17
|
* // React 18
|
|
18
18
|
* const Example = forwardRef<HTMLButtonElement, {}>((props, forwardedRef) => {
|
|
19
19
|
* const ref = useRef<HTMLButtonElement>(null)
|
|
20
|
-
* const
|
|
20
|
+
* const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
21
21
|
*
|
|
22
|
-
* return <button ref={
|
|
22
|
+
* return <button ref={mergedRef} />
|
|
23
23
|
* })
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* // React 19
|
|
27
27
|
* const Example = ({ref: externalRef}: {ref?: Ref<HTMLButtonElement>}) => {
|
|
28
28
|
* const ref = useRef<HTMLButtonElement>(null)
|
|
29
|
-
* const
|
|
29
|
+
* const mergedRef = useMergedRefs(externalRef, ref)
|
|
30
30
|
*
|
|
31
|
-
* return <button ref={
|
|
31
|
+
* return <button ref={mergedRef} />
|
|
32
32
|
* }
|
|
33
33
|
*/
|
|
34
34
|
declare function useMergedRefs<T>(refA: Ref$1<T | null>, refB: Ref$1<T | null>): (value: T | null) => (() => void) | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isExperimentalReactVersion, reactMajorVersion } from "../utils/environment.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import "react";
|
|
3
|
+
import { version } from "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);
|
|
5
7
|
/**
|
|
6
8
|
* Cleanup functions for refs were introduced in React 19. For feature detection,
|
|
7
9
|
* we look to see if current version of React is >= 19 or if it is an
|
|
@@ -26,18 +28,18 @@ const supportsRefCleanup = reactMajorVersion >= 19 || isExperimentalReactVersion
|
|
|
26
28
|
* // React 18
|
|
27
29
|
* const Example = forwardRef<HTMLButtonElement, {}>((props, forwardedRef) => {
|
|
28
30
|
* const ref = useRef<HTMLButtonElement>(null)
|
|
29
|
-
* const
|
|
31
|
+
* const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
30
32
|
*
|
|
31
|
-
* return <button ref={
|
|
33
|
+
* return <button ref={mergedRef} />
|
|
32
34
|
* })
|
|
33
35
|
*
|
|
34
36
|
* @example
|
|
35
37
|
* // React 19
|
|
36
38
|
* const Example = ({ref: externalRef}: {ref?: Ref<HTMLButtonElement>}) => {
|
|
37
39
|
* const ref = useRef<HTMLButtonElement>(null)
|
|
38
|
-
* const
|
|
40
|
+
* const mergedRef = useMergedRefs(externalRef, ref)
|
|
39
41
|
*
|
|
40
|
-
* return <button ref={
|
|
42
|
+
* return <button ref={mergedRef} />
|
|
41
43
|
* }
|
|
42
44
|
*/
|
|
43
45
|
function useMergedRefs(refA, refB) {
|
|
@@ -48,6 +50,7 @@ function useMergedRefs(refA, refB) {
|
|
|
48
50
|
const cleanupA = setRef(refA, value);
|
|
49
51
|
const cleanupB = setRef(refB, value);
|
|
50
52
|
if (!supportsRefCleanup) return;
|
|
53
|
+
if (majorReactVersion <= 18) return;
|
|
51
54
|
return () => {
|
|
52
55
|
if (cleanupA) cleanupA();
|
|
53
56
|
else setRef(refA, null);
|
|
@@ -9,17 +9,14 @@ 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
|
-
*
|
|
12
|
+
* @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
|
|
13
|
+
* In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
|
|
14
|
+
* {@linkcode useMergedRefs} instead.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - return <div ref={ref} />
|
|
21
|
-
* + return <div ref={mergedRef} />
|
|
22
|
-
* ```
|
|
16
|
+
* The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
|
|
17
|
+
* element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
|
|
18
|
+
* consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
|
|
19
|
+
* internal element.
|
|
23
20
|
*/
|
|
24
21
|
declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
|
|
25
22
|
//#endregion
|
|
@@ -8,17 +8,14 @@ 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
|
-
*
|
|
11
|
+
* @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
|
|
12
|
+
* In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
|
|
13
|
+
* {@linkcode useMergedRefs} instead.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - return <div ref={ref} />
|
|
20
|
-
* + return <div ref={mergedRef} />
|
|
21
|
-
* ```
|
|
15
|
+
* The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
|
|
16
|
+
* element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
|
|
17
|
+
* consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
|
|
18
|
+
* internal element.
|
|
22
19
|
*/
|
|
23
20
|
function useProvidedRefOrCreate(providedRef) {
|
|
24
21
|
const createdRef = React.useRef(null);
|
|
@@ -15,8 +15,7 @@ function useScrollFlash(scrollContainerRef) {
|
|
|
15
15
|
if (!scrollContainer) return;
|
|
16
16
|
const id = requestAnimationFrame(() => {
|
|
17
17
|
const currentScroll = scrollContainer.scrollTop;
|
|
18
|
-
|
|
19
|
-
scrollContainer.scrollTop = altScroll;
|
|
18
|
+
scrollContainer.scrollTop = currentScroll < 1 ? currentScroll + 1 : currentScroll - 1;
|
|
20
19
|
scrollContainer.scrollTop = currentScroll;
|
|
21
20
|
});
|
|
22
21
|
return () => cancelAnimationFrame(id);
|
package/dist/index.d.ts
CHANGED
|
@@ -16,9 +16,7 @@ import { LinkButton, LinkButtonProps } from "./Button/LinkButton.js";
|
|
|
16
16
|
import { ButtonComponent } from "./Button/Button.js";
|
|
17
17
|
import { ButtonBase } from "./Button/ButtonBase.js";
|
|
18
18
|
import { ResponsiveValue, useResponsiveValue } from "./hooks/useResponsiveValue.js";
|
|
19
|
-
import { CustomWidthOptions, PaneWidth, PaneWidthValue, UsePaneWidthOptions, UsePaneWidthResult, defaultPaneWidth, usePaneWidth } from "./PageLayout/usePaneWidth.js";
|
|
20
19
|
import { PageLayout, PageLayoutContentProps, PageLayoutFooterProps, PageLayoutHeaderProps, PageLayoutPaneProps, PageLayoutProps } from "./PageLayout/PageLayout.js";
|
|
21
|
-
import { DragHandle, DragHandleProps } from "./PageLayout/DragHandle.js";
|
|
22
20
|
import { SplitPageLayout, SplitPageLayoutContentProps, SplitPageLayoutFooterProps, SplitPageLayoutHeaderProps, SplitPageLayoutPaneProps, SplitPageLayoutProps } from "./SplitPageLayout/SplitPageLayout.js";
|
|
23
21
|
import useDetails from "./hooks/useDetails.js";
|
|
24
22
|
import useSafeTimeout from "./hooks/useSafeTimeout.js";
|
|
@@ -119,4 +117,4 @@ import { ActionsProps, ChildrenPropTypes, PageHeader, PageHeaderProps, TitleArea
|
|
|
119
117
|
import { SkeletonBox, SkeletonBoxProps } from "./Skeleton/SkeletonBox.js";
|
|
120
118
|
import { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps } from "./ActionMenu/ActionMenu.js";
|
|
121
119
|
import Overlay, { OverlayProps } from "./Overlay/Overlay.js";
|
|
122
|
-
export { ActionBar, type ActionBarProps, ActionList, type ActionListDescriptionProps, type ActionListDividerProps, type ActionListGroupHeadingProps, type ActionListGroupHeadingTrailingActionProps, type ActionListGroupProps, type ActionListItemProps, type ActionListLeadingVisualProps, type ActionListLinkItemProps, type ActionListProps, type ActionListTrailingActionProps, type ActionListTrailingVisualProps, ActionMenu, type ActionMenuAnchorProps, type ActionMenuButtonProps, type ActionMenuProps, AnchoredOverlay, type AnchoredOverlayProps, type AnchoredPositionHookSettings, _default as Autocomplete, type AutocompleteInputProps, type AutocompleteMenuProps, type AutocompleteOverlayProps, Avatar, type AvatarProps, AvatarStack, type AvatarStackProps, Banner, type BannerProps, BaseStyles, type BaseStylesProps, _default$1 as BranchName, type BranchNameProps, Breadcrumb, type BreadcrumbItemProps, type BreadcrumbProps, _default$2 as Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, ButtonComponent as Button, ButtonBase, type ButtonBaseProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, _default$3 as Checkbox, _default$4 as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _default$5 as CircleBadge, type CircleBadgeIconProps, type CircleBadgeProps, ConfirmationDialog, type ConfirmationDialogProps, CounterLabel, type CounterLabelProps,
|
|
120
|
+
export { ActionBar, type ActionBarProps, ActionList, type ActionListDescriptionProps, type ActionListDividerProps, type ActionListGroupHeadingProps, type ActionListGroupHeadingTrailingActionProps, type ActionListGroupProps, type ActionListItemProps, type ActionListLeadingVisualProps, type ActionListLinkItemProps, type ActionListProps, type ActionListTrailingActionProps, type ActionListTrailingVisualProps, ActionMenu, type ActionMenuAnchorProps, type ActionMenuButtonProps, type ActionMenuProps, AnchoredOverlay, type AnchoredOverlayProps, type AnchoredPositionHookSettings, _default as Autocomplete, type AutocompleteInputProps, type AutocompleteMenuProps, type AutocompleteOverlayProps, Avatar, type AvatarProps, AvatarStack, type AvatarStackProps, Banner, type BannerProps, BaseStyles, type BaseStylesProps, _default$1 as BranchName, type BranchNameProps, Breadcrumb, type BreadcrumbItemProps, type BreadcrumbProps, _default$2 as Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, ButtonComponent as Button, ButtonBase, type ButtonBaseProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, _default$3 as Checkbox, _default$4 as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _default$5 as CircleBadge, type CircleBadgeIconProps, type CircleBadgeProps, ConfirmationDialog, type ConfirmationDialogProps, CounterLabel, type CounterLabelProps, Details, type DetailsProps, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, type FCWithSlotMarker, Flash, type FlashProps, FocusKeys, type FocusTrapHookSettings, type FocusZoneHookSettings, _default$6 as FormControl, type FormControlCaptionProps, type Props as FormControlLabelProps, type FormControlProps, type FormControlValidationProps, _default$7 as Header, type HeaderItemProps, type HeaderLinkProps, type HeaderProps, Heading, type HeadingProps, IconButton, type IconButtonProps, IssueLabelToken, type IssueLabelTokenProps, Label, type LabelColorOptions, LabelGroup, type LabelGroupProps, type LabelProps, Link, LinkButton, type LinkButtonProps, type LinkProps, NavList, type NavListDividerProps, type NavListGroupHeadingProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, Overlay, type OverlayProps, PageHeader, type ActionsProps as PageHeaderActionsProps, type ChildrenPropTypes as PageHeaderChildrenPropTypes, type PageHeaderProps, type TitleAreaProps as PageHeaderTitleAreaProps, type TitleProps as PageHeaderTitleProps, PageLayout, type PageLayoutContentProps, type PageLayoutFooterProps, type PageLayoutHeaderProps, type PageLayoutPaneProps, type PageLayoutProps, Pagination, type PaginationProps, _default$8 as Popover, type PopoverContentProps, type PopoverProps, Portal, PortalContext, type PortalProps, ProgressBar, type ProgressBarItemProps, type ProgressBarProps, _default$9 as Radio, _default$10 as RadioGroup, type RadioGroupProps, type RadioProps, RelativeTime, type RelativeTimeProps, type ResponsiveValue, SegmentedControl, type SegmentedControlButtonProps, type SegmentedControlIconButtonProps, type SegmentedControlProps, _default$11 as Select, SelectPanel, type GroupedListProps as SelectPanelGroupedListProps, type ItemInput as SelectPanelItemInput, type FilteredActionListItemProps as SelectPanelItemProps, type SelectPanelProps, type SelectProps, _default$12 as SideNav, type SideNavLinkProps, type SideNavProps, SkeletonBox, type SkeletonBoxProps, type SlotMarker, Spinner, type SpinnerProps, SplitPageLayout, type SplitPageLayoutContentProps, type SplitPageLayoutFooterProps, type SplitPageLayoutHeaderProps, type SplitPageLayoutPaneProps, type SplitPageLayoutProps, Stack, type StackItemProps, type StackProps, StateLabel, type StateLabelProps, _default$13 as SubNav, type SubNavLinkProps, type SubNavLinksProps, type SubNavProps, _default$14 as Text, _default$15 as TextInput, type TextInputActionProps, type TextInputProps, _default$16 as TextInputWithTokens, type TextInputWithTokensProps, type TextProps, _default$17 as Textarea, type TextareaProps, type ThemeColorPaths, ThemeProvider, type ThemeProviderProps, type ThemeShadowPaths, _default$18 as Timeline, type TimelineActionsProps, type TimelineAvatarProps, type TimelineBadgeProps, type TimelineBadgeVariant, type TimelineBodyProps, type TimelineBreakProps, type TimelineItemProps, type TimelineItemsProps, type TimelineProps, ToggleSwitch, type ToggleSwitchProps, Token, type TokenProps, Tooltip, type TooltipProps, type TouchOrMouseEvent, TreeView, type TreeViewErrorDialogProps, type TreeViewItemProps, type TreeViewProps, type TreeViewSubTreeProps, type TreeViewVisualProps, Truncate, type TruncateProps, UnderlineNav, type UnderlineNavItemProps, type UnderlineNavProps, VisuallyHidden, type VisuallyHiddenProps, type WithSlotMarker, asSlot, createComponent, isSlot, registerPortalRoot, theme, useAnchoredPosition, useColorSchemeVar, useConfirm, useDetails, useFocusTrap, useFocusZone, useFormControlForwardedProps, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnEscapePress, useOnOutsideClick, useOpenAndCloseFocus, useOverlay, useProvidedRefOrCreate, useRefObjectAsForwardedRef, useResizeObserver, useResponsiveValue, useRovingTabIndex, useSafeTimeout, useSlots, useSyncedState, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -9,15 +9,12 @@ import { VisuallyHidden } from "./VisuallyHidden/VisuallyHidden.js";
|
|
|
9
9
|
import { useOnOutsideClick } from "./hooks/useOnOutsideClick.js";
|
|
10
10
|
import { useProvidedRefOrCreate } from "./hooks/useProvidedRefOrCreate.js";
|
|
11
11
|
import { useOnEscapePress } from "./hooks/useOnEscapePress.js";
|
|
12
|
-
import { useOpenAndCloseFocus } from "./hooks/useOpenAndCloseFocus.js";
|
|
13
12
|
import useIsomorphicLayoutEffect from "./utils/useIsomorphicLayoutEffect.js";
|
|
14
13
|
import { useResizeObserver } from "./hooks/useResizeObserver.js";
|
|
15
14
|
import { useAnchoredPosition } from "./hooks/useAnchoredPosition.js";
|
|
15
|
+
import { useOpenAndCloseFocus } from "./hooks/useOpenAndCloseFocus.js";
|
|
16
16
|
import { useOverlay } from "./hooks/useOverlay.js";
|
|
17
|
-
import { useRefObjectAsForwardedRef } from "./hooks/useRefObjectAsForwardedRef.js";
|
|
18
17
|
import { useId } from "./hooks/useId.js";
|
|
19
|
-
import { isSlot } from "./utils/is-slot.js";
|
|
20
|
-
import { useSlots } from "./hooks/useSlots.js";
|
|
21
18
|
import Spinner from "./Spinner/Spinner.js";
|
|
22
19
|
import CounterLabel from "./CounterLabel/CounterLabel.js";
|
|
23
20
|
import { ButtonBase } from "./Button/ButtonBase.js";
|
|
@@ -28,8 +25,8 @@ import { IconButton } from "./Button/IconButton.js";
|
|
|
28
25
|
import { LinkButton } from "./Button/LinkButton.js";
|
|
29
26
|
import { ButtonComponent } from "./Button/Button.js";
|
|
30
27
|
import { useResponsiveValue } from "./hooks/useResponsiveValue.js";
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
28
|
+
import { isSlot } from "./utils/is-slot.js";
|
|
29
|
+
import { useSlots } from "./hooks/useSlots.js";
|
|
33
30
|
import { PageLayout } from "./PageLayout/PageLayout.js";
|
|
34
31
|
import { SplitPageLayout } from "./SplitPageLayout/SplitPageLayout.js";
|
|
35
32
|
import useDetails from "./hooks/useDetails.js";
|
|
@@ -41,6 +38,7 @@ import Portal_default from "./Portal/index.js";
|
|
|
41
38
|
import { Dialog } from "./Dialog/Dialog.js";
|
|
42
39
|
import { ConfirmationDialog } from "./ConfirmationDialog/ConfirmationDialog.js";
|
|
43
40
|
import { useConfirm } from "./ConfirmationDialog/useConfirm.js";
|
|
41
|
+
import { useRefObjectAsForwardedRef } from "./hooks/useRefObjectAsForwardedRef.js";
|
|
44
42
|
import { createComponent } from "./utils/create-component.js";
|
|
45
43
|
import { asSlot } from "./utils/as-slot.js";
|
|
46
44
|
import Radio from "./Radio/Radio.js";
|
|
@@ -94,4 +92,4 @@ import { TreeView } from "./TreeView/TreeView.js";
|
|
|
94
92
|
import { UnderlineNav } from "./UnderlineNav/index.js";
|
|
95
93
|
import { ActionBar } from "./ActionBar/index.js";
|
|
96
94
|
import { PageHeader } from "./PageHeader/PageHeader.js";
|
|
97
|
-
export { ActionBar, ActionList, ActionMenu, AnchoredOverlay, Autocomplete_default as Autocomplete, Avatar, AvatarStack, Banner, BaseStyles, BranchName_default as BranchName, Breadcrumb, Breadcrumbs_default as Breadcrumbs, ButtonComponent as Button, ButtonBase, ButtonGroup, Checkbox, CheckboxGroup_default as CheckboxGroup, CircleBadge_default as CircleBadge, ConfirmationDialog, CounterLabel, Details, Dialog,
|
|
95
|
+
export { ActionBar, ActionList, ActionMenu, AnchoredOverlay, Autocomplete_default as Autocomplete, Avatar, AvatarStack, Banner, BaseStyles, BranchName_default as BranchName, Breadcrumb, Breadcrumbs_default as Breadcrumbs, ButtonComponent as Button, ButtonBase, ButtonGroup, Checkbox, CheckboxGroup_default as CheckboxGroup, CircleBadge_default as CircleBadge, ConfirmationDialog, CounterLabel, Details, Dialog, Flash, FocusKeys, FormControl_default as FormControl, Header_default as Header, Heading, IconButton, IssueLabelToken, Label_default as Label, LabelGroup, Link, LinkButton, NavList, Overlay, PageHeader, PageLayout, Pagination_default as Pagination, Popover_default as Popover, Portal_default as Portal, PortalContext, ProgressBar, Radio, RadioGroup_default as RadioGroup, RelativeTime, SegmentedControl, Select_default as Select, SelectPanel, SideNav_default as SideNav, SkeletonBox, Spinner, SplitPageLayout, Stack, StateLabel, SubNav_default as SubNav, Text_default as Text, TextInput_default as TextInput, TextInputWithTokens, Textarea, ThemeProvider, Timeline_default as Timeline, ToggleSwitch, Token, Tooltip, TreeView, Truncate, UnderlineNav, VisuallyHidden, asSlot, createComponent, isSlot, registerPortalRoot, theme, useAnchoredPosition, useColorSchemeVar, useConfirm, useDetails, useFocusTrap, useFocusZone, useFormControlForwardedProps, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnEscapePress, useOnOutsideClick, useOpenAndCloseFocus, useOverlay, useProvidedRefOrCreate, useRefObjectAsForwardedRef, useResizeObserver, useResponsiveValue, useRovingTabIndex, useSafeTimeout, useSlots, useSyncedState, useTheme };
|