@primer/react 0.0.0-20260403170759 → 0.0.0-20260403172558

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/dist/ActionBar/ActionBar-94abaa40.css +2 -0
  3. package/dist/ActionBar/ActionBar-94abaa40.css.map +1 -0
  4. package/dist/ActionBar/ActionBar.d.ts +1 -1
  5. package/dist/ActionBar/ActionBar.d.ts.map +1 -1
  6. package/dist/ActionBar/ActionBar.js +312 -367
  7. package/dist/ActionBar/ActionBar.module.css.js +2 -2
  8. package/dist/ActionBar/index.d.ts +1 -1
  9. package/dist/ActionList/List.d.ts.map +1 -1
  10. package/dist/ActionList/List.js +41 -41
  11. package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
  12. package/dist/AnchoredOverlay/AnchoredOverlay.js +13 -3
  13. package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  14. package/dist/ButtonGroup/ButtonGroup.js +23 -23
  15. package/dist/Checkbox/Checkbox.d.ts.map +1 -1
  16. package/dist/Checkbox/Checkbox.js +5 -5
  17. package/dist/Dialog/Dialog.d.ts.map +1 -1
  18. package/dist/Dialog/Dialog.js +7 -5
  19. package/dist/PageHeader/PageHeader.d.ts.map +1 -1
  20. package/dist/PageHeader/PageHeader.js +31 -30
  21. package/dist/TextInput/TextInput.d.ts.map +1 -1
  22. package/dist/TextInput/TextInput.js +6 -5
  23. package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
  24. package/dist/TooltipV2/Tooltip.js +4 -4
  25. package/dist/experimental/Tabs/Tabs.d.ts +1 -1
  26. package/dist/experimental/Tabs/Tabs.d.ts.map +1 -1
  27. package/dist/experimental/Tabs/Tabs.js +16 -16
  28. package/dist/hooks/useMergedRefs.d.ts +1 -1
  29. package/dist/hooks/useMergedRefs.d.ts.map +1 -1
  30. package/dist/hooks/useMergedRefs.js +1 -7
  31. package/dist/hooks/useProvidedRefOrCreate.d.ts +10 -7
  32. package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
  33. package/dist/hooks/useProvidedRefOrCreate.js +10 -10
  34. package/package.json +1 -1
  35. package/dist/ActionBar/ActionBar-a41224b2.css +0 -2
  36. package/dist/ActionBar/ActionBar-a41224b2.css.map +0 -1
@@ -9,7 +9,7 @@ import VisuallyHidden from '../_VisuallyHidden.js';
9
9
  import useSafeTimeout from '../hooks/useSafeTimeout.js';
10
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import { useId } from '../hooks/useId.js';
12
- import { useMergedRefs } from '../hooks/useMergedRefs.js';
12
+ import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
13
13
  import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
14
14
  import { useIsMacOS } from '../hooks/useIsMacOS.js';
15
15
  import { getAccessibleKeybindingHintString, KeybindingHint } from '../KeybindingHint/KeybindingHint.js';
