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