@primer/react 0.0.0-20260422181022 → 0.0.0-20260422184609
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,14 +1,16 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260422184609
|
|
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
|
+
|
|
9
11
|
### Patch Changes
|
|
10
12
|
|
|
11
|
-
- [#7714](https://github.com/primer/react/pull/7714) [`
|
|
13
|
+
- [#7714](https://github.com/primer/react/pull/7714) [`e974d9f`](https://github.com/primer/react/commit/e974d9f6d156805dbda9639a3fe6091a02a1a754) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(ActionList): replace :has() selector with JS-computed attribute
|
|
12
14
|
|
|
13
15
|
- [#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
16
|
|
|
@@ -94,6 +94,11 @@ 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 `"popover"`, 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 `"portal"`.
|
|
100
|
+
*/
|
|
101
|
+
renderAs?: 'portal' | 'popover';
|
|
97
102
|
}
|
|
98
103
|
export type AnchoredOverlayProps = AnchoredOverlayBaseProps & (AnchoredOverlayPropsWithAnchor | AnchoredOverlayPropsWithoutAnchor) & Partial<Pick<PositionSettings, 'align' | 'side' | 'anchorOffset' | 'alignmentOffset' | 'displayInViewport'>>;
|
|
99
104
|
/**
|
|
@@ -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,S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AAA;IAC5B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC;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,CA6OnF,CAAA"}
|
|
@@ -48,12 +48,15 @@ const AnchoredOverlay = ({
|
|
|
48
48
|
preventOverflow = true,
|
|
49
49
|
onPositionChange,
|
|
50
50
|
displayCloseButton = true,
|
|
51
|
-
closeButtonProps = defaultCloseButtonProps
|
|
51
|
+
closeButtonProps = defaultCloseButtonProps,
|
|
52
|
+
renderAs = 'portal'
|
|
52
53
|
}) => {
|
|
53
54
|
const cssAnchorPositioningFlag = useFeatureFlag('primer_react_css_anchor_positioning');
|
|
54
55
|
const supportsNativeCSSAnchorPositioning = useRef(false);
|
|
55
56
|
// eslint-disable-next-line react-hooks/refs
|
|
56
57
|
const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning.current;
|
|
58
|
+
// Only use Popover API when both CSS anchor positioning is enabled AND renderAs is true
|
|
59
|
+
const shouldRenderAsPopover = cssAnchorPositioning && renderAs === 'popover';
|
|
57
60
|
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
58
61
|
const [overlayRef, updateOverlayRef] = useRenderForcingRef();
|
|
59
62
|
const anchorId = useId(externalAnchorId);
|
|
@@ -159,15 +162,18 @@ const AnchoredOverlay = ({
|
|
|
159
162
|
const offset = result.horizontal === 'left' ? result.leftOffset : result.rightOffset;
|
|
160
163
|
currentOverlay.style.setProperty(`--anchored-overlay-anchor-offset-${result.horizontal}`, `${offset || 0}px`);
|
|
161
164
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
|
|
166
|
+
// Only call showPopover when renderAs is enabled
|
|
167
|
+
if (shouldRenderAsPopover) {
|
|
168
|
+
try {
|
|
169
|
+
if (!currentOverlay.matches(':popover-open')) {
|
|
170
|
+
currentOverlay.showPopover();
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
// Ignore if popover is already showing or not supported
|
|
165
174
|
}
|
|
166
|
-
} catch {
|
|
167
|
-
// Ignore if popover is already showing or not supported
|
|
168
175
|
}
|
|
169
|
-
|
|
170
|
-
}, [cssAnchorPositioning, open, overlayElement, id, overlayRef, anchorRef, width]);
|
|
176
|
+
}, [cssAnchorPositioning, shouldRenderAsPopover, open, overlayElement, id, overlayRef, anchorRef, width]);
|
|
171
177
|
const showXIcon = onClose && variant.narrow === 'fullscreen' && displayCloseButton;
|
|
172
178
|
const XButtonAriaLabelledBy = closeButtonProps['aria-labelledby'];
|
|
173
179
|
const XButtonAriaLabel = closeButtonProps['aria-label'];
|
|
@@ -187,7 +193,7 @@ const AnchoredOverlay = ({
|
|
|
187
193
|
tabIndex: 0,
|
|
188
194
|
onClick: onAnchorClick,
|
|
189
195
|
onKeyDown: onAnchorKeyDown,
|
|
190
|
-
...(
|
|
196
|
+
...(shouldRenderAsPopover ? {
|
|
191
197
|
popoverTarget: popoverId
|
|
192
198
|
} : {})
|
|
193
199
|
}), open ? /*#__PURE__*/jsxs(Overlay, {
|
|
@@ -207,11 +213,11 @@ const AnchoredOverlay = ({
|
|
|
207
213
|
preventOverflow: preventOverflow,
|
|
208
214
|
"data-component": "AnchoredOverlay",
|
|
209
215
|
_PrivateDisablePortal: _PrivateDisablePortal,
|
|
210
|
-
...(
|
|
216
|
+
...(shouldRenderAsPopover ? {
|
|
211
217
|
popover: 'manual'
|
|
212
218
|
} : {}),
|
|
213
219
|
...restOverlayProps,
|
|
214
|
-
...(
|
|
220
|
+
...(shouldRenderAsPopover ? {
|
|
215
221
|
id: popoverId
|
|
216
222
|
} : {}),
|
|
217
223
|
ref: node => {
|
package/package.json
CHANGED