@@ -91,8 +91,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
91
91
  }, forwardedRef) => {
92
92
  const tooltipId = useId(id);
93
93
  const child = Children.only(children);
94
- const triggerRef = useRef(null);
95
- const mergedTriggerRef = useMergedRefs(triggerRef, forwardedRef);
94
+ const triggerRef = useProvidedRefOrCreate(forwardedRef);
96
95
  const tooltipElRef = useRef(null);
97
96
  const [calculatedDirection, setCalculatedDirection] = useState(direction);
98
97
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
@@ -208,7 +207,8 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
208
207
  /*#__PURE__*/
209
208
  // eslint-disable-next-line react-hooks/refs
210
209
  React.cloneElement(child, {
211
- ref: mergedTriggerRef,
210
+ // @ts-expect-error it needs a non nullable ref
211
+ ref: triggerRef,
212
212
  // If it is a type description, we use tooltip to describe the trigger
213
213
  'aria-describedby': (() => {
214
214
  // If tooltip is not a description type, keep the original aria-describedby
@@ -66,7 +66,7 @@ declare function useTabList<T extends HTMLElement>(props: TabListProps & {
66
66
  'aria-orientation': AriaAttributes['aria-orientation'];
67
67
  'aria-label': AriaAttributes['aria-label'];
68
68
  'aria-labelledby': AriaAttributes['aria-labelledby'];
69
- ref: React.Ref<T>;
69
+ ref: React.RefObject<T | null>;
70
70
  role: 'tablist';
71
71
  };
72
72
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/experimental/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAA;AAKd;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAA;IAEpB;;OAEG;IACH,aAAa,EAAE,CAAC,EAAC,KAAK,EAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,KAAK,IAAI,CAAA;CAClD,CAAA;AAED;;GAEG;AACH,KAAK,qBAAqB,GAAG;IAC3B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;IAEb;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,EAAC,KAAK,EAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,KAAK,IAAI,CAAA;CACnD,CAAA;AAED,KAAK,SAAS,GAAG,iBAAiB,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,CAAA;AAE/E;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,KAAK,EAAE,SAAS,qBA2B7B;AAED,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,KAAK,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAA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CAAC,GAAG,aAAa,qBAQjG;AA+BD,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAC,CAAA;AACtE,YAAY,EAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAC,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import React, { useId, useRef, createContext, useContext } from 'react';
2
+ import React, { useId, createContext, useContext } from 'react';
3
3
  import useIsomorphicLayoutEffect from '../../utils/useIsomorphicLayoutEffect.js';
4
4
  import { useControllableState } from '../../hooks/useControllableState.js';
5
5
  import { jsx } from 'react/jsx-runtime';
6
- import { useMergedRefs } from '../../hooks/useMergedRefs.js';
6
+ import { useProvidedRefOrCreate } from '../../hooks/useProvidedRefOrCreate.js';
7
7
 
8
8
  /**
9
9
  * The Tabs component provides the base structure for a tabbed interface, without providing any formal requirement on DOM structure or styling.
@@ -87,16 +87,15 @@ function Tabs(props) {
87
87
  return t5;
88
88
  }
89
89
  function useTabList(props) {
90
- const $ = c(8);
90
+ const $ = c(9);
91
91
  const {
92
92
  "aria-label": ariaLabel,
93
93
  "aria-labelledby": ariaLabelledby,
94
94
  "aria-orientation": ariaOrientation
95
95
  } = props;
96
- const ref = useRef(null);
97
- const mergedRef = useMergedRefs(ref, props.ref);
96
+ const ref = useProvidedRefOrCreate(props.ref);
98
97
  let t0;
99
- if ($[0] !== ariaOrientation) {
98
+ if ($[0] !== ariaOrientation || $[1] !== ref) {
100
99
  t0 = event => {
101
100
  const {
102
101
  current: tablist
@@ -143,17 +142,18 @@ function useTabList(props) {
143
142
  }
144
143
  };
145
144
  $[0] = ariaOrientation;
146
- $[1] = t0;
145
+ $[1] = ref;
146
+ $[2] = t0;
147
147
  } else {
148
- t0 = $[1];
148
+ t0 = $[2];
149
149
  }
150
150
  const onKeyDown = t0;
151
151
  const t1 = ariaOrientation !== null && ariaOrientation !== void 0 ? ariaOrientation : "horizontal";
152
152
  let t2;
153
- if ($[2] !== ariaLabel || $[3] !== ariaLabelledby || $[4] !== mergedRef || $[5] !== onKeyDown || $[6] !== t1) {
153
+ if ($[3] !== ariaLabel || $[4] !== ariaLabelledby || $[5] !== onKeyDown || $[6] !== ref || $[7] !== t1) {
154
154
  t2 = {
155
155
  tabListProps: {
156
- ref: mergedRef,
156
+ ref,
157
157
  "aria-label": ariaLabel,
158
158
  "aria-labelledby": ariaLabelledby,
159
159
  "aria-orientation": t1,
@@ -161,14 +161,14 @@ function useTabList(props) {
161
161
  onKeyDown
162
162
  }
163
163
  };
164
- $[2] = ariaLabel;
165
- $[3] = ariaLabelledby;
166
- $[4] = mergedRef;
164
+ $[3] = ariaLabel;
165
+ $[4] = ariaLabelledby;
167
166
  $[5] = onKeyDown;
168
- $[6] = t1;
169
- $[7] = t2;
167
+ $[6] = ref;
168
+ $[7] = t1;
169
+ $[8] = t2;
170
170
  } else {
171
- t2 = $[7];
171
+ t2 = $[8];
172
172
  }
173
173
  return t2;
174
174
  }
@@ -29,7 +29,7 @@ import type { ForwardedRef, Ref as StandardRef } from 'react';
29
29
  * return <button ref={mergedRef} />
30
30
  * }
31
31
  */
32
- export declare function useMergedRefs<T>(refA: Ref<T | null>, refB: Ref<T | null>): (value: T | null) => (() => void) | undefined;
32
+ export declare function useMergedRefs<T>(refA: Ref<T | null>, refB: Ref<T | null>): (value: T | null) => () => void;
33
33
  type CleanupFunction = () => void;
34
34
  /**
35
35
  * React 19 supports callback refs that can return a cleanup function. If a cleanup function is returned, the
@@ -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;AAK7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAA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AA"}
@@ -1,8 +1,5 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import { version } from 'react';
3
-
4
- var _version$split$;
5
- const majorReactVersion = parseInt((_version$split$ = version.split('.')[0]) !== null && _version$split$ !== void 0 ? _version$split$ : '18', 10);
2
+ import 'react';
6
3
 
7
4
  /**
8
5
  * Combine two refs of matching type (typically an external or forwarded ref and an internal `useRef` object or
@@ -41,9 +38,6 @@ function useMergedRefs(refA, refB) {
41
38
  t0 = value => {
42
39
  const cleanupA = setRef(refA, value);
43
40
  const cleanupB = setRef(refB, value);
44
- if (majorReactVersion <= 18) {
45
- return;
46
- }
47
41
  return () => {
48
42
  if (cleanupA) {
49
43
  cleanupA();
@@ -7,14 +7,17 @@ import React from 'react';
7
7
  * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
8
8
  * @type TRef The type of the RefObject which should be created.
9
9
  *
10
- * @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
11
- * In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
12
- * {@linkcode useMergedRefs} instead.
10
+ * @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
11
+ * created ref instead.
13
12
  *
14
- * The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
15
- * element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
16
- * consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
17
- * internal element.
13
+ * ```diff
14
+ * - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
15
+ * + const ref = useRef(null)
16
+ * + const mergedRef = useMergedRefs(forwardedRef, ref)
17
+ *
18
+ * - return <div ref={ref} />
19
+ * + return <div ref={mergedRef} />
20
+ * ```
18
21
  */
19
22
  export declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
20
23
  //# sourceMappingURL=useProvidedRefOrCreate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProvidedRefOrCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/useProvidedRefOrCreate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAGrH"}
1
+ {"version":3,"file":"useProvidedRefOrCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/useProvidedRefOrCreate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAGrH"}
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
2
 
3
- // used in doc comment
4
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
-
6
3
  /**
7
4
  * There are some situations where we only want to create a new ref if one is not provided to a component
8
5
  * or hook as a prop. However, due to the `rules-of-hooks`, we cannot conditionally make a call to `React.useRef`
@@ -11,14 +8,17 @@ import React from 'react';
11
8
  * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
12
9
  * @type TRef The type of the RefObject which should be created.
13
10
  *
14
- * @note This hook is overly restrictive in that it forces the provided ref to be a ref object rather than a callback.
15
- * In particular, it should **not** be used to merge internal refs with forwarded refs. For this, use
16
- * {@linkcode useMergedRefs} instead.
11
+ * @deprecated This hook is incompatible with forwarded callback refs. Prefer `useMergedRefs` with an internally
12
+ * created ref instead.
13
+ *
14
+ * ```diff
15
+ * - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
16
+ * + const ref = useRef(null)
17
+ * + const mergedRef = useMergedRefs(forwardedRef, ref)
17
18
  *
18
- * The primary valid use case for this hook is for when the consumer is using the provided ref to point to an external
19
- * element, like an externally rendered anchor. This is 'backwards' from forwarded refs with respect to data flow; the
20
- * consumer is passing a reference to an external element, rather than passing a handle to obtain a reference to an
21
- * internal element.
19
+ * - return <div ref={ref} />
20
+ * + return <div ref={mergedRef} />
21
+ * ```
22
22
  */
23
23
  function useProvidedRefOrCreate(providedRef) {
24
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": "0.0.0-20260403170759",
4
+ "version": "0.0.0-20260403172558",
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",
@@ -1,2 +0,0 @@
1
- .prc-ActionBar-List-9uz46{align-items:center;display:flex;gap:var(--actionbar-gap,var(--stack-gap-condensed,.5rem));list-style:none;margin-bottom:-1px;min-width:0;position:relative;white-space:nowrap}.prc-ActionBar-List-9uz46:where([data-gap=none]){--actionbar-gap:0}.prc-ActionBar-List-9uz46:where([data-gap=none]) .prc-ActionBar-Divider-6V8yH{padding:0 var(--base-size-8,.5rem)}.prc-ActionBar-List-9uz46:where([data-gap=condensed]){--actionbar-gap:var(--stack-gap-condensed,0.5rem)}.prc-ActionBar-Nav-9spON{align-items:center;display:flex;justify-content:flex-end;padding-inline:var(--base-size-16,1rem)}.prc-ActionBar-Nav-9spON:where([data-flush=true]){padding-inline:0}.prc-ActionBar-Divider-6V8yH:before{background:var(--borderColor-muted,var(--color-border-muted));content:"";display:block;height:var(--base-size-20,1.25rem);width:var(--borderWidth-thin,.0625rem)}.prc-ActionBar-Group-peNCk{display:flex;gap:inherit}
2
- /*# sourceMappingURL=ActionBar-a41224b2.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ActionBar/ActionBar.module.css.js"],"names":[],"mappings":"AAAA,0BAUE,kBAAmB,CARnB,YAAa,CASb,yDAAqD,CAFrD,eAAgB,CAFhB,kBAAmB,CAJnB,WAAY,CAFZ,iBAAkB,CAOlB,kBAiBF,CAXE,iDACE,iBAKF,CAHE,8EACE,kCACF,CAGF,sDACE,iDACF,CAGF,yBAIE,kBAAmB,CAHnB,YAAa,CAEb,wBAAyB,CADzB,uCAOF,CAHE,kDACE,gBACF,CAIA,oCAME,6DAAoC,CAFpC,UAAW,CAHX,aAAc,CAEd,kCAA2B,CAD3B,sCAKF,CAGF,2BACE,YAAa,CACb,WACF","file":"ActionBar-a41224b2.css","sourcesContent":[".List {\n position: relative;\n display: flex;\n min-width: 0;\n\n /* wonder why this is here */\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n white-space: nowrap;\n list-style: none;\n align-items: center;\n gap: var(--actionbar-gap, var(--stack-gap-condensed));\n\n /* Gap scale (mirrors Stack) */\n &:where([data-gap='none']) {\n --actionbar-gap: 0;\n\n .Divider {\n padding: 0 var(--base-size-8);\n }\n }\n\n &:where([data-gap='condensed']) {\n --actionbar-gap: var(--stack-gap-condensed);\n }\n}\n\n.Nav {\n display: flex;\n padding-inline: var(--base-size-16);\n justify-content: flex-end;\n align-items: center;\n\n &:where([data-flush='true']) {\n padding-inline: 0;\n }\n}\n\n.Divider {\n &::before {\n display: block;\n width: var(--borderWidth-thin);\n height: var(--base-size-20);\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background: var(--borderColor-muted);\n }\n}\n\n.Group {\n display: flex;\n gap: inherit;\n}\n"]}