@primer/react 0.0.0-20261113153150 → 0.0.0-20261113171005

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,17 +1,17 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20261113153150
3
+ ## 0.0.0-20261113171005
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)! - ActionMenu, AnchoredOverlay, Tooltip: Add experimental element-based trigger composition through `@primer/react/experimental`, with automatically merged trigger props and refs.
10
+
9
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.
10
12
 
11
13
  ### Patch Changes
12
14
 
13
- - [#8748](https://github.com/primer/react/pull/8748) [`a3d58eb`](https://github.com/primer/react/commit/a3d58ebf31ce2c36c3ae5d16899bea6da2d7bbcc) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Breadcrumbs: Collapse crumbs that render more than one element (such as a link with a sibling button) when they no longer fit, instead of overflowing the container.
14
-
15
15
  - [#8683](https://github.com/primer/react/pull/8683) [`32d5061`](https://github.com/primer/react/commit/32d50618c58cceddf66d83716ac9742c2134b790) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Breadcrumbs: Improve the performance of `overflow="menu"` and `"menu-with-root"` on mount, resize and navigation. Server-rendered markup now applies the collapse rules before hydration, and the overflow menu trigger is a `<button>`.
16
16
 
17
17
  - [#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: Improve shrinking and equal-height layouts, keep secondary controls accessible in custom whole-card compositions, and keep images edge-to-edge across padding options.
@@ -1,9 +1,11 @@
1
+ import { useMergedRefs } from "../hooks/useMergedRefs.js";
1
2
  import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
2
3
  import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
3
4
  import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
4
5
  import { useMenuKeyboardNavigation } from "../hooks/useMenuKeyboardNavigation.js";
5
6
  import { useId as useId$1 } from "../hooks/useId.js";
6
7
  import { isSlot } from "../utils/is-slot.js";
8
+ import { invariant } from "../utils/invariant.js";
7
9
  import { Tooltip } from "../TooltipV2/Tooltip.js";
8
10
  import { ButtonComponent } from "../Button/Button.js";
9
11
  import { useResponsiveValue } from "../hooks/useResponsiveValue.js";
@@ -44,7 +46,7 @@ const mergeAnchorHandlers = (anchorProps, buttonProps) => {
44
46
  if (buttonProps.className) mergedAnchorProps.className = clsx(anchorProps.className, buttonProps.className);
45
47
  return mergedAnchorProps;
46
48
  };
47
- const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children }) => {
49
+ const ActionMenuImpl = ({ anchorRef: externalAnchorRef, open, onOpenChange, children, renderAnchor: customRenderAnchor }) => {
48
50
  const parentMenuContext = useContext(MenuContext);
49
51
  const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate(open, onOpenChange, false);
50
52
  const onOpen = React.useCallback(() => setCombinedOpenState(true), [setCombinedOpenState]);
@@ -65,10 +67,17 @@ const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children }) =>
65
67
  ]);
66
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)));
67
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.");
68
72
  const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
73
+ const callbackAnchorRef = useMergedRefs(anchorRef, void 0);
69
74
  const anchorId = useId$1(menuButtonChildId);
70
- let renderAnchor = null;
75
+ let renderAnchor = useMemo(() => customRenderAnchor ? (props) => customRenderAnchor({
76
+ ...props,
77
+ ref: callbackAnchorRef
78
+ }) : null, [customRenderAnchor, callbackAnchorRef]);
71
79
  const contents = React.Children.map(children, (child) => {
80
+ if (customRenderAnchor) return child;
72
81
  if (child.type === Tooltip || isSlot(child, Tooltip)) {
73
82
  const anchorChildren = child.props.children;
74
83
  if (anchorChildren.type === MenuButton || isSlot(anchorChildren, MenuButton)) renderAnchor = (anchorProps) => {
@@ -109,7 +118,8 @@ const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children }) =>
109
118
  open: combinedOpenState,
110
119
  onOpen,
111
120
  onClose,
112
- isSubmenu
121
+ isSubmenu,
122
+ isCustomAnchor: Boolean(customRenderAnchor)
113
123
  }), [
114
124
  anchorRef,
115
125
  renderAnchor,
@@ -117,7 +127,8 @@ const Menu = ({ anchorRef: externalAnchorRef, open, onOpenChange, children }) =>
117
127
  combinedOpenState,
118
128
  onOpen,
119
129
  onClose,
120
- isSubmenu
130
+ isSubmenu,
131
+ customRenderAnchor
121
132
  ]);
