@primer/react 0.0.0-20261113163104 → 0.0.0-20261113210458

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 CHANGED
@@ -1,12 +1,12 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20261113163104
3
+ ## 0.0.0-20261113210458
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - [#8592](https://github.com/primer/react/pull/8592) [`0ae18d3`](https://github.com/primer/react/commit/0ae18d38f09044c40c1a181288c2783e93629b4e) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Card: Add optional shadows, regular (16px) and spacious (24px) padding in either layout, and heading links and buttons with opt-in full-card hit areas using fullCardHitArea. Existing normal padding and defaults are unchanged.
8
8
 
9
- - [#8749](https://github.com/primer/react/pull/8749) [`ba03cb6`](https://github.com/primer/react/commit/ba03cb6524b86b59b997896b31ca7bcd7b8465fb) Thanks [@adierkens](https://github.com/adierkens)! - Tooltip, ActionMenu: Add custom trigger rendering to compose multiple behaviors on a single interactive element. AnchoredOverlay and SelectPanel expose the anchor ref in the render callback's second argument.
9
+ - [#8749](https://github.com/primer/react/pull/8749) [`ba03cb6`](https://github.com/primer/react/commit/ba03cb6524b86b59b997896b31ca7bcd7b8465fb) Thanks [@adierkens](https://github.com/adierkens)! - ActionMenu, AnchoredOverlay, Tooltip: Add experimental element-based trigger composition through `@primer/react/experimental`, with automatically merged trigger props and refs.
10
10
 
11
11
  - [#8692](https://github.com/primer/react/pull/8692) [`918d7cf`](https://github.com/primer/react/commit/918d7cf82d3884ab134e9b074e0a595198a1c033) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Stack: Add `balance` as a value for the `wrap` prop.
12
12
 
@@ -9,11 +9,6 @@ import { AnchorPosition } from "@primer/behaviors";
9
9
 
10
10
  //#region src/ActionMenu/ActionMenu.d.ts
11
11
  type ActionMenuProps = {
12
- /**
13
- * Render a custom trigger instead of ActionMenu.Button or ActionMenu.Anchor.
14
- * Forward all supplied props, including ref, to a single interactive element.
15
- */
16
- renderAnchor?: (props: ActionMenuAnchorRenderProps) => React.ReactElement;
17
12
  /**
18
13
  * Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with `ActionMenu.Overlay`
19
14
  */
@@ -27,9 +22,6 @@ type ActionMenuProps = {
27
22
  */
28
23
  onOpenChange?: (s: boolean) => void;
29
24
  } & Pick<AnchoredOverlayProps, 'anchorRef'>;
30
- type ActionMenuAnchorRenderProps = Omit<React.HTMLAttributes<HTMLElement>, 'aria-label' | 'aria-labelledby'> & {
31
- ref: React.RefCallback<HTMLElement>;
32
- };
33
25
  type ActionMenuAnchorProps = {
34
26
  children: React.ReactElement<any>;
35
27
  id?: string;
@@ -57,4 +49,4 @@ declare const ActionMenu: React.FC<React.PropsWithChildren<ActionMenuProps>> & S
57
49
  Divider: FCWithSlotMarker<React.PropsWithChildren<ActionListDividerProps>>;
58
50
  };
59
51
  //#endregion
60
- export { ActionMenu, ActionMenuAnchorProps, ActionMenuAnchorRenderProps, ActionMenuButtonProps, ActionMenuProps };
52
+ export { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps };
@@ -5,6 +5,7 @@ import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
5
5
  import { useMenuKeyboardNavigation } from "../hooks/useMenuKeyboardNavigation.js";
6
6
  import { useId as useId$1 } from "../hooks/useId.js";
7
7
  import { isSlot } from "../utils/is-slot.js";
8
+ import { invariant } from "../utils/invariant.js";
8
9
  import { Tooltip } from "../TooltipV2/Tooltip.js";
9
10
  import { ButtonComponent } from "../Button/Button.js";
10
11
  import { useResponsiveValue } from "../hooks/useResponsiveValue.js";
@@ -45,7 +46,7 @@ const mergeAnchorHandlers = (anchorProps, buttonProps) => {
45
46
  if (buttonProps.className) mergedAnchorProps.className = clsx(anchorProps.className, buttonProps.className);
46
47
  return mergedAnchorProps;
47
48
  };
48
- const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children, renderAnchor: customRenderAnchor }) => {
49
+ const ActionMenuImpl = ({ anchorRef: externalAnchorRef, open, onOpenChange, children, renderAnchor: customRenderAnchor }) => {
49
50
  const parentMenuContext = useContext(MenuContext);
50
51
  const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate(open, onOpenChange, false);
51
52
  const onOpen = React.useCallback(() => setCombinedOpenState(true), [setCombinedOpenState]);
@@ -66,6 +67,8 @@ const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children, rend
66
67
  ]);
67
68
  const menuButtonChild = React.Children.toArray(children).find((child) => /*#__PURE__*/ React.isValidElement(child) && (child.type === MenuButton || child.type === Anchor || isSlot(child, Anchor) || isSlot(child, MenuButton)));
68
69
  const menuButtonChildId = /*#__PURE__*/ React.isValidElement(menuButtonChild) ? menuButtonChild.props.id : void 0;
70
+ const hasTooltipAnchor = customRenderAnchor && React.Children.toArray(children).some((child) => /*#__PURE__*/ React.isValidElement(child) && (child.type === Tooltip || isSlot(child, Tooltip)) && /*#__PURE__*/ React.isValidElement(child.props.children) && (child.props.children.type === MenuButton || isSlot(child.props.children, MenuButton)));
71
+ customRenderAnchor && (menuButtonChild || hasTooltipAnchor) && invariant(false, "Pass either `renderAnchor` or `ActionMenu.Button`/`ActionMenu.Anchor`, not both.");
69
72
  const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
70
73
  const callbackAnchorRef = useMergedRefs(anchorRef, void 0);
71
74
  const anchorId = useId$1(menuButtonChildId);
@@ -115,7 +118,8 @@ const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children, rend
115
118
  open: combinedOpenState,
116
119
  onOpen,
117
120
  onClose,
118
- isSubmenu
121
+ isSubmenu,
122
+ isCustomAnchor: Boolean(customRenderAnchor)
119
123
  }), [
120
124
  anchorRef,
121
125
  renderAnchor,
@@ -123,7 +127,8 @@ const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children, rend
123
127
  combinedOpenState,
124
128
  onOpen,
125
129
  onClose,
126
- isSubmenu
130
+ isSubmenu,
131
+ customRenderAnchor
127
132
  ]);
