@primer/react 0.0.0-20260324190422 → 0.0.0-20260324193322
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 +1 -1
- package/dist/ActionMenu/ActionMenu.d.ts.map +1 -1
- package/dist/ActionMenu/ActionMenu.js +7 -10
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts +2 -2
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +5 -5
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +3 -4
- package/dist/deprecated/ActionMenu.d.ts.map +1 -1
- package/dist/deprecated/ActionMenu.js +7 -8
- package/dist/experimental/SelectPanel2/SelectPanel.d.ts.map +1 -1
- package/dist/experimental/SelectPanel2/SelectPanel.js +5 -5
- package/dist/hooks/useAnchoredPosition.js +1 -1
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +1 -1
- package/dist/hooks/useProvidedRefOrCreate.d.ts +7 -10
- package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.js +10 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/ActionMenu/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/ActionMenu/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8D,MAAM,OAAO,CAAA;AAGlF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAI5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAA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I,CAAC,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,mBAAmB,CAAC,GAAG;IAC/E;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,gBAAgB,CAAC,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAC,KAAK,IAAI,CAAA;CACpE,CAAA;AAmHH,eAAO,MAAM,UAAU;;;kBAhMP,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC;aAC5B,MAAM;;;;CA+L4E,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext,
|
|
1
|
+
import React, { useContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { ChevronRightIcon, TriangleDownIcon } from '@primer/octicons-react';
|
|
4
4
|
import { Divider } from '../ActionList/Divider.js';
|
|
@@ -11,7 +11,7 @@ import { isSlot } from '../utils/is-slot.js';
|
|
|
11
11
|
import { DialogContext } from '../Dialog/Dialog.js';
|
|
12
12
|
import { jsx } from 'react/jsx-runtime';
|
|
13
13
|
import { useProvidedStateOrCreate } from '../hooks/useProvidedStateOrCreate.js';
|
|
14
|
-
import {
|
|
14
|
+
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
15
15
|
import { useMenuKeyboardNavigation } from '../hooks/useMenuKeyboardNavigation.js';
|
|
16
16
|
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
17
17
|
import { AnchoredOverlay } from '../AnchoredOverlay/AnchoredOverlay.js';
|
|
@@ -76,8 +76,7 @@ const Menu = ({
|
|
|
76
76
|
}, [setCombinedOpenState, parentMenuContext, open, isNarrow]);
|
|
77
77
|
const menuButtonChild = React.Children.toArray(children).find(child => /*#__PURE__*/React.isValidElement(child) && (child.type === MenuButton || child.type === Anchor || isSlot(child, Anchor) || isSlot(child, MenuButton)));
|
|
78
78
|
const menuButtonChildId = /*#__PURE__*/React.isValidElement(menuButtonChild) ? menuButtonChild.props.id : undefined;
|
|
79
|
-
const anchorRef =
|
|
80
|
-
const mergedRef = useMergedRefs(anchorRef, externalAnchorRef);
|
|
79
|
+
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
81
80
|
const anchorId = useId(menuButtonChildId);
|
|
82
81
|
let renderAnchor = null;
|
|
83
82
|
// 🚨 Hack for good API!
|
|
@@ -98,7 +97,7 @@ const Menu = ({
|
|
|
98
97
|
}, anchorChildren.props));
|
|
99
98
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
100
99
|
children: triggerButton,
|
|
101
|
-
ref:
|
|
100
|
+
ref: anchorRef
|
|
102
101
|
});
|
|
103
102
|
};
|
|
104
103
|
}
|
|
@@ -120,7 +119,7 @@ const Menu = ({
|
|
|
120
119
|
});
|
|
121
120
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
122
121
|
children: tooltip,
|
|
123
|
-
ref:
|
|
122
|
+
ref: anchorRef
|
|
124
123
|
});
|
|
125
124
|
};
|
|
126
125
|
}
|
|
@@ -227,7 +226,7 @@ const Overlay = ({
|
|
|
227
226
|
// we typecast anchorRef as required instead of optional
|
|
228
227
|
// because we know that we're setting it in context in Menu
|
|
229
228
|
const {
|
|
230
|
-
anchorRef
|
|
229
|
+
anchorRef,
|
|
231
230
|
renderAnchor,
|
|
232
231
|
anchorId,
|
|
233
232
|
open,
|
|
@@ -235,8 +234,6 @@ const Overlay = ({
|
|
|
235
234
|
onClose,
|
|
236
235
|
isSubmenu = false
|
|
237
236
|
} = React.useContext(MenuContext);
|
|
238
|
-
const anchorRef = useRef(null);
|
|
239
|
-
const mergedAnchorRef = useMergedRefs(anchorRef, contextAnchorRef);
|
|
240
237
|
const containerRef = React.useRef(null);
|
|
241
238
|
const isNarrow = useResponsiveValue({
|
|
242
239
|
narrow: true
|
|
@@ -271,7 +268,7 @@ const Overlay = ({
|
|
|
271
268
|
const featureFlagMaxHeightClampToViewport = useFeatureFlag('primer_react_overlay_max_height_clamp_to_viewport');
|
|
272
269
|
const isInsideDialog = useContext(DialogContext) !== undefined;
|
|
273
270
|
return /*#__PURE__*/jsx(AnchoredOverlay, {
|
|
274
|
-
anchorRef:
|
|
271
|
+
anchorRef: anchorRef,
|
|
275
272
|
renderAnchor: renderAnchor,
|
|
276
273
|
anchorId: anchorId,
|
|
277
274
|
open: open,
|
|
@@ -15,7 +15,7 @@ interface AnchoredOverlayPropsWithAnchor {
|
|
|
15
15
|
/**
|
|
16
16
|
* An override to the internal ref that will be spread on to the renderAnchor
|
|
17
17
|
*/
|
|
18
|
-
anchorRef?: React.
|
|
18
|
+
anchorRef?: React.RefObject<HTMLElement | null>;
|
|
19
19
|
/**
|
|
20
20
|
* An override to the internal id that will be spread on to the renderAnchor
|
|
21
21
|
*/
|
|
@@ -31,7 +31,7 @@ interface AnchoredOverlayPropsWithoutAnchor {
|
|
|
31
31
|
* An override to the internal renderAnchor ref that will be used to position the overlay.
|
|
32
32
|
* When renderAnchor is null this can be used to make an anchor that is detached from ActionMenu.
|
|
33
33
|
*/
|
|
34
|
-
anchorRef: React.
|
|
34
|
+
anchorRef: React.RefObject<HTMLElement | null>;
|
|
35
35
|
/**
|
|
36
36
|
* An override to the internal id that will be spread on to the renderAnchor
|
|
37
37
|
*/
|
|
@@ -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;AAC9D,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;AAI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AA;IAChE;;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;AAoB9G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CA4KnF,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useRef, useEffect } from 'react';
|
|
2
2
|
import { useFocusTrap } from '../hooks/useFocusTrap.js';
|
|
3
3
|
import { useFocusZone } from '../hooks/useFocusZone.js';
|
|
4
4
|
import { useId } from '../hooks/useId.js';
|
|
@@ -8,8 +8,9 @@ import classes from './AnchoredOverlay.module.css.js';
|
|
|
8
8
|
import { clsx } from 'clsx';
|
|
9
9
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
10
10
|
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
11
|
-
import {
|
|
11
|
+
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
12
12
|
import { useRenderForcingRef } from '../hooks/useRenderForcingRef.js';
|
|
13
|
+
import { useMergedRefs } from '../hooks/useMergedRefs.js';
|
|
13
14
|
import { useAnchoredPosition } from '../hooks/useAnchoredPosition.js';
|
|
14
15
|
import Overlay from '../Overlay/Overlay.js';
|
|
15
16
|
|
|
@@ -60,8 +61,7 @@ const AnchoredOverlay = ({
|
|
|
60
61
|
closeButtonProps = defaultCloseButtonProps
|
|
61
62
|
}) => {
|
|
62
63
|
const cssAnchorPositioning = useFeatureFlag('primer_react_css_anchor_positioning');
|
|
63
|
-
const anchorRef =
|
|
64
|
-
const mergedRef = useMergedRefs(anchorRef, externalAnchorRef);
|
|
64
|
+
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
65
65
|
const [overlayRef, updateOverlayRef] = useRenderForcingRef();
|
|
66
66
|
const mergedOverlayRef = useMergedRefs(updateOverlayRef, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.ref);
|
|
67
67
|
const anchorId = useId(externalAnchorId);
|
|
@@ -135,7 +135,7 @@ const AnchoredOverlay = ({
|
|
|
135
135
|
} = overlayProps || {};
|
|
136
136
|
const innerContent = /*#__PURE__*/jsxs(Fragment, {
|
|
137
137
|
children: [renderAnchor && renderAnchor({
|
|
138
|
-
ref:
|
|
138
|
+
ref: anchorRef,
|
|
139
139
|
id: anchorId,
|
|
140
140
|
'aria-haspopup': 'true',
|
|
141
141
|
'aria-expanded': open,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../src/SelectPanel/SelectPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC1F,OAAO,KAAK,EAAE,EAAoD,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AACxF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAC,iCAAiC,EAAC,MAAM,oCAAoC,CAAA;AACzF,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAA;AAGlE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAY,SAAS,EAAC,MA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pB,eAAe,EACf,wBAA+B,EAC/B,yBAAyB,EACzB,KAAK,EACL,aAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,GAAG,SAAS,EACb,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA2yBhC;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAM1C,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,GAAG,WAAW,CAM1D,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA"}
|
|
@@ -18,7 +18,7 @@ import { isAlphabetKey } from '../hooks/useMnemonics.js';
|
|
|
18
18
|
import { useFormControlContext } from '../FormControl/_FormControlContext.js';
|
|
19
19
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
20
20
|
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
21
|
-
import {
|
|
21
|
+
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
22
22
|
import { AnchoredOverlay } from '../AnchoredOverlay/AnchoredOverlay.js';
|
|
23
23
|
import Heading from '../Heading/Heading.js';
|
|
24
24
|
import { FilteredActionList } from '../FilteredActionList/FilteredActionList.js';
|
|
@@ -383,8 +383,7 @@ function Panel({
|
|
|
383
383
|
announceNotice();
|
|
384
384
|
}
|
|
385
385
|
}, [notice, open]);
|
|
386
|
-
const anchorRef =
|
|
387
|
-
const mergedAnchorRef = useMergedRefs(anchorRef, externalAnchorRef);
|
|
386
|
+
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
388
387
|
const onOpen = useCallback(gesture => onOpenChange(true, gesture), [onOpenChange]);
|
|
389
388
|
const onCancelRequested = useCallback(() => {
|
|
390
389
|
onOpenChange(false, 'cancel');
|
|
@@ -660,7 +659,7 @@ function Panel({
|
|
|
660
659
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
661
660
|
children: [/*#__PURE__*/jsx(AnchoredOverlay, {
|
|
662
661
|
renderAnchor: renderMenuAnchor,
|
|
663
|
-
anchorRef:
|
|
662
|
+
anchorRef: anchorRef,
|
|
664
663
|
align: align,
|
|
665
664
|
open: open,
|
|
666
665
|
onOpen: onOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/deprecated/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAEtE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAA;AAG5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/deprecated/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAEtE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAA;AAG5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAuB,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AAGpD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAC,iCAAiC,EAAC,MAAM,oCAAoC,CAAA;AAEzF,UAAU,mBAAoB,SAAQ,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,aAAa,CAAC,CAAC,EAAE,aAAa;IACvG;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAE/B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IAErH;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IAE9B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CACrC;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,iCAAiC,CAAA;AAqErF;;GAEG;AACH,eAAO,MAAM,UAAU;gIAtDpB,eAAe,GAAG,GAAG,CAAC,OAAO;;;;;gBAhBD,SAAS;;;CAsEgD,CAAA"}
|
|
@@ -2,10 +2,10 @@ import { c } from 'react-compiler-runtime';
|
|
|
2
2
|
import { List } from './ActionList/List.js';
|
|
3
3
|
import { Item } from './ActionList/Item.js';
|
|
4
4
|
import { Divider } from './ActionList/Divider.js';
|
|
5
|
-
import
|
|
5
|
+
import 'react';
|
|
6
6
|
import { useProvidedStateOrCreate } from '../hooks/useProvidedStateOrCreate.js';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import {
|
|
8
|
+
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
9
9
|
import { ButtonComponent } from '../Button/Button.js';
|
|
10
10
|
import { AnchoredOverlay } from '../AnchoredOverlay/AnchoredOverlay.js';
|
|
11
11
|
|
|
@@ -75,8 +75,7 @@ const ActionMenuBase = t0 => {
|
|
|
75
75
|
}
|
|
76
76
|
const renderAnchor = t1 === undefined ? defaultRenderAnchor : t1;
|
|
77
77
|
const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate(open, setOpen, false);
|
|
78
|
-
const anchorRef =
|
|
79
|
-
const mergedRef = useMergedRefs(anchorRef, externalAnchorRef);
|
|
78
|
+
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
80
79
|
let t2;
|
|
81
80
|
if ($[10] !== setCombinedOpenState) {
|
|
82
81
|
t2 = () => setCombinedOpenState(true);
|
|
@@ -162,18 +161,18 @@ const ActionMenuBase = t0 => {
|
|
|
162
161
|
t6 = $[26];
|
|
163
162
|
}
|
|
164
163
|
let t7;
|
|
165
|
-
if ($[27] !==
|
|
164
|
+
if ($[27] !== anchorRef || $[28] !== combinedOpenState || $[29] !== onClose || $[30] !== onOpen || $[31] !== overlayProps || $[32] !== renderMenuAnchor || $[33] !== t6) {
|
|
166
165
|
t7 = /*#__PURE__*/jsx(AnchoredOverlay, {
|
|
167
166
|
renderAnchor: renderMenuAnchor,
|
|
168
|
-
anchorRef:
|
|
167
|
+
anchorRef: anchorRef,
|
|
169
168
|
open: combinedOpenState,
|
|
170
169
|
onOpen: onOpen,
|
|
171
170
|
onClose: onClose,
|
|
172
171
|
overlayProps: overlayProps,
|
|
173
172
|
children: t6
|
|
174
173
|
});
|
|
175
|
-
$[27] =
|
|
176
|
-
$[28] =
|
|
174
|
+
$[27] = anchorRef;
|
|
175
|
+
$[28] = combinedOpenState;
|
|
177
176
|
$[29] = onClose;
|
|
178
177
|
$[30] = onOpen;
|
|
179
178
|
$[31] = overlayProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../../src/experimental/SelectPanel2/SelectPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../../src/experimental/SelectPanel2/SelectPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAmB,SAAS,EAAE,aAAa,EAAC,MAAM,aAAa,CAAA;AAevG,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAMvD,OAAO,KAAK,EA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AAK,CAAC,SAAS,CAAA;CAAC,GAAG,CACxE,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,GAC7D,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GACxC,CAAC;IAAC,OAAO,EAAE,UAAU,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,aAAa,CAAC,CACvD,CAAA;AAwBD,MAAM,MAAM,uBAAuB,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAC,GAAG,CAChE;IACE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;CACvC,GACD;IACE,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,OAAO,EAAE,SAAS,GAAG,OAAO,CAAA;CAC7B,CACJ,CAAA;AAqCD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;iBAtRoE,MAAM,IAAI;;;;;;;;;4BA6NxC,KAAK,CAAC,iBAAiB;;;CAiEnF,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { AlertIcon, SearchIcon, XCircleFillIcon, ArrowLeftIcon, FilterRemoveIcon, XIcon } from '@primer/octicons-react';
|
|
3
3
|
import { ActionListContainerContext } from '../../ActionList/ActionListContainerContext.js';
|
|
4
4
|
import { useSlots } from '../../hooks/useSlots.js';
|
|
@@ -10,7 +10,7 @@ import { clsx } from 'clsx';
|
|
|
10
10
|
import classes from './SelectPanel.module.css.js';
|
|
11
11
|
import { isSlot } from '../../utils/is-slot.js';
|
|
12
12
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
13
|
-
import {
|
|
13
|
+
import { useProvidedRefOrCreate } from '../../hooks/useProvidedRefOrCreate.js';
|
|
14
14
|
import { useId } from '../../hooks/useId.js';
|
|
15
15
|
import { useAnchoredPosition } from '../../hooks/useAnchoredPosition.js';
|
|
16
16
|
import { AriaStatus } from '../../live-region/AriaStatus.js';
|
|
@@ -79,8 +79,7 @@ const Panel = ({
|
|
|
79
79
|
// with additional props for accessibility
|
|
80
80
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
81
|
let Anchor;
|
|
82
|
-
const anchorRef =
|
|
83
|
-
const mergedRef = useMergedRefs(providedAnchorRef, anchorRef);
|
|
82
|
+
const anchorRef = useProvidedRefOrCreate(providedAnchorRef);
|
|
84
83
|
const onAnchorClick = () => {
|
|
85
84
|
if (!internalOpen) setInternalOpen(true);else onInternalCancel();
|
|
86
85
|
};
|
|
@@ -88,7 +87,8 @@ const Panel = ({
|
|
|
88
87
|
if (/*#__PURE__*/React.isValidElement(child) && (child.type === SelectPanelButton || isSlot(child, SelectPanelButton))) {
|
|
89
88
|
// eslint-disable-next-line react-hooks/immutability
|
|
90
89
|
Anchor = /*#__PURE__*/React.cloneElement(child, {
|
|
91
|
-
|
|
90
|
+
// @ts-ignore TODO
|
|
91
|
+
ref: anchorRef,
|
|
92
92
|
onClick: child.props.onClick || onAnchorClick,
|
|
93
93
|
'aria-haspopup': true,
|
|
94
94
|
'aria-expanded': internalOpen
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getAnchoredPosition } from '@primer/behaviors';
|
|
3
|
+
import { useProvidedRefOrCreate } from './useProvidedRefOrCreate.js';
|
|
3
4
|
import { useResizeObserver } from './useResizeObserver.js';
|
|
4
5
|
import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
|
|
5
|
-
import { useProvidedRefOrCreate } from './useProvidedRefOrCreate.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Calculates the top and left values for an absolutely-positioned floating element
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAElD;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAErD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAE/B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACpD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,CAAC,EAAE,qBAAqB,EAChC,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC;IAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAAC,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CAAC,
|
|
1
|
+
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAElD;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAErD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAE/B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACpD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,CAAC,EAAE,qBAAqB,EAChC,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC;IAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAAC,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CAAC,CA0D3G"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { focusTrap } from '@primer/behaviors';
|
|
3
|
-
import { useOnOutsideClick } from './useOnOutsideClick.js';
|
|
4
3
|
import { useProvidedRefOrCreate } from './useProvidedRefOrCreate.js';
|
|
4
|
+
import { useOnOutsideClick } from './useOnOutsideClick.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Hook used to trap focus inside a container. Returns a ref that can be added to the container
|
|
@@ -7,17 +7,14 @@ 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
|
-
* @
|
|
11
|
-
*
|
|
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.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* - return <div ref={ref} />
|
|
19
|
-
* + return <div ref={mergedRef} />
|
|
20
|
-
* ```
|
|
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.
|
|
21
18
|
*/
|
|
22
19
|
export declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef | null>): React.RefObject<TRef | null>;
|
|
23
20
|
//# 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;
|
|
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,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
// used in doc comment
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* There are some situations where we only want to create a new ref if one is not provided to a component
|
|
5
8
|
* or hook as a prop. However, due to the `rules-of-hooks`, we cannot conditionally make a call to `React.useRef`
|
|
@@ -8,17 +11,14 @@ import React from 'react';
|
|
|
8
11
|
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
|
|
9
12
|
* @type TRef The type of the RefObject which should be created.
|
|
10
13
|
*
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* ```diff
|
|
15
|
-
* - const ref = useProvidedRefOrCreate(forwardedRef as RefObject<...>)
|
|
16
|
-
* + const ref = useRef(null)
|
|
17
|
-
* + const mergedRef = useMergedRefs(forwardedRef, ref)
|
|
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.
|
|
18
17
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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.
|
|
22
22
|
*/
|
|
23
23
|
function useProvidedRefOrCreate(providedRef) {
|
|
24
24
|
const createdRef = React.useRef(null);
|
package/package.json
CHANGED