122
133
  return /* @__PURE__ */ jsx(MenuContext.Provider, {
123
134
  value: menuContextValue,
@@ -177,7 +188,7 @@ const defaultVariant = {
177
188
  narrow: "anchored"
178
189
  };
179
190
  const Overlay = ({ children, align = "start", side, onPositionChange, displayInViewport, "aria-labelledby": ariaLabelledby, variant = defaultVariant, ...overlayProps }) => {
180
- 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);
181
192
  const containerRef = React.useRef(null);
182
193
  const isNarrowFullscreen = !!useResponsiveValue({ narrow: true }, false) && variant.narrow === "fullscreen";
183
194
  const handleClose = React.useCallback((gesture) => {
@@ -194,11 +205,15 @@ const Overlay = ({ children, align = "start", side, onPositionChange, displayInV
194
205
  const [anchorAriaLabelledby, setAnchorAriaLabelledby] = useState(null);
195
206
  useIsomorphicLayoutEffect(() => {
196
207
  if (open) {
197
- var _anchorRef$current$ge, _anchorRef$current;
198
- 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);
199
210
  setAnchorLabelReady(true);
200
211
  }
201
- }, [anchorRef, open]);
212
+ }, [
213
+ anchorRef,
214
+ open,
215
+ isCustomAnchor
216
+ ]);
202
217
  const afterSelect = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose("item-select"), [onClose]);
203
218
  const overlayContextValue = useMemo(() => ({
204
219
  container: "ActionMenu",
@@ -245,6 +260,7 @@ const Overlay = ({ children, align = "start", side, onPositionChange, displayInV
245
260
  })
246
261
  });
247
262
  };
263
+ const Menu = ActionMenuImpl;
248
264
  Menu.displayName = "ActionMenu";
249
265
  MenuButton.__SLOT__ = Symbol("ActionMenu.Button");
250
266
  Anchor.__SLOT__ = Symbol("ActionMenu.Anchor");
@@ -256,4 +272,4 @@ const ActionMenu = Object.assign(Menu, {
256
272
  Divider
257
273
  });
258
274
  //#endregion
259
- export { ActionMenu };
275
+ export { ActionMenu, ActionMenuImpl };
@@ -61,12 +61,6 @@ function getContentWidth(nav) {
61
61
  const { paddingLeft, paddingRight } = getComputedStyle(nav);
62
62
  return nav.clientWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
63
63
  }
64
- function getCrumbWidth(li, range) {
65
- range.selectNodeContents(li);
66
- const last = li.lastElementChild;
67
- if (last !== null && last !== void 0 && last.classList.contains(Breadcrumbs_module_css_default.ItemSeparator)) range.setEndBefore(last);
68
- return range.getBoundingClientRect().width;
69
- }
70
64
  const sameFit = (a, b) => a.extra === b.extra && a.rootCollapsed === b.rootCollapsed && a.narrow === b.narrow;
71
65
  function getValidChildren(children) {
72
66
  return React.Children.toArray(children).filter((child) => /*#__PURE__*/ React.isValidElement(child));
@@ -251,7 +245,6 @@ function Breadcrumbs(t0) {
251
245
  const previous = widthsRef.current;
252
246
  const widths_0 = /* @__PURE__ */ new Map();
253
247
  let separators = separatorsRef.current;
254
- const range = nav.ownerDocument.createRange();
255
248
  for (const item_0 of items) {
256
249
  var _item_0$key;
257
250
  const width = previous.get((_item_0$key = item_0.key) !== null && _item_0$key !== void 0 ? _item_0$key : "");
@@ -263,8 +256,9 @@ function Breadcrumbs(t0) {
263
256
  for (const li of nav.querySelectorAll(":scope > ol > li[data-index]")) {
264
257
  var _items$Number;
265
258
  const key = (_items$Number = items[Number(li.getAttribute("data-index"))]) === null || _items$Number === void 0 ? void 0 : _items$Number.key;
266
- if (key == null) continue;
267
- const crumbWidth = getCrumbWidth(li, range);
259
+ const crumb = li.firstElementChild;
260
+ if (key == null || !crumb) continue;
261
+ const crumbWidth = crumb.getBoundingClientRect().width;
268
262
  widths_0.set(key, crumbWidth);
269
263
  if (li.nextElementSibling && !li.hasAttribute("data-collapsed")) {
270
264
  const separator = li.getBoundingClientRect().width - crumbWidth;
@@ -1,4 +1,3 @@
1
- import { c } from "../utils/react-compiler-runtime.js";
2
1
  import { reactMajorVersion } from "../utils/environment.js";
3
2
  import { useMergedRefs } from "../hooks/useMergedRefs.js";
4
3
  import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
@@ -14,7 +13,7 @@ import { KeybindingHint } from "../KeybindingHint/KeybindingHint.js";
14
13
  import { getAccessibleKeybindingHintString } from "../KeybindingHint/utils.js";
15
14
  import useSafeTimeout from "../hooks/useSafeTimeout.js";
16
15
  import { TooltipContext } from "./TooltipContext.js";
17
- import React, { Children, useEffect, useRef, useState } from "react";
16
+ import React, { Children, useEffect, useMemo, useRef, useState } from "react";
18
17
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
18
  import { clsx } from "clsx";
20
19
  import { getAnchoredPosition } from "@primer/behaviors";
@@ -81,50 +80,11 @@ const isInteractive = (element) => {
81
80
  return interactiveElements.some((selector) => element.matches(selector)) || element.hasAttribute("role") && element.getAttribute("role") === "button";
82
81
  };
83
82
  const emptyKeybindingHints = [];
84
- const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
85
- const $ = c(60);
86
- let children;
87
- let className;
88
- let id;
89
- let rest;
90
- let t1;
91
- let t2;
92
- let t3;
93
- let t4;
94
- let t5;
95
- let text;
96
- if ($[0] !== t0) {
97
- ({direction: t1, text, type: t2, children, id, className, keybindingHint: t3, delay: t4, _privateDisableTooltip: t5, ...rest} = t0);
98
- $[0] = t0;
99
- $[1] = children;
100
- $[2] = className;
101
- $[3] = id;
102
- $[4] = rest;
103
- $[5] = t1;
104
- $[6] = t2;
105
- $[7] = t3;
106
- $[8] = t4;
107
- $[9] = t5;
108
- $[10] = text;
109
- } else {
110
- children = $[1];
111
- className = $[2];
112
- id = $[3];
113
- rest = $[4];
114
- t1 = $[5];
115
- t2 = $[6];
116
- t3 = $[7];
117
- t4 = $[8];
118
- t5 = $[9];
119
- text = $[10];
120
- }
121
- const direction = t1 === void 0 ? "s" : t1;
122
- const type = t2 === void 0 ? "description" : t2;
123
- const keybindingHint = t3 === void 0 ? emptyKeybindingHints : t3;
124
- const delay = t4 === void 0 ? "short" : t4;
125
- const _privateDisableTooltip = t5 === void 0 ? false : t5;
83
+ const TooltipImpl = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, renderAnchor, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
126
84
  const tooltipId = useId$1(id);
127
- const child = Children.only(children);
85
+ const hasRenderAnchor = renderAnchor !== void 0;
86
+ renderAnchor && children != null && invariant(false, "Pass either `children` or `renderAnchor` to `Tooltip`, not both.");
87
+ const child = renderAnchor ? void 0 : Children.only(children);
128
88
  const isFragmentTrigger = /*#__PURE__*/ React.isValidElement(child) && child.type === React.Fragment;
129
89
  warning(isFragmentTrigger, "The `Tooltip` component does not support a React Fragment as its trigger. Pass a single interactive element instead.");
130
90
  const elementChild = /*#__PURE__*/ React.isValidElement(child) ? child : void 0;
@@ -133,281 +93,166 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
133
93
  const triggerRef = useRef(null);
134
94
  const mergedTriggerRef = useMergedRefs(triggerRef, useMergedRefs(forwardedRef, childRef));
135
95
  const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : childRef);
136
- const readTriggerRef = mergedRefEnabled ? triggerRef : providedOrCreatedRef;
137
- const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
96
+ const readTriggerRef = renderAnchor || mergedRefEnabled ? triggerRef : providedOrCreatedRef;
97
+ const appliedTriggerRef = renderAnchor || mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
138
98
  const tooltipElRef = useRef(null);
139
99
  const [calculatedDirection, setCalculatedDirection] = useState(direction);
140
100
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
141
101
  const openTimeoutRef = React.useRef(null);
142
102
  const { safeSetTimeout, safeClearTimeout } = useSafeTimeout();
143
- let t6;
144
- if ($[11] !== _privateDisableTooltip || $[12] !== direction || $[13] !== readTriggerRef) {
145
- t6 = () => {
146
- try {
147
- if (tooltipElRef.current && readTriggerRef.current instanceof HTMLElement && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
148
- const tooltip = tooltipElRef.current;
149
- const trigger = readTriggerRef.current;
150
- tooltip.showPopover();
151
- setIsPopoverOpen(true);
152
- const settings = {
153
- side: directionToPosition[direction].side,
154
- align: directionToPosition[direction].align
155
- };
156
- const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, settings);
157
- const calculatedDirection_0 = positionToDirection[`${anchorSide}-${anchorAlign}`];
158
- setCalculatedDirection(calculatedDirection_0);
159
- tooltip.style.top = `${top}px`;
160
- tooltip.style.left = `${left}px`;
161
- }
162
- } catch (t7) {
163
- const error = t7;
164
- if (error && typeof error === "object" && "message" in error && typeof error.message === "string" && error.message.includes("not a valid selector")) {} else throw error;
165
- }
166
- };
167
- $[11] = _privateDisableTooltip;
168
- $[12] = direction;
169
- $[13] = readTriggerRef;
170
- $[14] = t6;
171
- } else t6 = $[14];
172
- const openTooltip = t6;
173
- let t7;
174
- if ($[15] !== readTriggerRef || $[16] !== safeClearTimeout) {
175
- t7 = () => {
176
- if (openTimeoutRef.current) {
177
- safeClearTimeout(openTimeoutRef.current);
178
- openTimeoutRef.current = null;
179
- }
180
- try {
181
- if (tooltipElRef.current && readTriggerRef.current && tooltipElRef.current.hasAttribute("popover") && tooltipElRef.current.matches(":popover-open")) {
182
- tooltipElRef.current.hidePopover();
183
- setIsPopoverOpen(false);
184
- } else setIsPopoverOpen(false);
185
- } catch (t8) {
186
- const error_0 = t8;
187
- if (error_0 && typeof error_0 === "object" && "message" in error_0 && typeof error_0.message === "string" && error_0.message.includes("not a valid selector")) {} else throw error_0;
103
+ const openTooltip = () => {
104
+ try {
105
+ if (tooltipElRef.current && readTriggerRef.current instanceof HTMLElement && tooltipElRef.current.hasAttribute("popover") && !tooltipElRef.current.matches(":popover-open") && !_privateDisableTooltip) {
106
+ const tooltip = tooltipElRef.current;
107
+ const trigger = readTriggerRef.current;
108
+ if (hasRenderAnchor && trigger.matches(":disabled")) return;
109
+ tooltip.showPopover();
110
+ setIsPopoverOpen(true);
111
+ const settings = {
112
+ side: directionToPosition[direction].side,
113
+ align: directionToPosition[direction].align
114
+ };
115
+ const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, settings);
116
+ const calculatedDirection = positionToDirection[`${anchorSide}-${anchorAlign}`];
117
+ setCalculatedDirection(calculatedDirection);
118
+ tooltip.style.top = `${top}px`;
119
+ tooltip.style.left = `${left}px`;
188
120
  }
189
- };
190
- $[15] = readTriggerRef;
191
- $[16] = safeClearTimeout;
192
- $[17] = t7;
193
- } else t7 = $[17];
194
- const closeTooltip = t7;
195
- let t8;
196
- if ($[18] !== tooltipId) {
197
- t8 = { tooltipId };
198
- $[18] = tooltipId;
199
- $[19] = t8;
200
- } else t8 = $[19];
201
- const value = t8;
202
- let t9;
203
- if ($[20] !== readTriggerRef || $[21] !== type) {
204
- t9 = () => {
205
- if (!tooltipElRef.current || !readTriggerRef.current) return;
206
- const trigger_0 = readTriggerRef.current;
207
- const isInvalidTrigger = !(trigger_0 instanceof HTMLElement);
208
- 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.");
209
- if (isInvalidTrigger) return;
210
- const isTriggerInteractive = isInteractive(trigger_0);
211
- const triggerChildren = trigger_0.childNodes;
212
- const hasInteractiveDescendant = Array.from(triggerChildren).some(_temp2);
213
- !(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.");
214
- if (type === "label") {
215
- const hasAriaLabel = trigger_0.hasAttribute("aria-label");
216
- const hasAriaLabelInChildren = Array.from(trigger_0.childNodes).some(_temp3);
217
- 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.");
218
- }
219
- if (typeof window !== "undefined") {
220
- if (!isSupported()) apply();
221
- }
222
- tooltipElRef.current.setAttribute("popover", "auto");
223
- };
224
- $[20] = readTriggerRef;
225
- $[21] = type;
226
- $[22] = t9;
227
- } else t9 = $[22];
228
- let t10;
229
- if ($[23] !== direction || $[24] !== readTriggerRef || $[25] !== type) {
230
- t10 = [
231
- tooltipElRef,
232
- readTriggerRef,
233
- direction,
234
- type
235
- ];
236
- $[23] = direction;
237
- $[24] = readTriggerRef;
238
- $[25] = type;
239
- $[26] = t10;
240
- } else t10 = $[26];
241
- useEffect(t9, t10);
242
- let t11;
243
- if ($[27] !== _privateDisableTooltip || $[28] !== closeTooltip || $[29] !== isPopoverOpen) {
244
- t11 = (event) => {
245
- if (isPopoverOpen) {
246
- if (!_privateDisableTooltip) {
247
- event.stopImmediatePropagation();
248
- event.preventDefault();
249
- }
250
- closeTooltip();
121
+ } catch (error) {
122
+ if (error && typeof error === "object" && "message" in error && typeof error.message === "string" && error.message.includes("not a valid selector")) {} else throw error;
123
+ }
124
+ };
125
+ const closeTooltip = () => {
126
+ if (openTimeoutRef.current) {
127
+ safeClearTimeout(openTimeoutRef.current);
128
+ openTimeoutRef.current = null;
129
+ }
130
+ try {
131
+ if (tooltipElRef.current && readTriggerRef.current && tooltipElRef.current.hasAttribute("popover") && tooltipElRef.current.matches(":popover-open")) {
132
+ tooltipElRef.current.hidePopover();
133
+ setIsPopoverOpen(false);
134
+ } else setIsPopoverOpen(false);
135
+ } catch (error) {
136
+ if (error && typeof error === "object" && "message" in error && typeof error.message === "string" && error.message.includes("not a valid selector")) {} else throw error;
137
+ }
138
+ };
139
+ const value = useMemo(() => ({ tooltipId }), [tooltipId]);
140
+ useEffect(() => {
141
+ if (!tooltipElRef.current || !readTriggerRef.current) return;
142
+ const trigger = readTriggerRef.current;
143
+ const isInvalidTrigger = !(trigger instanceof HTMLElement);
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.");
145
+ if (isInvalidTrigger) return;
146
+ const isTriggerInteractive = isInteractive(trigger) || hasRenderAnchor && trigger.matches(":disabled");
147
+ const triggerChildren = trigger.childNodes;
148
+ const hasInteractiveDescendant = Array.from(triggerChildren).some((child) => {
149
+ return child instanceof HTMLElement && isInteractive(child) || Array.from(child.childNodes).some((grandChild) => grandChild instanceof HTMLElement && isInteractive(grandChild));
150
+ });
151
+ !(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.");
152
+ if (type === "label") {
153
+ const hasAriaLabel = trigger.hasAttribute("aria-label");
154
+ const hasAriaLabelInChildren = Array.from(trigger.childNodes).some((child) => child instanceof HTMLElement && child.hasAttribute("aria-label"));
155
+ 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.");
156
+ }
157
+ if (typeof window !== "undefined") {
158
+ if (!isSupported()) apply();
159
+ }
160
+ tooltipElRef.current.setAttribute("popover", "auto");
161
+ }, [
162
+ tooltipElRef,
163
+ readTriggerRef,
164
+ direction,
165
+ type,
166
+ hasRenderAnchor
167
+ ]);
168
+ useOnEscapePress((event) => {
169
+ if (isPopoverOpen) {
170
+ if (!_privateDisableTooltip) {
171
+ event.stopImmediatePropagation();
172
+ event.preventDefault();
251
173
  }
252
- };
253
- $[27] = _privateDisableTooltip;
254
- $[28] = closeTooltip;
255
- $[29] = isPopoverOpen;
256
- $[30] = t11;
257
- } else t11 = $[30];
258
- let t12;
259
- if ($[31] !== _privateDisableTooltip || $[32] !== isPopoverOpen) {
260
- t12 = [isPopoverOpen, _privateDisableTooltip];
261
- $[31] = _privateDisableTooltip;
262
- $[32] = isPopoverOpen;
263
- $[33] = t12;
264
- } else t12 = $[33];
265
- useOnEscapePress(t11, t12);
174
+ closeTooltip();
175
+ }
176
+ }, [isPopoverOpen, _privateDisableTooltip]);
266
177
  const platform = usePlatform();
267
- const hasAriaLabel_0 = "aria-label" in rest;
268
- let t13;
269
- if ($[34] !== keybindingHint) {
270
- t13 = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint];
271
- $[34] = keybindingHint;
272
- $[35] = t13;
273
- } else t13 = $[35];
274
- const keybindingHints = t13;
178
+ const hasAriaLabel = "aria-label" in rest;
179
+ const keybindingHints = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint];
275
180
  if (isFragmentTrigger) return child;
276
- const t14 = TooltipContext;
277
- const t15 = /*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
181
+ const triggerProps = {
278
182
  ref: appliedTriggerRef,
279
- "aria-describedby": (() => {
280
- if (type !== "description") return child.props["aria-describedby"];
281
- const existingDescribedBy = child.props["aria-describedby"];
282
- if (existingDescribedBy) return `${existingDescribedBy} ${tooltipId}`;
283
- return tooltipId;
284
- })(),
285
- "aria-labelledby": type === "label" ? tooltipId : child.props["aria-labelledby"],
286
- onBlur: (event_0) => {
287
- var _child$props$onBlur, _child$props;
183
+ ...type === "description" ? { "aria-describedby": [elementChild === null || elementChild === void 0 ? void 0 : elementChild.props["aria-describedby"], tooltipId].filter(Boolean).join(" ") } : {},
184
+ ...type === "label" ? { "aria-labelledby": tooltipId } : {},
185
+ onBlur: (event) => {
186
+ var _elementChild$props$o, _elementChild$props;
288
187
  closeTooltip();
289
- (_child$props$onBlur = (_child$props = child.props).onBlur) === null || _child$props$onBlur === void 0 || _child$props$onBlur.call(_child$props, event_0);
188
+ elementChild === null || elementChild === void 0 || (_elementChild$props$o = (_elementChild$props = elementChild.props).onBlur) === null || _elementChild$props$o === void 0 || _elementChild$props$o.call(_elementChild$props, event);
290
189
  },
291
- onTouchEnd: (event_1) => {
292
- var _child$props$onTouchE, _child$props2;
293
- (_child$props$onTouchE = (_child$props2 = child.props).onTouchEnd) === null || _child$props$onTouchE === void 0 || _child$props$onTouchE.call(_child$props2, event_1);
190
+ onTouchEnd: (event) => {
191
+ var _elementChild$props$o2, _elementChild$props2;
192
+ elementChild === null || elementChild === void 0 || (_elementChild$props$o2 = (_elementChild$props2 = elementChild.props).onTouchEnd) === null || _elementChild$props$o2 === void 0 || _elementChild$props$o2.call(_elementChild$props2, event);
294
193
  safeSetTimeout(() => closeTooltip(), 10);
295
194
  },
296
- onFocus: (event_2) => {
297
- var _child$props$onFocus, _child$props3;
195
+ onFocus: (event) => {
196
+ var _elementChild$props$o3, _elementChild$props3;
298
197
  try {
299
- if (!event_2.target.matches(":focus-visible")) return;
300
- } catch (t16) {}
198
+ if (!event.target.matches(":focus-visible")) return;
199
+ } catch (_error) {}
301
200
  openTooltip();
302
- (_child$props$onFocus = (_child$props3 = child.props).onFocus) === null || _child$props$onFocus === void 0 || _child$props$onFocus.call(_child$props3, event_2);
201
+ elementChild === null || elementChild === void 0 || (_elementChild$props$o3 = (_elementChild$props3 = elementChild.props).onFocus) === null || _elementChild$props$o3 === void 0 || _elementChild$props$o3.call(_elementChild$props3, event);
303
202
  },
304
- onMouseOverCapture: (event_3) => {
203
+ onMouseOverCapture: (event) => {
305
204
  const delayTime = delayTimeMap[delay] || 50;
306
205
  openTimeoutRef.current = safeSetTimeout(() => {
307
- var _child$props$onMouseE, _child$props4;
206
+ var _elementChild$props$o4, _elementChild$props4;
308
207
  if (!openTimeoutRef.current) return;
309
208
  openTooltip();
310
- (_child$props$onMouseE = (_child$props4 = child.props).onMouseEnter) === null || _child$props$onMouseE === void 0 || _child$props$onMouseE.call(_child$props4, event_3);
209
+ elementChild === null || elementChild === void 0 || (_elementChild$props$o4 = (_elementChild$props4 = elementChild.props).onMouseEnter) === null || _elementChild$props$o4 === void 0 || _elementChild$props$o4.call(_elementChild$props4, event);
311
210
  }, delayTime);
312
211
  },
313
- onMouseLeave: (event_4) => {
314
- var _child$props$onMouseL, _child$props5;
212
+ onMouseLeave: (event) => {
213
+ var _elementChild$props$o5, _elementChild$props5;
315
214
  closeTooltip();
316
- (_child$props$onMouseL = (_child$props5 = child.props).onMouseLeave) === null || _child$props$onMouseL === void 0 || _child$props$onMouseL.call(_child$props5, event_4);
215
+ elementChild === null || elementChild === void 0 || (_elementChild$props$o5 = (_elementChild$props5 = elementChild.props).onMouseLeave) === null || _elementChild$props$o5 === void 0 || _elementChild$props$o5.call(_elementChild$props5, event);
317
216
  }
318
- });
319
- let t17;
320
- if ($[36] !== className) {
321
- t17 = clsx(className, Tooltip_module_css_default.Tooltip);
322
- $[36] = className;
323
- $[37] = t17;
324
- } else t17 = $[37];
325
- const t18 = type === "description" ? "tooltip" : void 0;
326
- const t19 = hasAriaLabel_0 || keybindingHints.length === 0 ? tooltipId : void 0;
327
- let t20;
328
- if ($[38] !== hasAriaLabel_0 || $[39] !== keybindingHints || $[40] !== platform || $[41] !== text || $[42] !== tooltipId) {
329
- t20 = keybindingHints.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
330
- id: hasAriaLabel_0 ? void 0 : tooltipId,
331
- children: [text, /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
332
- "(",
333
- keybindingHints.map((hint) => getAccessibleKeybindingHintString(hint, platform)).join(" or "),
334
- ")"
335
- ] })]
336
- }), /* @__PURE__ */ jsx("span", {
337
- className: clsx(Tooltip_module_css_default.KeybindingHintContainer, text && Tooltip_module_css_default.HasTextBefore, keybindingHints.length > 1 && Tooltip_module_css_default.HasMultipleHints),
338
- "aria-hidden": true,
339
- "data-component": "Tooltip.KeybindingHintContainer",
340
- children: keybindingHints.map(_temp4)
341
- })] }) : text;
342
- $[38] = hasAriaLabel_0;
343
- $[39] = keybindingHints;
344
- $[40] = platform;
345
- $[41] = text;
346
- $[42] = tooltipId;
347
- $[43] = t20;
348
- } else t20 = $[43];
349
- let t21;
350
- if ($[44] !== calculatedDirection || $[45] !== closeTooltip || $[46] !== openTooltip || $[47] !== rest || $[48] !== t17 || $[49] !== t18 || $[50] !== t19 || $[51] !== t20) {
351
- t21 = /* @__PURE__ */ jsx("span", {
352
- className: t17,
217
+ };
218
+ return /* @__PURE__ */ jsx(TooltipContext.Provider, {
219
+ value,
220
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [renderAnchor ? renderAnchor({
221
+ ...triggerProps,
222
+ ref: mergedTriggerRef
223
+ }) : /*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, triggerProps), /* @__PURE__ */ jsx("span", {
224
+ className: clsx(className, Tooltip_module_css_default.Tooltip),
353
225
  ref: tooltipElRef,
354
226
  "data-direction": calculatedDirection,
355
227
  "data-component": "Tooltip",
356
228
  ...rest,
357
- role: t18,
229
+ role: type === "description" ? "tooltip" : void 0,
358
230
  "aria-hidden": true,
359
231
  onMouseEnter: openTooltip,
360
232
  onMouseLeave: closeTooltip,
361
- id: t19,
362
- children: t20
363
- });
364
- $[44] = calculatedDirection;
365
- $[45] = closeTooltip;
366
- $[46] = openTooltip;
367
- $[47] = rest;
368
- $[48] = t17;
369
- $[49] = t18;
370
- $[50] = t19;
371
- $[51] = t20;
372
- $[52] = t21;
373
- } else t21 = $[52];
374
- let t22;
375
- if ($[53] !== t15 || $[54] !== t21) {
376
- t22 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t15, t21] });
377
- $[53] = t15;
378
- $[54] = t21;
379
- $[55] = t22;
380
- } else t22 = $[55];
381
- let t23;
382
- if ($[56] !== t14.Provider || $[57] !== t22 || $[58] !== value) {
383
- t23 = /* @__PURE__ */ jsx(t14.Provider, {
384
- value,
385
- children: t22
386
- });
387
- $[56] = t14.Provider;
388
- $[57] = t22;
389
- $[58] = value;
390
- $[59] = t23;
391
- } else t23 = $[59];
392
- return t23;
233
+ id: hasAriaLabel || keybindingHints.length === 0 ? tooltipId : void 0,
234
+ children: keybindingHints.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
235
+ id: hasAriaLabel ? void 0 : tooltipId,
236
+ children: [text, /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
237
+ "(",
238
+ keybindingHints.map((hint) => getAccessibleKeybindingHintString(hint, platform)).join(" or "),
239
+ ")"
240
+ ] })]
241
+ }), /* @__PURE__ */ jsx("span", {
242
+ className: clsx(Tooltip_module_css_default.KeybindingHintContainer, text && Tooltip_module_css_default.HasTextBefore, keybindingHints.length > 1 && Tooltip_module_css_default.HasMultipleHints),
243
+ "aria-hidden": true,
244
+ "data-component": "Tooltip.KeybindingHintContainer",
245
+ children: keybindingHints.map((hint, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i > 0 && " or ", /* @__PURE__ */ jsx(KeybindingHint, {
246
+ keys: hint,
247
+ format: "condensed",
248
+ variant: "onEmphasis",
249
+ size: "small"
250
+ })] }, `${i}-${hint}`))
251
+ })] }) : text
252
+ })] })
253
+ });
393
254
  });
255
+ const Tooltip = TooltipImpl;
394
256
  Tooltip.__SLOT__ = Symbol("Tooltip");
395
- function _temp(grandChild) {
396
- return grandChild instanceof HTMLElement && isInteractive(grandChild);
397
- }
398
- function _temp2(child_0) {
399
- return child_0 instanceof HTMLElement && isInteractive(child_0) || Array.from(child_0.childNodes).some(_temp);
400
- }
401
- function _temp3(child_1) {
402
- return child_1 instanceof HTMLElement && child_1.hasAttribute("aria-label");
403
- }
404
- function _temp4(hint_0, i) {
405
- return /* @__PURE__ */ jsxs(React.Fragment, { children: [i > 0 && " or ", /* @__PURE__ */ jsx(KeybindingHint, {
406
- keys: hint_0,
407
- format: "condensed",
408
- variant: "onEmphasis",
409
- size: "small"
410
- })] }, `${i}-${hint_0}`);
411
- }
412
257
  //#endregion
413
- export { Tooltip };
258
+ export { Tooltip, TooltipImpl };
@@ -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 };
@@ -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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20261113153150",
4
+ "version": "0.0.0-20261113171005",
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",