128
133
  return /* @__PURE__ */ jsx(MenuContext.Provider, {
129
134
  value: menuContextValue,
@@ -183,7 +188,7 @@ const defaultVariant = {
183
188
  narrow: "anchored"
184
189
  };
185
190
  const Overlay = ({ children, align = "start", side, onPositionChange, displayInViewport, "aria-labelledby": ariaLabelledby, variant = defaultVariant, ...overlayProps }) => {
186
- const { anchorRef, renderAnchor, anchorId, open, onOpen, onClose, isSubmenu = false } = React.useContext(MenuContext);
191
+ const { anchorRef, renderAnchor, anchorId, open, onOpen, onClose, isSubmenu = false, isCustomAnchor = false } = React.useContext(MenuContext);
187
192
  const containerRef = React.useRef(null);
188
193
  const isNarrowFullscreen = !!useResponsiveValue({ narrow: true }, false) && variant.narrow === "fullscreen";
189
194
  const handleClose = React.useCallback((gesture) => {
@@ -200,11 +205,15 @@ const Overlay = ({ children, align = "start", side, onPositionChange, displayInV
200
205
  const [anchorAriaLabelledby, setAnchorAriaLabelledby] = useState(null);
201
206
  useIsomorphicLayoutEffect(() => {
202
207
  if (open) {
203
- var _anchorRef$current$ge, _anchorRef$current;
204
- setAnchorAriaLabelledby((_anchorRef$current$ge = (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.getAttribute("aria-labelledby")) !== null && _anchorRef$current$ge !== void 0 ? _anchorRef$current$ge : null);
208
+ var _anchorRef$current, _anchorRef$current2;
209
+ setAnchorAriaLabelledby(((_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.getAttribute("aria-labelledby")) || (isCustomAnchor ? (_anchorRef$current2 = anchorRef.current) === null || _anchorRef$current2 === void 0 ? void 0 : _anchorRef$current2.id : null) || null);
205
210
  setAnchorLabelReady(true);
206
211
  }
207
- }, [anchorRef, open]);
212
+ }, [
213
+ anchorRef,
214
+ open,
215
+ isCustomAnchor
216
+ ]);
208
217
  const afterSelect = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("item-select"), [onClose]);
209
218
  const overlayContextValue = useMemo(() => ({
210
219
  container: "ActionMenu",
@@ -251,6 +260,7 @@ const Overlay = ({ children, align = "start", side, onPositionChange, displayInV
251
260
  })
252
261
  });
253
262
  };
263
+ const Menu = ActionMenuImpl;
254
264
  Menu.displayName = "ActionMenu";
255
265
  MenuButton.__SLOT__ = Symbol("ActionMenu.Button");
256
266
  Anchor.__SLOT__ = Symbol("ActionMenu.Anchor");
@@ -262,4 +272,4 @@ const ActionMenu = Object.assign(Menu, {
262
272
  Divider
263
273
  });
264
274
  //#endregion
265
- export { ActionMenu };
275
+ export { ActionMenu, ActionMenuImpl };
@@ -1,2 +1,2 @@
1
- import { ActionMenu, ActionMenuAnchorProps, ActionMenuAnchorRenderProps, ActionMenuButtonProps, ActionMenuProps } from "./ActionMenu.js";
2
- export { ActionMenu, ActionMenuAnchorProps, ActionMenuAnchorRenderProps, ActionMenuButtonProps, ActionMenuProps };
1
+ import { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps } from "./ActionMenu.js";
2
+ export { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps };
@@ -7,18 +7,12 @@ import React, { JSX } from "react";
7
7
  import { AnchorPosition, PositionSettings } from "@primer/behaviors";
8
8
 
9
9
  //#region src/AnchoredOverlay/AnchoredOverlay.d.ts
10
- type AnchoredOverlayAnchorContext = {
11
- ref: {
12
- readonly current: HTMLElement | null;
13
- };
14
- };
15
10
  interface AnchoredOverlayPropsWithAnchor {
16
11
  /**
17
12
  * A custom function component used to render the anchor element.
18
13
  * Will receive the selected text as `children` prop when an item is activated.
19
- * The second argument exposes the anchor's object ref for composing behaviors.
20
14
  */
21
- renderAnchor: <T extends Omit<React.HTMLAttributes<HTMLElement>, 'aria-label' | 'aria-labelledby'>>(props: T, context?: AnchoredOverlayAnchorContext) => JSX.Element;
15
+ renderAnchor: <T extends Omit<React.HTMLAttributes<HTMLElement>, 'aria-label' | 'aria-labelledby'>>(props: T) => JSX.Element;
22
16
  /**
23
17
  * An override to the internal ref that will be spread on to the renderAnchor
24
18
  */
@@ -131,4 +125,4 @@ type AnchoredOverlayProps = AnchoredOverlayBaseProps & (AnchoredOverlayPropsWith
131
125
  */
132
126
  declare const AnchoredOverlay: React.FC<React.PropsWithChildren<AnchoredOverlayProps>>;
133
127
  //#endregion
134
- export { AnchoredOverlay, AnchoredOverlayAnchorContext, AnchoredOverlayProps, AnchoredOverlayWrapperAnchorProps };
128
+ export { AnchoredOverlay, AnchoredOverlayProps, AnchoredOverlayWrapperAnchorProps };
@@ -173,7 +173,7 @@ const AnchoredOverlay = ({ renderAnchor, anchorRef: externalAnchorRef, anchorId:
173
173
  onClick: onAnchorClick,
174
174
  onKeyDown: onAnchorKeyDown,
175
175
  ...popoverTargetProps
176
- }, { ref: anchorRef }), open ? /* @__PURE__ */ jsxs(Overlay, {
176
+ }), open ? /* @__PURE__ */ jsxs(Overlay, {
177
177
  returnFocusRef: anchorRef,
178
178
  onClickOutside,
179
179
  ignoreClickRefs: [anchorRef],
@@ -1,2 +1,2 @@
1
- import { AnchoredOverlay, AnchoredOverlayAnchorContext, AnchoredOverlayProps } from "./AnchoredOverlay.js";
2
- export { AnchoredOverlay, type AnchoredOverlayAnchorContext, type AnchoredOverlayProps };
1
+ import { AnchoredOverlay, AnchoredOverlayProps } from "./AnchoredOverlay.js";
2
+ export { AnchoredOverlay, type AnchoredOverlayProps };
@@ -336,7 +336,7 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
336
336
  const selectedItems = Array.isArray(selected) ? selected : [...selected ? [selected] : []];
337
337
  const selectedValueText = selectedItems.length ? selectedItems.map((item) => item.text).join(", ") : placeholder;
338
338
  const shouldAutoWireLabel = isReferenced === false && Boolean(labelId) && Boolean(selectedValueId);
339
- return (props, context) => {
339
+ return (props) => {
340
340
  return renderAnchor({
341
341
  ...props,
342
342
  ...shouldAutoWireLabel ? { "aria-labelledby": [labelId, selectedValueId].filter(Boolean).join(" ") } : {},
@@ -344,7 +344,7 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
344
344
  id: selectedValueId,
345
345
  children: selectedValueText
346
346
  }) : selectedValueText
347
- }, context);
347
+ });
348
348
  };
349
349
  }, [
350
350
  placeholder,
@@ -5,11 +5,6 @@ import React, { ForwardRefExoticComponent } from "react";
5
5
  //#region src/TooltipV2/Tooltip.d.ts
6
6
  type TooltipDirection = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
7
7
  type TooltipProps = React.PropsWithChildren<{
8
- /**
9
- * Render a single interactive trigger instead of passing children.
10
- * Forward all supplied props, including ref, to that element.
11
- */
12
- renderAnchor?: (props: TooltipAnchorProps) => React.ReactElement;
13
8
  direction?: TooltipDirection;
14
9
  text: string;
15
10
  type?: 'label' | 'description';
@@ -32,9 +27,6 @@ type TooltipProps = React.PropsWithChildren<{
32
27
  */
33
28
  _privateDisableTooltip?: boolean;
34
29
  }> & React.HTMLAttributes<HTMLElement>;
35
- type TooltipAnchorProps = React.HTMLAttributes<HTMLElement> & {
36
- ref: React.RefCallback<HTMLElement>;
37
- };
38
30
  declare const Tooltip: ForwardRefExoticComponent<React.PropsWithoutRef<TooltipProps> & React.RefAttributes<HTMLElement>> & SlotMarker;
39
31
  //#endregion
40
- export { Tooltip, TooltipAnchorProps, TooltipDirection, TooltipProps };
32
+ export { Tooltip, TooltipDirection, TooltipProps };
@@ -80,8 +80,9 @@ const isInteractive = (element) => {
80
80
  return interactiveElements.some((selector) => element.matches(selector)) || element.hasAttribute("role") && element.getAttribute("role") === "button";
81
81
  };
82
82
  const emptyKeybindingHints = [];
83
- const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, renderAnchor, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
83
+ const TooltipImpl = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, renderAnchor, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
84
84
  const tooltipId = useId$1(id);
85
+ const hasRenderAnchor = renderAnchor !== void 0;
85
86
  renderAnchor && children != null && invariant(false, "Pass either `children` or `renderAnchor` to `Tooltip`, not both.");
86
87
  const child = renderAnchor ? void 0 : Children.only(children);
87
88
  const isFragmentTrigger = /*#__PURE__*/ React.isValidElement(child) && child.type === React.Fragment;
@@ -104,6 +105,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
104
105
  if (tooltipElRef.current && readTriggerRef.current instanceof HTMLElement && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
105
106
  const tooltip = tooltipElRef.current;
106
107
  const trigger = readTriggerRef.current;
108
+ if (hasRenderAnchor && trigger.matches(":disabled")) return;
107
109
  tooltip.showPopover();
108
110
  setIsPopoverOpen(true);
109
111
  const settings = {
@@ -141,7 +143,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
141
143
  const isInvalidTrigger = !(trigger instanceof HTMLElement);
142
144
  warning(isInvalidTrigger, "The `Tooltip` component expects its trigger ref to resolve to an HTML element. Ensure the trigger forwards its ref to a single interactive element instead of a React Fragment.");
143
145
  if (isInvalidTrigger) return;
144
- const isTriggerInteractive = isInteractive(trigger);
146
+ const isTriggerInteractive = isInteractive(trigger) || hasRenderAnchor && trigger.matches(":disabled");
145
147
  const triggerChildren = trigger.childNodes;
146
148
  const hasInteractiveDescendant = Array.from(triggerChildren).some((child) => {
147
149
  return child instanceof HTMLElement && isInteractive(child) || Array.from(child.childNodes).some((grandChild) => grandChild instanceof HTMLElement && isInteractive(grandChild));
@@ -160,7 +162,8 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
160
162
  tooltipElRef,
161
163
  readTriggerRef,
162
164
  direction,
163
- type
165
+ type,
166
+ hasRenderAnchor
164
167
  ]);
165
168
  useOnEscapePress((event) => {
166
169
  if (isPopoverOpen) {
@@ -249,6 +252,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
249
252
  })] })
250
253
  });
251
254
  });
255
+ const Tooltip = TooltipImpl;
252
256
  Tooltip.__SLOT__ = Symbol("Tooltip");
253
257
  //#endregion
254
- export { Tooltip };
258
+ export { Tooltip, TooltipImpl };
@@ -1,2 +1,2 @@
1
- import { Tooltip, TooltipAnchorProps, TooltipDirection, TooltipProps } from "./Tooltip.js";
2
- export { Tooltip, type TooltipAnchorProps, type TooltipDirection, type TooltipProps };
1
+ import { Tooltip, TooltipDirection, TooltipProps } from "./Tooltip.js";
2
+ export { Tooltip, type TooltipDirection, type TooltipProps };
@@ -82,11 +82,11 @@ const ActionMenuBase = (t0) => {
82
82
  }
83
83
  let t5;
84
84
  if ($[14] !== anchorContent || $[15] !== renderAnchor) {
85
- t5 = (props, context) => renderAnchor({
85
+ t5 = (props) => renderAnchor({
86
86
  "aria-label": "menu",
87
87
  children: anchorContent,
88
88
  ...props
89
- }, context);
89
+ });
90
90
  $[14] = anchorContent;
91
91
  $[15] = renderAnchor;
92
92
  $[16] = t5;
@@ -0,0 +1,134 @@
1
+ import { AriaRole } from "../../utils/types/AriaRole.js";
2
+ import { FCWithSlotMarker, SlotMarker, WithSlotMarker } from "../../utils/types/Slots.js";
3
+ import { ForwardRefComponent } from "../../utils/polymorphic.js";
4
+ import { TouchOrMouseEvent } from "../../hooks/useOnOutsideClick.js";
5
+ import { AnchorRenderer } from "../../internal/components/RenderAnchor.js";
6
+ import { TooltipProps as TooltipProps$1 } from "../../TooltipV2/Tooltip.js";
7
+ import { ButtonProps } from "../../Button/types.js";
8
+ import { ActionListDividerProps } from "../../ActionList/Divider.js";
9
+ import { AnchoredOverlayProps as AnchoredOverlayProps$1 } from "../../AnchoredOverlay/AnchoredOverlay.js";
10
+ import { ActionMenuProps as ActionMenuProps$1 } from "../../ActionMenu/ActionMenu.js";
11
+ import { heightMap, widthMap } from "../../Overlay/constants.js";
12
+ import React from "react";
13
+
14
+ //#region src/experimental/TriggerComposition/TriggerComposition.d.ts
15
+ type ActionMenuProps = ActionMenuProps$1 & {
16
+ renderAnchor?: AnchorRenderer;
17
+ };
18
+ declare function Menu({
19
+ renderAnchor,
20
+ ...props
21
+ }: ActionMenuProps): React.JSX.Element;
22
+ declare const ActionMenu: typeof Menu & {
23
+ Button: ForwardRefComponent<"button", ButtonProps>;
24
+ Anchor: WithSlotMarker<React.ForwardRefExoticComponent<{
25
+ children: React.ReactElement<any>;
26
+ id?: string;
27
+ } & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>>;
28
+ Overlay: FCWithSlotMarker<React.PropsWithChildren<Partial<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
29
+ ref?: React.RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
30
+ }, "as" | "height" | "maxHeight" | "maxWidth" | "overflow" | "style" | "width" | keyof {
31
+ visibility?: "visible" | "hidden";
32
+ 'data-test-id'?: unknown;
33
+ 'data-component'?: string;
34
+ position?: React.CSSProperties["position"];
35
+ top?: React.CSSProperties["top"];
36
+ left?: React.CSSProperties["left"];
37
+ right?: React.CSSProperties["right"];
38
+ bottom?: React.CSSProperties["bottom"];
39
+ role?: AriaRole;
40
+ children?: React.ReactNode;
41
+ className?: string;
42
+ responsiveVariant?: "fullscreen";
43
+ } | keyof {
44
+ anchorSide?: import("@primer/behaviors").AnchorSide;
45
+ _PrivateDisablePortal?: boolean;
46
+ ignoreClickRefs?: React.RefObject<HTMLElement | null>[];
47
+ initialFocusRef?: React.RefObject<HTMLElement | null>;
48
+ onClickOutside: (e: TouchOrMouseEvent) => void;
49
+ onEscape: (e: KeyboardEvent) => void;
50
+ portalContainerName?: string;
51
+ preventOverflow?: boolean;
52
+ preventFocusOnOpen?: boolean;
53
+ preventFocusOnClose?: boolean;
54
+ returnFocusRef: React.RefObject<HTMLElement | null>;
55
+ }> & Omit<Omit<{
56
+ width?: keyof typeof widthMap;
57
+ height?: keyof typeof heightMap;
58
+ maxHeight?: keyof Omit<typeof heightMap, "auto" | "initial">;
59
+ maxWidth?: keyof Omit<typeof widthMap, "auto">;
60
+ visibility?: "visible" | "hidden";
61
+ overflow?: "auto" | "hidden" | "scroll" | "visible";
62
+ style?: React.CSSProperties;
63
+ }, keyof {
64
+ visibility?: "visible" | "hidden";
65
+ 'data-test-id'?: unknown;
66
+ 'data-component'?: string;
67
+ position?: React.CSSProperties["position"];
68
+ top?: React.CSSProperties["top"];
69
+ left?: React.CSSProperties["left"];
70
+ right?: React.CSSProperties["right"];
71
+ bottom?: React.CSSProperties["bottom"];
72
+ role?: AriaRole;
73
+ children?: React.ReactNode;
74
+ className?: string;
75
+ responsiveVariant?: "fullscreen";
76
+ }> & {
77
+ visibility?: "visible" | "hidden";
78
+ 'data-test-id'?: unknown;
79
+ 'data-component'?: string;
80
+ position?: React.CSSProperties["position"];
81
+ top?: React.CSSProperties["top"];
82
+ left?: React.CSSProperties["left"];
83
+ right?: React.CSSProperties["right"];
84
+ bottom?: React.CSSProperties["bottom"];
85
+ role?: AriaRole;
86
+ children?: React.ReactNode;
87
+ className?: string;
88
+ responsiveVariant?: "fullscreen";
89
+ }, keyof {
90
+ anchorSide?: import("@primer/behaviors").AnchorSide;
91
+ _PrivateDisablePortal?: boolean;
92
+ ignoreClickRefs?: React.RefObject<HTMLElement | null>[];
93
+ initialFocusRef?: React.RefObject<HTMLElement | null>;
94
+ onClickOutside: (e: TouchOrMouseEvent) => void;
95
+ onEscape: (e: KeyboardEvent) => void;
96
+ portalContainerName?: string;
97
+ preventOverflow?: boolean;
98
+ preventFocusOnOpen?: boolean;
99
+ preventFocusOnClose?: boolean;
100
+ returnFocusRef: React.RefObject<HTMLElement | null>;
101
+ }> & {
102
+ anchorSide?: import("@primer/behaviors").AnchorSide;
103
+ _PrivateDisablePortal?: boolean;
104
+ ignoreClickRefs?: React.RefObject<HTMLElement | null>[];
105
+ initialFocusRef?: React.RefObject<HTMLElement | null>;
106
+ onClickOutside: (e: TouchOrMouseEvent) => void;
107
+ onEscape: (e: KeyboardEvent) => void;
108
+ portalContainerName?: string;
109
+ preventOverflow?: boolean;
110
+ preventFocusOnOpen?: boolean;
111
+ preventFocusOnClose?: boolean;
112
+ returnFocusRef: React.RefObject<HTMLElement | null>;
113
+ } & {
114
+ as?: "div" | undefined;
115
+ }> & Pick<AnchoredOverlayProps$1, "align" | "displayInViewport" | "side" | "variant"> & {
116
+ children: React.ReactNode;
117
+ onPositionChange?: ({
118
+ position
119
+ }: {
120
+ position: import("@primer/behaviors").AnchorPosition;
121
+ }) => void;
122
+ }>>;
123
+ Divider: FCWithSlotMarker<React.PropsWithChildren<ActionListDividerProps>>;
124
+ };
125
+ type AnchoredOverlayProps = AnchoredOverlayProps$1 | (Omit<AnchoredOverlayProps$1, 'renderAnchor'> & {
126
+ renderAnchor: React.ReactElement;
127
+ });
128
+ declare function AnchoredOverlay(props: React.PropsWithChildren<AnchoredOverlayProps>): React.JSX.Element;
129
+ type TooltipProps = TooltipProps$1 & {
130
+ renderAnchor?: AnchorRenderer;
131
+ };
132
+ declare const Tooltip: React.ForwardRefExoticComponent<React.PropsWithoutRef<TooltipProps> & React.RefAttributes<HTMLElement>> & SlotMarker;
133
+ //#endregion
134
+ export { ActionMenu, ActionMenuProps, AnchoredOverlay, AnchoredOverlayProps, Tooltip, TooltipProps };
@@ -0,0 +1,203 @@
1
+ import { c } from "../../utils/react-compiler-runtime.js";
2
+ import { useProvidedRefOrCreate } from "../../hooks/useProvidedRefOrCreate.js";
3
+ import { invariant } from "../../utils/invariant.js";
4
+ import { Tooltip as Tooltip$1, TooltipImpl } from "../../TooltipV2/Tooltip.js";
5
+ import { asSlot } from "../../utils/as-slot.js";
6
+ import { AnchoredOverlay as AnchoredOverlay$1 } from "../../AnchoredOverlay/AnchoredOverlay.js";
7
+ import { ActionMenu as ActionMenu$1, ActionMenuImpl } from "../../ActionMenu/ActionMenu.js";
8
+ import { mergeAnchorProps } from "../../internal/utils/mergeAnchorProps.js";
9
+ import { RenderAnchor } from "../../internal/components/RenderAnchor.js";
10
+ import React from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ //#region src/experimental/TriggerComposition/TriggerComposition.tsx
13
+ function Menu(t0) {
14
+ const $ = c(8);
15
+ let props;
16
+ let renderAnchor;
17
+ if ($[0] !== t0) {
18
+ ({renderAnchor, ...props} = t0);
19
+ $[0] = t0;
20
+ $[1] = props;
21
+ $[2] = renderAnchor;
22
+ } else {
23
+ props = $[1];
24
+ renderAnchor = $[2];
25
+ }
26
+ let t1;
27
+ if ($[3] !== renderAnchor) {
28
+ t1 = renderAnchor ? (anchorProps) => /* @__PURE__ */ jsx(RenderAnchor, {
29
+ render: renderAnchor,
30
+ props: anchorProps
31
+ }) : void 0;
32
+ $[3] = renderAnchor;
33
+ $[4] = t1;
34
+ } else t1 = $[4];
35
+ let t2;
36
+ if ($[5] !== props || $[6] !== t1) {
37
+ t2 = /* @__PURE__ */ jsx(ActionMenuImpl, {
38
+ ...props,
39
+ renderAnchor: t1
40
+ });
41
+ $[5] = props;
42
+ $[6] = t1;
43
+ $[7] = t2;
44
+ } else t2 = $[7];
45
+ return t2;
46
+ }
47
+ const ActionMenu = Object.assign(Menu, {
48
+ Button: ActionMenu$1.Button,
49
+ Anchor: ActionMenu$1.Anchor,
50
+ Overlay: ActionMenu$1.Overlay,
51
+ Divider: ActionMenu$1.Divider
52
+ });
53
+ function AnchoredOverlay(props) {
54
+ const $ = c(11);
55
+ const anchorRef = useProvidedRefOrCreate(props.anchorRef);
56
+ if (props.renderAnchor === null) {
57
+ let t0;
58
+ if ($[0] !== props) {
59
+ t0 = /* @__PURE__ */ jsx(AnchoredOverlay$1, { ...props });
60
+ $[0] = props;
61
+ $[1] = t0;
62
+ } else t0 = $[1];
63
+ return t0;
64
+ }
65
+ if (typeof props.renderAnchor === "function") {
66
+ let t0;
67
+ if ($[2] !== props) {
68
+ t0 = /* @__PURE__ */ jsx(AnchoredOverlay$1, {
69
+ ...props,
70
+ renderAnchor: props.renderAnchor
71
+ });
72
+ $[2] = props;
73
+ $[3] = t0;
74
+ } else t0 = $[3];
75
+ return t0;
76
+ }
77
+ const { renderAnchor } = props;
78
+ let t0;
79
+ if ($[4] !== anchorRef || $[5] !== renderAnchor) {
80
+ t0 = (anchorProps) => /* @__PURE__ */ jsx(RenderAnchor, {
81
+ render: renderAnchor,
82
+ props: {
83
+ ...anchorProps,
84
+ ref: anchorRef
85
+ }
86
+ });
87
+ $[4] = anchorRef;
88
+ $[5] = renderAnchor;
89
+ $[6] = t0;
90
+ } else t0 = $[6];
91
+ let t1;
92
+ if ($[7] !== anchorRef || $[8] !== props || $[9] !== t0) {
93
+ t1 = /* @__PURE__ */ jsx(AnchoredOverlay$1, {
94
+ ...props,
95
+ anchorRef,
96
+ renderAnchor: t0
97
+ });
98
+ $[7] = anchorRef;
99
+ $[8] = props;
100
+ $[9] = t0;
101
+ $[10] = t1;
102
+ } else t1 = $[10];
103
+ return t1;
104
+ }
105
+ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, ref) => {
106
+ const $ = c(29);
107
+ let _privateDisableTooltip;
108
+ let anchorProps;
109
+ let children;
110
+ let delay;
111
+ let direction;
112
+ let keybindingHint;
113
+ let renderAnchor;
114
+ let text;
115
+ let type;
116
+ if ($[0] !== t0) {
117
+ ({renderAnchor, children, text, type, direction, delay, keybindingHint, _privateDisableTooltip, ...anchorProps} = t0);
118
+ $[0] = t0;
119
+ $[1] = _privateDisableTooltip;
120
+ $[2] = anchorProps;
121
+ $[3] = children;
122
+ $[4] = delay;
123
+ $[5] = direction;
124
+ $[6] = keybindingHint;
125
+ $[7] = renderAnchor;
126
+ $[8] = text;
127
+ $[9] = type;
128
+ } else {
129
+ _privateDisableTooltip = $[1];
130
+ anchorProps = $[2];
131
+ children = $[3];
132
+ delay = $[4];
133
+ direction = $[5];
134
+ keybindingHint = $[6];
135
+ renderAnchor = $[7];
136
+ text = $[8];
137
+ type = $[9];
138
+ }
139
+ renderAnchor && children != null && invariant(false, "Pass either `children` or `renderAnchor` to `Tooltip`, not both.");
140
+ let t1;
141
+ if ($[10] !== _privateDisableTooltip || $[11] !== delay || $[12] !== direction || $[13] !== keybindingHint || $[14] !== text || $[15] !== type) {
142
+ t1 = {
143
+ text,
144
+ type,
145
+ direction,
146
+ delay,
147
+ keybindingHint,
148
+ _privateDisableTooltip
149
+ };
150
+ $[10] = _privateDisableTooltip;
151
+ $[11] = delay;
152
+ $[12] = direction;
153
+ $[13] = keybindingHint;
154
+ $[14] = text;
155
+ $[15] = type;
156
+ $[16] = t1;
157
+ } else t1 = $[16];
158
+ const tooltipProps = t1;
159
+ if (!renderAnchor) {
160
+ let t2;
161
+ if ($[17] !== anchorProps || $[18] !== children || $[19] !== ref || $[20] !== tooltipProps) {
162
+ t2 = /* @__PURE__ */ jsx(Tooltip$1, {
163
+ ...tooltipProps,
164
+ ...anchorProps,
165
+ ref,
166
+ children
167
+ });
168
+ $[17] = anchorProps;
169
+ $[18] = children;
170
+ $[19] = ref;
171
+ $[20] = tooltipProps;
172
+ $[21] = t2;
173
+ } else t2 = $[21];
174
+ return t2;
175
+ }
176
+ let t2;
177
+ if ($[22] !== anchorProps || $[23] !== renderAnchor) {
178
+ t2 = (tooltipAnchorProps) => /* @__PURE__ */ jsx(RenderAnchor, {
179
+ render: renderAnchor,
180
+ props: mergeAnchorProps(tooltipAnchorProps, anchorProps)
181
+ });
182
+ $[22] = anchorProps;
183
+ $[23] = renderAnchor;
184
+ $[24] = t2;
185
+ } else t2 = $[24];
186
+ let t3;
187
+ if ($[25] !== ref || $[26] !== t2 || $[27] !== tooltipProps) {
188
+ t3 = /* @__PURE__ */ jsx(TooltipImpl, {
189
+ ...tooltipProps,
190
+ ref,
191
+ renderAnchor: t2
192
+ });
193
+ $[25] = ref;
194
+ $[26] = t2;
195
+ $[27] = tooltipProps;
196
+ $[28] = t3;
197
+ } else t3 = $[28];
198
+ return t3;
199
+ });
200
+ Tooltip.displayName = "Tooltip";
201
+ asSlot(Tooltip, Tooltip$1);
202
+ //#endregion
203
+ export { ActionMenu, AnchoredOverlay, Tooltip };
@@ -4,7 +4,6 @@ import { AriaStatus, AriaStatusProps } from "../live-region/AriaStatus.js";
4
4
  import { KeybindingHintProps } from "../KeybindingHint/props.js";
5
5
  import { KeybindingHint } from "../KeybindingHint/KeybindingHint.js";
6
6
  import { getAccessibleKeybindingHintString } from "../KeybindingHint/utils.js";
7
- import { Tooltip, TooltipProps } from "../TooltipV2/Tooltip.js";
8
7
  import { ButtonBaseProps } from "../Button/types.js";
9
8
  import { ButtonBase } from "../Button/ButtonBase.js";
10
9
  import { Dialog, DialogButtonProps, DialogHeaderProps, DialogHeight, DialogProps, DialogWidth } from "../Dialog/Dialog.js";
@@ -36,6 +35,7 @@ import { InlineMessage, InlineMessageProps } from "../InlineMessage/InlineMessag
36
35
  import { Hidden, HiddenProps } from "../Hidden/Hidden.js";
37
36
  import { useOverflow } from "../hooks/useOverflow.js";
38
37
  import { SelectPanel, SelectPanelMessageProps, SelectPanelProps, SelectPanelSecondaryActionProps } from "./SelectPanel2/SelectPanel.js";
38
+ import { ActionMenu, ActionMenuProps, AnchoredOverlay, AnchoredOverlayProps, Tooltip, TooltipProps } from "./TriggerComposition/TriggerComposition.js";
39
39
  import { ScrollableRegion, ScrollableRegionProps } from "../ScrollableRegion/ScrollableRegion.js";
40
40
  import _default, { PanelProps, TabProps as TabProps$1, UnderlinePanelsProps } from "./UnderlinePanels/UnderlinePanels.js";
41
41
  import { SkeletonText, SkeletonTextProps } from "../SkeletonText/SkeletonText.js";
@@ -52,4 +52,4 @@ import { useTabPanel } from "./Tabs/useTabPanel.js";
52
52
  import { TopicTagProps } from "../TopicTag/TopicTag.js";
53
53
  import { TopicTagGroupProps } from "../TopicTag/TopicTagGroup.js";
54
54
  import { TopicTag } from "../TopicTag/index.js";
55
- export { ActionBar, type ActionBarButtonProps, type ActionBarMenuItemProps, type ActionBarMenuProps, type ActionBarProps, Announce, type AnnounceProps, AriaAlert, type AriaAlertProps, AriaStatus, type AriaStatusProps, BlankslateContainer as Blankslate, type BlankslateProps, ButtonBase, type ButtonBaseProps, Card, type ActionProps as CardActionProps, type ButtonProps as CardButtonProps, type DescriptionProps as CardDescriptionProps, type HeadingProps as CardHeadingProps, type IconProps as CardIconProps, type ImageProps as CardImageProps, type LinkProps as CardLinkProps, type MetadataProps as CardMetadataProps, type CardProps, type CellAlignment, type Column, type ColumnWidth, DataTable, type DataTableBulkActionsContext, type DataTableData, type DataTableProps, type DataTableRowGroup, type DataTableRowId, DefaultFeatureFlags, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, FeatureFlags, type FeatureFlagsProps, FilteredActionList, type FilteredActionListInputProps, FilteredActionListLoadingTypes, type FilteredActionListProps, Hidden, type HiddenProps, InlineMessage, type InlineMessageProps, IssueLabel, type IssueLabelProps, KeybindingHint, type KeybindingHintProps, NavList, type NavListDividerProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, type ObjectPaths, PageHeader, type ActionsProps as PageHeaderActionsProps, type PageHeaderProps, type TitleProps as PageHeaderTitleProps, ScrollableRegion, type ScrollableRegionProps, SelectPanel, type SelectPanelMessageProps, type SelectPanelProps, type SelectPanelSecondaryActionProps, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBox, type SkeletonBoxProps, SkeletonText, type SkeletonTextProps, SlotConfig, Stack, type StackItemProps, type StackProps, type TabListProps, type TabPanelProps, type TabProps, Table, type TableActionsProps, type TableBodyProps, type TableBulkActionsProps, type TableCellProps, type TableContainerProps, type TableGroupProps, type TableHeadProps, type TableHeaderProps, type TableProps, type TableRowProps, type TableRowSelectionProps, type TableSelectionHeaderProps, type TableSubtitleProps, type TableTitleProps, Tabs, type TabsProps, type TitleProps, Tooltip, type TooltipProps, TopicTag, type TopicTagGroupProps, type TopicTagProps, _default as UnderlinePanels, type PanelProps as UnderlinePanelsPanelProps, type UnderlinePanelsProps, type TabProps$1 as UnderlinePanelsTabProps, type UniqueRow, createColumnHelper, getAccessibleKeybindingHintString, useFeatureFlag, useOverflow, useSlots, useTab, useTabList, useTabPanel };
55
+ export { ActionBar, type ActionBarButtonProps, type ActionBarMenuItemProps, type ActionBarMenuProps, type ActionBarProps, ActionMenu, type ActionMenuProps, AnchoredOverlay, type AnchoredOverlayProps, Announce, type AnnounceProps, AriaAlert, type AriaAlertProps, AriaStatus, type AriaStatusProps, BlankslateContainer as Blankslate, type BlankslateProps, ButtonBase, type ButtonBaseProps, Card, type ActionProps as CardActionProps, type ButtonProps as CardButtonProps, type DescriptionProps as CardDescriptionProps, type HeadingProps as CardHeadingProps, type IconProps as CardIconProps, type ImageProps as CardImageProps, type LinkProps as CardLinkProps, type MetadataProps as CardMetadataProps, type CardProps, type CellAlignment, type Column, type ColumnWidth, DataTable, type DataTableBulkActionsContext, type DataTableData, type DataTableProps, type DataTableRowGroup, type DataTableRowId, DefaultFeatureFlags, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, FeatureFlags, type FeatureFlagsProps, FilteredActionList, type FilteredActionListInputProps, FilteredActionListLoadingTypes, type FilteredActionListProps, Hidden, type HiddenProps, InlineMessage, type InlineMessageProps, IssueLabel, type IssueLabelProps, KeybindingHint, type KeybindingHintProps, NavList, type NavListDividerProps, type NavListGroupProps, type NavListItemProps, type NavListLeadingVisualProps, type NavListProps, type NavListSubNavProps, type NavListTrailingVisualProps, type ObjectPaths, PageHeader, type ActionsProps as PageHeaderActionsProps, type PageHeaderProps, type TitleProps as PageHeaderTitleProps, ScrollableRegion, type ScrollableRegionProps, SelectPanel, type SelectPanelMessageProps, type SelectPanelProps, type SelectPanelSecondaryActionProps, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBox, type SkeletonBoxProps, SkeletonText, type SkeletonTextProps, SlotConfig, Stack, type StackItemProps, type StackProps, type TabListProps, type TabPanelProps, type TabProps, Table, type TableActionsProps, type TableBodyProps, type TableBulkActionsProps, type TableCellProps, type TableContainerProps, type TableGroupProps, type TableHeadProps, type TableHeaderProps, type TableProps, type TableRowProps, type TableRowSelectionProps, type TableSelectionHeaderProps, type TableSubtitleProps, type TableTitleProps, Tabs, type TabsProps, type TitleProps, Tooltip, type TooltipProps, TopicTag, type TopicTagGroupProps, type TopicTagProps, _default as UnderlinePanels, type PanelProps as UnderlinePanelsPanelProps, type UnderlinePanelsProps, type TabProps$1 as UnderlinePanelsTabProps, type UniqueRow, createColumnHelper, getAccessibleKeybindingHintString, useFeatureFlag, useOverflow, useSlots, useTab, useTabList, useTabPanel };
@@ -9,7 +9,6 @@ import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
9
9
  import { ButtonBase } from "../Button/ButtonBase.js";
10
10
  import { KeybindingHint } from "../KeybindingHint/KeybindingHint.js";
11
11
  import { getAccessibleKeybindingHintString } from "../KeybindingHint/utils.js";
12
- import { Tooltip } from "../TooltipV2/Tooltip.js";
13
12
  import { useOverflow } from "../hooks/useOverflow.js";
14
13
  import { ScrollableRegion } from "../ScrollableRegion/ScrollableRegion.js";
15
14
  import { Dialog } from "../Dialog/Dialog.js";
@@ -30,6 +29,7 @@ import { Table } from "../DataTable/index.js";
30
29
  import { InlineMessage } from "../InlineMessage/InlineMessage.js";
31
30
  import { Hidden } from "../Hidden/Hidden.js";
32
31
  import { SelectPanel } from "./SelectPanel2/SelectPanel.js";
32
+ import { ActionMenu, AnchoredOverlay, Tooltip } from "./TriggerComposition/TriggerComposition.js";
33
33
  import { useTab } from "./Tabs/useTab.js";
34
34
  import { useTabList } from "./Tabs/useTabList.js";
35
35
  import { useTabPanel } from "./Tabs/useTabPanel.js";
@@ -46,4 +46,4 @@ import { TopicTag } from "../TopicTag/index.js";
46
46
  * example: import {ActionList} from '@primer/react/drafts
47
47
  */
48
48
  //#endregion
49
- export { ActionBar, Announce, AriaAlert, AriaStatus, BlankslateContainer as Blankslate, ButtonBase, Card, DataTable, DefaultFeatureFlags, Dialog, FeatureFlags, FilteredActionList, FilteredActionListLoadingTypes, Hidden, InlineMessage, IssueLabel, KeybindingHint, NavList, PageHeader, ScrollableRegion, SelectPanel, SkeletonAvatar, SkeletonBox, SkeletonText, Stack, Table, Tabs, Tooltip, TopicTag, UnderlinePanels_default as UnderlinePanels, createColumnHelper, getAccessibleKeybindingHintString, useFeatureFlag, useOverflow, useSlots, useTab, useTabList, useTabPanel };
49
+ export { ActionBar, ActionMenu, AnchoredOverlay, Announce, AriaAlert, AriaStatus, BlankslateContainer as Blankslate, ButtonBase, Card, DataTable, DefaultFeatureFlags, Dialog, FeatureFlags, FilteredActionList, FilteredActionListLoadingTypes, Hidden, InlineMessage, IssueLabel, KeybindingHint, NavList, PageHeader, ScrollableRegion, SelectPanel, SkeletonAvatar, SkeletonBox, SkeletonText, Stack, Table, Tabs, Tooltip, TopicTag, UnderlinePanels_default as UnderlinePanels, createColumnHelper, getAccessibleKeybindingHintString, useFeatureFlag, useOverflow, useSlots, useTab, useTabList, useTabPanel };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { AriaStatus, AriaStatusProps } from "./live-region/AriaStatus.js";
11
11
  import BaseStyles, { BaseStylesProps } from "./BaseStyles.js";
12
12
  import { ThemeProvider, ThemeProviderProps } from "./ThemeProvider.js";
13
13
  import { useColorSchemeVar, useTheme } from "./useTheme.js";
14
- import { Tooltip, TooltipAnchorProps, TooltipProps } from "./TooltipV2/Tooltip.js";
14
+ import { Tooltip, TooltipProps } from "./TooltipV2/Tooltip.js";
15
15
  import { ButtonBaseProps, ButtonProps, IconButtonProps } from "./Button/types.js";
16
16
  import { IconButton } from "./Button/IconButton.js";
17
17
  import { LinkButton, LinkButtonProps } from "./Button/LinkButton.js";
@@ -49,7 +49,7 @@ import { ActionListDividerProps } from "./ActionList/Divider.js";
49
49
  import { ActionListDescriptionProps } from "./ActionList/Description.js";
50
50
  import { ActionListLeadingVisualProps, ActionListTrailingVisualProps } from "./ActionList/Visuals.js";
51
51
  import { ActionList } from "./ActionList/index.js";
52
- import { AnchoredOverlay, AnchoredOverlayAnchorContext, AnchoredOverlayProps } from "./AnchoredOverlay/AnchoredOverlay.js";
52
+ import { AnchoredOverlay, AnchoredOverlayProps } from "./AnchoredOverlay/AnchoredOverlay.js";
53
53
  import { AutocompleteMenuProps } from "./Autocomplete/AutocompleteMenu.js";
54
54
  import { AutocompleteOverlayProps } from "./Autocomplete/AutocompleteOverlay.js";
55
55
  import _default$15, { TextInputProps } from "./TextInput/TextInput.js";
@@ -121,6 +121,6 @@ import { StackItemProps, StackProps } from "./Stack/Stack.js";
121
121
  import { Stack } from "./Stack/index.js";
122
122
  import { ActionsProps, ChildrenPropTypes, PageHeader, PageHeaderProps, TitleAreaProps, TitleProps } from "./PageHeader/PageHeader.js";
123
123
  import { SkeletonBox, SkeletonBoxProps } from "./Skeleton/SkeletonBox.js";
124
- import { ActionMenu, ActionMenuAnchorProps, ActionMenuAnchorRenderProps, ActionMenuButtonProps, ActionMenuProps } from "./ActionMenu/ActionMenu.js";
124
+ import { ActionMenu, ActionMenuAnchorProps, ActionMenuButtonProps, ActionMenuProps } from "./ActionMenu/ActionMenu.js";
125
125
  import Overlay, { OverlayProps } from "./Overlay/Overlay.js";
126
- 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 ActionMenuAnchorRenderProps, type ActionMenuButtonProps, type ActionMenuProps, AnchoredOverlay, type AnchoredOverlayAnchorContext, type AnchoredOverlayProps, type AnchoredPositionHookSettings, AriaAlert, type AriaAlertProps, AriaStatus, type AriaStatusProps, _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, type CustomWidthOptions, Details, type DetailsProps, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, DragHandle, type DragHandleProps, 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, type PaneWidth, type PaneWidthValue, _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 SegmentedControlActionProps, type SegmentedControlButtonProps, type SegmentedControlDividerProps, 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 TooltipAnchorProps, type TooltipProps, type TouchOrMouseEvent, TreeView, type TreeViewErrorDialogProps, type TreeViewItemProps, type TreeViewProps, type TreeViewSubTreeProps, type TreeViewVisualProps, _default$19 as Truncate, type TruncateProps, UnderlineNav, type UnderlineNavItemProps, type UnderlineNavProps, type UsePaneWidthOptions, type UsePaneWidthResult, VisuallyHidden, type VisuallyHiddenProps, type WithSlotMarker, asSlot, createComponent, defaultPaneWidth, isSlot, registerPortalRoot, theme, useAnchoredPosition, useColorSchemeVar, useConfirm, useDetails, useFocusTrap, useFocusZone, useFormControlForwardedProps, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnEscapePress, useOnOutsideClick, useOpenAndCloseFocus, useOverlay, usePaneWidth, useProvidedRefOrCreate, useRefObjectAsForwardedRef, useResizeObserver, useResponsiveValue, useRovingTabIndex, useSafeTimeout, useSlots, useSyncedState, useTheme };
126
+ 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, AriaAlert, type AriaAlertProps, AriaStatus, type AriaStatusProps, _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, type CustomWidthOptions, Details, type DetailsProps, Dialog, type DialogButtonProps, type DialogHeaderProps, type DialogHeight, type DialogProps, type DialogWidth, DragHandle, type DragHandleProps, 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, type PaneWidth, type PaneWidthValue, _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 SegmentedControlActionProps, type SegmentedControlButtonProps, type SegmentedControlDividerProps, 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, _default$19 as Truncate, type TruncateProps, UnderlineNav, type UnderlineNavItemProps, type UnderlineNavProps, type UsePaneWidthOptions, type UsePaneWidthResult, VisuallyHidden, type VisuallyHiddenProps, type WithSlotMarker, asSlot, createComponent, defaultPaneWidth, isSlot, registerPortalRoot, theme, useAnchoredPosition, useColorSchemeVar, useConfirm, useDetails, useFocusTrap, useFocusZone, useFormControlForwardedProps, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnEscapePress, useOnOutsideClick, useOpenAndCloseFocus, useOverlay, usePaneWidth, useProvidedRefOrCreate, useRefObjectAsForwardedRef, useResizeObserver, useResponsiveValue, useRovingTabIndex, useSafeTimeout, useSlots, useSyncedState, useTheme };
@@ -0,0 +1,10 @@
1
+ import { AnchorProps } from "../utils/mergeAnchorProps.js";
2
+ import React from "react";
3
+
4
+ //#region src/internal/components/RenderAnchor.d.ts
5
+ type AnchorRenderProps = React.HTMLAttributes<HTMLElement> & {
6
+ ref: React.RefCallback<HTMLElement>;
7
+ };
8
+ type AnchorRenderer = React.ReactElement<AnchorProps> | ((props: AnchorRenderProps) => React.ReactElement);
9
+ //#endregion
10
+ export { AnchorRenderProps, AnchorRenderer };
@@ -0,0 +1,71 @@
1
+ import { c } from "../../utils/react-compiler-runtime.js";
2
+ import { reactMajorVersion } from "../../utils/environment.js";
3
+ import { useMergedRefs } from "../../hooks/useMergedRefs.js";
4
+ import { invariant } from "../../utils/invariant.js";
5
+ import { mergeAnchorProps } from "../utils/mergeAnchorProps.js";
6
+ import React from "react";
7
+ //#region src/internal/components/RenderAnchor.tsx
8
+ function RenderAnchor(t0) {
9
+ const $ = c(13);
10
+ const { render, props } = t0;
11
+ const element = typeof render === "function" ? void 0 : render;
12
+ !(typeof render === "function" || /*#__PURE__*/ React.isValidElement(element) && element.type !== React.Fragment) && invariant(false, "`renderAnchor` must render a single interactive element, not a React Fragment.");
13
+ const elementRef = reactMajorVersion > 18 ? element === null || element === void 0 ? void 0 : element.props.ref : element === null || element === void 0 ? void 0 : element.ref;
14
+ const ref = useMergedRefs(props.ref, elementRef);
15
+ if (typeof render === "function") {
16
+ let t1;
17
+ if ($[0] !== props || $[1] !== ref || $[2] !== render) {
18
+ t1 = render({
19
+ ...props,
20
+ ref
21
+ });
22
+ $[0] = props;
23
+ $[1] = ref;
24
+ $[2] = render;
25
+ $[3] = t1;
26
+ } else t1 = $[3];
27
+ return t1;
28
+ }
29
+ let t1;
30
+ if ($[4] !== props || $[5] !== ref || $[6] !== render) {
31
+ const merged = mergeAnchorProps(props, render.props);
32
+ const t2 = preventDisabledActivation(merged.onClick);
33
+ const t3 = preventDisabledActivation(merged.onKeyDown);
34
+ let t4;
35
+ if ($[8] !== merged || $[9] !== ref || $[10] !== t2 || $[11] !== t3) {
36
+ t4 = {
37
+ ...merged,
38
+ onClick: t2,
39
+ onKeyDown: t3,
40
+ ref
41
+ };
42
+ $[8] = merged;
43
+ $[9] = ref;
44
+ $[10] = t2;
45
+ $[11] = t3;
46
+ $[12] = t4;
47
+ } else t4 = $[12];
48
+ t1 = /*#__PURE__*/ React.cloneElement(render, t4);
49
+ $[4] = props;
50
+ $[5] = ref;
51
+ $[6] = render;
52
+ $[7] = t1;
53
+ } else t1 = $[7];
54
+ return t1;
55
+ }
56
+ function preventDisabledActivation(handler) {
57
+ return (event) => {
58
+ if ((!("key" in event) || [
59
+ "Enter",
60
+ " ",
61
+ "ArrowDown",
62
+ "ArrowUp"
63
+ ].some((key) => event.key === key)) && (event.currentTarget.matches(":disabled") || event.currentTarget.getAttribute("aria-disabled") === "true")) {
64
+ event.preventDefault();
65
+ return;
66
+ }
67
+ handler === null || handler === void 0 || handler(event);
68
+ };
69
+ }
70
+ //#endregion
71
+ export { RenderAnchor };
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+
3
+ //#region src/internal/utils/mergeAnchorProps.d.ts
4
+ type AnchorProps = React.HTMLAttributes<HTMLElement> & {
5
+ ref?: React.RefCallback<HTMLElement> | {
6
+ readonly current: HTMLElement | null;
7
+ } | null;
8
+ };
9
+ //#endregion
10
+ export { AnchorProps };
@@ -0,0 +1,18 @@
1
+ import { mergeProps } from "../../utils/mergeProps.js";
2
+ import { clsx } from "clsx";
3
+ //#region src/internal/utils/mergeAnchorProps.ts
4
+ function mergeAnchorProps(props, elementProps) {
5
+ const labelledBy = mergeIds(elementProps["aria-labelledby"], props["aria-labelledby"]);
6
+ const describedBy = mergeIds(elementProps["aria-describedby"], props["aria-describedby"]);
7
+ return {
8
+ ...mergeProps(props, elementProps, { eventHandlerOrder: "consumer-first" }),
9
+ className: clsx(elementProps.className, props.className) || void 0,
10
+ ...labelledBy ? { "aria-labelledby": labelledBy } : {},
11
+ ...describedBy ? { "aria-describedby": describedBy } : {}
12
+ };
13
+ }
14
+ function mergeIds(first, second) {
15
+ return [...new Set(`${first !== null && first !== void 0 ? first : ""} ${second !== null && second !== void 0 ? second : ""}`.split(/\s+/).filter(Boolean))].join(" ") || void 0;
16
+ }
17
+ //#endregion
18
+ export { mergeAnchorProps };
@@ -0,0 +1,48 @@
1
+ import { clsx } from "clsx";
2
+ //#region src/utils/mergeProps.ts
3
+ /**
4
+ * Applies our rules for merging props between two objects. This utility handles the following scenarios:
5
+ *
6
+ * - Merging `className` values
7
+ * - Merging event handlers
8
+ * - Merging `style` values
9
+ *
10
+ * In other cases, if a key exists in both `A` and `B` then the value in `B` will be used in the final result
11
+ */
12
+ function mergeProps(a, b, options) {
13
+ const merged = { ...a };
14
+ for (const [key, value] of Object.entries(b)) if (key in merged) {
15
+ const existing = merged[key];
16
+ if (key === "className") merged[key] = clsx(existing, value);
17
+ else if (isEventHandlerKey(key) && isEventHandler(existing)) {
18
+ if (isEventHandler(value)) merged[key] = (options === null || options === void 0 ? void 0 : options.eventHandlerOrder) === "consumer-first" ? composeEventHandlers(value, existing) : composeEventHandlers(existing, value);
19
+ else if (value !== void 0) merged[key] = value;
20
+ } else if (key === "style") merged[key] = mergeStyle(existing, value);
21
+ else merged[key] = value;
22
+ } else merged[key] = value;
23
+ return merged;
24
+ }
25
+ function composeEventHandlers(a, b) {
26
+ return (...args) => {
27
+ a(...args);
28
+ const event = args[0];
29
+ if (!(event !== null && event !== void 0 && event.defaultPrevented)) b(...args);
30
+ };
31
+ }
32
+ function isEventHandlerKey(key) {
33
+ return key.startsWith("on");
34
+ }
35
+ function isEventHandler(value) {
36
+ return typeof value === "function";
37
+ }
38
+ function mergeStyle(a, b) {
39
+ return {
40
+ ...isObject(a) ? a : {},
41
+ ...isObject(b) ? b : {}
42
+ };
43
+ }
44
+ function isObject(value) {
45
+ return typeof value === "object" && value !== null;
46
+ }
47
+ //#endregion
48
+ export { mergeProps };
@@ -743,11 +743,6 @@
743
743
  ],
