@primer/react 0.0.0-20260508121249 → 0.0.0-20260508164446
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 +5 -11
- package/dist/ActionBar/ActionBar-e2c44be2.css +2 -0
- package/dist/ActionBar/ActionBar-e2c44be2.css.map +1 -0
- package/dist/ActionBar/ActionBar.d.ts +1 -1
- package/dist/ActionBar/ActionBar.d.ts.map +1 -1
- package/dist/ActionBar/ActionBar.js +293 -381
- package/dist/ActionBar/ActionBar.module.css.js +2 -2
- package/dist/ActionBar/index.d.ts +1 -1
- package/dist/ActionList/LinkItem.d.ts +1 -1
- package/dist/ActionList/index.d.ts +2 -2
- package/dist/AnchoredOverlay/AnchoredOverlay-0c26c5f8.css +2 -0
- package/dist/AnchoredOverlay/AnchoredOverlay-0c26c5f8.css.map +1 -0
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +26 -63
- package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +1 -1
- package/dist/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/Autocomplete/AutocompleteOverlay.d.ts.map +1 -1
- package/dist/Autocomplete/AutocompleteOverlay.js +3 -16
- package/dist/DataTable/sorting.d.ts +1 -1
- package/dist/Overlay/{Overlay-4e689024.css → Overlay-95cfd3c7.css} +2 -2
- package/dist/Overlay/Overlay-95cfd3c7.css.map +1 -0
- package/dist/Overlay/Overlay.module.css.js +1 -1
- package/dist/TextInput/TextInput.d.ts +1 -1
- package/dist/TextInputWithTokens/TextInputWithTokens.d.ts +3 -3
- package/dist/experimental/SelectPanel2/mock-story-data.d.ts +3 -3
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useSyncedState.d.ts +1 -1
- package/dist/internal/components/TextInputInnerAction.d.ts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/utils/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/ActionBar/ActionBar-a41224b2.css +0 -2
- package/dist/ActionBar/ActionBar-a41224b2.css.map +0 -1
- package/dist/AnchoredOverlay/AnchoredOverlay-efecedd0.css +0 -2
- package/dist/AnchoredOverlay/AnchoredOverlay-efecedd0.css.map +0 -1
- package/dist/Overlay/Overlay-4e689024.css.map +0 -1
- package/dist/hooks/useCSSAnchorPositioning.d.ts +0 -35
- package/dist/hooks/useCSSAnchorPositioning.d.ts.map +0 -1
- package/dist/hooks/useCSSAnchorPositioning.js +0 -90
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { c } from 'react-compiler-runtime';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import { useId } from './useId.js';
|
|
4
|
-
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Manages CSS anchor positioning by linking an anchor element and a floating
|
|
8
|
-
* element via `anchor-name` and `position-anchor` CSS properties.
|
|
9
|
-
*
|
|
10
|
-
* 1. Checks the `primer_react_css_anchor_positioning` feature flag
|
|
11
|
-
* 2. Detects native browser support for CSS anchor positioning
|
|
12
|
-
* 3. Sets `anchor-name` on the anchor element
|
|
13
|
-
* 4. Sets `position-anchor` on the floating element when open
|
|
14
|
-
* 5. Cleans up styles on unmount or when closed
|
|
15
|
-
*/
|
|
16
|
-
function useCSSAnchorPositioning(settings) {
|
|
17
|
-
const $ = c(11);
|
|
18
|
-
const {
|
|
19
|
-
anchorElementRef,
|
|
20
|
-
floatingElementRef,
|
|
21
|
-
open: t0
|
|
22
|
-
} = settings;
|
|
23
|
-
const open = t0 === undefined ? true : t0;
|
|
24
|
-
const cssAnchorPositioningFlag = useFeatureFlag("primer_react_css_anchor_positioning");
|
|
25
|
-
const [supportsNativeCSSAnchorPositioning] = useState(_temp);
|
|
26
|
-
const enabled = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning;
|
|
27
|
-
const rawId = useId();
|
|
28
|
-
let t1;
|
|
29
|
-
if ($[0] !== rawId) {
|
|
30
|
-
t1 = rawId.replaceAll(":", "_");
|
|
31
|
-
$[0] = rawId;
|
|
32
|
-
$[1] = t1;
|
|
33
|
-
} else {
|
|
34
|
-
t1 = $[1];
|
|
35
|
-
}
|
|
36
|
-
const id = t1;
|
|
37
|
-
const anchorName = `--css-anchor-${id}`;
|
|
38
|
-
let t2;
|
|
39
|
-
let t3;
|
|
40
|
-
if ($[2] !== anchorElementRef || $[3] !== anchorName || $[4] !== enabled || $[5] !== floatingElementRef || $[6] !== open) {
|
|
41
|
-
t2 = () => {
|
|
42
|
-
if (!enabled) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const anchorElement = anchorElementRef.current;
|
|
46
|
-
const floatingElement = floatingElementRef.current;
|
|
47
|
-
if (!anchorElement) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
anchorElement.style.setProperty("anchor-name", anchorName);
|
|
51
|
-
if (open && floatingElement) {
|
|
52
|
-
floatingElement.style.setProperty("position-anchor", anchorName);
|
|
53
|
-
}
|
|
54
|
-
return () => {
|
|
55
|
-
anchorElement.style.removeProperty("anchor-name");
|
|
56
|
-
if (floatingElement) {
|
|
57
|
-
floatingElement.style.removeProperty("position-anchor");
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
t3 = [enabled, open, anchorName, anchorElementRef, floatingElementRef];
|
|
62
|
-
$[2] = anchorElementRef;
|
|
63
|
-
$[3] = anchorName;
|
|
64
|
-
$[4] = enabled;
|
|
65
|
-
$[5] = floatingElementRef;
|
|
66
|
-
$[6] = open;
|
|
67
|
-
$[7] = t2;
|
|
68
|
-
$[8] = t3;
|
|
69
|
-
} else {
|
|
70
|
-
t2 = $[7];
|
|
71
|
-
t3 = $[8];
|
|
72
|
-
}
|
|
73
|
-
useEffect(t2, t3);
|
|
74
|
-
let t4;
|
|
75
|
-
if ($[9] !== enabled) {
|
|
76
|
-
t4 = {
|
|
77
|
-
enabled
|
|
78
|
-
};
|
|
79
|
-
$[9] = enabled;
|
|
80
|
-
$[10] = t4;
|
|
81
|
-
} else {
|
|
82
|
-
t4 = $[10];
|
|
83
|
-
}
|
|
84
|
-
return t4;
|
|
85
|
-
}
|
|
86
|
-
function _temp() {
|
|
87
|
-
return typeof document !== "undefined" && "anchorName" in document.documentElement.style;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export { useCSSAnchorPositioning };
|