@primer/react 38.21.0-rc.75e2393d9 → 38.21.0-rc.7d6b01011
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
|
@@ -6,6 +6,8 @@
|
|
|
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) [`b3f06f1`](https://github.com/primer/react/commit/b3f06f1e2c91125c7b6b035bd019f534219d358f) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: (Behind feature flag) Make popover API usage opt-in
|
|
10
|
+
|
|
9
11
|
- [#7763](https://github.com/primer/react/pull/7763) [`b288d6e`](https://github.com/primer/react/commit/b288d6e2dc9d1eef345ef4d16f6b0fba4f165955) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Add borderRadius prop to Card component.
|
|
10
12
|
|
|
11
13
|
### Patch Changes
|
|
@@ -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,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,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,iCAAiC,GACzC,OAAO,CA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O,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CA8OnF,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,19 @@ 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
176
|
// eslint-disable-next-line react-hooks/refs
|
|
170
|
-
}, [cssAnchorPositioning, open, overlayElement, id, overlayRef, anchorRef, width]);
|
|
177
|
+
}, [cssAnchorPositioning, shouldRenderAsPopover, open, overlayElement, id, overlayRef, anchorRef, width]);
|
|
171
178
|
const showXIcon = onClose && variant.narrow === 'fullscreen' && displayCloseButton;
|
|
172
179
|
const XButtonAriaLabelledBy = closeButtonProps['aria-labelledby'];
|
|
173
180
|
const XButtonAriaLabel = closeButtonProps['aria-label'];
|
|
@@ -187,7 +194,7 @@ const AnchoredOverlay = ({
|
|
|
187
194
|
tabIndex: 0,
|
|
188
195
|
onClick: onAnchorClick,
|
|
189
196
|
onKeyDown: onAnchorKeyDown,
|
|
190
|
-
...(
|
|
197
|
+
...(shouldRenderAsPopover ? {
|
|
191
198
|
popoverTarget: popoverId
|
|
192
199
|
} : {})
|
|
193
200
|
}), open ? /*#__PURE__*/jsxs(Overlay, {
|
|
@@ -207,11 +214,11 @@ const AnchoredOverlay = ({
|
|
|
207
214
|
preventOverflow: preventOverflow,
|
|
208
215
|
"data-component": "AnchoredOverlay",
|
|
209
216
|
_PrivateDisablePortal: _PrivateDisablePortal,
|
|
210
|
-
...(
|
|
217
|
+
...(shouldRenderAsPopover ? {
|
|
211
218
|
popover: 'manual'
|
|
212
219
|
} : {}),
|
|
213
220
|
...restOverlayProps,
|
|
214
|
-
...(
|
|
221
|
+
...(shouldRenderAsPopover ? {
|
|
215
222
|
id: popoverId
|
|
216
223
|
} : {}),
|
|
217
224
|
ref: node => {
|
package/package.json
CHANGED