@primer/react 0.0.0-20260420145726 → 0.0.0-20260421144812

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,15 +1,15 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260420145726
3
+ ## 0.0.0-20260421144812
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - [#7760](https://github.com/primer/react/pull/7760) [`b2e0efd`](https://github.com/primer/react/commit/b2e0efd04c61e526d8e7db6bc773f9b4ab155d72) Thanks [@siddharthkp](https://github.com/siddharthkp)! - Deprecate the `useResponsiveValue` hook.
8
8
 
9
- - [#7766](https://github.com/primer/react/pull/7766) [`6770095`](https://github.com/primer/react/commit/67700952bec8373c01843b88e39ccb6dfe5b108c) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: (Behind feature flag) Make popover API usage opt-in
10
-
11
9
  ### Patch Changes
12
10
 
11
+ - [#7765](https://github.com/primer/react/pull/7765) [`4c2c54d`](https://github.com/primer/react/commit/4c2c54d1f96646a5705d83374317f29cc1cfd0ba) Thanks [@alexus37](https://github.com/alexus37)! - Checkbox: replace useLayoutEffect with ref callback for setting indeterminate state
12
+
13
13
  - [#7754](https://github.com/primer/react/pull/7754) [`9e3fe4b`](https://github.com/primer/react/commit/9e3fe4b501ce5affb558bf92697e5c79341903ca) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Breadcrumbs: On narrow viewports, only show the current page breadcrumb and the overflow menu when `overflow="menu"` is set.
14
14
 
15
15
  - Fake entry to force publishing
@@ -94,11 +94,6 @@ interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'
94
94
  * Props to be spread on the close button in the overlay.
95
95
  */
96
96
  closeButtonProps?: Partial<IconButtonProps>;
97
- /**
98
- * When `true`, uses the Popover API only if the CSS anchor positioning feature flag is enabled
99
- * and the browser supports native CSS anchor positioning. Has no effect otherwise. Defaults to `false`.
100
- */
101
- renderAs?: 'portal' | 'popover';
102
97
  }
103
98
  export type AnchoredOverlayProps = AnchoredOverlayBaseProps & (AnchoredOverlayPropsWithAnchor | AnchoredOverlayPropsWithoutAnchor) & Partial<Pick<PositionSettings, 'align' | 'side' | 'anchorOffset' | 'alignmentOffset' | 'displayInViewport'>>;
104
99
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../src/AnchoredOverlay/AnchoredOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAiC,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AAE9D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAA;AAEhE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAA;AAIhE,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAC,KAAK,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAa,KAAK,eAAe,EAAC,MAAM,WAAW,CAAA;AAO1D,UAAU,8BAA8B;IACtC;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAAC,EAChG,KAAK,EAAE,CAAC,KACL,GAAG,CAAC,OAAO,CAAA;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAE/C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,iCAAiC;IACzC;;;OAGG;IACH,YAAY,EAAE,IAAI,CAAA;IAElB;;;OAGG;IACH,SAAS,EAAE,KAA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;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAC,KAAK,IAAI,CAAA;IACnE;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAC5C;AAED,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GACzD,CAAC,8BAA8B,GAAG,iCAAiC,CAAC,GACpE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAS9G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAkOnF,CAAA"}
@@ -48,14 +48,11 @@ const AnchoredOverlay = ({
48
48
  preventOverflow = true,
49
49
  onPositionChange,
50
50
  displayCloseButton = true,
51
- closeButtonProps = defaultCloseButtonProps,
52
- renderAs = 'portal'
51
+ closeButtonProps = defaultCloseButtonProps
53
52
  }) => {
54
53
  const cssAnchorPositioningFlag = useFeatureFlag('primer_react_css_anchor_positioning');
55
54
  const supportsNativeCSSAnchorPositioning = useRef(false);
56
55
  const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning.current;
57
- // Only use Popover API when both CSS anchor positioning is enabled AND renderAs is true
58
- const shouldRenderAs = cssAnchorPositioning && renderAs === 'popover';
59
56
  const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
60
57
  const [overlayRef, updateOverlayRef] = useRenderForcingRef();
61
58
  const anchorId = useId(externalAnchorId);
@@ -157,18 +154,14 @@ const AnchoredOverlay = ({
157
154
  const offset = result.horizontal === 'left' ? result.leftOffset : result.rightOffset;
158
155
  currentOverlay.style.setProperty(`--anchored-overlay-anchor-offset-${result.horizontal}`, `${offset || 0}px`);
159
156
  }
160
-
161
- // Only call showPopover when renderAs is enabled
162
- if (shouldRenderAs) {
163
- try {
164
- if (!currentOverlay.matches(':popover-open')) {
165
- currentOverlay.showPopover();
166
- }
167
- } catch {
168
- // Ignore if popover is already showing or not supported
157
+ try {
158
+ if (!currentOverlay.matches(':popover-open')) {
159
+ currentOverlay.showPopover();
169
160
  }
161
+ } catch {
162
+ // Ignore if popover is already showing or not supported
170
163
  }
171
- }, [cssAnchorPositioning, shouldRenderAs, open, overlayElement, id, overlayRef, anchorRef, width]);
164
+ }, [cssAnchorPositioning, open, overlayElement, id, overlayRef, anchorRef, width]);
172
165
  const showXIcon = onClose && variant.narrow === 'fullscreen' && displayCloseButton;
173
166
  const XButtonAriaLabelledBy = closeButtonProps['aria-labelledby'];
174
167
  const XButtonAriaLabel = closeButtonProps['aria-label'];
@@ -186,7 +179,7 @@ const AnchoredOverlay = ({
186
179
  tabIndex: 0,
187
180
  onClick: onAnchorClick,
188
181
  onKeyDown: onAnchorKeyDown,
189
- ...(shouldRenderAs ? {
182
+ ...(cssAnchorPositioning ? {
190
183
  popoverTarget: popoverId
191
184
  } : {})
192
185
  }), open ? /*#__PURE__*/jsxs(Overlay, {
@@ -206,11 +199,11 @@ const AnchoredOverlay = ({
206
199
  preventOverflow: preventOverflow,
207
200
  "data-component": "AnchoredOverlay",
208
201
  _PrivateDisablePortal: _PrivateDisablePortal,
209
- ...(shouldRenderAs ? {
202
+ ...(cssAnchorPositioning ? {
210
203
  popover: 'manual'
211
204
  } : {}),
212
205
  ...restOverlayProps,
213
- ...(shouldRenderAs ? {
206
+ ...(cssAnchorPositioning ? {
214
207
  id: popoverId
215
208
  } : {}),
216
209
  ref: node => {
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAiD,KAAK,mBAAmB,EAAoB,MAAM,OAAO,C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,EAAE,oBAAoB,CAAA;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAA;AAE3D;;GAEG;AACH,QAAA,MAAM,QAAQ,qGA0Cb,CAAA;wBAK0B,cAAc,CAAC,OAAO,QAAQ,CAAC;AAA1D,wBAA0D"}
@@ -1,11 +1,10 @@
1
1
  import { clsx } from 'clsx';
2
- import React, { useContext, useEffect } from 'react';
3
- import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
2
+ import React, { useContext } from 'react';
4
3
  import { CheckboxGroupContext } from '../CheckboxGroup/CheckboxGroupContext.js';
5
4
  import classes from './Checkbox.module.css.js';
6
5
  import sharedClasses from './shared.module.css.js';
7
6
  import { jsx } from 'react/jsx-runtime';
8
- import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
7
+ import { useMergedRefs } from '../hooks/useMergedRefs.js';
9
8
 
10
9
  /**
11
10
  * An accessible, native checkbox component
@@ -24,7 +23,16 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
24
23
  }, ref
25
24
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
25
  ) => {
27
- const checkboxRef = useProvidedRefOrCreate(ref);
26
+ const setIndeterminate = React.useCallback(node => {
27
+ if (node) {
28
+ node.indeterminate = indeterminate || false;
29
+ }
30
+ },
31
+ // `checked` is intentionally included: browsers clear the indeterminate state
32
+ // when checked changes, so we need the callback to re-run to restore it.
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ [indeterminate, checked]);
35
+ const mergedRef = useMergedRefs(ref, setIndeterminate);
28
36
  const checkboxGroupContext = useContext(CheckboxGroupContext);
29
37
  const handleOnChange = e => {
30
38
  checkboxGroupContext.onChange && checkboxGroupContext.onChange(e);
@@ -33,36 +41,18 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
33
41
  const inputProps = {
34
42
  type: 'checkbox',
35
43
  disabled,
36
- ref: checkboxRef,
44
+ ref: mergedRef,
37
45
  checked: indeterminate ? false : checked,
38
46
  defaultChecked,
39
47
  required,
40
48
  ['aria-required']: required ? 'true' : 'false',
41
49
  ['aria-invalid']: validationStatus === 'error' ? 'true' : 'false',
50
+ ['aria-checked']: indeterminate ? 'mixed' : undefined,
42
51
  onChange: handleOnChange,
43
52
  value,
44
53
  name: value,
45
54
  ...rest
46
55
  };
47
- useIsomorphicLayoutEffect(() => {
48
- if (checkboxRef.current) {
49
- checkboxRef.current.indeterminate = indeterminate || false;
50
- }
51
- }, [indeterminate, checked, checkboxRef]);
52
- useEffect(() => {
53
- const {
54
- current: checkbox
55
- } = checkboxRef;
56
- if (!checkbox) {
57
- return;
58
- }
59
- if (indeterminate) {
60
- checkbox.setAttribute('aria-checked', 'mixed');
61
- } else {
62
- checkbox.setAttribute('aria-checked', checkbox.checked ? 'true' : 'false');
63
- }
64
- });
65
- // @ts-expect-error inputProp needs a non nullable ref
66
56
  return /*#__PURE__*/jsx("input", {
67
57
  ...inputProps,
68
58
  className: clsx(className, sharedClasses.Input, classes.Checkbox)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260420145726",
4
+ "version": "0.0.0-20260421144812",
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",