@radix-ui/react-popover 1.1.20 → 1.1.22
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/dist/index.d.mts +26 -12
- package/dist/index.d.ts +26 -12
- package/dist/index.js +104 -40
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +110 -41
- package/dist/index.mjs.map +3 -3
- package/package.json +19 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
4
|
-
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
4
|
+
import { FocusScope, FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';
|
|
5
5
|
import * as PopperPrimitive from '@radix-ui/react-popper';
|
|
6
|
-
import { Portal
|
|
6
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
8
|
|
|
9
9
|
declare const createPopoverScope: _radix_ui_react_context.CreateScope;
|
|
@@ -23,7 +23,7 @@ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.butt
|
|
|
23
23
|
interface PopoverTriggerProps extends PrimitiveButtonProps {
|
|
24
24
|
}
|
|
25
25
|
declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
26
|
-
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal
|
|
26
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
|
27
27
|
interface PopoverPortalProps {
|
|
28
28
|
children?: React.ReactNode;
|
|
29
29
|
/**
|
|
@@ -45,7 +45,7 @@ interface PopoverContentProps extends PopoverContentTypeProps {
|
|
|
45
45
|
forceMount?: true;
|
|
46
46
|
}
|
|
47
47
|
declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
48
|
-
interface PopoverContentTypeProps extends Omit<PopoverContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {
|
|
48
|
+
interface PopoverContentTypeProps extends Omit<PopoverContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents' | 'branchRegistry' | 'branchNodes'> {
|
|
49
49
|
}
|
|
50
50
|
type FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;
|
|
51
51
|
type DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;
|
|
@@ -66,7 +66,28 @@ interface PopoverContentImplProps extends Omit<PopperContentProps, 'onPlaced'>,
|
|
|
66
66
|
* Can be prevented.
|
|
67
67
|
*/
|
|
68
68
|
onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
|
|
69
|
+
/**
|
|
70
|
+
* Branch nodes registered by nested, portalled layers. Passed to the trapped
|
|
71
|
+
* `FocusScope` so focus isn't reclaimed from them. Only provided by the modal
|
|
72
|
+
* variant.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
branchNodes?: HTMLElement[];
|
|
76
|
+
/**
|
|
77
|
+
* Registry that nested, portalled layers use to register themselves as branches of this modal
|
|
78
|
+
* `Popover`. Only provided by the modal variant.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
branchRegistry?: FocusScopeBranchRegistry;
|
|
82
|
+
}
|
|
83
|
+
type PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;
|
|
84
|
+
interface PopoverTitleProps extends PrimitiveHeading2Props {
|
|
85
|
+
}
|
|
86
|
+
declare const PopoverTitle: React.ForwardRefExoticComponent<PopoverTitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
87
|
+
type PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;
|
|
88
|
+
interface PopoverDescriptionProps extends PrimitiveParagraphProps {
|
|
69
89
|
}
|
|
90
|
+
declare const PopoverDescription: React.ForwardRefExoticComponent<PopoverDescriptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
70
91
|
interface PopoverCloseProps extends PrimitiveButtonProps {
|
|
71
92
|
}
|
|
72
93
|
declare const PopoverClose: React.ForwardRefExoticComponent<PopoverCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -74,12 +95,5 @@ type PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Ar
|
|
|
74
95
|
interface PopoverArrowProps extends PopperArrowProps {
|
|
75
96
|
}
|
|
76
97
|
declare const PopoverArrow: React.ForwardRefExoticComponent<PopoverArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
77
|
-
declare const Root: React.FC<PopoverProps>;
|
|
78
|
-
declare const Anchor: React.ForwardRefExoticComponent<PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
79
|
-
declare const Trigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
80
|
-
declare const Portal: React.FC<PopoverPortalProps>;
|
|
81
|
-
declare const Content: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
82
|
-
declare const Close: React.ForwardRefExoticComponent<PopoverCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
83
|
-
declare const Arrow: React.ForwardRefExoticComponent<PopoverArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
84
98
|
|
|
85
|
-
export { Anchor, Arrow, Close, Content, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverArrow, type PopoverArrowProps, PopoverClose, type PopoverCloseProps, PopoverContent, type PopoverContentProps, PopoverPortal, type PopoverPortalProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, Root, Trigger, createPopoverScope };
|
|
99
|
+
export { PopoverAnchor as Anchor, PopoverArrow as Arrow, PopoverClose as Close, PopoverContent as Content, PopoverDescription as Description, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverArrow, type PopoverArrowProps, PopoverClose, type PopoverCloseProps, PopoverContent, type PopoverContentProps, PopoverDescription, type PopoverDescriptionProps, PopoverPortal, type PopoverPortalProps, type PopoverProps, PopoverTitle, type PopoverTitleProps, PopoverTrigger, type PopoverTriggerProps, PopoverPortal as Portal, Popover as Root, PopoverTitle as Title, PopoverTrigger as Trigger, createPopoverScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
4
|
-
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
4
|
+
import { FocusScope, FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';
|
|
5
5
|
import * as PopperPrimitive from '@radix-ui/react-popper';
|
|
6
|
-
import { Portal
|
|
6
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
8
|
|
|
9
9
|
declare const createPopoverScope: _radix_ui_react_context.CreateScope;
|
|
@@ -23,7 +23,7 @@ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.butt
|
|
|
23
23
|
interface PopoverTriggerProps extends PrimitiveButtonProps {
|
|
24
24
|
}
|
|
25
25
|
declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
26
|
-
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal
|
|
26
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
|
27
27
|
interface PopoverPortalProps {
|
|
28
28
|
children?: React.ReactNode;
|
|
29
29
|
/**
|
|
@@ -45,7 +45,7 @@ interface PopoverContentProps extends PopoverContentTypeProps {
|
|
|
45
45
|
forceMount?: true;
|
|
46
46
|
}
|
|
47
47
|
declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
48
|
-
interface PopoverContentTypeProps extends Omit<PopoverContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {
|
|
48
|
+
interface PopoverContentTypeProps extends Omit<PopoverContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents' | 'branchRegistry' | 'branchNodes'> {
|
|
49
49
|
}
|
|
50
50
|
type FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;
|
|
51
51
|
type DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;
|
|
@@ -66,7 +66,28 @@ interface PopoverContentImplProps extends Omit<PopperContentProps, 'onPlaced'>,
|
|
|
66
66
|
* Can be prevented.
|
|
67
67
|
*/
|
|
68
68
|
onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
|
|
69
|
+
/**
|
|
70
|
+
* Branch nodes registered by nested, portalled layers. Passed to the trapped
|
|
71
|
+
* `FocusScope` so focus isn't reclaimed from them. Only provided by the modal
|
|
72
|
+
* variant.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
branchNodes?: HTMLElement[];
|
|
76
|
+
/**
|
|
77
|
+
* Registry that nested, portalled layers use to register themselves as branches of this modal
|
|
78
|
+
* `Popover`. Only provided by the modal variant.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
branchRegistry?: FocusScopeBranchRegistry;
|
|
82
|
+
}
|
|
83
|
+
type PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;
|
|
84
|
+
interface PopoverTitleProps extends PrimitiveHeading2Props {
|
|
85
|
+
}
|
|
86
|
+
declare const PopoverTitle: React.ForwardRefExoticComponent<PopoverTitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
87
|
+
type PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;
|
|
88
|
+
interface PopoverDescriptionProps extends PrimitiveParagraphProps {
|
|
69
89
|
}
|
|
90
|
+
declare const PopoverDescription: React.ForwardRefExoticComponent<PopoverDescriptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
70
91
|
interface PopoverCloseProps extends PrimitiveButtonProps {
|
|
71
92
|
}
|
|
72
93
|
declare const PopoverClose: React.ForwardRefExoticComponent<PopoverCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -74,12 +95,5 @@ type PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Ar
|
|
|
74
95
|
interface PopoverArrowProps extends PopperArrowProps {
|
|
75
96
|
}
|
|
76
97
|
declare const PopoverArrow: React.ForwardRefExoticComponent<PopoverArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
77
|
-
declare const Root: React.FC<PopoverProps>;
|
|
78
|
-
declare const Anchor: React.ForwardRefExoticComponent<PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
79
|
-
declare const Trigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
80
|
-
declare const Portal: React.FC<PopoverPortalProps>;
|
|
81
|
-
declare const Content: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
82
|
-
declare const Close: React.ForwardRefExoticComponent<PopoverCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
83
|
-
declare const Arrow: React.ForwardRefExoticComponent<PopoverArrowProps & React.RefAttributes<SVGSVGElement>>;
|
|
84
98
|
|
|
85
|
-
export { Anchor, Arrow, Close, Content, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverArrow, type PopoverArrowProps, PopoverClose, type PopoverCloseProps, PopoverContent, type PopoverContentProps, PopoverPortal, type PopoverPortalProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, Root, Trigger, createPopoverScope };
|
|
99
|
+
export { PopoverAnchor as Anchor, PopoverArrow as Arrow, PopoverClose as Close, PopoverContent as Content, PopoverDescription as Description, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverArrow, type PopoverArrowProps, PopoverClose, type PopoverCloseProps, PopoverContent, type PopoverContentProps, PopoverDescription, type PopoverDescriptionProps, PopoverPortal, type PopoverPortalProps, type PopoverProps, PopoverTitle, type PopoverTitleProps, PopoverTrigger, type PopoverTriggerProps, PopoverPortal as Portal, Popover as Root, PopoverTitle as Title, PopoverTrigger as Trigger, createPopoverScope };
|
package/dist/index.js
CHANGED
|
@@ -32,26 +32,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
// src/index.ts
|
|
33
33
|
var index_exports = {};
|
|
34
34
|
__export(index_exports, {
|
|
35
|
-
Anchor: () =>
|
|
36
|
-
Arrow: () =>
|
|
37
|
-
Close: () =>
|
|
38
|
-
Content: () =>
|
|
35
|
+
Anchor: () => PopoverAnchor,
|
|
36
|
+
Arrow: () => PopoverArrow,
|
|
37
|
+
Close: () => PopoverClose,
|
|
38
|
+
Content: () => PopoverContent,
|
|
39
|
+
Description: () => PopoverDescription,
|
|
39
40
|
Popover: () => Popover,
|
|
40
41
|
PopoverAnchor: () => PopoverAnchor,
|
|
41
42
|
PopoverArrow: () => PopoverArrow,
|
|
42
43
|
PopoverClose: () => PopoverClose,
|
|
43
44
|
PopoverContent: () => PopoverContent,
|
|
45
|
+
PopoverDescription: () => PopoverDescription,
|
|
44
46
|
PopoverPortal: () => PopoverPortal,
|
|
47
|
+
PopoverTitle: () => PopoverTitle,
|
|
45
48
|
PopoverTrigger: () => PopoverTrigger,
|
|
46
|
-
Portal: () =>
|
|
47
|
-
Root: () =>
|
|
48
|
-
|
|
49
|
+
Portal: () => PopoverPortal,
|
|
50
|
+
Root: () => Popover,
|
|
51
|
+
Title: () => PopoverTitle,
|
|
52
|
+
Trigger: () => PopoverTrigger,
|
|
49
53
|
createPopoverScope: () => createPopoverScope
|
|
50
54
|
});
|
|
51
55
|
module.exports = __toCommonJS(index_exports);
|
|
52
56
|
|
|
53
57
|
// src/popover.tsx
|
|
54
58
|
var React = __toESM(require("react"));
|
|
59
|
+
var import_react_use_layout_effect = require("@radix-ui/react-use-layout-effect");
|
|
55
60
|
var import_primitive = require("@radix-ui/primitive");
|
|
56
61
|
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
|
57
62
|
var import_react_context = require("@radix-ui/react-context");
|
|
@@ -87,6 +92,8 @@ var Popover = /* @__PURE__ */ __name((props) => {
|
|
|
87
92
|
const popperScope = usePopperScope(__scopePopover);
|
|
88
93
|
const triggerRef = React.useRef(null);
|
|
89
94
|
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
95
|
+
const [titleCount, setTitleCount] = React.useState(0);
|
|
96
|
+
const [descriptionCount, setDescriptionCount] = React.useState(0);
|
|
90
97
|
const [open, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
|
|
91
98
|
prop: openProp,
|
|
92
99
|
defaultProp: defaultOpen ?? false,
|
|
@@ -98,6 +105,12 @@ var Popover = /* @__PURE__ */ __name((props) => {
|
|
|
98
105
|
{
|
|
99
106
|
scope: __scopePopover,
|
|
100
107
|
contentId: (0, import_react_id.useId)(),
|
|
108
|
+
titleId: (0, import_react_id.useId)(),
|
|
109
|
+
descriptionId: (0, import_react_id.useId)(),
|
|
110
|
+
titlePresent: titleCount > 0,
|
|
111
|
+
descriptionPresent: descriptionCount > 0,
|
|
112
|
+
setTitleCount,
|
|
113
|
+
setDescriptionCount,
|
|
101
114
|
triggerRef,
|
|
102
115
|
open,
|
|
103
116
|
onOpenChange: setOpen,
|
|
@@ -174,38 +187,52 @@ var PopoverContentModal = /* @__PURE__ */ React.forwardRef(
|
|
|
174
187
|
const contentRef = React.useRef(null);
|
|
175
188
|
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
176
189
|
const isRightClickOutsideRef = React.useRef(false);
|
|
190
|
+
const { nodes: branchNodes, registry: branchRegistry } = (0, import_react_focus_scope.useFocusScopeBranchRegistry)();
|
|
177
191
|
React.useEffect(() => {
|
|
178
192
|
const content = contentRef.current;
|
|
179
193
|
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
180
194
|
}, []);
|
|
181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
182
|
-
|
|
195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
196
|
+
import_react_remove_scroll.RemoveScroll,
|
|
183
197
|
{
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
event.preventDefault();
|
|
190
|
-
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
191
|
-
}),
|
|
192
|
-
onPointerDownOutside: (0, import_primitive.composeEventHandlers)(
|
|
193
|
-
props.onPointerDownOutside,
|
|
194
|
-
(event) => {
|
|
195
|
-
const originalEvent = event.detail.originalEvent;
|
|
196
|
-
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
197
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
198
|
-
isRightClickOutsideRef.current = isRightClick;
|
|
199
|
-
},
|
|
200
|
-
{ checkForDefaultPrevented: false }
|
|
198
|
+
as: Slot,
|
|
199
|
+
allowPinchZoom: true,
|
|
200
|
+
shards: React.useMemo(
|
|
201
|
+
() => [contentRef, ...branchNodes.map((node) => ({ current: node }))],
|
|
202
|
+
[contentRef, branchNodes]
|
|
201
203
|
),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
205
|
+
PopoverContentImpl,
|
|
206
|
+
{
|
|
207
|
+
...props,
|
|
208
|
+
ref: composedRefs,
|
|
209
|
+
branchNodes,
|
|
210
|
+
branchRegistry,
|
|
211
|
+
trapFocus: context.open,
|
|
212
|
+
disableOutsidePointerEvents: true,
|
|
213
|
+
onCloseAutoFocus: (0, import_primitive.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
216
|
+
}),
|
|
217
|
+
onPointerDownOutside: (0, import_primitive.composeEventHandlers)(
|
|
218
|
+
props.onPointerDownOutside,
|
|
219
|
+
(event) => {
|
|
220
|
+
const originalEvent = event.detail.originalEvent;
|
|
221
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
222
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
223
|
+
isRightClickOutsideRef.current = isRightClick;
|
|
224
|
+
},
|
|
225
|
+
{ checkForDefaultPrevented: false }
|
|
226
|
+
),
|
|
227
|
+
onFocusOutside: (0, import_primitive.composeEventHandlers)(
|
|
228
|
+
props.onFocusOutside,
|
|
229
|
+
(event) => event.preventDefault(),
|
|
230
|
+
{ checkForDefaultPrevented: false }
|
|
231
|
+
)
|
|
232
|
+
}
|
|
206
233
|
)
|
|
207
234
|
}
|
|
208
|
-
)
|
|
235
|
+
);
|
|
209
236
|
}, "PopoverContentModal")
|
|
210
237
|
);
|
|
211
238
|
var PopoverContentNonModal = /* @__PURE__ */ React.forwardRef(
|
|
@@ -262,10 +289,17 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
262
289
|
onPointerDownOutside,
|
|
263
290
|
onFocusOutside,
|
|
264
291
|
onInteractOutside,
|
|
292
|
+
"aria-describedby": ariaDescribedby,
|
|
293
|
+
branchNodes,
|
|
294
|
+
branchRegistry,
|
|
295
|
+
children,
|
|
265
296
|
...contentProps
|
|
266
297
|
} = props;
|
|
267
298
|
const context = usePopoverContext(CONTENT_NAME, __scopePopover);
|
|
268
299
|
const popperScope = usePopperScope(__scopePopover);
|
|
300
|
+
const [contentNode, setContentNode] = React.useState(null);
|
|
301
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setContentNode);
|
|
302
|
+
(0, import_react_focus_scope.useFocusScopeBranch)(contentNode);
|
|
269
303
|
(0, import_react_focus_guards.useFocusGuards)();
|
|
270
304
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
271
305
|
import_react_focus_scope.FocusScope,
|
|
@@ -273,6 +307,7 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
273
307
|
asChild: true,
|
|
274
308
|
loop: true,
|
|
275
309
|
trapped: trapFocus,
|
|
310
|
+
branches: branchNodes,
|
|
276
311
|
onMountAutoFocus: onOpenAutoFocus,
|
|
277
312
|
onUnmountAutoFocus: onCloseAutoFocus,
|
|
278
313
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -292,9 +327,11 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
292
327
|
"data-state": getState(context.open),
|
|
293
328
|
role: "dialog",
|
|
294
329
|
id: context.contentId,
|
|
330
|
+
"aria-labelledby": context.titlePresent ? context.titleId : void 0,
|
|
331
|
+
"aria-describedby": context.descriptionPresent ? concatAriaDescribedby(ariaDescribedby, context.descriptionId) : ariaDescribedby,
|
|
295
332
|
...popperScope,
|
|
296
333
|
...contentProps,
|
|
297
|
-
ref:
|
|
334
|
+
ref: composedRefs,
|
|
298
335
|
style: {
|
|
299
336
|
...contentProps.style,
|
|
300
337
|
// re-namespace exposed content custom properties
|
|
@@ -305,7 +342,8 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
305
342
|
"--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
|
|
306
343
|
"--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
|
|
307
344
|
}
|
|
308
|
-
}
|
|
345
|
+
},
|
|
346
|
+
children: branchRegistry ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_focus_scope.FocusScopeBranchProvider, { value: branchRegistry, children }) : children
|
|
309
347
|
}
|
|
310
348
|
)
|
|
311
349
|
}
|
|
@@ -314,6 +352,28 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
314
352
|
);
|
|
315
353
|
}, "PopoverContentImpl")
|
|
316
354
|
);
|
|
355
|
+
var PopoverTitle = /* @__PURE__ */ React.forwardRef(
|
|
356
|
+
/* @__PURE__ */ __name(function PopoverTitle2(props, forwardedRef) {
|
|
357
|
+
const { __scopePopover, ...titleProps } = props;
|
|
358
|
+
const context = usePopoverContext("PopoverTitle", __scopePopover);
|
|
359
|
+
const { setTitleCount } = context;
|
|
360
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
361
|
+
setTitleCount((count) => count + 1);
|
|
362
|
+
return () => setTitleCount((count) => count - 1);
|
|
363
|
+
}, [setTitleCount]);
|
|
364
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
365
|
+
}, "PopoverTitle")
|
|
366
|
+
);
|
|
367
|
+
var PopoverDescription = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function PopoverDescription2(props, forwardedRef) {
|
|
368
|
+
const { __scopePopover, ...descriptionProps } = props;
|
|
369
|
+
const context = usePopoverContext("PopoverDescription", __scopePopover);
|
|
370
|
+
const { setDescriptionCount } = context;
|
|
371
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
372
|
+
setDescriptionCount((count) => count + 1);
|
|
373
|
+
return () => setDescriptionCount((count) => count - 1);
|
|
374
|
+
}, [setDescriptionCount]);
|
|
375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
376
|
+
}, "PopoverDescription"));
|
|
317
377
|
var CLOSE_NAME = "PopoverClose";
|
|
318
378
|
var PopoverClose = /* @__PURE__ */ React.forwardRef(
|
|
319
379
|
/* @__PURE__ */ __name(function PopoverClose2(props, forwardedRef) {
|
|
@@ -341,11 +401,15 @@ function getState(open) {
|
|
|
341
401
|
return open ? "open" : "closed";
|
|
342
402
|
}
|
|
343
403
|
__name(getState, "getState");
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
404
|
+
function concatAriaDescribedby(...values) {
|
|
405
|
+
const ids = /* @__PURE__ */ new Set();
|
|
406
|
+
for (const value of values) {
|
|
407
|
+
if (typeof value !== "string") continue;
|
|
408
|
+
for (const id of String(value).trim().split(/\s+/)) {
|
|
409
|
+
if (id) ids.add(id);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return ids.size > 0 ? Array.from(ids).join(" ") : void 0;
|
|
413
|
+
}
|
|
414
|
+
__name(concatAriaDescribedby, "concatAriaDescribedby");
|
|
351
415
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/popover.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createPopoverScope,\n //\n Popover,\n PopoverAnchor,\n PopoverTrigger,\n PopoverPortal,\n PopoverContent,\n PopoverClose,\n PopoverArrow,\n //\n Root,\n Anchor,\n Trigger,\n Portal,\n Content,\n Close,\n Arrow,\n} from './popover';\nexport type {\n PopoverProps,\n PopoverAnchorProps,\n PopoverTriggerProps,\n PopoverPortalProps,\n PopoverContentProps,\n PopoverCloseProps,\n PopoverArrowProps,\n} from './popover';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { FocusScope } from '@radix-ui/react-focus-scope';\nimport { useId } from '@radix-ui/react-id';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { createSlot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { hideOthers } from 'aria-hidden';\nimport { RemoveScroll } from 'react-remove-scroll';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPOVER_NAME = 'Popover';\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope };\nconst [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope,\n]);\nconst usePopperScope = createPopperScope();\n\ntype PopoverContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n hasCustomAnchor: boolean;\n onCustomAnchorAdd(): void;\n onCustomAnchorRemove(): void;\n modal: boolean;\n};\n\nconst [PopoverProvider, usePopoverContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME);\n\ninterface PopoverProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\nconst Popover: React.FC<PopoverProps> = (props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false,\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: POPOVER_NAME,\n });\n\n return (\n <PopperPrimitive.Root {...popperScope}>\n <PopoverProvider\n scope={__scopePopover}\n contentId={useId()}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal={modal}\n >\n {children}\n </PopoverProvider>\n </PopperPrimitive.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor';\n\ntype PopoverAnchorElement = React.ComponentRef<typeof PopperPrimitive.Anchor>;\ntype PopperAnchorProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Anchor>;\ninterface PopoverAnchorProps extends PopperAnchorProps {}\n\nconst PopoverAnchor = /* @__PURE__ */ React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n function PopoverAnchor(props: ScopedProps<PopoverAnchorProps>, forwardedRef) {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n\n return <PopperPrimitive.Anchor {...popperScope} {...anchorProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger';\n\ntype PopoverTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface PopoverTriggerProps extends PrimitiveButtonProps {}\n\nconst PopoverTrigger = /* @__PURE__ */ React.forwardRef<PopoverTriggerElement, PopoverTriggerProps>(\n function PopoverTrigger(props: ScopedProps<PopoverTriggerProps>, forwardedRef) {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n\n const trigger = (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n {trigger}\n </PopperPrimitive.Anchor>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'PopoverPortal';\n\ntype PortalContextValue = { forceMount?: true };\nconst [PortalProvider, usePortalContext] = createPopoverContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface PopoverPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverPortal: React.FC<PopoverPortalProps> = (props: ScopedProps<PopoverPortalProps>) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return (\n <PortalProvider scope={__scopePopover} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent';\n\ninterface PopoverContentProps extends PopoverContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverContent = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentProps\n>(\n // blank line to reduce diff noise\n function PopoverContent(props: ScopedProps<PopoverContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <PopoverContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <PopoverContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Slot = createSlot('PopoverContent.RemoveScroll');\n\ntype PopoverContentTypeElement = PopoverContentImplElement;\ninterface PopoverContentTypeProps extends Omit<\n PopoverContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents'\n> {}\n\nconst PopoverContentModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <RemoveScroll as={Slot} allowPinchZoom>\n <PopoverContentImpl\n {...props}\n ref={composedRefs}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false },\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false },\n )}\n />\n </RemoveScroll>\n );\n },\n);\n\nconst PopoverContentNonModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentNonModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <PopoverContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ComponentRef<typeof PopperPrimitive.Content>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface PopoverContentImplProps\n extends Omit<PopperContentProps, 'onPlaced'>, Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n}\n\nconst PopoverContentImpl = /* @__PURE__ */ React.forwardRef<\n PopoverContentImplElement,\n PopoverContentImplProps\n>(\n // blank line to reduce diff noise\n function PopoverContentImpl(props: ScopedProps<PopoverContentImplProps>, forwardedRef) {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n\n // Make sure the whole tree has focus guards as our `Popover` may be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n return (\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={disableOutsidePointerEvents}\n onInteractOutside={onInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={onFocusOutside}\n onDismiss={() => context.onOpenChange(false)}\n deferPointerDownOutside\n >\n <PopperPrimitive.Content\n data-state={getState(context.open)}\n role=\"dialog\"\n id={context.contentId}\n {...popperScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n '--radix-popover-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-popover-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-popover-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-popover-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-popover-trigger-height': 'var(--radix-popper-anchor-height)',\n },\n }}\n />\n </DismissableLayer>\n </FocusScope>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose';\n\ntype PopoverCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface PopoverCloseProps extends PrimitiveButtonProps {}\n\nconst PopoverClose = /* @__PURE__ */ React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n function PopoverClose(props: ScopedProps<PopoverCloseProps>, forwardedRef) {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverArrowElement = React.ComponentRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;\ninterface PopoverArrowProps extends PopperArrowProps {}\n\nconst PopoverArrow = /* @__PURE__ */ React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n function PopoverArrow(props: ScopedProps<PopoverArrowProps>, forwardedRef) {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst Root = Popover;\nconst Anchor = PopoverAnchor;\nconst Trigger = PopoverTrigger;\nconst Portal = PopoverPortal;\nconst Content = PopoverContent;\nconst Close = PopoverClose;\nconst Arrow = PopoverArrow;\n\nexport {\n createPopoverScope,\n //\n Popover,\n PopoverAnchor,\n PopoverTrigger,\n PopoverPortal,\n PopoverContent,\n PopoverClose,\n PopoverArrow,\n //\n Root,\n Anchor,\n Trigger,\n Portal,\n Content,\n Close,\n Arrow,\n};\nexport type {\n PopoverProps,\n PopoverAnchorProps,\n PopoverTriggerProps,\n PopoverPortalProps,\n PopoverContentProps,\n PopoverCloseProps,\n PopoverArrowProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createPopoverScope,\n //\n Popover,\n PopoverAnchor,\n PopoverTrigger,\n PopoverPortal,\n PopoverContent,\n PopoverTitle,\n PopoverDescription,\n PopoverClose,\n PopoverArrow,\n //\n Root,\n Anchor,\n Trigger,\n Portal,\n Content,\n Title,\n Description,\n Close,\n Arrow,\n} from './popover';\nexport type {\n PopoverProps,\n PopoverAnchorProps,\n PopoverTriggerProps,\n PopoverPortalProps,\n PopoverContentProps,\n PopoverTitleProps,\n PopoverDescriptionProps,\n PopoverCloseProps,\n PopoverArrowProps,\n} from './popover';\n", "import * as React from 'react';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport {\n FocusScope,\n FocusScopeBranchProvider,\n useFocusScopeBranch,\n useFocusScopeBranchRegistry,\n} from '@radix-ui/react-focus-scope';\nimport type { FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';\nimport { useId } from '@radix-ui/react-id';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { createSlot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { hideOthers } from 'aria-hidden';\nimport { RemoveScroll } from 'react-remove-scroll';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPOVER_NAME = 'Popover';\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope };\nconst [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope,\n]);\nconst usePopperScope = createPopperScope();\n\ninterface PopoverContextValue {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n titlePresent: boolean;\n descriptionPresent: boolean;\n setTitleCount: React.Dispatch<React.SetStateAction<number>>;\n setDescriptionCount: React.Dispatch<React.SetStateAction<number>>;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n hasCustomAnchor: boolean;\n onCustomAnchorAdd(): void;\n onCustomAnchorRemove(): void;\n modal: boolean;\n}\n\nconst [PopoverProvider, usePopoverContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME);\n\ninterface PopoverProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\nconst Popover: React.FC<PopoverProps> = (props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false,\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [titleCount, setTitleCount] = React.useState(0);\n const [descriptionCount, setDescriptionCount] = React.useState(0);\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: POPOVER_NAME,\n });\n\n return (\n <PopperPrimitive.Root {...popperScope}>\n <PopoverProvider\n scope={__scopePopover}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n titlePresent={titleCount > 0}\n descriptionPresent={descriptionCount > 0}\n setTitleCount={setTitleCount}\n setDescriptionCount={setDescriptionCount}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal={modal}\n >\n {children}\n </PopoverProvider>\n </PopperPrimitive.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor';\n\ntype PopoverAnchorElement = React.ComponentRef<typeof PopperPrimitive.Anchor>;\ntype PopperAnchorProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Anchor>;\ninterface PopoverAnchorProps extends PopperAnchorProps {}\n\nconst PopoverAnchor = /* @__PURE__ */ React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n function PopoverAnchor(props: ScopedProps<PopoverAnchorProps>, forwardedRef) {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n\n return <PopperPrimitive.Anchor {...popperScope} {...anchorProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger';\n\ntype PopoverTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface PopoverTriggerProps extends PrimitiveButtonProps {}\n\nconst PopoverTrigger = /* @__PURE__ */ React.forwardRef<PopoverTriggerElement, PopoverTriggerProps>(\n function PopoverTrigger(props: ScopedProps<PopoverTriggerProps>, forwardedRef) {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n\n const trigger = (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n {trigger}\n </PopperPrimitive.Anchor>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'PopoverPortal';\n\ntype PortalContextValue = { forceMount?: true };\nconst [PortalProvider, usePortalContext] = createPopoverContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface PopoverPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverPortal: React.FC<PopoverPortalProps> = (props: ScopedProps<PopoverPortalProps>) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return (\n <PortalProvider scope={__scopePopover} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent';\n\ninterface PopoverContentProps extends PopoverContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverContent = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentProps\n>(\n // blank line to reduce diff noise\n function PopoverContent(props: ScopedProps<PopoverContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <PopoverContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <PopoverContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Slot = createSlot('PopoverContent.RemoveScroll');\n\ntype PopoverContentTypeElement = PopoverContentImplElement;\ninterface PopoverContentTypeProps extends Omit<\n PopoverContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents' | 'branchRegistry' | 'branchNodes'\n> {}\n\nconst PopoverContentModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n\n // Allows nested portalled layers to register themselves as branches of this\n // modal `Popover` so focus isn't reclaimed and scroll isn't locked for\n // them. See: https://github.com/radix-ui/primitives/issues/3423\n const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <RemoveScroll\n as={Slot}\n allowPinchZoom\n shards={React.useMemo(\n () => [contentRef, ...branchNodes.map((node) => ({ current: node }))],\n [contentRef, branchNodes],\n )}\n >\n <PopoverContentImpl\n {...props}\n ref={composedRefs}\n branchNodes={branchNodes}\n branchRegistry={branchRegistry}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false },\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false },\n )}\n />\n </RemoveScroll>\n );\n },\n);\n\nconst PopoverContentNonModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentNonModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <PopoverContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ComponentRef<typeof PopperPrimitive.Content>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface PopoverContentImplProps\n extends Omit<PopperContentProps, 'onPlaced'>, Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n\n /**\n * Branch nodes registered by nested, portalled layers. Passed to the trapped\n * `FocusScope` so focus isn't reclaimed from them. Only provided by the modal\n * variant.\n * @internal\n */\n branchNodes?: HTMLElement[];\n\n /**\n * Registry that nested, portalled layers use to register themselves as branches of this modal\n * `Popover`. Only provided by the modal variant.\n * @internal\n */\n branchRegistry?: FocusScopeBranchRegistry;\n}\n\nconst PopoverContentImpl = /* @__PURE__ */ React.forwardRef<\n PopoverContentImplElement,\n PopoverContentImplProps\n>(\n // blank line to reduce diff noise\n function PopoverContentImpl(props: ScopedProps<PopoverContentImplProps>, forwardedRef) {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n 'aria-describedby': ariaDescribedby,\n branchNodes,\n branchRegistry,\n children,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n\n // When this `Popover` is nested inside a modal layer (eg. a `Dialog`) but\n // portalled outside of it, register its content with the ancestor layer so\n // focus isn't reclaimed and scroll isn't locked for it. No-ops when there\n // is no ancestor layer. See:\n // https://github.com/radix-ui/primitives/issues/3423\n const [contentNode, setContentNode] = React.useState<PopoverContentImplElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setContentNode);\n useFocusScopeBranch(contentNode);\n\n // Make sure the whole tree has focus guards as our `Popover` may be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n return (\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n branches={branchNodes}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={disableOutsidePointerEvents}\n onInteractOutside={onInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={onFocusOutside}\n onDismiss={() => context.onOpenChange(false)}\n deferPointerDownOutside\n >\n <PopperPrimitive.Content\n data-state={getState(context.open)}\n role=\"dialog\"\n id={context.contentId}\n aria-labelledby={context.titlePresent ? context.titleId : undefined}\n aria-describedby={\n context.descriptionPresent\n ? concatAriaDescribedby(ariaDescribedby, context.descriptionId)\n : ariaDescribedby\n }\n {...popperScope}\n {...contentProps}\n ref={composedRefs}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n '--radix-popover-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-popover-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-popover-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-popover-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-popover-trigger-height': 'var(--radix-popper-anchor-height)',\n },\n }}\n >\n {branchRegistry ? (\n <FocusScopeBranchProvider value={branchRegistry}>{children}</FocusScopeBranchProvider>\n ) : (\n children\n )}\n </PopperPrimitive.Content>\n </DismissableLayer>\n </FocusScope>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverTitleElement = React.ComponentRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface PopoverTitleProps extends PrimitiveHeading2Props {}\n\nconst PopoverTitle = /* @__PURE__ */ React.forwardRef<PopoverTitleElement, PopoverTitleProps>(\n function PopoverTitle(props: ScopedProps<PopoverTitleProps>, forwardedRef) {\n const { __scopePopover, ...titleProps } = props;\n const context = usePopoverContext('PopoverTitle', __scopePopover);\n const { setTitleCount } = context;\n useLayoutEffect(() => {\n setTitleCount((count) => count + 1);\n return () => setTitleCount((count) => count - 1);\n }, [setTitleCount]);\n\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverDescriptionElement = React.ComponentRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface PopoverDescriptionProps extends PrimitiveParagraphProps {}\n\nconst PopoverDescription = /* @__PURE__ */ React.forwardRef<\n PopoverDescriptionElement,\n PopoverDescriptionProps\n>(function PopoverDescription(props: ScopedProps<PopoverDescriptionProps>, forwardedRef) {\n const { __scopePopover, ...descriptionProps } = props;\n const context = usePopoverContext('PopoverDescription', __scopePopover);\n const { setDescriptionCount } = context;\n useLayoutEffect(() => {\n setDescriptionCount((count) => count + 1);\n return () => setDescriptionCount((count) => count - 1);\n }, [setDescriptionCount]);\n\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n});\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose';\n\ntype PopoverCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface PopoverCloseProps extends PrimitiveButtonProps {}\n\nconst PopoverClose = /* @__PURE__ */ React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n function PopoverClose(props: ScopedProps<PopoverCloseProps>, forwardedRef) {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverArrowElement = React.ComponentRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;\ninterface PopoverArrowProps extends PopperArrowProps {}\n\nconst PopoverArrow = /* @__PURE__ */ React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n function PopoverArrow(props: ScopedProps<PopoverArrowProps>, forwardedRef) {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: unknown[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') continue;\n for (const id of String(value).trim().split(/\\s+/)) {\n if (id) ids.add(id);\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\nexport {\n createPopoverScope,\n //\n Popover,\n PopoverAnchor,\n PopoverTrigger,\n PopoverPortal,\n PopoverContent,\n PopoverTitle,\n PopoverDescription,\n PopoverClose,\n PopoverArrow,\n //\n Popover as Root,\n PopoverAnchor as Anchor,\n PopoverTrigger as Trigger,\n PopoverPortal as Portal,\n PopoverContent as Content,\n PopoverTitle as Title,\n PopoverDescription as Description,\n PopoverClose as Close,\n PopoverArrow as Arrow,\n};\nexport type {\n PopoverProps,\n PopoverAnchorProps,\n PopoverTriggerProps,\n PopoverPortalProps,\n PopoverContentProps,\n PopoverTitleProps,\n PopoverDescriptionProps,\n PopoverCloseProps,\n PopoverArrowProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,qCAAgC;AAChC,uBAAqC;AACrC,gCAAgC;AAChC,2BAAmC;AACnC,qCAAiC;AACjC,gCAA+B;AAC/B,+BAKO;AAEP,sBAAsB;AACtB,sBAAiC;AACjC,0BAAkC;AAClC,0BAA0C;AAC1C,4BAAyB;AACzB,6BAA0B;AAC1B,wBAA2B;AAC3B,0CAAqC;AACrC,yBAA2B;AAC3B,iCAA6B;AAoEvB;AA5DN,IAAM,eAAe;AAGrB,IAAM,CAAC,sBAAsB,kBAAkB,QAAI,yCAAmB,cAAc;AAAA,EAClF;AACF,CAAC;AACD,IAAM,qBAAiB,uCAAkB;AAoBzC,IAAM,CAAC,iBAAiB,iBAAiB,IACvC,qBAA0C,YAAY;AAUxD,IAAM,UAAkC,wBAAC,UAAqC;AAC5E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,EACV,IAAI;AACJ,QAAM,cAAc,eAAe,cAAc;AACjD,QAAM,aAAmB,aAA0B,IAAI;AACvD,QAAM,CAAC,iBAAiB,kBAAkB,IAAU,eAAS,KAAK;AAClE,QAAM,CAAC,YAAY,aAAa,IAAU,eAAS,CAAC;AACpD,QAAM,CAAC,kBAAkB,mBAAmB,IAAU,eAAS,CAAC;AAChE,QAAM,CAAC,MAAM,OAAO,QAAI,0DAAqB;AAAA,IAC3C,MAAM;AAAA,IACN,aAAa,eAAe;A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WACE;AAAA,MAAC,iCAAU;AAAA,MAAV;AAAA,QACC,MAAK;AAAA,QACJ,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,aAAS,uCAAqB,MAAM,SAAS,MAAM,QAAQ,aAAa,KAAK,CAAC;AAAA;AAAA,IAChF;AAAA,EAEJ,GAXA;AAYF;AAUA,IAAM,eAA+B,gBAAM;AAAA,EACzC,gCAASC,cAAa,OAAuC,cAAc;AACzE,UAAM,EAAE,gBAAgB,GAAG,WAAW,IAAI;AAC1C,UAAM,cAAc,eAAe,cAAc;AACjD,WAAO,4CAAiB,uBAAhB,EAAuB,GAAG,aAAc,GAAG,YAAY,KAAK,cAAc;AAAA,EACpF,GAJA;AAKF;AAIA,SAAS,SAAS,MAAe;AAC/B,SAAO,OAAO,SAAS;AACzB;AAFS;AAKT,SAAS,yBAAyB,QAAuC;AACvE,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,SAAU;AAC/B,eAAW,MAAM,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG;AAClD,UAAI,GAAI,KAAI,IAAI,EAAE;AAAA,IACpB;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,IAAI;AACpD;AAVS;",
|
|
6
|
+
"names": ["PopoverAnchor", "PopoverTrigger", "PortalPrimitive", "PopoverContent", "PopoverContentModal", "PopoverContentNonModal", "PopoverContentImpl", "PopoverTitle", "PopoverDescription", "PopoverClose", "PopoverArrow"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,18 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4
4
|
|
|
5
5
|
// src/popover.tsx
|
|
6
6
|
import * as React from "react";
|
|
7
|
+
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
|
7
8
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
8
9
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
9
10
|
import { createContextScope } from "@radix-ui/react-context";
|
|
10
11
|
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
11
12
|
import { useFocusGuards } from "@radix-ui/react-focus-guards";
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
FocusScope,
|
|
15
|
+
FocusScopeBranchProvider,
|
|
16
|
+
useFocusScopeBranch,
|
|
17
|
+
useFocusScopeBranchRegistry
|
|
18
|
+
} from "@radix-ui/react-focus-scope";
|
|
13
19
|
import { useId } from "@radix-ui/react-id";
|
|
14
20
|
import * as PopperPrimitive from "@radix-ui/react-popper";
|
|
15
21
|
import { createPopperScope } from "@radix-ui/react-popper";
|
|
@@ -39,6 +45,8 @@ var Popover = /* @__PURE__ */ __name((props) => {
|
|
|
39
45
|
const popperScope = usePopperScope(__scopePopover);
|
|
40
46
|
const triggerRef = React.useRef(null);
|
|
41
47
|
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
48
|
+
const [titleCount, setTitleCount] = React.useState(0);
|
|
49
|
+
const [descriptionCount, setDescriptionCount] = React.useState(0);
|
|
42
50
|
const [open, setOpen] = useControllableState({
|
|
43
51
|
prop: openProp,
|
|
44
52
|
defaultProp: defaultOpen ?? false,
|
|
@@ -50,6 +58,12 @@ var Popover = /* @__PURE__ */ __name((props) => {
|
|
|
50
58
|
{
|
|
51
59
|
scope: __scopePopover,
|
|
52
60
|
contentId: useId(),
|
|
61
|
+
titleId: useId(),
|
|
62
|
+
descriptionId: useId(),
|
|
63
|
+
titlePresent: titleCount > 0,
|
|
64
|
+
descriptionPresent: descriptionCount > 0,
|
|
65
|
+
setTitleCount,
|
|
66
|
+
setDescriptionCount,
|
|
53
67
|
triggerRef,
|
|
54
68
|
open,
|
|
55
69
|
onOpenChange: setOpen,
|
|
@@ -126,38 +140,52 @@ var PopoverContentModal = /* @__PURE__ */ React.forwardRef(
|
|
|
126
140
|
const contentRef = React.useRef(null);
|
|
127
141
|
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
128
142
|
const isRightClickOutsideRef = React.useRef(false);
|
|
143
|
+
const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();
|
|
129
144
|
React.useEffect(() => {
|
|
130
145
|
const content = contentRef.current;
|
|
131
146
|
if (content) return hideOthers(content);
|
|
132
147
|
}, []);
|
|
133
|
-
return /* @__PURE__ */ jsx(
|
|
134
|
-
|
|
148
|
+
return /* @__PURE__ */ jsx(
|
|
149
|
+
RemoveScroll,
|
|
135
150
|
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
143
|
-
}),
|
|
144
|
-
onPointerDownOutside: composeEventHandlers(
|
|
145
|
-
props.onPointerDownOutside,
|
|
146
|
-
(event) => {
|
|
147
|
-
const originalEvent = event.detail.originalEvent;
|
|
148
|
-
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
149
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
150
|
-
isRightClickOutsideRef.current = isRightClick;
|
|
151
|
-
},
|
|
152
|
-
{ checkForDefaultPrevented: false }
|
|
151
|
+
as: Slot,
|
|
152
|
+
allowPinchZoom: true,
|
|
153
|
+
shards: React.useMemo(
|
|
154
|
+
() => [contentRef, ...branchNodes.map((node) => ({ current: node }))],
|
|
155
|
+
[contentRef, branchNodes]
|
|
153
156
|
),
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
children: /* @__PURE__ */ jsx(
|
|
158
|
+
PopoverContentImpl,
|
|
159
|
+
{
|
|
160
|
+
...props,
|
|
161
|
+
ref: composedRefs,
|
|
162
|
+
branchNodes,
|
|
163
|
+
branchRegistry,
|
|
164
|
+
trapFocus: context.open,
|
|
165
|
+
disableOutsidePointerEvents: true,
|
|
166
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
169
|
+
}),
|
|
170
|
+
onPointerDownOutside: composeEventHandlers(
|
|
171
|
+
props.onPointerDownOutside,
|
|
172
|
+
(event) => {
|
|
173
|
+
const originalEvent = event.detail.originalEvent;
|
|
174
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
175
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
176
|
+
isRightClickOutsideRef.current = isRightClick;
|
|
177
|
+
},
|
|
178
|
+
{ checkForDefaultPrevented: false }
|
|
179
|
+
),
|
|
180
|
+
onFocusOutside: composeEventHandlers(
|
|
181
|
+
props.onFocusOutside,
|
|
182
|
+
(event) => event.preventDefault(),
|
|
183
|
+
{ checkForDefaultPrevented: false }
|
|
184
|
+
)
|
|
185
|
+
}
|
|
158
186
|
)
|
|
159
187
|
}
|
|
160
|
-
)
|
|
188
|
+
);
|
|
161
189
|
}, "PopoverContentModal")
|
|
162
190
|
);
|
|
163
191
|
var PopoverContentNonModal = /* @__PURE__ */ React.forwardRef(
|
|
@@ -214,10 +242,17 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
214
242
|
onPointerDownOutside,
|
|
215
243
|
onFocusOutside,
|
|
216
244
|
onInteractOutside,
|
|
245
|
+
"aria-describedby": ariaDescribedby,
|
|
246
|
+
branchNodes,
|
|
247
|
+
branchRegistry,
|
|
248
|
+
children,
|
|
217
249
|
...contentProps
|
|
218
250
|
} = props;
|
|
219
251
|
const context = usePopoverContext(CONTENT_NAME, __scopePopover);
|
|
220
252
|
const popperScope = usePopperScope(__scopePopover);
|
|
253
|
+
const [contentNode, setContentNode] = React.useState(null);
|
|
254
|
+
const composedRefs = useComposedRefs(forwardedRef, setContentNode);
|
|
255
|
+
useFocusScopeBranch(contentNode);
|
|
221
256
|
useFocusGuards();
|
|
222
257
|
return /* @__PURE__ */ jsx(
|
|
223
258
|
FocusScope,
|
|
@@ -225,6 +260,7 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
225
260
|
asChild: true,
|
|
226
261
|
loop: true,
|
|
227
262
|
trapped: trapFocus,
|
|
263
|
+
branches: branchNodes,
|
|
228
264
|
onMountAutoFocus: onOpenAutoFocus,
|
|
229
265
|
onUnmountAutoFocus: onCloseAutoFocus,
|
|
230
266
|
children: /* @__PURE__ */ jsx(
|
|
@@ -244,9 +280,11 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
244
280
|
"data-state": getState(context.open),
|
|
245
281
|
role: "dialog",
|
|
246
282
|
id: context.contentId,
|
|
283
|
+
"aria-labelledby": context.titlePresent ? context.titleId : void 0,
|
|
284
|
+
"aria-describedby": context.descriptionPresent ? concatAriaDescribedby(ariaDescribedby, context.descriptionId) : ariaDescribedby,
|
|
247
285
|
...popperScope,
|
|
248
286
|
...contentProps,
|
|
249
|
-
ref:
|
|
287
|
+
ref: composedRefs,
|
|
250
288
|
style: {
|
|
251
289
|
...contentProps.style,
|
|
252
290
|
// re-namespace exposed content custom properties
|
|
@@ -257,7 +295,8 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
257
295
|
"--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
|
|
258
296
|
"--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
|
|
259
297
|
}
|
|
260
|
-
}
|
|
298
|
+
},
|
|
299
|
+
children: branchRegistry ? /* @__PURE__ */ jsx(FocusScopeBranchProvider, { value: branchRegistry, children }) : children
|
|
261
300
|
}
|
|
262
301
|
)
|
|
263
302
|
}
|
|
@@ -266,6 +305,28 @@ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
266
305
|
);
|
|
267
306
|
}, "PopoverContentImpl")
|
|
268
307
|
);
|
|
308
|
+
var PopoverTitle = /* @__PURE__ */ React.forwardRef(
|
|
309
|
+
/* @__PURE__ */ __name(function PopoverTitle2(props, forwardedRef) {
|
|
310
|
+
const { __scopePopover, ...titleProps } = props;
|
|
311
|
+
const context = usePopoverContext("PopoverTitle", __scopePopover);
|
|
312
|
+
const { setTitleCount } = context;
|
|
313
|
+
useLayoutEffect(() => {
|
|
314
|
+
setTitleCount((count) => count + 1);
|
|
315
|
+
return () => setTitleCount((count) => count - 1);
|
|
316
|
+
}, [setTitleCount]);
|
|
317
|
+
return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
318
|
+
}, "PopoverTitle")
|
|
319
|
+
);
|
|
320
|
+
var PopoverDescription = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function PopoverDescription2(props, forwardedRef) {
|
|
321
|
+
const { __scopePopover, ...descriptionProps } = props;
|
|
322
|
+
const context = usePopoverContext("PopoverDescription", __scopePopover);
|
|
323
|
+
const { setDescriptionCount } = context;
|
|
324
|
+
useLayoutEffect(() => {
|
|
325
|
+
setDescriptionCount((count) => count + 1);
|
|
326
|
+
return () => setDescriptionCount((count) => count - 1);
|
|
327
|
+
}, [setDescriptionCount]);
|
|
328
|
+
return /* @__PURE__ */ jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
329
|
+
}, "PopoverDescription"));
|
|
269
330
|
var CLOSE_NAME = "PopoverClose";
|
|
270
331
|
var PopoverClose = /* @__PURE__ */ React.forwardRef(
|
|
271
332
|
/* @__PURE__ */ __name(function PopoverClose2(props, forwardedRef) {
|
|
@@ -293,28 +354,36 @@ function getState(open) {
|
|
|
293
354
|
return open ? "open" : "closed";
|
|
294
355
|
}
|
|
295
356
|
__name(getState, "getState");
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
357
|
+
function concatAriaDescribedby(...values) {
|
|
358
|
+
const ids = /* @__PURE__ */ new Set();
|
|
359
|
+
for (const value of values) {
|
|
360
|
+
if (typeof value !== "string") continue;
|
|
361
|
+
for (const id of String(value).trim().split(/\s+/)) {
|
|
362
|
+
if (id) ids.add(id);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return ids.size > 0 ? Array.from(ids).join(" ") : void 0;
|
|
366
|
+
}
|
|
367
|
+
__name(concatAriaDescribedby, "concatAriaDescribedby");
|
|
303
368
|
export {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
Close,
|
|
307
|
-
|
|
369
|
+
PopoverAnchor as Anchor,
|
|
370
|
+
PopoverArrow as Arrow,
|
|
371
|
+
PopoverClose as Close,
|
|
372
|
+
PopoverContent as Content,
|
|
373
|
+
PopoverDescription as Description,
|
|
308
374
|
Popover,
|
|
309
375
|
PopoverAnchor,
|
|
310
376
|
PopoverArrow,
|
|
311
377
|
PopoverClose,
|
|
312
378
|
PopoverContent,
|
|
379
|
+
PopoverDescription,
|
|
313
380
|
PopoverPortal,
|
|
381
|
+
PopoverTitle,
|
|
314
382
|
PopoverTrigger,
|
|
315
|
-
Portal,
|
|
316
|
-
|
|
317
|
-
|
|
383
|
+
PopoverPortal as Portal,
|
|
384
|
+
Popover as Root,
|
|
385
|
+
PopoverTitle as Title,
|
|
386
|
+
PopoverTrigger as Trigger,
|
|
318
387
|
createPopoverScope
|
|
319
388
|
};
|
|
320
389
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/popover.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { FocusScope } from '@radix-ui/react-focus-scope';\nimport { useId } from '@radix-ui/react-id';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { createSlot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { hideOthers } from 'aria-hidden';\nimport { RemoveScroll } from 'react-remove-scroll';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPOVER_NAME = 'Popover';\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope };\nconst [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope,\n]);\nconst usePopperScope = createPopperScope();\n\ntype PopoverContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n hasCustomAnchor: boolean;\n onCustomAnchorAdd(): void;\n onCustomAnchorRemove(): void;\n modal: boolean;\n};\n\nconst [PopoverProvider, usePopoverContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME);\n\ninterface PopoverProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\nconst Popover: React.FC<PopoverProps> = (props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false,\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: POPOVER_NAME,\n });\n\n return (\n <PopperPrimitive.Root {...popperScope}>\n <PopoverProvider\n scope={__scopePopover}\n contentId={useId()}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal={modal}\n >\n {children}\n </PopoverProvider>\n </PopperPrimitive.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor';\n\ntype PopoverAnchorElement = React.ComponentRef<typeof PopperPrimitive.Anchor>;\ntype PopperAnchorProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Anchor>;\ninterface PopoverAnchorProps extends PopperAnchorProps {}\n\nconst PopoverAnchor = /* @__PURE__ */ React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n function PopoverAnchor(props: ScopedProps<PopoverAnchorProps>, forwardedRef) {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n\n return <PopperPrimitive.Anchor {...popperScope} {...anchorProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger';\n\ntype PopoverTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface PopoverTriggerProps extends PrimitiveButtonProps {}\n\nconst PopoverTrigger = /* @__PURE__ */ React.forwardRef<PopoverTriggerElement, PopoverTriggerProps>(\n function PopoverTrigger(props: ScopedProps<PopoverTriggerProps>, forwardedRef) {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n\n const trigger = (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n {trigger}\n </PopperPrimitive.Anchor>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'PopoverPortal';\n\ntype PortalContextValue = { forceMount?: true };\nconst [PortalProvider, usePortalContext] = createPopoverContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface PopoverPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverPortal: React.FC<PopoverPortalProps> = (props: ScopedProps<PopoverPortalProps>) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return (\n <PortalProvider scope={__scopePopover} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent';\n\ninterface PopoverContentProps extends PopoverContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverContent = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentProps\n>(\n // blank line to reduce diff noise\n function PopoverContent(props: ScopedProps<PopoverContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <PopoverContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <PopoverContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Slot = createSlot('PopoverContent.RemoveScroll');\n\ntype PopoverContentTypeElement = PopoverContentImplElement;\ninterface PopoverContentTypeProps extends Omit<\n PopoverContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents'\n> {}\n\nconst PopoverContentModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <RemoveScroll as={Slot} allowPinchZoom>\n <PopoverContentImpl\n {...props}\n ref={composedRefs}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false },\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false },\n )}\n />\n </RemoveScroll>\n );\n },\n);\n\nconst PopoverContentNonModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentNonModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <PopoverContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ComponentRef<typeof PopperPrimitive.Content>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface PopoverContentImplProps\n extends Omit<PopperContentProps, 'onPlaced'>, Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n}\n\nconst PopoverContentImpl = /* @__PURE__ */ React.forwardRef<\n PopoverContentImplElement,\n PopoverContentImplProps\n>(\n // blank line to reduce diff noise\n function PopoverContentImpl(props: ScopedProps<PopoverContentImplProps>, forwardedRef) {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n\n // Make sure the whole tree has focus guards as our `Popover` may be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n return (\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={disableOutsidePointerEvents}\n onInteractOutside={onInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={onFocusOutside}\n onDismiss={() => context.onOpenChange(false)}\n deferPointerDownOutside\n >\n <PopperPrimitive.Content\n data-state={getState(context.open)}\n role=\"dialog\"\n id={context.contentId}\n {...popperScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n '--radix-popover-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-popover-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-popover-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-popover-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-popover-trigger-height': 'var(--radix-popper-anchor-height)',\n },\n }}\n />\n </DismissableLayer>\n </FocusScope>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose';\n\ntype PopoverCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface PopoverCloseProps extends PrimitiveButtonProps {}\n\nconst PopoverClose = /* @__PURE__ */ React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n function PopoverClose(props: ScopedProps<PopoverCloseProps>, forwardedRef) {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverArrowElement = React.ComponentRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;\ninterface PopoverArrowProps extends PopperArrowProps {}\n\nconst PopoverArrow = /* @__PURE__ */ React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n function PopoverArrow(props: ScopedProps<PopoverArrowProps>, forwardedRef) {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nconst Root = Popover;\nconst Anchor = PopoverAnchor;\nconst Trigger = PopoverTrigger;\nconst Portal = PopoverPortal;\nconst Content = PopoverContent;\nconst Close = PopoverClose;\nconst Arrow = PopoverArrow;\n\nexport {\n createPopoverScope,\n //\n Popover,\n PopoverAnchor,\n PopoverTrigger,\n PopoverPortal,\n PopoverContent,\n PopoverClose,\n PopoverArrow,\n //\n Root,\n Anchor,\n Trigger,\n Portal,\n Content,\n Close,\n Arrow,\n};\nexport type {\n PopoverProps,\n PopoverAnchorProps,\n PopoverTriggerProps,\n PopoverPortalProps,\n PopoverContentProps,\n PopoverCloseProps,\n PopoverArrowProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,
|
|
6
|
-
"names": ["PopoverAnchor", "PopoverTrigger", "PopoverContent", "PopoverContentModal", "PopoverContentNonModal", "PopoverContentImpl", "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport {\n FocusScope,\n FocusScopeBranchProvider,\n useFocusScopeBranch,\n useFocusScopeBranchRegistry,\n} from '@radix-ui/react-focus-scope';\nimport type { FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';\nimport { useId } from '@radix-ui/react-id';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { createSlot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { hideOthers } from 'aria-hidden';\nimport { RemoveScroll } from 'react-remove-scroll';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPOVER_NAME = 'Popover';\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope };\nconst [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope,\n]);\nconst usePopperScope = createPopperScope();\n\ninterface PopoverContextValue {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n titlePresent: boolean;\n descriptionPresent: boolean;\n setTitleCount: React.Dispatch<React.SetStateAction<number>>;\n setDescriptionCount: React.Dispatch<React.SetStateAction<number>>;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n hasCustomAnchor: boolean;\n onCustomAnchorAdd(): void;\n onCustomAnchorRemove(): void;\n modal: boolean;\n}\n\nconst [PopoverProvider, usePopoverContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME);\n\ninterface PopoverProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\nconst Popover: React.FC<PopoverProps> = (props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false,\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [titleCount, setTitleCount] = React.useState(0);\n const [descriptionCount, setDescriptionCount] = React.useState(0);\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: POPOVER_NAME,\n });\n\n return (\n <PopperPrimitive.Root {...popperScope}>\n <PopoverProvider\n scope={__scopePopover}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n titlePresent={titleCount > 0}\n descriptionPresent={descriptionCount > 0}\n setTitleCount={setTitleCount}\n setDescriptionCount={setDescriptionCount}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal={modal}\n >\n {children}\n </PopoverProvider>\n </PopperPrimitive.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor';\n\ntype PopoverAnchorElement = React.ComponentRef<typeof PopperPrimitive.Anchor>;\ntype PopperAnchorProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Anchor>;\ninterface PopoverAnchorProps extends PopperAnchorProps {}\n\nconst PopoverAnchor = /* @__PURE__ */ React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n function PopoverAnchor(props: ScopedProps<PopoverAnchorProps>, forwardedRef) {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n\n return <PopperPrimitive.Anchor {...popperScope} {...anchorProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger';\n\ntype PopoverTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface PopoverTriggerProps extends PrimitiveButtonProps {}\n\nconst PopoverTrigger = /* @__PURE__ */ React.forwardRef<PopoverTriggerElement, PopoverTriggerProps>(\n function PopoverTrigger(props: ScopedProps<PopoverTriggerProps>, forwardedRef) {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n\n const trigger = (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n {trigger}\n </PopperPrimitive.Anchor>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'PopoverPortal';\n\ntype PortalContextValue = { forceMount?: true };\nconst [PortalProvider, usePortalContext] = createPopoverContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface PopoverPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverPortal: React.FC<PopoverPortalProps> = (props: ScopedProps<PopoverPortalProps>) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return (\n <PortalProvider scope={__scopePopover} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent';\n\ninterface PopoverContentProps extends PopoverContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst PopoverContent = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentProps\n>(\n // blank line to reduce diff noise\n function PopoverContent(props: ScopedProps<PopoverContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <PopoverContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <PopoverContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Slot = createSlot('PopoverContent.RemoveScroll');\n\ntype PopoverContentTypeElement = PopoverContentImplElement;\ninterface PopoverContentTypeProps extends Omit<\n PopoverContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents' | 'branchRegistry' | 'branchNodes'\n> {}\n\nconst PopoverContentModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n\n // Allows nested portalled layers to register themselves as branches of this\n // modal `Popover` so focus isn't reclaimed and scroll isn't locked for\n // them. See: https://github.com/radix-ui/primitives/issues/3423\n const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <RemoveScroll\n as={Slot}\n allowPinchZoom\n shards={React.useMemo(\n () => [contentRef, ...branchNodes.map((node) => ({ current: node }))],\n [contentRef, branchNodes],\n )}\n >\n <PopoverContentImpl\n {...props}\n ref={composedRefs}\n branchNodes={branchNodes}\n branchRegistry={branchRegistry}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false },\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false },\n )}\n />\n </RemoveScroll>\n );\n },\n);\n\nconst PopoverContentNonModal = /* @__PURE__ */ React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>(\n // blank line to reduce diff noise\n function PopoverContentNonModal(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <PopoverContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ComponentRef<typeof PopperPrimitive.Content>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface PopoverContentImplProps\n extends Omit<PopperContentProps, 'onPlaced'>, Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped'];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];\n\n /**\n * Branch nodes registered by nested, portalled layers. Passed to the trapped\n * `FocusScope` so focus isn't reclaimed from them. Only provided by the modal\n * variant.\n * @internal\n */\n branchNodes?: HTMLElement[];\n\n /**\n * Registry that nested, portalled layers use to register themselves as branches of this modal\n * `Popover`. Only provided by the modal variant.\n * @internal\n */\n branchRegistry?: FocusScopeBranchRegistry;\n}\n\nconst PopoverContentImpl = /* @__PURE__ */ React.forwardRef<\n PopoverContentImplElement,\n PopoverContentImplProps\n>(\n // blank line to reduce diff noise\n function PopoverContentImpl(props: ScopedProps<PopoverContentImplProps>, forwardedRef) {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n 'aria-describedby': ariaDescribedby,\n branchNodes,\n branchRegistry,\n children,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n\n // When this `Popover` is nested inside a modal layer (eg. a `Dialog`) but\n // portalled outside of it, register its content with the ancestor layer so\n // focus isn't reclaimed and scroll isn't locked for it. No-ops when there\n // is no ancestor layer. See:\n // https://github.com/radix-ui/primitives/issues/3423\n const [contentNode, setContentNode] = React.useState<PopoverContentImplElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setContentNode);\n useFocusScopeBranch(contentNode);\n\n // Make sure the whole tree has focus guards as our `Popover` may be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n return (\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n branches={branchNodes}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={disableOutsidePointerEvents}\n onInteractOutside={onInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={onFocusOutside}\n onDismiss={() => context.onOpenChange(false)}\n deferPointerDownOutside\n >\n <PopperPrimitive.Content\n data-state={getState(context.open)}\n role=\"dialog\"\n id={context.contentId}\n aria-labelledby={context.titlePresent ? context.titleId : undefined}\n aria-describedby={\n context.descriptionPresent\n ? concatAriaDescribedby(ariaDescribedby, context.descriptionId)\n : ariaDescribedby\n }\n {...popperScope}\n {...contentProps}\n ref={composedRefs}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n '--radix-popover-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-popover-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-popover-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-popover-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-popover-trigger-height': 'var(--radix-popper-anchor-height)',\n },\n }}\n >\n {branchRegistry ? (\n <FocusScopeBranchProvider value={branchRegistry}>{children}</FocusScopeBranchProvider>\n ) : (\n children\n )}\n </PopperPrimitive.Content>\n </DismissableLayer>\n </FocusScope>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverTitleElement = React.ComponentRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface PopoverTitleProps extends PrimitiveHeading2Props {}\n\nconst PopoverTitle = /* @__PURE__ */ React.forwardRef<PopoverTitleElement, PopoverTitleProps>(\n function PopoverTitle(props: ScopedProps<PopoverTitleProps>, forwardedRef) {\n const { __scopePopover, ...titleProps } = props;\n const context = usePopoverContext('PopoverTitle', __scopePopover);\n const { setTitleCount } = context;\n useLayoutEffect(() => {\n setTitleCount((count) => count + 1);\n return () => setTitleCount((count) => count - 1);\n }, [setTitleCount]);\n\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverDescriptionElement = React.ComponentRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface PopoverDescriptionProps extends PrimitiveParagraphProps {}\n\nconst PopoverDescription = /* @__PURE__ */ React.forwardRef<\n PopoverDescriptionElement,\n PopoverDescriptionProps\n>(function PopoverDescription(props: ScopedProps<PopoverDescriptionProps>, forwardedRef) {\n const { __scopePopover, ...descriptionProps } = props;\n const context = usePopoverContext('PopoverDescription', __scopePopover);\n const { setDescriptionCount } = context;\n useLayoutEffect(() => {\n setDescriptionCount((count) => count + 1);\n return () => setDescriptionCount((count) => count - 1);\n }, [setDescriptionCount]);\n\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n});\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose';\n\ntype PopoverCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface PopoverCloseProps extends PrimitiveButtonProps {}\n\nconst PopoverClose = /* @__PURE__ */ React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n function PopoverClose(props: ScopedProps<PopoverCloseProps>, forwardedRef) {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\ntype PopoverArrowElement = React.ComponentRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = React.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;\ninterface PopoverArrowProps extends PopperArrowProps {}\n\nconst PopoverArrow = /* @__PURE__ */ React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n function PopoverArrow(props: ScopedProps<PopoverArrowProps>, forwardedRef) {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: unknown[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') continue;\n for (const id of String(value).trim().split(/\\s+/)) {\n if (id) ids.add(id);\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\nexport {\n createPopoverScope,\n //\n Popover,\n PopoverAnchor,\n PopoverTrigger,\n PopoverPortal,\n PopoverContent,\n PopoverTitle,\n PopoverDescription,\n PopoverClose,\n PopoverArrow,\n //\n Popover as Root,\n PopoverAnchor as Anchor,\n PopoverTrigger as Trigger,\n PopoverPortal as Portal,\n PopoverContent as Content,\n PopoverTitle as Title,\n PopoverDescription as Description,\n PopoverClose as Close,\n PopoverArrow as Arrow,\n};\nexport type {\n PopoverProps,\n PopoverAnchorProps,\n PopoverTriggerProps,\n PopoverPortalProps,\n PopoverContentProps,\n P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MAAM,SAAS,MAAM,QAAQ,aAAa,KAAK,CAAC;AAAA;AAAA,IAChF;AAAA,EAEJ,GAXA;AAYF;AAUA,IAAM,eAA+B,gBAAM;AAAA,EACzC,gCAASC,cAAa,OAAuC,cAAc;AACzE,UAAM,EAAE,gBAAgB,GAAG,WAAW,IAAI;AAC1C,UAAM,cAAc,eAAe,cAAc;AACjD,WAAO,oBAAiB,uBAAhB,EAAuB,GAAG,aAAc,GAAG,YAAY,KAAK,cAAc;AAAA,EACpF,GAJA;AAKF;AAIA,SAAS,SAAS,MAAe;AAC/B,SAAO,OAAO,SAAS;AACzB;AAFS;AAKT,SAAS,yBAAyB,QAAuC;AACvE,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,SAAU;AAC/B,eAAW,MAAM,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG;AAClD,UAAI,GAAI,KAAI,IAAI,EAAE;AAAA,IACpB;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,IAAI;AACpD;AAVS;",
|
|
6
|
+
"names": ["PopoverAnchor", "PopoverTrigger", "PopoverContent", "PopoverContentModal", "PopoverContentNonModal", "PopoverContentImpl", "PopoverTitle", "PopoverDescription", "PopoverClose", "PopoverArrow"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-popover",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,25 +13,26 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"aria-hidden": "^1.2.4",
|
|
15
15
|
"react-remove-scroll": "^2.7.2",
|
|
16
|
-
"@radix-ui/primitive": "1.1.
|
|
17
|
-
"@radix-ui/react-compose-refs": "1.1.
|
|
18
|
-
"@radix-ui/react-
|
|
19
|
-
"@radix-ui/react-
|
|
20
|
-
"@radix-ui/react-
|
|
21
|
-
"@radix-ui/react-
|
|
22
|
-
"@radix-ui/react-
|
|
23
|
-
"@radix-ui/react-
|
|
24
|
-
"@radix-ui/react-
|
|
25
|
-
"@radix-ui/react-
|
|
26
|
-
"@radix-ui/react-
|
|
27
|
-
"@radix-ui/react-
|
|
28
|
-
"@radix-ui/react-use-
|
|
16
|
+
"@radix-ui/primitive": "1.1.7",
|
|
17
|
+
"@radix-ui/react-compose-refs": "1.1.4",
|
|
18
|
+
"@radix-ui/react-focus-guards": "1.1.5",
|
|
19
|
+
"@radix-ui/react-focus-scope": "1.1.15",
|
|
20
|
+
"@radix-ui/react-context": "1.2.1",
|
|
21
|
+
"@radix-ui/react-dismissable-layer": "1.1.18",
|
|
22
|
+
"@radix-ui/react-portal": "1.1.16",
|
|
23
|
+
"@radix-ui/react-presence": "1.1.9",
|
|
24
|
+
"@radix-ui/react-popper": "1.3.6",
|
|
25
|
+
"@radix-ui/react-primitive": "2.1.9",
|
|
26
|
+
"@radix-ui/react-slot": "1.3.2",
|
|
27
|
+
"@radix-ui/react-use-controllable-state": "1.2.5",
|
|
28
|
+
"@radix-ui/react-use-layout-effect": "1.1.3",
|
|
29
|
+
"@radix-ui/react-id": "1.1.3"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@types/react": "^19.2.
|
|
32
|
-
"@types/react-dom": "^19.2.
|
|
33
|
-
"react": "^19.2.
|
|
34
|
-
"react-dom": "^19.2.
|
|
32
|
+
"@types/react": "^19.2.17",
|
|
33
|
+
"@types/react-dom": "^19.2.3",
|
|
34
|
+
"react": "^19.2.7",
|
|
35
|
+
"react-dom": "^19.2.7",
|
|
35
36
|
"typescript": "^5.9.3",
|
|
36
37
|
"@repo/builder": "0.0.0",
|
|
37
38
|
"@repo/typescript-config": "0.0.0"
|