@primer/react 0.0.0-20260701234532 → 0.0.0-20260701235500

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,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260701234532
3
+ ## 0.0.0-20260701235500
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -1,4 +1,3 @@
1
- import { useMergedRefs } from "../hooks/useMergedRefs.js";
2
1
  import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
3
2
  import { useId as useId$1 } from "../hooks/useId.js";
4
3
  import { warning } from "../utils/warning.js";
@@ -16,21 +15,6 @@ import React, { Children, useEffect, useMemo, useRef, useState } from "react";
16
15
  import { getAnchoredPosition } from "@primer/behaviors";
17
16
  import { apply, isSupported } from "@oddbird/popover-polyfill/fn";
18
17
  //#region src/TooltipV2/Tooltip.tsx
19
- function mergeRefs(...refs) {
20
- return (value) => {
21
- const cleanups = [];
22
- for (const ref of refs) {
23
- if (!ref) continue;
24
- if (typeof ref === "function") {
25
- const cleanup = ref(value);
26
- if (typeof cleanup === "function") cleanups.push(cleanup);
27
- } else ref.current = value;
28
- }
29
- if (cleanups.length > 0) return () => {
30
- for (const cleanup of cleanups) cleanup();
31
- };
32
- };
33
- }
34
18
  const directionToPosition = {
35
19
  nw: {
36
20
  side: "outside-top",
@@ -95,11 +79,18 @@ const emptyKeybindingHints = [];
95
79
  const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
96
80
  const tooltipId = useId$1(id);
97
81
  const child = Children.only(children);
82
+ const childRef = child.props.ref;
98
83
  const triggerRef = useRef(null);
99
- const tooltipElRef = useRef(null);
100
- const mergedTooltipRef = useMergedRefs(forwardedRef, triggerRef);
101
- const childPropRef = /*#__PURE__*/ React.isValidElement(child) && "props" in child ? child.props.ref : void 0;
102
- const triggerMergedRef = useMemo(() => mergeRefs(mergedTooltipRef, childPropRef), [mergedTooltipRef, childPropRef]);
84
+ const tooltipElRef = React.useRef(null);
85
+ const assignRef = (ref, node) => {
86
+ if (typeof ref === "function") ref(node);
87
+ else if (ref) ref.current = node;
88
+ };
89
+ const setTriggerRef = (node) => {
90
+ assignRef(triggerRef, node);
91
+ assignRef(childRef, node);
92
+ assignRef(forwardedRef, node);
93
+ };
103
94
  const [calculatedDirection, setCalculatedDirection] = useState(direction);
104
95
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
105
96
  const openTimeoutRef = React.useRef(null);
@@ -175,7 +166,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
175
166
  return /*#__PURE__*/ jsx(TooltipContext.Provider, {
176
167
  value,
177
168
  children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
178
- ref: triggerMergedRef,
169
+ ref: setTriggerRef,
179
170
  "aria-describedby": (() => {
180
171
  if (type !== "description") return child.props["aria-describedby"];
181
172
  const existingDescribedBy = child.props["aria-describedby"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260701234532",
4
+ "version": "0.0.0-20260701235500",
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",