@radix-ui/react-popover 1.0.8-rc.9 → 1.1.0-rc.1
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 +49 -37
- package/dist/index.d.ts +49 -37
- package/dist/index.js +315 -326
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +287 -292
- package/dist/index.mjs.map +7 -1
- package/package.json +14 -15
- package/dist/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,342 +1,331 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
18
31
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* Popover
|
|
61
|
-
* -----------------------------------------------------------------------------------------------*/ const $7d632c09314cddaf$var$POPOVER_NAME = 'Popover';
|
|
62
|
-
const [$7d632c09314cddaf$var$createPopoverContext, $7d632c09314cddaf$export$c8393c9e73286932] = $aJPOC$radixuireactcontext.createContextScope($7d632c09314cddaf$var$POPOVER_NAME, [
|
|
63
|
-
$aJPOC$radixuireactpopper.createPopperScope
|
|
64
|
-
]);
|
|
65
|
-
const $7d632c09314cddaf$var$usePopperScope = $aJPOC$radixuireactpopper.createPopperScope();
|
|
66
|
-
const [$7d632c09314cddaf$var$PopoverProvider, $7d632c09314cddaf$var$usePopoverContext] = $7d632c09314cddaf$var$createPopoverContext($7d632c09314cddaf$var$POPOVER_NAME);
|
|
67
|
-
const $7d632c09314cddaf$export$5b6b19405a83ff9d = (props)=>{
|
|
68
|
-
const { __scopePopover: __scopePopover , children: children , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , modal: modal = false } = props;
|
|
69
|
-
const popperScope = $7d632c09314cddaf$var$usePopperScope(__scopePopover);
|
|
70
|
-
const triggerRef = $aJPOC$react.useRef(null);
|
|
71
|
-
const [hasCustomAnchor, setHasCustomAnchor] = $aJPOC$react.useState(false);
|
|
72
|
-
const [open = false, setOpen] = $aJPOC$radixuireactusecontrollablestate.useControllableState({
|
|
73
|
-
prop: openProp,
|
|
74
|
-
defaultProp: defaultOpen,
|
|
75
|
-
onChange: onOpenChange
|
|
32
|
+
// packages/react/popover/src/Popover.tsx
|
|
33
|
+
var React = __toESM(__require("react"));
|
|
34
|
+
var import_primitive = __require("@radix-ui/primitive");
|
|
35
|
+
var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
|
|
36
|
+
var import_react_context = __require("@radix-ui/react-context");
|
|
37
|
+
var import_react_dismissable_layer = __require("@radix-ui/react-dismissable-layer");
|
|
38
|
+
var import_react_focus_guards = __require("@radix-ui/react-focus-guards");
|
|
39
|
+
var import_react_focus_scope = __require("@radix-ui/react-focus-scope");
|
|
40
|
+
var import_react_id = __require("@radix-ui/react-id");
|
|
41
|
+
var PopperPrimitive = __toESM(__require("@radix-ui/react-popper"));
|
|
42
|
+
var import_react_popper = __require("@radix-ui/react-popper");
|
|
43
|
+
var import_react_portal = __require("@radix-ui/react-portal");
|
|
44
|
+
var import_react_presence = __require("@radix-ui/react-presence");
|
|
45
|
+
var import_react_primitive = __require("@radix-ui/react-primitive");
|
|
46
|
+
var import_react_slot = __require("@radix-ui/react-slot");
|
|
47
|
+
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
|
|
48
|
+
var import_aria_hidden = __require("aria-hidden");
|
|
49
|
+
var import_react_remove_scroll = __require("react-remove-scroll");
|
|
50
|
+
var import_jsx_runtime = __require("react/jsx-runtime");
|
|
51
|
+
var POPOVER_NAME = "Popover";
|
|
52
|
+
var [createPopoverContext, createPopoverScope] = (0, import_react_context.createContextScope)(POPOVER_NAME, [
|
|
53
|
+
import_react_popper.createPopperScope
|
|
54
|
+
]);
|
|
55
|
+
var usePopperScope = (0, import_react_popper.createPopperScope)();
|
|
56
|
+
var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
|
|
57
|
+
var Popover = (props) => {
|
|
58
|
+
const {
|
|
59
|
+
__scopePopover,
|
|
60
|
+
children,
|
|
61
|
+
open: openProp,
|
|
62
|
+
defaultOpen,
|
|
63
|
+
onOpenChange,
|
|
64
|
+
modal = false
|
|
65
|
+
} = props;
|
|
66
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
67
|
+
const triggerRef = React.useRef(null);
|
|
68
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
69
|
+
const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
|
|
70
|
+
prop: openProp,
|
|
71
|
+
defaultProp: defaultOpen,
|
|
72
|
+
onChange: onOpenChange
|
|
76
73
|
});
|
|
77
|
-
return
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
+
PopoverProvider,
|
|
76
|
+
{
|
|
78
77
|
scope: __scopePopover,
|
|
79
|
-
contentId:
|
|
80
|
-
triggerRef
|
|
81
|
-
open
|
|
78
|
+
contentId: (0, import_react_id.useId)(),
|
|
79
|
+
triggerRef,
|
|
80
|
+
open,
|
|
82
81
|
onOpenChange: setOpen,
|
|
83
|
-
onOpenToggle:
|
|
84
|
-
|
|
85
|
-
, [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* -----------------------------------------------------------------------------------------------*/ const $7d632c09314cddaf$var$ANCHOR_NAME = 'PopoverAnchor';
|
|
102
|
-
const $7d632c09314cddaf$export$96e5381f42521a79 = /*#__PURE__*/ $aJPOC$react.forwardRef((props, forwardedRef)=>{
|
|
103
|
-
const { __scopePopover: __scopePopover , ...anchorProps } = props;
|
|
104
|
-
const context = $7d632c09314cddaf$var$usePopoverContext($7d632c09314cddaf$var$ANCHOR_NAME, __scopePopover);
|
|
105
|
-
const popperScope = $7d632c09314cddaf$var$usePopperScope(__scopePopover);
|
|
106
|
-
const { onCustomAnchorAdd: onCustomAnchorAdd , onCustomAnchorRemove: onCustomAnchorRemove } = context;
|
|
107
|
-
$aJPOC$react.useEffect(()=>{
|
|
82
|
+
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
83
|
+
hasCustomAnchor,
|
|
84
|
+
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
85
|
+
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
|
|
86
|
+
modal,
|
|
87
|
+
children
|
|
88
|
+
}
|
|
89
|
+
) });
|
|
90
|
+
};
|
|
91
|
+
Popover.displayName = POPOVER_NAME;
|
|
92
|
+
var ANCHOR_NAME = "PopoverAnchor";
|
|
93
|
+
var PopoverAnchor = React.forwardRef(
|
|
94
|
+
(props, forwardedRef) => {
|
|
95
|
+
const { __scopePopover, ...anchorProps } = props;
|
|
96
|
+
const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
|
|
97
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
98
|
+
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
99
|
+
React.useEffect(() => {
|
|
108
100
|
onCustomAnchorAdd();
|
|
109
|
-
return ()=>onCustomAnchorRemove()
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
/*#__PURE__*/ Object.assign($7d632c09314cddaf$export$dd679ffb4362d2d4, {
|
|
167
|
-
displayName: $7d632c09314cddaf$var$PORTAL_NAME
|
|
168
|
-
});
|
|
169
|
-
/* -------------------------------------------------------------------------------------------------
|
|
170
|
-
* PopoverContent
|
|
171
|
-
* -----------------------------------------------------------------------------------------------*/ const $7d632c09314cddaf$var$CONTENT_NAME = 'PopoverContent';
|
|
172
|
-
const $7d632c09314cddaf$export$d7e1f420b25549ff = /*#__PURE__*/ $aJPOC$react.forwardRef((props, forwardedRef)=>{
|
|
173
|
-
const portalContext = $7d632c09314cddaf$var$usePortalContext($7d632c09314cddaf$var$CONTENT_NAME, props.__scopePopover);
|
|
174
|
-
const { forceMount: forceMount = portalContext.forceMount , ...contentProps } = props;
|
|
175
|
-
const context = $7d632c09314cddaf$var$usePopoverContext($7d632c09314cddaf$var$CONTENT_NAME, props.__scopePopover);
|
|
176
|
-
return /*#__PURE__*/ $aJPOC$react.createElement($aJPOC$radixuireactpresence.Presence, {
|
|
177
|
-
present: forceMount || context.open
|
|
178
|
-
}, context.modal ? /*#__PURE__*/ $aJPOC$react.createElement($7d632c09314cddaf$var$PopoverContentModal, ($parcel$interopDefault($aJPOC$babelruntimehelpersextends))({}, contentProps, {
|
|
179
|
-
ref: forwardedRef
|
|
180
|
-
})) : /*#__PURE__*/ $aJPOC$react.createElement($7d632c09314cddaf$var$PopoverContentNonModal, ($parcel$interopDefault($aJPOC$babelruntimehelpersextends))({}, contentProps, {
|
|
181
|
-
ref: forwardedRef
|
|
182
|
-
})));
|
|
183
|
-
});
|
|
184
|
-
/*#__PURE__*/ Object.assign($7d632c09314cddaf$export$d7e1f420b25549ff, {
|
|
185
|
-
displayName: $7d632c09314cddaf$var$CONTENT_NAME
|
|
186
|
-
});
|
|
187
|
-
/* -----------------------------------------------------------------------------------------------*/ const $7d632c09314cddaf$var$PopoverContentModal = /*#__PURE__*/ $aJPOC$react.forwardRef((props, forwardedRef)=>{
|
|
188
|
-
const context = $7d632c09314cddaf$var$usePopoverContext($7d632c09314cddaf$var$CONTENT_NAME, props.__scopePopover);
|
|
189
|
-
const contentRef = $aJPOC$react.useRef(null);
|
|
190
|
-
const composedRefs = $aJPOC$radixuireactcomposerefs.useComposedRefs(forwardedRef, contentRef);
|
|
191
|
-
const isRightClickOutsideRef = $aJPOC$react.useRef(false); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
|
|
192
|
-
$aJPOC$react.useEffect(()=>{
|
|
101
|
+
return () => onCustomAnchorRemove();
|
|
102
|
+
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
PopoverAnchor.displayName = ANCHOR_NAME;
|
|
107
|
+
var TRIGGER_NAME = "PopoverTrigger";
|
|
108
|
+
var PopoverTrigger = React.forwardRef(
|
|
109
|
+
(props, forwardedRef) => {
|
|
110
|
+
const { __scopePopover, ...triggerProps } = props;
|
|
111
|
+
const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
|
|
112
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
113
|
+
const composedTriggerRef = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
114
|
+
const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
import_react_primitive.Primitive.button,
|
|
116
|
+
{
|
|
117
|
+
type: "button",
|
|
118
|
+
"aria-haspopup": "dialog",
|
|
119
|
+
"aria-expanded": context.open,
|
|
120
|
+
"aria-controls": context.contentId,
|
|
121
|
+
"data-state": getState(context.open),
|
|
122
|
+
...triggerProps,
|
|
123
|
+
ref: composedTriggerRef,
|
|
124
|
+
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onOpenToggle)
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
PopoverTrigger.displayName = TRIGGER_NAME;
|
|
131
|
+
var PORTAL_NAME = "PopoverPortal";
|
|
132
|
+
var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
|
|
133
|
+
forceMount: void 0
|
|
134
|
+
});
|
|
135
|
+
var PopoverPortal = (props) => {
|
|
136
|
+
const { __scopePopover, forceMount, children, container } = props;
|
|
137
|
+
const context = usePopoverContext(PORTAL_NAME, __scopePopover);
|
|
138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_portal.Portal, { asChild: true, container, children }) }) });
|
|
139
|
+
};
|
|
140
|
+
PopoverPortal.displayName = PORTAL_NAME;
|
|
141
|
+
var CONTENT_NAME = "PopoverContent";
|
|
142
|
+
var PopoverContent = React.forwardRef(
|
|
143
|
+
(props, forwardedRef) => {
|
|
144
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
|
|
145
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
146
|
+
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
PopoverContent.displayName = CONTENT_NAME;
|
|
151
|
+
var PopoverContentModal = React.forwardRef(
|
|
152
|
+
(props, forwardedRef) => {
|
|
153
|
+
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
|
|
154
|
+
const contentRef = React.useRef(null);
|
|
155
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
156
|
+
const isRightClickOutsideRef = React.useRef(false);
|
|
157
|
+
React.useEffect(() => {
|
|
193
158
|
const content = contentRef.current;
|
|
194
|
-
if (content) return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
onCloseAutoFocus: $aJPOC$radixuiprimitive.composeEventHandlers(props.onCloseAutoFocus, (event)=>{
|
|
205
|
-
var _context$triggerRef$c;
|
|
159
|
+
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
160
|
+
}, []);
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_remove_scroll.RemoveScroll, { as: import_react_slot.Slot, allowPinchZoom: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
|
+
PopoverContentImpl,
|
|
163
|
+
{
|
|
164
|
+
...props,
|
|
165
|
+
ref: composedRefs,
|
|
166
|
+
trapFocus: context.open,
|
|
167
|
+
disableOutsidePointerEvents: true,
|
|
168
|
+
onCloseAutoFocus: (0, import_primitive.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
206
169
|
event.preventDefault();
|
|
207
|
-
if (!isRightClickOutsideRef.current)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
170
|
+
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
171
|
+
}),
|
|
172
|
+
onPointerDownOutside: (0, import_primitive.composeEventHandlers)(
|
|
173
|
+
props.onPointerDownOutside,
|
|
174
|
+
(event) => {
|
|
175
|
+
const originalEvent = event.detail.originalEvent;
|
|
176
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
177
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
178
|
+
isRightClickOutsideRef.current = isRightClick;
|
|
179
|
+
},
|
|
180
|
+
{ checkForDefaultPrevented: false }
|
|
181
|
+
),
|
|
182
|
+
onFocusOutside: (0, import_primitive.composeEventHandlers)(
|
|
183
|
+
props.onFocusOutside,
|
|
184
|
+
(event) => event.preventDefault(),
|
|
185
|
+
{ checkForDefaultPrevented: false }
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
) });
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
var PopoverContentNonModal = React.forwardRef(
|
|
192
|
+
(props, forwardedRef) => {
|
|
193
|
+
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
|
|
194
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
195
|
+
const hasPointerDownOutsideRef = React.useRef(false);
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
197
|
+
PopoverContentImpl,
|
|
198
|
+
{
|
|
199
|
+
...props,
|
|
200
|
+
ref: forwardedRef,
|
|
201
|
+
trapFocus: false,
|
|
202
|
+
disableOutsidePointerEvents: false,
|
|
203
|
+
onCloseAutoFocus: (event) => {
|
|
204
|
+
props.onCloseAutoFocus?.(event);
|
|
235
205
|
if (!event.defaultPrevented) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
event.preventDefault();
|
|
206
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
207
|
+
event.preventDefault();
|
|
239
208
|
}
|
|
240
209
|
hasInteractedOutsideRef.current = false;
|
|
241
210
|
hasPointerDownOutsideRef.current = false;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(_props$onInteractOuts = props.onInteractOutside) === null || _props$onInteractOuts === void 0 || _props$onInteractOuts.call(props, event);
|
|
211
|
+
},
|
|
212
|
+
onInteractOutside: (event) => {
|
|
213
|
+
props.onInteractOutside?.(event);
|
|
246
214
|
if (!event.defaultPrevented) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
215
|
+
hasInteractedOutsideRef.current = true;
|
|
216
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
217
|
+
hasPointerDownOutsideRef.current = true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
252
220
|
const target = event.target;
|
|
253
|
-
const targetIsTrigger =
|
|
254
|
-
if (targetIsTrigger) event.preventDefault();
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
221
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
222
|
+
if (targetIsTrigger) event.preventDefault();
|
|
223
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
224
|
+
event.preventDefault();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
259
227
|
}
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
var PopoverContentImpl = React.forwardRef(
|
|
232
|
+
(props, forwardedRef) => {
|
|
233
|
+
const {
|
|
234
|
+
__scopePopover,
|
|
235
|
+
trapFocus,
|
|
236
|
+
onOpenAutoFocus,
|
|
237
|
+
onCloseAutoFocus,
|
|
238
|
+
disableOutsidePointerEvents,
|
|
239
|
+
onEscapeKeyDown,
|
|
240
|
+
onPointerDownOutside,
|
|
241
|
+
onFocusOutside,
|
|
242
|
+
onInteractOutside,
|
|
243
|
+
...contentProps
|
|
244
|
+
} = props;
|
|
245
|
+
const context = usePopoverContext(CONTENT_NAME, __scopePopover);
|
|
246
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
247
|
+
(0, import_react_focus_guards.useFocusGuards)();
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
249
|
+
import_react_focus_scope.FocusScope,
|
|
250
|
+
{
|
|
251
|
+
asChild: true,
|
|
252
|
+
loop: true,
|
|
253
|
+
trapped: trapFocus,
|
|
254
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
255
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
256
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
257
|
+
import_react_dismissable_layer.DismissableLayer,
|
|
258
|
+
{
|
|
259
|
+
asChild: true,
|
|
260
|
+
disableOutsidePointerEvents,
|
|
261
|
+
onInteractOutside,
|
|
262
|
+
onEscapeKeyDown,
|
|
263
|
+
onPointerDownOutside,
|
|
264
|
+
onFocusOutside,
|
|
265
|
+
onDismiss: () => context.onOpenChange(false),
|
|
266
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
267
|
+
PopperPrimitive.Content,
|
|
268
|
+
{
|
|
269
|
+
"data-state": getState(context.open),
|
|
270
|
+
role: "dialog",
|
|
271
|
+
id: context.contentId,
|
|
272
|
+
...popperScope,
|
|
273
|
+
...contentProps,
|
|
274
|
+
ref: forwardedRef,
|
|
275
|
+
style: {
|
|
276
|
+
...contentProps.style,
|
|
277
|
+
// re-namespace exposed content custom properties
|
|
278
|
+
...{
|
|
279
|
+
"--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
280
|
+
"--radix-popover-content-available-width": "var(--radix-popper-available-width)",
|
|
281
|
+
"--radix-popover-content-available-height": "var(--radix-popper-available-height)",
|
|
282
|
+
"--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
|
|
283
|
+
"--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
)
|
|
295
290
|
}
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const $7d632c09314cddaf$export$f39c2d165cd861fe = $7d632c09314cddaf$export$d6ac43ebaa40d53e;
|
|
337
|
-
const $7d632c09314cddaf$export$21b07c8f274aebd5 = $7d632c09314cddaf$export$3152841115e061b2;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
var CLOSE_NAME = "PopoverClose";
|
|
295
|
+
var PopoverClose = React.forwardRef(
|
|
296
|
+
(props, forwardedRef) => {
|
|
297
|
+
const { __scopePopover, ...closeProps } = props;
|
|
298
|
+
const context = usePopoverContext(CLOSE_NAME, __scopePopover);
|
|
299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
300
|
+
import_react_primitive.Primitive.button,
|
|
301
|
+
{
|
|
302
|
+
type: "button",
|
|
303
|
+
...closeProps,
|
|
304
|
+
ref: forwardedRef,
|
|
305
|
+
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, () => context.onOpenChange(false))
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
PopoverClose.displayName = CLOSE_NAME;
|
|
311
|
+
var ARROW_NAME = "PopoverArrow";
|
|
312
|
+
var PopoverArrow = React.forwardRef(
|
|
313
|
+
(props, forwardedRef) => {
|
|
314
|
+
const { __scopePopover, ...arrowProps } = props;
|
|
315
|
+
const popperScope = usePopperScope(__scopePopover);
|
|
316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
PopoverArrow.displayName = ARROW_NAME;
|
|
320
|
+
function getState(open) {
|
|
321
|
+
return open ? "open" : "closed";
|
|
322
|
+
}
|
|
323
|
+
var Root2 = Popover;
|
|
324
|
+
var Anchor2 = PopoverAnchor;
|
|
325
|
+
var Trigger = PopoverTrigger;
|
|
326
|
+
var Portal = PopoverPortal;
|
|
327
|
+
var Content2 = PopoverContent;
|
|
328
|
+
var Close = PopoverClose;
|
|
329
|
+
var Arrow2 = PopoverArrow;
|
|
330
|
+
})();
|
|
342
331
|
//# sourceMappingURL=index.js.map
|