@primer/react 0.0.0-20260630210825 → 0.0.0-20260630224830
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/TooltipV2/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,yBAAyB,
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/TooltipV2/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,KAAK,yBAAyB,EAAC,MAAM,OAAO,CAAA;AASnG,OAAO,EAAoD,KAAK,mBAAmB,EAAC,MAAM,mBAAmB,CAAA;AAI7G,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AAG9C,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAA;AAChF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACjD,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,GAAG,aAAa,CAAA;IAC9B,cAAc,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAA;IACjF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACnC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAC,GACA,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AAmEnC,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAC7C,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CACvE,GACC,UAmSD,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, useState, useMemo, useEffect } from 'react';
|
|
2
2
|
import { invariant } from '../utils/invariant.js';
|
|
3
3
|
import { warning } from '../utils/warning.js';
|
|
4
4
|
import { getAnchoredPosition } from '@primer/behaviors';
|
|
@@ -11,7 +11,7 @@ import useSafeTimeout from '../hooks/useSafeTimeout.js';
|
|
|
11
11
|
import { TooltipContext } from './TooltipContext.js';
|
|
12
12
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
13
|
import { useId } from '../hooks/useId.js';
|
|
14
|
-
import {
|
|
14
|
+
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
15
15
|
import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
|
|
16
16
|
import { getAccessibleKeybindingHintString } from '../KeybindingHint/utils.js';
|
|
17
17
|
import { KeybindingHint } from '../KeybindingHint/KeybindingHint.js';
|
|
@@ -92,9 +92,8 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
92
92
|
}, forwardedRef) => {
|
|
93
93
|
const tooltipId = useId(id);
|
|
94
94
|
const child = Children.only(children);
|
|
95
|
-
const triggerRef =
|
|
96
|
-
const
|
|
97
|
-
const tooltipElRef = useRef(null);
|
|
95
|
+
const triggerRef = useProvidedRefOrCreate(forwardedRef);
|
|
96
|
+
const tooltipElRef = React.useRef(null);
|
|
98
97
|
const [calculatedDirection, setCalculatedDirection] = useState(direction);
|
|
99
98
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
100
99
|
const openTimeoutRef = React.useRef(null);
|
|
@@ -207,7 +206,8 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
207
206
|
value: value,
|
|
208
207
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
209
208
|
children: [/*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.cloneElement(child, {
|
|
210
|
-
ref
|
|
209
|
+
// @ts-expect-error it needs a non nullable ref
|
|
210
|
+
ref: triggerRef,
|
|
211
211
|
// If it is a type description, we use tooltip to describe the trigger
|
|
212
212
|
'aria-describedby': (() => {
|
|
213
213
|
// If tooltip is not a description type, keep the original aria-describedby
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMergedRefs.d.ts","sourceRoot":"","sources":["../../src/hooks/useMergedRefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,GAAG,IAAI,WAAW,EAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"useMergedRefs.d.ts","sourceRoot":"","sources":["../../src/hooks/useMergedRefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,GAAG,IAAI,WAAW,EAAmB,MAAM,OAAO,CAAA;AAe7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,WAE7D,CAAC,GAAG,IAAI,8BAwBnB;AAED,KAAK,eAAe,GAAG,MAAM,IAAI,CAAA;AAEjC;;;GAGG;AAEH,KAAK,kBAAkB,CAAC,CAAC,IAAI;IAC3B,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,GAAG,eAAe,CAAA;CACpD,CAAC,gBAAgB,CAAC,CAAA;AAEnB;;;;;;;GAOG;AACH,KAAK,GAAG,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
1
|
+
import { useCallback, version } from 'react';
|
|
2
2
|
import { reactMajorVersion, isExperimentalReactVersion } from '../utils/environment.js';
|
|
3
3
|
|
|
4
|
+
var _version$split$;
|
|
5
|
+
const majorReactVersion = parseInt((_version$split$ = version.split('.')[0]) !== null && _version$split$ !== void 0 ? _version$split$ : '18', 10);
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Cleanup functions for refs were introduced in React 19. For feature detection,
|
|
6
9
|
* we look to see if current version of React is >= 19 or if it is an
|
|
@@ -50,8 +53,9 @@ function useMergedRefs(refA, refB) {
|
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
//
|
|
56
|
+
// Callback refs only work in React 19+. In React 18, the ref will get called with
|
|
54
57
|
// `null` which will be passed to each ref as expected.
|
|
58
|
+
if (majorReactVersion <= 18) return;
|
|
55
59
|
return () => {
|
|
56
60
|
// For object refs and callback refs that don't return cleanups, we still need to pass `null` on cleanup
|
|
57
61
|
if (cleanupA) cleanupA();else setRef(refA, null);
|
package/package.json
CHANGED