@tamagui/popover 2.7.7 → 3.0.0-beta.637.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/cjs/Popover.cjs +509 -664
- package/dist/cjs/Popover.native.cjs +603 -0
- package/dist/cjs/Popover.native.js +536 -691
- package/dist/cjs/Popover.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +22 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useFloatingContext.cjs +202 -234
- package/dist/cjs/useFloatingContext.native.cjs +36 -0
- package/dist/cjs/useFloatingContext.native.js +20 -27
- package/dist/cjs/useFloatingContext.native.js.map +1 -1
- package/dist/esm/Popover.mjs +473 -617
- package/dist/esm/Popover.mjs.map +1 -1
- package/dist/esm/Popover.native.js +499 -644
- package/dist/esm/Popover.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.native.js +3 -3
- package/dist/esm/useFloatingContext.mjs +186 -208
- package/dist/esm/useFloatingContext.mjs.map +1 -1
- package/dist/esm/useFloatingContext.native.js +4 -2
- package/dist/esm/useFloatingContext.native.js.map +1 -1
- package/dist/jsx/Popover.mjs +473 -617
- package/dist/jsx/Popover.mjs.map +1 -1
- package/dist/jsx/Popover.native.cjs +603 -0
- package/dist/jsx/Popover.native.js +536 -691
- package/dist/jsx/Popover.native.js.map +1 -1
- package/dist/jsx/index.js +3 -3
- package/dist/jsx/index.mjs +3 -3
- package/dist/jsx/index.native.cjs +22 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useFloatingContext.mjs +186 -208
- package/dist/jsx/useFloatingContext.mjs.map +1 -1
- package/dist/jsx/useFloatingContext.native.cjs +36 -0
- package/dist/jsx/useFloatingContext.native.js +20 -27
- package/dist/jsx/useFloatingContext.native.js.map +1 -1
- package/package.json +22 -22
- package/src/Popover.tsx +115 -147
- package/types/Popover.d.ts +33 -109
- package/types/Popover.d.ts.map +1 -1
- package/types/useFloatingContext.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
package/dist/cjs/Popover.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,51 +6,44 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var Popover_exports = {};
|
|
35
29
|
__export(Popover_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
Popover: () => Popover,
|
|
31
|
+
PopoverAnchor: () => PopoverAnchor,
|
|
32
|
+
PopoverArrow: () => PopoverArrow,
|
|
33
|
+
PopoverClose: () => PopoverClose,
|
|
34
|
+
PopoverContent: () => PopoverContent,
|
|
35
|
+
PopoverContext: () => PopoverContext,
|
|
36
|
+
PopoverContextProvider: () => PopoverContextProvider,
|
|
37
|
+
PopoverTrigger: () => PopoverTrigger,
|
|
38
|
+
PopoverTriggerContext: () => PopoverTriggerContext,
|
|
39
|
+
PopoverZIndexContext: () => PopoverZIndexContext,
|
|
40
|
+
closeLastOpenedPopover: () => closeLastOpenedPopover,
|
|
41
|
+
closeOpenPopovers: () => closeOpenPopovers,
|
|
42
|
+
hasOpenPopovers: () => hasOpenPopovers,
|
|
43
|
+
usePopoverContext: () => usePopoverContext,
|
|
44
|
+
usePopoverOpen: () => usePopoverOpen,
|
|
45
|
+
usePopoverTriggerContext: () => usePopoverTriggerContext,
|
|
46
|
+
usePopoverTriggerSetup: () => usePopoverTriggerSetup
|
|
53
47
|
});
|
|
54
48
|
module.exports = __toCommonJS(Popover_exports);
|
|
55
49
|
require("@tamagui/polyfill-dev");
|
|
@@ -67,667 +61,518 @@ var import_popper = require("@tamagui/popper");
|
|
|
67
61
|
var import_portal = require("@tamagui/portal");
|
|
68
62
|
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
69
63
|
var import_scroll_view = require("@tamagui/scroll-view");
|
|
70
|
-
var import_controller = require("@tamagui/sheet/controller");
|
|
71
64
|
var import_stacks = require("@tamagui/stacks");
|
|
72
65
|
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
73
66
|
var React = __toESM(require("react"), 1);
|
|
74
67
|
var import_useFloatingContext = require("./useFloatingContext.cjs");
|
|
75
68
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
76
69
|
const needsRepropagation = (0, import_portal.needsPortalRepropagation)();
|
|
77
|
-
const openPopovers = /* @__PURE__ */new Set();
|
|
70
|
+
const openPopovers = /* @__PURE__ */ new Set();
|
|
78
71
|
const hasOpenPopovers = () => {
|
|
79
|
-
|
|
72
|
+
return openPopovers.size > 0;
|
|
80
73
|
};
|
|
81
74
|
const closeOpenPopovers = () => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
if (openPopovers.size === 0) return false;
|
|
76
|
+
openPopovers.forEach((setOpen) => setOpen(false));
|
|
77
|
+
return true;
|
|
85
78
|
};
|
|
86
79
|
const closeLastOpenedPopover = () => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
if (openPopovers.size === 0) return false;
|
|
81
|
+
const last = Array.from(openPopovers).pop();
|
|
82
|
+
if (last) {
|
|
83
|
+
last(false);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
94
87
|
};
|
|
95
|
-
const PopoverContext = (0, import_core.createStyledContext)(
|
|
96
|
-
// since we always provide this we can avoid setting here
|
|
97
|
-
{}, "Popover__");
|
|
88
|
+
const PopoverContext = (0, import_core.createStyledContext)({}, "Popover__");
|
|
98
89
|
const PopoverZIndexContext = React.createContext(void 0);
|
|
99
|
-
const PopoverAdaptHiddenContext = React.createContext(true);
|
|
100
90
|
const PopoverTriggerContext = (0, import_core.createStyledContext)({}, "PopoverTrigger__");
|
|
101
91
|
const usePopoverContext = PopoverContext.useStyledContext;
|
|
102
92
|
const usePopoverTriggerContext = PopoverTriggerContext.useStyledContext;
|
|
103
93
|
function usePopoverOpen(scope) {
|
|
104
|
-
|
|
94
|
+
return usePopoverContext(scope).open;
|
|
105
95
|
}
|
|
106
96
|
function usePopoverTriggerSetup(open) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
97
|
+
const triggerStateSettersRef = React.useRef(/* @__PURE__ */ new Map());
|
|
98
|
+
const activeTriggerIdRef = React.useRef(null);
|
|
99
|
+
const setActiveTrigger = (0, import_core.useEvent)((id) => {
|
|
100
|
+
const prevId = activeTriggerIdRef.current;
|
|
101
|
+
if (prevId === id) return;
|
|
102
|
+
if (prevId) triggerStateSettersRef.current.get(prevId)?.(false);
|
|
103
|
+
activeTriggerIdRef.current = id;
|
|
104
|
+
if (id && open) triggerStateSettersRef.current.get(id)?.(true);
|
|
105
|
+
});
|
|
106
|
+
const registerTrigger = (0, import_core.useEvent)((id, setOpenState) => {
|
|
107
|
+
triggerStateSettersRef.current.set(id, setOpenState);
|
|
108
|
+
setOpenState(activeTriggerIdRef.current === id && open);
|
|
109
|
+
});
|
|
110
|
+
const unregisterTrigger = (0, import_core.useEvent)((id) => {
|
|
111
|
+
triggerStateSettersRef.current.delete(id);
|
|
112
|
+
if (activeTriggerIdRef.current === id) activeTriggerIdRef.current = null;
|
|
113
|
+
});
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
if (!open) {
|
|
116
|
+
setActiveTrigger(null);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const activeId = activeTriggerIdRef.current;
|
|
120
|
+
if (activeId) triggerStateSettersRef.current.get(activeId)?.(true);
|
|
121
|
+
}, [open, setActiveTrigger]);
|
|
122
|
+
return {
|
|
123
|
+
setActiveTrigger,
|
|
124
|
+
registerTrigger,
|
|
125
|
+
unregisterTrigger
|
|
126
|
+
};
|
|
137
127
|
}
|
|
138
|
-
const PopoverContextProvider = React.memo(({
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
hasCustomAnchor,
|
|
174
|
-
onCustomAnchorAdd,
|
|
175
|
-
onCustomAnchorRemove,
|
|
176
|
-
anchorTo,
|
|
177
|
-
branches,
|
|
178
|
-
breakpointActive,
|
|
179
|
-
keepChildrenMounted,
|
|
180
|
-
disableDismissable,
|
|
181
|
-
hoverable,
|
|
182
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverTriggerContext.Provider, {
|
|
183
|
-
scope,
|
|
184
|
-
triggerRef,
|
|
185
|
-
hasCustomAnchor,
|
|
186
|
-
anchorTo,
|
|
187
|
-
branches,
|
|
188
|
-
onOpenToggle,
|
|
189
|
-
setActiveTrigger,
|
|
190
|
-
registerTrigger,
|
|
191
|
-
unregisterTrigger,
|
|
192
|
-
children
|
|
193
|
-
})
|
|
194
|
-
});
|
|
128
|
+
const PopoverContextProvider = React.memo(({ scope, children, open, onOpenChange, onOpenToggle, triggerRef, id = "", contentId, hasCustomAnchor = false, onCustomAnchorAdd = voidFn, onCustomAnchorRemove = voidFn, anchorTo, adaptScope, breakpointActive, keepChildrenMounted, disableDismissable, hoverable }) => {
|
|
129
|
+
const [branches] = React.useState(() => /* @__PURE__ */ new Set());
|
|
130
|
+
const { setActiveTrigger, registerTrigger, unregisterTrigger } = usePopoverTriggerSetup(open);
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
132
|
+
scope,
|
|
133
|
+
popoverScope: scope,
|
|
134
|
+
adaptScope,
|
|
135
|
+
id,
|
|
136
|
+
contentId,
|
|
137
|
+
triggerRef,
|
|
138
|
+
open,
|
|
139
|
+
onOpenChange,
|
|
140
|
+
onOpenToggle,
|
|
141
|
+
hasCustomAnchor,
|
|
142
|
+
onCustomAnchorAdd,
|
|
143
|
+
onCustomAnchorRemove,
|
|
144
|
+
anchorTo,
|
|
145
|
+
branches,
|
|
146
|
+
breakpointActive,
|
|
147
|
+
keepChildrenMounted,
|
|
148
|
+
disableDismissable,
|
|
149
|
+
hoverable,
|
|
150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverTriggerContext.Provider, {
|
|
151
|
+
scope,
|
|
152
|
+
triggerRef,
|
|
153
|
+
hasCustomAnchor,
|
|
154
|
+
anchorTo,
|
|
155
|
+
branches,
|
|
156
|
+
onOpenToggle,
|
|
157
|
+
setActiveTrigger,
|
|
158
|
+
registerTrigger,
|
|
159
|
+
unregisterTrigger,
|
|
160
|
+
children
|
|
161
|
+
})
|
|
162
|
+
});
|
|
195
163
|
});
|
|
196
164
|
const voidFn = () => {};
|
|
197
|
-
const PopoverAnchor = React.memo(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
210
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, {
|
|
211
|
-
scope,
|
|
212
|
-
...rest,
|
|
213
|
-
ref: forwardedRef
|
|
214
|
-
});
|
|
165
|
+
const PopoverAnchor = React.memo((0, import_core.createRefComponent)(function PopoverAnchor2(props, forwardedRef) {
|
|
166
|
+
const { scope, ...rest } = props;
|
|
167
|
+
const { onCustomAnchorAdd, onCustomAnchorRemove } = usePopoverContext(scope) || {};
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
onCustomAnchorAdd();
|
|
170
|
+
return () => onCustomAnchorRemove();
|
|
171
|
+
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, {
|
|
173
|
+
scope,
|
|
174
|
+
...rest,
|
|
175
|
+
ref: forwardedRef
|
|
176
|
+
});
|
|
215
177
|
}));
|
|
216
|
-
const PopoverTrigger = React.memo(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
});
|
|
178
|
+
const PopoverTrigger = React.memo((0, import_core.createRefComponent)(function PopoverTrigger2(props, forwardedRef) {
|
|
179
|
+
const { scope, disablePressTrigger, ...rest } = props;
|
|
180
|
+
const triggerContext = usePopoverTriggerContext(scope);
|
|
181
|
+
const triggerId = React.useId();
|
|
182
|
+
const [open, setOpen] = React.useState(false);
|
|
183
|
+
const anchorTo = triggerContext.anchorTo;
|
|
184
|
+
const triggerElRef = React.useRef(null);
|
|
185
|
+
const composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, triggerElRef);
|
|
186
|
+
const { registerTrigger, unregisterTrigger } = triggerContext;
|
|
187
|
+
React.useEffect(() => {
|
|
188
|
+
registerTrigger(triggerId, setOpen);
|
|
189
|
+
return () => {
|
|
190
|
+
unregisterTrigger(triggerId);
|
|
191
|
+
};
|
|
192
|
+
}, [
|
|
193
|
+
registerTrigger,
|
|
194
|
+
unregisterTrigger,
|
|
195
|
+
triggerId
|
|
196
|
+
]);
|
|
197
|
+
if (!rest.children) return null;
|
|
198
|
+
const activateSelf = () => {
|
|
199
|
+
triggerContext.setActiveTrigger(triggerId);
|
|
200
|
+
const el = triggerElRef.current;
|
|
201
|
+
if (el) triggerContext.triggerRef.current = el;
|
|
202
|
+
};
|
|
203
|
+
const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.View, {
|
|
204
|
+
"aria-expanded": open,
|
|
205
|
+
"data-state": getState(open),
|
|
206
|
+
...rest,
|
|
207
|
+
ref: composedTriggerRef,
|
|
208
|
+
onPress: (0, import_helpers.composeEventHandlers)(rest.onPress, () => {
|
|
209
|
+
if (disablePressTrigger) return;
|
|
210
|
+
triggerContext.setActiveTrigger(open ? null : triggerId);
|
|
211
|
+
triggerContext.onOpenToggle();
|
|
212
|
+
}),
|
|
213
|
+
onMouseEnter: (0, import_helpers.composeEventHandlers)(rest.onMouseEnter, activateSelf),
|
|
214
|
+
onPressIn: (0, import_helpers.composeEventHandlers)(rest.onPressIn, activateSelf),
|
|
215
|
+
onFocus: (0, import_helpers.composeEventHandlers)(rest.onFocus, activateSelf)
|
|
216
|
+
});
|
|
217
|
+
const virtualRef = React.useMemo(() => {
|
|
218
|
+
if (!anchorTo) return null;
|
|
219
|
+
return { current: {
|
|
220
|
+
getBoundingClientRect: () => import_constants.isWeb ? DOMRect.fromRect(anchorTo) : anchorTo,
|
|
221
|
+
...!import_constants.isWeb && {
|
|
222
|
+
measure: (c) => c(anchorTo?.x, anchorTo?.y, anchorTo?.width, anchorTo?.height),
|
|
223
|
+
measureInWindow: (c) => c(anchorTo?.x, anchorTo?.y, anchorTo?.width, anchorTo?.height)
|
|
224
|
+
}
|
|
225
|
+
} };
|
|
226
|
+
}, [
|
|
227
|
+
triggerContext.anchorTo,
|
|
228
|
+
anchorTo?.x,
|
|
229
|
+
anchorTo?.y,
|
|
230
|
+
anchorTo?.height,
|
|
231
|
+
anchorTo?.width
|
|
232
|
+
]);
|
|
233
|
+
const wrappedTrigger = import_constants.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dismissable.DismissableBranch, {
|
|
234
|
+
branches: triggerContext.branches,
|
|
235
|
+
children: trigger
|
|
236
|
+
}) : trigger;
|
|
237
|
+
return triggerContext.hasCustomAnchor ? wrappedTrigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, {
|
|
238
|
+
...virtualRef && { virtualRef },
|
|
239
|
+
scope,
|
|
240
|
+
asChild: true,
|
|
241
|
+
children: wrappedTrigger
|
|
242
|
+
});
|
|
282
243
|
}));
|
|
283
|
-
const PopoverContent = import_popper.PopperContentFrame
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
checkDefaultPrevented: false
|
|
340
|
-
})
|
|
341
|
-
})
|
|
342
|
-
})
|
|
343
|
-
});
|
|
244
|
+
const PopoverContent = (0, import_core.createStyledHOC)(import_popper.PopperContentFrame, function PopoverContent2(props, forwardedRef) {
|
|
245
|
+
const { trapFocus, enableRemoveScroll = false, zIndex: zIndexProp, scope, forceMount, ...contentImplProps } = props;
|
|
246
|
+
const context = usePopoverContext(scope);
|
|
247
|
+
const adaptContext = (0, import_adapt.useAdaptContext)(context.adaptScope);
|
|
248
|
+
const zIndexFromContext = React.useContext(PopoverZIndexContext);
|
|
249
|
+
const zIndex = zIndexProp ?? zIndexFromContext;
|
|
250
|
+
const open = usePopoverOpen(scope);
|
|
251
|
+
const contentRef = React.useRef(null);
|
|
252
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
253
|
+
const isRightClickOutsideRef = React.useRef(false);
|
|
254
|
+
const [isFullyHidden, setIsFullyHidden] = React.useState(!open);
|
|
255
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
256
|
+
if (open && isFullyHidden) setIsFullyHidden(false);
|
|
257
|
+
}, [open, isFullyHidden]);
|
|
258
|
+
if (!forceMount && !context.keepChildrenMounted) {
|
|
259
|
+
if (context.breakpointActive) {
|
|
260
|
+
if (!open && adaptContext.targetFullyHidden) return null;
|
|
261
|
+
} else if (isFullyHidden && !open) return null;
|
|
262
|
+
}
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverPortal, {
|
|
264
|
+
passThrough: context.breakpointActive,
|
|
265
|
+
context,
|
|
266
|
+
open,
|
|
267
|
+
visuallyActive: open || !isFullyHidden,
|
|
268
|
+
zIndex,
|
|
269
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.View, {
|
|
270
|
+
passThrough: context.breakpointActive,
|
|
271
|
+
pointerEvents: open ? contentImplProps.pointerEvents ?? "auto" : "none",
|
|
272
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentImpl, {
|
|
273
|
+
...contentImplProps,
|
|
274
|
+
context,
|
|
275
|
+
open,
|
|
276
|
+
forceMount,
|
|
277
|
+
enableRemoveScroll,
|
|
278
|
+
ref: composedRefs,
|
|
279
|
+
setIsFullyHidden,
|
|
280
|
+
scope,
|
|
281
|
+
trapFocus: trapFocus ?? open,
|
|
282
|
+
disableOutsidePointerEvents: true,
|
|
283
|
+
onCloseAutoFocus: props.onCloseAutoFocus === false ? void 0 : (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
284
|
+
if (event.isCanceled) return;
|
|
285
|
+
event.cancel();
|
|
286
|
+
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
|
|
287
|
+
}),
|
|
288
|
+
onPointerDownOutside: (0, import_helpers.composeEventHandlers)(props.onPointerDownOutside, (event) => {
|
|
289
|
+
const originalEvent = event.event;
|
|
290
|
+
if (!originalEvent) return;
|
|
291
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
292
|
+
isRightClickOutsideRef.current = originalEvent.button === 2 || ctrlLeftClick;
|
|
293
|
+
}, { checkDefaultPrevented: false }),
|
|
294
|
+
onFocusOutside: (0, import_helpers.composeEventHandlers)(props.onFocusOutside, (event) => {
|
|
295
|
+
if (trapFocus ?? open) event.cancel();
|
|
296
|
+
}, { checkDefaultPrevented: false })
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
});
|
|
344
300
|
});
|
|
345
|
-
const useParentContexts = scope => {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
301
|
+
const useParentContexts = (scope) => {
|
|
302
|
+
const context = usePopoverContext(scope);
|
|
303
|
+
const triggerContext = usePopoverTriggerContext(scope);
|
|
304
|
+
return {
|
|
305
|
+
popperContext: (0, import_popper.usePopperContext)(scope),
|
|
306
|
+
adaptContext: (0, import_adapt.useAdaptContext)(context.adaptScope),
|
|
307
|
+
context,
|
|
308
|
+
triggerContext
|
|
309
|
+
};
|
|
354
310
|
};
|
|
355
|
-
function RepropagateParentContexts({
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
...adaptContext,
|
|
373
|
-
children
|
|
374
|
-
})
|
|
375
|
-
})
|
|
376
|
-
})
|
|
377
|
-
});
|
|
311
|
+
function RepropagateParentContexts({ adaptContext, children, context, triggerContext, popperContext }) {
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperProvider, {
|
|
313
|
+
scope: context.popoverScope,
|
|
314
|
+
...popperContext,
|
|
315
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
316
|
+
scope: context.popoverScope,
|
|
317
|
+
...context,
|
|
318
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverTriggerContext.Provider, {
|
|
319
|
+
scope: context.popoverScope,
|
|
320
|
+
...triggerContext,
|
|
321
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
322
|
+
...adaptContext,
|
|
323
|
+
children
|
|
324
|
+
})
|
|
325
|
+
})
|
|
326
|
+
})
|
|
327
|
+
});
|
|
378
328
|
}
|
|
379
|
-
const PortalAdaptSafe = ({
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {
|
|
396
|
-
scope: context.adaptScope,
|
|
397
|
-
children
|
|
398
|
-
});
|
|
329
|
+
const PortalAdaptSafe = ({ children, context }) => {
|
|
330
|
+
"use no memo";
|
|
331
|
+
if (needsRepropagation) {
|
|
332
|
+
const parentContexts = useParentContexts(context.popoverScope);
|
|
333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {
|
|
334
|
+
scope: context.adaptScope,
|
|
335
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepropagateParentContexts, {
|
|
336
|
+
...parentContexts,
|
|
337
|
+
children
|
|
338
|
+
})
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {
|
|
342
|
+
scope: context.adaptScope,
|
|
343
|
+
children
|
|
344
|
+
});
|
|
399
345
|
};
|
|
400
|
-
function PopoverPortal({
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
zIndex,
|
|
422
|
-
children: [!!open && !context.breakpointActive && !context.hoverable && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
423
|
-
fullscreen: true,
|
|
424
|
-
onPress: (0, import_helpers.composeEventHandlers)(onPress, context.onOpenToggle)
|
|
425
|
-
}), content]
|
|
426
|
-
});
|
|
346
|
+
function PopoverPortal({ context, open, visuallyActive, zIndex, passThrough, children, onPress }) {
|
|
347
|
+
"use no memo";
|
|
348
|
+
let content = children;
|
|
349
|
+
if (needsRepropagation) {
|
|
350
|
+
const parentContexts = useParentContexts(context.popoverScope);
|
|
351
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepropagateParentContexts, {
|
|
352
|
+
...parentContexts,
|
|
353
|
+
children: content
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_portal.Portal, {
|
|
357
|
+
passThrough,
|
|
358
|
+
stackZIndex: true,
|
|
359
|
+
zIndex,
|
|
360
|
+
hidden: !visuallyActive,
|
|
361
|
+
children: [!!open && !context.breakpointActive && !context.hoverable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
362
|
+
position: "absolute",
|
|
363
|
+
inset: 0,
|
|
364
|
+
onPress: (0, import_helpers.composeEventHandlers)(onPress, context.onOpenToggle)
|
|
365
|
+
}), content]
|
|
366
|
+
});
|
|
427
367
|
}
|
|
428
|
-
const PopoverContentImpl =
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
onFocusOutside,
|
|
487
|
-
onInteractOutside,
|
|
488
|
-
onDismiss: handleDismiss,
|
|
489
|
-
children: contents
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate.Animate, {
|
|
493
|
-
type: "presence",
|
|
494
|
-
present: Boolean(open),
|
|
495
|
-
keepChildrenMounted: Boolean(keepChildrenMounted),
|
|
496
|
-
onExitComplete: handleExitComplete,
|
|
497
|
-
lazyMount,
|
|
498
|
-
passThrough: context.breakpointActive,
|
|
499
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperContent, {
|
|
500
|
-
scope,
|
|
501
|
-
"data-state": getState(open),
|
|
502
|
-
id: context.contentId,
|
|
503
|
-
ref: forwardedRef,
|
|
504
|
-
passThrough: context.breakpointActive,
|
|
505
|
-
...(!contentProps.unstyled && {
|
|
506
|
-
size: "$true",
|
|
507
|
-
backgroundColor: "$background",
|
|
508
|
-
alignItems: "center"
|
|
509
|
-
}),
|
|
510
|
-
...contentProps,
|
|
511
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PortalAdaptSafe, {
|
|
512
|
-
context,
|
|
513
|
-
children: contents
|
|
514
|
-
})
|
|
515
|
-
}, context.contentId)
|
|
516
|
-
});
|
|
368
|
+
const PopoverContentImpl = (0, import_core.createRefComponent)(function PopoverContentImpl2(props, forwardedRef) {
|
|
369
|
+
const { trapFocus, scope, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, disableFocusScope, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, children, enableRemoveScroll, freezeContentsWhenHidden, setIsFullyHidden, lazyMount, forceUnmount, forceMount, context, open, alwaysDisable, ...contentProps } = props;
|
|
370
|
+
const { disableDismissable } = context;
|
|
371
|
+
const keepChildrenMounted = context.keepChildrenMounted || forceMount;
|
|
372
|
+
const handleExitComplete = React.useCallback(() => {
|
|
373
|
+
setIsFullyHidden?.(true);
|
|
374
|
+
}, [setIsFullyHidden]);
|
|
375
|
+
let contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.ResetPresence, {
|
|
376
|
+
disable: context.breakpointActive,
|
|
377
|
+
children
|
|
378
|
+
});
|
|
379
|
+
const handleDismiss = React.useCallback(() => {
|
|
380
|
+
context.onOpenChange(false, "press");
|
|
381
|
+
}, [context]);
|
|
382
|
+
if (!context.breakpointActive) {
|
|
383
|
+
if (!alwaysDisable || !alwaysDisable.focus) contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_focus_scope.FocusScope, {
|
|
384
|
+
loop: trapFocus !== false,
|
|
385
|
+
enabled: context.breakpointActive ? false : disableFocusScope ? false : open,
|
|
386
|
+
trapped: context.breakpointActive ? false : trapFocus,
|
|
387
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
388
|
+
onUnmountAutoFocus: onCloseAutoFocus === false ? void 0 : onCloseAutoFocus,
|
|
389
|
+
children: contents
|
|
390
|
+
});
|
|
391
|
+
if (!alwaysDisable || !alwaysDisable["remove-scroll"]) contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_remove_scroll.RemoveScroll, {
|
|
392
|
+
enabled: context.breakpointActive ? false : enableRemoveScroll ? open : false,
|
|
393
|
+
children: contents
|
|
394
|
+
});
|
|
395
|
+
if (!alwaysDisable || !alwaysDisable.dismiss) contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dismissable.Dismissable, {
|
|
396
|
+
branches: context.branches,
|
|
397
|
+
forceUnmount: disableDismissable || (forceUnmount ?? !open),
|
|
398
|
+
onEscapeKeyDown,
|
|
399
|
+
onPointerDownOutside,
|
|
400
|
+
onFocusOutside,
|
|
401
|
+
onInteractOutside,
|
|
402
|
+
onDismiss: handleDismiss,
|
|
403
|
+
children: contents
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate.Animate, {
|
|
407
|
+
type: "presence",
|
|
408
|
+
present: Boolean(open),
|
|
409
|
+
keepChildrenMounted: Boolean(keepChildrenMounted),
|
|
410
|
+
onExitComplete: handleExitComplete,
|
|
411
|
+
lazyMount,
|
|
412
|
+
passThrough: context.breakpointActive,
|
|
413
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperContent, {
|
|
414
|
+
scope,
|
|
415
|
+
"data-state": getState(open),
|
|
416
|
+
id: context.contentId,
|
|
417
|
+
ref: forwardedRef,
|
|
418
|
+
passThrough: context.breakpointActive,
|
|
419
|
+
...contentProps,
|
|
420
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalAdaptSafe, {
|
|
421
|
+
context,
|
|
422
|
+
children: contents
|
|
423
|
+
})
|
|
424
|
+
}, context.contentId)
|
|
425
|
+
});
|
|
517
426
|
});
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
528
|
-
...rest,
|
|
529
|
-
ref: forwardedRef,
|
|
530
|
-
componentName: "PopoverClose",
|
|
531
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, () => context?.onOpenChange?.(false, "press"))
|
|
532
|
-
});
|
|
427
|
+
const PopoverClose = (0, import_core.createRefComponent)(function PopoverClose2(props, forwardedRef) {
|
|
428
|
+
const { scope, className, ...rest } = props;
|
|
429
|
+
const context = usePopoverContext(scope);
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
431
|
+
...rest,
|
|
432
|
+
ref: forwardedRef,
|
|
433
|
+
className: `is_PopoverClose ${className || ""}`.trim(),
|
|
434
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, () => context?.onOpenChange?.(false, "press"))
|
|
435
|
+
});
|
|
533
436
|
});
|
|
534
|
-
const PopoverArrow = import_popper.PopperArrowFrame
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
...rest,
|
|
545
|
-
ref: forwardedRef
|
|
546
|
-
});
|
|
437
|
+
const PopoverArrow = (0, import_core.createStyledHOC)(import_popper.PopperArrowFrame, function PopoverArrow2(props, forwardedRef) {
|
|
438
|
+
const { scope, className, ...rest } = props;
|
|
439
|
+
const context = usePopoverContext(scope);
|
|
440
|
+
if ((0, import_adapt.useAdaptIsActive)(context.adaptScope)) return null;
|
|
441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperArrow, {
|
|
442
|
+
scope,
|
|
443
|
+
className: `is_PopoverArrow ${className || ""}`.trim(),
|
|
444
|
+
...rest,
|
|
445
|
+
ref: forwardedRef
|
|
446
|
+
});
|
|
547
447
|
});
|
|
548
|
-
const PopoverScrollView =
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
passThrough: context.breakpointActive,
|
|
558
|
-
...props
|
|
559
|
-
});
|
|
448
|
+
const PopoverScrollView = (0, import_core.createRefComponent)(({ scope, ...props }, ref) => {
|
|
449
|
+
const context = usePopoverContext(scope);
|
|
450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_scroll_view.ScrollView, {
|
|
451
|
+
ref,
|
|
452
|
+
pointerEvents: context.breakpointActive ? "none" : void 0,
|
|
453
|
+
scrollEnabled: !context.breakpointActive,
|
|
454
|
+
passThrough: context.breakpointActive,
|
|
455
|
+
...props
|
|
456
|
+
});
|
|
560
457
|
});
|
|
561
458
|
const DEFAULT_SCOPE = "";
|
|
562
|
-
const Popover = (0, import_helpers.withStaticProperties)(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
459
|
+
const Popover = (0, import_helpers.withStaticProperties)((0, import_core.createRefComponent)(function Popover2({ scope = DEFAULT_SCOPE, ...props }, ref) {
|
|
460
|
+
const id = React.useId();
|
|
461
|
+
const adaptScope = `PopoverAdapt${scope}`;
|
|
462
|
+
const { open: openProp, defaultOpen, onOpenChange } = props;
|
|
463
|
+
const viaRef = React.useRef(void 0);
|
|
464
|
+
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
465
|
+
prop: openProp,
|
|
466
|
+
defaultProp: defaultOpen || false,
|
|
467
|
+
onChange: (val) => {
|
|
468
|
+
onOpenChange?.(val, viaRef.current);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
const handleOpenChange = (0, import_core.useEvent)((val, via) => {
|
|
472
|
+
viaRef.current = via;
|
|
473
|
+
setOpen(val);
|
|
474
|
+
});
|
|
475
|
+
React.useEffect(() => {
|
|
476
|
+
if (!open) return;
|
|
477
|
+
openPopovers.add(setOpen);
|
|
478
|
+
return () => {
|
|
479
|
+
openPopovers.delete(setOpen);
|
|
480
|
+
};
|
|
481
|
+
}, [open, setOpen]);
|
|
482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
483
|
+
scope: adaptScope,
|
|
484
|
+
open,
|
|
485
|
+
onOpenChange: setOpen,
|
|
486
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverInner, {
|
|
487
|
+
adaptScope,
|
|
488
|
+
ref,
|
|
489
|
+
id,
|
|
490
|
+
scope,
|
|
491
|
+
open,
|
|
492
|
+
setOpen,
|
|
493
|
+
handleOpenChange,
|
|
494
|
+
...props
|
|
495
|
+
})
|
|
496
|
+
});
|
|
579
497
|
}), {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
498
|
+
Anchor: PopoverAnchor,
|
|
499
|
+
Arrow: PopoverArrow,
|
|
500
|
+
Trigger: PopoverTrigger,
|
|
501
|
+
Content: PopoverContent,
|
|
502
|
+
Close: PopoverClose,
|
|
503
|
+
Adapt: import_adapt.Adapt,
|
|
504
|
+
ScrollView: PopoverScrollView,
|
|
505
|
+
FocusScope: import_focus_scope.FocusScopeController
|
|
588
506
|
});
|
|
589
|
-
const PopoverInner =
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
passThrough: isAdapted,
|
|
658
|
-
scope,
|
|
659
|
-
stayInFrame: true,
|
|
660
|
-
...restProps,
|
|
661
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContextProvider, {
|
|
662
|
-
scope,
|
|
663
|
-
open,
|
|
664
|
-
onOpenChange: handleOpenChange,
|
|
665
|
-
onOpenToggle,
|
|
666
|
-
triggerRef,
|
|
667
|
-
id,
|
|
668
|
-
contentId,
|
|
669
|
-
hasCustomAnchor,
|
|
670
|
-
onCustomAnchorAdd,
|
|
671
|
-
onCustomAnchorRemove,
|
|
672
|
-
anchorTo,
|
|
673
|
-
adaptScope,
|
|
674
|
-
breakpointActive: isAdapted,
|
|
675
|
-
keepChildrenMounted,
|
|
676
|
-
disableDismissable,
|
|
677
|
-
hoverable,
|
|
678
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverSheetController, {
|
|
679
|
-
onOpenChange: setOpen,
|
|
680
|
-
open,
|
|
681
|
-
scope,
|
|
682
|
-
children
|
|
683
|
-
})
|
|
684
|
-
})
|
|
685
|
-
});
|
|
686
|
-
let result = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
687
|
-
children: import_constants.isWeb ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, {
|
|
688
|
-
value: floatingContext,
|
|
689
|
-
children: contents
|
|
690
|
-
}) : contents
|
|
691
|
-
});
|
|
692
|
-
if (zIndex !== void 0) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverZIndexContext.Provider, {
|
|
693
|
-
value: zIndex,
|
|
694
|
-
children: result
|
|
695
|
-
});
|
|
696
|
-
return result;
|
|
507
|
+
const PopoverInner = (0, import_core.createRefComponent)(function PopoverInner2(props, forwardedRef) {
|
|
508
|
+
const { children, open: _openProp, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, scope = DEFAULT_SCOPE, keepChildrenMounted: keepChildrenMountedProp, hoverable, disableFocus, disableDismissable, zIndex, id, adaptScope, open, setOpen, handleOpenChange, ...restProps } = props;
|
|
509
|
+
const triggerRef = React.useRef(null);
|
|
510
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
511
|
+
const [keepChildrenMounted] = (0, import_use_controllable_state.useControllableState)({
|
|
512
|
+
prop: keepChildrenMountedProp,
|
|
513
|
+
defaultProp: false,
|
|
514
|
+
transition: keepChildrenMountedProp === "lazy"
|
|
515
|
+
});
|
|
516
|
+
const isAdapted = (0, import_adapt.useAdaptIsActive)(adaptScope);
|
|
517
|
+
const floatingContext = (0, import_useFloatingContext.useFloatingContext)({
|
|
518
|
+
open,
|
|
519
|
+
setOpen: handleOpenChange,
|
|
520
|
+
disable: isAdapted,
|
|
521
|
+
hoverable,
|
|
522
|
+
disableFocus
|
|
523
|
+
});
|
|
524
|
+
const [anchorTo, setAnchorToRaw] = React.useState();
|
|
525
|
+
const setAnchorTo = (0, import_core.useCreateShallowSetState)(setAnchorToRaw);
|
|
526
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
527
|
+
anchorTo: setAnchorTo,
|
|
528
|
+
toggle: () => setOpen((prev) => !prev),
|
|
529
|
+
open: () => setOpen(true),
|
|
530
|
+
close: () => setOpen(false),
|
|
531
|
+
setOpen
|
|
532
|
+
}));
|
|
533
|
+
const contentId = React.useId();
|
|
534
|
+
const onOpenToggle = (0, import_core.useEvent)(() => {
|
|
535
|
+
if (open && isAdapted) return;
|
|
536
|
+
setOpen(!open);
|
|
537
|
+
});
|
|
538
|
+
const onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(true), []);
|
|
539
|
+
const onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(false), []);
|
|
540
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.Popper, {
|
|
541
|
+
open,
|
|
542
|
+
passThrough: isAdapted,
|
|
543
|
+
scope,
|
|
544
|
+
stayInFrame: true,
|
|
545
|
+
...restProps,
|
|
546
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContextProvider, {
|
|
547
|
+
scope,
|
|
548
|
+
open,
|
|
549
|
+
onOpenChange: handleOpenChange,
|
|
550
|
+
onOpenToggle,
|
|
551
|
+
triggerRef,
|
|
552
|
+
id,
|
|
553
|
+
contentId,
|
|
554
|
+
hasCustomAnchor,
|
|
555
|
+
onCustomAnchorAdd,
|
|
556
|
+
onCustomAnchorRemove,
|
|
557
|
+
anchorTo,
|
|
558
|
+
adaptScope,
|
|
559
|
+
breakpointActive: isAdapted,
|
|
560
|
+
keepChildrenMounted,
|
|
561
|
+
disableDismissable,
|
|
562
|
+
hoverable,
|
|
563
|
+
children
|
|
564
|
+
})
|
|
565
|
+
});
|
|
566
|
+
let result = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: import_constants.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, {
|
|
567
|
+
value: floatingContext,
|
|
568
|
+
children: contents
|
|
569
|
+
}) : contents });
|
|
570
|
+
if (zIndex !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverZIndexContext.Provider, {
|
|
571
|
+
value: zIndex,
|
|
572
|
+
children: result
|
|
573
|
+
});
|
|
574
|
+
return result;
|
|
697
575
|
});
|
|
698
576
|
function getState(open) {
|
|
699
|
-
|
|
577
|
+
return open ? "open" : "closed";
|
|
700
578
|
}
|
|
701
|
-
const PopoverSheetController = ({
|
|
702
|
-
open,
|
|
703
|
-
scope,
|
|
704
|
-
...props
|
|
705
|
-
}) => {
|
|
706
|
-
const context = usePopoverContext(scope);
|
|
707
|
-
const showSheet = useShowPopoverSheet(context, open);
|
|
708
|
-
const breakpointActive = context?.breakpointActive;
|
|
709
|
-
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
710
|
-
const [isAdaptFullyHidden, setIsAdaptFullyHidden] = React.useState(!open);
|
|
711
|
-
if (open && isAdaptFullyHidden) setIsAdaptFullyHidden(false);
|
|
712
|
-
const handleSheetAnimationComplete = React.useCallback(({
|
|
713
|
-
open: isOpen
|
|
714
|
-
}) => {
|
|
715
|
-
if (!isOpen) setIsAdaptFullyHidden(true);
|
|
716
|
-
}, []);
|
|
717
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_controller.SheetController, {
|
|
718
|
-
onOpenChange: val => {
|
|
719
|
-
if (getShowSheet()) props.onOpenChange?.(val);
|
|
720
|
-
},
|
|
721
|
-
onAnimationComplete: handleSheetAnimationComplete,
|
|
722
|
-
open,
|
|
723
|
-
hidden: !breakpointActive,
|
|
724
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverAdaptHiddenContext.Provider, {
|
|
725
|
-
value: isAdaptFullyHidden,
|
|
726
|
-
children: props.children
|
|
727
|
-
})
|
|
728
|
-
});
|
|
729
|
-
};
|
|
730
|
-
const useShowPopoverSheet = (context, open) => {
|
|
731
|
-
const isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
732
|
-
return open === false ? false : isAdapted;
|
|
733
|
-
};
|