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