@primer/react 38.34.0-rc.6e2d5aac5 → 38.34.0-rc.8fa435aeb

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.
@@ -1,9 +1,7 @@
1
1
  import { isExperimentalReactVersion, reactMajorVersion } from "../utils/environment.js";
2
2
  import { c } from "react-compiler-runtime";
3
- import { version } from "react";
3
+ import "react";
4
4
  //#region src/hooks/useMergedRefs.ts
5
- var _version$split$;
6
- const majorReactVersion = parseInt((_version$split$ = version.split(".")[0]) !== null && _version$split$ !== void 0 ? _version$split$ : "18", 10);
7
5
  /**
8
6
  * Cleanup functions for refs were introduced in React 19. For feature detection,
9
7
  * we look to see if current version of React is >= 19 or if it is an
@@ -28,18 +26,18 @@ const supportsRefCleanup = reactMajorVersion >= 19 || isExperimentalReactVersion
28
26
  * // React 18
29
27
  * const Example = forwardRef<HTMLButtonElement, {}>((props, forwardedRef) => {
30
28
  * const ref = useRef<HTMLButtonElement>(null)
31
- * const mergedRef = useMergedRefs(forwardedRef, ref)
29
+ * const combinedRef = useMergedRefs(forwardedRef, ref)
32
30
  *
33
- * return <button ref={mergedRef} />
31
+ * return <button ref={combinedRef} />
34
32
  * })
35
33
  *
36
34
  * @example
37
35
  * // React 19
38
36
  * const Example = ({ref: externalRef}: {ref?: Ref<HTMLButtonElement>}) => {
39
37
  * const ref = useRef<HTMLButtonElement>(null)
40
- * const mergedRef = useMergedRefs(externalRef, ref)
38
+ * const combinedRef = useMergedRefs(externalRef, ref)
41
39
  *
42
- * return <button ref={mergedRef} />
40
+ * return <button ref={combinedRef} />
43
41
  * }
44
42
  */
45
43
  function useMergedRefs(refA, refB) {
@@ -50,7 +48,6 @@ function useMergedRefs(refA, refB) {
50
48
  const cleanupA = setRef(refA, value);
51
49
  const cleanupB = setRef(refB, value);
52
50
  if (!supportsRefCleanup) return;
53
- if (majorReactVersion <= 18) return;
54
51
  return () => {
55
52
  if (cleanupA) cleanupA();
56
53
  else setRef(refA, null);
@@ -9,14 +9,17 @@ import React from "react";
9
9
  * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
10
10
  * @type TRef The type of the RefObject which should be created.
11
11
  *
12
- * @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
13
- * In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
14
- * {@linkcode useMergedRefs} instead.
12
+ * @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
13
+ * created ref instead.
15
14
  *
16
- * The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
17
- * element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
18
- * consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
19
- * internal element.
15
+ * ```diff
16
+ * - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
17
+ * + const ref = useRef(null)
18
+ * + const mergedRef = useMergedRefs(forwardedRef, ref)
19
+ *
20
+ * - return <div ref={ref} />
21
+ * + return <div ref={mergedRef} />
22
+ * ```
20
23
  */
21
24
  declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
22
25
  //#endregion
@@ -8,14 +8,17 @@ import React from "react";
8
8
  * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
9
9
  * @type TRef The type of the RefObject which should be created.
10
10
  *
11
- * @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
12
- * In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
13
- * {@linkcode useMergedRefs} instead.
11
+ * @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
12
+ * created ref instead.
14
13
  *
15
- * The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
16
- * element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
17
- * consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
18
- * internal element.
14
+ * ```diff
15
+ * - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
16
+ * + const ref = useRef(null)
17
+ * + const mergedRef = useMergedRefs(forwardedRef, ref)
18
+ *
19
+ * - return <div ref={ref} />
20
+ * + return <div ref={mergedRef} />
21
+ * ```
19
22
  */
20
23
  function useProvidedRefOrCreate(providedRef) {
21
24
  const createdRef = React.useRef(null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.34.0-rc.6e2d5aac5",
4
+ "version": "38.34.0-rc.8fa435aeb",
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",
@@ -77,6 +77,7 @@
77
77
  "dependencies": {
78
78
  "@github/mini-throttle": "^2.1.1",
79
79
  "@github/relative-time-element": "^5.0.0",
80
+ "@github/tab-container-element": "^4.8.2",
80
81
  "@lit-labs/react": "1.2.1",
81
82
  "@oddbird/popover-polyfill": "^0.5.2",
82
83
  "@primer/behaviors": "^1.10.3",