744
744
  "importPath": "@primer/react",
745
745
  "props": [
746
- {
747
- "name": "renderAnchor",
748
- "type": "(props: ActionMenuAnchorRenderProps) => React.ReactElement",
749
- "description": "Render a custom trigger instead of ActionMenu.Button or ActionMenu.Anchor. Forward every supplied prop, including ref, to a single interactive HTML element."
750
- },
751
746
  {
752
747
  "name": "children",
753
748
  "type": "React.ReactElement[]",
@@ -937,9 +932,9 @@
937
932
  },
938
933
  {
939
934
  "name": "renderAnchor",
940
- "type": "<T extends React.HTMLAttributes<HTMLElement>>(props: T, context?: AnchoredOverlayAnchorContext) => JSX.Element",
935
+ "type": "<T extends React.HTMLAttributes<HTMLElement>>(props: T) => JSX.Element",
941
936
  "defaultValue": "",
942
- "description": "Render the anchor element. The second argument exposes the same object ref already supplied in the props, for composing trigger behaviors. Existing one-argument callbacks remain supported. When renderAnchor is null, an anchorRef is required."
937
+ "description": "A custom function component used to render the anchor element. When renderAnchor is null, an anchorRef is required."
943
938
  },
944
939
  {
945
940
  "name": "anchorRef",
@@ -9114,11 +9109,6 @@
9114
9109
  }
9115
9110
  ],
9116
9111
  "props": [
9117
- {
9118
- "name": "renderAnchor",
9119
- "type": "(props: TooltipAnchorProps) => React.ReactElement",
9120
- "description": "Render a single interactive trigger instead of children. Forward every supplied prop, including the callback ref, to that element. Tooltip combines its internal ref with any forwarded ref."
9121
- },
9122
9112
  {
9123
9113
  "name": "direction",
9124
9114
  "type": "'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw'",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20261113163104",
4
+ "version": "0.0.0-20261113210458",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",